Merge
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 08fd371..75fcb5f 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -361,3 +361,4 @@
 6743a8e0cab7b5f6f4a0575f6664892f0ab740af jdk-9+116
 e882bcdbdac436523f3d5681611d3118a3804ea7 jdk-9+117
 047f95de8f918d8ff5e8cd2636a2abb5c3c8adb8 jdk-9+118
+3463a3f14f0f0e8a68f29ac6405454f2fa2f598a jdk-9+119
diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4
index f295a46..6a64c47 100644
--- a/common/autoconf/basics.m4
+++ b/common/autoconf/basics.m4
@@ -484,6 +484,8 @@
   BASIC_REQUIRE_PROGS(FILE, file)
   BASIC_REQUIRE_PROGS(FIND, find)
   BASIC_REQUIRE_PROGS(HEAD, head)
+  BASIC_REQUIRE_PROGS(GUNZIP, gunzip)
+  BASIC_REQUIRE_PROGS(GZIP, pigz gzip)
   BASIC_REQUIRE_PROGS(LN, ln)
   BASIC_REQUIRE_PROGS(LS, ls)
   BASIC_REQUIRE_PROGS(MKDIR, mkdir)
@@ -496,7 +498,7 @@
   BASIC_REQUIRE_PROGS(SH, sh)
   BASIC_REQUIRE_PROGS(SORT, sort)
   BASIC_REQUIRE_PROGS(TAIL, tail)
-  BASIC_REQUIRE_PROGS(TAR, tar)
+  BASIC_REQUIRE_PROGS(TAR, gtar tar)
   BASIC_REQUIRE_PROGS(TEE, tee)
   BASIC_REQUIRE_PROGS(TOUCH, touch)
   BASIC_REQUIRE_PROGS(TR, tr)
@@ -839,8 +841,6 @@
 
   # The spec.gmk file contains all variables for the make system.
   AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
-  # The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
-  AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in])
   # The bootcycle-spec.gmk file contains support for boot cycle builds.
   AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
   # The buildjdk-spec.gmk file contains support for building a buildjdk when cross compiling.
@@ -1009,11 +1009,36 @@
   AC_SUBST(FIND_DELETE)
 ])
 
+AC_DEFUN([BASIC_CHECK_TAR],
+[
+  # Test which kind of tar was found
+  if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
+    TAR_TYPE="gnu"
+  elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
+    TAR_TYPE="bsd"
+  elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
+    TAR_TYPE="solaris"
+  fi
+  AC_MSG_CHECKING([what type of tar was found])
+  AC_MSG_RESULT([$TAR_TYPE])
+
+  if test "x$TAR_TYPE" = "xgnu"; then
+    TAR_INCLUDE_PARAM="T"
+    TAR_SUPPORTS_TRANSFORM="true"
+  else
+    TAR_INCLUDE_PARAM="I"
+    TAR_SUPPORTS_TRANSFORM="false"
+  fi
+  AC_SUBST(TAR_INCLUDE_PARAM)
+  AC_SUBST(TAR_SUPPORTS_TRANSFORM)
+])
+
 AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
 [
   BASIC_CHECK_GNU_MAKE
 
   BASIC_CHECK_FIND_DELETE
+  BASIC_CHECK_TAR
 
   # These tools might not be installed by default,
   # need hint on how to install them.
diff --git a/common/autoconf/buildjdk-spec.gmk.in b/common/autoconf/buildjdk-spec.gmk.in
index 818f21e..c4b7d90 100644
--- a/common/autoconf/buildjdk-spec.gmk.in
+++ b/common/autoconf/buildjdk-spec.gmk.in
@@ -134,8 +134,9 @@
 endif
 
 HOTSPOT_MAKE_ARGS := product docs export_product
-# Control wether Hotspot runs Queens test after building
-TEST_IN_BUILD := false
+
+# Control wether Hotspot builds gtest tests
+BUILD_GTEST := false
 
 USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@
 
diff --git a/common/autoconf/compare.sh.in b/common/autoconf/compare.sh.in
index 67a69ff..f7e2003 100644
--- a/common/autoconf/compare.sh.in
+++ b/common/autoconf/compare.sh.in
@@ -48,6 +48,7 @@
 export FILE="@FILE@"
 export FIND="@FIND@"
 export GREP="@GREP@"
+export GUNZIP="@GUNZIP@"
 export LDD="@LDD@"
 export LN="@LN@"
 export MKDIR="@MKDIR@"
@@ -63,10 +64,11 @@
 export SORT="@SORT@"
 export STAT="@STAT@"
 export STRIP="@STRIP@ @STRIPFLAGS@"
+export TAR="@TAR@"
 export TEE="@TEE@"
 export UNIQ="@UNIQ@"
 export UNPACK200="@FIXPATH@ @BOOT_JDK@/bin/unpack200"
-export UNARCHIVE="@UNZIP@ -q"
+export UNARCHIVE="@UNZIP@ -q -o"
 
 export SRC_ROOT="@TOPDIR@"
 export OUTPUT_ROOT="@OUTPUT_ROOT@"
diff --git a/common/autoconf/configure.ac b/common/autoconf/configure.ac
index 291851f..0079a94 100644
--- a/common/autoconf/configure.ac
+++ b/common/autoconf/configure.ac
@@ -207,6 +207,7 @@
 # Need toolchain to setup dtrace
 HOTSPOT_SETUP_DTRACE
 HOTSPOT_SETUP_JVM_FEATURES
+HOTSPOT_ENABLE_DISABLE_GTEST
 
 ###############################################################################
 #
@@ -226,7 +227,6 @@
 #
 ###############################################################################
 
-HOTSPOT_SETUP_LEGACY_BUILD
 JDKOPT_DETECT_INTREE_EC
 JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
 
diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
index f40198f..ef4a267 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -652,21 +652,7 @@
 NUM_CORES
 BUILD_FAILURE_HANDLER
 ENABLE_INTREE_EC
-JVM_VARIANT_CORE
-JVM_VARIANT_ZEROSHARK
-JVM_VARIANT_ZERO
-JVM_VARIANT_HOTSPOT
-JVM_VARIANT_MINIMAL1
-JVM_VARIANT_CLIENT
-JVM_VARIANT_SERVER
-JVM_VARIANTS_COMMA
-TEST_IN_BUILD
-HOTSPOT_MAKE_ARGS
-MACOSX_UNIVERSAL
-DEBUG_CLASSFILES
-FASTDEBUG
-VARIANT
-USE_NEW_HOTSPOT_BUILD
+STLPORT_LIB
 LIBZIP_CAN_USE_MMAP
 LIBDL
 LIBM
@@ -702,6 +688,7 @@
 STATIC_CXX_SETTING
 FIXPATH_DETACH_FLAG
 FIXPATH
+BUILD_GTEST
 VALID_JVM_FEATURES
 JVM_FEATURES_custom
 JVM_FEATURES_zeroshark
@@ -963,6 +950,8 @@
 LDD
 ZIP
 UNZIP
+TAR_SUPPORTS_TRANSFORM
+TAR_INCLUDE_PARAM
 FIND_DELETE
 OUTPUT_SYNC
 OUTPUT_SYNC_SUPPORTED
@@ -995,6 +984,9 @@
 HOTSPOT_BUILD_CPU
 HOTSPOT_BUILD_OS_TYPE
 HOTSPOT_BUILD_OS
+OPENJDK_BUILD_BUNDLE_PLATFORM
+OPENJDK_BUILD_CPU_BUNDLE
+OPENJDK_BUILD_OS_BUNDLE
 OPENJDK_BUILD_OS_EXPORT_DIR
 OPENJDK_BUILD_CPU_JLI_CFLAGS
 OPENJDK_BUILD_CPU_OSARCH
@@ -1009,6 +1001,9 @@
 HOTSPOT_TARGET_OS
 DEFINE_CROSS_COMPILE_ARCH
 LP64
+OPENJDK_TARGET_BUNDLE_PLATFORM
+OPENJDK_TARGET_CPU_BUNDLE
+OPENJDK_TARGET_OS_BUNDLE
 OPENJDK_TARGET_OS_EXPORT_DIR
 OPENJDK_TARGET_CPU_JLI_CFLAGS
 OPENJDK_TARGET_CPU_OSARCH
@@ -1078,6 +1073,8 @@
 MKDIR
 LS
 LN
+GZIP
+GUNZIP
 HEAD
 FIND
 FILE
@@ -1202,6 +1199,7 @@
 enable_dtrace
 with_jvm_features
 with_jvm_interpreter
+enable_hotspot_gtest
 with_stdc__lib
 with_msvcr_dll
 with_msvcp_dll
@@ -1227,8 +1225,6 @@
 with_dxsdk
 with_dxsdk_lib
 with_dxsdk_include
-enable_new_hotspot_build
-enable_hotspot_test_in_build
 enable_jtreg_failure_handler
 with_num_cores
 with_memory_size
@@ -1262,6 +1258,8 @@
 FILE
 FIND
 HEAD
+GUNZIP
+GZIP
 LN
 LS
 MKDIR
@@ -1996,15 +1994,11 @@
   --enable-dtrace[=yes/no/auto]
                           enable dtrace. Default is auto, where dtrace is
                           enabled if all dependencies are present.
+  --disable-hotspot-gtest Disables building of the Hotspot unit tests
   --disable-freetype-bundling
                           disable bundling of the freetype library with the
                           build result [enabled on Windows or when using
                           --with-freetype, disabled otherwise]
-  --disable-new-hotspot-build
-                          disable the new hotspot build system (use the old)
-                          [enabled]
-  --enable-hotspot-test-in-build
-                          run the Queens test after Hotspot build [disabled]
   --enable-jtreg-failure-handler
                           forces build of the jtreg failure handler to be
                           enabled, missing dependencies become fatal errors.
@@ -2205,6 +2199,8 @@
   FILE        Override default value for FILE
   FIND        Override default value for FIND
   HEAD        Override default value for HEAD
+  GUNZIP      Override default value for GUNZIP
+  GZIP        Override default value for GZIP
   LN          Override default value for LN
   LS          Override default value for LS
   MKDIR       Override default value for MKDIR
@@ -3707,6 +3703,8 @@
 
 
 
+
+
 # Check if build directory is on local disk. If not possible to determine,
 # we prefer to claim it's local.
 # Argument 1: directory to test
@@ -4303,9 +4301,8 @@
 #
 
 
-###############################################################################
-# Support for old hotspot build. Remove once new hotspot build has proven
-# to work satisfactory.
+################################################################################
+# Check if gtest should be built
 #
 
 
@@ -4732,6 +4729,13 @@
 ################################################################################
 
 
+################################################################################
+# libstlport.so.1 is needed for running gtest on Solaris. Find it to
+# redistribute it in the test image.
+################################################################################
+
+
+
 #
 # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -5076,7 +5080,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1462970869
+DATE_WHEN_GENERATED=1463732692
 
 ###############################################################################
 #
@@ -8404,6 +8408,414 @@
   # Publish this variable in the help.
 
 
+  if [ -z "${GUNZIP+x}" ]; then
+    # The variable is not set by user, try to locate tool using the code snippet
+    for ac_prog in gunzip
+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_GUNZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GUNZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GUNZIP="$GUNZIP" # 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_GUNZIP="$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
+GUNZIP=$ac_cv_path_GUNZIP
+if test -n "$GUNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5
+$as_echo "$GUNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GUNZIP" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !GUNZIP! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!GUNZIP!/}
+    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 "xGUNZIP" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of GUNZIP from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of GUNZIP from the environment. Use command line variables instead." >&2;}
+      fi
+      # Try to locate tool using the code snippet
+      for ac_prog in gunzip
+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_GUNZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GUNZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GUNZIP="$GUNZIP" # 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_GUNZIP="$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
+GUNZIP=$ac_cv_path_GUNZIP
+if test -n "$GUNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5
+$as_echo "$GUNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GUNZIP" && 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 we try to supply an empty value
+      if test "x$GUNZIP" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool GUNZIP= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool GUNZIP= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GUNZIP" >&5
+$as_echo_n "checking for GUNZIP... " >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+      else
+        # Check if the provided tool contains a complete path.
+        tool_specified="$GUNZIP"
+        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 GUNZIP=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool GUNZIP=$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_GUNZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GUNZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GUNZIP="$GUNZIP" # 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_GUNZIP="$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
+GUNZIP=$ac_cv_path_GUNZIP
+if test -n "$GUNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5
+$as_echo "$GUNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$GUNZIP" = 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 GUNZIP=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool GUNZIP=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GUNZIP" >&5
+$as_echo_n "checking for GUNZIP... " >&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 GUNZIP=$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
+
+  fi
+
+
+
+  if test "x$GUNZIP" = x; then
+    as_fn_error $? "Could not find required tool for GUNZIP" "$LINENO" 5
+  fi
+
+
+
+
+
+  # Publish this variable in the help.
+
+
+  if [ -z "${GZIP+x}" ]; then
+    # The variable is not set by user, try to locate tool using the code snippet
+    for ac_prog in pigz gzip
+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_GZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GZIP="$GZIP" # 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_GZIP="$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
+GZIP=$ac_cv_path_GZIP
+if test -n "$GZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
+$as_echo "$GZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GZIP" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !GZIP! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!GZIP!/}
+    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 "xGZIP" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of GZIP from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of GZIP from the environment. Use command line variables instead." >&2;}
+      fi
+      # Try to locate tool using the code snippet
+      for ac_prog in pigz gzip
+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_GZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GZIP="$GZIP" # 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_GZIP="$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
+GZIP=$ac_cv_path_GZIP
+if test -n "$GZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
+$as_echo "$GZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GZIP" && 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 we try to supply an empty value
+      if test "x$GZIP" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool GZIP= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool GZIP= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GZIP" >&5
+$as_echo_n "checking for GZIP... " >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+      else
+        # Check if the provided tool contains a complete path.
+        tool_specified="$GZIP"
+        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 GZIP=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool GZIP=$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_GZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GZIP="$GZIP" # 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_GZIP="$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
+GZIP=$ac_cv_path_GZIP
+if test -n "$GZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
+$as_echo "$GZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$GZIP" = 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 GZIP=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool GZIP=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GZIP" >&5
+$as_echo_n "checking for GZIP... " >&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 GZIP=$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
+
+  fi
+
+
+
+  if test "x$GZIP" = x; then
+    as_fn_error $? "Could not find required tool for GZIP" "$LINENO" 5
+  fi
+
+
+
+
+
+  # Publish this variable in the help.
+
+
   if [ -z "${LN+x}" ]; then
     # The variable is not set by user, try to locate tool using the code snippet
     for ac_prog in ln
@@ -10854,7 +11266,7 @@
 
   if [ -z "${TAR+x}" ]; then
     # The variable is not set by user, try to locate tool using the code snippet
-    for ac_prog in tar
+    for ac_prog in gtar tar
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -10912,7 +11324,7 @@
 $as_echo "$as_me: WARNING: Ignoring value of TAR from the environment. Use command line variables instead." >&2;}
       fi
       # Try to locate tool using the code snippet
-      for ac_prog in tar
+      for ac_prog in gtar tar
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -15428,6 +15840,23 @@
   fi
 
 
+  # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
+  # Macosx is osx and x86_64 is x64
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    OPENJDK_TARGET_OS_BUNDLE="osx"
+  else
+    OPENJDK_TARGET_OS_BUNDLE="$OPENJDK_TARGET_OS"
+  fi
+  if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+    OPENJDK_TARGET_CPU_BUNDLE="x64"
+  else
+    OPENJDK_TARGET_CPU_BUNDLE="$OPENJDK_TARGET_CPU"
+  fi
+  OPENJDK_TARGET_BUNDLE_PLATFORM="${OPENJDK_TARGET_OS_BUNDLE}-${OPENJDK_TARGET_CPU_BUNDLE}"
+
+
+
+
   if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
     A_LP64="LP64:="
     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
@@ -15584,6 +16013,23 @@
   fi
 
 
+  # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
+  # Macosx is osx and x86_64 is x64
+  if test "x$OPENJDK_BUILD_OS" = xmacosx; then
+    OPENJDK_BUILD_OS_BUNDLE="osx"
+  else
+    OPENJDK_BUILD_OS_BUNDLE="$OPENJDK_TARGET_OS"
+  fi
+  if test "x$OPENJDK_BUILD_CPU" = xx86_64; then
+    OPENJDK_BUILD_CPU_BUNDLE="x64"
+  else
+    OPENJDK_BUILD_CPU_BUNDLE="$OPENJDK_BUILD_CPU"
+  fi
+  OPENJDK_BUILD_BUNDLE_PLATFORM="${OPENJDK_BUILD_OS_BUNDLE}-${OPENJDK_BUILD_CPU_BUNDLE}"
+
+
+
+
   if test "x$OPENJDK_BUILD_CPU_BITS" = x64; then
     A_LP64="LP64:="
     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
@@ -16297,7 +16743,10 @@
   # Check that the selected variants are valid
 
   # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
-  INVALID_VARIANTS=`$GREP -Fvx "${VALID_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  # Notice that the original variant failes on SLES 10 and 11
+  NEEDLE=${VALID_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if test "x$INVALID_VARIANTS" != x; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: Unknown variant(s) specified: $INVALID_VARIANTS" >&5
 $as_echo "$as_me: Unknown variant(s) specified: $INVALID_VARIANTS" >&6;}
@@ -16306,7 +16755,9 @@
 
   # All "special" variants share the same output directory ("server")
   VALID_MULTIPLE_JVM_VARIANTS="server client minimal"
-  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if  test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then
     as_fn_error $? "You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS." "$LINENO" 5
   fi
@@ -17016,9 +17467,6 @@
   # The spec.gmk file contains all variables for the make system.
   ac_config_files="$ac_config_files $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in"
 
-  # The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
-  ac_config_files="$ac_config_files $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in"
-
   # The bootcycle-spec.gmk file contains support for boot cycle builds.
   ac_config_files="$ac_config_files $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in"
 
@@ -20699,6 +21147,30 @@
 
 
 
+  # Test which kind of tar was found
+  if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
+    TAR_TYPE="gnu"
+  elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
+    TAR_TYPE="bsd"
+  elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
+    TAR_TYPE="solaris"
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking what type of tar was found" >&5
+$as_echo_n "checking what type of tar was found... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR_TYPE" >&5
+$as_echo "$TAR_TYPE" >&6; }
+
+  if test "x$TAR_TYPE" = "xgnu"; then
+    TAR_INCLUDE_PARAM="T"
+    TAR_SUPPORTS_TRANSFORM="true"
+  else
+    TAR_INCLUDE_PARAM="I"
+    TAR_SUPPORTS_TRANSFORM="false"
+  fi
+
+
+
+
   # These tools might not be installed by default,
   # need hint on how to install them.
 
@@ -23790,9 +24262,6 @@
   if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
-  if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
-    INCLUDE_SA=false
-  fi
 
 
   # Compress jars
@@ -52948,6 +53417,49 @@
 
 
 
+  # Check whether --enable-hotspot-gtest was given.
+if test "${enable_hotspot_gtest+set}" = set; then :
+  enableval=$enable_hotspot_gtest;
+fi
+
+
+  if test -e "$HOTSPOT_TOPDIR/test/native"; then
+    GTEST_DIR_EXISTS="true"
+  else
+    GTEST_DIR_EXISTS="false"
+  fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Hotspot gtest unit tests should be built" >&5
+$as_echo_n "checking if Hotspot gtest unit tests should be built... " >&6; }
+  if test "x$enable_hotspot_gtest" = "xyes"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5
+$as_echo "yes, forced" >&6; }
+      BUILD_GTEST="true"
+    else
+      as_fn_error $? "Cannot build gtest without the test source" "$LINENO" 5
+    fi
+  elif test "x$enable_hotspot_gtest" = "xno"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5
+$as_echo "no, forced" >&6; }
+    BUILD_GTEST="false"
+  elif test "x$enable_hotspot_gtest" = "x"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      BUILD_GTEST="true"
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      BUILD_GTEST="false"
+    fi
+  else
+    as_fn_error $? "--enable-gtest must be either yes or no" "$LINENO" 5
+  fi
+
+
+
+
 ###############################################################################
 #
 # Check dependencies for external and internal libraries.
@@ -64076,6 +64588,157 @@
 
 
 
+  if test "$OPENJDK_TARGET_OS" = "solaris"; then
+    # Find the root of the Solaris Studio installation from the compiler path
+    SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
+    STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libstlport.so.1" >&5
+$as_echo_n "checking for libstlport.so.1... " >&6; }
+    if test -f "$STLPORT_LIB"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, $STLPORT_LIB" >&5
+$as_echo "yes, $STLPORT_LIB" >&6; }
+
+  # Only process if variable expands to non-empty
+
+  if test "x$STLPORT_LIB" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$STLPORT_LIB"
+  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 STLPORT_LIB, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of STLPORT_LIB" "$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-style (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
+    STLPORT_LIB="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STLPORT_LIB to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting STLPORT_LIB to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$STLPORT_LIB"
+  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
+    STLPORT_LIB="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STLPORT_LIB to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting STLPORT_LIB 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="$STLPORT_LIB"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of STLPORT_LIB, 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 STLPORT_LIB, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        STLPORT_LIB="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        STLPORT_LIB="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, not found at $STLPORT_LIB" >&5
+$as_echo "no, not found at $STLPORT_LIB" >&6; }
+      as_fn_error $? "Failed to find libstlport.so.1, cannot build Hotspot gtests" "$LINENO" 5
+    fi
+
+  fi
+
+
+
 
 
 
@@ -64094,144 +64757,6 @@
 ###############################################################################
 
 
-  # Check whether --enable-new-hotspot-build was given.
-if test "${enable_new_hotspot_build+set}" = set; then :
-  enableval=$enable_new_hotspot_build;
-fi
-
-
-   if test "x$enable_new_hotspot_build" = "x" || test "x$enable_new_hotspot_build" = "xyes"; then
-     USE_NEW_HOTSPOT_BUILD=true
-   else
-     USE_NEW_HOTSPOT_BUILD=false
-   fi
-
-
-  case $HOTSPOT_DEBUG_LEVEL in
-    product )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-    fastdebug )
-      VARIANT="DBG"
-      FASTDEBUG="true"
-      DEBUG_CLASSFILES="true"
-      ;;
-    debug )
-      VARIANT="DBG"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="true"
-      ;;
-    optimized )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-  esac
-
-
-
-
-  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-    MACOSX_UNIVERSAL="true"
-  fi
-
-
-
-  # Make sure JVM_VARIANTS_COMMA use minimal1 for backwards compatibility
-  JVM_VARIANTS_COMMA=`$ECHO ,$JVM_VARIANTS_OPT, | $SED -e 's/,minimal,/,minimal1,/'`
-
-  JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'`
-  JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'`
-  JVM_VARIANT_MINIMAL1=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,minimal1\?,/!s/.*/false/g' -e '/,minimal1\?,/s/.*/true/g'`
-  JVM_VARIANT_CORE=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,core,/!s/.*/false/g' -e '/,core,/s/.*/true/g'`
-  JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'`
-  JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'`
-  JVM_VARIANT_CUSTOM=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,custom,/!s/.*/false/g' -e '/,custom,/s/.*/true/g'`
-
-  #####
-  # Generate the legacy makefile targets for hotspot.
-  HOTSPOT_TARGET=""
-
-  if test "x$JVM_VARIANT_SERVER" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} "
-  fi
-
-  if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 "
-  fi
-
-  if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}minimal1 "
-  fi
-
-  if test "x$JVM_VARIANT_ZERO" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero "
-  fi
-
-  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark "
-  fi
-
-  if test "x$JVM_VARIANT_CORE" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}core "
-  fi
-
-  HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_DEBUG_LEVEL"
-
-  # On Macosx universal binaries are produced, but they only contain
-  # 64 bit intel. This invalidates control of which jvms are built
-  # from configure, but only server is valid anyway. Fix this
-  # when hotspot makefiles are rewritten.
-  if test "x$MACOSX_UNIVERSAL" = xtrue; then
-    HOTSPOT_TARGET=universal_${HOTSPOT_DEBUG_LEVEL}
-  fi
-
-  HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
-
-
-  # Control wether Hotspot runs Queens test after build.
-  # Check whether --enable-hotspot-test-in-build was given.
-if test "${enable_hotspot_test_in_build+set}" = set; then :
-  enableval=$enable_hotspot_test_in_build;
-else
-  enable_hotspot_test_in_build=no
-fi
-
-  if test "x$enable_hotspot_test_in_build" = "xyes"; then
-    TEST_IN_BUILD=true
-  else
-    TEST_IN_BUILD=false
-  fi
-
-
-  if test "x$USE_NEW_HOTSPOT_BUILD" = xfalse; then
-    if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        as_fn_error $? "You cannot build a client JVM for a 64-bit machine." "$LINENO" 5
-      fi
-    fi
-    if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        as_fn_error $? "You cannot build a minimal JVM for a 64-bit machine." "$LINENO" 5
-      fi
-    fi
-    if test "x$JVM_VARIANT_CUSTOM" = xtrue; then
-        as_fn_error $? "You cannot build a custom JVM using the old hotspot build system." "$LINENO" 5
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if elliptic curve crypto implementation is present" >&5
 $as_echo_n "checking if elliptic curve crypto implementation is present... " >&6; }
 
@@ -65977,7 +66502,9 @@
     JVM_FEATURES_TO_TEST=${!features_var_name}
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JVM_FEATURES_TO_TEST" >&5
 $as_echo "$JVM_FEATURES_TO_TEST" >&6; }
-    INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_TO_TEST// /$'\n'}"`
+    NEEDLE=${VALID_JVM_FEATURES// /$'\n'}
+    STACK=${JVM_FEATURES_TO_TEST// /$'\n'}
+    INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
     if test "x$INVALID_FEATURES" != x; then
       as_fn_error $? "Invalid JVM feature(s): $INVALID_FEATURES" "$LINENO" 5
     fi
@@ -66697,7 +67224,6 @@
 do
   case $ac_config_target in
     "$OUTPUT_ROOT/spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in" ;;
-    "$OUTPUT_ROOT/hotspot-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in" ;;
     "$OUTPUT_ROOT/bootcycle-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in" ;;
     "$OUTPUT_ROOT/buildjdk-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/buildjdk-spec.gmk:$AUTOCONF_DIR/buildjdk-spec.gmk.in" ;;
     "$OUTPUT_ROOT/compare.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in" ;;
diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in
deleted file mode 100644
index 50d7908..0000000
--- a/common/autoconf/hotspot-spec.gmk.in
+++ /dev/null
@@ -1,158 +0,0 @@
-#
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# Chaining of spec files
-HOTSPOT_SPEC:=$(dir $(SPEC))hotspot-spec.gmk
-override SPEC=$(HOTSPOT_SPEC)
-# Now include the base spec.gmk file
-include $(BASE_SPEC)
-
-# Additional legacy variables defined for Hotspot
-
-@SET_OPENJDK@
-@HOTSPOT_SET_WARNINGS_AS_ERRORS@
-
-# Legacy defines controlled by the SUPPORT_HEADLESS and SUPPORT_HEADFUL options.
-@BUILD_HEADLESS@
-
-JVM_VARIANTS:=@JVM_VARIANTS_COMMA@
-
-JVM_VARIANT_SERVER:=@JVM_VARIANT_SERVER@
-JVM_VARIANT_CLIENT:=@JVM_VARIANT_CLIENT@
-JVM_VARIANT_MINIMAL1:=@JVM_VARIANT_MINIMAL1@
-JVM_VARIANT_CORE:=@JVM_VARIANT_CORE@
-JVM_VARIANT_ZERO:=@JVM_VARIANT_ZERO@
-JVM_VARIANT_ZEROSHARK:=@JVM_VARIANT_ZEROSHARK@
-JVM_VARIANT_CUSTOM:=@JVM_VARIANT_HOTSPOT@
-
-# Legacy setting: OPT or DBG
-VARIANT:=@VARIANT@
-# Legacy setting: true or false
-FASTDEBUG:=@FASTDEBUG@
-# Legacy setting: debugging the class files?
-DEBUG_CLASSFILES:=@DEBUG_CLASSFILES@
-
-ALT_CUPS_HEADERS_PATH:=$(patsubst -I%,%,$(filter -I%,@CUPS_CFLAGS@))
-
-# The HOSTCC/HOSTCXX is Hotspot terminology for the BUILD_CC/BUILD_CXX, i.e. the
-# compiler that produces code that can be run on the build platform.
-HOSTCC:=@FIXPATH@ @BUILD_ICECC@ @BUILD_CC@ $(BUILD_SYSROOT_CFLAGS)
-HOSTCXX:=@FIXPATH@ @BUILD_ICECC@ @BUILD_CXX@ $(BUILD_SYSROOT_CFLAGS)
-
-####################################################
-#
-# Legacy Hotspot support
-
-# If cross compiling, then define CROSS_COMPILE_ARCH:=cpu_name here.
-@DEFINE_CROSS_COMPILE_ARCH@
-
-# Old name for OPENJDK_TARGET_OS (aix,bsd,hpux,linux,macosx,solaris,windows etc)
-PLATFORM=$(OPENJDK_TARGET_OS)
-# 32 or 64 bit
-ARCH_DATA_MODEL=$(OPENJDK_TARGET_CPU_BITS)
-
-ALT_BOOTDIR=$(BOOT_JDK)
-# Can be /sparcv9 or /amd64 on Solaris
-ISA_DIR=$(OPENJDK_TARGET_CPU_ISADIR)
-# Yet another name for arch used for an extra subdir below the jvm lib.
-# Uses i386 and amd64, instead of x86 and x86_64.
-LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB)
-# Set the cpu architecture
-ARCH=$(OPENJDK_TARGET_CPU_ARCH)
-# Legacy setting for building for a 64 bit machine.
-# If yes then this expands to _LP64:=1
-@LP64@
-
-# Legacy settings for zero
-ZERO_ENDIANNESS=$(OPENJDK_TARGET_CPU_ENDIAN)
-ZERO_LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB)
-ZERO_ARCHDEF=@ZERO_ARCHDEF@
-ZERO_ARCHFLAG=@ZERO_ARCHFLAG@
-LIBFFI_CFLAGS=@LIBFFI_CFLAGS@
-LIBFFI_LIBS=@LIBFFI_LIBS@
-
-# Legacy settings for zeroshark
-LLVM_CFLAGS=@LLVM_CFLAGS@
-LLVM_LIBS=@LLVM_LIBS@
-LLVM_LDFLAGS=@LLVM_LDFLAGS@
-
-ALT_OUTPUTDIR=$(HOTSPOT_OUTPUTDIR)
-ALT_EXPORT_PATH=$(HOTSPOT_DIST)
-
-ifeq ($(HOTSPOT_TARGET_CPU), zero)
-  CC_INTERP=true
-endif
-
-HOTSPOT_MAKE_ARGS:=@HOTSPOT_MAKE_ARGS@ @STATIC_CXX_SETTING@
-# Control wether Hotspot runs Queens test after building
-TEST_IN_BUILD=@TEST_IN_BUILD@
-
-USE_CLANG := @USE_CLANG@
-
-# For hotspot, override compiler/tools definition to not include FIXPATH prefix.
-# Hotspot has its own handling on the Windows path situation.
-CXX:=@CCACHE@ @ICECC@ @HOTSPOT_CXX@
-LD:=@HOTSPOT_LD@
-MT:=@HOTSPOT_MT@
-RC:=@HOTSPOT_RC@
-
-EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(CFLAGS_CCACHE) $(NO_NULL_POINTER_CHECK_FLAG) \
-				   $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG)
-EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ $(CFLAGS_CCACHE)
-EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
-
-USE_PRECOMPILED_HEADER=@USE_PRECOMPILED_HEADER@
-
-# Hotspot expects the variable FULL_DEBUG_SYMBOLS=1/0 to control debug symbols
-# creation.
-ifeq ($(COPY_DEBUG_SYMBOLS), true)
-  FULL_DEBUG_SYMBOLS=1
-  # Ensure hotspot uses the objcopy that configure located
-  ALT_OBJCOPY:=$(OBJCOPY)
-else
-  FULL_DEBUG_SYMBOLS=0
-endif
-
-# Hotspot expects the variable ZIP_DEBUGINFO_FILES=1/0 and not true/false.
-ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
-  ZIP_DEBUGINFO_FILES:=1
-else
-  ZIP_DEBUGINFO_FILES:=0
-endif
-
-DEBUG_BINARIES := @DEBUG_BINARIES@
-STRIP_POLICY := @STRIP_POLICY@
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  # On Windows, the Visual Studio toolchain needs the LIB and INCLUDE
-  # environment variables (in Windows path style).
-  export INCLUDE:=@VS_INCLUDE@
-  export LIB:=@VS_LIB@
-endif
-
-# Sneak this in via the spec.gmk file, since we don't want to mess around too much with the Hotspot make files.
-# This is needed to get the LOG setting to work properly.
-include $(SRC_ROOT)/make/common/MakeBase.gmk
diff --git a/common/autoconf/hotspot.m4 b/common/autoconf/hotspot.m4
index 4fffa86..18b6ec0 100644
--- a/common/autoconf/hotspot.m4
+++ b/common/autoconf/hotspot.m4
@@ -93,7 +93,10 @@
   # Check that the selected variants are valid
 
   # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
-  INVALID_VARIANTS=`$GREP -Fvx "${VALID_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  # Notice that the original variant failes on SLES 10 and 11
+  NEEDLE=${VALID_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if test "x$INVALID_VARIANTS" != x; then
     AC_MSG_NOTICE([Unknown variant(s) specified: $INVALID_VARIANTS])
     AC_MSG_ERROR([The available JVM variants are: $VALID_JVM_VARIANTS])
@@ -101,7 +104,9 @@
 
   # All "special" variants share the same output directory ("server")
   VALID_MULTIPLE_JVM_VARIANTS="server client minimal"
-  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if  test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then
     AC_MSG_ERROR([You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS.])
   fi
@@ -293,146 +298,51 @@
     features_var_name=JVM_FEATURES_$variant
     JVM_FEATURES_TO_TEST=${!features_var_name}
     AC_MSG_RESULT([$JVM_FEATURES_TO_TEST])
-    INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_TO_TEST// /$'\n'}"`
+    NEEDLE=${VALID_JVM_FEATURES// /$'\n'}
+    STACK=${JVM_FEATURES_TO_TEST// /$'\n'}
+    INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
     if test "x$INVALID_FEATURES" != x; then
       AC_MSG_ERROR([Invalid JVM feature(s): $INVALID_FEATURES])
     fi
   done
 ])
 
-###############################################################################
-# Support for old hotspot build. Remove once new hotspot build has proven
-# to work satisfactory.
+################################################################################
+# Check if gtest should be built
 #
-AC_DEFUN_ONCE([HOTSPOT_SETUP_LEGACY_BUILD],
+AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_GTEST],
 [
-  AC_ARG_ENABLE(new-hotspot-build, [AS_HELP_STRING([--disable-new-hotspot-build],
-      [disable the new hotspot build system (use the old) @<:@enabled@:>@])])
+  AC_ARG_ENABLE([hotspot-gtest], [AS_HELP_STRING([--disable-hotspot-gtest],
+      [Disables building of the Hotspot unit tests])])
 
-   if test "x$enable_new_hotspot_build" = "x" || test "x$enable_new_hotspot_build" = "xyes"; then
-     USE_NEW_HOTSPOT_BUILD=true
-   else
-     USE_NEW_HOTSPOT_BUILD=false
-   fi
-  AC_SUBST(USE_NEW_HOTSPOT_BUILD)
-
-  case $HOTSPOT_DEBUG_LEVEL in
-    product )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-    fastdebug )
-      VARIANT="DBG"
-      FASTDEBUG="true"
-      DEBUG_CLASSFILES="true"
-      ;;
-    debug )
-      VARIANT="DBG"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="true"
-      ;;
-    optimized )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-  esac
-  AC_SUBST(VARIANT)
-  AC_SUBST(FASTDEBUG)
-  AC_SUBST(DEBUG_CLASSFILES)
-
-  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-    MACOSX_UNIVERSAL="true"
-  fi
-
-  AC_SUBST(MACOSX_UNIVERSAL)
-
-  # Make sure JVM_VARIANTS_COMMA use minimal1 for backwards compatibility
-  JVM_VARIANTS_COMMA=`$ECHO ,$JVM_VARIANTS_OPT, | $SED -e 's/,minimal,/,minimal1,/'`
-
-  JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'`
-  JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'`
-  JVM_VARIANT_MINIMAL1=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,minimal1\?,/!s/.*/false/g' -e '/,minimal1\?,/s/.*/true/g'`
-  JVM_VARIANT_CORE=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,core,/!s/.*/false/g' -e '/,core,/s/.*/true/g'`
-  JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'`
-  JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'`
-  JVM_VARIANT_CUSTOM=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,custom,/!s/.*/false/g' -e '/,custom,/s/.*/true/g'`
-
-  #####
-  # Generate the legacy makefile targets for hotspot.
-  HOTSPOT_TARGET=""
-
-  if test "x$JVM_VARIANT_SERVER" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} "
-  fi
-
-  if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 "
-  fi
-
-  if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}minimal1 "
-  fi
-
-  if test "x$JVM_VARIANT_ZERO" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero "
-  fi
-
-  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark "
-  fi
-
-  if test "x$JVM_VARIANT_CORE" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}core "
-  fi
-
-  HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_DEBUG_LEVEL"
-
-  # On Macosx universal binaries are produced, but they only contain
-  # 64 bit intel. This invalidates control of which jvms are built
-  # from configure, but only server is valid anyway. Fix this
-  # when hotspot makefiles are rewritten.
-  if test "x$MACOSX_UNIVERSAL" = xtrue; then
-    HOTSPOT_TARGET=universal_${HOTSPOT_DEBUG_LEVEL}
-  fi
-
-  HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
-  AC_SUBST(HOTSPOT_MAKE_ARGS)
-
-  # Control wether Hotspot runs Queens test after build.
-  AC_ARG_ENABLE([hotspot-test-in-build], [AS_HELP_STRING([--enable-hotspot-test-in-build],
-      [run the Queens test after Hotspot build @<:@disabled@:>@])],,
-      [enable_hotspot_test_in_build=no])
-  if test "x$enable_hotspot_test_in_build" = "xyes"; then
-    TEST_IN_BUILD=true
+  if test -e "$HOTSPOT_TOPDIR/test/native"; then
+    GTEST_DIR_EXISTS="true"
   else
-    TEST_IN_BUILD=false
-  fi
-  AC_SUBST(TEST_IN_BUILD)
-
-  if test "x$USE_NEW_HOTSPOT_BUILD" = xfalse; then
-    if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        AC_MSG_ERROR([You cannot build a client JVM for a 64-bit machine.])
-      fi
-    fi
-    if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        AC_MSG_ERROR([You cannot build a minimal JVM for a 64-bit machine.])
-      fi
-    fi
-    if test "x$JVM_VARIANT_CUSTOM" = xtrue; then
-        AC_MSG_ERROR([You cannot build a custom JVM using the old hotspot build system.])
-    fi
+    GTEST_DIR_EXISTS="false"
   fi
 
-  AC_SUBST(JVM_VARIANTS_COMMA)
-  AC_SUBST(JVM_VARIANT_SERVER)
-  AC_SUBST(JVM_VARIANT_CLIENT)
-  AC_SUBST(JVM_VARIANT_MINIMAL1)
-  AC_SUBST(JVM_VARIANT_HOTSPOT)
-  AC_SUBST(JVM_VARIANT_ZERO)
-  AC_SUBST(JVM_VARIANT_ZEROSHARK)
-  AC_SUBST(JVM_VARIANT_CORE)
+  AC_MSG_CHECKING([if Hotspot gtest unit tests should be built])
+  if test "x$enable_hotspot_gtest" = "xyes"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      AC_MSG_RESULT([yes, forced])
+      BUILD_GTEST="true"
+    else
+      AC_MSG_ERROR([Cannot build gtest without the test source])
+    fi
+  elif test "x$enable_hotspot_gtest" = "xno"; then
+    AC_MSG_RESULT([no, forced])
+    BUILD_GTEST="false"
+  elif test "x$enable_hotspot_gtest" = "x"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      AC_MSG_RESULT([yes])
+      BUILD_GTEST="true"
+    else
+      AC_MSG_RESULT([no])
+      BUILD_GTEST="false"
+    fi
+  else
+    AC_MSG_ERROR([--enable-gtest must be either yes or no])
+  fi
+
+  AC_SUBST(BUILD_GTEST)
 ])
diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4
index e34e4d9..076b6cf 100644
--- a/common/autoconf/jdk-options.m4
+++ b/common/autoconf/jdk-options.m4
@@ -209,9 +209,6 @@
   if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
-  if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
-    INCLUDE_SA=false
-  fi
   AC_SUBST(INCLUDE_SA)
 
   # Compress jars
diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4
index e1e91d6..4238a17 100644
--- a/common/autoconf/libraries.m4
+++ b/common/autoconf/libraries.m4
@@ -95,6 +95,7 @@
   LIB_SETUP_LLVM
   LIB_SETUP_BUNDLED_LIBS
   LIB_SETUP_MISC_LIBS
+  LIB_SETUP_SOLARIS_STLPORT
 ])
 
 ################################################################################
@@ -189,3 +190,26 @@
   LIBZIP_CAN_USE_MMAP=true
   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 ])
+
+################################################################################
+# libstlport.so.1 is needed for running gtest on Solaris. Find it to
+# redistribute it in the test image.
+################################################################################
+AC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
+[
+  if test "$OPENJDK_TARGET_OS" = "solaris"; then
+    # Find the root of the Solaris Studio installation from the compiler path
+    SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
+    STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
+    AC_MSG_CHECKING([for libstlport.so.1])
+    if test -f "$STLPORT_LIB"; then
+      AC_MSG_RESULT([yes, $STLPORT_LIB])
+      BASIC_FIXUP_PATH([STLPORT_LIB])
+    else
+      AC_MSG_RESULT([no, not found at $STLPORT_LIB])
+      AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests])
+    fi
+    AC_SUBST(STLPORT_LIB)
+  fi
+])
+
diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4
index 2e99c45..2fbac1d 100644
--- a/common/autoconf/platform.m4
+++ b/common/autoconf/platform.m4
@@ -366,6 +366,23 @@
   fi
   AC_SUBST(OPENJDK_$1_OS_EXPORT_DIR)
 
+  # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
+  # Macosx is osx and x86_64 is x64
+  if test "x$OPENJDK_$1_OS" = xmacosx; then
+    OPENJDK_$1_OS_BUNDLE="osx"
+  else
+    OPENJDK_$1_OS_BUNDLE="$OPENJDK_TARGET_OS"
+  fi
+  if test "x$OPENJDK_$1_CPU" = xx86_64; then
+    OPENJDK_$1_CPU_BUNDLE="x64"
+  else
+    OPENJDK_$1_CPU_BUNDLE="$OPENJDK_$1_CPU"
+  fi
+  OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}"
+  AC_SUBST(OPENJDK_$1_OS_BUNDLE)
+  AC_SUBST(OPENJDK_$1_CPU_BUNDLE)
+  AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM)
+
   if test "x$OPENJDK_$1_CPU_BITS" = x64; then
     A_LP64="LP64:="
     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in
index 467cc30..cace143 100644
--- a/common/autoconf/spec.gmk.in
+++ b/common/autoconf/spec.gmk.in
@@ -89,6 +89,10 @@
 HOTSPOT_TARGET_CPU_ARCH := @HOTSPOT_TARGET_CPU_ARCH@
 HOTSPOT_TARGET_CPU_DEFINE := @HOTSPOT_TARGET_CPU_DEFINE@
 
+OPENJDK_TARGET_CPU_BUNDLE:=@OPENJDK_TARGET_CPU_BUNDLE@
+OPENJDK_TARGET_OS_BUNDLE:=@OPENJDK_TARGET_OS_BUNDLE@
+OPENJDK_TARGET_BUNDLE_PLATFORM:=@OPENJDK_TARGET_BUNDLE_PLATFORM@
+
 # We are building on this build system.
 # When not cross-compiling, it is the same as the target.
 OPENJDK_BUILD_OS:=@OPENJDK_BUILD_OS@
@@ -232,6 +236,9 @@
 VALID_JVM_FEATURES := @VALID_JVM_FEATURES@
 VALID_JVM_VARIANTS := @VALID_JVM_VARIANTS@
 
+# Control wether Hotspot builds gtest tests
+BUILD_GTEST := @BUILD_GTEST@
+
 # Control use of precompiled header in hotspot libjvm build
 USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@
 
@@ -265,6 +272,7 @@
 HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot
 JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk
 IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
+BUNDLES_OUTPUTDIR=$(BUILD_OUTPUT)/bundles
 TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make
 MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support
 # This does not get overridden in a bootcycle build
@@ -629,6 +637,7 @@
 EGREP:=@EGREP@
 FGREP:=@FGREP@
 GREP:=@GREP@
+GZIP:=@GZIP@
 HEAD:=@HEAD@
 LS:=@LS@
 LN:=@LN@
@@ -676,6 +685,9 @@
 DTRACE := @DTRACE@
 FIXPATH:=@FIXPATH@
 
+TAR_INCLUDE_PARAM:=@TAR_INCLUDE_PARAM@
+TAR_SUPPORTS_TRANSFORM:=@TAR_SUPPORTS_TRANSFORM@
+
 # Build setup
 ENABLE_JFR=@ENABLE_JFR@
 ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
@@ -685,6 +697,7 @@
 LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@
 MSVCR_DLL:=@MSVCR_DLL@
 MSVCP_DLL:=@MSVCP_DLL@
+STLPORT_LIB:=@STLPORT_LIB@
 
 ####################################################
 #
@@ -781,11 +794,46 @@
 # Interim image
 INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image
 
+# Docs image
+DOCS_IMAGE_SUBDIR := docs
+DOCS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR)
+
 # Macosx bundles directory definitions
-JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle/jdk-$(VERSION_NUMBER).jdk/Contents
-JRE_MACOSX_BUNDLE_SUBDIR=jre-bundle/jre-$(VERSION_NUMBER).jre/Contents
+JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle
+JRE_MACOSX_BUNDLE_SUBDIR=jre-bundle
 JDK_MACOSX_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_MACOSX_BUNDLE_SUBDIR)
 JRE_MACOSX_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_MACOSX_BUNDLE_SUBDIR)
+JDK_MACOSX_CONTENTS_SUBDIR=jdk-$(VERSION_NUMBER).jdk/Contents
+JRE_MACOSX_CONTENTS_SUBDIR=jre-$(VERSION_NUMBER).jre/Contents
+JDK_MACOSX_CONTENTS_DIR=$(JDK_MACOSX_BUNDLE_DIR)/$(JDK_MACOSX_CONTENTS_SUBDIR)
+JRE_MACOSX_CONTENTS_DIR=$(JRE_MACOSX_BUNDLE_DIR)/$(JRE_MACOSX_CONTENTS_SUBDIR)
+
+# Bundle names
+BASE_NAME := $(VERSION_SHORT)+$(VERSION_BUILD)_$(OPENJDK_TARGET_BUNDLE_PLATFORM)
+ifeq ($(DEBUG_LEVEL), fastdebug)
+  DEBUG_PART := -debug
+else ifneq ($(DEBUG_LEVEL), release)
+  DEBUG_PART := -$(DEBUG_LEVEL)
+endif
+JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
+JRE_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
+JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
+JRE_SYMBOLS_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_demo$(DEBUG_PART).zip
+else
+  DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_demo$(DEBUG_PART).tar.gz
+endif
+TEST_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests$(DEBUG_PART).tar.gz
+DOCS_BUNDLE_NAME := jdk-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz
+
+JDK_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_BUNDLE_NAME)
+JRE_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JRE_BUNDLE_NAME)
+JDK_SYMBOLS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JDK_SYMBOLS_BUNDLE_NAME)
+JRE_SYMBOLS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JRE_SYMBOLS_BUNDLE_NAME)
+DEMOS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(DEMOS_BUNDLE_NAME)
+TEST_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(TEST_BUNDLE_NAME)
+DOCS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(DOCS_BUNDLE_NAME)
 
 # This macro is called to allow inclusion of closed source counterparts.
 # Unless overridden in closed sources, it expands to nothing.
diff --git a/common/bin/compare.sh b/common/bin/compare.sh
index db73426..0126b9c 100644
--- a/common/bin/compare.sh
+++ b/common/bin/compare.sh
@@ -274,14 +274,19 @@
 
     $MKDIR -p $WORK_DIR
 
+    FILE_TYPES_FILTER="$SED \
+        -e 's/BuildID[^,]*//' \
+        -e 's/last modified: .*//' \
+        "
+
     echo -n File types...
     found=""
     for f in `cd $OTHER_DIR && $FIND . ! -type d`
     do
         if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
         if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
-        OF=`cd ${OTHER_DIR} && $FILE -h $f | $SED 's/BuildID[^,]*//g'`
-        TF=`cd ${THIS_DIR} && $FILE -h $f | $SED 's/BuildID[^,]*//g'`
+        OF=$(cd ${OTHER_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER)
+        TF=$(cd ${THIS_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER)
         if [ "$OF" != "$TF" ]
         then
             if [ "`echo $OF | $GREP -c 'Zip archive data'`" -gt 0 ] \
@@ -320,7 +325,7 @@
         ! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \
         ! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \
         ! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \
-        ! -name "finish_installation" ! -name "Sparkle" \
+        ! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \
         | $GREP -v "./bin/"  | $SORT | $FILTER)
 
     echo Other files with binary differences...
@@ -423,6 +428,10 @@
     then
         (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
         (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
+    elif [ "$TYPE" = "gz" ]
+    then
+        (cd $THIS_UNZIPDIR && $GUNZIP -c $THIS_ZIP | $TAR xf -)
+        (cd $OTHER_UNZIPDIR && $GUNZIP -c $OTHER_ZIP | $TAR xf -)
     else
         (cd $THIS_UNZIPDIR && $JIMAGE extract $THIS_ZIP)
         (cd $OTHER_UNZIPDIR && $JIMAGE extract $OTHER_ZIP)
@@ -526,10 +535,11 @@
     OTHER_DIR=$2
     WORK_DIR=$3
 
-    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER )
+    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" -o -name "*.tar.gz" \
+        | $SORT | $FILTER )
 
     if [ -n "$ZIPS" ]; then
-        echo Zip files...
+        echo Zip/tar.gz files...
 
         return_value=0
         for f in $ZIPS; do
@@ -913,7 +923,7 @@
             FULLDUMP_MSG="          "
             DIFF_FULLDUMP=
             if [[ "$KNOWN_FULLDUMP_DIFF $ACCEPTED_FULLDUMP_DIFF" = *"$BIN_FILE"* ]]; then
-                FULLDUMP_MSG="    !     "
+                FULLDUMP_MSG="    !    "
             fi
         fi
     fi
diff --git a/common/bin/idea.sh b/common/bin/idea.sh
index 911d309..2cd6f92 100644
--- a/common/bin/idea.sh
+++ b/common/bin/idea.sh
@@ -155,6 +155,14 @@
   printf "%s\n" "$mn" >> $IDEA_ANT
 }
 
+JTREG_HOME="        <property name=\"jtreg.home\" value=\"####\" />"
+
+addJtregHome() {
+  DIR=`dirname $SPEC`
+  mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`"
+  printf "%s\n" "$mn" >> $IDEA_ANT
+}
+
 ### Generate ant.xml
 
 rm -f $IDEA_ANT
@@ -162,6 +170,8 @@
 do
   if echo "$line" | egrep "^ .* <property name=\"module.name\"" > /dev/null ; then
     addModuleName
+  elif echo "$line" | egrep "^ .* <property name=\"jtreg.home\"" > /dev/null ; then
+    addJtregHome
   elif echo "$line" | egrep "^ .* <property name=\"build.target.dir\"" > /dev/null ; then
     addBuildDir
   else
diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js
index 2b71647..2d752fd 100644
--- a/common/conf/jib-profiles.js
+++ b/common/conf/jib-profiles.js
@@ -215,11 +215,11 @@
     var common = {};
 
     common.dependencies = ["boot_jdk", "gnumake", "jtreg"],
-    common.default_make_targets = ["product-images", "test-image"],
+    common.default_make_targets = ["product-bundles", "test-bundles"],
     common.default_make_targets_debug = common.default_make_targets;
     common.default_make_targets_slowdebug = common.default_make_targets;
     common.configure_args = ["--enable-jtreg-failure-handler"],
-    common.configure_args_32bit = ["--with-target-bits=32", "--with-jvm-variants=client,server"],
+    common.configure_args_32bit = ["--with-target-bits=32"],
     common.configure_args_debug = ["--enable-debug"],
     common.configure_args_slowdebug = ["--with-debug-level=slowdebug"],
     common.organization = "jpg.infra.builddeps"
@@ -245,7 +245,7 @@
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: concat(common.configure_args, "--with-zlib=system"),
-            default_make_targets: concat(common.default_make_targets, "docs-image")
+            default_make_targets: concat(common.default_make_targets, "docs-bundles")
         },
 
         "linux-x86": {
@@ -254,7 +254,7 @@
             build_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: concat(common.configure_args, common.configure_args_32bit,
-                "--with-zlib=system"),
+                "--with-jvm-variants=minimal,client,server", "--with-zlib=system"),
             default_make_targets: common.default_make_targets
         },
 
@@ -295,7 +295,8 @@
             target_cpu: "x86",
             build_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit", "freetype"),
-            configure_args: concat(common.configure_args, common.configure_args_32bit),
+            configure_args: concat(common.configure_args,
+                "--with-jvm-variants=client,server", common.configure_args_32bit),
             default_make_targets: common.default_make_targets
         }
     };
diff --git a/corba/.hgtags b/corba/.hgtags
index feea5f0..db59b1c 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -361,3 +361,4 @@
 7dfa7377a5e601b8f740741a9a80e04c72dd04d6 jdk-9+116
 7a1b36bf2fe55a9a7732489ccdd326c910329a7e jdk-9+117
 8c2c2d17f7ce92a31c9ccb44a122ec62f5a85ace jdk-9+118
+daf533920b1266603b5cbdab31908d2a931c5361 jdk-9+119
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index c2bf9fb..754ebb6 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -521,3 +521,4 @@
 61a214186dae6811dd989e9165e42f7dbf02acde jdk-9+116
 88170d3642905b9e6cac03e8efcc976885a7e6da jdk-9+117
 9b1075cac08dc836ec32e7b368415cbe3aceaf8c jdk-9+118
+15f3fe264872766bcb205696198f0c1502420e17 jdk-9+119
diff --git a/hotspot/.mx.jvmci/suite.py b/hotspot/.mx.jvmci/suite.py
index 514994c..3da6124 100644
--- a/hotspot/.mx.jvmci/suite.py
+++ b/hotspot/.mx.jvmci/suite.py
@@ -83,6 +83,21 @@
       "workingSets" : "API,JVMCI",
     },
 
+    "jdk.vm.ci.code.test" : {
+      "subDir" : "test/compiler/jvmci",
+      "sourceDirs" : ["src"],
+      "dependencies" : [
+        "mx:JUNIT",
+        "jdk.vm.ci.amd64",
+        "jdk.vm.ci.sparc",
+        "jdk.vm.ci.code",
+        "jdk.vm.ci.hotspot",
+      ],
+      "checkstyle" : "jdk.vm.ci.services",
+      "javaCompliance" : "1.8",
+      "workingSets" : "API,JVMCI",
+    },
+
     "jdk.vm.ci.runtime" : {
       "subDir" : "src/jdk.vm.ci/share/classes",
       "sourceDirs" : ["src"],
@@ -164,7 +179,7 @@
       "subDir" : "test/compiler/jvmci",
       "sourceDirs" : ["src"],
       "dependencies" : [
-        "mx:TESTNG",
+        "TESTNG",
         "jdk.vm.ci.hotspot",
       ],
       "checkstyle" : "jdk.vm.ci.services",
diff --git a/hotspot/makefiles/BuildHotspot.gmk b/hotspot/make/BuildHotspot.gmk
similarity index 100%
rename from hotspot/makefiles/BuildHotspot.gmk
rename to hotspot/make/BuildHotspot.gmk
diff --git a/hotspot/makefiles/Dist.gmk b/hotspot/make/Dist.gmk
similarity index 100%
rename from hotspot/makefiles/Dist.gmk
rename to hotspot/make/Dist.gmk
diff --git a/hotspot/makefiles/HotspotCommon.gmk b/hotspot/make/HotspotCommon.gmk
similarity index 100%
rename from hotspot/makefiles/HotspotCommon.gmk
rename to hotspot/make/HotspotCommon.gmk
diff --git a/hotspot/make/Makefile b/hotspot/make/Makefile
deleted file mode 100644
index db2b96e..0000000
--- a/hotspot/make/Makefile
+++ /dev/null
@@ -1,895 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Top level gnumake file for hotspot builds
-#
-# Default is to build the both product images and construct an export dir.
-#  The default export directory name is `pwd`/export-$(PLATFORM).
-#
-#   Use: 'gnumake help' for more information.
-#
-# This makefile uses the default settings for where to find compilers and
-#    tools, and obeys the ALT_* variable settings used by the other JDK
-#    workspaces.
-#
-
-# Expected/optional make variables defined on make command line:
-#  LP64=1 or ARCH_DATA_MODEL=64 for 64bit build
-#
-# Expected/optional make variables or environment variables:
-#  ALT_SLASH_JAVA             Location of /java or J:
-#  ALT_BOOTDIR                Previous JDK home directory for javac compiler
-#  ALT_OUTPUTDIR              Output directory to use for hotspot build
-#  ALT_EXPORT_PATH            Directory to export hotspot build to
-#  ALT_JDK_IMPORT_PATH        Current JDK build (only for create_jdk rules)
-#  ALT_JDK_TARGET_IMPORT_PATH Current JDK build when cross-compiling
-#
-# Version strings and numbers:
-#  VERSION_SHORT      Current JDK version (e.g. 9.0.0)
-#  JDK_PREVIOUS_VERSION Previous (bootdir) JDK version (e.g. 1.5.0) (Only needed
-#  to facilitate standalone build.)
-#  VERSION_STRING     Full version string to use (e.g. "9.0.0-ea-b42")
-#  VERSION_MAJOR Major number for version (e.g. 9)
-#  VERSION_MINOR Minor number for version (e.g. 0)
-#  VERSION_SECURITY Security number for version (e.g. 0)
-#  VERSION_PATCH Patch number for version (e.g. 0)
-#
-
-# Default is build both product fastdebug and create export area
-
-# Allow to build HotSpot in local directory from sources specified by GAMMADIR.
-# After make/defs.make GAMMADIR is defined.
-ifdef GAMMADIR
-  ifndef ALT_OUTPUTDIR
-    ALT_OUTPUTDIR := $(shell pwd)
-  endif
-  include $(GAMMADIR)/make/defs.make
-else
-  include defs.make
-endif
-
-include $(GAMMADIR)/make/altsrc.make
-
--include $(HS_ALT_MAKE)/Makefile.make
-
-ifneq ($(ALT_OUTPUTDIR),)
-  ALT_OUT=ALT_OUTPUTDIR=$(ALT_OUTPUTDIR)
-else
-  ALT_OUT=
-endif
-
-# Typical C1/C2 targets made available with this Makefile
-C1_VM_TARGETS=product1 fastdebug1 optimized1 debug1
-C2_VM_TARGETS=product  fastdebug  optimized  debug
-CORE_VM_TARGETS=productcore fastdebugcore optimizedcore debugcore
-ZERO_VM_TARGETS=productzero fastdebugzero optimizedzero debugzero
-SHARK_VM_TARGETS=productshark fastdebugshark optimizedshark debugshark
-MINIMAL1_VM_TARGETS=productminimal1 fastdebugminimal1 debugminimal1
-
-COMMON_VM_PRODUCT_TARGETS=product product1 docs export_product
-COMMON_VM_FASTDEBUG_TARGETS=fastdebug fastdebug1 docs export_fastdebug
-COMMON_VM_DEBUG_TARGETS=debug debug1 docs export_debug
-COMMON_VM_OPTIMIZED_TARGETS=optimized optimized1 docs export_optimized
-
-# JDK directory list
-JDK_DIRS=bin include lib demo
-
-all:           all_product all_fastdebug
-
-ifeq ($(JVM_VARIANT_MINIMAL1),true)
-all_product:	productminimal1
-all_fastdebug:	fastdebugminimal1
-all_debug:	debugminimal1
-endif
-
-ifdef BUILD_CLIENT_ONLY
-all_product:   product1 docs export_product
-all_fastdebug: fastdebug1 docs export_fastdebug
-all_debug:     debug1 docs export_debug
-all_optimized: optimized1 docs export_optimized
-else
-ifeq ($(MACOSX_UNIVERSAL),true)
-all_product:   universal_product
-all_fastdebug: universal_fastdebug
-all_debug:     universal_debug
-all_optimized: universal_optimized
-else
-all_product:   $(COMMON_VM_PRODUCT_TARGETS)
-all_fastdebug: $(COMMON_VM_FASTDEBUG_TARGETS)
-all_debug:     $(COMMON_VM_DEBUG_TARGETS)
-all_optimized: $(COMMON_VM_OPTIMIZED_TARGETS)
-endif
-endif
-
-allzero:           all_productzero all_fastdebugzero
-all_productzero:   productzero docs export_product
-all_fastdebugzero: fastdebugzero docs export_fastdebug
-all_debugzero:     debugzero docs export_debug
-all_optimizedzero: optimizedzero docs export_optimized
-
-allshark:           all_productshark all_fastdebugshark
-all_productshark:   productshark docs export_product
-all_fastdebugshark: fastdebugshark docs export_fastdebug
-all_debugshark:     debugshark docs export_debug
-all_optimizedshark: optimizedshark docs export_optimized
-
-allcore:           all_productcore all_fastdebugcore
-all_productcore:   productcore docs export_product
-all_fastdebugcore: fastdebugcore docs export_fastdebug
-all_debugcore:     debugcore docs export_debug
-all_optimizedcore: optimizedcore docs export_optimized
-
-# Do everything
-world:         all create_jdk
-
-# Build or export docs
-docs:
-ifeq ($(OSNAME),windows)
-	@$(ECHO) "No docs ($(VM_TARGET)) for windows"
-else
-# We specify 'BUILD_FLAVOR=product' so that the proper
-# ENABLE_FULL_DEBUG_SYMBOLS value is used.
-	$(CD) $(OUTPUTDIR); \
-	    $(MAKE) -f $(ABS_OS_MAKEFILE) \
-		      $(MAKE_ARGS) BUILD_FLAVOR=product docs
-endif
-
-# Output directories
-C1_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1
-C2_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2
-CORE_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_core
-MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1
-ZERO_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_zero
-SHARK_DIR   =$(OUTPUTDIR)/$(VM_PLATFORM)_shark
-
-# Build variation of hotspot
-$(C1_VM_TARGETS):
-	$(CD) $(GAMMADIR)/make; \
-	$(MAKE) BUILD_DIR=$(C1_DIR) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT)
-
-$(C2_VM_TARGETS):
-	$(CD) $(GAMMADIR)/make; \
-	$(MAKE) BUILD_DIR=$(C2_DIR) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT)
-
-$(CORE_VM_TARGETS):
-	$(CD) $(GAMMADIR)/make; \
-	$(MAKE) BUILD_DIR=$(CORE_DIR) BUILD_FLAVOR=$(@:%core=%) VM_TARGET=$@ generic_buildcore $(ALT_OUT)
-
-$(ZERO_VM_TARGETS):
-	$(CD) $(GAMMADIR)/make; \
-	$(MAKE) BUILD_DIR=$(ZERO_DIR) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ generic_buildzero $(ALT_OUT)
-
-$(SHARK_VM_TARGETS):
-	$(CD) $(GAMMADIR)/make; \
-	$(MAKE) BUILD_DIR=$(SHARK_DIR) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ generic_buildshark $(ALT_OUT)
-
-$(MINIMAL1_VM_TARGETS):
-	$(CD) $(GAMMADIR)/make; \
-	$(MAKE) BUILD_DIR=$(MINIMAL1_DIR) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ generic_buildminimal1 $(ALT_OUT)
-
-# Install hotspot script in build directory
-HOTSPOT_SCRIPT=$(BUILD_DIR)/$(BUILD_FLAVOR)/hotspot
-$(HOTSPOT_SCRIPT): $(GAMMADIR)/make/hotspot.script
-	$(QUIETLY) $(MKDIR) -p $(BUILD_DIR)/$(BUILD_FLAVOR)
-	$(QUIETLY) cat $< | sed -e 's|@@LIBARCH@@|$(LIBARCH)|g' | sed -e 's|@@JDK_IMPORT_PATH@@|$(JDK_IMPORT_PATH)|g' > $@
-	$(QUIETLY) chmod +x $@
-
-# Build compiler1 (client) rule, different for platforms
-generic_build1: $(HOTSPOT_SCRIPT)
-	$(MKDIR) -p $(OUTPUTDIR)
-ifeq ($(OSNAME),windows)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-	$(CD) $(OUTPUTDIR); \
-	    $(NMAKE) -f $(ABS_OS_MAKEFILE) \
-		      Variant=compiler1 \
-                      WorkSpace=$(ABS_GAMMADIR) \
-		      BootStrapDir=$(ABS_BOOTDIR) \
-                      BuildUser=$(USERNAME) \
-		      $(MAKE_ARGS) $(VM_TARGET:%1=%)
-  else
-	@$(ECHO) "No compiler1 ($(VM_TARGET)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
-  endif
-else
-  ifeq ($(ARCH_DATA_MODEL), 32)
-	$(CD) $(OUTPUTDIR); \
-	    $(MAKE) -f $(ABS_OS_MAKEFILE) \
-		      $(MAKE_ARGS) $(VM_TARGET)
-  else
-	@$(ECHO) "No compiler1 ($(VM_TARGET)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
-  endif
-endif
-
-# Build compiler2 (server) rule, different for platforms
-generic_build2: $(HOTSPOT_SCRIPT)
-	$(MKDIR) -p $(OUTPUTDIR)
-ifeq ($(OSNAME),windows)
-	$(CD) $(OUTPUTDIR); \
-	    $(NMAKE) -f $(ABS_OS_MAKEFILE) \
-		      Variant=compiler2 \
-                      WorkSpace=$(ABS_GAMMADIR) \
-		      BootStrapDir=$(ABS_BOOTDIR) \
-                      BuildUser=$(USERNAME) \
-		      $(MAKE_ARGS) $(VM_TARGET)
-else
-	$(CD) $(OUTPUTDIR); \
-	    $(MAKE) -f $(ABS_OS_MAKEFILE) \
-		      $(MAKE_ARGS) $(VM_TARGET)
-endif
-
-# NOTE: Changes in this file was just to facilitate comparison when 
-# developing the new build, and should not be integrated.
-generic_buildcore: $(HOTSPOT_SCRIPT)
-#ifeq ($(HS_ARCH),ppc)
-#  ifeq ($(ARCH_DATA_MODEL),64)
-	$(MKDIR) -p $(OUTPUTDIR)
-	$(CD) $(OUTPUTDIR); \
-		$(MAKE) -f $(ABS_OS_MAKEFILE) \
-			$(MAKE_ARGS) $(VM_TARGET)
-#  else
-#	@$(ECHO) "No ($(VM_TARGET)) for ppc ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
-#  endif
-#else
-#	@$(ECHO) "No ($(VM_TARGET)) for $(HS_ARCH)"
-#endif
-
-generic_buildzero: $(HOTSPOT_SCRIPT)
-	$(MKDIR) -p $(OUTPUTDIR)
-	$(CD) $(OUTPUTDIR); \
-		$(MAKE) -f $(ABS_OS_MAKEFILE) \
-			$(MAKE_ARGS) $(VM_TARGET)
-
-generic_buildshark: $(HOTSPOT_SCRIPT)
-	$(MKDIR) -p $(OUTPUTDIR)
-	$(CD) $(OUTPUTDIR); \
-		$(MAKE) -f $(ABS_OS_MAKEFILE) \
-			$(MAKE_ARGS) $(VM_TARGET)
-
-generic_buildminimal1: $(HOTSPOT_SCRIPT)
-ifeq ($(JVM_VARIANT_MINIMAL1),true)
-	$(MKDIR) -p $(OUTPUTDIR)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    ifeq ($(OSNAME),windows)
-	$(ECHO) "No ($(VM_TARGET)) for $(OSNAME) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" ;
-    else
-      ifeq ($(OSNAME),solaris)
-	$(ECHO) "No ($(VM_TARGET)) for $(OSNAME) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" ;
-      else
-	$(CD) $(OUTPUTDIR); \
-	$(MAKE) -f $(ABS_OS_MAKEFILE) $(MAKE_ARGS) $(VM_TARGET) ;
-      endif
-    endif
-  else
-	    @$(ECHO) "No ($(VM_TARGET)) for $(OSNAME) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
-  endif
-else
-	@$(ECHO) "Error: trying to build a minimal target but JVM_VARIANT_MINIMAL1 is not true."
-endif
-
-remove_old_debuginfo:
-ifeq ($(JVM_VARIANT_CLIENT), true)
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-    ifeq ($(OSNAME), windows)
-	  $(RM) -f $(EXPORT_CLIENT_DIR)/jvm.map $(EXPORT_CLIENT_DIR)/jvm.pdb
-    else
-	  $(RM) -f $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
-    endif
-  else
-	$(RM) -f $(EXPORT_CLIENT_DIR)/libjvm.diz
-  endif
-endif
-ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-    ifeq ($(OSNAME), windows)
-	  $(RM) -f $(EXPORT_SERVER_DIR)/jvm.map $(EXPORT_SERVER_DIR)/jvm.pdb
-    else
-      ifeq ($(OS_VENDOR), Darwin)
-	    $(RM) -rf $(EXPORT_SERVER_DIR)/libjvm.dylib.dSYM
-      else
-	    $(RM) -f $(EXPORT_SERVER_DIR)/libjvm.debuginfo
-      endif
-    endif
-  else
-	$(RM) -f $(EXPORT_SERVER_DIR)/libjvm.diz
-  endif
-endif
-ifeq ($(JVM_VARIANT_MINIMAL1),true)
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(RM) -f $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo
-  else
-	$(RM) -f $(EXPORT_MINIMAL_DIR)/libjvm.diz
-  endif
-endif
-
-# Export file rule
-generic_export: $(EXPORT_LIST) remove_old_debuginfo
-
-export_product:
-	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) generic_export
-export_fastdebug:
-	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
-export_debug:
-	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
-export_optimized:
-	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
-
-export_product_jdk::
-	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export
-export_optimized_jdk::
-	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
-export_fastdebug_jdk::
-	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
-export_debug_jdk::
-	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
-
-# Export file copy rules
-XUSAGE=$(HS_SRC_DIR)/share/vm/Xusage.txt
-DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs
-C1_BUILD_DIR      =$(C1_DIR)/$(BUILD_FLAVOR)
-C2_BUILD_DIR      =$(C2_DIR)/$(BUILD_FLAVOR)
-CORE_BUILD_DIR    =$(CORE_DIR)/$(BUILD_FLAVOR)
-MINIMAL1_BUILD_DIR=$(MINIMAL1_DIR)/$(BUILD_FLAVOR)
-ZERO_BUILD_DIR    =$(ZERO_DIR)/$(BUILD_FLAVOR)
-SHARK_BUILD_DIR   =$(SHARK_DIR)/$(BUILD_FLAVOR)
-
-# Server (C2)
-ifeq ($(JVM_VARIANT_SERVER), true)
-# Common
-$(EXPORT_SERVER_DIR)/%.diz:       		$(C2_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_LIB_DIR)/%.jar:			$(C2_BUILD_DIR)/../generated/%.jar
-	$(install-file)
-$(EXPORT_INCLUDE_DIR)/%:			$(C2_BUILD_DIR)/../generated/jvmtifiles/%
-	$(install-file)
-# Windows
-$(EXPORT_SERVER_DIR)/%.dll:			$(C2_BUILD_DIR)/%.dll
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.pdb:			$(C2_BUILD_DIR)/%.pdb
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.map:			$(C2_BUILD_DIR)/%.map
-	$(install-file)
-$(EXPORT_LIB_DIR)/%.lib:			$(C2_BUILD_DIR)/%.lib
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.diz:			$(C2_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.dll:			$(C2_BUILD_DIR)/%.dll
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.pdb:			$(C2_BUILD_DIR)/%.pdb
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.map:			$(C2_BUILD_DIR)/%.map
-	$(install-file)
-# Unix
-$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.debuginfo: 	$(C2_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.debuginfo:       	$(C2_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.debuginfo:    	$(C2_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.diz: 		$(C2_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.diz:    		$(C2_BUILD_DIR)/%.diz
-	$(install-file)
-# MacOS X
-$(EXPORT_LIB_ARCH_DIR)/%.dSYM: 		$(C2_BUILD_DIR)/%.dSYM
-	$(install-dir)
-$(EXPORT_SERVER_DIR)/%.dSYM:       		$(C2_BUILD_DIR)/%.dSYM
-	$(install-dir)
-$(EXPORT_SERVER_DIR)/%.symbols:                 $(C2_BUILD_DIR)/%.symbols
-	$(install-file)
-endif
-
-# Client (C1)
-ifeq ($(JVM_VARIANT_CLIENT), true)
-# Common
-$(EXPORT_CLIENT_DIR)/%.diz:       		$(C1_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_LIB_DIR)/%.jar:			$(C1_BUILD_DIR)/../generated/%.jar
-	$(install-file)
-$(EXPORT_INCLUDE_DIR)/%:			$(C1_BUILD_DIR)/../generated/jvmtifiles/%
-	$(install-file)
-# Windows
-$(EXPORT_CLIENT_DIR)/%.dll:			$(C1_BUILD_DIR)/%.dll
-	$(install-file)
-$(EXPORT_CLIENT_DIR)/%.pdb:			$(C1_BUILD_DIR)/%.pdb
-	$(install-file)
-$(EXPORT_CLIENT_DIR)/%.map:			$(C1_BUILD_DIR)/%.map
-	$(install-file)
-$(EXPORT_LIB_DIR)/%.lib:			$(C1_BUILD_DIR)/%.lib
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.diz:			$(C1_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.dll:			$(C1_BUILD_DIR)/%.dll
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.pdb:			$(C1_BUILD_DIR)/%.pdb
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.map:			$(C1_BUILD_DIR)/%.map
-	$(install-file)
-# Unix
-$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX):       $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.debuginfo: 	$(C1_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_CLIENT_DIR)/%.debuginfo:       	$(C1_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.debuginfo:    	$(C1_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.diz: 		$(C1_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.diz:    		$(C1_BUILD_DIR)/%.diz
-	$(install-file)
-# MacOS X
-$(EXPORT_LIB_ARCH_DIR)/%.dSYM: 		$(C1_BUILD_DIR)/%.dSYM
-	$(install-dir)
-$(EXPORT_CLIENT_DIR)/%.dSYM:       		$(C1_BUILD_DIR)/%.dSYM
-	$(install-dir)
-endif
-
-# Minimal1
-ifeq ($(JVM_VARIANT_MINIMAL1), true)
-# Common
-$(EXPORT_MINIMAL_DIR)/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_LIB_DIR)/%.jar:			$(MINIMAL1_BUILD_DIR)/../generated/%.jar
-	$(install-file)
-$(EXPORT_INCLUDE_DIR)/%:			$(MINIMAL1_BUILD_DIR)/../generated/jvmtifiles/%
-	$(install-file)
-# Windows
-$(EXPORT_MINIMAL_DIR)/%.dll:			$(MINIMAL1_BUILD_DIR)/%.dll
-	$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.pdb:			$(MINIMAL1_BUILD_DIR)/%.pdb
-	$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.map:			$(MINIMAL1_BUILD_DIR)/%.map
-	$(install-file)
-$(EXPORT_LIB_DIR)/%.lib:			$(MINIMAL1_BUILD_DIR)/%.lib
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.dll:			$(MINIMAL1_BUILD_DIR)/%.dll
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.pdb:			$(MINIMAL1_BUILD_DIR)/%.pdb
-	$(install-file)
-$(EXPORT_BIN_DIR)/%.map:			$(MINIMAL1_BUILD_DIR)/%.map
-	$(install-file)
-# Unix
-$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_MINIMAL_DIR)/64/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.diz:		$(MINIMAL1_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_MINIMAL_DIR)/64/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
-	$(install-file)
-# MacOS X does not support Minimal1 config
-endif
-
-# Zero
-ifeq ($(JVM_VARIANT_ZERO), true)
-# Common
-$(EXPORT_LIB_DIR)/%.jar:			$(ZERO_BUILD_DIR)/../generated/%.jar
-	$(install-file)
-$(EXPORT_INCLUDE_DIR)/%:			$(ZERO_BUILD_DIR)/../generated/jvmtifiles/%
-	$(install-file)
-# Unix
-$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.debuginfo:		$(ZERO_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.diz:		$(ZERO_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.debuginfo:		$(ZERO_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.diz:			$(ZERO_BUILD_DIR)/%.diz
-	$(install-file)
-# MacOS X
-$(EXPORT_LIB_ARCH_DIR)/%.dSYM: 		$(ZERO_BUILD_DIR)/%.dSYM
-	$(install-dir)
-$(EXPORT_SERVER_DIR)/%.dSYM:			$(ZERO_BUILD_DIR)/%.dSYM
-	$(install-dir)
-endif
-
-# Core
-ifeq ($(JVM_VARIANT_CORE), true)
-# Common
-$(EXPORT_LIB_DIR)/%.jar:			$(CORE_BUILD_DIR)/../generated/%.jar
-	$(install-file)
-$(EXPORT_INCLUDE_DIR)/%:			$(CORE_BUILD_DIR)/../generated/jvmtifiles/%
-	$(install-file)
-# Unix
-$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX):	$(CORE_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.debuginfo:		$(CORE_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.diz:		$(CORE_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):	$(CORE_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.debuginfo:		$(CORE_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.diz:			$(CORE_BUILD_DIR)/%.diz
-	$(install-file)
-endif
-
-# Shark
-ifeq ($(JVM_VARIANT_ZEROSHARK), true)
-# Common
-$(EXPORT_LIB_DIR)/%.jar:			$(SHARK_BUILD_DIR)/../generated/%.jar
-	$(install-file)
-$(EXPORT_INCLUDE_DIR)/%:			$(SHARK_BUILD_DIR)/../generated/jvmtifiles/%
-	$(install-file)
-# Unix
-$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.debuginfo):	$(SHARK_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_LIB_ARCH_DIR)/%.diz:		$(SHARK_BUILD_DIR)/%.diz
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.debuginfo:		$(SHARK_BUILD_DIR)/%.debuginfo
-	$(install-file)
-$(EXPORT_SERVER_DIR)/%.diz:			$(SHARK_BUILD_DIR)/%.diz
-	$(install-file)
-# MacOS X
-$(EXPORT_LIB_ARCH_DIR)/%.dSYM: 		$(SHARK_BUILD_DIR)/%.dSYM
-	$(install-dir)
-$(EXPORT_SERVER_DIR)/%.dSYM:			$(SHARK_BUILD_DIR)/%.dSYM
-	$(install-dir)
-endif
-
-$(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/code/%
-	$(install-file)
-
-$(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/prims/%
-	$(install-file)
-
-HS_JNI_ARCH_SRC=$(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(HS_ARCH)/vm/jni_$(HS_ARCH).h)
-$(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h: $(HS_JNI_ARCH_SRC)
-	$(install-file)
-
-$(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/services/%
-	$(install-file)
-
-JFR_EXISTS=$(shell if [ -d $(HS_ALT_SRC) ]; then echo 1; else echo 0; fi)
-# export jfr.h
-ifeq ($JFR_EXISTS,1)
-$(EXPORT_INCLUDE_DIR)/%: $(HS_ALT_SRC)/share/vm/jfr/%
-	$(install-file)
-else
-$(EXPORT_INCLUDE_DIR)/jfr.h:
-endif
-
-# Doc files (jvmti.html)
-$(EXPORT_DOCS_DIR)/platform/jvmti/%: $(DOCS_DIR)/%
-	$(install-file)
-
-# Xusage file
-$(EXPORT_SERVER_DIR)/Xusage.txt $(EXPORT_CLIENT_DIR)/Xusage.txt $(EXPORT_MINIMAL_DIR)/Xusage.txt: $(XUSAGE)
-	$(prep-target)
-	$(RM) $@.temp
-	$(SED) 's/\(separated by \)[;:]/\1$(PATH_SEP)/g' $< > $@.temp
-	$(MV) $@.temp $@
-
-#
-# Clean rules
-#
-clobber clean: clean_build clean_export clean_jdk
-clean_build:
-	$(RM) -r $(C1_DIR)
-	$(RM) -r $(C2_DIR)
-	$(RM) -r $(CORE_DIR)
-	$(RM) -r $(ZERO_DIR)
-	$(RM) -r $(SHARK_DIR)
-	$(RM) -r $(MINIMAL1_DIR)
-clean_export:
-	$(RM) -r $(EXPORT_PATH)
-clean_jdk:
-	$(RM) -r $(JDK_IMAGE_DIR)
-
-#
-# Create JDK and place this build into it
-#
-create_jdk: copy_jdk update_jdk
-
-update_jdk: export_product_jdk export_fastdebug_jdk test_jdk
-
-copy_jdk: $(JDK_IMAGE_DIR)/bin/java
-
-$(JDK_IMAGE_DIR)/bin/java:
-	$(RM) -r $(JDK_IMAGE_DIR)
-	$(MKDIR) -p $(JDK_IMAGE_DIR)
-	($(CD) $(JDK_IMPORT_PATH) && \
-	 $(TAR) -cf - *) | \
-	 ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -)
-
-
-# Testing the built JVM
-RUN_JVM=JAVA_HOME=$(JDK_IMPORT_PATH) $(JDK_IMPORT_PATH)/bin/java -d$(ARCH_DATA_MODEL) -XXaltjvm=$(ALTJVM_DIR) -Dsun.java.launcher.is_altjvm=true
-generic_test:
-	@$(ECHO) "Running with: $(ALTJVM_DIR)"
-	@$(RUN_JVM) -Xinternalversion
-	@$(RUN_JVM) -showversion -help
-
-# C2 test targets
-test_product test_optimized test_fastdebug test_debug:
-	@$(MAKE) generic_test ALTJVM_DIR="$(C2_DIR)/$(@:test_%=%)"
-
-# C1 test targets
-test_product1 test_optimized1 test_fastdebug1 test_debug1:
-  ifeq ($(ARCH_DATA_MODEL), 32)
-	@$(MAKE) generic_test ALTJVM_DIR="$(C1_DIR)/$(@:test_%1=%)"
-  else
-	@$(ECHO) "No compiler1 ($(@:test_%=%)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
-  endif
-
-# Zero test targets
-test_productzero test_optimizedzero test_fastdebugzero test_debugzero:
-	@$(MAKE) generic_test ALTJVM_DIR="$(ZERO_DIR)/$(@:test_%zero=%)"
-
-# Shark test targets
-test_productshark test_optimizedshark test_fastdebugshark test_debugshark:
-	@$(MAKE) generic_test ALTJVM_DIR="$(SHARK_DIR)/$(@:test_%shark=%)"
-
-# Minimal1 test targets
-test_productminimal1 test_optimizedminimal1 test_fastdebugminimal1 test_debugminimal1:
-	@$(MAKE) generic_test ALTJVM_DIR="$(MINIMAL1_DIR)/$(@:test_%minimal1=%)"
-
-
-test_jdk:
-  ifeq ($(JVM_VARIANT_CLIENT), true)
-	$(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -client -Xinternalversion
-	$(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -client -version
-  endif
-  ifeq ($(findstring true, $(JVM_VARIANT_SERVER)\
-		$(JVM_VARIANT_ZERO)$(JVM_VARIANT_ZEROSHARK)), true)
-	$(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -server -Xinternalversion
-	$(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -server -version
-  endif
-
-copy_product_jdk::
-	$(RM) -r $(JDK_IMAGE_DIR)
-	$(MKDIR) -p $(JDK_IMAGE_DIR)
-	($(CD) $(JDK_IMPORT_PATH) && \
-	 $(TAR) -cf - $(JDK_DIRS)) | \
-	 ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -)
-
-copy_fastdebug_jdk::
-	$(RM) -r $(JDK_IMAGE_DIR)/fastdebug
-	$(MKDIR) -p $(JDK_IMAGE_DIR)/fastdebug
-	if [ -d $(JDK_IMPORT_PATH)/fastdebug ] ; then \
-	  ($(CD) $(JDK_IMPORT_PATH)/fastdebug && \
-	   $(TAR) -cf - $(JDK_DIRS)) | \
-	   ($(CD) $(JDK_IMAGE_DIR)/fastdebug && $(TAR) -xf -) ; \
-	else \
-	  ($(CD) $(JDK_IMPORT_PATH) && \
-	   $(TAR) -cf - $(JDK_DIRS)) | \
-	   ($(CD) $(JDK_IMAGE_DIR)/fastdebug && $(TAR) -xf -) ; \
-	fi
-
-copy_debug_jdk::
-	$(RM) -r $(JDK_IMAGE_DIR)/debug
-	$(MKDIR) -p $(JDK_IMAGE_DIR)/debug
-	if [ -d $(JDK_IMPORT_PATH)/debug ] ; then \
-	  ($(CD) $(JDK_IMPORT_PATH)/debug && \
-	   $(TAR) -cf - $(JDK_DIRS)) | \
-	   ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
-	elif [ -d $(JDK_IMPORT_PATH)/fastdebug ] ; then \
-	  ($(CD) $(JDK_IMPORT_PATH)/fastdebug && \
-	   $(TAR) -cf - $(JDK_DIRS)) | \
-	   ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
-	else \
-	  ($(CD) $(JDK_IMPORT_PATH) && \
-	   $(TAR) -cf - $(JDK_DIRS)) | \
-	   ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
-	fi
-
-copy_optimized_jdk::
-	$(RM) -r $(JDK_IMAGE_DIR)/optimized
-	$(MKDIR) -p $(JDK_IMAGE_DIR)/optimized
-	if [ -d $(JDK_IMPORT_PATH)/optimized ] ; then \
-	  ($(CD) $(JDK_IMPORT_PATH)/optimized && \
-	   $(TAR) -cf - $(JDK_DIRS)) | \
-	   ($(CD) $(JDK_IMAGE_DIR)/optimized && $(TAR) -xf -) ; \
-	else \
-	  ($(CD) $(JDK_IMPORT_PATH) && \
-	   $(TAR) -cf - $(JDK_DIRS)) | \
-	   ($(CD) $(JDK_IMAGE_DIR)/optimized && $(TAR) -xf -) ; \
-	fi
-
-#
-# Check target
-#
-check: variable_check
-
-#
-# Help target
-#
-help: intro_help target_help variable_help notes_help examples_help
-
-# Intro help message
-intro_help:
-	@$(ECHO) \
-"Makefile for the Hotspot workspace."
-	@$(ECHO) \
-"Default behavior is to build and create an export area for the j2se builds."
-
-# Target help
-target_help:
-	@$(ECHO) "help:             This help message"
-	@$(ECHO) "all:              Same as: all_product all_fastdebug"
-	@$(ECHO) "world:            Same as: all create_jdk"
-	@$(ECHO) "all_product:      Same as: product product1 export_product"
-	@$(ECHO) "all_fastdebug:    Same as: fastdebug fastdebug1 export_fastdebug"
-	@$(ECHO) "all_debug:        Same as: debug debug1 export_debug"
-	@$(ECHO) "all_optimized:    Same as: optimized optimized1 export_optimized"
-	@$(ECHO) "clean:            Clean all areas"
-	@$(ECHO) "export_product:   Export product files to EXPORT_PATH"
-	@$(ECHO) "export_fastdebug: Export fastdebug files to EXPORT_PATH"
-	@$(ECHO) "export_debug:     Export debug files to EXPORT_PATH"
-	@$(ECHO) "export_optimized: Export optimized files to EXPORT_PATH"
-	@$(ECHO) "create_jdk:       Create JDK image, export all files into it"
-	@$(ECHO) "update_jdk:       Update JDK image with fresh exported files"
-	@$(ECHO) " "
-	@$(ECHO) "Other targets are:"
-	@$(ECHO) "   $(C1_VM_TARGETS)"
-	@$(ECHO) "   $(C2_VM_TARGETS)"
-	@$(ECHO) "   $(MINIMAL1_VM_TARGETS)"
-
-# Variable help (only common ones used by this workspace)
-variable_help: variable_help_intro variable_list variable_help_end
-variable_help_intro:
-	@$(ECHO) "--- Common Variables ---"
-variable_help_end:
-	@$(ECHO) " "
-	@$(ECHO) "--- Make Arguments ---"
-	@$(ECHO) "MAKE_ARGS=$(MAKE_ARGS)"
-
-# One line descriptions for the variables
-SLASH_JAVA.desc            = Root of all build tools, e.g. /java or J:
-OUTPUTDIR.desc             = Output directory, default is build/<osname>
-BOOTDIR.desc               = JDK used to compile agent java source and test with
-JDK_IMPORT_PATH.desc       = Promoted JDK to copy for 'create_jdk'
-JDK_IMAGE_DIR.desc         = Directory to place JDK to copy
-EXPORT_PATH.desc           = Directory to place files to export for JDK build
-
-# Make variables to print out (description and value)
-VARIABLE_PRINTVAL_LIST +=       \
-    SLASH_JAVA                  \
-    OUTPUTDIR                   \
-    BOOTDIR                     \
-    JDK_IMPORT_PATH             \
-    JDK_IMAGE_DIR               \
-    EXPORT_PATH
-
-# Make variables that should refer to directories that exist
-VARIABLE_CHECKDIR_LIST +=       \
-    SLASH_JAVA                  \
-    BOOTDIR                     \
-    JDK_IMPORT_PATH
-
-# For pattern rules below, so all are treated the same
-DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval)
-DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir)
-
-# Complete variable check
-variable_check: $(DO_CHECKDIR_LIST)
-variable_list: $(DO_PRINTVAL_LIST) variable_check
-
-# Pattern rule for printing out a variable
-%.printval:
-	@$(ECHO) "  ALT_$* - $($*.desc)"
-	@$(ECHO) "        $*=$($*)"
-
-# Pattern rule for checking to see if a variable with a directory exists
-%.checkdir:
-	@if [ ! -d $($*) ] ; then \
-	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
-	fi
-
-# Pattern rule for checking to see if a variable with a file exists
-%.checkfil:
-	@if [ ! -f $($*) ] ; then \
-	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
-	fi
-
-# Misc notes on help
-notes_help:
-	@$(ECHO) \
-"--- Notes --- "
-	@$(ECHO) \
-"- JDK_IMPORT_PATH must refer to a compatible build, not all past promoted"
-	@$(ECHO) \
-"        builds or previous release JDK builds will work."
-	@$(ECHO) \
-"- The fastest builds have been when the workspace and the BOOTDIR are on"
-	@$(ECHO) \
-"        local disk."
-
-examples_help:
-	@$(ECHO) \
-"--- Examples --- "
-	@$(ECHO) \
-"  $(MAKE) all"
-	@$(ECHO) \
-"  $(MAKE) world"
-	@$(ECHO) \
-"  $(MAKE) ALT_BOOTDIR=/opt/java/jdk$(JDK_PREVIOUS_VERSION)"
-	@$(ECHO) \
-"  $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk$(VERSION_STRING)"
-
-# Universal build support
-ifeq ($(OS_VENDOR), Darwin)
-ifeq ($(MACOSX_UNIVERSAL),true)
-include $(GAMMADIR)/make/$(OSNAME)/makefiles/universal.gmk
-endif
-endif
-
-# Compatibility for transition to new naming
-warn_jvmg_deprecated:
-	echo "Warning: The jvmg target has been replaced with debug"
-	echo "Warning: Please update your usage"
-
-jvmg: warn_jvmg_deprecated debug
-
-jvmg1: warn_jvmg_deprecated debug1
-
-jvmgminimal1: warn_jvmg_deprecated debugminimal1
-
-jvmgcore: warn_jvmg_deprecated debugcore
-
-jvmgzero: warn_jvmg_deprecated debugzero
-
-jvmgshark: warn_jvmg_deprecated debugshark
-
-# JPRT rule to build this workspace
-include $(GAMMADIR)/make/jprt.gmk
-
-.PHONY: all world clobber clean help $(C1_VM_TARGETS) $(C2_VM_TARGETS) \
-        $(MINIMAL1_VM_TARGETS) \
-	generic_build1 generic_build2 generic_buildminimal1 generic_export \
-	export_product export_fastdebug export_debug export_optimized \
-	export_jdk_product export_jdk_fastdebug export_jdk_debug \
-	create_jdk copy_jdk update_jdk test_jdk \
-	copy_product_jdk copy_fastdebug_jdk copy_debug_jdk  \
-	$(HS_ALT_MAKE)/Makefile.make remove_old_debuginfo
-
-.NOTPARALLEL:
diff --git a/hotspot/make/aix/Makefile b/hotspot/make/aix/Makefile
deleted file mode 100644
index 951a985..0000000
--- a/hotspot/make/aix/Makefile
+++ /dev/null
@@ -1,369 +0,0 @@
-#
-# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2015 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile creates a build tree and lights off a build.
-# You can go back into the build tree and perform rebuilds or
-# incremental builds as desired. Be sure to reestablish
-# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME.
-
-# The make process now relies on java and javac. These can be
-# specified either implicitly on the PATH, by setting the
-# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a
-# JDK in which bin/java and bin/javac are present and working (e.g.,
-# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited)
-# default BOOTDIR path value. Note that one of ALT_BOOTDIR
-# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc.
-# from the PATH.
-#
-# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on
-# an architecture that differs from the target architecture, as long
-# as the bootstrap jdk runs under the same flavor of OS as the target
-# (i.e., if the target is linux, point to a jdk that runs on a linux
-# box).  In order to use such a bootstrap jdk, set the make variable
-# REMOTE to the desired remote command mechanism, e.g.,
-#
-#    make REMOTE="rsh -l me myotherlinuxbox"
-
-# No tests on Aix.
-TEST_IN_BUILD=false
-
-ifeq ($(GAMMADIR),)
-include ../../make/defs.make
-else
-include $(GAMMADIR)/make/defs.make
-endif
-include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make
-
-ifndef CC_INTERP
-  ifndef FORCE_TIERED
-    FORCE_TIERED=1
-  endif
-endif
-
-ifdef LP64
-  ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
-    _JUNK_ := $(shell echo >&2 \
-       $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!")
-	@exit 1
-  endif
-endif
-
-# we need to set up LP64 correctly to satisfy sanity checks in adlc
-ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
-  MFLAGS += " LP64=1 "
-endif
-
-# pass USE_SUNCC further, through MFLAGS
-ifdef USE_SUNCC
-  MFLAGS += " USE_SUNCC=1 "
-endif
-
-# The following renders pathnames in generated Makefiles valid on
-# machines other than the machine containing the build tree.
-#
-# For example, let's say my build tree lives on /files12 on
-# exact.east.sun.com.  This logic will cause GAMMADIR to begin with
-# /net/exact/files12/...
-#
-# We only do this on SunOS variants, for a couple of reasons:
-#  * It is extremely rare that source trees exist on other systems
-#  * It has been claimed that the Linux automounter is flakey, so
-#    changing GAMMADIR in a way that exercises the automounter could
-#    prove to be a source of unreliability in the build process.
-# Obviously, this Makefile is only relevant on SunOS boxes to begin
-# with, but the SunOS conditionalization will make it easier to
-# combine Makefiles in the future (assuming we ever do that).
-
-ifeq ($(OSNAME),solaris)
-
-  #   prepend current directory to relative pathnames.
-  NEW_GAMMADIR :=                                    \
-    $(shell echo $(GAMMADIR) |                       \
-      sed -e "s=^\([^/].*\)=$(shell pwd)/\1="        \
-     )
-  unexport NEW_GAMMADIR
-
-  # If NEW_GAMMADIR doesn't already start with "/net/":
-  ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),)
-    #   prepend /net/$(HOST)
-    #   remove /net/$(HOST) if name already began with /home/
-    #   remove /net/$(HOST) if name already began with /java/
-    #   remove /net/$(HOST) if name already began with /lab/
-    NEW_GAMMADIR :=                                     \
-         $(shell echo $(NEW_GAMMADIR) |                 \
-                 sed -e "s=^\(.*\)=/net/$(HOST)\1="     \
-                     -e "s=^/net/$(HOST)/home/=/home/=" \
-                     -e "s=^/net/$(HOST)/java/=/java/=" \
-                     -e "s=^/net/$(HOST)/lab/=/lab/="   \
-          )
-    # Don't use the new value for GAMMADIR unless a file with the new
-    # name actually exists.
-    ifneq ($(wildcard $(NEW_GAMMADIR)),)
-      GAMMADIR := $(NEW_GAMMADIR)
-    endif
-  endif
-
-endif
-
-# BUILDARCH is set to "zero" for Zero builds.  VARIANTARCH
-# is used to give the build directories meaningful names.
-VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH))
-
-# There is a (semi-) regular correspondence between make targets and actions:
-#
-#       Target          Tree Type       Build Dir
-#
-#       debug           compiler2       <os>_<arch>_compiler2/debug
-#       fastdebug       compiler2       <os>_<arch>_compiler2/fastdebug
-#       optimized       compiler2       <os>_<arch>_compiler2/optimized
-#       product         compiler2       <os>_<arch>_compiler2/product
-#
-#       debug1          compiler1       <os>_<arch>_compiler1/debug
-#       fastdebug1      compiler1       <os>_<arch>_compiler1/fastdebug
-#       optimized1      compiler1       <os>_<arch>_compiler1/optimized
-#       product1        compiler1       <os>_<arch>_compiler1/product
-#
-#       debugcore       core            <os>_<arch>_core/debug
-#       fastdebugcore   core            <os>_<arch>_core/fastdebug
-#       optimizedcore   core            <os>_<arch>_core/optimized
-#       productcore     core            <os>_<arch>_core/product
-#
-#       debugzero       zero            <os>_<arch>_zero/debug
-#       fastdebugzero   zero            <os>_<arch>_zero/fastdebug
-#       optimizedzero   zero            <os>_<arch>_zero/optimized
-#       productzero     zero            <os>_<arch>_zero/product
-#
-#       debugshark      shark           <os>_<arch>_shark/debug
-#       fastdebugshark  shark           <os>_<arch>_shark/fastdebug
-#       optimizedshark  shark           <os>_<arch>_shark/optimized
-#       productshark    shark           <os>_<arch>_shark/product
-#
-#       fastdebugminimal1 minimal1      <os>_<arch>_minimal1/fastdebug
-#       productminimal1   minimal1      <os>_<arch>_minimal1/product
-#
-# What you get with each target:
-#
-# debug*     - debug compile with asserts enabled
-# fastdebug* - optimized compile, but with asserts enabled
-# optimized* - optimized compile, no asserts
-# product*   - the shippable thing:  optimized compile, no asserts, -DPRODUCT
-
-# This target list needs to be coordinated with the usage message
-# in the build.sh script:
-TARGETS           = debug fastdebug optimized product
-
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  SUBDIR_DOCS     = $(OSNAME)_$(VARIANTARCH)_docs
-else
-  SUBDIR_DOCS     = $(OSNAME)_$(BUILDARCH)_docs
-endif
-SUBDIRS_C1        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS))
-SUBDIRS_C2        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS))
-SUBDIRS_TIERED    = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS))
-SUBDIRS_CORE      = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS))
-SUBDIRS_ZERO      = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS))
-SUBDIRS_SHARK     = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS))
-SUBDIRS_MINIMAL1  = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS))
-
-TARGETS_C2        = $(TARGETS)
-TARGETS_C1        = $(addsuffix 1,$(TARGETS))
-TARGETS_TIERED    = $(addsuffix tiered,$(TARGETS))
-TARGETS_CORE      = $(addsuffix core,$(TARGETS))
-TARGETS_ZERO      = $(addsuffix zero,$(TARGETS))
-TARGETS_SHARK     = $(addsuffix shark,$(TARGETS))
-TARGETS_MINIMAL1 =  $(addsuffix minimal1,$(TARGETS))
-
-BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
-BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
-BUILDTREE_VARS   += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-BUILDTREE_VARS   += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE)
-
-BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
-
-#-------------------------------------------------------------------------------
-
-# Could make everything by default, but that would take a while.
-all:
-	@echo "Try '$(MAKE) <target> ...'  where <target> is one or more of"
-	@echo "  $(TARGETS_C2)"
-	@echo "  $(TARGETS_C1)"
-	@echo "  $(TARGETS_CORE)"
-	@echo "  $(TARGETS_ZERO)"
-	@echo "  $(TARGETS_SHARK)"
-	@echo "  $(TARGETS_MINIMAL1)"
-
-checks: check_os_version check_j2se_version
-
-# We do not want people accidentally building on old systems (e.g. Linux 2.2.x,
-# Solaris 2.5.1, 2.6).
-# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.
-
-SUPPORTED_OS_VERSION = AIX
-OS_VERSION := $(shell uname -a)
-EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
-
-check_os_version:
-ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
-	$(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
-endif
-
-# jvmti.make requires XSLT (J2SE 1.4.x or newer):
-XSLT_CHECK	= $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
-# If not found then fail fast.
-check_j2se_version:
-	$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
-	  $(REMOTE) $(RUN.JAVA) -version; \
-	  echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
-	  "to bootstrap this build" 1>&2; \
-	  exit 1; \
-	fi
-
-$(SUBDIRS_TIERED): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered
-
-$(SUBDIRS_C2): $(BUILDTREE_MAKE)
-ifeq ($(FORCE_TIERED),1)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1
-else
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler2
-endif
-
-$(SUBDIRS_C1): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler1
-
-$(SUBDIRS_CORE): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=core
-
-$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH)
-
-$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH)
-
-$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=minimal1
-
-
-platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
-	$(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@
-
-# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME
-
-$(TARGETS_C2):  $(SUBDIRS_C2)
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_TIERED):  $(SUBDIRS_TIERED)
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_C1):  $(SUBDIRS_C1)
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_CORE):  $(SUBDIRS_CORE)
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_ZERO):  $(SUBDIRS_ZERO)
-	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_SHARK):  $(SUBDIRS_SHARK)
-	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_MINIMAL1):  $(SUBDIRS_MINIMAL1)
-	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-# Just build the tree, and nothing else:
-tree:      $(SUBDIRS_C2)
-tree1:     $(SUBDIRS_C1)
-treecore:  $(SUBDIRS_CORE)
-treezero:  $(SUBDIRS_ZERO)
-treeshark: $(SUBDIRS_SHARK)
-treeminimal1: $(SUBDIRS_MINIMAL1)
-
-# Doc target.  This is the same for all build options.
-#     Hence create a docs directory beside ...$(ARCH)_[...]
-# We specify 'BUILD_FLAVOR=product' so that the proper
-# ENABLE_FULL_DEBUG_SYMBOLS value is used.
-docs: checks
-	$(QUIETLY) mkdir -p $(SUBDIR_DOCS)
-	$(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs
-
-# Synonyms for win32-like targets.
-compiler2:  debug product
-
-compiler1:  debug1 product1
-
-core: debugcore productcore
-
-zero: debugzero productzero
-
-shark: debugshark productshark
-
-clean_docs:
-	rm -rf $(SUBDIR_DOCS)
-
-clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1:
-	rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@)
-
-clean:  clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs
-
-include $(GAMMADIR)/make/cscope.make
-
-#-------------------------------------------------------------------------------
-
-.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1)
-.PHONY: tree tree1 treecore treezero treeshark
-.PHONY: all compiler1 compiler2 core zero shark
-.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs
-.PHONY: checks check_os_version check_j2se_version
-
-.NOTPARALLEL:
diff --git a/hotspot/make/aix/adlc_updater b/hotspot/make/aix/adlc_updater
deleted file mode 100644
index 99e04e3..0000000
--- a/hotspot/make/aix/adlc_updater
+++ /dev/null
@@ -1,23 +0,0 @@
-#! /bin/sh
-#
-# This file is used by adlc.make to selectively update generated
-# adlc files. Because source and target diretories are relative
-# paths, this file is copied to the target build directory before
-# use.
-#
-# adlc-updater <file> <source-dir> <target-dir>
-#
-fix_lines() {
-  # repair bare #line directives in $1 to refer to $2
-  # and add an override of __FILE__ with just the basename on the
-  # first line of the file.
-  awk < $1 > $1+ -v F2=$2 '
-    BEGIN { print "#line 1 \"" F2 "\""; }
-    /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next}
-    {print}
-  '
-  mv $1+ $1
-}
-fix_lines $2/$1 $1
-[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \
-( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 )
diff --git a/hotspot/make/aix/makefiles/adjust-mflags.sh b/hotspot/make/aix/makefiles/adjust-mflags.sh
deleted file mode 100644
index 6c06819..0000000
--- a/hotspot/make/aix/makefiles/adjust-mflags.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This script is used only from top.make.
-# The macro $(MFLAGS-adjusted) calls this script to
-# adjust the "-j" arguments to take into account
-# the HOTSPOT_BUILD_JOBS variable.  The default
-# handling of the "-j" argument by gnumake does
-# not meet our needs, so we must adjust it ourselves.
-
-# This argument adjustment applies to two recursive
-# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make.
-# One invokes adlc.make, and the other invokes vm.make.
-# The adjustment propagates the desired concurrency
-# level down to the sub-make (of the adlc or vm).
-# The default behavior of gnumake is to run all
-# sub-makes without concurrency ("-j1").
-
-# Also, we use a make variable rather than an explicit
-# "-j<N>" argument to control this setting, so that
-# the concurrency setting (which must be tuned separately
-# for each MP system) can be set via an environment variable.
-# The recommended setting is 1.5x to 2x the number of available
-# CPUs on the MP system, which is large enough to keep the CPUs
-# busy (even though some jobs may be I/O bound) but not too large,
-# we may presume, to overflow the system's swap space.
-
-set -eu
-
-default_build_jobs=4
-
-case $# in
-[12])	true;;
-*)	>&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;;
-esac
-
-MFLAGS=$1
-HOTSPOT_BUILD_JOBS=${2-}
-
-# Normalize any -jN argument to the form " -j${HBJ}"
-MFLAGS=`
-	echo "$MFLAGS" \
-	| sed '
-		s/^-/ -/
-		s/ -\([^ 	I][^ 	I]*\)j/ -\1 -j/
-		s/ -j[0-9][0-9]*/ -j/
-		s/ -j\([^ 	]\)/ -j -\1/
-		s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/
-	' `
-
-case ${HOTSPOT_BUILD_JOBS} in \
-
-'') case ${MFLAGS} in
-    *\ -j*)
-	>&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." 
-	>&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment."
-    esac;;
-
-?*) case ${MFLAGS} in
-     *\ -j*) true;;
-     *)      MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";;
-    esac;;
-esac
-
-echo "${MFLAGS}"
diff --git a/hotspot/make/aix/makefiles/adlc.make b/hotspot/make/aix/makefiles/adlc.make
deleted file mode 100644
index 63dc981..0000000
--- a/hotspot/make/aix/makefiles/adlc.make
+++ /dev/null
@@ -1,225 +0,0 @@
-#
-# 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This makefile (adlc.make) is included from the adlc.make in the
-# build directories.
-# It knows how to compile, link, and run the adlc.
-
-include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
-
-# #########################################################################
-
-# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
-GENERATED = ../generated
-OUTDIR  = $(GENERATED)/adfiles
-
-ARCH = $(Platform_arch)
-OS = $(Platform_os_family)
-
-SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
-
-ifeq ("${Platform_arch_model}", "${Platform_arch}")
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 
-else
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 
-endif
-
-EXEC = $(OUTDIR)/adlc
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor
-Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED)
-INCLUDES += $(Src_Dirs_I:%=-I%)
-
-# set flags for adlc compilation
-CXXFLAGS = $(SYSDEFS) $(INCLUDES)
-
-# Force assertions on.
-CXXFLAGS += -DASSERT
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-# Suppress warnings (for now)
-CFLAGS_WARN = -w
-CFLAGS += $(CFLAGS_WARN)
-
-OBJECTNAMES = \
-	adlparse.o \
-	archDesc.o \
-	arena.o \
-	dfa.o \
-	dict2.o \
-	filebuff.o \
-	forms.o \
-	formsopt.o \
-	formssel.o \
-	main.o \
-	adlc-opcodes.o \
-	output_c.o \
-	output_h.o \
-
-OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)
-
-GENERATEDNAMES = \
-        ad_$(Platform_arch_model).cpp \
-        ad_$(Platform_arch_model).hpp \
-        ad_$(Platform_arch_model)_clone.cpp \
-        ad_$(Platform_arch_model)_expand.cpp \
-        ad_$(Platform_arch_model)_format.cpp \
-        ad_$(Platform_arch_model)_gen.cpp \
-        ad_$(Platform_arch_model)_misc.cpp \
-        ad_$(Platform_arch_model)_peephole.cpp \
-        ad_$(Platform_arch_model)_pipeline.cpp \
-        adGlobals_$(Platform_arch_model).hpp \
-        dfa_$(Platform_arch_model).cpp \
-
-GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)
-
-# #########################################################################
-
-all: $(EXEC)
-
-$(EXEC) : $(OBJECTS)
-	@echo $(LOG_INFO) Making adlc
-	$(QUIETLY) $(HOST.LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS)
-
-# Random dependencies:
-$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
-
-# The source files refer to ostream.h, which sparcworks calls iostream.h
-$(OBJECTS): ostream.h
-
-ostream.h :
-	@echo >$@ '#include <iostream.h>'
-
-dump:
-	: OUTDIR=$(OUTDIR)
-	: OBJECTS=$(OBJECTS)
-	: products = $(GENERATEDFILES)
-
-all: $(GENERATEDFILES)
-
-$(GENERATEDFILES): refresh_adfiles
-
-# Get a unique temporary directory name, so multiple makes can run in parallel.
-# Note that product files are updated via "mv", which is atomic.
-TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)
-
-# Debuggable by default
-CFLAGS += -g
-
-# Pass -D flags into ADLC.
-ADLCFLAGS += $(SYSDEFS)
-
-# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
-ADLCFLAGS += -q -T
-
-ADLCFLAGS += -g
-
-ifdef LP64
-ADLCFLAGS += -D_LP64
-else
-ADLCFLAGS += -U_LP64
-endif
-
-#
-# adlc_updater is a simple sh script, under sccs control. It is
-# used to selectively update generated adlc files. This should
-# provide a nice compilation speed improvement.
-#
-ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
-ADLC_UPDATER = adlc_updater
-$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
-	$(QUIETLY) cp $< $@; chmod +x $@
-
-# This action refreshes all generated adlc files simultaneously.
-# The way it works is this:
-# 1) create a scratch directory to work in.
-# 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
-# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
-# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
-# 5) If we actually updated any files, echo a notice.
-#
-refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
-	@rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
-	$(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
-            -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \
-	    || { rm -rf $(TEMPDIR); exit 1; }
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
-		|| echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes."
-	$(QUIETLY) rm -rf $(TEMPDIR)
-
-
-# #########################################################################
-
-$(SOURCE.AD): $(SOURCES.AD)
-	$(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)
-
-#PROCESS_AD_FILES = cat
-# Pass through #line directives, in case user enables -g option above:
-PROCESS_AD_FILES = awk '{ \
-    if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
-    if (need_lineno && $$0 !~ /\/\//) \
-      { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
-    print }'
-
-$(OUTDIR)/%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
-
-# Some object files are given a prefix, to disambiguate
-# them from objects of the same name built for the VM.
-$(OUTDIR)/adlc-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
-
-# #########################################################################
-
-clean:
-	rm $(OBJECTS)
-
-cleanall:
-	rm $(OBJECTS) $(EXEC)
-
-# #########################################################################
-
-.PHONY: all dump refresh_adfiles clean cleanall
diff --git a/hotspot/make/aix/makefiles/build_vm_def.sh b/hotspot/make/aix/makefiles/build_vm_def.sh
deleted file mode 100644
index 8d8e8fd..0000000
--- a/hotspot/make/aix/makefiles/build_vm_def.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# If we're cross compiling use that path for nm
-if [ "$CROSS_COMPILE_ARCH" != "" ]; then 
-NM=$ALT_COMPILER_PATH/nm
-else
-# On AIX we have to prevent that we pick up the 'nm' version from the GNU binutils
-# which may be installed under /opt/freeware/bin. So better use an absolute path here! 
-NM=/usr/bin/nm
-fi
-
-$NM -X64 -B -C $* \
-    | awk '{
-              if (($2="d" || $2="D") && ($3 ~ /^__vft/ || $3 ~ /^gHotSpotVM/)) print "\t" $3 ";"
-              if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";"
-              if ($3 ~ /^SharedArchivePath__9Arguments$/) print "\t" $3 ";"
-          }' \
-    | sort -u
diff --git a/hotspot/make/aix/makefiles/buildtree.make b/hotspot/make/aix/makefiles/buildtree.make
deleted file mode 100644
index 94b71eb..0000000
--- a/hotspot/make/aix/makefiles/buildtree.make
+++ /dev/null
@@ -1,351 +0,0 @@
-#
-# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Usage:
-#
-# $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch
-#         GAMMADIR=dir OS_FAMILY=os VARIANT=variant
-#
-# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the
-# environment or on the command-line:
-#
-# ARCH		- sparc, i486, ... HotSpot cpu and os_cpu source directory
-# BUILDARCH     - build directory
-# LIBARCH       - the corresponding directory in JDK/JRE
-# GAMMADIR	- top of workspace
-# OS_FAMILY	- operating system
-# VARIANT	- core, compiler1, compiler2, or tiered
-# VERSION_STRING - the JDK version string as specified by JEP-223
-# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build
-#
-# Builds the directory trees with makefiles plus some convenience files in
-# each directory:
-#
-# Makefile	- for "make foo"
-# flags.make	- with macro settings
-# vm.make	- to support making "$(MAKE) -v vm.make" in makefiles
-# adlc.make	-
-# trace.make	- generate tracing event and type definitions
-# jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
-#
-# The makefiles are split this way so that "make foo" will run faster by not
-# having to read the dependency files for the vm.
-
--include $(SPEC)
-include $(GAMMADIR)/make/scm.make
-include $(GAMMADIR)/make/defs.make
-include $(GAMMADIR)/make/altsrc.make
-
-
-# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)	= @
-
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
-else
-  ifdef USE_SUNCC
-    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc
-  else
-    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
-  endif
-endif
-
-# Allow overriding of the arch part of the directory but default
-# to BUILDARCH if nothing is specified
-ifeq ($(VARIANTARCH),)
-  VARIANTARCH=$(BUILDARCH)
-endif
-
-ifdef FORCE_TIERED
-ifeq		($(VARIANT),tiered)
-PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_compiler2
-else
-PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
-endif
-else
-PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
-endif
-
-#
-# We do two levels of exclusion in the shared directory.
-# TOPLEVEL excludes are pruned, they are not recursively searched,
-# but lower level directories can be named without fear of collision.
-# ALWAYS excludes are excluded at any level in the directory tree.
-#
-
-ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
-
-ifeq		($(VARIANT),tiered)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
-else
-ifeq		($(VARIANT),compiler2)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
-else
-# compiler1 and core use the same exclude list
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
-endif
-endif
-
-# Get things from the platform file.
-COMPILER	= $(shell sed -n 's/^compiler[ 	]*=[ 	]*//p' $(PLATFORM_FILE))
-
-SIMPLE_DIRS	= \
-	$(PLATFORM_DIR)/generated/dependencies \
-	$(PLATFORM_DIR)/generated/adfiles \
-	$(PLATFORM_DIR)/generated/jvmtifiles \
-	$(PLATFORM_DIR)/generated/tracefiles
-
-TARGETS      = debug fastdebug optimized product
-SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
-
-# For dependencies and recursive makes.
-BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
-
-BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make
-
-BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
-	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
-
-# Define variables to be set in flags.make.
-# Default values are set in make/defs.make.
-
-# Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
-endif
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell whoami)
-endif
-# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
-# or make/hotspot_distro.
-ifndef HOTSPOT_VM_DISTRO
-  ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    include $(GAMMADIR)/make/hotspot_distro
-  else
-    include $(GAMMADIR)/make/openjdk_distro
-  endif
-endif
-
-# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
-ifndef OPENJDK
-  ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    OPENJDK=true
-  endif
-endif
-
-BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-
-BUILDTREE	= \
-	$(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
-
-BUILDTREE_COMMENT	= echo "\# Generated by $(BUILDTREE_MAKE)"
-
-all:  $(SUBMAKE_DIRS)
-
-# Run make in each subdirectory recursively.
-$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
-	$(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
-	+$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
-	$(QUIETLY) touch $@
-
-$(SIMPLE_DIRS):
-	$(QUIETLY) mkdir -p $@
-
-# Convenience macro which takes a source relative path, applies $(1) to the
-# absolute path, and then replaces $(GAMMADIR) in the result with a
-# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.
-gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
-
-# This bit is needed to enable local rebuilds.
-# Unless the makefile itself sets LP64, any environmental
-# setting of LP64 will interfere with the build.
-LP64_SETTING/32 = LP64 = \#empty
-LP64_SETTING/64 = LP64 = 1
-
-DATA_MODE/ppc64 = 64
-
-DATA_MODE = $(DATA_MODE/$(BUILDARCH))
-
-flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
-	sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
-	echo; \
-	echo "GAMMADIR = $(GAMMADIR)"; \
-	echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
-	echo "OSNAME = $(OSNAME)"; \
-	echo "SYSDEFS = \$$(Platform_sysdefs)"; \
-	echo "SRCARCH = $(SRCARCH)"; \
-	echo "BUILDARCH = $(BUILDARCH)"; \
-	echo "LIBARCH = $(LIBARCH)"; \
-	echo "TARGET = $(TARGET)"; \
-	echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \
-	echo "VERSION_STRING = $(VERSION_STRING)"; \
-	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
-	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
-	echo "OPENJDK = $(OPENJDK)"; \
-	echo "$(LP64_SETTING/$(DATA_MODE))"; \
-	echo; \
-	echo "# Used for platform dispatching"; \
-	echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
-	echo "CFLAGS += \$$(TARGET_DEFINES)"; \
-	echo; \
-	echo "Src_Dirs_V = \\"; \
-	sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
-	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	echo; \
-	echo "Src_Dirs_I = \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	[ -n "$(CFLAGS_BROWSE)" ] && \
-	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
-	[ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
-	    echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
-	[ -n "$(OBJCOPY)" ] && \
-	    echo && echo "OBJCOPY = $(OBJCOPY)"; \
-	[ -n "$(STRIP_POLICY)" ] && \
-	    echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
-	[ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
-	    echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
-	[ -n "$(ZIPEXE)" ] && \
-	    echo && echo "ZIPEXE = $(ZIPEXE)"; \
-	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
-	    echo && \
-	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
-	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
-	[ -n "$(INCLUDE_TRACE)" ] && \
-	    echo && echo "INCLUDE_TRACE = $(INCLUDE_TRACE)"; \
-	echo; \
-	[ -n "$(SPEC)" ] && \
-	    echo "include $(SPEC)"; \
-	echo "CP ?= cp"; \
-	echo "MV ?= mv"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
-	echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
-	) > $@
-
-flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
-	) > $@
-
-../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
-	@echo $(LOG_INFO) Creating directory list $@
-	$(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
-          find $(HS_ALT_SRC)/share/vm/* -prune \
-	  -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-          \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
-        fi;
-	$(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
-	-type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
-
-Makefile: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
-	) > $@
-
-vm.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo include flags_vm.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-adlc.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-jvmti.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-trace.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-FORCE:
-
-.PHONY:  all FORCE
-
-.NOTPARALLEL:
diff --git a/hotspot/make/aix/makefiles/compiler2.make b/hotspot/make/aix/makefiles/compiler2.make
deleted file mode 100644
index 1398630..0000000
--- a/hotspot/make/aix/makefiles/compiler2.make
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making server version of VM
-
-TYPE=COMPILER2
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2
diff --git a/hotspot/make/aix/makefiles/core.make b/hotspot/make/aix/makefiles/core.make
deleted file mode 100644
index 56d85c8..0000000
--- a/hotspot/make/aix/makefiles/core.make
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making core version of VM
-
-# Select which files to use (in top.make)
-TYPE=CORE
-
-# There is no "core" directory in JDK. Install core build in server directory.
-VM_SUBDIR = server
-
-# Note:  macros.hpp defines CORE
diff --git a/hotspot/make/aix/makefiles/debug.make b/hotspot/make/aix/makefiles/debug.make
deleted file mode 100644
index 1a1c4eb..0000000
--- a/hotspot/make/aix/makefiles/debug.make
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS)
-DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
-CFLAGS += $(DEBUG_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/aix/makefiles/mapfile-vers-debug
-
-VERSION = debug
-SYSDEFS += -DASSERT -DDEBUG
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/aix/makefiles/defs.make b/hotspot/make/aix/makefiles/defs.make
deleted file mode 100644
index b9c54e3..0000000
--- a/hotspot/make/aix/makefiles/defs.make
+++ /dev/null
@@ -1,204 +0,0 @@
-#
-# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# The common definitions for hotspot AIX builds.
-# Include the top level defs.make under make directory instead of this one.
-# This file is included into make/defs.make.
-
-SLASH_JAVA ?= /java
-
-define print_info
-  ifneq ($$(LOG_LEVEL), warn)
-    $$(shell echo >&2 "INFO: $1")
-  endif
-endef
-
-# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name
-#ARCH:=$(shell uname -m)
-PATH_SEP = :
-ifeq ($(LP64), 1)
-  ARCH_DATA_MODEL ?= 64
-else
-  ARCH_DATA_MODEL ?= 32
-endif
-
-ifeq ($(ARCH_DATA_MODEL), 64)
-  ARCH = ppc64
-else
-  ARCH = ppc
-endif
-
-# PPC
-ifeq ($(ARCH), ppc)
-  #ARCH_DATA_MODEL = 32
-  PLATFORM         = aix-ppc
-  VM_PLATFORM      = aix_ppc
-  HS_ARCH          = ppc
-endif
-
-# PPC64
-ifeq ($(ARCH), ppc64)
-  #ARCH_DATA_MODEL = 64
-  MAKE_ARGS       += LP64=1
-  PLATFORM         = aix-ppc64
-  VM_PLATFORM      = aix_ppc64
-  HS_ARCH          = ppc
-endif
-
-# On 32 bit aix we build server and client, on 64 bit just server.
-ifeq ($(JVM_VARIANTS),)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    JVM_VARIANTS:=client,server
-    JVM_VARIANT_CLIENT:=true
-    JVM_VARIANT_SERVER:=true
-  else
-    JVM_VARIANTS:=server
-    JVM_VARIANT_SERVER:=true
-  endif
-endif
-
-# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product
-# builds is enabled with debug info files ZIP'ed to save space. For
-# BUILD_FLAVOR != product builds, FDS is always enabled, after all a
-# debug build without debug info isn't very useful.
-# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled.
-#
-# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
-# disabled for a BUILD_FLAVOR == product build.
-#
-# Note: Use of a different variable name for the FDS override option
-# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
-# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
-# in options via environment variables, use of distinct variables
-# prevents strange behaviours. For example, in a BUILD_FLAVOR !=
-# product build, the FULL_DEBUG_SYMBOLS environment variable will be
-# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If
-# the same variable name is used, then different values can be picked
-# up by different parts of the build. Just to be clear, we only need
-# two variable names because the incoming option value can be
-# overridden in some situations, e.g., a BUILD_FLAVOR != product
-# build.
-
-# Due to the multiple sub-make processes that occur this logic gets
-# executed multiple times. We reduce the noise by at least checking that
-# BUILD_FLAVOR has been set.
-ifneq ($(BUILD_FLAVOR),)
-  ifeq ($(BUILD_FLAVOR), product)
-    FULL_DEBUG_SYMBOLS ?= 1
-    ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
-  else
-    # debug variants always get Full Debug Symbols (if available)
-    ENABLE_FULL_DEBUG_SYMBOLS = 1
-  endif
-  $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-  # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    # Default OBJCOPY comes from GNU Binutils on Linux
-    ifeq ($(CROSS_COMPILE_ARCH),)
-      DEF_OBJCOPY=/usr/bin/objcopy
-    else
-      # Assume objcopy is part of the cross-compilation toolset
-      ifneq ($(ALT_COMPILER_PATH),)
-        DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy
-      endif
-    endif
-    OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
-    ifneq ($(ALT_OBJCOPY),)
-      $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)"))
-      OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
-    endif
-
-    ifeq ($(OBJCOPY),)
-      $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files. You may need to set ALT_OBJCOPY."))
-      ENABLE_FULL_DEBUG_SYMBOLS=0
-      $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-    else
-      $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo files."))
-
-      # Library stripping policies for .debuginfo configs:
-      #   all_strip - strips everything from the library
-      #   min_strip - strips most stuff from the library; leaves minimum symbols
-      #   no_strip  - does not strip the library at all
-      #
-      # Oracle security policy requires "all_strip". A waiver was granted on
-      # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
-      #
-      # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled.
-      #
-      STRIP_POLICY ?= min_strip
-
-      $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)"))
-
-      ZIP_DEBUGINFO_FILES ?= 1
-
-      $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)"))
-    endif
-  endif # ENABLE_FULL_DEBUG_SYMBOLS=1
-endif # BUILD_FLAVOR
-
-# unused JDK_INCLUDE_SUBDIR=aix
-
-# Library suffix
-LIBRARY_SUFFIX=so
-
-EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
-
-# client and server subdirectories have symbolic links to ../libjsig.so
-EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
-#ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-#  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-#    EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz
-#  else
-#    EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo
-#  endif
-#endif
-EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server
-EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client
-EXPORT_MINIMAL_DIR = $(EXPORT_LIB_ARCH_DIR)/minimal
-
-ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK) $(JVM_VARIANT_CORE)), true)
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
-#  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-#    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-#      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz
-#    else
-#      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
-#    endif
-#  endif
-endif
-
-ifeq ($(JVM_VARIANT_CLIENT),true)
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
-#  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-#    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-#      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz
-#    else
-#      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
-#    endif
-#  endif
-endif
diff --git a/hotspot/make/aix/makefiles/dtrace.make b/hotspot/make/aix/makefiles/dtrace.make
deleted file mode 100644
index 749877d..0000000
--- a/hotspot/make/aix/makefiles/dtrace.make
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Linux does not build jvm_db
-LIBJVM_DB =
-
diff --git a/hotspot/make/aix/makefiles/fastdebug.make b/hotspot/make/aix/makefiles/fastdebug.make
deleted file mode 100644
index c0d5007..0000000
--- a/hotspot/make/aix/makefiles/fastdebug.make
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-# Pare down optimization to -O2 if xlCV10.1 is in use.
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) $(QV10_OPT_CONSERVATIVE)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-ifeq ($(BUILDARCH), ia64)
-  # Bug in GCC, causes hang.  -O1 will override the -O3 specified earlier
-  OPT_CFLAGS/callGenerator.o += -O1
-  OPT_CFLAGS/ciTypeFlow.o += -O1
-  OPT_CFLAGS/compile.o += -O1
-  OPT_CFLAGS/concurrentMarkSweepGeneration.o += -O1
-  OPT_CFLAGS/doCall.o += -O1
-  OPT_CFLAGS/generateOopMap.o += -O1
-  OPT_CFLAGS/generateOptoStub.o += -O1
-  OPT_CFLAGS/graphKit.o += -O1
-  OPT_CFLAGS/instanceKlass.o += -O1
-  OPT_CFLAGS/interpreterRT_ia64.o += -O1
-  OPT_CFLAGS/output.o += -O1
-  OPT_CFLAGS/parse1.o += -O1
-  OPT_CFLAGS/runtime.o += -O1
-  OPT_CFLAGS/synchronizer.o += -O1
-endif
-
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/aix/makefiles/mapfile-vers-debug
-
-# xlc 10.1 parameters for ipa linkage.
-#  - remove ipa linkage altogether. Does not seem to benefit performance, 
-#    but increases code footprint.
-#  - this is a debug build in the end. Extra effort for ipa linkage is thus 
-#    not justified.
-LFLAGS_QIPA=
-
-VERSION = optimized
-SYSDEFS += -DASSERT
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/aix/makefiles/jsig.make b/hotspot/make/aix/makefiles/jsig.make
deleted file mode 100644
index 86c4bea..0000000
--- a/hotspot/make/aix/makefiles/jsig.make
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Rules to build signal interposition library, used by vm.make
-
-# libjsig.so: signal interposition library
-JSIG = jsig
-LIBJSIG = lib$(JSIG).so
-
-LIBJSIG_DEBUGINFO   = lib$(JSIG).debuginfo
-LIBJSIG_DIZ         = lib$(JSIG).diz
-
-JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
-
-DEST_JSIG           = $(JDK_LIBDIR)/$(LIBJSIG)
-DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO)
-DEST_JSIG_DIZ       = $(JDK_LIBDIR)/$(LIBJSIG_DIZ)
-
-LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
-
-# On Linux we really dont want a mapfile, as this library is small
-# and preloaded using LD_PRELOAD, making functions private will
-# cause problems with interposing. See CR: 6466665
-# LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
-
-LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE)
-
-LFLAGS_JSIG += $(BIN_UTILS)
-
-# DEBUG_BINARIES overrides everything, use full -g debug information
-ifeq ($(DEBUG_BINARIES), true)
-  JSIG_DEBUG_CFLAGS = -g
-endif
-
-$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
-	@echo $(LOG_INFO) Making signal interposition lib...
-	$(QUIETLY) $(CXX) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
-                         $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $< -ldl
-
-#ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-#	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
-#	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
-#  ifeq ($(STRIP_POLICY),all_strip)
-#	$(QUIETLY) $(STRIP) $@
-#  else
-#    ifeq ($(STRIP_POLICY),min_strip)
-#	$(QUIETLY) $(STRIP) -g $@
-#    # implied else here is no stripping at all
-#    endif
-#  endif
-#  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-#	$(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO)
-#	$(RM) $(LIBJSIG_DEBUGINFO)
-#  endif
-#endif
-
-install_jsig: $(LIBJSIG)
-	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
-	$(QUIETLY) test -f $(LIBJSIG_DEBUGINFO) && \
-	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
-	$(QUIETLY) test -f $(LIBJSIG_DIZ) && \
-	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
-
-.PHONY: install_jsig
diff --git a/hotspot/make/aix/makefiles/jvmti.make b/hotspot/make/aix/makefiles/jvmti.make
deleted file mode 100644
index cff6a74..0000000
--- a/hotspot/make/aix/makefiles/jvmti.make
+++ /dev/null
@@ -1,117 +0,0 @@
-#
-# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This makefile (jvmti.make) is included from the jvmti.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate jvmti.
-
-include $(GAMMADIR)/make/aix/makefiles/rules.make
-
-# #########################################################################
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-JvmtiOutDir = $(GENERATED)/jvmtifiles
-
-JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims
-InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(JvmtiSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-JvmtiGeneratedNames = \
-        jvmtiEnv.hpp \
-        jvmtiEnter.cpp \
-        jvmtiEnterTrace.cpp \
-        jvmtiEnvRecommended.cpp \
-        bytecodeInterpreterWithChecks.cpp \
-        jvmti.h \
-
-JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java
-JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class
-
-JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java
-JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class
-
-JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%)
-
-XSLT = $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-.PHONY: all jvmtidocs clean cleanall
-
-# #########################################################################
-
-all: $(JvmtiGeneratedFiles)
-
-both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl
-
-$(JvmtiGenClass): $(JvmtiGenSource)
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource)
-
-$(JvmtiEnvFillClass): $(JvmtiEnvFillSource)
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource)
-
-$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti
-
-$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp 
-
-$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace
-
-$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass)
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp
-	$(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp
-
-$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp
-
-$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h
-
-jvmtidocs:  $(JvmtiOutDir)/jvmti.html 
-
-$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html
-
-# #########################################################################
-
-clean :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-cleanall :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-# #########################################################################
diff --git a/hotspot/make/aix/makefiles/mapfile-vers-debug b/hotspot/make/aix/makefiles/mapfile-vers-debug
deleted file mode 100644
index fb75f3d..0000000
--- a/hotspot/make/aix/makefiles/mapfile-vers-debug
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                JVM_handle_linux_signal;
-
-                # debug JVM
-                JVM_AccessVMBooleanFlag;
-                JVM_AccessVMIntFlag;
-                JVM_VMBreakPoint;
-
-                # miscellaneous functions
-                jio_fprintf;
-                jio_printf;
-                jio_snprintf;
-                jio_vfprintf;
-                jio_vsnprintf;
-                numa_warn;
-                numa_error;
-
-                # Needed because there is no JVM interface for this.
-                sysThreadAvailableStackWithSlack;
-
-                # This is for Forte Analyzer profiling support.
-                AsyncGetCallTrace;
-
-		# INSERT VTABLE SYMBOLS HERE
-
-        local:
-                *;
-};
-
diff --git a/hotspot/make/aix/makefiles/mapfile-vers-jsig b/hotspot/make/aix/makefiles/mapfile-vers-jsig
deleted file mode 100644
index ddb46c0..0000000
--- a/hotspot/make/aix/makefiles/mapfile-vers-jsig
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Define library interface.
-
-SUNWprivate_1.1 {
-        global:
-            JVM_begin_signal_setting;
-            JVM_end_signal_setting;
-            JVM_get_libjsig_version;
-            JVM_get_signal_action;
-            sigaction;
-            signal;
-            sigset;
-        local:
-                *;
-};
diff --git a/hotspot/make/aix/makefiles/mapfile-vers-product b/hotspot/make/aix/makefiles/mapfile-vers-product
deleted file mode 100644
index ec0f06d..0000000
--- a/hotspot/make/aix/makefiles/mapfile-vers-product
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                JVM_handle_linux_signal;
-
-                # miscellaneous functions
-                jio_fprintf;
-                jio_printf;
-                jio_snprintf;
-                jio_vfprintf;
-                jio_vsnprintf;
-                numa_warn;
-                numa_error;
-
-                # Needed because there is no JVM interface for this.
-                sysThreadAvailableStackWithSlack;
-
-                # This is for Forte Analyzer profiling support.
-                AsyncGetCallTrace;
-
-		# INSERT VTABLE SYMBOLS HERE
-
-        local:
-                *;
-};
-
diff --git a/hotspot/make/aix/makefiles/ppc64.make b/hotspot/make/aix/makefiles/ppc64.make
deleted file mode 100644
index d7ad951..0000000
--- a/hotspot/make/aix/makefiles/ppc64.make
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-# Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2015 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Produce 64 bits object files.
-CFLAGS += -q64
-
-# Balanced tuning for recent versions of the POWER architecture (if supported by xlc).
-QTUNE=$(if $(CXX_SUPPORTS_BALANCED_TUNING),balanced,pwr5)
-
-# Try to speed up the interpreter: use ppc64 instructions and inline 
-# glue code for external functions.
-OPT_CFLAGS += -qarch=ppc64 -qtune=$(QTUNE) -qinlglue
-
-# We need variable length arrays
-CFLAGS += -qlanglvl=c99vla
-# Just to check for unwanted macro redefinitions
-CFLAGS += -qlanglvl=noredefmac
-
-# Suppress those "implicit private" warnings xlc gives.
-#  - The omitted keyword "private" is assumed for base class "...".
-CFLAGS += -qsuppress=1540-0198
-
-# Suppress the following numerous warning:
-#  - 1540-1090 (I) The destructor of "..." might not be called.
-#  - 1500-010: (W) WARNING in ...: Infinite loop.  Program may not stop.
-#    There are several infinite loops in the vm, suppress.
-#  - 1540-1639 (I) The behavior of long type bit fields has changed ...
-#                  ... long type bit fields now default to long, not int.
-CFLAGS += -qsuppress=1540-1090 -qsuppress=1500-010 -qsuppress=1540-1639
-
-# Suppress 
-#  - 540-1088 (W) The exception specification is being ignored.
-# caused by throw() in declaration of new() in nmethod.hpp.
-CFLAGS += -qsuppress=1540-1088
-
-# Turn off floating-point optimizations that may alter program semantics
-OPT_CFLAGS += -qstrict
-
-# Disable aggressive optimizations for functions in sharedRuntimeTrig.cpp 
-# and sharedRuntimeTrans.cpp on ppc64. 
-# -qstrict turns off the following optimizations:
-#   * Performing code motion and scheduling on computations such as loads
-#     and floating-point computations that may trigger an exception.
-#   * Relaxing conformance to IEEE rules.
-#   * Reassociating floating-point expressions.
-# When using '-qstrict' there still remains one problem
-# in javasoft.sqe.tests.api.java.lang.Math.sin5Tests when run in compile-all
-# mode, so don't optimize sharedRuntimeTrig.cpp at all.
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-
-# Xlc 10.1 parameters for aggressive optimization:
-# - qhot=level=1: Most aggressive loop optimizations.
-# - qignerrno: Assume errno is not modified by system calls.
-# - qinline: Inline method calls. No suboptions for c++ compiles.
-# - qxflag=ASMMIDCOALFIX: Activate fix for -O3 problem in interpreter loop.
-# - qxflag=asmfastsync: Activate fix for performance problem with inline assembler with memory clobber.
-QV10_OPT=$(if $(CXX_IS_V10),-qxflag=ASMMIDCOALFIX -qxflag=asmfastsync)
-QV10_OPT_AGGRESSIVE=$(if $(CXX_IS_V10),-qhot=level=1 -qignerrno -qinline)
-QV10_OPT_CONSERVATIVE=$(if $(CXX_IS_V10),-qhot=level=1 -qignerrno -qinline)
-
-# Disallow inlining for synchronizer.cpp, but perform O3 optimizations.
-OPT_CFLAGS/synchronizer.o = $(OPT_CFLAGS) -qnoinline
-
-# Set all the xlC V10.1 options here.
-OPT_CFLAGS += $(QV10_OPT) $(QV10_OPT_AGGRESSIVE)
-
-export OBJECT_MODE=64
-
-# Also build launcher as 64 bit executable.
-LAUNCHERFLAGS += -q64
diff --git a/hotspot/make/aix/makefiles/product.make b/hotspot/make/aix/makefiles/product.make
deleted file mode 100644
index f36ef69..0000000
--- a/hotspot/make/aix/makefiles/product.make
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making optimized version of Gamma VM
-# (This is the "product", not the "release" version.)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/aix/makefiles/mapfile-vers-product
-
-# Remove ipa linkage altogether. Does not seem to benfit performance, but increases code footprint.
-LFLAGS_QIPA=
-
-SYSDEFS += -DPRODUCT
-VERSION = optimized
-
-# use -g to strip library as -x will discard its symbol table; -x is fine for
-# executables.
-# Note: these macros are not used in .debuginfo configs
-STRIP_LIBJVM = $(STRIP) -g $@ || exit 1;
-STRIP_AOUT   = $(STRIP) -x $@ || exit 1;
-
-# If we can create .debuginfo files, then the VM is stripped in vm.make
-# and this macro is not used.
-# LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO))
diff --git a/hotspot/make/aix/makefiles/rules.make b/hotspot/make/aix/makefiles/rules.make
deleted file mode 100644
index effca45..0000000
--- a/hotspot/make/aix/makefiles/rules.make
+++ /dev/null
@@ -1,208 +0,0 @@
-#
-# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# Common rules/macros for the vm, adlc.
-
-# Tell make that .cpp is important
-.SUFFIXES: .cpp $(SUFFIXES)
-
-DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
-
-# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
-CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
-CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
-
-AS.S            = $(AS) $(ASFLAGS)
-
-COMPILE.CC       = $(CC_COMPILE) -c
-GENASM.CC        = $(CC_COMPILE) -S
-LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CC    = $(CC_COMPILE) -E
-
-COMPILE.CXX      = $(CXX_COMPILE) -c
-GENASM.CXX       = $(CXX_COMPILE) -S
-LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
-LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CXX   = $(CXX_COMPILE) -E
-
-# cross compiling the jvm with c2 requires host compilers to build
-# adlc tool
-
-HOST.CXX_COMPILE      = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS)
-HOST.COMPILE.CXX      = $(HOST.CXX_COMPILE) -c
-HOST.LINK_NOPROF.CXX  = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS)
-
-
-# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
-REMOVE_TARGET   = rm -f $@
-
-# Note use of ALT_BOOTDIR to explicitly specify location of java and
-# javac; this is the same environment variable used in the J2SE build
-# process for overriding the default spec, which is BOOTDIR.
-# Note also that we fall back to using JAVA_HOME if neither of these is
-# specified.
-
-ifdef ALT_BOOTDIR
-
-RUN.JAVA  = $(ALT_BOOTDIR)/bin/java
-RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap
-RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah
-RUN.JAR   = $(ALT_BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac
-COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(ALT_BOOTDIR)
-
-else
-
-ifdef BOOTDIR
-
-RUN.JAVA  = $(BOOTDIR)/bin/java
-RUN.JAVAP = $(BOOTDIR)/bin/javap
-RUN.JAVAH = $(BOOTDIR)/bin/javah
-RUN.JAR   = $(BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(BOOTDIR)/bin/javac
-COMPILE.RMIC  = $(BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(BOOTDIR)
-
-else
-
-ifdef JAVA_HOME
-
-RUN.JAVA  = $(JAVA_HOME)/bin/java
-RUN.JAVAP = $(JAVA_HOME)/bin/javap
-RUN.JAVAH = $(JAVA_HOME)/bin/javah
-RUN.JAR   = $(JAVA_HOME)/bin/jar
-COMPILE.JAVAC = $(JAVA_HOME)/bin/javac
-COMPILE.RMIC  = $(JAVA_HOME)/bin/rmic
-BOOT_JAVA_HOME = $(JAVA_HOME)
-
-else
-
-# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined
-
-RUN.JAVA  = java
-RUN.JAVAP = javap
-RUN.JAVAH = javah
-RUN.JAR   = jar
-COMPILE.JAVAC = javac
-COMPILE.RMIC  = rmic
-
-endif
-endif
-endif
-
-COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS)
-
-SUM = /usr/bin/sum
-
-# 'gmake MAKE_VERBOSE=y' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)  = @
-RUN.JAR$(MAKE_VERBOSE) += >/dev/null
-
-# Settings for javac
-JAVAC_FLAGS = -g -encoding ascii
-
-# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system)
-# Fall back to the values here if it's not set (hotspot only builds)
-ifeq ($(BOOT_JDK_SOURCETARGET),)
-BOOTSTRAP_SOURCETARGET := -source 8 -target 8
-else
-BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET)
-endif
-
-BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET)
-
-# With parallel makes, print a message at the end of compilation.
-ifeq    ($(findstring j,$(MFLAGS)),j)
-COMPILE_DONE    = && { echo Done with $<; }
-endif
-
-# Include $(NONPIC_OBJ_FILES) definition
-ifndef LP64
-include $(GAMMADIR)/make/pic.make
-endif
-
-include $(GAMMADIR)/make/altsrc.make
-
-# The non-PIC object files are only generated for 32 bit platforms.
-ifdef LP64
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
-else
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
-	   $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
-	   $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
-endif
-
-%.o: %.s
-	@echo $(LOG_INFO) Assembling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
-
-%.s: %.cpp
-	@echo $(LOG_INFO) Generating assembly for $<
-	$(QUIETLY) $(GENASM.CXX) -o $@ $<
-	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
-
-# Intermediate files (for debugging macros)
-%.i: %.cpp
-	@echo $(LOG_INFO) Preprocessing $< to $@
-	$(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
-
-#  Override gnumake built-in rules which do sccs get operations badly.
-#  (They put the checked out code in the current directory, not in the
-#  directory of the original file.)  Since this is a symptom of a teamware
-#  failure, and since not all problems can be detected by gnumake due
-#  to incomplete dependency checking... just complain and stop.
-%:: s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-%:: SCCS/s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-.PHONY: default
diff --git a/hotspot/make/aix/makefiles/tiered.make b/hotspot/make/aix/makefiles/tiered.make
deleted file mode 100644
index f04496b..0000000
--- a/hotspot/make/aix/makefiles/tiered.make
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2015 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making tiered version of VM
-
-TYPE=TIERED
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2 -DCOMPILER1
diff --git a/hotspot/make/aix/makefiles/top.make b/hotspot/make/aix/makefiles/top.make
deleted file mode 100644
index fa9107c..0000000
--- a/hotspot/make/aix/makefiles/top.make
+++ /dev/null
@@ -1,147 +0,0 @@
-#
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# top.make is included in the Makefile in the build directories.
-# It DOES NOT include the vm dependency info in order to be faster.
-# Its main job is to implement the incremental form of make lists.
-# It also:
-#   -builds and runs adlc via adlc.make
-#   -generates JVMTI source and docs via jvmti.make (JSR-163)
-
-# It assumes the following flags are set:
-# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Obj_Files
-
-# -- D. Ungar (5/97) from a file by Bill Bush
-
-# Don't override the built-in $(MAKE).
-# Instead, use "gmake" (or "gnumake") from the command line.  --Rose
-#MAKE = gmake
-
-include $(GAMMADIR)/make/altsrc.make
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-VM          = $(GAMMADIR)/src/share/vm
-Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED);
-
-ifneq ($(USE_PRECOMPILED_HEADER),0)
-UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS)
-else
-UpdatePCH = \# precompiled header is not used
-endif
-
-Cached_plat = $(GENERATED)/platform.current
-
-AD_Dir   = $(GENERATED)/adfiles
-ADLC     = $(AD_Dir)/adlc
-AD_Spec  = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad)
-AD_Src   = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc)
-AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
-AD_Files = $(AD_Names:%=$(AD_Dir)/%)
-
-# AD_Files_If_Required/COMPILER1 = ad_stuff
-AD_Files_If_Required/COMPILER2 = ad_stuff
-AD_Files_If_Required/TIERED = ad_stuff
-AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE))
-
-# Wierd argument adjustment for "gnumake -j..."
-adjust-mflags   = $(GENERATED)/adjust-mflags
-# If SPEC is set, it's from configure and it's already controlling concurrency
-# for us. Skip setting -j with HOTSPOT_BUILD_JOBS.
-ifeq ($(SPEC), )
-  MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"`
-else
-  MFLAGS-adjusted = -r $(MFLAGS)
-endif
-
-
-# default target: update lists, make vm
-# done in stages to force sequential order with parallel make
-#
-
-default: vm_build_preliminaries the_vm
-	@echo All done.
-
-# This is an explicit dependency for the sake of parallel makes.
-vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) trace_stuff jvmti_stuff
-	@# We need a null action here, so implicit rules don't get consulted.
-
-$(Cached_plat): $(Plat_File)
-	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
-
-# make AD files as necessary
-ad_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f adlc.make $(MFLAGS-adjusted)
-
-# generate JVMTI files from the spec
-jvmti_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f jvmti.make $(MFLAGS-adjusted)
-
-# generate trace files
-trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f trace.make $(MFLAGS-adjusted)
-
-# and the VM: must use other makefile with dependencies included
-
-# We have to go to great lengths to get control over the -jN argument
-# to the recursive invocation of vm.make.  The problem is that gnumake
-# resets -jN to -j1 for recursive runs.  (How helpful.)
-# Note that the user must specify the desired parallelism level via a
-# command-line or environment variable name HOTSPOT_BUILD_JOBS.
-$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh
-	@+rm -f $@ $@+
-	@+cat $< > $@+
-	@+chmod +x $@+
-	@+mv $@+ $@
-
-the_vm: vm_build_preliminaries $(adjust-mflags)
-	+@$(UpdatePCH)
-	@$(MAKE) -f vm.make $(MFLAGS-adjusted)
-
-install gamma: the_vm
-	@$(MAKE) -f vm.make $@
-
-# next rules support "make foo.[ois]"
-
-%.o %.i %.s:
-	+$(UpdatePCH)
-	$(MAKE) -f vm.make $(MFLAGS) $@
-	#$(MAKE) -f vm.make $@
-
-# this should force everything to be rebuilt
-clean:
-	rm -f $(GENERATED)/*.class
-	$(MAKE) -f vm.make $(MFLAGS) clean
-
-# just in case it doesn't, this should do it
-realclean:
-	$(MAKE) -f vm.make $(MFLAGS) clean
-	rm -fr $(GENERATED)
-
-.PHONY: default vm_build_preliminaries
-.PHONY: lists ad_stuff jvmti_stuff the_vm clean realclean
-.PHONY: checks check_os_version install
-
-.NOTPARALLEL:
diff --git a/hotspot/make/aix/makefiles/trace.make b/hotspot/make/aix/makefiles/trace.make
deleted file mode 100644
index f17e75e..0000000
--- a/hotspot/make/aix/makefiles/trace.make
+++ /dev/null
@@ -1,119 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile (trace.make) is included from the trace.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate trace files.
-
-include $(GAMMADIR)/make/aix/makefiles/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-# #########################################################################
-
-HAS_ALT_SRC := false
-ifndef OPENJDK
-  ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), )
-    HAS_ALT_SRC := true
-  endif
-endif
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-JvmtiOutDir = $(GENERATED)/jvmtifiles
-TraceOutDir   = $(GENERATED)/tracefiles
-
-TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace
-TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-TraceGeneratedNames =     \
-    traceEventClasses.hpp \
-	traceEventIds.hpp     \
-	traceTypes.hpp
-
-ifeq ($(HAS_ALT_SRC), true)
-TraceGeneratedNames +=  \
-	traceRequestables.hpp \
-    traceEventControl.hpp
-endif
-
-TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%)
-
-XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-TraceXml = $(TraceSrcDir)/trace.xml
-ifeq ($(HAS_ALT_SRC), true)
-  TraceXml = $(TraceAltSrcDir)/trace.xml
-endif
-
-XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \
-    $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \
-    $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml
-ifeq ($(HAS_ALT_SRC), true)
-  XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \
-      $(TraceAltSrcDir)/traceeventtypes.xml
-endif
-
-.PHONY: all clean cleanall
-
-# #########################################################################
-
-all: $(TraceGeneratedFiles)
-
-GENERATE_CODE= \
-  $(QUIETLY) echo $(LOG_INFO) Generating $@; \
-  $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@
-
-$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-ifeq ($(HAS_ALT_SRC), false)
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-else
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-endif
-
-# #########################################################################
-
-clean cleanall:
-	rm $(TraceGeneratedFiles)
diff --git a/hotspot/make/aix/makefiles/vm.make b/hotspot/make/aix/makefiles/vm.make
deleted file mode 100644
index 808bb12..0000000
--- a/hotspot/make/aix/makefiles/vm.make
+++ /dev/null
@@ -1,370 +0,0 @@
-#
-# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Rules to build JVM and related libraries, included from vm.make in the build
-# directory.
-
-# Common build rules.
-MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
-include $(MAKEFILES_DIR)/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-default: build
-
-#----------------------------------------------------------------------
-# Defs
-
-GENERATED     = ../generated
-DEP_DIR       = $(GENERATED)/dependencies
-
-# reads the generated files defining the set of .o's and the .o .h dependencies
--include $(DEP_DIR)/*.d
-
-# read machine-specific adjustments (%%% should do this via buildtree.make?)
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  include $(MAKEFILES_DIR)/zeroshark.make
-else
-  include $(MAKEFILES_DIR)/$(BUILDARCH).make
-endif
-
-# set VPATH so make knows where to look for source files
-# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
-# The adfiles directory contains ad_<arch>.[ch]pp.
-# The jvmtifiles directory contains jvmti*.[ch]pp
-Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor.
-Src_Dirs_I += $(GENERATED)
-# The order is important for the precompiled headers to work.
-INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
-
-# SYMFLAG is used by jsig.make
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  # always build with debug info when we can create .debuginfo files
-  SYMFLAG = -g
-else
-  ifeq (${VERSION}, debug)
-    SYMFLAG = -g
-  else
-    SYMFLAG =
-  endif
-endif
-
-# The following variables are defined in the generated flags.make file.
-JDK_VER_DEFS  = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-		-DVERSION_MINOR=$(VERSION_MINOR) \
-		-DVERSION_SECURITY=$(VERSION_SECURITY) \
-	        -DVERSION_PATCH=$(VERSION_PATCH) \
-		-DVERSION_BUILD=$(VERSION_BUILD)
-VM_VER_DEFS   = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-		-DVERSION_STRING="\"$(VERSION_STRING)\""  \
-	        -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \
-		$(JDK_VER_DEFS)
-HS_LIB_ARCH   = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
-BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
-VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
-
-CXXFLAGS =           \
-  ${SYSDEFS}         \
-  ${INCLUDES}        \
-  ${BUILD_USER}      \
-  ${HS_LIB_ARCH}     \
-  ${VM_DISTRO}
-
-# This is VERY important! The version define must only be supplied to vm_version.o
-# If not, ccache will not re-use the cache at all, since the version string might contain
-# a time and date.
-CXXFLAGS/vm_version.o += ${VM_VER_DEFS}
-
-CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
-
-# File specific flags
-CXXFLAGS += $(CXXFLAGS/BYFILE)
-
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-CFLAGS += $(CFLAGS_WARN/BYFILE)
-
-# Do not use C++ exception handling
-CFLAGS += $(CFLAGS/NOEX)
-
-# Extra flags from gnumake's invocation or environment
-CFLAGS += $(EXTRA_CFLAGS)
-LFLAGS += $(EXTRA_CFLAGS)
-
-# Don't set excutable bit on stack segment
-# the same could be done by separate execstack command
-#LFLAGS += -Xlinker -z -Xlinker noexecstack
-
-LIBS += -lm -ldl -lpthread
-
-# By default, link the *.o into the library, not the executable.
-LINK_INTO$(LINK_INTO) = LIBJVM
-
-JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH)
-
-#----------------------------------------------------------------------
-# jvm_db & dtrace
-include $(MAKEFILES_DIR)/dtrace.make
-
-#----------------------------------------------------------------------
-# JVM
-
-JVM      = jvm
-LIBJVM   = lib$(JVM).so
-
-LIBJVM_DEBUGINFO   = lib$(JVM).debuginfo
-LIBJVM_DIZ         = lib$(JVM).diz
-
-SPECIAL_PATHS:=adlc c1 gc opto shark libadt
-
-SOURCE_PATHS=\
-  $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
-      \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(SRCARCH)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_family)_$(SRCARCH)/vm
-
-CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
-CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
-
-ifneq ($(INCLUDE_TRACE), false)
-CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \
-  find $(HS_ALT_SRC)/share/vm/jfr -type d; \
-  fi)
-endif
-
-COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
-COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
-
-COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
-COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
-COMPILER2_PATHS += $(GENERATED)/adfiles
-
-SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
-
-# Include dirs per type.
-Src_Dirs/CORE      := $(CORE_PATHS)
-Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
-Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/TIERED    := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/ZERO      := $(CORE_PATHS)
-Src_Dirs/SHARK     := $(CORE_PATHS) $(SHARK_PATHS)
-Src_Dirs := $(Src_Dirs/$(TYPE))
-
-COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\*
-COMPILER1_SPECIFIC_FILES := c1_\*
-SHARK_SPECIFIC_FILES     := shark
-ZERO_SPECIFIC_FILES      := zero
-
-# Always exclude these.
-Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
-
-# Exclude per type.
-Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
-
-Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
-
-# Disable ELF decoder on AIX (AIX uses XCOFF).
-Src_Files_EXCLUDE += decoder_elf.cpp elfFile.cpp elfStringTable.cpp elfSymbolTable.cpp elfFuncDescTable.cpp
-
-# Special handling of arch model.
-ifeq ($(Platform_arch_model), x86_32)
-Src_Files_EXCLUDE += \*x86_64\*
-endif
-ifeq ($(Platform_arch_model), x86_64)
-Src_Files_EXCLUDE += \*x86_32\*
-endif
-
-# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
-define findsrc
-	$(notdir $(shell find $(1)/. ! -name . -prune \
-		-a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
-		-a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
-endef
-
-Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
-
-Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))))
-
-JVM_OBJ_FILES = $(Obj_Files)
-
-vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
-
-MAPFILE_SHARE  := $(GAMMADIR)/make/share/makefiles/mapfile-vers
-
-mapfile : $(MAPFILE) $(MAPFILE_SHARE) vm.def
-	rm -f $@
-	awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE")	\
-                 { system ("cat ${MAPFILE_SHARE} vm.def"); } \
-               else					\
-                 { print $$0 }				\
-             }' > $@ < $(MAPFILE)
-
-mapfile_reorder : mapfile $(REORDERFILE)
-	rm -f $@
-	cat $^ > $@
-
-vm.def: $(Res_Files) $(Obj_Files)
-	sh $(GAMMADIR)/make/aix/makefiles/build_vm_def.sh *.o > $@
-
-ifeq ($(JVM_VARIANT_ZEROSHARK), true)
-  STATIC_CXX = false
-else
-  ifeq ($(ZERO_LIBARCH), ppc64)
-    STATIC_CXX = false
-  else
-    STATIC_CXX = true
-  endif
-endif
-
-ifeq ($(LINK_INTO),AOUT)
-  LIBJVM.o                 =
-  LIBJVM_MAPFILE           =
-  LIBS_VM                  = $(LIBS)
-else
-  LIBJVM.o                 = $(JVM_OBJ_FILES)
-  LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
-  LFLAGS_VM$(LDNOMAP)      += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
-# xlC_r ignores the -o= syntax
-# LFLAGS_VM                += $(SONAMEFLAG:SONAME=$(LIBJVM))
-
-  # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
-  # get around library dependency and compatibility issues. Must use gcc not
-  # g++ to link.
-  LIBS_VM                  += $(STATIC_STDCXX) $(LIBS)
-endif
-
-LINK_VM = $(LINK_LIB.CXX)
-
-# create loadmap for libjvm.so by default. Helps in diagnosing some problems.
-LFLAGS_VM += -bloadmap:libjvm.loadmap
-
-# rule for building precompiled header
-$(PRECOMPILED_HEADER):
-	$(QUIETLY) echo $(LOG_INFO) Generating precompiled header $@
-	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
-	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
-
-# making the library:
-
-ifneq ($(JVM_BASE_ADDR),)
-# By default shared library is linked at base address == 0. Modify the
-# linker script if JVM prefers a different base location. It can also be
-# implemented with 'prelink -r'. But 'prelink' is not (yet) available on
-# our build platform (AS-2.1).
-LD_SCRIPT = libjvm.so.lds
-$(LD_SCRIPT): $(LIBJVM_MAPFILE)
-	$(QUIETLY) {                                                \
-	  rm -rf $@;                                                \
-	  $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1             |  \
-	    sed -e '/^======/,/^======/!d'                          \
-		-e '/^======/d'                                     \
-		-e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/'   \
-		> $@;                                               \
-	}
-LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
-endif
-
-# With more recent Redhat releases (or the cutting edge version Fedora), if
-# SELinux is configured to be enabled, the runtime linker will fail to apply
-# the text relocation to libjvm.so considering that it is built as a non-PIC
-# DSO. To workaround that, we run chcon to libjvm.so after it is built. See
-# details in bug 6538311.
-$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
-	$(QUIETLY) {                                                      \
-	    echo $(LOG_INFO) Linking vm...;                                           \
-	    $(LINK_LIB.CXX/PRE_HOOK)                                      \
-	    $(LINK_VM) $(LD_SCRIPT_FLAG)                                  \
-		       $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM); \
-	    $(LINK_LIB.CXX/POST_HOOK)                                     \
-	    rm -f $@.1; ln -s $@ $@.1;                                    \
-	}
-# No security contexts on AIX
-#           if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then              \
-#	      if [ -x /usr/sbin/selinuxenabled ] ; then                 \
-#	        /usr/sbin/selinuxenabled;                               \
-#               if [ $$? = 0 ] ; then					\
-#		  /usr/bin/chcon -t textrel_shlib_t $@;                 \
-#		  if [ $$? != 0 ]; then                                 \
-#		    echo "ERROR: Cannot chcon $@";			\
-#		  fi							\
-#	        fi							\
-#	      fi                                                        \
-#           fi 							        \
-#	}
-
-#ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-#	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
-#	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
-#    ifeq ($(STRIP_POLICY),all_strip)
-#	$(QUIETLY) $(STRIP) $@
-#    else
-#      ifeq ($(STRIP_POLICY),min_strip)
-#	$(QUIETLY) $(STRIP) -g $@
-#      # implied else here is no stripping at all
-#      endif
-#    endif
-#    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-#	$(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO)
-#	$(RM) $(LIBJVM_DEBUGINFO)
-#  endif
-#endif
-
-DEST_SUBDIR        = $(JDK_LIBDIR)/$(VM_SUBDIR)
-DEST_JVM           = $(DEST_SUBDIR)/$(LIBJVM)
-DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO)
-DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
-
-install_jvm: $(LIBJVM)
-	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
-	$(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \
-	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
-	$(QUIETLY) test -f $(LIBJVM_DIZ) && \
-	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
-
-#----------------------------------------------------------------------
-# Other files
-
-# Signal interposition library
-include $(MAKEFILES_DIR)/jsig.make
-
-#----------------------------------------------------------------------
-
-build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB)
-
-install: install_jvm install_jsig
-
-.PHONY: default build install install_jvm
diff --git a/hotspot/make/aix/makefiles/xlc.make b/hotspot/make/aix/makefiles/xlc.make
deleted file mode 100644
index c44d306..0000000
--- a/hotspot/make/aix/makefiles/xlc.make
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2015 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-#------------------------------------------------------------------------
-# CC, CXX & AS
-
-# Set compiler explicitly
-CXX = $(COMPILER_PATH)xlC_r
-CC  = $(COMPILER_PATH)xlc_r
-HOSTCXX = $(CXX)
-HOSTCC  = $(CC)
-
-AS  = $(CC) -c
-
-# get xlc version which comes as VV.RR.MMMM.LLLL where 'VV' is the version,
-# 'RR' is the release, 'MMMM' is the modification and 'LLLL' is the level.
-# We only use 'VV.RR.LLLL' to avoid integer overflows in bash when comparing
-# the version numbers (some shells only support 32-bit integer compares!).
-CXX_VERSION := $(shell $(CXX) -qversion 2>&1 | \
-                   sed -n 's/.*Version: \([0-9]\{2\}\).\([0-9]\{2\}\).[0-9]\{4\}.\([0-9]\{4\}\)/\1\2\3/p')
-
-# xlc 08.00.0000.0023 and higher supports -qtune=balanced
-CXX_SUPPORTS_BALANCED_TUNING := $(shell if [ $(CXX_VERSION) -ge 08000023 ] ; then echo "true" ; fi)
-# xlc 10.01 is used with aggressive optimizations to boost performance
-CXX_IS_V10 := $(shell if [ $(CXX_VERSION) -ge 10010000 ] ; then echo "true" ; fi)
-
-# check for precompiled headers support
-
-# Switch off the precompiled header support. Neither xlC 8.0 nor xlC 10.0
-# support precompiled headers. Both "understand" the command line switches "-qusepcomp" and 
-# "-qgenpcomp" but when we specify them the following message is printed:
-# "1506-755 (W) The -qusepcomp option is not supported in this release."
-USE_PRECOMPILED_HEADER = 0
-ifneq ($(USE_PRECOMPILED_HEADER),0)
-PRECOMPILED_HEADER_DIR=.
-PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
-PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
-endif
-
-
-#------------------------------------------------------------------------
-# Compiler flags
-
-# position-independent code
-PICFLAG = -qpic=large
-
-VM_PICFLAG/LIBJVM = $(PICFLAG)
-VM_PICFLAG/AOUT   =
-VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
-
-CFLAGS += $(VM_PICFLAG)
-CFLAGS += -qnortti
-CFLAGS += -qnoeh
-
-# for compiler-level tls
-CFLAGS += -qtls=default
-
-CFLAGS += -D_REENTRANT
-# no xlc counterpart for -fcheck-new
-# CFLAGS += -fcheck-new
-
-# We need to define this on the command line if we want to use the the
-# predefined format specifiers from "inttypes.h". Otherwise system headrs
-# can indirectly include inttypes.h before we define __STDC_FORMAT_MACROS
-# in globalDefinitions.hpp
-CFLAGS += -D__STDC_FORMAT_MACROS
-
-ARCHFLAG = -q64
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-ASFLAGS    += $(ARCHFLAG)
-
-# Use C++ Interpreter
-ifdef CC_INTERP
-  CFLAGS += -DCC_INTERP
-endif
-
-# Keep temporary files (.ii, .s)
-# no counterpart on xlc for -save-temps, -pipe
-
-# Compiler warnings are treated as errors
-# Do not treat warnings as errors
-# WARNINGS_ARE_ERRORS = -Werror
-# Except for a few acceptable ones
-# ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
-# CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
-CFLAGS_WARN/COMMON = 
-CFLAGS_WARN/DEFAULT = $(CFLAGS_WARN/COMMON) $(EXTRA_WARNINGS)
-# Special cases
-CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
-
-# The flags to use for an optimized build
-OPT_CFLAGS += -O3
-
-# Hotspot uses very unstrict aliasing turn this optimization off
-OPT_CFLAGS += -qalias=noansi
-
-OPT_CFLAGS/NOOPT=-qnoopt
-
-DEPFLAGS = -qmakedep=gcc -MF $(DEP_DIR)/$(@:%=%.d)
-
-#------------------------------------------------------------------------
-# Linker flags
-
-# statically link libstdc++.so, work with gcc but ignored by g++
-STATIC_STDCXX = -Wl,-lC_r
-
-# Enable linker optimization
-# no counterpart on xlc for this 
-# LFLAGS += -Xlinker -O1
-
-# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-# MAPFLAG = -Xlinker --version-script=FILENAME
-
-# Build shared library
-SHARED_FLAG = -q64 -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath -bernotok
-
-#------------------------------------------------------------------------
-# Debug flags
-
-# Always compile with '-g' to get symbols in the stacktraces in the hs_err file
-DEBUG_CFLAGS += -g
-FASTDEBUG_CFLAGS += -g
-OPT_CFLAGS += -g
-
-# DEBUG_BINARIES overrides everything, use full -g debug information
-ifeq ($(DEBUG_BINARIES), true)
-  DEBUG_CFLAGS = -g
-  CFLAGS += $(DEBUG_CFLAGS)
-endif
-
-# If we are building HEADLESS, pass on to VM
-# so it can set the java.awt.headless property
-ifdef HEADLESS
-CFLAGS += -DHEADLESS
-endif
-
-# We are building Embedded for a small device
-# favor code space over speed
-ifdef MINIMIZE_RAM_USAGE
-CFLAGS += -DMINIMIZE_RAM_USAGE
-endif
-
-ifdef CROSS_COMPILE_ARCH
-  STRIP = $(ALT_COMPILER_PATH)/strip
-else
-  STRIP = strip
-endif
diff --git a/hotspot/make/aix/platform_ppc64 b/hotspot/make/aix/platform_ppc64
deleted file mode 100644
index 5a21fb9..0000000
--- a/hotspot/make/aix/platform_ppc64
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = aix
-
-arch = ppc
-
-arch_model = ppc_64
-
-os_arch = aix_ppc
-
-os_arch_model = aix_ppc_64
-
-lib_arch = ppc64
-
-compiler = xlc
-
-gnu_dis_arch = ppc64
-
-sysdefs = -DAIX -DPPC64
diff --git a/hotspot/make/altsrc.make b/hotspot/make/altsrc.make
deleted file mode 100644
index 027dc35..0000000
--- a/hotspot/make/altsrc.make
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This file defines variables and macros which are used in the makefiles to 
-# allow distributions to augment or replace common hotspot code with 
-# distribution-specific source files. This capability is disabled when
-# an OPENJDK build is requested, unless HS_ALT_SRC_REL has been set externally.
-
-# Requires: GAMMADIR
-# Provides:
-#   variables: HS_COMMON_SRC, HS_ALT_SRC, HS_COMMON_SRC_REL, and HS_ALT_SRC_REL
-#   functions: altsrc-equiv, if-has-altsrc, altsrc, altsrc-replace
-
-HS_COMMON_SRC_REL=src
-
-ifneq ($(OPENJDK),true)
-  # This needs to be changed to a more generic location, but we keep it 
-  # as this for now for compatibility
-  HS_ALT_SRC_REL=src/closed
-else
-  HS_ALT_SRC_REL=NO_SUCH_PATH
-endif
-
-HS_COMMON_SRC=$(GAMMADIR)/$(HS_COMMON_SRC_REL)
-HS_ALT_SRC=$(GAMMADIR)/$(HS_ALT_SRC_REL)
-
-## altsrc-equiv 
-# 
-# Convert a common source path to an alternative source path
-#
-# Parameter: An absolute path into the common sources
-# Result: The matching path to the alternate-source location
-#
-altsrc-equiv=$(subst $(HS_COMMON_SRC)/,$(HS_ALT_SRC)/,$(1))
-
-
-## if-has-altsrc
-#
-# Conditional macro to test for the existence of an alternate source path
-#
-# Parameter: An absolute path into the common sources
-# Parameter: Result if the alternative-source location exists
-# Parameter: Result if the alternative-source location does not exist
-# Result: expands to parameter 2 or 3 depending on existence of alternate source
-#
-if-has-altsrc=$(if $(wildcard $(call altsrc-equiv,$(1))),$(2),$(3))
-
-
-## altsrc
-#
-# Converts common source path to alternate source path if the alternate 
-# path exists, otherwise evaluates to nul (empty string)
-# 
-# Parameter: An absolute path into the common sources
-# Result: The equivalent path to the alternate-source location, if such a 
-#         location exists on the filesystem.  Otherwise it expands to empty.
-# 
-altsrc=$(call if-has-altsrc,$(1),$(call altsrc-equiv,$(1)))
-
-## commonsrc
-# 
-# Returns parameter.
-#
-commonsrc=$(1)
-
-
-## altsrc-replace
-#
-# Converts a common source path to an alternate source path if the alternate
-# source path exists.  Otherwise it evaluates to the input common source path.
-#
-# Parameter: An absolute path into the common sources
-# Result: A path to either the common or alternate sources
-#
-altsrc-replace=$(call if-has-altsrc,$(1),$(call altsrc-equiv,$(1)),$(1))
diff --git a/hotspot/make/bsd/Makefile b/hotspot/make/bsd/Makefile
deleted file mode 100644
index d3e977f..0000000
--- a/hotspot/make/bsd/Makefile
+++ /dev/null
@@ -1,386 +0,0 @@
-#
-# 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile creates a build tree and lights off a build.
-# You can go back into the build tree and perform rebuilds or
-# incremental builds as desired. Be sure to reestablish
-# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME.
-
-# The make process now relies on java and javac. These can be
-# specified either implicitly on the PATH, by setting the
-# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a
-# JDK in which bin/java and bin/javac are present and working (e.g.,
-# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited)
-# default BOOTDIR path value. Note that one of ALT_BOOTDIR
-# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc.
-# from the PATH.
-#
-# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on
-# an architecture that differs from the target architecture, as long
-# as the bootstrap jdk runs under the same flavor of OS as the target
-# (i.e., if the target is linux, point to a jdk that runs on a linux
-# box).  In order to use such a bootstrap jdk, set the make variable
-# REMOTE to the desired remote command mechanism, e.g.,
-#
-#    make REMOTE="rsh -l me myotherlinuxbox"
-
-ifeq ($(GAMMADIR),)
-include ../../make/defs.make
-else
-include $(GAMMADIR)/make/defs.make
-endif
-include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make
-
-ifndef CC_INTERP
-  ifndef FORCE_TIERED
-    FORCE_TIERED=1
-  endif
-endif
-
-ifdef LP64
-  ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
-    _JUNK_ := $(shell echo >&2 \
-       $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!")
-	@exit 1
-  endif
-endif
-
-# we need to set up LP64 correctly to satisfy sanity checks in adlc
-ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
-  MFLAGS += " LP64=1 "
-endif
-
-# pass USE_SUNCC further, through MFLAGS
-ifdef USE_SUNCC
-  MFLAGS += " USE_SUNCC=1 "
-endif
-
-# The following renders pathnames in generated Makefiles valid on
-# machines other than the machine containing the build tree.
-#
-# For example, let's say my build tree lives on /files12 on
-# exact.east.sun.com.  This logic will cause GAMMADIR to begin with
-# /net/exact/files12/...
-#
-# We only do this on SunOS variants, for a couple of reasons:
-#  * It is extremely rare that source trees exist on other systems
-#  * It has been claimed that the Linux automounter is flakey, so
-#    changing GAMMADIR in a way that exercises the automounter could
-#    prove to be a source of unreliability in the build process.
-# Obviously, this Makefile is only relevant on SunOS boxes to begin
-# with, but the SunOS conditionalization will make it easier to
-# combine Makefiles in the future (assuming we ever do that).
-
-ifeq ($(OSNAME),solaris)
-
-  #   prepend current directory to relative pathnames.
-  NEW_GAMMADIR :=                                    \
-    $(shell echo $(GAMMADIR) |                       \
-      sed -e "s=^\([^/].*\)=$(shell pwd)/\1="        \
-     )
-  unexport NEW_GAMMADIR
-
-  # If NEW_GAMMADIR doesn't already start with "/net/":
-  ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),)
-    #   prepend /net/$(HOST)
-    #   remove /net/$(HOST) if name already began with /home/
-    #   remove /net/$(HOST) if name already began with /java/
-    #   remove /net/$(HOST) if name already began with /lab/
-    NEW_GAMMADIR :=                                     \
-         $(shell echo $(NEW_GAMMADIR) |                 \
-                 sed -e "s=^\(.*\)=/net/$(HOST)\1="     \
-                     -e "s=^/net/$(HOST)/home/=/home/=" \
-                     -e "s=^/net/$(HOST)/java/=/java/=" \
-                     -e "s=^/net/$(HOST)/lab/=/lab/="   \
-          )
-    # Don't use the new value for GAMMADIR unless a file with the new
-    # name actually exists.
-    ifneq ($(wildcard $(NEW_GAMMADIR)),)
-      GAMMADIR := $(NEW_GAMMADIR)
-    endif
-  endif
-
-endif
-
-# BUILDARCH is set to "zero" for Zero builds.  VARIANTARCH
-# is used to give the build directories meaningful names.
-VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH))
-
-# There is a (semi-) regular correspondence between make targets and actions:
-#
-#       Target          Tree Type       Build Dir
-#
-#       debug           compiler2       <os>_<arch>_compiler2/debug
-#       fastdebug       compiler2       <os>_<arch>_compiler2/fastdebug
-#       optimized       compiler2       <os>_<arch>_compiler2/optimized
-#       product         compiler2       <os>_<arch>_compiler2/product
-#
-#       debug1          compiler1       <os>_<arch>_compiler1/debug
-#       fastdebug1      compiler1       <os>_<arch>_compiler1/fastdebug
-#       optimized1      compiler1       <os>_<arch>_compiler1/optimized
-#       product1        compiler1       <os>_<arch>_compiler1/product
-#
-#       debugcore       core            <os>_<arch>_core/debug
-#       fastdebugcore   core            <os>_<arch>_core/fastdebug
-#       optimizedcore   core            <os>_<arch>_core/optimized
-#       productcore     core            <os>_<arch>_core/product
-#
-#       debugzero       zero            <os>_<arch>_zero/debug
-#       fastdebugzero   zero            <os>_<arch>_zero/fastdebug
-#       optimizedzero   zero            <os>_<arch>_zero/optimized
-#       productzero     zero            <os>_<arch>_zero/product
-#
-#       debugshark      shark           <os>_<arch>_shark/debug
-#       fastdebugshark  shark           <os>_<arch>_shark/fastdebug
-#       optimizedshark  shark           <os>_<arch>_shark/optimized
-#       productshark    shark           <os>_<arch>_shark/product
-#
-#       fastdebugminimal1 minimal1      <os>_<arch>_minimal1/fastdebug
-#       debugminimal1     minimal1      <os>_<arch>_minimal1/debug
-#       productminimal1   minimal1      <os>_<arch>_minimal1/product
-#
-# What you get with each target:
-#
-# debug*     - debug compile with asserts enabled
-# fastdebug* - optimized compile, but with asserts enabled
-# optimized* - optimized compile, no asserts
-# product*   - the shippable thing:  optimized compile, no asserts, -DPRODUCT
-
-# This target list needs to be coordinated with the usage message
-# in the build.sh script:
-TARGETS           = debug fastdebug optimized product
-
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  SUBDIR_DOCS     = $(OSNAME)_$(VARIANTARCH)_docs
-else
-  SUBDIR_DOCS     = $(OSNAME)_$(BUILDARCH)_docs
-endif
-SUBDIRS_C1        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS))
-SUBDIRS_C2        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS))
-SUBDIRS_TIERED    = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS))
-SUBDIRS_CORE      = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS))
-SUBDIRS_ZERO      = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS))
-SUBDIRS_SHARK     = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS))
-SUBDIRS_MINIMAL1  = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS))
-
-TARGETS_C2        = $(TARGETS)
-TARGETS_C1        = $(addsuffix 1,$(TARGETS))
-TARGETS_TIERED    = $(addsuffix tiered,$(TARGETS))
-TARGETS_CORE      = $(addsuffix core,$(TARGETS))
-TARGETS_ZERO      = $(addsuffix zero,$(TARGETS))
-TARGETS_SHARK     = $(addsuffix shark,$(TARGETS))
-TARGETS_MINIMAL1  = $(addsuffix minimal1,$(TARGETS))
-
-BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
-BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) LIBRARY_SUFFIX=$(LIBRARY_SUFFIX)
-BUILDTREE_VARS   += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-BUILDTREE_VARS   += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE)
-
-BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
-
-#-------------------------------------------------------------------------------
-
-# Could make everything by default, but that would take a while.
-all:
-	@echo "Try '$(MAKE) <target> ...'  where <target> is one or more of"
-	@echo "  $(TARGETS_C2)"
-	@echo "  $(TARGETS_C1)"
-	@echo "  $(TARGETS_CORE)"
-	@echo "  $(TARGETS_ZERO)"
-	@echo "  $(TARGETS_SHARK)"
-	@echo "  $(TARGETS_MINIMAL1)"
-
-checks: check_os_version check_j2se_version
-
-# We do not want people accidentally building on old systems (e.g. Linux 2.2.x,
-# Solaris 2.5.1, 2.6).
-# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.
-
-#SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7%
-DISABLE_HOTSPOT_OS_VERSION_CHECK = ok
-OS_VERSION := $(shell uname -r)
-EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
-
-check_os_version:
-ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
-	$(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
-endif
-
-# jvmti.make requires XSLT (J2SE 1.4.x or newer):
-XSLT_CHECK	= $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
-# If not found then fail fast.
-check_j2se_version:
-	$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
-	  $(REMOTE) $(RUN.JAVA) -version; \
-	  echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
-	  "to bootstrap this build" 1>&2; \
-	  exit 1; \
-	fi
-
-$(SUBDIRS_TIERED): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered
-
-$(SUBDIRS_C2): $(BUILDTREE_MAKE)
-ifeq ($(FORCE_TIERED),1)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1
-else
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler2
-endif
-
-$(SUBDIRS_C1): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler1
-
-$(SUBDIRS_CORE): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=core
-
-$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH)
-
-$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH)
-
-$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=minimal1
-
-platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
-	$(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@
-
-# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME
-
-$(TARGETS_C2):  $(SUBDIRS_C2)
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_TIERED):  $(SUBDIRS_TIERED)
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_C1):  $(SUBDIRS_C1)
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_CORE):  $(SUBDIRS_CORE)
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_ZERO):  $(SUBDIRS_ZERO)
-	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_SHARK):  $(SUBDIRS_SHARK)
-	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_MINIMAL1):  $(SUBDIRS_MINIMAL1)
-	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-# Just build the tree, and nothing else:
-tree:      $(SUBDIRS_C2)
-tree1:     $(SUBDIRS_C1)
-treecore:  $(SUBDIRS_CORE)
-treezero:  $(SUBDIRS_ZERO)
-treeshark: $(SUBDIRS_SHARK)
-treeminimal1: $(SUBDIRS_MINIMAL1)
-
-# Doc target.  This is the same for all build options.
-#     Hence create a docs directory beside ...$(ARCH)_[...]
-# We specify 'BUILD_FLAVOR=product' so that the proper
-# ENABLE_FULL_DEBUG_SYMBOLS value is used.
-docs: checks
-	$(QUIETLY) mkdir -p $(SUBDIR_DOCS)
-	$(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs
-
-# Synonyms for win32-like targets.
-compiler2:  debug product
-
-compiler1:  debug1 product1
-
-core: debugcore productcore
-
-zero: debugzero productzero
-
-shark: debugshark productshark
-
-warn_jvmg_deprecated:
-	echo "Warning: The jvmg target has been replaced with debug"
-	echo "Warning: Please update your usage"
-
-jvmg: warn_jvmg_deprecated debug
-
-jvmg1: warn_jvmg_deprecated debug1
-
-jvmgcore: warn_jvmg_deprecated debugcore
-
-jvmgzero: warn_jvmg_deprecated debugzero
-
-jvmgshark: warn_jvmg_deprecated debugshark
-
-clean_docs:
-	rm -rf $(SUBDIR_DOCS)
-
-clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1:
-	rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@)
-
-clean:  clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs
-
-include $(GAMMADIR)/make/cscope.make
-
-#
-# Include alternate Makefile if it exists.
-#
--include $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
-
-#-------------------------------------------------------------------------------
-
-.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1)
-.PHONY: tree tree1 treecore treezero treeshark
-.PHONY: all compiler1 compiler2 core zero shark
-.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs
-.PHONY: checks check_os_version check_j2se_version
-.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
-
-.NOTPARALLEL:
diff --git a/hotspot/make/bsd/README b/hotspot/make/bsd/README
deleted file mode 100644
index d3efaf8..0000000
--- a/hotspot/make/bsd/README
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
-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.
-
-________________________________________________________________________
-
-Please refer to the comments in the Makefile in this directory
-for instructions how to build the Solaris versions.
-
diff --git a/hotspot/make/bsd/adlc_updater b/hotspot/make/bsd/adlc_updater
deleted file mode 100644
index 99e04e3..0000000
--- a/hotspot/make/bsd/adlc_updater
+++ /dev/null
@@ -1,23 +0,0 @@
-#! /bin/sh
-#
-# This file is used by adlc.make to selectively update generated
-# adlc files. Because source and target diretories are relative
-# paths, this file is copied to the target build directory before
-# use.
-#
-# adlc-updater <file> <source-dir> <target-dir>
-#
-fix_lines() {
-  # repair bare #line directives in $1 to refer to $2
-  # and add an override of __FILE__ with just the basename on the
-  # first line of the file.
-  awk < $1 > $1+ -v F2=$2 '
-    BEGIN { print "#line 1 \"" F2 "\""; }
-    /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next}
-    {print}
-  '
-  mv $1+ $1
-}
-fix_lines $2/$1 $1
-[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \
-( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 )
diff --git a/hotspot/make/bsd/makefiles/adjust-mflags.sh b/hotspot/make/bsd/makefiles/adjust-mflags.sh
deleted file mode 100644
index 97bc02d..0000000
--- a/hotspot/make/bsd/makefiles/adjust-mflags.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This script is used only from top.make.
-# The macro $(MFLAGS-adjusted) calls this script to
-# adjust the "-j" arguments to take into account
-# the HOTSPOT_BUILD_JOBS variable.  The default
-# handling of the "-j" argument by gnumake does
-# not meet our needs, so we must adjust it ourselves.
-
-# This argument adjustment applies to two recursive
-# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make.
-# One invokes adlc.make, and the other invokes vm.make.
-# The adjustment propagates the desired concurrency
-# level down to the sub-make (of the adlc or vm).
-# The default behavior of gnumake is to run all
-# sub-makes without concurrency ("-j1").
-
-# Also, we use a make variable rather than an explicit
-# "-j<N>" argument to control this setting, so that
-# the concurrency setting (which must be tuned separately
-# for each MP system) can be set via an environment variable.
-# The recommended setting is 1.5x to 2x the number of available
-# CPUs on the MP system, which is large enough to keep the CPUs
-# busy (even though some jobs may be I/O bound) but not too large,
-# we may presume, to overflow the system's swap space.
-
-set -eu
-
-default_build_jobs=4
-
-case $# in
-[12])	true;;
-*)	>&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;;
-esac
-
-MFLAGS=$1
-HOTSPOT_BUILD_JOBS=${2-}
-
-# Normalize any -jN argument to the form " -j${HBJ}"
-MFLAGS=`
-	echo "$MFLAGS" \
-	| sed '
-		s/^-/ -/
-		s/ -\([^ 	I][^ 	I]*\)j/ -\1 -j/
-		s/ -j[0-9][0-9]*/ -j/
-		s/ -j\([^ 	]\)/ -j -\1/
-		s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/
-	' `
-
-case ${HOTSPOT_BUILD_JOBS} in \
-
-'') case ${MFLAGS} in
-    *\ -j*)
-	>&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." 
-	>&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment."
-    esac;;
-
-?*) case ${MFLAGS} in
-     *\ -j*) true;;
-     *)      MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";;
-    esac;;
-esac
-
-echo "${MFLAGS}"
diff --git a/hotspot/make/bsd/makefiles/adlc.make b/hotspot/make/bsd/makefiles/adlc.make
deleted file mode 100644
index dd3346e..0000000
--- a/hotspot/make/bsd/makefiles/adlc.make
+++ /dev/null
@@ -1,233 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This makefile (adlc.make) is included from the adlc.make in the
-# build directories.
-# It knows how to compile, link, and run the adlc.
-
-include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
-
-# #########################################################################
-
-# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
-GENERATED = ../generated
-OUTDIR  = $(GENERATED)/adfiles
-
-ARCH = $(Platform_arch)
-OS = $(Platform_os_family)
-
-SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
-
-ifeq ("${Platform_arch_model}", "${Platform_arch}")
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 
-else
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 
-endif
-
-EXEC	= $(OUTDIR)/adlc
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor
-Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED)
-INCLUDES += $(Src_Dirs_I:%=-I%)
-
-# set flags for adlc compilation
-CXXFLAGS = $(SYSDEFS) $(INCLUDES)
-
-# Force assertions on.
-CXXFLAGS += -DASSERT
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-# Compiler warnings are treated as errors
-ifneq ($(COMPILER_WARNINGS_FATAL),false)
-  CFLAGS_WARN = $(WARNINGS_ARE_ERRORS)
-endif
-CFLAGS += $(CFLAGS_WARN)
-
-OBJECTNAMES = \
-	adlparse.o \
-	archDesc.o \
-	arena.o \
-	dfa.o \
-	dict2.o \
-	filebuff.o \
-	forms.o \
-	formsopt.o \
-	formssel.o \
-	main.o \
-	adlc-opcodes.o \
-	output_c.o \
-	output_h.o \
-
-OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)
-
-GENERATEDNAMES = \
-        ad_$(Platform_arch_model).cpp \
-        ad_$(Platform_arch_model).hpp \
-        ad_$(Platform_arch_model)_clone.cpp \
-        ad_$(Platform_arch_model)_expand.cpp \
-        ad_$(Platform_arch_model)_format.cpp \
-        ad_$(Platform_arch_model)_gen.cpp \
-        ad_$(Platform_arch_model)_misc.cpp \
-        ad_$(Platform_arch_model)_peephole.cpp \
-        ad_$(Platform_arch_model)_pipeline.cpp \
-        adGlobals_$(Platform_arch_model).hpp \
-        dfa_$(Platform_arch_model).cpp \
-
-GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)
-
-# #########################################################################
-
-all: $(EXEC)
-
-$(EXEC) : $(OBJECTS)
-	@echo $(LOG_INFO) Making adlc
-	$(QUIETLY) $(HOST.LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS)
-
-# Random dependencies:
-$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
-
-# The source files refer to ostream.h, which sparcworks calls iostream.h
-$(OBJECTS): ostream.h
-
-ostream.h :
-	@echo >$@ '#include <iostream.h>'
-
-dump:
-	: OUTDIR=$(OUTDIR)
-	: OBJECTS=$(OBJECTS)
-	: products = $(GENERATEDFILES)
-
-all: $(GENERATEDFILES)
-
-$(GENERATEDFILES): refresh_adfiles
-
-# Get a unique temporary directory name, so multiple makes can run in parallel.
-# Note that product files are updated via "mv", which is atomic.
-TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)
-
-# Debuggable by default
-CFLAGS += -g
-
-# Pass -D flags into ADLC.
-ADLCFLAGS += $(SYSDEFS)
-
-# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
-ADLCFLAGS += -q -T
-
-# Normally, debugging is done directly on the ad_<arch>*.cpp files.
-# But -g will put #line directives in those files pointing back to <arch>.ad.
-# Some builds of gcc 3.2 have a bug that gets tickled by the extra #line directives
-# so skip it for 3.2 and ealier.
-ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-ADLCFLAGS += -g
-endif
-
-ifdef LP64
-ADLCFLAGS += -D_LP64
-else
-ADLCFLAGS += -U_LP64
-endif
-
-#
-# adlc_updater is a simple sh script, under sccs control. It is
-# used to selectively update generated adlc files. This should
-# provide a nice compilation speed improvement.
-#
-ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
-ADLC_UPDATER = adlc_updater
-$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
-	$(QUIETLY) cp $< $@; chmod +x $@
-
-# This action refreshes all generated adlc files simultaneously.
-# The way it works is this:
-# 1) create a scratch directory to work in.
-# 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
-# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
-# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
-# 5) If we actually updated any files, echo a notice.
-#
-refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
-	@rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
-	$(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
- -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \
-	    || { rm -rf $(TEMPDIR); exit 1; }
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
-		|| echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes."
-	$(QUIETLY) rm -rf $(TEMPDIR)
-
-
-# #########################################################################
-
-$(SOURCE.AD): $(SOURCES.AD)
-	$(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)
-
-#PROCESS_AD_FILES = cat
-# Pass through #line directives, in case user enables -g option above:
-PROCESS_AD_FILES = awk '{ \
-    if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
-    if (need_lineno && $$0 !~ /\/\//) \
-      { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
-    print }'
-
-$(OUTDIR)/%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
-
-# Some object files are given a prefix, to disambiguate
-# them from objects of the same name built for the VM.
-$(OUTDIR)/adlc-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
-
-# #########################################################################
-
-clean	:
-	rm $(OBJECTS)
-
-cleanall :
-	rm $(OBJECTS) $(EXEC)
-
-# #########################################################################
-
-.PHONY: all dump refresh_adfiles clean cleanall
diff --git a/hotspot/make/bsd/makefiles/amd64.make b/hotspot/make/bsd/makefiles/amd64.make
deleted file mode 100644
index 6512375..0000000
--- a/hotspot/make/bsd/makefiles/amd64.make
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-# Must also specify if CPU is little endian
-CFLAGS += -DVM_LITTLE_ENDIAN
-
-CFLAGS += -D_LP64=1
-
-# The serviceability agent relies on frame pointer (%rbp) to walk thread stack
-ifndef USE_SUNCC
-  CFLAGS += -fno-omit-frame-pointer
-endif
-
-OPT_CFLAGS/compactingPermGenGen.o = -O1
-
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/sharedRuntimeTrig.o += -g
-   OPT_CFLAGS/sharedRuntimeTrans.o += -g
-   OPT_CFLAGS/compactingPermGenGen.o += -g
-endif
diff --git a/hotspot/make/bsd/makefiles/arm.make b/hotspot/make/bsd/makefiles/arm.make
deleted file mode 100644
index 9e6fdd5..0000000
--- a/hotspot/make/bsd/makefiles/arm.make
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-Obj_Files += bsd_arm.o
-
-CFLAGS += -DVM_LITTLE_ENDIAN
diff --git a/hotspot/make/bsd/makefiles/build_vm_def.sh b/hotspot/make/bsd/makefiles/build_vm_def.sh
deleted file mode 100644
index 9191863..0000000
--- a/hotspot/make/bsd/makefiles/build_vm_def.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# If we're cross compiling use that path for nm
-if [ "$CROSS_COMPILE_ARCH" != "" ]; then 
-NM=$ALT_COMPILER_PATH/nm
-else
-NM=nm
-fi
-
-$NM -Uj $* | awk '
-   { if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 }
-   '
diff --git a/hotspot/make/bsd/makefiles/buildtree.make b/hotspot/make/bsd/makefiles/buildtree.make
deleted file mode 100644
index 3ae09d3..0000000
--- a/hotspot/make/bsd/makefiles/buildtree.make
+++ /dev/null
@@ -1,370 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Usage:
-#
-# $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch
-#         GAMMADIR=dir OS_FAMILY=os VARIANT=variant
-#
-# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the
-# environment or on the command-line:
-#
-# ARCH		- sparc, i486, ... HotSpot cpu and os_cpu source directory
-# BUILDARCH     - build directory
-# LIBARCH       - the corresponding directory in JDK/JRE
-# GAMMADIR	- top of workspace
-# OS_FAMILY	- operating system
-# VARIANT	- core, compiler1, compiler2, or tiered
-# VERSION_STRING - the JDK version string as specified by JEP-223
-# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build
-#
-# Builds the directory trees with makefiles plus some convenience files in
-# each directory:
-#
-# Makefile	- for "make foo"
-# flags.make	- with macro settings
-# vm.make	- to support making "$(MAKE) -v vm.make" in makefiles
-# adlc.make	-
-# trace.make	- generate tracing event and type definitions
-# jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
-#
-# The makefiles are split this way so that "make foo" will run faster by not
-# having to read the dependency files for the vm.
-
-# needs to be set here since this Makefile doesn't include defs.make
-OS_VENDOR:=$(shell uname -s)
-
--include $(SPEC)
-include $(GAMMADIR)/make/scm.make
-include $(GAMMADIR)/make/defs.make
-include $(GAMMADIR)/make/altsrc.make
-
-
-# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)	= @
-
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
-else
-  ifdef USE_SUNCC
-    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc
-  else
-    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
-  endif
-endif
-
-# Allow overriding of the arch part of the directory but default
-# to BUILDARCH if nothing is specified
-ifeq ($(VARIANTARCH),)
-  VARIANTARCH=$(BUILDARCH)
-endif
-
-ifdef FORCE_TIERED
-ifeq		($(VARIANT),tiered)
-PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_compiler2
-else
-PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
-endif
-else
-PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
-endif
-
-#
-# We do two levels of exclusion in the shared directory.
-# TOPLEVEL excludes are pruned, they are not recursively searched,
-# but lower level directories can be named without fear of collision.
-# ALWAYS excludes are excluded at any level in the directory tree.
-#
-
-ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
-
-ifeq		($(VARIANT),tiered)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
-else
-ifeq		($(VARIANT),compiler2)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
-else
-# compiler1 and core use the same exclude list
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
-endif
-endif
-
-# Get things from the platform file.
-COMPILER	= $(shell sed -n 's/^compiler[ 	]*=[ 	]*//p' $(PLATFORM_FILE))
-
-# dtracefiles is used on BSD versions that implement Dtrace (like MacOS X)
-SIMPLE_DIRS	= \
-	$(PLATFORM_DIR)/generated/dependencies \
-	$(PLATFORM_DIR)/generated/adfiles \
-	$(PLATFORM_DIR)/generated/jvmtifiles \
-	$(PLATFORM_DIR)/generated/tracefiles \
-	$(PLATFORM_DIR)/generated/dtracefiles
-
-TARGETS      = debug fastdebug optimized product
-SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
-
-# For dependencies and recursive makes.
-BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
-
-# dtrace.make is used on BSD versions that implement Dtrace (like MacOS X)
-BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make dtrace.make
-
-BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
-	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
-
-# Define variables to be set in flags.make.
-# Default values are set in make/defs.make.
-
-# Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
-endif
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell whoami)
-endif
-# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
-# or make/hotspot_distro.
-ifndef HOTSPOT_VM_DISTRO
-  ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    include $(GAMMADIR)/make/hotspot_distro
-  else
-    include $(GAMMADIR)/make/openjdk_distro
-  endif
-endif
-
-# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
-ifndef OPENJDK
-  ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    OPENJDK=true
-  endif
-endif
-
-BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-
-BUILDTREE	= \
-	$(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
-
-BUILDTREE_COMMENT	= echo "\# Generated by $(BUILDTREE_MAKE)"
-
-all:  $(SUBMAKE_DIRS)
-
-# Run make in each subdirectory recursively.
-$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
-	$(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
-	+$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
-	$(QUIETLY) touch $@
-
-$(SIMPLE_DIRS):
-	$(QUIETLY) mkdir -p $@
-
-# Convenience macro which takes a source relative path, applies $(1) to the
-# absolute path, and then replaces $(GAMMADIR) in the result with a
-# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.
-gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
-
-# This bit is needed to enable local rebuilds.
-# Unless the makefile itself sets LP64, any environmental
-# setting of LP64 will interfere with the build.
-LP64_SETTING/32 = LP64 = \#empty
-LP64_SETTING/64 = LP64 = 1
-
-DATA_MODE/i486 = 32
-DATA_MODE/amd64 = 64
-
-DATA_MODE = $(DATA_MODE/$(BUILDARCH))
-
-flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
-	sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
-	echo; \
-	echo "GAMMADIR = $(GAMMADIR)"; \
-	echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
-	echo "OSNAME = $(OSNAME)"; \
-	echo "SYSDEFS = \$$(Platform_sysdefs)"; \
-	echo "SRCARCH = $(SRCARCH)"; \
-	echo "BUILDARCH = $(BUILDARCH)"; \
-	echo "LIBARCH = $(LIBARCH)"; \
-	echo "TARGET = $(TARGET)"; \
-	echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \
-	echo "VERSION_STRING = $(VERSION_STRING)"; \
-	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
-	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
-	echo "OPENJDK = $(OPENJDK)"; \
-	echo "$(LP64_SETTING/$(DATA_MODE))"; \
-	echo; \
-	echo "STATIC_BUILD = $(STATIC_BUILD)"; \
-	echo "COMPILER_WARNINGS_FATAL = $(COMPILER_WARNINGS_FATAL)"; \
-	echo "EXTRA_LDFLAGS = $(EXTRA_LDFLAGS)"; \
-	echo "LIBRARY_SUFFIX = $(LIBRARY_SUFFIX)"; \
-	echo; \
-	echo "# Used for platform dispatching"; \
-	echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
-	echo "CFLAGS += \$$(TARGET_DEFINES)"; \
-	echo; \
-	echo "Src_Dirs_V = \\"; \
-	sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
-	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	echo; \
-	echo "Src_Dirs_I = \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	[ -n "$(CFLAGS_BROWSE)" ] && \
-	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
-	[ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
-	    echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
-	[ -n "$(OBJCOPY)" ] && \
-	    echo && echo "OBJCOPY = $(OBJCOPY)"; \
-	[ -n "$(STRIP_POLICY)" ] && \
-	    echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
-	[ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
-	    echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
-	[ -n "$(ZIPEXE)" ] && \
-	    echo && echo "ZIPEXE = $(ZIPEXE)"; \
-	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
-	    echo && \
-	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
-	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
-	echo; \
-	[ -n "$(SPEC)" ] && \
-	    echo "include $(SPEC)"; \
-	echo "CP ?= cp"; \
-	echo "MV ?= mv"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
-	echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
-	) > $@
-
-flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
-	) > $@
-
-../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
-	@echo $(LOG_INFO) Creating directory list $@
-	$(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
-          find $(HS_ALT_SRC)/share/vm/* -prune \
-	  -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-          \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
-        fi;
-	$(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
-	-type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
-
-Makefile: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
-	) > $@
-
-vm.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo include flags_vm.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-adlc.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-jvmti.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-trace.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-dtrace.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-FORCE:
-
-.PHONY:  all FORCE
-
-.NOTPARALLEL:
diff --git a/hotspot/make/bsd/makefiles/compiler1.make b/hotspot/make/bsd/makefiles/compiler1.make
deleted file mode 100644
index d303bfc..0000000
--- a/hotspot/make/bsd/makefiles/compiler1.make
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making client version of VM
-
-TYPE=COMPILER1
-
-VM_SUBDIR = client
-
-# We don't support the JVMCI in a client VM.
-INCLUDE_JVMCI := false
-
-CFLAGS += -DCOMPILER1
diff --git a/hotspot/make/bsd/makefiles/compiler2.make b/hotspot/make/bsd/makefiles/compiler2.make
deleted file mode 100644
index c881079..0000000
--- a/hotspot/make/bsd/makefiles/compiler2.make
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making server version of VM
-
-TYPE=COMPILER2
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2
diff --git a/hotspot/make/bsd/makefiles/core.make b/hotspot/make/bsd/makefiles/core.make
deleted file mode 100644
index e032d96..0000000
--- a/hotspot/make/bsd/makefiles/core.make
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-# Sets make macros for making core version of VM
-
-# Select which files to use (in top.make)
-TYPE=CORE
-
-# There is no "core" directory in JDK. Install core build in server directory.
-VM_SUBDIR = server
-
-# Note:  macros.hpp defines CORE
diff --git a/hotspot/make/bsd/makefiles/cscope.make b/hotspot/make/bsd/makefiles/cscope.make
deleted file mode 100644
index 7a12b3b..0000000
--- a/hotspot/make/bsd/makefiles/cscope.make
+++ /dev/null
@@ -1,160 +0,0 @@
-#
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-#
-# The cscope.out file is made in the current directory and spans the entire
-# source tree.
-#
-# Things to note:
-#	1. We use relative names for cscope.
-#	2. We *don't* remove the old cscope.out file, because cscope is smart
-#	   enough to only build what has changed.  It can be confused, however,
-#	   if files are renamed or removed, so it may be necessary to manually
-#	   remove cscope.out if a lot of reorganization has occurred.
-#
-
-include $(GAMMADIR)/make/scm.make
-
-NAWK	= awk
-RM	= rm -f
-HG	= hg
-CS_TOP	= ../..
-
-CSDIRS	= $(CS_TOP)/src $(CS_TOP)/build
-CSINCS	= $(CSDIRS:%=-I%)
-
-CSCOPE		= cscope
-CSCOPE_FLAGS	= -b
-
-# Allow .java files to be added from the environment (CSCLASSES=yes).
-ifdef	CSCLASSES
-ADDCLASSES=	-o -name '*.java'
-endif
-
-# Adding CClassHeaders also pushes the file count of a full workspace up about
-# 200 files (these files also don't exist in a new workspace, and thus will
-# cause the recreation of the database as they get created, which might seem
-# a little confusing).  Thus allow these files to be added from the environment
-# (CSHEADERS=yes).
-ifndef	CSHEADERS
-RMCCHEADERS=	-o -name CClassHeaders
-endif
-
-# Use CS_GENERATED=x to include auto-generated files in the build directories.
-ifdef	CS_GENERATED
-CS_ADD_GENERATED	= -o -name '*.incl'
-else
-CS_PRUNE_GENERATED	= -o -name '${OS}_*_core' -o -name '${OS}_*_compiler?'
-endif
-
-# OS-specific files for other systems are excluded by default.  Use CS_OS=yes
-# to include platform-specific files for other platforms.
-ifndef	CS_OS
-CS_OS		= linux macos solaris win32 bsd
-CS_PRUNE_OS	= $(patsubst %,-o -name '*%*',$(filter-out ${OS},${CS_OS}))
-endif
-
-# Processor-specific files for other processors are excluded by default.  Use
-# CS_CPU=x to include platform-specific files for other platforms.
-ifndef	CS_CPU
-CS_CPU		= i486 sparc amd64 ia64
-CS_PRUNE_CPU	= $(patsubst %,-o -name '*%*',$(filter-out ${SRCARCH},${CS_CPU}))
-endif
-
-# What files should we include?  A simple rule might be just those files under
-# SCCS control, however this would miss files we create like the opcodes and
-# CClassHeaders.  The following attempts to find everything that is *useful*.
-# (.del files are created by sccsrm, demo directories contain many .java files
-# that probably aren't useful for development, and the pkgarchive may contain
-# duplicates of files within the source hierarchy).
-
-# Directories to exclude.
-CS_PRUNE_STD	= $(SCM_DIRS) \
-		  -o -name '.del-*' \
-		  -o -name '*demo' \
-		  -o -name pkgarchive
-
-CS_PRUNE	= $(CS_PRUNE_STD) \
-		  $(CS_PRUNE_OS) \
-		  $(CS_PRUNE_CPU) \
-		  $(CS_PRUNE_GENERATED) \
-		  $(RMCCHEADERS)
-
-# File names to include.
-CSFILENAMES	= -name '*.[ch]pp' \
-		  -o -name '*.[Ccshlxy]' \
-		  $(CS_ADD_GENERATED) \
-		  -o -name '*.il' \
-		  -o -name '*.cc' \
-		  -o -name '*[Mm]akefile*' \
-		  -o -name '*.gmk' \
-		  -o -name '*.make' \
-		  -o -name '*.ad' \
-		  $(ADDCLASSES)
-
-.PRECIOUS:	cscope.out
-
-cscope cscope.out: cscope.files FORCE
-	$(CSCOPE) $(CSCOPE_FLAGS)
-
-# The .raw file is reordered here in an attempt to make cscope display the most
-# relevant files first.
-cscope.files: .cscope.files.raw
-	echo "$(CSINCS)" > $@
-	-egrep -v "\.java|\/make\/"	$< >> $@
-	-fgrep ".java"			$< >> $@
-	-fgrep "/make/"		$< >> $@
-
-.cscope.files.raw:  .nametable.files
-	-find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \
-	    -type f \( $(CSFILENAMES) \) -print > $@
-
-cscope.clean:  nametable.clean
-	-$(RM) cscope.out cscope.files .cscope.files.raw
-
-TAGS:  cscope.files FORCE
-	egrep -v '^-|^$$' $< | etags --members -
-
-TAGS.clean:  nametable.clean
-	-$(RM) TAGS
-
-# .nametable.files and .nametable.files.tmp are used to determine if any files
-# were added to/deleted from/renamed in the workspace.  If not, then there's
-# normally no need to rebuild the cscope database. To force a rebuild of
-# the cscope database: gmake nametable.clean.
-.nametable.files:  .nametable.files.tmp
-	( cmp -s $@ $< ) || ( cp $< $@ )
-	-$(RM) $<
-
-# `hg status' is slightly faster than `hg fstatus'. Both are
-# quite a bit slower on an NFS mounted file system, so this is
-# really geared towards repos on local file systems.
-.nametable.files.tmp:
-	-$(HG) fstatus -acmn > $@
-nametable.clean:
-	-$(RM) .nametable.files .nametable.files.tmp
-
-FORCE:
-
-.PHONY:		cscope cscope.clean TAGS.clean nametable.clean FORCE
diff --git a/hotspot/make/bsd/makefiles/debug.make b/hotspot/make/bsd/makefiles/debug.make
deleted file mode 100644
index 1c4ef14..0000000
--- a/hotspot/make/bsd/makefiles/debug.make
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS)
-DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
-
-# _NMT_NOINLINE_ informs NMT that no inlining by Compiler
-CFLAGS += $(DEBUG_CFLAGS/BYFILE) -D_NMT_NOINLINE_
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug
-ifeq ($(OS_VENDOR), Darwin)
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-debug
-endif
-
-VERSION = debug
-SYSDEFS += -DASSERT
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/bsd/makefiles/defs.make b/hotspot/make/bsd/makefiles/defs.make
deleted file mode 100644
index 795bf57..0000000
--- a/hotspot/make/bsd/makefiles/defs.make
+++ /dev/null
@@ -1,382 +0,0 @@
-#
-# Copyright (c) 2006, 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
-# 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.
-#
-#
-
-# The common definitions for hotspot bsd builds.
-# Include the top level defs.make under make directory instead of this one.
-# This file is included into make/defs.make.
-
-SLASH_JAVA ?= /java
-
-define print_info
-  ifneq ($$(LOG_LEVEL), warn)
-    $$(shell echo >&2 "INFO: $1")
-  endif
-endef
-
-# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name
-ARCH:=$(shell uname -m)
-PATH_SEP = :
-ifeq ($(LP64), 1)
-  ARCH_DATA_MODEL ?= 64
-else
-  ARCH_DATA_MODEL ?= 32
-endif
-
-# zero
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    MAKE_ARGS      += LP64=1
-  endif
-  PLATFORM         = bsd-zero
-  VM_PLATFORM      = bsd_$(subst i386,i486,$(ZERO_LIBARCH))
-  HS_ARCH          = zero
-  ARCH             = zero
-endif
-
-# ia64
-ifeq ($(ARCH), ia64)
-  ARCH_DATA_MODEL = 64
-  MAKE_ARGS      += LP64=1
-  PLATFORM        = bsd-ia64
-  VM_PLATFORM     = bsd_ia64
-  HS_ARCH         = ia64
-endif
-
-# sparc
-ifeq ($(ARCH), sparc64)
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    ARCH_DATA_MODEL  = 64
-    MAKE_ARGS        += LP64=1
-    PLATFORM         = bsd-sparcv9
-    VM_PLATFORM      = bsd_sparcv9
-  else
-    ARCH_DATA_MODEL  = 32
-    PLATFORM         = bsd-sparc
-    VM_PLATFORM      = bsd_sparc
-  endif
-  HS_ARCH            = sparc
-endif
-
-# amd64
-ifneq (,$(findstring $(ARCH), amd64 x86_64))
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    ARCH_DATA_MODEL = 64
-    MAKE_ARGS       += LP64=1
-    PLATFORM        = bsd-amd64
-    VM_PLATFORM     = bsd_amd64
-    HS_ARCH         = x86
-  else
-    ARCH_DATA_MODEL = 32
-    PLATFORM        = bsd-i586
-    VM_PLATFORM     = bsd_i486
-    HS_ARCH         = x86
-    # We have to reset ARCH to i386 since SRCARCH relies on it
-    ARCH            = i386
-  endif
-endif
-
-# i386
-ifeq ($(ARCH), i386)
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    ARCH_DATA_MODEL = 64
-    MAKE_ARGS       += LP64=1
-    PLATFORM        = bsd-amd64
-    VM_PLATFORM     = bsd_amd64
-    HS_ARCH         = x86
-    # We have to reset ARCH to amd64 since SRCARCH relies on it
-    ARCH            = amd64
-  else
-    ARCH_DATA_MODEL  = 32
-    PLATFORM         = bsd-i586
-    VM_PLATFORM      = bsd_i486
-    HS_ARCH          = x86
-  endif
-endif
-
-# ARM
-ifeq ($(ARCH), arm)
-  ARCH_DATA_MODEL  = 32
-  PLATFORM         = bsd-arm
-  VM_PLATFORM      = bsd_arm
-  HS_ARCH          = arm
-endif
-
-# PPC
-ifeq ($(ARCH), ppc)
-  ARCH_DATA_MODEL  = 32
-  PLATFORM         = bsd-ppc
-  VM_PLATFORM      = bsd_ppc
-  HS_ARCH          = ppc
-endif
-
-# On 32 bit bsd we build server and client, on 64 bit just server.
-ifeq ($(JVM_VARIANTS),)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    JVM_VARIANTS:=client,server
-    JVM_VARIANT_CLIENT:=true
-    JVM_VARIANT_SERVER:=true
-  else
-    JVM_VARIANTS:=server
-    JVM_VARIANT_SERVER:=true
-  endif
-endif
-
-OS_VENDOR:=$(shell uname -s)
-
-# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product
-# builds is enabled with debug info files ZIP'ed to save space. For
-# BUILD_FLAVOR != product builds, FDS is always enabled, after all a
-# debug build without debug info isn't very useful.
-# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled.
-#
-# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
-# disabled for a BUILD_FLAVOR == product build.
-#
-# Note: Use of a different variable name for the FDS override option
-# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
-# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
-# in options via environment variables, use of distinct variables
-# prevents strange behaviours. For example, in a BUILD_FLAVOR !=
-# product build, the FULL_DEBUG_SYMBOLS environment variable will be
-# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If
-# the same variable name is used, then different values can be picked
-# up by different parts of the build. Just to be clear, we only need
-# two variable names because the incoming option value can be
-# overridden in some situations, e.g., a BUILD_FLAVOR != product
-# build.
-
-# Due to the multiple sub-make processes that occur this logic gets
-# executed multiple times. We reduce the noise by at least checking that
-# BUILD_FLAVOR has been set.
-ifneq ($(BUILD_FLAVOR),)
-  # FULL_DEBUG_SYMBOLS not created for individual static libraries
-  ifeq ($(STATIC_BUILD),false)
-    ifeq ($(BUILD_FLAVOR), product)
-      FULL_DEBUG_SYMBOLS ?= 1
-      ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
-    else
-      # debug variants always get Full Debug Symbols (if available)
-      ENABLE_FULL_DEBUG_SYMBOLS = 1
-    endif
-  endif
-  $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-  # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(OS_VENDOR), Darwin)
-        # MacOS X doesn't use OBJCOPY or STRIP_POLICY
-        OBJCOPY=
-        STRIP_POLICY=
-        ZIP_DEBUGINFO_FILES ?= 1
-    else
-      # Default OBJCOPY comes from GNU Binutils on BSD
-      ifeq ($(CROSS_COMPILE_ARCH),)
-        DEF_OBJCOPY=/usr/bin/objcopy
-      else
-        # Assume objcopy is part of the cross-compilation toolset
-        ifneq ($(ALT_COMPILER_PATH),)
-          DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy
-        endif
-      endif
-      OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
-      ifneq ($(ALT_OBJCOPY),)
-        $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)"))
-        OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
-      endif
-
-      ifeq ($(OBJCOPY),)
-        $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo" \
-            "files. You may need to set ALT_OBJCOPY."))
-        ENABLE_FULL_DEBUG_SYMBOLS=0
-        $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-      else
-        $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo" \
-            "files."))
-
-        # Library stripping policies for .debuginfo configs:
-        #   all_strip - strips everything from the library
-        #   min_strip - strips most stuff from the library; leaves
-        #               minimum symbols
-        #   no_strip  - does not strip the library at all
-        #
-        # Oracle security policy requires "all_strip". A waiver was
-        # granted on 2011.09.01 that permits using "min_strip" in the
-        # Java JDK and Java JRE.
-        #
-        # Currently, STRIP_POLICY is only used when Full Debug Symbols
-        # is enabled.
-        #
-        STRIP_POLICY ?= min_strip
-
-        $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)"))
-
-        ZIP_DEBUGINFO_FILES ?= 1
-      endif
-
-      $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)"))
-    endif
-  endif # ENABLE_FULL_DEBUG_SYMBOLS=1
-endif # BUILD_FLAVOR
-
-JDK_INCLUDE_SUBDIR=bsd
-
-# Library suffix
-ifneq ($(STATIC_BUILD),true)
-ifeq ($(OS_VENDOR),Darwin)
-  LIBRARY_SUFFIX=dylib
-else
-  LIBRARY_SUFFIX=so
-endif
-else
-  LIBRARY_SUFFIX=a
-endif
-
-
-EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
-
-# jsig library not needed for static builds
-ifneq ($(STATIC_BUILD),true)
-  # client and server subdirectories have symbolic links to ../libjsig.so
-  EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
-endif
-
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-      EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz
-  else
-    ifeq ($(OS_VENDOR), Darwin)
-        EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX).dSYM
-    else
-        EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo
-    endif
-  endif
-endif
-
-EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server
-EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client
-EXPORT_MINIMAL_DIR = $(EXPORT_LIB_ARCH_DIR)/minimal
-
-ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
-  ifeq ($(STATIC_BUILD),true)
-    EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.symbols
-  endif
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-        EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz
-    else
-      ifeq ($(OS_VENDOR), Darwin)
-          EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX).dSYM
-      else
-          EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
-      endif
-    endif
-  endif
-endif
-
-ifeq ($(JVM_VARIANT_CLIENT),true)
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
-  ifeq ($(STATIC_BUILD),true)
-    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.symbols
-  endif
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-        EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz
-    else
-      ifeq ($(OS_VENDOR), Darwin)
-          EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX).dSYM
-      else
-          EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
-      endif
-    endif
-  endif
-endif
-
-ifeq ($(JVM_VARIANT_MINIMAL1),true)
-  EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.$(LIBRARY_SUFFIX)
-  ifeq ($(STATIC_BUILD),true)
-    EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.symbols
-  endif
-endif
-
-# Universal build settings
-ifeq ($(OS_VENDOR), Darwin)
-  # Build universal binaries by default on Mac OS X
-  MACOSX_UNIVERSAL = true
-  ifneq ($(ALT_MACOSX_UNIVERSAL),)
-    MACOSX_UNIVERSAL = $(ALT_MACOSX_UNIVERSAL)
-  endif
-  MAKE_ARGS += MACOSX_UNIVERSAL=$(MACOSX_UNIVERSAL)
-
-  # Universal settings
-  ifeq ($(MACOSX_UNIVERSAL), true)
-
-    # Set universal export path but avoid using ARCH or PLATFORM subdirs
-    EXPORT_PATH=$(OUTPUTDIR)/export-universal$(EXPORT_SUBDIR)
-    ifneq ($(ALT_EXPORT_PATH),)
-      EXPORT_PATH=$(ALT_EXPORT_PATH)
-    endif
-
-    # Set universal image dir
-    JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-universal$(EXPORT_SUBDIR)
-    ifneq ($(ALT_JDK_IMAGE_DIR),)
-      JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR)
-    endif
-
-    # Binaries to 'universalize' if built
-    ifneq ($(STATIC_BUILD),true)
-    UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX)
-    endif
-    UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX)
-    UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX)
-
-    # Files to simply copy in place
-    UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/Xusage.txt
-    UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/Xusage.txt
-
-    ifeq ($(STATIC_BUILD),true)
-      UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.symbols
-      UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.symbols
-      UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/minimal/libjvm.symbols
-    endif
-
-    ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-      ifeq ($(ZIP_DEBUGINFO_FILES),1)
-          UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.diz
-          UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.diz
-          UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/libjsig.diz
-      else
-          UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX).dSYM
-          UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX).dSYM
-          UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX).dSYM
-      endif
-    endif
-
-  endif
-endif
diff --git a/hotspot/make/bsd/makefiles/dtrace.make b/hotspot/make/bsd/makefiles/dtrace.make
deleted file mode 100644
index e2af31e..0000000
--- a/hotspot/make/bsd/makefiles/dtrace.make
+++ /dev/null
@@ -1,333 +0,0 @@
-#
-# 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
-# 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.
-#  
-#
-
-# Rules to build jvm_db/dtrace, used by vm.make
-
-# We build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2
-# but not for CORE configuration.
-
-ifneq ("${TYPE}", "CORE")
-
-ifeq ($(OS_VENDOR), Darwin)
-# we build dtrace for macosx using USDT2 probes
-
-DtraceOutDir = $(GENERATED)/dtracefiles
-
-# Bsd does not build libjvm_db, does not compile on macosx
-# disabled in build: rule in vm.make
-JVM_DB = libjvm_db
-LIBJVM_DB = libjvm_db.$(LIBRARY_SUFFIX)
-
-LIBJVM_DB_DEBUGINFO   = libjvm_db.$(LIBRARY_SUFFIX).dSYM
-LIBJVM_DB_DIZ         = libjvm_db.diz
-
-JVM_DTRACE = jvm_dtrace
-LIBJVM_DTRACE = libjvm_dtrace.$(LIBRARY_SUFFIX)
-
-LIBJVM_DTRACE_DEBUGINFO   = libjvm_dtrace.$(LIBRARY_SUFFIX).dSYM
-LIBJVM_DTRACE_DIZ         = libjvm_dtrace.diz
-
-JVMOFFS = JvmOffsets
-JVMOFFS.o = $(JVMOFFS).o
-GENOFFS = generate$(JVMOFFS)
-
-DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace
-DTRACE_COMMON_SRCDIR = $(GAMMADIR)/src/os/posix/dtrace
-DTRACE = dtrace
-DTRACE.o = $(DTRACE).o
-
-# to remove '-g' option which causes link problems
-# also '-z nodefs' is used as workaround
-GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';)
-
-ifdef LP64
-DTRACE_OPTS = -D_LP64
-endif
-
-# making libjvm_db
-
-# Use mapfile with libjvm_db.so
-LIBJVM_DB_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_db
-
-# Use mapfile with libjvm_dtrace.so
-LIBJVM_DTRACE_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace
-
-LFLAGS_JVM_DB += $(PICFLAG) # -D_REENTRANT
-LFLAGS_JVM_DTRACE += $(PICFLAG) # -D_REENTRANT
-
-ISA = $(subst i386,i486,$(BUILDARCH))
-
-# Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so
-ifneq ("${ISA}","${BUILDARCH}")
-
-XLIBJVM_DIR = 64
-XLIBJVM_DB = $(XLIBJVM_DIR)/$(LIBJVM_DB)
-XLIBJVM_DTRACE = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE)
-XARCH = $(subst sparcv9,v9,$(shell echo $(ISA)))
-
-XLIBJVM_DB_DEBUGINFO       = $(XLIBJVM_DIR)/$(LIBJVM_DB_DEBUGINFO)
-XLIBJVM_DB_DIZ             = $(XLIBJVM_DIR)/$(LIBJVM_DB_DIZ)
-XLIBJVM_DTRACE_DEBUGINFO   = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DEBUGINFO)
-XLIBJVM_DTRACE_DIZ         = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DIZ)
-
-$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
-	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \
-		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c #-lc
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(OS_VENDOR), Darwin)
-	$(DSYMUTIL) $@
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-        # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR)
-        # is not in the archived name:
-	( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -r -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) )
-	$(RM) -r $(XLIBJVM_DB_DEBUGINFO)
-    endif
-  else
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DB_DEBUGINFO)
-        # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR)
-        # is not in the link name:
-        $(QUIETLY) ( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) )
-    ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-    else
-      ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-      # implied else here is no stripping at all
-      endif
-    endif
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-        # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR)
-        # is not in the archived name:
-	( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) )
-	$(RM) $(XLIBJVM_DB_DEBUGINFO)
-    endif
-  endif
-endif
-
-$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
-	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \
-		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(OS_VENDOR), Darwin)
-	$(DSYMUTIL) $@
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-        # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR)
-        # is not in the archived name:
-	( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -r -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) )
-	$(RM) -r $(XLIBJVM_DTRACE_DEBUGINFO)
-    endif
-  else
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DTRACE_DEBUGINFO)
-        # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR)
-        # is not in the link name:
-	( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) )
-    ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-    else
-      ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-      # implied else here is no stripping at all
-      endif
-    endif
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-        # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR)
-        # is not in the archived name:
-	( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) )
-	$(RM) $(XLIBJVM_DTRACE_DEBUGINFO)
-    endif
-  endif
-endif
-
-endif # ifneq ("${ISA}","${BUILDARCH}")
-
-LFLAGS_GENOFFS += -L.
-
-lib$(GENOFFS).$(LIBRARY_SUFFIX): $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
-                  $(LIBJVM.o)
-	$(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
-		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm
-
-$(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).$(LIBRARY_SUFFIX)
-	$(QUIETLY) $(LINK.CXX) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
-		./lib$(GENOFFS).$(LIBRARY_SUFFIX)
-
-# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
-$(JVMOFFS).h: $(GENOFFS)
-	$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -header > $@.tmp; touch $@; \
-	if diff $@.tmp $@ > /dev/null 2>&1 ; \
-	then rm -f $@.tmp; \
-	else rm -f $@; mv $@.tmp $@; \
-	fi
-
-$(JVMOFFS)Index.h: $(GENOFFS)
-	$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -index > $@.tmp; touch $@; \
-	if diff $@.tmp $@ > /dev/null 2>&1 ; \
-	then rm -f $@.tmp; \
-	else rm -f $@; mv $@.tmp $@; \
-	fi
-
-$(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
-	$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -table > $@.tmp; touch $@; \
-	if diff $@.tmp $@ > /dev/null 2>&1; \
-	then rm -f $@.tmp; \
-	else rm -f $@; mv $@.tmp $@; \
-	fi
-
-$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
-	$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
-
-$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
-		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -Wall # -lc
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(OS_VENDOR), Darwin)
-	$(DSYMUTIL) $@
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -r -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO)
-	$(RM) -r $(LIBJVM_DB_DEBUGINFO)
-    endif
-  else
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DB_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@
-    ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-    else
-      ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-      # implied else here is no stripping at all
-      endif
-    endif
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO)
-	$(RM) $(LIBJVM_DB_DEBUGINFO)
-    endif
-  endif
-endif
-
-$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I.  \
-		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(OS_VENDOR), Darwin)
-	$(DSYMUTIL) $@
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -r -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) 
-	$(RM) -r $(LIBJVM_DTRACE_DEBUGINFO)
-    endif
-  else
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DTRACE_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@
-    ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-    else
-      ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-      # implied else here is no stripping at all
-      endif
-    endif
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) 
-	$(RM) $(LIBJVM_DTRACE_DEBUGINFO)
-    endif
-  endif
-endif
-
-
-$(DtraceOutDir):
-	mkdir $(DtraceOutDir)
-
-# When building using a devkit, dtrace cannot find the correct preprocessor so
-# we run it explicitly before runing dtrace.
-$(DtraceOutDir)/hotspot.h: $(DTRACE_COMMON_SRCDIR)/hotspot.d | $(DtraceOutDir)
-	$(QUIETLY) $(CC) -E $(DTRACE_OPTS) -I. -x c $(DTRACE_COMMON_SRCDIR)/hotspot.d > $(DtraceOutDir)/hotspot.d
-	$(QUIETLY) $(DTRACE_PROG) -h -o $@ -s $(DtraceOutDir)/hotspot.d
-
-$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
-	$(QUIETLY) $(CC) -E $(DTRACE_OPTS) -I. -x c $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d > $(DtraceOutDir)/hotspot_jni.d
-	$(QUIETLY) $(DTRACE_PROG) -h -o $@ -s $(DtraceOutDir)/hotspot_jni.d
-
-$(DtraceOutDir)/hs_private.h: $(DTRACE_COMMON_SRCDIR)/hs_private.d | $(DtraceOutDir)
-	$(QUIETLY) $(CC) -E $(DTRACE_OPTS) -I. -x c $(DTRACE_COMMON_SRCDIR)/hs_private.d > $(DtraceOutDir)/hs_private.d
-	$(QUIETLY) $(DTRACE_PROG) -h -o $@ -s $(DtraceOutDir)/hs_private.d
-
-dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h 
-
-
-.PHONY: dtraceCheck
-
-SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
-systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
-
-ifneq ("$(systemDtraceFound)", "")
-DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
-else
-
-endif
-
-ifneq ("${DTRACE_PROG}", "")
-ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
-
-DTRACE_OBJS = $(DTRACE.o) #$(JVMOFFS.o)
-CFLAGS += -DDTRACE_ENABLED #$(DTRACE_INCL)
-
-
-dtraceCheck:
-
-dtrace_stuff: dtrace_gen_headers
-	$(QUIETLY) echo $(LOG_INFO) "dtrace headers generated"
-
-
-else # manually disabled
-
-dtraceCheck:
-	$(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled via environment variable"
-
-dtrace_stuff:
-
-endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
-
-else # No dtrace program found
-
-dtraceCheck:
-	$(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled: not supported by system"
-
-dtrace_stuff:
-
-endif # ifneq ("${dtraceFound}", "")
-
-endif # ifeq ($(OS_VENDOR), Darwin)
-
-
-else # CORE build
-
-dtraceCheck:
-	$(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled for CORE builds"
-
-endif # ifneq ("${TYPE}", "CORE")
diff --git a/hotspot/make/bsd/makefiles/fastdebug.make b/hotspot/make/bsd/makefiles/fastdebug.make
deleted file mode 100644
index d57e545..0000000
--- a/hotspot/make/bsd/makefiles/fastdebug.make
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS.
-
-FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# The following lines are copied from debug.make, except that we
-# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS.
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS)
-DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
-CFLAGS += $(DEBUG_CFLAGS/BYFILE)
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug
-ifeq ($(OS_VENDOR), Darwin)
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-debug
-endif
-
-VERSION = fastdebug
-SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make
deleted file mode 100644
index 1bf6521..0000000
--- a/hotspot/make/bsd/makefiles/gcc.make
+++ /dev/null
@@ -1,543 +0,0 @@
-#
-# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-OS_VENDOR = $(shell uname -s)
-
-#------------------------------------------------------------------------
-# CC, CXX & AS
-
-# If a SPEC is not set already, then use these defaults.
-ifeq ($(SPEC),)
-  # When cross-compiling the ALT_COMPILER_PATH points
-  # to the cross-compilation toolset
-  ifdef CROSS_COMPILE_ARCH
-    CXX = $(ALT_COMPILER_PATH)/g++
-    CC  = $(ALT_COMPILER_PATH)/gcc
-    HOSTCXX = g++
-    HOSTCC  = gcc
-  else ifneq ($(OS_VENDOR), Darwin)
-    CXX = g++
-    CC  = gcc
-    HOSTCXX = $(CXX)
-    HOSTCC  = $(CC)
-  endif
-
-  # i486 hotspot requires -mstackrealign on Darwin.
-  # llvm-gcc supports this in Xcode 3.2.6 and 4.0.
-  # gcc-4.0 supports this on earlier versions.
-  # Prefer llvm-gcc where available.
-  ifeq ($(OS_VENDOR), Darwin)
-    ifeq ($(origin CXX), default)
-      CXX = llvm-g++
-    endif
-    ifeq ($(origin CC), default)
-      CC  = llvm-gcc
-    endif
-
-    ifeq ($(ARCH), i486)
-      LLVM_SUPPORTS_STACKREALIGN := $(shell \
-       [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
-       && echo true || echo false)
-
-      ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
-        CXX32 ?= llvm-g++
-        CC32  ?= llvm-gcc
-      else
-        CXX32 ?= g++-4.0
-        CC32  ?= gcc-4.0
-      endif
-      CXX = $(CXX32)
-      CC  = $(CC32)
-    endif
-
-    ifeq ($(USE_CLANG), true)
-      CXX = clang++
-      CC  = clang
-    endif
-
-    HOSTCXX = $(CXX)
-    HOSTCC  = $(CC)
-  endif
-
-  AS  = $(CC) -c
-endif
-
-ifeq ($(OS_VENDOR), Darwin)
-  ifeq ($(DSYMUTIL),)
-    DSYMUTIL=dsymutil
-  endif
-endif
-
-ifeq ($(USE_CLANG), true)
-  CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1)
-  CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2)
-else
-  # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
-  # prints the numbers (e.g. "2.95", "3.2.1")
-  CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
-  CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
-  CC_VER_MICRO := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f3)
-endif
-
-ifeq ($(USE_CLANG), true)
-  # Clang has precompiled headers support by default, but the user can switch
-  # it off by using 'USE_PRECOMPILED_HEADER=0'.
-  ifdef LP64
-    ifeq ($(USE_PRECOMPILED_HEADER),)
-      USE_PRECOMPILED_HEADER=1
-    endif
-  else
-    # We don't support precompiled headers on 32-bit builds because there some files are
-    # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make)
-    # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit.
-    USE_PRECOMPILED_HEADER=0
-  endif
-
-  ifeq ($(USE_PRECOMPILED_HEADER),1)
-
-    ifndef LP64
-      $(error " Precompiled Headers only supported on 64-bit platforms!")
-    endif
-
-    PRECOMPILED_HEADER_DIR=.
-    PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
-    PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch
-
-    PCH_FLAG = -include precompiled.hpp
-    PCH_FLAG/DEFAULT = $(PCH_FLAG)
-    PCH_FLAG/NO_PCH = -DNO_PCH
-    PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))
-
-    VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)
-    VM_PCH_FLAG/AOUT =
-    VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))
-
-    # We only use precompiled headers for the JVM build
-    CFLAGS += $(VM_PCH_FLAG)
-
-    # The following files are compiled at various optimization
-    # levels due to optimization issues encountered at the
-    # 'OPT_CFLAGS_DEFAULT' level. The Clang compiler issues a compile
-    # time error if there is an optimization level specification
-    # skew between the PCH file and the C++ file.  Especially if the
-    # PCH file is compiled at a higher optimization level than
-    # the C++ file.  One solution might be to prepare extra optimization
-    # level specific PCH files for the opt build and use them here, but
-    # it's probably not worth the effort as long as only a few files
-    # need this special handling.
-    PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
-    PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
-    PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
-    PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH)
-    PCH_FLAG/jvmciCompilerToVM.o = $(PCH_FLAG/NO_PCH)
-
-  endif
-else # ($(USE_CLANG), true)
-  # check for precompiled headers support
-  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
-    # Allow the user to turn off precompiled headers from the command line.
-    ifneq ($(USE_PRECOMPILED_HEADER),0)
-      PRECOMPILED_HEADER_DIR=.
-      PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
-      PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
-    endif
-  endif
-endif
-
-# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
-ifeq ($(USE_PRECOMPILED_HEADER),0)
-  CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
-endif
-
-#------------------------------------------------------------------------
-# Compiler flags
-
-# position-independent code
-PICFLAG = -fPIC
-
-VM_PICFLAG/LIBJVM = $(PICFLAG)
-VM_PICFLAG/AOUT   =
-VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
-
-ifeq ($(JVM_VARIANT_ZERO), true)
-  CFLAGS += $(LIBFFI_CFLAGS)
-endif
-ifeq ($(JVM_VARIANT_ZEROSHARK), true)
-  CFLAGS += $(LIBFFI_CFLAGS)
-  CFLAGS += $(LLVM_CFLAGS)
-endif
-
-ifeq ($(STATIC_BUILD),true)
-CXXFLAGS += -DSTATIC_BUILD
-CFLAGS += -DSTATIC_BUILD
-else
-CFLAGS += $(VM_PICFLAG)
-endif
-
-CFLAGS += -fno-rtti
-CFLAGS += -fno-exceptions
-ifeq ($(USE_CLANG),)
-  CFLAGS += -pthread
-  CFLAGS += -fcheck-new
-  # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
-  # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
-  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-    CFLAGS += -fvisibility=hidden
-  endif
-else
-  CFLAGS += -fvisibility=hidden
-endif
-
-ifeq ($(USE_CLANG), true)
-  # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm'
-  # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment')
-  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0"
-    STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16
-  else
-    STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16
-  endif
-endif
-
-ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
-ARCHFLAG/i486    = -m32 -march=i586
-ARCHFLAG/amd64   = -m64 $(STACK_ALIGNMENT_OPT)
-ARCHFLAG/ia64    =
-ARCHFLAG/sparc   = -m32 -mcpu=v9
-ARCHFLAG/sparcv9 = -m64 -mcpu=v9
-ARCHFLAG/zero    = $(ZERO_ARCHFLAG)
-
-# Darwin-specific build flags
-ifeq ($(OS_VENDOR), Darwin)
-  # Ineffecient 16-byte stack re-alignment on Darwin/IA32
-  ARCHFLAG/i486 += -mstackrealign
-endif
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-ASFLAGS    += $(ARCHFLAG)
-
-ifdef E500V2
-CFLAGS += -DE500V2
-endif
-
-# Use C++ Interpreter
-ifdef CC_INTERP
-  CFLAGS += -DCC_INTERP
-endif
-
-# Keep temporary files (.ii, .s)
-ifdef NEED_ASM
-  CFLAGS += -save-temps
-else
-  CFLAGS += -pipe
-endif
-
-# Compiler warnings are treated as errors
-ifneq ($(COMPILER_WARNINGS_FATAL),false)
-  WARNINGS_ARE_ERRORS ?= -Werror
-endif
-
-ifeq ($(USE_CLANG), true)
-  # However we need to clean the code up before we can unrestrictedly enable this option with Clang
-  WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
-  WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare
-# Not yet supported by clang in Xcode 4.6.2
-#  WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare
-  WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
-  WARNINGS_ARE_ERRORS += -Wno-empty-body
-endif
-
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2
-
-ifeq ($(USE_CLANG),)
-  # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
-  # conversions which might affect the values. Only enable it in earlier versions.
-  ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-    WARNINGS_FLAGS += -Wconversion
-  endif
-endif
-
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
-# Special cases
-CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
-# XXXDARWIN: for _dyld_bind_fully_image_containing_address
-ifeq ($(OS_VENDOR), Darwin)
-  CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
-endif
-
-# optimization control flags (Used by fastdebug and release variants)
-OPT_CFLAGS/NOOPT=-O0
-OPT_CFLAGS/DEBUG=-O0
-OPT_CFLAGS/SIZE=-Os
-OPT_CFLAGS/SPEED=-O3
-
-ifeq ($(OS_VENDOR), Darwin)
-  # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
-  # <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata>
-  OPT_CFLAGS_DEFAULT ?= SIZE
-else
-  OPT_CFLAGS_DEFAULT ?= SPEED
-endif
-
-# Hotspot uses very unstrict aliasing turn this optimization off
-# This option is added to CFLAGS rather than OPT_CFLAGS
-# so that OPT_CFLAGS overrides get this option too.
-CFLAGS += -fno-strict-aliasing
-
-ifdef OPT_CFLAGS
-  ifneq ("$(origin OPT_CFLAGS)", "command line")
-    $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
-  endif
-endif
-
-OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
-
-# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
-# if we use expensive-optimizations
-ifeq ($(BUILDARCH), ia64)
-OPT_CFLAGS += -fno-expensive-optimizations
-endif
-
-# Work around some compiler bugs.
-ifeq ($(USE_CLANG), true)
-  # Clang < 6 | <= 6.1 | <= 7.0
-  ifeq ($(shell expr \
-      $(CC_VER_MAJOR) \< 6 \| \
-      \( $(CC_VER_MAJOR) = 6 \& $(CC_VER_MINOR) \<= 1 \) \| \
-      \( $(CC_VER_MAJOR) = 7 \& $(CC_VER_MINOR) \<= 0 \) \
-    ), 1)
-    OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
-    OPT_CFLAGS/unsafe.o += -O1
-
-    # The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-    # of OPT_CFLAGS. Restore it here.
-    ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-      OPT_CFLAGS/loopTransform.o += -g
-      OPT_CFLAGS/unsafe.o += -g
-    endif
-  else
-    $(error "Update compiler workarounds for Clang $(CC_VER_MAJOR).$(CC_VER_MINOR)")
-  endif
-else
-  # Do not allow GCC 4.1.1
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 1 \& $(CC_VER_MICRO) = 1), 1)
-    $(error "GCC $(CC_VER_MAJOR).$(CC_VER_MINOR).$(CC_VER_MICRO) not supported because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27724")
-  endif
-  # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
-    OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
-  endif 
-endif
-
-# Flags for generating make dependency flags.
-DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
-ifeq ($(USE_CLANG),)
-  ifneq ($(CC_VER_MAJOR), 2)
-    DEPFLAGS += -fpch-deps
-  endif
-endif
-
-# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
-ifeq ($(USE_PRECOMPILED_HEADER),0)
-CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
-endif
-
-ifeq ($(OS_VENDOR), Darwin)
-  # Setting these parameters makes it an error to link to macosx APIs that are
-  # newer than the given OS version and makes the linked binaries compatible even
-  # if built on a newer version of the OS.
-  # The expected format is X.Y.Z
-  ifeq ($(MACOSX_VERSION_MIN),)
-    MACOSX_VERSION_MIN=10.7.0
-  endif
-  # The macro takes the version with no dots, ex: 1070
-  CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
-            -mmacosx-version-min=$(MACOSX_VERSION_MIN)
-  LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
-endif
-
-
-#------------------------------------------------------------------------
-# Assembler flags
-
-# Enforce prerpocessing of .s files
-ASFLAGS += -x assembler-with-cpp
-
-#------------------------------------------------------------------------
-# Linker flags
-
-# statically link libstdc++.so, work with gcc but ignored by g++
-STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
-
-# Ensure use libstdc++ on clang, not libc++
-ifeq ($(USE_CLANG), true)
-  LFLAGS += -stdlib=libstdc++
-endif
-
-ifeq ($(USE_CLANG),)
-  # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
-  ifneq ($(CC_VER_MAJOR), 2)
-    STATIC_LIBGCC += -static-libgcc
-  endif
-
-  ifneq ($(OS_VENDOR), Darwin)
-    ifneq (, findstring(debug,$(BUILD_FLAVOR)))
-      # for relocations read-only
-      LFLAGS += -Xlinker -z -Xlinker relro
-
-      ifeq ($(BUILD_FLAVOR), debug)
-        # disable incremental relocations linking
-        LFLAGS += -Xlinker -z -Xlinker now
-      endif
-    endif
-  endif
-
-  ifeq ($(BUILDARCH), ia64)
-    LFLAGS += -Wl,-relax
-  endif
-endif
-
-# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-MAPFLAG = -Xlinker --version-script=FILENAME
-
-#
-# Shared Library
-#
-ifeq ($(OS_VENDOR), Darwin)
-  # Standard linker flags
-  LFLAGS +=
-
-  # The apple linker has its own variant of mapfiles/version-scripts
-  MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME
-
-  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-  SONAMEFLAG =
-
-  # Build shared library
-  SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)
-
-  # Keep symbols even they are not used
-  #AOUT_FLAGS += -Xlinker -export-dynamic
-else
-  # Enable linker optimization
-  LFLAGS += -Xlinker -O1
-
-  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-  SONAMEFLAG = -Xlinker -soname=SONAME
-
-  # Build shared library
-  SHARED_FLAG = -shared $(VM_PICFLAG)
-
-  # Keep symbols even they are not used
-  AOUT_FLAGS += -Xlinker -export-dynamic
-endif
-
-#------------------------------------------------------------------------
-# Debug flags
-
-ifeq ($(USE_CLANG), true)
-  # Restrict the debug information created by Clang to avoid
-  # too big object files and speed the build up a little bit
-  # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
-  CFLAGS += -flimit-debug-info
-endif
-
-# Allow no optimizations.
-DEBUG_CFLAGS=-O0
-
-# DEBUG_BINARIES uses full -g debug information for all configs
-ifeq ($(DEBUG_BINARIES), true)
-  CFLAGS += -g
-else
-  # Use the stabs format for debugging information (this is the default
-  # on gcc-2.91). It's good enough, has all the information about line
-  # numbers and local variables, and libjvm.so is only about 16M.
-  # Change this back to "-g" if you want the most expressive format.
-  # (warning: that could easily inflate libjvm.so to 150M!)
-  # Note: The Itanium gcc compiler crashes when using -gstabs.
-  DEBUG_CFLAGS/ia64  = -g
-  DEBUG_CFLAGS/amd64 = -g
-  DEBUG_CFLAGS/arm   = -g
-  DEBUG_CFLAGS/ppc   = -g
-  DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
-  ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
-      ifeq ($(USE_CLANG), true)
-        # Clang doesn't understand -gstabs
-        DEBUG_CFLAGS += -g
-      else
-        DEBUG_CFLAGS += -gstabs
-      endif
-  endif
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    FASTDEBUG_CFLAGS/ia64  = -g
-    FASTDEBUG_CFLAGS/amd64 = -g
-    FASTDEBUG_CFLAGS/arm   = -g
-    FASTDEBUG_CFLAGS/ppc   = -g
-    FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))
-    ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
-      ifeq ($(USE_CLANG), true)
-        # Clang doesn't understand -gstabs
-        FASTDEBUG_CFLAGS += -g
-      else
-        FASTDEBUG_CFLAGS += -gstabs
-      endif
-    endif
-
-    OPT_CFLAGS/ia64  = -g
-    OPT_CFLAGS/amd64 = -g
-    OPT_CFLAGS/arm   = -g
-    OPT_CFLAGS/ppc   = -g
-    OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
-    ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
-      ifeq ($(USE_CLANG), true)
-        # Clang doesn't understand -gstabs
-        OPT_CFLAGS += -g
-      else
-        OPT_CFLAGS += -gstabs
-      endif
-    endif
-  endif
-endif
-
-ifeq ($(USE_CLANG),)
-  # Enable bounds checking.
-  ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1"
-    # stack smashing checks.
-    DEBUG_CFLAGS += -fstack-protector-all --param ssp-buffer-size=1
-  endif
-endif
-
-# If we are building HEADLESS, pass on to VM
-# so it can set the java.awt.headless property
-ifdef HEADLESS
-CFLAGS += -DHEADLESS
-endif
-
-# We are building Embedded for a small device
-# favor code space over speed
-ifdef MINIMIZE_RAM_USAGE
-CFLAGS += -DMINIMIZE_RAM_USAGE
-endif
diff --git a/hotspot/make/bsd/makefiles/hp.make b/hotspot/make/bsd/makefiles/hp.make
deleted file mode 100644
index e0b262a..0000000
--- a/hotspot/make/bsd/makefiles/hp.make
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making premium version of VM
-
-TYPE=HP
-
-CFLAGS += -DCOMPILER2
diff --git a/hotspot/make/bsd/makefiles/hp1.make b/hotspot/make/bsd/makefiles/hp1.make
deleted file mode 100644
index 2e37a6e..0000000
--- a/hotspot/make/bsd/makefiles/hp1.make
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making premium version of VM
-
-TYPE=HP1
-
-CFLAGS += -DCOMPILER1
diff --git a/hotspot/make/bsd/makefiles/i486.make b/hotspot/make/bsd/makefiles/i486.make
deleted file mode 100644
index 86e825d..0000000
--- a/hotspot/make/bsd/makefiles/i486.make
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-# TLS helper, assembled from .s file
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-# Must also specify if CPU is little endian
-CFLAGS += -DVM_LITTLE_ENDIAN
-
-OPT_CFLAGS/compactingPermGenGen.o = -O1
diff --git a/hotspot/make/bsd/makefiles/ia64.make b/hotspot/make/bsd/makefiles/ia64.make
deleted file mode 100644
index 8535807..0000000
--- a/hotspot/make/bsd/makefiles/ia64.make
+++ /dev/null
@@ -1,41 +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.
-#  
-#
-
-#
-# IA64 only uses c++ based interpreter
-CFLAGS += -DCC_INTERP -D_LP64=1 -DVM_LITTLE_ENDIAN
-ifeq ($(VERSION),debug)
-ASM_FLAGS= -DDEBUG
-else
-ASM_FLAGS=
-endif
-# workaround gcc bug in compiling varargs
-OPT_CFLAGS/jni.o = -O0
-
-# gcc/ia64 has a bug that internal gcc functions linked with libjvm.so
-# are made public. Hiding those symbols will cause undefined symbol error
-# when VM is dropped into older JDK. We probably will need an IA64
-# mapfile to include those symbols as a workaround. Disable linker mapfile 
-# for now.
-LDNOMAP=true
diff --git a/hotspot/make/bsd/makefiles/jsig.make b/hotspot/make/bsd/makefiles/jsig.make
deleted file mode 100644
index 585a0f4..0000000
--- a/hotspot/make/bsd/makefiles/jsig.make
+++ /dev/null
@@ -1,110 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Rules to build signal interposition library, used by vm.make
-
-# libjsig.so: signal interposition library
-JSIG   = jsig
-
-ifeq ($(OS_VENDOR), Darwin)
-  LIBJSIG   = lib$(JSIG).$(LIBRARY_SUFFIX)
-
-  LIBJSIG_DEBUGINFO   = lib$(JSIG).$(LIBRARY_SUFFIX).dSYM
-  LIBJSIG_DIZ         = lib$(JSIG).diz
-else
-  LIBJSIG   = lib$(JSIG).so
-
-  LIBJSIG_DEBUGINFO   = lib$(JSIG).debuginfo
-  LIBJSIG_DIZ         = lib$(JSIG).diz
-endif
-
-JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
-
-DEST_JSIG           = $(JDK_LIBDIR)/$(LIBJSIG)
-DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO)
-DEST_JSIG_DIZ       = $(JDK_LIBDIR)/$(LIBJSIG_DIZ)
-
-LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
-
-# On Bsd we really dont want a mapfile, as this library is small
-# and preloaded using LD_PRELOAD, making functions private will
-# cause problems with interposing. See CR: 6466665
-# LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
-
-LFLAGS_JSIG += -D_GNU_SOURCE -pthread $(LDFLAGS_HASH_STYLE)
-
-# DEBUG_BINARIES overrides everything, use full -g debug information
-ifeq ($(DEBUG_BINARIES), true)
-  JSIG_DEBUG_CFLAGS = -g
-endif
-
-$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
-	@echo $(LOG_INFO) Making signal interposition lib...
-ifeq ($(STATIC_BUILD),true)
-	$(QUIETLY) $(CC) -c $(SYMFLAG) $(EXTRA_CFLAGS) $(ARCHFLAG) $(PICFLAG) \
-                          $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $(JSIG).o $<
-	$(QUIETLY) $(AR) $(ARFLAGS) $@ $(JSIG).o
-else
-	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
-                          $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) $(EXTRA_CFLAGS) -o $@ $<
-endif
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(OS_VENDOR), Darwin)
-	$(DSYMUTIL) $@
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -r -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO)
-	$(RM) -r $(LIBJSIG_DEBUGINFO)
-    endif
-  else
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
-    ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-    else
-      ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -g $@
-      # implied else here is no stripping at all
-      endif
-    endif
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO)
-	$(RM) $(LIBJSIG_DEBUGINFO)
-    endif
-  endif
-endif
-
-install_jsig: $(LIBJSIG)
-	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
-ifeq ($(OS_VENDOR), Darwin)
-	$(QUIETLY) test ! -d $(LIBJSIG_DEBUGINFO) || \
-	    $(CP) -f -r $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
-else
-	$(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \
-	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
-endif
-	$(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \
-	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
-
-.PHONY: install_jsig
diff --git a/hotspot/make/bsd/makefiles/jvmti.make b/hotspot/make/bsd/makefiles/jvmti.make
deleted file mode 100644
index cb22c2b..0000000
--- a/hotspot/make/bsd/makefiles/jvmti.make
+++ /dev/null
@@ -1,116 +0,0 @@
-#
-# Copyright (c) 2003, 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.
-#  
-#
-
-# This makefile (jvmti.make) is included from the jvmti.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate jvmti.
-
-include $(GAMMADIR)/make/bsd/makefiles/rules.make
-
-# #########################################################################
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-JvmtiOutDir = $(GENERATED)/jvmtifiles
-
-JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims
-InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(JvmtiSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-JvmtiGeneratedNames = \
-        jvmtiEnv.hpp \
-        jvmtiEnter.cpp \
-        jvmtiEnterTrace.cpp \
-        jvmtiEnvRecommended.cpp \
-        bytecodeInterpreterWithChecks.cpp \
-        jvmti.h \
-
-JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java
-JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class
-
-JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java
-JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class
-
-JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%)
-
-XSLT = $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-.PHONY: all jvmtidocs clean cleanall
-
-# #########################################################################
-
-all: $(JvmtiGeneratedFiles)
-
-both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl
-
-$(JvmtiGenClass): $(JvmtiGenSource)
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource)
-
-$(JvmtiEnvFillClass): $(JvmtiEnvFillSource)
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource)
-
-$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti
-
-$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp 
-
-$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace
-
-$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass)
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp
-	$(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp
-
-$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp
-
-$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h
-
-jvmtidocs:  $(JvmtiOutDir)/jvmti.html 
-
-$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html
-
-# #########################################################################
-
-clean :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-cleanall :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-# #########################################################################
diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug
deleted file mode 100644
index f92fe18..0000000
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-# Only used for OSX/Darwin builds
-
-# Define public interface.
-                _JVM_handle_bsd_signal
-
-		# miscellaneous functions
-                _jio_fprintf
-                _jio_printf
-                _jio_snprintf
-                _jio_vfprintf
-                _jio_vsnprintf
-
-                # This is for Forte Analyzer profiling support.
-                _AsyncGetCallTrace
-
-                # INSERT VTABLE SYMBOLS HERE
-
diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product
deleted file mode 100644
index 47b8549..0000000
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-# Only used for OSX/Darwin builds
-
-# Define public interface.
-                _JVM_handle_bsd_signal
-
-                # miscellaneous functions
-                _jio_fprintf
-                _jio_printf
-                _jio_snprintf
-                _jio_vfprintf
-                _jio_vsnprintf
-
-                # This is for Forte Analyzer profiling support.
-                _AsyncGetCallTrace
-
-                # INSERT VTABLE SYMBOLS HERE
-
diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-debug b/hotspot/make/bsd/makefiles/mapfile-vers-debug
deleted file mode 100644
index ec0f06d..0000000
--- a/hotspot/make/bsd/makefiles/mapfile-vers-debug
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                JVM_handle_linux_signal;
-
-                # miscellaneous functions
-                jio_fprintf;
-                jio_printf;
-                jio_snprintf;
-                jio_vfprintf;
-                jio_vsnprintf;
-                numa_warn;
-                numa_error;
-
-                # Needed because there is no JVM interface for this.
-                sysThreadAvailableStackWithSlack;
-
-                # This is for Forte Analyzer profiling support.
-                AsyncGetCallTrace;
-
-		# INSERT VTABLE SYMBOLS HERE
-
-        local:
-                *;
-};
-
diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-jsig b/hotspot/make/bsd/makefiles/mapfile-vers-jsig
deleted file mode 100644
index 8a67504..0000000
--- a/hotspot/make/bsd/makefiles/mapfile-vers-jsig
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-
-#
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Define library interface.
-
-SUNWprivate_1.1 {
-        global:
-            JVM_begin_signal_setting;
-            JVM_end_signal_setting;
-            JVM_get_libjsig_version;
-            JVM_get_signal_action;
-            sigaction;
-            signal;
-            sigset;
-        local:
-                *;
-};
diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-product b/hotspot/make/bsd/makefiles/mapfile-vers-product
deleted file mode 100644
index ec0f06d..0000000
--- a/hotspot/make/bsd/makefiles/mapfile-vers-product
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                JVM_handle_linux_signal;
-
-                # miscellaneous functions
-                jio_fprintf;
-                jio_printf;
-                jio_snprintf;
-                jio_vfprintf;
-                jio_vsnprintf;
-                numa_warn;
-                numa_error;
-
-                # Needed because there is no JVM interface for this.
-                sysThreadAvailableStackWithSlack;
-
-                # This is for Forte Analyzer profiling support.
-                AsyncGetCallTrace;
-
-		# INSERT VTABLE SYMBOLS HERE
-
-        local:
-                *;
-};
-
diff --git a/hotspot/make/bsd/makefiles/minimal1.make b/hotspot/make/bsd/makefiles/minimal1.make
deleted file mode 100644
index d453e78..0000000
--- a/hotspot/make/bsd/makefiles/minimal1.make
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-TYPE=MINIMAL1
-
-# Force all variables to false, overriding any other
-# setting that may have occurred in the makefiles. These
-# can still be overridden by passing the variable as an
-# argument to 'make'
-INCLUDE_JVMTI := false
-INCLUDE_FPROF := false
-INCLUDE_VM_STRUCTS := false
-INCLUDE_JNI_CHECK := false
-INCLUDE_SERVICES := false
-INCLUDE_MANAGEMENT := false
-INCLUDE_ALL_GCS := false
-INCLUDE_NMT := false
-INCLUDE_TRACE := false
-INCLUDE_CDS := false
-INCLUDE_JVMCI := false
-
-CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
-CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
-
-Src_Dirs/MINIMAL1 = $(CORE_PATHS) $(COMPILER1_PATHS)
-
-Src_Files_EXCLUDE/MINIMAL1 += $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-
--include $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make
-
-.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make
diff --git a/hotspot/make/bsd/makefiles/optimized.make b/hotspot/make/bsd/makefiles/optimized.make
deleted file mode 100644
index f098efd..0000000
--- a/hotspot/make/bsd/makefiles/optimized.make
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-# Sets make macros for making optimized version of HotSpot VM
-# (This is the "product", not the "release" version.)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug
-ifeq ($(OS_VENDOR), Darwin)
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-debug
-endif
-
-VERSION = optimized
diff --git a/hotspot/make/bsd/makefiles/ppc.make b/hotspot/make/bsd/makefiles/ppc.make
deleted file mode 100644
index 92957f9..0000000
--- a/hotspot/make/bsd/makefiles/ppc.make
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-
-# Must also specify if CPU is big endian
-CFLAGS += -DVM_BIG_ENDIAN
-
diff --git a/hotspot/make/bsd/makefiles/product.make b/hotspot/make/bsd/makefiles/product.make
deleted file mode 100644
index 7d3c345..0000000
--- a/hotspot/make/bsd/makefiles/product.make
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making optimized version of HotSpot VM
-# (This is the "product", not the "release" version.)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-product
-ifeq ($(OS_VENDOR), Darwin)
-MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-product
-endif
-
-SYSDEFS += -DPRODUCT
-VERSION = optimized
-
-ifneq ($(OS_VENDOR), Darwin)
-  # use -g to strip library as -x will discard its symbol table; -x is fine for
-  # executables.
-  ifdef CROSS_COMPILE_ARCH
-    STRIP = $(ALT_COMPILER_PATH)/strip
-  else
-    STRIP = strip
-  endif
-  STRIP_LIBJVM = $(STRIP) -g $@ || exit 1;
-  STRIP_AOUT   = $(STRIP) -x $@ || exit 1;
-
-  # Don't strip in VM build; JDK build will strip libraries later
-  # LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO))
-endif
diff --git a/hotspot/make/bsd/makefiles/rules.make b/hotspot/make/bsd/makefiles/rules.make
deleted file mode 100644
index bb36f19..0000000
--- a/hotspot/make/bsd/makefiles/rules.make
+++ /dev/null
@@ -1,212 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Common rules/macros for the vm, adlc.
-
-# Tell make that .cpp is important
-.SUFFIXES: .cpp $(SUFFIXES)
-
-DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
-
-# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
-CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
-CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
-
-AS.S            = $(AS) $(ASFLAGS)
-
-COMPILE.CC       = $(CC_COMPILE) -c
-GENASM.CC        = $(CC_COMPILE) -S
-LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-ifeq ($(STATIC_BUILD),true)
-LINK_LIB.CC      = $(AR) $(ARFLAGS)
-else
-LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
-endif
-PREPROCESS.CC    = $(CC_COMPILE) -E
-
-COMPILE.CXX      = $(CXX_COMPILE) -c
-GENASM.CXX       = $(CXX_COMPILE) -S
-LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
-LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CXX   = $(CXX_COMPILE) -E
-
-# cross compiling the jvm with c2 requires host compilers to build
-# adlc tool
-
-HOST.CXX_COMPILE      = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS)
-HOST.COMPILE.CXX      = $(HOST.CXX_COMPILE) -c
-HOST.LINK_NOPROF.CXX  = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS)
-
-
-# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
-REMOVE_TARGET   = rm -f $@
-
-# Note use of ALT_BOOTDIR to explicitly specify location of java and
-# javac; this is the same environment variable used in the J2SE build
-# process for overriding the default spec, which is BOOTDIR.
-# Note also that we fall back to using JAVA_HOME if neither of these is
-# specified.
-
-ifdef ALT_BOOTDIR
-
-RUN.JAVA  = $(ALT_BOOTDIR)/bin/java
-RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap
-RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah
-RUN.JAR   = $(ALT_BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac
-COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(ALT_BOOTDIR)
-
-else
-
-ifdef BOOTDIR
-
-RUN.JAVA  = $(BOOTDIR)/bin/java
-RUN.JAVAP = $(BOOTDIR)/bin/javap
-RUN.JAVAH = $(BOOTDIR)/bin/javah
-RUN.JAR   = $(BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(BOOTDIR)/bin/javac
-COMPILE.RMIC  = $(BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(BOOTDIR)
-
-else
-
-ifdef JAVA_HOME
-
-RUN.JAVA  = $(JAVA_HOME)/bin/java
-RUN.JAVAP = $(JAVA_HOME)/bin/javap
-RUN.JAVAH = $(JAVA_HOME)/bin/javah
-RUN.JAR   = $(JAVA_HOME)/bin/jar
-COMPILE.JAVAC = $(JAVA_HOME)/bin/javac
-COMPILE.RMIC  = $(JAVA_HOME)/bin/rmic
-BOOT_JAVA_HOME = $(JAVA_HOME)
-
-else
-
-# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined
-
-RUN.JAVA  = java
-RUN.JAVAP = javap
-RUN.JAVAH = javah
-RUN.JAR   = jar
-COMPILE.JAVAC = javac
-COMPILE.RMIC  = rmic
-
-endif
-endif
-endif
-
-COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS)
-
-SUM = /usr/bin/sum
-
-# 'gmake MAKE_VERBOSE=y' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)  = @
-RUN.JAR$(MAKE_VERBOSE) += >/dev/null
-
-# Settings for javac
-JAVAC_FLAGS = -g -encoding ascii
-
-# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system)
-# Fall back to the values here if it's not set (hotspot only builds)
-ifeq ($(BOOT_JDK_SOURCETARGET),)
-BOOTSTRAP_SOURCETARGET := -source 8 -target 8
-else
-BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET)
-endif
-
-BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET)
-
-# With parallel makes, print a message at the end of compilation.
-ifeq    ($(findstring j,$(MFLAGS)),j)
-COMPILE_DONE    = && { echo Done with $<; }
-endif
-
-# Include $(NONPIC_OBJ_FILES) definition
-ifndef LP64
-include $(GAMMADIR)/make/pic.make
-endif
-
-include $(GAMMADIR)/make/altsrc.make
-
-# The non-PIC object files are only generated for 32 bit platforms.
-ifdef LP64
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
-else
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
-	   $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
-	   $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
-endif
-
-%.o: %.s
-	@echo $(LOG_INFO) Assembling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
-
-%.s: %.cpp
-	@echo $(LOG_INFO) Generating assembly for $<
-	$(QUIETLY) $(GENASM.CXX) -o $@ $<
-	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
-
-# Intermediate files (for debugging macros)
-%.i: %.cpp
-	@echo $(LOG_INFO) Preprocessing $< to $@
-	$(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
-
-#  Override gnumake built-in rules which do sccs get operations badly.
-#  (They put the checked out code in the current directory, not in the
-#  directory of the original file.)  Since this is a symptom of a teamware
-#  failure, and since not all problems can be detected by gnumake due
-#  to incomplete dependency checking... just complain and stop.
-%:: s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-%:: SCCS/s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-.PHONY: default
diff --git a/hotspot/make/bsd/makefiles/shark.make b/hotspot/make/bsd/makefiles/shark.make
deleted file mode 100644
index ca702ee..0000000
--- a/hotspot/make/bsd/makefiles/shark.make
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2008, 2010 Red Hat, Inc.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making Shark version of VM
-
-TYPE = SHARK
-
-VM_SUBDIR = server
-
-CFLAGS += -DSHARK
diff --git a/hotspot/make/bsd/makefiles/sparc.make b/hotspot/make/bsd/makefiles/sparc.make
deleted file mode 100644
index ddb0513..0000000
--- a/hotspot/make/bsd/makefiles/sparc.make
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (c) 2005, 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.
-#  
-#
-
diff --git a/hotspot/make/bsd/makefiles/sparcWorks.make b/hotspot/make/bsd/makefiles/sparcWorks.make
deleted file mode 100644
index e391160..0000000
--- a/hotspot/make/bsd/makefiles/sparcWorks.make
+++ /dev/null
@@ -1,107 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-#------------------------------------------------------------------------
-# CC, CXX & AS
-
-# If a SPEC is not set already, then use these defaults.
-ifeq ($(SPEC),)
-  CXX = CC
-  CC  = cc
-  AS  = $(CC) -c
-
-  HOSTCXX = $(CXX)
-  HOSTCC  = $(CC)
-endif
-
-ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
-ARCHFLAG/i486    = -m32
-ARCHFLAG/amd64   = -m64
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-ASFLAGS    += $(ARCHFLAG)
-
-#------------------------------------------------------------------------
-# Compiler flags
-
-# position-independent code
-PICFLAG = -KPIC
-
-CFLAGS += $(PICFLAG)
-# no more exceptions
-CFLAGS += -features=no%except
-# Reduce code bloat by reverting back to 5.0 behavior for static initializers
-CFLAGS += -features=no%split_init
-# allow zero sized arrays
-CFLAGS += -features=zla
-
-# Use C++ Interpreter
-ifdef CC_INTERP
-  CFLAGS += -DCC_INTERP
-endif
-
-# We don't need libCstd.so and librwtools7.so, only libCrun.so
-CFLAGS += -library=Crun
-LIBS += -lCrun
-
-CFLAGS += -mt
-LFLAGS += -mt
-
-# Compiler warnings are treated as errors
-#WARNINGS_ARE_ERRORS = -errwarn=%all
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) 
-# Special cases
-CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
-
-# The flags to use for an Optimized build
-OPT_CFLAGS+=-xO4
-OPT_CFLAGS/NOOPT=-xO0
-
-# Flags for creating the dependency files.
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-DEPFLAGS = -xMMD -xMF $(DEP_DIR)/$(@:%=%.d)
-endif
-
-# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
-CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
-
-#------------------------------------------------------------------------
-# Linker flags
-
-# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-MAPFLAG = -Wl,--version-script=FILENAME
-
-# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-SONAMEFLAG = -h SONAME
-
-# Build shared library
-SHARED_FLAG = -G
-
-#------------------------------------------------------------------------
-# Debug flags
-DEBUG_CFLAGS += -g
-FASTDEBUG_CFLAGS = -g0
-
diff --git a/hotspot/make/bsd/makefiles/sparcv9.make b/hotspot/make/bsd/makefiles/sparcv9.make
deleted file mode 100644
index b9e4e52..0000000
--- a/hotspot/make/bsd/makefiles/sparcv9.make
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 2005, 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.
-#  
-
-# gcc 4.0 miscompiles this code in -m64
-OPT_CFLAGS/macro.o = -O0
-
-CFLAGS += -D_LP64=1
diff --git a/hotspot/make/bsd/makefiles/tiered.make b/hotspot/make/bsd/makefiles/tiered.make
deleted file mode 100644
index da79ade..0000000
--- a/hotspot/make/bsd/makefiles/tiered.make
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making tiered version of VM
-
-TYPE=TIERED
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2 -DCOMPILER1
diff --git a/hotspot/make/bsd/makefiles/top.make b/hotspot/make/bsd/makefiles/top.make
deleted file mode 100644
index 47394d6..0000000
--- a/hotspot/make/bsd/makefiles/top.make
+++ /dev/null
@@ -1,156 +0,0 @@
-#
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# top.make is included in the Makefile in the build directories.
-# It DOES NOT include the vm dependency info in order to be faster.
-# Its main job is to implement the incremental form of make lists.
-# It also:
-#   -builds and runs adlc via adlc.make
-#   -generates JVMTI source and docs via jvmti.make (JSR-163)
-
-# It assumes the following flags are set:
-# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Obj_Files
-
-# -- D. Ungar (5/97) from a file by Bill Bush
-
-# Don't override the built-in $(MAKE).
-# Instead, use "gmake" (or "gnumake") from the command line.  --Rose
-#MAKE = gmake
-
-include $(GAMMADIR)/make/altsrc.make
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-VM          = $(GAMMADIR)/src/share/vm
-Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED);
-
-ifneq ($(USE_PRECOMPILED_HEADER),0)
-UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS)
-else
-UpdatePCH = \# precompiled header is not used
-endif
-
-Cached_plat = $(GENERATED)/platform.current
-
-AD_Dir   = $(GENERATED)/adfiles
-ADLC     = $(AD_Dir)/adlc
-AD_Spec  = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad)
-AD_Src   = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc)
-AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
-AD_Files = $(AD_Names:%=$(AD_Dir)/%)
-
-# AD_Files_If_Required/COMPILER1 = ad_stuff
-AD_Files_If_Required/COMPILER2 = ad_stuff
-AD_Files_If_Required/TIERED = ad_stuff
-AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE))
-
-# Wierd argument adjustment for "gnumake -j..."
-adjust-mflags   = $(GENERATED)/adjust-mflags
-# If SPEC is set, it's from configure and it's already controlling concurrency
-# for us. Skip setting -j with HOTSPOT_BUILD_JOBS.
-ifeq ($(SPEC), )
-  MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"`
-else
-  MFLAGS-adjusted = -r $(MFLAGS)
-endif
-
-
-# default target: update lists, make vm
-# done in stages to force sequential order with parallel make
-#
-
-default: vm_build_preliminaries the_vm
-	@echo All done.
-
-# This is an explicit dependency for the sake of parallel makes.
-vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff trace_stuff dtrace_stuff
-	@# We need a null action here, so implicit rules don't get consulted.
-
-$(Cached_plat): $(Plat_File)
-	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
-
-# make AD files as necessary
-ad_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f adlc.make $(MFLAGS-adjusted)
-
-# generate JVMTI files from the spec
-jvmti_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f jvmti.make $(MFLAGS-adjusted)
-
-# generate trace files
-trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f trace.make $(MFLAGS-adjusted)
-
-ifeq ($(OS_VENDOR), Darwin)
-# generate dtrace header files
-dtrace_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f dtrace.make dtrace_stuff $(MFLAGS-adjusted) GENERATED=$(GENERATED)
-else
-dtrace_stuff:
-	@# We need a null action here, so implicit rules don't get consulted.
-endif
-
-# and the VM: must use other makefile with dependencies included
-
-# We have to go to great lengths to get control over the -jN argument
-# to the recursive invocation of vm.make.  The problem is that gnumake
-# resets -jN to -j1 for recursive runs.  (How helpful.)
-# Note that the user must specify the desired parallelism level via a
-# command-line or environment variable name HOTSPOT_BUILD_JOBS.
-$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh
-	@+rm -f $@ $@+
-	@+cat $< > $@+
-	@+chmod +x $@+
-	@+mv $@+ $@
-
-the_vm: vm_build_preliminaries $(adjust-mflags)
-	+@$(UpdatePCH)
-	@$(MAKE) -f vm.make $(MFLAGS-adjusted)
-
-install : the_vm
-	@$(MAKE) -f vm.make $@
-
-# next rules support "make foo.[ois]"
-
-%.o %.i %.s:
-	+$(UpdatePCH)
-	$(MAKE) -f vm.make $(MFLAGS) $@
-	#$(MAKE) -f vm.make $@
-
-# this should force everything to be rebuilt
-clean:
-	rm -f $(GENERATED)/*.class
-	$(MAKE) -f vm.make $(MFLAGS) clean
-
-# just in case it doesn't, this should do it
-realclean:
-	$(MAKE) -f vm.make $(MFLAGS) clean
-	rm -fr $(GENERATED)
-
-.PHONY: default vm_build_preliminaries
-.PHONY: lists ad_stuff jvmti_stuff the_vm clean realclean
-.PHONY: checks check_os_version install
-
-.NOTPARALLEL:
diff --git a/hotspot/make/bsd/makefiles/trace.make b/hotspot/make/bsd/makefiles/trace.make
deleted file mode 100644
index 37df442..0000000
--- a/hotspot/make/bsd/makefiles/trace.make
+++ /dev/null
@@ -1,119 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile (trace.make) is included from the trace.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate trace files.
-
-include $(GAMMADIR)/make/bsd/makefiles/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-# #########################################################################
-
-HAS_ALT_SRC := false
-ifndef OPENJDK
-  ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), )
-    HAS_ALT_SRC := true
-  endif
-endif
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-JvmtiOutDir = $(GENERATED)/jvmtifiles
-TraceOutDir   = $(GENERATED)/tracefiles
-
-TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace
-TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-TraceGeneratedNames =     \
-    traceEventClasses.hpp \
-	traceEventIds.hpp     \
-	traceTypes.hpp
-
-ifeq ($(HAS_ALT_SRC), true)
-TraceGeneratedNames +=  \
-	traceRequestables.hpp \
-    traceEventControl.hpp
-endif
-
-TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%)
-
-XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-TraceXml = $(TraceSrcDir)/trace.xml
-ifeq ($(HAS_ALT_SRC), true)
-  TraceXml = $(TraceAltSrcDir)/trace.xml
-endif
-
-XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \
-    $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \
-    $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml
-ifeq ($(HAS_ALT_SRC), true)
-  XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \
-      $(TraceAltSrcDir)/traceeventtypes.xml
-endif
-
-.PHONY: all clean cleanall
-
-# #########################################################################
-
-all: $(TraceGeneratedFiles)
-
-GENERATE_CODE= \
-  $(QUIETLY) echo $(LOG_INFO) Generating $@; \
-  $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@
-
-$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-ifeq ($(HAS_ALT_SRC), false)
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-else
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-endif
-
-# #########################################################################
-
-clean cleanall:
-	rm $(TraceGeneratedFiles)
diff --git a/hotspot/make/bsd/makefiles/universal.gmk b/hotspot/make/bsd/makefiles/universal.gmk
deleted file mode 100644
index 128d21b..0000000
--- a/hotspot/make/bsd/makefiles/universal.gmk
+++ /dev/null
@@ -1,126 +0,0 @@
-#
-# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# macosx universal builds
-universal_product:
-	$(MAKE) MACOSX_UNIVERSAL=true all_product_universal
-universal_optimized:
-	$(MAKE) MACOSX_UNIVERSAL=true all_optimized_universal
-universal_fastdebug:
-	$(MAKE) MACOSX_UNIVERSAL=true all_fastdebug_universal
-universal_debug:
-	$(MAKE) MACOSX_UNIVERSAL=true all_debug_universal
-
-
-# Universal builds include 1 or more architectures in a single binary
-all_product_universal:
-#	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_PRODUCT_TARGETS)
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_PRODUCT_TARGETS)
-	$(QUIETLY) $(MAKE) BUILD_FLAVOR=product EXPORT_SUBDIR= universalize
-all_optimized_universal:
-#	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_OPTIMIZED_TARGETS)
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_OPTIMIZED_TARGETS)
-	$(QUIETLY) $(MAKE) BUILD_FLAVOR=optimized EXPORT_SUBDIR=/optimized universalize
-all_fastdebug_universal:
-#	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_FASTDEBUG_TARGETS)
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_FASTDEBUG_TARGETS)
-	$(QUIETLY) $(MAKE) BUILD_FLAVOR=fastdebug EXPORT_SUBDIR=/fastdebug universalize
-all_debug_universal:
-#	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_DEBUG_TARGETS)
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_DEBUG_TARGETS)
-	$(QUIETLY) $(MAKE) BUILD_FLAVOR=debug EXPORT_SUBDIR=/debug universalize
-
-
-# Consolidate architecture builds into a single Universal binary
-universalize: $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST)
-	$(RM) -r $(EXPORT_PATH)/lib/{i386,amd64}
-
-LIPO ?= lipo
-
-# Package built libraries in a universal binary
-$(UNIVERSAL_LIPO_LIST):
-	BUILT_LIPO_FILES="`find $(EXPORT_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_LIB_DIR)/,,$@) 2>/dev/null`" || test $$? = "1"; \
-	if [ -n "$${BUILT_LIPO_FILES}" ]; then \
-	  $(MKDIR) -p $(shell dirname $@); \
-	  $(LIPO) -create -output $@ $${BUILT_LIPO_FILES}; \
-	fi
-
-
-# Copy built non-universal binaries in place
-# - copies directories; including empty dirs
-# - copies files, symlinks, other non-directory files
-$(UNIVERSAL_COPY_LIST):
-	BUILT_COPY_FILES="`find $(EXPORT_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_LIB_DIR)/,,$@) -prune 2>/dev/null`" || test $$? = "1"; \
-	if [ -n "$${BUILT_COPY_FILES}" ]; then \
-	  for i in $${BUILT_COPY_FILES}; do \
-	    $(MKDIR) -p $(shell dirname $@); \
-	    $(CP) -R $${i} $@; \
-	  done; \
-	fi
-
-
-# Replace arch specific binaries with universal binaries
-# Do not touch lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
-# That symbolic link belongs to the 'jdk' build.
-export_universal:
-	$(RM) -r $(EXPORT_PATH)/lib/{i386,amd64}
-	$(RM) -r $(JDK_IMAGE_DIR)/lib/{i386,amd64}
-	($(CD) $(EXPORT_PATH) && \
-	  $(TAR) -cf - *) | \
-	  ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xpf -)
-
-
-# Overlay universal binaries
-# Do not touch lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
-# That symbolic link belongs to the 'jdk' build.
-copy_universal:
-	$(RM) -r $(JDK_IMAGE_DIR)$(COPY_SUBDIR)/lib/{i386,amd64}
-	($(CD) $(EXPORT_PATH)$(COPY_SUBDIR) && \
-	  $(TAR) -cf - *) | \
-	  ($(CD) $(JDK_IMAGE_DIR)$(COPY_SUBDIR) && $(TAR) -xpf -)
-
-
-# Additional processing for universal builds
-export_product_jdk::
-	$(MAKE) EXPORT_SUBDIR=           export_universal
-export_optimized_jdk::
-	$(MAKE) EXPORT_SUBDIR=/optimized export_universal
-export_fastdebug_jdk::
-	$(MAKE) EXPORT_SUBDIR=/fastdebug export_universal
-export_debug_jdk::
-	$(MAKE) EXPORT_SUBDIR=/debug     export_universal
-copy_product_jdk::
-	$(MAKE) COPY_SUBDIR=             copy_universal
-copy_optimized_jdk::
-	$(MAKE) COPY_SUBDIR=/optimized   copy_universal
-copy_fastdebug_jdk::
-	$(MAKE) COPY_SUBDIR=/fastdebug   copy_universal
-copy_debug_jdk::
-	$(MAKE) COPY_SUBDIR=/debug       copy_universal
-
-.PHONY:	universal_product universal_fastdebug universal_debug \
-	all_product_universal all_fastdebug_universal all_debug_universal \
-	universal_optimized all_optimized_universal \
-	universalize export_universal copy_universal \
-	$(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST)
diff --git a/hotspot/make/bsd/makefiles/vm.make b/hotspot/make/bsd/makefiles/vm.make
deleted file mode 100644
index a3c1ce6..0000000
--- a/hotspot/make/bsd/makefiles/vm.make
+++ /dev/null
@@ -1,438 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Rules to build JVM and related libraries, included from vm.make in the build
-# directory.
-
-# Common build rules.
-MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
-include $(MAKEFILES_DIR)/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-default: build
-
-#----------------------------------------------------------------------
-# Defs
-
-GENERATED     = ../generated
-DEP_DIR       = $(GENERATED)/dependencies
-
-# reads the generated files defining the set of .o's and the .o .h dependencies
--include $(DEP_DIR)/*.d
-
-# read machine-specific adjustments (%%% should do this via buildtree.make?)
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  include $(MAKEFILES_DIR)/zeroshark.make
-else
-  include $(MAKEFILES_DIR)/$(BUILDARCH).make
-endif
-
-# set VPATH so make knows where to look for source files
-# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
-# The adfiles directory contains ad_<arch>.[ch]pp.
-# The jvmtifiles directory contains jvmti*.[ch]pp
-Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor.
-Src_Dirs_I += $(GENERATED)
-# The order is important for the precompiled headers to work.
-INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
-
-# SYMFLAG is used by jsig.make
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  # always build with debug info when we can create .dSYM/.debuginfo files
-  SYMFLAG = -g
-else
-  ifeq (${VERSION}, debug)
-    SYMFLAG = -g
-  else
-    SYMFLAG =
-  endif
-endif
-
-# The following variables are defined in the generated flags.make file.
-JDK_VER_DEFS  = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-		-DVERSION_MINOR=$(VERSION_MINOR) \
-		-DVERSION_SECURITY=$(VERSION_SECURITY) \
-	        -DVERSION_PATCH=$(VERSION_PATCH) \
-		-DVERSION_BUILD=$(VERSION_BUILD)
-VM_VER_DEFS   = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-		-DVERSION_STRING="\"$(VERSION_STRING)\""  \
-	        -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \
-		$(JDK_VER_DEFS)
-HS_LIB_ARCH   = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
-BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
-VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
-
-CXXFLAGS =           \
-  ${SYSDEFS}         \
-  ${INCLUDES}        \
-  ${BUILD_USER}      \
-  ${HS_LIB_ARCH}     \
-  ${VM_DISTRO}
-
-# This is VERY important! The version define must only be supplied to vm_version.o
-# If not, ccache will not re-use the cache at all, since the version string might contain
-# a time and date.
-CXXFLAGS/vm_version.o += ${VM_VER_DEFS}
-
-CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
-
-# File specific flags
-CXXFLAGS += $(CXXFLAGS/BYFILE)
-
-ifdef DEFAULT_LIBPATH
-CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
-endif
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-CFLAGS += $(CFLAGS_WARN/BYFILE)
-
-# Do not use C++ exception handling
-CFLAGS += $(CFLAGS/NOEX)
-
-# Extra flags from gnumake's invocation or environment
-CFLAGS += $(EXTRA_CFLAGS)
-LFLAGS += $(EXTRA_CFLAGS)
-
-# Don't set excutable bit on stack segment
-# the same could be done by separate execstack command
-# Darwin is non-executable-stack by default
-ifneq ($(OS_VENDOR), Darwin)
-LFLAGS += -Xlinker -z -Xlinker noexecstack
-endif
-
-LIBS += -lm
-
-ifeq ($(USE_CLANG),)
-  LIBS += -pthread
-endif
-
-# By default, link the *.o into the library, not the executable.
-LINK_INTO$(LINK_INTO) = LIBJVM
-
-JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH)
-
-#----------------------------------------------------------------------
-# jvm_db & dtrace
-include $(MAKEFILES_DIR)/dtrace.make
-
-#----------------------------------------------------------------------
-# JVM
-
-JVM    = jvm
-ifeq ($(OS_VENDOR), Darwin)
-  LIBJVM   = lib$(JVM).$(LIBRARY_SUFFIX)
-  CFLAGS  += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
-
-  LIBJVM_DEBUGINFO   = lib$(JVM).$(LIBRARY_SUFFIX).dSYM
-  LIBJVM_DIZ         = lib$(JVM).diz
-else
-  LIBJVM   = lib$(JVM).so
-
-  LIBJVM_DEBUGINFO   = lib$(JVM).debuginfo
-  LIBJVM_DIZ         = lib$(JVM).diz
-endif
-
-SPECIAL_PATHS:=adlc c1 gc opto shark libadt
-
-SOURCE_PATHS=\
-  $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
-      \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
-
-CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
-CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
-
-ifneq ($(INCLUDE_TRACE), false)
-CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \
-  find $(HS_ALT_SRC)/share/vm/jfr -type d; \
-  fi)
-endif
-
-COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
-COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
-
-COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
-COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
-COMPILER2_PATHS += $(GENERATED)/adfiles
-
-SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
-
-# Include dirs per type.
-Src_Dirs/CORE      := $(CORE_PATHS)
-Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
-Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/TIERED    := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/ZERO      := $(CORE_PATHS)
-Src_Dirs/SHARK     := $(CORE_PATHS) $(SHARK_PATHS)
-Src_Dirs := $(Src_Dirs/$(TYPE))
-
-COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\*
-COMPILER1_SPECIFIC_FILES := c1_\*
-SHARK_SPECIFIC_FILES     := shark
-ZERO_SPECIFIC_FILES      := zero
-
-# Always exclude these.
-Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
-
-# Exclude per type.
-Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
-
-Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
-
-# Special handling of arch model.
-ifeq ($(Platform_arch_model), x86_32)
-Src_Files_EXCLUDE += \*x86_64\*
-endif
-ifeq ($(Platform_arch_model), x86_64)
-Src_Files_EXCLUDE += \*x86_32\*
-endif
-
-# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
-define findsrc
-	$(notdir $(shell find $(1)/. ! -name . -prune \
-		-a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
-		-a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
-endef
-
-Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
-
-Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))))
-
-JVM_OBJ_FILES = $(Obj_Files)
-
-vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
-
-MAPFILE_SHARE  := $(GAMMADIR)/make/share/makefiles/mapfile-vers
-
-MAPFILE_EXT_SRC := $(HS_ALT_MAKE)/share/makefiles/mapfile-ext
-ifneq ("$(wildcard $(MAPFILE_EXT_SRC))","")
-MAPFILE_EXT     := $(MAPFILE_EXT_SRC)
-endif
-
-# For Darwin: add _ prefix and remove trailing ;
-mapfile_extra: $(MAPFILE_SHARE) $(MAPFILE_EXT)
-	rm -f $@
-ifeq ($(OS_VENDOR), Darwin)
-	cat $(MAPFILE_SHARE) $(MAPFILE_EXT) | \
-	    sed -e 's/#.*//g' -e 's/[ ]*//g' -e 's/;//g' | \
-	    awk '{ if ($$0 ~ ".") { print "\t\t_" $$0 } }' \
-	 > $@
-else
-	cat $(MAPFILE_SHARE) $(MAPFILE_EXT) > $@
-endif
-
-mapfile : $(MAPFILE) mapfile_extra vm.def
-	rm -f $@
-	awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE")	\
-                 { system ("cat mapfile_extra vm.def"); } \
-               else					\
-                 { print $$0 }				\
-             }' > $@ < $(MAPFILE)
-
-ifeq ($(STATIC_BUILD),true)
-EXPORTED_SYMBOLS = libjvm.symbols
-
-libjvm.symbols : mapfile
-	$(CP) mapfile libjvm.symbols
-
-else
-EXPORTED_SYMBOLS =
-endif
-
-mapfile_reorder : mapfile $(REORDERFILE)
-	rm -f $@
-	cat $^ > $@
-
-vm.def: $(Res_Files) $(Obj_Files)
-	sh $(GAMMADIR)/make/bsd/makefiles/build_vm_def.sh *.o > $@
-
-mapfile_ext:
-	rm -f $@
-	touch $@
-	if [ -f $(HS_ALT_MAKE)/bsd/makefiles/mapfile-ext ]; then \
-	  cat $(HS_ALT_MAKE)/bsd/makefiles/mapfile-ext > $@; \
-	fi
-
-STATIC_CXX = false
-
-ifeq ($(LINK_INTO),AOUT)
-  LIBJVM.o                 =
-  LIBJVM_MAPFILE           =
-  LIBS_VM                  = $(LIBS)
-else
-  LIBJVM.o                 = $(JVM_OBJ_FILES)
-  LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
-  LFLAGS_VM$(LDNOMAP)      += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
-  LFLAGS_VM                += $(SONAMEFLAG:SONAME=$(LIBJVM))
-
-  ifeq ($(OS_VENDOR), Darwin)
-    ifneq ($(STATIC_BUILD),true)
-    LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/.
-    LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/..
-    LFLAGS_VM += -Xlinker -install_name -Xlinker @rpath/$(@F)
-    endif
-  else
-    LFLAGS_VM                += -Wl,-z,defs
-  endif
-
-  # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
-  # get around library dependency and compatibility issues. Must use gcc not
-  # g++ to link.
-  ifeq ($(STATIC_CXX), true)
-    LFLAGS_VM              += $(STATIC_LIBGCC)
-    LIBS_VM                += $(STATIC_STDCXX)
-    LINK_VM                = $(LINK_LIB.CC)
-  else
-    LINK_VM                = $(LINK_LIB.CXX)
-  endif
-
-  LIBS_VM                  += $(LIBS)
-endif
-ifeq ($(JVM_VARIANT_ZERO), true)
-  LIBS_VM += $(LIBFFI_LIBS)
-endif
-ifeq ($(JVM_VARIANT_ZEROSHARK), true)
-  LIBS_VM   += $(LIBFFI_LIBS) $(LLVM_LIBS)
-  LFLAGS_VM += $(LLVM_LDFLAGS)
-endif
-
-
-# rule for building precompiled header
-$(PRECOMPILED_HEADER):
-	$(QUIETLY) echo $(LOG_INFO) Generating precompiled header $@
-	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
-	$(QUIETLY) rm -f $@
-	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
-
-# making the library:
-
-ifneq ($(JVM_BASE_ADDR),)
-# By default shared library is linked at base address == 0. Modify the
-# linker script if JVM prefers a different base location. It can also be
-# implemented with 'prelink -r'. But 'prelink' is not (yet) available on
-# our build platform (AS-2.1).
-LD_SCRIPT = libjvm.so.lds
-$(LD_SCRIPT): $(LIBJVM_MAPFILE)
-	$(QUIETLY) {                                                \
-	  rm -rf $@;                                                \
-	  $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1             |  \
-	    sed -e '/^======/,/^======/!d'                          \
-		-e '/^======/d'                                     \
-		-e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/'   \
-		> $@;                                               \
-	}
-LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
-endif
-
-$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
-ifeq ($(STATIC_BUILD),true)
-	echo Linking static vm...;
-	$(LINK_LIB.CC) $@ $(LIBJVM.o)
-else
-	$(QUIETLY) {                                                    \
-	    echo $(LOG_INFO) Linking vm...;                                         \
-	    $(LINK_LIB.CXX/PRE_HOOK)                                     \
-	    $(LINK_VM) $(LD_SCRIPT_FLAG)                                \
-		       $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM); \
-	    $(LINK_LIB.CXX/POST_HOOK)                                    \
-	    rm -f $@.1; ln -s $@ $@.1;                                  \
-	}
-
-endif
-
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(OS_VENDOR), Darwin)
-	$(DSYMUTIL) $@
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -r -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO)
-	$(RM) -r $(LIBJVM_DEBUGINFO)
-    endif
-  else
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
-    ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-    else
-      ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -g $@
-      # implied else here is no stripping at all
-      endif
-    endif
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO)
-	$(RM) $(LIBJVM_DEBUGINFO)
-    endif
-  endif
-endif
-
-DEST_SUBDIR        = $(JDK_LIBDIR)/$(VM_SUBDIR)
-DEST_JVM           = $(DEST_SUBDIR)/$(LIBJVM)
-DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO)
-DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
-
-install_jvm: $(LIBJVM)
-	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
-ifeq ($(OS_VENDOR), Darwin)
-	$(QUIETLY) test ! -d $(LIBJVM_DEBUGINFO) || \
-	    $(CP) -f -r $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
-else
-	$(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \
-	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
-endif
-	$(QUIETLY) test ! -f $(LIBJVM_DIZ) || \
-	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
-
-#----------------------------------------------------------------------
-# Other files
-
-# Signal interposition library
-include $(MAKEFILES_DIR)/jsig.make
-
-#----------------------------------------------------------------------
-
-ifeq ($(OS_VENDOR), Darwin)
-# no libjvm_db for macosx
-build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) dtraceCheck $(EXPORTED_SYMBOLS)
-	echo "Doing vm.make build:"
-else
-build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(EXPORTED_SYMBOLS)
-endif
-
-install: install_jvm install_jsigs
-
-.PHONY: default build install install_jvm
diff --git a/hotspot/make/bsd/makefiles/zero.make b/hotspot/make/bsd/makefiles/zero.make
deleted file mode 100644
index 0270711..0000000
--- a/hotspot/make/bsd/makefiles/zero.make
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2009 Red Hat, Inc.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Setup for Zero (non-Shark) version of VM
-
-# Select which files to use (in top.make)
-TYPE = ZERO
-
-# Install libjvm.so, etc in in server directory.
-VM_SUBDIR = server
diff --git a/hotspot/make/bsd/makefiles/zeroshark.make b/hotspot/make/bsd/makefiles/zeroshark.make
deleted file mode 100644
index 12c4198..0000000
--- a/hotspot/make/bsd/makefiles/zeroshark.make
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2007, 2008 Red Hat, Inc.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Setup common to Zero (non-Shark) and Shark versions of VM
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-
-# Specify that the CPU is little endian, if necessary
-ifeq ($(ZERO_ENDIANNESS), little)
-  CFLAGS += -DVM_LITTLE_ENDIAN
-endif
-
-# Specify that the CPU is 64 bit, if necessary
-ifeq ($(ARCH_DATA_MODEL), 64)
-  CFLAGS += -D_LP64=1
-endif
-
-# Specify the path to the FFI headers
-ifdef ALT_PACKAGE_PATH
-  PACKAGE_PATH = $(ALT_PACKAGE_PATH)
-else
-  ifeq ($(OS_VENDOR),Apple)
-    PACKAGE_PATH = /opt/local
-  else
-    ifeq ($(OS_VENDOR),NetBSD)
-      PACKAGE_PATH = /usr/pkg
-      LIBS += -Wl,-R${PACKAGE_PATH}/lib
-    else
-      PACKAGE_PATH = /usr/local
-    endif
-  endif
-endif
-
-CFLAGS += -I$(PACKAGE_PATH)/include
-LIBS += -L$(PACKAGE_PATH)/lib -lffi
-
-OPT_CFLAGS/compactingPermGenGen.o = -O1
diff --git a/hotspot/make/bsd/platform_amd64 b/hotspot/make/bsd/platform_amd64
deleted file mode 100644
index 51b2b1c..0000000
--- a/hotspot/make/bsd/platform_amd64
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = bsd
-
-arch = x86
-
-arch_model = x86_64
-
-os_arch = bsd_x86
-
-os_arch_model = bsd_x86_64
-
-lib_arch = amd64
-
-compiler = gcc
-
-sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DAMD64
diff --git a/hotspot/make/bsd/platform_amd64.suncc b/hotspot/make/bsd/platform_amd64.suncc
deleted file mode 100644
index 68e0cc3..0000000
--- a/hotspot/make/bsd/platform_amd64.suncc
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = bsd
-
-arch = x86
-
-arch_model = x86_64
-
-os_arch = bsd_x86
-
-os_arch_model = bsd_x86_64
-
-lib_arch = amd64
-
-compiler = sparcWorks
-
-gnu_dis_arch = amd64
-
-sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DAMD64
diff --git a/hotspot/make/bsd/platform_i486 b/hotspot/make/bsd/platform_i486
deleted file mode 100644
index 2f77e79..0000000
--- a/hotspot/make/bsd/platform_i486
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = bsd
-
-arch = x86
-
-arch_model = x86_32
-
-os_arch = bsd_x86
-
-os_arch_model = bsd_x86_32
-
-lib_arch = i386
-
-compiler = gcc
-
-sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA32
diff --git a/hotspot/make/bsd/platform_i486.suncc b/hotspot/make/bsd/platform_i486.suncc
deleted file mode 100644
index 5b203cd..0000000
--- a/hotspot/make/bsd/platform_i486.suncc
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = bsd
-
-arch = x86
-
-arch_model = x86_32
-
-os_arch = bsd_x86
-
-os_arch_model = bsd_x86_32
-
-lib_arch = i386
-
-compiler = sparcWorks
-
-gnu_dis_arch = i386
-
-sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DIA32
diff --git a/hotspot/make/bsd/platform_ia64 b/hotspot/make/bsd/platform_ia64
deleted file mode 100644
index 00b9f33..0000000
--- a/hotspot/make/bsd/platform_ia64
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = bsd
-
-arch = ia64
-
-os_arch = bsd_ia64
-
-lib_arch = ia64
-
-compiler = gcc
-
-gnu_dis_arch = ia64
-
-sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA64 -DCC_INTERP
-
-mark_style = alignment
diff --git a/hotspot/make/bsd/platform_sparc b/hotspot/make/bsd/platform_sparc
deleted file mode 100644
index 04772ad..0000000
--- a/hotspot/make/bsd/platform_sparc
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = bsd
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = bsd_sparc
-
-os_arch_model = bsd_sparc
-
-lib_arch = sparc
-
-compiler = gcc
-
-sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC
diff --git a/hotspot/make/bsd/platform_sparcv9 b/hotspot/make/bsd/platform_sparcv9
deleted file mode 100644
index 89e51c5..0000000
--- a/hotspot/make/bsd/platform_sparcv9
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = bsd
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = bsd_sparc
-
-os_arch_model = bsd_sparc
-
-lib_arch = sparcv9
-
-compiler = gcc
-
-sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC
diff --git a/hotspot/make/bsd/platform_zero.in b/hotspot/make/bsd/platform_zero.in
deleted file mode 100644
index f6729c2..0000000
--- a/hotspot/make/bsd/platform_zero.in
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = bsd
-
-arch = zero
-
-arch_model = zero
-
-os_arch = bsd_zero
-
-os_arch_model = bsd_zero
-
-lib_arch = zero
-
-compiler = gcc
-
-gnu_dis_arch = zero
-
-sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\"
diff --git a/hotspot/make/build.sh b/hotspot/make/build.sh
deleted file mode 100644
index 27c7843..0000000
--- a/hotspot/make/build.sh
+++ /dev/null
@@ -1,92 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Make sure the variable JAVA_HOME is set before running this script.
-
-set -u
-
-
-if [ $# -lt 1 ]; then 
-    echo "Usage : $0 BuildTarget [LP64=1] [BuildOptions]"
-    echo "               Server VM | Client VM"
-    echo "BuildTarget :  debug     | debug1"
-    echo "               fastdebug | fastdebug1"
-    echo "               jvmg      | jvmg1"
-    echo "               optimized | optimized1"
-    echo "               profiled  | profiled1"
-    echo "               product   | product1"
-    exit 1
-fi
-
-if [ "${JAVA_HOME-}" = ""  -o  ! -d "${JAVA_HOME-}" ]; then
-    echo "JAVA_HOME needs to be set to a valid JDK path"
-    echo "JAVA_HOME: ${JAVA_HOME-}"
-    exit 1
-fi
-
-# Just in case:
-JAVA_HOME=`( cd $JAVA_HOME; pwd )`
-
-if [ "${ALT_BOOTDIR-}" = ""  -o  ! -d "${ALT_BOOTDIR-}" -o ! -d ${ALT_BOOTDIR-}/lib/ ]; then
-    ALT_BOOTDIR=${JAVA_HOME}
-fi
-
-# build in current directory by default
-if [ "${ALT_OUTPUTDIR-}" = ""  -o  ! -d "${ALT_OUTPUTDIR-}" ]; then
-    ALT_OUTPUTDIR=`(pwd)`
-fi
-
-HOTSPOT_SRC=`(dirname $0)`/..
-HOTSPOT_SRC=`(cd ${HOTSPOT_SRC}; pwd)`
-
-for gm in gmake gnumake
-do
-  if [ "${GNUMAKE-}" != "" ]; then break; fi
-  ($gm --version >/dev/null) 2>/dev/null && GNUMAKE=$gm
-done
-: ${GNUMAKE:?'Cannot locate the gnumake program.  Stop.'}
-
-# quiet build by default
-Quiet="MAKE_VERBOSE="
-
-# no debug info by default
-NoDebugInfo="ENABLE_FULL_DEBUG_SYMBOLS="
-
-LANG=C
-
-echo "### ENVIRONMENT SETTINGS:"
-export HOTSPOT_SRC		; echo "HOTSPOT_SRC=$HOTSPOT_SRC"
-export JAVA_HOME		; echo "JAVA_HOME=$JAVA_HOME"
-export ALT_BOOTDIR		; echo "ALT_BOOTDIR=$ALT_BOOTDIR"
-export ALT_OUTPUTDIR		; echo "ALT_OUTPUTDIR=$ALT_OUTPUTDIR"
-export GNUMAKE			; echo "GNUMAKE=$GNUMAKE"
-export LANG			; echo "LANG=$LANG"
-echo "###"
-
-BuildOptions="$Quiet $NoDebugInfo $*"
-
-echo \
-${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC}
-${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC}
diff --git a/hotspot/make/cscope.make b/hotspot/make/cscope.make
deleted file mode 100644
index c38b7a5..0000000
--- a/hotspot/make/cscope.make
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# The cscope.out file is generated in the current directory.  The old cscope.out
-# file is *not* removed because cscope is smart enough to only build what has
-# changed.  cscope can be confused if files are renamed or removed, so it may be
-# necessary to remove cscope.out (gmake cscope.clean) if a lot of reorganization
-# has occurred.
-
-include $(GAMMADIR)/make/scm.make
-
-RM	= rm -f
-HG	= hg
-CS_TOP	= $(GAMMADIR)
-
-CSDIRS	= $(CS_TOP)/src $(CS_TOP)/make
-CSINCS	= $(CSDIRS:%=-I%)
-
-CSCOPE		= cscope
-CSCOPE_OUT	= cscope.out
-CSCOPE_FLAGS	= -b
-
-# Allow .java files to be added from the environment (CSCLASSES=yes).
-ifdef	CSCLASSES
-ADDCLASSES=	-o -name '*.java'
-endif
-
-# Adding CClassHeaders also pushes the file count of a full workspace up about
-# 200 files (these files also don't exist in a new workspace, and thus will
-# cause the recreation of the database as they get created, which might seem
-# a little confusing).  Thus allow these files to be added from the environment
-# (CSHEADERS=yes).
-ifndef	CSHEADERS
-RMCCHEADERS=	-o -name CClassHeaders
-endif
-
-# Ignore build products.
-CS_PRUNE_GENERATED	= -o -name '${OSNAME}_*_core' -o \
-			     -name '${OSNAME}_*_compiler?'
-
-# O/S-specific files for all systems are included by default.  Set CS_OS to a
-# space-separated list of identifiers to include only those systems.
-ifdef	CS_OS
-CS_PRUNE_OS	= $(patsubst %,-o -name '*%*',\
-		    $(filter-out ${CS_OS},bsd linux macos solaris windows))
-endif
-
-# CPU-specific files for all processors are included by default.  Set CS_CPU 
-# space-separated list identifiers to include only those CPUs.
-ifdef	CS_CPU
-CS_PRUNE_CPU	= $(patsubst %,-o -name '*%*',\
-		    $(filter-out ${CS_CPU},arm ppc sparc x86 zero))
-endif
-
-# What files should we include?  A simple rule might be just those files under
-# SCCS control, however this would miss files we create like the opcodes and
-# CClassHeaders.  The following attempts to find everything that is *useful*.
-# (.del files are created by sccsrm, demo directories contain many .java files
-# that probably aren't useful for development, and the pkgarchive may contain
-# duplicates of files within the source hierarchy).
-
-# Directories to exclude.
-CS_PRUNE_STD	= $(SCM_DIRS) \
-		  -o -name '.del-*' \
-		  -o -name '*demo' \
-		  -o -name pkgarchive
-
-# Placeholder for user-defined excludes.
-CS_PRUNE_EX	=
-
-CS_PRUNE	= $(CS_PRUNE_STD) \
-		  $(CS_PRUNE_OS) \
-		  $(CS_PRUNE_CPU) \
-		  $(CS_PRUNE_GENERATED) \
-		  $(CS_PRUNE_EX) \
-		  $(RMCCHEADERS)
-
-# File names to include.
-CSFILENAMES	= -name '*.[ch]pp' \
-		  -o -name '*.[Ccshlxy]' \
-		  $(CS_ADD_GENERATED) \
-		  -o -name '*.d' \
-		  -o -name '*.il' \
-		  -o -name '*.cc' \
-		  -o -name '*[Mm]akefile*' \
-		  -o -name '*.gmk' \
-		  -o -name '*.make' \
-		  -o -name '*.ad' \
-		  $(ADDCLASSES)
-
-.PHONY:		cscope cscope.clean cscope.scratch TAGS.clean FORCE
-.PRECIOUS:	cscope.out
-
-cscope $(CSCOPE_OUT): cscope.files FORCE
-	$(CSCOPE) -f $(CSCOPE_OUT) $(CSCOPE_FLAGS)
-
-cscope.clean:
-	$(QUIETLY) $(RM) $(CSCOPE_OUT) cscope.files
-
-cscope.scratch:  cscope.clean cscope
-
-# The raw list is reordered so cscope displays the most relevant files first.
-cscope.files:
-	$(QUIETLY)						\
-	raw=cscope.$$$$;					\
-	find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o	\
-	    -type f \( $(CSFILENAMES) \) -print > $$raw;	\
-	{							\
-	echo "$(CSINCS)";					\
-	egrep -v "\.java|/make/" $$raw;				\
-	fgrep ".java" $$raw;					\
-	fgrep "/make/" $$raw;					\
-	} > $@;							\
-	rm -f $$raw
-
-TAGS:  cscope.files FORCE
-	egrep -v '^-|^$$' $< | etags --members -
-
-TAGS.clean:
-	$(RM) TAGS
diff --git a/hotspot/make/defs.make b/hotspot/make/defs.make
deleted file mode 100644
index e02d660..0000000
--- a/hotspot/make/defs.make
+++ /dev/null
@@ -1,362 +0,0 @@
-#
-# Copyright (c) 2006, 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
-# 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.
-#
-#
-
-# The common definitions for hotspot builds.
-
-# Optionally include SPEC file generated by configure.
-ifneq ($(SPEC),)
-  include $(SPEC)
-endif
-
-ifeq ($(LOG_LEVEL),warn)
-  LOG_INFO := > /dev/null
-else
-  LOG_INFO :=
-endif
-
-# Directory paths and user name
-# Unless GAMMADIR is set on the command line, search upward from
-# the current directory for a parent directory containing "src/share/vm".
-# If that fails, look for $GAMMADIR in the environment.
-# When the tree of subdirs is built, this setting is stored in each flags.make.
-GAMMADIR := $(shell until ([ -d dev ]&&echo $${GAMMADIR:-/GAMMADIR/}) || ([ -d src/share/vm ]&&pwd); do cd ..; done)
-HS_SRC_DIR=$(GAMMADIR)/src
-HS_MAKE_DIR=$(GAMMADIR)/make
-HS_BUILD_DIR=$(GAMMADIR)/build
-
-ifeq ($(USER),)
-  USER=$(USERNAME)
-endif
-
-ifeq ($(HS_ALT_MAKE),)
-  ifneq ($(OPENJDK),true)
-    HS_ALT_MAKE=$(GAMMADIR)/make/closed
-  else
-    HS_ALT_MAKE=NO_SUCH_PATH
-  endif
-endif
-
-#
-# Include alternate defs.make if it exists
-#
--include $(HS_ALT_MAKE)/defs.make
-
-# Default to verbose build logs (show all compile lines):
-MAKE_VERBOSE=y
-
-# Make macros for install files or preparing targets
-CD=cd
-CP=cp
-ECHO=echo
-GREP=grep
-MKDIR=mkdir
-MV=mv
-PWD=pwd
-RM=rm -f
-SED=sed
-TAR=tar
-ZIPEXE=zip
-
-define install-file
-@$(MKDIR) -p $(@D)
-@$(RM) $@
-$(CP) $< $@
-endef
-
-# MacOS X strongly discourages 'cp -r' and provides 'cp -R' instead.
-# May need to have a MacOS X specific definition of install-dir
-# sometime in the future.
-define install-dir
-@$(MKDIR) -p $(@D)
-@$(RM) -r $@
-$(CP) -r $< $@
-endef
-
-define prep-target
-@$(MKDIR) -p $(@D)
-@$(RM) $@
-endef
-
-# Default values for JVM_VARIANT* variables if configure hasn't set
-# it already.
-ifeq ($(JVM_VARIANTS),)
-  ifeq ($(ZERO_BUILD), true)
-    ifeq ($(SHARK_BUILD), true)
-      JVM_VARIANTS:=zeroshark
-      JVM_VARIANT_ZEROSHARK:=true
-    else
-      JVM_VARIANTS:=zero
-      JVM_VARIANT_ZERO:=true
-    endif
-  else
-    # A default is needed
-    ifeq ($(BUILD_CLIENT_ONLY), true)
-      JVM_VARIANTS:=client
-      JVM_VARIANT_CLIENT:=true
-    endif
-    # Further defaults are platform and arch specific
-  endif
-endif
-
-# hotspot version definitions
-include $(GAMMADIR)/make/jdk_version
-
-# JDK_PREVIOUS_VERSION is only needed to facilitate standalone builds
-ifeq ($(JDK_PREVIOUS_VERSION),)
-  export JDK_PREVIOUS_VERSION=$(STANDALONE_JDK_PREVIOUS_VERSION)
-endif
-# Java versions needed
-ifeq ($(VERSION_MAJOR),)
-  export VERSION_MAJOR=$(STANDALONE_JDK_MAJOR_VER)
-endif
-ifeq ($(VERSION_MINOR),)
-  export VERSION_MINOR=$(STANDALONE_JDK_MINOR_VER)
-endif
-ifeq ($(VERSION_SECURITY),)
-  export VERSION_SECURITY=$(STANDALONE_JDK_SECURITY_VER)
-endif
-ifeq ($(VERSION_PATCH),)
-  export VERSION_PATCH=$(STANDALONE_JDK_PATCH_VER)
-endif
-ifeq ($(VERSION_BUILD),)
-  export VERSION_BUILD=0
-endif
-ifeq ($(VERSION_SHORT),)
-  export VERSION_SHORT=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_SECURITY)
-endif
-ifeq ($(VERSION_STRING),)
-  # Note that this is an extremely rough and incorrect approximation of a correct version string.
-  export VERSION_STRING=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_SECURITY)-internal
-endif
-
-ifneq ($(HOTSPOT_RELEASE_VERSION),)
-  # Allow old command-line overrides
-  HOTSPOT_VERSION_STRING := $(HOTSPOT_RELEASE_VERSION)
-else
-  # Normally get from surrounding JDK build
-  HOTSPOT_VERSION_STRING := $(VERSION_STRING)
-endif
-
-ifneq ($(HOTSPOT_BUILD_VERSION),)
-  # If old command-lines variable exists, append to version string
-  HOTSPOT_VERSION_STRING := $(HOTSPOT_VERSION_STRING)-$(HOTSPOT_BUILD_VERSION)
-else
-  ifeq ($(SPEC),)
-    # If building standalone, add -internal.
-    HOTSPOT_VERSION_STRING := $(HOTSPOT_VERSION_STRING)-internal
-  endif
-endif
-
-# Windows should have OS predefined
-ifeq ($(OS),)
-  OS   := $(shell uname -s)
-  ifneq ($(findstring BSD,$(OS)),)
-    OS=bsd
-  endif
-  ifeq ($(OS), Darwin)
-    OS=bsd
-  endif
-  HOST := $(shell uname -n)
-endif
-
-# If not SunOS, not Linux not BSD and not AIX, assume Windows
-ifneq ($(OS), Linux)
-  ifneq ($(OS), SunOS)
-    ifneq ($(OS), bsd)
-      ifneq ($(OS), AIX)
-        OSNAME=windows
-      else
-        OSNAME=aix
-      endif
-    else
-      OSNAME=bsd
-    endif
-  else
-    OSNAME=solaris
-  endif
-else
-  OSNAME=linux
-endif
-
-# Determinations of default make arguments and platform specific settings
-MAKE_ARGS=
-
-# ARCH_DATA_MODEL==64 is equivalent to LP64=1
-ifeq ($(ARCH_DATA_MODEL), 64)
-  ifndef LP64
-    LP64 := 1
-  endif
-endif
-
-# Defaults set for product build
-EXPORT_SUBDIR=
-
-# Change default /java path if requested
-ifneq ($(ALT_SLASH_JAVA),)
-  SLASH_JAVA=$(ALT_SLASH_JAVA)
-endif
-
-# Default OUTPUTDIR
-OUTPUTDIR=$(HS_BUILD_DIR)/$(OSNAME)
-ifneq ($(ALT_OUTPUTDIR),)
-  OUTPUTDIR=$(ALT_OUTPUTDIR)
-endif
-
-# Find latest promoted JDK area
-JDK_IMPORT_PATH=$(SLASH_JAVA)/re/j2se/$(VERSION_STRING)/promoted/latest/binaries/$(PLATFORM)
-ifneq ($(ALT_JDK_IMPORT_PATH),)
-  JDK_IMPORT_PATH=$(ALT_JDK_IMPORT_PATH)
-endif
-
-# Other parts of JDK build may require an import JDK that can be executed
-# on the build host. For cross-compile builds we also need an import JDK
-# that matches the target arch, so for that we set ALT_JDK_TARGET_IMPORT_PATH
-ifneq ($(ALT_JDK_TARGET_IMPORT_PATH),)
-  JDK_IMPORT_PATH=$(ALT_JDK_TARGET_IMPORT_PATH)
-endif
-
-# Find JDK used for javac compiles
-BOOTDIR=$(SLASH_JAVA)/re/j2se/$(JDK_PREVIOUS_VERSION)/latest/binaries/$(PLATFORM)
-ifneq ($(ALT_BOOTDIR),)
-  BOOTDIR=$(ALT_BOOTDIR)
-endif
-
-# Select name of the export directory and honor ALT overrides
-EXPORT_PATH=$(OUTPUTDIR)/export-$(PLATFORM)$(EXPORT_SUBDIR)
-ifneq ($(ALT_EXPORT_PATH),)
-  EXPORT_PATH=$(ALT_EXPORT_PATH)
-endif
-
-# Default jdk image if one is created for you with create_jdk
-JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-$(PLATFORM)
-ifneq ($(ALT_JDK_IMAGE_DIR),)
-  JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR)
-endif
-
-# The platform dependent defs.make defines platform specific variable such
-# as ARCH, EXPORT_LIST etc. We must place the include here after BOOTDIR is defined.
-include $(GAMMADIR)/make/$(OSNAME)/makefiles/defs.make
-
-# We are trying to put platform specific defintions
-# files to make/$(OSNAME)/makefiles dictory. However
-# some definitions are common for both linux and solaris,
-# so we put them here.
-ifneq ($(OSNAME),windows)
-  ABS_OUTPUTDIR     := $(shell mkdir -p $(OUTPUTDIR); $(CD) $(OUTPUTDIR); $(PWD))
-  ABS_BOOTDIR       := $(shell $(CD) $(BOOTDIR); $(PWD))
-  ABS_GAMMADIR      := $(shell $(CD) $(GAMMADIR); $(PWD))
-  ABS_OS_MAKEFILE   := $(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME); $(PWD))/Makefile
-
-  # uname, HotSpot source directory, build directory and JDK use different names
-  # for CPU architectures.
-  #   ARCH      - uname output
-  #   SRCARCH   - where to find HotSpot cpu and os_cpu source files
-  #   BUILDARCH - build directory
-  #   LIBARCH   - directory name in JDK/JRE
-
-  # Use uname output for SRCARCH, but deal with platform differences. If ARCH
-  # is not explicitly listed below, it is treated as x86.
-  SRCARCH    ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 ppc64le aarch64 zero,$(ARCH)))
-  ARCH/       = x86
-  ARCH/sparc  = sparc
-  ARCH/sparc64= sparc
-  ARCH/ia64   = ia64
-  ARCH/amd64  = x86
-  ARCH/x86_64 = x86
-  ARCH/ppc64  = ppc
-  ARCH/ppc64le= ppc
-  ARCH/ppc    = ppc
-  ARCH/aarch64= aarch64
-  ARCH/zero   = zero
-
-  # BUILDARCH is usually the same as SRCARCH, except for sparcv9
-  BUILDARCH ?= $(SRCARCH)
-  ifeq ($(BUILDARCH), x86)
-    ifdef LP64
-      BUILDARCH = amd64
-    else
-      BUILDARCH = i486
-    endif
-  endif
-  ifeq ($(BUILDARCH), sparc)
-    ifdef LP64
-      BUILDARCH = sparcv9
-    endif
-  endif
-  ifeq ($(BUILDARCH), ppc)
-    ifdef LP64
-      BUILDARCH = ppc64
-    endif
-  endif
-
-  # LIBARCH is 1:1 mapping from BUILDARCH, except for ARCH=ppc64le
-  ifeq ($(ARCH),ppc64le)
-    LIBARCH      ?= ppc64le
-  else
-    LIBARCH      ?= $(LIBARCH/$(BUILDARCH))
-  endif
-
-  LIBARCH/i486    = i386
-  LIBARCH/amd64   = amd64
-  LIBARCH/sparc   = sparc
-  LIBARCH/sparcv9 = sparcv9
-  LIBARCH/ia64    = ia64
-  LIBARCH/ppc64   = ppc64
-  LIBARCH/aarch64 = aarch64
-  LIBARCH/zero    = $(ZERO_LIBARCH)
-
-  LP64_ARCH = sparcv9 amd64 ia64 ppc64 aarch64 zero
-endif
-
-# Required make macro settings for all platforms
-MAKE_ARGS += BOOTDIR=$(ABS_BOOTDIR)
-MAKE_ARGS += OUTPUTDIR=$(ABS_OUTPUTDIR)
-MAKE_ARGS += GAMMADIR=$(ABS_GAMMADIR)
-MAKE_ARGS += MAKE_VERBOSE=$(MAKE_VERBOSE)
-MAKE_ARGS += VERSION_STRING=$(VERSION_STRING)
-
-MAKE_ARGS += BOOT_JDK_SOURCETARGET="$(BOOT_JDK_SOURCETARGET)"
-
-# Various export sub directories
-EXPORT_INCLUDE_DIR = $(EXPORT_PATH)/include
-EXPORT_DOCS_DIR = $(EXPORT_PATH)/docs
-EXPORT_LIB_DIR = $(EXPORT_PATH)/lib
-EXPORT_BIN_DIR = $(EXPORT_PATH)/bin
-EXPORT_LIB_ARCH_DIR = $(EXPORT_LIB_DIR)/$(LIBARCH)
-
-# non-universal macosx builds need to appear universal
-ifeq ($(OS_VENDOR), Darwin)
-  ifneq ($(MACOSX_UNIVERSAL), true)
-    EXPORT_LIB_ARCH_DIR = $(EXPORT_LIB_DIR)
-  endif
-endif
-
-# Common export list of files
-EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmti.h
-EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmticmlr.h
-EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h
-EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h
-EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h
-
-.PHONY: $(HS_ALT_MAKE)/defs.make
diff --git a/hotspot/make/excludeSrc.make b/hotspot/make/excludeSrc.make
deleted file mode 100644
index cab00ed..0000000
--- a/hotspot/make/excludeSrc.make
+++ /dev/null
@@ -1,131 +0,0 @@
-#
-# Copyright (c) 2014, 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
-# 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 $(GAMMADIR)/make/altsrc.make
-
-ifeq ($(INCLUDE_JVMTI), false)
-      CXXFLAGS += -DINCLUDE_JVMTI=0
-      CFLAGS += -DINCLUDE_JVMTI=0
-
-      Src_Files_EXCLUDE += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \
-	jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \
-	jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \
-	jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
-	jvmtiClassFileReconstituter.cpp
-endif
-
-ifeq ($(INCLUDE_FPROF), false)
-      CXXFLAGS += -DINCLUDE_FPROF=0
-      CFLAGS += -DINCLUDE_FPROF=0
-
-      Src_Files_EXCLUDE += fprofiler.cpp
-endif
-
-ifeq ($(INCLUDE_VM_STRUCTS), false)
-      CXXFLAGS += -DINCLUDE_VM_STRUCTS=0
-      CFLAGS += -DINCLUDE_VM_STRUCTS=0
-
-      Src_Files_EXCLUDE += vmStructs.cpp
-endif
-
-ifeq ($(INCLUDE_JNI_CHECK), false)
-      CXXFLAGS += -DINCLUDE_JNI_CHECK=0
-      CFLAGS += -DINCLUDE_JNI_CHECK=0
-
-      Src_Files_EXCLUDE += jniCheck.cpp
-endif
-
-ifeq ($(INCLUDE_SERVICES), false)
-      CXXFLAGS += -DINCLUDE_SERVICES=0
-      CFLAGS += -DINCLUDE_SERVICES=0
-
-      Src_Files_EXCLUDE += heapDumper.cpp heapInspection.cpp \
-	attachListener_linux.cpp attachListener.cpp
-endif
-
-ifeq ($(INCLUDE_MANAGEMENT), false)
-      CXXFLAGS += -DINCLUDE_MANAGEMENT=0
-      CFLAGS += -DINCLUDE_MANAGEMENT=0
-endif
-
-ifeq ($(INCLUDE_CDS), false)
-      CXXFLAGS += -DINCLUDE_CDS=0
-      CFLAGS += -DINCLUDE_CDS=0
-
-      Src_Files_EXCLUDE += classListParser.cpp classLoaderExt.cpp \
-        filemap.cpp metaspaceShared*.cpp sharedClassUtil.cpp sharedPathsMiscInfo.cpp \
-        systemDictionaryShared.cpp
-endif
-
-ifeq ($(INCLUDE_ALL_GCS), false)
-      CXXFLAGS += -DINCLUDE_ALL_GCS=0
-      CFLAGS += -DINCLUDE_ALL_GCS=0
-
-      gc_dir := $(HS_COMMON_SRC)/share/vm/gc
-      gc_dir_alt := $(HS_ALT_SRC)/share/vm/gc
-      gc_subdirs := cms g1 parallel
-      gc_exclude := $(foreach gc,$(gc_subdirs),				\
-		     $(notdir $(wildcard $(gc_dir)/$(gc)/*.cpp))	\
-		     $(notdir $(wildcard $(gc_dir_alt)/$(gc)/*.cpp)))
-      Src_Files_EXCLUDE += $(gc_exclude)				\
-	concurrentGCThread.cpp						\
-	plab.cpp
-
-      # src/share/vm/services
-      Src_Files_EXCLUDE +=						\
-	g1MemoryPool.cpp						\
-	psMemoryPool.cpp
-endif
-
-ifeq ($(INCLUDE_NMT), false)
-      CXXFLAGS += -DINCLUDE_NMT=0
-      CFLAGS += -DINCLUDE_NMT=0
-
-      Src_Files_EXCLUDE += \
-	 memBaseline.cpp memReporter.cpp mallocTracker.cpp virtualMemoryTracker.cpp nmtCommon.cpp \
-	 memTracker.cpp nmtDCmd.cpp mallocSiteTable.cpp
-endif
-
-ifneq (,$(findstring $(Platform_arch_model), aarch64, arm_64, sparc, x86_64))
-      # JVMCI is supported
-else
-      INCLUDE_JVMCI := false
-endif
-
-ifeq ($(INCLUDE_JVMCI), false)
-      CXXFLAGS += -DINCLUDE_JVMCI=0
-      CFLAGS += -DINCLUDE_JVMCI=0
-
-      jvmci_dir := $(HS_COMMON_SRC)/share/vm/jvmci
-      jvmci_dir_alt := $(HS_ALT_SRC)/share/vm/jvmci
-      jvmci_exclude := $(notdir $(wildcard $(jvmci_dir)/*.cpp))	\
-			$(notdir $(wildcard $(jvmci_dir_alt)/*.cpp))
-      Src_Files_EXCLUDE += $(jvmci_exclude) \
-	jvmciCodeInstaller_aarch64.cpp jvmciCodeInstaller_ppc.cpp jvmciCodeInstaller_sparc.cpp \
-	jvmciCodeInstaller_x86.cpp
-endif
-
--include $(HS_ALT_MAKE)/excludeSrc.make
-
-.PHONY: $(HS_ALT_MAKE)/excludeSrc.make
diff --git a/hotspot/makefiles/gensrc/GenerateSources.gmk b/hotspot/make/gensrc/GenerateSources.gmk
similarity index 100%
rename from hotspot/makefiles/gensrc/GenerateSources.gmk
rename to hotspot/make/gensrc/GenerateSources.gmk
diff --git a/hotspot/makefiles/gensrc/GensrcAdlc.gmk b/hotspot/make/gensrc/GensrcAdlc.gmk
similarity index 100%
rename from hotspot/makefiles/gensrc/GensrcAdlc.gmk
rename to hotspot/make/gensrc/GensrcAdlc.gmk
diff --git a/hotspot/makefiles/gensrc/GensrcDtrace.gmk b/hotspot/make/gensrc/GensrcDtrace.gmk
similarity index 100%
rename from hotspot/makefiles/gensrc/GensrcDtrace.gmk
rename to hotspot/make/gensrc/GensrcDtrace.gmk
diff --git a/hotspot/makefiles/gensrc/GensrcJvmti.gmk b/hotspot/make/gensrc/GensrcJvmti.gmk
similarity index 100%
rename from hotspot/makefiles/gensrc/GensrcJvmti.gmk
rename to hotspot/make/gensrc/GensrcJvmti.gmk
diff --git a/hotspot/make/hotspot_distro b/hotspot/make/hotspot_distro
deleted file mode 100644
index 059f4d1..0000000
--- a/hotspot/make/hotspot_distro
+++ /dev/null
@@ -1,32 +0,0 @@
-# 
-# Copyright (c) 2006, 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.
-# 
-
-#
-# This file format must remain compatible with both
-# GNU Makefile and Microsoft nmake formats.
-#
-
-# Don't put quotes (fail windows build).
-HOTSPOT_VM_DISTRO=Java HotSpot(TM)
-COMPANY_NAME=Oracle Corporation
-PRODUCT_NAME=Java(TM) Platform SE
diff --git a/hotspot/makefiles/ide/CreateVSProject.gmk b/hotspot/make/ide/CreateVSProject.gmk
similarity index 98%
rename from hotspot/makefiles/ide/CreateVSProject.gmk
rename to hotspot/make/ide/CreateVSProject.gmk
index d804dcc..d6f5324 100644
--- a/hotspot/makefiles/ide/CreateVSProject.gmk
+++ b/hotspot/make/ide/CreateVSProject.gmk
@@ -90,7 +90,7 @@
   $(eval $(call SetupJavaCompilation, BUILD_PROJECT_CREATOR, \
       SETUP := GENERATE_OLDBYTECODE, \
       ADD_JAVAC_FLAGS := -Xlint:-auxiliaryclass, \
-      SRC := $(HOTSPOT_TOPDIR)/makefiles/src/classes, \
+      SRC := $(HOTSPOT_TOPDIR)/make/src/classes, \
       BIN := $(TOOLS_OUTPUTDIR), \
   ))
 
diff --git a/hotspot/make/jdk_version b/hotspot/make/jdk_version
deleted file mode 100644
index 90b509e..0000000
--- a/hotspot/make/jdk_version
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Copyright (c) 2006, 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
-# 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.
-#
-# Master JDK version file.  These values may be overridden by a control
-# workspace build.  This file format must remain compatible with both
-# GNU Makefile and Microsoft nmake formats.
-#
-
-# Don't put quotes (fail windows build).
-HOTSPOT_VM_COPYRIGHT=Copyright 2015
-
-STANDALONE_JDK_MAJOR_VER=9
-STANDALONE_JDK_MINOR_VER=0
-STANDALONE_JDK_SECURITY_VER=0
-STANDALONE_JDK_PATCH_VER=0
-
-# Previous (bootdir) JDK version
-STANDALONE_JDK_PREVIOUS_VERSION=1.8.0
diff --git a/hotspot/make/jprt.gmk b/hotspot/make/jprt.gmk
deleted file mode 100644
index 41db068..0000000
--- a/hotspot/make/jprt.gmk
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# JPRT rule to build this workspace
-
-JPRT_ARCHIVE_BUNDLE=$(ABS_OUTPUTDIR)/$(JPRT_BUILD_FLAVOR)-bundle.zip
-
-ifeq ($(OSNAME),windows)
-  ZIPFLAGS=-q
-else
-  # store symbolic links as the link
-  ZIPFLAGS=-q -y
-endif
-
-jprt_build_productEmb:
-	$(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_product
-
-jprt_build_debugEmb:
-	$(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_debug
-
-jprt_build_fastdebugEmb:
-	$(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_fastdebug
-
-jprt_build_optimizedEmb:
-	$(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_optimized
-
-jprt_build_productOpen:
-	$(MAKE) OPENJDK=true jprt_build_product
-
-jprt_build_debugOpen:
-	$(MAKE) OPENJDK=true jprt_build_debug
-
-jprt_build_fastdebugOpen:
-	$(MAKE) OPENJDK=true jprt_build_fastdebug
-
-jprt_build_optimizedOpen:
-	$(MAKE) OPENJDK=true jprt_build_optimized
-
-jprt_build_product: all_product copy_product_jdk export_product_jdk
-	( $(CD) $(JDK_IMAGE_DIR) && \
-	  $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . )
-
-jprt_build_fastdebug: all_fastdebug copy_fastdebug_jdk export_fastdebug_jdk
-	( $(CD) $(JDK_IMAGE_DIR)/fastdebug && \
-	  $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . )
-
-jprt_build_debug: all_debug copy_debug_jdk export_debug_jdk
-	( $(CD) $(JDK_IMAGE_DIR)/debug && \
-	  $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . )
-
-jprt_build_optimized: all_optimized copy_optimized_jdk export_optimized_jdk
-	( $(CD) $(JDK_IMAGE_DIR)/optimized && \
-	  $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . )
-
-.PHONY: jprt_build_product jprt_build_fastdebug jprt_build_debug jprt_build_optimized
-
diff --git a/hotspot/makefiles/lib/CompileDtracePostJvm.gmk b/hotspot/make/lib/CompileDtracePostJvm.gmk
similarity index 97%
rename from hotspot/makefiles/lib/CompileDtracePostJvm.gmk
rename to hotspot/make/lib/CompileDtracePostJvm.gmk
index 127460a..50a7f10 100644
--- a/hotspot/makefiles/lib/CompileDtracePostJvm.gmk
+++ b/hotspot/make/lib/CompileDtracePostJvm.gmk
@@ -186,7 +186,7 @@
         CFLAGS := -m64 -G -mt -KPIC, \
         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
         LIBS := $(LIBDL) -lc -lthread -ldoor, \
-        MAPFILE := $(HOTSPOT_TOPDIR)/makefiles/mapfiles/libjvm_dtrace/mapfile-vers, \
+        MAPFILE := $(HOTSPOT_TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \
         OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
         STRIP_SYMBOLS := true, \
     ))
@@ -204,7 +204,7 @@
             -m64 -G -mt -KPIC, \
         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
         LIBS := -lc, \
-        MAPFILE := $(HOTSPOT_TOPDIR)/makefiles/mapfiles/libjvm_db/mapfile-vers, \
+        MAPFILE := $(HOTSPOT_TOPDIR)/make/mapfiles/libjvm_db/mapfile-vers, \
         OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \
         STRIP_SYMBOLS := true, \
     ))
diff --git a/hotspot/makefiles/lib/CompileDtracePreJvm.gmk b/hotspot/make/lib/CompileDtracePreJvm.gmk
similarity index 100%
rename from hotspot/makefiles/lib/CompileDtracePreJvm.gmk
rename to hotspot/make/lib/CompileDtracePreJvm.gmk
diff --git a/hotspot/make/lib/CompileGtest.gmk b/hotspot/make/lib/CompileGtest.gmk
new file mode 100644
index 0000000..9cf1d89
--- /dev/null
+++ b/hotspot/make/lib/CompileGtest.gmk
@@ -0,0 +1,116 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+GTEST_TEST_SRC := $(HOTSPOT_TOPDIR)/test/native
+GTEST_FRAMEWORK_SRC := $(SRC_ROOT)/test/fmw/gtest
+
+# On Windows, there are no internal debug symbols so must set copying to true
+# to get any at all.
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  GTEST_COPY_DEBUG_SYMBOLS := true
+else
+  GTEST_COPY_DEBUG_SYMBOLS := false
+endif
+
+################################################################################
+
+GTEST_TEST_SRC_FILES := $(shell $(FIND) $(HOTSPOT_TOPDIR)/test/native -name \
+    "test*.cpp" -type f)
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  GTEST_JVM_MAPFILE := $(JVM_MAPFILE)
+else
+  GTEST_JVM_MAPFILE := $(JVM_OUTPUTDIR)/gtest/mapfile
+
+  $(JVM_OUTPUTDIR)/gtest/symbols: $(JVM_OUTPUTDIR)/symbols
+	$(call MakeDir, $(@D))
+	( $(CAT) $< ; echo "runUnitTests" ) > $@
+
+  $(GTEST_JVM_MAPFILE): $(JVM_OUTPUTDIR)/gtest/symbols
+	$(call create-mapfile)
+endif
+
+# Disabling switch warning for clang because of test source.
+
+$(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \
+    TOOLCHAIN := $(JVM_TOOLCHAIN), \
+    LIBRARY := jvm, \
+    OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \
+    EXTRA_FILES := $(GTEST_TEST_SRC_FILES) \
+        $(GTEST_FRAMEWORK_SRC)/src/gtest-all.cc \
+        $(GTEST_TEST_SRC)/gtestMain.cpp, \
+    OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/objs, \
+    EXTRA_OBJECT_FILES := $(filter-out %/operator_new$(OBJ_SUFFIX), \
+        $(BUILD_LIBJVM_ALL_OBJS)), \
+    CFLAGS := $(JVM_CFLAGS) -I$(GTEST_FRAMEWORK_SRC) \
+        -I$(GTEST_FRAMEWORK_SRC)/include \
+        -I$(GTEST_TEST_SRC), \
+    CFLAGS_windows := /EHsc, \
+    CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4, \
+    CFLAGS_macosx := -DGTEST_OS_MAC=1, \
+    CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
+    CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
+    DISABLED_WARNINGS_gcc := undef, \
+    DISABLED_WARNINGS_clang := undef switch format-nonliteral \
+        tautological-undefined-compare, \
+    DISABLED_WARNINGS_solstudio := identexpected, \
+    LDFLAGS := $(JVM_LDFLAGS), \
+    LDFLAGS_solaris := -library=stlport4 $(call SET_SHARED_LIBRARY_ORIGIN), \
+    LIBS := $(JVM_LIBS), \
+    OPTIMIZATION := $(JVM_OPTIMIZATION), \
+    MAPFILE := $(GTEST_JVM_MAPFILE), \
+    USE_MAPFILE_FOR_SYMBOLS := true, \
+    COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
+    ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
+))
+
+TARGETS += $(BUILD_GTEST_LIBJVM)
+
+################################################################################
+
+$(eval $(call SetupNativeCompilation, BUILD_GTEST_LAUNCHER, \
+    TOOLCHAIN := $(JVM_TOOLCHAIN), \
+    PROGRAM := gtestLauncher, \
+    OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \
+    EXTRA_FILES := $(GTEST_TEST_SRC)/gtestLauncher.cpp, \
+    OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/launcher-objs, \
+    CFLAGS := $(JVM_CFLAGS) -I$(GTEST_FRAMEWORK_SRC) \
+        -I$(GTEST_FRAMEWORK_SRC)/include, \
+    CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
+    CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
+    LDFLAGS := $(LDFLAGS_TESTEXE), \
+    LDFLAGS_unix := -L$(JVM_OUTPUTDIR)/gtest $(call SET_SHARED_LIBRARY_ORIGIN), \
+    LDFLAGS_solaris := -library=stlport4, \
+    LIBS_unix := -ljvm, \
+    LIBS_windows := $(JVM_OUTPUTDIR)/gtest/objs/jvm.lib, \
+    COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
+    ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
+))
+
+$(BUILD_GTEST_LAUNCHER): $(BUILD_GTEST_LIBJVM)
+
+TARGETS += $(BUILD_GTEST_LAUNCHER)
+
+################################################################################
diff --git a/hotspot/makefiles/lib/CompileJvm.gmk b/hotspot/make/lib/CompileJvm.gmk
similarity index 100%
rename from hotspot/makefiles/lib/CompileJvm.gmk
rename to hotspot/make/lib/CompileJvm.gmk
diff --git a/hotspot/makefiles/lib/CompileLibjsig.gmk b/hotspot/make/lib/CompileLibjsig.gmk
similarity index 96%
rename from hotspot/makefiles/lib/CompileLibjsig.gmk
rename to hotspot/make/lib/CompileLibjsig.gmk
index ba9791c..1c9a10f 100644
--- a/hotspot/makefiles/lib/CompileLibjsig.gmk
+++ b/hotspot/make/lib/CompileLibjsig.gmk
@@ -79,7 +79,7 @@
     endif
 
     LIBJSIG_SRC_FILE := $(HOTSPOT_TOPDIR)/src/os/$(HOTSPOT_TARGET_OS)/vm/jsig.c
-    LIBJSIG_MAPFILE := $(wildcard $(HOTSPOT_TOPDIR)/makefiles/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS))
+    LIBJSIG_MAPFILE := $(wildcard $(HOTSPOT_TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS))
     LIBJSIG_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/libjsig
 
     LIBJSIG_LDFLAGS += $(SHARED_LIBRARY_FLAGS)
diff --git a/hotspot/makefiles/lib/CompileLibraries.gmk b/hotspot/make/lib/CompileLibraries.gmk
similarity index 95%
rename from hotspot/makefiles/lib/CompileLibraries.gmk
rename to hotspot/make/lib/CompileLibraries.gmk
index 7a7a165..d7e39e7 100644
--- a/hotspot/makefiles/lib/CompileLibraries.gmk
+++ b/hotspot/make/lib/CompileLibraries.gmk
@@ -37,6 +37,10 @@
 include lib/CompileJvm.gmk
 include lib/CompileDtracePostJvm.gmk
 
+ifeq ($(BUILD_GTEST), true)
+  include lib/CompileGtest.gmk
+endif
+
 all: $(TARGETS)
 
 .PHONY: all
diff --git a/hotspot/makefiles/lib/JvmFeatures.gmk b/hotspot/make/lib/JvmFeatures.gmk
similarity index 100%
rename from hotspot/makefiles/lib/JvmFeatures.gmk
rename to hotspot/make/lib/JvmFeatures.gmk
diff --git a/hotspot/makefiles/lib/JvmMapfile.gmk b/hotspot/make/lib/JvmMapfile.gmk
similarity index 85%
rename from hotspot/makefiles/lib/JvmMapfile.gmk
rename to hotspot/make/lib/JvmMapfile.gmk
index 9d7655b..9f9c928 100644
--- a/hotspot/makefiles/lib/JvmMapfile.gmk
+++ b/hotspot/make/lib/JvmMapfile.gmk
@@ -31,20 +31,20 @@
 ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86_64)
   # On Windows x86_64, we should not have any symbols at all, since that
   # results in duplicate warnings from the linker (JDK-8043491).
-  SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-shared
+  SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-shared
 endif
 
 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
-  SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-unix
+  SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-unix
 endif
 
-ifneq ($(wildcard $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)), )
-  SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)
+ifneq ($(wildcard $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS)), )
+  SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS)
 endif
 
 ifneq ($(findstring debug, $(DEBUG_LEVEL)), )
-  ifneq ($(wildcard $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)-debug), )
-    SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)-debug
+  ifneq ($(wildcard $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS)-debug), )
+    SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS)-debug
   endif
 endif
 
@@ -53,9 +53,9 @@
     # Additional mapfiles that are only used when dtrace is enabled
     ifeq ($(call check-jvm-feature, compiler2), true)
       # This also covers the case of compiler1+compiler2.
-      SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-solaris-dtrace-compiler2
+      SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-solaris-dtrace-compiler2
     else ifeq ($(call check-jvm-feature, compiler1), true)
-      SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-solaris-dtrace-compiler1
+      SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-solaris-dtrace-compiler1
     endif
   endif
 endif
@@ -153,20 +153,33 @@
 ################################################################################
 # Finally convert the symbol list into a platform-specific mapfile
 
-$(JVM_MAPFILE): $(JVM_OUTPUTDIR)/symbols
-	$(call LogInfo, Creating mapfile)
-	$(RM) $@
-        ifeq ($(OPENJDK_TARGET_OS), macosx)
-          # On macosx, we need to add a leading underscore
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+  # On macosx, we need to add a leading underscore
+  define create-mapfile-work
 	  $(AWK) '{ if ($$0 ~ ".") { print "  _" $$0 } }'  < $^ > $@.tmp
-        else ifeq ($(OPENJDK_TARGET_OS), windows)
-          # On windows, add an 'EXPORTS' header
+  endef
+else ifeq ($(OPENJDK_TARGET_OS), windows)
+  # On windows, add an 'EXPORTS' header
+  define create-mapfile-work
 	  $(ECHO) "EXPORTS" > $@.tmp
 	  $(AWK) '{ if ($$0 ~ ".") { print "  " $$0 } }'  < $^ >> $@.tmp
-        else
-          # Assume standard linker script
+  endef
+else
+  # Assume standard linker script
+  define create-mapfile-work
 	  $(PRINTF) "SUNWprivate_1.1 { \n  global: \n" > $@.tmp
 	  $(AWK) '{ if ($$0 ~ ".") { print "    " $$0 ";" } }' < $^ >> $@.tmp
 	  $(PRINTF) "  local: \n    *; \n }; \n" >> $@.tmp
-        endif
+  endef
+endif
+
+define create-mapfile
+	$(call LogInfo, Creating mapfile)
+	$(call MakeDir, $(@D))
+	$(call create-mapfile-work)
+	$(RM) $@
 	$(MV) $@.tmp $@
+endef
+
+$(JVM_MAPFILE): $(JVM_OUTPUTDIR)/symbols
+	$(call create-mapfile)
diff --git a/hotspot/makefiles/lib/JvmOverrideFiles.gmk b/hotspot/make/lib/JvmOverrideFiles.gmk
similarity index 100%
rename from hotspot/makefiles/lib/JvmOverrideFiles.gmk
rename to hotspot/make/lib/JvmOverrideFiles.gmk
diff --git a/hotspot/make/linux/Makefile b/hotspot/make/linux/Makefile
deleted file mode 100644
index dba2862..0000000
--- a/hotspot/make/linux/Makefile
+++ /dev/null
@@ -1,385 +0,0 @@
-#
-# 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile creates a build tree and lights off a build.
-# You can go back into the build tree and perform rebuilds or
-# incremental builds as desired. Be sure to reestablish
-# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME.
-
-# The make process now relies on java and javac. These can be
-# specified either implicitly on the PATH, by setting the
-# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a
-# JDK in which bin/java and bin/javac are present and working (e.g.,
-# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited)
-# default BOOTDIR path value. Note that one of ALT_BOOTDIR
-# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc.
-# from the PATH.
-#
-# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on
-# an architecture that differs from the target architecture, as long
-# as the bootstrap jdk runs under the same flavor of OS as the target
-# (i.e., if the target is linux, point to a jdk that runs on a linux
-# box).  In order to use such a bootstrap jdk, set the make variable
-# REMOTE to the desired remote command mechanism, e.g.,
-#
-#    make REMOTE="rsh -l me myotherlinuxbox"
-
-ifeq ($(GAMMADIR),)
-include ../../make/defs.make
-else
-include $(GAMMADIR)/make/defs.make
-endif
-include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make
-
-ifndef CC_INTERP
-  ifndef FORCE_TIERED
-    FORCE_TIERED=1
-  endif
-endif
-
-ifdef LP64
-  ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
-    _JUNK_ := $(shell echo >&2 \
-       $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!")
-	@exit 1
-  endif
-endif
-
-# we need to set up LP64 correctly to satisfy sanity checks in adlc
-ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
-  MFLAGS += " LP64=1 "
-endif
-
-# pass USE_SUNCC further, through MFLAGS
-ifdef USE_SUNCC
-  MFLAGS += " USE_SUNCC=1 "
-endif
-
-# The following renders pathnames in generated Makefiles valid on
-# machines other than the machine containing the build tree.
-#
-# For example, let's say my build tree lives on /files12 on
-# exact.east.sun.com.  This logic will cause GAMMADIR to begin with
-# /net/exact/files12/...
-#
-# We only do this on SunOS variants, for a couple of reasons:
-#  * It is extremely rare that source trees exist on other systems
-#  * It has been claimed that the Linux automounter is flakey, so
-#    changing GAMMADIR in a way that exercises the automounter could
-#    prove to be a source of unreliability in the build process.
-# Obviously, this Makefile is only relevant on SunOS boxes to begin
-# with, but the SunOS conditionalization will make it easier to
-# combine Makefiles in the future (assuming we ever do that).
-
-ifeq ($(OSNAME),solaris)
-
-  #   prepend current directory to relative pathnames.
-  NEW_GAMMADIR :=                                    \
-    $(shell echo $(GAMMADIR) |                       \
-      sed -e "s=^\([^/].*\)=$(shell pwd)/\1="        \
-     )
-  unexport NEW_GAMMADIR
-
-  # If NEW_GAMMADIR doesn't already start with "/net/":
-  ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),)
-    #   prepend /net/$(HOST)
-    #   remove /net/$(HOST) if name already began with /home/
-    #   remove /net/$(HOST) if name already began with /java/
-    #   remove /net/$(HOST) if name already began with /lab/
-    NEW_GAMMADIR :=                                     \
-         $(shell echo $(NEW_GAMMADIR) |                 \
-                 sed -e "s=^\(.*\)=/net/$(HOST)\1="     \
-                     -e "s=^/net/$(HOST)/home/=/home/=" \
-                     -e "s=^/net/$(HOST)/java/=/java/=" \
-                     -e "s=^/net/$(HOST)/lab/=/lab/="   \
-          )
-    # Don't use the new value for GAMMADIR unless a file with the new
-    # name actually exists.
-    ifneq ($(wildcard $(NEW_GAMMADIR)),)
-      GAMMADIR := $(NEW_GAMMADIR)
-    endif
-  endif
-
-endif
-
-# BUILDARCH is set to "zero" for Zero builds.  VARIANTARCH
-# is used to give the build directories meaningful names.
-VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH))
-
-# There is a (semi-) regular correspondence between make targets and actions:
-#
-#       Target          Tree Type       Build Dir
-#
-#       debug           compiler2       <os>_<arch>_compiler2/debug
-#       fastdebug       compiler2       <os>_<arch>_compiler2/fastdebug
-#       optimized       compiler2       <os>_<arch>_compiler2/optimized
-#       product         compiler2       <os>_<arch>_compiler2/product
-#
-#       debug1          compiler1       <os>_<arch>_compiler1/debug
-#       fastdebug1      compiler1       <os>_<arch>_compiler1/fastdebug
-#       optimized1      compiler1       <os>_<arch>_compiler1/optimized
-#       product1        compiler1       <os>_<arch>_compiler1/product
-#
-#       debugcore       core            <os>_<arch>_core/debug
-#       fastdebugcore   core            <os>_<arch>_core/fastdebug
-#       optimizedcore   core            <os>_<arch>_core/optimized
-#       productcore     core            <os>_<arch>_core/product
-#
-#       debugzero       zero            <os>_<arch>_zero/debug
-#       fastdebugzero   zero            <os>_<arch>_zero/fastdebug
-#       optimizedzero   zero            <os>_<arch>_zero/optimized
-#       productzero     zero            <os>_<arch>_zero/product
-#
-#       debugshark      shark           <os>_<arch>_shark/debug
-#       fastdebugshark  shark           <os>_<arch>_shark/fastdebug
-#       optimizedshark  shark           <os>_<arch>_shark/optimized
-#       productshark    shark           <os>_<arch>_shark/product
-#
-#       fastdebugminimal1 minimal1      <os>_<arch>_minimal1/fastdebug
-#       productminimal1   minimal1      <os>_<arch>_minimal1/product
-#
-# What you get with each target:
-#
-# debug*     - debug compile with asserts enabled
-# fastdebug* - optimized compile, but with asserts enabled
-# optimized* - optimized compile, no asserts
-# product*   - the shippable thing:  optimized compile, no asserts, -DPRODUCT
-
-# This target list needs to be coordinated with the usage message
-# in the build.sh script:
-TARGETS           = debug fastdebug optimized product
-
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  SUBDIR_DOCS     = $(OSNAME)_$(VARIANTARCH)_docs
-else
-  SUBDIR_DOCS     = $(OSNAME)_$(BUILDARCH)_docs
-endif
-SUBDIRS_C1        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS))
-SUBDIRS_C2        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS))
-SUBDIRS_TIERED    = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS))
-SUBDIRS_CORE      = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS))
-SUBDIRS_ZERO      = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS))
-SUBDIRS_SHARK     = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS))
-SUBDIRS_MINIMAL1  = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS))
-
-TARGETS_C2        = $(TARGETS)
-TARGETS_C1        = $(addsuffix 1,$(TARGETS))
-TARGETS_TIERED    = $(addsuffix tiered,$(TARGETS))
-TARGETS_CORE      = $(addsuffix core,$(TARGETS))
-TARGETS_ZERO      = $(addsuffix zero,$(TARGETS))
-TARGETS_SHARK     = $(addsuffix shark,$(TARGETS))
-TARGETS_MINIMAL1 =  $(addsuffix minimal1,$(TARGETS))
-
-BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
-BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
-BUILDTREE_VARS   += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-BUILDTREE_VARS   += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE)
-
-BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
-
-#-------------------------------------------------------------------------------
-
-# Could make everything by default, but that would take a while.
-all:
-	@echo "Try '$(MAKE) <target> ...'  where <target> is one or more of"
-	@echo "  $(TARGETS_C2)"
-	@echo "  $(TARGETS_C1)"
-	@echo "  $(TARGETS_CORE)"
-	@echo "  $(TARGETS_ZERO)"
-	@echo "  $(TARGETS_SHARK)"
-	@echo "  $(TARGETS_MINIMAL1)"
-
-checks: check_os_version check_j2se_version
-
-# We do not want people accidentally building on old systems (e.g. Linux 2.2.x,
-# Solaris 2.5.1, 2.6).
-# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.
-
-SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 4%
-OS_VERSION := $(shell uname -r)
-EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
-
-check_os_version:
-ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
-	$(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
-endif
-
-# jvmti.make requires XSLT (J2SE 1.4.x or newer):
-XSLT_CHECK	= $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
-# If not found then fail fast.
-check_j2se_version:
-	$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
-	  $(REMOTE) $(RUN.JAVA) -version; \
-	  echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
-	  "to bootstrap this build" 1>&2; \
-	  exit 1; \
-	fi
-
-$(SUBDIRS_TIERED): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered
-
-$(SUBDIRS_C2): $(BUILDTREE_MAKE)
-ifeq ($(FORCE_TIERED),1)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1
-else
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler2
-endif
-
-$(SUBDIRS_C1): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler1
-
-$(SUBDIRS_CORE): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=core
-
-$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH)
-
-$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH)
-
-$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=minimal1
-
-
-platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
-	$(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@
-
-# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME
-
-$(TARGETS_C2):  $(SUBDIRS_C2)
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_TIERED):  $(SUBDIRS_TIERED)
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_C1):  $(SUBDIRS_C1)
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_CORE):  $(SUBDIRS_CORE)
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_ZERO):  $(SUBDIRS_ZERO)
-	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_SHARK):  $(SUBDIRS_SHARK)
-	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_MINIMAL1):  $(SUBDIRS_MINIMAL1)
-	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-# Just build the tree, and nothing else:
-tree:      $(SUBDIRS_C2)
-tree1:     $(SUBDIRS_C1)
-treecore:  $(SUBDIRS_CORE)
-treezero:  $(SUBDIRS_ZERO)
-treeshark: $(SUBDIRS_SHARK)
-treeminimal1: $(SUBDIRS_MINIMAL1)
-
-# Doc target.  This is the same for all build options.
-#     Hence create a docs directory beside ...$(ARCH)_[...]
-# We specify 'BUILD_FLAVOR=product' so that the proper
-# ENABLE_FULL_DEBUG_SYMBOLS value is used.
-docs: checks
-	$(QUIETLY) mkdir -p $(SUBDIR_DOCS)
-	$(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs
-
-# Synonyms for win32-like targets.
-compiler2:  debug product
-
-compiler1:  debug1 product1
-
-core: debugcore productcore
-
-zero: debugzero productzero
-
-shark: debugshark productshark
-
-warn_jvmg_deprecated:
-	echo "Warning: The jvmg target has been replaced with debug"
-	echo "Warning: Please update your usage"
-
-jvmg: warn_jvmg_deprecated debug
-
-jvmg1: warn_jvmg_deprecated debug1
-
-jvmgcore: warn_jvmg_deprecated debugcore
-
-jvmgzero: warn_jvmg_deprecated debugzero
-
-jvmgshark: warn_jvmg_deprecated debugshark
-
-clean_docs:
-	rm -rf $(SUBDIR_DOCS)
-
-clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1:
-	rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@)
-
-clean:  clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs
-
-include $(GAMMADIR)/make/cscope.make
-
-#
-# Include alternate Makefile if it exists.
-#
--include $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
-
-#-------------------------------------------------------------------------------
-
-.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1)
-.PHONY: tree tree1 treecore treezero treeshark
-.PHONY: all compiler1 compiler2 core zero shark
-.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs
-.PHONY: checks check_os_version check_j2se_version
-.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
-
-.NOTPARALLEL:
diff --git a/hotspot/make/linux/README b/hotspot/make/linux/README
deleted file mode 100644
index d3efaf8..0000000
--- a/hotspot/make/linux/README
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
-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.
-
-________________________________________________________________________
-
-Please refer to the comments in the Makefile in this directory
-for instructions how to build the Solaris versions.
-
diff --git a/hotspot/make/linux/adlc_updater b/hotspot/make/linux/adlc_updater
deleted file mode 100644
index 99e04e3..0000000
--- a/hotspot/make/linux/adlc_updater
+++ /dev/null
@@ -1,23 +0,0 @@
-#! /bin/sh
-#
-# This file is used by adlc.make to selectively update generated
-# adlc files. Because source and target diretories are relative
-# paths, this file is copied to the target build directory before
-# use.
-#
-# adlc-updater <file> <source-dir> <target-dir>
-#
-fix_lines() {
-  # repair bare #line directives in $1 to refer to $2
-  # and add an override of __FILE__ with just the basename on the
-  # first line of the file.
-  awk < $1 > $1+ -v F2=$2 '
-    BEGIN { print "#line 1 \"" F2 "\""; }
-    /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next}
-    {print}
-  '
-  mv $1+ $1
-}
-fix_lines $2/$1 $1
-[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \
-( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 )
diff --git a/hotspot/make/linux/makefiles/aarch64.make b/hotspot/make/linux/makefiles/aarch64.make
deleted file mode 100644
index 9dedb3e..0000000
--- a/hotspot/make/linux/makefiles/aarch64.make
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-# Must also specify if CPU is little endian
-CFLAGS += -DVM_LITTLE_ENDIAN
-
-CFLAGS += -D_LP64=1
diff --git a/hotspot/make/linux/makefiles/adjust-mflags.sh b/hotspot/make/linux/makefiles/adjust-mflags.sh
deleted file mode 100644
index 97bc02d..0000000
--- a/hotspot/make/linux/makefiles/adjust-mflags.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This script is used only from top.make.
-# The macro $(MFLAGS-adjusted) calls this script to
-# adjust the "-j" arguments to take into account
-# the HOTSPOT_BUILD_JOBS variable.  The default
-# handling of the "-j" argument by gnumake does
-# not meet our needs, so we must adjust it ourselves.
-
-# This argument adjustment applies to two recursive
-# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make.
-# One invokes adlc.make, and the other invokes vm.make.
-# The adjustment propagates the desired concurrency
-# level down to the sub-make (of the adlc or vm).
-# The default behavior of gnumake is to run all
-# sub-makes without concurrency ("-j1").
-
-# Also, we use a make variable rather than an explicit
-# "-j<N>" argument to control this setting, so that
-# the concurrency setting (which must be tuned separately
-# for each MP system) can be set via an environment variable.
-# The recommended setting is 1.5x to 2x the number of available
-# CPUs on the MP system, which is large enough to keep the CPUs
-# busy (even though some jobs may be I/O bound) but not too large,
-# we may presume, to overflow the system's swap space.
-
-set -eu
-
-default_build_jobs=4
-
-case $# in
-[12])	true;;
-*)	>&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;;
-esac
-
-MFLAGS=$1
-HOTSPOT_BUILD_JOBS=${2-}
-
-# Normalize any -jN argument to the form " -j${HBJ}"
-MFLAGS=`
-	echo "$MFLAGS" \
-	| sed '
-		s/^-/ -/
-		s/ -\([^ 	I][^ 	I]*\)j/ -\1 -j/
-		s/ -j[0-9][0-9]*/ -j/
-		s/ -j\([^ 	]\)/ -j -\1/
-		s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/
-	' `
-
-case ${HOTSPOT_BUILD_JOBS} in \
-
-'') case ${MFLAGS} in
-    *\ -j*)
-	>&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." 
-	>&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment."
-    esac;;
-
-?*) case ${MFLAGS} in
-     *\ -j*) true;;
-     *)      MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";;
-    esac;;
-esac
-
-echo "${MFLAGS}"
diff --git a/hotspot/make/linux/makefiles/adlc.make b/hotspot/make/linux/makefiles/adlc.make
deleted file mode 100644
index 2879231..0000000
--- a/hotspot/make/linux/makefiles/adlc.make
+++ /dev/null
@@ -1,233 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This makefile (adlc.make) is included from the adlc.make in the
-# build directories.
-# It knows how to compile, link, and run the adlc.
-
-include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
-
-# #########################################################################
-
-# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
-GENERATED = ../generated
-OUTDIR  = $(GENERATED)/adfiles
-
-ARCH = $(Platform_arch)
-OS = $(Platform_os_family)
-
-SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
-
-ifeq ("${Platform_arch_model}", "${Platform_arch}")
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 
-else
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 
-endif
-
-EXEC	= $(OUTDIR)/adlc
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor
-Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED)
-INCLUDES += $(Src_Dirs_I:%=-I%)
-
-# set flags for adlc compilation
-CXXFLAGS = $(SYSDEFS) $(INCLUDES)
-
-# Force assertions on.
-CXXFLAGS += -DASSERT
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-# Compiler warnings are treated as errors
-CFLAGS_WARN = $(WARNINGS_ARE_ERRORS)
-CFLAGS += $(CFLAGS_WARN)
-
-OBJECTNAMES = \
-	adlparse.o \
-	archDesc.o \
-	arena.o \
-	dfa.o \
-	dict2.o \
-	filebuff.o \
-	forms.o \
-	formsopt.o \
-	formssel.o \
-	main.o \
-	adlc-opcodes.o \
-	output_c.o \
-	output_h.o \
-
-OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)
-
-GENERATEDNAMES = \
-        ad_$(Platform_arch_model).cpp \
-        ad_$(Platform_arch_model).hpp \
-        ad_$(Platform_arch_model)_clone.cpp \
-        ad_$(Platform_arch_model)_expand.cpp \
-        ad_$(Platform_arch_model)_format.cpp \
-        ad_$(Platform_arch_model)_gen.cpp \
-        ad_$(Platform_arch_model)_misc.cpp \
-        ad_$(Platform_arch_model)_peephole.cpp \
-        ad_$(Platform_arch_model)_pipeline.cpp \
-        adGlobals_$(Platform_arch_model).hpp \
-        dfa_$(Platform_arch_model).cpp \
-
-GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)
-
-# #########################################################################
-
-all: $(EXEC)
-
-$(EXEC) : $(OBJECTS)
-	@echo $(LOG_INFO) Making adlc
-	$(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.LINK_NOPROF.CXX)) -o $(EXEC) $(OBJECTS)
-
-# Random dependencies:
-$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
-
-# The source files refer to ostream.h, which sparcworks calls iostream.h
-$(OBJECTS): ostream.h
-
-ostream.h :
-	@echo >$@ '#include <iostream.h>'
-
-dump:
-	: OUTDIR=$(OUTDIR)
-	: OBJECTS=$(OBJECTS)
-	: products = $(GENERATEDFILES)
-
-all: $(GENERATEDFILES)
-
-$(GENERATEDFILES): refresh_adfiles
-
-# Get a unique temporary directory name, so multiple makes can run in parallel.
-# Note that product files are updated via "mv", which is atomic.
-TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)
-
-ifneq ($(DEBUG_BINARIES), true)
-  # Debuggable by default (unless already done by DEBUG_BINARIES)
-  CFLAGS += -g
-endif
-
-# Pass -D flags into ADLC.
-ADLCFLAGS += $(SYSDEFS)
-
-# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
-ADLCFLAGS += -q -T
-
-# Normally, debugging is done directly on the ad_<arch>*.cpp files.
-# But -g will put #line directives in those files pointing back to <arch>.ad.
-# Some builds of gcc 3.2 have a bug that gets tickled by the extra #line directives
-# so skip it for 3.2 and ealier.
-ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-ADLCFLAGS += -g
-endif
-
-ifdef LP64
-ADLCFLAGS += -D_LP64
-else
-ADLCFLAGS += -U_LP64
-endif
-
-#
-# adlc_updater is a simple sh script, under sccs control. It is
-# used to selectively update generated adlc files. This should
-# provide a nice compilation speed improvement.
-#
-ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
-ADLC_UPDATER = adlc_updater
-$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
-	$(QUIETLY) cp $< $@; chmod +x $@
-
-# This action refreshes all generated adlc files simultaneously.
-# The way it works is this:
-# 1) create a scratch directory to work in.
-# 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
-# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
-# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
-# 5) If we actually updated any files, echo a notice.
-#
-refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
-	@rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
-	$(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
- -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \
-	    || { rm -rf $(TEMPDIR); exit 1; }
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
-		|| echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes."
-	$(QUIETLY) rm -rf $(TEMPDIR)
-
-
-# #########################################################################
-
-$(SOURCE.AD): $(SOURCES.AD)
-	$(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)
-
-#PROCESS_AD_FILES = cat
-# Pass through #line directives, in case user enables -g option above:
-PROCESS_AD_FILES = awk '{ \
-    if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
-    if (need_lineno && $$0 !~ /\/\//) \
-      { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
-    print }'
-
-$(OUTDIR)/%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -o $@ $< $(COMPILE_DONE)
-
-# Some object files are given a prefix, to disambiguate
-# them from objects of the same name built for the VM.
-$(OUTDIR)/adlc-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -o $@ $< $(COMPILE_DONE)
-
-# #########################################################################
-
-clean	:
-	rm $(OBJECTS)
-
-cleanall :
-	rm $(OBJECTS) $(EXEC)
-
-# #########################################################################
-
-.PHONY: all dump refresh_adfiles clean cleanall
diff --git a/hotspot/make/linux/makefiles/amd64.make b/hotspot/make/linux/makefiles/amd64.make
deleted file mode 100644
index c98a582..0000000
--- a/hotspot/make/linux/makefiles/amd64.make
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-# Must also specify if CPU is little endian
-CFLAGS += -DVM_LITTLE_ENDIAN
-
-CFLAGS += -D_LP64=1
-
-OPT_CFLAGS/compactingPermGenGen.o = -O1
-
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/sharedRuntimeTrig.o += -g
-   OPT_CFLAGS/sharedRuntimeTrans.o += -g
-   OPT_CFLAGS/compactingPermGenGen.o += -g
-endif
diff --git a/hotspot/make/linux/makefiles/buildtree.make b/hotspot/make/linux/makefiles/buildtree.make
deleted file mode 100644
index b5eb37e..0000000
--- a/hotspot/make/linux/makefiles/buildtree.make
+++ /dev/null
@@ -1,368 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Usage:
-#
-# $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch
-#         GAMMADIR=dir OS_FAMILY=os VARIANT=variant
-#
-# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the
-# environment or on the command-line:
-#
-# ARCH		- sparc, i486, ... HotSpot cpu and os_cpu source directory
-# BUILDARCH     - build directory
-# LIBARCH       - the corresponding directory in JDK/JRE
-# GAMMADIR	- top of workspace
-# OS_FAMILY	- operating system
-# VARIANT	- core, compiler1, compiler2, or tiered
-# VERSION_STRING - the JDK version string as specified by JEP-223
-# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build
-#
-# Builds the directory trees with makefiles plus some convenience files in
-# each directory:
-#
-# Makefile	- for "make foo"
-# flags.make	- with macro settings
-# vm.make	- to support making "$(MAKE) -v vm.make" in makefiles
-# adlc.make	-
-# trace.make	- generate tracing event and type definitions
-# jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
-#
-# The makefiles are split this way so that "make foo" will run faster by not
-# having to read the dependency files for the vm.
-
--include $(SPEC)
-include $(GAMMADIR)/make/scm.make
-include $(GAMMADIR)/make/defs.make
-include $(GAMMADIR)/make/altsrc.make
-
-
-# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)	= @
-
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
-else
-  ifdef USE_SUNCC
-    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc
-  else
-    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
-    ALT_PLATFORM_FILE = $(HS_ALT_MAKE)/$(OS_FAMILY)/platform_$(BUILDARCH)
-    PLATFORM_FILE := $(if $(wildcard $(ALT_PLATFORM_FILE)),$(ALT_PLATFORM_FILE),$(PLATFORM_FILE))
-  endif
-endif
-
-# Allow overriding of the arch part of the directory but default
-# to BUILDARCH if nothing is specified
-ifeq ($(VARIANTARCH),)
-  VARIANTARCH=$(BUILDARCH)
-endif
-
-ifdef FORCE_TIERED
-ifeq		($(VARIANT),tiered)
-PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_compiler2
-else
-PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
-endif
-else
-PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
-endif
-
-#
-# We do two levels of exclusion in the shared directory.
-# TOPLEVEL excludes are pruned, they are not recursively searched,
-# but lower level directories can be named without fear of collision.
-# ALWAYS excludes are excluded at any level in the directory tree.
-#
-
-ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
-
-ifeq		($(VARIANT),tiered)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
-else
-ifeq		($(VARIANT),compiler2)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
-else
-# compiler1 and core use the same exclude list
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
-endif
-endif
-
-# Get things from the platform file.
-COMPILER	= $(shell sed -n 's/^compiler[ 	]*=[ 	]*//p' $(PLATFORM_FILE))
-
-SIMPLE_DIRS	= \
-	$(PLATFORM_DIR)/generated/dependencies \
-	$(PLATFORM_DIR)/generated/adfiles \
-	$(PLATFORM_DIR)/generated/jvmtifiles \
-	$(PLATFORM_DIR)/generated/tracefiles \
-	$(PLATFORM_DIR)/generated/extensions
-
-TARGETS      = debug fastdebug optimized product
-SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
-
-# For dependencies and recursive makes.
-BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
-
-BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make dtrace.make
-
-BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
-	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
-
-# Define variables to be set in flags.make.
-# Default values are set in make/defs.make.
-
-# Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
-endif
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell whoami)
-endif
-# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
-# or make/hotspot_distro.
-ifndef HOTSPOT_VM_DISTRO
-  ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    include $(GAMMADIR)/make/hotspot_distro
-  else
-    include $(GAMMADIR)/make/openjdk_distro
-  endif
-endif
-
-# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
-ifndef OPENJDK
-  ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    OPENJDK=true
-  endif
-endif
-
-BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-
-BUILDTREE	= \
-	$(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
-
-BUILDTREE_COMMENT	= echo "\# Generated by $(BUILDTREE_MAKE)"
-
-all:  $(SUBMAKE_DIRS)
-
-# Run make in each subdirectory recursively.
-$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
-	$(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
-	+$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
-	$(QUIETLY) touch $@
-
-$(SIMPLE_DIRS):
-	$(QUIETLY) mkdir -p $@
-
-# Convenience macro which takes a source relative path, applies $(1) to the
-# absolute path, and then replaces $(GAMMADIR) in the result with a
-# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.
-gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
-
-# This bit is needed to enable local rebuilds.
-# Unless the makefile itself sets LP64, any environmental
-# setting of LP64 will interfere with the build.
-LP64_SETTING/32 = LP64 = \#empty
-LP64_SETTING/64 = LP64 = 1
-
-DATA_MODE/i486 = 32
-DATA_MODE/sparc = 32
-DATA_MODE/sparcv9 = 64
-DATA_MODE/amd64 = 64
-DATA_MODE/ppc64 = 64
-DATA_MODE/aarch64 = 64
-
-DATA_MODE = $(DATA_MODE/$(BUILDARCH))
-
-flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "Platform_file = $(PLATFORM_FILE)" | sed -e 's|$(HS_ALT_MAKE)|$$(HS_ALT_MAKE)|' -e 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
-	sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
-	echo; \
-	echo "GAMMADIR = $(GAMMADIR)"; \
-	echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
-	echo "OSNAME = $(OSNAME)"; \
-	echo "SYSDEFS = \$$(Platform_sysdefs)"; \
-	echo "SRCARCH = $(SRCARCH)"; \
-	echo "BUILDARCH = $(BUILDARCH)"; \
-	echo "LIBARCH = $(LIBARCH)"; \
-	echo "TARGET = $(TARGET)"; \
-	echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \
-	echo "VERSION_STRING = $(VERSION_STRING)"; \
-	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
-	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
-	echo "OPENJDK = $(OPENJDK)"; \
-	echo "$(LP64_SETTING/$(DATA_MODE))"; \
-	echo; \
-	echo "# Used for platform dispatching"; \
-	echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
-	echo "CFLAGS += \$$(TARGET_DEFINES)"; \
-	echo; \
-	echo "Src_Dirs_V = \\"; \
-	sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
-	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	echo; \
-	echo "Src_Dirs_I = \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	[ -n "$(CFLAGS_BROWSE)" ] && \
-	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
-	[ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
-	    echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
-	[ -n "$(OBJCOPY)" ] && \
-	    echo && echo "OBJCOPY = $(OBJCOPY)"; \
-	[ -n "$(STRIP_POLICY)" ] && \
-	    echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
-	[ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
-	    echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
-	[ -n "$(ZIPEXE)" ] && \
-	    echo && echo "ZIPEXE = $(ZIPEXE)"; \
-	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
-	    echo && \
-	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
-	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
-	[ -n "$(INCLUDE_TRACE)" ] && \
-	    echo && echo "INCLUDE_TRACE = $(INCLUDE_TRACE)"; \
-	echo; \
-	[ -n "$(SPEC)" ] && \
-	    echo "include $(SPEC)"; \
-	echo "CP ?= cp"; \
-	echo "MV ?= mv"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
-	echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
-	) > $@
-
-flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
-	) > $@
-
-../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
-	@echo $(LOG_INFO) Creating directory list $@
-	$(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
-          find $(HS_ALT_SRC)/share/vm/* -prune \
-	  -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-          \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
-        fi;
-	$(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
-	-type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
-
-Makefile: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
-	) > $@
-
-vm.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo include flags_vm.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-adlc.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-jvmti.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-trace.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-dtrace.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-FORCE:
-
-.PHONY:  all FORCE
-
-.NOTPARALLEL:
diff --git a/hotspot/make/linux/makefiles/compiler1.make b/hotspot/make/linux/makefiles/compiler1.make
deleted file mode 100644
index d303bfc..0000000
--- a/hotspot/make/linux/makefiles/compiler1.make
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making client version of VM
-
-TYPE=COMPILER1
-
-VM_SUBDIR = client
-
-# We don't support the JVMCI in a client VM.
-INCLUDE_JVMCI := false
-
-CFLAGS += -DCOMPILER1
diff --git a/hotspot/make/linux/makefiles/compiler2.make b/hotspot/make/linux/makefiles/compiler2.make
deleted file mode 100644
index c881079..0000000
--- a/hotspot/make/linux/makefiles/compiler2.make
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making server version of VM
-
-TYPE=COMPILER2
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2
diff --git a/hotspot/make/linux/makefiles/core.make b/hotspot/make/linux/makefiles/core.make
deleted file mode 100644
index e032d96..0000000
--- a/hotspot/make/linux/makefiles/core.make
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-# Sets make macros for making core version of VM
-
-# Select which files to use (in top.make)
-TYPE=CORE
-
-# There is no "core" directory in JDK. Install core build in server directory.
-VM_SUBDIR = server
-
-# Note:  macros.hpp defines CORE
diff --git a/hotspot/make/linux/makefiles/debug.make b/hotspot/make/linux/makefiles/debug.make
deleted file mode 100644
index 7c57280..0000000
--- a/hotspot/make/linux/makefiles/debug.make
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS)
-DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
-
-# _NMT_NOINLINE_ informs NMT that no inlining by Compiler
-CFLAGS += $(DEBUG_CFLAGS/BYFILE) -D_NMT_NOINLINE_
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug
-
-VERSION = debug
-SYSDEFS += -DASSERT
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/linux/makefiles/defs.make b/hotspot/make/linux/makefiles/defs.make
deleted file mode 100644
index f61dacd..0000000
--- a/hotspot/make/linux/makefiles/defs.make
+++ /dev/null
@@ -1,279 +0,0 @@
-#
-# Copyright (c) 2006, 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
-# 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.
-#
-#
-
-# The common definitions for hotspot linux builds.
-# Include the top level defs.make under make directory instead of this one.
-# This file is included into make/defs.make.
-
-SLASH_JAVA ?= /java
-
-define print_info
-  ifneq ($$(LOG_LEVEL), warn)
-    $$(shell echo >&2 "INFO: $1")
-  endif
-endef
-
-# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name
-
-# ARCH can be set explicitly in spec.gmk
-ifndef ARCH
-  ARCH := $(shell uname -m)
-  # Fold little endian PowerPC64 into big-endian (if ARCH is set in
-  # hotspot-spec.gmk, this will be done by the configure script).
-  ifeq ($(ARCH),ppc64le)
-    ARCH := ppc64
-  endif
-endif
-
-PATH_SEP ?= :
-
-ifeq ($(LP64), 1)
-  ARCH_DATA_MODEL ?= 64
-else
-  ARCH_DATA_MODEL ?= 32
-endif
-
-# zero
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    MAKE_ARGS      += LP64=1
-  endif
-  PLATFORM         = linux-zero
-  VM_PLATFORM      = linux_$(subst i386,i486,$(ZERO_LIBARCH))
-  HS_ARCH          = zero
-  ARCH             = zero
-endif
-
-# ia64
-ifeq ($(ARCH), ia64)
-  ARCH_DATA_MODEL = 64
-  MAKE_ARGS      += LP64=1
-  PLATFORM        = linux-ia64
-  VM_PLATFORM     = linux_ia64
-  HS_ARCH         = ia64
-endif
-
-# sparc
-ifneq (,$(findstring $(ARCH), sparc))
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    ARCH_DATA_MODEL  = 64
-    MAKE_ARGS        += LP64=1
-    PLATFORM         = linux-sparcv9
-    VM_PLATFORM      = linux_sparcv9
-  else
-    ARCH_DATA_MODEL  = 32
-    PLATFORM         = linux-sparc
-    VM_PLATFORM      = linux_sparc
-  endif
-  HS_ARCH            = sparc
-endif
-
-# i686/i586 and amd64/x86_64
-ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586))
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    ARCH_DATA_MODEL = 64
-    MAKE_ARGS       += LP64=1
-    PLATFORM        = linux-amd64
-    VM_PLATFORM     = linux_amd64
-  else
-    ARCH_DATA_MODEL = 32
-    PLATFORM        = linux-i586
-    VM_PLATFORM     = linux_i486
-  endif
-
-  HS_ARCH           = x86
-endif
-
-# PPC
-# Notice: after 8046471 ARCH will be 'ppc' for top-level ppc64 builds but
-# 'ppc64' for HotSpot-only ppc64 builds. Need to detect both variants here!
-ifneq (,$(findstring $(ARCH), ppc ppc64))
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    MAKE_ARGS        += LP64=1
-    PLATFORM         = linux-ppc64
-    VM_PLATFORM      = linux_ppc64
-  endif
-
-  HS_ARCH = ppc
-endif
-
-# AARCH64
-ifeq ($(ARCH), aarch64)
-  ARCH_DATA_MODEL  = 64
-  MAKE_ARGS        += LP64=1
-  PLATFORM         = linux-aarch64
-  VM_PLATFORM      = linux_aarch64
-  HS_ARCH          = aarch64
-endif
-
-# On 32 bit linux we build server and client, on 64 bit just server.
-ifeq ($(JVM_VARIANTS),)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    JVM_VARIANTS:=client,server
-    JVM_VARIANT_CLIENT:=true
-    JVM_VARIANT_SERVER:=true
-  else
-    JVM_VARIANTS:=server
-    JVM_VARIANT_SERVER:=true
-  endif
-endif
-
-# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product
-# builds is enabled with debug info files ZIP'ed to save space. For
-# BUILD_FLAVOR != product builds, FDS is always enabled, after all a
-# debug build without debug info isn't very useful.
-# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled.
-#
-# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
-# disabled for a BUILD_FLAVOR == product build.
-#
-# Note: Use of a different variable name for the FDS override option
-# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
-# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
-# in options via environment variables, use of distinct variables
-# prevents strange behaviours. For example, in a BUILD_FLAVOR !=
-# product build, the FULL_DEBUG_SYMBOLS environment variable will be
-# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If
-# the same variable name is used, then different values can be picked
-# up by different parts of the build. Just to be clear, we only need
-# two variable names because the incoming option value can be
-# overridden in some situations, e.g., a BUILD_FLAVOR != product
-# build.
-
-# Due to the multiple sub-make processes that occur this logic gets
-# executed multiple times. We reduce the noise by at least checking that
-# BUILD_FLAVOR has been set.
-ifneq ($(BUILD_FLAVOR),)
-  ifeq ($(BUILD_FLAVOR), product)
-    FULL_DEBUG_SYMBOLS ?= 1
-    ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
-  else
-    # debug variants always get Full Debug Symbols (if available)
-    ENABLE_FULL_DEBUG_SYMBOLS = 1
-  endif
-  $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-  # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    # Default OBJCOPY comes from GNU Binutils on Linux
-    ifeq ($(CROSS_COMPILE_ARCH),)
-      DEF_OBJCOPY=/usr/bin/objcopy
-    else
-      # Assume objcopy is part of the cross-compilation toolset
-      ifneq ($(ALT_COMPILER_PATH),)
-        DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy
-      endif
-    endif
-    OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
-    ifneq ($(ALT_OBJCOPY),)
-      $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)"))
-      OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
-    endif
-
-    ifeq ($(OBJCOPY),)
-      $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files. You may need to set ALT_OBJCOPY."))
-      ENABLE_FULL_DEBUG_SYMBOLS=0
-      $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-    else
-      $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo files."))
-
-      # Library stripping policies for .debuginfo configs:
-      #   all_strip - strips everything from the library
-      #   min_strip - strips most stuff from the library; leaves minimum symbols
-      #   no_strip  - does not strip the library at all
-      #
-      # Oracle security policy requires "all_strip". A waiver was granted on
-      # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
-      #
-      # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled.
-      #
-      STRIP_POLICY ?= min_strip
-
-      $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)"))
-
-      ZIP_DEBUGINFO_FILES ?= 1
-
-      $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)"))
-    endif
-  endif # ENABLE_FULL_DEBUG_SYMBOLS=1
-endif # BUILD_FLAVOR
-
-JDK_INCLUDE_SUBDIR=linux
-
-# Library suffix
-LIBRARY_SUFFIX=so
-
-EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
-
-# client and server subdirectories have symbolic links to ../libjsig.so
-EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-    EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz
-  else
-    EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo
-  endif
-endif
-EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server
-EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client
-EXPORT_MINIMAL_DIR = $(EXPORT_LIB_ARCH_DIR)/minimal
-
-ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK) $(JVM_VARIANT_CORE)), true)
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz
-    else
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
-    endif
-  endif
-endif
-
-ifeq ($(JVM_VARIANT_CLIENT),true)
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz
-    else
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
-    endif
-  endif
-endif
-
-ifeq ($(JVM_VARIANT_MINIMAL1),true)
-  EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.$(LIBRARY_SUFFIX)
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.diz
-    else
-	EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo
-    endif
-  endif
-endif
-
--include $(HS_ALT_MAKE)/linux/makefiles/defs.make
diff --git a/hotspot/make/linux/makefiles/dtrace.make b/hotspot/make/linux/makefiles/dtrace.make
deleted file mode 100644
index 2c898d0..0000000
--- a/hotspot/make/linux/makefiles/dtrace.make
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012 Red Hat, Inc.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Linux does not build jvm_db
-LIBJVM_DB =
-
-# Only OPENJDK builds test and support SDT probes currently.
-ifndef OPENJDK
-REASON = "This JDK does not support SDT probes"
-else
-
-# We need a recent GCC for the default (4.4 or later)
-ifeq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 4 \) \) \| \( $(CC_VER_MAJOR) \>= 5 \) )" "0"
-REASON = "gcc version is too old"
-else
-
-# But it does have a SystemTap dtrace compatible sys/sdt.h
-ifneq ($(ALT_SDT_H),)
-  SDT_H_FILE = $(ALT_SDT_H)
-else
-  ifeq ($(USE_CLANG), true)
-    # Clang doesn't support the -print-sysroot option and there is no known equivalent
-    # option, so fall back to using / as sysroot
-    SDT_SYSROOT=
-  else
-    SDT_SYSROOT=$(shell $(CXX) -print-sysroot)
-  endif
-  SDT_H_FILE = $(SDT_SYSROOT)/usr/include/sys/sdt.h
-endif
-
-DTRACE_ENABLED = $(shell test -f $(SDT_H_FILE) && echo $(SDT_H_FILE))
-REASON = "$(SDT_H_FILE) not found"
-
-endif # GCC version
-endif # OPENJDK
-
-
-DTRACE_COMMON_SRCDIR = $(GAMMADIR)/src/os/posix/dtrace
-DTRACE_PROG = dtrace
-DtraceOutDir = $(GENERATED)/dtracefiles
-
-$(DtraceOutDir):
-	mkdir $(DtraceOutDir)
-
-$(DtraceOutDir)/hotspot.h: $(DTRACE_COMMON_SRCDIR)/hotspot.d | $(DtraceOutDir)
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot.d
-
-$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d
-
-$(DtraceOutDir)/hs_private.h: $(DTRACE_COMMON_SRCDIR)/hs_private.d | $(DtraceOutDir)
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hs_private.d
-
-ifneq ($(DTRACE_ENABLED),)
-CFLAGS += -DDTRACE_ENABLED
-dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h
-else
-dtrace_gen_headers:
-	$(QUIETLY) $(LOG_INFO) echo "**NOTICE** Dtrace support disabled: $(REASON)"
-endif
-
-# Phony target used in vm.make build target to check whether enabled.
-ifeq ($(DTRACE_ENABLED),)
-dtraceCheck:
-	$(QUIETLY) $(LOG_INFO) echo "**NOTICE** Dtrace support disabled: $(REASON)"
-else
-dtraceCheck:
-endif
-
-.PHONY: dtrace_gen_headers dtraceCheck
-
-# It doesn't support HAVE_DTRACE_H though.
-
diff --git a/hotspot/make/linux/makefiles/fastdebug.make b/hotspot/make/linux/makefiles/fastdebug.make
deleted file mode 100644
index ebadd19..0000000
--- a/hotspot/make/linux/makefiles/fastdebug.make
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS.
-
-FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-ifeq ($(BUILDARCH), ia64)
-  # Bug in GCC, causes hang.  -O1 will override the -O3 specified earlier
-  OPT_CFLAGS/callGenerator.o += -O1
-  OPT_CFLAGS/ciTypeFlow.o += -O1
-  OPT_CFLAGS/compile.o += -O1
-  OPT_CFLAGS/concurrentMarkSweepGeneration.o += -O1
-  OPT_CFLAGS/doCall.o += -O1
-  OPT_CFLAGS/generateOopMap.o += -O1
-  OPT_CFLAGS/generateOptoStub.o += -O1
-  OPT_CFLAGS/graphKit.o += -O1
-  OPT_CFLAGS/instanceKlass.o += -O1
-  OPT_CFLAGS/interpreterRT_ia64.o += -O1
-  OPT_CFLAGS/output.o += -O1
-  OPT_CFLAGS/parse1.o += -O1
-  OPT_CFLAGS/runtime.o += -O1
-  OPT_CFLAGS/synchronizer.o += -O1
-endif
-
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-# The following lines are copied from debug.make, except that we
-# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS.
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS)
-DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
-CFLAGS += $(DEBUG_CFLAGS/BYFILE)
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug
-
-VERSION = optimized
-SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make
deleted file mode 100644
index 75dcaeb..0000000
--- a/hotspot/make/linux/makefiles/gcc.make
+++ /dev/null
@@ -1,425 +0,0 @@
-#
-# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-#------------------------------------------------------------------------
-# CC, CXX & AS
-
-# If a SPEC is not set already, then use these defaults.
-ifeq ($(SPEC),)
-  # When cross-compiling the ALT_COMPILER_PATH points
-  # to the cross-compilation toolset
-  ifdef CROSS_COMPILE_ARCH
-    CXX = $(ALT_COMPILER_PATH)/g++
-    CC  = $(ALT_COMPILER_PATH)/gcc
-    HOSTCXX = g++
-    HOSTCC  = gcc
-    STRIP = $(ALT_COMPILER_PATH)/strip
-  else
-    ifeq ($(USE_CLANG), true)
-      CXX = clang++
-      CC  = clang
-    else
-      CXX = g++
-      CC  = gcc
-    endif
-
-    HOSTCXX = $(CXX)
-    HOSTCC  = $(CC)
-    STRIP = strip
-  endif
-  AS  = $(CC) -c
-endif
-
-
-ifeq ($(USE_CLANG), true)
-  CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1)
-  CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2)
-else
-  # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
-  # prints the numbers (e.g. "2.95", "3.2.1")
-  CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
-  CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
-  CC_VER_MICRO := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f3)
-  # Workaround Ubuntu bug where -dumpversion doesn't print a micro version
-  # https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1360404
-  ifeq ($(CC_VER_MICRO),)
-    CC_VER_MICRO := "0"
-  endif
-endif
-
-ifeq ($(USE_CLANG), true)
-  # Clang has precompiled headers support by default, but the user can switch
-  # it off by using 'USE_PRECOMPILED_HEADER=0'.
-  ifdef LP64
-    ifeq ($(USE_PRECOMPILED_HEADER),)
-      USE_PRECOMPILED_HEADER=1
-    endif
-  else
-    # We don't support precompiled headers on 32-bit builds because there some files are
-    # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make)
-    # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit.
-    USE_PRECOMPILED_HEADER=0
-  endif
-
-  ifeq ($(USE_PRECOMPILED_HEADER),1)
-
-    ifndef LP64
-      $(error " Precompiled Headers only supported on 64-bit platforms!")
-    endif
-
-    PRECOMPILED_HEADER_DIR=.
-    PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
-    PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch
-
-    PCH_FLAG = -include precompiled.hpp
-    PCH_FLAG/DEFAULT = $(PCH_FLAG)
-    PCH_FLAG/NO_PCH = -DNO_PCH
-    PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))
-
-    VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)
-    VM_PCH_FLAG/AOUT =
-    VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))
-
-    # We only use precompiled headers for the JVM build
-    CFLAGS += $(VM_PCH_FLAG)
-
-    # There are some files which don't like precompiled headers
-    # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build.
-    # But Clang doesn't support a precompiled header which was compiled with -O3
-    # to be used in a compilation unit which uses '-O0'. We could also prepare an
-    # extra '-O0' PCH file for the opt build and use it here, but it's probably
-    # not worth the effort as long as only two files need this special handling.
-    PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
-    PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
-    PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
-
-  endif
-else # ($(USE_CLANG), true)
-  # check for precompiled headers support
-  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
-    # Allow the user to turn off precompiled headers from the command line.
-    ifneq ($(USE_PRECOMPILED_HEADER),0)
-      PRECOMPILED_HEADER_DIR=.
-      PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
-      PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
-    endif
-  endif
-endif
-
-# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
-ifeq ($(USE_PRECOMPILED_HEADER),0)
-  CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
-endif
-
-
-#------------------------------------------------------------------------
-# Compiler flags
-
-# position-independent code
-PICFLAG = -fPIC
-
-VM_PICFLAG/LIBJVM = $(PICFLAG)
-VM_PICFLAG/AOUT   =
-VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
-
-ifeq ($(JVM_VARIANT_ZERO), true)
-CFLAGS += $(LIBFFI_CFLAGS)
-endif
-ifeq ($(JVM_VARIANT_ZEROSHARK), true)
-CFLAGS += $(LIBFFI_CFLAGS)
-CFLAGS += $(LLVM_CFLAGS)
-endif
-CFLAGS += $(VM_PICFLAG)
-CFLAGS += -fno-rtti
-CFLAGS += -fno-exceptions
-CFLAGS += -D_REENTRANT
-ifeq ($(USE_CLANG),)
-  CFLAGS += -fcheck-new
-  # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
-  # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
-  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-    CFLAGS += -fvisibility=hidden
-  endif
-else
-  CFLAGS += -fvisibility=hidden
-endif
-
-ifeq ($(USE_CLANG), true)
-  # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm'
-  # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment')
-  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0"
-    STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16
-  else
-    STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16
-  endif
-endif
-
-ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
-ARCHFLAG/i486    = -m32 -march=i586
-ARCHFLAG/amd64   = -m64 $(STACK_ALIGNMENT_OPT)
-ARCHFLAG/aarch64 =
-ARCHFLAG/ia64    =
-ARCHFLAG/sparc   = -m32 -mcpu=v9
-ARCHFLAG/sparcv9 = -m64 -mcpu=v9
-ARCHFLAG/zero    = $(ZERO_ARCHFLAG)
-ARCHFLAG/ppc64   =  -m64
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-ASFLAGS    += $(ARCHFLAG)
-
-# Use C++ Interpreter
-ifdef CC_INTERP
-  CFLAGS += -DCC_INTERP
-endif
-
-# Keep temporary files (.ii, .s)
-ifdef NEED_ASM
-  CFLAGS += -save-temps
-else
-  CFLAGS += -pipe
-endif
-
-# Compiler warnings are treated as errors
-WARNINGS_ARE_ERRORS ?= -Werror
-
-ifeq ($(USE_CLANG), true)
-  # However we need to clean the code up before we can unrestrictedly enable this option with Clang
-  WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
-  WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare
-  WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
-  WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
-endif
-
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Woverloaded-virtual
-
-ifeq ($(USE_CLANG),)
-  # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
-  # conversions which might affect the values. Only enable it in earlier versions.
-  ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-    # GCC < 4.3
-    WARNING_FLAGS += -Wconversion
-  endif
-  ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1"
-    # GCC >= 4.8
-    # This flag is only known since GCC 4.3. Gcc 4.8 contains a fix so that with templates no
-    # warnings are issued: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11856
-    WARNING_FLAGS += -Wtype-limits
-    # GCC < 4.8 don't accept this flag for C++.
-    WARNING_FLAGS += -Wno-format-zero-length
-    # GCC 4.8 reports less false positives than the older compilers.
-    WARNING_FLAGS += -Wuninitialized
-  endif
-endif
-
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
-
-# Special cases
-CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
-
-# optimization control flags (Used by fastdebug and release variants)
-OPT_CFLAGS/NOOPT=-O0
-OPT_CFLAGS/DEBUG=-O0
-OPT_CFLAGS/SIZE=-Os
-OPT_CFLAGS/SPEED=-O3
-
-OPT_CFLAGS_DEFAULT ?= SPEED
-
-# Hotspot uses very unstrict aliasing turn this optimization off
-# This option is added to CFLAGS rather than OPT_CFLAGS
-# so that OPT_CFLAGS overrides get this option too.
-CFLAGS += -fno-strict-aliasing
-
-ifdef OPT_CFLAGS
-  ifneq ("$(origin OPT_CFLAGS)", "command line")
-    $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
-  endif
-endif
-
-OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
-
-# Variable tracking size limit exceeded for VMStructs::init()
-ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "1"
-  # GCC >= 4.3
-  # Gcc 4.1.2 does not support this flag, nor does it have problems compiling the file.
-  OPT_CFLAGS/vmStructs.o += -fno-var-tracking-assignments
-  # The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-  # of OPT_CFLAGS. Restore it here.
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    OPT_CFLAGS/vmStructs.o += -g
-  endif
-endif
-
-# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
-# if we use expensive-optimizations
-ifeq ($(BUILDARCH), ia64)
-OPT_CFLAGS += -fno-expensive-optimizations
-endif
-
-# Work around some compiler bugs.
-ifeq ($(USE_CLANG), true)
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
-    OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
-    # The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-    # of OPT_CFLAGS. Restore it here.
-    ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-      OPT_CFLAGS/loopTransform.o += -g
-    endif
-  endif
-else
-  # Do not allow GCC 4.1.1
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 1 \& $(CC_VER_MICRO) = 1), 1)
-    $(error "GCC $(CC_VER_MAJOR).$(CC_VER_MINOR).$(CC_VER_MICRO) not supported because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27724")
-  endif
-  # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
-    OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
-  endif
-endif
-
-# Flags for generating make dependency flags.
-DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
-ifeq ($(USE_CLANG),)
-  ifneq ($(CC_VER_MAJOR), 2)
-    DEPFLAGS += -fpch-deps
-  endif
-endif
-
-#------------------------------------------------------------------------
-# Linker flags
-
-# statically link libstdc++.so, work with gcc but ignored by g++
-STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
-
-# Enable linker optimization
-LFLAGS += -Xlinker -O1
-
-ifeq ($(USE_CLANG),)
-  STATIC_LIBGCC += -static-libgcc
-
-  ifneq (, findstring(debug,$(BUILD_FLAVOR)))
-    # for relocations read-only
-    LFLAGS += -Xlinker -z -Xlinker relro
-
-    ifeq ($(BUILD_FLAVOR), debug)
-      # disable incremental relocations linking
-      LFLAGS += -Xlinker -z -Xlinker now
-    endif
-  endif
-
-  ifeq ($(BUILDARCH), ia64)
-    LFLAGS += -Wl,-relax
-  endif
-
-  # If this is a --hash-style=gnu system, use --hash-style=both
-  #   The gnu .hash section won't work on some Linux systems like SuSE 10.
-  _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
-  ifneq ($(_HAS_HASH_STYLE_GNU),)
-    LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
-  endif
-else
-  # Don't know how to find out the 'hash style' of a system as '-dumpspecs'
-  # doesn't work for Clang. So for now we'll alwys use --hash-style=both
-  LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
-endif
-
-LFLAGS += $(LDFLAGS_HASH_STYLE)
-
-# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-MAPFLAG = -Xlinker --version-script=FILENAME
-
-# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-SONAMEFLAG = -Xlinker -soname=SONAME
-
-# Build shared library
-SHARED_FLAG = -shared
-
-# Keep symbols even they are not used
-AOUT_FLAGS += -Xlinker -export-dynamic
-
-#------------------------------------------------------------------------
-# Debug flags
-
-ifeq ($(USE_CLANG), true)
-  # Restrict the debug information created by Clang to avoid
-  # too big object files and speed the build up a little bit
-  # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
-  CFLAGS += -flimit-debug-info
-endif
-
-# Allow no optimizations.
-DEBUG_CFLAGS=-O0
-
-# DEBUG_BINARIES uses full -g debug information for all configs
-ifeq ($(DEBUG_BINARIES), true)
-  CFLAGS += -g
-else
-  DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
-  ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
-    DEBUG_CFLAGS += -g
-  endif
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))
-    ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
-      FASTDEBUG_CFLAGS += -g
-    endif
-
-    OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
-    ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
-      OPT_CFLAGS += -g
-    endif
-  endif
-endif
-
-ifeq ($(USE_CLANG),)
-  # Enable bounds checking.
-  ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1"
-    # stack smashing checks.
-    DEBUG_CFLAGS += -fstack-protector-all --param ssp-buffer-size=1
-  endif
-endif
-
-
-# If we are building HEADLESS, pass on to VM
-# so it can set the java.awt.headless property
-ifdef HEADLESS
-CFLAGS += -DHEADLESS
-endif
-
-# We are building Embedded for a small device
-# favor code space over speed
-ifdef MINIMIZE_RAM_USAGE
-CFLAGS += -DMINIMIZE_RAM_USAGE
-endif
-
-# Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack.
-# Explicitly specify -fno-omit-frame-pointer because it is off by default
-# starting with gcc 4.6.
-ifndef USE_SUNCC
-  CFLAGS += -fno-omit-frame-pointer
-endif
-
--include $(HS_ALT_MAKE)/linux/makefiles/gcc.make
diff --git a/hotspot/make/linux/makefiles/hp.make b/hotspot/make/linux/makefiles/hp.make
deleted file mode 100644
index e0b262a..0000000
--- a/hotspot/make/linux/makefiles/hp.make
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making premium version of VM
-
-TYPE=HP
-
-CFLAGS += -DCOMPILER2
diff --git a/hotspot/make/linux/makefiles/hp1.make b/hotspot/make/linux/makefiles/hp1.make
deleted file mode 100644
index 2e37a6e..0000000
--- a/hotspot/make/linux/makefiles/hp1.make
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making premium version of VM
-
-TYPE=HP1
-
-CFLAGS += -DCOMPILER1
diff --git a/hotspot/make/linux/makefiles/i486.make b/hotspot/make/linux/makefiles/i486.make
deleted file mode 100644
index a1adda6..0000000
--- a/hotspot/make/linux/makefiles/i486.make
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# TLS helper, assembled from .s file
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-# Must also specify if CPU is little endian
-CFLAGS += -DVM_LITTLE_ENDIAN
-
-OPT_CFLAGS/compactingPermGenGen.o = -O1
-
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/sharedRuntimeTrig.o += -g
-   OPT_CFLAGS/sharedRuntimeTrans.o += -g
-   OPT_CFLAGS/compactingPermGenGen.o += -g
-endif
diff --git a/hotspot/make/linux/makefiles/ia64.make b/hotspot/make/linux/makefiles/ia64.make
deleted file mode 100644
index 8535807..0000000
--- a/hotspot/make/linux/makefiles/ia64.make
+++ /dev/null
@@ -1,41 +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.
-#  
-#
-
-#
-# IA64 only uses c++ based interpreter
-CFLAGS += -DCC_INTERP -D_LP64=1 -DVM_LITTLE_ENDIAN
-ifeq ($(VERSION),debug)
-ASM_FLAGS= -DDEBUG
-else
-ASM_FLAGS=
-endif
-# workaround gcc bug in compiling varargs
-OPT_CFLAGS/jni.o = -O0
-
-# gcc/ia64 has a bug that internal gcc functions linked with libjvm.so
-# are made public. Hiding those symbols will cause undefined symbol error
-# when VM is dropped into older JDK. We probably will need an IA64
-# mapfile to include those symbols as a workaround. Disable linker mapfile 
-# for now.
-LDNOMAP=true
diff --git a/hotspot/make/linux/makefiles/jsig.make b/hotspot/make/linux/makefiles/jsig.make
deleted file mode 100644
index 58c8493..0000000
--- a/hotspot/make/linux/makefiles/jsig.make
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# Rules to build signal interposition library, used by vm.make
-
-# libjsig.so: signal interposition library
-JSIG = jsig
-LIBJSIG = lib$(JSIG).so
-
-LIBJSIG_DEBUGINFO   = lib$(JSIG).debuginfo
-LIBJSIG_DIZ         = lib$(JSIG).diz
-
-JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
-
-DEST_JSIG           = $(JDK_LIBDIR)/$(LIBJSIG)
-DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO)
-DEST_JSIG_DIZ       = $(JDK_LIBDIR)/$(LIBJSIG_DIZ)
-
-LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
-
-# On Linux we really dont want a mapfile, as this library is small
-# and preloaded using LD_PRELOAD, making functions private will
-# cause problems with interposing. See CR: 6466665
-# LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
-
-LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE)
-
-# DEBUG_BINARIES overrides everything, use full -g debug information
-ifeq ($(DEBUG_BINARIES), true)
-  JSIG_DEBUG_CFLAGS = -g
-endif
-
-$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
-	@echo $(LOG_INFO) Making signal interposition lib...
-	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
-                         $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) $(EXTRA_CFLAGS) -o $@ $< -ldl
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -g $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO)
-	$(RM) $(LIBJSIG_DEBUGINFO)
-  endif
-endif
-
-install_jsig: $(LIBJSIG)
-	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
-	$(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \
-	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
-	$(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \
-	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
-
-.PHONY: install_jsig
diff --git a/hotspot/make/linux/makefiles/jvmti.make b/hotspot/make/linux/makefiles/jvmti.make
deleted file mode 100644
index 14220e9..0000000
--- a/hotspot/make/linux/makefiles/jvmti.make
+++ /dev/null
@@ -1,117 +0,0 @@
-#
-# Copyright (c) 2003, 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.
-#  
-#
-
-# This makefile (jvmti.make) is included from the jvmti.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate jvmti.
-
-include $(GAMMADIR)/make/linux/makefiles/rules.make
-
-# #########################################################################
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-JvmtiOutDir = $(GENERATED)/jvmtifiles
-
-JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims
-InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(JvmtiSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-JvmtiGeneratedNames = \
-        jvmtiEnv.hpp \
-        jvmtiEnter.cpp \
-        jvmtiEnterTrace.cpp \
-        jvmtiEnvRecommended.cpp \
-        bytecodeInterpreterWithChecks.cpp \
-        jvmti.h \
-
-JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java
-JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class
-
-JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java
-JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class
-
-JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%)
-
-XSLT = $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-.PHONY: all jvmtidocs clean cleanall
-
-# #########################################################################
-
-all: $(JvmtiGeneratedFiles)
-
-both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl
-
-$(JvmtiGenClass): $(JvmtiGenSource)
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource)
-
-$(JvmtiEnvFillClass): $(JvmtiEnvFillSource)
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource)
-
-$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti
-
-$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp 
-
-$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace
-
-$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass)
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp
-	$(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp
-
-$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp
-
-$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h
-
-jvmtidocs:  $(JvmtiOutDir)/jvmti.html 
-
-$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html
-
-# #########################################################################
-
-clean :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-cleanall :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-# #########################################################################
-
diff --git a/hotspot/make/linux/makefiles/mapfile-vers-debug b/hotspot/make/linux/makefiles/mapfile-vers-debug
deleted file mode 100644
index ec0f06d..0000000
--- a/hotspot/make/linux/makefiles/mapfile-vers-debug
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                JVM_handle_linux_signal;
-
-                # miscellaneous functions
-                jio_fprintf;
-                jio_printf;
-                jio_snprintf;
-                jio_vfprintf;
-                jio_vsnprintf;
-                numa_warn;
-                numa_error;
-
-                # Needed because there is no JVM interface for this.
-                sysThreadAvailableStackWithSlack;
-
-                # This is for Forte Analyzer profiling support.
-                AsyncGetCallTrace;
-
-		# INSERT VTABLE SYMBOLS HERE
-
-        local:
-                *;
-};
-
diff --git a/hotspot/make/linux/makefiles/mapfile-vers-jsig b/hotspot/make/linux/makefiles/mapfile-vers-jsig
deleted file mode 100644
index 8a67504..0000000
--- a/hotspot/make/linux/makefiles/mapfile-vers-jsig
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-
-#
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Define library interface.
-
-SUNWprivate_1.1 {
-        global:
-            JVM_begin_signal_setting;
-            JVM_end_signal_setting;
-            JVM_get_libjsig_version;
-            JVM_get_signal_action;
-            sigaction;
-            signal;
-            sigset;
-        local:
-                *;
-};
diff --git a/hotspot/make/linux/makefiles/mapfile-vers-product b/hotspot/make/linux/makefiles/mapfile-vers-product
deleted file mode 100644
index ec0f06d..0000000
--- a/hotspot/make/linux/makefiles/mapfile-vers-product
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# 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.
-#
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                JVM_handle_linux_signal;
-
-                # miscellaneous functions
-                jio_fprintf;
-                jio_printf;
-                jio_snprintf;
-                jio_vfprintf;
-                jio_vsnprintf;
-                numa_warn;
-                numa_error;
-
-                # Needed because there is no JVM interface for this.
-                sysThreadAvailableStackWithSlack;
-
-                # This is for Forte Analyzer profiling support.
-                AsyncGetCallTrace;
-
-		# INSERT VTABLE SYMBOLS HERE
-
-        local:
-                *;
-};
-
diff --git a/hotspot/make/linux/makefiles/minimal1.make b/hotspot/make/linux/makefiles/minimal1.make
deleted file mode 100644
index d453e78..0000000
--- a/hotspot/make/linux/makefiles/minimal1.make
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-TYPE=MINIMAL1
-
-# Force all variables to false, overriding any other
-# setting that may have occurred in the makefiles. These
-# can still be overridden by passing the variable as an
-# argument to 'make'
-INCLUDE_JVMTI := false
-INCLUDE_FPROF := false
-INCLUDE_VM_STRUCTS := false
-INCLUDE_JNI_CHECK := false
-INCLUDE_SERVICES := false
-INCLUDE_MANAGEMENT := false
-INCLUDE_ALL_GCS := false
-INCLUDE_NMT := false
-INCLUDE_TRACE := false
-INCLUDE_CDS := false
-INCLUDE_JVMCI := false
-
-CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
-CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
-
-Src_Dirs/MINIMAL1 = $(CORE_PATHS) $(COMPILER1_PATHS)
-
-Src_Files_EXCLUDE/MINIMAL1 += $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-
--include $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make
-
-.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make
diff --git a/hotspot/make/linux/makefiles/optimized.make b/hotspot/make/linux/makefiles/optimized.make
deleted file mode 100644
index 41d5e5d..0000000
--- a/hotspot/make/linux/makefiles/optimized.make
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-# Sets make macros for making optimized version of HotSpot VM
-# (This is the "product", not the "release" version.)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug
-
-VERSION = optimized
diff --git a/hotspot/make/linux/makefiles/ppc64.make b/hotspot/make/linux/makefiles/ppc64.make
deleted file mode 100644
index acb51ab..0000000
--- a/hotspot/make/linux/makefiles/ppc64.make
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2013 SAP SE. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# make c code know it is on a 64 bit platform.
-CFLAGS += -D_LP64=1
-
-ifeq ($(origin OPENJDK_TARGET_CPU_ENDIAN),undefined)
-  # This can happen during hotspot standalone build. Set endianness from
-  # uname. We assume build and target machines are the same.
-  OPENJDK_TARGET_CPU_ENDIAN:=$(if $(filter ppc64le,$(shell uname -m)),little,big)
-endif
-
-ifeq ($(filter $(OPENJDK_TARGET_CPU_ENDIAN),big little),)
-  $(error OPENJDK_TARGET_CPU_ENDIAN value should be 'big' or 'little')
-endif
-
-ifeq ($(OPENJDK_TARGET_CPU_ENDIAN),big)
-  # fixes `relocation truncated to fit' error for gcc 4.1.
-  CFLAGS += -mminimal-toc
-
-  # finds use ppc64 instructions, but schedule for power5
-  CFLAGS += -mcpu=powerpc64 -mtune=power5 -minsert-sched-nops=regroup_exact -mno-multiple -mno-string
-else
-  # Little endian machine uses ELFv2 ABI.
-  CFLAGS += -DVM_LITTLE_ENDIAN -DABI_ELFv2
-
-  # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
-  CFLAGS += -mcpu=power7 -mtune=power8 -minsert-sched-nops=regroup_exact -mno-multiple -mno-string
-endif
diff --git a/hotspot/make/linux/makefiles/product.make b/hotspot/make/linux/makefiles/product.make
deleted file mode 100644
index 70e23c6..0000000
--- a/hotspot/make/linux/makefiles/product.make
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-# Sets make macros for making optimized version of HotSpot VM
-# (This is the "product", not the "release" version.)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfile
-MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-product
-
-SYSDEFS += -DPRODUCT
-VERSION = optimized
-
-# use -g to strip library as -x will discard its symbol table; -x is fine for
-# executables.
-# Note: these macros are not used in .debuginfo configs
-STRIP_LIBJVM = $(STRIP) -g $@ || exit 1;
-STRIP_AOUT   = $(STRIP) -x $@ || exit 1;
-
-# If we can create .debuginfo files, then the VM is stripped in vm.make
-# and this macro is not used.
-# LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO))
diff --git a/hotspot/make/linux/makefiles/rules.make b/hotspot/make/linux/makefiles/rules.make
deleted file mode 100644
index 82b952d..0000000
--- a/hotspot/make/linux/makefiles/rules.make
+++ /dev/null
@@ -1,214 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Common rules/macros for the vm, adlc.
-
-# Tell make that .cpp is important
-.SUFFIXES: .cpp $(SUFFIXES)
-
-DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
-
-# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
-CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
-CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
-
-AS.S             = $(AS) $(ASFLAGS)
-
-COMPILE.CC       = $(CC_COMPILE) -c
-GENASM.CC        = $(CC_COMPILE) -S
-LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CC    = $(CC_COMPILE) -E
-
-COMPILE.CXX      = $(CXX_COMPILE) -c
-GENASM.CXX       = $(CXX_COMPILE) -S
-LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
-LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CXX   = $(CXX_COMPILE) -E
-
-# cross compiling the jvm with c2 requires host compilers to build
-# adlc tool
-
-HOST.CXX_COMPILE      = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS)
-HOST.COMPILE.CXX      = $(HOST.CXX_COMPILE) -c
-HOST.LINK_NOPROF.CXX  = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS)
-
-
-# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
-REMOVE_TARGET   = rm -f $@
-
-# Note use of ALT_BOOTDIR to explicitly specify location of java and
-# javac; this is the same environment variable used in the J2SE build
-# process for overriding the default spec, which is BOOTDIR.
-# Note also that we fall back to using JAVA_HOME if neither of these is
-# specified.
-
-ifdef ALT_BOOTDIR
-
-RUN.JAVA  = $(ALT_BOOTDIR)/bin/java
-RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap
-RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah
-RUN.JAR   = $(ALT_BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac
-COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(ALT_BOOTDIR)
-
-else
-
-ifdef BOOTDIR
-
-RUN.JAVA  = $(BOOTDIR)/bin/java
-RUN.JAVAP = $(BOOTDIR)/bin/javap
-RUN.JAVAH = $(BOOTDIR)/bin/javah
-RUN.JAR   = $(BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(BOOTDIR)/bin/javac
-COMPILE.RMIC  = $(BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(BOOTDIR)
-
-else
-
-ifdef JAVA_HOME
-
-RUN.JAVA  = $(JAVA_HOME)/bin/java
-RUN.JAVAP = $(JAVA_HOME)/bin/javap
-RUN.JAVAH = $(JAVA_HOME)/bin/javah
-RUN.JAR   = $(JAVA_HOME)/bin/jar
-COMPILE.JAVAC = $(JAVA_HOME)/bin/javac
-COMPILE.RMIC  = $(JAVA_HOME)/bin/rmic
-BOOT_JAVA_HOME = $(JAVA_HOME)
-
-else
-
-# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined
-
-RUN.JAVA  = java
-RUN.JAVAP = javap
-RUN.JAVAH = javah
-RUN.JAR   = jar
-COMPILE.JAVAC = javac
-COMPILE.RMIC  = rmic
-
-endif
-endif
-endif
-
-COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS)
-
-SUM = /usr/bin/sum
-
-# 'gmake MAKE_VERBOSE=y' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)  = @
-RUN.JAR$(MAKE_VERBOSE) += >/dev/null
-
-# Settings for javac
-JAVAC_FLAGS = -g -encoding ascii
-
-# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system)
-# Fall back to the values here if it's not set (hotspot only builds)
-ifeq ($(BOOT_JDK_SOURCETARGET),)
-BOOTSTRAP_SOURCETARGET := -source 8 -target 8
-else
-BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET)
-endif
-
-BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET)
-
-# With parallel makes, print a message at the end of compilation.
-ifeq    ($(findstring j,$(MFLAGS)),j)
-COMPILE_DONE    = && { echo Done with $<; }
-endif
-
-# Include $(NONPIC_OBJ_FILES) definition
-ifndef LP64
-include $(GAMMADIR)/make/pic.make
-endif
-
-include $(GAMMADIR)/make/altsrc.make
-
-# The non-PIC object files are only generated for 32 bit platforms.
-ifdef LP64
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
-else
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
-	   $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
-	   $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
-endif
-
-%.o: %.s
-	@echo $(LOG_INFO) Assembling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
-
-# gcc applies preprocessing if the file extension is .S instead of .s
-%.o: %.S
-	@echo $(LOG_INFO) Preprocessing and assembling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) 
-
-%.s: %.cpp
-	@echo $(LOG_INFO) Generating assembly for $<
-	$(QUIETLY) $(GENASM.CXX) -o $@ $<
-	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
-
-# Intermediate files (for debugging macros)
-%.i: %.cpp
-	@echo $(LOG_INFO) Preprocessing $< to $@
-	$(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
-
-#  Override gnumake built-in rules which do sccs get operations badly.
-#  (They put the checked out code in the current directory, not in the
-#  directory of the original file.)  Since this is a symptom of a teamware
-#  failure, and since not all problems can be detected by gnumake due
-#  to incomplete dependency checking... just complain and stop.
-%:: s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-%:: SCCS/s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-.PHONY: default
diff --git a/hotspot/make/linux/makefiles/shark.make b/hotspot/make/linux/makefiles/shark.make
deleted file mode 100644
index ca702ee..0000000
--- a/hotspot/make/linux/makefiles/shark.make
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2008, 2010 Red Hat, Inc.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making Shark version of VM
-
-TYPE = SHARK
-
-VM_SUBDIR = server
-
-CFLAGS += -DSHARK
diff --git a/hotspot/make/linux/makefiles/sparc.make b/hotspot/make/linux/makefiles/sparc.make
deleted file mode 100644
index ddb0513..0000000
--- a/hotspot/make/linux/makefiles/sparc.make
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (c) 2005, 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.
-#  
-#
-
diff --git a/hotspot/make/linux/makefiles/sparcWorks.make b/hotspot/make/linux/makefiles/sparcWorks.make
deleted file mode 100644
index e391160..0000000
--- a/hotspot/make/linux/makefiles/sparcWorks.make
+++ /dev/null
@@ -1,107 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-#------------------------------------------------------------------------
-# CC, CXX & AS
-
-# If a SPEC is not set already, then use these defaults.
-ifeq ($(SPEC),)
-  CXX = CC
-  CC  = cc
-  AS  = $(CC) -c
-
-  HOSTCXX = $(CXX)
-  HOSTCC  = $(CC)
-endif
-
-ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
-ARCHFLAG/i486    = -m32
-ARCHFLAG/amd64   = -m64
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-ASFLAGS    += $(ARCHFLAG)
-
-#------------------------------------------------------------------------
-# Compiler flags
-
-# position-independent code
-PICFLAG = -KPIC
-
-CFLAGS += $(PICFLAG)
-# no more exceptions
-CFLAGS += -features=no%except
-# Reduce code bloat by reverting back to 5.0 behavior for static initializers
-CFLAGS += -features=no%split_init
-# allow zero sized arrays
-CFLAGS += -features=zla
-
-# Use C++ Interpreter
-ifdef CC_INTERP
-  CFLAGS += -DCC_INTERP
-endif
-
-# We don't need libCstd.so and librwtools7.so, only libCrun.so
-CFLAGS += -library=Crun
-LIBS += -lCrun
-
-CFLAGS += -mt
-LFLAGS += -mt
-
-# Compiler warnings are treated as errors
-#WARNINGS_ARE_ERRORS = -errwarn=%all
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) 
-# Special cases
-CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
-
-# The flags to use for an Optimized build
-OPT_CFLAGS+=-xO4
-OPT_CFLAGS/NOOPT=-xO0
-
-# Flags for creating the dependency files.
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-DEPFLAGS = -xMMD -xMF $(DEP_DIR)/$(@:%=%.d)
-endif
-
-# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
-CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
-
-#------------------------------------------------------------------------
-# Linker flags
-
-# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-MAPFLAG = -Wl,--version-script=FILENAME
-
-# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-SONAMEFLAG = -h SONAME
-
-# Build shared library
-SHARED_FLAG = -G
-
-#------------------------------------------------------------------------
-# Debug flags
-DEBUG_CFLAGS += -g
-FASTDEBUG_CFLAGS = -g0
-
diff --git a/hotspot/make/linux/makefiles/sparcv9.make b/hotspot/make/linux/makefiles/sparcv9.make
deleted file mode 100644
index b9e4e52..0000000
--- a/hotspot/make/linux/makefiles/sparcv9.make
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 2005, 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.
-#  
-
-# gcc 4.0 miscompiles this code in -m64
-OPT_CFLAGS/macro.o = -O0
-
-CFLAGS += -D_LP64=1
diff --git a/hotspot/make/linux/makefiles/tiered.make b/hotspot/make/linux/makefiles/tiered.make
deleted file mode 100644
index da79ade..0000000
--- a/hotspot/make/linux/makefiles/tiered.make
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making tiered version of VM
-
-TYPE=TIERED
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2 -DCOMPILER1
diff --git a/hotspot/make/linux/makefiles/top.make b/hotspot/make/linux/makefiles/top.make
deleted file mode 100644
index d798d42..0000000
--- a/hotspot/make/linux/makefiles/top.make
+++ /dev/null
@@ -1,150 +0,0 @@
-#
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# top.make is included in the Makefile in the build directories.
-# It DOES NOT include the vm dependency info in order to be faster.
-# Its main job is to implement the incremental form of make lists.
-# It also:
-#   -builds and runs adlc via adlc.make
-#   -generates JVMTI source and docs via jvmti.make (JSR-163)
-
-# It assumes the following flags are set:
-# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Obj_Files
-
-# -- D. Ungar (5/97) from a file by Bill Bush
-
-# Don't override the built-in $(MAKE).
-# Instead, use "gmake" (or "gnumake") from the command line.  --Rose
-#MAKE = gmake
-
-include $(GAMMADIR)/make/altsrc.make
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-VM          = $(GAMMADIR)/src/share/vm
-Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED);
-
-ifneq ($(USE_PRECOMPILED_HEADER),0)
-UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS)
-else
-UpdatePCH = \# precompiled header is not used
-endif
-
-Cached_plat = $(GENERATED)/platform.current
-
-AD_Dir   = $(GENERATED)/adfiles
-ADLC     = $(AD_Dir)/adlc
-AD_Spec  = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad)
-AD_Src   = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc)
-AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
-AD_Files = $(AD_Names:%=$(AD_Dir)/%)
-
-# AD_Files_If_Required/COMPILER1 = ad_stuff
-AD_Files_If_Required/COMPILER2 = ad_stuff
-AD_Files_If_Required/TIERED = ad_stuff
-AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE))
-
-# Wierd argument adjustment for "gnumake -j..."
-adjust-mflags   = $(GENERATED)/adjust-mflags
-# If SPEC is set, it's from configure and it's already controlling concurrency
-# for us. Skip setting -j with HOTSPOT_BUILD_JOBS.
-ifeq ($(SPEC), )
-  MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"`
-else
-  MFLAGS-adjusted = -r $(MFLAGS)
-endif
-
-
-# default target: update lists, make vm
-# done in stages to force sequential order with parallel make
-#
-
-default: vm_build_preliminaries the_vm
-	@echo All done.
-
-# This is an explicit dependency for the sake of parallel makes.
-vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) trace_stuff jvmti_stuff dtrace_stuff
-	@# We need a null action here, so implicit rules don't get consulted.
-
-$(Cached_plat): $(Plat_File)
-	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
-
-# make AD files as necessary
-ad_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f adlc.make $(MFLAGS-adjusted)
-
-# generate JVMTI files from the spec
-jvmti_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f jvmti.make $(MFLAGS-adjusted)
-
-# generate trace files
-trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f trace.make $(MFLAGS-adjusted)
-
-dtrace_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f dtrace.make dtrace_gen_headers $(MFLAGS-adjusted) GENERATED=$(GENERATED)
-
-# and the VM: must use other makefile with dependencies included
-
-# We have to go to great lengths to get control over the -jN argument
-# to the recursive invocation of vm.make.  The problem is that gnumake
-# resets -jN to -j1 for recursive runs.  (How helpful.)
-# Note that the user must specify the desired parallelism level via a
-# command-line or environment variable name HOTSPOT_BUILD_JOBS.
-$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh
-	@+rm -f $@ $@+
-	@+cat $< > $@+
-	@+chmod +x $@+
-	@+mv $@+ $@
-
-the_vm: vm_build_preliminaries $(adjust-mflags)
-	+@$(UpdatePCH)
-	@$(MAKE) -f vm.make $(MFLAGS-adjusted)
-
-install: the_vm
-	@$(MAKE) -f vm.make $@
-
-# next rules support "make foo.[ois]"
-
-%.o %.i %.s:
-	+$(UpdatePCH)
-	$(MAKE) -f vm.make $(MFLAGS) $@
-	#$(MAKE) -f vm.make $@
-
-# this should force everything to be rebuilt
-clean:
-	rm -f $(GENERATED)/*.class
-	$(MAKE) -f vm.make $(MFLAGS) clean
-
-# just in case it doesn't, this should do it
-realclean:
-	$(MAKE) -f vm.make $(MFLAGS) clean
-	rm -fr $(GENERATED)
-
-.PHONY: default vm_build_preliminaries
-.PHONY: lists ad_stuff jvmti_stuff the_vm clean realclean
-.PHONY: checks check_os_version install
-
-.NOTPARALLEL:
diff --git a/hotspot/make/linux/makefiles/trace.make b/hotspot/make/linux/makefiles/trace.make
deleted file mode 100644
index 2209716..0000000
--- a/hotspot/make/linux/makefiles/trace.make
+++ /dev/null
@@ -1,119 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile (trace.make) is included from the trace.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate trace files.
-
-include $(GAMMADIR)/make/linux/makefiles/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-# #########################################################################
-
-HAS_ALT_SRC := false
-ifndef OPENJDK
-  ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), )
-    HAS_ALT_SRC := true
-  endif
-endif
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-JvmtiOutDir = $(GENERATED)/jvmtifiles
-TraceOutDir   = $(GENERATED)/tracefiles
-
-TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace
-TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-TraceGeneratedNames =     \
-    traceEventClasses.hpp \
-	traceEventIds.hpp     \
-	traceTypes.hpp
-
-ifeq ($(HAS_ALT_SRC), true)
-TraceGeneratedNames +=  \
-	traceRequestables.hpp \
-    traceEventControl.hpp
-endif
-
-TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%)
-
-XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-TraceXml = $(TraceSrcDir)/trace.xml
-ifeq ($(HAS_ALT_SRC), true)
-  TraceXml = $(TraceAltSrcDir)/trace.xml
-endif
-
-XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \
-    $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \
-    $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml
-ifeq ($(HAS_ALT_SRC), true)
-  XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \
-      $(TraceAltSrcDir)/traceeventtypes.xml
-endif
-
-.PHONY: all clean cleanall
-
-# #########################################################################
-
-all: $(TraceGeneratedFiles)
-
-GENERATE_CODE= \
-  $(QUIETLY) echo $(LOG_INFO) Generating $@; \
-  $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@
-
-$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-ifeq ($(HAS_ALT_SRC), false)
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-else
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-endif
-
-# #########################################################################
-
-clean cleanall:
-	rm $(TraceGeneratedFiles)
diff --git a/hotspot/make/linux/makefiles/vm.make b/hotspot/make/linux/makefiles/vm.make
deleted file mode 100644
index f97884a..0000000
--- a/hotspot/make/linux/makefiles/vm.make
+++ /dev/null
@@ -1,407 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Rules to build JVM and related libraries, included from vm.make in the build
-# directory.
-
-# Common build rules.
-MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
-include $(MAKEFILES_DIR)/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-default: build
-
-#----------------------------------------------------------------------
-# Defs
-
-GENERATED     = ../generated
-DEP_DIR       = $(GENERATED)/dependencies
-
-# reads the generated files defining the set of .o's and the .o .h dependencies
--include $(DEP_DIR)/*.d
-
-# read machine-specific adjustments (%%% should do this via buildtree.make?)
-ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
-  include $(MAKEFILES_DIR)/zeroshark.make
-else
-  BUILDARCH_MAKE = $(MAKEFILES_DIR)/$(BUILDARCH).make
-  ALT_BUILDARCH_MAKE = $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make
-  include $(if $(wildcard $(ALT_BUILDARCH_MAKE)),$(ALT_BUILDARCH_MAKE),$(BUILDARCH_MAKE))
-endif
-
-# set VPATH so make knows where to look for source files
-# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
-# The adfiles directory contains ad_<arch>.[ch]pp.
-# The jvmtifiles directory contains jvmti*.[ch]pp
-Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles $(GENERATED)/extensions
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor.
-Src_Dirs_I += $(GENERATED)
-# The order is important for the precompiled headers to work.
-INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
-
-# SYMFLAG is used by jsig.make
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  # always build with debug info when we can create .debuginfo files
-  SYMFLAG = -g
-else
-  ifeq (${VERSION}, debug)
-    SYMFLAG = -g
-  else
-    SYMFLAG =
-  endif
-endif
-
-# The following variables are defined in the generated flags.make file.
-JDK_VER_DEFS  = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-		-DVERSION_MINOR=$(VERSION_MINOR) \
-		-DVERSION_SECURITY=$(VERSION_SECURITY) \
-	        -DVERSION_PATCH=$(VERSION_PATCH) \
-		-DVERSION_BUILD=$(VERSION_BUILD)
-VM_VER_DEFS   = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-		-DVERSION_STRING="\"$(VERSION_STRING)\""  \
-	        -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \
-		$(JDK_VER_DEFS)
-HS_LIB_ARCH   = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
-BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
-VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
-
-CXXFLAGS =           \
-  ${SYSDEFS}         \
-  ${INCLUDES}        \
-  ${BUILD_USER}      \
-  ${HS_LIB_ARCH}     \
-  ${VM_DISTRO}
-
-# This is VERY important! The version define must only be supplied to vm_version.o
-# If not, ccache will not re-use the cache at all, since the version string might contain
-# a time and date.
-CXXFLAGS/vm_version.o += ${VM_VER_DEFS}
-
-CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
-
-# File specific flags
-CXXFLAGS += $(CXXFLAGS/BYFILE)
-
-# Large File Support
-ifneq ($(LP64), 1)
-CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64
-endif # ifneq ($(LP64), 1)
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-CFLAGS += $(CFLAGS_WARN/BYFILE)
-
-# Do not use C++ exception handling
-CFLAGS += $(CFLAGS/NOEX)
-
-# Extra flags from gnumake's invocation or environment
-CFLAGS += $(EXTRA_CFLAGS)
-LFLAGS += $(EXTRA_CFLAGS)
-
-# Don't set excutable bit on stack segment
-# the same could be done by separate execstack command
-LFLAGS += -Xlinker -z -Xlinker noexecstack
-
-LIBS += -lm -ldl -lpthread
-
-# By default, link the *.o into the library, not the executable.
-LINK_INTO$(LINK_INTO) = LIBJVM
-
-JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH)
-
-#----------------------------------------------------------------------
-# jvm_db & dtrace
-include $(MAKEFILES_DIR)/dtrace.make
-
-#----------------------------------------------------------------------
-# JVM
-
-JVM      = jvm
-LIBJVM   = lib$(JVM).so
-
-LIBJVM_DEBUGINFO   = lib$(JVM).debuginfo
-LIBJVM_DIZ         = lib$(JVM).diz
-
-SPECIAL_PATHS:=adlc c1 gc opto shark libadt
-
-SOURCE_PATHS=\
-  $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
-      \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
-
-CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
-CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
-
-ifneq ($(INCLUDE_TRACE), false)
-CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \
-  find $(HS_ALT_SRC)/share/vm/jfr -type d; \
-  fi)
-endif
-
-CORE_PATHS+=$(GENERATED)/extensions
-
-COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
-COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
-
-COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
-COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
-COMPILER2_PATHS += $(GENERATED)/adfiles
-
-SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
-
-# Include dirs per type.
-Src_Dirs/CORE      := $(CORE_PATHS)
-Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
-Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/TIERED    := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/ZERO      := $(CORE_PATHS)
-Src_Dirs/SHARK     := $(CORE_PATHS) $(SHARK_PATHS)
-Src_Dirs := $(Src_Dirs/$(TYPE))
-
-COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\*
-COMPILER1_SPECIFIC_FILES := c1_\*
-SHARK_SPECIFIC_FILES     := shark
-ZERO_SPECIFIC_FILES      := zero
-
-# Always exclude these.
-Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
-
-# Exclude per type.
-Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
-
-Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
-
-# Special handling of arch model.
-ifeq ($(Platform_arch_model), x86_32)
-Src_Files_EXCLUDE += \*x86_64\*
-endif
-ifeq ($(Platform_arch_model), x86_64)
-Src_Files_EXCLUDE += \*x86_32\*
-endif
-
-Src_Files_BASE += \*.c \*.cpp \*.s 
-
-# Alternate vm.make
-# This has to be included here to allow changes to the source
-# directories and excluded files before they are expanded
-# by the definition of Src_Files.
--include $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make
-
-# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
-define findsrc
-	$(notdir $(shell find $(1)/. ! -name . -prune \
-		-a \( -name DUMMY $(addprefix -o -name ,$(Src_Files_BASE)) \) \
-		-a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
-endef
-
-Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
-
-Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))) $(EXTENDED_JVM_OBJ_FILES))
-
-JVM_OBJ_FILES = $(Obj_Files)
-
-vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
-
-MAPFILE_SHARE  := $(GAMMADIR)/make/share/makefiles/mapfile-vers
-
-MAPFILE_EXT_SRC := $(HS_ALT_MAKE)/share/makefiles/mapfile-ext
-ifneq ("$(wildcard $(MAPFILE_EXT_SRC))","")
-MAPFILE_EXT     := $(MAPFILE_EXT_SRC)
-endif
-
-mapfile : $(MAPFILE) $(MAPFILE_SHARE) vm.def $(MAPFILE_EXT)
-	rm -f $@
-	awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE")	\
-                 { system ("cat ${MAPFILE_SHARE} $(MAPFILE_EXT) vm.def"); } \
-               else					\
-                 { print $$0 }				\
-             }' > $@ < $(MAPFILE)
-
-mapfile_reorder : mapfile $(REORDERFILE)
-	rm -f $@
-	cat $^ > $@
-
-VMDEF_PAT  = ^_ZTV
-VMDEF_PAT := ^gHotSpotVM|$(VMDEF_PAT)
-VMDEF_PAT := ^UseSharedSpaces$$|$(VMDEF_PAT)
-VMDEF_PAT := ^_ZN9Arguments17SharedArchivePathE$$|$(VMDEF_PAT)
-ifneq ($(VMDEF_PAT_EXT),)
-  VMDEF_PAT := $(VMDEF_PAT_EXT)|$(VMDEF_PAT)
-endif        
-
-vm.def: $(Res_Files) $(Obj_Files) $(VM_DEF_EXT)
-	$(QUIETLY) $(NM) --defined-only $(Obj_Files) | sort -k3 -u | \
-	awk '$$3 ~ /$(VMDEF_PAT)/ { print "\t" $$3 ";" }' > $@
-ifneq ($(VM_DEF_EXT),)
-	cat $(VM_DEF_EXT) >> $@
-endif        
-
-ifeq ($(JVM_VARIANT_ZEROSHARK), true)
-  STATIC_CXX = false
-else
-  ifeq ($(ZERO_LIBARCH), ppc64)
-    STATIC_CXX = false
-  else
-    STATIC_CXX = true
-  endif
-endif
-
-ifeq ($(LINK_INTO),AOUT)
-  LIBJVM.o                 =
-  LIBJVM_MAPFILE           =
-  LIBS_VM                  = $(LIBS)
-else
-  LIBJVM.o                 = $(JVM_OBJ_FILES)
-  LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
-  LFLAGS_VM$(LDNOMAP)      += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
-  LFLAGS_VM                += $(SONAMEFLAG:SONAME=$(LIBJVM))
-  LFLAGS_VM                += -Wl,-z,defs
-
-  # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
-  # get around library dependency and compatibility issues. Must use gcc not
-  # g++ to link.
-  ifeq ($(STATIC_CXX), true)
-    LFLAGS_VM              += $(STATIC_LIBGCC)
-    LIBS_VM                += $(STATIC_STDCXX)
-  else
-    LIBS_VM                += -lstdc++
-  endif
-
-  LIBS_VM                  += $(LIBS)
-endif
-ifeq ($(JVM_VARIANT_ZERO), true)
-  LIBS_VM += $(LIBFFI_LIBS)
-endif
-ifeq ($(JVM_VARIANT_ZEROSHARK), true)
-  LIBS_VM   += $(LIBFFI_LIBS) $(LLVM_LIBS)
-  LFLAGS_VM += $(LLVM_LDFLAGS)
-endif
-
-LINK_VM = $(LINK_LIB.CC)
-
-# rule for building precompiled header
-$(PRECOMPILED_HEADER):
-	$(QUIETLY) echo $(LOG_INFO) Generating precompiled header $@
-	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
-	$(QUIETLY) rm -f $@
-	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
-
-# making the library:
-
-ifneq ($(JVM_BASE_ADDR),)
-# By default shared library is linked at base address == 0. Modify the
-# linker script if JVM prefers a different base location. It can also be
-# implemented with 'prelink -r'. But 'prelink' is not (yet) available on
-# our build platform (AS-2.1).
-LD_SCRIPT = libjvm.so.lds
-$(LD_SCRIPT): $(LIBJVM_MAPFILE)
-	$(QUIETLY) {                                                \
-	  rm -rf $@;                                                \
-	  $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1             |  \
-	    sed -e '/^======/,/^======/!d'                          \
-		-e '/^======/d'                                     \
-		-e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/'   \
-		> $@;                                               \
-	}
-LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
-endif
-
-# With more recent Redhat releases (or the cutting edge version Fedora), if
-# SELinux is configured to be enabled, the runtime linker will fail to apply
-# the text relocation to libjvm.so considering that it is built as a non-PIC
-# DSO. To workaround that, we run chcon to libjvm.so after it is built. See
-# details in bug 6538311.
-$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
-	$(QUIETLY) {                                                    \
-	    echo $(LOG_INFO) Linking vm...;                             \
-	    $(LINK_LIB.CXX/PRE_HOOK)                                     \
-	    $(LINK_VM) $(LD_SCRIPT_FLAG)                                \
-		       $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM);       \
-	    $(LINK_LIB.CXX/POST_HOOK)                                    \
-	    rm -f $@.1; ln -s $@ $@.1;                                  \
-            if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then                    \
-	      if [ -x /usr/sbin/selinuxenabled ] ; then                 \
-                if /usr/sbin/selinuxenabled; then			\
-		  if ! /usr/bin/chcon -t textrel_shlib_t $@; then       \
-		    echo "ERROR: Cannot chcon $@";			\
-		  fi							\
-	        fi							\
-	      fi                                                        \
-            fi 								\
-	}
-
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -g $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO)
-	$(RM) $(LIBJVM_DEBUGINFO)
-  endif
-endif
-
-DEST_SUBDIR        = $(JDK_LIBDIR)/$(VM_SUBDIR)
-DEST_JVM           = $(DEST_SUBDIR)/$(LIBJVM)
-DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO)
-DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
-
-install_jvm: $(LIBJVM)
-	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
-	$(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \
-	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
-	$(QUIETLY) test ! -f $(LIBJVM_DIZ) || \
-	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
-
-#----------------------------------------------------------------------
-# Other files
-
-# Signal interposition library
-include $(MAKEFILES_DIR)/jsig.make
-
-#----------------------------------------------------------------------
-
-build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) dtraceCheck
-
-install: install_jvm install_jsig
-
-.PHONY: default build install install_jvm $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make
diff --git a/hotspot/make/linux/makefiles/zero.make b/hotspot/make/linux/makefiles/zero.make
deleted file mode 100644
index 622710f..0000000
--- a/hotspot/make/linux/makefiles/zero.make
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2009 Red Hat, Inc.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Setup for Zero (non-Shark) version of VM
-
-# Select which files to use (in top.make)
-TYPE = ZERO
-
-# Install libjvm.so, etc in in server directory.
-VM_SUBDIR = server
-
-# Disable trace for zero builds
-# NOTE: This is used for simple comparison with the new build system, and
-# should not be merged into mainline with build-infra.
-INCLUDE_TRACE := false
diff --git a/hotspot/make/linux/makefiles/zeroshark.make b/hotspot/make/linux/makefiles/zeroshark.make
deleted file mode 100644
index 4f9a70c..0000000
--- a/hotspot/make/linux/makefiles/zeroshark.make
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2007, 2008 Red Hat, Inc.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Setup common to Zero (non-Shark) and Shark versions of VM
-
-# Some versions of llvm do not like -Wundef
-ifeq ($(USE_CLANG), true)
-  WARNING_FLAGS += -Wno-undef
-endif
-
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
-
-# Specify that the CPU is little endian, if necessary
-ifeq ($(ZERO_ENDIANNESS), little)
-  CFLAGS += -DVM_LITTLE_ENDIAN
-endif
-
-# Specify that the CPU is 64 bit, if necessary
-ifeq ($(ARCH_DATA_MODEL), 64)
-  CFLAGS += -D_LP64=1
-endif
diff --git a/hotspot/make/linux/platform_aarch64 b/hotspot/make/linux/platform_aarch64
deleted file mode 100644
index f0bbf33..0000000
--- a/hotspot/make/linux/platform_aarch64
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = linux
-
-arch = aarch64
-
-arch_model = aarch64
-
-os_arch = linux_aarch64
-
-os_arch_model = linux_aarch64
-
-lib_arch = aarch64
-
-compiler = gcc
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DAARCH64
diff --git a/hotspot/make/linux/platform_amd64 b/hotspot/make/linux/platform_amd64
deleted file mode 100644
index b612635..0000000
--- a/hotspot/make/linux/platform_amd64
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = linux
-
-arch = x86
-
-arch_model = x86_64
-
-os_arch = linux_x86
-
-os_arch_model = linux_x86_64
-
-lib_arch = amd64
-
-compiler = gcc
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DAMD64
diff --git a/hotspot/make/linux/platform_amd64.suncc b/hotspot/make/linux/platform_amd64.suncc
deleted file mode 100644
index 4366549..0000000
--- a/hotspot/make/linux/platform_amd64.suncc
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = linux
-
-arch = x86
-
-arch_model = x86_64
-
-os_arch = linux_x86
-
-os_arch_model = linux_x86_64
-
-lib_arch = amd64
-
-compiler = sparcWorks
-
-gnu_dis_arch = amd64
-
-sysdefs = -DLINUX -DSPARC_WORKS -D_GNU_SOURCE -DAMD64
diff --git a/hotspot/make/linux/platform_i486 b/hotspot/make/linux/platform_i486
deleted file mode 100644
index 610ac91..0000000
--- a/hotspot/make/linux/platform_i486
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = linux
-
-arch = x86
-
-arch_model = x86_32
-
-os_arch = linux_x86
-
-os_arch_model = linux_x86_32
-
-lib_arch = i386
-
-compiler = gcc
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DIA32
diff --git a/hotspot/make/linux/platform_i486.suncc b/hotspot/make/linux/platform_i486.suncc
deleted file mode 100644
index 325a3fe..0000000
--- a/hotspot/make/linux/platform_i486.suncc
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = linux
-
-arch = x86
-
-arch_model = x86_32
-
-os_arch = linux_x86
-
-os_arch_model = linux_x86_32
-
-lib_arch = i386
-
-compiler = sparcWorks
-
-gnu_dis_arch = i386
-
-sysdefs = -DLINUX -DSPARC_WORKS -D_GNU_SOURCE -DIA32
diff --git a/hotspot/make/linux/platform_ia64 b/hotspot/make/linux/platform_ia64
deleted file mode 100644
index 7474e5b..0000000
--- a/hotspot/make/linux/platform_ia64
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = linux
-
-arch = ia64
-
-os_arch = linux_ia64
-
-lib_arch = ia64
-
-compiler = gcc
-
-gnu_dis_arch = ia64
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DIA64 -DCC_INTERP
-
-mark_style = alignment
diff --git a/hotspot/make/linux/platform_ppc64 b/hotspot/make/linux/platform_ppc64
deleted file mode 100644
index 2fd79c4..0000000
--- a/hotspot/make/linux/platform_ppc64
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = linux
-
-arch = ppc
-
-arch_model = ppc_64
-
-os_arch = linux_ppc
-
-os_arch_model = linux_ppc_64
-
-lib_arch = ppc64
-
-compiler = gcc
-
-gnu_dis_arch = ppc64
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DPPC64
diff --git a/hotspot/make/linux/platform_sparc b/hotspot/make/linux/platform_sparc
deleted file mode 100644
index 8d9e3ee..0000000
--- a/hotspot/make/linux/platform_sparc
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = linux
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = linux_sparc
-
-os_arch_model = linux_sparc
-
-lib_arch = sparc
-
-compiler = gcc
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DSPARC
diff --git a/hotspot/make/linux/platform_sparcv9 b/hotspot/make/linux/platform_sparcv9
deleted file mode 100644
index c9f8722..0000000
--- a/hotspot/make/linux/platform_sparcv9
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = linux
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = linux_sparc
-
-os_arch_model = linux_sparc
-
-lib_arch = sparcv9
-
-compiler = gcc
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DSPARC
diff --git a/hotspot/make/linux/platform_zero.in b/hotspot/make/linux/platform_zero.in
deleted file mode 100644
index 404ad3f..0000000
--- a/hotspot/make/linux/platform_zero.in
+++ /dev/null
@@ -1,17 +0,0 @@
-os_family = linux
-
-arch = zero
-
-arch_model = zero
-
-os_arch = linux_zero
-
-os_arch_model = linux_zero
-
-lib_arch = zero
-
-compiler = gcc
-
-gnu_dis_arch = zero
-
-sysdefs = -DLINUX -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\"
diff --git a/hotspot/makefiles/mapfiles/libjsig/mapfile-vers-solaris b/hotspot/make/mapfiles/libjsig/mapfile-vers-solaris
similarity index 100%
rename from hotspot/makefiles/mapfiles/libjsig/mapfile-vers-solaris
rename to hotspot/make/mapfiles/libjsig/mapfile-vers-solaris
diff --git a/hotspot/makefiles/mapfiles/libjvm_db/mapfile-vers b/hotspot/make/mapfiles/libjvm_db/mapfile-vers
similarity index 100%
rename from hotspot/makefiles/mapfiles/libjvm_db/mapfile-vers
rename to hotspot/make/mapfiles/libjvm_db/mapfile-vers
diff --git a/hotspot/makefiles/mapfiles/libjvm_dtrace/mapfile-vers b/hotspot/make/mapfiles/libjvm_dtrace/mapfile-vers
similarity index 100%
rename from hotspot/makefiles/mapfiles/libjvm_dtrace/mapfile-vers
rename to hotspot/make/mapfiles/libjvm_dtrace/mapfile-vers
diff --git a/hotspot/make/openjdk_distro b/hotspot/make/openjdk_distro
deleted file mode 100644
index 520b33d..0000000
--- a/hotspot/make/openjdk_distro
+++ /dev/null
@@ -1,32 +0,0 @@
-# 
-# Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-# 
-
-#
-# This file format must remain compatible with both
-# GNU Makefile and Microsoft nmake formats.
-#
-
-# Don't put quotes (fail windows build).
-HOTSPOT_VM_DISTRO=OpenJDK
-COMPANY_NAME=
-PRODUCT_NAME=OpenJDK
diff --git a/hotspot/make/pic.make b/hotspot/make/pic.make
deleted file mode 100644
index 9211b5b..0000000
--- a/hotspot/make/pic.make
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright (c) 2006, 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
-# 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.
-#  
-#
-
-# A list of object files built without the platform specific PIC flags, e.g.
-# -fPIC on linux. Performance measurements show that by compiling GC related 
-# code, we could significantly reduce the GC pause time on 32 bit Linux/Unix
-# platforms. See 6454213 for more details.
-include $(GAMMADIR)/make/scm.make
-
-ifneq ($(OSNAME), windows)
-  ifndef LP64
-    PARTIAL_NONPIC=1
-  endif
-  PIC_ARCH = ppc arm
-  ifneq ("$(filter $(PIC_ARCH),$(BUILDARCH))","")
-    PARTIAL_NONPIC=0
-  endif
-  ifeq ($(PARTIAL_NONPIC),1)
-    NONPIC_DIRS  = memory oops gc
-    NONPIC_DIRS  := $(foreach dir,$(NONPIC_DIRS), $(GAMMADIR)/src/share/vm/$(dir))
-    # Look for source files under NONPIC_DIRS
-    NONPIC_FILES := $(foreach dir,$(NONPIC_DIRS),\
-                      $(shell find $(dir) \( $(SCM_DIRS) \) -prune -o \
-		      -name '*.cpp' -print))
-    NONPIC_OBJ_FILES := $(notdir $(subst .cpp,.o,$(NONPIC_FILES)))
-  endif
-endif
diff --git a/hotspot/make/scm.make b/hotspot/make/scm.make
deleted file mode 100644
index 011492d..0000000
--- a/hotspot/make/scm.make
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-
-# Prune out all known SCM (Source Code Management) directories
-# so they will not appear on -I PATHs, when copying directory trees,
-# packaging up .jar files, etc.  This applies to all workspaces.
-#
-SCM_DIRS = -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files
diff --git a/hotspot/make/share/makefiles/mapfile-vers b/hotspot/make/share/makefiles/mapfile-vers
deleted file mode 100644
index f7d08e5..0000000
--- a/hotspot/make/share/makefiles/mapfile-vers
+++ /dev/null
@@ -1,180 +0,0 @@
-                # JNI
-                JNI_CreateJavaVM;
-                JNI_GetCreatedJavaVMs;
-                JNI_GetDefaultJavaVMInitArgs;
-
-                # JVM
-                JVM_ActiveProcessorCount;
-                JVM_ArrayCopy;
-                JVM_AssertionStatusDirectives;
-                JVM_CallStackWalk;
-                JVM_ClassDepth;
-                JVM_ClassLoaderDepth;
-                JVM_Clone;
-                JVM_ConstantPoolGetClassAt;
-                JVM_ConstantPoolGetClassAtIfLoaded;
-                JVM_ConstantPoolGetClassRefIndexAt;
-                JVM_ConstantPoolGetDoubleAt;
-                JVM_ConstantPoolGetFieldAt;
-                JVM_ConstantPoolGetFieldAtIfLoaded;
-                JVM_ConstantPoolGetFloatAt;
-                JVM_ConstantPoolGetIntAt;
-                JVM_ConstantPoolGetLongAt;
-                JVM_ConstantPoolGetMethodAt;
-                JVM_ConstantPoolGetMethodAtIfLoaded;
-                JVM_ConstantPoolGetMemberRefInfoAt;
-                JVM_ConstantPoolGetNameAndTypeRefInfoAt;
-                JVM_ConstantPoolGetNameAndTypeRefIndexAt;
-                JVM_ConstantPoolGetSize;
-                JVM_ConstantPoolGetStringAt;
-                JVM_ConstantPoolGetTagAt;
-                JVM_ConstantPoolGetUTF8At;
-                JVM_CountStackFrames;
-                JVM_CurrentClassLoader;
-                JVM_CurrentLoadedClass;
-                JVM_CurrentThread;
-                JVM_CurrentTimeMillis;
-                JVM_DefineClass;
-                JVM_DefineClassWithSource;
-                JVM_DesiredAssertionStatus;
-                JVM_DoPrivileged;
-                JVM_DumpAllStacks;
-                JVM_DumpThreads;
-                JVM_FillInStackTrace;
-                JVM_FindClassFromCaller;
-                JVM_FindClassFromClass;
-                JVM_FindClassFromBootLoader;
-                JVM_FindLibraryEntry;
-                JVM_FindLoadedClass;
-                JVM_FindPrimitiveClass;
-                JVM_FindSignal;
-                JVM_FreeMemory;
-                JVM_GC;
-                JVM_GetAllThreads;
-                JVM_GetArrayElement;
-                JVM_GetArrayLength;
-                JVM_GetCPClassNameUTF;
-                JVM_GetCPFieldClassNameUTF;
-                JVM_GetCPFieldModifiers;
-                JVM_GetCPFieldNameUTF;
-                JVM_GetCPFieldSignatureUTF;
-                JVM_GetCPMethodClassNameUTF;
-                JVM_GetCPMethodModifiers;
-                JVM_GetCPMethodNameUTF;
-                JVM_GetCPMethodSignatureUTF;
-                JVM_GetCallerClass;
-                JVM_GetClassAccessFlags;
-                JVM_GetClassAnnotations;
-                JVM_GetClassCPEntriesCount;
-                JVM_GetClassCPTypes;
-                JVM_GetClassConstantPool;
-                JVM_GetClassContext;
-                JVM_GetClassDeclaredConstructors;
-                JVM_GetClassDeclaredFields;
-                JVM_GetClassDeclaredMethods;
-                JVM_GetClassFieldsCount;
-                JVM_GetClassInterfaces;
-                JVM_GetClassMethodsCount;
-                JVM_GetClassModifiers;
-                JVM_GetClassName;
-                JVM_GetClassNameUTF;
-                JVM_GetClassSignature;
-                JVM_GetClassSigners;
-                JVM_GetClassTypeAnnotations;
-                JVM_GetDeclaredClasses;
-                JVM_GetDeclaringClass;
-                JVM_GetSimpleBinaryName;
-                JVM_GetEnclosingMethodInfo;
-                JVM_GetFieldIxModifiers;
-                JVM_GetFieldTypeAnnotations;
-                JVM_GetInheritedAccessControlContext;
-                JVM_GetInterfaceVersion;
-                JVM_GetManagement;
-                JVM_GetMethodIxArgsSize;
-                JVM_GetMethodIxByteCode;
-                JVM_GetMethodIxByteCodeLength;
-                JVM_GetMethodIxExceptionIndexes;
-                JVM_GetMethodIxExceptionTableEntry;
-                JVM_GetMethodIxExceptionTableLength;
-                JVM_GetMethodIxExceptionsCount;
-                JVM_GetMethodIxLocalsCount;
-                JVM_GetMethodIxMaxStack;
-                JVM_GetMethodIxModifiers;
-                JVM_GetMethodIxNameUTF;
-                JVM_GetMethodIxSignatureUTF;
-                JVM_GetMethodParameters;
-                JVM_GetMethodTypeAnnotations;
-                JVM_GetNanoTimeAdjustment;
-                JVM_GetPrimitiveArrayElement;
-                JVM_GetProtectionDomain;
-                JVM_GetStackAccessControlContext;
-                JVM_GetStackTraceElements;
-                JVM_GetSystemPackage;
-                JVM_GetSystemPackages;
-                JVM_GetTemporaryDirectory;
-                JVM_GetVersionInfo;
-                JVM_GetVmArguments;
-                JVM_Halt;
-                JVM_HoldsLock;
-                JVM_IHashCode;
-                JVM_InitAgentProperties;
-                JVM_InitProperties;
-                JVM_InternString;
-                JVM_Interrupt;
-                JVM_InvokeMethod;
-                JVM_IsArrayClass;
-                JVM_IsConstructorIx;
-                JVM_IsInterface;
-                JVM_IsInterrupted;
-                JVM_IsPrimitiveClass;
-                JVM_IsSameClassPackage;
-                JVM_IsSupportedJNIVersion;
-                JVM_IsThreadAlive;
-                JVM_IsVMGeneratedMethodIx;
-                JVM_LatestUserDefinedLoader;
-                JVM_LoadLibrary;
-                JVM_MaxObjectInspectionAge;
-                JVM_MaxMemory;
-                JVM_MonitorNotify;
-                JVM_MonitorNotifyAll;
-                JVM_MonitorWait;
-                JVM_MoreStackWalk;
-                JVM_NanoTime;
-                JVM_NativePath;
-                JVM_NewArray;
-                JVM_NewInstanceFromConstructor;
-                JVM_NewMultiArray;
-                JVM_RaiseSignal;
-                JVM_RawMonitorCreate;
-                JVM_RawMonitorDestroy;
-                JVM_RawMonitorEnter;
-                JVM_RawMonitorExit;
-                JVM_RegisterSignal;
-                JVM_ReleaseUTF;
-                JVM_ResumeThread;
-                JVM_SetArrayElement;
-                JVM_SetClassSigners;
-                JVM_SetNativeThreadName;
-                JVM_SetPrimitiveArrayElement;
-                JVM_SetThreadPriority;
-                JVM_Sleep;
-                JVM_StartThread;
-                JVM_StopThread;
-                JVM_SuspendThread;
-                JVM_SupportsCX8;
-                JVM_ToStackTraceElement;
-                JVM_TotalMemory;
-                JVM_UnloadLibrary;
-                JVM_Yield;
-
-                # Module related API's
-                JVM_AddModuleExports;
-                JVM_AddModuleExportsToAll;
-                JVM_AddModuleExportsToAllUnnamed;
-                JVM_AddModulePackage;
-                JVM_AddReadsModule;
-                JVM_CanReadModule;
-                JVM_DefineModule;
-                JVM_IsExportedToModule;
-                JVM_SetBootLoaderUnnamedModule;
-                JVM_GetModuleByPackageName;
diff --git a/hotspot/make/solaris/Makefile b/hotspot/make/solaris/Makefile
deleted file mode 100644
index 4a89bb3..0000000
--- a/hotspot/make/solaris/Makefile
+++ /dev/null
@@ -1,286 +0,0 @@
-#
-# 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile creates a build tree and lights off a build.
-# You can go back into the build tree and perform rebuilds or
-# incremental builds as desired. Be sure to reestablish
-# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME.
-
-# The make process now relies on java and javac. These can be
-# specified either implicitly on the PATH, by setting the
-# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a
-# JDK in which bin/java and bin/javac are present and working (e.g.,
-# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited)
-# default BOOTDIR path value. Note that one of ALT_BOOTDIR
-# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc.
-# from the PATH.
-
-ifeq ($(GAMMADIR),)
-include ../../make/defs.make
-else
-include $(GAMMADIR)/make/defs.make
-endif
-include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make
-
-ifndef CC_INTERP
-  ifndef FORCE_TIERED
-    FORCE_TIERED=1
-  endif
-endif
-
-ifdef LP64
-  ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
-    _JUNK_ := $(shell echo >&2 \
-         $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!")
-	  @exit 1
-  endif
-endif
-
-# The following renders pathnames in generated Makefiles valid on
-# machines other than the machine containing the build tree.
-#
-# For example, let's say my build tree lives on /files12 on
-# exact.east.sun.com.  This logic will cause GAMMADIR to begin with
-# /net/exact/files12/...
-#
-# We only do this on SunOS variants, for a couple of reasons:
-#  * It is extremely rare that source trees exist on other systems
-#  * It has been claimed that the Linux automounter is flakey, so
-#    changing GAMMADIR in a way that exercises the automounter could
-#    prove to be a source of unreliability in the build process.
-# Obviously, this Makefile is only relevant on SunOS boxes to begin
-# with, but the SunOS conditionalization will make it easier to
-# combine Makefiles in the future (assuming we ever do that).
-
-ifeq ($(OSNAME),solaris)
-
-  #   prepend current directory to relative pathnames.
-  NEW_GAMMADIR :=                                    \
-    $(shell echo $(GAMMADIR) |                       \
-      sed -e "s=^\([^/].*\)=$(shell pwd)/\1="        \
-     )
-  unexport NEW_GAMMADIR
-
-  # If NEW_GAMMADIR doesn't already start with "/net/":
-  ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),)
-    #   prepend /net/$(HOST)
-    #   remove /net/$(HOST) if name already began with /home/
-    #   remove /net/$(HOST) if name already began with /java/
-    #   remove /net/$(HOST) if name already began with /lab/
-    NEW_GAMMADIR :=                                     \
-         $(shell echo $(NEW_GAMMADIR) |                 \
-                 sed -e "s=^\(.*\)=/net/$(HOST)\1="     \
-                     -e "s=^/net/$(HOST)/home/=/home/=" \
-                     -e "s=^/net/$(HOST)/java/=/java/=" \
-                     -e "s=^/net/$(HOST)/lab/=/lab/="   \
-          )
-    # Don't use the new value for GAMMADIR unless a file with the new
-    # name actually exists.
-    ifneq ($(wildcard $(NEW_GAMMADIR)),)
-      GAMMADIR := $(NEW_GAMMADIR)
-    endif
-  endif
-
-endif
-
-
-# There is a (semi-) regular correspondence between make targets and actions:
-#
-#       Target          Tree Type       Build Dir
-#
-#       debug           compiler2       <os>_<arch>_compiler2/debug
-#       fastdebug       compiler2       <os>_<arch>_compiler2/fastdebug
-#       optimized       compiler2       <os>_<arch>_compiler2/optimized
-#       product         compiler2       <os>_<arch>_compiler2/product
-#
-#       debug1          compiler1       <os>_<arch>_compiler1/debug
-#       fastdebug1      compiler1       <os>_<arch>_compiler1/fastdebug
-#       optimized1      compiler1       <os>_<arch>_compiler1/optimized
-#       product1        compiler1       <os>_<arch>_compiler1/product
-#
-#       debugcore       core            <os>_<arch>_core/debug
-#       fastdebugcore   core            <os>_<arch>_core/fastdebug
-#       optimizedcore   core            <os>_<arch>_core/optimized
-#       productcore     core            <os>_<arch>_core/product
-#
-# What you get with each target:
-#
-# debug*     - debug compile with asserts enabled
-# fastdebug* - optimized compile, but with asserts enabled
-# optimized* - optimized compile, no asserts
-# product*   - the shippable thing:  optimized compile, no asserts, -DPRODUCT
-
-# This target list needs to be coordinated with the usage message
-# in the build.sh script:
-TARGETS           = debug fastdebug optimized product
-
-SUBDIR_DOCS       = $(OSNAME)_$(BUILDARCH)_docs
-SUBDIRS_C1        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS))
-SUBDIRS_C2        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS))
-SUBDIRS_TIERED    = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS))
-SUBDIRS_CORE      = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS))
-
-TARGETS_C2        = $(TARGETS)
-TARGETS_C1        = $(addsuffix 1,$(TARGETS))
-TARGETS_TIERED    = $(addsuffix tiered,$(TARGETS))
-TARGETS_CORE      = $(addsuffix core,$(TARGETS))
-
-BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
-BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) ARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
-BUILDTREE_VARS   += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-BUILDTREE_VARS   += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE)
-
-BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
-
-#-------------------------------------------------------------------------------
-
-# Could make everything by default, but that would take a while.
-all:
-	@echo "Try '$(MAKE) <target> ...'  where <target> is one or more of"
-	@echo "  $(TARGETS_C2)"
-	@echo "  $(TARGETS_C1)"
-	@echo "  $(TARGETS_CORE)"
-
-checks: check_os_version check_j2se_version
-
-# We do not want people accidentally building on old systems (e.g. Linux 2.2.x,
-# Solaris 2.5.1, 2.6).
-# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.
-
-SUPPORTED_OS_VERSION = 5.7 5.8 5.9 5.10 5.11
-OS_VERSION := $(shell uname -r)
-EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
-
-check_os_version:
-ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
-	$(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
-endif
-
-# jvmti.make requires XSLT (J2SE 1.4.x or newer):
-XSLT_CHECK	= $(RUN.JAVAP) javax.xml.transform.TransformerFactory
-# If not found then fail fast.
-check_j2se_version:
-	$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
-	  $(RUN.JAVA) -version; \
-	  echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
-	  "to bootstrap this build" 1>&2; \
-	  exit 1; \
-	fi
-
-$(SUBDIRS_TIERED): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered
-
-$(SUBDIRS_C2): $(BUILDTREE_MAKE)
-ifeq ($(FORCE_TIERED),1)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1
-else
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler2
-endif
-
-$(SUBDIRS_C1): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=compiler1
-
-$(SUBDIRS_CORE): $(BUILDTREE_MAKE)
-	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
-	+$(BUILDTREE) VARIANT=core
-
-# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME
-
-$(TARGETS_C2):  $(SUBDIRS_C2)
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_TIERED):  $(SUBDIRS_TIERED)
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_C1):  $(SUBDIRS_C1)
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-$(TARGETS_CORE):  $(SUBDIRS_CORE)
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
-ifdef INSTALL
-	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
-endif
-
-# Just build the tree, and nothing else:
-tree:      $(SUBDIRS_C2)
-tree1:     $(SUBDIRS_C1)
-treecore:  $(SUBDIRS_CORE)
-
-# Doc target.  This is the same for all build options.
-#     Hence create a docs directory beside ...$(ARCH)_[...]
-# We specify 'BUILD_FLAVOR=product' so that the proper
-# ENABLE_FULL_DEBUG_SYMBOLS value is used.
-docs: checks
-	$(QUIETLY) mkdir -p $(SUBDIR_DOCS)
-	$(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs
-
-# Synonyms for win32-like targets.
-compiler2:  debug product
-
-compiler1:  debug1 product1
-
-core: debugcore productcore
-
-warn_jvmg_deprecated:
-	echo "Warning: The jvmg target has been replaced with debug"
-	echo "Warning: Please update your usage"
-
-jvmg: warn_jvmg_deprecated debug
-
-jvmg1: warn_jvmg_deprecated debug1
-
-jvmgcore: warn_jvmg_deprecated debugcore
-
-clean_docs:
-	rm -rf $(SUBDIR_DOCS)
-
-clean_compiler1 clean_compiler2 clean_core:
-	rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@)
-
-clean:  clean_compiler2 clean_compiler1 clean_core clean_docs
-
-include $(GAMMADIR)/make/cscope.make
-
-#-------------------------------------------------------------------------------
-
-.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE)
-.PHONY: tree tree1 treecore
-.PHONY: all compiler1 compiler2 core
-.PHONY: clean clean_compiler1 clean_compiler2 clean_core docs clean_docs
-.PHONY: checks check_os_version check_j2se_version
-
-.NOTPARALLEL:
diff --git a/hotspot/make/solaris/adlc_updater b/hotspot/make/solaris/adlc_updater
deleted file mode 100644
index 8b1df72..0000000
--- a/hotspot/make/solaris/adlc_updater
+++ /dev/null
@@ -1,23 +0,0 @@
-#! /bin/sh
-#
-# This file is used by adlc.make to selectively update generated
-# adlc files. Because source and target diretories are relative
-# paths, this file is copied to the target build directory before
-# use.
-#
-# adlc-updater <file> <source-dir> <target-dir>
-#
-fix_lines() {
-  # repair bare #line directives in $1 to refer to $2
-  # and add an override of __FILE__ with just the basename on the
-  # first line of the file.
-  nawk < $1 > $1+ -v F2=$2 '
-    BEGIN { print "#line 1 \"" F2 "\""; }
-    /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next}
-    {print}
-  '
-  mv $1+ $1
-}
-fix_lines $2/$1 $1
-[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \
-( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 )
diff --git a/hotspot/make/solaris/makefiles/adjust-mflags.sh b/hotspot/make/solaris/makefiles/adjust-mflags.sh
deleted file mode 100644
index 97bc02d..0000000
--- a/hotspot/make/solaris/makefiles/adjust-mflags.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This script is used only from top.make.
-# The macro $(MFLAGS-adjusted) calls this script to
-# adjust the "-j" arguments to take into account
-# the HOTSPOT_BUILD_JOBS variable.  The default
-# handling of the "-j" argument by gnumake does
-# not meet our needs, so we must adjust it ourselves.
-
-# This argument adjustment applies to two recursive
-# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make.
-# One invokes adlc.make, and the other invokes vm.make.
-# The adjustment propagates the desired concurrency
-# level down to the sub-make (of the adlc or vm).
-# The default behavior of gnumake is to run all
-# sub-makes without concurrency ("-j1").
-
-# Also, we use a make variable rather than an explicit
-# "-j<N>" argument to control this setting, so that
-# the concurrency setting (which must be tuned separately
-# for each MP system) can be set via an environment variable.
-# The recommended setting is 1.5x to 2x the number of available
-# CPUs on the MP system, which is large enough to keep the CPUs
-# busy (even though some jobs may be I/O bound) but not too large,
-# we may presume, to overflow the system's swap space.
-
-set -eu
-
-default_build_jobs=4
-
-case $# in
-[12])	true;;
-*)	>&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;;
-esac
-
-MFLAGS=$1
-HOTSPOT_BUILD_JOBS=${2-}
-
-# Normalize any -jN argument to the form " -j${HBJ}"
-MFLAGS=`
-	echo "$MFLAGS" \
-	| sed '
-		s/^-/ -/
-		s/ -\([^ 	I][^ 	I]*\)j/ -\1 -j/
-		s/ -j[0-9][0-9]*/ -j/
-		s/ -j\([^ 	]\)/ -j -\1/
-		s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/
-	' `
-
-case ${HOTSPOT_BUILD_JOBS} in \
-
-'') case ${MFLAGS} in
-    *\ -j*)
-	>&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." 
-	>&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment."
-    esac;;
-
-?*) case ${MFLAGS} in
-     *\ -j*) true;;
-     *)      MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";;
-    esac;;
-esac
-
-echo "${MFLAGS}"
diff --git a/hotspot/make/solaris/makefiles/adlc.make b/hotspot/make/solaris/makefiles/adlc.make
deleted file mode 100644
index 730a5a3..0000000
--- a/hotspot/make/solaris/makefiles/adlc.make
+++ /dev/null
@@ -1,257 +0,0 @@
-#
-# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This makefile (adlc.make) is included from the adlc.make in the
-# build directories.
-# It knows how to compile, link, and run the adlc.
-
-include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-# #########################################################################
-
-# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
-GENERATED = ../generated
-OUTDIR  = $(GENERATED)/adfiles
-
-ARCH = $(Platform_arch)
-OS = $(Platform_os_family)
-
-SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
-
-ifeq ("${Platform_arch_model}", "${Platform_arch}")
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 
-else
-  SOURCES.AD = \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
-  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 
-endif
-
-EXEC	= $(OUTDIR)/adlc
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor
-Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED)
-INCLUDES += $(Src_Dirs_I:%=-I%)
-
-# set flags for adlc compilation
-CXXFLAGS = $(SYSDEFS) $(INCLUDES)
-
-# Force assertions on.
-CXXFLAGS += -DASSERT
-
-ifndef USE_GCC
-  # We need libCstd.so for adlc
-  CFLAGS += -library=Cstd -g
-  LFLAGS += -library=Cstd -g
-endif
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-CFLAGS_WARN = +w
-# Compiler warnings are treated as errors
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-  WARNINGS_ARE_ERRORS ?= -xwe
-endif
-
-CFLAGS_WARN += $(WARNINGS_ARE_ERRORS)
-
-# When using compiler version 5.13 (Solaris Studio 12.4), calls to explicitly
-# instantiated template functions trigger this warning when +w is active.
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 513), 1)
-  CFLAGS_WARN += -erroff=notemsource
-endif
-CFLAGS += $(CFLAGS_WARN)
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-# Enable the following CFLAGS addition if you need to compare the
-# built ELF objects.
-#
-# The -g option makes static data global and the "-Qoption ccfe
-# -xglobalstatic" option tells the compiler to not globalize static
-# data using a unique globalization prefix. Instead force the use
-# of a static globalization prefix based on the source filepath so
-# the objects from two identical compilations are the same.
-#CFLAGS += -Qoption ccfe -xglobalstatic
-endif # Platform_compiler == sparcWorks
-
-OBJECTNAMES = \
-	adlparse.o \
-	archDesc.o \
-	arena.o \
-	dfa.o \
-	dict2.o \
-	filebuff.o \
-	forms.o \
-	formsopt.o \
-	formssel.o \
-	main.o \
-	adlc-opcodes.o \
-	output_c.o \
-	output_h.o \
-
-OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)
-
-GENERATEDNAMES = \
-        ad_$(Platform_arch_model).cpp \
-        ad_$(Platform_arch_model).hpp \
-        ad_$(Platform_arch_model)_clone.cpp \
-        ad_$(Platform_arch_model)_expand.cpp \
-        ad_$(Platform_arch_model)_format.cpp \
-        ad_$(Platform_arch_model)_gen.cpp \
-        ad_$(Platform_arch_model)_misc.cpp \
-        ad_$(Platform_arch_model)_peephole.cpp \
-        ad_$(Platform_arch_model)_pipeline.cpp \
-        adGlobals_$(Platform_arch_model).hpp \
-        dfa_$(Platform_arch_model).cpp \
-
-GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)
-
-# #########################################################################
-
-all: $(EXEC)
-
-$(EXEC) : $(OBJECTS)
-	@echo $(LOG_INFO) Making adlc
-	$(QUIETLY) $(LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS)
-
-# Random dependencies:
-$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
-
-# The source files refer to ostream.h, which sparcworks calls iostream.h
-$(OBJECTS): ostream.h
-
-ostream.h :
-	@echo >$@ '#include <iostream.h>'
-
-dump:
-	: OUTDIR=$(OUTDIR)
-	: OBJECTS=$(OBJECTS)
-	: products = $(GENERATEDFILES)
-
-all: $(GENERATEDFILES)
-
-$(GENERATEDFILES): refresh_adfiles
-
-# Get a unique temporary directory name, so multiple makes can run in parallel.
-# Note that product files are updated via "mv", which is atomic.
-TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)
-
-# Debuggable by default
-CFLAGS += -g
-
-# Pass -D flags into ADLC.
-ADLCFLAGS += $(SYSDEFS)
-
-# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
-ADLCFLAGS += -q -T
-
-# Normally, debugging is done directly on the ad_<arch>*.cpp files.
-# But -g will put #line directives in those files pointing back to <arch>.ad.
-ADLCFLAGS += -g
-
-ifdef LP64
-ADLCFLAGS += -D_LP64
-else
-ADLCFLAGS += -U_LP64
-endif
-
-#
-# adlc_updater is a simple sh script, under sccs control. It is
-# used to selectively update generated adlc files. This should
-# provide a nice compilation speed improvement.
-#
-ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
-ADLC_UPDATER = adlc_updater
-$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
-	$(QUIETLY) cp $< $@; chmod +x $@
-
-# This action refreshes all generated adlc files simultaneously.
-# The way it works is this:
-# 1) create a scratch directory to work in.
-# 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
-# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
-# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
-# 5) If we actually updated any files, echo a notice.
-#
-refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
-	@rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
-	$(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
- -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \
-	    || { rm -rf $(TEMPDIR); exit 1; }
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
-	$(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
-		|| echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes."
-	$(QUIETLY) rm -rf $(TEMPDIR)
-
-
-# #########################################################################
-
-$(SOURCE.AD): $(SOURCES.AD)
-	$(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)
-
-#PROCESS_AD_FILES = cat
-# Pass through #line directives, in case user enables -g option above:
-PROCESS_AD_FILES = awk '{ \
-    if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
-    if (need_lineno && $$0 !~ /\/\//) \
-      { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
-    print }'
-
-$(OUTDIR)/%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
-
-# Some object files are given a prefix, to disambiguate
-# them from objects of the same name built for the VM.
-$(OUTDIR)/adlc-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
-
-# #########################################################################
-
-clean	:
-	rm $(OBJECTS)
-
-cleanall :
-	rm $(OBJECTS) $(EXEC)
-
-# #########################################################################
-
-.PHONY: all dump refresh_adfiles clean cleanall
diff --git a/hotspot/make/solaris/makefiles/amd64.make b/hotspot/make/solaris/makefiles/amd64.make
deleted file mode 100644
index 3eb6dee..0000000
--- a/hotspot/make/solaris/makefiles/amd64.make
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Must also specify if CPU is little endian
-CFLAGS += -DVM_LITTLE_ENDIAN
-
-#
-# Special case flags for compilers and compiler versions on amd64.
-#
-ifeq ("${Platform_compiler}", "sparcWorks")
-
-# Temporary until SS10 C++ compiler is fixed
-OPT_CFLAGS/generateOptoStub.o = -xO2
-# Temporary util SS12u1 C++ compiler is fixed
-OPT_CFLAGS/c1_LinearScan.o = -xO2
-
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  OPT_CFLAGS/generateOptoStub.o += -g0 -xs
-  OPT_CFLAGS/c1_LinearScan.o += -g0 -xs
-endif
-
-else
-
-ifeq ("${Platform_compiler}", "gcc")
-# gcc
-# The serviceability agent relies on frame pointer (%rbp) to walk thread stack
-CFLAGS += -fno-omit-frame-pointer
-
-else
-# error
-_JUNK2_ := $(shell echo >&2 \
-       "*** ERROR: this compiler is not yet supported by this code base!")
-       @exit 1
-endif
-endif
diff --git a/hotspot/make/solaris/makefiles/build_vm_def.sh b/hotspot/make/solaris/makefiles/build_vm_def.sh
deleted file mode 100644
index 7f86953..0000000
--- a/hotspot/make/solaris/makefiles/build_vm_def.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-/usr/ccs/bin/nm -p $* \
-    | awk '{
-          if ($2 == "U") next
-          if ($3 ~ /^__1c.*__vtbl_$/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";"
-          if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";"
-          if ($3 ~ /^__1cJArgumentsRSharedArchivePath_$/) print "\t" $3 ";"
-          }' \
-    | sort -u
diff --git a/hotspot/make/solaris/makefiles/buildtree.make b/hotspot/make/solaris/makefiles/buildtree.make
deleted file mode 100644
index 905eaa0..0000000
--- a/hotspot/make/solaris/makefiles/buildtree.make
+++ /dev/null
@@ -1,354 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Usage:
-#
-# $(MAKE) -f buildtree.make ARCH=arch BUILDARCH=buildarch LIBARCH=libarch
-#         GAMMADIR=dir OS_FAMILY=os VARIANT=variant
-#
-# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the
-# environment or on the command-line:
-#
-# ARCH		- sparc, i486, ... HotSpot cpu and os_cpu source directory
-# BUILDARCH     - build directory
-# LIBARCH       - the corresponding directory in JDK/JRE
-# GAMMADIR	- top of workspace
-# OS_FAMILY	- operating system
-# VARIANT	- core, compiler1, compiler2, or tiered
-# VERSION_STRING - the JDK version string as specified by JEP-223
-# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build
-#
-# Builds the directory trees with makefiles plus some convenience files in
-# each directory:
-#
-# Makefile	- for "make foo"
-# flags.make	- with macro settings
-# vm.make	- to support making "$(MAKE) -v vm.make" in makefiles
-# adlc.make	-
-# trace.make	- generate tracing event and type definitions
-# jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
-#
-# The makefiles are split this way so that "make foo" will run faster by not
-# having to read the dependency files for the vm.
-
--include $(SPEC)
-include $(GAMMADIR)/make/scm.make
-include $(GAMMADIR)/make/defs.make
-include $(GAMMADIR)/make/altsrc.make
-
-
-# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)	= @
-
-### maye ARCH_XXX instead?
-ifdef USE_GCC
-PLATFORM_FILE	= $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).gcc
-GCC_LIB         = /usr/local/lib
-else
-PLATFORM_FILE	= $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
-GCC_LIB         =
-endif
-
-ifdef FORCE_TIERED
-ifeq		($(VARIANT),tiered)
-PLATFORM_DIR	= $(OS_FAMILY)_$(BUILDARCH)_compiler2
-else
-PLATFORM_DIR	= $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT)
-endif
-else
-PLATFORM_DIR    = $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT)
-endif
-
-#
-# We do two levels of exclusion in the shared directory.
-# TOPLEVEL excludes are pruned, they are not recursively searched,
-# but lower level directories can be named without fear of collision.
-# ALWAYS excludes are excluded at any level in the directory tree.
-#
-
-ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
-
-ifeq		($(VARIANT),tiered)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
-else
-ifeq		($(VARIANT),compiler2)
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
-else
-# compiler1 and core use the same exclude list
-TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
-endif
-endif
-
-# Get things from the platform file.
-COMPILER	= $(shell sed -n 's/^compiler[ 	]*=[ 	]*//p' $(PLATFORM_FILE))
-
-SIMPLE_DIRS	= \
-	$(PLATFORM_DIR)/generated/dependencies \
-	$(PLATFORM_DIR)/generated/adfiles \
-	$(PLATFORM_DIR)/generated/jvmtifiles \
-	$(PLATFORM_DIR)/generated/tracefiles
-
-TARGETS      = debug fastdebug optimized product
-SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
-
-# For dependencies and recursive makes.
-BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
-
-BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make dtrace.make
-
-BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
-	ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
-
-# Define variables to be set in flags.make.
-# Default values are set in make/defs.make.
-
-# Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
-endif
-ifndef HOTSPOT_BUILD_USER
-  HOTSPOT_BUILD_USER := $(shell whoami)
-endif
-# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
-# or make/hotspot_distro.
-ifndef HOTSPOT_VM_DISTRO
-  ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    include $(GAMMADIR)/make/hotspot_distro
-  else
-    include $(GAMMADIR)/make/openjdk_distro
-  endif
-endif
-
-# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
-ifndef OPENJDK
-  ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
-    OPENJDK=true
-  endif
-endif
-
-BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
-
-BUILDTREE	= \
-	$(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
-
-BUILDTREE_COMMENT	= echo "\# Generated by $(BUILDTREE_MAKE)"
-
-all:  $(SUBMAKE_DIRS)
-
-# Run make in each subdirectory recursively.
-$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
-	$(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
-	+$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
-	$(QUIETLY) touch $@
-
-$(SIMPLE_DIRS):
-	$(QUIETLY) mkdir -p $@
-
-# Convenience macro which takes a source relative path, applies $(1) to the
-# absolute path, and then replaces $(GAMMADIR) in the result with a
-# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.
-gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
-
-# This bit is needed to enable local rebuilds.
-# Unless the makefile itself sets LP64, any environmental
-# setting of LP64 will interfere with the build.
-LP64_SETTING/32 = LP64 = \#empty
-LP64_SETTING/64 = LP64 = 1
-
-DATA_MODE/i486 = 32
-DATA_MODE/sparc = 32
-DATA_MODE/sparcv9 = 64
-DATA_MODE/amd64 = 64
-
-DATA_MODE = $(DATA_MODE/$(BUILDARCH))
-
-flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
-	sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
-	echo; \
-	echo "GAMMADIR = $(GAMMADIR)"; \
-	echo "SYSDEFS = \$$(Platform_sysdefs)"; \
-	echo "SRCARCH = $(ARCH)"; \
-	echo "BUILDARCH = $(BUILDARCH)"; \
-	echo "LIBARCH = $(LIBARCH)"; \
-	echo "TARGET = $(TARGET)"; \
-	echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \
-	echo "VERSION_STRING = $(VERSION_STRING)"; \
-	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
-	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
-	echo "OPENJDK = $(OPENJDK)"; \
-	echo "$(LP64_SETTING/$(DATA_MODE))"; \
-	echo; \
-	echo "# Used for platform dispatching"; \
-	echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
-	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
-	echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
-	echo "CFLAGS += \$$(TARGET_DEFINES)"; \
-	echo; \
-	echo "Src_Dirs_V = \\"; \
-	sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
-	echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	echo; \
-	echo "Src_Dirs_I = \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm) \\"; \
-	echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
-	echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
-	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
-	[ -n "$(CFLAGS_BROWSE)" ] && \
-	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
-	[ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
-	    echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
-	[ -n "$(OBJCOPY)" ] && \
-	    echo && echo "OBJCOPY = $(OBJCOPY)"; \
-	[ -n "$(STRIP_POLICY)" ] && \
-	    echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
-	[ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
-	    echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
-	[ -n "$(ZIPEXE)" ] && \
-	    echo && echo "ZIPEXE = $(ZIPEXE)"; \
-	[ -n "$(HS_ALT_MAKE)" ] && \
-	    echo && echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
-	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
-	    echo && \
-	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
-	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
-	echo; \
-	[ -n "$(SPEC)" ] && \
-	    echo "include $(SPEC)"; \
-	echo "CP ?= cp"; \
-	echo "MV ?= mv"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
-	echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
-	) > $@
-
-flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
-	) > $@
-
-../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
-	@echo $(LOG_INFO) Creating directory list $@
-	$(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
-          find $(HS_ALT_SRC)/share/vm/* -prune \
-	  -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-          \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
-        fi;
-	$(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
-	-type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
-
-Makefile: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
-	) > $@
-
-vm.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo include flags_vm.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-adlc.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-jvmti.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-trace.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-dtrace.make: $(BUILDTREE_MAKE)
-	@echo $(LOG_INFO) Creating $@ ...
-	$(QUIETLY) ( \
-	$(BUILDTREE_COMMENT); \
-	echo; \
-	echo include flags.make; \
-	echo; \
-	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
-	) > $@
-
-FORCE:
-
-.PHONY:  all FORCE
-
-.NOTPARALLEL:
diff --git a/hotspot/make/solaris/makefiles/compiler1.make b/hotspot/make/solaris/makefiles/compiler1.make
deleted file mode 100644
index d303bfc..0000000
--- a/hotspot/make/solaris/makefiles/compiler1.make
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making client version of VM
-
-TYPE=COMPILER1
-
-VM_SUBDIR = client
-
-# We don't support the JVMCI in a client VM.
-INCLUDE_JVMCI := false
-
-CFLAGS += -DCOMPILER1
diff --git a/hotspot/make/solaris/makefiles/compiler2.make b/hotspot/make/solaris/makefiles/compiler2.make
deleted file mode 100644
index c881079..0000000
--- a/hotspot/make/solaris/makefiles/compiler2.make
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making server version of VM
-
-TYPE=COMPILER2
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2
diff --git a/hotspot/make/solaris/makefiles/core.make b/hotspot/make/solaris/makefiles/core.make
deleted file mode 100644
index 6440055..0000000
--- a/hotspot/make/solaris/makefiles/core.make
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 1998, 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.
-#  
-#
-
-# Sets make macros for making core version of VM
-
-# Select which files to use (in top.make)
-TYPE=CORE
-
-# There is no "core" directory in JDK. Install core build in server directory.
-VM_SUBDIR = server
-
-# Note:  macros.hpp defines CORE
diff --git a/hotspot/make/solaris/makefiles/debug.make b/hotspot/make/solaris/makefiles/debug.make
deleted file mode 100644
index 3fba8e1..0000000
--- a/hotspot/make/solaris/makefiles/debug.make
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS)
-DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-
-ifeq ($(COMPILER_REV_NUMERIC),508)
-  # SS11 SEGV when compiling with -g and -xarch=v8, using different backend
-  DEBUG_CFLAGS/compileBroker.o = $(DEBUG_CFLAGS) -xO0
-  DEBUG_CFLAGS/jvmtiTagMap.o   = $(DEBUG_CFLAGS) -xO0
-endif
-endif
-
-# _NMT_NOINLINE_ informs NMT that no inlining by Compiler
-CFLAGS += $(DEBUG_CFLAGS/BYFILE) -D_NMT_NOINLINE_
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfiles
-MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \
-          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug
-
-# This mapfile is only needed when compiling with dtrace support,
-# and mustn't be otherwise.
-MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE)
-
-VERSION = debug
-SYSDEFS += -DASSERT
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/solaris/makefiles/defs.make b/hotspot/make/solaris/makefiles/defs.make
deleted file mode 100644
index f6b913a..0000000
--- a/hotspot/make/solaris/makefiles/defs.make
+++ /dev/null
@@ -1,279 +0,0 @@
-#
-# Copyright (c) 2006, 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
-# 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.
-#
-#
-
-# The common definitions for hotspot solaris builds.
-# Include the top level defs.make under make directory instead of this one.
-# This file is included into make/defs.make.
-
-define print_info
-  ifneq ($$(LOG_LEVEL), warn)
-    $$(shell echo >&2 "INFO: $1")
-  endif
-endef
-
-# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name
-SLASH_JAVA ?= /java
-ARCH:=$(shell uname -p)
-PATH_SEP = :
-ifeq ($(LP64), 1)
-  ARCH_DATA_MODEL=64
-else
-  ARCH_DATA_MODEL=32
-endif
-
-ifeq ($(ARCH),sparc)
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    MAKE_ARGS += LP64=1
-    PLATFORM=solaris-sparcv9
-    VM_PLATFORM=solaris_sparcv9
-  else
-    PLATFORM=solaris-sparc
-    VM_PLATFORM=solaris_sparc
-  endif
-  HS_ARCH=sparc
-else
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    MAKE_ARGS += LP64=1
-    PLATFORM=solaris-amd64
-    VM_PLATFORM=solaris_amd64
-    HS_ARCH=x86
-  else
-    PLATFORM=solaris-i586
-    VM_PLATFORM=solaris_i486
-    HS_ARCH=x86
-  endif
-endif
-
-# On 32 bit solaris we build server and client, on 64 bit just server.
-ifeq ($(JVM_VARIANTS),)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    JVM_VARIANTS:=client,server
-    JVM_VARIANT_CLIENT:=true
-    JVM_VARIANT_SERVER:=true
-  else
-    JVM_VARIANTS:=server
-    JVM_VARIANT_SERVER:=true
-  endif
-endif
-
-# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product
-# builds is enabled with debug info files ZIP'ed to save space. For
-# BUILD_FLAVOR != product builds, FDS is always enabled, after all a
-# debug build without debug info isn't very useful.
-# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled.
-#
-# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
-# disabled for a BUILD_FLAVOR == product build.
-#
-# Note: Use of a different variable name for the FDS override option
-# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
-# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
-# in options via environment variables, use of distinct variables
-# prevents strange behaviours. For example, in a BUILD_FLAVOR !=
-# product build, the FULL_DEBUG_SYMBOLS environment variable will be
-# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If
-# the same variable name is used, then different values can be picked
-# up by different parts of the build. Just to be clear, we only need
-# two variable names because the incoming option value can be
-# overridden in some situations, e.g., a BUILD_FLAVOR != product
-# build.
-
-# Due to the multiple sub-make processes that occur this logic gets
-# executed multiple times. We reduce the noise by at least checking that
-# BUILD_FLAVOR has been set.
-ifneq ($(BUILD_FLAVOR),)
-  ifeq ($(BUILD_FLAVOR), product)
-    FULL_DEBUG_SYMBOLS ?= 1
-    ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
-  else
-    # debug variants always get Full Debug Symbols (if available)
-    ENABLE_FULL_DEBUG_SYMBOLS = 1
-  endif
-  $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-  # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    # Default OBJCOPY comes from the SUNWbinutils package:
-    DEF_OBJCOPY=/usr/sfw/bin/gobjcopy
-    OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
-    ifneq ($(ALT_OBJCOPY),)
-      $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)"))
-      OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
-    endif
-
-    ifneq ($(OBJCOPY),)
-      # OBJCOPY version check:
-      # - version number is last blank separate word on first line
-      # - version number formats that have been seen:
-      #   - <major>.<minor>
-      #   - <major>.<minor>.<micro>
-      #
-      # Full Debug Symbols on Solaris needs version 2.21.1 or newer.
-      #
-      OBJCOPY_VERS_CHK := $(shell \
-        $(OBJCOPY) --version \
-          | sed -n \
-                -e 's/.* //' \
-                -e '/^[01]\./b bad' \
-                -e '/^2\./{' \
-                -e '  s/^2\.//' \
-                -e '  /^[0-9]$$/b bad' \
-                -e '  /^[0-9]\./b bad' \
-                -e '  /^1[0-9]$$/b bad' \
-                -e '  /^1[0-9]\./b bad' \
-                -e '  /^20\./b bad' \
-                -e '  /^21\.0$$/b bad' \
-                -e '  /^21\.0\./b bad' \
-                -e '}' \
-                -e ':good' \
-                -e 's/.*/VALID_VERSION/p' \
-                -e 'q' \
-                -e ':bad' \
-                -e 's/.*/BAD_VERSION/p' \
-                -e 'q' \
-        )
-      ifeq ($(OBJCOPY_VERS_CHK),BAD_VERSION)
-        _JUNK_ := $(shell \
-          echo >&2 "WARNING: $(OBJCOPY) --version info:"; \
-          $(OBJCOPY) --version | sed -n -e 's/^/WARNING: /p' -e 'q' >&2; \
-          echo >&2 "WARNING: an objcopy version of 2.21.1 or newer" \
-            "is needed to create valid .debuginfo files."; \
-          echo >&2 "WARNING: ignoring above objcopy command."; \
-          echo >&2 "WARNING: patch 149063-01 or newer contains the" \
-            "correct Solaris 10 SPARC version."; \
-          echo >&2 "WARNING: patch 149064-01 or newer contains the" \
-            "correct Solaris 10 X86 version."; \
-          echo >&2 "WARNING: Solaris 11 Update 1 contains the" \
-            "correct version."; \
-          )
-        OBJCOPY=
-      endif
-    endif
-
-    ifeq ($(OBJCOPY),)
-      $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files."))
-      ENABLE_FULL_DEBUG_SYMBOLS=0
-      $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
-    else
-      $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo files."))
-
-      # Library stripping policies for .debuginfo configs:
-      #   all_strip - strips everything from the library
-      #   min_strip - strips most stuff from the library; leaves minimum symbols
-      #   no_strip  - does not strip the library at all
-      #
-      # Oracle security policy requires "all_strip". A waiver was granted on
-      # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
-      #
-      # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled.
-      #
-      STRIP_POLICY ?= min_strip
-
-      $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)"))
-
-      ZIP_DEBUGINFO_FILES ?= 1
-
-      $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)"))
-    endif
-  endif # ENABLE_FULL_DEBUG_SYMBOLS=1
-endif # BUILD_FLAVOR
-
-JDK_INCLUDE_SUBDIR=solaris
-
-# Library suffix
-LIBRARY_SUFFIX=so
-
-EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
-
-# client and server subdirectories have symbolic links to ../libjsig.$(LIBRARY_SUFFIX)
-EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-    EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz
-  else
-    EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo
-  endif
-endif
-
-EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server
-EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client
-
-ifeq ($(JVM_VARIANT_SERVER),true)
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.$(LIBRARY_SUFFIX)
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX)
-  ifeq ($(ARCH_DATA_MODEL),32)
-    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX)
-    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX)
-  endif
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.diz
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.diz
-      ifeq ($(ARCH_DATA_MODEL),32)
-        EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.diz
-        EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.diz
-      endif
-    else
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.debuginfo
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.debuginfo
-      ifeq ($(ARCH_DATA_MODEL),32)
-        EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.debuginfo
-        EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.debuginfo
-      endif
-    endif
-  endif
-endif
-ifeq ($(JVM_VARIANT_CLIENT),true)
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.$(LIBRARY_SUFFIX)
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX)
-  ifeq ($(ARCH_DATA_MODEL),32)
-    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX)
-    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX)
-  endif
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.diz
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.diz
-      ifeq ($(ARCH_DATA_MODEL),32)
-        EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.diz
-        EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.diz
-      endif
-    else
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.debuginfo
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.debuginfo
-      ifeq ($(ARCH_DATA_MODEL),32)
-        EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.debuginfo
-        EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.debuginfo
-      endif
-    endif
-  endif
-endif
diff --git a/hotspot/make/solaris/makefiles/dtrace.make b/hotspot/make/solaris/makefiles/dtrace.make
deleted file mode 100644
index 2c65059..0000000
--- a/hotspot/make/solaris/makefiles/dtrace.make
+++ /dev/null
@@ -1,387 +0,0 @@
-#
-# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#  
-#
-
-# Rules to build jvm_db/dtrace, used by vm.make
-
-# We build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2
-# but not for CORE configuration.
-
-ifneq ("${TYPE}", "CORE")
-
-ifdef USE_GCC
-
-dtraceCheck:
-	$(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled for gcc builds"
-
-else
-
-DtraceOutDir = $(GENERATED)/dtracefiles
-
-JVM_DB = libjvm_db
-LIBJVM_DB = libjvm_db.so
-
-LIBJVM_DB_DEBUGINFO   = libjvm_db.debuginfo
-LIBJVM_DB_DIZ         = libjvm_db.diz
-
-JVM_DTRACE = jvm_dtrace
-LIBJVM_DTRACE = libjvm_dtrace.so
-
-LIBJVM_DTRACE_DEBUGINFO   = libjvm_dtrace.debuginfo
-LIBJVM_DTRACE_DIZ         = libjvm_dtrace.diz
-
-JVMOFFS = JvmOffsets
-JVMOFFS.o = $(JVMOFFS).o
-GENOFFS = generate$(JVMOFFS)
-
-DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace
-DTRACE_COMMON_SRCDIR = $(GAMMADIR)/src/os/posix/dtrace
-DTRACE = dtrace
-DTRACE.o = $(DTRACE).o
-DTRACE_JHELPER = dtrace_jhelper
-DTRACE_JHELPER.o = $(DTRACE_JHELPER).o
-
-# to remove '-g' option which causes link problems
-# also '-z nodefs' is used as workaround
-GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';)
-
-ifdef LP64
-DTRACE_OPTS = -64 -D_LP64
-endif
-
-# making libjvm_db
-
-# Use mapfile with libjvm_db.so
-LIBJVM_DB_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jvm_db
-LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE))
-
-# Use mapfile with libjvm_dtrace.so
-LIBJVM_DTRACE_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace
-LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE))
-
-ifdef USE_GCC
-LFLAGS_JVM_DB += -D_REENTRANT $(PICFLAG)
-LFLAGS_JVM_DTRACE += -D_REENTRANT $(PICFLAG)
-else
-LFLAGS_JVM_DB += -mt $(PICFLAG) -xnolib
-LFLAGS_JVM_DTRACE += -mt $(PICFLAG) -xnolib -ldl
-endif
-
-ISA = $(subst i386,i486,$(shell isainfo -n))
-
-# Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so
-ifneq ("${ISA}","${BUILDARCH}")
-
-XLIBJVM_DIR = 64
-XLIBJVM_DB = $(XLIBJVM_DIR)/$(LIBJVM_DB)
-XLIBJVM_DTRACE = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE)
-
-XLIBJVM_DB_DEBUGINFO       = $(XLIBJVM_DIR)/$(LIBJVM_DB_DEBUGINFO)
-XLIBJVM_DB_DIZ             = $(XLIBJVM_DIR)/$(LIBJVM_DB_DIZ)
-XLIBJVM_DTRACE_DEBUGINFO   = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DEBUGINFO)
-XLIBJVM_DTRACE_DIZ         = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DIZ)
-
-$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
-	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. -I$(GENERATED) \
-		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DB_DEBUGINFO)
-# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
-# in the link name:
-	( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) )
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
-# in the archived name:
-	( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) )
-	$(RM) $(XLIBJVM_DB_DEBUGINFO)
-  endif
-endif
-
-$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
-	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. $(EXTRA_CFLAGS) \
-	    $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c \
-	    $(EXTRA_LDFLAGS) -lc -lthread -ldoor
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DTRACE_DEBUGINFO)
-# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
-# in the link name:
-	( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) )
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
-# in the archived name:
-	( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO))
-	$(RM) $(XLIBJVM_DTRACE_DEBUGINFO)
-  endif
-endif
-
-endif # ifneq ("${ISA}","${BUILDARCH}")
-
-ifdef USE_GCC
-LFLAGS_GENOFFS += -D_REENTRANT
-else
-LFLAGS_GENOFFS += -mt -xnolib -norunpath
-endif
-
-lib$(GENOFFS).so: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
-                  $(LIBJVM.o)
-	$(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
-		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -lc
-
-$(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).so
-	$(QUIETLY) $(LINK.CXX) -z nodefs -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
-		./lib$(GENOFFS).so
-
-CONDITIONALLY_UPDATE_JVMOFFS_TARGET = \
-	if cmp -s $@ $@.tmp; then \
-	  rm -f $@.tmp; \
-	else \
-	  rm -f $@ && mv $@.tmp $@ && echo Updated $@; \
-	fi
-
-# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
-$(JVMOFFS).h: $(GENOFFS)
-	$(QUIETLY) LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./$(GENOFFS) -header > $@.tmp
-	$(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET)
-
-$(JVMOFFS)Index.h: $(GENOFFS)
-	$(QUIETLY) LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./$(GENOFFS) -index > $@.tmp
-	$(QUIETLY)  $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET)
-
-$(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
-	$(QUIETLY) LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./$(GENOFFS) -table > $@.tmp
-	$(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET)
-
-$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
-	$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
-
-$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
-		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DB_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO)
-	$(RM) $(LIBJVM_DB_DEBUGINFO)
-  endif
-endif
-
-$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
-	@echo $(LOG_INFO) Making $@
-	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. $(EXTRA_CFLAGS) \
-	    $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c \
-	    $(EXTRA_LDFLAGS) -lc -lthread -ldoor
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DTRACE_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) 
-	$(RM) $(LIBJVM_DTRACE_DEBUGINFO)
-  endif
-endif
-
-$(DTRACE).d: $(DTRACE_COMMON_SRCDIR)/hotspot.d $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d \
-             $(DTRACE_COMMON_SRCDIR)/hs_private.d
-	$(QUIETLY) cat $^ > $@
-
-$(DTRACE_JHELPER).d: $(DTRACE_SRCDIR)/jhelper.d
-	$(QUIETLY) cat $^ > $@
-
-DTraced_Files = ciEnv.o \
-                classLoadingService.o \
-                compileBroker.o \
-                hashtable.o \
-                instanceKlass.o \
-                java.o \
-                jni.o \
-                jvm.o \
-                memoryManager.o \
-                nmethod.o \
-                objectMonitor.o \
-                runtimeService.o \
-                sharedRuntime.o \
-                synchronizer.o \
-                thread.o \
-                unsafe.o \
-                vmThread.o \
-                vmCMSOperations.o \
-                vmPSOperations.o \
-                vmGCOperations.o \
-
-# Dtrace is available, so we build $(DTRACE.o)  
-$(DTRACE.o): $(DTRACE).d $(DTraced_Files)
-	@echo $(LOG_INFO) Compiling $(DTRACE).d
-
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -xlazyload -o $@ -s $(DTRACE).d \
-     $(sort $(DTraced_Files)) ||\
-  STATUS=$$?;\
-  if [ x"$$STATUS" = x"1" ]; then \
-      if [ x`uname -r` = x"5.10" -a \
-           x`uname -p` = x"sparc" ]; then\
-    echo "*****************************************************************";\
-    echo "* If you are building server compiler, and the error message is ";\
-    echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\
-    echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\
-    echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\
-    echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\
-    echo "* dtrace probes for this build.";\
-    echo "*****************************************************************";\
-      elif [ x`uname -r` = x"5.10" ]; then\
-    echo "*****************************************************************";\
-    echo "* If you are seeing 'syntax error near \"umpiconninfo_t\"' on Solaris";\
-    echo "* 10, try doing 'cd /usr/lib/dtrace && gzip mpi.d' as root, ";\
-    echo "* or set the environment variable HOTSPOT_DISABLE_DTRACE_PROBES";\
-    echo "* to disable dtrace probes for this build.";\
-    echo "*****************************************************************";\
-      else \
-    echo "*****************************************************************";\
-    echo "* If you cannot fix dtrace build issues, try to ";\
-    echo "* set the environment variable HOTSPOT_DISABLE_DTRACE_PROBES";\
-    echo "* to disable dtrace probes for this build.";\
-    echo "*****************************************************************";\
-      fi; \
-  fi;\
-  exit $$STATUS
-  # Since some DTraced_Files are in LIBJVM.o and they are touched by this
-  # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will
-  # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets*
-  # files, but it doesn't, so we touch the necessary files to prevent later
-  # recompilation. Note: we only touch the necessary files if they already
-  # exist in order to close a race where an empty file can be created
-  # before the real build rule is executed.
-  # But, we can't touch the *.h files:  This rule depends
-  # on them, and that would cause an infinite cycle of rebuilding.
-  # Neither the *.h or *.ccp files need to be touched, since they have
-  # rules which do not update them when the generator file has not
-  # changed their contents.
-	$(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi
-	$(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
-	$(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
-
-
-$(DtraceOutDir):
-	mkdir $(DtraceOutDir)
-
-$(DtraceOutDir)/hotspot.h: $(DTRACE_COMMON_SRCDIR)/hotspot.d | $(DtraceOutDir)
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot.d
-
-$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d
-
-$(DtraceOutDir)/hs_private.h: $(DTRACE_COMMON_SRCDIR)/hs_private.d | $(DtraceOutDir)
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hs_private.d
-
-dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h
-
-# The jhelper.d and hotspot probes are separated into two different SUNW_dof sections.
-# Now the jhelper.d is built without the -Xlazyload flag.
-$(DTRACE_JHELPER.o) : $(DTRACE_JHELPER).d $(JVMOFFS).h $(JVMOFFS)Index.h
-	@echo $(LOG_INFO) Compiling $(DTRACE_JHELPER).d
-	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -o $@ -s $(DTRACE_JHELPER).d
-
-.PHONY: dtraceCheck
-
-SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
-PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
-systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
-patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
-
-ifneq ("$(patchDtraceFound)", "")
-DTRACE_PROG=$(PATCH_DTRACE_PROG)
-DTRACE_INCL=-I/opt/SUNWdtrd/include
-else
-ifneq ("$(systemDtraceFound)", "")
-DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
-else
-
-endif # ifneq ("$(systemDtraceFound)", "")
-endif # ifneq ("$(patchDtraceFound)", "")
-
-ifneq ("${DTRACE_PROG}", "")
-ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
-
-DTRACE_OBJS = $(DTRACE.o) $(JVMOFFS.o) $(DTRACE_JHELPER.o)
-CFLAGS += $(DTRACE_INCL) -DDTRACE_ENABLED
-MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE)
-
-dtraceCheck:
-
-else # manually disabled
-
-dtraceCheck:
-	$(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled via environment variable"
-
-endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
-
-else # No dtrace program found
-
-dtraceCheck:
-	$(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled: not supported by system"
-
-endif # ifneq ("${dtraceFound}", "")
-
-endif # ifdef USE_GCC
-
-else # CORE build
-
-dtraceCheck:
-	$(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled for CORE builds"
-
-endif # ifneq ("${TYPE}", "CORE")
diff --git a/hotspot/make/solaris/makefiles/fastdebug.make b/hotspot/make/solaris/makefiles/fastdebug.make
deleted file mode 100644
index 3719c3e..0000000
--- a/hotspot/make/solaris/makefiles/fastdebug.make
+++ /dev/null
@@ -1,127 +0,0 @@
-#
-# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# Sets make macros for making debug version of VM
-
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS.
-
-FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-OPT_CFLAGS/SLOWER = -xO2
-
-ifeq ($(COMPILER_REV_NUMERIC), 510)
-# Avoid apparent crash because of corrupted methodHandle in a tail call
-OPT_CFLAGS/simpleThresholdPolicy.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT)
-# CC 5.10 has bug XXXXX with -xO4
-OPT_CFLAGS/jvmtiClassFileReconstituter.o = $(OPT_CFLAGS/SLOWER)
-endif # COMPILER_REV_NUMERIC == 510
-
-ifeq ($(COMPILER_REV_NUMERIC), 509)
-# To avoid jvm98 crash
-OPT_CFLAGS/instanceKlass.o = $(OPT_CFLAGS/SLOWER)
-endif # COMPILER_NUMERIC_REV == 509
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-# dtrace cannot handle tail call optimization (6672627, 6693876)
-OPT_CFLAGS/jni.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT)
-# this hangs in iropt now (7113504)
-OPT_CFLAGS/compileBroker.o = $(OPT_CFLAGS/SLOWER)
-endif # COMPILER_NUMERIC_REV >= 509
-
-ifeq ($(COMPILER_REV_NUMERIC), 505)
-# CC 5.5 has bug 4908364 with -xO4  (Fixed in 5.6)
-OPT_CFLAGS/library_call.o = $(OPT_CFLAGS/SLOWER)
-endif # COMPILER_REV_NUMERIC == 505
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \<= 504), 1)
-# Compilation of *_<arch>.cpp can take an hour or more at O3.  Use O2
-# See comments at top of sparc.make.
-OPT_CFLAGS/ad_$(Platform_arch_model).o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/dfa_$(Platform_arch_model).o = $(OPT_CFLAGS/SLOWER)
-endif # COMPILER_REV_NUMERIC <= 504
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 505), 1)
-# Same problem with Solaris/x86 compiler (both 5.0 and 5.2) on ad_x86_{32,64}.cpp.
-# CC build time is also too long for ad_$(Platform_arch_model)_{gen,misc}.o
-OPT_CFLAGS/ad_$(Platform_arch_model).o = -c
-OPT_CFLAGS/ad_$(Platform_arch_model)_gen.o = -c
-OPT_CFLAGS/ad_$(Platform_arch_model)_misc.o = -c
-ifeq ($(Platform_arch), x86)
-# Same problem for the wrapper roosts: jni.o jvm.o
-OPT_CFLAGS/jni.o = -c
-OPT_CFLAGS/jvm.o = -c
-# Same problem in parse2.o (probably the Big Switch over bytecodes)
-OPT_CFLAGS/parse2.o = -c
-endif # Platform_arch == x86
-endif
-
-# Frame size > 100k  if we allow inlining via -g0!
-DEBUG_CFLAGS/bytecodeInterpreter.o = -g
-DEBUG_CFLAGS/bytecodeInterpreterWithChecks.o = -g
-ifeq ($(Platform_arch), x86)
-# ube explodes on x86
-OPT_CFLAGS/bytecodeInterpreter.o = -xO1
-OPT_CFLAGS/bytecodeInterpreterWithChecks.o =  -xO1
-endif # Platform_arch == x86
-
-endif # Platform_compiler == sparcWorks
-
-# Workaround for a bug in dtrace.  If ciEnv::post_compiled_method_load_event()
-# is inlined, the resulting dtrace object file needs a reference to this
-# function, whose symbol name is too long for dtrace.  So disable inlining
-# for this method for now. (fix this when dtrace bug 6258412 is fixed)
-OPT_CFLAGS/ciEnv.o = $(OPT_CFLAGS) -xinline=no%__1cFciEnvbFpost_compiled_method_load_event6MpnHnmethod__v_
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# The following lines are copied from debug.make, except that we
-# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS.
-# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
-DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS)
-DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
-CFLAGS += $(DEBUG_CFLAGS/BYFILE)
-
-# Linker mapfiles
-MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \
-	  $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug
-
-# This mapfile is only needed when compiling with dtrace support,
-# and mustn't be otherwise.
-MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE)
-
-VERSION = optimized
-SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS
-PICFLAGS = DEFAULT
diff --git a/hotspot/make/solaris/makefiles/gcc.make b/hotspot/make/solaris/makefiles/gcc.make
deleted file mode 100644
index d31237a..0000000
--- a/hotspot/make/solaris/makefiles/gcc.make
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-#------------------------------------------------------------------------
-# CC, CXX & AS
-
-# If a SPEC is not set already, then use these defaults.
-ifeq ($(SPEC),)
-  CXX = g++
-  CC  = gcc
-  AS  = $(CC) -c
-  MCS = /usr/ccs/bin/mcs
-endif
-
-Compiler = gcc
-
-# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
-# prints the numbers (e.g. "2.95", "3.2.1")
-CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
-CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
-CC_VER_MICRO := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f3)
-
-# Check for the versions of C++ and C compilers ($CXX and $CC) used.
-
-# Get the last thing on the line that looks like x.x+ (x is a digit).
-COMPILER_REV := \
-$(shell $(CXX) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
-CC_COMPILER_REV := \
-$(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
-
-
-# check for precompiled headers support
-ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
-# Allow the user to turn off precompiled headers from the command line.
-ifneq ($(USE_PRECOMPILED_HEADER),0)
-PRECOMPILED_HEADER_DIR=.
-PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
-PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
-endif
-endif
-
-
-#------------------------------------------------------------------------
-# Compiler flags
-
-# position-independent code
-PICFLAG = -fPIC
-
-VM_PICFLAG/LIBJVM = $(PICFLAG)
-VM_PICFLAG/AOUT   =
-VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
-
-CFLAGS += $(VM_PICFLAG)
-CFLAGS += -fno-rtti
-CFLAGS += -fno-exceptions
-CFLAGS += -D_REENTRANT
-CFLAGS += -fcheck-new
-
-ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
-
-ARCHFLAG/sparc   = -m32 -mcpu=v9
-ARCHFLAG/sparcv9 = -m64 -mcpu=v9
-ARCHFLAG/i486    = -m32 -march=i586
-ARCHFLAG/amd64   = -m64 -march=k8
-
-
-# Optional sub-directory in /usr/lib where BUILDARCH libraries are kept.
-ISA_DIR=$(ISA_DIR/$(BUILDARCH))
-ISA_DIR/amd64=/amd64
-ISA_DIR/i486=
-ISA_DIR/sparcv9=/64
-
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-ASFLAGS    += $(ARCHFLAG)
-
-ifeq ($(BUILDARCH), amd64)
-ASFLAGS += -march=k8  -march=amd64
-LFLAGS += -march=k8
-endif
-
-
-# Use C++ Interpreter
-ifdef CC_INTERP
-  CFLAGS += -DCC_INTERP
-endif
-
-# Keep temporary files (.ii, .s)
-ifdef NEED_ASM
-  CFLAGS += -save-temps
-else
-  CFLAGS += -pipe
-endif
-
-
-# Compiler warnings are treated as errors
-WARNINGS_ARE_ERRORS ?= -Werror
-
-# Enable these warnings. See 'info gcc' about details on these options
-WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
-
-# Special cases
-CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
-
-# optimization control flags (Used by fastdebug and release variants)
-OPT_CFLAGS/NOOPT=-O0
-OPT_CFLAGS/DEBUG=-O0
-OPT_CFLAGS/SIZE=-Os
-OPT_CFLAGS/SPEED=-O3
-
-OPT_CFLAGS_DEFAULT ?= SPEED
-
-# Hotspot uses very unstrict aliasing turn this optimization off
-# This option is added to CFLAGS rather than OPT_CFLAGS
-# so that OPT_CFLAGS overrides get this option too.
-CFLAGS += -fno-strict-aliasing
-
-ifdef OPT_CFLAGS
-  ifneq ("$(origin OPT_CFLAGS)", "command line")
-    $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
-  endif
-endif
-
-OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
-
-# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
-# if we use expensive-optimizations
-# Note: all ia64 setting reflect the ones for linux
-# No actial testing was performed: there is no Solaris on ia64 presently
-ifeq ($(BUILDARCH), ia64)
-OPT_CFLAGS/bytecodeInterpreter.o += -fno-expensive-optimizations
-endif
-
-# Work around some compiler bugs.
-ifeq ($(USE_CLANG), true)
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
-    OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
-  endif
-else
-  # Do not allow GCC 4.1.1
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 1 \& $(CC_VER_MICRO) = 1), 1)
-    $(error "GCC $(CC_VER_MAJOR).$(CC_VER_MINOR).$(CC_VER_MICRO) not supported because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27724")
-  endif
-  # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
-  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
-    OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
-  endif
-endif
-
-# Flags for generating make dependency flags.
-ifneq ($(CC_VER_MAJOR), 2)
-DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
-endif
-
-# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
-ifeq ($(USE_PRECOMPILED_HEADER),0)
-CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
-endif
-
-#------------------------------------------------------------------------
-# Linker flags
-
-# statically link libstdc++.so, work with gcc but ignored by g++
-STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
-
-
-ifdef USE_GNULD
-  # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
-  ifneq ($(CC_VER_MAJOR), 2)
-    STATIC_LIBGCC += -static-libgcc
-  endif
-
-  # Enable linker optimization
-  LFLAGS += -Xlinker -O1
-
-  ifneq (, findstring(debug,$(BUILD_FLAVOR)))
-    # for relocations read-only
-    LFLAGS += -Xlinker -z -Xlinker relro
-
-    ifeq ($(BUILD_FLAVOR), debug)
-      # disable incremental relocations linking
-      LFLAGS += -Xlinker -z -Xlinker now
-    endif
-  endif
-
-  ifeq ($(BUILDARCH), ia64)
-    # Note: all ia64 setting reflect the ones for linux
-    # No actual testing was performed: there is no Solaris on ia64 presently
-    LFLAGS += -Wl,-relax
-  endif
-
-  # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-  MAPFLAG = -Xlinker --version-script=FILENAME
-else
-  MAPFLAG = -Xlinker -M -Xlinker FILENAME
-endif
-
-# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-SONAMEFLAG = -Xlinker -soname=SONAME
-
-# Build shared library
-SHARED_FLAG = -shared
-
-#------------------------------------------------------------------------
-# Debug flags
-
-# Allow no optimizations.
-DEBUG_CFLAGS=-O0
-
-# Enable debug symbols
-DEBUG_CFLAGS += -g
-
-# Enable bounds checking.
-ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1"
-  # stack smashing checks.
-  DEBUG_CFLAGS += -fstack-protector-all --param ssp-buffer-size=1
-endif
diff --git a/hotspot/make/solaris/makefiles/hp.make b/hotspot/make/solaris/makefiles/hp.make
deleted file mode 100644
index d0b1026..0000000
--- a/hotspot/make/solaris/makefiles/hp.make
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making premium version of VM
-
-TYPE=HP
-
-CFLAGS += -DCOMPILER2
diff --git a/hotspot/make/solaris/makefiles/hp1.make b/hotspot/make/solaris/makefiles/hp1.make
deleted file mode 100644
index 2e37a6e..0000000
--- a/hotspot/make/solaris/makefiles/hp1.make
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making premium version of VM
-
-TYPE=HP1
-
-CFLAGS += -DCOMPILER1
diff --git a/hotspot/make/solaris/makefiles/i486.make b/hotspot/make/solaris/makefiles/i486.make
deleted file mode 100644
index c2e6ff8..0000000
--- a/hotspot/make/solaris/makefiles/i486.make
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 1998, 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.
-#  
-#
-
-# Must also specify if CPU is little endian
-CFLAGS += -DVM_LITTLE_ENDIAN
-
-# TLS helper, assembled from .s file
-
-#
-# Special case flags for compilers and compiler versions on i486.
-#
-ifeq ("${Platform_compiler}", "sparcWorks")
-# ILD is gone as of SS11 (5.8), not supported in SS10 (5.7)
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 507), 1)
-  #
-  # Bug in ild causes it to fail randomly. Until we get a fix we can't
-  # use ild.
-  #
-  ILDFLAG/debug     = -xildoff
-endif
-endif
diff --git a/hotspot/make/solaris/makefiles/jsig.make b/hotspot/make/solaris/makefiles/jsig.make
deleted file mode 100644
index 392f78c..0000000
--- a/hotspot/make/solaris/makefiles/jsig.make
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# Rules to build signal interposition library, used by vm.make
-
-# libjsig.so: signal interposition library
-JSIG      = jsig
-LIBJSIG   = lib$(JSIG).so
-
-LIBJSIG_DEBUGINFO   = lib$(JSIG).debuginfo
-LIBJSIG_DIZ         = lib$(JSIG).diz
-
-JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
-
-DEST_JSIG           = $(JDK_LIBDIR)/$(LIBJSIG)
-DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO)
-DEST_JSIG_DIZ       = $(JDK_LIBDIR)/$(LIBJSIG_DIZ)
-
-LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
-
-LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
-
-ifdef USE_GCC
-LFLAGS_JSIG += -D_REENTRANT
-else
-LFLAGS_JSIG += -mt -xnolib
-endif
-
-$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
-	@echo $(LOG_INFO) Making signal interposition lib...
-	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
-	                 $(EXTRA_CFLAGS) \
-                         $(LFLAGS_JSIG) $(EXTRA_LDFLAGS) \
-	                 -o $@ $(JSIGSRCDIR)/jsig.c -ldl
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO)
-	$(RM) $(LIBJSIG_DEBUGINFO)
-  endif
-endif
-
-install_jsig: $(LIBJSIG)
-	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
-	$(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \
-	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
-	$(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \
-	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
-
-.PHONY: install_jsig
diff --git a/hotspot/make/solaris/makefiles/jvmti.make b/hotspot/make/solaris/makefiles/jvmti.make
deleted file mode 100644
index 93b9f6e..0000000
--- a/hotspot/make/solaris/makefiles/jvmti.make
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# Copyright (c) 2003, 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.
-#  
-#
-
-# This makefile (jvmti.make) is included from the jvmti.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate jvmti.
-
-include $(GAMMADIR)/make/solaris/makefiles/rules.make
-
-# #########################################################################
-
-GENERATED    = ../generated
-JvmtiOutDir  = $(GENERATED)/jvmtifiles
-
-JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims
-InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(JvmtiSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-JvmtiGeneratedNames = \
-        jvmtiEnv.hpp \
-        jvmtiEnter.cpp \
-        jvmtiEnterTrace.cpp \
-        jvmtiEnvRecommended.cpp\
-        bytecodeInterpreterWithChecks.cpp\
-        jvmti.h \
-
-JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java
-JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class
-
-JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java
-JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class
-
-JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%)
-
-XSLT = $(QUIETLY) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-.PHONY: all jvmtidocs clean cleanall
-
-# #########################################################################
-
-all: $(JvmtiGeneratedFiles)
-
-both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl
-
-$(JvmtiGenClass): $(JvmtiGenSource)
-	$(QUIETLY) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource)
-
-$(JvmtiEnvFillClass): $(JvmtiEnvFillSource)
-	$(QUIETLY) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource)
-
-$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti
-
-$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp 
-
-$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace
-
-$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass)
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp
-	$(QUIETLY) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp
-
-$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp
-
-$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h
-
-jvmtidocs:  $(JvmtiOutDir)/jvmti.html
-
-$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl
-	@echo $(LOG_INFO) Generating $@
-	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html
-
-# #########################################################################
-
-clean :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-cleanall :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-# #########################################################################
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers b/hotspot/make/solaris/makefiles/mapfile-vers
deleted file mode 100644
index 3de0dd9..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                JVM_handle_solaris_signal;
-
-                # miscellaneous functions
-                jio_fprintf;
-                jio_printf;
-                jio_snprintf;
-                jio_vfprintf;
-                jio_vsnprintf;
-
-                # Needed because there is no JVM interface for this.
-                sysThreadAvailableStackWithSlack;
-
-                # This is for Forte Analyzer profiling support.
-                AsyncGetCallTrace;
-
-                # INSERT VTABLE SYMBOLS HERE
-
-        local:
-                *;
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER1 b/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER1
deleted file mode 100644
index f3a0256..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER1
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-
-#
-# Copyright (c) 2003, 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.
-#  
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                # Dtrace support
-                __1cJCodeCacheG_heaps_;
-                __1cIUniverseO_collectedHeap_;
-                __1cGMethodG__vtbl_;
-                __1cHnmethodG__vtbl_;
-                __1cICodeBlobG__vtbl_;
-                __1cKBufferBlobG__vtbl_;
-                __1cLRuntimeStubG__vtbl_;
-                __1cNSafepointBlobG__vtbl_;
-                __1cSDeoptimizationBlobG__vtbl_;
-
-		__JvmOffsets;
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER2 b/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER2
deleted file mode 100644
index 383ba3c..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER2
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-
-#
-# Copyright (c) 2003, 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.
-#  
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                # Dtrace support
-                __1cJCodeCacheG_heaps_;
-                __1cIUniverseO_collectedHeap_;
-                __1cGMethodG__vtbl_;
-                __1cHnmethodG__vtbl_;
-                __1cICodeBlobG__vtbl_;
-                __1cKBufferBlobG__vtbl_;
-                __1cLRuntimeStubG__vtbl_;
-                __1cNSafepointBlobG__vtbl_;
-                __1cSDeoptimizationBlobG__vtbl_;
-
-                __1cNExceptionBlobG__vtbl_;
-                __1cQUncommonTrapBlobG__vtbl_;
-
-		__JvmOffsets;
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-CORE b/hotspot/make/solaris/makefiles/mapfile-vers-CORE
deleted file mode 100644
index ed5896b..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-CORE
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-
-#
-# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-TIERED b/hotspot/make/solaris/makefiles/mapfile-vers-TIERED
deleted file mode 100644
index 2f2c69d..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-TIERED
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-
-#
-# Copyright (c) 2006, 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.
-#  
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-                # Dtrace support
-                __1cJCodeCacheG_heaps_;
-                __1cIUniverseO_collectedHeap_;
-                __1cGMethodG__vtbl_;
-                __1cHnmethodG__vtbl_;
-                __1cICodeBlobG__vtbl_;
-                __1cKBufferBlobG__vtbl_;
-                __1cLRuntimeStubG__vtbl_;
-                __1cNSafepointBlobG__vtbl_;
-                __1cSDeoptimizationBlobG__vtbl_;
-                __1cNExceptionBlobG__vtbl_;
-                __1cQUncommonTrapBlobG__vtbl_;
-
-		__JvmOffsets;
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-debug b/hotspot/make/solaris/makefiles/mapfile-vers-debug
deleted file mode 100644
index f6b63d5..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-debug
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-
-#
-# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-
-		# miscellaneous
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-jsig b/hotspot/make/solaris/makefiles/mapfile-vers-jsig
deleted file mode 100644
index 8a67504..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-jsig
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-
-#
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Define library interface.
-
-SUNWprivate_1.1 {
-        global:
-            JVM_begin_signal_setting;
-            JVM_end_signal_setting;
-            JVM_get_libjsig_version;
-            JVM_get_signal_action;
-            sigaction;
-            signal;
-            sigset;
-        local:
-                *;
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_db b/hotspot/make/solaris/makefiles/mapfile-vers-jvm_db
deleted file mode 100644
index 9ee418d..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_db
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-
-#
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Define library interface.
-
-SUNWprivate_1.1 {
-        global:
-            Jagent_create;
-	    Jagent_destroy;
-	    Jframe_iter;
-	    #Jget_vframe;
-	    #Jlookup_by_regs;
-        local:
-                *;
-};
diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_dtrace b/hotspot/make/solaris/makefiles/mapfile-vers-jvm_dtrace
deleted file mode 100644
index f9aaa19..0000000
--- a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_dtrace
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-
-#
-# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Define library interface for JVM-DTrace interface
-
-SUNWprivate_1.1 {
-        global:
-            jvm_attach;
-            jvm_get_last_error;
-            jvm_enable_dtprobes;
-            jvm_detach;
-        local:
-                *;
-};
diff --git a/hotspot/make/solaris/makefiles/optimized.make b/hotspot/make/solaris/makefiles/optimized.make
deleted file mode 100644
index f353628..0000000
--- a/hotspot/make/solaris/makefiles/optimized.make
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Copyright (c) 1998, 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.
-#  
-#
-
-# Sets make macros for making optimized version of HotSpot VM
-# (This is the "product", not the "release" version.)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-ifeq ("${Platform_compiler}", "sparcWorks")
-
-ifeq ($(COMPILER_REV_NUMERIC), 510)
-# CC 5.10 has bug XXXXX with -xO4
-OPT_CFLAGS/jvmtiClassFileReconstituter.o = $(OPT_CFLAGS/O2)
-endif # COMPILER_REV_NUMERIC == 510
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-# dtrace cannot handle tail call optimization (6672627, 6693876)
-OPT_CFLAGS/jni.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT)
-endif # COMPILER_NUMERIC_REV >= 509
-
-# Workaround SS11 bug 6345274 (all platforms) (Fixed in SS11 patch and SS12)
-ifeq ($(COMPILER_REV_NUMERIC),508)
-OPT_CFLAGS/ciTypeFlow.o = $(OPT_CFLAGS/O2)
-endif # COMPILER_REV_NUMERIC == 508
-
-endif # Platform_compiler == sparcWorks
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-
-# Linker mapfiles
-MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers
-
-# This mapfile is only needed when compiling with dtrace support, 
-# and mustn't be otherwise.
-MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE)
-
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-VERSION = optimized
diff --git a/hotspot/make/solaris/makefiles/product.make b/hotspot/make/solaris/makefiles/product.make
deleted file mode 100644
index b36159f..0000000
--- a/hotspot/make/solaris/makefiles/product.make
+++ /dev/null
@@ -1,103 +0,0 @@
-#
-# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Sets make macros for making optimized version of HotSpot VM
-# (This is the "product", not the "release" version.)
-
-# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
-OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
-OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
-
-# Workaround for a bug in dtrace.  If ciEnv::post_compiled_method_load_event()
-# is inlined, the resulting dtrace object file needs a reference to this
-# function, whose symbol name is too long for dtrace.  So disable inlining
-# for this method for now. (fix this when dtrace bug 6258412 is fixed)
-ifndef USE_GCC
-OPT_CFLAGS/ciEnv.o = $(OPT_CFLAGS) -xinline=no%__1cFciEnvbFpost_compiled_method_load_event6MpnHnmethod__v_
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/ciEnv.o += -g0 -xs
-endif
-endif
-
-# Need extra inlining to get oop_ps_push_contents functions to perform well enough.
-ifndef USE_GCC
-OPT_CFLAGS/psPromotionManager.o = $(OPT_CFLAGS) -W2,-Ainline:inc=1000
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/psPromotionManager.o += -g0 -xs
-endif
-endif
-
-# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
-ifeq ("${Platform_compiler}", "sparcWorks")
-
-ifeq ($(COMPILER_REV_NUMERIC), 510)
-# CC 5.10 has bug XXXXX with -xO4
-OPT_CFLAGS/jvmtiClassFileReconstituter.o = $(OPT_CFLAGS/O2)
-# Avoid apparent crash because of corrupted methodHandle in a tail call
-OPT_CFLAGS/simpleThresholdPolicy.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT)
-endif # COMPILER_REV_NUMERIC == 510
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-# dtrace cannot handle tail call optimization (6672627, 6693876)
-OPT_CFLAGS/jni.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT)
-# The -g0 -xs flag is added to OPT_CFLAGS in sparcWorks.make, but lost in case of
-# per-file overrides of OPT_CFLAGS. Restore it here. This is mainly needed
-# to provide a good baseline to compare the new build against.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/jni.o += -g0 -xs
-endif
-endif # COMPILER_NUMERIC_REV >= 509
-
-# Workaround SS11 bug 6345274 (all platforms) (Fixed in SS11 patch and SS12)
-ifeq ($(COMPILER_REV_NUMERIC),508)
-OPT_CFLAGS/ciTypeFlow.o = $(OPT_CFLAGS/O2)
-endif # COMPILER_REV_NUMERIC == 508
-
-endif # Platform_compiler == sparcWorks
-
-# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
-CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
-# Set the environment variable HOTSPARC_GENERIC to "true"
-# to inhibit the effect of the previous line on CFLAGS.
-
-# Linker mapfiles
-MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers
-
-ifndef USE_GCC
-# This mapfile is only needed when compiling with dtrace support, 
-# and mustn't be otherwise.
-MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE)
-
-endif
-
-# If we can create .debuginfo files, then the VM is stripped in vm.make
-# and this macro is not used.
-# LINK_LIB.CXX/POST_HOOK += $(STRIP_LIB.CXX/POST_HOOK)
-
-SYSDEFS += -DPRODUCT
-VERSION = optimized
diff --git a/hotspot/make/solaris/makefiles/reorder_CORE_amd64 b/hotspot/make/solaris/makefiles/reorder_CORE_amd64
deleted file mode 100644
index e69de29..0000000
--- a/hotspot/make/solaris/makefiles/reorder_CORE_amd64
+++ /dev/null
diff --git a/hotspot/make/solaris/makefiles/rules.make b/hotspot/make/solaris/makefiles/rules.make
deleted file mode 100644
index a35b9da..0000000
--- a/hotspot/make/solaris/makefiles/rules.make
+++ /dev/null
@@ -1,200 +0,0 @@
-#
-# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# Common rules/macros for the vm, adlc.
-
-# Tell make that .cpp is important
-.SUFFIXES: .cpp $(SUFFIXES)
-
-DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
-
-# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
-CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
-CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
-
-AS.S            = $(AS) $(ASFLAGS)
-
-COMPILE.CC       = $(CC_COMPILE) -c
-GENASM.CC        = $(CC_COMPILE) -S
-LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CC    = $(CC_COMPILE) -E
-
-COMPILE.CXX      = $(CXX_COMPILE) -c
-GENASM.CXX       = $(CXX_COMPILE) -S
-LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
-LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CXX   = $(CXX_COMPILE) -E
-
-# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
-REMOVE_TARGET   = rm -f $@
-
-# Note use of ALT_BOOTDIR to explicitly specify location of java and
-# javac; this is the same environment variable used in the J2SE build
-# process for overriding the default spec, which is BOOTDIR.
-# Note also that we fall back to using JAVA_HOME if neither of these is
-# specified.
-
-ifdef ALT_BOOTDIR
-
-RUN.JAVA  = $(ALT_BOOTDIR)/bin/java
-RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap
-RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah
-RUN.JAR   = $(ALT_BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac
-COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(ALT_BOOTDIR)
-
-else
-
-ifdef BOOTDIR
-
-RUN.JAVA  = $(BOOTDIR)/bin/java
-RUN.JAVAP = $(BOOTDIR)/bin/javap
-RUN.JAVAH = $(BOOTDIR)/bin/javah
-RUN.JAR   = $(BOOTDIR)/bin/jar
-COMPILE.JAVAC = $(BOOTDIR)/bin/javac
-COMPILE.RMIC  = $(BOOTDIR)/bin/rmic
-BOOT_JAVA_HOME = $(BOOTDIR)
-
-else
-
-ifdef JAVA_HOME
-
-RUN.JAVA  = $(JAVA_HOME)/bin/java
-RUN.JAVAP = $(JAVA_HOME)/bin/javap
-RUN.JAVAH = $(JAVA_HOME)/bin/javah
-RUN.JAR   = $(JAVA_HOME)/bin/jar
-COMPILE.JAVAC = $(JAVA_HOME)/bin/javac
-COMPILE.RMIC  = $(JAVA_HOME)/bin/rmic
-BOOT_JAVA_HOME = $(JAVA_HOME)
-
-else
-
-# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined
-
-RUN.JAVA  = java
-RUN.JAVAP = javap
-RUN.JAVAH = javah
-RUN.JAR   = jar
-COMPILE.JAVAC = javac
-COMPILE.RMIC  = rmic
-
-endif
-endif
-endif
-
-COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS)
-
-SUM = /usr/bin/sum
-
-# 'gmake MAKE_VERBOSE=y' gives all the gory details.
-QUIETLY$(MAKE_VERBOSE)  = @
-RUN.JAR$(MAKE_VERBOSE) += >/dev/null
-
-# Settings for javac
-JAVAC_FLAGS = -g -encoding ascii
-
-# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system)
-# Fall back to the values here if it's not set (hotspot only builds)
-ifeq ($(BOOT_JDK_SOURCETARGET),)
-BOOTSTRAP_SOURCETARGET := -source 8 -target 8
-else
-BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET)
-endif
-
-BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET)
-
-# With parallel makes, print a message at the end of compilation.
-ifeq    ($(findstring j,$(MFLAGS)),j)
-COMPILE_DONE    = && { echo Done with $<; }
-endif
-
-# Include NONPIC_OBJ_FILES definition
-ifndef LP64
-include $(GAMMADIR)/make/pic.make
-endif
-
-include $(GAMMADIR)/make/altsrc.make
-
-# Sun compiler for 64 bit Solaris does not support building non-PIC object files.
-ifdef LP64
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
-else
-%.o: %.cpp
-	@echo $(LOG_INFO) Compiling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
-	   $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
-	   $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
-endif
-
-%.o: %.s
-	@echo $(LOG_INFO) Assembling $<
-	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(AS.S) -o $@ $< $(COMPILE_DONE)
-
-%.s: %.cpp
-	@echo $(LOG_INFO) Generating assembly for $<
-	$(QUIETLY) $(GENASM.CXX) -o $@ $<
-	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
-
-# Intermediate files (for debugging macros)
-%.i: %.cpp
-	@echo $(LOG_INFO) Preprocessing $< to $@
-	$(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
-
-#  Override gnumake built-in rules which do sccs get operations badly.
-#  (They put the checked out code in the current directory, not in the
-#  directory of the original file.)  Since this is a symptom of a teamware
-#  failure, and since not all problems can be detected by gnumake due
-#  to incomplete dependency checking... just complain and stop.
-%:: s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-%:: SCCS/s.%
-	@echo "========================================================="
-	@echo File $@
-	@echo is out of date with respect to its SCCS file.
-	@echo This file may be from an unresolved Teamware conflict.
-	@echo This is also a symptom of a Teamware bringover/putback failure
-	@echo in which SCCS files are updated but not checked out.
-	@echo Check for other out of date files in your workspace.
-	@echo "========================================================="
-	@exit 666
-
-.PHONY: default
diff --git a/hotspot/make/solaris/makefiles/sparc.make b/hotspot/make/solaris/makefiles/sparc.make
deleted file mode 100644
index ff507f2..0000000
--- a/hotspot/make/solaris/makefiles/sparc.make
+++ /dev/null
@@ -1,124 +0,0 @@
-#
-# Copyright (c) 1998, 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.
-#  
-#
-
-Obj_Files += solaris_sparc.o
-ASFLAGS += $(AS_ARCHFLAG)
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 505), 1)
-# For 5.2 ad_sparc file is compiled with -O2 %%%% remove when adlc is fixed
-OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER)
-# CC drops core on systemDictionary.o in -xO4 mode
-OPT_CFLAGS/systemDictionary.o = $(OPT_CFLAGS/SLOWER)
-# SC5.0 bug 4284168
-OPT_CFLAGS/carRememberedSet.o = $(OPT_CFLAGS/O2)
-# Temporarily drop the optimization level for compiling
-# jniHandles.cpp to O3 from O4; see bug 4309181
-OPT_CFLAGS/jniHandles.o = $(OPT_CFLAGS/O2)
-# CC brings an US-II to its knees compiling the vmStructs asserts under -xO4
-OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2)
-endif # COMPILER_REV_NUMERIC < 505
-else
-# Options for gcc
-OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/systemDictionary.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/carRememberedSet.o = $(OPT_CFLAGS/O2)
-OPT_CFLAGS/jniHandles.o = $(OPT_CFLAGS/O2)
-OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2)
-endif
-
-# File-specific adjustments to the PICFLAG, applicable only to SPARC,
-# which has a very tight limit on global constant references.
-
-# Old files which seemed hot at one point or another:
-#PICFLAG/runtime.o = $(PICFLAG/BETTER)
-#PICFLAG/generateOopMap.o = $(PICFLAG/BETTER)
-#PICFLAG/thread.o = $(PICFLAG/BETTER)
-#PICFLAG/parse2.o = $(PICFLAG/BETTER)
-#PICFLAG/parse1.o = $(PICFLAG/BETTER)
-#PICFLAG/universe.o = $(PICFLAG/BETTER)
-#PICFLAG/safepoint.o = $(PICFLAG/BETTER)
-#PICFLAG/parse3.o = $(PICFLAG/BETTER)
-#PICFLAG/compile.o = $(PICFLAG/BETTER)
-#PICFLAG/codeBlob.o = $(PICFLAG/BETTER)
-#PICFLAG/mutexLocker.o = $(PICFLAG/BETTER)
-#PICFLAG/nativeInst_sparc.o = $(PICFLAG/BETTER)
-#PICFLAG/methodLiveness.o = $(PICFLAG/BETTER)
-#PICFLAG/synchronizer.o = $(PICFLAG/BETTER)
-#PICFLAG/method.o = $(PICFLAG/BETTER)
-#PICFLAG/space.o = $(PICFLAG/BETTER)
-#PICFLAG/interpreterRT_sparc.o = $(PICFLAG/BETTER)
-#PICFLAG/generation.o = $(PICFLAG/BETTER)
-#PICFLAG/markSweep.o = $(PICFLAG/BETTER)
-#PICFLAG/parseHelper.o = $(PICFLAG/BETTER)
-
-# Confirmed by function-level profiling:
-PICFLAG/scavenge.o = $(PICFLAG/BETTER)
-PICFLAG/instanceKlass.o = $(PICFLAG/BETTER)
-PICFLAG/frame.o = $(PICFLAG/BETTER)
-PICFLAG/phaseX.o = $(PICFLAG/BETTER)
-PICFLAG/lookupCache.o = $(PICFLAG/BETTER)
-PICFLAG/chaitin.o = $(PICFLAG/BETTER)
-PICFLAG/type.o = $(PICFLAG/BETTER)
-PICFLAG/jvm.o = $(PICFLAG/BETTER)
-PICFLAG/jni.o = $(PICFLAG/BETTER)
-PICFLAG/matcher.o = $(PICFLAG/BETTER)
-
-# New from module-level profiling (trustworthy?):
-PICFLAG/rememberedSet.o = $(PICFLAG/BETTER)
-PICFLAG/frame_sparc.o = $(PICFLAG/BETTER)
-PICFLAG/live.o = $(PICFLAG/BETTER)
-PICFLAG/vectset.o = $(PICFLAG/BETTER)
-PICFLAG/objArrayKlass.o = $(PICFLAG/BETTER)
-PICFLAG/do_call.o = $(PICFLAG/BETTER)
-PICFLAG/loopnode.o = $(PICFLAG/BETTER)
-PICFLAG/cfgnode.o = $(PICFLAG/BETTER)
-PICFLAG/ifg.o = $(PICFLAG/BETTER)
-PICFLAG/vframe.o = $(PICFLAG/BETTER)
-PICFLAG/postaloc.o = $(PICFLAG/BETTER)
-PICFLAG/carRememberedSet.o = $(PICFLAG/BETTER)
-PICFLAG/gcm.o = $(PICFLAG/BETTER)
-PICFLAG/coalesce.o = $(PICFLAG/BETTER)
-PICFLAG/oop.o = $(PICFLAG/BETTER)
-PICFLAG/oopMap.o = $(PICFLAG/BETTER)
-PICFLAG/resourceArea.o = $(PICFLAG/BETTER)
-PICFLAG/node.o = $(PICFLAG/BETTER)
-PICFLAG/dict.o = $(PICFLAG/BETTER)
-PICFLAG/domgraph.o = $(PICFLAG/BETTER)
-PICFLAG/dfa_sparc.o = $(PICFLAG/BETTER)
-PICFLAG/block.o = $(PICFLAG/BETTER)
-PICFLAG/javaClasses.o = $(PICFLAG/BETTER)
-
-# New hot files:
-PICFLAG/classes.o = $(PICFLAG/BETTER)
-#PICFLAG/ad_sparc.o = $(PICFLAG/BETTER)
-PICFLAG/nmethod.o = $(PICFLAG/BETTER)
-PICFLAG/relocInfo.o = $(PICFLAG/BETTER)
-PICFLAG/codeBuffer_sparc.o = $(PICFLAG/BETTER)
-PICFLAG/callnode.o = $(PICFLAG/BETTER)
-PICFLAG/multnode.o = $(PICFLAG/BETTER)
-PICFLAG/os_solaris.o = $(PICFLAG/BETTER)
-PICFLAG/typeArrayKlass.o = $(PICFLAG/BETTER)
diff --git a/hotspot/make/solaris/makefiles/sparcWorks.make b/hotspot/make/solaris/makefiles/sparcWorks.make
deleted file mode 100644
index 5c66b2f..0000000
--- a/hotspot/make/solaris/makefiles/sparcWorks.make
+++ /dev/null
@@ -1,565 +0,0 @@
-#
-# Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# If a SPEC is not set already, then use these defaults.
-ifeq ($(SPEC),)
-  # Compiler-specific flags for sparcworks.
-  CC	= cc
-  CXX	= CC
-
-  # Note that this 'as' is an older version of the Sun Studio 'fbe', and will
-  #   use the older style options. The 'fbe' options will match 'cc' and 'CC'.
-  AS	= /usr/ccs/bin/as
-
-  NM    = /usr/ccs/bin/nm
-  NAWK  = /bin/nawk
-
-  MCS	= /usr/ccs/bin/mcs
-  STRIP	= /usr/ccs/bin/strip
-endif
-
-# Check for the versions of C++ and C compilers ($CXX and $CC) used.
-
-# Get the last thing on the line that looks like x.x+ (x is a digit).
-COMPILER_REV := \
-$(shell $(CXX) -V 2>&1 | sed -n 's/^.*[ ,\t]C++[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
-CC_COMPILER_REV := \
-$(shell $(CC) -V 2>&1 | sed -n 's/^.*[ ,\t]C[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
-
-# Pick which compiler is validated
-# Validated compiler for JDK9 is SS12.4 (5.13)
-VALIDATED_COMPILER_REVS   := 5.13
-VALIDATED_CC_COMPILER_REVS := 5.13
-
-# Warning messages about not using the above validated versions
-ENFORCE_COMPILER_REV${ENFORCE_COMPILER_REV} := $(strip ${VALIDATED_COMPILER_REVS})
-ifeq ($(filter ${ENFORCE_COMPILER_REV},${COMPILER_REV}),)
-PRINTABLE_CC_REVS := $(subst $(shell echo ' '), or ,${ENFORCE_COMPILER_REV})
-dummy_var_to_enforce_compiler_rev := $(shell \
-	echo >&2 WARNING: You are using CC version ${COMPILER_REV} and \
-	should be using version ${PRINTABLE_CC_REVS}.; \
-	echo >&2 Set ENFORCE_COMPILER_REV=${COMPILER_REV} to avoid this \
-	warning.)
-endif
-
-ENFORCE_CC_COMPILER_REV${ENFORCE_CC_COMPILER_REV} := $(strip ${VALIDATED_CC_COMPILER_REVS})
-ifeq ($(filter ${ENFORCE_CC_COMPILER_REV},${CC_COMPILER_REV}),)
-PRINTABLE_C_REVS := $(subst $(shell echo ' '), or ,${ENFORCE_CC_COMPILER_REV})
-dummy_var_to_enforce_c_compiler_rev := $(shell \
-	echo >&2 WARNING: You are using cc version ${CC_COMPILER_REV} and \
-	should be using version ${PRINTABLE_C_REVS}.; \
-	echo >&2 Set ENFORCE_CC_COMPILER_REV=${CC_COMPILER_REV} to avoid this \
-	warning.)
-endif
-
-COMPILER_REV_NUMERIC := $(shell echo $(COMPILER_REV) | awk -F. '{ print $$1 * 100 + $$2 }')
-
-# Fail the build if __fabsf is used.  __fabsf exists only in Solaris 8 2/04
-# and newer; objects with a dependency on this symbol will not run on older
-# Solaris 8.
-JVM_FAIL_IF_UNDEFINED = __fabsf
-
-JVM_CHECK_SYMBOLS = $(NM) -u -p $(LIBJVM.o) | \
-	$(NAWK) -v f="${JVM_FAIL_IF_UNDEFINED}" \
-	     'BEGIN    { c=split(f,s); rc=0; } \
-	      /:$$/     { file = $$1; } \
-	      /[^:]$$/  { for(n=1;n<=c;++n) { \
-			   if($$1==s[n]) { \
-			     printf("JVM_CHECK_SYMBOLS: %s contains illegal symbol %s\n", \
-				    file,$$1); \
-			     rc=1; \
-			   } \
-		         } \
-                       } \
-	      END      { exit rc; }'
-
-LINK_LIB.CXX/PRE_HOOK += $(JVM_CHECK_SYMBOLS) || exit 1;
-
-# New architecture options started in SS12 (5.9), we need both styles to build.
-#   The older arch options for SS11 (5.8) or older and also for /usr/ccs/bin/as.
-#   Note: default for 32bit sparc is now the same as v8plus, so the
-#         settings below have changed all 32bit sparc builds to be v8plus.
-ARCHFLAG_OLD/sparc   = -xarch=v8plus
-ARCHFLAG_NEW/sparc   = -m32 -xarch=sparc
-ARCHFLAG_OLD/sparcv9 = -xarch=v9
-ARCHFLAG_NEW/sparcv9 = -m64 -xarch=sparc
-ARCHFLAG_OLD/i486    =
-ARCHFLAG_NEW/i486    = -m32
-ARCHFLAG_OLD/amd64   = -xarch=amd64
-ARCHFLAG_NEW/amd64   = -m64
-
-# Select the ARCHFLAGs and other SS12 (5.9) options
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-  ARCHFLAG/sparc   = $(ARCHFLAG_NEW/sparc)
-  ARCHFLAG/sparcv9 = $(ARCHFLAG_NEW/sparcv9)
-  ARCHFLAG/i486    = $(ARCHFLAG_NEW/i486)
-  ARCHFLAG/amd64   = $(ARCHFLAG_NEW/amd64)
-else
-  ARCHFLAG/sparc   = $(ARCHFLAG_OLD/sparc)
-  ARCHFLAG/sparcv9 = $(ARCHFLAG_OLD/sparcv9)
-  ARCHFLAG/i486    = $(ARCHFLAG_OLD/i486)
-  ARCHFLAG/amd64   = $(ARCHFLAG_OLD/amd64)
-endif
-
-# ARCHFLAGS for the current build arch
-ARCHFLAG    = $(ARCHFLAG/$(BUILDARCH))
-AS_ARCHFLAG = $(ARCHFLAG_OLD/$(BUILDARCH))
-
-# Optional sub-directory in /usr/lib where BUILDARCH libraries are kept.
-ISA_DIR=$(ISA_DIR/$(BUILDARCH))
-ISA_DIR/sparcv9=/sparcv9
-ISA_DIR/amd64=/amd64
-
-# Use these to work around compiler bugs:
-OPT_CFLAGS/SLOWER=-xO3
-OPT_CFLAGS/O2=-xO2
-OPT_CFLAGS/NOOPT=-xO1
-
-# Flags for creating the dependency files.
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-DEPFLAGS = -xMMD -xMF $(DEP_DIR)/$(@:%=%.d)
-endif
-
-# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
-CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
-
-# Compiler warnings are treated as errors
-WARNINGS_ARE_ERRORS ?= -xwe
-CFLAGS_WARN = $(WARNINGS_ARE_ERRORS)
-
-################################################
-# Begin current (>=5.9) Forte compiler options #
-#################################################
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-ifeq ($(Platform_arch), x86)
-OPT_CFLAGS/NO_TAIL_CALL_OPT  = -Wu,-O~yz
-OPT_CCFLAGS/NO_TAIL_CALL_OPT = -Qoption ube -O~yz
-OPT_CFLAGS/stubGenerator_x86_32.o = $(OPT_CFLAGS) -xspace
-OPT_CFLAGS/stubGenerator_x86_64.o = $(OPT_CFLAGS) -xspace
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/stubGenerator_x86_32.o += -g0 -xs
-   OPT_CFLAGS/stubGenerator_x86_64.o += -g0 -xs
-endif
-endif # Platform_arch == x86
-ifeq ("${Platform_arch}", "sparc")
-OPT_CFLAGS/stubGenerator_sparc.o = $(OPT_CFLAGS) -xspace
-# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
-# of OPT_CFLAGS. Restore it here.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-   OPT_CFLAGS/stubGenerator_sparc.o += -g0 -xs
-endif
-endif
-endif # COMPILER_REV_NUMERIC >= 509
-
-#################################################
-# Begin current (>=5.6) Forte compiler options #
-#################################################
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 506), 1)
-
-ifeq ("${Platform_arch}", "sparc")
-
-# We MUST allow data alignment of 4 for sparc (sparcv9 is ok at 8s)
-ifndef LP64
-CFLAGS += -xmemalign=4s
-endif
-
-endif
-
-endif
-
-#################################################
-# Begin current (>=5.5) Forte compiler options #
-#################################################
-
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1)
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LIB_FLAGS  += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-
-ifeq ("${Platform_arch}", "sparc")
-
-# Flags for Optimization
-
-# [phh] Commented out pending verification that we do indeed want
-#       to potentially bias against u1 and u3 targets.
-#CFLAGS += -xchip=ultra2
-
-OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
-
-endif # sparc
-
-ifeq ("${Platform_arch_model}", "x86_32")
-
-OPT_CFLAGS=-xtarget=pentium -xO4 $(EXTRA_OPT_CFLAGS)
-
-endif # 32bit x86
-
-ifeq ("${Platform_arch_model}", "x86_64")
-
-ASFLAGS += $(AS_ARCHFLAG)
-CFLAGS  += $(ARCHFLAG/amd64)
-# this one seemed useless
-LFLAGS_VM  += $(ARCHFLAG/amd64)
-# this one worked
-LFLAGS  += $(ARCHFLAG/amd64)
-AOUT_FLAGS += $(ARCHFLAG/amd64)
-
-# -xO3 is faster than -xO4 on specjbb with SS10 compiler
-OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
-
-endif # 64bit x86
-
-# Inline functions
-CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_${Platform_arch}/vm/solaris_${Platform_arch_model}.il
-
-# no more exceptions
-CFLAGS/NOEX=-features=no%except
-
-
-# avoid compilation problems arising from fact that C++ compiler tries
-# to search for external template definition by just compiling additional
-# source files in th same context
-CFLAGS +=  -template=no%extdef
-
-# Reduce code bloat by reverting back to 5.0 behavior for static initializers
-CFLAGS += -features=no%split_init
-
-# Use -D_Crun_inline_placement so we don't get references to
-#    __1c2n6FIpv_0_ or   void*operator new(unsigned,void*)
-#  This avoids the hard requirement of the newer Solaris C++ runtime patches.
-#  NOTE: This is an undocumented feature of the SS10 compiler. See 6306698.
-CFLAGS += -D_Crun_inline_placement
-
-# PIC is safer for SPARC, and is considerably slower
-# a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC"
-PICFLAG         = -KPIC
-PICFLAG/DEFAULT = $(PICFLAG)
-# [RGV] Need to figure which files to remove to get link to work
-#PICFLAG/BETTER  = -pic
-PICFLAG/BETTER  = $(PICFLAG/DEFAULT)
-PICFLAG/BYFILE  = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@))
-
-# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-MAPFLAG = -M FILENAME
-
-# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-SONAMEFLAG = -h SONAME
-
-# Build shared library
-SHARED_FLAG = -G
-
-# We don't need libCstd.so and librwtools7.so, only libCrun.so
-CFLAGS += -library=%none
-LFLAGS += -library=%none
-
-LFLAGS += -mt
-
-endif	# COMPILER_REV_NUMERIC >= 505
-
-######################################
-# End 5.5 Forte compiler options     #
-######################################
-
-######################################
-# Begin 5.2 Forte compiler options   #
-######################################
-
-ifeq ($(COMPILER_REV_NUMERIC), 502)
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LIB_FLAGS  += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-
-ifeq ("${Platform_arch}", "sparc")
-
-# Flags for Optimization
-
-# [phh] Commented out pending verification that we do indeed want
-#       to potentially bias against u1 and u3 targets.
-#CFLAGS += -xchip=ultra2
-
-ifdef LP64
-# SC5.0 tools on v9 are flakey at -xO4
-# [phh] Is this still true for 6.1?
-OPT_CFLAGS=-xO3 $(EXTRA_OPT_CFLAGS)
-else
-OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
-endif
-
-endif # sparc
-
-ifeq ("${Platform_arch_model}", "x86_32")
-
-OPT_CFLAGS=-xtarget=pentium $(EXTRA_OPT_CFLAGS)
-
-# SC5.0 tools on x86 are flakey at -xO4
-# [phh] Is this still true for 6.1?
-OPT_CFLAGS+=-xO3
-
-endif # 32bit x86
-
-# no more exceptions
-CFLAGS/NOEX=-noex
-
-# Inline functions
-CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_${Platform_arch}/vm/solaris_${Platform_arch_model}.il
-
-# Reduce code bloat by reverting back to 5.0 behavior for static initializers
-CFLAGS += -Qoption ccfe -one_static_init
-
-# PIC is safer for SPARC, and is considerably slower
-# a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC"
-PICFLAG         = -KPIC
-PICFLAG/DEFAULT = $(PICFLAG)
-# [RGV] Need to figure which files to remove to get link to work
-#PICFLAG/BETTER  = -pic
-PICFLAG/BETTER  = $(PICFLAG/DEFAULT)
-PICFLAG/BYFILE  = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@))
-
-# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
-MAPFLAG = -M FILENAME
-
-# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-SONAMEFLAG = -h SONAME
-
-# Build shared library
-SHARED_FLAG = -G
-
-# Would be better if these weren't needed, since we link with CC, but
-# at present removing them causes run-time errors
-LFLAGS += -library=Crun
-LIBS   += -library=Crun -lCrun
-
-endif	# COMPILER_REV_NUMERIC == 502
-
-##################################
-# End 5.2 Forte compiler options #
-##################################
-
-##################################
-# Begin old 5.1 compiler options #
-##################################
-ifeq ($(COMPILER_REV_NUMERIC), 501)
-
-_JUNK_ := $(shell echo >&2 \
-       "*** ERROR: sparkWorks.make incomplete for 5.1 compiler")
-	@exit 1
-endif
-##################################
-# End old 5.1 compiler options   #
-##################################
-
-##################################
-# Begin old 5.0 compiler options #
-##################################
-
-ifeq	(${COMPILER_REV_NUMERIC}, 500)
-
-# Had to hoist this higher apparently because of other changes. Must
-# come before -xarch specification.
-#  NOTE: native says optimize for the machine doing the compile, bad news.
-CFLAGS += -xtarget=native
-
-CFLAGS     += $(ARCHFLAG)
-AOUT_FLAGS += $(ARCHFLAG)
-LIB_FLAGS  += $(ARCHFLAG)
-LFLAGS     += $(ARCHFLAG)
-
-CFLAGS += -library=iostream
-LFLAGS += -library=iostream  -library=Crun
-LIBS += -library=iostream -library=Crun -lCrun
-
-# Flags for Optimization
-ifdef LP64
-# SC5.0 tools on v9 are flakey at -xO4
-OPT_CFLAGS=-xO3 $(EXTRA_OPT_CFLAGS)
-else
-OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
-endif
-
-ifeq ("${Platform_arch}", "sparc")
-
-CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.il
-
-endif # sparc
-
-ifeq ("${Platform_arch_model}", "x86_32")
-OPT_CFLAGS=-xtarget=pentium $(EXTRA_OPT_CFLAGS)
-ifeq ("${COMPILER_REV_NUMERIC}", "500")
-# SC5.0 tools on x86 are flakey at -xO4
-OPT_CFLAGS+=-xO3
-else
-OPT_CFLAGS+=-xO4
-endif
-
-CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_x86/vm/solaris_x86_32.il
-
-endif  # 32bit x86
-
-# The following options run into misaligned ldd problem (raj)
-#OPT_CFLAGS = -fast -O4 $(ARCHFLAG/sparc) -xchip=ultra
-
-# no more exceptions
-CFLAGS/NOEX=-noex
-
-# PIC is safer for SPARC, and is considerably slower
-# a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC"
-PICFLAG         = -PIC
-PICFLAG/DEFAULT = $(PICFLAG)
-# [RGV] Need to figure which files to remove to get link to work
-#PICFLAG/BETTER  = -pic
-PICFLAG/BETTER  = $(PICFLAG/DEFAULT)
-PICFLAG/BYFILE  = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@))
-
-endif	# COMPILER_REV_NUMERIC = 500
-
-################################
-# End old 5.0 compiler options #
-################################
-
-ifeq ("${COMPILER_REV_NUMERIC}", "402")
-# 4.2 COMPILERS SHOULD NO LONGER BE USED
-_JUNK_ := $(shell echo >&2 \
-       "*** ERROR: SC4.2 compilers are not supported by this code base!")
-	@exit 1
-endif
-
-# do not include shared lib path in a.outs
-AOUT_FLAGS += -norunpath
-LFLAGS_VM = -norunpath -z noversion
-
-# need position-indep-code for shared libraries
-# (ild appears to get errors on PIC code, so we'll try non-PIC for debug)
-ifeq ($(PICFLAGS),DEFAULT)
-VM_PICFLAG/LIBJVM  = $(PICFLAG/DEFAULT)
-else
-VM_PICFLAG/LIBJVM  = $(PICFLAG/BYFILE)
-endif
-VM_PICFLAG/AOUT    =
-
-VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
-CFLAGS += $(VM_PICFLAG)
-
-# less dynamic linking (no PLTs, please)
-#LIB_FLAGS += $(LINK_MODE)
-# %%%%% despite -znodefs, -Bsymbolic gets link errors -- Rose
-
-LINK_MODE = $(LINK_MODE/$(VERSION))
-LINK_MODE/debug     =
-LINK_MODE/optimized = -Bsymbolic -znodefs
-
-# Have thread local errnos
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1)
-CFLAGS += -mt
-else
-CFLAGS += -D_REENTRANT
-endif
-
-ifdef CC_INTERP
-# C++ Interpreter
-CFLAGS += -DCC_INTERP
-endif
-
-# Flags for Debugging
-# The -g0 setting allows the C++ frontend to inline, which is a big win.
-# The -xs setting disables 'lazy debug info' which puts everything in
-# the .so instead of requiring the '.o' files.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  OPT_CFLAGS += -g0 -xs
-endif
-DEBUG_CFLAGS = -g
-FASTDEBUG_CFLAGS = -g0
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  DEBUG_CFLAGS += -xs
-  FASTDEBUG_CFLAGS += -xs
-endif
-
-# Enable the following CFLAGS additions if you need to compare the
-# built ELF objects.
-#
-# The -g option makes static data global and the "-Qoption ccfe
-# -xglobalstatic" option tells the compiler to not globalize static
-# data using a unique globalization prefix. Instead force the use of
-# a static globalization prefix based on the source filepath so the
-# objects from two identical compilations are the same.
-# EXTRA_CFLAGS only covers vm_version.cpp for some reason
-#EXTRA_CFLAGS += -Qoption ccfe -xglobalstatic
-#OPT_CFLAGS += -Qoption ccfe -xglobalstatic
-#DEBUG_CFLAGS += -Qoption ccfe -xglobalstatic
-#FASTDEBUG_CFLAGS += -Qoption ccfe -xglobalstatic
-
-ifeq	(${COMPILER_REV_NUMERIC}, 502)
-COMPILER_DATE := $(shell $(CXX) -V 2>&1 | sed -n '/^.*[ ]C++[ ]\([1-9]\.[0-9][0-9]*\)/p' | awk '{ print $$NF; }')
-ifeq	(${COMPILER_DATE}, 2001/01/31)
-# disable -g0 in fastdebug since SC6.1 dated 2001/01/31 seems to be buggy
-# use an innocuous value because it will get -g if it's empty
-FASTDEBUG_CFLAGS = -c
-endif
-endif
-
-# Uncomment or 'gmake CFLAGS_BROWSE=-sbfast' to get source browser information.
-# CFLAGS_BROWSE	= -sbfast
-CFLAGS		+= $(CFLAGS_BROWSE)
-
-# ILD is gone as of SS11 (5.8), not supportted in SS10 (5.7)
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 507), 1)
-  # use ild when debugging (but when optimizing we want reproducible results)
-  ILDFLAG = $(ILDFLAG/$(VERSION))
-  ILDFLAG/debug     = -xildon
-  ILDFLAG/optimized =
-  AOUT_FLAGS += $(ILDFLAG)
-endif
-
-# Where to put the *.o files (a.out, or shared library)?
-LINK_INTO = $(LINK_INTO/$(VERSION))
-LINK_INTO/debug = LIBJVM
-LINK_INTO/optimized = LIBJVM
-
-# We link the debug version into the a.out because:
-#  1. ild works on a.out but not shared libraries, and using ild
-#     can cut rebuild times by 25% for small changes. (ILD is gone in SS11)
-#  2. dbx cannot gracefully set breakpoints in shared libraries
-#
-
-# apply this setting to link into the shared library even in the debug version:
-ifdef LP64
-LINK_INTO = LIBJVM
-else
-#LINK_INTO = LIBJVM
-endif
-
-# Also, strip debug and line number information (worth about 1.7Mb).
-# If we can create .debuginfo files, then the VM is stripped in vm.make
-# and this macro is not used.
-STRIP_LIB.CXX/POST_HOOK = $(STRIP) -x $@ || exit 1;
-# STRIP_LIB.CXX/POST_HOOK is incorporated into LINK_LIB.CXX/POST_HOOK
-# in certain configurations, such as product.make.  Other configurations,
-# such as debug.make, do not include the strip operation.
diff --git a/hotspot/make/solaris/makefiles/sparcv9.make b/hotspot/make/solaris/makefiles/sparcv9.make
deleted file mode 100644
index ae2fad4..0000000
--- a/hotspot/make/solaris/makefiles/sparcv9.make
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright (c) 1999, 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.
-#  
-#
-
-ASFLAGS += $(AS_ARCHFLAG)
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 505), 1)
-# When optimized fully, stubGenerator_sparc.cpp 
-# has bogus code for the routine 
-# StubGenerator::generate_flush_callers_register_windows() 
-OPT_CFLAGS/stubGenerator_sparc.o = $(OPT_CFLAGS/SLOWER)
-
-# For now ad_sparc file is compiled with -O2 %%%% remove when adlc is fixed
-OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER)
-
-# CC brings an US-II to its knees compiling the vmStructs asserts under -xO4
-OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2)
-endif
-
-else
-#Options for gcc
-OPT_CFLAGS/stubGenerator_sparc.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER)
-OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2)
-endif
diff --git a/hotspot/make/solaris/makefiles/tiered.make b/hotspot/make/solaris/makefiles/tiered.make
deleted file mode 100644
index da79ade..0000000
--- a/hotspot/make/solaris/makefiles/tiered.make
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-# Sets make macros for making tiered version of VM
-
-TYPE=TIERED
-
-VM_SUBDIR = server
-
-CFLAGS += -DCOMPILER2 -DCOMPILER1
diff --git a/hotspot/make/solaris/makefiles/top.make b/hotspot/make/solaris/makefiles/top.make
deleted file mode 100644
index 0786477..0000000
--- a/hotspot/make/solaris/makefiles/top.make
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-#
-
-# top.make is included in the Makefile in the build directories.
-# It DOES NOT include the vm dependency info in order to be faster.
-# Its main job is to implement the incremental form of make lists.
-# It also:
-#   -builds and runs adlc via adlc.make
-#   -generates JVMTI source and docs via jvmti.make (JSR-163)
-
-# It assumes the following flags are set:
-# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Jvm_Obj_Files
-
-# -- D. Ungar (5/97) from a file by Bill Bush
-
-# Don't override the built-in $(MAKE).
-# Instead, use "gmake" (or "gnumake") from the command line.  --Rose
-#MAKE = gmake
-
-include $(GAMMADIR)/make/altsrc.make
-
-GENERATED   = ../generated
-VM          = $(GAMMADIR)/src/share/vm
-Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED);
-
-Cached_plat = $(GENERATED)/platform.current
-
-AD_Dir   = $(GENERATED)/adfiles
-ADLC     = $(AD_Dir)/adlc
-AD_Spec  = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad)
-AD_Src   = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc)
-AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
-AD_Files = $(AD_Names:%=$(AD_Dir)/%)
-
-# AD_Files_If_Required/COMPILER1 = ad_stuff
-AD_Files_If_Required/COMPILER2 = ad_stuff
-AD_Files_If_Required/TIERED = ad_stuff
-AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE))
-
-# Wierd argument adjustment for "gnumake -j..."
-adjust-mflags   = $(GENERATED)/adjust-mflags
-# If SPEC is set, it's from configure and it's already controlling concurrency
-# for us. Skip setting -j with HOTSPOT_BUILD_JOBS.
-ifeq ($(SPEC), )
-  MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"`
-else
-  MFLAGS-adjusted = -r $(MFLAGS)
-endif
-
-
-# default target: update lists, make vm
-# done in stages to force sequential order with parallel make
-#
-
-default: vm_build_preliminaries the_vm
-	@echo All done.
-
-# This is an explicit dependency for the sake of parallel makes.
-vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff trace_stuff dtrace_stuff
-	@# We need a null action here, so implicit rules don't get consulted.
-
-$(Cached_plat): $(Plat_File)
-	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
-
-# make AD files as necessary
-ad_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f adlc.make $(MFLAGS-adjusted)
-
-# generate JVMTI files from the spec
-jvmti_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f jvmti.make $(MFLAGS-adjusted)
-
-# generate trace files
-trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f trace.make $(MFLAGS-adjusted)
-
-dtrace_stuff: $(Cached_plat) $(adjust-mflags)
-	@$(MAKE) -f dtrace.make dtrace_gen_headers $(MFLAGS-adjusted) GENERATED=$(GENERATED)
-
-# and the VM: must use other makefile with dependencies included
-
-# We have to go to great lengths to get control over the -jN argument
-# to the recursive invocation of vm.make.  The problem is that gnumake
-# resets -jN to -j1 for recursive runs.  (How helpful.)
-# Note that the user must specify the desired parallelism level via a
-# command-line or environment variable name HOTSPOT_BUILD_JOBS.
-$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh
-	@+rm -f $@ $@+
-	@+cat $< > $@+
-	@+chmod +x $@+
-	@+mv $@+ $@
-
-the_vm: vm_build_preliminaries $(adjust-mflags)
-	@$(MAKE) -f vm.make $(MFLAGS-adjusted)
-
-install: the_vm
-	@$(MAKE) -f vm.make $@
-
-# next rules support "make foo.[oi]"
-
-%.o %.i %.s:
-	$(MAKE) -f vm.make $(MFLAGS) $@
-	#$(MAKE) -f vm.make $@
-
-# this should force everything to be rebuilt
-clean:
-	rm -f $(GENERATED)/*.class
-	$(MAKE) -f vm.make $(MFLAGS) clean
-
-# just in case it doesn't, this should do it
-realclean:
-	$(MAKE) -f vm.make $(MFLAGS) clean
-	rm -fr $(GENERATED)
-
-.PHONY: default vm_build_preliminaries
-.PHONY: lists ad_stuff jvmti_stuff trace_stuff the_vm clean realclean
-.PHONY: checks check_os_version install
-
-.NOTPARALLEL:
diff --git a/hotspot/make/solaris/makefiles/trace.make b/hotspot/make/solaris/makefiles/trace.make
deleted file mode 100644
index effe340..0000000
--- a/hotspot/make/solaris/makefiles/trace.make
+++ /dev/null
@@ -1,119 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile (trace.make) is included from the trace.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate trace files.
-
-include $(GAMMADIR)/make/solaris/makefiles/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-# #########################################################################
-
-HAS_ALT_SRC := false
-ifndef OPENJDK
-  ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), )
-    HAS_ALT_SRC := true
-  endif
-endif
-
-TOPDIR      = $(shell echo `pwd`)
-GENERATED   = $(TOPDIR)/../generated
-JvmtiOutDir = $(GENERATED)/jvmtifiles
-TraceOutDir   = $(GENERATED)/tracefiles
-
-TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace
-TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace
-
-# set VPATH so make knows where to look for source files
-Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir)
-VPATH += $(Src_Dirs_V:%=%:)
-
-TraceGeneratedNames =     \
-    traceEventClasses.hpp \
-	traceEventIds.hpp     \
-	traceTypes.hpp
-
-ifeq ($(HAS_ALT_SRC), true)
-TraceGeneratedNames +=  \
-	traceRequestables.hpp \
-    traceEventControl.hpp
-endif
-
-TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%)
-
-XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-TraceXml = $(TraceSrcDir)/trace.xml
-ifeq ($(HAS_ALT_SRC), true)
-  TraceXml = $(TraceAltSrcDir)/trace.xml
-endif
-
-XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \
-    $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \
-    $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml
-ifeq ($(HAS_ALT_SRC), true)
-  XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \
-      $(TraceAltSrcDir)/traceeventtypes.xml
-endif
-
-.PHONY: all clean cleanall
-
-# #########################################################################
-
-all: $(TraceGeneratedFiles)
-
-GENERATE_CODE= \
-  $(QUIETLY) echo $(LOG_INFO) Generating $@; \
-  $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@
-
-$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-ifeq ($(HAS_ALT_SRC), false)
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-else
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS)
-	$(GENERATE_CODE)
-
-endif
-
-# #########################################################################
-
-clean cleanall:
-	rm $(TraceGeneratedFiles)
diff --git a/hotspot/make/solaris/makefiles/vm.make b/hotspot/make/solaris/makefiles/vm.make
deleted file mode 100644
index 270a8ce..0000000
--- a/hotspot/make/solaris/makefiles/vm.make
+++ /dev/null
@@ -1,352 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Rules to build JVM and related libraries, included from vm.make in the build
-# directory.
-
-# Common build rules.
-MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
-include $(MAKEFILES_DIR)/rules.make
-include $(GAMMADIR)/make/altsrc.make
-
-default: build
-
-#----------------------------------------------------------------------
-# Defs
-
-GENERATED     = ../generated
-DEP_DIR       = $(GENERATED)/dependencies
-
-# reads the generated files defining the set of .o's and the .o .h dependencies
--include $(DEP_DIR)/*.d
-
-# read machine-specific adjustments (%%% should do this via buildtree.make?)
-include $(MAKEFILES_DIR)/$(BUILDARCH).make
-
-# set VPATH so make knows where to look for source files
-# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
-# The adfiles directory contains ad_<arch>.[ch]pp.
-# The jvmtifiles directory contains jvmti*.[ch]pp
-Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
-VPATH += $(Src_Dirs_V:%=%:)
-
-# set INCLUDES for C preprocessor
-Src_Dirs_I += $(GENERATED)
-INCLUDES += $(Src_Dirs_I:%=-I%)
-
-# SYMFLAG is used by {dtrace,jsig}.make.
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  # always build with debug info when we can create .debuginfo files
-  # and disable 'lazy debug info' so the .so has everything.
-  SYMFLAG = -g -xs
-else
-  ifeq (${VERSION}, debug)
-    SYMFLAG = -g
-  else
-    SYMFLAG =
-  endif
-endif
-
-# The following variables are defined in the generated flags.make file.
-JDK_VER_DEFS  = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-		-DVERSION_MINOR=$(VERSION_MINOR) \
-		-DVERSION_SECURITY=$(VERSION_SECURITY) \
-	        -DVERSION_PATCH=$(VERSION_PATCH) \
-		-DVERSION_BUILD=$(VERSION_BUILD)
-VM_VER_DEFS   = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-		-DVERSION_STRING="\"$(VERSION_STRING)\""  \
-	        -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \
-		$(JDK_VER_DEFS)
-HS_LIB_ARCH   = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
-BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
-VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
-
-CXXFLAGS =           \
-  ${SYSDEFS}         \
-  ${INCLUDES}        \
-  ${BUILD_USER}      \
-  ${HS_LIB_ARCH}     \
-  ${VM_DISTRO}
-
-# This is VERY important! The version define must only be supplied to vm_version.o
-# If not, ccache will not re-use the cache at all, since the version string might contain
-# a time and date.
-CXXFLAGS/vm_version.o += ${VM_VER_DEFS}
-
-CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
-
-# File specific flags
-CXXFLAGS += $(CXXFLAGS/BYFILE)
-
-# Large File Support
-ifneq ($(LP64), 1)
-CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64
-endif # ifneq ($(LP64), 1)
-
-# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-CFLAGS += $(CFLAGS_WARN)
-
-# Do not use C++ exception handling
-CFLAGS += $(CFLAGS/NOEX)
-
-# Extra flags from gnumake's invocation or environment
-CFLAGS += $(EXTRA_CFLAGS)
-
-# Math Library (libm.so), do not use -lm.
-#    There might be two versions of libm.so on the build system:
-#    libm.so.1 and libm.so.2, and we want libm.so.1.
-#    Depending on the Solaris release being used to build with,
-#    /usr/lib/libm.so could point at a libm.so.2, so we are
-#    explicit here so that the libjvm.so you have built will work on an
-#    older Solaris release that might not have libm.so.2.
-#    This is a critical factor in allowing builds on Solaris 10 or newer
-#    to run on Solaris 8 or 9.
-#
-LIBM=/usr/lib$(ISA_DIR)/libm.so.1
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-# The whole megilla:
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1)
-# Old Comment: List the libraries in the order the compiler was designed for
-# Not sure what the 'designed for' comment is referring too above.
-#   The order may not be too significant anymore, but I have placed this
-#   older libm before libCrun, just to make sure it's found and used first.
-LIBS += -lsocket -lsched -ldl $(LIBM) -lCrun -lthread -ldoor -lc -ldemangle -lnsl
-else
-ifeq ($(COMPILER_REV_NUMERIC), 502)
-# SC6.1 has it's own libm.so: specifying anything else provokes a name conflict.
-LIBS += -ldl -lthread -lsocket -lm -lsched -ldoor -ldemangle
-else
-LIBS += -ldl -lthread -lsocket $(LIBM) -lsched -ldoor -ldemangle
-endif # 502
-endif # 505
-else
-LIBS += -lsocket -lsched -ldl $(LIBM) -lthread -lc -ldemangle
-endif # sparcWorks
-
-LIBS += -lkstat -lrt
-
-# By default, link the *.o into the library, not the executable.
-LINK_INTO$(LINK_INTO) = LIBJVM
-
-JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH)
-
-#----------------------------------------------------------------------
-# jvm_db & dtrace
-include $(MAKEFILES_DIR)/dtrace.make
-
-#----------------------------------------------------------------------
-# JVM
-
-JVM      = jvm
-LIBJVM   = lib$(JVM).so
-
-LIBJVM_DEBUGINFO   = lib$(JVM).debuginfo
-LIBJVM_DIZ         = lib$(JVM).diz
-
-SPECIAL_PATHS:=adlc c1 dist gc opto shark libadt
-
-SOURCE_PATHS=\
-  $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
-      \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
-
-CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
-CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
-
-ifneq ($(INCLUDE_TRACE), false)
-CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \
-  find $(HS_ALT_SRC)/share/vm/jfr -type d; \
-  fi)
-endif
-
-COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
-COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
-
-COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
-COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
-COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
-COMPILER2_PATHS +=  $(GENERATED)/adfiles
-
-# Include dirs per type.
-Src_Dirs/CORE      := $(CORE_PATHS)
-Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
-Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/TIERED    := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
-Src_Dirs/ZERO      := $(CORE_PATHS)
-Src_Dirs/SHARK     := $(CORE_PATHS) $(SHARK_PATHS)
-Src_Dirs := $(Src_Dirs/$(TYPE))
-
-COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\*
-COMPILER1_SPECIFIC_FILES := c1_\*
-SHARK_SPECIFIC_FILES     := shark
-ZERO_SPECIFIC_FILES      := zero
-
-# Always exclude these.
-Src_Files_EXCLUDE += dtrace jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
-
-# Exclude per type.
-Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
-Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
-
-Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
-
-# Special handling of arch model.
-ifeq ($(Platform_arch_model), x86_32)
-Src_Files_EXCLUDE += \*x86_64\*
-endif
-ifeq ($(Platform_arch_model), x86_64)
-Src_Files_EXCLUDE += \*x86_32\*
-endif
-
-# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
-define findsrc
-	$(notdir $(shell find $(1)/. ! -name . -prune \
-		-a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
-		-a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
-endef
-
-Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
-
-Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))))
-
-JVM_OBJ_FILES = $(Obj_Files) $(DTRACE_OBJS)
-
-vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
-
-MAPFILE_SHARE  := $(GAMMADIR)/make/share/makefiles/mapfile-vers
-
-MAPFILE_EXT_SRC := $(HS_ALT_MAKE)/share/makefiles/mapfile-ext
-ifneq ("$(wildcard $(MAPFILE_EXT_SRC))","")
-MAPFILE_EXT     := $(MAPFILE_EXT_SRC)
-endif
-
-mapfile : $(MAPFILE) $(MAPFILE_SHARE) vm.def $(MAPFILE_EXT)
-	rm -f $@
-	cat $(MAPFILE) $(MAPFILE_DTRACE_OPT) \
-	    | $(NAWK) '{                                         \
-	              if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") {  \
-	                  system ("cat ${MAPFILE_SHARE} $(MAPFILE_EXT) vm.def"); \
-	              } else {                                   \
-	                  print $$0;                             \
-	              }                                          \
-	          }' > $@
-
-mapfile_extended : mapfile $(MAPFILE_DTRACE_OPT)
-	rm -f $@
-	cat $^ > $@
-
-vm.def: $(Obj_Files)
-	sh $(GAMMADIR)/make/solaris/makefiles/build_vm_def.sh *.o > $@
-
-
-ifeq ($(LINK_INTO),AOUT)
-  LIBJVM.o                 =
-  LIBJVM_MAPFILE           =
-  LIBS_VM                  = $(LIBS)
-else
-  LIBJVM.o                 = $(JVM_OBJ_FILES)
-  LIBJVM_MAPFILE$(LDNOMAP) = mapfile_extended
-  LFLAGS_VM$(LDNOMAP)      += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
-  LFLAGS_VM                += $(SONAMEFLAG:SONAME=$(LIBJVM))
-  LFLAGS_VM                += -Wl,-z,defs
-ifndef USE_GCC
-  LIBS_VM                  = $(LIBS)
-else
-  # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
-  # get around library dependency and compatibility issues. Must use gcc not
-  # g++ to link.
-  LFLAGS_VM                += $(STATIC_LIBGCC)
-  LIBS_VM                  += $(STATIC_STDCXX) $(LIBS)
-endif
-endif
-
-LFLAGS_VM += $(EXTRA_LDFLAGS)
-
-ifdef USE_GCC
-LINK_VM = $(LINK_LIB.CC)
-else
-LINK_VM = $(LINK_LIB.CXX)
-endif
-# making the library:
-$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE)
-ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
-	@echo $(LOG_INFO) Linking vm...
-	$(QUIETLY) $(LINK_LIB.CXX/PRE_HOOK)
-	$(QUIETLY) $(LINK_VM) $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM)
-	$(QUIETLY) $(LINK_LIB.CXX/POST_HOOK)
-	$(QUIETLY) rm -f $@.1 && ln -s $@ $@.1
-ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
-	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
-  ifeq ($(STRIP_POLICY),all_strip)
-	$(QUIETLY) $(STRIP) $@
-  else
-    ifeq ($(STRIP_POLICY),min_strip)
-	$(QUIETLY) $(STRIP) -x $@
-    # implied else here is no stripping at all
-    endif
-  endif
-  ifeq ($(ZIP_DEBUGINFO_FILES),1)
-	$(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO)
-	$(RM) $(LIBJVM_DEBUGINFO)
-  endif
-endif
-endif # filter -sbfast -xsbfast
-
-
-DEST_SUBDIR        = $(JDK_LIBDIR)/$(VM_SUBDIR)
-DEST_JVM           = $(DEST_SUBDIR)/$(LIBJVM)
-DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO)
-DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
-
-install_jvm: $(LIBJVM)
-	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
-	$(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \
-	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
-	$(QUIETLY) test ! -f $(LIBJVM_DIZ) || \
-	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
-
-#----------------------------------------------------------------------
-# Other files
-
-# Signal interposition library
-include $(MAKEFILES_DIR)/jsig.make
-
-#----------------------------------------------------------------------
-
-build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(LIBJVM_DTRACE) dtraceCheck
-
-install: install_jvm install_jsig
-
-.PHONY: default build install install_jvm
diff --git a/hotspot/make/solaris/platform_amd64 b/hotspot/make/solaris/platform_amd64
deleted file mode 100644
index f85242b..0000000
--- a/hotspot/make/solaris/platform_amd64
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = x86
-
-arch_model = x86_64
-
-os_arch = solaris_x86
-
-os_arch_model = solaris_x86_64
-
-lib_arch = amd64
-
-compiler = sparcWorks
-
-sysdefs = -DSOLARIS -DSPARC_WORKS -DAMD64
diff --git a/hotspot/make/solaris/platform_amd64.gcc b/hotspot/make/solaris/platform_amd64.gcc
deleted file mode 100644
index ebd495b..0000000
--- a/hotspot/make/solaris/platform_amd64.gcc
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = x86
-
-arch_model = x86_64
-
-os_arch = solaris_x86
-
-os_arch_model = solaris_x86_64
-
-lib_arch = amd64
-
-compiler = gcc
-
-sysdefs = -DSOLARIS -D_GNU_SOURCE  -DAMD64
diff --git a/hotspot/make/solaris/platform_i486 b/hotspot/make/solaris/platform_i486
deleted file mode 100644
index 91d4c5e..0000000
--- a/hotspot/make/solaris/platform_i486
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = x86
-
-arch_model = x86_32
-
-os_arch = solaris_x86
-
-os_arch_model = solaris_x86_32
-
-lib_arch = i386
-
-compiler = sparcWorks
-
-sysdefs = -DSOLARIS -DSPARC_WORKS -DIA32
diff --git a/hotspot/make/solaris/platform_i486.gcc b/hotspot/make/solaris/platform_i486.gcc
deleted file mode 100644
index 61d55e1..0000000
--- a/hotspot/make/solaris/platform_i486.gcc
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = x86
-
-arch_model = x86_32
-
-os_arch = solaris_x86
-
-os_arch_model = solaris_x86_32
-
-lib_arch = i386
-
-compiler = gcc
-
-sysdefs = -DSOLARIS -D_GNU_SOURCE -DIA32
diff --git a/hotspot/make/solaris/platform_sparc b/hotspot/make/solaris/platform_sparc
deleted file mode 100644
index 424088e..0000000
--- a/hotspot/make/solaris/platform_sparc
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = solaris_sparc
-
-os_arch_model = solaris_sparc
-
-lib_arch = sparc
-
-compiler = sparcWorks
-
-sysdefs = -DSOLARIS -DSPARC_WORKS -DSPARC
diff --git a/hotspot/make/solaris/platform_sparc.gcc b/hotspot/make/solaris/platform_sparc.gcc
deleted file mode 100644
index 9a900f4..0000000
--- a/hotspot/make/solaris/platform_sparc.gcc
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = solaris_sparc
-
-os_arch_model = solaris_sparc
-
-lib_arch = sparc
-
-compiler = gcc
-
-sysdefs = -DSOLARIS -D_GNU_SOURCE -DSPARC
diff --git a/hotspot/make/solaris/platform_sparcv9 b/hotspot/make/solaris/platform_sparcv9
deleted file mode 100644
index a17dd08..0000000
--- a/hotspot/make/solaris/platform_sparcv9
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = solaris_sparc
-
-os_arch_model = solaris_sparc
-
-lib_arch = sparcv9
-
-compiler = sparcWorks
-
-sysdefs = -DSOLARIS -DSPARC_WORKS -DSPARC
diff --git a/hotspot/make/solaris/platform_sparcv9.gcc b/hotspot/make/solaris/platform_sparcv9.gcc
deleted file mode 100644
index 2824381..0000000
--- a/hotspot/make/solaris/platform_sparcv9.gcc
+++ /dev/null
@@ -1,15 +0,0 @@
-os_family = solaris
-
-arch = sparc
-
-arch_model = sparc
-
-os_arch = solaris_sparc
-
-os_arch_model = solaris_sparc
-
-lib_arch = sparcv9
-
-compiler = gcc
-
-sysdefs = -DSOLARIS -D_GNU_SOURCE -DSPARC
diff --git a/hotspot/src/share/tools/ProjectCreator/ArgsParser.java b/hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java
similarity index 95%
rename from hotspot/src/share/tools/ProjectCreator/ArgsParser.java
rename to hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java
index ca5d0a3..97dff3e 100644
--- a/hotspot/src/share/tools/ProjectCreator/ArgsParser.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  *
  */
 
+package build.tools.projectcreator;
+
 class ArgIterator {
     String[] args;
     int i;
diff --git a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java b/hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java
similarity index 94%
rename from hotspot/src/share/tools/ProjectCreator/BuildConfig.java
rename to hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java
index 0ce7ecf..81e5552 100644
--- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  *
  */
 
+package build.tools.projectcreator;
+
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Vector;
@@ -37,7 +39,7 @@
         if (ci == null) {
             String comp = (String)getField(null, "CompilerVersion");
             try {
-                ci = (CompilerInterface)Class.forName("CompilerInterface" + comp).newInstance();
+                ci = (CompilerInterface)Class.forName("build.tools.projectcreator.CompilerInterface" + comp).newInstance();
             } catch (Exception cnfe) {
                 System.err.println("Cannot find support for compiler " + comp);
                 throw new RuntimeException(cnfe.toString());
@@ -66,6 +68,8 @@
         String buildSpace = getFieldString(null, "BuildSpace");
         String outDir = buildBase;
         String jdkTargetRoot = getFieldString(null, "JdkTargetRoot");
+        String makeBinary = getFieldString(null, "MakeBinary");
+        String makeOutput = expandFormat(getFieldString(null, "MakeOutput"));
 
         put("Id", flavourBuild);
         put("OutputDir", outDir);
@@ -74,6 +78,8 @@
         put("BuildSpace", buildSpace);
         put("OutputDll", outDir + Util.sep + outDll);
         put("JdkTargetRoot", jdkTargetRoot);
+        put("MakeBinary", makeBinary);
+        put("MakeOutput", makeOutput);
 
         context = new String [] {flavourBuild, flavour, build, null};
     }
@@ -148,9 +154,11 @@
         String relativeAltSrcInclude =
             getFieldString(null, "RelativeAltSrcInclude");
         Vector<String> v = getFieldVector(null, "AltRelativeInclude");
-        for (String pathPart : v) {
-            if (path.contains(relativeAltSrcInclude + Util.sep + pathPart))  {
-                return true;
+        if (v != null) {
+            for (String pathPart : v) {
+                if (path.contains(relativeAltSrcInclude + Util.sep + pathPart))  {
+                    return true;
+                }
             }
         }
         return false;
@@ -360,8 +368,7 @@
 
     static boolean appliesToTieredBuild(String cfg) {
         return (cfg != null &&
-                (cfg.startsWith("compiler1") ||
-                 cfg.startsWith("compiler2")));
+                cfg.startsWith("server"));
     }
 
     // Filters out the IgnoreFile and IgnorePaths since they are
@@ -372,7 +379,7 @@
 
     static String getTieredBuildCfg(String cfg) {
         assert appliesToTieredBuild(cfg) : "illegal configuration " + cfg;
-        return "tiered" + cfg.substring(9);
+        return "server";
     }
 
     static Object getField(String cfg, String field) {
@@ -524,7 +531,7 @@
     }
 
     C1DebugConfig() {
-        initNames("compiler1", "debug", "jvm.dll");
+        initNames("client", "debug", "jvm.dll");
         init(getIncludes(), getDefines());
     }
 }
@@ -535,7 +542,7 @@
     }
 
     C1FastDebugConfig() {
-        initNames("compiler1", "fastdebug", "jvm.dll");
+        initNames("client", "fastdebug", "jvm.dll");
         init(getIncludes(), getDefines());
     }
 }
@@ -546,7 +553,7 @@
     }
 
     TieredDebugConfig() {
-        initNames("tiered", "debug", "jvm.dll");
+        initNames("server", "debug", "jvm.dll");
         init(getIncludes(), getDefines());
     }
 }
@@ -557,7 +564,7 @@
     }
 
     TieredFastDebugConfig() {
-        initNames("tiered", "fastdebug", "jvm.dll");
+        initNames("server", "fastdebug", "jvm.dll");
         init(getIncludes(), getDefines());
     }
 }
@@ -576,14 +583,14 @@
 
 class C1ProductConfig extends ProductConfig {
     C1ProductConfig() {
-        initNames("compiler1", "product", "jvm.dll");
+        initNames("client", "product", "jvm.dll");
         init(getIncludes(), getDefines());
     }
 }
 
 class TieredProductConfig extends ProductConfig {
     TieredProductConfig() {
-        initNames("tiered", "product", "jvm.dll");
+        initNames("server", "product", "jvm.dll");
         init(getIncludes(), getDefines());
     }
 }
diff --git a/hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java
similarity index 66%
rename from hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java
rename to hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java
index a81132c..385903e 100644
--- a/hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java
@@ -1,3 +1,29 @@
+/*
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package build.tools.projectcreator;
+
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
 import java.nio.file.SimpleFileVisitor;
diff --git a/hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java
similarity index 98%
rename from hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java
rename to hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java
index cb0fe33..fb7a77f 100644
--- a/hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  *
  */
 
+package build.tools.projectcreator;
+
 import static java.nio.file.FileVisitResult.CONTINUE;
 
 import java.io.IOException;
diff --git a/hotspot/src/share/tools/ProjectCreator/ProjectCreator.java b/hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java
similarity index 97%
rename from hotspot/src/share/tools/ProjectCreator/ProjectCreator.java
rename to hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java
index f1e16ea..d547823 100644
--- a/hotspot/src/share/tools/ProjectCreator/ProjectCreator.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  *
  */
 
+package build.tools.projectcreator;
+
 public class ProjectCreator {
 
    public static void usage() {
diff --git a/hotspot/src/share/tools/ProjectCreator/Util.java b/hotspot/make/src/classes/build/tools/projectcreator/Util.java
similarity index 95%
rename from hotspot/src/share/tools/ProjectCreator/Util.java
rename to hotspot/make/src/classes/build/tools/projectcreator/Util.java
index ca83078..9741c15 100644
--- a/hotspot/src/share/tools/ProjectCreator/Util.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/Util.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  *
  */
 
+package build.tools.projectcreator;
+
 import java.util.*;
 import java.io.File;
 
diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java
similarity index 97%
rename from hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java
rename to hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java
index a87d447..bc0cad7 100644
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  *
  */
 
+package build.tools.projectcreator;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -317,6 +319,18 @@
                               HsArgHandler.STRING
                               ),
 
+               new HsArgRule("-makeBinary",
+                              "MakeBinary",
+                              null,
+                              HsArgHandler.STRING
+                              ),
+
+               new HsArgRule("-makeOutput",
+                              "MakeOutput",
+                              null,
+                              HsArgHandler.STRING
+                              ),
+
               new HsArgRule("-platformName",
                               "PlatformName",
                               null,
@@ -554,10 +568,6 @@
             usage();
         }
 
-        if (BuildConfig.getField(null, "UseToGeneratePch") == null) {
-            throw new RuntimeException("ERROR: need to specify one file to compute PCH, with -useToGeneratePch flag");
-        }
-
         BuildConfig.putField(null, "PlatformObject", this);
     }
 
diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java
similarity index 91%
rename from hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
rename to hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java
index 3225f1e..d44fb04 100644
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
+++ b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  *
  */
 
+package build.tools.projectcreator;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -71,6 +73,7 @@
 
         startTag("PropertyGroup", "Label", "Globals");
         tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}");
+        tagData("Keyword", "MakeFileProj");
         tag("SccProjectName");
         tag("SccLocalPath");
         endTag();
@@ -79,9 +82,8 @@
 
         for (BuildConfig cfg : allConfigs) {
             startTag(cfg, "PropertyGroup", "Label", "Configuration");
-            tagData("ConfigurationType", "DynamicLibrary");
-            tagData("UseOfMfc", "false");
-            tagData("PlatformToolset", "v120");
+            tagData("ConfigurationType", "Makefile");
+            tagData("UseDebugLibraries", "true");
             endTag();
         }
 
@@ -111,6 +113,14 @@
             tag(cfg, "CodeAnalysisRules");
             tag(cfg, "CodeAnalysisRuleAssemblies");
         }
+        for (BuildConfig cfg : allConfigs) {
+            tagData(cfg, "NMakeBuildCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile import-hotspot LOG=info");
+            tagData(cfg, "NMakeReBuildCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile clean-hotspot import-hotspot LOG=info");
+            tagData(cfg, "NMakeCleanCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile clean-hotspot LOG=info");
+            tagData(cfg, "NMakeOutput", cfg.get("MakeOutput") + Util.sep + "jvm.dll");
+            tagData(cfg, "NMakePreprocessorDefinitions", Util.join(";", cfg.getDefines()));
+            tagData(cfg, "NMakeIncludeSearchPath", Util.join(";", cfg.getIncludes()));
+        }
         endTag();
 
         for (BuildConfig cfg : allConfigs) {
@@ -123,11 +133,6 @@
             tagV(cfg.getV("LinkerFlags"));
             endTag();
 
-            startTag("PreLinkEvent");
-            tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription"));
-            tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n")));
-            endTag();
-
             endTag();
         }
 
@@ -162,18 +167,13 @@
         for (BuildConfig cfg : allConfigs) {
             startTag(cfg, "PropertyGroup");
             tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe");
-            // The JVM loads some libraries using a path relative to
-            // itself because it expects to be in a JRE or a JDK. The java
-            // launcher's '-XXaltjvm=' option allows the JVM to be outside
-            // the JRE or JDK so '-Dsun.java.launcher.is_altjvm=true'
-            // forces a fake JAVA_HOME relative path to be used to
-            // find the other libraries. The '-XX:+PauseAtExit' option
+            // Since we run "make hotspot-import", we get the correct jvm.dll by java.exe.
+            // The '-XX:+PauseAtExit' option
             // causes the VM to wait for key press before exiting; this
             // allows any stdout or stderr messages to be seen before
             // the cmdtool exits.
-            tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) "
-                    + "-Dsun.java.launcher.is_altjvm=true "
-                    + "-XX:+UnlockDiagnosticVMOptions -XX:+PauseAtExit");
+            tagData("LocalDebuggerCommandArguments",
+                    "-XX:+UnlockDiagnosticVMOptions -XX:+PauseAtExit");
             tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot"));
             endTag();
         }
@@ -209,11 +209,6 @@
            tagData("UniqueIdentifier", "{" + uuid.toString() + "}");
            endTag();
         }
-        startTag("Filter", "Include", "Resource Files");
-        UUID uuid = UUID.randomUUID();
-        tagData("UniqueIdentifier", "{" + uuid.toString() + "}");
-        tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe");
-        endTag();
         endTag();
 
         //TODO - do I need to split cpp and hpp files?
diff --git a/hotspot/makefiles/symbols/symbols-aix b/hotspot/make/symbols/symbols-aix
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-aix
rename to hotspot/make/symbols/symbols-aix
diff --git a/hotspot/makefiles/symbols/symbols-aix-debug b/hotspot/make/symbols/symbols-aix-debug
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-aix-debug
rename to hotspot/make/symbols/symbols-aix-debug
diff --git a/hotspot/makefiles/symbols/symbols-linux b/hotspot/make/symbols/symbols-linux
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-linux
rename to hotspot/make/symbols/symbols-linux
diff --git a/hotspot/makefiles/symbols/symbols-macosx b/hotspot/make/symbols/symbols-macosx
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-macosx
rename to hotspot/make/symbols/symbols-macosx
diff --git a/hotspot/makefiles/symbols/symbols-shared b/hotspot/make/symbols/symbols-shared
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-shared
rename to hotspot/make/symbols/symbols-shared
diff --git a/hotspot/makefiles/symbols/symbols-solaris b/hotspot/make/symbols/symbols-solaris
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-solaris
rename to hotspot/make/symbols/symbols-solaris
diff --git a/hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler1 b/hotspot/make/symbols/symbols-solaris-dtrace-compiler1
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler1
rename to hotspot/make/symbols/symbols-solaris-dtrace-compiler1
diff --git a/hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler2 b/hotspot/make/symbols/symbols-solaris-dtrace-compiler2
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler2
rename to hotspot/make/symbols/symbols-solaris-dtrace-compiler2
diff --git a/hotspot/makefiles/symbols/symbols-unix b/hotspot/make/symbols/symbols-unix
similarity index 100%
rename from hotspot/makefiles/symbols/symbols-unix
rename to hotspot/make/symbols/symbols-unix
diff --git a/hotspot/make/test/GtestImage.gmk b/hotspot/make/test/GtestImage.gmk
new file mode 100644
index 0000000..f24b1a7
--- /dev/null
+++ b/hotspot/make/test/GtestImage.gmk
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+
+$(foreach v, $(JVM_VARIANTS), \
+  $(eval $(call SetupCopyFiles, COPY_GTEST_$v, \
+      SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \
+      DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \
+      FILES := $(call SHARED_LIBRARY,jvm) gtestLauncher$(EXE_SUFFIX), \
+  )) \
+  $(eval TARGETS += $$(COPY_GTEST_$v)) \
+)
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  $(foreach v, $(JVM_VARIANTS), \
+    $(eval $(call SetupCopyFiles, COPY_GTEST_MSVCR_$v, \
+        DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \
+        FILES := $(MSVCR_DLL) $(MSVCP_DLL), \
+        FLATTEN := true, \
+    )) \
+    $(eval TARGETS += $$(COPY_GTEST_MSVCR_$v)) \
+    $(eval $(call SetupCopyFiles, COPY_GTEST_PDB_$v, \
+        SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \
+        DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \
+        FILES := jvm.pdb gtestLauncher.pdb, \
+    )) \
+    $(eval TARGETS += $$(COPY_GTEST_PDB_$v)) \
+  )
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+  $(foreach v, $(JVM_VARIANTS), \
+    $(eval $(call SetupCopyFiles, COPY_GTEST_STLPORT_$v, \
+        DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \
+        FILES := $(STLPORT_LIB), \
+    )) \
+    $(eval TARGETS += $$(COPY_GTEST_STLPORT_$v)) \
+  )
+endif
+
+all: $(TARGETS)
diff --git a/hotspot/make/test/JtregNative.gmk b/hotspot/make/test/JtregNative.gmk
index 62478ce..4e61967 100644
--- a/hotspot/make/test/JtregNative.gmk
+++ b/hotspot/make/test/JtregNative.gmk
@@ -51,6 +51,7 @@
     $(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \
     $(HOTSPOT_TOPDIR)/test/compiler/calls \
     $(HOTSPOT_TOPDIR)/test/compiler/native \
+    $(HOTSPOT_TOPDIR)/test/testlibrary/jvmti \
     #
 
 # Add conditional directories here when needed.
@@ -62,6 +63,7 @@
 
 ifeq ($(TOOLCHAIN_TYPE), solstudio)
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_liboverflow := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libSimpleClassFileLoadHook := -lc
 endif
 
 BUILD_HOTSPOT_JTREG_OUTPUT_DIR := $(BUILD_OUTPUT)/support/test/hotspot/jtreg/native
diff --git a/hotspot/make/windows/build.bat b/hotspot/make/windows/build.bat
deleted file mode 100644
index d81bb6d..0000000
--- a/hotspot/make/windows/build.bat
+++ /dev/null
@@ -1,85 +0,0 @@
-@echo off
-REM
-REM Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
-REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-REM
-REM This code is free software; you can redistribute it and/or modify it
-REM under the terms of the GNU General Public License version 2 only, as
-REM published by the Free Software Foundation.
-REM
-REM This code is distributed in the hope that it will be useful, but WITHOUT
-REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-REM FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-REM version 2 for more details (a copy is included in the LICENSE file that
-REM accompanied this code).
-REM
-REM You should have received a copy of the GNU General Public License version
-REM 2 along with this work; if not, write to the Free Software Foundation,
-REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-REM
-REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-REM or visit www.oracle.com if you need additional information or have any
-REM questions.
-REM  
-REM
-
-REM Set HotSpotWorkSpace to the directory two steps above this script
-for %%i in ("%~dp0..") do ( set HotSpotWorkSpace=%%~dpi)
-
-REM
-REM Since we don't have uname and we could be cross-compiling,
-REM Use the compiler to determine which ARCH we are building
-REM 
-cl 2>&1 1>&3 | findstr x64>NUL
-if %errorlevel% == 0 goto amd64
-set VCPROJ=%HotSpotWorkSpace%\build\vs-i486\jvm.vcxproj
-set PLATFORM=x86
-goto testmkshome
-:amd64
-set VCPROJ=%HotSpotWorkSpace%\build\vs-amd64\jvm.vcxproj
-set PLATFORM=x64
-goto testmkshome
-
-:testmkshome
-if not "%HOTSPOTMKSHOME%" == "" goto testjavahome
-if exist c:\cygwin\bin set HOTSPOTMKSHOME=c:\cygwin\bin
-if not "%HOTSPOTMKSHOME%" == "" goto testjavahome
-if exist c:\cygwin64\bin set HOTSPOTMKSHOME=c:\cygwin64\bin
-if not "%HOTSPOTMKSHOME%" == "" goto testjavahome
-echo Error: please set variable HOTSPOTMKSHOME to place where 
-echo          your MKS/Cygwin installation is
-echo.
-goto end
-
-:testjavahome
-if not "%JAVA_HOME%" == "" goto testbuildversion
-echo Error: please set variable JAVA_HOME to a bootstrap JDK 
-echo.
-goto end
-
-:testbuildversion
-if "%1" == "compiler1" goto testdebuglevel
-if "%1" == "tiered"    goto testdebuglevel
-goto usage
-
-:testdebuglevel
-if "%2" == "product"   goto build
-if "%2" == "debug"     goto build
-if "%2" == "fastdebug" goto build
-goto usage
-
-:build
-if NOT EXIST %VCPROJ% call %~dp0\create.bat %JAVA_HOME%
-msbuild /Property:Platform=%PLATFORM% /Property:Configuration=%1_%2 /v:m %VCPROJ%
-goto end
-
-:usage
-echo Usage: build version debuglevel
-echo.
-echo where:
-echo version is "compiler1" or "tiered",
-echo debuglevel is "product", "debug" or "fastdebug"
-exit /b 1
-
-:end
-exit /b %errorlevel%
diff --git a/hotspot/make/windows/build.make b/hotspot/make/windows/build.make
deleted file mode 100644
index 603f15c..0000000
--- a/hotspot/make/windows/build.make
+++ /dev/null
@@ -1,253 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Note: this makefile is invoked both from build.bat and from the J2SE
-# control workspace in exactly the same manner; the required
-# environment variables (Variant, WorkSpace, BootStrapDir, BuildUser, HOTSPOT_BUILD_VERSION)
-# are passed in as command line arguments.
-
-# Note: Running nmake or build.bat from the Windows command shell requires
-# that "sh" be accessible on the PATH. An MKS install does this.
-
-# If we haven't set an ARCH yet use x86
-# create.bat and build.bat will set it, if used.
-!ifndef ARCH
-ARCH=x86
-!endif
-
-
-# Must be one of these values (if value comes in from env, can't trust it)
-!if "$(ARCH)" != "x86"
-!if "$(ARCH)" != "ia64"
-ARCH=x86
-!endif
-!endif
-
-# At this point we should be certain that ARCH has a definition
-# now determine the BUILDARCH
-#
-
-# the default BUILDARCH
-BUILDARCH=i486
-
-# Allow control workspace to force Itanium or AMD64 builds with LP64
-ARCH_TEXT=
-!ifdef LP64
-!if "$(LP64)" == "1"
-ARCH_TEXT=64-Bit
-!if "$(ARCH)" == "x86"
-BUILDARCH=amd64
-!else
-BUILDARCH=ia64
-!endif
-!endif
-!endif
-
-!if "$(BUILDARCH)" != "ia64"
-!ifndef CC_INTERP
-!ifndef FORCE_TIERED
-FORCE_TIERED=1
-!endif
-!endif
-!endif
-
-!if "$(BUILDARCH)" == "amd64"
-Platform_arch=x86
-Platform_arch_model=x86_64
-!endif
-!if "$(BUILDARCH)" == "i486"
-Platform_arch=x86
-Platform_arch_model=x86_32
-!endif
-
-# Supply these from the command line or the environment
-#  It doesn't make sense to default this one
-Variant=
-#  It doesn't make sense to default this one
-WorkSpace=
-
-variantDir = windows_$(BUILDARCH)_$(Variant)
-
-realVariant=$(Variant)
-VARIANT_TEXT=Core
-!if "$(Variant)" == "compiler1"
-VARIANT_TEXT=Client
-!elseif "$(Variant)" == "compiler2"
-!if "$(FORCE_TIERED)" == "1"
-VARIANT_TEXT=Server
-realVariant=tiered
-!else
-VARIANT_TEXT=Server
-!endif
-!elseif "$(Variant)" == "tiered"
-VARIANT_TEXT=Tiered
-!endif
-
-#########################################################################
-# Parameters for VERSIONINFO resource for jvm.dll.
-# These can be overridden via the nmake.exe command line.
-# They are overridden by RE during the control builds.
-#
-!include "$(WorkSpace)/make/jdk_version"
-
-# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
-# or make/hotspot_distro.
-!ifndef HOTSPOT_VM_DISTRO
-!ifndef OPENJDK
-!if exists($(WorkSpace)\src\closed)
-!include $(WorkSpace)\make\hotspot_distro
-!else
-!include $(WorkSpace)\make\openjdk_distro
-!endif
-!else
-!include $(WorkSpace)\make\openjdk_distro
-!endif
-!endif
-
-HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(ARCH_TEXT) $(VARIANT_TEXT) VM
-
-# JDK ProductVersion:
-# 1.5.0_<wx>-b<yz> will have DLL version 5.0.wx*10.yz
-# Thus, 1.5.0_10-b04  will be 5.0.100.4
-#       1.6.0-b01     will be 6.0.0.1
-#       1.6.0_01a-b02 will be 6.0.11.2
-#
-# STANDALONE_JDK_* variables are defined in make/jdk_version or on command line
-#
-!if "$(JDK_VER)" == ""
-JDK_VER=$(STANDALONE_JDK_MAJOR_VER),$(STANDALONE_JDK_MINOR_VER),$(STANDALONE_JDK_SECURITY_VER),$(STANDALONE_JDK_PATCH_VER)
-!endif
-!if "$(JDK_DOTVER)" == ""
-JDK_DOTVER=$(STANDALONE_JDK_MAJOR_VER).$(STANDALONE_JDK_MINOR_VER).$(STANDALONE_JDK_SECURITY_VER).$(STANDALONE_JDK_PATCH_VER)
-!endif
-!if "$(VERSION_SHORT)" == ""
-VERSION_SHORT=$(STANDALONE_JDK_MAJOR_VER).$(STANDALONE_JDK_MINOR_VER).$(STANDALONE_JDK_SECURITY_VER)
-!endif
-
-HS_VER=$(JDK_VER)
-HS_DOTVER=$(JDK_DOTVER)
-
-!if "$(HOTSPOT_RELEASE_VERSION)" == ""
-HOTSPOT_RELEASE_VERSION=$(VERSION_STRING)
-!endif
-
-!if "$(HOTSPOT_VERSION_STRING)" == ""
-HOTSPOT_VERSION_STRING=$(HOTSPOT_RELEASE_VERSION)
-!endif
-
-# End VERSIONINFO parameters
-
-# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
-!ifndef OPENJDK
-!if !exists($(WorkSpace)\src\closed)
-OPENJDK=true
-!endif
-!endif
-
-#########################################################################
-
-defaultTarget: product
-
-# The product or release build is an optimized build, and is the default
-
-# note that since all the build targets depend on local.make that BUILDARCH
-# and Platform_arch and Platform_arch_model will get set in local.make
-# and there is no need to pass them thru here on the command line
-#
-product release optimized: checks $(variantDir) $(variantDir)\local.make sanity
-	cd $(variantDir)
-	nmake -nologo -f $(WorkSpace)\make\windows\makefiles\top.make BUILD_FLAVOR=product ARCH=$(ARCH)
-
-# The debug build is an optional build
-debug: checks $(variantDir) $(variantDir)\local.make sanity
-	cd $(variantDir)
-	nmake -nologo -f $(WorkSpace)\make\windows\makefiles\top.make BUILD_FLAVOR=debug ARCH=$(ARCH)
-fastdebug: checks $(variantDir) $(variantDir)\local.make sanity
-	cd $(variantDir)
-	nmake -nologo -f $(WorkSpace)\make\windows\makefiles\top.make BUILD_FLAVOR=fastdebug ARCH=$(ARCH)
-
-# target to create just the directory structure
-tree: checks $(variantDir) $(variantDir)\local.make sanity
-	mkdir $(variantDir)\product
-	mkdir $(variantDir)\debug
-	mkdir $(variantDir)\fastdebug
-
-sanity:
-	@ echo;
-	@ cd $(variantDir)
-	@ nmake -nologo -f $(WorkSpace)\make\windows\makefiles\sanity.make
-	@ cd ..
-	@ echo;
-
-clean: checkVariant
-	- rm -r -f $(variantDir)
-
-$(variantDir):
-	mkdir $(variantDir)
-
-$(variantDir)\local.make: checks
-	@ echo # Generated file					>  $@
-	@ echo Variant=$(realVariant)				>> $@
-	@ echo WorkSpace=$(WorkSpace)				>> $@
-	@ echo BootStrapDir=$(BootStrapDir)			>> $@
-	@ if "$(USERNAME)" NEQ "" echo BuildUser=$(USERNAME)	>> $@
-	@ echo HS_VER=$(HS_VER)					>> $@
-	@ echo HS_DOTVER=$(HS_DOTVER)				>> $@
-	@ echo HS_COMPANY=$(COMPANY_NAME)			>> $@
-	@ echo HS_FILEDESC=$(HS_FILEDESC)			>> $@
-	@ echo HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO)		>> $@
-	@ if "$(OPENJDK)" NEQ "" echo OPENJDK=$(OPENJDK)	>> $@
-	@ echo HS_COPYRIGHT=$(HOTSPOT_VM_COPYRIGHT)		>> $@
-	@ echo HS_NAME=$(PRODUCT_NAME) $(VERSION_SHORT)		>> $@
-	@ echo HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING)	>> $@
-	@ echo JDK_VER=$(JDK_VER)				>> $@
-	@ echo JDK_DOTVER=$(JDK_DOTVER)				>> $@
-	@ echo VERSION_STRING=$(VERSION_STRING)			>> $@
-	@ echo BUILDARCH=$(BUILDARCH)         			>> $@
-	@ echo Platform_arch=$(Platform_arch)        		>> $@
-	@ echo Platform_arch_model=$(Platform_arch_model)	>> $@
-	@ echo CXX=$(CXX)					>> $@
-	@ echo LD=$(LD)						>> $@
-	@ echo MT=$(MT)						>> $@
-	@ echo RC=$(RC)						>> $@
-	@ sh $(WorkSpace)/make/windows/get_msc_ver.sh		>> $@
-	@ if "$(ENABLE_FULL_DEBUG_SYMBOLS)" NEQ "" echo ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) >> $@
-	@ if "$(ZIP_DEBUGINFO_FILES)" NEQ "" echo ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) >> $@
-	@ if "$(RM)" NEQ "" echo RM=$(RM)                       >> $@
-	@ if "$(CP)" NEQ "" echo CP=$(CP)                       >> $@
-	@ if "$(MV)" NEQ "" echo MV=$(MV)                       >> $@
-	@ if "$(ZIPEXE)" NEQ "" echo ZIPEXE=$(ZIPEXE)           >> $@
-
-checks: checkVariant checkWorkSpace
-
-checkVariant:
-	@ if "$(Variant)"=="" echo Need to specify "Variant=[tiered|compiler2|compiler1|core]" && false
-	@ if "$(Variant)" NEQ "tiered" if "$(Variant)" NEQ "compiler2" if "$(Variant)" NEQ "compiler1" if "$(Variant)" NEQ "core" \
-          echo Need to specify "Variant=[tiered|compiler2|compiler1|core]" && false
-
-checkWorkSpace:
-	@ if "$(WorkSpace)"=="" echo Need to specify "WorkSpace=..." && false
-
-checkBuildID:
-	@ if "$(BuildID)"=="" echo Need to specify "BuildID=..." && false
diff --git a/hotspot/make/windows/build_vm_def.sh b/hotspot/make/windows/build_vm_def.sh
deleted file mode 100644
index 7224970..0000000
--- a/hotspot/make/windows/build_vm_def.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This shell script builds a vm.def file for the current VM variant.
-# The .def file exports vtbl symbols which allow the Serviceability
-# Agent to run on Windows. See make/windows/projectfiles/*/vm.def
-# for more information.
-#
-# The script expects to be executed in the directory containing all of
-# the object files.
-
-# Note that we currently do not have a way to set HotSpotMksHome in
-# the batch build, but so far this has not seemed to be a problem. The
-# reason this environment variable is necessary is that it seems that
-# Windows truncates very long PATHs when executing shells like MKS's
-# sh, and it has been found that sometimes `which sh` fails.
-if [ "x$HOTSPOTMKSHOME" != "x" ]; then
- MKS_HOME="$HOTSPOTMKSHOME"
-else
- SH=`which sh`
- MKS_HOME=`dirname "$SH"`
-fi
-
-AWK="$MKS_HOME/awk.exe"
-if [ ! -e $AWK ]; then
-    AWK="$MKS_HOME/gawk.exe"
-fi
-GREP="$MKS_HOME/grep.exe"
-SORT="$MKS_HOME/sort.exe"
-UNIQ="$MKS_HOME/uniq.exe"
-CAT="$MKS_HOME/cat.exe"
-RM="$MKS_HOME/rm.exe"
-DUMPBIN="link.exe /dump"
-export VS_UNICODE_OUTPUT= 
-
-echo "EXPORTS" > vm1.def
-
-# When called from IDE the first param should contain the link version, otherwise may be nill
-if [ "x$1" != "x" ]; then
-LD_VER="$1"
-fi
-
-if [ "x$LD_VER" != "x800" -a  "x$LD_VER" != "x900" -a "x$LD_VER" != "x1000" ]; then
-$DUMPBIN /symbols *.obj | "$GREP" "??_7.*@@6B@" | "$GREP" -v "type_info" | "$AWK" '{print $7}' | "$SORT" | "$UNIQ" > vm2.def
-else
-# Can't use pipes when calling cl.exe or link.exe from IDE. Using transit file vm3.def
-$DUMPBIN /OUT:vm3.def /symbols *.obj 
-"$CAT" vm3.def | "$GREP" "??_7.*@@6B@" | "$GREP" -v "type_info" | "$AWK" '{print $7}' | "$SORT" | "$UNIQ" > vm2.def
-"$RM" -f vm3.def
-fi
-
-"$CAT" vm1.def vm2.def > vm.def
-"$RM" -f vm1.def vm2.def
diff --git a/hotspot/make/windows/create.bat b/hotspot/make/windows/create.bat
deleted file mode 100644
index a2cdaaa..0000000
--- a/hotspot/make/windows/create.bat
+++ /dev/null
@@ -1,198 +0,0 @@
-@echo off
-REM
-REM Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
-REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-REM
-REM This code is free software; you can redistribute it and/or modify it
-REM under the terms of the GNU General Public License version 2 only, as
-REM published by the Free Software Foundation.
-REM
-REM This code is distributed in the hope that it will be useful, but WITHOUT
-REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-REM FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-REM version 2 for more details (a copy is included in the LICENSE file that
-REM accompanied this code).
-REM
-REM You should have received a copy of the GNU General Public License version
-REM 2 along with this work; if not, write to the Free Software Foundation,
-REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-REM
-REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-REM or visit www.oracle.com if you need additional information or have any
-REM questions.
-REM  
-REM
-
-REM This is the interactive build setup script (as opposed to the batch
-REM build execution script). It creates $HotSpotBuildSpace if necessary,
-REM copies the appropriate files out of $HotSpotWorkSpace into it, and
-REM builds and runs ProjectCreator in it. This has the side-effect of creating
-REM the vm.vcproj file in the buildspace, which is then used in Visual C++.
-
-REM
-REM Since we don't have uname and we could be cross-compiling,
-REM Use the compiler to determine which ARCH we are building
-REM 
-REM Note: Running this batch file from the Windows command shell requires
-REM that "grep" be accessible on the PATH. An MKS install does this.
-REM 
-
-cl 2>NUL >NUL
-if %errorlevel% == 0 goto nexttest
-echo Make sure cl.exe is in your PATH before running this script.
-goto end
-
-:nexttest
-grep -V 2>NUL >NUL
-if %errorlevel% == 0 goto testit
-echo Make sure grep.exe is in your PATH before running this script. Either cygwin or MKS should work.
-goto end
-
-
-:testit
-cl 2>&1 | grep "x64" >NUL
-if %errorlevel% == 0 goto amd64
-set ARCH=x86
-set BUILDARCH=i486
-set Platform_arch=x86
-set Platform_arch_model=x86_32
-goto done
-:amd64
-set ARCH=x86
-set BUILDARCH=amd64
-set Platform_arch=x86
-set Platform_arch_model=x86_64
-:done
-
-setlocal
-
-if "%1" == "" goto usage
-
-if not "%2" == "" goto usage
-
-REM Set HotSpotWorkSpace to the directy two steps above this script
-for %%i in ("%~dp0..") do ( set HotSpotWorkSpace=%%~dpi)
-set HotSpotBuildRoot=%HotSpotWorkSpace%build
-set HotSpotBuildSpace=%HotSpotBuildRoot%\vs-%BUILDARCH%
-set HotSpotJDKDist=%1
-
-
-REM figure out MSC version
-for /F %%i in ('sh %HotSpotWorkSpace%/make/windows/get_msc_ver.sh') do set %%i
-
-echo **************************************************************
-echo MSC_VER = "%MSC_VER%" 
-set ProjectFile=%HotSpotBuildSpace%\jvm.vcxproj
-echo %ProjectFile%
-echo **************************************************************
-
-REM Test all variables to see whether the directories they
-REM reference exist
-
-if exist %HotSpotWorkSpace% goto test1
-
-echo Error: directory pointed to by HotSpotWorkSpace
-echo does not exist, or the variable is not set.
-echo.
-goto usage
-
-:test1
-if exist %HotSpotBuildSpace% goto test2
-if not "%HotSpotBuildSpace%" == "" mkdir %HotSpotBuildSpace%
-if exist %HotSpotBuildSpace% goto test2
-echo Error: directory pointed to by HotSpotBuildSpace
-echo does not exist, or the variable is not set.
-echo.
-goto usage
-
-:test2
-if exist %HotSpotJDKDist% goto test3
-echo Error: directory pointed to by %HotSpotJDKDist%
-echo does not exist, or the variable is not set.
-echo.
-goto usage
-
-:test3
-if not "%HOTSPOTMKSHOME%" == "" goto makedir
-if exist c:\cygwin\bin set HOTSPOTMKSHOME=c:\cygwin\bin
-if not "%HOTSPOTMKSHOME%" == "" goto makedir
-if exist c:\cygwin64\bin set HOTSPOTMKSHOME=c:\cygwin64\bin
-if not "%HOTSPOTMKSHOME%" == "" goto makedir
-echo Warning: please set variable HOTSPOTMKSHOME to place where 
-echo          your MKS/Cygwin installation is
-echo.
-goto usage
-
-:generatefiles
-if NOT EXIST %HotSpotBuildSpace%\%1\generated mkdir %HotSpotBuildSpace%\%1\generated
-copy %HotSpotWorkSpace%\make\windows\projectfiles\%1\* %HotSpotBuildSpace%\%1\generated > NUL
-
-REM force regneration of ProjectFile
-if exist %ProjectFile% del %ProjectFile%
-
-echo -- %1 --
-echo # Generated file!                                                        >    %HotSpotBuildSpace%\%1\local.make
-echo # Changing a variable below and then deleting %ProjectFile% will cause  >>    %HotSpotBuildSpace%\%1\local.make
-echo # %ProjectFile% to be regenerated with the new values.  Changing the    >>    %HotSpotBuildSpace%\%1\local.make
-echo # version requires rerunning create.bat.                                >>    %HotSpotBuildSpace%\%1\local.make
-echo.                                      >>    %HotSpotBuildSpace%\%1\local.make
-echo Variant=%1			           >>    %HotSpotBuildSpace%\%1\local.make
-echo WorkSpace=%HotSpotWorkSpace%   	   >>    %HotSpotBuildSpace%\%1\local.make
-echo HOTSPOTWORKSPACE=%HotSpotWorkSpace%   >>    %HotSpotBuildSpace%\%1\local.make
-echo HOTSPOTBUILDROOT=%HotSpotBuildRoot%   >>    %HotSpotBuildSpace%\%1\local.make
-echo HOTSPOTBUILDSPACE=%HotSpotBuildSpace% >>    %HotSpotBuildSpace%\%1\local.make
-echo HOTSPOTJDKDIST=%HotSpotJDKDist%       >>    %HotSpotBuildSpace%\%1\local.make
-echo ARCH=%ARCH%                           >>    %HotSpotBuildSpace%\%1\local.make
-echo BUILDARCH=%BUILDARCH%                 >>    %HotSpotBuildSpace%\%1\local.make
-echo Platform_arch=%Platform_arch%         >>    %HotSpotBuildSpace%\%1\local.make
-echo Platform_arch_model=%Platform_arch_model% >>    %HotSpotBuildSpace%\%1\local.make
-echo MSC_VER=%MSC_VER% 			   >>    %HotSpotBuildSpace%\%1\local.make
-
-for /D %%j in (debug, fastdebug, product) do (
-  if NOT EXIST %HotSpotBuildSpace%\%1\%%j mkdir %HotSpotBuildSpace%\%1\%%j
-)
-
-pushd %HotSpotBuildSpace%\%1\generated
-nmake /nologo
-popd
-
-goto :eof
-
-
-:makedir
-echo NOTE: Using the following settings:
-echo   HotSpotWorkSpace=%HotSpotWorkSpace%
-echo   HotSpotBuildSpace=%HotSpotBuildSpace%
-echo   HotSpotJDKDist=%HotSpotJDKDist%
-
-echo COPYFILES %BUILDARCH%
-call :generatefiles compiler1
-call :generatefiles tiered
-
-pushd %HotSpotBuildRoot%
-REM It doesn't matter which variant we use here, "tiered" is as good as any of the others - we need the common variables
-nmake /nologo /F %HotSpotWorkSpace%/make/windows/projectfiles/common/Makefile LOCAL_MAKE=%HotSpotBuildSpace%\tiered\local.make %ProjectFile%
-
-popd
-
-goto end
-
-:usage
-echo Usage: create HotSpotJDKDist
-echo.
-echo This is the VS build setup script (as opposed to the batch
-echo build execution script). It creates a build directory if necessary,
-echo copies the appropriate files out of the workspace into it, and
-echo builds and runs ProjectCreator in it. This has the side-effect of creating
-echo the %ProjectFile% file in the build space, which is then used in Visual C++.
-echo.
-echo The HotSpotJDKDist defines the JDK that should be used when running the JVM.
-echo Environment variable FORCE_MSC_VER allows to override MSVC version autodetection.
-echo.
-echo NOTE that it is now NOT safe to modify any of the files in the build
-echo space, since they may be overwritten whenever this script is run or
-echo nmake is run in that directory.
-
-:end
-
-endlocal
diff --git a/hotspot/make/windows/create_obj_files.sh b/hotspot/make/windows/create_obj_files.sh
deleted file mode 100644
index 685f7f3..0000000
--- a/hotspot/make/windows/create_obj_files.sh
+++ /dev/null
@@ -1,167 +0,0 @@
-#
-# Copyright (c) 2010, 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
-# 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.
-#  
-#
-
-set -e
-
-# Note that we currently do not have a way to set HotSpotMksHome in
-# the batch build, but so far this has not seemed to be a problem. The
-# reason this environment variable is necessary is that it seems that
-# Windows truncates very long PATHs when executing shells like MKS's
-# sh, and it has been found that sometimes `which sh` fails.
-
-if [ "x$HotSpotMksHome" != "x" ]; then
-  TOOL_DIR="$HotSpotMksHome"
-else
-  # HotSpotMksHome is not set so use the directory that contains "sh".
-  # This works with both MKS and Cygwin.
-  SH=`which sh`
-  TOOL_DIR=`dirname "$SH"`
-fi
-
-DIRNAME="$TOOL_DIR/dirname"
-FIND="$TOOL_DIR/find"
-
-TYPE=$1
-Platform_arch=$2
-Platform_arch_model=$3
-Platform_os_family=windows
-Platform_os_arch=windows_$Platform_arch
-
-WorkSpace=$4
-GENERATED=$5
-
-COMMONSRC_REL=src
-ALTSRC_REL=src/closed # Change this to pick up alt sources from somewhere else
-
-COMMONSRC=${WorkSpace}/${COMMONSRC_REL}
-if [ "x$OPENJDK" != "xtrue" ]; then
-  ALTSRC=${WorkSpace}/${ALTSRC_REL}
-else
-  ALTSRC=PATH_THAT_DOES_NOT_EXIST
-fi
-
-BASE_PATHS="`if [ -d ${ALTSRC}/share/vm ]; then $FIND ${ALTSRC}/share/vm ! -name vm -prune -type d \! \( -name adlc -o -name c1 -o -name gc -o -name opto -o -name shark -o -name libadt \); fi`"
-BASE_PATHS="${BASE_PATHS} ` $FIND ${COMMONSRC}/share/vm ! -name vm -prune -type d \! \( -name adlc -o -name c1 -o -name gc -o -name opto -o -name shark -o -name libadt \)`"
-
-for sd in \
-    share/vm/gc/shared \
-    os/${Platform_os_family}/vm \
-    cpu/${Platform_arch}/vm \
-    os_cpu/${Platform_os_arch}/vm; do 
-  if [ -d "${ALTSRC}/${sd}" ]; then
-    BASE_PATHS="${BASE_PATHS} ${ALTSRC}/${sd}"
-  fi
-  BASE_PATHS="${BASE_PATHS} ${COMMONSRC}/${sd}"
-done
-
-BASE_PATHS="${BASE_PATHS} ${GENERATED}/jvmtifiles ${GENERATED}/tracefiles"
-
-if [ -d "${ALTSRC}/share/vm/jfr/buffers" ]; then
-  BASE_PATHS="${BASE_PATHS} ${ALTSRC}/share/vm/jfr/buffers"
-fi
-
-BASE_PATHS="${BASE_PATHS} ${COMMONSRC}/share/vm/prims/wbtestmethods"
-
-# shared is already in BASE_PATHS. Should add vm/memory but that one is also in BASE_PATHS.
-if [ -d "${ALTSRC}/share/vm/gc" ]; then
-  BASE_PATHS="${BASE_PATHS} `$FIND ${ALTSRC}/share/vm/gc ! -name gc -prune -type d \! -name shared`"
-fi
-BASE_PATHS="${BASE_PATHS} `$FIND ${COMMONSRC}/share/vm/gc ! -name gc -prune -type d \! -name shared`"
-
-if [ -d "${ALTSRC}/share/vm/c1" ]; then
-  COMPILER1_PATHS="${ALTSRC}/share/vm/c1"
-fi
-COMPILER1_PATHS="${COMPILER1_PATHS} ${COMMONSRC}/share/vm/c1"
-
-if [ -d "${ALTSRC}/share/vm/opto" ]; then
-  COMPILER2_PATHS="${ALTSRC}/share/vm/opto"
-fi
-COMPILER2_PATHS="${COMPILER2_PATHS} ${COMMONSRC}/share/vm/opto"
-if [ -d "${ALTSRC}/share/vm/libadt" ]; then
-  COMPILER2_PATHS="${COMPILER2_PATHS} ${ALTSRC}/share/vm/libadt"
-fi
-COMPILER2_PATHS="${COMPILER2_PATHS} ${COMMONSRC}/share/vm/libadt"
-COMPILER2_PATHS="${COMPILER2_PATHS} ${GENERATED}/adfiles"
-
-# Include dirs per type.
-case "${TYPE}" in
-    "compiler1") Src_Dirs="${BASE_PATHS} ${COMPILER1_PATHS}" ;;
-    "compiler2") Src_Dirs="${BASE_PATHS} ${COMPILER2_PATHS}" ;;
-    "tiered")    Src_Dirs="${BASE_PATHS} ${COMPILER1_PATHS} ${COMPILER2_PATHS}" ;;
-    "zero")      Src_Dirs="${BASE_PATHS}" ;;
-    "shark")     Src_Dirs="${BASE_PATHS}" ;;
-esac
-
-COMPILER2_SPECIFIC_FILES="opto libadt bcEscapeAnalyzer.cpp c2_* runtime_*"
-COMPILER1_SPECIFIC_FILES="c1_*"
-JVMCI_SPECIFIC_FILES="*jvmci* *JVMCI*"
-SHARK_SPECIFIC_FILES="shark"
-ZERO_SPECIFIC_FILES="zero"
-
-# Always exclude these.
-Src_Files_EXCLUDE="jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp"
-
-# Exclude per type.
-case "${TYPE}" in
-    "compiler1") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER2_SPECIFIC_FILES} ${JVMCI_SPECIFIC_FILES} ${ZERO_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES} ciTypeFlow.cpp" ;;
-    "compiler2") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER1_SPECIFIC_FILES} ${ZERO_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES}" ;;
-    "tiered")    Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${ZERO_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES}" ;;
-    "zero")      Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER1_SPECIFIC_FILES} ${COMPILER2_SPECIFIC_FILES} ${JVMCI_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES} ciTypeFlow.cpp" ;;
-    "shark")     Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER1_SPECIFIC_FILES} ${COMPILER2_SPECIFIC_FILES} ${JVMCI_SPECIFIC_FILES} ${ZERO_SPECIFIC_FILES}" ;;
-esac
-
-# Special handling of arch model.
-case "${Platform_arch_model}" in
-	"x86_32") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} *x86_64* ${JVMCI_SPECIFIC_FILES}" ;;
-	"x86_64") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} *x86_32*" ;;
-esac
-
-# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
-function findsrc {
-    $FIND ${1}/. ! -name . -prune \
-		-a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
-		-a \! \( -name ${Src_Files_EXCLUDE// / -o -name } \) \
-		| sed 's/.*\/\(.*\)/\1/';
-}
-
-Src_Files=
-for e in ${Src_Dirs}; do
-   Src_Files="${Src_Files}`findsrc ${e}` "
-done 
-
-Obj_Files=" "
-for e in ${Src_Files}; do
-        o="${e%\.[!.]*}.obj"
-        set +e
-        chk=`expr "${Obj_Files}" : ".* $o"`
-        set -e
-        if [ "$chk" != 0 ]; then
-             echo "# INFO: skipping duplicate $o"
-             continue
-        fi
-	Obj_Files="${Obj_Files}$o "
-done
-Obj_Files=`echo ${Obj_Files} | tr ' ' '\n' | LC_ALL=C sort`
-
-echo Obj_Files=${Obj_Files}
diff --git a/hotspot/make/windows/cross_build.bat b/hotspot/make/windows/cross_build.bat
deleted file mode 100644
index 36eac52..0000000
--- a/hotspot/make/windows/cross_build.bat
+++ /dev/null
@@ -1,61 +0,0 @@
-@echo off
-REM
-REM Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
-REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-REM
-REM This code is free software; you can redistribute it and/or modify it
-REM under the terms of the GNU General Public License version 2 only, as
-REM published by the Free Software Foundation.
-REM
-REM This code is distributed in the hope that it will be useful, but WITHOUT
-REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-REM FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-REM version 2 for more details (a copy is included in the LICENSE file that
-REM accompanied this code).
-REM
-REM You should have received a copy of the GNU General Public License version
-REM 2 along with this work; if not, write to the Free Software Foundation,
-REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-REM
-REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-REM or visit www.oracle.com if you need additional information or have any
-REM questions.
-REM  
-REM
-
-REM Cross compile IA64 compiler2 VM
-REM Usage:
-REM cross_compile flavor workspace bootstrap_dir [build_id]
-REM                 %1       %2             %3      %4
-REM
-REM Set current directory
-for /F %%i in ('cd') do set CD=%%i
-echo Setting up Visual C++ Compilation Environment
-if "%MSVCDir%" == "" goto setdir1
-goto setenv1
-:setdir1
-SET MSVCDir=C:\Program Files\Microsoft Visual Studio\VC98
-:setenv1
-SET OLDINCLUDE=%INCLUDE%
-SET OLDLIB=%LIB%
-SET OLDPATH=%PATH%
-call "%MSVCDir%\Bin\VCVARS32"
-call %2\make\windows\build %1 adlc %2 %3 %4
-SET INCLUDE=%OLDINCLUDE%
-SET LIB=%OLDLIB%
-SET PATH=%OLDPATH%
-echo Setting up 64-BIT Compilation Environment
-if "%MSSdk%" == "" goto setdir2
-goto setenv2
-:setdir2
-SET MSSdk=C:\Program Files\Microsoft SDK
-:setenv2
-call "%MSSdk%\SetEnv.bat" /XP64
-SET ALT_ADLC_PATH=%CD%\windows_i486_compiler2\generated
-call %2\make\windows\build %1 compiler2 %2 %3 %4
-SET INCLUDE=%OLDINCLUDE%
-SET LIB=%OLDLIB%
-SET PATH=%OLDPATH%
-SET OLDINCLUDE=
-SET OLDLIB=
-SET OLDPATH=
diff --git a/hotspot/make/windows/get_msc_ver.sh b/hotspot/make/windows/get_msc_ver.sh
deleted file mode 100644
index 89c7a3f..0000000
--- a/hotspot/make/windows/get_msc_ver.sh
+++ /dev/null
@@ -1,93 +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.
-#  
-#
-
-set -e
-
-# This shell script echoes "MSC_VER=<munged version of cl>"
-# It ignores the micro version component.
-# Examples:
-# cl version 12.00.8804 returns "MSC_VER=1200"
-# cl version 13.10.3077 returns "MSC_VER=1310"
-# cl version 14.00.30701 returns "MSC_VER=1399" (OLD_MSSDK version)
-# cl version 14.00.40310.41 returns "MSC_VER=1400"
-# cl version 15.00.21022.8 returns "MSC_VER=1500"
-
-# Note that we currently do not have a way to set HotSpotMksHome in
-# the batch build, but so far this has not seemed to be a problem. The
-# reason this environment variable is necessary is that it seems that
-# Windows truncates very long PATHs when executing shells like MKS's
-# sh, and it has been found that sometimes `which sh` fails.
-
-if [ "x$HotSpotMksHome" != "x" ]; then
-  TOOL_DIR="$HotSpotMksHome"
-else
-  # HotSpotMksHome is not set so use the directory that contains "sh".
-  # This works with both MKS and Cygwin.
-  SH=`which sh`
-  TOOL_DIR=`dirname "$SH"`
-fi
-
-DIRNAME="$TOOL_DIR/dirname"
-HEAD="$TOOL_DIR/head"
-ECHO="$TOOL_DIR/echo"
-EXPR="$TOOL_DIR/expr"
-CUT="$TOOL_DIR/cut"
-SED="$TOOL_DIR/sed"
-
-if [ "x$FORCE_MSC_VER" != "x" ]; then
-  echo "MSC_VER=$FORCE_MSC_VER"
-else
-  MSC_VER_RAW=`cl 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
-  MSC_VER_MAJOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f1`
-  MSC_VER_MINOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f2`
-  MSC_VER_MICRO=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f3`
-  if [ "${MSC_VER_MAJOR}" -eq 14 -a "${MSC_VER_MINOR}" -eq 0 -a "${MSC_VER_MICRO}" -eq 30701 ] ; then
-    # This said 1400 but it was really more like VS2003 (VC7) in terms of options
-    MSC_VER=1399
-  else
-    MSC_VER=`"$EXPR" $MSC_VER_MAJOR \* 100 + $MSC_VER_MINOR`
-  fi
-  echo "MSC_VER=$MSC_VER"
-  echo "MSC_VER_RAW=$MSC_VER_RAW"
-fi
-
-if [ "x$FORCE_LD_VER" != "x" ]; then
-  echo "LD_VER=$FORCE_LD_VER"
-else
-  # use the "link" command that is co-located with the "cl" command
-  cl_cmd=`which cl`
-  if [ "x$cl_cmd" != "x" ]; then
-    link_cmd=`$DIRNAME "$cl_cmd"`/link
-  else
-    # which can't find "cl" so just use which ever "link" we find
-    link_cmd="link"
-  fi
-  LD_VER_RAW=`"$link_cmd" 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
-  LD_VER_MAJOR=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f1`
-  LD_VER_MINOR=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f2`
-  LD_VER_MICRO=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f3`
-  LD_VER=`"$EXPR" $LD_VER_MAJOR \* 100 + $LD_VER_MINOR`
-  echo "LD_VER=$LD_VER"
-  echo "LD_VER_RAW=$LD_VER_RAW"
-fi
diff --git a/hotspot/make/windows/jvmexp.lcf b/hotspot/make/windows/jvmexp.lcf
deleted file mode 100644
index 6489d02..0000000
--- a/hotspot/make/windows/jvmexp.lcf
+++ /dev/null
@@ -1,10 +0,0 @@
--export:JNI_GetDefaultJavaVMInitArgs
--export:JNI_CreateJavaVM
--export:JNI_GetCreatedJavaVMs
-
--export:jio_snprintf
--export:jio_printf
--export:jio_fprintf
--export:jio_vfprintf
--export:jio_vsnprintf
-
diff --git a/hotspot/make/windows/jvmexp_g.lcf b/hotspot/make/windows/jvmexp_g.lcf
deleted file mode 100644
index 6489d02..0000000
--- a/hotspot/make/windows/jvmexp_g.lcf
+++ /dev/null
@@ -1,10 +0,0 @@
--export:JNI_GetDefaultJavaVMInitArgs
--export:JNI_CreateJavaVM
--export:JNI_GetCreatedJavaVMs
-
--export:jio_snprintf
--export:jio_printf
--export:jio_fprintf
--export:jio_vfprintf
--export:jio_vsnprintf
-
diff --git a/hotspot/make/windows/makefiles/adlc.make b/hotspot/make/windows/makefiles/adlc.make
deleted file mode 100644
index 781e3ac..0000000
--- a/hotspot/make/windows/makefiles/adlc.make
+++ /dev/null
@@ -1,119 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-
-# Rules for building adlc.exe
-
-# Need exception handling support here
-# $(MS_RUNTIME_OPTION) ( with /D_STATIC_CPPLIB)
-# causes adlc.exe to link with the static
-# multithread Standard C++ library (libcpmt.lib) instead of
-# the dynamic version (msvcprt.lib), which is not included
-# in any of the free tools.
-EXH_FLAGS=$(GX_OPTION) $(MS_RUNTIME_OPTION)
-
-!ifdef ALT_ADLC_PATH
-ADLC=$(ALT_ADLC_PATH)\adlc.exe
-!else
-ADLC=adlc
-!endif
-
-!ifdef LP64
-ADLCFLAGS=-q -T -D_LP64
-!else
-ADLCFLAGS=-q -T -U_LP64
-!endif
-
-ADLC_CXX_FLAGS=$(CXX_FLAGS) /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
-
-CXX_INCLUDE_DIRS=\
-  /I "..\generated" \
-  /I "$(WorkSpace)\src\share\vm" \
-  /I "$(WorkSpace)\src\os\windows\vm" \
-  /I "$(WorkSpace)\src\cpu\$(Platform_arch)\vm"
-
-!if "$(Platform_arch_model)" == "$(Platform_arch)"
-SOURCES_AD=\
-  $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad 
-!else
-SOURCES_AD=\
-  $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad \
-  $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch).ad 
-!endif
-
-# NOTE! If you add any files here, you must also update GENERATED_NAMES_IN_DIR
-# and ProjectCreatorIDEOptions in projectcreator.make. 
-GENERATED_NAMES=\
-  ad_$(Platform_arch_model).cpp \
-  ad_$(Platform_arch_model).hpp \
-  ad_$(Platform_arch_model)_clone.cpp \
-  ad_$(Platform_arch_model)_expand.cpp \
-  ad_$(Platform_arch_model)_format.cpp \
-  ad_$(Platform_arch_model)_gen.cpp \
-  ad_$(Platform_arch_model)_misc.cpp \
-  ad_$(Platform_arch_model)_peephole.cpp \
-  ad_$(Platform_arch_model)_pipeline.cpp \
-  adGlobals_$(Platform_arch_model).hpp \
-  dfa_$(Platform_arch_model).cpp
-
-# NOTE! This must be kept in sync with GENERATED_NAMES
-GENERATED_NAMES_IN_DIR=\
-  $(AdlcOutDir)\ad_$(Platform_arch_model).cpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model).hpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model)_clone.cpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model)_expand.cpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model)_format.cpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model)_gen.cpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model)_misc.cpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model)_peephole.cpp \
-  $(AdlcOutDir)\ad_$(Platform_arch_model)_pipeline.cpp \
-  $(AdlcOutDir)\adGlobals_$(Platform_arch_model).hpp \
-  $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp
-
-{$(WorkSpace)\src\share\vm\adlc}.cpp.obj::
-        $(CXX) $(ADLC_CXX_FLAGS) $(EXH_FLAGS) $(CXX_INCLUDE_DIRS) /c $<
-
-{$(WorkSpace)\src\share\vm\opto}.cpp.obj::
-        $(CXX) $(ADLC_CXX_FLAGS) $(EXH_FLAGS) $(CXX_INCLUDE_DIRS) /c $<
-
-adlc.exe: main.obj adlparse.obj archDesc.obj arena.obj dfa.obj dict2.obj filebuff.obj \
-          forms.obj formsopt.obj formssel.obj opcodes.obj output_c.obj output_h.obj
-	$(LD) $(LD_FLAGS) /subsystem:console /out:$@ $**
-!if "$(MT)" != ""
-# The previous link command created a .manifest file that we want to
-# insert into the linked artifact so we do not need to track it
-# separately.  Use ";#2" for .dll and ";#1" for .exe:
-	$(MT) /manifest $@.manifest /outputresource:$@;#1
-!endif
-
-$(GENERATED_NAMES_IN_DIR): $(Platform_arch_model).ad adlc.exe
-	rm -f $(GENERATED_NAMES)
-	if exist $(AdlcOutDir) rmdir /s /q $(AdlcOutDir)
-	mkdir $(AdlcOutDir)
-	$(ADLC) $(ADLCFLAGS) $(Platform_arch_model).ad
-	mv $(GENERATED_NAMES) $(AdlcOutDir)/
-
-$(Platform_arch_model).ad: $(SOURCES_AD)
-	rm -f $(Platform_arch_model).ad
-	cat $(SOURCES_AD) >$(Platform_arch_model).ad
diff --git a/hotspot/make/windows/makefiles/compile.make b/hotspot/make/windows/makefiles/compile.make
deleted file mode 100644
index 0af2574..0000000
--- a/hotspot/make/windows/makefiles/compile.make
+++ /dev/null
@@ -1,197 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Generic compiler settings
-!if "x$(CXX)" == "x"
-CXX=cl.exe
-!endif
-
-# CXX Flags: (these vary slightly from VC6->VS2003->VS2005 compilers)
-#   /nologo   Supress copyright message at every cl.exe startup
-#   /W3       Warning level 3
-#   /Zi       Include debugging information
-#   /d2Zi+    Extended debugging symbols for optimized code (/Zo in VS2013 Update 3 and later)
-#   /WX       Treat any warning error as a fatal error
-#   /MD       Use dynamic multi-threaded runtime (msvcrt.dll or msvc*NN.dll)
-#   /MTd      Use static multi-threaded runtime debug versions
-#   /O1       Optimize for size (/Os), skips /Oi
-#   /O2       Optimize for speed (/Ot), adds /Oi to /O1
-#   /Ox       Old "all optimizations flag" for VC6 (in /O1)
-#   /Oy       Use frame pointer register as GP reg (in /Ox and /O1)
-#   /GF       Merge string constants and put in read-only memory (in /O1)
-#   /Gy       Func level link (in /O1, allows for link-time func ordering)
-#   /Gs       Inserts stack probes (in /O1)
-#   /GS       Inserts security stack checks in some functions (VS2005 default)
-#   /Oi       Use intrinsics (in /O2)
-#   /Od       Disable all optimizations
-#   /MP       Use multiple cores for compilation
-#
-# NOTE: Normally following any of the above with a '-' will turn off that flag
-#
-# 6655385: For VS2003/2005 we now specify /Oy- (disable frame pointer
-# omission.)  This has little to no effect on performance while vastly
-# improving the quality of crash log stack traces involving jvm.dll.
-
-# These are always used in all compiles
-CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3
-
-!if "$(WARNINGS_AS_ERRORS)" != "false"
-CXX_FLAGS=$(CXX_FLAGS) /WX
-!endif
-
-# Let's add debug information when Full Debug Symbols is enabled
-!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
-CXX_FLAGS=$(CXX_FLAGS) /Zi /d2Zi+
-!endif
-
-# Based on BUILDARCH we add some flags and select the default compiler name
-!if "$(BUILDARCH)" == "ia64"
-MACHINE=IA64
-CXX_FLAGS=$(CXX_FLAGS) /D "CC_INTERP" /D "_LP64" /D "IA64"
-!endif
-
-!if "$(BUILDARCH)" == "amd64"
-MACHINE=AMD64
-CXX_FLAGS=$(CXX_FLAGS) /D "_LP64" /D "AMD64"
-LP64=1
-!endif
-
-!if "$(BUILDARCH)" == "i486"
-MACHINE=I386
-# VS2013 generates bad l2f without /arch:IA32
-CXX_FLAGS=$(CXX_FLAGS) /D "IA32" /arch:IA32
-!endif
-
-CXX_FLAGS=$(CXX_FLAGS) /D "WIN32" /D "_WINDOWS"
-# Must specify this for sharedRuntimeTrig.cpp
-CXX_FLAGS=$(CXX_FLAGS) /D "VM_LITTLE_ENDIAN"
-
-# Used for platform dispatching
-CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_FAMILY_windows
-CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_$(Platform_arch)
-CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model)
-CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch)
-CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model)
-CXX_FLAGS=$(CXX_FLAGS) /D TARGET_COMPILER_visCPP
-
-
-# MSC_VER is a 4 digit number that tells us what compiler is being used
-#    and is generated when the local.make file is created by build.make
-#    via the script get_msc_ver.sh
-#
-#    If MSC_VER is set, it overrides the above default setting.
-#    But it should be set.
-#    Possible values:
-#      1200 is for VC6
-#      1300 and 1310 is VS2003 or VC7
-#      1399 is our fake number for the VS2005 compiler that really isn't 1400
-#      1400 is for VS2005
-#      1500 is for VS2008
-#      1600 is for VS2010
-#      1700 is for VS2012
-#      1800 is for VS2013
-#    Do not confuse this MSC_VER with the predefined macro _MSC_VER that the
-#    compiler provides, when MSC_VER==1399, _MSC_VER will be 1400.
-#    Normally they are the same, but a pre-release of the VS2005 compilers
-#    in the Windows 64bit Platform SDK said it was 1400 when it was really
-#    closer to VS2003 in terms of option spellings, so we use 1399 for that
-#    1400 version that really isn't 1400.
-#    See the file get_msc_ver.sh for more info.
-
-# By default, we do not want to use the debug version of the msvcrt.dll file
-#   but if MFC_DEBUG is defined in the environment it will be used.
-MS_RUNTIME_OPTION = /MD
-!if "$(MFC_DEBUG)" == "true"
-MS_RUNTIME_OPTION = /MTd /D "_DEBUG"
-!endif
-
-# VS2012 and later won't work with:
-#     /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
-!if "$(MSC_VER)" < "1700"
-# Always add the _STATIC_CPPLIB flag
-STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
-MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION)
-!endif
-CXX_FLAGS=$(CXX_FLAGS) $(MS_RUNTIME_OPTION)
-
-PRODUCT_OPT_OPTION   = /O2 /Oy-
-FASTDEBUG_OPT_OPTION = /O2 /Oy-
-DEBUG_OPT_OPTION     = /Od
-GX_OPTION = /EHsc
-LD_FLAGS = /manifest $(LD_FLAGS)
-MP_FLAG = /MP
-# Manifest Tool - used in VS2005 and later to adjust manifests stored
-# as resources inside build artifacts.
-!if "x$(MT)" == "x"
-MT=mt.exe
-!endif
-!if "$(BUILDARCH)" == "i486"
-LD_FLAGS = /SAFESEH $(LD_FLAGS)
-!endif
-
-CXX_FLAGS = $(CXX_FLAGS) $(MP_FLAG)
-
-# If NO_OPTIMIZATIONS is defined in the environment, turn everything off
-!ifdef NO_OPTIMIZATIONS
-PRODUCT_OPT_OPTION   = $(DEBUG_OPT_OPTION)
-FASTDEBUG_OPT_OPTION = $(DEBUG_OPT_OPTION)
-!endif
-
-# Generic linker settings
-!if "x$(LD)" == "x"
-LD=link.exe
-!endif
-LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
- comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
- uuid.lib Wsock32.lib winmm.lib version.lib /nologo /machine:$(MACHINE) /opt:REF \
- /opt:ICF,8
-!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
-LD_FLAGS= $(LD_FLAGS) /map /debug
-!endif
-
-
-!if $(MSC_VER) >= 1600
-LD_FLAGS= $(LD_FLAGS) psapi.lib
-!endif
-
-# Resource compiler settings
-!if "x$(RC)" == "x"
-RC=rc.exe
-!endif
-RC_FLAGS=/D "HS_VER=$(HS_VER)" \
-	 /D "HS_DOTVER=$(HS_DOTVER)" \
-	 /D "HS_BUILD_ID=$(HS_BUILD_ID)" \
-	 /D "JDK_VER=$(JDK_VER)" \
-	 /D "JDK_DOTVER=$(JDK_DOTVER)" \
-	 /D "HS_COMPANY=$(HS_COMPANY)" \
-	 /D "HS_FILEDESC=$(HS_FILEDESC)" \
-	 /D "HS_COPYRIGHT=$(HS_COPYRIGHT)" \
-	 /D "HS_FNAME=$(HS_FNAME)" \
-	 /D "HS_INTERNAL_NAME=$(HS_INTERNAL_NAME)" \
-	 /D "HS_NAME=$(HS_NAME)"
-
-# Need this to match the CXX_FLAGS settings
-!if "$(MFC_DEBUG)" == "true"
-RC_FLAGS = $(RC_FLAGS) /D "_DEBUG"
-!endif
diff --git a/hotspot/make/windows/makefiles/debug.make b/hotspot/make/windows/makefiles/debug.make
deleted file mode 100644
index 3ad4562..0000000
--- a/hotspot/make/windows/makefiles/debug.make
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-HS_INTERNAL_NAME=jvm
-HS_FNAME=$(HS_INTERNAL_NAME).dll
-AOUT=$(HS_FNAME)
-GENERATED=../generated
-
-# Allow the user to turn off precompiled headers from the command line.
-!if "$(USE_PRECOMPILED_HEADER)" != "0"
-BUILD_PCH_FILE=_build_pch_file.obj
-!endif
-
-default:: $(BUILD_PCH_FILE) $(AOUT)
-
-!include ../local.make
-!include compile.make
-
-# _NMT_NOINLINE_ informs NMT that no inlining by Compiler
-CXX_FLAGS=$(CXX_FLAGS) $(DEBUG_OPT_OPTION) /D "_NMT_NOINLINE_"
-
-!include $(WorkSpace)/make/windows/makefiles/vm.make
-!include local.make
-
-HS_BUILD_ID=$(HOTSPOT_VERSION_STRING)-debug
-
-# Force resources to be rebuilt every time
-$(Res_Files): FORCE
-
-# NOTE: Changes in this file was just to give a proper command line when linking
-# for use when developing the new build, and should not be integrated.
-$(AOUT): $(Res_Files) $(Obj_Files) vm.def
-	$(LD) $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
-!if "$(MT)" != ""
-# The previous link command created a .manifest file that we want to
-# insert into the linked artifact so we do not need to track it
-# separately.  Use ";#2" for .dll and ";#1" for .exe:
-	$(MT) /manifest $@.manifest /outputresource:$@;#2
-!endif
-!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
-!if "$(ZIP_DEBUGINFO_FILES)" == "1"
-	$(ZIPEXE) -q $*.diz $*.map $*.pdb
-	$(RM) $*.map $*.pdb
-!endif
-!endif
-
-!include $(WorkSpace)/make/windows/makefiles/shared.make
diff --git a/hotspot/make/windows/makefiles/defs.make b/hotspot/make/windows/makefiles/defs.make
deleted file mode 100644
index fbbe6f1..0000000
--- a/hotspot/make/windows/makefiles/defs.make
+++ /dev/null
@@ -1,282 +0,0 @@
-#
-# Copyright (c) 2006, 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
-# 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.
-#
-#
-
-# The common definitions for hotspot windows builds.
-# Include the top level defs.make under make directory instead of this one.
-# This file is included into make/defs.make.
-# On windows it is only used to construct parameters for
-# make/windows/build.make when make/Makefile is used to build VM.
-
-SLASH_JAVA ?= J:
-PATH_SEP = ;
-
-MAKE_ARGS += WARNINGS_AS_ERRORS=$(WARNINGS_AS_ERRORS)
-
-# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name
-ifeq ($(ARCH_DATA_MODEL),32)
-  ARCH_DATA_MODEL=32
-  PLATFORM=windows-i586
-  VM_PLATFORM=windows_i486
-  HS_ARCH=x86
-  MAKE_ARGS += ARCH=x86
-  MAKE_ARGS += BUILDARCH=i486
-  MAKE_ARGS += Platform_arch=x86
-  MAKE_ARGS += Platform_arch_model=x86_32
-endif
-
-ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) x86),)
-  ARCH_DATA_MODEL=32
-  PLATFORM=windows-i586
-  VM_PLATFORM=windows_i486
-  HS_ARCH=x86
-  MAKE_ARGS += ARCH=x86
-  MAKE_ARGS += BUILDARCH=i486
-  MAKE_ARGS += Platform_arch=x86
-  MAKE_ARGS += Platform_arch_model=x86_32
-endif
-
-ifneq ($(ARCH_DATA_MODEL),32)
-  ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) ia64),)
-    ARCH_DATA_MODEL=64
-    PLATFORM=windows-ia64
-    VM_PLATFORM=windows_ia64
-    HS_ARCH=ia64
-    MAKE_ARGS += LP64=1
-    MAKE_ARGS += ARCH=ia64
-    MAKE_ARGS += BUILDARCH=ia64
-    MAKE_ARGS += Platform_arch=ia64
-    MAKE_ARGS += Platform_arch_model=ia64
-  endif
-
-# http://support.microsoft.com/kb/888731 : this can be either
-# AMD64 for AMD, or EM64T for Intel chips.
-  ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) AMD64),)
-    ARCH_DATA_MODEL=64
-    PLATFORM=windows-amd64
-    VM_PLATFORM=windows_amd64
-    HS_ARCH=x86
-    MAKE_ARGS += LP64=1
-    MAKE_ARGS += ARCH=x86
-    MAKE_ARGS += BUILDARCH=amd64
-    MAKE_ARGS += Platform_arch=x86
-    MAKE_ARGS += Platform_arch_model=x86_64
-  endif
-
-ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) EM64T),)
-    ARCH_DATA_MODEL=64
-    PLATFORM=windows-amd64
-    VM_PLATFORM=windows_amd64
-    HS_ARCH=x86
-    MAKE_ARGS += LP64=1
-    MAKE_ARGS += ARCH=x86
-    MAKE_ARGS += BUILDARCH=amd64
-    MAKE_ARGS += Platform_arch=x86
-    MAKE_ARGS += Platform_arch_model=x86_64
-  endif
-
-# NB later OS versions than 2003 may report "Intel64"
-  ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) Intel64),)
-    ARCH_DATA_MODEL=64
-    PLATFORM=windows-amd64
-    VM_PLATFORM=windows_amd64
-    HS_ARCH=x86
-    MAKE_ARGS += LP64=1
-    MAKE_ARGS += ARCH=x86
-    MAKE_ARGS += BUILDARCH=amd64
-    MAKE_ARGS += Platform_arch=x86
-    MAKE_ARGS += Platform_arch_model=x86_64
-  endif
-endif
-
-# Full Debug Symbols has been enabled on Windows since JDK1.4.1 so
-# there is no need for an "earlier than JDK7 check".
-# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product
-# builds is enabled with debug info files ZIP'ed to save space. For
-# BUILD_FLAVOR != product builds, FDS is always enabled, after all a
-# debug build without debug info isn't very useful.
-# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled.
-#
-# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
-# disabled for a BUILD_FLAVOR == product build.
-#
-# Note: Use of a different variable name for the FDS override option
-# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
-# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
-# in options via environment variables, use of distinct variables
-# prevents strange behaviours. For example, in a BUILD_FLAVOR !=
-# product build, the FULL_DEBUG_SYMBOLS environment variable will be
-# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If
-# the same variable name is used, then different values can be picked
-# up by different parts of the build. Just to be clear, we only need
-# two variable names because the incoming option value can be
-# overridden in some situations, e.g., a BUILD_FLAVOR != product
-# build.
-
-# Due to the multiple sub-make processes that occur this logic gets
-# executed multiple times. We reduce the noise by at least checking that
-# BUILD_FLAVOR has been set.
-ifneq ($(BUILD_FLAVOR),)
-  ifeq ($(BUILD_FLAVOR), product)
-    FULL_DEBUG_SYMBOLS ?= 1
-    ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
-  else
-    # debug variants always get Full Debug Symbols (if available)
-    ENABLE_FULL_DEBUG_SYMBOLS = 1
-  endif
-  _JUNK_ := $(shell \
-    echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
-  MAKE_ARGS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)
-
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ZIP_DEBUGINFO_FILES ?= 1
-  else
-    ZIP_DEBUGINFO_FILES=0
-  endif
-  MAKE_ARGS += ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)
-endif
-
-MAKE_ARGS += RM="$(RM)"
-MAKE_ARGS += ZIPEXE=$(ZIPEXE)
-MAKE_ARGS += CP="${CP}"
-MAKE_ARGS += MV="${MV}"
-
-
-# On 32 bit windows we build server and client, on 64 bit just server.
-ifeq ($(JVM_VARIANTS),)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    JVM_VARIANTS:=client,server
-    JVM_VARIANT_CLIENT:=true
-    JVM_VARIANT_SERVER:=true
-  else
-    JVM_VARIANTS:=server
-    JVM_VARIANT_SERVER:=true
-  endif
-endif
-
-JDK_INCLUDE_SUBDIR=win32
-
-# Library suffix
-LIBRARY_SUFFIX=dll
-
-# next parameters are defined in $(GAMMADIR)/make/defs.make.
-MAKE_ARGS += VERSION_SHORT=$(VERSION_SHORT)
-MAKE_ARGS += VERSION_MAJOR=$(VERSION_MAJOR)
-MAKE_ARGS += VERSION_MINOR=$(VERSION_MINOR)
-MAKE_ARGS += VERSION_SECURITY=$(VERSION_SECURITY)
-MAKE_ARGS += VERSION_PATCH=$(VERSION_PATCH)
-MAKE_ARGS += VERSION_BUILD=$(VERSION_BUILD)
-MAKE_ARGS += DEBUG_LEVEL=$(DEBUG_LEVEL)
-
-# JDK_DOTVER and JDK_VER are needed in Windows RC files
-COMMA:=,
-MAKE_ARGS += JDK_DOTVER=$(VERSION_NUMBER_FOUR_POSITIONS)
-MAKE_ARGS += JDK_VER=$(subst .,$(COMMA),$(VERSION_NUMBER_FOUR_POSITIONS))
-
-NMAKE= MAKEFLAGS= MFLAGS= EXTRA_CFLAGS="$(EXTRA_CFLAGS)" nmake -NOLOGO
-ifndef SYSTEM_UNAME
-  SYSTEM_UNAME := $(shell uname)
-  export SYSTEM_UNAME
-endif
-
-# Check for CYGWIN
-ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
-  USING_CYGWIN=true
-else
-  USING_CYGWIN=false
-endif
-# Check for MinGW
-ifneq (,$(findstring MINGW,$(SYSTEM_UNAME)))
-  USING_MINGW=true
-endif
-
-# Windows wants particular paths due to nmake (must be after macros defined)
-#   It is important that gnumake invokes nmake with C:\\...\\  formated
-#   strings so that nmake gets C:\...\ style strings.
-# Check for CYGWIN
-ifeq ($(USING_CYGWIN), true)
-  ABS_OUTPUTDIR   := $(subst /,\\,$(shell /bin/cygpath -m -a "$(OUTPUTDIR)"))
-  ABS_BOOTDIR     := $(subst /,\\,$(shell /bin/cygpath -m -a "$(BOOTDIR)"))
-  ABS_GAMMADIR    := $(subst /,\\,$(shell /bin/cygpath -m -a "$(GAMMADIR)"))
-  ABS_OS_MAKEFILE := $(shell /bin/cygpath -m -a "$(HS_MAKE_DIR)/$(OSNAME)")/build.make
-else ifeq ($(USING_MINGW), true)
-    ABS_OUTPUTDIR   := $(shell $(CD) $(OUTPUTDIR);$(PWD))
-    ABS_BOOTDIR     := $(shell $(CD) $(BOOTDIR);$(PWD))
-    ABS_GAMMADIR    := $(shell $(CD) $(GAMMADIR);$(PWD))
-    ABS_OS_MAKEFILE := $(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME);$(PWD))/build.make
-  else
-    ABS_OUTPUTDIR   := $(subst /,\\,$(shell $(CD) $(OUTPUTDIR);$(PWD)))
-    ABS_BOOTDIR     := $(subst /,\\,$(shell $(CD) $(BOOTDIR);$(PWD)))
-    ABS_GAMMADIR    := $(subst /,\\,$(shell $(CD) $(GAMMADIR);$(PWD)))
-    ABS_OS_MAKEFILE := $(subst /,\\,$(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME);$(PWD))/build.make)
-endif
-
-EXPORT_SERVER_DIR = $(EXPORT_BIN_DIR)/server
-EXPORT_CLIENT_DIR = $(EXPORT_BIN_DIR)/client
-
-ifeq ($(JVM_VARIANT_SERVER),true)
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.$(LIBRARY_SUFFIX)
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.diz
-    else
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.pdb
-      EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.map
-    endif
-  endif
-endif
-ifeq ($(JVM_VARIANT_CLIENT),true)
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.$(LIBRARY_SUFFIX)
-  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    ifeq ($(ZIP_DEBUGINFO_FILES),1)
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.diz
-    else
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.pdb
-      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.map
-    endif
-  endif
-endif
-
-EXPORT_LIST += $(EXPORT_LIB_DIR)/jvm.lib
-
-# Propagate compiler and tools paths from configure to nmake.
-# Need to make sure they contain \\ and not /.
-ifneq ($(SPEC),)
-  ifeq ($(USING_CYGWIN), true)
-    MAKE_ARGS += CXX="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(CXX)))"
-    MAKE_ARGS += LD="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(LD)))"
-    MAKE_ARGS += RC="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(RC)))"
-    MAKE_ARGS += MT="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(MT)))"
-  else
-    MAKE_ARGS += CXX="$(subst /,\\,$(CXX))"
-    MAKE_ARGS += LD="$(subst /,\\,$(LD))"
-    MAKE_ARGS += RC="$(subst /,\\,$(RC))"
-    MAKE_ARGS += MT="$(subst /,\\,$(MT))"
-  endif
-endif
-
-ifdef OPENJDK
-  MAKE_ARGS += OPENJDK="$(OPENJDK)"
-endif
diff --git a/hotspot/make/windows/makefiles/fastdebug.make b/hotspot/make/windows/makefiles/fastdebug.make
deleted file mode 100644
index ea6fc41..0000000
--- a/hotspot/make/windows/makefiles/fastdebug.make
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-HS_INTERNAL_NAME=jvm
-HS_FNAME=$(HS_INTERNAL_NAME).dll
-AOUT=$(HS_FNAME)
-GENERATED=../generated
-
-# Allow the user to turn off precompiled headers from the command line.
-!if "$(USE_PRECOMPILED_HEADER)" != "0"
-BUILD_PCH_FILE=_build_pch_file.obj
-!endif
-
-default:: $(BUILD_PCH_FILE) $(AOUT)
-
-!include ../local.make
-!include compile.make
-
-CXX_FLAGS=$(CXX_FLAGS) $(FASTDEBUG_OPT_OPTION)
-
-!include $(WorkSpace)/make/windows/makefiles/vm.make
-!include local.make
-
-HS_BUILD_ID=$(HOTSPOT_VERSION_STRING)-fastdebug
-
-# Force resources to be rebuilt every time
-$(Res_Files): FORCE
-
-# NOTE: Changes in this file was just to give a proper command line when linking
-# for use when developing the new build, and should not be integrated.
-$(AOUT): $(Res_Files) $(Obj_Files) vm.def
-	$(LD) $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
-!if "$(MT)" != ""
-# The previous link command created a .manifest file that we want to
-# insert into the linked artifact so we do not need to track it
-# separately.  Use ";#2" for .dll and ";#1" for .exe:
-	$(MT) /manifest $@.manifest /outputresource:$@;#2
-!endif
-!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
-!if "$(ZIP_DEBUGINFO_FILES)" == "1"
-	$(ZIPEXE) -q $*.diz $*.map $*.pdb
-	$(RM) $*.map $*.pdb
-!endif
-!endif
-
-!include $(WorkSpace)/make/windows/makefiles/shared.make
diff --git a/hotspot/make/windows/makefiles/generated.make b/hotspot/make/windows/makefiles/generated.make
deleted file mode 100644
index e376c74..0000000
--- a/hotspot/make/windows/makefiles/generated.make
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-!include ../local.make
-!include $(WorkSpace)/make/windows/makefiles/projectcreator.make
-!include local.make
-
-# Pick up rules for building JVMTI (JSR-163)
-JvmtiOutDir=jvmtifiles
-!include $(WorkSpace)/make/windows/makefiles/jvmti.make
-
-# Pick up rules for building trace
-TraceOutDir=tracefiles
-!include $(WorkSpace)/make/windows/makefiles/trace.make
-
-AdlcOutDir=adfiles
-
-!if ("$(Variant)" == "compiler2") || ("$(Variant)" == "tiered")
-default:: $(AdlcOutDir)/ad_$(Platform_arch_model).cpp $(AdlcOutDir)/dfa_$(Platform_arch_model).cpp $(JvmtiGeneratedFiles) $(TraceGeneratedFiles) buildobjfiles
-!else
-default:: $(JvmtiGeneratedFiles) $(TraceGeneratedFiles) buildobjfiles
-!endif
-
-buildobjfiles:
-	@ sh $(WorkSpace)/make/windows/create_obj_files.sh $(Variant) $(Platform_arch) $(Platform_arch_model) $(WorkSpace) .	> objfiles.make
-
-classes/ProjectCreator.class: $(ProjectCreatorSources)
-	if exist classes rmdir /s /q classes
-	mkdir classes
-	$(COMPILE_JAVAC) -classpath $(WorkSpace)\src\share\tools\ProjectCreator -d classes $(ProjectCreatorSources)
-
-!if ("$(Variant)" == "compiler2") || ("$(Variant)" == "tiered")
-
-!include $(WorkSpace)/make/windows/makefiles/compile.make
-!include $(WorkSpace)/make/windows/makefiles/adlc.make
-
-!endif
-
-!include $(WorkSpace)/make/windows/makefiles/shared.make
diff --git a/hotspot/make/windows/makefiles/jvmti.make b/hotspot/make/windows/makefiles/jvmti.make
deleted file mode 100644
index ce29fe3..0000000
--- a/hotspot/make/windows/makefiles/jvmti.make
+++ /dev/null
@@ -1,114 +0,0 @@
-#
-# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# This makefile (jvmti.make) is included from the jvmti.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate jvmti.
-
-!include $(WorkSpace)/make/windows/makefiles/rules.make
-
-# #########################################################################
-
-JvmtiSrcDir = $(WorkSpace)/src/share/vm/prims
-InterpreterSrcDir = $(WorkSpace)/src/share/vm/interpreter
-
-JvmtiGeneratedNames = \
-        jvmtiEnv.hpp \
-        jvmtiEnter.cpp \
-        jvmtiEnterTrace.cpp \
-        jvmtiEnvRecommended.cpp \
-        bytecodeInterpreterWithChecks.cpp \
-        jvmti.h \
-
-JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java
-JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class
-
-JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java
-JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class
-
-#Note: JvmtiGeneratedFiles must be kept in sync with JvmtiGeneratedNames by hand.
-#Should be equivalent #to "JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%)"
-JvmtiGeneratedFiles = \
-        $(JvmtiOutDir)/jvmtiEnv.hpp \
-        $(JvmtiOutDir)/jvmtiEnter.cpp \
-        $(JvmtiOutDir)/jvmtiEnterTrace.cpp \
-        $(JvmtiOutDir)/jvmtiEnvRecommended.cpp\
-        $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp\
-        $(JvmtiOutDir)/jvmti.h \
-
-XSLT = $(RUN_JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-# #########################################################################
-
-both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl
-
-default::
-        @if not exist $(JvmtiOutDir) mkdir $(JvmtiOutDir)
-
-$(JvmtiGenClass): $(JvmtiGenSource)
-	$(COMPILE_JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource)
-
-$(JvmtiEnvFillClass): $(JvmtiEnvFillSource)
-	@$(COMPILE_JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource)
-
-$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo Generating $@
-	@$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti
-
-$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl
-	@echo Generating $@
-	@$(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp
-
-$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
-	@echo Generating $@
-	@$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace
-
-$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass)
-	@echo Generating $@
-	@$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp
-	@$(RUN_JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp
-
-$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl
-	@echo Generating $@
-	@$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp
-
-$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl
-	@echo Generating $@
-	@$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h
-
-jvmtidocs:  $(JvmtiOutDir)/jvmti.html
-
-$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl
-	@echo Generating $@
-	@$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html
-
-# #########################################################################
-
-cleanall :
-	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
-
-# #########################################################################
-
-.PHONY: jvmtidocs cleanall
diff --git a/hotspot/make/windows/makefiles/product.make b/hotspot/make/windows/makefiles/product.make
deleted file mode 100644
index 09e750a..0000000
--- a/hotspot/make/windows/makefiles/product.make
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-HS_INTERNAL_NAME=jvm
-HS_FNAME=$(HS_INTERNAL_NAME).dll
-AOUT=$(HS_FNAME)
-GENERATED=../generated
-
-# Allow the user to turn off precompiled headers from the command line.
-!if "$(USE_PRECOMPILED_HEADER)" != "0"
-BUILD_PCH_FILE=_build_pch_file.obj
-!endif
-
-default:: $(BUILD_PCH_FILE) $(AOUT)
-
-!include ../local.make
-!include compile.make
-
-CXX_FLAGS=$(CXX_FLAGS) $(PRODUCT_OPT_OPTION)
-
-RELEASE=
-
-RC_FLAGS=$(RC_FLAGS) /D "NDEBUG"
-
-!include $(WorkSpace)/make/windows/makefiles/vm.make
-!include local.make
-
-HS_BUILD_ID=$(HOTSPOT_VERSION_STRING)
-
-# Force resources to be rebuilt every time
-$(Res_Files): FORCE
-
-# NOTE: Changes in this file was just to give a proper command line when linking
-# for use when developing the new build, and should not be integrated.
-$(AOUT): $(Res_Files) $(Obj_Files) vm.def
-	$(LD) $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
-
-!if "$(MT)" != ""
-# The previous link command created a .manifest file that we want to
-# insert into the linked artifact so we do not need to track it
-# separately.  Use ";#2" for .dll and ";#1" for .exe:
-	$(MT) /manifest $@.manifest /outputresource:$@;#2
-!endif
-!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
-!if "$(ZIP_DEBUGINFO_FILES)" == "1"
-	$(ZIPEXE) -q $*.diz $*.map $*.pdb
-	$(RM) $*.map $*.pdb
-!endif
-!endif
-
-!include $(WorkSpace)/make/windows/makefiles/shared.make
diff --git a/hotspot/make/windows/makefiles/projectcreator.make b/hotspot/make/windows/makefiles/projectcreator.make
deleted file mode 100644
index e48a07b..0000000
--- a/hotspot/make/windows/makefiles/projectcreator.make
+++ /dev/null
@@ -1,210 +0,0 @@
-#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-!include $(WorkSpace)/make/windows/makefiles/rules.make
-
-# This is used externally by both batch and IDE builds, so can't
-# reference any of the HOTSPOTWORKSPACE, HOTSPOTBUILDSPACE,
-# HOTSPOTRELEASEBINDEST, or HOTSPOTDEBUGBINDEST environment variables.
-
-ProjectCreatorSources=\
-        $(WorkSpace)\src\share\tools\ProjectCreator\ProjectCreator.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\FileTreeCreator.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\FileTreeCreatorVC10.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatform.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC10.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\Util.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\BuildConfig.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\ArgsParser.java
-
-# This is only used internally
-ProjectCreatorIncludesPRIVATE=\
-        -relativeAltSrcInclude src\closed \
-        -altRelativeInclude share\vm \
-        -altRelativeInclude os\windows\vm \
-        -altRelativeInclude os_cpu\windows_$(Platform_arch)\vm \
-        -altRelativeInclude cpu\$(Platform_arch)\vm \
-        -relativeInclude src\share\vm \
-        -relativeInclude src\share\vm\precompiled \
-        -relativeInclude src\share\vm\prims\wbtestmethods \
-        -relativeInclude src\share\vm\prims \
-        -relativeInclude src\os\windows\vm \
-        -relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \
-        -relativeInclude src\cpu\$(Platform_arch)\vm \
-        -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \
-        -relativeSrcInclude src \
-        -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \
-        -ignorePath $(HOTSPOTBUILDSPACE) \
-        -ignorePath share\vm\adlc \
-        -ignorePath share\vm\shark \
-        -ignorePath share\tools \
-        -ignorePath solaris \
-        -ignorePath posix \
-        -ignorePath sparc \
-        -ignorePath linux \
-        -ignorePath bsd \
-        -ignorePath osx \
-        -ignorePath arm \
-        -ignorePath ppc \
-        -ignorePath zero \
-        -ignorePath aix \
-        -ignorePath aarch64 \
-        -ignorePath jdk.vm.ci \
-        -hidePath .hg
-
-
-# This is referenced externally by both the IDE and batch builds
-ProjectCreatorOptions=
-
-# This is used externally, but only by the IDE builds, so we can
-# reference environment variables which aren't defined in the batch
-# build process.
-
-ProjectCreatorIDEOptions = \
-        -useToGeneratePch  java.cpp \
-        -disablePch        os_windows.cpp \
-        -disablePch        os_windows_$(Platform_arch).cpp \
-        -disablePch        osThread_windows.cpp \
-        -disablePch        bytecodeInterpreter.cpp \
-        -disablePch        bytecodeInterpreterWithChecks.cpp \
-        -disablePch        getThread_windows_$(Platform_arch).cpp \
-        -disablePch_compiler2     opcodes.cpp
-
-# Common options for the IDE builds for c1, and c2
-ProjectCreatorIDEOptions=\
-        $(ProjectCreatorIDEOptions) \
-        -sourceBase $(HOTSPOTWORKSPACE) \
-        -buildBase $(HOTSPOTBUILDSPACE)\%f\%b \
-        -buildSpace $(HOTSPOTBUILDSPACE) \
-        -startAt src \
-        -compiler $(VcVersion) \
-        -projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \
-        -jdkTargetRoot $(HOTSPOTJDKDIST) \
-        -define ALIGN_STACK_FRAMES \
-        -define VM_LITTLE_ENDIAN \
-        -prelink  "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	set JAVA_HOME=$(HOTSPOTJDKDIST)	$(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \
-        -ignorePath src\jdk.hotspot.agent \
-        -ignoreFile jsig.c \
-        -ignoreFile jvmtiEnvRecommended.cpp \
-        -ignoreFile jvmtiEnvStub.cpp \
-        -ignoreFile globalDefinitions_gcc.hpp \
-        -ignoreFile globalDefinitions_sparcWorks.hpp \
-        -ignoreFile version.rc \
-        -ignoreFile Xusage.txt \
-        -define TARGET_ARCH_x86 \
-        -define TARGET_OS_ARCH_windows_x86 \
-        -define TARGET_OS_FAMILY_windows \
-        -define TARGET_COMPILER_visCPP \
-        -define INCLUDE_TRACE=1 \
-       $(ProjectCreatorIncludesPRIVATE)
-
-# Add in build-specific options
-!if "$(BUILDARCH)" == "i486"
-ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
-        -platformName Win32 \
-        -ignorePath x86_64 \
-        -ignorePath src\share\vm\jvmci \
-        -ignoreFile jvmciCodeInstaller_x86.cpp \
-        -define IA32 \
-        -define INCLUDE_JVMCI=0 \
-        -define TARGET_ARCH_MODEL_x86_32
-!else
-!if "$(BUILDARCH)" == "amd64"
-ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
-        -platformName x64 \
-        -ignorePath x86_32 \
-        -define AMD64 \
-        -define _LP64 \
-        -define INCLUDE_JVMCI=1 \
-        -define TARGET_ARCH_MODEL_x86_64 \
-        -define TARGET_OS_ARCH_MODEL_windows_x86_64
-!endif
-!endif
-
-ProjectCreatorIDEOptionsIgnoreCompiler1=\
- -ignorePath_TARGET compiler1 \
- -ignorePath_TARGET tiered \
- -ignorePath_TARGET c1_
-
-ProjectCreatorIDEOptionsIgnoreCompiler2=\
- -ignorePath_TARGET compiler2 \
- -ignorePath_TARGET tiered \
- -ignorePath_TARGET src/share/vm/opto \
- -ignorePath_TARGET src/share/vm/libadt \
- -ignorePath_TARGET adfiles \
- -ignoreFile_TARGET bcEscapeAnalyzer.cpp \
- -ignoreFile_TARGET bcEscapeAnalyzer.hpp \
- -ignorePath_TARGET chaitin \
- -ignorePath_TARGET c2_ \
- -ignorePath_TARGET runtime_ \
- -ignoreFile_TARGET ciTypeFlow.cpp \
- -ignoreFile_TARGET ciTypeFlow.hpp \
- -ignoreFile_TARGET $(Platform_arch_model).ad
-
-##################################################
-# Client(C1) compiler specific options
-##################################################
-ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
- -define_compiler1 COMPILER1 \
-$(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1)
-
-##################################################
-# Server(C2) compiler specific options
-##################################################
-#NOTE! This list must be kept in sync with GENERATED_NAMES in adlc.make.
-ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
- -define_compiler2 COMPILER2 \
- -additionalFile_compiler2 $(Platform_arch_model).ad \
- -additionalFile_compiler2 ad_$(Platform_arch_model).cpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model).hpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model)_clone.cpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model)_expand.cpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model)_format.cpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model)_gen.cpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model)_misc.cpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model)_peephole.cpp \
- -additionalFile_compiler2 ad_$(Platform_arch_model)_pipeline.cpp \
- -additionalFile_compiler2 adGlobals_$(Platform_arch_model).hpp \
- -additionalFile_compiler2 dfa_$(Platform_arch_model).cpp \
- $(ProjectCreatorIDEOptionsIgnoreCompiler1:TARGET=compiler2)
-
-# Add in the jvmti (JSR-163) options
-# NOTE: do not pull in jvmtiEnvRecommended.cpp.  This file is generated
-#       so the programmer can diff it with jvmtiEnv.cpp to be sure the
-#       code merge was done correctly (@see jvmti.make and jvmtiEnvFill.java).
-#       If so, they would then check it in as a new version of jvmtiEnv.cpp.
-ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
- -additionalFile jvmtiEnv.hpp \
- -additionalFile jvmtiEnter.cpp \
- -additionalFile jvmtiEnterTrace.cpp \
- -additionalFile jvmti.h \
- -additionalFile bytecodeInterpreterWithChecks.cpp \
- -additionalFile traceEventClasses.hpp \
- -additionalFile traceEventIds.hpp \
-!if "$(OPENJDK)" != "true"
- -additionalFile traceRequestables.hpp \
- -additionalFile traceEventControl.hpp \
- -additionalFile traceProducer.cpp \
-!endif
- -additionalFile traceTypes.hpp
diff --git a/hotspot/make/windows/makefiles/rules.make b/hotspot/make/windows/makefiles/rules.make
deleted file mode 100644
index 2bd0237..0000000
--- a/hotspot/make/windows/makefiles/rules.make
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#  
-#
-
-# These are the commands used externally to compile and run.
-# The \ are used here for traditional Windows apps and " quoted to get
-# past the Unix-like shell:
-!ifdef BootStrapDir
-RUN_JAVA="$(BootStrapDir)\bin\java"
-RUN_JAVAP="$(BootStrapDir)\bin\javap"
-RUN_JAVAH="$(BootStrapDir)\bin\javah"
-RUN_JAR="$(BootStrapDir)\bin\jar"
-COMPILE_JAVAC="$(BootStrapDir)\bin\javac" $(BOOTSTRAP_JAVAC_FLAGS)
-COMPILE_RMIC="$(BootStrapDir)\bin\rmic"
-BOOT_JAVA_HOME=$(BootStrapDir)
-!else
-RUN_JAVA=java
-RUN_JAVAP=javap
-RUN_JAVAH=javah
-RUN_JAR=jar
-COMPILE_JAVAC=javac $(BOOTSTRAP_JAVAC_FLAGS)
-COMPILE_RMIC=rmic
-BOOT_JAVA_HOME=
-!endif
-
-# Settings for javac
-JAVAC_FLAGS=-g -encoding ascii
-
-# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system)
-# Fall back to the values here if it's not set (hotspot only builds)
-!ifndef BOOT_JDK_SOURCETARGET
-BOOTSTRAP_SOURCETARGET=-source 8 -target 8
-!else
-BOOTSTRAP_SOURCETARGET=$(BOOT_JDK_SOURCETARGET)
-!endif
-
-BOOTSTRAP_JAVAC_FLAGS=$(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET)
-
-# VS2012 and VS2013 loads VS10 projects just fine (and will
-# upgrade them automatically to VS2012 format).
-VcVersion=VC10
-ProjectFile=jvm.vcxproj
-
diff --git a/hotspot/make/windows/makefiles/sanity.make b/hotspot/make/windows/makefiles/sanity.make
deleted file mode 100644
index 515b0bb..0000000
--- a/hotspot/make/windows/makefiles/sanity.make
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
-# 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 local.make
-
-all: checkCL checkLink
-
-checkCL:
-	@ if "$(MSC_VER)" NEQ "1600" if "$(MSC_VER)" NEQ "1700" if "$(MSC_VER)" NEQ "1800" \
-	echo *** WARNING *** Unsupported cl.exe version detected: $(MSC_VER) ($(RAW_MSC_VER)), only 1600/1700/1800 (Visual Studio 2010/2012/2013) are supported.
-
-checkLink:
-	@ if "$(LD_VER)" NEQ "1000" if "$(LD_VER)" NEQ "1100" if "$(LD_VER)" NEQ "1200" \
-	echo *** WARNING *** Unsupported link.exe version detected: $(LD_VER) ($(RAW_LD_VER)), only 1000/1100/1200 (Visual Studio 2010/2012/2013) are supported.
diff --git a/hotspot/make/windows/makefiles/shared.make b/hotspot/make/windows/makefiles/shared.make
deleted file mode 100644
index 06cd75f..0000000
--- a/hotspot/make/windows/makefiles/shared.make
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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.
-#  
-#
-
-DEFAULTACTIONS=clean post_update create
-
-default:: $(SUBDIRS)
-
-!ifndef DIR
-DIR=.
-!endif
-
-!ifndef CXX
-CXX=cl.exe
-!endif
-
-
-!ifdef SUBDIRS
-# \ is used below because $(MAKE) is nmake here, which expects Windows paths
-$(SUBDIRS): FORCE
-	@if not exist $@ mkdir $@
-	@if not exist $@/local.make echo # Empty > $@/local.make
-	@echo nmake $(ACTION) in $(DIR)/$@
-	cd $@ && $(MAKE) -NOLOGO -f $(WorkSpace)\make\windows\makefiles\$@.make $(ACTION) DIR=$(DIR)\$@ BUILD_FLAVOR=$(BUILD_FLAVOR)
-!endif
-
-# Creates the needed directory
-create::
-!if "$(DIR)" != "."
-	@echo mkdir $(DIR)
-!endif
-
-# Epilog to update for generating derived files
-post_update::
-
-# Removes scrap files
-clean:: FORCE
-	-@rm -f *.OLD *.publish
-
-# Remove all scrap files and all generated files
-pure:: clean
-	-@rm -f *.OLD *.publish
-
-$(DEFAULTACTIONS) $(ACTIONS)::
-!ifdef SUBDIRS
-	@$(MAKE) -nologo ACTION=$@ DIR=$(DIR)
-!endif
-
-FORCE:
-
-
diff --git a/hotspot/make/windows/makefiles/top.make b/hotspot/make/windows/makefiles/top.make
deleted file mode 100644
index fb9c2a2..0000000
--- a/hotspot/make/windows/makefiles/top.make
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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 local.make
-
-!ifdef ADLC_ONLY
-SUBDIRS=generated
-!else
-SUBDIRS=generated $(BUILD_FLAVOR)
-!endif
-
-!include $(WorkSpace)/make/windows/makefiles/shared.make
-
diff --git a/hotspot/make/windows/makefiles/trace.make b/hotspot/make/windows/makefiles/trace.make
deleted file mode 100644
index d523913..0000000
--- a/hotspot/make/windows/makefiles/trace.make
+++ /dev/null
@@ -1,132 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-# This makefile (trace.make) is included from the trace.make in the
-# build directories.
-#
-# It knows how to build and run the tools to generate trace files.
-
-!include $(WorkSpace)/make/windows/makefiles/rules.make
-
-# #########################################################################
-
-
-TraceAltSrcDir = $(WorkSpace)\src\closed\share\vm\trace
-TraceSrcDir = $(WorkSpace)\src\share\vm\trace
-
-!ifndef OPENJDK
-!if EXISTS($(TraceAltSrcDir))
-HAS_ALT_SRC = true
-!endif
-!endif
-
-!ifndef OPENJDK
-!if EXISTS($(TraceAltSrcDir))
-HAS_ALT_SRC = true
-!endif
-!endif
-
-TraceGeneratedNames =     \
-    traceEventClasses.hpp \
-    traceEventIds.hpp     \
-    traceTypes.hpp
-
-!ifdef HAS_ALT_SRC
-TraceGeneratedNames = $(TraceGeneratedNames) \
-    traceRequestables.hpp \
-    traceEventControl.hpp
-!endif
-
-
-#Note: TraceGeneratedFiles must be kept in sync with TraceGeneratedNames by hand.
-#Should be equivalent to "TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%)"
-TraceGeneratedFiles = \
-    $(TraceOutDir)/traceEventClasses.hpp \
-    $(TraceOutDir)/traceEventIds.hpp     \
-    $(TraceOutDir)/traceTypes.hpp
-
-!ifdef HAS_ALT_SRC
-TraceGeneratedFiles = $(TraceGeneratedFiles) \
-    $(TraceOutDir)/traceRequestables.hpp \
-    $(TraceOutDir)/traceEventControl.hpp
-!endif
-
-XSLT = $(QUIETLY) $(REMOTE) $(RUN_JAVA) -classpath $(JvmtiOutDir) jvmtiGen
-
-TraceXml = $(TraceSrcDir)/trace.xml
-
-!ifdef HAS_ALT_SRC
-TraceXml = $(TraceAltSrcDir)/trace.xml
-!endif
-
-XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \
-    $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \
-    $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml
-
-!ifdef HAS_ALT_SRC
-XML_DEPS = $(XML_DEPS) $(TraceAltSrcDir)/traceeventscustom.xml \
-    $(TraceAltSrcDir)/traceeventtypes.xml
-!endif
-
-.PHONY: all clean cleanall
-
-# #########################################################################
-
-default::
-	@if not exist $(TraceOutDir) mkdir $(TraceOutDir)
-
-$(TraceOutDir)/traceEventIds.hpp: $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS)
-	@echo Generating $@
-	$(XSLT) -IN $(TraceXml) -XSL $(TraceSrcDir)/traceEventIds.xsl -OUT $(TraceOutDir)/traceEventIds.hpp
-
-$(TraceOutDir)/traceTypes.hpp: $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS)
-	@echo Generating $@
-	$(XSLT) -IN $(TraceXml) -XSL $(TraceSrcDir)/traceTypes.xsl -OUT $(TraceOutDir)/traceTypes.hpp
-
-!ifndef HAS_ALT_SRC
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	@echo Generating OpenJDK $@
-	$(XSLT) -IN $(TraceXml) -XSL $(TraceSrcDir)/traceEventClasses.xsl -OUT $(TraceOutDir)/traceEventClasses.hpp
-
-!else
-
-$(TraceOutDir)/traceEventClasses.hpp: $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS)
-	@echo Generating AltSrc $@
-	$(XSLT) -IN $(TraceXml) -XSL $(TraceAltSrcDir)/traceEventClasses.xsl -OUT $(TraceOutDir)/traceEventClasses.hpp
-
-$(TraceOutDir)/traceRequestables.hpp: $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS)
-	@echo Generating AltSrc $@
-	$(XSLT) -IN $(TraceXml) -XSL $(TraceAltSrcDir)/traceRequestables.xsl -OUT $(TraceOutDir)/traceRequestables.hpp
-
-$(TraceOutDir)/traceEventControl.hpp: $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS)
-	@echo Generating AltSrc $@
-	$(XSLT) -IN $(TraceXml) -XSL $(TraceAltSrcDir)/traceEventControl.xsl -OUT $(TraceOutDir)/traceEventControl.hpp
-
-!endif
-
-# #########################################################################
-
-cleanall :
-	rm $(TraceGeneratedFiles)
diff --git a/hotspot/make/windows/makefiles/vm.make b/hotspot/make/windows/makefiles/vm.make
deleted file mode 100644
index a1391a0..0000000
--- a/hotspot/make/windows/makefiles/vm.make
+++ /dev/null
@@ -1,428 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-# Resource file containing VERSIONINFO
-Res_Files=.\version.res
-
-!include ..\generated\objfiles.make
-
-COMMONSRC=$(WorkSpace)\src
-ALTSRC=$(WorkSpace)\src\closed
-
-!ifdef RELEASE
-CXX_FLAGS=$(CXX_FLAGS) /D "PRODUCT"
-!else
-CXX_FLAGS=$(CXX_FLAGS) /D "ASSERT"
-!if "$(BUILDARCH)" == "amd64"
-CXX_FLAGS=$(CXX_FLAGS) /homeparams
-!endif
-!endif
-
-!if "$(Variant)" == "compiler1"
-CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER1" /D INCLUDE_JVMCI=0
-!endif
-
-!if "$(Variant)" == "compiler2"
-CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER2"
-!if "$(BUILDARCH)" == "i486"
-CXX_FLAGS=$(CXX_FLAGS) /D INCLUDE_JVMCI=0
-!endif
-!endif
-
-!if "$(Variant)" == "tiered"
-CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER1" /D "COMPILER2"
-!if "$(BUILDARCH)" == "i486"
-CXX_FLAGS=$(CXX_FLAGS) /D INCLUDE_JVMCI=0
-!endif
-!endif
-
-!if "$(BUILDARCH)" == "i486"
-HOTSPOT_LIB_ARCH=i386
-!else
-HOTSPOT_LIB_ARCH=$(BUILDARCH)
-!endif
-
-# The following variables are defined in the generated local.make file.
-CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_VERSION_STRING=\"$(HOTSPOT_VERSION_STRING)\""
-CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_MAJOR=$(VERSION_MAJOR)"
-CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_MINOR=$(VERSION_MINOR)"
-CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_SECURITY=$(VERSION_SECURITY)"
-CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_PATCH=$(VERSION_PATCH)"
-CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_BUILD=$(VERSION_BUILD)"
-CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_STRING=\"$(VERSION_STRING)\""
-CXX_FLAGS=$(CXX_FLAGS) /D "DEBUG_LEVEL=\"$(DEBUG_LEVEL)\""
-CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(HOTSPOT_LIB_ARCH)\""
-CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_BUILD_TARGET=\"$(BUILD_FLAVOR)\""
-CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\""
-CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\""
-
-CXX_FLAGS=$(CXX_FLAGS) $(CXX_INCLUDE_DIRS)
-
-# Define that so jni.h is on correct side
-CXX_FLAGS=$(CXX_FLAGS) /D "_JNI_IMPLEMENTATION_"
-
-!if "$(BUILDARCH)" == "ia64"
-STACK_SIZE="/STACK:1048576,262144"
-!else
-STACK_SIZE=
-!endif
-
-!if "$(BUILDARCH)" == "ia64"
-# AsyncGetCallTrace is not supported on IA64 yet
-AGCT_EXPORT=
-!else
-AGCT_EXPORT=/export:AsyncGetCallTrace
-!endif
-
-# If you modify exports below please do the corresponding changes in
-# src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
-!if "$(BUILDARCH)" == "amd64"
-EXPORT_LIST=
-!else
-EXPORT_LIST=/export:JNI_GetDefaultJavaVMInitArgs \
-            /export:JNI_CreateJavaVM             \
-            /export:JVM_FindClassFromBootLoader  \
-            /export:JNI_GetCreatedJavaVMs        \
-            /export:jio_snprintf                 \
-            /export:jio_printf                   \
-            /export:jio_fprintf                  \
-            /export:jio_vfprintf                 \
-            /export:jio_vsnprintf                \
-            $(AGCT_EXPORT)                       \
-            /export:JVM_GetVersionInfo           \
-            /export:JVM_InitAgentProperties
-!endif
-
-LD_FLAGS=$(LD_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 $(EXPORT_LIST)
-
-CXX_INCLUDE_DIRS=/I "..\generated"
-
-!ifndef OPENJDK
-!if exists($(ALTSRC)\share\vm)
-CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\share\vm"
-!endif
-
-!if exists($(ALTSRC)\os\windows\vm)
-CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\os\windows\vm"
-!endif
-
-!if exists($(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm)
-CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm"
-!endif
-
-!if exists($(ALTSRC)\cpu\$(Platform_arch)\vm)
-CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\cpu\$(Platform_arch)\vm"
-!endif
-!endif # OPENJDK
-
-CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) \
-  /I "$(COMMONSRC)\share\vm" \
-  /I "$(COMMONSRC)\share\vm\precompiled" \
-  /I "$(COMMONSRC)\share\vm\prims" \
-  /I "$(COMMONSRC)\os\windows\vm" \
-  /I "$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm" \
-  /I "$(COMMONSRC)\cpu\$(Platform_arch)\vm"
-
-CXX_DONT_USE_PCH=/D DONT_USE_PRECOMPILED_HEADER
-
-!if "$(USE_PRECOMPILED_HEADER)" != "0"
-CXX_USE_PCH=/Fp"vm.pch" /Yu"precompiled.hpp"
-!if "$(MSC_VER)" > "1600"
-# VS2012 requires this object file to be listed:
-LD_FLAGS=$(LD_FLAGS) _build_pch_file.obj
-!endif
-!else
-CXX_USE_PCH=$(CXX_DONT_USE_PCH)
-!endif
-
-# Where to find the source code for the virtual machine (is this used?)
-VM_PATH=../generated
-VM_PATH=$(VM_PATH);../generated/adfiles
-VM_PATH=$(VM_PATH);../generated/jvmtifiles
-VM_PATH=$(VM_PATH);../generated/tracefiles
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/c1
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/jvmci
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/compiler
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/code
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/interpreter
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/ci
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/classfile
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/parallel
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/shared
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/serial
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/cms
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/g1
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/asm
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/logging
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/memory
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/oops
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/prims
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/prims/wbtestmethods
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/runtime
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/services
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/trace
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/utilities
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/libadt
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/os/windows/vm
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/os_cpu/windows_$(Platform_arch)/vm
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/cpu/$(Platform_arch)/vm
-VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/opto
-
-!ifndef OPENJDK
-!if exists($(ALTSRC)\share\vm\jfr)
-VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr
-VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr/buffers
-!endif
-!endif # OPENJDK
-
-VM_PATH={$(VM_PATH)}
-
-# Special case files not using precompiled header files.
-
-c1_RInfo_$(Platform_arch).obj: $(WorkSpace)\src\cpu\$(Platform_arch)\vm\c1_RInfo_$(Platform_arch).cpp
-	 $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\cpu\$(Platform_arch)\vm\c1_RInfo_$(Platform_arch).cpp
-
-os_windows.obj: $(WorkSpace)\src\os\windows\vm\os_windows.cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\os_windows.cpp
-
-os_windows_$(Platform_arch).obj: $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\os_windows_$(Platform_arch).cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\os_windows_$(Platform_arch).cpp
-
-osThread_windows.obj: $(WorkSpace)\src\os\windows\vm\osThread_windows.cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\osThread_windows.cpp
-
-conditionVar_windows.obj: $(WorkSpace)\src\os\windows\vm\conditionVar_windows.cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\conditionVar_windows.cpp
-
-getThread_windows_$(Platform_arch).obj: $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\getThread_windows_$(Platform_arch).cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\getThread_windows_$(Platform_arch).cpp
-
-opcodes.obj: $(WorkSpace)\src\share\vm\opto\opcodes.cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\opto\opcodes.cpp
-
-bytecodeInterpreter.obj: $(WorkSpace)\src\share\vm\interpreter\bytecodeInterpreter.cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\interpreter\bytecodeInterpreter.cpp
-
-bytecodeInterpreterWithChecks.obj: ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp
-        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp
-
-# Default rules for the Virtual Machine
-{$(COMMONSRC)\share\vm\c1}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\compiler}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\code}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\interpreter}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\ci}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\classfile}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\jvmci}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\gc\parallel}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\gc\shared}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\gc\serial}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\gc\cms}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\gc\g1}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\asm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\logging}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\memory}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\oops}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\prims}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\prims\wbtestmethods}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\runtime}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\services}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\trace}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\utilities}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\libadt}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\share\vm\opto}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\os\windows\vm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-# This guy should remain a single colon rule because
-# otherwise we can't specify the output filename.
-# NOTE: Changes in this file was just to give a proper command line when linking
-# for use when developing the new build, and should not be integrated.
-{$(COMMONSRC)\os\windows\vm}.rc.res:
-        $(RC) $(RC_FLAGS) /fo"$@" $<
-
-{$(COMMONSRC)\cpu\$(Platform_arch)\vm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-!ifndef OPENJDK
-{$(ALTSRC)\share\vm\c1}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\compiler}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\code}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\interpreter}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\ci}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\classfile}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\gc\parallel}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\gc\shared}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\gc\serial}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\gc\cms}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\gc\g1}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\asm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\logging}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\memory}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\oops}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\prims}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\prims\wbtestmethods}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\runtime}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\services}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\trace}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\utilities}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\libadt}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\opto}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\os\windows\vm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-# otherwise we can't specify the output filename.
-{$(ALTSRC)\os\windows\vm}.rc.res:
-        @$(RC) $(RC_FLAGS) /fo"$@" $<
-
-{$(ALTSRC)\cpu\$(Platform_arch)\vm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\jfr}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{$(ALTSRC)\share\vm\jfr\buffers}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-!endif
-
-{..\generated\incls}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{..\generated\adfiles}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{..\generated\jvmtifiles}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-{..\generated\tracefiles}.cpp.obj::
-        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
-
-default::
-
-_build_pch_file.obj:
-        @echo #include "precompiled.hpp" > ../generated/_build_pch_file.cpp
-        $(CXX) $(CXX_FLAGS) /Fp"vm.pch" /Yc"precompiled.hpp" /c ../generated/_build_pch_file.cpp
-
-vm.def: $(Obj_Files)
-	sh $(WorkSpace)/make/windows/build_vm_def.sh
diff --git a/hotspot/make/windows/projectfiles/common/Makefile b/hotspot/make/windows/projectfiles/common/Makefile
deleted file mode 100644
index 3fe5abc..0000000
--- a/hotspot/make/windows/projectfiles/common/Makefile
+++ /dev/null
@@ -1,132 +0,0 @@
-#
-# 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
-# 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.
-#
-#
-
-!ifdef LOCAL_MAKE
-!include $(LOCAL_MAKE)
-!endif
-
-
-WorkSpace=$(HOTSPOTWORKSPACE)
-
-!ifdef ALT_BOOTDIR
-BootStrapDir=$(ALT_BOOTDIR)
-!else
-!ifdef BOOTDIR
-BootStrapDir=$(BOOTDIR)
-!else
-!ifdef JAVA_HOME
-BootStrapDir=$(JAVA_HOME)
-!else
-!ifdef HOTSPOTJDKDIST
-BootStrapDir=$(HOTSPOTJDKDIST)
-!endif
-!endif
-!endif
-!endif
-
-# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
-!ifndef OPENJDK
-!if !exists($(WorkSpace)\src\closed)
-OPENJDK=true
-!endif
-!endif
-
-
-!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/projectcreator.make
-!include $(WorkSpace)/make/windows/makefiles/compile.make
-
-# Pick up rules for building JVMTI (JSR-163)
-JvmtiOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\jvmtifiles
-!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/jvmti.make
-
-# Pick up rules for building trace
-TraceOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\tracefiles
-!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/trace.make
-
-!if "$(Variant)" == "compiler2"
-# Pick up rules for building adlc
-!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/adlc.make
-!endif
-
-!if "$(Variant)" == "tiered"
-# Pick up rules for building adlc
-!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/adlc.make
-!endif
-
-HS_INTERNAL_NAME=jvm
-
-default:: $(AdditionalTargets) $(JvmtiGeneratedFiles) $(TraceGeneratedFiles)
-
-!include $(HOTSPOTWORKSPACE)/make/jdk_version
-
-VERSION_MAJOR=$(STANDALONE_JDK_MAJOR_VER)
-VERSION_MINOR=$(STANDALONE_JDK_MINOR_VER)
-VERSION_SECURITY=$(STANDALONE_JDK_SECURITY_VER)
-VERSION_PATCH=$(STANDALONE_JDK_PATCH_VER)
-
-!if "$(VERSION_BUILD)" == ""
-VERSION_BUILD=0
-!endif
-
-!if "$(VERSION_OPT)" != ""
-HOTSPOT_PRE = internal-$(VERSION_OPT)
-!else
-HOTSPOT_PRE = internal
-!endif
-!if "$(VERSION_STRING)" == ""
-VERSION_STRING="\\\"$(VERSION_MAJOR)-$(HOTSPOT_PRE)+$(VERSION_BUILD)-$(USERNAME).vsbuild\\\""
-!endif
-HOTSPOT_VERSION_STRING=$(VERSION_STRING)
-
-# Define HOTSPOT_VM_DISTRO if HOTSPOT_VM_DISTRO is set,
-# and if it is not see if we have the src/closed directory
-!if "$(HOTSPOT_VM_DISTRO)" != ""
-HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO)
-!else
-!if exists($(HOTSPOTWORKSPACE)\src\closed)
-HOTSPOT_VM_DISTRO="\\\"Java HotSpot(TM)\\\""
-!else
-HOTSPOT_VM_DISTRO="\\\"OpenJDK\\\""
-!endif
-
-!endif
-
-
-
-ReleaseOptions = -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) -define VERSION_MAJOR=$(VERSION_MAJOR) -define VERSION_MINOR=$(VERSION_MINOR) -define VERSION_SECURITY=$(VERSION_SECURITY) -define VERSION_PATCH=$(VERSION_PATCH) -define VERSION_BUILD=$(VERSION_BUILD) -define VERSION_STRING=$(VERSION_STRING)
-ProjectCreatorIDEOptions = $(ProjectCreatorIDEOptions) $(ReleaseOptions)
-
-$(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class
-	@$(RUN_JAVA) -Djava.class.path="$(HOTSPOTBUILDSPACE)/classes" ProjectCreator WinGammaPlatform$(VcVersion) $(ProjectCreatorIDEOptions)
-
-clean:
-	@rm -rf $(HOTSPOTBUILDSPACE)/classes
-	@rm -r $(HOTSPOTBUILDSPACE)/$(ProjectFile)
-
-$(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class: $(ProjectCreatorSources)
-	@if exist $(HOTSPOTBUILDSPACE)\classes rmdir /s /q $(HOTSPOTBUILDSPACE)\classes
-	@mkdir $(HOTSPOTBUILDSPACE)\classes
-	@$(COMPILE_JAVAC) -classpath $(HOTSPOTWORKSPACE)\src\share\tools\ProjectCreator -d $(HOTSPOTBUILDSPACE)/classes $(ProjectCreatorSources)
-
-FORCE:
diff --git a/hotspot/make/windows/projectfiles/compiler1/Makefile b/hotspot/make/windows/projectfiles/compiler1/Makefile
deleted file mode 100644
index 183a276..0000000
--- a/hotspot/make/windows/projectfiles/compiler1/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 1999, 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 ../local.make
-
-!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile
diff --git a/hotspot/make/windows/projectfiles/compiler1/vm.def b/hotspot/make/windows/projectfiles/compiler1/vm.def
deleted file mode 100644
index b450e81..0000000
--- a/hotspot/make/windows/projectfiles/compiler1/vm.def
+++ /dev/null
@@ -1,7 +0,0 @@
-;

-; This .DEF file is a placeholder for one which is automatically

-; generated during the build process. See

-; make\windows\build_vm_def.sh and

-; make\windows\makefiles\projectcreator.make (esp. the "-prelink"

-; options).

-;

diff --git a/hotspot/make/windows/projectfiles/compiler1/vm.dsw b/hotspot/make/windows/projectfiles/compiler1/vm.dsw
deleted file mode 100644
index 934f51a..0000000
--- a/hotspot/make/windows/projectfiles/compiler1/vm.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00

-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

-

-###############################################################################

-

-Project: "vm"=.\vm.dsp - Package Owner=<4>

-

-Package=<5>

-{{{

-}}}

-

-Package=<4>

-{{{

-}}}

-

-###############################################################################

-

-Global:

-

-Package=<5>

-{{{

-}}}

-

-Package=<3>

-{{{

-}}}

-

-###############################################################################

-

diff --git a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsp b/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsp
deleted file mode 100644
index 557cce4..0000000
--- a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsp
+++ /dev/null
Binary files differ
diff --git a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsw b/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsw
deleted file mode 100644
index 0ad5370..0000000
--- a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00

-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

-

-###############################################################################

-

-Project: "ADLCompiler"=".\ADLCompiler.dsp" - Package Owner=<4>

-

-Package=<5>

-{{{

-}}}

-

-Package=<4>

-{{{

-}}}

-

-###############################################################################

-

-Global:

-

-Package=<5>

-{{{

-}}}

-

-Package=<3>

-{{{

-}}}

-

-###############################################################################

-

diff --git a/hotspot/make/windows/projectfiles/compiler2/Makefile b/hotspot/make/windows/projectfiles/compiler2/Makefile
deleted file mode 100644
index 1df97d2..0000000
--- a/hotspot/make/windows/projectfiles/compiler2/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 1998, 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 ../local.make
-AdlcOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\adfiles
-AdditionalTargets=$(AdlcOutDir)\ad_$(Platform_arch_model).cpp $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp
-
-!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile
diff --git a/hotspot/make/windows/projectfiles/compiler2/vm.def b/hotspot/make/windows/projectfiles/compiler2/vm.def
deleted file mode 100644
index b450e81..0000000
--- a/hotspot/make/windows/projectfiles/compiler2/vm.def
+++ /dev/null
@@ -1,7 +0,0 @@
-;

-; This .DEF file is a placeholder for one which is automatically

-; generated during the build process. See

-; make\windows\build_vm_def.sh and

-; make\windows\makefiles\projectcreator.make (esp. the "-prelink"

-; options).

-;

diff --git a/hotspot/make/windows/projectfiles/compiler2/vm.dsw b/hotspot/make/windows/projectfiles/compiler2/vm.dsw
deleted file mode 100644
index 26aab5c..0000000
--- a/hotspot/make/windows/projectfiles/compiler2/vm.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 5.00

-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

-

-###############################################################################

-

-Project: "vm"=.\vm.dsp - Package Owner=<4>

-

-Package=<5>

-{{{

-}}}

-

-Package=<4>

-{{{

-}}}

-

-###############################################################################

-

-Global:

-

-Package=<5>

-{{{

-}}}

-

-Package=<3>

-{{{

-}}}

-

-###############################################################################

-

diff --git a/hotspot/make/windows/projectfiles/core/Makefile b/hotspot/make/windows/projectfiles/core/Makefile
deleted file mode 100644
index 5b23a84..0000000
--- a/hotspot/make/windows/projectfiles/core/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 1998, 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 ../local.make
-
-!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile
diff --git a/hotspot/make/windows/projectfiles/core/vm.def b/hotspot/make/windows/projectfiles/core/vm.def
deleted file mode 100644
index b450e81..0000000
--- a/hotspot/make/windows/projectfiles/core/vm.def
+++ /dev/null
@@ -1,7 +0,0 @@
-;

-; This .DEF file is a placeholder for one which is automatically

-; generated during the build process. See

-; make\windows\build_vm_def.sh and

-; make\windows\makefiles\projectcreator.make (esp. the "-prelink"

-; options).

-;

diff --git a/hotspot/make/windows/projectfiles/core/vm.dsw b/hotspot/make/windows/projectfiles/core/vm.dsw
deleted file mode 100644
index 934f51a..0000000
--- a/hotspot/make/windows/projectfiles/core/vm.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00

-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

-

-###############################################################################

-

-Project: "vm"=.\vm.dsp - Package Owner=<4>

-

-Package=<5>

-{{{

-}}}

-

-Package=<4>

-{{{

-}}}

-

-###############################################################################

-

-Global:

-

-Package=<5>

-{{{

-}}}

-

-Package=<3>

-{{{

-}}}

-

-###############################################################################

-

diff --git a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsp b/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsp
deleted file mode 100644
index 557cce4..0000000
--- a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsp
+++ /dev/null
Binary files differ
diff --git a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsw b/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsw
deleted file mode 100644
index 0ad5370..0000000
--- a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00

-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

-

-###############################################################################

-

-Project: "ADLCompiler"=".\ADLCompiler.dsp" - Package Owner=<4>

-

-Package=<5>

-{{{

-}}}

-

-Package=<4>

-{{{

-}}}

-

-###############################################################################

-

-Global:

-

-Package=<5>

-{{{

-}}}

-

-Package=<3>

-{{{

-}}}

-

-###############################################################################

-

diff --git a/hotspot/make/windows/projectfiles/tiered/Makefile b/hotspot/make/windows/projectfiles/tiered/Makefile
deleted file mode 100644
index 5398cb9..0000000
--- a/hotspot/make/windows/projectfiles/tiered/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 2006, 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 ../local.make
-AdlcOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\adfiles
-AdditionalTargets=$(AdlcOutDir)\ad_$(Platform_arch_model).cpp $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp
-
-!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile
diff --git a/hotspot/make/windows/projectfiles/tiered/vm.def b/hotspot/make/windows/projectfiles/tiered/vm.def
deleted file mode 100644
index b450e81..0000000
--- a/hotspot/make/windows/projectfiles/tiered/vm.def
+++ /dev/null
@@ -1,7 +0,0 @@
-;

-; This .DEF file is a placeholder for one which is automatically

-; generated during the build process. See

-; make\windows\build_vm_def.sh and

-; make\windows\makefiles\projectcreator.make (esp. the "-prelink"

-; options).

-;

diff --git a/hotspot/make/windows/projectfiles/tiered/vm.dsw b/hotspot/make/windows/projectfiles/tiered/vm.dsw
deleted file mode 100644
index 26aab5c..0000000
--- a/hotspot/make/windows/projectfiles/tiered/vm.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 5.00

-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

-

-###############################################################################

-

-Project: "vm"=.\vm.dsp - Package Owner=<4>

-

-Package=<5>

-{{{

-}}}

-

-Package=<4>

-{{{

-}}}

-

-###############################################################################

-

-Global:

-

-Package=<5>

-{{{

-}}}

-

-Package=<3>

-{{{

-}}}

-

-###############################################################################

-

diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad
index e92411b..5359f30 100644
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad
@@ -996,6 +996,7 @@
 source_hpp %{
 
 #include "gc/shared/cardTableModRefBS.hpp"
+#include "opto/addnode.hpp"
 
 class CallStubImpl {
 
@@ -1061,6 +1062,9 @@
 
   // predicate controlling translation of StoreCM
   bool unnecessary_storestore(const Node *storecm);
+
+  // predicate controlling addressing modes
+  bool size_fits_all_mem_uses(AddPNode* addp, int shift);
 %}
 
 source %{
@@ -3077,7 +3081,7 @@
       assert((src_lo_rc != rc_int && dst_lo_rc != rc_int), "sanity");
       if (src_lo_rc == rc_stack && dst_lo_rc == rc_stack) {
         // stack->stack
-        assert((src_offset & 7) && (dst_offset & 7), "unaligned stack offset");
+        assert((src_offset & 7) == 0 && (dst_offset & 7) == 0, "unaligned stack offset");
         if (ireg == Op_VecD) {
           __ unspill(rscratch1, true, src_offset);
           __ spill(rscratch1, true, dst_offset);
@@ -3325,9 +3329,15 @@
 
 const bool Matcher::match_rule_supported(int opcode) {
 
-  // TODO
-  // identify extra cases that we might want to provide match rules for
-  // e.g. Op_StrEquals and other intrinsics
+  switch (opcode) {
+  case Op_StrComp:
+  case Op_StrIndexOf:
+    if (CompactStrings)  return false;
+    break;
+  default:
+    break;
+  }
+
   if (!has_match_rule(opcode)) {
     return false;
   }
@@ -3346,6 +3356,10 @@
   return ret_value;  // Per default match rules are supported.
 }
 
+const bool Matcher::has_predicated_vectors(void) {
+  return false;
+}
+
 const int Matcher::float_pressure(int default_pressure_threshold) {
   return default_pressure_threshold;
 }
@@ -3439,11 +3453,6 @@
 // Does the CPU require late expand (see block.cpp for description of late expand)?
 const bool Matcher::require_postalloc_expand = false;
 
-// Should the Matcher clone shifts on addressing modes, expecting them
-// to be subsumed into complex addressing expressions or compute them
-// into registers?  True for Intel but false for most RISCs
-const bool Matcher::clone_shift_expressions = false;
-
 // Do we need to mask the count passed to shift instructions or does
 // the cpu only look at the lower 5/6 bits anyway?
 const bool Matcher::need_masked_shift_count = false;
@@ -3562,6 +3571,119 @@
   return FP_REG_mask();
 }
 
+bool size_fits_all_mem_uses(AddPNode* addp, int shift) {
+  for (DUIterator_Fast imax, i = addp->fast_outs(imax); i < imax; i++) {
+    Node* u = addp->fast_out(i);
+    if (u->is_Mem()) {
+      int opsize = u->as_Mem()->memory_size();
+      assert(opsize > 0, "unexpected memory operand size");
+      if (u->as_Mem()->memory_size() != (1<<shift)) {
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+const bool Matcher::convi2l_type_required = false;
+
+// Should the Matcher clone shifts on addressing modes, expecting them
+// to be subsumed into complex addressing expressions or compute them
+// into registers?
+bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) {
+  if (clone_base_plus_offset_address(m, mstack, address_visited)) {
+    return true;
+  }
+
+  Node *off = m->in(AddPNode::Offset);
+  if (off->Opcode() == Op_LShiftL && off->in(2)->is_Con() &&
+      size_fits_all_mem_uses(m, off->in(2)->get_int()) &&
+      // Are there other uses besides address expressions?
+      !is_visited(off)) {
+    address_visited.set(off->_idx); // Flag as address_visited
+    mstack.push(off->in(2), Visit);
+    Node *conv = off->in(1);
+    if (conv->Opcode() == Op_ConvI2L &&
+        // Are there other uses besides address expressions?
+        !is_visited(conv)) {
+      address_visited.set(conv->_idx); // Flag as address_visited
+      mstack.push(conv->in(1), Pre_Visit);
+    } else {
+      mstack.push(conv, Pre_Visit);
+    }
+    address_visited.test_set(m->_idx); // Flag as address_visited
+    mstack.push(m->in(AddPNode::Address), Pre_Visit);
+    mstack.push(m->in(AddPNode::Base), Pre_Visit);
+    return true;
+  } else if (off->Opcode() == Op_ConvI2L &&
+             // Are there other uses besides address expressions?
+             !is_visited(off)) {
+    address_visited.test_set(m->_idx); // Flag as address_visited
+    address_visited.set(off->_idx); // Flag as address_visited
+    mstack.push(off->in(1), Pre_Visit);
+    mstack.push(m->in(AddPNode::Address), Pre_Visit);
+    mstack.push(m->in(AddPNode::Base), Pre_Visit);
+    return true;
+  }
+  return false;
+}
+
+// Transform:
+// (AddP base (AddP base address (LShiftL index con)) offset)
+// into:
+// (AddP base (AddP base offset) (LShiftL index con))
+// to take full advantage of ARM's addressing modes
+void Compile::reshape_address(AddPNode* addp) {
+  Node *addr = addp->in(AddPNode::Address);
+  if (addr->is_AddP() && addr->in(AddPNode::Base) == addp->in(AddPNode::Base)) {
+    const AddPNode *addp2 = addr->as_AddP();
+    if ((addp2->in(AddPNode::Offset)->Opcode() == Op_LShiftL &&
+         addp2->in(AddPNode::Offset)->in(2)->is_Con() &&
+         size_fits_all_mem_uses(addp, addp2->in(AddPNode::Offset)->in(2)->get_int())) ||
+        addp2->in(AddPNode::Offset)->Opcode() == Op_ConvI2L) {
+
+      // Any use that can't embed the address computation?
+      for (DUIterator_Fast imax, i = addp->fast_outs(imax); i < imax; i++) {
+        Node* u = addp->fast_out(i);
+        if (!u->is_Mem() || u->is_LoadVector() || u->is_StoreVector() || u->Opcode() == Op_StoreCM) {
+          return;
+        }
+      }
+      
+      Node* off = addp->in(AddPNode::Offset);
+      Node* addr2 = addp2->in(AddPNode::Address);
+      Node* base = addp->in(AddPNode::Base);
+      
+      Node* new_addr = NULL;
+      // Check whether the graph already has the new AddP we need
+      // before we create one (no GVN available here).
+      for (DUIterator_Fast imax, i = addr2->fast_outs(imax); i < imax; i++) {
+        Node* u = addr2->fast_out(i);
+        if (u->is_AddP() &&
+            u->in(AddPNode::Base) == base &&
+            u->in(AddPNode::Address) == addr2 &&
+            u->in(AddPNode::Offset) == off) {
+          new_addr = u;
+          break;
+        }
+      }
+      
+      if (new_addr == NULL) {
+        new_addr = new AddPNode(base, addr2, off);
+      }
+      Node* new_off = addp2->in(AddPNode::Offset);
+      addp->set_req(AddPNode::Address, new_addr);
+      if (addr->outcnt() == 0) {
+        addr->disconnect_inputs(NULL, this);
+      }
+      addp->set_req(AddPNode::Offset, new_off);
+      if (off->outcnt() == 0) {
+        off->disconnect_inputs(NULL, this);
+      }
+    }
+  }
+}
+
 // helper for encoding java_to_runtime calls on sim
 //
 // this is needed to compute the extra arguments required when
@@ -3631,12 +3753,10 @@
     // encoder that the index needs to be sign extended, so we have to
     // enumerate all the cases.
     switch (opcode) {
-    case INDINDEXSCALEDOFFSETI2L:
     case INDINDEXSCALEDI2L:
-    case INDINDEXSCALEDOFFSETI2LN:
     case INDINDEXSCALEDI2LN:
-    case INDINDEXOFFSETI2L:
-    case INDINDEXOFFSETI2LN:
+    case INDINDEXI2L:
+    case INDINDEXI2LN:
       scale = Address::sxtw(size);
       break;
     default:
@@ -3646,12 +3766,8 @@
     if (index == -1) {
       (masm.*insn)(reg, Address(base, disp));
     } else {
-      if (disp == 0) {
-        (masm.*insn)(reg, Address(base, as_Register(index), scale));
-      } else {
-        masm.lea(rscratch1, Address(base, disp));
-        (masm.*insn)(reg, Address(rscratch1, as_Register(index), scale));
-      }
+      assert(disp == 0, "unsupported address mode: disp = %d", disp);
+      (masm.*insn)(reg, Address(base, as_Register(index), scale));
     }
   }
 
@@ -3662,9 +3778,7 @@
     Address::extend scale;
 
     switch (opcode) {
-    case INDINDEXSCALEDOFFSETI2L:
     case INDINDEXSCALEDI2L:
-    case INDINDEXSCALEDOFFSETI2LN:
     case INDINDEXSCALEDI2LN:
       scale = Address::sxtw(size);
       break;
@@ -3675,12 +3789,8 @@
      if (index == -1) {
       (masm.*insn)(reg, Address(base, disp));
     } else {
-      if (disp == 0) {
-        (masm.*insn)(reg, Address(base, as_Register(index), scale));
-      } else {
-        masm.lea(rscratch1, Address(base, disp));
-        (masm.*insn)(reg, Address(rscratch1, as_Register(index), scale));
-      }
+      assert(disp == 0, "unsupported address mode: disp = %d", disp);
+      (masm.*insn)(reg, Address(base, as_Register(index), scale));
     }
   }
 
@@ -4190,55 +4300,6 @@
     }
   %}
 
-  enc_class aarch64_enc_clear_array_reg_reg(iRegL_R11 cnt, iRegP_R10 base) %{
-    MacroAssembler _masm(&cbuf);
-    Register cnt_reg = as_Register($cnt$$reg);
-    Register base_reg = as_Register($base$$reg);
-    // base is word aligned
-    // cnt is count of words
-
-    Label loop;
-    Label entry;
-
-//  Algorithm:
-//
-//    scratch1 = cnt & 7;
-//    cnt -= scratch1;
-//    p += scratch1;
-//    switch (scratch1) {
-//      do {
-//        cnt -= 8;
-//          p[-8] = 0;
-//        case 7:
-//          p[-7] = 0;
-//        case 6:
-//          p[-6] = 0;
-//          // ...
-//        case 1:
-//          p[-1] = 0;
-//        case 0:
-//          p += 8;
-//      } while (cnt);
-//    }
-
-    const int unroll = 8; // Number of str(zr) instructions we'll unroll
-
-    __ andr(rscratch1, cnt_reg, unroll - 1);  // tmp1 = cnt % unroll
-    __ sub(cnt_reg, cnt_reg, rscratch1);      // cnt -= unroll
-    // base_reg always points to the end of the region we're about to zero
-    __ add(base_reg, base_reg, rscratch1, Assembler::LSL, exact_log2(wordSize));
-    __ adr(rscratch2, entry);
-    __ sub(rscratch2, rscratch2, rscratch1, Assembler::LSL, 2);
-    __ br(rscratch2);
-    __ bind(loop);
-    __ sub(cnt_reg, cnt_reg, unroll);
-    for (int i = -unroll; i < 0; i++)
-      __ str(zr, Address(base_reg, i * wordSize));
-    __ bind(entry);
-    __ add(base_reg, base_reg, unroll * wordSize);
-    __ cbnz(cnt_reg, loop);
-  %}
-
   /// mov envcodings
 
   enc_class aarch64_enc_movw_imm(iRegI dst, immI src) %{
@@ -5351,6 +5412,36 @@
   interface(CONST_INTER);
 %}
 
+operand immIOffset4()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_int(), 2));
+  match(ConI);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immIOffset8()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_int(), 3));
+  match(ConI);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immIOffset16()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_int(), 4));
+  match(ConI);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
 operand immLoffset()
 %{
   predicate(Address::offset_ok_for_immed(n->get_long()));
@@ -5361,6 +5452,36 @@
   interface(CONST_INTER);
 %}
 
+operand immLoffset4()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_long(), 2));
+  match(ConL);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immLoffset8()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_long(), 3));
+  match(ConL);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immLoffset16()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_long(), 4));
+  match(ConL);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
 // 32 bit integer valid for add sub immediate
 operand immIAddSub()
 %{
@@ -6083,65 +6204,10 @@
   %}
 %}
 
-operand indIndexScaledOffsetI(iRegP reg, iRegL lreg, immIScale scale, immIU12 off)
-%{
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP reg (LShiftL lreg scale)) off);
-  op_cost(INSN_COST);
-  format %{ "$reg, $lreg lsl($scale), $off" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($lreg);
-    scale($scale);
-    disp($off);
-  %}
-%}
-
-operand indIndexScaledOffsetL(iRegP reg, iRegL lreg, immIScale scale, immLU12 off)
-%{
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP reg (LShiftL lreg scale)) off);
-  op_cost(INSN_COST);
-  format %{ "$reg, $lreg lsl($scale), $off" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($lreg);
-    scale($scale);
-    disp($off);
-  %}
-%}
-
-operand indIndexOffsetI2L(iRegP reg, iRegI ireg, immLU12 off)
-%{
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP reg (ConvI2L ireg)) off);
-  op_cost(INSN_COST);
-  format %{ "$reg, $ireg, $off I2L" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($ireg);
-    scale(0x0);
-    disp($off);
-  %}
-%}
-
-operand indIndexScaledOffsetI2L(iRegP reg, iRegI ireg, immIScale scale, immLU12 off)
-%{
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP reg (LShiftL (ConvI2L ireg) scale)) off);
-  op_cost(INSN_COST);
-  format %{ "$reg, $ireg sxtw($scale), $off I2L" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($ireg);
-    scale($scale);
-    disp($off);
-  %}
-%}
-
 operand indIndexScaledI2L(iRegP reg, iRegI ireg, immIScale scale)
 %{
   constraint(ALLOC_IN_RC(ptr_reg));
+  predicate(size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int()));
   match(AddP reg (LShiftL (ConvI2L ireg) scale));
   op_cost(0);
   format %{ "$reg, $ireg sxtw($scale), 0, I2L" %}
@@ -6156,6 +6222,7 @@
 operand indIndexScaled(iRegP reg, iRegL lreg, immIScale scale)
 %{
   constraint(ALLOC_IN_RC(ptr_reg));
+  predicate(size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int()));
   match(AddP reg (LShiftL lreg scale));
   op_cost(0);
   format %{ "$reg, $lreg lsl($scale)" %}
@@ -6167,6 +6234,20 @@
   %}
 %}
 
+operand indIndexI2L(iRegP reg, iRegI ireg)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg (ConvI2L ireg));
+  op_cost(0);
+  format %{ "$reg, $ireg, 0, I2L" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index($ireg);
+    scale(0x0);
+    disp(0x0);
+  %}
+%}
+
 operand indIndex(iRegP reg, iRegL lreg)
 %{
   constraint(ALLOC_IN_RC(ptr_reg));
@@ -6195,6 +6276,48 @@
   %}
 %}
 
+operand indOffI4(iRegP reg, immIOffset4 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
+operand indOffI8(iRegP reg, immIOffset8 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
+operand indOffI16(iRegP reg, immIOffset16 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
 operand indOffL(iRegP reg, immLoffset off)
 %{
   constraint(ALLOC_IN_RC(ptr_reg));
@@ -6209,6 +6332,47 @@
   %}
 %}
 
+operand indOffL4(iRegP reg, immLoffset4 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
+operand indOffL8(iRegP reg, immLoffset8 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
+operand indOffL16(iRegP reg, immLoffset16 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
 
 operand indirectN(iRegN reg)
 %{
@@ -6225,69 +6389,9 @@
   %}
 %}
 
-operand indIndexScaledOffsetIN(iRegN reg, iRegL lreg, immIScale scale, immIU12 off)
-%{
-  predicate(Universe::narrow_oop_shift() == 0);
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP (DecodeN reg) (LShiftL lreg scale)) off);
-  op_cost(0);
-  format %{ "$reg, $lreg lsl($scale), $off\t# narrow" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($lreg);
-    scale($scale);
-    disp($off);
-  %}
-%}
-
-operand indIndexScaledOffsetLN(iRegN reg, iRegL lreg, immIScale scale, immLU12 off)
-%{
-  predicate(Universe::narrow_oop_shift() == 0);
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP (DecodeN reg) (LShiftL lreg scale)) off);
-  op_cost(INSN_COST);
-  format %{ "$reg, $lreg lsl($scale), $off\t# narrow" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($lreg);
-    scale($scale);
-    disp($off);
-  %}
-%}
-
-operand indIndexOffsetI2LN(iRegN reg, iRegI ireg, immLU12 off)
-%{
-  predicate(Universe::narrow_oop_shift() == 0);
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP (DecodeN reg) (ConvI2L ireg)) off);
-  op_cost(INSN_COST);
-  format %{ "$reg, $ireg, $off I2L\t# narrow" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($ireg);
-    scale(0x0);
-    disp($off);
-  %}
-%}
-
-operand indIndexScaledOffsetI2LN(iRegN reg, iRegI ireg, immIScale scale, immLU12 off)
-%{
-  predicate(Universe::narrow_oop_shift() == 0);
-  constraint(ALLOC_IN_RC(ptr_reg));
-  match(AddP (AddP (DecodeN reg) (LShiftL (ConvI2L ireg) scale)) off);
-  op_cost(INSN_COST);
-  format %{ "$reg, $ireg sxtw($scale), $off I2L\t# narrow" %}
-  interface(MEMORY_INTER) %{
-    base($reg);
-    index($ireg);
-    scale($scale);
-    disp($off);
-  %}
-%}
-
 operand indIndexScaledI2LN(iRegN reg, iRegI ireg, immIScale scale)
 %{
-  predicate(Universe::narrow_oop_shift() == 0);
+  predicate(Universe::narrow_oop_shift() == 0 && size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int()));
   constraint(ALLOC_IN_RC(ptr_reg));
   match(AddP (DecodeN reg) (LShiftL (ConvI2L ireg) scale));
   op_cost(0);
@@ -6302,7 +6406,7 @@
 
 operand indIndexScaledN(iRegN reg, iRegL lreg, immIScale scale)
 %{
-  predicate(Universe::narrow_oop_shift() == 0);
+  predicate(Universe::narrow_oop_shift() == 0 && size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int()));
   constraint(ALLOC_IN_RC(ptr_reg));
   match(AddP (DecodeN reg) (LShiftL lreg scale));
   op_cost(0);
@@ -6315,6 +6419,21 @@
   %}
 %}
 
+operand indIndexI2LN(iRegN reg, iRegI ireg)
+%{
+  predicate(Universe::narrow_oop_shift() == 0);
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP (DecodeN reg) (ConvI2L ireg));
+  op_cost(0);
+  format %{ "$reg, $ireg, 0, I2L\t# narrow" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index($ireg);
+    scale(0x0);
+    disp(0x0);
+  %}
+%}
+
 operand indIndexN(iRegN reg, iRegL lreg)
 %{
   predicate(Universe::narrow_oop_shift() == 0);
@@ -6521,7 +6640,9 @@
   interface(REG_INTER)
 %}
 
-opclass vmem(indirect, indIndex, indOffI, indOffL);
+opclass vmem4(indirect, indIndex, indOffI4, indOffL4);
+opclass vmem8(indirect, indIndex, indOffI8, indOffL8);
+opclass vmem16(indirect, indIndex, indOffI16, indOffL16);
 
 //----------OPERAND CLASSES----------------------------------------------------
 // Operand Classes are groups of operands that are used as to simplify
@@ -6533,9 +6654,8 @@
 // memory is used to define read/write location for load/store
 // instruction defs. we can turn a memory op into an Address
 
-opclass memory(indirect, indIndexScaledOffsetI, indIndexScaledOffsetL, indIndexOffsetI2L, indIndexScaledOffsetI2L, indIndexScaled, indIndexScaledI2L, indIndex, indOffI, indOffL,
-               indirectN, indIndexScaledOffsetIN, indIndexScaledOffsetLN, indIndexOffsetI2LN, indIndexScaledOffsetI2LN, indIndexScaledN, indIndexScaledI2LN, indIndexN, indOffIN, indOffLN);
-
+opclass memory(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI, indOffL,
+               indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN);
 
 // iRegIorL2I is used for src inputs in rules for 32 bit int (I)
 // operations. it allows the src to be either an iRegI or a (ConvL2I
@@ -7053,7 +7173,7 @@
   NEON_FP : S3;
 %}
 
-pipe_class vload_reg_mem64(vecD dst, vmem mem)
+pipe_class vload_reg_mem64(vecD dst, vmem8 mem)
 %{
   single_instruction;
   dst    : S5(write);
@@ -7062,7 +7182,7 @@
   NEON_FP : S3;
 %}
 
-pipe_class vload_reg_mem128(vecX dst, vmem mem)
+pipe_class vload_reg_mem128(vecX dst, vmem16 mem)
 %{
   single_instruction;
   dst    : S5(write);
@@ -7071,7 +7191,7 @@
   NEON_FP : S3;
 %}
 
-pipe_class vstore_reg_mem64(vecD src, vmem mem)
+pipe_class vstore_reg_mem64(vecD src, vmem8 mem)
 %{
   single_instruction;
   mem    : ISS(read);
@@ -7080,7 +7200,7 @@
   NEON_FP : S3;
 %}
 
-pipe_class vstore_reg_mem128(vecD src, vmem mem)
+pipe_class vstore_reg_mem128(vecD src, vmem16 mem)
 %{
   single_instruction;
   mem    : ISS(read);
@@ -12123,21 +12243,21 @@
   %}
 %}
 
-instruct rorI_rReg_Var_C_32(iRegLNoSp dst, iRegL src, iRegI shift, immI_32 c_32, rFlagsReg cr)
+instruct rorI_rReg_Var_C_32(iRegINoSp dst, iRegI src, iRegI shift, immI_32 c_32, rFlagsReg cr)
 %{
   match(Set dst (OrI (URShiftI src shift) (LShiftI src (SubI c_32 shift))));
 
   expand %{
-    rorL_rReg(dst, src, shift, cr);
+    rorI_rReg(dst, src, shift, cr);
   %}
 %}
 
-instruct rorI_rReg_Var_C0(iRegLNoSp dst, iRegL src, iRegI shift, immI0 c0, rFlagsReg cr)
+instruct rorI_rReg_Var_C0(iRegINoSp dst, iRegI src, iRegI shift, immI0 c0, rFlagsReg cr)
 %{
   match(Set dst (OrI (URShiftI src shift) (LShiftI src (SubI c0 shift))));
 
   expand %{
-    rorL_rReg(dst, src, shift, cr);
+    rorI_rReg(dst, src, shift, cr);
   %}
 %}
 
@@ -13363,7 +13483,24 @@
   ins_cost(4 * INSN_COST);
   format %{ "ClearArray $cnt, $base" %}
 
-  ins_encode(aarch64_enc_clear_array_reg_reg(cnt, base));
+  ins_encode %{
+    __ zero_words($base$$Register, $cnt$$Register);
+  %}
+
+  ins_pipe(pipe_class_memory);
+%}
+
+instruct clearArray_imm_reg(immL cnt, iRegP_R10 base, iRegL_R11 tmp, Universe dummy, rFlagsReg cr)
+%{
+  match(Set dummy (ClearArray cnt base));
+  effect(USE_KILL base, TEMP tmp);
+
+  ins_cost(4 * INSN_COST);
+  format %{ "ClearArray $cnt, $base" %}
+
+  ins_encode %{
+    __ zero_words($base$$Register, (u_int64_t)$cnt$$constant);
+  %}
 
   ins_pipe(pipe_class_memory);
 %}
@@ -14797,10 +14934,10 @@
   ins_pipe(pipe_class_memory);
 %}
 
-instruct string_compare(iRegP_R1 str1, iRegI_R2 cnt1, iRegP_R3 str2, iRegI_R4 cnt2,
+instruct string_compareU(iRegP_R1 str1, iRegI_R2 cnt1, iRegP_R3 str2, iRegI_R4 cnt2,
                         iRegI_R0 result, iRegP_R10 tmp1, rFlagsReg cr)
 %{
-  predicate(!CompactStrings);
+  predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::UU);
   match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
   effect(KILL tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr);
 
@@ -14819,7 +14956,7 @@
 instruct string_indexof(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, iRegI_R2 cnt2,
        iRegI_R0 result, iRegI tmp1, iRegI tmp2, iRegI tmp3, iRegI tmp4, rFlagsReg cr)
 %{
-  predicate(!CompactStrings);
+  predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UU);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2)));
   effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2,
          TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, KILL cr);
@@ -14839,7 +14976,7 @@
                  immI_le_4 int_cnt2, iRegI_R0 result, iRegI tmp1, iRegI tmp2,
                  iRegI tmp3, iRegI tmp4, rFlagsReg cr)
 %{
-  predicate(!CompactStrings);
+  predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UU);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 int_cnt2)));
   effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt1,
          TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, KILL cr);
@@ -14856,10 +14993,27 @@
   ins_pipe(pipe_class_memory);
 %}
 
-instruct string_equals(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt,
+instruct string_equalsL(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt,
                         iRegI_R0 result, rFlagsReg cr)
 %{
-  predicate(!CompactStrings);
+  predicate(((StrEqualsNode*)n)->encoding() == StrIntrinsicNode::LL);
+  match(Set result (StrEquals (Binary str1 str2) cnt));
+  effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL cr);
+
+  format %{ "String Equals $str1,$str2,$cnt -> $result" %}
+  ins_encode %{
+    // Count is in 8-bit bytes; non-Compact chars are 16 bits.
+    __ arrays_equals($str1$$Register, $str2$$Register,
+                     $result$$Register, $cnt$$Register,
+                     1, /*is_string*/true);
+  %}
+  ins_pipe(pipe_class_memory);
+%}
+
+instruct string_equalsU(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt,
+                        iRegI_R0 result, rFlagsReg cr)
+%{
+  predicate(((StrEqualsNode*)n)->encoding() == StrIntrinsicNode::UU);
   match(Set result (StrEquals (Binary str1 str2) cnt));
   effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL cr);
 
@@ -14907,6 +15061,40 @@
 %}
 
 
+// fast char[] to byte[] compression
+instruct string_compress(iRegP_R2 src, iRegP_R1 dst, iRegI_R3 len,
+                         vRegD_V0 tmp1, vRegD_V1 tmp2,
+                         vRegD_V2 tmp3, vRegD_V3 tmp4,
+                         iRegI_R0 result, rFlagsReg cr)
+%{
+  match(Set result (StrCompressedCopy src (Binary dst len)));
+  effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, USE_KILL src, USE_KILL dst, USE_KILL len, KILL cr);
+
+  format %{ "String Compress $src,$dst -> $result    // KILL R1, R2, R3, R4" %}
+  ins_encode %{
+    __ char_array_compress($src$$Register, $dst$$Register, $len$$Register,
+                           $tmp1$$FloatRegister, $tmp2$$FloatRegister,
+                           $tmp3$$FloatRegister, $tmp4$$FloatRegister,
+                           $result$$Register);
+  %}
+  ins_pipe( pipe_slow );
+%}
+
+// fast byte[] to char[] inflation
+instruct string_inflate(Universe dummy, iRegP_R0 src, iRegP_R1 dst, iRegI_R2 len,
+                        vRegD tmp1, vRegD tmp2, vRegD tmp3, iRegP_R3 tmp4, rFlagsReg cr)
+%{
+  match(Set dummy (StrInflatedCopy src (Binary dst len)));
+  effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, USE_KILL src, USE_KILL dst, USE_KILL len, KILL cr);
+
+  format %{ "String Inflate $src,$dst    // KILL $tmp1, $tmp2" %}
+  ins_encode %{
+    __ byte_array_inflate($src$$Register, $dst$$Register, $len$$Register,
+                          $tmp1$$FloatRegister, $tmp2$$FloatRegister, $tmp3$$FloatRegister, $tmp4$$Register);
+  %}
+  ins_pipe(pipe_class_memory);
+%}
+
 // encode char[] to byte[] in ISO_8859_1
 instruct encode_iso_array(iRegP_R2 src, iRegP_R1 dst, iRegI_R3 len,
                           vRegD_V0 Vtmp1, vRegD_V1 Vtmp2,
@@ -14948,7 +15136,7 @@
 // ====================VECTOR INSTRUCTIONS=====================================
 
 // Load vector (32 bits)
-instruct loadV4(vecD dst, vmem mem)
+instruct loadV4(vecD dst, vmem4 mem)
 %{
   predicate(n->as_LoadVector()->memory_size() == 4);
   match(Set dst (LoadVector mem));
@@ -14959,7 +15147,7 @@
 %}
 
 // Load vector (64 bits)
-instruct loadV8(vecD dst, vmem mem)
+instruct loadV8(vecD dst, vmem8 mem)
 %{
   predicate(n->as_LoadVector()->memory_size() == 8);
   match(Set dst (LoadVector mem));
@@ -14970,7 +15158,7 @@
 %}
 
 // Load Vector (128 bits)
-instruct loadV16(vecX dst, vmem mem)
+instruct loadV16(vecX dst, vmem16 mem)
 %{
   predicate(n->as_LoadVector()->memory_size() == 16);
   match(Set dst (LoadVector mem));
@@ -14981,7 +15169,7 @@
 %}
 
 // Store Vector (32 bits)
-instruct storeV4(vecD src, vmem mem)
+instruct storeV4(vecD src, vmem4 mem)
 %{
   predicate(n->as_StoreVector()->memory_size() == 4);
   match(Set mem (StoreVector mem src));
@@ -14992,7 +15180,7 @@
 %}
 
 // Store Vector (64 bits)
-instruct storeV8(vecD src, vmem mem)
+instruct storeV8(vecD src, vmem8 mem)
 %{
   predicate(n->as_StoreVector()->memory_size() == 8);
   match(Set mem (StoreVector mem src));
@@ -15003,7 +15191,7 @@
 %}
 
 // Store Vector (128 bits)
-instruct storeV16(vecX src, vmem mem)
+instruct storeV16(vecX src, vmem16 mem)
 %{
   predicate(n->as_StoreVector()->memory_size() == 16);
   match(Set mem (StoreVector mem src));
diff --git a/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp
index 77f49a7..a09f268 100644
--- a/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -177,4 +177,6 @@
   }
   *interpreter_frame->interpreter_frame_cache_addr() =
     method->constants()->cache();
+  *interpreter_frame->interpreter_frame_mirror_addr() =
+    method->method_holder()->java_mirror();
 }
diff --git a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp
index 965a5c8..8c7901e 100644
--- a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp
@@ -1032,12 +1032,28 @@
     system(0b00, 0b011, 0b00011, SY, 0b110);
   }
 
-  void dc(Register Rt) {
-    system(0b01, 0b011, 0b0111, 0b1011, 0b001, Rt);
+  void sys(int op1, int CRn, int CRm, int op2,
+           Register rt = (Register)0b11111) {
+    system(0b01, op1, CRn, CRm, op2, rt);
   }
 
-  void ic(Register Rt) {
-    system(0b01, 0b011, 0b0111, 0b0101, 0b001, Rt);
+  // Only implement operations accessible from EL0 or higher, i.e.,
+  //            op1    CRn    CRm    op2
+  // IC IVAU     3      7      5      1
+  // DC CVAC     3      7      10     1
+  // DC CVAU     3      7      11     1
+  // DC CIVAC    3      7      14     1
+  // DC ZVA      3      7      4      1
+  // So only deal with the CRm field.
+  enum icache_maintenance {IVAU = 0b0101};
+  enum dcache_maintenance {CVAC = 0b1010, CVAU = 0b1011, CIVAC = 0b1110, ZVA = 0b100};
+
+  void dc(dcache_maintenance cm, Register Rt) {
+    sys(0b011, 0b0111, cm, 0b001, Rt);
+  }
+
+  void ic(icache_maintenance cm, Register Rt) {
+    sys(0b011, 0b0111, cm, 0b001, Rt);
   }
 
   // A more convenient access to dmb for our purposes
@@ -2245,18 +2261,18 @@
     rf(Vn, 5), rf(Rd, 0);
   }
 
-#define INSN(NAME, opc, opc2) \
-  void NAME(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, int shift){         \
-    starti;                                                                             \
-    /* The encodings for the immh:immb fields (bits 22:16) are                          \
-     *   0001 xxx       8B/16B, shift = xxx                                             \
-     *   001x xxx       4H/8H,  shift = xxxx                                            \
-     *   01xx xxx       2S/4S,  shift = xxxxx                                           \
-     *   1xxx xxx       1D/2D,  shift = xxxxxx (1D is RESERVED)                         \
-     */                                                                                 \
-    assert((1 << ((T>>1)+3)) > shift, "Invalid Shift value");                           \
-    f(0, 31), f(T & 1, 30), f(opc, 29), f(0b011110, 28, 23),                            \
-    f((1 << ((T>>1)+3))|shift, 22, 16); f(opc2, 15, 10), rf(Vn, 5), rf(Vd, 0);          \
+#define INSN(NAME, opc, opc2)                                           \
+  void NAME(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, int shift){ \
+    starti;                                                             \
+    /* The encodings for the immh:immb fields (bits 22:16) are          \
+     *   0001 xxx       8B/16B, shift = xxx                             \
+     *   001x xxx       4H/8H,  shift = xxxx                            \
+     *   01xx xxx       2S/4S,  shift = xxxxx                           \
+     *   1xxx xxx       1D/2D,  shift = xxxxxx (1D is RESERVED)         \
+     */                                                                 \
+    assert((1 << ((T>>1)+3)) > shift, "Invalid Shift value");           \
+    f(0, 31), f(T & 1, 30), f(opc, 29), f(0b011110, 28, 23),            \
+    f((1 << ((T>>1)+3))|shift, 22, 16); f(opc2, 15, 10), rf(Vn, 5), rf(Vd, 0); \
   }
 
   INSN(shl,  0, 0b010101);
@@ -2347,6 +2363,24 @@
     f(0b000001, 15, 10), rf(Vn, 5), rf(Vd, 0);
   }
 
+  // AdvSIMD ZIP/UZP/TRN
+#define INSN(NAME, opcode)                                              \
+  void NAME(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, FloatRegister Vm) { \
+    starti;                                                             \
+    f(0, 31), f(0b001110, 29, 24), f(0, 21), f(0b001110, 15, 10);       \
+    rf(Vm, 16), rf(Vn, 5), rf(Vd, 0);                                   \
+    f(T & 1, 30), f(T >> 1, 23, 22);                                    \
+  }
+
+  INSN(uzp1, 0b001);
+  INSN(trn1, 0b010);
+  INSN(zip1, 0b011);
+  INSN(uzp2, 0b101);
+  INSN(trn2, 0b110);
+  INSN(zip2, 0b111);
+
+#undef INSN
+
   // CRC32 instructions
 #define INSN(NAME, c, sf, sz)                                             \
   void NAME(Register Rd, Register Rn, Register Rm) {                      \
diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp
index 976e691..e34c6fa 100644
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp
@@ -2942,6 +2942,10 @@
 
 void LIR_Assembler::membar_storeload() { __ membar(MacroAssembler::StoreLoad); }
 
+void LIR_Assembler::on_spin_wait() {
+  Unimplemented();
+}
+
 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
   __ mov(result_reg->as_register(), rthread);
 }
diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
index 191c4e4..4690e75 100644
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -331,7 +331,7 @@
     length.load_item();
 
   }
-  if (needs_store_check) {
+  if (needs_store_check || x->check_boolean()) {
     value.load_item();
   } else {
     value.load_for_store(x->elt_type());
@@ -380,7 +380,8 @@
     // Seems to be a precise
     post_barrier(LIR_OprFact::address(array_addr), value.result());
   } else {
-    __ move(value.result(), array_addr, null_check_info);
+    LIR_Opr result = maybe_mask_boolean(x, array.result(), value.result(), null_check_info);
+    __ move(result, array_addr, null_check_info);
   }
 }
 
@@ -1029,6 +1030,14 @@
   }
 }
 
+void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
+  Unimplemented();
+}
+
+void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
+  fatal("vectorizedMismatch intrinsic is not implemented on this platform");
+}
+
 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
 // _i2b, _i2c, _i2s
 void LIRGenerator::do_Convert(Convert* x) {
@@ -1127,7 +1136,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
diff --git a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp
index f4170ae..865ee69 100644
--- a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp
@@ -71,7 +71,7 @@
 define_pd_global(bool, OptoScheduling,               false);
 define_pd_global(bool, OptoBundling,                 false);
 define_pd_global(bool, OptoRegScheduling,            false);
-define_pd_global(bool, SuperWordLoopUnrollAnalysis,  false);
+define_pd_global(bool, SuperWordLoopUnrollAnalysis,  true);
 
 define_pd_global(intx, ReservedCodeCacheSize,        48*M);
 define_pd_global(intx, NonProfiledCodeHeapSize,      21*M);
diff --git a/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp
index 103b936..bd4e55a 100644
--- a/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -32,22 +32,6 @@
 #include "runtime/mutexLocker.hpp"
 #include "runtime/safepoint.hpp"
 
-// Release the CompiledICHolder* associated with this call site is there is one.
-void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  if (is_icholder_entry(call->destination())) {
-    NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());
-    InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());
-  }
-}
-
-bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  return is_icholder_entry(call->destination());
-}
-
 // ----------------------------------------------------------------------------
 
 #define __ _masm.
diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp
index bce575a..42c61b9 100644
--- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -221,21 +221,19 @@
       return jcw_safe;
     }
 
-    if (sender_blob->is_nmethod()) {
-        nmethod* nm = sender_blob->as_nmethod_or_null();
-        if (nm != NULL) {
-            if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
-                nm->method()->is_method_handle_intrinsic()) {
-                return false;
-            }
-        }
+    CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
+    if (nm != NULL) {
+      if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
+          nm->method()->is_method_handle_intrinsic()) {
+        return false;
+      }
     }
 
     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
     // because the return address counts against the callee's frame.
 
     if (sender_blob->frame_size() <= 0) {
-      assert(!sender_blob->is_nmethod(), "should count return address at least");
+      assert(!sender_blob->is_compiled(), "should count return address at least");
       return false;
     }
 
@@ -244,7 +242,7 @@
     // should not be anything but the call stub (already covered), the interpreter (already covered)
     // or an nmethod.
 
-    if (!sender_blob->is_nmethod()) {
+    if (!sender_blob->is_compiled()) {
         return false;
     }
 
@@ -286,7 +284,7 @@
   assert(_pc == *pc_addr || pc == *pc_addr, "must be");
   *pc_addr = pc;
   _cb = CodeCache::find_blob(pc);
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     assert(original_pc == _pc, "expected original PC to be stored before patching");
     _deopt_state = is_deoptimized;
@@ -371,7 +369,7 @@
 // Verifies the calculated original PC of a deoptimization PC for the
 // given unextended SP.
 #ifdef ASSERT
-void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) {
+void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) {
   frame fr;
 
   // This is ugly but it's better than to change {get,set}_original_pc
@@ -391,12 +389,14 @@
   // as any other call site. Therefore, no special action is needed when we are
   // returning to any of these call sites.
 
-  nmethod* sender_nm = (_cb == NULL) ? NULL : _cb->as_nmethod_or_null();
-  if (sender_nm != NULL) {
-    // If the sender PC is a deoptimization point, get the original PC.
-    if (sender_nm->is_deopt_entry(_pc) ||
-        sender_nm->is_deopt_mh_entry(_pc)) {
-      DEBUG_ONLY(verify_deopt_original_pc(sender_nm, _unextended_sp));
+  if (_cb != NULL) {
+    CompiledMethod* sender_cm = _cb->as_compiled_method_or_null();
+    if (sender_cm != NULL) {
+      // If the sender PC is a deoptimization point, get the original PC.
+      if (sender_cm->is_deopt_entry(_pc) ||
+          sender_cm->is_deopt_mh_entry(_pc)) {
+        DEBUG_ONLY(verify_deopt_original_pc(sender_cm, _unextended_sp));
+      }
     }
   }
 }
diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp
index 4332abc..5bcee32 100644
--- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -78,7 +78,9 @@
     interpreter_frame_last_sp_offset                 = interpreter_frame_sender_sp_offset - 1,
     interpreter_frame_method_offset                  = interpreter_frame_last_sp_offset - 1,
     interpreter_frame_mdp_offset                     = interpreter_frame_method_offset - 1,
-    interpreter_frame_cache_offset                   = interpreter_frame_mdp_offset - 1,
+    interpreter_frame_padding_offset                 = interpreter_frame_mdp_offset - 1,
+    interpreter_frame_mirror_offset                  = interpreter_frame_padding_offset - 1,
+    interpreter_frame_cache_offset                   = interpreter_frame_mirror_offset - 1,
     interpreter_frame_locals_offset                  = interpreter_frame_cache_offset - 1,
     interpreter_frame_bcp_offset                     = interpreter_frame_locals_offset - 1,
     interpreter_frame_initial_sp_offset              = interpreter_frame_bcp_offset - 1,
@@ -124,7 +126,7 @@
 
 #ifdef ASSERT
   // Used in frame::sender_for_{interpreter,compiled}_frame
-  static void verify_deopt_original_pc(   nmethod* nm, intptr_t* unextended_sp);
+  static void verify_deopt_original_pc(   CompiledMethod* nm, intptr_t* unextended_sp);
 #endif
 
  public:
diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp
index 7fce68b..7c410aa 100644
--- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp
+++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -55,7 +55,7 @@
   _cb = CodeCache::find_blob(pc);
   adjust_unextended_sp();
 
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     _pc = original_pc;
     _deopt_state = is_deoptimized;
@@ -79,10 +79,10 @@
   _cb = CodeCache::find_blob(pc);
   adjust_unextended_sp();
 
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     _pc = original_pc;
-    assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod");
+    assert(((CompiledMethod*)_cb)->insts_contains(_pc), "original PC must be in CompiledMethod");
     _deopt_state = is_deoptimized;
   } else {
     _deopt_state = not_deoptimized;
@@ -111,7 +111,7 @@
   _cb = CodeCache::find_blob(_pc);
   adjust_unextended_sp();
 
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     _pc = original_pc;
     _deopt_state = is_deoptimized;
@@ -188,6 +188,12 @@
   return (Method**)addr_at(interpreter_frame_method_offset);
 }
 
+// Mirror
+
+inline oop* frame::interpreter_frame_mirror_addr() const {
+  return (oop*)addr_at(interpreter_frame_mirror_offset);
+}
+
 // top of expression stack
 inline intptr_t* frame::interpreter_frame_tos_address() const {
   intptr_t* last_sp = interpreter_frame_last_sp();
diff --git a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp
index 60edc02..604b8cd 100644
--- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp
@@ -48,9 +48,9 @@
 #define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5))
 #define DEFAULT_STACK_RESERVED_PAGES (0)
 
-#define MIN_STACK_YELLOW_PAGES 1
-#define MIN_STACK_RED_PAGES    1
-#define MIN_STACK_SHADOW_PAGES 1
+#define MIN_STACK_YELLOW_PAGES DEFAULT_STACK_YELLOW_PAGES
+#define MIN_STACK_RED_PAGES    DEFAULT_STACK_RED_PAGES
+#define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES
 #define MIN_STACK_RESERVED_PAGES (0)
 
 define_pd_global(intx, StackYellowPages, DEFAULT_STACK_YELLOW_PAGES);
@@ -76,7 +76,8 @@
 // avoid biased locking while we are bootstrapping the aarch64 build
 define_pd_global(bool, UseBiasedLocking, false);
 
-define_pd_global(intx, InitArrayShortSize, 18*BytesPerLong);
+// Clear short arrays bigger than one word in an arch-specific way
+define_pd_global(intx, InitArrayShortSize, BytesPerLong);
 
 #if defined(COMPILER1) || defined(COMPILER2)
 define_pd_global(intx, InlineSmallCode,          1000);
@@ -84,7 +85,14 @@
 
 #ifdef BUILTIN_SIM
 #define UseBuiltinSim           true
-#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \
+#define ARCH_FLAGS(develop, \
+                   product, \
+                   diagnostic, \
+                   experimental, \
+                   notproduct, \
+                   range, \
+                   constraint, \
+                   writeable) \
                                                                         \
   product(bool, NotifySimulator, UseBuiltinSim,                         \
          "tell the AArch64 sim where we are in method code")            \
@@ -116,7 +124,14 @@
 #define NotifySimulator         false
 #define UseSimulatorCache       false
 #define DisableBCCheck          true
-#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \
+#define ARCH_FLAGS(develop, \
+                   product, \
+                   diagnostic, \
+                   experimental, \
+                   notproduct, \
+                   range, \
+                   constraint, \
+                   writeable) \
                                                                         \
   product(bool, NearCpool, true,                                        \
          "constant pool is close to instructions")                      \
@@ -131,6 +146,11 @@
           "Use SIMD instructions in generated memory move code")        \
   product(bool, UseLSE, false,                                          \
           "Use LSE instructions")                                       \
+  product(bool, UseBlockZeroing, true,                                  \
+          "Use DC ZVA for block zeroing")                               \
+  product(intx, BlockZeroingLowLimit, 256,                              \
+          "Minimum size in bytes when block zeroing will be used")      \
+          range(1, max_jint)                                            \
   product(bool, TraceTraps, false, "Trace all traps the signal handler")
 
 #endif
diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp
index 59d06cb..2271210 100644
--- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp
@@ -27,12 +27,12 @@
 #include "interp_masm_aarch64.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
+#include "logging/log.hpp"
 #include "oops/arrayOop.hpp"
 #include "oops/markOop.hpp"
 #include "oops/methodData.hpp"
 #include "oops/method.hpp"
 #include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/jvmtiThreadState.hpp"
 #include "runtime/basicLock.hpp"
 #include "runtime/biasedLocking.hpp"
@@ -40,7 +40,43 @@
 #include "runtime/thread.inline.hpp"
 
 
-// Implementation of InterpreterMacroAssembler
+void InterpreterMacroAssembler::narrow(Register result) {
+
+  // Get method->_constMethod->_result_type
+  ldr(rscratch1, Address(rfp, frame::interpreter_frame_method_offset * wordSize));
+  ldr(rscratch1, Address(rscratch1, Method::const_offset()));
+  ldrb(rscratch1, Address(rscratch1, ConstMethod::result_type_offset()));
+
+  Label done, notBool, notByte, notChar;
+
+  // common case first
+  cmpw(rscratch1, T_INT);
+  br(Assembler::EQ, done);
+
+  // mask integer result to narrower return type.
+  cmpw(rscratch1, T_BOOLEAN);
+  br(Assembler::NE, notBool);
+  andw(result, result, 0x1);
+  b(done);
+
+  bind(notBool);
+  cmpw(rscratch1, T_BYTE);
+  br(Assembler::NE, notByte);
+  sbfx(result, result, 0, 8);
+  b(done);
+
+  bind(notByte);
+  cmpw(rscratch1, T_CHAR);
+  br(Assembler::NE, notChar);
+  ubfx(result, result, 0, 16);  // truncate upper 16 bits
+  b(done);
+
+  bind(notChar);
+  sbfx(result, result, 0, 16);     // sign-extend short
+
+  // Nothing to do for T_INT
+  bind(done);
+}
 
 void InterpreterMacroAssembler::jump_to_entry(address entry) {
   assert(entry, "Entry must have been generated by now");
@@ -81,6 +117,7 @@
                verify_oop(r0, state);               break;
     case ltos: ldr(r0, val_addr);                   break;
     case btos:                                   // fall through
+    case ztos:                                   // fall through
     case ctos:                                   // fall through
     case stos:                                   // fall through
     case itos: ldrw(r0, val_addr);                  break;
@@ -314,6 +351,7 @@
   switch (state) {
   case atos: pop_ptr();                 break;
   case btos:
+  case ztos:
   case ctos:
   case stos:
   case itos: pop_i();                   break;
@@ -331,6 +369,7 @@
   switch (state) {
   case atos: push_ptr();                break;
   case btos:
+  case ztos:
   case ctos:
   case stos:
   case itos: push_i();                  break;
@@ -1411,7 +1450,7 @@
   }
 
   // RedefineClasses() tracing support for obsolete method entry
-  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete)) {
     get_method(c_rarg1);
     call_VM_leaf(
       CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp
index d56d17a..dd73bf5 100644
--- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp
@@ -245,6 +245,9 @@
   void update_mdp_by_constant(Register mdp_in, int constant);
   void update_mdp_for_ret(Register return_bci);
 
+  // narrow int return value
+  void narrow(Register result);
+
   void profile_taken_branch(Register mdp, Register bumped_count);
   void profile_not_taken_branch(Register mdp);
   void profile_call(Register mdp);
diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
index 0ede2e9..a271ba9 100644
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
@@ -3217,6 +3217,14 @@
   }
 }
 
+void MacroAssembler::load_mirror(Register dst, Register method) {
+  const int mirror_offset = in_bytes(Klass::java_mirror_offset());
+  ldr(dst, Address(rmethod, Method::const_offset()));
+  ldr(dst, Address(dst, ConstMethod::constants_offset()));
+  ldr(dst, Address(dst, ConstantPool::pool_holder_offset_in_bytes()));
+  ldr(dst, Address(dst, mirror_offset));
+}
+
 void MacroAssembler::cmp_klass(Register oop, Register trial_klass, Register tmp) {
   if (UseCompressedClassPointers) {
     ldrw(tmp, Address(oop, oopDesc::klass_offset_in_bytes()));
@@ -4085,7 +4093,10 @@
     // and it might even be negative.
     unsigned long offset;
     adrp(reg, ExternalAddress((address)byte_map_base), offset);
-    assert(offset == 0, "misaligned card table base");
+    // We expect offset to be zero with most collectors.
+    if (offset != 0) {
+      add(reg, reg, offset);
+    }
   } else {
     mov(reg, (uint64_t)byte_map_base);
   }
@@ -4585,7 +4596,16 @@
   assert(elem_size == 1 || elem_size == 2, "must be char or byte");
   assert_different_registers(a1, a2, result, cnt1, rscratch1, rscratch2);
 
-  BLOCK_COMMENT(is_string ? "string_equals {" : "array_equals {");
+#ifndef PRODUCT
+  {
+    const char kind = (elem_size == 2) ? 'U' : 'L';
+    char comment[64];
+    snprintf(comment, sizeof comment, "%s%c%s {",
+             is_string ? "string_equals" : "array_equals",
+             kind, "{");
+    BLOCK_COMMENT(comment);
+  }
+#endif
 
   mov(result, false);
 
@@ -4671,7 +4691,179 @@
 }
 
 
-// encode char[] to byte[] in ISO_8859_1
+// base:     Address of a buffer to be zeroed, 8 bytes aligned.
+// cnt:      Count in HeapWords.
+// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit.
+void MacroAssembler::zero_words(Register base, Register cnt)
+{
+  if (UseBlockZeroing) {
+    block_zero(base, cnt);
+  } else {
+    fill_words(base, cnt, zr);
+  }
+}
+
+// r10 = base:   Address of a buffer to be zeroed, 8 bytes aligned.
+// cnt:          Immediate count in HeapWords.
+// r11 = tmp:    For use as cnt if we need to call out
+#define ShortArraySize (18 * BytesPerLong)
+void MacroAssembler::zero_words(Register base, u_int64_t cnt)
+{
+  Register tmp = r11;
+  int i = cnt & 1;  // store any odd word to start
+  if (i) str(zr, Address(base));
+
+  if (cnt <= ShortArraySize / BytesPerLong) {
+    for (; i < (int)cnt; i += 2)
+      stp(zr, zr, Address(base, i * wordSize));
+  } else if (UseBlockZeroing && cnt >= (u_int64_t)(BlockZeroingLowLimit >> LogBytesPerWord)) {
+    mov(tmp, cnt);
+    block_zero(base, tmp, true);
+  } else {
+    const int unroll = 4; // Number of stp(zr, zr) instructions we'll unroll
+    int remainder = cnt % (2 * unroll);
+    for (; i < remainder; i += 2)
+      stp(zr, zr, Address(base, i * wordSize));
+
+    Label loop;
+    Register cnt_reg = rscratch1;
+    Register loop_base = rscratch2;
+    cnt = cnt - remainder;
+    mov(cnt_reg, cnt);
+    // adjust base and prebias by -2 * wordSize so we can pre-increment
+    add(loop_base, base, (remainder - 2) * wordSize);
+    bind(loop);
+    sub(cnt_reg, cnt_reg, 2 * unroll);
+    for (i = 1; i < unroll; i++)
+      stp(zr, zr, Address(loop_base, 2 * i * wordSize));
+    stp(zr, zr, Address(pre(loop_base, 2 * unroll * wordSize)));
+    cbnz(cnt_reg, loop);
+  }
+}
+
+// base:   Address of a buffer to be filled, 8 bytes aligned.
+// cnt:    Count in 8-byte unit.
+// value:  Value to be filled with.
+// base will point to the end of the buffer after filling.
+void MacroAssembler::fill_words(Register base, Register cnt, Register value)
+{
+//  Algorithm:
+//
+//    scratch1 = cnt & 7;
+//    cnt -= scratch1;
+//    p += scratch1;
+//    switch (scratch1) {
+//      do {
+//        cnt -= 8;
+//          p[-8] = v;
+//        case 7:
+//          p[-7] = v;
+//        case 6:
+//          p[-6] = v;
+//          // ...
+//        case 1:
+//          p[-1] = v;
+//        case 0:
+//          p += 8;
+//      } while (cnt);
+//    }
+
+  assert_different_registers(base, cnt, value, rscratch1, rscratch2);
+
+  Label fini, skip, entry, loop;
+  const int unroll = 8; // Number of stp instructions we'll unroll
+
+  cbz(cnt, fini);
+  tbz(base, 3, skip);
+  str(value, Address(post(base, 8)));
+  sub(cnt, cnt, 1);
+  bind(skip);
+
+  andr(rscratch1, cnt, (unroll-1) * 2);
+  sub(cnt, cnt, rscratch1);
+  add(base, base, rscratch1, Assembler::LSL, 3);
+  adr(rscratch2, entry);
+  sub(rscratch2, rscratch2, rscratch1, Assembler::LSL, 1);
+  br(rscratch2);
+
+  bind(loop);
+  add(base, base, unroll * 16);
+  for (int i = -unroll; i < 0; i++)
+    stp(value, value, Address(base, i * 16));
+  bind(entry);
+  subs(cnt, cnt, unroll * 2);
+  br(Assembler::GE, loop);
+
+  tbz(cnt, 0, fini);
+  str(value, Address(post(base, 8)));
+  bind(fini);
+}
+
+// Use DC ZVA to do fast zeroing.
+// base:   Address of a buffer to be zeroed, 8 bytes aligned.
+// cnt:    Count in HeapWords.
+// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit.
+void MacroAssembler::block_zero(Register base, Register cnt, bool is_large)
+{
+  Label small;
+  Label store_pair, loop_store_pair, done;
+  Label base_aligned;
+
+  assert_different_registers(base, cnt, rscratch1);
+  guarantee(base == r10 && cnt == r11, "fix register usage");
+
+  Register tmp = rscratch1;
+  Register tmp2 = rscratch2;
+  int zva_length = VM_Version::zva_length();
+
+  // Ensure ZVA length can be divided by 16. This is required by
+  // the subsequent operations.
+  assert (zva_length % 16 == 0, "Unexpected ZVA Length");
+
+  if (!is_large) cbz(cnt, done);
+  tbz(base, 3, base_aligned);
+  str(zr, Address(post(base, 8)));
+  sub(cnt, cnt, 1);
+  bind(base_aligned);
+
+  // Ensure count >= zva_length * 2 so that it still deserves a zva after
+  // alignment.
+  if (!is_large || !(BlockZeroingLowLimit >= zva_length * 2)) {
+    int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit);
+    cmp(cnt, low_limit >> 3);
+    br(Assembler::LT, small);
+  }
+
+  far_call(StubRoutines::aarch64::get_zero_longs());
+
+  bind(small);
+
+  const int unroll = 8; // Number of stp instructions we'll unroll
+  Label small_loop, small_table_end;
+
+  andr(tmp, cnt, (unroll-1) * 2);
+  sub(cnt, cnt, tmp);
+  add(base, base, tmp, Assembler::LSL, 3);
+  adr(tmp2, small_table_end);
+  sub(tmp2, tmp2, tmp, Assembler::LSL, 1);
+  br(tmp2);
+
+  bind(small_loop);
+  add(base, base, unroll * 16);
+  for (int i = -unroll; i < 0; i++)
+    stp(zr, zr, Address(base, i * 16));
+  bind(small_table_end);
+  subs(cnt, cnt, unroll * 2);
+  br(Assembler::GE, small_loop);
+
+  tbz(cnt, 0, done);
+  str(zr, Address(post(base, 8)));
+
+  bind(done);
+}
+
+// Intrinsic for sun/nio/cs/ISO_8859_1$Encoder.implEncodeISOArray and
+// java/lang/StringUTF16.compress.
 void MacroAssembler::encode_iso_array(Register src, Register dst,
                       Register len, Register result,
                       FloatRegister Vtmp1, FloatRegister Vtmp2,
@@ -4734,6 +4926,90 @@
 
     BIND(DONE);
       sub(result, result, len); // Return index where we stopped
+                                // Return len == 0 if we processed all
+                                // characters
+}
+
+
+// Inflate byte[] array to char[].
+void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len,
+                                        FloatRegister vtmp1, FloatRegister vtmp2, FloatRegister vtmp3,
+                                        Register tmp4) {
+  Label big, done;
+
+  assert_different_registers(src, dst, len, tmp4, rscratch1);
+
+  fmovd(vtmp1 , zr);
+  lsrw(rscratch1, len, 3);
+
+  cbnzw(rscratch1, big);
+
+  // Short string: less than 8 bytes.
+  {
+    Label loop, around, tiny;
+
+    subsw(len, len, 4);
+    andw(len, len, 3);
+    br(LO, tiny);
+
+    // Use SIMD to do 4 bytes.
+    ldrs(vtmp2, post(src, 4));
+    zip1(vtmp3, T8B, vtmp2, vtmp1);
+    strd(vtmp3, post(dst, 8));
+
+    cbzw(len, done);
+
+    // Do the remaining bytes by steam.
+    bind(loop);
+    ldrb(tmp4, post(src, 1));
+    strh(tmp4, post(dst, 2));
+    subw(len, len, 1);
+
+    bind(tiny);
+    cbnz(len, loop);
+
+    bind(around);
+    b(done);
+  }
+
+  // Unpack the bytes 8 at a time.
+  bind(big);
+  andw(len, len, 7);
+
+  {
+    Label loop, around;
+
+    bind(loop);
+    ldrd(vtmp2, post(src, 8));
+    sub(rscratch1, rscratch1, 1);
+    zip1(vtmp3, T16B, vtmp2, vtmp1);
+    st1(vtmp3, T8H, post(dst, 16));
+    cbnz(rscratch1, loop);
+
+    bind(around);
+  }
+
+  // Do the tail of up to 8 bytes.
+  sub(src, src, 8);
+  add(src, src, len, ext::uxtw, 0);
+  ldrd(vtmp2, Address(src));
+  sub(dst, dst, 16);
+  add(dst, dst, len, ext::uxtw, 1);
+  zip1(vtmp3, T16B, vtmp2, vtmp1);
+  st1(vtmp3, T8H, Address(dst));
+
+  bind(done);
+}
+
+// Compress char[] array to byte[].
+void MacroAssembler::char_array_compress(Register src, Register dst, Register len,
+                                         FloatRegister tmp1Reg, FloatRegister tmp2Reg,
+                                         FloatRegister tmp3Reg, FloatRegister tmp4Reg,
+                                         Register result) {
+  encode_iso_array(src, dst, len, result,
+                   tmp1Reg, tmp2Reg, tmp3Reg, tmp4Reg);
+  cmp(len, zr);
+  csel(result, result, zr, EQ);
 }
 
 // get_thread() can be called anywhere inside generated code so we
diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
index b114e1b..0db161d 100644
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -536,6 +536,15 @@
     msr(0b011, 0b0100, 0b0100, 0b001, zr);
   }
 
+  // DCZID_EL0: op1 == 011
+  //            CRn == 0000
+  //            CRm == 0000
+  //            op2 == 111
+  inline void get_dczid_el0(Register reg)
+  {
+    mrs(0b011, 0b0000, 0b0000, 0b111, reg);
+  }
+
   // idiv variant which deals with MINLONG as dividend and -1 as divisor
   int corrected_idivl(Register result, Register ra, Register rb,
                       bool want_remainder, Register tmp = rscratch1);
@@ -770,6 +779,8 @@
   void store_klass(Register dst, Register src);
   void cmp_klass(Register oop, Register trial_klass, Register tmp);
 
+  void load_mirror(Register dst, Register method);
+
   void load_heap_oop(Register dst, Address src);
 
   void load_heap_oop_not_null(Register dst, Address src);
@@ -1184,6 +1195,20 @@
                      Register result, Register cnt1,
                      int elem_size, bool is_string);
 
+  void fill_words(Register base, Register cnt, Register value);
+  void zero_words(Register base, u_int64_t cnt);
+  void zero_words(Register base, Register cnt);
+  void block_zero(Register base, Register cnt, bool is_large = false);
+
+  void byte_array_inflate(Register src, Register dst, Register len,
+                          FloatRegister vtmp1, FloatRegister vtmp2,
+                          FloatRegister vtmp3, Register tmp4);
+
+  void char_array_compress(Register src, Register dst, Register len,
+                           FloatRegister tmp1Reg, FloatRegister tmp2Reg,
+                           FloatRegister tmp3Reg, FloatRegister tmp4Reg,
+                           Register result);
+
   void encode_iso_array(Register src, Register dst,
                         Register len, Register result,
                         FloatRegister Vtmp1, FloatRegister Vtmp2,
diff --git a/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp
index e36434c..88e1d3d 100644
--- a/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp
@@ -99,7 +99,7 @@
 
   address bl_destination
     = MacroAssembler::pd_call_destination(call_addr);
-  if (code->content_contains(bl_destination) &&
+  if (code->contains(bl_destination) &&
       is_NativeCallTrampolineStub_at(bl_destination))
     return bl_destination;
 
diff --git a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp
index 760256d..6a5bb7a 100644
--- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp
@@ -31,9 +31,9 @@
 #include "code/vtableStubs.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interp_masm.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/compiledICHolder.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vframeArray.hpp"
 #include "vmreg_aarch64.inline.hpp"
@@ -1781,7 +1781,7 @@
   }
 
   // RedefineClasses() tracing support for obsolete method entry
-  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete)) {
     // protect the args we've loaded
     save_args(masm, total_c_args, c_arg, out_regs);
     __ mov_metadata(c_rarg1, method());
diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
index b0787dd..2355579 100644
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
@@ -719,6 +719,48 @@
     }
   }
 
+  address generate_zero_longs(Register base, Register cnt) {
+    Register tmp = rscratch1;
+    Register tmp2 = rscratch2;
+    int zva_length = VM_Version::zva_length();
+    Label initial_table_end, loop_zva;
+    Label fini;
+
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", "zero_longs");
+    address start = __ pc();
+
+    // Base must be 16 byte aligned. If not just return and let caller handle it
+    __ tst(base, 0x0f);
+    __ br(Assembler::NE, fini);
+    // Align base with ZVA length.
+    __ neg(tmp, base);
+    __ andr(tmp, tmp, zva_length - 1);
+
+    // tmp: the number of bytes to be filled to align the base with ZVA length.
+    __ add(base, base, tmp);
+    __ sub(cnt, cnt, tmp, Assembler::ASR, 3);
+    __ adr(tmp2, initial_table_end);
+    __ sub(tmp2, tmp2, tmp, Assembler::LSR, 2);
+    __ br(tmp2);
+
+    for (int i = -zva_length + 16; i < 0; i += 16)
+      __ stp(zr, zr, Address(base, i));
+    __ bind(initial_table_end);
+
+    __ sub(cnt, cnt, zva_length >> 3);
+    __ bind(loop_zva);
+    __ dc(Assembler::ZVA, base);
+    __ subs(cnt, cnt, zva_length >> 3);
+    __ add(base, base, zva_length);
+    __ br(Assembler::GE, loop_zva);
+    __ add(cnt, cnt, zva_length >> 3); // count not zeroed by DC ZVA
+    __ bind(fini);
+    __ ret(lr);
+
+    return start;
+  }
+
   typedef enum {
     copy_forwards = 1,
     copy_backwards = -1
@@ -2021,6 +2063,154 @@
     return start;
   }
 
+  //
+  // Generate stub for array fill. If "aligned" is true, the
+  // "to" address is assumed to be heapword aligned.
+  //
+  // Arguments for generated stub:
+  //   to:    c_rarg0
+  //   value: c_rarg1
+  //   count: c_rarg2 treated as signed
+  //
+  address generate_fill(BasicType t, bool aligned, const char *name) {
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", name);
+    address start = __ pc();
+
+    BLOCK_COMMENT("Entry:");
+
+    const Register to        = c_rarg0;  // source array address
+    const Register value     = c_rarg1;  // value
+    const Register count     = c_rarg2;  // elements count
+
+    const Register bz_base = r10;        // base for block_zero routine
+    const Register cnt_words = r11;      // temp register
+
+    __ enter();
+
+    Label L_fill_elements, L_exit1;
+
+    int shift = -1;
+    switch (t) {
+      case T_BYTE:
+        shift = 0;
+        __ cmpw(count, 8 >> shift); // Short arrays (< 8 bytes) fill by element
+        __ bfi(value, value, 8, 8);   // 8 bit -> 16 bit
+        __ bfi(value, value, 16, 16); // 16 bit -> 32 bit
+        __ br(Assembler::LO, L_fill_elements);
+        break;
+      case T_SHORT:
+        shift = 1;
+        __ cmpw(count, 8 >> shift); // Short arrays (< 8 bytes) fill by element
+        __ bfi(value, value, 16, 16); // 16 bit -> 32 bit
+        __ br(Assembler::LO, L_fill_elements);
+        break;
+      case T_INT:
+        shift = 2;
+        __ cmpw(count, 8 >> shift); // Short arrays (< 8 bytes) fill by element
+        __ br(Assembler::LO, L_fill_elements);
+        break;
+      default: ShouldNotReachHere();
+    }
+
+    // Align source address at 8 bytes address boundary.
+    Label L_skip_align1, L_skip_align2, L_skip_align4;
+    if (!aligned) {
+      switch (t) {
+        case T_BYTE:
+          // One byte misalignment happens only for byte arrays.
+          __ tbz(to, 0, L_skip_align1);
+          __ strb(value, Address(__ post(to, 1)));
+          __ subw(count, count, 1);
+          __ bind(L_skip_align1);
+          // Fallthrough
+        case T_SHORT:
+          // Two bytes misalignment happens only for byte and short (char) arrays.
+          __ tbz(to, 1, L_skip_align2);
+          __ strh(value, Address(__ post(to, 2)));
+          __ subw(count, count, 2 >> shift);
+          __ bind(L_skip_align2);
+          // Fallthrough
+        case T_INT:
+          // Align to 8 bytes, we know we are 4 byte aligned to start.
+          __ tbz(to, 2, L_skip_align4);
+          __ strw(value, Address(__ post(to, 4)));
+          __ subw(count, count, 4 >> shift);
+          __ bind(L_skip_align4);
+          break;
+        default: ShouldNotReachHere();
+      }
+    }
+
+    //
+    //  Fill large chunks
+    //
+    __ lsrw(cnt_words, count, 3 - shift); // number of words
+    __ bfi(value, value, 32, 32);         // 32 bit -> 64 bit
+    __ subw(count, count, cnt_words, Assembler::LSL, 3 - shift);
+    if (UseBlockZeroing) {
+      Label non_block_zeroing, rest;
+      // count >= BlockZeroingLowLimit && value == 0
+      __ cmp(cnt_words, BlockZeroingLowLimit >> 3);
+      __ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE);
+      __ br(Assembler::NE, non_block_zeroing);
+      __ mov(bz_base, to);
+      __ block_zero(bz_base, cnt_words, true);
+      __ mov(to, bz_base);
+      __ b(rest);
+      __ bind(non_block_zeroing);
+      __ fill_words(to, cnt_words, value);
+      __ bind(rest);
+    }
+    else {
+      __ fill_words(to, cnt_words, value);
+    }
+
+    // Remaining count is less than 8 bytes. Fill it by a single store.
+    // Note that the total length is no less than 8 bytes.
+    if (t == T_BYTE || t == T_SHORT) {
+      Label L_exit1;
+      __ cbzw(count, L_exit1);
+      __ add(to, to, count, Assembler::LSL, shift); // points to the end
+      __ str(value, Address(to, -8));    // overwrite some elements
+      __ bind(L_exit1);
+      __ leave();
+      __ ret(lr);
+    }
+
+    // Handle copies less than 8 bytes.
+    Label L_fill_2, L_fill_4, L_exit2;
+    __ bind(L_fill_elements);
+    switch (t) {
+      case T_BYTE:
+        __ tbz(count, 0, L_fill_2);
+        __ strb(value, Address(__ post(to, 1)));
+        __ bind(L_fill_2);
+        __ tbz(count, 1, L_fill_4);
+        __ strh(value, Address(__ post(to, 2)));
+        __ bind(L_fill_4);
+        __ tbz(count, 2, L_exit2);
+        __ strw(value, Address(to));
+        break;
+      case T_SHORT:
+        __ tbz(count, 0, L_fill_4);
+        __ strh(value, Address(__ post(to, 2)));
+        __ bind(L_fill_4);
+        __ tbz(count, 1, L_exit2);
+        __ strw(value, Address(to));
+        break;
+      case T_INT:
+        __ cbzw(count, L_exit2);
+        __ strw(value, Address(to));
+        break;
+      default: ShouldNotReachHere();
+    }
+    __ bind(L_exit2);
+    __ leave();
+    __ ret(lr);
+    return start;
+  }
+
   void generate_arraycopy_stubs() {
     address entry;
     address entry_jbyte_arraycopy;
@@ -2033,6 +2223,8 @@
     generate_copy_longs(copy_f, r0, r1, rscratch2, copy_forwards);
     generate_copy_longs(copy_b, r0, r1, rscratch2, copy_backwards);
 
+    StubRoutines::aarch64::_zero_longs = generate_zero_longs(r10, r11);
+
     //*** jbyte
     // Always need aligned and unaligned versions
     StubRoutines::_jbyte_disjoint_arraycopy         = generate_disjoint_byte_copy(false, &entry,
@@ -2124,6 +2316,12 @@
                                                                entry_jlong_arraycopy,
                                                                entry_checkcast_arraycopy);
 
+    StubRoutines::_jbyte_fill = generate_fill(T_BYTE, false, "jbyte_fill");
+    StubRoutines::_jshort_fill = generate_fill(T_SHORT, false, "jshort_fill");
+    StubRoutines::_jint_fill = generate_fill(T_INT, false, "jint_fill");
+    StubRoutines::_arrayof_jbyte_fill = generate_fill(T_BYTE, true, "arrayof_jbyte_fill");
+    StubRoutines::_arrayof_jshort_fill = generate_fill(T_SHORT, true, "arrayof_jshort_fill");
+    StubRoutines::_arrayof_jint_fill = generate_fill(T_INT, true, "arrayof_jint_fill");
   }
 
   void generate_math_stubs() { Unimplemented(); }
diff --git a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp
index e7d7f5b..f5727ee 100644
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp
@@ -43,6 +43,7 @@
 address StubRoutines::aarch64::_float_sign_flip = NULL;
 address StubRoutines::aarch64::_double_sign_mask = NULL;
 address StubRoutines::aarch64::_double_sign_flip = NULL;
+address StubRoutines::aarch64::_zero_longs = NULL;
 
 /**
  *  crc_table[] from jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h
diff --git a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp
index 8764ebf..1355a68 100644
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp
@@ -61,6 +61,8 @@
   static address _double_sign_mask;
   static address _double_sign_flip;
 
+  static address _zero_longs;
+
  public:
 
   static address get_previous_fp_entry()
@@ -113,6 +115,11 @@
     return _double_sign_flip;
   }
 
+  static address get_zero_longs()
+  {
+    return _zero_longs;
+  }
+
  private:
   static juint    _crc_table[];
 
diff --git a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp
index 7fe8f14..e78276e 100644
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp
@@ -759,18 +759,13 @@
 
   // get synchronization object
   {
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
     Label done;
     __ ldrw(r0, access_flags);
     __ tst(r0, JVM_ACC_STATIC);
     // get receiver (assume this is frequent case)
     __ ldr(r0, Address(rlocals, Interpreter::local_offset_in_bytes(0)));
     __ br(Assembler::EQ, done);
-    __ ldr(r0, Address(rmethod, Method::const_offset()));
-    __ ldr(r0, Address(r0, ConstMethod::constants_offset()));
-    __ ldr(r0, Address(r0,
-                           ConstantPool::pool_holder_offset_in_bytes()));
-    __ ldr(r0, Address(r0, mirror_offset));
+    __ load_mirror(r0, rmethod);
 
 #ifdef ASSERT
     {
@@ -807,16 +802,16 @@
 void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
   // initialize fixed part of activation frame
   if (native_call) {
-    __ sub(esp, sp, 12 *  wordSize);
+    __ sub(esp, sp, 14 *  wordSize);
     __ mov(rbcp, zr);
-    __ stp(esp, zr, Address(__ pre(sp, -12 * wordSize)));
+    __ stp(esp, zr, Address(__ pre(sp, -14 * wordSize)));
     // add 2 zero-initialized slots for native calls
-    __ stp(zr, zr, Address(sp, 10 * wordSize));
+    __ stp(zr, zr, Address(sp, 12 * wordSize));
   } else {
-    __ sub(esp, sp, 10 *  wordSize);
+    __ sub(esp, sp, 12 *  wordSize);
     __ ldr(rscratch1, Address(rmethod, Method::const_offset()));      // get ConstMethod
     __ add(rbcp, rscratch1, in_bytes(ConstMethod::codes_offset())); // get codebase
-    __ stp(esp, rbcp, Address(__ pre(sp, -10 * wordSize)));
+    __ stp(esp, rbcp, Address(__ pre(sp, -12 * wordSize)));
   }
 
   if (ProfileInterpreter) {
@@ -825,22 +820,26 @@
     __ cbz(rscratch1, method_data_continue);
     __ lea(rscratch1, Address(rscratch1, in_bytes(MethodData::data_offset())));
     __ bind(method_data_continue);
-    __ stp(rscratch1, rmethod, Address(sp, 4 * wordSize));  // save Method* and mdp (method data pointer)
+    __ stp(rscratch1, rmethod, Address(sp, 6 * wordSize));  // save Method* and mdp (method data pointer)
   } else {
-    __ stp(zr, rmethod, Address(sp, 4 * wordSize));        // save Method* (no mdp)
+    __ stp(zr, rmethod, Address(sp, 6 * wordSize));        // save Method* (no mdp)
   }
 
+  // Get mirror and store it in the frame as GC root for this Method*
+  __ load_mirror(rscratch1, rmethod);
+  __ stp(rscratch1, zr, Address(sp, 4 * wordSize));
+
   __ ldr(rcpool, Address(rmethod, Method::const_offset()));
   __ ldr(rcpool, Address(rcpool, ConstMethod::constants_offset()));
   __ ldr(rcpool, Address(rcpool, ConstantPool::cache_offset_in_bytes()));
   __ stp(rlocals, rcpool, Address(sp, 2 * wordSize));
 
-  __ stp(rfp, lr, Address(sp, 8 * wordSize));
-  __ lea(rfp, Address(sp, 8 * wordSize));
+  __ stp(rfp, lr, Address(sp, 10 * wordSize));
+  __ lea(rfp, Address(sp, 10 * wordSize));
 
   // set sender sp
   // leave last_sp as null
-  __ stp(zr, r13, Address(sp, 6 * wordSize));
+  __ stp(zr, r13, Address(sp, 8 * wordSize));
 
   // Move SP out of the way
   if (! native_call) {
@@ -1242,15 +1241,11 @@
   // pass mirror handle if static call
   {
     Label L;
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
     __ ldrw(t, Address(rmethod, Method::access_flags_offset()));
     __ tst(t, JVM_ACC_STATIC);
     __ br(Assembler::EQ, L);
     // get mirror
-    __ ldr(t, Address(rmethod, Method::const_offset()));
-    __ ldr(t, Address(t, ConstMethod::constants_offset()));
-    __ ldr(t, Address(t, ConstantPool::pool_holder_offset_in_bytes()));
-    __ ldr(t, Address(t, mirror_offset));
+    __ load_mirror(t, rmethod);
     // copy mirror into activation frame
     __ str(t, Address(rfp, frame::interpreter_frame_oop_temp_offset * wordSize));
     // pass handle to mirror
diff --git a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp
index 6c8c5ac..5c1a984 100644
--- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp
@@ -229,6 +229,7 @@
   switch (bc) {
   case Bytecodes::_fast_aputfield:
   case Bytecodes::_fast_bputfield:
+  case Bytecodes::_fast_zputfield:
   case Bytecodes::_fast_cputfield:
   case Bytecodes::_fast_dputfield:
   case Bytecodes::_fast_fputfield:
@@ -1082,6 +1083,17 @@
   // r1: index
   // r3: array
   index_check(r3, r1); // prefer index in r1
+
+  // Need to check whether array is boolean or byte
+  // since both types share the bastore bytecode.
+  __ load_klass(r2, r3);
+  __ ldrw(r2, Address(r2, Klass::layout_helper_offset()));
+  int diffbit_index = exact_log2(Klass::layout_helper_boolean_diffbit());
+  Label L_skip;
+  __ tbz(r2, diffbit_index, L_skip);
+  __ andw(r0, r0, 1);  // if it is a T_BOOLEAN array, mask the stored value to 0/1
+  __ bind(L_skip);
+
   __ lea(rscratch1, Address(r3, r1, Address::uxtw(0)));
   __ strb(r0, Address(rscratch1,
                       arrayOopDesc::base_offset_in_bytes(T_BYTE)));
@@ -2193,6 +2205,13 @@
   if (_desc->bytecode() == Bytecodes::_return)
     __ membar(MacroAssembler::StoreStore);
 
+  // Narrow result if state is itos but result type is smaller.
+  // Need to narrow in the return bytecode rather than in generate_return_entry
+  // since compiled code callers expect the result to already be narrowed.
+  if (state == itos) {
+    __ narrow(r0);
+  }
+
   __ remove_activation(state);
   __ ret(lr);
 }
@@ -2386,7 +2405,7 @@
 
   const Address field(obj, off);
 
-  Label Done, notByte, notInt, notShort, notChar,
+  Label Done, notByte, notBool, notInt, notShort, notChar,
               notLong, notFloat, notObj, notDouble;
 
   // x86 uses a shift and mask or wings it with a shift plus assert
@@ -2409,6 +2428,20 @@
   __ b(Done);
 
   __ bind(notByte);
+  __ cmp(flags, ztos);
+  __ br(Assembler::NE, notBool);
+
+  // ztos (same code as btos)
+  __ ldrsb(r0, field);
+  __ push(ztos);
+  // Rewrite bytecode to be faster
+  if (!is_static) {
+    // use btos rewriting, no truncating to t/f bit is needed for getfield.
+    patch_bytecode(Bytecodes::_fast_bgetfield, bc, r1);
+  }
+  __ b(Done);
+
+  __ bind(notBool);
   __ cmp(flags, atos);
   __ br(Assembler::NE, notObj);
   // atos
@@ -2604,7 +2637,7 @@
   // field address
   const Address field(obj, off);
 
-  Label notByte, notInt, notShort, notChar,
+  Label notByte, notBool, notInt, notShort, notChar,
         notLong, notFloat, notObj, notDouble;
 
   // x86 uses a shift and mask or wings it with a shift plus assert
@@ -2629,6 +2662,22 @@
   }
 
   __ bind(notByte);
+  __ cmp(flags, ztos);
+  __ br(Assembler::NE, notBool);
+
+  // ztos
+  {
+    __ pop(ztos);
+    if (!is_static) pop_and_check_object(obj);
+    __ andw(r0, r0, 0x1);
+    __ strb(r0, field);
+    if (!is_static) {
+      patch_bytecode(Bytecodes::_fast_zputfield, bc, r1, true, byte_no);
+    }
+    __ b(Done);
+  }
+
+  __ bind(notBool);
   __ cmp(flags, atos);
   __ br(Assembler::NE, notObj);
 
@@ -2783,6 +2832,7 @@
     switch (bytecode()) {          // load values into the jvalue object
     case Bytecodes::_fast_aputfield: __ push_ptr(r0); break;
     case Bytecodes::_fast_bputfield: // fall through
+    case Bytecodes::_fast_zputfield: // fall through
     case Bytecodes::_fast_sputfield: // fall through
     case Bytecodes::_fast_cputfield: // fall through
     case Bytecodes::_fast_iputfield: __ push_i(r0); break;
@@ -2808,6 +2858,7 @@
     switch (bytecode()) {             // restore tos values
     case Bytecodes::_fast_aputfield: __ pop_ptr(r0); break;
     case Bytecodes::_fast_bputfield: // fall through
+    case Bytecodes::_fast_zputfield: // fall through
     case Bytecodes::_fast_sputfield: // fall through
     case Bytecodes::_fast_cputfield: // fall through
     case Bytecodes::_fast_iputfield: __ pop_i(r0); break;
@@ -2863,6 +2914,9 @@
   case Bytecodes::_fast_iputfield:
     __ strw(r0, field);
     break;
+  case Bytecodes::_fast_zputfield:
+    __ andw(r0, r0, 0x1);  // boolean is true if LSB is 1
+    // fall through to bputfield
   case Bytecodes::_fast_bputfield:
     __ strb(r0, field);
     break;
@@ -2982,7 +3036,7 @@
   __ null_check(r0);
   switch (state) {
   case itos:
-    __ ldr(r0, Address(r0, r1, Address::lsl(0)));
+    __ ldrw(r0, Address(r0, r1, Address::lsl(0)));
     break;
   case atos:
     __ load_heap_oop(r0, Address(r0, r1, Address::lsl(0)));
@@ -3000,7 +3054,7 @@
     __ ldrw(r3, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
                                      ConstantPoolCacheEntry::flags_offset())));
     __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
-    __ membar(MacroAssembler::LoadLoad);
+    __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);
     __ bind(notVolatile);
   }
 
diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
index 40275ca..bf96f24 100644
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
@@ -71,6 +71,7 @@
 int VM_Version::_variant;
 int VM_Version::_revision;
 int VM_Version::_stepping;
+VM_Version::PsrInfo VM_Version::_psr_info   = { 0, };
 
 static BufferBlob* stub_blob;
 static const int stub_size = 550;
@@ -95,13 +96,16 @@
     __ c_stub_prolog(1, 0, MacroAssembler::ret_type_void);
 #endif
 
-    // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
+    // void getPsrInfo(VM_Version::PsrInfo* psr_info);
 
     address entry = __ pc();
 
-    // TODO : redefine fields in CpuidInfo and generate
-    // code to fill them in
+    __ enter();
 
+    __ get_dczid_el0(rscratch1);
+    __ strw(rscratch1, Address(c_rarg0, in_bytes(VM_Version::dczid_el0_offset())));
+
+    __ leave();
     __ ret(lr);
 
 #   undef __
@@ -118,6 +122,8 @@
   _supports_atomic_getset8 = true;
   _supports_atomic_getadd8 = true;
 
+  getPsrInfo_stub(&_psr_info);
+
   if (FLAG_IS_DEFAULT(AllocatePrefetchDistance))
     FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256);
   if (FLAG_IS_DEFAULT(AllocatePrefetchStepSize))
@@ -285,6 +291,18 @@
     FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
   }
 
+  if (is_zva_enabled()) {
+    if (FLAG_IS_DEFAULT(UseBlockZeroing)) {
+      FLAG_SET_DEFAULT(UseBlockZeroing, true);
+    }
+    if (FLAG_IS_DEFAULT(BlockZeroingLowLimit)) {
+      FLAG_SET_DEFAULT(BlockZeroingLowLimit, 4 * VM_Version::zva_length());
+    }
+  } else if (UseBlockZeroing) {
+    warning("DC ZVA is not available on this CPU");
+    FLAG_SET_DEFAULT(UseBlockZeroing, false);
+  }
+
   // This machine allows unaligned memory accesses
   if (FLAG_IS_DEFAULT(UseUnalignedAccesses)) {
     FLAG_SET_DEFAULT(UseUnalignedAccesses, true);
diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp
index 2ed5e7e..25f5b92 100644
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp
@@ -40,6 +40,10 @@
   static int _revision;
   static int _stepping;
 
+  struct PsrInfo {
+    uint32_t dczid_el0;
+  };
+  static PsrInfo _psr_info;
   static void get_processor_features();
 
 public:
@@ -83,6 +87,17 @@
   static int cpu_model2()                     { return _model2; }
   static int cpu_variant()                    { return _variant; }
   static int cpu_revision()                   { return _revision; }
+  static ByteSize dczid_el0_offset() { return byte_offset_of(PsrInfo, dczid_el0); }
+  static bool is_zva_enabled() {
+    // Check the DZP bit (bit 4) of dczid_el0 is zero
+    // and block size (bit 0~3) is not zero.
+    return ((_psr_info.dczid_el0 & 0x10) == 0 &&
+            (_psr_info.dczid_el0 & 0xf) != 0);
+  }
+  static int zva_length() {
+    assert(is_zva_enabled(), "ZVA not available");
+    return 4 << (_psr_info.dczid_el0 & 0xf);
+  }
 };
 
 #endif // CPU_AARCH64_VM_VM_VERSION_AARCH64_HPP
diff --git a/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp b/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp
index eaff19d..933a2f4 100644
--- a/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -152,6 +152,7 @@
   intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
 
   interpreter_frame->interpreter_frame_set_method(method);
+  interpreter_frame->interpreter_frame_set_mirror(method->method_holder()->java_mirror());
   interpreter_frame->interpreter_frame_set_locals(locals_base);
   interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
   interpreter_frame->interpreter_frame_set_esp(esp);
diff --git a/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp b/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp
index b7bc0cb..ed381b9 100644
--- a/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp
@@ -2845,6 +2845,9 @@
   __ membar(Assembler::StoreLoad);
 }
 
+void LIR_Assembler::on_spin_wait() {
+  Unimplemented();
+}
 
 void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest) {
   LIR_Address* addr = addr_opr->as_address_ptr();
diff --git a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp
index 0d1cb47..c322541 100644
--- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -1056,7 +1056,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
@@ -1428,3 +1428,11 @@
     }
   }
 }
+
+void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
+  fatal("vectorizedMismatch intrinsic is not implemented on this platform");
+}
+
+void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
+  Unimplemented();
+}
diff --git a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp
index 68dabc4..e50399d 100644
--- a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -35,22 +35,6 @@
 #include "opto/matcher.hpp"
 #endif
 
-// Release the CompiledICHolder* associated with this call site is there is one.
-void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  if (is_icholder_entry(call->destination())) {
-    NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());
-    InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());
-  }
-}
-
-bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  return is_icholder_entry(call->destination());
-}
-
 // ----------------------------------------------------------------------------
 
 // A PPC CompiledStaticCall looks like this:
diff --git a/hotspot/src/cpu/ppc/vm/frame_ppc.hpp b/hotspot/src/cpu/ppc/vm/frame_ppc.hpp
index 6f8f029..ae6847e 100644
--- a/hotspot/src/cpu/ppc/vm/frame_ppc.hpp
+++ b/hotspot/src/cpu/ppc/vm/frame_ppc.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -261,6 +261,7 @@
     uint64_t ijava_reserved2; // Inserted for alignment.
 #endif
     uint64_t method;
+    uint64_t mirror;
     uint64_t locals;
     uint64_t monitors;
     uint64_t cpoolCache;
diff --git a/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp b/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp
index 7fce058..d22f5b5 100644
--- a/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp
+++ b/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -40,7 +40,7 @@
 
   _fp = (intptr_t*)own_abi()->callers_sp;
 
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     _pc = original_pc;
     _deopt_state = is_deoptimized;
@@ -148,6 +148,11 @@
 inline Method** frame::interpreter_frame_method_addr() const {
   return (Method**) &(get_ijava_state()->method);
 }
+
+inline oop* frame::interpreter_frame_mirror_addr() const {
+  return (oop*) &(get_ijava_state()->mirror);
+}
+
 inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {
   return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache);
 }
diff --git a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp
index 77f7a49..b69e405 100644
--- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp
+++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp
@@ -79,7 +79,14 @@
 define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
 
 // Platform dependent flag handling: flags only defined on this platform.
-#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint)  \
+#define ARCH_FLAGS(develop, \
+                   product, \
+                   diagnostic, \
+                   experimental, \
+                   notproduct, \
+                   range, \
+                   constraint, \
+                   writeable)  \
                                                                             \
   /* Load poll address from thread. This is used to implement per-thread */ \
   /* safepoints on platforms != IA64. */                                    \
diff --git a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp
index ce9d109..a18254f 100644
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp
@@ -3118,6 +3118,14 @@
   }
 }
 
+void MacroAssembler::load_mirror(Register mirror, Register method) {
+  const int mirror_offset = in_bytes(Klass::java_mirror_offset());
+  ld(mirror, in_bytes(Method::const_offset()), method);
+  ld(mirror, in_bytes(ConstMethod::constants_offset()), mirror);
+  ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror);
+  ld(mirror, mirror_offset, mirror);
+}
+
 // Clear Array
 // Kills both input registers. tmp == R0 is allowed.
 void MacroAssembler::clear_memory_doubleword(Register base_ptr, Register cnt_dwords, Register tmp) {
diff --git a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp
index 53a269a..180a1dd 100644
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp
@@ -647,6 +647,9 @@
   void load_klass(Register dst, Register src);
   void store_klass(Register dst_oop, Register klass, Register tmp = R0);
   void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified.
+
+  void load_mirror(Register mirror, Register method);
+
   static int instr_size_for_decode_klass_not_null();
   void decode_klass_not_null(Register dst, Register src = noreg);
   Register encode_klass_not_null(Register dst, Register src = noreg);
diff --git a/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp b/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp
index 0870434..70cd4eb 100644
--- a/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp
@@ -137,7 +137,7 @@
     return NULL;
 
   address bl_destination = Assembler::bxx_destination(call_addr);
-  if (code->content_contains(bl_destination) &&
+  if (code->contains(bl_destination) &&
       is_NativeCallTrampolineStub_at(bl_destination))
     return bl_destination;
 
diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad
index 20521eb..0dc5a4d 100644
--- a/hotspot/src/cpu/ppc/vm/ppc.ad
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad
@@ -817,6 +817,16 @@
 
 source %{
 
+// Should the Matcher clone shifts on addressing modes, expecting them
+// to be subsumed into complex addressing expressions or compute them
+// into registers?
+bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) {
+  return clone_base_plus_offset_address(m, mstack, address_visited);
+}
+
+void Compile::reshape_address(AddPNode* addp) {
+}
+
 // Optimize load-acquire.
 //
 // Check if acquire is unnecessary due to following operation that does
@@ -1380,6 +1390,8 @@
     // Save return pc.
     ___(std) std(return_pc, _abi(lr), callers_sp);
   }
+  
+  C->set_frame_complete(cbuf.insts_size());
 }
 #undef ___
 #undef ___stop
@@ -2047,6 +2059,10 @@
   return ret_value;  // Per default match rules are supported.
 }
 
+const bool Matcher::has_predicated_vectors(void) {
+  return false;
+}
+
 const int Matcher::float_pressure(int default_pressure_threshold) {
   return default_pressure_threshold;
 }
@@ -2151,11 +2167,6 @@
 // Power6 requires postalloc expand (see block.cpp for description of postalloc expand).
 const bool Matcher::require_postalloc_expand = true;
 
-// Should the Matcher clone shifts on addressing modes, expecting them to
-// be subsumed into complex addressing expressions or compute them into
-// registers? True for Intel but false for most RISCs.
-const bool Matcher::clone_shift_expressions = false;
-
 // Do we need to mask the count passed to shift instructions or does
 // the cpu only look at the lower 5/6 bits anyway?
 // PowerPC requires masked shift counts.
@@ -2307,6 +2318,8 @@
   return RegMask();
 }
 
+const bool Matcher::convi2l_type_required = true;
+
 %}
 
 //----------ENCODING BLOCK-----------------------------------------------------
diff --git a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
index ee8685f..38c83d3 100644
--- a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
@@ -33,7 +33,6 @@
 #include "interpreter/interp_masm.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/compiledICHolder.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vframeArray.hpp"
 #include "vmreg_ppc.inline.hpp"
diff --git a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp
index 2eba3eda..58222ba 100644
--- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp
@@ -825,17 +825,6 @@
     return start;
   }
 
-  // The following routine generates a subroutine to throw an asynchronous
-  // UnknownError when an unsafe access gets a fault that could not be
-  // reasonably prevented by the programmer.  (Example: SIGBUS/OBJERR.)
-  //
-  address generate_handler_for_unsafe_access() {
-    StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access");
-    address start = __ function_entry();
-    __ unimplemented("StubRoutines::handler_for_unsafe_access", 93);
-    return start;
-  }
-
 #if !defined(PRODUCT)
   // Wrapper which calls oopDesc::is_oop_or_null()
   // Only called by MacroAssembler::verify_oop
@@ -3111,8 +3100,6 @@
     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError),  false);
     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
 
-    StubRoutines::_handler_for_unsafe_access_entry         = generate_handler_for_unsafe_access();
-
     // support for verify_oop (must happen after universe_init)
     StubRoutines::_verify_oop_subroutine_entry             = generate_verify_oop();
 
diff --git a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp
index 3602c64..3869906 100644
--- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp
@@ -871,7 +871,6 @@
 
   // Get synchronization object to Rscratch2.
   {
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
     Label Lstatic;
     Label Ldone;
 
@@ -883,10 +882,7 @@
     __ b(Ldone);
 
     __ bind(Lstatic); // Static case: Lock the java mirror
-    __ ld(Robj_to_lock, in_bytes(Method::const_offset()), R19_method);
-    __ ld(Robj_to_lock, in_bytes(ConstMethod::constants_offset()), Robj_to_lock);
-    __ ld(Robj_to_lock, ConstantPool::pool_holder_offset_in_bytes(), Robj_to_lock);
-    __ ld(Robj_to_lock, mirror_offset, Robj_to_lock);
+    __ load_mirror(Robj_to_lock, R19_method);
 
     __ bind(Ldone);
     __ verify_oop(Robj_to_lock);
@@ -1051,10 +1047,14 @@
   __ addi(R26_monitor, R1_SP, - frame::ijava_state_size);
   __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize);
 
+  // Get mirror and store it in the frame as GC root for this Method*
+  __ load_mirror(R12_scratch2, R19_method);
+
   // Store values.
   // R15_esp, R14_bcp, R26_monitor, R28_mdx are saved at java calls
   // in InterpreterMacroAssembler::call_from_interpreter.
   __ std(R19_method, _ijava_state_neg(method), R1_SP);
+  __ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP);
   __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
   __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);
   __ std(R18_locals, _ijava_state_neg(locals), R1_SP);
@@ -1319,21 +1319,11 @@
     __ testbitdi(CCR0, R0, access_flags, JVM_ACC_STATIC_BIT);
     __ bfalse(CCR0, method_is_not_static);
 
-    // constants = method->constants();
-    __ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
-    __ ld(R11_scratch1, in_bytes(ConstMethod::constants_offset()), R11_scratch1);
-    // pool_holder = method->constants()->pool_holder();
-    __ ld(R11_scratch1/*pool_holder*/, ConstantPool::pool_holder_offset_in_bytes(),
-          R11_scratch1/*constants*/);
-
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
-
-    // mirror = pool_holder->klass_part()->java_mirror();
-    __ ld(R0/*mirror*/, mirror_offset, R11_scratch1/*pool_holder*/);
+    __ load_mirror(R12_scratch2, R19_method);
     // state->_native_mirror = mirror;
 
     __ ld(R11_scratch1, 0, R1_SP);
-    __ std(R0/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1);
+    __ std(R12_scratch2/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1);
     // R4_ARG2 = &state->_oop_temp;
     __ addi(R4_ARG2, R11_scratch1, _ijava_state_neg(oop_tmp));
     BIND(method_is_not_static);
diff --git a/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp
index d85bd78..f9ba798 100644
--- a/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -281,11 +281,12 @@
   // Llast_SP will be same as SP as there is no adapter space
   *interpreter_frame->register_addr(Llast_SP)    = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
   *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
+  // save the mirror in the interpreter frame
+  *interpreter_frame->interpreter_frame_mirror_addr() = method->method_holder()->java_mirror();
 #ifdef FAST_DISPATCH
   *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
 #endif
 
-
 #ifdef ASSERT
   BasicObjectLock* mp = (BasicObjectLock*)monitors;
 
diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
index 128f6c3..8a9ef34 100644
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
@@ -3313,6 +3313,9 @@
   __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
 }
 
+void LIR_Assembler::on_spin_wait() {
+  Unimplemented();
+}
 
 // Pack two sequential registers containing 32 bit values
 // into a single 64 bit register.
diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
index de568fd..f4d84c8 100644
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -869,6 +869,94 @@
   }
 }
 
+void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
+  // Make all state_for calls early since they can emit code
+  LIR_Opr result = rlock_result(x);
+  int flags = 0;
+  switch (x->id()) {
+    case vmIntrinsics::_updateBytesCRC32C:
+    case vmIntrinsics::_updateDirectByteBufferCRC32C: {
+
+      bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32C);
+      int array_offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0;
+
+      LIRItem crc(x->argument_at(0), this);
+      LIRItem buf(x->argument_at(1), this);
+      LIRItem off(x->argument_at(2), this);
+      LIRItem end(x->argument_at(3), this);
+
+      buf.load_item();
+      off.load_nonconstant();
+      end.load_nonconstant();
+
+      // len = end - off
+      LIR_Opr len  = end.result();
+      LIR_Opr tmpA = new_register(T_INT);
+      LIR_Opr tmpB = new_register(T_INT);
+      __ move(end.result(), tmpA);
+      __ move(off.result(), tmpB);
+      __ sub(tmpA, tmpB, tmpA);
+      len = tmpA;
+
+      LIR_Opr index = off.result();
+
+      if(off.result()->is_constant()) {
+        index = LIR_OprFact::illegalOpr;
+        array_offset += off.result()->as_jint();
+      }
+
+      LIR_Opr base_op = buf.result();
+
+      if (index->is_valid()) {
+        LIR_Opr tmp = new_register(T_LONG);
+        __ convert(Bytecodes::_i2l, index, tmp);
+        index = tmp;
+        if (index->is_constant()) {
+          array_offset += index->as_constant_ptr()->as_jint();
+          index = LIR_OprFact::illegalOpr;
+        } else if (index->is_register()) {
+          LIR_Opr tmp2 = new_register(T_LONG);
+          LIR_Opr tmp3 = new_register(T_LONG);
+          __ move(base_op, tmp2);
+          __ move(index, tmp3);
+          __ add(tmp2, tmp3, tmp2);
+          base_op = tmp2;
+        } else {
+          ShouldNotReachHere();
+        }
+      }
+
+      LIR_Address* a = new LIR_Address(base_op, array_offset, T_BYTE);
+
+      BasicTypeList signature(3);
+      signature.append(T_INT);
+      signature.append(T_ADDRESS);
+      signature.append(T_INT);
+      CallingConvention* cc = frame_map()->c_calling_convention(&signature);
+      const LIR_Opr result_reg = result_register_for(x->type());
+
+      LIR_Opr addr = new_pointer_register();
+      __ leal(LIR_OprFact::address(a), addr);
+
+      crc.load_item_force(cc->at(0));
+      __ move(addr, cc->at(1));
+      __ move(len, cc->at(2));
+
+      __ call_runtime_leaf(StubRoutines::updateBytesCRC32C(), getThreadTemp(), result_reg, cc->args());
+      __ move(result_reg, result);
+
+      break;
+    }
+    default: {
+      ShouldNotReachHere();
+    }
+  }
+}
+
+void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
+  fatal("vectorizedMismatch intrinsic is not implemented on this platform");
+}
+
 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
 // _i2b, _i2c, _i2s
 void LIRGenerator::do_Convert(Convert* x) {
@@ -1034,7 +1122,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
diff --git a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp
index d56af16..c544e7a 100644
--- a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,22 +34,6 @@
 #include "opto/matcher.hpp"
 #endif
 
-// Release the CompiledICHolder* associated with this call site is there is one.
-void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  if (is_icholder_entry(call->destination())) {
-    NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());
-    InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());
-  }
-}
-
-bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  return is_icholder_entry(call->destination());
-}
-
 // ----------------------------------------------------------------------------
 
 #define __ _masm.
diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp
index a9ac2a9..ab6aeee 100644
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -212,7 +212,7 @@
     // ok. adapter blobs never have a frame complete and are never ok.
 
     if (!_cb->is_frame_complete_at(_pc)) {
-      if (_cb->is_nmethod() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) {
+      if (_cb->is_compiled() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) {
         return false;
       }
     }
@@ -304,7 +304,7 @@
     // because you must allocate window space
 
     if (sender_blob->frame_size() <= 0) {
-      assert(!sender_blob->is_nmethod(), "should count return address at least");
+      assert(!sender_blob->is_compiled(), "should count return address at least");
       return false;
     }
 
@@ -315,7 +315,7 @@
     // the stack unwalkable. pd_get_top_frame_for_signal_handler tries to recover from this by unwinding
     // that initial frame and retrying.
 
-    if (!sender_blob->is_nmethod()) {
+    if (!sender_blob->is_compiled()) {
       return false;
     }
 
@@ -358,9 +358,9 @@
   }
   _deopt_state = unknown;
 #ifdef ASSERT
-  if ( _cb != NULL && _cb->is_nmethod()) {
+  if ( _cb != NULL && _cb->is_compiled()) {
     // Without a valid unextended_sp() we can't convert the pc to "original"
-    assert(!((nmethod*)_cb)->is_deopt_pc(_pc), "invariant broken");
+    assert(!((CompiledMethod*)_cb)->is_deopt_pc(_pc), "invariant broken");
   }
 #endif // ASSERT
 }
@@ -393,7 +393,7 @@
 
   // Check for MethodHandle call sites.
   if (_cb != NULL) {
-    nmethod* nm = _cb->as_nmethod_or_null();
+    CompiledMethod* nm = _cb->as_compiled_method_or_null();
     if (nm != NULL) {
       if (nm->is_deopt_mh_entry(_pc) || nm->is_method_handle_return(_pc)) {
         _sp_adjustment_by_callee = (intptr_t*) ((intptr_t) sp[L7_mh_SP_save->sp_offset_in_saved_window()] + STACK_BIAS) - sp;
@@ -413,7 +413,7 @@
   // this lookup as get_deopt_original_pc() needs a correct value for
   // unextended_sp() which uses _sp_adjustment_by_callee.
   if (_pc != NULL) {
-    address original_pc = nmethod::get_deopt_original_pc(this);
+    address original_pc = CompiledMethod::get_deopt_original_pc(this);
     if (original_pc != NULL) {
       _pc = original_pc;
       _deopt_state = is_deoptimized;
@@ -547,7 +547,7 @@
   _cb = CodeCache::find_blob(pc);
   *O7_addr() = pc - pc_return_offset;
   _cb = CodeCache::find_blob(_pc);
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     assert(original_pc == _pc, "expected original to be stored before patching");
     _deopt_state = is_deoptimized;
@@ -783,7 +783,7 @@
   if (is_interpreted_frame()) {
     DESCRIBE_FP_OFFSET(interpreter_frame_d_scratch_fp);
     DESCRIBE_FP_OFFSET(interpreter_frame_l_scratch_fp);
-    DESCRIBE_FP_OFFSET(interpreter_frame_padding);
+    DESCRIBE_FP_OFFSET(interpreter_frame_mirror);
     DESCRIBE_FP_OFFSET(interpreter_frame_oop_temp);
 
     // esp, according to Lesp (e.g. not depending on bci), if seems valid
diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.hpp b/hotspot/src/cpu/sparc/vm/frame_sparc.hpp
index cd91f52..48cf45b 100644
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -209,7 +209,8 @@
        // 2 words, also used to save float regs across  calls to C
        interpreter_frame_d_scratch_fp_offset          = -2,
        interpreter_frame_l_scratch_fp_offset          = -4,
-       interpreter_frame_padding_offset               = -5, // for native calls only
+       interpreter_frame_mirror_offset                = -5, // keep interpreted method alive
+
        interpreter_frame_oop_temp_offset              = -6, // for native calls only
        interpreter_frame_vm_locals_fp_offset          = -6, // should be same as above, and should be zero mod 8
 
diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp
index 01e2472..e10261f 100644
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -163,6 +163,10 @@
   *interpreter_frame_monitors_addr() = monitors;
 }
 
+inline oop* frame::interpreter_frame_mirror_addr() const {
+  return (oop*)(fp() + interpreter_frame_mirror_offset);
+}
+
 // Constant pool cache
 
 // where LcpoolCache is saved:
diff --git a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp
index 66889ae..1e1ef75 100644
--- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp
@@ -92,7 +92,14 @@
 
 define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
 
-#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \
+#define ARCH_FLAGS(develop, \
+                   product, \
+                   diagnostic, \
+                   experimental, \
+                   notproduct, \
+                   range, \
+                   constraint, \
+                   writeable) \
                                                                             \
   product(intx, UseVIS, 99,                                                 \
           "Highest supported VIS instructions set on Sparc")                \
diff --git a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp
index 580b133..ba25825 100644
--- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp
@@ -26,13 +26,13 @@
 #include "interp_masm_sparc.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
+#include "logging/log.hpp"
 #include "oops/arrayOop.hpp"
 #include "oops/markOop.hpp"
 #include "oops/methodData.hpp"
 #include "oops/method.hpp"
 #include "oops/methodCounters.hpp"
 #include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/jvmtiThreadState.hpp"
 #include "runtime/basicLock.hpp"
 #include "runtime/biasedLocking.hpp"
@@ -2645,7 +2645,7 @@
   }
 
   // RedefineClasses() tracing support for obsolete method entry
-  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete)) {
     call_VM_leaf(noreg,
       CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
       G2_thread, Lmethod);
diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp
index f6770b0..5fe78ad 100644
--- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp
@@ -3257,12 +3257,12 @@
     if (var_size_in_bytes->is_valid()) {
       // size is unknown at compile time
       cmp(free, var_size_in_bytes);
-      br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
+      brx(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
       delayed()->add(obj, var_size_in_bytes, end);
     } else {
       // size is known at compile time
       cmp(free, con_size_in_bytes);
-      br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
+      brx(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
       delayed()->add(obj, con_size_in_bytes, end);
     }
     // Compare obj with the value at top_addr; if still equal, swap the value of
@@ -3972,6 +3972,14 @@
   card_table_write(bs->byte_map_base, tmp, store_addr);
 }
 
+void MacroAssembler::load_mirror(Register mirror, Register method) {
+  const int mirror_offset = in_bytes(Klass::java_mirror_offset());
+  ld_ptr(method, in_bytes(Method::const_offset()), mirror);
+  ld_ptr(mirror, in_bytes(ConstMethod::constants_offset()), mirror);
+  ld_ptr(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror);
+  ld_ptr(mirror, mirror_offset, mirror);
+}
+
 void MacroAssembler::load_klass(Register src_oop, Register klass) {
   // The number of bytes in this code is used by
   // MachCallDynamicJavaNode::ret_addr_offset()
@@ -4516,18 +4524,10 @@
   }
 
   // Compare the rest of the characters
-  if (ae == StrIntrinsicNode::UU) {
-    lduh(str1, limit1, chr1);
-  } else {
-    ldub(str1, limit1, chr1);
-  }
+  load_sized_value(Address(str1, limit1), chr1, (ae == StrIntrinsicNode::UU) ? 2 : 1, false);
 
   bind(Lloop);
-  if (ae == StrIntrinsicNode::LL) {
-    ldub(str2, limit2, chr2);
-  } else {
-    lduh(str2, limit2, chr2);
-  }
+  load_sized_value(Address(str2, limit2), chr2, (ae == StrIntrinsicNode::LL) ? 1 : 2, false);
 
   subcc(chr1, chr2, chr1);
   br(Assembler::notZero, false, Assembler::pt, Ldone);
@@ -4539,11 +4539,7 @@
 
   // annul LDUB if branch is not taken to prevent access past end of string
   br(Assembler::notZero, true, Assembler::pt, Lloop);
-  if (ae == StrIntrinsicNode::UU) {
-    delayed()->lduh(str1, limit2, chr1);
-  } else {
-    delayed()->ldub(str1, limit1, chr1);
-  }
+  delayed()->load_sized_value(Address(str1, limit1), chr1, (ae == StrIntrinsicNode::UU) ? 2 : 1, false);
 
   // If strings are equal up to min length, return the length difference.
   if (ae == StrIntrinsicNode::UU) {
@@ -4563,23 +4559,24 @@
 
 void MacroAssembler::array_equals(bool is_array_equ, Register ary1, Register ary2,
                                   Register limit, Register tmp, Register result, bool is_byte) {
-  Label Ldone, Lvector, Lloop;
+  Label Ldone, Lloop, Lremaining;
   assert_different_registers(ary1, ary2, limit, tmp, result);
 
   int length_offset  = arrayOopDesc::length_offset_in_bytes();
   int base_offset    = arrayOopDesc::base_offset_in_bytes(is_byte ? T_BYTE : T_CHAR);
+  assert(base_offset % 8 == 0, "Base offset must be 8-byte aligned");
 
   if (is_array_equ) {
     // return true if the same array
     cmp(ary1, ary2);
     brx(Assembler::equal, true, Assembler::pn, Ldone);
-    delayed()->add(G0, 1, result); // equal
+    delayed()->mov(1, result);  // equal
 
     br_null(ary1, true, Assembler::pn, Ldone);
-    delayed()->mov(G0, result);    // not equal
+    delayed()->clr(result);     // not equal
 
     br_null(ary2, true, Assembler::pn, Ldone);
-    delayed()->mov(G0, result);    // not equal
+    delayed()->clr(result);     // not equal
 
     // load the lengths of arrays
     ld(Address(ary1, length_offset), limit);
@@ -4588,81 +4585,77 @@
     // return false if the two arrays are not equal length
     cmp(limit, tmp);
     br(Assembler::notEqual, true, Assembler::pn, Ldone);
-    delayed()->mov(G0, result);    // not equal
+    delayed()->clr(result);     // not equal
   }
 
   cmp_zero_and_br(Assembler::zero, limit, Ldone, true, Assembler::pn);
-  delayed()->add(G0, 1, result); // zero-length arrays are equal
+  delayed()->mov(1, result); // zero-length arrays are equal
 
   if (is_array_equ) {
     // load array addresses
     add(ary1, base_offset, ary1);
     add(ary2, base_offset, ary2);
+    // set byte count
+    if (!is_byte) {
+      sll(limit, exact_log2(sizeof(jchar)), limit);
+    }
   } else {
     // We have no guarantee that on 64 bit the higher half of limit is 0
     signx(limit);
   }
 
-  if (is_byte) {
-    Label Lskip;
-    // check for trailing byte
-    andcc(limit, 0x1, tmp);
-    br(Assembler::zero, false, Assembler::pt, Lskip);
-    delayed()->nop();
+#ifdef ASSERT
+  // Sanity check for doubleword (8-byte) alignment of ary1 and ary2.
+  // Guaranteed on 64-bit systems (see arrayOopDesc::header_size_in_bytes()).
+  Label Laligned;
+  or3(ary1, ary2, tmp);
+  andcc(tmp, 7, tmp);
+  br_null_short(tmp, Assembler::pn, Laligned);
+  STOP("First array element is not 8-byte aligned.");
+  should_not_reach_here();
+  bind(Laligned);
+#endif
 
-    // compare the trailing byte
-    sub(limit, sizeof(jbyte), limit);
-    ldub(ary1, limit, result);
-    ldub(ary2, limit, tmp);
-    cmp(result, tmp);
-    br(Assembler::notEqual, true, Assembler::pt, Ldone);
-    delayed()->mov(G0, result);    // not equal
-
-    // only one byte?
-    cmp_zero_and_br(zero, limit, Ldone, true, Assembler::pn);
-    delayed()->add(G0, 1, result); // zero-length arrays are equal
-    bind(Lskip);
-  } else if (is_array_equ) {
-    // set byte count
-    sll(limit, exact_log2(sizeof(jchar)), limit);
-  }
-
-  // check for trailing character
-  andcc(limit, 0x2, tmp);
-  br(Assembler::zero, false, Assembler::pt, Lvector);
-  delayed()->nop();
-
-  // compare the trailing char
-  sub(limit, sizeof(jchar), limit);
-  lduh(ary1, limit, result);
-  lduh(ary2, limit, tmp);
-  cmp(result, tmp);
-  br(Assembler::notEqual, true, Assembler::pt, Ldone);
-  delayed()->mov(G0, result);     // not equal
-
-  // only one char?
-  cmp_zero_and_br(zero, limit, Ldone, true, Assembler::pn);
-  delayed()->add(G0, 1, result); // zero-length arrays are equal
-
-  // word by word compare, dont't need alignment check
-  bind(Lvector);
   // Shift ary1 and ary2 to the end of the arrays, negate limit
   add(ary1, limit, ary1);
   add(ary2, limit, ary2);
   neg(limit, limit);
 
-  lduw(ary1, limit, result);
+  // MAIN LOOP
+  // Load and compare array elements of size 'byte_width' until the elements are not
+  // equal or we reached the end of the arrays. If the size of the arrays is not a
+  // multiple of 'byte_width', we simply read over the end of the array, bail out and
+  // compare the remaining bytes below by skipping the garbage bytes.
+  ldx(ary1, limit, result);
   bind(Lloop);
-  lduw(ary2, limit, tmp);
-  cmp(result, tmp);
-  br(Assembler::notEqual, true, Assembler::pt, Ldone);
-  delayed()->mov(G0, result);     // not equal
-  inccc(limit, 2*sizeof(jchar));
-  // annul LDUW if branch is not taken to prevent access past end of array
-  br(Assembler::notZero, true, Assembler::pt, Lloop);
-  delayed()->lduw(ary1, limit, result); // hoisted
+  ldx(ary2, limit, tmp);
+  inccc(limit, 8);
+  // Bail out if we reached the end (but still do the comparison)
+  br(Assembler::positive, false, Assembler::pn, Lremaining);
+  delayed()->cmp(result, tmp);
+  // Check equality of elements
+  brx(Assembler::equal, false, Assembler::pt, target(Lloop));
+  delayed()->ldx(ary1, limit, result);
 
-  add(G0, 1, result); // equals
+  ba(Ldone);
+  delayed()->clr(result); // not equal
+
+  // TAIL COMPARISON
+  // We got here because we reached the end of the arrays. 'limit' is the number of
+  // garbage bytes we may have compared by reading over the end of the arrays. Shift
+  // out the garbage and compare the remaining elements.
+  bind(Lremaining);
+  // Optimistic shortcut: elements potentially including garbage are equal
+  brx(Assembler::equal, true, Assembler::pt, target(Ldone));
+  delayed()->mov(1, result); // equal
+  // Shift 'limit' bytes to the right and compare
+  sll(limit, 3, limit); // bytes to bits
+  srlx(result, limit, result);
+  srlx(tmp, limit, tmp);
+  cmp(result, tmp);
+  clr(result);
+  movcc(Assembler::equal, false, xcc, 1, result);
+
   bind(Ldone);
 }
 
@@ -4774,6 +4767,7 @@
   assert(UseBlockZeroing && VM_Version::has_block_zeroing(), "only works with BIS zeroing");
   Register end = count;
   int cache_line_size = VM_Version::prefetch_data_size();
+  assert(cache_line_size > 0, "cache line size should be known for this code");
   // Minimum count when BIS zeroing can be used since
   // it needs membar which is expensive.
   int block_zero_size  = MAX2(cache_line_size*3, (int)BlockZeroingLowLimit);
@@ -4852,21 +4846,21 @@
 
 // Reverse byte order of lower 32 bits, assuming upper 32 bits all zeros
 void MacroAssembler::reverse_bytes_32(Register src, Register dst, Register tmp) {
-  srlx(src, 24, dst);
+    srlx(src, 24, dst);
 
-  sllx(src, 32+8, tmp);
-  srlx(tmp, 32+24, tmp);
-  sllx(tmp, 8, tmp);
-  or3(dst, tmp, dst);
+    sllx(src, 32+8, tmp);
+    srlx(tmp, 32+24, tmp);
+    sllx(tmp, 8, tmp);
+    or3(dst, tmp, dst);
 
-  sllx(src, 32+16, tmp);
-  srlx(tmp, 32+24, tmp);
-  sllx(tmp, 16, tmp);
-  or3(dst, tmp, dst);
+    sllx(src, 32+16, tmp);
+    srlx(tmp, 32+24, tmp);
+    sllx(tmp, 16, tmp);
+    or3(dst, tmp, dst);
 
-  sllx(src, 32+24, tmp);
-  srlx(tmp, 32, tmp);
-  or3(dst, tmp, dst);
+    sllx(src, 32+24, tmp);
+    srlx(tmp, 32, tmp);
+    or3(dst, tmp, dst);
 }
 
 void MacroAssembler::movitof_revbytes(Register src, FloatRegister dst, Register tmp1, Register tmp2) {
@@ -5118,3 +5112,176 @@
   not1(crc);
 }
 
+#define CHUNK_LEN   128          /* 128 x 8B = 1KB */
+#define CHUNK_K1    0x1307a0206  /* reverseBits(pow(x, CHUNK_LEN*8*8*3 - 32) mod P(x)) << 1 */
+#define CHUNK_K2    0x1a0f717c4  /* reverseBits(pow(x, CHUNK_LEN*8*8*2 - 32) mod P(x)) << 1 */
+#define CHUNK_K3    0x0170076fa  /* reverseBits(pow(x, CHUNK_LEN*8*8*1 - 32) mod P(x)) << 1 */
+
+void MacroAssembler::kernel_crc32c(Register crc, Register buf, Register len, Register table) {
+
+  Label L_crc32c_head, L_crc32c_aligned;
+  Label L_crc32c_parallel, L_crc32c_parallel_loop;
+  Label L_crc32c_serial, L_crc32c_x32_loop, L_crc32c_x8, L_crc32c_x8_loop;
+  Label L_crc32c_done, L_crc32c_tail, L_crc32c_return;
+
+  set(ExternalAddress(StubRoutines::crc32c_table_addr()), table);
+
+  cmp_and_br_short(len, 0, Assembler::lessEqual, Assembler::pn, L_crc32c_return);
+
+  // clear upper 32 bits of crc
+  clruwu(crc);
+
+  and3(buf, 7, G4);
+  cmp_and_brx_short(G4, 0, Assembler::equal, Assembler::pt, L_crc32c_aligned);
+
+  mov(8, G1);
+  sub(G1, G4, G4);
+
+  // ------ process the misaligned head (7 bytes or less) ------
+  bind(L_crc32c_head);
+
+  // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF];
+  ldub(buf, 0, G1);
+  update_byte_crc32(crc, G1, table);
+
+  inc(buf);
+  dec(len);
+  cmp_and_br_short(len, 0, Assembler::equal, Assembler::pn, L_crc32c_return);
+  dec(G4);
+  cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_head);
+
+  // ------ process the 8-byte-aligned body ------
+  bind(L_crc32c_aligned);
+  nop();
+  cmp_and_br_short(len, 8, Assembler::less, Assembler::pn, L_crc32c_tail);
+
+  // reverse the byte order of lower 32 bits to big endian, and move to FP side
+  movitof_revbytes(crc, F0, G1, G3);
+
+  set(CHUNK_LEN*8*4, G4);
+  cmp_and_br_short(len, G4, Assembler::less, Assembler::pt, L_crc32c_serial);
+
+  // ------ process four 1KB chunks in parallel ------
+  bind(L_crc32c_parallel);
+
+  fzero(FloatRegisterImpl::D, F2);
+  fzero(FloatRegisterImpl::D, F4);
+  fzero(FloatRegisterImpl::D, F6);
+
+  mov(CHUNK_LEN - 1, G4);
+  bind(L_crc32c_parallel_loop);
+  // schedule ldf's ahead of crc32c's to hide the load-use latency
+  ldf(FloatRegisterImpl::D, buf, 0,            F8);
+  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8,  F10);
+  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12);
+  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*24, F14);
+  crc32c(F0, F8,  F0);
+  crc32c(F2, F10, F2);
+  crc32c(F4, F12, F4);
+  crc32c(F6, F14, F6);
+  inc(buf, 8);
+  dec(G4);
+  cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_parallel_loop);
+
+  ldf(FloatRegisterImpl::D, buf, 0,            F8);
+  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8,  F10);
+  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12);
+  crc32c(F0, F8,  F0);
+  crc32c(F2, F10, F2);
+  crc32c(F4, F12, F4);
+
+  inc(buf, CHUNK_LEN*24);
+  ldfl(FloatRegisterImpl::D, buf, G0, F14);  // load in little endian
+  inc(buf, 8);
+
+  prefetch(buf, 0,            Assembler::severalReads);
+  prefetch(buf, CHUNK_LEN*8,  Assembler::severalReads);
+  prefetch(buf, CHUNK_LEN*16, Assembler::severalReads);
+  prefetch(buf, CHUNK_LEN*24, Assembler::severalReads);
+
+  // move to INT side, and reverse the byte order of lower 32 bits to little endian
+  movftoi_revbytes(F0, O4, G1, G4);
+  movftoi_revbytes(F2, O5, G1, G4);
+  movftoi_revbytes(F4, G5, G1, G4);
+
+  // combine the results of 4 chunks
+  set64(CHUNK_K1, G3, G1);
+  xmulx(O4, G3, O4);
+  set64(CHUNK_K2, G3, G1);
+  xmulx(O5, G3, O5);
+  set64(CHUNK_K3, G3, G1);
+  xmulx(G5, G3, G5);
+
+  movdtox(F14, G4);
+  xor3(O4, O5, O5);
+  xor3(G5, O5, O5);
+  xor3(G4, O5, O5);
+
+  // reverse the byte order to big endian, via stack, and move to FP side
+  // TODO: use new revb instruction
+  add(SP, -8, G1);
+  srlx(G1, 3, G1);
+  sllx(G1, 3, G1);
+  stx(O5, G1, G0);
+  ldfl(FloatRegisterImpl::D, G1, G0, F2);  // load in little endian
+
+  crc32c(F6, F2, F0);
+
+  set(CHUNK_LEN*8*4, G4);
+  sub(len, G4, len);
+  cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_parallel);
+  nop();
+  cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_done);
+
+  bind(L_crc32c_serial);
+
+  mov(32, G4);
+  cmp_and_br_short(len, G4, Assembler::less, Assembler::pn, L_crc32c_x8);
+
+  // ------ process 32B chunks ------
+  bind(L_crc32c_x32_loop);
+  ldf(FloatRegisterImpl::D, buf, 0, F2);
+  crc32c(F0, F2, F0);
+  ldf(FloatRegisterImpl::D, buf, 8, F2);
+  crc32c(F0, F2, F0);
+  ldf(FloatRegisterImpl::D, buf, 16, F2);
+  crc32c(F0, F2, F0);
+  ldf(FloatRegisterImpl::D, buf, 24, F2);
+  inc(buf, 32);
+  crc32c(F0, F2, F0);
+  dec(len, 32);
+  cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_x32_loop);
+
+  bind(L_crc32c_x8);
+  nop();
+  cmp_and_br_short(len, 8, Assembler::less, Assembler::pt, L_crc32c_done);
+
+  // ------ process 8B chunks ------
+  bind(L_crc32c_x8_loop);
+  ldf(FloatRegisterImpl::D, buf, 0, F2);
+  inc(buf, 8);
+  crc32c(F0, F2, F0);
+  dec(len, 8);
+  cmp_and_br_short(len, 8, Assembler::greaterEqual, Assembler::pt, L_crc32c_x8_loop);
+
+  bind(L_crc32c_done);
+
+  // move to INT side, and reverse the byte order of lower 32 bits to little endian
+  movftoi_revbytes(F0, crc, G1, G3);
+
+  cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_return);
+
+  // ------ process the misaligned tail (7 bytes or less) ------
+  bind(L_crc32c_tail);
+
+  // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF];
+  ldub(buf, 0, G1);
+  update_byte_crc32(crc, G1, table);
+
+  inc(buf);
+  dec(len);
+  cmp_and_br_short(len, 0, Assembler::greater, Assembler::pt, L_crc32c_tail);
+
+  bind(L_crc32c_return);
+  nop();
+}
diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp
index dbbfbbc..d94de09 100644
--- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp
@@ -1012,6 +1012,8 @@
   inline void ldbool(const Address& a, Register d);
   inline void movbool( bool boolconst, Register d);
 
+  void load_mirror(Register mirror, Register method);
+
   // klass oop manipulations if compressed
   void load_klass(Register src_oop, Register klass);
   void store_klass(Register klass, Register dst_oop);
@@ -1418,6 +1420,8 @@
   // Fold 8-bit data
   void fold_8bit_crc32(Register xcrc, Register table, Register xtmp, Register tmp);
   void fold_8bit_crc32(Register crc, Register table, Register tmp);
+  // CRC32C code for java.util.zip.CRC32C::updateBytes/updateDirectByteBuffer instrinsic.
+  void kernel_crc32c(Register crc, Register buf, Register len, Register table);
 
 };
 
diff --git a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
index 6727c14..a587b55 100644
--- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
@@ -28,9 +28,9 @@
 #include "code/icBuffer.hpp"
 #include "code/vtableStubs.hpp"
 #include "interpreter/interpreter.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/compiledICHolder.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vframeArray.hpp"
 #include "vmreg_sparc.inline.hpp"
@@ -2450,7 +2450,7 @@
   }
 
   // RedefineClasses() tracing support for obsolete method entry
-  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete)) {
     // create inner frame
     __ save_frame(0);
     __ mov(G2_thread, L7_thread_cache);
diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad
index d669d87..653da26 100644
--- a/hotspot/src/cpu/sparc/vm/sparc.ad
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad
@@ -1904,6 +1904,10 @@
   return ret_value;  // Per default match rules are supported.
 }
 
+const bool Matcher::has_predicated_vectors(void) {
+  return false;
+}
+
 const int Matcher::float_pressure(int default_pressure_threshold) {
   return default_pressure_threshold;
 }
@@ -1991,11 +1995,6 @@
 // Does the CPU require late expand (see block.cpp for description of late expand)?
 const bool Matcher::require_postalloc_expand = false;
 
-// Should the Matcher clone shifts on addressing modes, expecting them to
-// be subsumed into complex addressing expressions or compute them into
-// registers?  True for Intel but false for most RISCs
-const bool Matcher::clone_shift_expressions = false;
-
 // Do we need to mask the count passed to shift instructions or does
 // the cpu only look at the lower 5/6 bits anyway?
 const bool Matcher::need_masked_shift_count = false;
@@ -2129,6 +2128,19 @@
   return L7_REGP_mask();
 }
 
+
+const bool Matcher::convi2l_type_required = true;
+
+// Should the Matcher clone shifts on addressing modes, expecting them
+// to be subsumed into complex addressing expressions or compute them
+// into registers?
+bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) {
+  return clone_base_plus_offset_address(m, mstack, address_visited);
+}
+
+void Compile::reshape_address(AddPNode* addp) {
+}
+
 %}
 
 
diff --git a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp
index db2c5ee..8babb47 100644
--- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,20 +64,6 @@
 // -------------------------------------------------------------------------------------------------------------------------
 // Stub Code definitions
 
-static address handle_unsafe_access() {
-  JavaThread* thread = JavaThread::current();
-  address pc  = thread->saved_exception_pc();
-  address npc = thread->saved_exception_npc();
-  // pc is the instruction which we must emulate
-  // doing a no-op is fine:  return garbage from the load
-
-  // request an async exception
-  thread->set_pending_unsafe_access_error();
-
-  // return address of next instruction to execute
-  return npc;
-}
-
 class StubGenerator: public StubCodeGenerator {
  private:
 
@@ -746,62 +732,6 @@
   Label _atomic_add_stub;  // called from other stubs
 
 
-  //------------------------------------------------------------------------------------------------------------------------
-  // The following routine generates a subroutine to throw an asynchronous
-  // UnknownError when an unsafe access gets a fault that could not be
-  // reasonably prevented by the programmer.  (Example: SIGBUS/OBJERR.)
-  //
-  // Arguments :
-  //
-  //      trapping PC:    O7
-  //
-  // Results:
-  //     posts an asynchronous exception, skips the trapping instruction
-  //
-
-  address generate_handler_for_unsafe_access() {
-    StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access");
-    address start = __ pc();
-
-    const int preserve_register_words = (64 * 2);
-    Address preserve_addr(FP, (-preserve_register_words * wordSize) + STACK_BIAS);
-
-    Register Lthread = L7_thread_cache;
-    int i;
-
-    __ save_frame(0);
-    __ mov(G1, L1);
-    __ mov(G2, L2);
-    __ mov(G3, L3);
-    __ mov(G4, L4);
-    __ mov(G5, L5);
-    for (i = 0; i < 64; i += 2) {
-      __ stf(FloatRegisterImpl::D, as_FloatRegister(i), preserve_addr, i * wordSize);
-    }
-
-    address entry_point = CAST_FROM_FN_PTR(address, handle_unsafe_access);
-    BLOCK_COMMENT("call handle_unsafe_access");
-    __ call(entry_point, relocInfo::runtime_call_type);
-    __ delayed()->nop();
-
-    __ mov(L1, G1);
-    __ mov(L2, G2);
-    __ mov(L3, G3);
-    __ mov(L4, G4);
-    __ mov(L5, G5);
-    for (i = 0; i < 64; i += 2) {
-      __ ldf(FloatRegisterImpl::D, preserve_addr, as_FloatRegister(i), i * wordSize);
-    }
-
-    __ verify_thread();
-
-    __ jmp(O0, 0);
-    __ delayed()->restore();
-
-    return start;
-  }
-
-
   // Support for uint StubRoutine::Sparc::partial_subtype_check( Klass sub, Klass super );
   // Arguments :
   //
@@ -4909,11 +4839,6 @@
       return start;
   }
 
-#define CHUNK_LEN   128          /* 128 x 8B = 1KB */
-#define CHUNK_K1    0x1307a0206  /* reverseBits(pow(x, CHUNK_LEN*8*8*3 - 32) mod P(x)) << 1 */
-#define CHUNK_K2    0x1a0f717c4  /* reverseBits(pow(x, CHUNK_LEN*8*8*2 - 32) mod P(x)) << 1 */
-#define CHUNK_K3    0x0170076fa  /* reverseBits(pow(x, CHUNK_LEN*8*8*1 - 32) mod P(x)) << 1 */
-
   /**
    *  Arguments:
    *
@@ -4938,171 +4863,8 @@
     const Register len   = O2;  // number of bytes
     const Register table = O3;  // byteTable
 
-    Label L_crc32c_head, L_crc32c_aligned;
-    Label L_crc32c_parallel, L_crc32c_parallel_loop;
-    Label L_crc32c_serial, L_crc32c_x32_loop, L_crc32c_x8, L_crc32c_x8_loop;
-    Label L_crc32c_done, L_crc32c_tail, L_crc32c_return;
+    __ kernel_crc32c(crc, buf, len, table);
 
-    __ cmp_and_br_short(len, 0, Assembler::lessEqual, Assembler::pn, L_crc32c_return);
-
-    // clear upper 32 bits of crc
-    __ clruwu(crc);
-
-    __ and3(buf, 7, G4);
-    __ cmp_and_brx_short(G4, 0, Assembler::equal, Assembler::pt, L_crc32c_aligned);
-
-    __ mov(8, G1);
-    __ sub(G1, G4, G4);
-
-    // ------ process the misaligned head (7 bytes or less) ------
-    __ BIND(L_crc32c_head);
-
-    // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF];
-    __ ldub(buf, 0, G1);
-    __ update_byte_crc32(crc, G1, table);
-
-    __ inc(buf);
-    __ dec(len);
-    __ cmp_and_br_short(len, 0, Assembler::equal, Assembler::pn, L_crc32c_return);
-    __ dec(G4);
-    __ cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_head);
-
-    // ------ process the 8-byte-aligned body ------
-    __ BIND(L_crc32c_aligned);
-    __ nop();
-    __ cmp_and_br_short(len, 8, Assembler::less, Assembler::pn, L_crc32c_tail);
-
-    // reverse the byte order of lower 32 bits to big endian, and move to FP side
-    __ movitof_revbytes(crc, F0, G1, G3);
-
-    __ set(CHUNK_LEN*8*4, G4);
-    __ cmp_and_br_short(len, G4, Assembler::less, Assembler::pt, L_crc32c_serial);
-
-    // ------ process four 1KB chunks in parallel ------
-    __ BIND(L_crc32c_parallel);
-
-    __ fzero(FloatRegisterImpl::D, F2);
-    __ fzero(FloatRegisterImpl::D, F4);
-    __ fzero(FloatRegisterImpl::D, F6);
-
-    __ mov(CHUNK_LEN - 1, G4);
-    __ BIND(L_crc32c_parallel_loop);
-    // schedule ldf's ahead of crc32c's to hide the load-use latency
-    __ ldf(FloatRegisterImpl::D, buf, 0,            F8);
-    __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8,  F10);
-    __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12);
-    __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*24, F14);
-    __ crc32c(F0, F8,  F0);
-    __ crc32c(F2, F10, F2);
-    __ crc32c(F4, F12, F4);
-    __ crc32c(F6, F14, F6);
-    __ inc(buf, 8);
-    __ dec(G4);
-    __ cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_parallel_loop);
-
-    __ ldf(FloatRegisterImpl::D, buf, 0,            F8);
-    __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8,  F10);
-    __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12);
-    __ crc32c(F0, F8,  F0);
-    __ crc32c(F2, F10, F2);
-    __ crc32c(F4, F12, F4);
-
-    __ inc(buf, CHUNK_LEN*24);
-    __ ldfl(FloatRegisterImpl::D, buf, G0, F14);  // load in little endian
-    __ inc(buf, 8);
-
-    __ prefetch(buf, 0,            Assembler::severalReads);
-    __ prefetch(buf, CHUNK_LEN*8,  Assembler::severalReads);
-    __ prefetch(buf, CHUNK_LEN*16, Assembler::severalReads);
-    __ prefetch(buf, CHUNK_LEN*24, Assembler::severalReads);
-
-    // move to INT side, and reverse the byte order of lower 32 bits to little endian
-    __ movftoi_revbytes(F0, O4, G1, G4);
-    __ movftoi_revbytes(F2, O5, G1, G4);
-    __ movftoi_revbytes(F4, G5, G1, G4);
-
-    // combine the results of 4 chunks
-    __ set64(CHUNK_K1, G3, G1);
-    __ xmulx(O4, G3, O4);
-    __ set64(CHUNK_K2, G3, G1);
-    __ xmulx(O5, G3, O5);
-    __ set64(CHUNK_K3, G3, G1);
-    __ xmulx(G5, G3, G5);
-
-    __ movdtox(F14, G4);
-    __ xor3(O4, O5, O5);
-    __ xor3(G5, O5, O5);
-    __ xor3(G4, O5, O5);
-
-    // reverse the byte order to big endian, via stack, and move to FP side
-    __ add(SP, -8, G1);
-    __ srlx(G1, 3, G1);
-    __ sllx(G1, 3, G1);
-    __ stx(O5, G1, G0);
-    __ ldfl(FloatRegisterImpl::D, G1, G0, F2);  // load in little endian
-
-    __ crc32c(F6, F2, F0);
-
-    __ set(CHUNK_LEN*8*4, G4);
-    __ sub(len, G4, len);
-    __ cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_parallel);
-    __ nop();
-    __ cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_done);
-
-    __ BIND(L_crc32c_serial);
-
-    __ mov(32, G4);
-    __ cmp_and_br_short(len, G4, Assembler::less, Assembler::pn, L_crc32c_x8);
-
-    // ------ process 32B chunks ------
-    __ BIND(L_crc32c_x32_loop);
-    __ ldf(FloatRegisterImpl::D, buf, 0, F2);
-    __ inc(buf, 8);
-    __ crc32c(F0, F2, F0);
-    __ ldf(FloatRegisterImpl::D, buf, 0, F2);
-    __ inc(buf, 8);
-    __ crc32c(F0, F2, F0);
-    __ ldf(FloatRegisterImpl::D, buf, 0, F2);
-    __ inc(buf, 8);
-    __ crc32c(F0, F2, F0);
-    __ ldf(FloatRegisterImpl::D, buf, 0, F2);
-    __ inc(buf, 8);
-    __ crc32c(F0, F2, F0);
-    __ dec(len, 32);
-    __ cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_x32_loop);
-
-    __ BIND(L_crc32c_x8);
-    __ nop();
-    __ cmp_and_br_short(len, 8, Assembler::less, Assembler::pt, L_crc32c_done);
-
-    // ------ process 8B chunks ------
-    __ BIND(L_crc32c_x8_loop);
-    __ ldf(FloatRegisterImpl::D, buf, 0, F2);
-    __ inc(buf, 8);
-    __ crc32c(F0, F2, F0);
-    __ dec(len, 8);
-    __ cmp_and_br_short(len, 8, Assembler::greaterEqual, Assembler::pt, L_crc32c_x8_loop);
-
-    __ BIND(L_crc32c_done);
-
-    // move to INT side, and reverse the byte order of lower 32 bits to little endian
-    __ movftoi_revbytes(F0, crc, G1, G3);
-
-    __ cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_return);
-
-    // ------ process the misaligned tail (7 bytes or less) ------
-    __ BIND(L_crc32c_tail);
-
-    // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF];
-    __ ldub(buf, 0, G1);
-    __ update_byte_crc32(crc, G1, table);
-
-    __ inc(buf);
-    __ dec(len);
-    __ cmp_and_br_short(len, 0, Assembler::greater, Assembler::pt, L_crc32c_tail);
-
-    __ BIND(L_crc32c_return);
-    __ nop();
     __ retl();
     __ delayed()->nop();
 
@@ -5366,6 +5128,12 @@
       StubRoutines::_crc_table_adr = (address)StubRoutines::Sparc::_crc_table;
       StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32();
     }
+
+    if (UseCRC32CIntrinsics) {
+      // set table address before stub generation which use it
+      StubRoutines::_crc32c_table_addr = (address)StubRoutines::Sparc::_crc32c_table;
+      StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C();
+    }
   }
 
 
@@ -5380,9 +5148,6 @@
     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
 
-    StubRoutines::_handler_for_unsafe_access_entry =
-      generate_handler_for_unsafe_access();
-
     // support for verify_oop (must happen after universe_init)
     StubRoutines::_verify_oop_subroutine_entry     = generate_verify_oop_subroutine();
 
@@ -5425,12 +5190,6 @@
       StubRoutines::_sha512_implCompress   = generate_sha512_implCompress(false, "sha512_implCompress");
       StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(true,  "sha512_implCompressMB");
     }
-
-    // generate CRC32C intrinsic code
-    if (UseCRC32CIntrinsics) {
-      StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C();
-    }
-
     // generate Adler32 intrinsics code
     if (UseAdler32Intrinsics) {
       StubRoutines::_updateBytesAdler32 = generate_updateBytesAdler32();
diff --git a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp
index f8083c0..63cbcf0 100644
--- a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -147,3 +147,62 @@
     0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
     0x2d02ef8dUL
 };
+
+/**
+ * CRC32C constants lookup table
+ */
+juint StubRoutines::Sparc::_crc32c_table[] =
+{
+    0x00000000UL, 0xF26B8303UL, 0xE13B70F7UL, 0x1350F3F4UL, 0xC79A971FUL,
+    0x35F1141CUL, 0x26A1E7E8UL, 0xD4CA64EBUL, 0x8AD958CFUL, 0x78B2DBCCUL,
+    0x6BE22838UL, 0x9989AB3BUL, 0x4D43CFD0UL, 0xBF284CD3UL, 0xAC78BF27UL,
+    0x5E133C24UL, 0x105EC76FUL, 0xE235446CUL, 0xF165B798UL, 0x030E349BUL,
+    0xD7C45070UL, 0x25AFD373UL, 0x36FF2087UL, 0xC494A384UL, 0x9A879FA0UL,
+    0x68EC1CA3UL, 0x7BBCEF57UL, 0x89D76C54UL, 0x5D1D08BFUL, 0xAF768BBCUL,
+    0xBC267848UL, 0x4E4DFB4BUL, 0x20BD8EDEUL, 0xD2D60DDDUL, 0xC186FE29UL,
+    0x33ED7D2AUL, 0xE72719C1UL, 0x154C9AC2UL, 0x061C6936UL, 0xF477EA35UL,
+    0xAA64D611UL, 0x580F5512UL, 0x4B5FA6E6UL, 0xB93425E5UL, 0x6DFE410EUL,
+    0x9F95C20DUL, 0x8CC531F9UL, 0x7EAEB2FAUL, 0x30E349B1UL, 0xC288CAB2UL,
+    0xD1D83946UL, 0x23B3BA45UL, 0xF779DEAEUL, 0x05125DADUL, 0x1642AE59UL,
+    0xE4292D5AUL, 0xBA3A117EUL, 0x4851927DUL, 0x5B016189UL, 0xA96AE28AUL,
+    0x7DA08661UL, 0x8FCB0562UL, 0x9C9BF696UL, 0x6EF07595UL, 0x417B1DBCUL,
+    0xB3109EBFUL, 0xA0406D4BUL, 0x522BEE48UL, 0x86E18AA3UL, 0x748A09A0UL,
+    0x67DAFA54UL, 0x95B17957UL, 0xCBA24573UL, 0x39C9C670UL, 0x2A993584UL,
+    0xD8F2B687UL, 0x0C38D26CUL, 0xFE53516FUL, 0xED03A29BUL, 0x1F682198UL,
+    0x5125DAD3UL, 0xA34E59D0UL, 0xB01EAA24UL, 0x42752927UL, 0x96BF4DCCUL,
+    0x64D4CECFUL, 0x77843D3BUL, 0x85EFBE38UL, 0xDBFC821CUL, 0x2997011FUL,
+    0x3AC7F2EBUL, 0xC8AC71E8UL, 0x1C661503UL, 0xEE0D9600UL, 0xFD5D65F4UL,
+    0x0F36E6F7UL, 0x61C69362UL, 0x93AD1061UL, 0x80FDE395UL, 0x72966096UL,
+    0xA65C047DUL, 0x5437877EUL, 0x4767748AUL, 0xB50CF789UL, 0xEB1FCBADUL,
+    0x197448AEUL, 0x0A24BB5AUL, 0xF84F3859UL, 0x2C855CB2UL, 0xDEEEDFB1UL,
+    0xCDBE2C45UL, 0x3FD5AF46UL, 0x7198540DUL, 0x83F3D70EUL, 0x90A324FAUL,
+    0x62C8A7F9UL, 0xB602C312UL, 0x44694011UL, 0x5739B3E5UL, 0xA55230E6UL,
+    0xFB410CC2UL, 0x092A8FC1UL, 0x1A7A7C35UL, 0xE811FF36UL, 0x3CDB9BDDUL,
+    0xCEB018DEUL, 0xDDE0EB2AUL, 0x2F8B6829UL, 0x82F63B78UL, 0x709DB87BUL,
+    0x63CD4B8FUL, 0x91A6C88CUL, 0x456CAC67UL, 0xB7072F64UL, 0xA457DC90UL,
+    0x563C5F93UL, 0x082F63B7UL, 0xFA44E0B4UL, 0xE9141340UL, 0x1B7F9043UL,
+    0xCFB5F4A8UL, 0x3DDE77ABUL, 0x2E8E845FUL, 0xDCE5075CUL, 0x92A8FC17UL,
+    0x60C37F14UL, 0x73938CE0UL, 0x81F80FE3UL, 0x55326B08UL, 0xA759E80BUL,
+    0xB4091BFFUL, 0x466298FCUL, 0x1871A4D8UL, 0xEA1A27DBUL, 0xF94AD42FUL,
+    0x0B21572CUL, 0xDFEB33C7UL, 0x2D80B0C4UL, 0x3ED04330UL, 0xCCBBC033UL,
+    0xA24BB5A6UL, 0x502036A5UL, 0x4370C551UL, 0xB11B4652UL, 0x65D122B9UL,
+    0x97BAA1BAUL, 0x84EA524EUL, 0x7681D14DUL, 0x2892ED69UL, 0xDAF96E6AUL,
+    0xC9A99D9EUL, 0x3BC21E9DUL, 0xEF087A76UL, 0x1D63F975UL, 0x0E330A81UL,
+    0xFC588982UL, 0xB21572C9UL, 0x407EF1CAUL, 0x532E023EUL, 0xA145813DUL,
+    0x758FE5D6UL, 0x87E466D5UL, 0x94B49521UL, 0x66DF1622UL, 0x38CC2A06UL,
+    0xCAA7A905UL, 0xD9F75AF1UL, 0x2B9CD9F2UL, 0xFF56BD19UL, 0x0D3D3E1AUL,
+    0x1E6DCDEEUL, 0xEC064EEDUL, 0xC38D26C4UL, 0x31E6A5C7UL, 0x22B65633UL,
+    0xD0DDD530UL, 0x0417B1DBUL, 0xF67C32D8UL, 0xE52CC12CUL, 0x1747422FUL,
+    0x49547E0BUL, 0xBB3FFD08UL, 0xA86F0EFCUL, 0x5A048DFFUL, 0x8ECEE914UL,
+    0x7CA56A17UL, 0x6FF599E3UL, 0x9D9E1AE0UL, 0xD3D3E1ABUL, 0x21B862A8UL,
+    0x32E8915CUL, 0xC083125FUL, 0x144976B4UL, 0xE622F5B7UL, 0xF5720643UL,
+    0x07198540UL, 0x590AB964UL, 0xAB613A67UL, 0xB831C993UL, 0x4A5A4A90UL,
+    0x9E902E7BUL, 0x6CFBAD78UL, 0x7FAB5E8CUL, 0x8DC0DD8FUL, 0xE330A81AUL,
+    0x115B2B19UL, 0x020BD8EDUL, 0xF0605BEEUL, 0x24AA3F05UL, 0xD6C1BC06UL,
+    0xC5914FF2UL, 0x37FACCF1UL, 0x69E9F0D5UL, 0x9B8273D6UL, 0x88D28022UL,
+    0x7AB90321UL, 0xAE7367CAUL, 0x5C18E4C9UL, 0x4F48173DUL, 0xBD23943EUL,
+    0xF36E6F75UL, 0x0105EC76UL, 0x12551F82UL, 0xE03E9C81UL, 0x34F4F86AUL,
+    0xC69F7B69UL, 0xD5CF889DUL, 0x27A40B9EUL, 0x79B737BAUL, 0x8BDCB4B9UL,
+    0x988C474DUL, 0x6AE7C44EUL, 0xBE2DA0A5UL, 0x4C4623A6UL, 0x5F16D052UL,
+    0xAD7D5351UL
+};
diff --git a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp
index e28ec2f..eb6c909 100644
--- a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,7 @@
   // masks and table for CRC32
   static uint64_t _crc_by128_masks[];
   static juint    _crc_table[];
+  static juint    _crc32c_table[];
 
  public:
   // test assembler stop routine by setting registers
diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp
index 008fcee..f96b3e4 100644
--- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp
@@ -557,17 +557,12 @@
 
   // get synchronization object to O0
   { Label done;
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
     __ btst(JVM_ACC_STATIC, O0);
     __ br( Assembler::zero, true, Assembler::pt, done);
     __ delayed()->ld_ptr(Llocals, Interpreter::local_offset_in_bytes(0), O0); // get receiver for not-static case
 
-    __ ld_ptr( Lmethod, in_bytes(Method::const_offset()), O0);
-    __ ld_ptr( O0, in_bytes(ConstMethod::constants_offset()), O0);
-    __ ld_ptr( O0, ConstantPool::pool_holder_offset_in_bytes(), O0);
-
     // lock the mirror, not the Klass*
-    __ ld_ptr( O0, mirror_offset, O0);
+    __ load_mirror(O0, Lmethod);
 
 #ifdef ASSERT
     __ tst(O0);
@@ -881,6 +876,10 @@
     __ add(Lbcp, in_bytes(ConstMethod::codes_offset()), Lbcp);
   }
   __ mov( G5_method, Lmethod);                 // set Lmethod
+  // Get mirror and store it in the frame as GC root for this Method*
+  Register mirror = LcpoolCache;
+  __ load_mirror(mirror, Lmethod);
+  __ st_ptr(mirror, FP, (frame::interpreter_frame_mirror_offset * wordSize) + STACK_BIAS);
   __ get_constant_pool_cache( LcpoolCache );   // set LcpoolCache
   __ sub(FP, rounded_vm_local_words * BytesPerWord, Lmonitors ); // set Lmonitors
 #ifdef _LP64
@@ -1082,8 +1081,56 @@
   return NULL;
 }
 
-// Not supported
+/**
+ * Method entry for intrinsic-candidate (non-native) methods:
+ *   int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end)
+ *   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long buf, int off, int end)
+ * Unlike CRC32, CRC32C does not have any methods marked as native
+ * CRC32C also uses an "end" variable instead of the length variable CRC32 uses
+ */
 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
+
+  if (UseCRC32CIntrinsics) {
+    address entry = __ pc();
+
+    // Load parameters from the stack
+    const Register crc    = O0; // initial crc
+    const Register buf    = O1; // source java byte array address
+    const Register offset = O2; // offset
+    const Register end    = O3; // index of last element to process
+    const Register len    = O2; // len argument to the kernel
+    const Register table  = O3; // crc32c lookup table address
+
+    // Arguments are reversed on java expression stack
+    // Calculate address of start element
+    if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) {
+      __ lduw(Gargs, 0,  end);
+      __ lduw(Gargs, 8,  offset);
+      __ ldx( Gargs, 16, buf);
+      __ lduw(Gargs, 32, crc);
+      __ add(buf, offset, buf);
+      __ sub(end, offset, len);
+    } else {
+      __ lduw(Gargs, 0,  end);
+      __ lduw(Gargs, 8,  offset);
+      __ ldx( Gargs, 16, buf);
+      __ lduw(Gargs, 24, crc);
+      __ add(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE), buf); // account for the header size
+      __ add(buf, offset, buf);
+      __ sub(end, offset, len);
+    }
+
+    // Call the crc32c kernel
+    __ MacroAssembler::save_thread(L7_thread_cache);
+    __ kernel_crc32c(crc, buf, len, table);
+    __ MacroAssembler::restore_thread(L7_thread_cache);
+
+    // result in O0
+    __ retl();
+    __ delayed()->nop();
+
+    return entry;
+  }
   return NULL;
 }
 
@@ -1297,12 +1344,7 @@
     // get native function entry point(O0 is a good temp until the very end)
     __ delayed()->ld_ptr(Lmethod, in_bytes(Method::native_function_offset()), O0);
     // for static methods insert the mirror argument
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
-
-    __ ld_ptr(Lmethod, Method:: const_offset(), O1);
-    __ ld_ptr(O1, ConstMethod::constants_offset(), O1);
-    __ ld_ptr(O1, ConstantPool::pool_holder_offset_in_bytes(), O1);
-    __ ld_ptr(O1, mirror_offset, O1);
+    __ load_mirror(O1, Lmethod);
 #ifdef ASSERT
     if (!PrintSignatureHandlers)  // do not dirty the output with this
     { Label L;
diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
index 93c8d40..88ac31e 100644
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
@@ -49,9 +49,11 @@
   AllocatePrefetchDistance = allocate_prefetch_distance();
   AllocatePrefetchStyle    = allocate_prefetch_style();
 
-  if (AllocatePrefetchStyle == 3 && !has_blk_init()) {
-    warning("BIS instructions are not available on this CPU");
-    FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
+  if (!has_blk_init() || cache_line_size <= 0) {
+    if (AllocatePrefetchInstr == 1) {
+      warning("BIS instructions required for AllocatePrefetchInstr 1 unavailable");
+      FLAG_SET_DEFAULT(AllocatePrefetchInstr, 0);
+    }
   }
 
   UseSSE = 0; // Only on x86 and x64
@@ -85,14 +87,16 @@
       FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
     }
     if (is_niagara_plus()) {
-      if (has_blk_init() && UseTLAB &&
+      if (has_blk_init() && (cache_line_size > 0) && UseTLAB &&
           FLAG_IS_DEFAULT(AllocatePrefetchInstr)) {
         // Use BIS instruction for TLAB allocation prefetch.
-        FLAG_SET_ERGO(intx, AllocatePrefetchInstr, 1);
-        if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
-          FLAG_SET_ERGO(intx, AllocatePrefetchStyle, 3);
-        }
-        if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
+        FLAG_SET_DEFAULT(AllocatePrefetchInstr, 1);
+      }
+      if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
+        if (AllocatePrefetchInstr == 0) {
+          // Use different prefetch distance without BIS
+          FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256);
+        } else {
           // Use smaller prefetch distance with BIS
           FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64);
         }
@@ -107,22 +111,14 @@
           FLAG_SET_ERGO(intx, AllocateInstancePrefetchLines, AllocateInstancePrefetchLines*2);
         }
       }
-      if (AllocatePrefetchStyle != 3 && FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
-        // Use different prefetch distance without BIS
-        FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256);
-      }
-      if (AllocatePrefetchInstr == 1) {
-        // Need a space at the end of TLAB for BIS since it
-        // will fault when accessing memory outside of heap.
-
-        // +1 for rounding up to next cache line, +1 to be safe
-        int lines = AllocatePrefetchLines + 2;
-        int step_size = AllocatePrefetchStepSize;
-        int distance = AllocatePrefetchDistance;
-        _reserve_for_allocation_prefetch = (distance + step_size*lines)/(int)HeapWordSize;
-      }
     }
-#endif
+
+    if (AllocatePrefetchInstr == 1) {
+      // Use allocation prefetch style 3 because BIS instructions
+      // require aligned memory addresses.
+      FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3);
+    }
+#endif /* COMPILER2 */
   }
 
   // Use hardware population count instruction if available.
diff --git a/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp
index ed991d5..5a1f37f 100644
--- a/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -113,6 +113,8 @@
   }
   *interpreter_frame->interpreter_frame_cache_addr() =
     method->constants()->cache();
+  *interpreter_frame->interpreter_frame_mirror_addr() =
+    method->method_holder()->java_mirror();
 }
 
 #ifndef _LP64
diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
index e30a028..d65577f 100644
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
@@ -1240,6 +1240,7 @@
 void Assembler::addsd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -1250,6 +1251,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
   emit_operand(dst, src);
@@ -1599,6 +1601,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);;
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x2F);
   emit_operand(dst, src);
@@ -1607,6 +1610,7 @@
 void Assembler::comisd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x2F);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -1733,6 +1737,7 @@
 void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5A);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -1743,6 +1748,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5A);
   emit_operand(dst, src);
@@ -1827,6 +1833,15 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::cvttpd2dq(XMMRegister dst, XMMRegister src) {
+  NOT_LP64(assert(VM_Version::supports_sse2(), ""));
+  int vector_len = VM_Version::supports_avx512novl() ? AVX_512bit : AVX_128bit;
+  InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0xE6);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
 void Assembler::decl(Address dst) {
   // Don't use it directly. Use MacroAssembler::decrement() instead.
   InstructionMark im(this);
@@ -1840,6 +1855,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5E);
   emit_operand(dst, src);
@@ -1848,6 +1864,7 @@
 void Assembler::divsd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5E);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -2122,6 +2139,7 @@
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   int vector_len = VM_Version::supports_avx512novl() ? AVX_512bit : AVX_128bit;
   InstructionAttr attributes(vector_len, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x28);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -2156,6 +2174,7 @@
   NOT_LP64(assert(VM_Version::supports_sse3(), ""));
   int vector_len = VM_Version::supports_avx512novl() ? AVX_512bit : AVX_128bit;
   InstructionAttr attributes(vector_len, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x12);
   emit_int8(0xC0 | encode);
@@ -2193,6 +2212,15 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::kmovwl(KRegister dst, Address src) {
+  assert(VM_Version::supports_evex(), "");
+  InstructionMark im(this);
+  InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
+  vex_prefix(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0x90);
+  emit_operand((Register)dst, src);
+}
+
 void Assembler::kmovdl(KRegister dst, Register src) {
   assert(VM_Version::supports_avx512bw(), "");
   InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
@@ -2251,6 +2279,14 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::knotwl(KRegister dst, KRegister src) {
+  assert(VM_Version::supports_evex(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0x44);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
 // This instruction produces ZF or CF flags
 void Assembler::kortestbl(KRegister src1, KRegister src2) {
   assert(VM_Version::supports_avx512dq(), "");
@@ -2287,6 +2323,31 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+// This instruction produces ZF or CF flags
+void Assembler::ktestql(KRegister src1, KRegister src2) {
+  assert(VM_Version::supports_avx512bw(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(src1->encoding(), 0, src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0x99);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::ktestq(KRegister src1, KRegister src2) {
+  assert(VM_Version::supports_avx512bw(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(src1->encoding(), 0, src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0x99);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::ktestd(KRegister src1, KRegister src2) {
+  assert(VM_Version::supports_avx512bw(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(src1->encoding(), 0, src2->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0x99);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
 void Assembler::movb(Address dst, int imm8) {
   InstructionMark im(this);
    prefix(dst);
@@ -2423,6 +2484,7 @@
 void Assembler::evmovdqub(XMMRegister dst, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+  attributes.set_is_evex_instruction();
   int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3;
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes);
   emit_int8(0x6F);
@@ -2435,6 +2497,7 @@
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
   int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3;
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
   vex_prefix(src, 0, dst->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes);
   emit_int8(0x6F);
   emit_operand(dst, src);
@@ -2447,18 +2510,23 @@
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
   int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3;
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
   vex_prefix(dst, 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7F);
   emit_operand(src, dst);
 }
 
-void Assembler::evmovdquw(XMMRegister dst, XMMRegister src, int vector_len) {
-  assert(VM_Version::supports_evex(), "");
-  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
-  int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3;
-  int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes);
+void Assembler::evmovdqub(XMMRegister dst, KRegister mask, Address src, int vector_len) {
+  assert(VM_Version::supports_avx512vlbw(), "");
+  assert(is_vector_masking(), "");    // For stub code use only
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  vex_prefix(src, 0, dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x6F);
-  emit_int8((unsigned char)(0xC0 | encode));
+  emit_operand(dst, src);
 }
 
 void Assembler::evmovdquw(XMMRegister dst, Address src, int vector_len) {
@@ -2466,24 +2534,52 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
   int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3;
   vex_prefix(src, 0, dst->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes);
   emit_int8(0x6F);
   emit_operand(dst, src);
 }
 
+void Assembler::evmovdquw(XMMRegister dst, KRegister mask, Address src, int vector_len) {
+  assert(is_vector_masking(), "");
+  assert(VM_Version::supports_avx512vlbw(), "");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  vex_prefix(src, 0, dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
+  emit_int8(0x6F);
+  emit_operand(dst, src);
+}
+
 void Assembler::evmovdquw(Address dst, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   assert(src != xnoreg, "sanity");
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
   int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3;
   vex_prefix(dst, 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7F);
   emit_operand(src, dst);
 }
 
+void Assembler::evmovdquw(Address dst, KRegister mask, XMMRegister src, int vector_len) {
+  assert(VM_Version::supports_avx512vlbw(), "");
+  assert(src != xnoreg, "sanity");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
+  emit_int8(0x7F);
+  emit_operand(src, dst);
+}
+
 void Assembler::evmovdqul(XMMRegister dst, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
@@ -2509,8 +2605,8 @@
   assert(src != xnoreg, "sanity");
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
-  attributes.set_is_evex_instruction();
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7F);
   emit_operand(src, dst);
@@ -2529,8 +2625,8 @@
   assert(VM_Version::supports_evex(), "");
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
-  attributes.set_is_evex_instruction();
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
   vex_prefix(src, 0, dst->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x6F);
   emit_operand(dst, src);
@@ -2541,8 +2637,8 @@
   assert(src != xnoreg, "sanity");
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
-  attributes.set_is_evex_instruction();
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7F);
   emit_operand(src, dst);
@@ -2591,7 +2687,8 @@
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
-  attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_32bit);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x12);
   emit_operand(dst, src);
@@ -2622,6 +2719,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, xnoreg, src, VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7E);
   emit_operand(dst, src);
@@ -2632,6 +2730,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(src, xnoreg, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xD6);
   emit_operand(src, dst);
@@ -2656,6 +2755,7 @@
 void Assembler::movsd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x10);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -2666,6 +2766,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, xnoreg, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x10);
   emit_operand(dst, src);
@@ -2676,6 +2777,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(src, xnoreg, dst, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x11);
   emit_operand(src, dst);
@@ -2799,6 +2901,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_operand(dst, src);
@@ -2807,6 +2910,7 @@
 void Assembler::mulsd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -3161,6 +3265,16 @@
   emit_int8(imm8);
 }
 
+void Assembler::vperm2i128(XMMRegister dst,  XMMRegister nds, XMMRegister src, int imm8) {
+  assert(VM_Version::supports_avx2(), "");
+  InstructionAttr attributes(AVX_256bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8(0x46);
+  emit_int8(0xC0 | encode);
+  emit_int8(imm8);
+}
+
+
 void Assembler::pause() {
   emit_int8((unsigned char)0xF3);
   emit_int8((unsigned char)0x90);
@@ -3213,10 +3327,71 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::evpcmpgtb(KRegister kdst, XMMRegister nds, Address src, int vector_len) {
+  assert(VM_Version::supports_avx512vlbw(), "");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
+  int dst_enc = kdst->encoding();
+  vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+  emit_int8(0x64);
+  emit_operand(as_Register(dst_enc), src);
+}
+
+void Assembler::evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len) {
+  assert(is_vector_masking(), "");
+  assert(VM_Version::supports_avx512vlbw(), "");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  int dst_enc = kdst->encoding();
+  vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+  emit_int8(0x64);
+  emit_operand(as_Register(dst_enc), src);
+}
+
+void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) {
+  assert(VM_Version::supports_avx512vlbw(), "");
+  InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+  attributes.set_is_evex_instruction();
+  int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8(0x3E);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8(vcc);
+}
+
+void Assembler::evpcmpuw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) {
+  assert(is_vector_masking(), "");
+  assert(VM_Version::supports_avx512vlbw(), "");
+  InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8(0x3E);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8(vcc);
+}
+
+void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len) {
+  assert(VM_Version::supports_avx512vlbw(), "");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
+  int dst_enc = kdst->encoding();
+  vex_prefix(src, nds->encoding(), kdst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8(0x3E);
+  emit_operand(as_Register(dst_enc), src);
+  emit_int8(vcc);
+}
+
 void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vector_len) {
   assert(VM_Version::supports_avx512bw(), "");
   InstructionMark im(this);
-  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true);
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
   attributes.set_is_evex_instruction();
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
   int dst_enc = kdst->encoding();
@@ -3225,6 +3400,19 @@
   emit_operand(as_Register(dst_enc), src);
 }
 
+void Assembler::evpcmpeqb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len) {
+  assert(VM_Version::supports_avx512vlbw(), "");
+  assert(is_vector_masking(), "");    // For stub code use only
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_reg_mask */ false, /* uses_vl */ false);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  vex_prefix(src, nds->encoding(), kdst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+  emit_int8(0x74);
+  emit_operand(as_Register(kdst->encoding()), src);
+}
+
 // In this context, the dst vector contains the components that are equal, non equal components are zeroed in dst
 void Assembler::pcmpeqw(XMMRegister dst, XMMRegister src) {
   assert(VM_Version::supports_sse2(), "");
@@ -3525,6 +3713,46 @@
   emit_operand(dst, src);
 }
 
+void Assembler::evpmovzxbw(XMMRegister dst, KRegister mask, Address src, int vector_len) {
+  assert(is_vector_masking(), "");
+  assert(VM_Version::supports_avx512vlbw(), "");
+  assert(dst != xnoreg, "sanity");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_HVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+  emit_int8(0x30);
+  emit_operand(dst, src);
+}
+
+void Assembler::evpmovwb(Address dst, XMMRegister src, int vector_len) {
+  assert(VM_Version::supports_avx512vlbw(), "");
+  assert(src != xnoreg, "sanity");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_HVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_is_evex_instruction();
+  vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes);
+  emit_int8(0x30);
+  emit_operand(src, dst);
+}
+
+void Assembler::evpmovwb(Address dst, KRegister mask, XMMRegister src, int vector_len) {
+  assert(is_vector_masking(), "");
+  assert(VM_Version::supports_avx512vlbw(), "");
+  assert(src != xnoreg, "sanity");
+  InstructionMark im(this);
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_address_attributes(/* tuple_type */ EVEX_HVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.set_embedded_opmask_register_specifier(mask);
+  attributes.set_is_evex_instruction();
+  vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes);
+  emit_int8(0x30);
+  emit_operand(src, dst);
+}
+
 // generic
 void Assembler::pop(Register dst) {
   int encode = prefix_and_encode(dst->encoding());
@@ -3629,6 +3857,16 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::vpshufb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
+  assert(vector_len == AVX_128bit? VM_Version::supports_avx() :
+         vector_len == AVX_256bit? VM_Version::supports_avx2() :
+         0, "");
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+  int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+  emit_int8(0x00);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
 void Assembler::pshufb(XMMRegister dst, Address src) {
   assert(VM_Version::supports_ssse3(), "");
   InstructionMark im(this);
@@ -3650,6 +3888,18 @@
   emit_int8(mode & 0xFF);
 }
 
+void Assembler::vpshufd(XMMRegister dst, XMMRegister src, int mode, int vector_len) {
+  assert(vector_len == AVX_128bit? VM_Version::supports_avx() :
+         vector_len == AVX_256bit? VM_Version::supports_avx2() :
+         0, "");
+  NOT_LP64(assert(VM_Version::supports_sse2(), ""));
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+  emit_int8(0x70);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8(mode & 0xFF);
+}
+
 void Assembler::pshufd(XMMRegister dst, Address src, int mode) {
   assert(isByte(mode), "invalid value");
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
@@ -3690,7 +3940,6 @@
   // Shift left 128 bit value in dst XMMRegister by shift number of bytes.
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false);
-  // XMM3 is for /3 encoding: 66 0F 73 /3 ib
   int encode = simd_prefix_and_encode(xmm3, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x73);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -3786,6 +4035,7 @@
 void Assembler::punpcklqdq(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x6C);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -3972,6 +4222,17 @@
   emit_int8(imm8);
 }
 
+void Assembler::vpalignr(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8, int vector_len) {
+  assert(vector_len == AVX_128bit? VM_Version::supports_avx() :
+         vector_len == AVX_256bit? VM_Version::supports_avx2() :
+         0, "");
+  InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true);
+  int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8((unsigned char)0x0F);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8(imm8);
+}
+
 void Assembler::pblendw(XMMRegister dst, XMMRegister src, int imm8) {
   assert(VM_Version::supports_sse4_1(), "");
   InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
@@ -4081,6 +4342,7 @@
 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x51);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4091,6 +4353,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x51);
   emit_operand(dst, src);
@@ -4166,6 +4429,7 @@
 void Assembler::subsd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5C);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4176,6 +4440,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5C);
   emit_operand(dst, src);
@@ -4263,6 +4528,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x2E);
   emit_operand(dst, src);
@@ -4271,6 +4537,7 @@
 void Assembler::ucomisd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x2E);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4382,6 +4649,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
   emit_operand(dst, src);
@@ -4390,6 +4658,7 @@
 void Assembler::vaddsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4418,6 +4687,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5E);
   emit_operand(dst, src);
@@ -4426,6 +4696,7 @@
 void Assembler::vdivsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5E);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4454,6 +4725,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_operand(dst, src);
@@ -4462,6 +4734,7 @@
 void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4490,6 +4763,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5C);
   emit_operand(dst, src);
@@ -4498,6 +4772,7 @@
 void Assembler::vsubsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5C);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4528,6 +4803,7 @@
 void Assembler::addpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4537,6 +4813,7 @@
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
   simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
@@ -4555,6 +4832,7 @@
 void Assembler::vaddpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4573,6 +4851,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x58);
   emit_operand(dst, src);
@@ -4591,6 +4870,7 @@
 void Assembler::subpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5C);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4607,6 +4887,7 @@
 void Assembler::vsubpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5C);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4625,6 +4906,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5C);
   emit_operand(dst, src);
@@ -4643,6 +4925,7 @@
 void Assembler::mulpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4653,6 +4936,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_operand(dst, src);
@@ -4669,6 +4953,7 @@
 void Assembler::vmulpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4687,6 +4972,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x59);
   emit_operand(dst, src);
@@ -4705,6 +4991,7 @@
 void Assembler::divpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5E);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4721,6 +5008,7 @@
 void Assembler::vdivpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5E);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4739,6 +5027,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x5E);
   emit_operand(dst, src);
@@ -4757,6 +5046,7 @@
 void Assembler::vsqrtpd(XMMRegister dst, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x51);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4767,6 +5057,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x51);
   emit_operand(dst, src);
@@ -4775,6 +5066,7 @@
 void Assembler::andpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x54);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4803,6 +5095,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x54);
   emit_operand(dst, src);
@@ -4811,6 +5104,7 @@
 void Assembler::vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x54);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4829,6 +5123,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x54);
   emit_operand(dst, src);
@@ -4847,6 +5142,7 @@
 void Assembler::unpckhpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x15);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4855,6 +5151,7 @@
 void Assembler::unpcklpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x14);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4863,6 +5160,7 @@
 void Assembler::xorpd(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x57);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4881,6 +5179,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x57);
   emit_operand(dst, src);
@@ -4899,6 +5198,7 @@
 void Assembler::vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x57);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -4917,6 +5217,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x57);
   emit_operand(dst, src);
@@ -4987,13 +5288,14 @@
 void Assembler::paddq(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xD4);
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
 void Assembler::phaddw(XMMRegister dst, XMMRegister src) {
-  NOT_LP64(assert(VM_Version::supports_sse3(), ""));
+  assert(VM_Version::supports_sse3(), "");
   InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x01);
@@ -5001,7 +5303,7 @@
 }
 
 void Assembler::phaddd(XMMRegister dst, XMMRegister src) {
-  NOT_LP64(assert(VM_Version::supports_sse3(), ""));
+  assert(VM_Version::supports_sse3(), "");
   InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x02);
@@ -5035,6 +5337,7 @@
 void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(UseAVX > 0, "requires some form of AVX");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xD4);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5075,6 +5378,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xD4);
   emit_operand(dst, src);
@@ -5106,6 +5410,7 @@
 void Assembler::psubq(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xFB);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5138,6 +5443,7 @@
 void Assembler::vpsubq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(UseAVX > 0, "requires some form of AVX");
   InstructionAttr attributes(vector_len, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xFB);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5178,6 +5484,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xFB);
   emit_operand(dst, src);
@@ -5216,8 +5523,9 @@
 }
 
 void Assembler::vpmullq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
-  assert(UseAVX > 2, "requires some form of AVX");
-  InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
+  assert(UseAVX > 2, "requires some form of EVEX");
+  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_is_evex_instruction();
   int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x40);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5244,10 +5552,11 @@
 }
 
 void Assembler::vpmullq(XMMRegister dst, XMMRegister nds, Address src, int vector_len) {
-  assert(UseAVX > 0, "requires some form of AVX");
+  assert(UseAVX > 2, "requires some form of EVEX");
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_is_evex_instruction();
   vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x40);
   emit_operand(dst, src);
@@ -5303,6 +5612,7 @@
 void Assembler::psllq(XMMRegister dst, XMMRegister shift) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xF3);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5332,6 +5642,7 @@
 void Assembler::vpsllq(XMMRegister dst, XMMRegister src, int shift, int vector_len) {
   assert(UseAVX > 0, "requires some form of AVX");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   // XMM6 is for /6 encoding: 66 0F 73 /6 ib
   int encode = vex_prefix_and_encode(xmm6->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x73);
@@ -5358,6 +5669,7 @@
 void Assembler::vpsllq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) {
   assert(UseAVX > 0, "requires some form of AVX");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), src->encoding(), shift->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xF3);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5389,6 +5701,7 @@
   // shifts 128 bit value in xmm register by number of bytes.
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   // XMM2 is for /2 encoding: 66 0F 73 /2 ib
   int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x73);
@@ -5415,6 +5728,7 @@
 void Assembler::psrlq(XMMRegister dst, XMMRegister shift) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xD3);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5443,6 +5757,7 @@
 void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, int shift, int vector_len) {
   assert(UseAVX > 0, "requires some form of AVX");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   // XMM2 is for /2 encoding: 66 0F 73 /2 ib
   int encode = vex_prefix_and_encode(xmm2->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x73);
@@ -5469,6 +5784,7 @@
 void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) {
   assert(UseAVX > 0, "requires some form of AVX");
   InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), src->encoding(), shift->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xD3);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5578,6 +5894,7 @@
 void Assembler::pandn(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8((unsigned char)0xDF);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5867,9 +6184,9 @@
 }
 
 void Assembler::vextracti64x2(XMMRegister dst, XMMRegister src, uint8_t imm8) {
-  assert(VM_Version::supports_evex(), "");
+  assert(VM_Version::supports_avx512dq(), "");
   assert(imm8 <= 0x03, "imm8: %u", imm8);
-  InstructionAttr attributes(AVX_512bit, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x39);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -5957,9 +6274,9 @@
 }
 
 void Assembler::vextractf64x2(XMMRegister dst, XMMRegister src, uint8_t imm8) {
-  assert(VM_Version::supports_evex(), "");
+  assert(VM_Version::supports_avx512dq(), "");
   assert(imm8 <= 0x03, "imm8: %u", imm8);
-  InstructionAttr attributes(AVX_512bit, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x19);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -6084,7 +6401,8 @@
 // duplicate 8-byte integer data from src into programmed locations in dest : requires AVX512VL
 void Assembler::evpbroadcastq(XMMRegister dst, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
-  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x59);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -6094,7 +6412,8 @@
   assert(VM_Version::supports_evex(), "");
   assert(dst != xnoreg, "sanity");
   InstructionMark im(this);
-  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
   // swap src<->dst for encoding
   vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
@@ -6129,7 +6448,8 @@
 // duplicate double precision data from src into programmed locations in dest : requires AVX512VL
 void Assembler::evpbroadcastsd(XMMRegister dst, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
-  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_rex_vex_w_reverted();
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x19);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -6139,8 +6459,9 @@
   assert(VM_Version::supports_evex(), "");
   assert(dst != xnoreg, "sanity");
   InstructionMark im(this);
-  InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.set_rex_vex_w_reverted();
   // swap src<->dst for encoding
   vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x19);
@@ -6154,12 +6475,9 @@
 void Assembler::evpbroadcastb(XMMRegister dst, Register src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+  attributes.set_is_evex_instruction();
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
-  if (attributes.is_evex_instruction()) {
-    emit_int8(0x7A);
-  } else {
-    emit_int8(0x78);
-  }
+  emit_int8(0x7A);
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
@@ -6167,12 +6485,9 @@
 void Assembler::evpbroadcastw(XMMRegister dst, Register src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+  attributes.set_is_evex_instruction();
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
-  if (attributes.is_evex_instruction()) {
-    emit_int8(0x7B);
-  } else {
-    emit_int8(0x79);
-  }
+  emit_int8(0x7B);
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
@@ -6180,12 +6495,9 @@
 void Assembler::evpbroadcastd(XMMRegister dst, Register src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_is_evex_instruction();
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
-  if (attributes.is_evex_instruction()) {
-    emit_int8(0x7C);
-  } else {
-    emit_int8(0x58);
-  }
+  emit_int8(0x7C);
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
@@ -6193,12 +6505,9 @@
 void Assembler::evpbroadcastq(XMMRegister dst, Register src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.set_is_evex_instruction();
   int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
-  if (attributes.is_evex_instruction()) {
-    emit_int8(0x7C);
-  } else {
-    emit_int8(0x59);
-  }
+  emit_int8(0x7C);
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
@@ -6230,7 +6539,6 @@
   emit_int8(0x77);
 }
 
-
 #ifndef _LP64
 // 32bit only pieces of the assembler
 
@@ -6797,7 +7105,10 @@
   emit_int8(byte3);
 
   // P2: byte 4 as zL'Lbv'aaa
-  int byte4 = (_attributes->is_no_reg_mask()) ? 0 : 1; // kregs are implemented in the low 3 bits as aaa (hard code k1, it will be initialized for now)
+  // kregs are implemented in the low 3 bits as aaa (hard code k1, it will be initialized for now)
+  int byte4 = (_attributes->is_no_reg_mask()) ?
+              0 :
+              _attributes->get_embedded_opmask_register_specifier();
   // EVEX.v` for extending EVEX.vvvv or VIDX
   byte4 |= (evex_v ? 0: EVEX_V);
   // third EXEC.b for broadcast actions
@@ -6853,6 +7164,9 @@
     attributes->set_is_evex_instruction();
     evex_prefix(vex_r, vex_b, vex_x, evex_r, evex_v, nds_enc, pre, opc);
   } else {
+    if (UseAVX > 2 && attributes->is_rex_vex_w_reverted()) {
+      attributes->set_rex_vex_w(false);
+    }
     vex_prefix(vex_r, vex_b, vex_x, nds_enc, pre, opc);
   }
 }
@@ -6912,6 +7226,9 @@
     attributes->set_is_evex_instruction();
     evex_prefix(vex_r, vex_b, vex_x, evex_r, evex_v, nds_enc, pre, opc);
   } else {
+    if (UseAVX > 2 && attributes->is_rex_vex_w_reverted()) {
+      attributes->set_rex_vex_w(false);
+    }
     vex_prefix(vex_r, vex_b, vex_x, nds_enc, pre, opc);
   }
 
@@ -6966,6 +7283,21 @@
   emit_int8((unsigned char)(0xF0 & src2_enc<<4));
 }
 
+void Assembler::shlxl(Register dst, Register src1, Register src2) {
+  assert(VM_Version::supports_bmi2(), "");
+  InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), src2->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xF7);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::shlxq(Register dst, Register src1, Register src2) {
+  assert(VM_Version::supports_bmi2(), "");
+  InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), src2->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xF7);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
 
 #ifndef _LP64
 
@@ -8185,6 +8517,15 @@
   emit_int8(imm8);
 }
 
+void Assembler::rorxd(Register dst, Register src, int imm8) {
+  assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported");
+  InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8((unsigned char)0xF0);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8(imm8);
+}
+
 void Assembler::sarq(Register dst, int imm8) {
   assert(isShiftCount(imm8 >> 1), "illegal shift count");
   int encode = prefixq_and_encode(dst->encoding());
diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp
index fd3053d..5616538 100644
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp
@@ -587,6 +587,16 @@
 #endif
   };
 
+  enum ComparisonPredicate {
+    eq = 0,
+    lt = 1,
+    le = 2,
+    _false = 3,
+    neq = 4,
+    nlt = 5,
+    nle = 6,
+    _true = 7
+  };
 
 
   // NOTE: The general philopsophy of the declarations here is that 64bit versions
@@ -606,6 +616,7 @@
   bool _legacy_mode_vl;
   bool _legacy_mode_vlbw;
   bool _is_managed;
+  bool _vector_masking;    // For stub code use only
 
   class InstructionAttr *_attributes;
 
@@ -813,6 +824,7 @@
     _legacy_mode_vl = (VM_Version::supports_avx512vl() == false);
     _legacy_mode_vlbw = (VM_Version::supports_avx512vlbw() == false);
     _is_managed = false;
+    _vector_masking = false;
     _attributes = NULL;
   }
 
@@ -823,6 +835,11 @@
   void clear_managed(void) { _is_managed = false; }
   bool is_managed(void) { return _is_managed; }
 
+  // Following functions are for stub code use only
+  void set_vector_masking(void) { _vector_masking = true; }
+  void clear_vector_masking(void) { _vector_masking = false; }
+  bool is_vector_masking(void) { return _vector_masking; }
+
   void lea(Register dst, Address src);
 
   void mov(Register dst, Register src);
@@ -1048,6 +1065,8 @@
   void cvttss2sil(Register dst, XMMRegister src);
   void cvttss2siq(Register dst, XMMRegister src);
 
+  void cvttpd2dq(XMMRegister dst, XMMRegister src);
+
   // Divide Scalar Double-Precision Floating-Point Values
   void divsd(XMMRegister dst, Address src);
   void divsd(XMMRegister dst, XMMRegister src);
@@ -1335,6 +1354,7 @@
   void kmovbl(KRegister dst, Register src);
   void kmovbl(Register dst, KRegister src);
   void kmovwl(KRegister dst, Register src);
+  void kmovwl(KRegister dst, Address src);
   void kmovwl(Register dst, KRegister src);
   void kmovdl(KRegister dst, Register src);
   void kmovdl(Register dst, KRegister src);
@@ -1344,11 +1364,18 @@
   void kmovql(KRegister dst, Register src);
   void kmovql(Register dst, KRegister src);
 
+  void knotwl(KRegister dst, KRegister src);
+
   void kortestbl(KRegister dst, KRegister src);
   void kortestwl(KRegister dst, KRegister src);
   void kortestdl(KRegister dst, KRegister src);
   void kortestql(KRegister dst, KRegister src);
 
+  void ktestq(KRegister src1, KRegister src2);
+  void ktestd(KRegister src1, KRegister src2);
+
+  void ktestql(KRegister dst, KRegister src);
+
   void movdl(XMMRegister dst, Register src);
   void movdl(Register dst, XMMRegister src);
   void movdl(XMMRegister dst, Address src);
@@ -1376,9 +1403,11 @@
   void evmovdqub(Address dst, XMMRegister src, int vector_len);
   void evmovdqub(XMMRegister dst, Address src, int vector_len);
   void evmovdqub(XMMRegister dst, XMMRegister src, int vector_len);
+  void evmovdqub(XMMRegister dst, KRegister mask, Address src, int vector_len);
   void evmovdquw(Address dst, XMMRegister src, int vector_len);
+  void evmovdquw(Address dst, KRegister mask, XMMRegister src, int vector_len);
   void evmovdquw(XMMRegister dst, Address src, int vector_len);
-  void evmovdquw(XMMRegister dst, XMMRegister src, int vector_len);
+  void evmovdquw(XMMRegister dst, KRegister mask, Address src, int vector_len);
   void evmovdqul(Address dst, XMMRegister src, int vector_len);
   void evmovdqul(XMMRegister dst, Address src, int vector_len);
   void evmovdqul(XMMRegister dst, XMMRegister src, int vector_len);
@@ -1517,6 +1546,7 @@
   // Pemutation of 64bit words
   void vpermq(XMMRegister dst, XMMRegister src, int imm8, int vector_len);
   void vpermq(XMMRegister dst, XMMRegister src, int imm8);
+  void vperm2i128(XMMRegister dst,  XMMRegister nds, XMMRegister src, int imm8);
 
   void pause();
 
@@ -1528,6 +1558,14 @@
   void vpcmpeqb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
   void evpcmpeqb(KRegister kdst, XMMRegister nds, XMMRegister src, int vector_len);
   void evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vector_len);
+  void evpcmpeqb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len);
+
+  void evpcmpgtb(KRegister kdst, XMMRegister nds, Address src, int vector_len);
+  void evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len);
+
+  void evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len);
+  void evpcmpuw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, ComparisonPredicate of, int vector_len);
+  void evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len);
 
   void pcmpeqw(XMMRegister dst, XMMRegister src);
   void vpcmpeqw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
@@ -1571,7 +1609,11 @@
   void pmovzxbw(XMMRegister dst, XMMRegister src);
   void pmovzxbw(XMMRegister dst, Address src);
 
-  void vpmovzxbw(XMMRegister dst, Address src, int vector_len);
+  void vpmovzxbw( XMMRegister dst, Address src, int vector_len);
+  void evpmovzxbw(XMMRegister dst, KRegister mask, Address src, int vector_len);
+
+  void evpmovwb(Address dst, XMMRegister src, int vector_len);
+  void evpmovwb(Address dst, KRegister mask, XMMRegister src, int vector_len);
 
 #ifndef _LP64 // no 32bit push/pop on amd64
   void popl(Address dst);
@@ -1601,10 +1643,12 @@
   // Shuffle Bytes
   void pshufb(XMMRegister dst, XMMRegister src);
   void pshufb(XMMRegister dst, Address src);
+  void vpshufb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
 
   // Shuffle Packed Doublewords
   void pshufd(XMMRegister dst, XMMRegister src, int mode);
   void pshufd(XMMRegister dst, Address src,     int mode);
+  void vpshufd(XMMRegister dst, XMMRegister src, int mode, int vector_len);
 
   // Shuffle Packed Low Words
   void pshuflw(XMMRegister dst, XMMRegister src, int mode);
@@ -1656,6 +1700,7 @@
 #ifdef _LP64
   void rorq(Register dst, int imm8);
   void rorxq(Register dst, Register src, int imm8);
+  void rorxd(Register dst, Register src, int imm8);
 #endif
 
   void sahf();
@@ -1679,6 +1724,8 @@
   void setb(Condition cc, Register dst);
 
   void palignr(XMMRegister dst, XMMRegister src, int imm8);
+  void vpalignr(XMMRegister dst, XMMRegister src1, XMMRegister src2, int imm8, int vector_len);
+
   void pblendw(XMMRegister dst, XMMRegister src, int imm8);
 
   void sha1rnds4(XMMRegister dst, XMMRegister src, int imm8);
@@ -1816,6 +1863,8 @@
   void vsubss(XMMRegister dst, XMMRegister nds, Address src);
   void vsubss(XMMRegister dst, XMMRegister nds, XMMRegister src);
 
+  void shlxl(Register dst, Register src1, Register src2);
+  void shlxq(Register dst, Register src1, Register src2);
 
   //====================VECTOR ARITHMETIC=====================================
 
@@ -2050,7 +2099,6 @@
   void cmppd(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len);
   void vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len);
 
-
  protected:
   // Next instructions require address alignment 16 bytes SSE mode.
   // They should be called only from corresponding MacroAssembler instructions.
@@ -2075,6 +2123,7 @@
     :
       _avx_vector_len(vector_len),
       _rex_vex_w(rex_vex_w),
+      _rex_vex_w_reverted(false),
       _legacy_mode(legacy_mode),
       _no_reg_mask(no_reg_mask),
       _uses_vl(uses_vl),
@@ -2084,7 +2133,8 @@
       _evex_encoding(0),
       _is_clear_context(false),
       _is_extended_context(false),
-      _current_assembler(NULL) {
+      _current_assembler(NULL),
+      _embedded_opmask_register_specifier(1) { // hard code k1, it will be initialized for now
     if (UseAVX < 3) _legacy_mode = true;
   }
 
@@ -2098,6 +2148,7 @@
 private:
   int  _avx_vector_len;
   bool _rex_vex_w;
+  bool _rex_vex_w_reverted;
   bool _legacy_mode;
   bool _no_reg_mask;
   bool _uses_vl;
@@ -2107,6 +2158,7 @@
   int  _evex_encoding;
   bool _is_clear_context;
   bool _is_extended_context;
+  int _embedded_opmask_register_specifier;
 
   Assembler *_current_assembler;
 
@@ -2114,6 +2166,7 @@
   // query functions for field accessors
   int  get_vector_len(void) const { return _avx_vector_len; }
   bool is_rex_vex_w(void) const { return _rex_vex_w; }
+  bool is_rex_vex_w_reverted(void) { return _rex_vex_w_reverted; }
   bool is_legacy_mode(void) const { return _legacy_mode; }
   bool is_no_reg_mask(void) const { return _no_reg_mask; }
   bool uses_vl(void) const { return _uses_vl; }
@@ -2123,10 +2176,17 @@
   int  get_evex_encoding(void) const { return _evex_encoding; }
   bool is_clear_context(void) const { return _is_clear_context; }
   bool is_extended_context(void) const { return _is_extended_context; }
+  int get_embedded_opmask_register_specifier(void) const { return _embedded_opmask_register_specifier; }
 
   // Set the vector len manually
   void set_vector_len(int vector_len) { _avx_vector_len = vector_len; }
 
+  // Set revert rex_vex_w for avx encoding
+  void set_rex_vex_w_reverted(void) { _rex_vex_w_reverted = true; }
+
+  // Set rex_vex_w based on state
+  void set_rex_vex_w(bool state) { _rex_vex_w = state; }
+
   // Set the instruction to be encoded in AVX mode
   void set_is_legacy_mode(void) { _legacy_mode = true; }
 
@@ -2150,6 +2210,11 @@
     }
   }
 
+  // Set embedded opmask register specifier.
+  void set_embedded_opmask_register_specifier(KRegister mask) {
+    _embedded_opmask_register_specifier = (*mask).encoding() & 0x7;
+  }
+
 };
 
 #endif // CPU_X86_VM_ASSEMBLER_X86_HPP
diff --git a/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp b/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp
index 3fbd57c..6d91d19 100644
--- a/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -169,18 +169,18 @@
 
 intArray* FpuStackSim::write_state() {
   intArray* res = new intArray(1 + FrameMap::nof_fpu_regs);
-  (*res)[0] = stack_size();
+  res->append(stack_size());
   for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
-    (*res)[1 + i] = regs_at(i);
+    res->append(regs_at(i));
   }
   return res;
 }
 
 
 void FpuStackSim::read_state(intArray* fpu_stack_state) {
-  _stack_size = (*fpu_stack_state)[0];
+  _stack_size = fpu_stack_state->at(0);
   for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
-    set_regs_at(i, (*fpu_stack_state)[1 + i]);
+    set_regs_at(i, fpu_stack_state->at(1 + i));
   }
 }
 
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
index c23ebaa..3a9bf0a 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
@@ -2365,13 +2365,8 @@
   } else if (value->is_double_fpu()) {
     assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS");
     switch(code) {
-      case lir_log10 : __ flog10() ; break;
       case lir_abs   : __ fabs() ; break;
       case lir_sqrt  : __ fsqrt(); break;
-      case lir_tan :
-        // Should consider not saving rbx, if not necessary
-        __ trigfunc('t', op->as_Op2()->fpu_stack_size());
-        break;
       default      : ShouldNotReachHere();
     }
   } else {
@@ -3886,6 +3881,10 @@
   __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
 }
 
+void LIR_Assembler::on_spin_wait() {
+  __ pause ();
+}
+
 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
   assert(result_reg->is_register(), "check");
 #ifdef _LP64
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
index 20c1932..26488c9 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -813,7 +813,8 @@
 
   if (x->id() == vmIntrinsics::_dexp || x->id() == vmIntrinsics::_dlog ||
       x->id() == vmIntrinsics::_dpow || x->id() == vmIntrinsics::_dcos ||
-      x->id() == vmIntrinsics::_dsin) {
+      x->id() == vmIntrinsics::_dsin || x->id() == vmIntrinsics::_dtan ||
+      x->id() == vmIntrinsics::_dlog10) {
     do_LibmIntrinsic(x);
     return;
   }
@@ -821,58 +822,17 @@
   LIRItem value(x->argument_at(0), this);
 
   bool use_fpu = false;
-  if (UseSSE >= 2) {
-    switch(x->id()) {
-      case vmIntrinsics::_dtan:
-      case vmIntrinsics::_dlog10:
-        use_fpu = true;
-        break;
-    }
-  } else {
+  if (UseSSE < 2) {
     value.set_destroys_register();
   }
-
   value.load_item();
 
   LIR_Opr calc_input = value.result();
-  LIR_Opr calc_input2 = NULL;
-  if (x->id() == vmIntrinsics::_dpow) {
-    LIRItem extra_arg(x->argument_at(1), this);
-    if (UseSSE < 2) {
-      extra_arg.set_destroys_register();
-    }
-    extra_arg.load_item();
-    calc_input2 = extra_arg.result();
-  }
   LIR_Opr calc_result = rlock_result(x);
 
-  // sin, cos, pow and exp need two free fpu stack slots, so register
-  // two temporary operands
-  LIR_Opr tmp1 = FrameMap::caller_save_fpu_reg_at(0);
-  LIR_Opr tmp2 = FrameMap::caller_save_fpu_reg_at(1);
-
-  if (use_fpu) {
-    LIR_Opr tmp = FrameMap::fpu0_double_opr;
-    int tmp_start = 1;
-    if (calc_input2 != NULL) {
-      __ move(calc_input2, tmp);
-      tmp_start = 2;
-      calc_input2 = tmp;
-    }
-    __ move(calc_input, tmp);
-
-    calc_input = tmp;
-    calc_result = tmp;
-
-    tmp1 = FrameMap::caller_save_fpu_reg_at(tmp_start);
-    tmp2 = FrameMap::caller_save_fpu_reg_at(tmp_start + 1);
-  }
-
   switch(x->id()) {
     case vmIntrinsics::_dabs:   __ abs  (calc_input, calc_result, LIR_OprFact::illegalOpr); break;
     case vmIntrinsics::_dsqrt:  __ sqrt (calc_input, calc_result, LIR_OprFact::illegalOpr); break;
-    case vmIntrinsics::_dtan:   __ tan  (calc_input, calc_result, tmp1, tmp2);              break;
-    case vmIntrinsics::_dlog10: __ log10(calc_input, calc_result, tmp1);                    break;
     default:                    ShouldNotReachHere();
   }
 
@@ -913,21 +873,28 @@
   result_reg = tmp;
   switch(x->id()) {
     case vmIntrinsics::_dexp:
-      if (VM_Version::supports_sse2()) {
+      if (StubRoutines::dexp() != NULL) {
         __ call_runtime_leaf(StubRoutines::dexp(), getThreadTemp(), result_reg, cc->args());
       } else {
         __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dexp), getThreadTemp(), result_reg, cc->args());
       }
       break;
     case vmIntrinsics::_dlog:
-      if (VM_Version::supports_sse2()) {
+      if (StubRoutines::dlog() != NULL) {
         __ call_runtime_leaf(StubRoutines::dlog(), getThreadTemp(), result_reg, cc->args());
       } else {
         __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog), getThreadTemp(), result_reg, cc->args());
       }
       break;
+    case vmIntrinsics::_dlog10:
+      if (StubRoutines::dlog10() != NULL) {
+       __ call_runtime_leaf(StubRoutines::dlog10(), getThreadTemp(), result_reg, cc->args());
+      } else {
+        __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10), getThreadTemp(), result_reg, cc->args());
+      }
+      break;
     case vmIntrinsics::_dpow:
-      if (VM_Version::supports_sse2()) {
+      if (StubRoutines::dpow() != NULL) {
         __ call_runtime_leaf(StubRoutines::dpow(), getThreadTemp(), result_reg, cc->args());
       } else {
         __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dpow), getThreadTemp(), result_reg, cc->args());
@@ -947,18 +914,44 @@
         __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dcos), getThreadTemp(), result_reg, cc->args());
       }
       break;
+    case vmIntrinsics::_dtan:
+      if (StubRoutines::dtan() != NULL) {
+        __ call_runtime_leaf(StubRoutines::dtan(), getThreadTemp(), result_reg, cc->args());
+      } else {
+        __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtan), getThreadTemp(), result_reg, cc->args());
+      }
+      break;
     default:  ShouldNotReachHere();
   }
 #else
   switch (x->id()) {
     case vmIntrinsics::_dexp:
-      __ call_runtime_leaf(StubRoutines::dexp(), getThreadTemp(), result_reg, cc->args());
+      if (StubRoutines::dexp() != NULL) {
+        __ call_runtime_leaf(StubRoutines::dexp(), getThreadTemp(), result_reg, cc->args());
+      } else {
+        __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dexp), getThreadTemp(), result_reg, cc->args());
+      }
       break;
     case vmIntrinsics::_dlog:
+      if (StubRoutines::dlog() != NULL) {
       __ call_runtime_leaf(StubRoutines::dlog(), getThreadTemp(), result_reg, cc->args());
+      } else {
+        __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog), getThreadTemp(), result_reg, cc->args());
+      }
+      break;
+    case vmIntrinsics::_dlog10:
+      if (StubRoutines::dlog10() != NULL) {
+      __ call_runtime_leaf(StubRoutines::dlog10(), getThreadTemp(), result_reg, cc->args());
+      } else {
+        __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10), getThreadTemp(), result_reg, cc->args());
+      }
       break;
     case vmIntrinsics::_dpow:
+       if (StubRoutines::dpow() != NULL) {
       __ call_runtime_leaf(StubRoutines::dpow(), getThreadTemp(), result_reg, cc->args());
+      } else {
+        __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dpow), getThreadTemp(), result_reg, cc->args());
+      }
       break;
     case vmIntrinsics::_dsin:
       if (StubRoutines::dsin() != NULL) {
@@ -974,6 +967,13 @@
         __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dcos), getThreadTemp(), result_reg, cc->args());
       }
       break;
+    case vmIntrinsics::_dtan:
+       if (StubRoutines::dtan() != NULL) {
+      __ call_runtime_leaf(StubRoutines::dtan(), getThreadTemp(), result_reg, cc->args());
+      } else {
+        __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtan), getThreadTemp(), result_reg, cc->args());
+      }
+      break;
     default:  ShouldNotReachHere();
   }
 #endif // _LP64
@@ -1109,6 +1109,87 @@
   }
 }
 
+void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
+  Unimplemented();
+}
+
+void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
+  assert(UseVectorizedMismatchIntrinsic, "need AVX instruction support");
+
+  // Make all state_for calls early since they can emit code
+  LIR_Opr result = rlock_result(x);
+
+  LIRItem a(x->argument_at(0), this); // Object
+  LIRItem aOffset(x->argument_at(1), this); // long
+  LIRItem b(x->argument_at(2), this); // Object
+  LIRItem bOffset(x->argument_at(3), this); // long
+  LIRItem length(x->argument_at(4), this); // int
+  LIRItem log2ArrayIndexScale(x->argument_at(5), this); // int
+
+  a.load_item();
+  aOffset.load_nonconstant();
+  b.load_item();
+  bOffset.load_nonconstant();
+
+  long constant_aOffset = 0;
+  LIR_Opr result_aOffset = aOffset.result();
+  if (result_aOffset->is_constant()) {
+    constant_aOffset = result_aOffset->as_jlong();
+    result_aOffset = LIR_OprFact::illegalOpr;
+  }
+  LIR_Opr result_a = a.result();
+
+  long constant_bOffset = 0;
+  LIR_Opr result_bOffset = bOffset.result();
+  if (result_bOffset->is_constant()) {
+    constant_bOffset = result_bOffset->as_jlong();
+    result_bOffset = LIR_OprFact::illegalOpr;
+  }
+  LIR_Opr result_b = b.result();
+
+#ifndef _LP64
+  result_a = new_register(T_INT);
+  __ convert(Bytecodes::_l2i, a.result(), result_a);
+  result_b = new_register(T_INT);
+  __ convert(Bytecodes::_l2i, b.result(), result_b);
+#endif
+
+
+  LIR_Address* addr_a = new LIR_Address(result_a,
+                                        result_aOffset,
+                                        LIR_Address::times_1,
+                                        constant_aOffset,
+                                        T_BYTE);
+
+  LIR_Address* addr_b = new LIR_Address(result_b,
+                                        result_bOffset,
+                                        LIR_Address::times_1,
+                                        constant_bOffset,
+                                        T_BYTE);
+
+  BasicTypeList signature(4);
+  signature.append(T_ADDRESS);
+  signature.append(T_ADDRESS);
+  signature.append(T_INT);
+  signature.append(T_INT);
+  CallingConvention* cc = frame_map()->c_calling_convention(&signature);
+  const LIR_Opr result_reg = result_register_for(x->type());
+
+  LIR_Opr ptr_addr_a = new_pointer_register();
+  __ leal(LIR_OprFact::address(addr_a), ptr_addr_a);
+
+  LIR_Opr ptr_addr_b = new_pointer_register();
+  __ leal(LIR_OprFact::address(addr_b), ptr_addr_b);
+
+  __ move(ptr_addr_a, cc->at(0));
+  __ move(ptr_addr_b, cc->at(1));
+  length.load_item_force(cc->at(2));
+  log2ArrayIndexScale.load_item_force(cc->at(3));
+
+  __ call_runtime_leaf(StubRoutines::vectorizedMismatch(), getThreadTemp(), result_reg, cc->args());
+  __ move(result_reg, result);
+}
+
 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
 // _i2b, _i2c, _i2s
 LIR_Opr fixed_register_for(BasicType type) {
@@ -1261,7 +1342,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp
index c310872..5c41181 100644
--- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp
@@ -67,7 +67,7 @@
       //       register information would be incorrect.
       if (b->number_of_preds() > 1) {
         int id = b->first_lir_instruction_id();
-        BitMap regs(FrameMap::nof_fpu_regs);
+        ResourceBitMap regs(FrameMap::nof_fpu_regs);
         regs.clear();
 
         iw.walk_to(id);   // walk after the first instruction (always a label) of the block
@@ -786,58 +786,6 @@
       break;
     }
 
-    case lir_log10: {
-      // log and log10 need one temporary fpu stack slot, so
-      // there is one temporary registers stored in temp of the
-      // operation. the stack allocator must guarantee that the stack
-      // slots are really free, otherwise there might be a stack
-      // overflow.
-      assert(right->is_illegal(), "must be");
-      assert(left->is_fpu_register(), "must be");
-      assert(res->is_fpu_register(), "must be");
-      assert(op2->tmp1_opr()->is_fpu_register(), "must be");
-
-      insert_free_if_dead(op2->tmp1_opr());
-      insert_free_if_dead(res, left);
-      insert_exchange(left);
-      do_rename(left, res);
-
-      new_left = to_fpu_stack_top(res);
-      new_res = new_left;
-
-      op2->set_fpu_stack_size(sim()->stack_size());
-      assert(sim()->stack_size() <= 7, "at least one stack slot must be free");
-      break;
-    }
-
-
-    case lir_tan: {
-      // sin, cos and exp need two temporary fpu stack slots, so there are two temporary
-      // registers (stored in right and temp of the operation).
-      // the stack allocator must guarantee that the stack slots are really free,
-      // otherwise there might be a stack overflow.
-      assert(left->is_fpu_register(), "must be");
-      assert(res->is_fpu_register(), "must be");
-      // assert(left->is_last_use(), "old value gets destroyed");
-      assert(right->is_fpu_register(), "right is used as the first temporary register");
-      assert(op2->tmp1_opr()->is_fpu_register(), "temp is used as the second temporary register");
-      assert(fpu_num(left) != fpu_num(right) && fpu_num(right) != fpu_num(op2->tmp1_opr()) && fpu_num(op2->tmp1_opr()) != fpu_num(res), "need distinct temp registers");
-
-      insert_free_if_dead(right);
-      insert_free_if_dead(op2->tmp1_opr());
-
-      insert_free_if_dead(res, left);
-      insert_exchange(left);
-      do_rename(left, res);
-
-      new_left = to_fpu_stack_top(res);
-      new_res = new_left;
-
-      op2->set_fpu_stack_size(sim()->stack_size());
-      assert(sim()->stack_size() <= 6, "at least two stack slots must be free");
-      break;
-    }
-
     default: {
       assert(false, "missed a fpu-operation");
     }
@@ -1121,7 +1069,7 @@
       // clean up stack first so that there are no dead values on the stack
       if (ComputeExactFPURegisterUsage) {
         FpuStackSim* cur_sim = sim();
-        BitMap live_fpu_regs = block->sux_at(0)->fpu_register_usage();
+        ResourceBitMap live_fpu_regs = block->sux_at(0)->fpu_register_usage();
         assert(live_fpu_regs.size() == FrameMap::nof_fpu_regs, "missing register usage");
 
         merge_cleanup_fpu_stack(instrs, cur_sim, live_fpu_regs);
diff --git a/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp b/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp
index 865e149..6d4c06f 100644
--- a/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,22 +31,6 @@
 #include "runtime/mutexLocker.hpp"
 #include "runtime/safepoint.hpp"
 
-// Release the CompiledICHolder* associated with this call site is there is one.
-void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  if (is_icholder_entry(call->destination())) {
-    NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());
-    InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());
-  }
-}
-
-bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  return is_icholder_entry(call->destination());
-}
-
 // ----------------------------------------------------------------------------
 
 #define __ _masm.
diff --git a/hotspot/src/cpu/x86/vm/frame_x86.cpp b/hotspot/src/cpu/x86/vm/frame_x86.cpp
index d61ae16..ae8628c 100644
--- a/hotspot/src/cpu/x86/vm/frame_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@
     // ok. adapter blobs never have a frame complete and are never ok.
 
     if (!_cb->is_frame_complete_at(_pc)) {
-      if (_cb->is_nmethod() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) {
+      if (_cb->is_compiled() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) {
         return false;
       }
     }
@@ -220,13 +220,11 @@
       return jcw_safe;
     }
 
-    if (sender_blob->is_nmethod()) {
-        nmethod* nm = sender_blob->as_nmethod_or_null();
-        if (nm != NULL) {
-            if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
-                nm->method()->is_method_handle_intrinsic()) {
-                return false;
-            }
+    CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
+    if (nm != NULL) {
+        if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
+            nm->method()->is_method_handle_intrinsic()) {
+            return false;
         }
     }
 
@@ -234,7 +232,7 @@
     // because the return address counts against the callee's frame.
 
     if (sender_blob->frame_size() <= 0) {
-      assert(!sender_blob->is_nmethod(), "should count return address at least");
+      assert(!sender_blob->is_compiled(), "should count return address at least");
       return false;
     }
 
@@ -243,7 +241,7 @@
     // should not be anything but the call stub (already covered), the interpreter (already covered)
     // or an nmethod.
 
-    if (!sender_blob->is_nmethod()) {
+    if (!sender_blob->is_compiled()) {
         return false;
     }
 
@@ -286,7 +284,7 @@
   assert(_pc == *pc_addr || pc == *pc_addr, "must be");
   *pc_addr = pc;
   _cb = CodeCache::find_blob(pc);
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     assert(original_pc == _pc, "expected original PC to be stored before patching");
     _deopt_state = is_deoptimized;
@@ -372,7 +370,7 @@
 // Verifies the calculated original PC of a deoptimization PC for the
 // given unextended SP.
 #ifdef ASSERT
-void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) {
+void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) {
   frame fr;
 
   // This is ugly but it's better than to change {get,set}_original_pc
@@ -381,7 +379,7 @@
   fr._unextended_sp = unextended_sp;
 
   address original_pc = nm->get_original_pc(&fr);
-  assert(nm->insts_contains(original_pc), "original PC must be in nmethod");
+  assert(nm->insts_contains(original_pc), "original PC must be in CompiledMethod");
 }
 #endif
 
@@ -392,12 +390,14 @@
   // as any other call site. Therefore, no special action is needed when we are
   // returning to any of these call sites.
 
-  nmethod* sender_nm = (_cb == NULL) ? NULL : _cb->as_nmethod_or_null();
-  if (sender_nm != NULL) {
-    // If the sender PC is a deoptimization point, get the original PC.
-    if (sender_nm->is_deopt_entry(_pc) ||
-        sender_nm->is_deopt_mh_entry(_pc)) {
-      DEBUG_ONLY(verify_deopt_original_pc(sender_nm, _unextended_sp));
+  if (_cb != NULL) {
+    CompiledMethod* sender_cm = _cb->as_compiled_method_or_null();
+    if (sender_cm != NULL) {
+      // If the sender PC is a deoptimization point, get the original PC.
+      if (sender_cm->is_deopt_entry(_pc) ||
+          sender_cm->is_deopt_mh_entry(_pc)) {
+        DEBUG_ONLY(verify_deopt_original_pc(sender_cm, _unextended_sp));
+      }
     }
   }
 }
@@ -640,6 +640,7 @@
     DESCRIBE_FP_OFFSET(interpreter_frame_sender_sp);
     DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
     DESCRIBE_FP_OFFSET(interpreter_frame_method);
+    DESCRIBE_FP_OFFSET(interpreter_frame_mirror);
     DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
     DESCRIBE_FP_OFFSET(interpreter_frame_cache);
     DESCRIBE_FP_OFFSET(interpreter_frame_locals);
diff --git a/hotspot/src/cpu/x86/vm/frame_x86.hpp b/hotspot/src/cpu/x86/vm/frame_x86.hpp
index b10f9ce3..dbfcaf7 100644
--- a/hotspot/src/cpu/x86/vm/frame_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/frame_x86.hpp
@@ -70,7 +70,8 @@
     // outgoing sp before a call to an invoked method
     interpreter_frame_last_sp_offset                 = interpreter_frame_sender_sp_offset - 1,
     interpreter_frame_method_offset                  = interpreter_frame_last_sp_offset - 1,
-    interpreter_frame_mdp_offset                     = interpreter_frame_method_offset - 1,
+    interpreter_frame_mirror_offset                  = interpreter_frame_method_offset - 1,
+    interpreter_frame_mdp_offset                     = interpreter_frame_mirror_offset - 1,
     interpreter_frame_cache_offset                   = interpreter_frame_mdp_offset - 1,
     interpreter_frame_locals_offset                  = interpreter_frame_cache_offset - 1,
     interpreter_frame_bcp_offset                     = interpreter_frame_locals_offset - 1,
@@ -124,7 +125,7 @@
 
 #ifdef ASSERT
   // Used in frame::sender_for_{interpreter,compiled}_frame
-  static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp);
+  static void verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp);
 #endif
 
  public:
diff --git a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp
index 374d83c..0c968ce 100644
--- a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp
+++ b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
   _cb = CodeCache::find_blob(pc);
   adjust_unextended_sp();
 
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     _pc = original_pc;
     _deopt_state = is_deoptimized;
@@ -72,10 +72,10 @@
   _cb = CodeCache::find_blob(pc);
   adjust_unextended_sp();
 
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     _pc = original_pc;
-    assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod");
+    assert(((CompiledMethod*)_cb)->insts_contains(_pc), "original PC must be in CompiledMethod");
     _deopt_state = is_deoptimized;
   } else {
     if (_cb->is_deoptimization_stub()) {
@@ -106,7 +106,7 @@
   _cb = CodeCache::find_blob(_pc);
   adjust_unextended_sp();
 
-  address original_pc = nmethod::get_deopt_original_pc(this);
+  address original_pc = CompiledMethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
     _pc = original_pc;
     _deopt_state = is_deoptimized;
@@ -184,6 +184,12 @@
   return (Method**)addr_at(interpreter_frame_method_offset);
 }
 
+// Mirror
+
+inline oop* frame::interpreter_frame_mirror_addr() const {
+  return (oop*)addr_at(interpreter_frame_mirror_offset);
+}
+
 // top of expression stack
 inline intptr_t* frame::interpreter_frame_tos_address() const {
   intptr_t* last_sp = interpreter_frame_last_sp();
diff --git a/hotspot/src/cpu/x86/vm/globals_x86.hpp b/hotspot/src/cpu/x86/vm/globals_x86.hpp
index a8d3609..93aea2a 100644
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp
@@ -99,7 +99,14 @@
 
 define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
 
-#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \
+#define ARCH_FLAGS(develop, \
+                   product, \
+                   diagnostic, \
+                   experimental, \
+                   notproduct, \
+                   range, \
+                   constraint, \
+                   writeable) \
                                                                             \
   develop(bool, IEEEPrecision, true,                                        \
           "Enables IEEE precision (for INTEL only)")                        \
@@ -194,9 +201,6 @@
   product(bool, UseBMI2Instructions, false,                                 \
           "Use BMI2 instructions")                                          \
                                                                             \
-  diagnostic(bool, UseLibmSinIntrinsic, true,                               \
-          "Use Libm Sin Intrinsic")                                         \
-                                                                            \
-  diagnostic(bool, UseLibmCosIntrinsic, true,                               \
-          "Use Libm Cos Intrinsic")
+  diagnostic(bool, UseLibmIntrinsic, true,                                  \
+          "Use Libm Intrinsics")
 #endif // CPU_X86_VM_GLOBALS_X86_HPP
diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp
index f8578f9..15cf1f7 100644
--- a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp
@@ -26,12 +26,12 @@
 #include "interp_masm_x86.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
+#include "logging/log.hpp"
 #include "oops/arrayOop.hpp"
 #include "oops/markOop.hpp"
 #include "oops/methodData.hpp"
 #include "oops/method.hpp"
 #include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/jvmtiThreadState.hpp"
 #include "runtime/basicLock.hpp"
 #include "runtime/biasedLocking.hpp"
@@ -1953,7 +1953,7 @@
   }
 
   // RedefineClasses() tracing support for obsolete method entry
-  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete)) {
     NOT_LP64(get_thread(rthread);)
     get_method(rarg);
     call_VM_leaf(
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_32.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_32.cpp
deleted file mode 100644
index 923e8fc..0000000
--- a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_32.cpp
+++ /dev/null
@@ -1,4571 +0,0 @@
-/*
- * Copyright (c) 2015, Intel Corporation.
- * Intel Math Library (LIBM) Source Code
- *
- * 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 "asm/assembler.hpp"
-#include "asm/assembler.inline.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "macroAssembler_x86.hpp"
-
-#ifdef _MSC_VER
-#define ALIGNED_(x) __declspec(align(x))
-#else
-#define ALIGNED_(x) __attribute__ ((aligned(x)))
-#endif
-
-// The 32 bit code is at most SSE2 compliant
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - EXP()
-//                     ---------------------
-//
-// Description:
-//  Let K = 64 (table size).
-//        x    x/log(2)     n
-//       e  = 2          = 2 * T[j] * (1 + P(y))
-//  where
-//       x = m*log(2)/K + y,    y in [-log(2)/K..log(2)/K]
-//       m = n*K + j,           m,n,j - signed integer, j in [-K/2..K/2]
-//                  j/K
-//       values of 2   are tabulated as T[j] = T_hi[j] ( 1 + T_lo[j]).
-//
-//       P(y) is a minimax polynomial approximation of exp(x)-1
-//       on small interval [-log(2)/K..log(2)/K] (were calculated by Maple V).
-//
-//  To avoid problems with arithmetic overflow and underflow,
-//            n                        n1  n2
-//  value of 2  is safely computed as 2 * 2 where n1 in [-BIAS/2..BIAS/2]
-//  where BIAS is a value of exponent bias.
-//
-// Special cases:
-//  exp(NaN) = NaN
-//  exp(+INF) = +INF
-//  exp(-INF) = 0
-//  exp(x) = 1 for subnormals
-//  for finite argument, only exp(0)=1 is exact
-//  For IEEE double
-//    if x >  709.782712893383973096 then exp(x) overflow
-//    if x < -745.133219101941108420 then exp(x) underflow
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _static_const_table[] =
-{
-    0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL, 0xffffffc0UL,
-    0x00000000UL, 0xffffffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL,
-    0x0000ffc0UL, 0x00000000UL, 0x00000000UL, 0x43380000UL, 0x00000000UL,
-    0x43380000UL, 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL,
-    0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL,
-    0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL,
-    0xfffffffeUL, 0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL,
-    0x3fa55555UL, 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL,
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL,
-    0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL,
-    0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL,
-    0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL,
-    0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL,
-    0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL,
-    0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL,
-    0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL,
-    0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL,
-    0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL,
-    0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL,
-    0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL,
-    0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL,
-    0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL,
-    0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL,
-    0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL,
-    0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL,
-    0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL,
-    0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL,
-    0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL,
-    0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL,
-    0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL,
-    0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL,
-    0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL,
-    0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL,
-    0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL,
-    0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL,
-    0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL,
-    0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL,
-    0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL,
-    0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL,
-    0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL,
-    0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL,
-    0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL,
-    0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL,
-    0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL,
-    0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL,
-    0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL,
-    0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL,
-    0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL,
-    0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL,
-    0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL,
-    0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL,
-    0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL,
-    0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL,
-    0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL,
-    0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL,
-    0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL,
-    0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL,
-    0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL,
-    0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL,
-    0x000fa7c1UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x7ff00000UL,
-    0x00000000UL, 0x00000000UL, 0xffffffffUL, 0x7fefffffUL, 0x00000000UL,
-    0x00100000UL
-};
-
-//registers,
-// input: (rbp + 8)
-// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
-//          rax, rdx, rcx, rbx (tmp)
-
-// Code generated by Intel C compiler for LIBM library
-
-void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
-  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
-  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start;
-
-  assert_different_registers(tmp, eax, ecx, edx);
-  jmp(start);
-  address static_const_table = (address)_static_const_table;
-
-  bind(start);
-  subl(rsp, 120);
-  movl(Address(rsp, 64), tmp);
-  lea(tmp, ExternalAddress(static_const_table));
-  movdqu(xmm0, Address(rsp, 128));
-  unpcklpd(xmm0, xmm0);
-  movdqu(xmm1, Address(tmp, 64));          // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL
-  movdqu(xmm6, Address(tmp, 48));          // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL
-  movdqu(xmm2, Address(tmp, 80));          // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL
-  movdqu(xmm3, Address(tmp, 96));          // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32767);
-  movl(edx, 16527);
-  subl(edx, eax);
-  subl(eax, 15504);
-  orl(edx, eax);
-  cmpl(edx, INT_MIN);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
-  mulpd(xmm1, xmm0);
-  addpd(xmm1, xmm6);
-  movapd(xmm7, xmm1);
-  subpd(xmm1, xmm6);
-  mulpd(xmm2, xmm1);
-  movdqu(xmm4, Address(tmp, 128));         // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL
-  mulpd(xmm3, xmm1);
-  movdqu(xmm5, Address(tmp, 144));         // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL
-  subpd(xmm0, xmm2);
-  movdl(eax, xmm7);
-  movl(ecx, eax);
-  andl(ecx, 63);
-  shll(ecx, 4);
-  sarl(eax, 6);
-  movl(edx, eax);
-  movdqu(xmm6, Address(tmp, 16));          // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL
-  pand(xmm7, xmm6);
-  movdqu(xmm6, Address(tmp, 32));          // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL
-  paddq(xmm7, xmm6);
-  psllq(xmm7, 46);
-  subpd(xmm0, xmm3);
-  movdqu(xmm2, Address(tmp, ecx, Address::times_1, 160));
-  mulpd(xmm4, xmm0);
-  movapd(xmm6, xmm0);
-  movapd(xmm1, xmm0);
-  mulpd(xmm6, xmm6);
-  mulpd(xmm0, xmm6);
-  addpd(xmm5, xmm4);
-  mulsd(xmm0, xmm6);
-  mulpd(xmm6, Address(tmp, 112));          // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL
-  addsd(xmm1, xmm2);
-  unpckhpd(xmm2, xmm2);
-  mulpd(xmm0, xmm5);
-  addsd(xmm1, xmm0);
-  por(xmm2, xmm7);
-  unpckhpd(xmm0, xmm0);
-  addsd(xmm0, xmm1);
-  addsd(xmm0, xmm6);
-  addl(edx, 894);
-  cmpl(edx, 1916);
-  jcc (Assembler::above, L_2TAG_PACKET_1_0_2);
-  mulsd(xmm0, xmm2);
-  addsd(xmm0, xmm2);
-  jmp(L_2TAG_PACKET_2_0_2);
-
-  bind(L_2TAG_PACKET_1_0_2);
-  fnstcw(Address(rsp, 24));
-  movzwl(edx, Address(rsp, 24));
-  orl(edx, 768);
-  movw(Address(rsp, 28), edx);
-  fldcw(Address(rsp, 28));
-  movl(edx, eax);
-  sarl(eax, 1);
-  subl(edx, eax);
-  movdqu(xmm6, Address(tmp, 0));           // 0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL
-  pandn(xmm6, xmm2);
-  addl(eax, 1023);
-  movdl(xmm3, eax);
-  psllq(xmm3, 52);
-  por(xmm6, xmm3);
-  addl(edx, 1023);
-  movdl(xmm4, edx);
-  psllq(xmm4, 52);
-  movsd(Address(rsp, 8), xmm0);
-  fld_d(Address(rsp, 8));
-  movsd(Address(rsp, 16), xmm6);
-  fld_d(Address(rsp, 16));
-  fmula(1);
-  faddp(1);
-  movsd(Address(rsp, 8), xmm4);
-  fld_d(Address(rsp, 8));
-  fmulp(1);
-  fstp_d(Address(rsp, 8));
-  movsd(xmm0,Address(rsp, 8));
-  fldcw(Address(rsp, 24));
-  pextrw(ecx, xmm0, 3);
-  andl(ecx, 32752);
-  cmpl(ecx, 32752);
-  jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2);
-  cmpl(ecx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
-  jmp(L_2TAG_PACKET_2_0_2);
-  cmpl(ecx, INT_MIN);
-  jcc(Assembler::less, L_2TAG_PACKET_3_0_2);
-  cmpl(ecx, -1064950997);
-  jcc(Assembler::less, L_2TAG_PACKET_2_0_2);
-  jcc(Assembler::greater, L_2TAG_PACKET_4_0_2);
-  movl(edx, Address(rsp, 128));
-  cmpl(edx ,-17155601);
-  jcc(Assembler::less, L_2TAG_PACKET_2_0_2);
-  jmp(L_2TAG_PACKET_4_0_2);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  movl(edx, 14);
-  jmp(L_2TAG_PACKET_5_0_2);
-
-  bind(L_2TAG_PACKET_4_0_2);
-  movl(edx, 15);
-
-  bind(L_2TAG_PACKET_5_0_2);
-  movsd(Address(rsp, 0), xmm0);
-  movsd(xmm0, Address(rsp, 128));
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_7_0_2);
-  cmpl(eax, 2146435072);
-  jcc(Assembler::greaterEqual, L_2TAG_PACKET_8_0_2);
-  movl(eax, Address(rsp, 132));
-  cmpl(eax, INT_MIN);
-  jcc(Assembler::greaterEqual, L_2TAG_PACKET_9_0_2);
-  movsd(xmm0, Address(tmp, 1208));         // 0xffffffffUL, 0x7fefffffUL
-  mulsd(xmm0, xmm0);
-  movl(edx, 14);
-  jmp(L_2TAG_PACKET_5_0_2);
-
-  bind(L_2TAG_PACKET_9_0_2);
-  movsd(xmm0, Address(tmp, 1216));
-  mulsd(xmm0, xmm0);
-  movl(edx, 15);
-  jmp(L_2TAG_PACKET_5_0_2);
-
-  bind(L_2TAG_PACKET_8_0_2);
-  movl(edx, Address(rsp, 128));
-  cmpl(eax, 2146435072);
-  jcc(Assembler::above, L_2TAG_PACKET_10_0_2);
-  cmpl(edx, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_2);
-  movl(eax, Address(rsp, 132));
-  cmpl(eax, 2146435072);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2);
-  movsd(xmm0, Address(tmp, 1192));         // 0x00000000UL, 0x7ff00000UL
-  jmp(L_2TAG_PACKET_2_0_2);
-
-  bind(L_2TAG_PACKET_11_0_2);
-  movsd(xmm0, Address(tmp, 1200));         // 0x00000000UL, 0x00000000UL
-  jmp(L_2TAG_PACKET_2_0_2);
-
-  bind(L_2TAG_PACKET_10_0_2);
-  movsd(xmm0, Address(rsp, 128));
-  addsd(xmm0, xmm0);
-  jmp(L_2TAG_PACKET_2_0_2);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  movl(eax, Address(rsp, 132));
-  andl(eax, 2147483647);
-  cmpl(eax, 1083179008);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2);
-  movsd(xmm0, Address(rsp, 128));
-  addsd(xmm0, Address(tmp, 1184));         // 0x00000000UL, 0x3ff00000UL
-  jmp(L_2TAG_PACKET_2_0_2);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  movsd(Address(rsp, 48), xmm0);
-  fld_d(Address(rsp, 48));
-
-  bind(L_2TAG_PACKET_6_0_2);
-  movl(tmp, Address(rsp, 64));
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - LOG()
-//                     ---------------------
-//
-//    x=2^k * mx, mx in [1,2)
-//
-//    Get B~1/mx based on the output of rcpss instruction (B0)
-//    B = int((B0*2^7+0.5))/2^7
-//
-//    Reduced argument: r=B*mx-1.0 (computed accurately in high and low parts)
-//
-//    Result:  k*log(2) - log(B) + p(r) if |x-1| >= small value (2^-6)  and
-//             p(r) is a degree 7 polynomial
-//             -log(B) read from data table (high, low parts)
-//             Result is formed from high and low parts
-//
-// Special cases:
-//  log(NaN) = quiet NaN, and raise invalid exception
-//  log(+INF) = that INF
-//  log(0) = -INF with divide-by-zero exception raised
-//  log(1) = +0
-//  log(x) = NaN with invalid exception raised if x < -0, including -INF
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _static_const_table_log[] =
-{
-  0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL,
-  0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL,
-  0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL,
-  0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL,
-  0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL,
-  0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL,
-  0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL,
-  0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL,
-  0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL,
-  0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL,
-  0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL,
-  0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL,
-  0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL,
-  0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL,
-  0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL,
-  0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL,
-  0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL,
-  0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL,
-  0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL,
-  0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL,
-  0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL,
-  0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL,
-  0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL,
-  0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL,
-  0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL,
-  0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL,
-  0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL,
-  0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL,
-  0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL,
-  0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL,
-  0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL,
-  0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL,
-  0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL,
-  0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL,
-  0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL,
-  0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL,
-  0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL,
-  0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL,
-  0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL,
-  0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL,
-  0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL,
-  0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL,
-  0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL,
-  0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL,
-  0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL,
-  0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL,
-  0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL,
-  0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL,
-  0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL,
-  0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL,
-  0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL,
-  0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL,
-  0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL,
-  0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL,
-  0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL,
-  0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL,
-  0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL,
-  0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL,
-  0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL,
-  0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL,
-  0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL,
-  0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL,
-  0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL,
-  0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL,
-  0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL,
-  0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL,
-  0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL,
-  0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL,
-  0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL,
-  0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL,
-  0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL,
-  0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL,
-  0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL,
-  0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL,
-  0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL,
-  0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL,
-  0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL,
-  0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL,
-  0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL,
-  0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL,
-  0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL,
-  0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL,
-  0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL,
-  0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL,
-  0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL,
-  0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL,
-  0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL,
-  0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL,
-  0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL,
-  0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL,
-  0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL,
-  0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL,
-  0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL,
-  0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL,
-  0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL,
-  0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL,
-  0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL,
-  0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL,
-  0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL,
-  0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL,
-  0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL,
-  0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL,
-  0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-  0x80000000UL, 0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL,
-  0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL,
-  0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL,
-  0x00000000UL, 0xbfe00000UL, 0x00000000UL, 0xffffe000UL, 0x00000000UL,
-  0xffffe000UL
-};
-//registers,
-// input: xmm0
-// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
-//          rax, rdx, rcx, rbx (tmp)
-
-void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
-  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2;
-  Label L_2TAG_PACKET_10_0_2, start;
-
-  assert_different_registers(tmp, eax, ecx, edx);
-  jmp(start);
-  address static_const_table = (address)_static_const_table_log;
-
-  bind(start);
-  subl(rsp, 104);
-  movl(Address(rsp, 40), tmp);
-  lea(tmp, ExternalAddress(static_const_table));
-  xorpd(xmm2, xmm2);
-  movl(eax, 16368);
-  pinsrw(xmm2, eax, 3);
-  xorpd(xmm3, xmm3);
-  movl(edx, 30704);
-  pinsrw(xmm3, edx, 3);
-  movsd(xmm0, Address(rsp, 112));
-  movapd(xmm1, xmm0);
-  movl(ecx, 32768);
-  movdl(xmm4, ecx);
-  movsd(xmm5, Address(tmp, 2128));         // 0x00000000UL, 0xffffe000UL
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  psllq(xmm0, 5);
-  movl(ecx, 16352);
-  psrlq(xmm0, 34);
-  rcpss(xmm0, xmm0);
-  psllq(xmm1, 12);
-  pshufd(xmm6, xmm5, 228);
-  psrlq(xmm1, 12);
-  subl(eax, 16);
-  cmpl(eax, 32736);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
-
-  bind(L_2TAG_PACKET_1_0_2);
-  paddd(xmm0, xmm4);
-  por(xmm1, xmm3);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  pand(xmm5, xmm1);
-  pand(xmm0, xmm6);
-  subsd(xmm1, xmm5);
-  mulpd(xmm5, xmm0);
-  andl(eax, 32752);
-  subl(eax, ecx);
-  cvtsi2sdl(xmm7, eax);
-  mulsd(xmm1, xmm0);
-  movsd(xmm6, Address(tmp, 2064));         // 0xfefa3800UL, 0x3fa62e42UL
-  movdqu(xmm3, Address(tmp, 2080));        // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL
-  subsd(xmm5, xmm2);
-  andl(edx, 16711680);
-  shrl(edx, 12);
-  movdqu(xmm0, Address(tmp, edx));
-  movdqu(xmm4, Address(tmp, 2096));        // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL
-  addsd(xmm1, xmm5);
-  movdqu(xmm2, Address(tmp, 2112));        // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL
-  mulsd(xmm6, xmm7);
-  pshufd(xmm5, xmm1, 68);
-  mulsd(xmm7, Address(tmp, 2072));         // 0x93c76730UL, 0x3ceef357UL, 0x92492492UL, 0x3fc24924UL
-  mulsd(xmm3, xmm1);
-  addsd(xmm0, xmm6);
-  mulpd(xmm4, xmm5);
-  mulpd(xmm5, xmm5);
-  pshufd(xmm6, xmm0, 228);
-  addsd(xmm0, xmm1);
-  addpd(xmm4, xmm2);
-  mulpd(xmm3, xmm5);
-  subsd(xmm6, xmm0);
-  mulsd(xmm4, xmm1);
-  pshufd(xmm2, xmm0, 238);
-  addsd(xmm1, xmm6);
-  mulsd(xmm5, xmm5);
-  addsd(xmm7, xmm2);
-  addpd(xmm4, xmm3);
-  addsd(xmm1, xmm7);
-  mulpd(xmm4, xmm5);
-  addsd(xmm1, xmm4);
-  pshufd(xmm5, xmm4, 238);
-  addsd(xmm1, xmm5);
-  addsd(xmm0, xmm1);
-  jmp(L_2TAG_PACKET_2_0_2);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  movsd(xmm0, Address(rsp, 112));
-  movdqu(xmm1, xmm0);
-  addl(eax, 16);
-  cmpl(eax, 32768);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_3_0_2);
-  cmpl(eax, 16);
-  jcc(Assembler::below, L_2TAG_PACKET_4_0_2);
-
-  bind(L_2TAG_PACKET_5_0_2);
-  addsd(xmm0, xmm0);
-  jmp(L_2TAG_PACKET_2_0_2);
-
-  bind(L_2TAG_PACKET_6_0_2);
-  jcc(Assembler::above, L_2TAG_PACKET_5_0_2);
-  cmpl(edx, 0);
-  jcc(Assembler::above, L_2TAG_PACKET_5_0_2);
-  jmp(L_2TAG_PACKET_7_0_2);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  movdl(edx, xmm1);
-  psrlq(xmm1, 32);
-  movdl(ecx, xmm1);
-  addl(ecx, ecx);
-  cmpl(ecx, -2097152);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_6_0_2);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
-
-  bind(L_2TAG_PACKET_7_0_2);
-  xorpd(xmm1, xmm1);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32752);
-  pinsrw(xmm1, eax, 3);
-  movl(edx, 3);
-  mulsd(xmm0, xmm1);
-
-  bind(L_2TAG_PACKET_9_0_2);
-  movsd(Address(rsp, 0), xmm0);
-  movsd(xmm0, Address(rsp, 112));
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_10_0_2);
-
-  bind(L_2TAG_PACKET_8_0_2);
-  xorpd(xmm1, xmm1);
-  xorpd(xmm0, xmm0);
-  movl(eax, 49136);
-  pinsrw(xmm0, eax, 3);
-  divsd(xmm0, xmm1);
-  movl(edx, 2);
-  jmp(L_2TAG_PACKET_9_0_2);
-
-  bind(L_2TAG_PACKET_4_0_2);
-  movdl(edx, xmm1);
-  psrlq(xmm1, 32);
-  movdl(ecx, xmm1);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
-  xorpd(xmm1, xmm1);
-  movl(eax, 18416);
-  pinsrw(xmm1, eax, 3);
-  mulsd(xmm0, xmm1);
-  movapd(xmm1, xmm0);
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  psllq(xmm0, 5);
-  movl(ecx, 18416);
-  psrlq(xmm0, 34);
-  rcpss(xmm0, xmm0);
-  psllq(xmm1, 12);
-  pshufd(xmm6, xmm5, 228);
-  psrlq(xmm1, 12);
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  movsd(Address(rsp, 24), xmm0);
-  fld_d(Address(rsp, 24));
-
-  bind(L_2TAG_PACKET_10_0_2);
-  movl(tmp, Address(rsp, 40));
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION  - POW()
-//                     ---------------------
-//
-//    Let x=2^k * mx, mx in [1,2)
-//
-//    log2(x) calculation:
-//
-//    Get B~1/mx based on the output of rcpps instruction (B0)
-//    B = int((B0*LH*2^9+0.5))/2^9
-//    LH is a short approximation for log2(e)
-//
-//    Reduced argument, scaled by LH:
-//                r=B*mx-LH (computed accurately in high and low parts)
-//
-//    log2(x) result:  k - log2(B) + p(r)
-//             p(r) is a degree 8 polynomial
-//             -log2(B) read from data table (high, low parts)
-//             log2(x) is formed from high and low parts
-//    For |x| in [1-1/32, 1+1/16), a slower but more accurate computation
-//    based om the same table design is performed.
-//
-//   Main path is taken if | floor(log2(|log2(|x|)|) + floor(log2|y|) | < 8,
-//   to filter out all potential OF/UF cases.
-//   exp2(y*log2(x)) is computed using an 8-bit index table and a degree 5
-//   polynomial
-//
-// Special cases:
-//  pow(-0,y) = -INF and raises the divide-by-zero exception for y an odd
-//  integer < 0.
-//  pow(-0,y) = +INF and raises the divide-by-zero exception for y < 0 and
-//  not an odd integer.
-//  pow(-0,y) = -0 for y an odd integer > 0.
-//  pow(-0,y) = +0 for y > 0 and not an odd integer.
-//  pow(-1,-INF) = NaN.
-//  pow(+1,y) = NaN for any y, even a NaN.
-//  pow(x,-0) = 1 for any x, even a NaN.
-//  pow(x,y) = a NaN and raises the invalid exception for finite x < 0 and
-//  finite non-integer y.
-//  pow(x,-INF) = +INF for |x|<1.
-//  pow(x,-INF) = +0 for |x|>1.
-//  pow(x,+INF) = +0 for |x|<1.
-//  pow(x,+INF) = +INF for |x|>1.
-//  pow(-INF,y) = -0 for y an odd integer < 0.
-//  pow(-INF,y) = +0 for y < 0 and not an odd integer.
-//  pow(-INF,y) = -INF for y an odd integer > 0.
-//  pow(-INF,y) = +INF for y > 0 and not an odd integer.
-//  pow(+INF,y) = +0 for y <0.
-//  pow(+INF,y) = +INF for y >0.
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _static_const_table_pow[] =
-{
-  0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL, 0xf8000000UL,
-  0xffffffffUL, 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0x3ff00000UL,
-  0x00000000UL, 0x00000000UL, 0x20000000UL, 0x3feff00aUL, 0x96621f95UL,
-  0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL, 0xe5916f9eUL, 0xbe325278UL,
-  0x00000000UL, 0x3fefd02fUL, 0x859a1062UL, 0x3e595fb7UL, 0xc0000000UL,
-  0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL, 0xe0000000UL, 0x3fefb069UL,
-  0xad2880a7UL, 0xbe501230UL, 0x60000000UL, 0x3fefa08fUL, 0xc8e72420UL,
-  0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL, 0xc30c4500UL, 0xbe5d6c75UL,
-  0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL, 0x3e2e1318UL, 0xc0000000UL,
-  0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL, 0x00000000UL, 0x3fef615cUL,
-  0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL, 0x3fef519cUL, 0x65c5cd68UL,
-  0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL, 0x46d1306cUL, 0xbe5a840eUL,
-  0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL, 0x3e5071afUL, 0xa0000000UL,
-  0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL, 0xa0000000UL, 0x3fef12d4UL,
-  0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL, 0x3fef032fUL, 0xbc7247faUL,
-  0xbe2bab83UL, 0x80000000UL, 0x3feef390UL, 0xbcaa1e46UL, 0xbe53bb3bUL,
-  0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL, 0xbe54c619UL, 0x80000000UL,
-  0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL, 0xe0000000UL, 0x3feec4d1UL,
-  0xec678f76UL, 0xbe369af6UL, 0x80000000UL, 0x3feeb547UL, 0x41301f55UL,
-  0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL, 0x676da6bdUL, 0xbe4d8dd0UL,
-  0x60000000UL, 0x3fee9642UL, 0x57a891c4UL, 0x3e51f991UL, 0xa0000000UL,
-  0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL, 0x20000000UL, 0x3fee7752UL,
-  0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL, 0x3fee67e1UL, 0xd75b5bf1UL,
-  0xbe449531UL, 0x80000000UL, 0x3fee5876UL, 0xbd423b8eUL, 0x3df54fe4UL,
-  0x60000000UL, 0x3fee4910UL, 0x330e51b9UL, 0x3e54289cUL, 0x80000000UL,
-  0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL, 0xa0000000UL, 0x3fee2a53UL,
-  0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL, 0x3fee1afcUL, 0x0989328dUL,
-  0x3e23958cUL, 0x40000000UL, 0x3fee0babUL, 0xee642abdUL, 0xbe425dd8UL,
-  0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL, 0x3e526362UL, 0x20000000UL,
-  0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL, 0xc0000000UL, 0x3fedddd4UL,
-  0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL, 0x3fedce97UL, 0x0ecac52fUL,
-  0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL, 0x124cb3b8UL, 0x3e257024UL,
-  0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL, 0xbe2033eeUL, 0x20000000UL,
-  0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL, 0xc0000000UL, 0x3fed91d3UL,
-  0xef8a552aUL, 0xbe543390UL, 0x40000000UL, 0x3fed82afUL, 0xb8e85204UL,
-  0x3e513850UL, 0xe0000000UL, 0x3fed738fUL, 0x3d59fe08UL, 0xbe5db728UL,
-  0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL, 0x3e58804bUL, 0xc0000000UL,
-  0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL, 0x00000000UL, 0x3fed464fUL,
-  0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL, 0x3fed3743UL, 0xb0b0a190UL,
-  0x3e598635UL, 0x80000000UL, 0x3fed283cUL, 0xe2113295UL, 0xbe5c1119UL,
-  0x80000000UL, 0x3fed193aUL, 0xafbf1728UL, 0xbe492e9cUL, 0x60000000UL,
-  0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL, 0x20000000UL, 0x3fecfb45UL,
-  0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL, 0x3fecec51UL, 0x110f7dddUL,
-  0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL, 0x7dd7d508UL, 0xbe5a8943UL,
-  0x80000000UL, 0x3fecce79UL, 0x9b60f271UL, 0xbe50676aUL, 0x80000000UL,
-  0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL, 0x60000000UL, 0x3fecb0b4UL,
-  0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL, 0x3feca1d9UL, 0x38a6ec89UL,
-  0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL, 0x3a0b7d8eUL, 0x3e53dbfdUL,
-  0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL, 0xbe27c5c9UL, 0xc0000000UL,
-  0x3fec7563UL, 0x0c706381UL, 0xbe593653UL, 0x60000000UL, 0x3fec669bUL,
-  0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL, 0x3fec57d7UL, 0x40e5e7e8UL,
-  0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL, 0x5602770fUL, 0xbe55219dUL,
-  0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL, 0x3e5a5d25UL, 0x60000000UL,
-  0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL, 0x80000000UL, 0x3fec1cf8UL,
-  0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL, 0x3fec0e4cUL, 0x580798bdUL,
-  0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL, 0xb8282df6UL, 0xbe46b874UL,
-  0x20000000UL, 0x3febf102UL, 0xe33a6729UL, 0x3e54963fUL, 0x00000000UL,
-  0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL, 0x60000000UL, 0x3febd3caUL,
-  0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL, 0x3febc535UL, 0xa335c5eeUL,
-  0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL, 0x7325b04dUL, 0x3e42ba15UL,
-  0x60000000UL, 0x3feba819UL, 0x1564540fUL, 0x3e3a9f35UL, 0x40000000UL,
-  0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL, 0xa0000000UL, 0x3feb8b0fUL,
-  0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL, 0x3feb7c91UL, 0x6d6f1ea4UL,
-  0x3e557657UL, 0x00000000UL, 0x3feb6e18UL, 0x5e80a1bfUL, 0x3e4ddbb6UL,
-  0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL, 0x3e592877UL, 0xa0000000UL,
-  0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL, 0xa0000000UL, 0x3feb42c6UL,
-  0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL, 0x3feb345fUL, 0xa3e0cceeUL,
-  0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL, 0x8e752b50UL, 0xbe3da3c2UL,
-  0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL, 0x3e1fb481UL, 0xc0000000UL,
-  0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL, 0x20000000UL, 0x3feafaeeUL,
-  0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL, 0x3feaec9dUL, 0x3c3d640eUL,
-  0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL, 0x8f97a715UL, 0x3e3a8ec5UL,
-  0x20000000UL, 0x3fead008UL, 0x23ab2839UL, 0x3e2fe98aUL, 0x40000000UL,
-  0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL, 0xe0000000UL, 0x3feab384UL,
-  0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL, 0x3feaa549UL, 0x7c7b0eeaUL,
-  0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL, 0xf56f7013UL, 0x3e386200UL,
-  0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL, 0xbe514af5UL, 0xe0000000UL,
-  0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL, 0x60000000UL, 0x3fea6c89UL,
-  0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL, 0x3fea5e64UL, 0x3f19d970UL,
-  0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL, 0x09ea3e6bUL, 0x3e5065dcUL,
-  0x80000000UL, 0x3fea4226UL, 0x78df246cUL, 0x3e5e05f6UL, 0x40000000UL,
-  0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL, 0x40000000UL, 0x3fea25faUL,
-  0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL, 0x3fea17eaUL, 0x9436f40aUL,
-  0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL, 0x4b5253b3UL, 0x3e46380bUL,
-  0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL, 0xbe386f9bUL, 0x20000000UL,
-  0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL, 0x60000000UL, 0x3fe9dfd6UL,
-  0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL, 0x3fe9d1dcUL, 0xeabdff1dUL,
-  0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL, 0xafd30e73UL, 0xbe585e63UL,
-  0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL, 0xbe43e8f9UL, 0x20000000UL,
-  0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL, 0x80000000UL, 0x3fe99a1cUL,
-  0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL, 0x3fe98c37UL, 0x7c9a88fbUL,
-  0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL, 0xda015741UL, 0xbe5d13baUL,
-  0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL, 0x3e51b947UL, 0x00000000UL,
-  0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL, 0x40000000UL, 0x3fe954cbUL,
-  0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL, 0x3fe946faUL, 0xe63b3767UL,
-  0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL, 0xe57cc2a9UL, 0x3e34eda3UL,
-  0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL, 0x3e5766a0UL, 0xc0000000UL,
-  0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL, 0x80000000UL, 0x3fe90fe1UL,
-  0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL, 0x3fe90225UL, 0xdbd3f369UL,
-  0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL, 0x1c9be989UL, 0xbe5e2b0aUL,
-  0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL, 0x3e5c8618UL, 0xe0000000UL,
-  0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL, 0x20000000UL, 0x3fe8cb5eUL,
-  0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL, 0x3fe8bdb6UL, 0x49e58cc3UL,
-  0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL, 0xa7cfeb8fUL, 0x3e56c412UL,
-  0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL, 0x3e1429b8UL, 0x60000000UL,
-  0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL, 0xc0000000UL, 0x3fe8873fUL,
-  0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL, 0x3fe879acUL, 0x56aee828UL,
-  0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL, 0x7ceab8ecUL, 0x3e493365UL,
-  0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL, 0xbe4f7f25UL, 0x00000000UL,
-  0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL, 0x40000000UL, 0x3fe84385UL,
-  0x34ba4e15UL, 0x3e328077UL, 0x80000000UL, 0x3fe83605UL, 0xa670975aUL,
-  0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL, 0xf61b77b2UL, 0xbe43a20aUL,
-  0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL, 0x3e5e5fe5UL, 0xc0000000UL,
-  0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL, 0xa0000000UL, 0x3fe8002dUL,
-  0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL, 0x3fe7f2c1UL, 0x22a16f01UL,
-  0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL, 0xc38cd451UL, 0x3e506963UL,
-  0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL, 0x3e4503d7UL, 0x40000000UL,
-  0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL, 0xa0000000UL, 0x3fe7bd37UL,
-  0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL, 0x3fe7afdeUL, 0xe3b0be70UL,
-  0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL, 0xaf9f193cUL, 0xbe5dff6cUL,
-  0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL, 0xbe258ed0UL, 0xa0000000UL,
-  0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL, 0x40000000UL, 0x3fe77aa2UL,
-  0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL, 0x3fe76d5cUL, 0x7cb0b5e4UL,
-  0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL, 0x2b1bc4adUL, 0xbe32e8bbUL,
-  0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL, 0x3e41f57bUL, 0xc0000000UL,
-  0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL, 0x60000000UL, 0x3fe7386cUL,
-  0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL, 0x3fe72b39UL, 0x91d690f7UL,
-  0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL, 0x627a2159UL, 0xbe4425d5UL,
-  0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL, 0x3e422b7eUL, 0x60000000UL,
-  0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL, 0xe0000000UL, 0x3fe6f694UL,
-  0x84d628a2UL, 0xbe51f090UL, 0x00000000UL, 0x3fe6e975UL, 0x306d8894UL,
-  0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL, 0x30bf24aaUL, 0xbe4650caUL,
-  0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL, 0xbe5db007UL, 0xc0000000UL,
-  0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL, 0xc0000000UL, 0x3fe6b51aUL,
-  0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL, 0x3fe6a80dUL, 0xf3559341UL,
-  0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL, 0xa885899eUL, 0xbe5c2011UL,
-  0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL, 0x3e224a82UL, 0xa0000000UL,
-  0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL, 0x00000000UL, 0x3fe673fdUL,
-  0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL, 0x3fe66702UL, 0x5df10408UL,
-  0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL, 0xa4070568UL, 0xbe40b12fUL,
-  0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL, 0x3e5f5e8bUL, 0x00000000UL,
-  0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL, 0xa0000000UL, 0x3fe6333aUL,
-  0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL, 0x3fe62651UL, 0x6f538d61UL,
-  0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL, 0x14344120UL, 0xbe529af6UL,
-  0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL, 0xbe3e1e4fUL, 0x00000000UL,
-  0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL, 0x80000000UL, 0x3fe5f2d2UL,
-  0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL, 0x3fe5e5fbUL, 0xa4695699UL,
-  0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL, 0x80d118aeUL, 0x3e456b61UL,
-  0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL, 0x3e54dc29UL, 0x80000000UL,
-  0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL, 0xe0000000UL, 0x3fe5b2c3UL,
-  0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL, 0x3fe5a5feUL, 0x9292c7eaUL,
-  0x3e188650UL, 0x20000000UL, 0x3fe5993dUL, 0x33b4d380UL, 0x3e5d6d93UL,
-  0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL, 0x3e2fe961UL, 0xa0000000UL,
-  0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL, 0xa0000000UL, 0x3fe5730dUL,
-  0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL, 0x3fe5665aUL, 0x024acfeaUL,
-  0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL, 0xcc9edd09UL, 0xbe325403UL,
-  0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL, 0x3e5d500eUL, 0x60000000UL,
-  0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL, 0xc0000000UL, 0x3fe533aeUL,
-  0x154b0287UL, 0xbe401571UL, 0xa0000000UL, 0x3fe5270cUL, 0x0673f401UL,
-  0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL, 0x751b639cUL, 0x3e235269UL,
-  0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL, 0x3ddec887UL, 0xc0000000UL,
-  0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL, 0x60000000UL, 0x3fe4f4a6UL,
-  0x2e308668UL, 0x3e59aed6UL, 0x80000000UL, 0x3fe4e815UL, 0xf33e2a76UL,
-  0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL, 0x839f3e3eUL, 0x3e57db01UL,
-  0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL, 0x3e535e0fUL, 0x00000000UL,
-  0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL, 0xc0000000UL, 0x3fe4b5f3UL,
-  0x05192456UL, 0xbe4e8518UL, 0xc0000000UL, 0x3fe4a973UL, 0x4aa7cd1dUL,
-  0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL, 0x8e23025eUL, 0xbe5749f2UL,
-  0x00000000UL, 0x3fe4907eUL, 0x18d30215UL, 0x3e360f39UL, 0x20000000UL,
-  0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL, 0xc0000000UL, 0x3fe47795UL,
-  0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL, 0x3fe46b26UL, 0x8f0e62aaUL,
-  0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL, 0x5775c40cUL, 0xbe56aad4UL,
-  0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL, 0x3e48bd71UL, 0x40000000UL,
-  0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL, 0x80000000UL, 0x3fe4398bUL,
-  0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL, 0x3fe42d2dUL, 0x388e4d2eUL,
-  0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL, 0x6f797c18UL, 0x3e554b4cUL,
-  0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL, 0xbe5b1112UL, 0x80000000UL,
-  0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL, 0x40000000UL, 0x3fe3fbd4UL,
-  0x50201119UL, 0x3e40b701UL, 0x40000000UL, 0x3fe3ef86UL, 0x0a4db32cUL,
-  0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL, 0x0c9c148bUL, 0xbe50c1f6UL,
-  0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL, 0x3e533fa0UL, 0x00000000UL,
-  0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL, 0x20000000UL, 0x3fe3be6fUL,
-  0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL, 0x3fe3b231UL, 0x7f908258UL,
-  0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL, 0x1a09af78UL, 0x3e08038bUL,
-  0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL, 0xbe5dbe42UL, 0xe0000000UL,
-  0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL, 0x20000000UL, 0x3fe3815bUL,
-  0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL, 0x3fe3752dUL, 0x6182e429UL,
-  0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL, 0xab6eb1aeUL, 0x3e5a2cc5UL,
-  0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL, 0xbe5c5878UL, 0x40000000UL,
-  0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL, 0x80000000UL, 0x3fe34497UL,
-  0x857761aaUL, 0x3e5fff53UL, 0x00000000UL, 0x3fe3387aUL, 0xf872d68cUL,
-  0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL, 0x087e97c2UL, 0x3e52842eUL,
-  0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL, 0xbe503edfUL, 0x80000000UL,
-  0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL, 0xa0000000UL, 0x3fe30823UL,
-  0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL, 0x3fe2fc15UL, 0x855a7390UL,
-  0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL, 0xa2898287UL, 0x3e3d22a2UL,
-  0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL, 0xbe5aa5fdUL, 0x80000000UL,
-  0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL, 0x60000000UL, 0x3fe2cbfeUL,
-  0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL, 0x3fe2c000UL, 0x6b01bf10UL,
-  0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL, 0xb07a1cdfUL, 0x3e5c5cdaUL,
-  0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL, 0xbe5668b3UL, 0xc0000000UL,
-  0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL, 0x00000000UL, 0x3fe29027UL,
-  0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL, 0x3fe28438UL, 0x6433c727UL,
-  0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL, 0x41782631UL, 0xbe30750cUL,
-  0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL, 0xbe58290eUL, 0x40000000UL,
-  0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL, 0x00000000UL, 0x3fe2549dUL,
-  0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL, 0x3fe248bdUL, 0x4248b9fbUL,
-  0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL, 0xf35cf82fUL, 0x3e561b71UL,
-  0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL, 0x3e518fb9UL, 0x60000000UL,
-  0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL, 0x40000000UL, 0x3fe2195fUL,
-  0x80943911UL, 0xbe07f819UL, 0x40000000UL, 0x3fe20d8fUL, 0x386f2d6cUL,
-  0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL, 0xf29664acUL, 0xbe5eb815UL,
-  0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL, 0x3e5e320cUL, 0x20000000UL,
-  0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL, 0x40000000UL, 0x3fe1de6dUL,
-  0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL, 0x3fe1d2acUL, 0x4ae0b55eUL,
-  0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL, 0x28569a5eUL, 0x3e598a4fUL,
-  0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL, 0x3e46130aUL, 0x20000000UL,
-  0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL, 0x00000000UL, 0x3fe1a3c6UL,
-  0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL, 0x3fe19813UL, 0x2f02b836UL,
-  0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL, 0x28dec9d4UL, 0x3e09064fUL,
-  0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL, 0x3e5b1f46UL, 0x40000000UL,
-  0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL, 0x00000000UL, 0x3fe16969UL,
-  0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL, 0x3fe15dc5UL, 0x73bad6f8UL,
-  0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL, 0x5385769cUL, 0x3e5e8d76UL,
-  0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL, 0x3e571d08UL, 0x20000000UL,
-  0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL, 0x60000000UL, 0x3fe12f55UL,
-  0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL, 0x3fe123c0UL, 0x403638e1UL,
-  0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL, 0x557a092bUL, 0xbdd0116bUL,
-  0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL, 0x3e4a61baUL, 0xc0000000UL,
-  0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL, 0x20000000UL, 0x3fe0ea04UL,
-  0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL, 0x3fe0d300UL, 0x23190e54UL,
-  0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL, 0x1379a5a6UL, 0xbe51619dUL,
-  0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL, 0x3e5cf019UL, 0xa0000000UL,
-  0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL, 0x20000000UL, 0x3fe07762UL,
-  0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL, 0x3fe06097UL, 0xfd9cf274UL,
-  0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL, 0x3689b49dUL, 0xbe36d26dUL,
-  0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL, 0xbe54cd08UL, 0xa0000000UL,
-  0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL, 0x00000000UL, 0x3fe005daUL,
-  0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL, 0x3fdfde8dUL, 0xad67766dUL,
-  0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL, 0x644f4ae7UL, 0x3e1ee43bUL,
-  0x40000000UL, 0x3fdf8481UL, 0x903234d2UL, 0x3e501a86UL, 0x40000000UL,
-  0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL, 0x00000000UL, 0x3fdf2acdUL,
-  0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL, 0x3fdefe13UL, 0x3b94305eUL,
-  0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL, 0x5d95da61UL, 0xbe55c198UL,
-  0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL, 0xbdd99a19UL, 0x00000000UL,
-  0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL, 0x80000000UL, 0x3fde4c04UL,
-  0x83eec535UL, 0xbe3e1232UL, 0x40000000UL, 0x3fde1fb6UL, 0x3dfbffcbUL,
-  0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL, 0x7e1be4e0UL, 0xbe5b8f8fUL,
-  0x40000000UL, 0x3fddc759UL, 0x46dae887UL, 0xbe350458UL, 0x80000000UL,
-  0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL, 0x80000000UL, 0x3fdd6f50UL,
-  0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL, 0x3fdd436bUL, 0xf0bccb32UL,
-  0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL, 0x9bbfc779UL, 0xbe54a26aUL,
-  0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL, 0x3e43c6b7UL, 0x40000000UL,
-  0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL, 0x40000000UL, 0x3fdc94a7UL,
-  0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL, 0x3fdc6929UL, 0xf0a8f95aUL,
-  0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL, 0x6ee2693bUL, 0x3e0992e6UL,
-  0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL, 0xbe2834b6UL, 0x40000000UL,
-  0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL, 0x00000000UL, 0x3fdbbbffUL,
-  0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL, 0x3fdb90e7UL, 0x479664c0UL,
-  0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL, 0x5004975bUL, 0xbe55258fUL,
-  0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL, 0xbe588407UL, 0xc0000000UL,
-  0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL, 0x80000000UL, 0x3fdae54eUL,
-  0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL, 0x3fdaba9aUL, 0xe19d0913UL,
-  0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL, 0x43cfd006UL, 0xbe4cfdebUL,
-  0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL, 0x3e5e47a8UL, 0xc0000000UL,
-  0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL, 0xc0000000UL, 0x3fda108cUL,
-  0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL, 0x3fd9e63aUL, 0x396f8f2cUL,
-  0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL, 0xe32b25ddUL, 0x3e5c3a54UL,
-  0x40000000UL, 0x3fd991cfUL, 0x431e4035UL, 0xbe457925UL, 0x80000000UL,
-  0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL, 0x00000000UL, 0x3fd93db1UL,
-  0xd7449365UL, 0x3e306419UL, 0x80000000UL, 0x3fd913beUL, 0x1746e791UL,
-  0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL, 0xf3a9028bUL, 0xbe5041b9UL,
-  0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL, 0xbe26e20aUL, 0x40000000UL,
-  0x3fd89659UL, 0x19763102UL, 0xbe51f466UL, 0x80000000UL, 0x3fd86cb2UL,
-  0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL, 0x3fd8431eUL, 0xdeb39fabUL,
-  0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL, 0x5d01cbe0UL, 0xbe5425b3UL,
-  0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL, 0x3e146fa8UL, 0x80000000UL,
-  0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL, 0xc0000000UL, 0x3fd79d88UL,
-  0x8606c236UL, 0x3e423a08UL, 0x80000000UL, 0x3fd77451UL, 0x8fd1e1b7UL,
-  0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL, 0xe491456aUL, 0x3e42c1caUL,
-  0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL, 0x3e36a69aUL, 0x00000000UL,
-  0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL, 0x00000000UL, 0x3fd6d02cUL,
-  0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL, 0x3fd6a750UL, 0x1919fd61UL,
-  0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL, 0xaa7a994dUL, 0xbe3f3fbdUL,
-  0x00000000UL, 0x3fd655ceUL, 0x67db014cUL, 0x3e33c550UL, 0x00000000UL,
-  0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL, 0xc0000000UL, 0x3fd60493UL,
-  0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL, 0x3fd5dc11UL, 0x1222bd5cUL,
-  0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL, 0x6e8dc2d3UL, 0x3e5d4d79UL,
-  0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL, 0xbe517303UL, 0x80000000UL,
-  0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL, 0xc0000000UL, 0x3fd53ab8UL,
-  0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL, 0x3fd5128eUL, 0xea902207UL,
-  0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL, 0x9f911d79UL, 0x3e511735UL,
-  0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL, 0xbe5b1643UL, 0x40000000UL,
-  0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL, 0x80000000UL, 0x3fd47293UL,
-  0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL, 0x3fd44abfUL, 0xe04042f5UL,
-  0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL, 0x1d8bf2c8UL, 0x3e5d8810UL,
-  0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL, 0xbe311454UL, 0xc0000000UL,
-  0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL, 0x40000000UL, 0x3fd3ac1cUL,
-  0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL, 0x3fd3849dUL, 0xd4e34b9eUL,
-  0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL, 0x177204fbUL, 0xbe2b8cd7UL,
-  0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL, 0xbe4356e1UL, 0x80000000UL,
-  0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL, 0x00000000UL, 0x3fd2e74cUL,
-  0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL, 0x3fd2c021UL, 0x516dab3fUL,
-  0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL, 0x2bfb7313UL, 0x3e5674a2UL,
-  0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL, 0x3e385d29UL, 0xc0000000UL,
-  0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL, 0x00000000UL, 0x3fd2241cUL,
-  0x3f91953aUL, 0x3e389977UL, 0xc0000000UL, 0x3fd1fd43UL, 0xa1543f71UL,
-  0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL, 0x4ec8867cUL, 0x3df6a2dcUL,
-  0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL, 0x3e41d9c0UL, 0x80000000UL,
-  0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL, 0x40000000UL, 0x3fd16285UL,
-  0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL, 0x3fd13bfeUL, 0xb9aec164UL,
-  0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL, 0xd91e1316UL, 0xbe350630UL,
-  0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL, 0x3e3f5219UL, 0x40000000UL,
-  0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL, 0x00000000UL, 0x3fd0a281UL,
-  0x2a63447dUL, 0xbe541377UL, 0x80000000UL, 0x3fd07c49UL, 0xfac483b5UL,
-  0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL, 0x36b8a570UL, 0xbe4fd4bdUL,
-  0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL, 0xbe450388UL, 0x80000000UL,
-  0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL, 0x80000000UL, 0x3fcfc811UL,
-  0x707475acUL, 0x3e38806eUL, 0x80000000UL, 0x3fcf7c3fUL, 0xc91817fcUL,
-  0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL, 0xae05d5e9UL, 0xbe4919b8UL,
-  0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL, 0xbe530b94UL, 0x00000000UL,
-  0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL, 0x00000000UL, 0x3fce4e2dUL,
-  0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL, 0x3fce02f5UL, 0x8abe2c2eUL,
-  0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL, 0x1495450dUL, 0xbe0872ccUL,
-  0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL, 0xbe4f59a0UL, 0x00000000UL,
-  0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL, 0x00000000UL, 0x3fccd747UL,
-  0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL, 0x3fcc8ca7UL, 0xd305b56cUL,
-  0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL, 0x399a6910UL, 0xbe482a1cUL,
-  0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL, 0xbe587372UL, 0x80000000UL,
-  0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL, 0x00000000UL, 0x3fcb6355UL,
-  0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL, 0x3fcb194aUL, 0x8416c0bcUL,
-  0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL, 0x49f7f08fUL, 0x3e56da76UL,
-  0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL, 0x3e5f390cUL, 0x00000000UL,
-  0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL, 0x80000000UL, 0x3fc9f249UL,
-  0x33631553UL, 0x3e52aeb1UL, 0x00000000UL, 0x3fc9a8d3UL, 0xde8795a6UL,
-  0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL, 0x076bf41eUL, 0x3e5122feUL,
-  0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL, 0x3e3dd064UL, 0x00000000UL,
-  0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL, 0x80000000UL, 0x3fc8841aUL,
-  0xb2a96650UL, 0xbe575444UL, 0x80000000UL, 0x3fc83b34UL, 0x2376c0cbUL,
-  0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL, 0xd8a0b653UL, 0xbe5181b6UL,
-  0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL, 0xbe4a78b4UL, 0x00000000UL,
-  0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL, 0x80000000UL, 0x3fc718bbUL,
-  0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL, 0x3fc6d064UL, 0x3728b8cfUL,
-  0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL, 0xc79a4067UL, 0x3e5c380fUL,
-  0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL, 0x3e550a84UL, 0x80000000UL,
-  0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL, 0x80000000UL, 0x3fc5b022UL,
-  0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL, 0x3fc56858UL, 0x659b18beUL,
-  0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL, 0x66ee3631UL, 0xbe57d769UL,
-  0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL, 0x3e2427f7UL, 0x80000000UL,
-  0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL, 0x00000000UL, 0x3fc44a44UL,
-  0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL, 0x3fc40304UL, 0xcf1d3eabUL,
-  0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL, 0x79aba3eaUL, 0xbdf1b7c8UL,
-  0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL, 0xbe5130cfUL, 0x80000000UL,
-  0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL, 0x00000000UL, 0x3fc2e716UL,
-  0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL, 0x3fc2a05eUL, 0x6caed92eUL,
-  0xbe533924UL, 0x00000000UL, 0x3fc259c2UL, 0x9cb5034eUL, 0xbe510e31UL,
-  0x80000000UL, 0x3fc21340UL, 0x12c4d378UL, 0xbe540b43UL, 0x80000000UL,
-  0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL, 0x00000000UL, 0x3fc1868eUL,
-  0x921f4106UL, 0xbe528e67UL, 0x80000000UL, 0x3fc1405cUL, 0x3969441eUL,
-  0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL, 0xd941ef5bUL, 0x3e5f9079UL,
-  0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL, 0xbe567691UL, 0x00000000UL,
-  0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL, 0x00000000UL, 0x3fc028a2UL,
-  0x0a92a162UL, 0xbe52f394UL, 0x00000000UL, 0x3fbfc5eaUL, 0x209897e5UL,
-  0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL, 0x8458bd7bUL, 0x3e582831UL,
-  0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL, 0xbe486b4aUL, 0x00000000UL,
-  0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL, 0x00000000UL, 0x3fbd9a90UL,
-  0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL, 0x3fbd103cUL, 0x73eb6ab7UL,
-  0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL, 0x32ceaff5UL, 0xbe32dc5aUL,
-  0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL, 0xbe4a71a4UL, 0x00000000UL,
-  0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL, 0x00000000UL, 0x3fbae8eeUL,
-  0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL, 0x3fba5f9aUL, 0x95ce1114UL,
-  0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL, 0x6d7c0f78UL, 0x3e3abc2dUL,
-  0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL, 0xbe566cbcUL, 0x00000000UL,
-  0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL, 0x00000000UL, 0x3fb83c4aUL,
-  0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL, 0x3fb7b3f4UL, 0x2193d81eUL,
-  0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL, 0xdd70c122UL, 0x3e527a8cUL,
-  0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL, 0xbe450393UL, 0x00000000UL,
-  0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL, 0x00000000UL, 0x3fb59492UL,
-  0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL, 0x3fb50d36UL, 0x950f9f45UL,
-  0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL, 0x582cdcb1UL, 0x3e506d39UL,
-  0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL, 0x3e4aa719UL, 0x00000000UL,
-  0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL, 0x00000000UL, 0x3fb2f1b4UL,
-  0x7a138b41UL, 0xbe50b418UL, 0x00000000UL, 0x3fb26b4eUL, 0x2fbfd7eaUL,
-  0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL, 0x18913ccbUL, 0x3e465fc1UL,
-  0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL, 0x3e042843UL, 0x00000000UL,
-  0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL, 0x00000000UL, 0x3fb0539eUL,
-  0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL, 0x3faf9c56UL, 0x1777f657UL,
-  0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL, 0xc317b86aUL, 0xbe5a61e0UL,
-  0x00000000UL, 0x3fad87acUL, 0xb7664efbUL, 0xbe41f64eUL, 0x00000000UL,
-  0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL, 0x00000000UL, 0x3fab7480UL,
-  0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL, 0x3faa6b78UL, 0x06a253f1UL,
-  0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL, 0xa35f541bUL, 0x3e5a187aUL,
-  0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL, 0xbe508150UL, 0x00000000UL,
-  0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL, 0x00000000UL, 0x3fa64b10UL,
-  0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL, 0x3fa543e2UL, 0x97506fefUL,
-  0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL, 0xe75f7dd9UL, 0xbe388dd3UL,
-  0x00000000UL, 0x3fa3369cUL, 0xa4139632UL, 0xbdea5177UL, 0x00000000UL,
-  0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL, 0x00000000UL, 0x3fa12accUL,
-  0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL, 0x3fa0256eUL, 0x7478da78UL,
-  0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL, 0xf59cef7fUL, 0xbe539d0aUL,
-  0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL, 0x3e53c2c8UL, 0x00000000UL,
-  0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL, 0x00000000UL, 0x3f982724UL,
-  0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL, 0x3f962000UL, 0x130d9356UL,
-  0x3e475ba0UL, 0x00000000UL, 0x3f941994UL, 0x8f86f883UL, 0xbe513d0bUL,
-  0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL, 0xbe534335UL, 0x00000000UL,
-  0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL, 0x00000000UL, 0x3f8c1510UL,
-  0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL, 0x3f880de0UL, 0x8a27857eUL,
-  0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL, 0xda767328UL, 0x3e531b3dUL,
-  0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL, 0xbe5f04e3UL, 0x00000000UL,
-  0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL, 0x00000000UL, 0x3f6ffc40UL,
-  0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL, 0x3f5ff6c0UL, 0x1ad218afUL,
-  0xbe4c78a7UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL,
-  0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL, 0x00000000UL,
-  0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL, 0x6dc96112UL, 0xbf836578UL,
-  0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL,
-  0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL,
-  0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL, 0x9f95985aUL,
-  0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL, 0x486ececbUL, 0x3fc4635eUL,
-  0x412055ccUL, 0xbdd61bb2UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL,
-  0xffffffffUL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL,
-  0xfa5abcbfUL, 0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL,
-  0x3ff0163dUL, 0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL,
-  0x0fc54eb6UL, 0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL,
-  0xbc719083UL, 0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL,
-  0xe86e7f85UL, 0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL,
-  0x3ff04e5fUL, 0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL,
-  0xa475b465UL, 0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL,
-  0xbc95cb7bUL, 0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL,
-  0x2b72a836UL, 0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL,
-  0x3ff08745UL, 0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL,
-  0x800a3fd1UL, 0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL,
-  0x3c914878UL, 0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL,
-  0x6cf9890fUL, 0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL,
-  0x3ff0c0f1UL, 0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL,
-  0x16e24f71UL, 0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL,
-  0xbc9bc14dUL, 0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL,
-  0x5fdfa9c5UL, 0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL,
-  0x3ff0fb66UL, 0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL,
-  0x1692fdd5UL, 0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL,
-  0xbc96c510UL, 0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL,
-  0xc06c31ccUL, 0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL,
-  0x3ff136a8UL, 0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL,
-  0x9af1369eUL, 0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL,
-  0xbc8b91e8UL, 0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL,
-  0x5471c3c2UL, 0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL,
-  0x3ff172b8UL, 0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL,
-  0xe2ac5a64UL, 0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL,
-  0xbc911023UL, 0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL,
-  0xeb6fcb75UL, 0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL,
-  0x3ff1af99UL, 0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL,
-  0x352ef607UL, 0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL,
-  0x3c900977UL, 0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL,
-  0x5eb44027UL, 0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL,
-  0x3ff1ed50UL, 0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL,
-  0xa097af5cUL, 0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL,
-  0x3c8dc775UL, 0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL,
-  0x917ddc96UL, 0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL,
-  0x3ff22bddUL, 0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL,
-  0xb6c70573UL, 0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL,
-  0x3c8acfccUL, 0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL,
-  0x711ece75UL, 0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL,
-  0x3ff26b45UL, 0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL,
-  0x05f9e76cUL, 0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL,
-  0xbc9a4c3aUL, 0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL,
-  0xf51fdee1UL, 0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL,
-  0x3ff2ab8aUL, 0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL,
-  0xd6381aa4UL, 0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL,
-  0xbc950145UL, 0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL,
-  0x1f641589UL, 0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL,
-  0x3ff2ecafUL, 0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL,
-  0x532bda93UL, 0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL,
-  0x3c86f46aUL, 0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL,
-  0xfc4cd831UL, 0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL,
-  0x3ff32eb8UL, 0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL,
-  0x843659a6UL, 0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL,
-  0xbc835a75UL, 0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL,
-  0xa2de883bUL, 0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL,
-  0x3ff371a7UL, 0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL,
-  0x9eceb23cUL, 0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL,
-  0xbc9e958dUL, 0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL,
-  0x34e59ff7UL, 0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL,
-  0x3ff3b57fUL, 0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL,
-  0x375d29c3UL, 0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL,
-  0x3c7fe8d0UL, 0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL,
-  0xdf1c5175UL, 0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL,
-  0x3ff3fa45UL, 0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL,
-  0xb6f4d048UL, 0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL,
-  0xbc5ef369UL, 0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL,
-  0xd950a897UL, 0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL,
-  0x3ff43ffaUL, 0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL,
-  0x04ef80d0UL, 0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL,
-  0xbc686419UL, 0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL,
-  0x668b3237UL, 0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL,
-  0x3ff486a2UL, 0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL,
-  0x5e499ea0UL, 0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL,
-  0x3c99cb62UL, 0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL,
-  0xd5362a27UL, 0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL,
-  0x3ff4ce41UL, 0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL,
-  0xbc6a7833UL, 0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL,
-  0xbc95257dUL, 0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL,
-  0x7f4531eeUL, 0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL,
-  0x3ff516daUL, 0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL,
-  0x43efef71UL, 0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL,
-  0xbc807abeUL, 0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL,
-  0xca5d920fUL, 0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL,
-  0x3ff56070UL, 0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL,
-  0x011d93adUL, 0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL,
-  0xbc90b98cUL, 0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL,
-  0x27ff07ccUL, 0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL,
-  0x3ff5ab07UL, 0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL,
-  0x4c233e1aUL, 0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL,
-  0x3c3c4b1bUL, 0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL,
-  0x15ad2148UL, 0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL,
-  0x3ff5f6a3UL, 0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL,
-  0x9b56de47UL, 0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL,
-  0x3c9e4b3eUL, 0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL,
-  0x1d1929fdUL, 0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL,
-  0x3ff64346UL, 0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL,
-  0xc9a73e09UL, 0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL,
-  0xbc9bb609UL, 0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL,
-  0xd44ca973UL, 0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL,
-  0x3ff690f4UL, 0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL,
-  0x13b26456UL, 0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL,
-  0x3c7a38f5UL, 0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL,
-  0xddd47645UL, 0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL,
-  0x3ff6dfb2UL, 0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL,
-  0x9e1ac8b2UL, 0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL,
-  0xbc883c0fUL, 0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL,
-  0xe8ec5f74UL, 0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL,
-  0x3ff72f82UL, 0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL,
-  0x6c65d53cUL, 0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL,
-  0x3c9047fdUL, 0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL,
-  0xb1ab6e09UL, 0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL,
-  0x3ff78069UL, 0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL,
-  0x62aadd3eUL, 0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL,
-  0xbc841577UL, 0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL,
-  0x0130c132UL, 0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL,
-  0x3ff7d26aUL, 0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL,
-  0xba15797eUL, 0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL,
-  0xbc807f11UL, 0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL,
-  0xadd106d9UL, 0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL,
-  0x3ff82589UL, 0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL,
-  0x31df2bd5UL, 0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL,
-  0xbc88d684UL, 0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL,
-  0x9b4492edUL, 0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL,
-  0x3ff879caUL, 0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL,
-  0xf37cb53aUL, 0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL,
-  0x3c9d5395UL, 0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL,
-  0xbad61778UL, 0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL,
-  0x3ff8cf32UL, 0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL,
-  0x6fc9b2e6UL, 0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL,
-  0x3c85cc13UL, 0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL,
-  0x0b91ffc6UL, 0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL,
-  0x3ff925c3UL, 0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL,
-  0x81b57ebcUL, 0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL,
-  0xbc8dc3d6UL, 0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL,
-  0x9a7670b3UL, 0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL,
-  0x3ff97d82UL, 0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL,
-  0xa24c78ecUL, 0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL,
-  0xbc9173bdUL, 0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL,
-  0x82a3f090UL, 0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL,
-  0x3ff9d674UL, 0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL,
-  0x78e64c6eUL, 0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL,
-  0xbc84a9ceUL, 0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL,
-  0xed8eb8bbUL, 0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL,
-  0x3ffa309bUL, 0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL,
-  0x589fb120UL, 0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL,
-  0xbc9d2f6eUL, 0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL,
-  0x1330b358UL, 0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL,
-  0x3ffa8bfeUL, 0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL,
-  0x0ef7fd31UL, 0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL,
-  0x3c889c31UL, 0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL,
-  0x3a3c2774UL, 0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL,
-  0x3ffae89fUL, 0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL,
-  0x0f315ecdUL, 0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL,
-  0xbc9bdef5UL, 0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL,
-  0xb84f15fbUL, 0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL,
-  0x3ffb4684UL, 0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL,
-  0xbbba6de3UL, 0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL,
-  0x3c92a8f3UL, 0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL,
-  0xf22749e4UL, 0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL,
-  0x3ffba5b0UL, 0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL,
-  0xc9696205UL, 0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL,
-  0x3c823dd0UL, 0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL,
-  0x5bd71e09UL, 0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL,
-  0x3ffc0628UL, 0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL,
-  0x895048ddUL, 0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL,
-  0xbc96e516UL, 0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL,
-  0x78fafb22UL, 0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL,
-  0x3ffc67f1UL, 0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL,
-  0xbe255559UL, 0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL,
-  0x3c71acbcUL, 0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL,
-  0xdcef9069UL, 0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL,
-  0x3ffccb0fUL, 0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL,
-  0x53829d72UL, 0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL,
-  0xbc9a08e9UL, 0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL,
-  0x2b08c968UL, 0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL,
-  0x3ffd2f87UL, 0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL,
-  0xbf5a1614UL, 0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL,
-  0x3c82ed02UL, 0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL,
-  0x16c98398UL, 0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL,
-  0x3ffd955dUL, 0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL,
-  0x696db532UL, 0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL,
-  0xbc9b76f1UL, 0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL,
-  0x641c0658UL, 0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL,
-  0x3ffdfc97UL, 0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL,
-  0xbd5c7f44UL, 0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL,
-  0xbc97b627UL, 0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL,
-  0xe78b3ff6UL, 0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL,
-  0x3ffe6539UL, 0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL,
-  0xca0c8de2UL, 0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL,
-  0xbc910894UL, 0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL,
-  0x867cca6eUL, 0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL,
-  0x3ffecf48UL, 0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL,
-  0xa487568dUL, 0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL,
-  0x3c9dc7f4UL, 0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL,
-  0x376bba97UL, 0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL,
-  0x3fff3ac9UL, 0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL,
-  0x2dd8a18bUL, 0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL,
-  0x3c9fa37bUL, 0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL,
-  0x02243c89UL, 0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL,
-  0x3fffa7c1UL, 0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL,
-  0x15098eb6UL, 0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL,
-  0x3c62eb74UL, 0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL,
-  0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL,
-  0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL,
-  0x00000000UL, 0x00000000UL, 0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL,
-  0xbfe62e42UL, 0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL,
-  0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL
-
-};
-
-//registers,
-// input: xmm0, xmm1
-// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
-//          eax, edx, ecx, ebx
-
-// Code generated by Intel C compiler for LIBM library
-
-void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
-  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
-  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2;
-  Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2;
-  Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2;
-  Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2;
-  Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2;
-  Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2;
-  Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2;
-  Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2;
-  Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2;
-  Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2;
-  Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2;
-  Label L_2TAG_PACKET_56_0_2, L_2TAG_PACKET_57_0_2, L_2TAG_PACKET_58_0_2, start;
-
-  assert_different_registers(tmp, eax, ecx, edx);
-
-  address static_const_table_pow = (address)_static_const_table_pow;
-
-  bind(start);
-  subl(rsp, 120);
-  movl(Address(rsp, 64), tmp);
-  lea(tmp, ExternalAddress(static_const_table_pow));
-  movsd(xmm0, Address(rsp, 128));
-  movsd(xmm1, Address(rsp, 136));
-  xorpd(xmm2, xmm2);
-  movl(eax, 16368);
-  pinsrw(xmm2, eax, 3);
-  movl(ecx, 1069088768);
-  movdl(xmm7, ecx);
-  movsd(Address(rsp, 16), xmm1);
-  xorpd(xmm1, xmm1);
-  movl(edx, 30704);
-  pinsrw(xmm1, edx, 3);
-  movsd(Address(rsp, 8), xmm0);
-  movdqu(xmm3, xmm0);
-  movl(edx, 8192);
-  movdl(xmm4, edx);
-  movdqu(xmm6, Address(tmp, 8240));
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  psllq(xmm0, 5);
-  movsd(xmm2, Address(tmp, 8256));
-  psrlq(xmm0, 34);
-  movl(edx, eax);
-  andl(edx, 32752);
-  subl(edx, 16368);
-  movl(ecx, edx);
-  sarl(edx, 31);
-  addl(ecx, edx);
-  xorl(ecx, edx);
-  rcpss(xmm0, xmm0);
-  psllq(xmm3, 12);
-  addl(ecx, 16);
-  bsrl(ecx, ecx);
-  psrlq(xmm3, 12);
-  movl(Address(rsp, 24), rsi);
-  subl(eax, 16);
-  cmpl(eax, 32736);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
-  movl(rsi, 0);
-
-  bind(L_2TAG_PACKET_1_0_2);
-  mulss(xmm0, xmm7);
-  movl(edx, -1);
-  subl(ecx, 4);
-  shll(edx);
-  movdl(xmm5, edx);
-  por(xmm3, xmm1);
-  subl(eax, 16351);
-  cmpl(eax, 1);
-  jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2);
-  paddd(xmm0, xmm4);
-  psllq(xmm5, 32);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  pand(xmm5, xmm3);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  pand(xmm0, xmm6);
-  subsd(xmm3, xmm5);
-  subl(eax, 1);
-  sarl(eax, 4);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-
-  bind(L_2TAG_PACKET_4_0_2);
-  mulsd(xmm3, xmm0);
-  movdqu(xmm1, Address(tmp, 8272));
-  subsd(xmm5, xmm2);
-  movdqu(xmm4, Address(tmp, 8288));
-  movl(ecx, eax);
-  sarl(eax, 31);
-  addl(ecx, eax);
-  xorl(eax, ecx);
-  addl(eax, 1);
-  bsrl(eax, eax);
-  unpcklpd(xmm5, xmm3);
-  movdqu(xmm6, Address(tmp, 8304));
-  addsd(xmm3, xmm5);
-  andl(edx, 16760832);
-  shrl(edx, 10);
-  addpd(xmm5, Address(tmp, edx, Address::times_1, -3616));
-  movdqu(xmm0, Address(tmp, 8320));
-  pshufd(xmm2, xmm3, 68);
-  mulsd(xmm3, xmm3);
-  mulpd(xmm1, xmm2);
-  mulpd(xmm4, xmm2);
-  addsd(xmm5, xmm7);
-  mulsd(xmm2, xmm3);
-  addpd(xmm6, xmm1);
-  mulsd(xmm3, xmm3);
-  addpd(xmm0, xmm4);
-  movsd(xmm1, Address(rsp, 16));
-  movzwl(ecx, Address(rsp, 22));
-  pshufd(xmm7, xmm5, 238);
-  movsd(xmm4, Address(tmp, 8368));
-  mulpd(xmm6, xmm2);
-  pshufd(xmm3, xmm3, 68);
-  mulpd(xmm0, xmm2);
-  shll(eax, 4);
-  subl(eax, 15872);
-  andl(ecx, 32752);
-  addl(eax, ecx);
-  mulpd(xmm3, xmm6);
-  cmpl(eax, 624);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2);
-  xorpd(xmm6, xmm6);
-  movl(edx, 17080);
-  pinsrw(xmm6, edx, 3);
-  movdqu(xmm2, xmm1);
-  pand(xmm4, xmm1);
-  subsd(xmm1, xmm4);
-  mulsd(xmm4, xmm5);
-  addsd(xmm0, xmm7);
-  mulsd(xmm1, xmm5);
-  movdqu(xmm7, xmm6);
-  addsd(xmm6, xmm4);
-  addpd(xmm3, xmm0);
-  movdl(edx, xmm6);
-  subsd(xmm6, xmm7);
-  pshufd(xmm0, xmm3, 238);
-  subsd(xmm4, xmm6);
-  addsd(xmm0, xmm3);
-  movl(ecx, edx);
-  andl(edx, 255);
-  addl(edx, edx);
-  movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384));
-  addsd(xmm4, xmm1);
-  mulsd(xmm2, xmm0);
-  movdqu(xmm7, Address(tmp, 12480));
-  movdqu(xmm3, Address(tmp, 12496));
-  shll(ecx, 12);
-  xorl(ecx, rsi);
-  andl(ecx, -1048576);
-  movdl(xmm6, ecx);
-  addsd(xmm2, xmm4);
-  movsd(xmm1, Address(tmp, 12512));
-  pshufd(xmm0, xmm2, 68);
-  pshufd(xmm4, xmm2, 68);
-  mulpd(xmm0, xmm0);
-  movl(rsi, Address(rsp, 24));
-  mulpd(xmm7, xmm4);
-  pshufd(xmm6, xmm6, 17);
-  mulsd(xmm1, xmm2);
-  mulsd(xmm0, xmm0);
-  paddd(xmm5, xmm6);
-  addpd(xmm3, xmm7);
-  mulsd(xmm1, xmm5);
-  pshufd(xmm6, xmm5, 238);
-  mulpd(xmm0, xmm3);
-  addsd(xmm1, xmm6);
-  pshufd(xmm3, xmm0, 238);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm3, xmm5);
-  addsd(xmm0, xmm1);
-  addsd(xmm0, xmm3);
-  addsd(xmm0, xmm5);
-  movsd(Address(rsp, 0), xmm0);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_7_0_2);
-  movsd(xmm0, Address(rsp, 128));
-  movsd(xmm1, Address(rsp, 136));
-  mulsd(xmm0, xmm1);
-  movsd(Address(rsp, 0), xmm0);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  addl(eax, 16);
-  movl(edx, 32752);
-  andl(edx, eax);
-  cmpl(edx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
-  testl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_2);
-
-  bind(L_2TAG_PACKET_10_0_2);
-  movl(ecx, Address(rsp, 16));
-  xorl(edx, edx);
-  testl(ecx, ecx);
-  movl(ecx, 1);
-  cmovl(Assembler::notEqual, edx, ecx);
-  orl(edx, Address(rsp, 20));
-  cmpl(edx, 1072693248);
-  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
-  movsd(xmm0, Address(rsp, 8));
-  movsd(xmm3, Address(rsp, 8));
-  movdl(edx, xmm3);
-  psrlq(xmm3, 32);
-  movdl(ecx, xmm3);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_11_0_2);
-  xorpd(xmm3, xmm3);
-  movl(eax, 18416);
-  pinsrw(xmm3, eax, 3);
-  mulsd(xmm0, xmm3);
-  xorpd(xmm2, xmm2);
-  movl(eax, 16368);
-  pinsrw(xmm2, eax, 3);
-  movdqu(xmm3, xmm0);
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  movl(ecx, 18416);
-  psllq(xmm0, 5);
-  movsd(xmm2, Address(tmp, 8256));
-  psrlq(xmm0, 34);
-  rcpss(xmm0, xmm0);
-  psllq(xmm3, 12);
-  movdqu(xmm6, Address(tmp, 8240));
-  psrlq(xmm3, 12);
-  mulss(xmm0, xmm7);
-  movl(edx, -1024);
-  movdl(xmm5, edx);
-  por(xmm3, xmm1);
-  paddd(xmm0, xmm4);
-  psllq(xmm5, 32);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  pand(xmm5, xmm3);
-  movl(rsi, 0);
-  pand(xmm0, xmm6);
-  subsd(xmm3, xmm5);
-  andl(eax, 32752);
-  subl(eax, 18416);
-  sarl(eax, 4);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-  jmp(L_2TAG_PACKET_4_0_2);
-
-  bind(L_2TAG_PACKET_12_0_2);
-  movl(ecx, Address(rsp, 16));
-  xorl(edx, edx);
-  testl(ecx, ecx);
-  movl(ecx, 1);
-  cmovl(Assembler::notEqual, edx, ecx);
-  orl(edx, Address(rsp, 20));
-  cmpl(edx, 1072693248);
-  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
-  movsd(xmm0, Address(rsp, 8));
-  movsd(xmm3, Address(rsp, 8));
-  movdl(edx, xmm3);
-  psrlq(xmm3, 32);
-  movdl(ecx, xmm3);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_11_0_2);
-  xorpd(xmm3, xmm3);
-  movl(eax, 18416);
-  pinsrw(xmm3, eax, 3);
-  mulsd(xmm0, xmm3);
-  xorpd(xmm2, xmm2);
-  movl(eax, 16368);
-  pinsrw(xmm2, eax, 3);
-  movdqu(xmm3, xmm0);
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  movl(ecx, 18416);
-  psllq(xmm0, 5);
-  movsd(xmm2, Address(tmp, 8256));
-  psrlq(xmm0, 34);
-  rcpss(xmm0, xmm0);
-  psllq(xmm3, 12);
-  movdqu(xmm6, Address(tmp, 8240));
-  psrlq(xmm3, 12);
-  mulss(xmm0, xmm7);
-  movl(edx, -1024);
-  movdl(xmm5, edx);
-  por(xmm3, xmm1);
-  paddd(xmm0, xmm4);
-  psllq(xmm5, 32);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  pand(xmm5, xmm3);
-  movl(rsi, INT_MIN);
-  pand(xmm0, xmm6);
-  subsd(xmm3, xmm5);
-  andl(eax, 32752);
-  subl(eax, 18416);
-  sarl(eax, 4);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-  jmp(L_2TAG_PACKET_4_0_2);
-
-  bind(L_2TAG_PACKET_5_0_2);
-  cmpl(eax, 0);
-  jcc(Assembler::less, L_2TAG_PACKET_13_0_2);
-  cmpl(eax, 752);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_14_0_2);
-
-  bind(L_2TAG_PACKET_15_0_2);
-  addsd(xmm0, xmm7);
-  movsd(xmm2, Address(tmp, 12544));
-  addpd(xmm3, xmm0);
-  xorpd(xmm6, xmm6);
-  movl(eax, 17080);
-  pinsrw(xmm6, eax, 3);
-  pshufd(xmm0, xmm3, 238);
-  addsd(xmm0, xmm3);
-  movdqu(xmm3, xmm5);
-  addsd(xmm5, xmm0);
-  movdqu(xmm4, xmm2);
-  subsd(xmm3, xmm5);
-  movdqu(xmm7, xmm5);
-  pand(xmm5, xmm2);
-  movdqu(xmm2, xmm1);
-  pand(xmm4, xmm1);
-  subsd(xmm7, xmm5);
-  addsd(xmm0, xmm3);
-  subsd(xmm1, xmm4);
-  mulsd(xmm4, xmm5);
-  addsd(xmm0, xmm7);
-  mulsd(xmm2, xmm0);
-  movdqu(xmm7, xmm6);
-  mulsd(xmm1, xmm5);
-  addsd(xmm6, xmm4);
-  movdl(eax, xmm6);
-  subsd(xmm6, xmm7);
-  addsd(xmm2, xmm1);
-  movdqu(xmm7, Address(tmp, 12480));
-  movdqu(xmm3, Address(tmp, 12496));
-  subsd(xmm4, xmm6);
-  pextrw(edx, xmm6, 3);
-  movl(ecx, eax);
-  andl(eax, 255);
-  addl(eax, eax);
-  movdqu(xmm5, Address(tmp, eax, Address::times_8, 8384));
-  addsd(xmm2, xmm4);
-  sarl(ecx, 8);
-  movl(eax, ecx);
-  sarl(ecx, 1);
-  subl(eax, ecx);
-  shll(ecx, 20);
-  xorl(ecx, rsi);
-  movdl(xmm6, ecx);
-  movsd(xmm1, Address(tmp, 12512));
-  andl(edx, 32767);
-  cmpl(edx, 16529);
-  jcc(Assembler::above, L_2TAG_PACKET_14_0_2);
-  pshufd(xmm0, xmm2, 68);
-  pshufd(xmm4, xmm2, 68);
-  mulpd(xmm0, xmm0);
-  mulpd(xmm7, xmm4);
-  pshufd(xmm6, xmm6, 17);
-  mulsd(xmm1, xmm2);
-  mulsd(xmm0, xmm0);
-  paddd(xmm5, xmm6);
-  addpd(xmm3, xmm7);
-  mulsd(xmm1, xmm5);
-  pshufd(xmm6, xmm5, 238);
-  mulpd(xmm0, xmm3);
-  addsd(xmm1, xmm6);
-  pshufd(xmm3, xmm0, 238);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm3, xmm5);
-  shll(eax, 4);
-  xorpd(xmm4, xmm4);
-  addl(eax, 16368);
-  pinsrw(xmm4, eax, 3);
-  addsd(xmm0, xmm1);
-  movl(rsi, Address(rsp, 24));
-  addsd(xmm0, xmm3);
-  movdqu(xmm1, xmm0);
-  addsd(xmm0, xmm5);
-  mulsd(xmm0, xmm4);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_16_0_2);
-  cmpl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_18_0_2);
-  movsd(Address(rsp, 0), xmm0);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_8_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  movsd(xmm0, Address(rsp, 8));
-  movdqu(xmm2, xmm0);
-  movdl(eax, xmm2);
-  psrlq(xmm2, 20);
-  movdl(edx, xmm2);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_19_0_2);
-  addsd(xmm0, xmm0);
-  movdl(eax, xmm1);
-  psrlq(xmm1, 32);
-  movdl(edx, xmm1);
-  movl(ecx, edx);
-  addl(edx, edx);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_20_0_2);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_20_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  movl(edx, 29);
-  jmp(L_2TAG_PACKET_21_0_2);
-
-  bind(L_2TAG_PACKET_22_0_2);
-  movsd(xmm0, Address(rsp, 16));
-  addpd(xmm0, xmm0);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_19_0_2);
-  movdl(eax, xmm1);
-  movdqu(xmm2, xmm1);
-  psrlq(xmm1, 32);
-  movdl(edx, xmm1);
-  movl(ecx, edx);
-  addl(edx, edx);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_23_0_2);
-  pextrw(eax, xmm2, 3);
-  andl(eax, 32752);
-  cmpl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2);
-  movdl(eax, xmm2);
-  psrlq(xmm2, 20);
-  movdl(edx, xmm2);
-  orl(eax, edx);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
-
-  bind(L_2TAG_PACKET_24_0_2);
-  pextrw(eax, xmm0, 3);
-  testl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2);
-  testl(ecx, INT_MIN);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_27_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  movdl(eax, xmm1);
-  testl(eax, 1);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2);
-  testl(eax, 2);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_29_0_2);
-  jmp(L_2TAG_PACKET_28_0_2);
-
-  bind(L_2TAG_PACKET_25_0_2);
-  shrl(ecx, 20);
-  andl(ecx, 2047);
-  cmpl(ecx, 1075);
-  jcc(Assembler::above, L_2TAG_PACKET_28_0_2);
-  jcc(Assembler::equal, L_2TAG_PACKET_30_0_2);
-  cmpl(ecx, 1074);
-  jcc(Assembler::above, L_2TAG_PACKET_27_0_2);
-  cmpl(ecx, 1023);
-  jcc(Assembler::below, L_2TAG_PACKET_28_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  movl(eax, 17208);
-  xorpd(xmm3, xmm3);
-  pinsrw(xmm3, eax, 3);
-  movdqu(xmm4, xmm3);
-  addsd(xmm3, xmm1);
-  subsd(xmm4, xmm3);
-  addsd(xmm1, xmm4);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2);
-  movdl(eax, xmm3);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_28_0_2);
-
-  bind(L_2TAG_PACKET_29_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32768);
-  jcc(Assembler::equal, L_2TAG_PACKET_18_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32768);
-  pinsrw(xmm0, eax, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_28_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2);
-
-  bind(L_2TAG_PACKET_31_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32752);
-  pinsrw(xmm0, eax, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_30_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  movdl(eax, xmm1);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_28_0_2);
-  jmp(L_2TAG_PACKET_29_0_2);
-
-  bind(L_2TAG_PACKET_32_0_2);
-  movdl(eax, xmm1);
-  psrlq(xmm1, 20);
-  movdl(edx, xmm1);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_33_0_2);
-  movsd(xmm0, Address(rsp, 16));
-  addsd(xmm0, xmm0);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_33_0_2);
-  movsd(xmm0, Address(rsp, 8));
-  pextrw(eax, xmm0, 3);
-  cmpl(eax, 49136);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
-  movdl(ecx, xmm0);
-  psrlq(xmm0, 20);
-  movdl(edx, xmm0);
-  orl(ecx, edx);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32760);
-  pinsrw(xmm0, eax, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_34_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  andl(eax, 32752);
-  subl(eax, 16368);
-  pextrw(edx, xmm1, 3);
-  xorpd(xmm0, xmm0);
-  xorl(eax, edx);
-  andl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
-  movl(ecx, 32752);
-  pinsrw(xmm0, ecx, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_35_0_2);
-  movdl(eax, xmm1);
-  cmpl(edx, 17184);
-  jcc(Assembler::above, L_2TAG_PACKET_36_0_2);
-  testl(eax, 1);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2);
-  testl(eax, 2);
-  jcc(Assembler::equal, L_2TAG_PACKET_38_0_2);
-  jmp(L_2TAG_PACKET_39_0_2);
-
-  bind(L_2TAG_PACKET_36_0_2);
-  testl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_38_0_2);
-  jmp(L_2TAG_PACKET_39_0_2);
-
-  bind(L_2TAG_PACKET_9_0_2);
-  movsd(xmm2, Address(rsp, 8));
-  movdl(eax, xmm2);
-  psrlq(xmm2, 31);
-  movdl(ecx, xmm2);
-  orl(eax, ecx);
-  jcc(Assembler::equal, L_2TAG_PACKET_11_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  pextrw(edx, xmm1, 3);
-  movdl(eax, xmm1);
-  movdqu(xmm2, xmm1);
-  psrlq(xmm2, 32);
-  movdl(ecx, xmm2);
-  addl(ecx, ecx);
-  orl(ecx, eax);
-  jcc(Assembler::equal, L_2TAG_PACKET_40_0_2);
-  andl(edx, 32752);
-  cmpl(edx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_32_0_2);
-  cmpl(edx, 17200);
-  jcc(Assembler::above, L_2TAG_PACKET_38_0_2);
-  cmpl(edx, 17184);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_35_0_2);
-  cmpl(edx, 16368);
-  jcc(Assembler::below, L_2TAG_PACKET_37_0_2);
-  movl(eax, 17208);
-  xorpd(xmm2, xmm2);
-  pinsrw(xmm2, eax, 3);
-  movdqu(xmm4, xmm2);
-  addsd(xmm2, xmm1);
-  subsd(xmm4, xmm2);
-  addsd(xmm1, xmm4);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32767);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2);
-  movdl(eax, xmm2);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_38_0_2);
-
-  bind(L_2TAG_PACKET_39_0_2);
-  xorpd(xmm1, xmm1);
-  movl(edx, 30704);
-  pinsrw(xmm1, edx, 3);
-  movsd(xmm2, Address(tmp, 8256));
-  movsd(xmm4, Address(rsp, 8));
-  pextrw(eax, xmm4, 3);
-  movl(edx, 8192);
-  movdl(xmm4, edx);
-  andl(eax, 32767);
-  subl(eax, 16);
-  jcc(Assembler::less, L_2TAG_PACKET_12_0_2);
-  movl(edx, eax);
-  andl(edx, 32752);
-  subl(edx, 16368);
-  movl(ecx, edx);
-  sarl(edx, 31);
-  addl(ecx, edx);
-  xorl(ecx, edx);
-  addl(ecx, 16);
-  bsrl(ecx, ecx);
-  movl(rsi, INT_MIN);
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_37_0_2);
-  xorpd(xmm1, xmm1);
-  movl(eax, 32752);
-  pinsrw(xmm1, eax, 3);
-  xorpd(xmm0, xmm0);
-  mulsd(xmm0, xmm1);
-  movl(edx, 28);
-  jmp(L_2TAG_PACKET_21_0_2);
-
-  bind(L_2TAG_PACKET_38_0_2);
-  xorpd(xmm1, xmm1);
-  movl(edx, 30704);
-  pinsrw(xmm1, edx, 3);
-  movsd(xmm2, Address(tmp, 8256));
-  movsd(xmm4, Address(rsp, 8));
-  pextrw(eax, xmm4, 3);
-  movl(edx, 8192);
-  movdl(xmm4, edx);
-  andl(eax, 32767);
-  subl(eax, 16);
-  jcc(Assembler::less, L_2TAG_PACKET_10_0_2);
-  movl(edx, eax);
-  andl(edx, 32752);
-  subl(edx, 16368);
-  movl(ecx, edx);
-  sarl(edx, 31);
-  addl(ecx, edx);
-  xorl(ecx, edx);
-  addl(ecx, 16);
-  bsrl(ecx, ecx);
-  movl(rsi, 0);
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_23_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_26_0_2);
-  xorpd(xmm0, xmm0);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_13_0_2);
-  addl(eax, 384);
-  cmpl(eax, 0);
-  jcc(Assembler::less, L_2TAG_PACKET_41_0_2);
-  mulsd(xmm5, xmm1);
-  addsd(xmm0, xmm7);
-  shrl(rsi, 31);
-  addpd(xmm3, xmm0);
-  pshufd(xmm0, xmm3, 238);
-  addsd(xmm3, xmm0);
-  movsd(xmm4, Address(tmp, rsi, Address::times_8, 12528));
-  mulsd(xmm1, xmm3);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  shll(rsi, 15);
-  orl(eax, rsi);
-  pinsrw(xmm0, eax, 3);
-  addsd(xmm5, xmm1);
-  movl(rsi, Address(rsp, 24));
-  mulsd(xmm5, xmm4);
-  addsd(xmm0, xmm5);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_41_0_2);
-  movl(rsi, Address(rsp, 24));
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_40_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_42_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  movl(edx, 26);
-  jmp(L_2TAG_PACKET_21_0_2);
-
-  bind(L_2TAG_PACKET_11_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  movdqu(xmm2, xmm1);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32752);
-  cmpl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2);
-  movdl(eax, xmm2);
-  psrlq(xmm2, 20);
-  movdl(edx, xmm2);
-  orl(eax, edx);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
-
-  bind(L_2TAG_PACKET_43_0_2);
-  movdl(eax, xmm1);
-  psrlq(xmm1, 32);
-  movdl(edx, xmm1);
-  movl(ecx, edx);
-  addl(edx, edx);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_42_0_2);
-  shrl(edx, 21);
-  cmpl(edx, 1075);
-  jcc(Assembler::above, L_2TAG_PACKET_44_0_2);
-  jcc(Assembler::equal, L_2TAG_PACKET_45_0_2);
-  cmpl(edx, 1023);
-  jcc(Assembler::below, L_2TAG_PACKET_44_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  movl(eax, 17208);
-  xorpd(xmm3, xmm3);
-  pinsrw(xmm3, eax, 3);
-  movdqu(xmm4, xmm3);
-  addsd(xmm3, xmm1);
-  subsd(xmm4, xmm3);
-  addsd(xmm1, xmm4);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2);
-  movdl(eax, xmm3);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_44_0_2);
-
-  bind(L_2TAG_PACKET_46_0_2);
-  movsd(xmm0, Address(rsp, 8));
-  testl(ecx, INT_MIN);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_47_0_2);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_45_0_2);
-  movsd(xmm1, Address(rsp, 16));
-  movdl(eax, xmm1);
-  testl(eax, 1);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2);
-
-  bind(L_2TAG_PACKET_44_0_2);
-  testl(ecx, INT_MIN);
-  jcc(Assembler::equal, L_2TAG_PACKET_26_0_2);
-  xorpd(xmm0, xmm0);
-
-  bind(L_2TAG_PACKET_47_0_2);
-  movl(eax, 16368);
-  xorpd(xmm1, xmm1);
-  pinsrw(xmm1, eax, 3);
-  divsd(xmm1, xmm0);
-  movdqu(xmm0, xmm1);
-  movl(edx, 27);
-  jmp(L_2TAG_PACKET_21_0_2);
-
-  bind(L_2TAG_PACKET_14_0_2);
-  movsd(xmm2, Address(rsp, 8));
-  movsd(xmm6, Address(rsp, 16));
-  pextrw(eax, xmm2, 3);
-  pextrw(edx, xmm6, 3);
-  movl(ecx, 32752);
-  andl(ecx, edx);
-  cmpl(ecx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_48_0_2);
-  andl(eax, 32752);
-  subl(eax, 16368);
-  xorl(edx, eax);
-  testl(edx, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_49_0_2);
-
-  bind(L_2TAG_PACKET_50_0_2);
-  movl(eax, 32736);
-  pinsrw(xmm0, eax, 3);
-  shrl(rsi, 16);
-  orl(eax, rsi);
-  pinsrw(xmm1, eax, 3);
-  movl(rsi, Address(rsp, 24));
-  mulsd(xmm0, xmm1);
-
-  bind(L_2TAG_PACKET_17_0_2);
-  movl(edx, 24);
-
-  bind(L_2TAG_PACKET_21_0_2);
-  movsd(Address(rsp, 0), xmm0);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_49_0_2);
-  movl(eax, 16);
-  pinsrw(xmm0, eax, 3);
-  mulsd(xmm0, xmm0);
-  testl(rsi, INT_MIN);
-  jcc(Assembler::equal, L_2TAG_PACKET_51_0_2);
-  movsd(xmm2, Address(tmp, 12560));
-  xorpd(xmm0, xmm2);
-
-  bind(L_2TAG_PACKET_51_0_2);
-  movl(rsi, Address(rsp, 24));
-  movl(edx, 25);
-  jmp(L_2TAG_PACKET_21_0_2);
-
-  bind(L_2TAG_PACKET_16_0_2);
-  pextrw(ecx, xmm5, 3);
-  pextrw(edx, xmm4, 3);
-  movl(eax, -1);
-  andl(ecx, 32752);
-  subl(ecx, 16368);
-  andl(edx, 32752);
-  addl(edx, ecx);
-  movl(ecx, -31);
-  sarl(edx, 4);
-  subl(ecx, edx);
-  jcc(Assembler::lessEqual, L_2TAG_PACKET_52_0_2);
-  cmpl(ecx, 20);
-  jcc(Assembler::above, L_2TAG_PACKET_53_0_2);
-  shll(eax);
-
-  bind(L_2TAG_PACKET_52_0_2);
-  movdl(xmm0, eax);
-  psllq(xmm0, 32);
-  pand(xmm0, xmm5);
-  subsd(xmm5, xmm0);
-  addsd(xmm5, xmm1);
-  mulsd(xmm0, xmm4);
-  mulsd(xmm5, xmm4);
-  addsd(xmm0, xmm5);
-
-  bind(L_2TAG_PACKET_53_0_2);
-  movl(edx, 25);
-  jmp(L_2TAG_PACKET_21_0_2);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  movzwl(ecx, Address(rsp, 22));
-  movl(edx, INT_MIN);
-  movdl(xmm1, edx);
-  xorpd(xmm7, xmm7);
-  paddd(xmm0, xmm4);
-  psllq(xmm5, 32);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  paddq(xmm1, xmm3);
-  pand(xmm5, xmm1);
-  andl(ecx, 32752);
-  cmpl(ecx, 16560);
-  jcc(Assembler::below, L_2TAG_PACKET_3_0_2);
-  pand(xmm0, xmm6);
-  subsd(xmm3, xmm5);
-  addl(eax, 16351);
-  shrl(eax, 4);
-  subl(eax, 1022);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-  movsd(xmm4, Address(tmp, 0));
-  mulsd(xmm3, xmm0);
-  movsd(xmm6, Address(tmp, 0));
-  subsd(xmm5, xmm2);
-  movsd(xmm1, Address(tmp, 8));
-  pshufd(xmm2, xmm3, 68);
-  unpcklpd(xmm5, xmm3);
-  addsd(xmm3, xmm5);
-  movsd(xmm0, Address(tmp, 8));
-  andl(edx, 16760832);
-  shrl(edx, 10);
-  addpd(xmm7, Address(tmp, edx, Address::times_1, -3616));
-  mulsd(xmm4, xmm5);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm6, xmm2);
-  mulsd(xmm1, xmm2);
-  movdqu(xmm2, xmm5);
-  mulsd(xmm4, xmm5);
-  addsd(xmm5, xmm0);
-  movdqu(xmm0, xmm7);
-  addsd(xmm2, xmm3);
-  addsd(xmm7, xmm5);
-  mulsd(xmm6, xmm2);
-  subsd(xmm0, xmm7);
-  movdqu(xmm2, xmm7);
-  addsd(xmm7, xmm4);
-  addsd(xmm0, xmm5);
-  subsd(xmm2, xmm7);
-  addsd(xmm4, xmm2);
-  pshufd(xmm2, xmm5, 238);
-  movdqu(xmm5, xmm7);
-  addsd(xmm7, xmm2);
-  addsd(xmm4, xmm0);
-  movdqu(xmm0, Address(tmp, 8272));
-  subsd(xmm5, xmm7);
-  addsd(xmm6, xmm4);
-  movdqu(xmm4, xmm7);
-  addsd(xmm5, xmm2);
-  addsd(xmm7, xmm1);
-  movdqu(xmm2, Address(tmp, 8336));
-  subsd(xmm4, xmm7);
-  addsd(xmm6, xmm5);
-  addsd(xmm4, xmm1);
-  pshufd(xmm5, xmm7, 238);
-  movdqu(xmm1, xmm7);
-  addsd(xmm7, xmm5);
-  subsd(xmm1, xmm7);
-  addsd(xmm1, xmm5);
-  movdqu(xmm5, Address(tmp, 8352));
-  pshufd(xmm3, xmm3, 68);
-  addsd(xmm6, xmm4);
-  addsd(xmm6, xmm1);
-  movdqu(xmm1, Address(tmp, 8304));
-  mulpd(xmm0, xmm3);
-  mulpd(xmm2, xmm3);
-  pshufd(xmm4, xmm3, 68);
-  mulpd(xmm3, xmm3);
-  addpd(xmm0, xmm1);
-  addpd(xmm5, xmm2);
-  mulsd(xmm4, xmm3);
-  movsd(xmm2, Address(tmp, 16));
-  mulpd(xmm3, xmm3);
-  movsd(xmm1, Address(rsp, 16));
-  movzwl(ecx, Address(rsp, 22));
-  mulpd(xmm0, xmm4);
-  pextrw(eax, xmm7, 3);
-  mulpd(xmm5, xmm4);
-  mulpd(xmm0, xmm3);
-  movsd(xmm4, Address(tmp, 8376));
-  pand(xmm2, xmm7);
-  addsd(xmm5, xmm6);
-  subsd(xmm7, xmm2);
-  addpd(xmm5, xmm0);
-  andl(eax, 32752);
-  subl(eax, 16368);
-  andl(ecx, 32752);
-  cmpl(ecx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_48_0_2);
-  addl(ecx, eax);
-  cmpl(ecx, 16576);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_54_0_2);
-  pshufd(xmm0, xmm5, 238);
-  pand(xmm4, xmm1);
-  movdqu(xmm3, xmm1);
-  addsd(xmm5, xmm0);
-  subsd(xmm1, xmm4);
-  xorpd(xmm6, xmm6);
-  movl(edx, 17080);
-  pinsrw(xmm6, edx, 3);
-  addsd(xmm7, xmm5);
-  mulsd(xmm4, xmm2);
-  mulsd(xmm1, xmm2);
-  movdqu(xmm5, xmm6);
-  mulsd(xmm3, xmm7);
-  addsd(xmm6, xmm4);
-  addsd(xmm1, xmm3);
-  movdqu(xmm7, Address(tmp, 12480));
-  movdl(edx, xmm6);
-  subsd(xmm6, xmm5);
-  movdqu(xmm3, Address(tmp, 12496));
-  movsd(xmm2, Address(tmp, 12512));
-  subsd(xmm4, xmm6);
-  movl(ecx, edx);
-  andl(edx, 255);
-  addl(edx, edx);
-  movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384));
-  addsd(xmm4, xmm1);
-  pextrw(edx, xmm6, 3);
-  shrl(ecx, 8);
-  movl(eax, ecx);
-  shrl(ecx, 1);
-  subl(eax, ecx);
-  shll(ecx, 20);
-  movdl(xmm6, ecx);
-  pshufd(xmm0, xmm4, 68);
-  pshufd(xmm1, xmm4, 68);
-  mulpd(xmm0, xmm0);
-  mulpd(xmm7, xmm1);
-  pshufd(xmm6, xmm6, 17);
-  mulsd(xmm2, xmm4);
-  andl(edx, 32767);
-  cmpl(edx, 16529);
-  jcc(Assembler::above, L_2TAG_PACKET_14_0_2);
-  mulsd(xmm0, xmm0);
-  paddd(xmm5, xmm6);
-  addpd(xmm3, xmm7);
-  mulsd(xmm2, xmm5);
-  pshufd(xmm6, xmm5, 238);
-  mulpd(xmm0, xmm3);
-  addsd(xmm2, xmm6);
-  pshufd(xmm3, xmm0, 238);
-  addl(eax, 1023);
-  shll(eax, 20);
-  orl(eax, rsi);
-  movdl(xmm4, eax);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm3, xmm5);
-  addsd(xmm0, xmm2);
-  psllq(xmm4, 32);
-  addsd(xmm0, xmm3);
-  movdqu(xmm1, xmm0);
-  addsd(xmm0, xmm5);
-  movl(rsi, Address(rsp, 24));
-  mulsd(xmm0, xmm4);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_16_0_2);
-  cmpl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_55_0_2);
-  movsd(Address(rsp, 0), xmm0);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_48_0_2);
-  movl(rsi, Address(rsp, 24));
-
-  bind(L_2TAG_PACKET_56_0_2);
-  movsd(xmm0, Address(rsp, 8));
-  movsd(xmm1, Address(rsp, 16));
-  addsd(xmm1, xmm1);
-  xorpd(xmm2, xmm2);
-  movl(eax, 49136);
-  pinsrw(xmm2, eax, 3);
-  addsd(xmm2, xmm0);
-  pextrw(eax, xmm2, 3);
-  cmpl(eax, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_57_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32760);
-  pinsrw(xmm0, eax, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_57_0_2);
-  movdl(edx, xmm1);
-  movdqu(xmm3, xmm1);
-  psrlq(xmm3, 20);
-  movdl(ecx, xmm3);
-  orl(ecx, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_58_0_2);
-  addsd(xmm1, xmm1);
-  movdqu(xmm0, xmm1);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_58_0_2);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  pextrw(edx, xmm1, 3);
-  xorpd(xmm0, xmm0);
-  subl(eax, 16368);
-  xorl(eax, edx);
-  testl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
-  movl(edx, 32752);
-  pinsrw(xmm0, edx, 3);
-  jmp(L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_54_0_2);
-  pextrw(eax, xmm1, 3);
-  pextrw(ecx, xmm2, 3);
-  xorl(eax, ecx);
-  testl(eax, 32768);
-  jcc(Assembler::equal, L_2TAG_PACKET_50_0_2);
-  jmp(L_2TAG_PACKET_49_0_2);
-
-  bind(L_2TAG_PACKET_6_0_2);
-  movl(tmp, Address(rsp, 64));
-
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - SIN()
-//                     ---------------------
-//
-//     1. RANGE REDUCTION
-//
-//     We perform an initial range reduction from X to r with
-//
-//          X =~= N * pi/32 + r
-//
-//     so that |r| <= pi/64 + epsilon. We restrict inputs to those
-//     where |N| <= 932560. Beyond this, the range reduction is
-//     insufficiently accurate. For extremely small inputs,
-//     denormalization can occur internally, impacting performance.
-//     This means that the main path is actually only taken for
-//     2^-252 <= |X| < 90112.
-//
-//     To avoid branches, we perform the range reduction to full
-//     accuracy each time.
-//
-//          X - N * (P_1 + P_2 + P_3)
-//
-//     where P_1 and P_2 are 32-bit numbers (so multiplication by N
-//     is exact) and P_3 is a 53-bit number. Together, these
-//     approximate pi well enough for all cases in the restricted
-//     range.
-//
-//     The main reduction sequence is:
-//
-//             y = 32/pi * x
-//             N = integer(y)
-//     (computed by adding and subtracting off SHIFTER)
-//
-//             m_1 = N * P_1
-//             m_2 = N * P_2
-//             r_1 = x - m_1
-//             r = r_1 - m_2
-//     (this r can be used for most of the calculation)
-//
-//             c_1 = r_1 - r
-//             m_3 = N * P_3
-//             c_2 = c_1 - m_2
-//             c = c_2 - m_3
-//
-//     2. MAIN ALGORITHM
-//
-//     The algorithm uses a table lookup based on B = M * pi / 32
-//     where M = N mod 64. The stored values are:
-//       sigma             closest power of 2 to cos(B)
-//       C_hl              53-bit cos(B) - sigma
-//       S_hi + S_lo       2 * 53-bit sin(B)
-//
-//     The computation is organized as follows:
-//
-//          sin(B + r + c) = [sin(B) + sigma * r] +
-//                           r * (cos(B) - sigma) +
-//                           sin(B) * [cos(r + c) - 1] +
-//                           cos(B) * [sin(r + c) - r]
-//
-//     which is approximately:
-//
-//          [S_hi + sigma * r] +
-//          C_hl * r +
-//          S_lo + S_hi * [(cos(r) - 1) - r * c] +
-//          (C_hl + sigma) * [(sin(r) - r) + c]
-//
-//     and this is what is actually computed. We separate this sum
-//     into four parts:
-//
-//          hi + med + pols + corr
-//
-//     where
-//
-//          hi       = S_hi + sigma r
-//          med      = C_hl * r
-//          pols     = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r)
-//          corr     = S_lo + c * ((C_hl + sigma) - S_hi * r)
-//
-//     3. POLYNOMIAL
-//
-//     The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) *
-//     (sin(r) - r) can be rearranged freely, since it is quite
-//     small, so we exploit parallelism to the fullest.
-//
-//          psc4       =   SC_4 * r_1
-//          msc4       =   psc4 * r
-//          r2         =   r * r
-//          msc2       =   SC_2 * r2
-//          r4         =   r2 * r2
-//          psc3       =   SC_3 + msc4
-//          psc1       =   SC_1 + msc2
-//          msc3       =   r4 * psc3
-//          sincospols =   psc1 + msc3
-//          pols       =   sincospols *
-//                         <S_hi * r^2 | (C_hl + sigma) * r^3>
-//
-//     4. CORRECTION TERM
-//
-//     This is where the "c" component of the range reduction is
-//     taken into account; recall that just "r" is used for most of
-//     the calculation.
-//
-//          -c   = m_3 - c_2
-//          -d   = S_hi * r - (C_hl + sigma)
-//          corr = -c * -d + S_lo
-//
-//     5. COMPENSATED SUMMATIONS
-//
-//     The two successive compensated summations add up the high
-//     and medium parts, leaving just the low parts to add up at
-//     the end.
-//
-//          rs        =  sigma * r
-//          res_int   =  S_hi + rs
-//          k_0       =  S_hi - res_int
-//          k_2       =  k_0 + rs
-//          med       =  C_hl * r
-//          res_hi    =  res_int + med
-//          k_1       =  res_int - res_hi
-//          k_3       =  k_1 + med
-//
-//     6. FINAL SUMMATION
-//
-//     We now add up all the small parts:
-//
-//          res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3
-//
-//     Now the overall result is just:
-//
-//          res_hi + res_lo
-//
-//     7. SMALL ARGUMENTS
-//
-//     If |x| < SNN (SNN meaning the smallest normal number), we
-//     simply perform 0.1111111 cdots 1111 * x. For SNN <= |x|, we
-//     do 2^-55 * (2^55 * x - x).
-//
-// Special cases:
-//  sin(NaN) = quiet NaN, and raise invalid exception
-//  sin(INF) = NaN and raise invalid exception
-//  sin(+/-0) = +/-0
-//
-/******************************************************************************/
-
-ALIGNED_(8) juint _zero_none[] =
-{
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL
-};
-
-ALIGNED_(4) juint __4onpi_d[] =
-{
-    0x6dc9c883UL, 0x3ff45f30UL
-};
-
-ALIGNED_(4) juint _TWO_32H[] =
-{
-    0x00000000UL, 0x41f80000UL
-};
-
-ALIGNED_(4) juint _pi04_3d[] =
-{
-    0x54442d00UL, 0x3fe921fbUL, 0x98cc5180UL, 0x3ce84698UL, 0xcbb5bf6cUL,
-    0xb9dfc8f8UL
-};
-
-ALIGNED_(4) juint _pi04_5d[] =
-{
-    0x54400000UL, 0x3fe921fbUL, 0x1a600000UL, 0x3dc0b461UL, 0x2e000000UL,
-    0x3b93198aUL, 0x25200000UL, 0x396b839aUL, 0x533e63a0UL, 0x37027044UL
-};
-
-ALIGNED_(4) juint _SCALE[] =
-{
-    0x00000000UL, 0x32600000UL
-};
-
-ALIGNED_(4) juint _zeros[] =
-{
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL
-};
-
-ALIGNED_(4) juint _pi04_2d[] =
-{
-    0x54400000UL, 0x3fe921fbUL, 0x1a626331UL, 0x3dc0b461UL
-};
-
-ALIGNED_(4) juint _TWO_12H[] =
-{
-    0x00000000UL, 0x40b80000UL
-};
-
-ALIGNED_(2) jushort __4onpi_31l[] =
-{
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x836e, 0xa2f9,
-    0x40d8, 0x0000, 0x0000, 0x0000, 0x2a50, 0x9c88, 0x40b7, 0x0000, 0x0000, 0x0000,
-    0xabe8, 0xfe13, 0x4099, 0x0000, 0x0000, 0x0000, 0x6ee0, 0xfa9a, 0x4079, 0x0000,
-    0x0000, 0x0000, 0x9580, 0xdb62, 0x4058, 0x0000, 0x0000, 0x0000, 0x1c82, 0xc9e2,
-    0x403d, 0x0000, 0x0000, 0x0000, 0xb1c0, 0xff28, 0x4019, 0x0000, 0x0000, 0x0000,
-    0xef14, 0xaf7a, 0x3ffe, 0x0000, 0x0000, 0x0000, 0x48dc, 0xc36e, 0x3fdf, 0x0000,
-    0x0000, 0x0000, 0x3740, 0xe909, 0x3fbe, 0x0000, 0x0000, 0x0000, 0x924a, 0xb801,
-    0x3fa2, 0x0000, 0x0000, 0x0000, 0x3a32, 0xdd41, 0x3f83, 0x0000, 0x0000, 0x0000,
-    0x8778, 0x873f, 0x3f62, 0x0000, 0x0000, 0x0000, 0x1298, 0xb1cb, 0x3f44, 0x0000,
-    0x0000, 0x0000, 0xa208, 0x9cfb, 0x3f26, 0x0000, 0x0000, 0x0000, 0xbaec, 0xd7d4,
-    0x3f06, 0x0000, 0x0000, 0x0000, 0xd338, 0x8909, 0x3ee7, 0x0000, 0x0000, 0x0000,
-    0x68b8, 0xe04d, 0x3ec7, 0x0000, 0x0000, 0x0000, 0x4e64, 0xdf90, 0x3eaa, 0x0000,
-    0x0000, 0x0000, 0xc1a8, 0xeb1c, 0x3e89, 0x0000, 0x0000, 0x0000, 0x2720, 0xce7d,
-    0x3e6a, 0x0000, 0x0000, 0x0000, 0x77b8, 0x8bf1, 0x3e4b, 0x0000, 0x0000, 0x0000,
-    0xec7e, 0xe4a0, 0x3e2e, 0x0000, 0x0000, 0x0000, 0xffbc, 0xf12f, 0x3e0f, 0x0000,
-    0x0000, 0x0000, 0xfdc0, 0xb301, 0x3deb, 0x0000, 0x0000, 0x0000, 0xc5ac, 0x9788,
-    0x3dd1, 0x0000, 0x0000, 0x0000, 0x47da, 0x829b, 0x3db2, 0x0000, 0x0000, 0x0000,
-    0xd9e4, 0xa6cf, 0x3d93, 0x0000, 0x0000, 0x0000, 0x36e8, 0xf961, 0x3d73, 0x0000,
-    0x0000, 0x0000, 0xf668, 0xf463, 0x3d54, 0x0000, 0x0000, 0x0000, 0x5168, 0xf2ff,
-    0x3d35, 0x0000, 0x0000, 0x0000, 0x758e, 0xea4f, 0x3d17, 0x0000, 0x0000, 0x0000,
-    0xf17a, 0xebe5, 0x3cf8, 0x0000, 0x0000, 0x0000, 0x9cfa, 0x9e83, 0x3cd9, 0x0000,
-    0x0000, 0x0000, 0xa4ba, 0xe294, 0x3cba, 0x0000, 0x0000, 0x0000, 0xd7ec, 0x9afe,
-    0x3c9a, 0x0000, 0x0000, 0x0000, 0xae80, 0x8fc6, 0x3c79, 0x0000, 0x0000, 0x0000,
-    0x3304, 0x8560, 0x3c5c, 0x0000, 0x0000, 0x0000, 0x6d70, 0xdf8f, 0x3c3b, 0x0000,
-    0x0000, 0x0000, 0x3ef0, 0xafc3, 0x3c1e, 0x0000, 0x0000, 0x0000, 0xd0d8, 0x826b,
-    0x3bfe, 0x0000, 0x0000, 0x0000, 0x1c80, 0xed4f, 0x3bdd, 0x0000, 0x0000, 0x0000,
-    0x730c, 0xb0af, 0x3bc1, 0x0000, 0x0000, 0x0000, 0x6660, 0xc219, 0x3ba2, 0x0000,
-    0x0000, 0x0000, 0x940c, 0xabe2, 0x3b83, 0x0000, 0x0000, 0x0000, 0xdffc, 0x8408,
-    0x3b64, 0x0000, 0x0000, 0x0000, 0x6b98, 0xc402, 0x3b45, 0x0000, 0x0000, 0x0000,
-    0x1818, 0x9cc4, 0x3b26, 0x0000, 0x0000, 0x0000, 0x5390, 0xaab6, 0x3b05, 0x0000,
-    0x0000, 0x0000, 0xb070, 0xd464, 0x3ae9, 0x0000, 0x0000, 0x0000, 0x231a, 0x9ef0,
-    0x3aca, 0x0000, 0x0000, 0x0000, 0x0670, 0xd1f1, 0x3aaa, 0x0000, 0x0000, 0x0000,
-    0x7738, 0xd9f3, 0x3a8a, 0x0000, 0x0000, 0x0000, 0xa834, 0x8092, 0x3a6c, 0x0000,
-    0x0000, 0x0000, 0xb45c, 0xce23, 0x3a4d, 0x0000, 0x0000, 0x0000, 0x36e8, 0xb0e5,
-    0x3a2d, 0x0000, 0x0000, 0x0000, 0xd156, 0xaf44, 0x3a10, 0x0000, 0x0000, 0x0000,
-    0x9f52, 0x8c82, 0x39f1, 0x0000, 0x0000, 0x0000, 0x829c, 0xff83, 0x39d1, 0x0000,
-    0x0000, 0x0000, 0x7d06, 0xefc6, 0x39b3, 0x0000, 0x0000, 0x0000, 0x93e0, 0xb0b7,
-    0x3992, 0x0000, 0x0000, 0x0000, 0xedde, 0xc193, 0x3975, 0x0000, 0x0000, 0x0000,
-    0xbbc0, 0xcf49, 0x3952, 0x0000, 0x0000, 0x0000, 0xbdf0, 0xd63c, 0x3937, 0x0000,
-    0x0000, 0x0000, 0x1f34, 0x9f3a, 0x3918, 0x0000, 0x0000, 0x0000, 0x3f8e, 0xe579,
-    0x38f9, 0x0000, 0x0000, 0x0000, 0x90c8, 0xc3f8, 0x38d9, 0x0000, 0x0000, 0x0000,
-    0x48c0, 0xf8f8, 0x38b7, 0x0000, 0x0000, 0x0000, 0xed56, 0xafa6, 0x389c, 0x0000,
-    0x0000, 0x0000, 0x8218, 0xb969, 0x387d, 0x0000, 0x0000, 0x0000, 0x1852, 0xec57,
-    0x385e, 0x0000, 0x0000, 0x0000, 0x670c, 0xd674, 0x383e, 0x0000, 0x0000, 0x0000,
-    0xad40, 0xc2c4, 0x3820, 0x0000, 0x0000, 0x0000, 0x2e80, 0xa696, 0x3801, 0x0000,
-    0x0000, 0x0000, 0xd800, 0xc467, 0x37dc, 0x0000, 0x0000, 0x0000, 0x3c72, 0xc5ae,
-    0x37c3, 0x0000, 0x0000, 0x0000, 0xb006, 0xac69, 0x37a4, 0x0000, 0x0000, 0x0000,
-    0x34a0, 0x8cdf, 0x3782, 0x0000, 0x0000, 0x0000, 0x9ed2, 0xd25e, 0x3766, 0x0000,
-    0x0000, 0x0000, 0x6fec, 0xaaaa, 0x3747, 0x0000, 0x0000, 0x0000, 0x6040, 0xfb5c,
-    0x3726, 0x0000, 0x0000, 0x0000, 0x764c, 0xa3fc, 0x3708, 0x0000, 0x0000, 0x0000,
-    0xb254, 0x954e, 0x36e9, 0x0000, 0x0000, 0x0000, 0x3e1c, 0xf5dc, 0x36ca, 0x0000,
-    0x0000, 0x0000, 0x7b06, 0xc635, 0x36ac, 0x0000, 0x0000, 0x0000, 0xa8ba, 0xd738,
-    0x368d, 0x0000, 0x0000, 0x0000, 0x06cc, 0xb24e, 0x366d, 0x0000, 0x0000, 0x0000,
-    0x7108, 0xac76, 0x364f, 0x0000, 0x0000, 0x0000, 0x2324, 0xa7cb, 0x3630, 0x0000,
-    0x0000, 0x0000, 0xac40, 0xef15, 0x360f, 0x0000, 0x0000, 0x0000, 0xae46, 0xd516,
-    0x35f2, 0x0000, 0x0000, 0x0000, 0x615e, 0xe003, 0x35d3, 0x0000, 0x0000, 0x0000,
-    0x0cf0, 0xefe7, 0x35b1, 0x0000, 0x0000, 0x0000, 0xfb50, 0xf98c, 0x3595, 0x0000,
-    0x0000, 0x0000, 0x0abc, 0xf333, 0x3575, 0x0000, 0x0000, 0x0000, 0xdd60, 0xca3f,
-    0x3555, 0x0000, 0x0000, 0x0000, 0x7eb6, 0xd87f, 0x3538, 0x0000, 0x0000, 0x0000,
-    0x44f4, 0xb291, 0x3519, 0x0000, 0x0000, 0x0000, 0xff80, 0xc982, 0x34f6, 0x0000,
-    0x0000, 0x0000, 0x9de0, 0xd9b8, 0x34db, 0x0000, 0x0000, 0x0000, 0xcd42, 0x9366,
-    0x34bc, 0x0000, 0x0000, 0x0000, 0xbef0, 0xfaee, 0x349d, 0x0000, 0x0000, 0x0000,
-    0xdac4, 0xb6f1, 0x347d, 0x0000, 0x0000, 0x0000, 0xf140, 0x94de, 0x345d, 0x0000,
-    0x0000, 0x0000, 0xa218, 0x8b4b, 0x343e, 0x0000, 0x0000, 0x0000, 0x6380, 0xa135,
-    0x341e, 0x0000, 0x0000, 0x0000, 0xb184, 0x8cb2, 0x3402, 0x0000, 0x0000, 0x0000,
-    0x196e, 0xdc61, 0x33e3, 0x0000, 0x0000, 0x0000, 0x0c00, 0xde05, 0x33c4, 0x0000,
-    0x0000, 0x0000, 0xef9a, 0xbd38, 0x33a5, 0x0000, 0x0000, 0x0000, 0xc1a0, 0xdf00,
-    0x3385, 0x0000, 0x0000, 0x0000, 0x1090, 0x9973, 0x3365, 0x0000, 0x0000, 0x0000,
-    0x4882, 0x8301, 0x3348, 0x0000, 0x0000, 0x0000, 0x7abe, 0xadc7, 0x3329, 0x0000,
-    0x0000, 0x0000, 0x7cba, 0xec2b, 0x330a, 0x0000, 0x0000, 0x0000, 0xa520, 0x8f21,
-    0x32e9, 0x0000, 0x0000, 0x0000, 0x710c, 0x8d36, 0x32cc, 0x0000, 0x0000, 0x0000,
-    0x5212, 0xc6ed, 0x32ad, 0x0000, 0x0000, 0x0000, 0x7308, 0xfd76, 0x328d, 0x0000,
-    0x0000, 0x0000, 0x5014, 0xd548, 0x326f, 0x0000, 0x0000, 0x0000, 0xd3f2, 0xb499,
-    0x3250, 0x0000, 0x0000, 0x0000, 0x7f74, 0xa606, 0x3230, 0x0000, 0x0000, 0x0000,
-    0xf0a8, 0xd720, 0x3212, 0x0000, 0x0000, 0x0000, 0x185c, 0xe20f, 0x31f2, 0x0000,
-    0x0000, 0x0000, 0xa5a8, 0x8738, 0x31d4, 0x0000, 0x0000, 0x0000, 0xdd74, 0xcafb,
-    0x31b4, 0x0000, 0x0000, 0x0000, 0x98b6, 0xbd8e, 0x3196, 0x0000, 0x0000, 0x0000,
-    0xe9de, 0x977f, 0x3177, 0x0000, 0x0000, 0x0000, 0x67c0, 0x818d, 0x3158, 0x0000,
-    0x0000, 0x0000, 0xe52a, 0x9322, 0x3139, 0x0000, 0x0000, 0x0000, 0xe568, 0x9b6c,
-    0x3119, 0x0000, 0x0000, 0x0000, 0x2358, 0xaa0a, 0x30fa, 0x0000, 0x0000, 0x0000,
-    0xe480, 0xe13b, 0x30d9, 0x0000, 0x0000, 0x0000, 0x3024, 0x90a1, 0x30bd, 0x0000,
-    0x0000, 0x0000, 0x9620, 0xda30, 0x309d, 0x0000, 0x0000, 0x0000, 0x898a, 0xb388,
-    0x307f, 0x0000, 0x0000, 0x0000, 0xb24c, 0xc891, 0x3060, 0x0000, 0x0000, 0x0000,
-    0x8056, 0xf98b, 0x3041, 0x0000, 0x0000, 0x0000, 0x72a4, 0xa1ea, 0x3021, 0x0000,
-    0x0000, 0x0000, 0x6af8, 0x9488, 0x3001, 0x0000, 0x0000, 0x0000, 0xe00c, 0xdfcb,
-    0x2fe4, 0x0000, 0x0000, 0x0000, 0xeeec, 0xc941, 0x2fc4, 0x0000, 0x0000, 0x0000,
-    0x53e0, 0xe70f, 0x2fa4, 0x0000, 0x0000, 0x0000, 0x8f60, 0x9c07, 0x2f85, 0x0000,
-    0x0000, 0x0000, 0xb328, 0xc3e7, 0x2f68, 0x0000, 0x0000, 0x0000, 0x9404, 0xf8c7,
-    0x2f48, 0x0000, 0x0000, 0x0000, 0x38e0, 0xc99f, 0x2f29, 0x0000, 0x0000, 0x0000,
-    0x9778, 0xd984, 0x2f09, 0x0000, 0x0000, 0x0000, 0xe700, 0xd142, 0x2eea, 0x0000,
-    0x0000, 0x0000, 0xd904, 0x9443, 0x2ecd, 0x0000, 0x0000, 0x0000, 0xd4ba, 0xae7e,
-    0x2eae, 0x0000, 0x0000, 0x0000, 0x8e5e, 0x8524, 0x2e8f, 0x0000, 0x0000, 0x0000,
-    0xb550, 0xc9ed, 0x2e6e, 0x0000, 0x0000, 0x0000, 0x53b8, 0x8648, 0x2e51, 0x0000,
-    0x0000, 0x0000, 0xdae4, 0x87f9, 0x2e32, 0x0000, 0x0000, 0x0000, 0x2942, 0xd966,
-    0x2e13, 0x0000, 0x0000, 0x0000, 0x4f28, 0xcf3c, 0x2df3, 0x0000, 0x0000, 0x0000,
-    0xfa40, 0xc4ef, 0x2dd1, 0x0000, 0x0000, 0x0000, 0x4424, 0xbca7, 0x2db5, 0x0000,
-    0x0000, 0x0000, 0x2e62, 0xcdc5, 0x2d97, 0x0000, 0x0000, 0x0000, 0xed88, 0x996b,
-    0x2d78, 0x0000, 0x0000, 0x0000, 0x7c30, 0xd97d, 0x2d56, 0x0000, 0x0000, 0x0000,
-    0xed26, 0xbf6e, 0x2d3a, 0x0000, 0x0000, 0x0000, 0x2918, 0x921b, 0x2d1a, 0x0000,
-    0x0000, 0x0000, 0x4e24, 0xe84e, 0x2cfb, 0x0000, 0x0000, 0x0000, 0x6dc0, 0x92ec,
-    0x2cdd, 0x0000, 0x0000, 0x0000, 0x4f2c, 0xacf8, 0x2cbd, 0x0000, 0x0000, 0x0000,
-    0xc634, 0xf094, 0x2c9e, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe5d3, 0x2c7e, 0x0000,
-    0x0000, 0x0000, 0x2180, 0xa600, 0x2c5b, 0x0000, 0x0000, 0x0000, 0x8480, 0xd680,
-    0x2c3c, 0x0000, 0x0000, 0x0000, 0x8b24, 0xd63b, 0x2c22, 0x0000, 0x0000, 0x0000,
-    0x02e0, 0xaa47, 0x2c00, 0x0000, 0x0000, 0x0000, 0x9ad0, 0xee84, 0x2be3, 0x0000,
-    0x0000, 0x0000, 0xf7dc, 0xf699, 0x2bc6, 0x0000, 0x0000, 0x0000, 0xddde, 0xe490,
-    0x2ba7, 0x0000, 0x0000, 0x0000, 0x34a0, 0xb4fd, 0x2b85, 0x0000, 0x0000, 0x0000,
-    0x91b4, 0x8ef6, 0x2b68, 0x0000, 0x0000, 0x0000, 0xa3e0, 0xa2a7, 0x2b47, 0x0000,
-    0x0000, 0x0000, 0xcce4, 0x82b3, 0x2b2a, 0x0000, 0x0000, 0x0000, 0xe4be, 0x8207,
-    0x2b0c, 0x0000, 0x0000, 0x0000, 0x1d92, 0xab43, 0x2aed, 0x0000, 0x0000, 0x0000,
-    0xe818, 0xf9f6, 0x2acd, 0x0000, 0x0000, 0x0000, 0xff12, 0xba80, 0x2aaf, 0x0000,
-    0x0000, 0x0000, 0x5254, 0x8529, 0x2a90, 0x0000, 0x0000, 0x0000, 0x1b88, 0xe032,
-    0x2a71, 0x0000, 0x0000, 0x0000, 0x3248, 0xd86d, 0x2a50, 0x0000, 0x0000, 0x0000,
-    0x3140, 0xc9d5, 0x2a2e, 0x0000, 0x0000, 0x0000, 0x14e6, 0xbd47, 0x2a14, 0x0000,
-    0x0000, 0x0000, 0x5c10, 0xe544, 0x29f4, 0x0000, 0x0000, 0x0000, 0x9f50, 0x90b6,
-    0x29d4, 0x0000, 0x0000, 0x0000, 0x9850, 0xab55, 0x29b6, 0x0000, 0x0000, 0x0000,
-    0x2750, 0x9d07, 0x2998, 0x0000, 0x0000, 0x0000, 0x6700, 0x8bbb, 0x2973, 0x0000,
-    0x0000, 0x0000, 0x5dba, 0xed31, 0x295a, 0x0000, 0x0000, 0x0000, 0x61dc, 0x85fe,
-    0x293a, 0x0000, 0x0000, 0x0000, 0x9ba2, 0xd6b4, 0x291c, 0x0000, 0x0000, 0x0000,
-    0x2d30, 0xe3a5, 0x28fb, 0x0000, 0x0000, 0x0000, 0x6630, 0xb566, 0x28dd, 0x0000,
-    0x0000, 0x0000, 0x5ad4, 0xa829, 0x28bf, 0x0000, 0x0000, 0x0000, 0x89d8, 0xe290,
-    0x28a0, 0x0000, 0x0000, 0x0000, 0x3916, 0xc428, 0x2881, 0x0000, 0x0000, 0x0000,
-    0x0490, 0xbea4, 0x2860, 0x0000, 0x0000, 0x0000, 0xee06, 0x80ee, 0x2843, 0x0000,
-    0x0000, 0x0000, 0xfc00, 0xf327, 0x2820, 0x0000, 0x0000, 0x0000, 0xea40, 0xa871,
-    0x2800, 0x0000, 0x0000, 0x0000, 0x63d8, 0x9c26, 0x27e4, 0x0000, 0x0000, 0x0000,
-    0x07ba, 0xc0c9, 0x27c7, 0x0000, 0x0000, 0x0000, 0x3fa2, 0x9797, 0x27a8, 0x0000,
-    0x0000, 0x0000, 0x21c6, 0xfeca, 0x2789, 0x0000, 0x0000, 0x0000, 0xde40, 0x860d,
-    0x2768, 0x0000, 0x0000, 0x0000, 0x9cc8, 0x98ce, 0x2749, 0x0000, 0x0000, 0x0000,
-    0x3778, 0xa31c, 0x272a, 0x0000, 0x0000, 0x0000, 0xe778, 0xf6e2, 0x270b, 0x0000,
-    0x0000, 0x0000, 0x59b8, 0xf841, 0x26ed, 0x0000, 0x0000, 0x0000, 0x02e0, 0xad04,
-    0x26cd, 0x0000, 0x0000, 0x0000, 0x5a92, 0x9380, 0x26b0, 0x0000, 0x0000, 0x0000,
-    0xc740, 0x8886, 0x268d, 0x0000, 0x0000, 0x0000, 0x0680, 0xfaf8, 0x266c, 0x0000,
-    0x0000, 0x0000, 0xfb60, 0x897f, 0x2653, 0x0000, 0x0000, 0x0000, 0x8760, 0xf903,
-    0x2634, 0x0000, 0x0000, 0x0000, 0xad2a, 0xc2c8, 0x2615, 0x0000, 0x0000, 0x0000,
-    0x2d86, 0x8aef, 0x25f6, 0x0000, 0x0000, 0x0000, 0x1ef4, 0xe627, 0x25d6, 0x0000,
-    0x0000, 0x0000, 0x09e4, 0x8020, 0x25b7, 0x0000, 0x0000, 0x0000, 0x7548, 0xd227,
-    0x2598, 0x0000, 0x0000, 0x0000, 0x75dc, 0xfb5b, 0x2579, 0x0000, 0x0000, 0x0000,
-    0xea84, 0xc8b6, 0x255a, 0x0000, 0x0000, 0x0000, 0xe4d0, 0x8145, 0x253b, 0x0000,
-    0x0000, 0x0000, 0x3640, 0x9768, 0x251c, 0x0000, 0x0000, 0x0000, 0x246a, 0xccec,
-    0x24fe, 0x0000, 0x0000, 0x0000, 0x51d0, 0xa075, 0x24dd, 0x0000, 0x0000, 0x0000,
-    0x4638, 0xa385, 0x24bf, 0x0000, 0x0000, 0x0000, 0xd788, 0xd776, 0x24a1, 0x0000,
-    0x0000, 0x0000, 0x1370, 0x8997, 0x2482, 0x0000, 0x0000, 0x0000, 0x1e88, 0x9b67,
-    0x2462, 0x0000, 0x0000, 0x0000, 0x6c08, 0xd975, 0x2444, 0x0000, 0x0000, 0x0000,
-    0xfdb0, 0xcfc0, 0x2422, 0x0000, 0x0000, 0x0000, 0x3100, 0xc026, 0x2406, 0x0000,
-    0x0000, 0x0000, 0xc5b4, 0xae64, 0x23e6, 0x0000, 0x0000, 0x0000, 0x2280, 0xf687,
-    0x23c3, 0x0000, 0x0000, 0x0000, 0x2de0, 0x9006, 0x23a9, 0x0000, 0x0000, 0x0000,
-    0x24bc, 0xf631, 0x238a, 0x0000, 0x0000, 0x0000, 0xb8d4, 0xa975, 0x236b, 0x0000,
-    0x0000, 0x0000, 0xd9a4, 0xb949, 0x234b, 0x0000, 0x0000, 0x0000, 0xb54e, 0xbd39,
-    0x232d, 0x0000, 0x0000, 0x0000, 0x4aac, 0x9a52, 0x230e, 0x0000, 0x0000, 0x0000,
-    0xbbbc, 0xd085, 0x22ef, 0x0000, 0x0000, 0x0000, 0xdf18, 0xc633, 0x22cf, 0x0000,
-    0x0000, 0x0000, 0x16d0, 0xeca5, 0x22af, 0x0000, 0x0000, 0x0000, 0xf2a0, 0xdf6f,
-    0x228e, 0x0000, 0x0000, 0x0000, 0x8c44, 0xe86b, 0x2272, 0x0000, 0x0000, 0x0000,
-    0x35c0, 0xbbf4, 0x2253, 0x0000, 0x0000, 0x0000, 0x0c40, 0xdafb, 0x2230, 0x0000,
-    0x0000, 0x0000, 0x92dc, 0x9935, 0x2216, 0x0000, 0x0000, 0x0000, 0x0ca0, 0xbda6,
-    0x21f3, 0x0000, 0x0000, 0x0000, 0x5958, 0xa6fd, 0x21d6, 0x0000, 0x0000, 0x0000,
-    0xa3dc, 0x9d7f, 0x21b9, 0x0000, 0x0000, 0x0000, 0x79dc, 0xfcb5, 0x2199, 0x0000,
-    0x0000, 0x0000, 0xf264, 0xcebb, 0x217b, 0x0000, 0x0000, 0x0000, 0x0abe, 0x8308,
-    0x215c, 0x0000, 0x0000, 0x0000, 0x30ae, 0xb463, 0x213d, 0x0000, 0x0000, 0x0000,
-    0x6228, 0xb040, 0x211c, 0x0000, 0x0000, 0x0000, 0xc9b2, 0xf43b, 0x20ff, 0x0000,
-    0x0000, 0x0000, 0x3d8e, 0xa4b3, 0x20e0, 0x0000, 0x0000, 0x0000, 0x84e6, 0x8dab,
-    0x20c1, 0x0000, 0x0000, 0x0000, 0xa124, 0x9b74, 0x20a1, 0x0000, 0x0000, 0x0000,
-    0xc276, 0xd497, 0x2083, 0x0000, 0x0000, 0x0000, 0x6354, 0xa466, 0x2063, 0x0000,
-    0x0000, 0x0000, 0x8654, 0xaf0a, 0x2044, 0x0000, 0x0000, 0x0000, 0x1d20, 0xfa5c,
-    0x2024, 0x0000, 0x0000, 0x0000, 0xbcd0, 0xf3f0, 0x2004, 0x0000, 0x0000, 0x0000,
-    0xedf0, 0xf0b6, 0x1fe7, 0x0000, 0x0000, 0x0000, 0x45bc, 0x9182, 0x1fc9, 0x0000,
-    0x0000, 0x0000, 0xe254, 0xdc85, 0x1faa, 0x0000, 0x0000, 0x0000, 0xb898, 0xe9b1,
-    0x1f8a, 0x0000, 0x0000, 0x0000, 0x0ebe, 0xe6f0, 0x1f6c, 0x0000, 0x0000, 0x0000,
-    0xa9b8, 0xf584, 0x1f4c, 0x0000, 0x0000, 0x0000, 0x12e8, 0xdf6b, 0x1f2e, 0x0000,
-    0x0000, 0x0000, 0x9f9e, 0xcd55, 0x1f0f, 0x0000, 0x0000, 0x0000, 0x05a0, 0xec3a,
-    0x1eef, 0x0000, 0x0000, 0x0000, 0xd8e0, 0x96f8, 0x1ed1, 0x0000, 0x0000, 0x0000,
-    0x3bd4, 0xccc6, 0x1eb1, 0x0000, 0x0000, 0x0000, 0x4910, 0xb87b, 0x1e93, 0x0000,
-    0x0000, 0x0000, 0xbefc, 0xd40b, 0x1e73, 0x0000, 0x0000, 0x0000, 0x317e, 0xa406,
-    0x1e55, 0x0000, 0x0000, 0x0000, 0x6bb2, 0xc2b2, 0x1e36, 0x0000, 0x0000, 0x0000,
-    0xb87e, 0xbb78, 0x1e17, 0x0000, 0x0000, 0x0000, 0xa03c, 0xdbbd, 0x1df7, 0x0000,
-    0x0000, 0x0000, 0x5b6c, 0xe3c8, 0x1dd9, 0x0000, 0x0000, 0x0000, 0x8968, 0xca8e,
-    0x1dba, 0x0000, 0x0000, 0x0000, 0xc024, 0xe6ab, 0x1d9a, 0x0000, 0x0000, 0x0000,
-    0x4110, 0xd4eb, 0x1d7a, 0x0000, 0x0000, 0x0000, 0xa168, 0xbdb5, 0x1d5d, 0x0000,
-    0x0000, 0x0000, 0x012e, 0xa5fa, 0x1d3e, 0x0000, 0x0000, 0x0000, 0x6838, 0x9c1f,
-    0x1d1e, 0x0000, 0x0000, 0x0000, 0xa158, 0xaa76, 0x1d00, 0x0000, 0x0000, 0x0000,
-    0x090a, 0xbd95, 0x1ce1, 0x0000, 0x0000, 0x0000, 0xf73e, 0x8b6d, 0x1cc2, 0x0000,
-    0x0000, 0x0000, 0x5fda, 0xbcbf, 0x1ca3, 0x0000, 0x0000, 0x0000, 0xdbe8, 0xb89f,
-    0x1c84, 0x0000, 0x0000, 0x0000, 0x6e4c, 0x96c7, 0x1c64, 0x0000, 0x0000, 0x0000,
-    0x19c2, 0xf2a4, 0x1c46, 0x0000, 0x0000, 0x0000, 0xb800, 0xf855, 0x1c1e, 0x0000,
-    0x0000, 0x0000, 0x87fc, 0x85ff, 0x1c08, 0x0000, 0x0000, 0x0000, 0x1418, 0x839f,
-    0x1be9, 0x0000, 0x0000, 0x0000, 0x6186, 0xd9d8, 0x1bca, 0x0000, 0x0000, 0x0000,
-    0xf500, 0xabaa, 0x1ba6, 0x0000, 0x0000, 0x0000, 0x7b36, 0xdafe, 0x1b8c, 0x0000,
-    0x0000, 0x0000, 0xf394, 0xe6d8, 0x1b6c, 0x0000, 0x0000, 0x0000, 0x6efc, 0x9e55,
-    0x1b4e, 0x0000, 0x0000, 0x0000, 0x5e10, 0xc523, 0x1b2e, 0x0000, 0x0000, 0x0000,
-    0x8210, 0xb6f9, 0x1b0d, 0x0000, 0x0000, 0x0000, 0x9ab0, 0x96e3, 0x1af1, 0x0000,
-    0x0000, 0x0000, 0x3864, 0x92e7, 0x1ad1, 0x0000, 0x0000, 0x0000, 0x9878, 0xdc65,
-    0x1ab1, 0x0000, 0x0000, 0x0000, 0xfa20, 0xd6cb, 0x1a94, 0x0000, 0x0000, 0x0000,
-    0x6c00, 0xa4e4, 0x1a70, 0x0000, 0x0000, 0x0000, 0xab40, 0xb41b, 0x1a53, 0x0000,
-    0x0000, 0x0000, 0x43a4, 0x8ede, 0x1a37, 0x0000, 0x0000, 0x0000, 0x22e0, 0x9314,
-    0x1a15, 0x0000, 0x0000, 0x0000, 0x6170, 0xb949, 0x19f8, 0x0000, 0x0000, 0x0000,
-    0x6b00, 0xe056, 0x19d8, 0x0000, 0x0000, 0x0000, 0x9ba8, 0xa94c, 0x19b9, 0x0000,
-    0x0000, 0x0000, 0xfaa0, 0xaa16, 0x199b, 0x0000, 0x0000, 0x0000, 0x899a, 0xf627,
-    0x197d, 0x0000, 0x0000, 0x0000, 0x9f20, 0xfb70, 0x195d, 0x0000, 0x0000, 0x0000,
-    0xa4b8, 0xc176, 0x193e, 0x0000, 0x0000, 0x0000, 0xb21c, 0x85c3, 0x1920, 0x0000,
-    0x0000, 0x0000, 0x50d2, 0x9b19, 0x1901, 0x0000, 0x0000, 0x0000, 0xd4b0, 0xb708,
-    0x18e0, 0x0000, 0x0000, 0x0000, 0xfb88, 0xf510, 0x18c1, 0x0000, 0x0000, 0x0000,
-    0x31ec, 0xdc8d, 0x18a3, 0x0000, 0x0000, 0x0000, 0x3c00, 0xbff9, 0x1885, 0x0000,
-    0x0000, 0x0000, 0x5020, 0xc30b, 0x1862, 0x0000, 0x0000, 0x0000, 0xd4f0, 0xda0c,
-    0x1844, 0x0000, 0x0000, 0x0000, 0x20d2, 0x99a5, 0x1828, 0x0000, 0x0000, 0x0000,
-    0x852e, 0xd159, 0x1809, 0x0000, 0x0000, 0x0000, 0x7cd8, 0x97a1, 0x17e9, 0x0000,
-    0x0000, 0x0000, 0x423a, 0x997b, 0x17cb, 0x0000, 0x0000, 0x0000, 0xc1c0, 0xbe7d,
-    0x17a8, 0x0000, 0x0000, 0x0000, 0xe8bc, 0xdcdd, 0x178d, 0x0000, 0x0000, 0x0000,
-    0x8b28, 0xae06, 0x176e, 0x0000, 0x0000, 0x0000, 0x102e, 0xb8d4, 0x174f, 0x0000,
-    0x0000, 0x0000, 0xaa00, 0xaa5c, 0x172f, 0x0000, 0x0000, 0x0000, 0x51f0, 0x9fc0,
-    0x170e, 0x0000, 0x0000, 0x0000, 0xf858, 0xe181, 0x16f2, 0x0000, 0x0000, 0x0000,
-    0x91a8, 0x8162, 0x16d3, 0x0000, 0x0000, 0x0000, 0x5f40, 0xcb6f, 0x16b1, 0x0000,
-    0x0000, 0x0000, 0xbb50, 0xe55f, 0x1693, 0x0000, 0x0000, 0x0000, 0xacd2, 0xd895,
-    0x1676, 0x0000, 0x0000, 0x0000, 0xef30, 0x97bf, 0x1654, 0x0000, 0x0000, 0x0000,
-    0xf700, 0xb3d7, 0x1633, 0x0000, 0x0000, 0x0000, 0x3454, 0xa7b5, 0x1619, 0x0000,
-    0x0000, 0x0000, 0x6b00, 0xa929, 0x15f6, 0x0000, 0x0000, 0x0000, 0x9f04, 0x89f7,
-    0x15db, 0x0000, 0x0000, 0x0000, 0xad78, 0xd985, 0x15bc, 0x0000, 0x0000, 0x0000,
-    0xa46a, 0xae3f, 0x159d, 0x0000, 0x0000, 0x0000, 0x63a0, 0xd0da, 0x157c, 0x0000,
-    0x0000, 0x0000, 0x5e90, 0x817d, 0x155e, 0x0000, 0x0000, 0x0000, 0x1494, 0xb13f,
-    0x1540, 0x0000, 0x0000, 0x0000, 0x0090, 0x9c40, 0x1521, 0x0000, 0x0000, 0x0000,
-    0xdd70, 0xcc86, 0x1500, 0x0000, 0x0000, 0x0000, 0x64f8, 0xdb6f, 0x14e1, 0x0000,
-    0x0000, 0x0000, 0xe22c, 0xac17, 0x14c3, 0x0000, 0x0000, 0x0000, 0x60e0, 0xa9ad,
-    0x14a3, 0x0000, 0x0000, 0x0000, 0x4640, 0xd658, 0x1481, 0x0000, 0x0000, 0x0000,
-    0x6490, 0xa181, 0x1467, 0x0000, 0x0000, 0x0000, 0x1df4, 0xaaa2, 0x1447, 0x0000,
-    0x0000, 0x0000, 0xb94a, 0x8f61, 0x1429, 0x0000, 0x0000, 0x0000, 0x5198, 0x9d83,
-    0x1409, 0x0000, 0x0000, 0x0000, 0x0f7a, 0xa818, 0x13eb, 0x0000, 0x0000, 0x0000,
-    0xc45e, 0xc06c, 0x13cc, 0x0000, 0x0000, 0x0000, 0x4ec0, 0xfa29, 0x13a8, 0x0000,
-    0x0000, 0x0000, 0x6418, 0x8cad, 0x138c, 0x0000, 0x0000, 0x0000, 0xbcc8, 0xe7d1,
-    0x136f, 0x0000, 0x0000, 0x0000, 0xc934, 0xf9b0, 0x134f, 0x0000, 0x0000, 0x0000,
-    0x6ce0, 0x98df, 0x1331, 0x0000, 0x0000, 0x0000, 0x3516, 0xe5e9, 0x1312, 0x0000,
-    0x0000, 0x0000, 0xc6c0, 0xef8b, 0x12ef, 0x0000, 0x0000, 0x0000, 0xaf02, 0x913d,
-    0x12d4, 0x0000, 0x0000, 0x0000, 0xd230, 0xe1d5, 0x12b5, 0x0000, 0x0000, 0x0000,
-    0xfba8, 0xc232, 0x1295, 0x0000, 0x0000, 0x0000, 0x7ba4, 0xabeb, 0x1277, 0x0000,
-    0x0000, 0x0000, 0x6e5c, 0xc692, 0x1258, 0x0000, 0x0000, 0x0000, 0x76a2, 0x9756,
-    0x1239, 0x0000, 0x0000, 0x0000, 0xe180, 0xe423, 0x1214, 0x0000, 0x0000, 0x0000,
-    0x8c3c, 0x90f8, 0x11fb, 0x0000, 0x0000, 0x0000, 0x9f3c, 0x9fd2, 0x11dc, 0x0000,
-    0x0000, 0x0000, 0x53e0, 0xb73e, 0x11bd, 0x0000, 0x0000, 0x0000, 0x45be, 0x88d6,
-    0x119e, 0x0000, 0x0000, 0x0000, 0x111a, 0x8bc0, 0x117f, 0x0000, 0x0000, 0x0000,
-    0xe26a, 0xd7ff, 0x1160, 0x0000, 0x0000, 0x0000, 0xfb60, 0xdd8d, 0x113f, 0x0000,
-    0x0000, 0x0000, 0x9370, 0xc108, 0x1120, 0x0000, 0x0000, 0x0000, 0x9654, 0x8baf,
-    0x1103, 0x0000, 0x0000, 0x0000, 0xd6ec, 0xd6b9, 0x10e4, 0x0000, 0x0000, 0x0000,
-    0x23e4, 0xd7b7, 0x10c4, 0x0000, 0x0000, 0x0000, 0x1aa6, 0xa847, 0x10a6, 0x0000,
-    0x0000, 0x0000, 0xbee6, 0x9fef, 0x1087, 0x0000, 0x0000, 0x0000, 0x26d0, 0xa6eb,
-    0x1066, 0x0000, 0x0000, 0x0000, 0x5b86, 0xa880, 0x1049, 0x0000, 0x0000, 0x0000,
-    0x125c, 0xd971, 0x1029, 0x0000, 0x0000, 0x0000, 0x1f78, 0x9d18, 0x100a, 0x0000,
-    0x0000, 0x0000, 0x0e84, 0xb15b, 0x0feb, 0x0000, 0x0000, 0x0000, 0xd0c0, 0xc150,
-    0x0fcc, 0x0000, 0x0000, 0x0000, 0xa330, 0xc40c, 0x0fad, 0x0000, 0x0000, 0x0000,
-    0x5202, 0xfc2c, 0x0f8f, 0x0000, 0x0000, 0x0000, 0x3f7c, 0xecf5, 0x0f6f, 0x0000,
-    0x0000, 0x0000, 0xef44, 0xfdfd, 0x0f50, 0x0000, 0x0000, 0x0000, 0x3f6c, 0xab1b,
-    0x0f31, 0x0000, 0x0000, 0x0000, 0xf658, 0x89ec, 0x0f11, 0x0000, 0x0000, 0x0000,
-    0xbfc8, 0x9ba8, 0x0ef4, 0x0000, 0x0000, 0x0000, 0x3d40, 0xbe21, 0x0ed5, 0x0000,
-    0x0000, 0x0000, 0xbbc4, 0xc70d, 0x0eb6, 0x0000, 0x0000, 0x0000, 0x5158, 0xdb16,
-    0x0e96, 0x0000, 0x0000, 0x0000, 0xb5a8, 0xa8d8, 0x0e78, 0x0000, 0x0000, 0x0000,
-    0xcccc, 0xb40e, 0x0e58, 0x0000, 0x0000, 0x0000, 0x448c, 0xcb62, 0x0e3a, 0x0000,
-    0x0000, 0x0000, 0xf12a, 0x8aed, 0x0e1b, 0x0000, 0x0000, 0x0000, 0x79d0, 0xc59c,
-    0x0dfb, 0x0000, 0x0000, 0x0000, 0x06b4, 0xcdc9, 0x0ddd, 0x0000, 0x0000, 0x0000,
-    0xae70, 0xa979, 0x0dbe, 0x0000, 0x0000, 0x0000, 0x317c, 0xa8fb, 0x0d9e, 0x0000,
-    0x0000, 0x0000, 0x5fe0, 0x8a50, 0x0d7d, 0x0000, 0x0000, 0x0000, 0x70b6, 0xfdfa,
-    0x0d61, 0x0000, 0x0000, 0x0000, 0x1640, 0x9dc7, 0x0d41, 0x0000, 0x0000, 0x0000,
-    0x9a9c, 0xdc50, 0x0d23, 0x0000, 0x0000, 0x0000, 0x4fcc, 0x9a9b, 0x0d04, 0x0000,
-    0x0000, 0x0000, 0x7e48, 0x8f77, 0x0ce5, 0x0000, 0x0000, 0x0000, 0x84e4, 0xd4b9,
-    0x0cc6, 0x0000, 0x0000, 0x0000, 0x84e0, 0xbd10, 0x0ca6, 0x0000, 0x0000, 0x0000,
-    0x1b0a, 0xc8d9, 0x0c88, 0x0000, 0x0000, 0x0000, 0x6a48, 0xfc81, 0x0c68, 0x0000,
-    0x0000, 0x0000, 0x070a, 0xbef6, 0x0c4a, 0x0000, 0x0000, 0x0000, 0x8a70, 0xf096,
-    0x0c2b, 0x0000, 0x0000, 0x0000, 0xecc2, 0xc994, 0x0c0c, 0x0000, 0x0000, 0x0000,
-    0x1540, 0x9537, 0x0bea, 0x0000, 0x0000, 0x0000, 0x1b02, 0xab5b, 0x0bce, 0x0000,
-    0x0000, 0x0000, 0x5dc0, 0xb0c8, 0x0bad, 0x0000, 0x0000, 0x0000, 0xc928, 0xe034,
-    0x0b8f, 0x0000, 0x0000, 0x0000, 0x2d12, 0xb4b0, 0x0b71, 0x0000, 0x0000, 0x0000,
-    0x8fc2, 0xbb94, 0x0b52, 0x0000, 0x0000, 0x0000, 0xe236, 0xe22f, 0x0b33, 0x0000,
-    0x0000, 0x0000, 0xb97c, 0xbe9e, 0x0b13, 0x0000, 0x0000, 0x0000, 0xe1a6, 0xe16d,
-    0x0af5, 0x0000, 0x0000, 0x0000, 0xd330, 0xbaf0, 0x0ad6, 0x0000, 0x0000, 0x0000,
-    0xc0bc, 0xbbd0, 0x0ab7, 0x0000, 0x0000, 0x0000, 0x8e66, 0xdd9b, 0x0a98, 0x0000,
-    0x0000, 0x0000, 0xc95c, 0xf799, 0x0a79, 0x0000, 0x0000, 0x0000, 0xdac0, 0xbe4c,
-    0x0a55, 0x0000, 0x0000, 0x0000, 0xafc0, 0xc378, 0x0a37, 0x0000, 0x0000, 0x0000,
-    0xa880, 0xe341, 0x0a19, 0x0000, 0x0000, 0x0000, 0xc242, 0x81f6, 0x09fd, 0x0000,
-    0x0000, 0x0000, 0x7470, 0xc777, 0x09de, 0x0000, 0x0000, 0x0000, 0x62bc, 0xb684,
-    0x09be, 0x0000, 0x0000, 0x0000, 0x43ac, 0x8c58, 0x099f, 0x0000, 0x0000, 0x0000,
-    0xcc3c, 0xf9ac, 0x0981, 0x0000, 0x0000, 0x0000, 0x1526, 0xb670, 0x0962, 0x0000,
-    0x0000, 0x0000, 0xc9fe, 0xdf50, 0x0943, 0x0000, 0x0000, 0x0000, 0x6ae6, 0xc065,
-    0x0924, 0x0000, 0x0000, 0x0000, 0xb114, 0xcf29, 0x0905, 0x0000, 0x0000, 0x0000,
-    0xd388, 0x922a, 0x08e4, 0x0000, 0x0000, 0x0000, 0xcf54, 0xb926, 0x08c7, 0x0000,
-    0x0000, 0x0000, 0x3826, 0xe855, 0x08a8, 0x0000, 0x0000, 0x0000, 0xe7c8, 0x829b,
-    0x0888, 0x0000, 0x0000, 0x0000, 0x546c, 0xa903, 0x086a, 0x0000, 0x0000, 0x0000,
-    0x8768, 0x99cc, 0x0849, 0x0000, 0x0000, 0x0000, 0x00ac, 0xf529, 0x082b, 0x0000,
-    0x0000, 0x0000, 0x2658, 0x9f0b, 0x080c, 0x0000, 0x0000, 0x0000, 0xfe5c, 0x9e21,
-    0x07ee, 0x0000, 0x0000, 0x0000, 0x6da2, 0x9910, 0x07cf, 0x0000, 0x0000, 0x0000,
-    0x9220, 0xf9b3, 0x07b0, 0x0000, 0x0000, 0x0000, 0x3d90, 0xa541, 0x0791, 0x0000,
-    0x0000, 0x0000, 0x6e4c, 0xe7cc, 0x0771, 0x0000, 0x0000, 0x0000, 0xa8fa, 0xe80a,
-    0x0753, 0x0000, 0x0000, 0x0000, 0x4e14, 0xc3a7, 0x0734, 0x0000, 0x0000, 0x0000,
-    0xf7e0, 0xbad9, 0x0712, 0x0000, 0x0000, 0x0000, 0xfea0, 0xeff2, 0x06f5, 0x0000,
-    0x0000, 0x0000, 0xcef6, 0xbd48, 0x06d7, 0x0000, 0x0000, 0x0000, 0x7544, 0xf559,
-    0x06b7, 0x0000, 0x0000, 0x0000, 0x2388, 0xf655, 0x0698, 0x0000, 0x0000, 0x0000,
-    0xe900, 0xad56, 0x0676, 0x0000, 0x0000, 0x0000, 0x2cc0, 0x8437, 0x0659, 0x0000,
-    0x0000, 0x0000, 0x3068, 0xc544, 0x063b, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe73c,
-    0x061b, 0x0000, 0x0000, 0x0000, 0xee50, 0x9d49, 0x05fc, 0x0000, 0x0000, 0x0000,
-    0x93d2, 0x81f6, 0x05df, 0x0000, 0x0000, 0x0000, 0x941c, 0xadff, 0x05bf, 0x0000,
-    0x0000, 0x0000, 0x2ce2, 0x8e45, 0x05a1, 0x0000, 0x0000, 0x0000, 0x4a60, 0x95fd,
-    0x0581, 0x0000, 0x0000, 0x0000, 0x79f8, 0xb83a, 0x0563, 0x0000, 0x0000, 0x0000,
-    0xcb58, 0xa1f5, 0x0543, 0x0000, 0x0000, 0x0000, 0x2a3a, 0xdc36, 0x0525, 0x0000,
-    0x0000, 0x0000, 0x14ee, 0x890e, 0x0506, 0x0000, 0x0000, 0x0000, 0x8f20, 0xc432,
-    0x04e3, 0x0000, 0x0000, 0x0000, 0x8440, 0xb21d, 0x04c6, 0x0000, 0x0000, 0x0000,
-    0x5430, 0xf698, 0x04a7, 0x0000, 0x0000, 0x0000, 0x04ae, 0x8b20, 0x048a, 0x0000,
-    0x0000, 0x0000, 0x04d0, 0xe872, 0x046b, 0x0000, 0x0000, 0x0000, 0xc78e, 0x8893,
-    0x044c, 0x0000, 0x0000, 0x0000, 0x0f78, 0x9895, 0x042b, 0x0000, 0x0000, 0x0000,
-    0x11d4, 0xdf2e, 0x040d, 0x0000, 0x0000, 0x0000, 0xe84c, 0x89d5, 0x03ef, 0x0000,
-    0x0000, 0x0000, 0xf7be, 0x8a67, 0x03d0, 0x0000, 0x0000, 0x0000, 0x95d0, 0xc906,
-    0x03b1, 0x0000, 0x0000, 0x0000, 0x64ce, 0xd96c, 0x0392, 0x0000, 0x0000, 0x0000,
-    0x97ba, 0xa16f, 0x0373, 0x0000, 0x0000, 0x0000, 0x463c, 0xc51a, 0x0354, 0x0000,
-    0x0000, 0x0000, 0xef0a, 0xe93e, 0x0335, 0x0000, 0x0000, 0x0000, 0x526a, 0xa466,
-    0x0316, 0x0000, 0x0000, 0x0000, 0x4140, 0xa94d, 0x02f5, 0x0000, 0x0000, 0x0000,
-    0xb4ec, 0xce68, 0x02d8, 0x0000, 0x0000, 0x0000, 0x4fa2, 0x8490, 0x02b9, 0x0000,
-    0x0000, 0x0000, 0x4e60, 0xca98, 0x0298, 0x0000, 0x0000, 0x0000, 0x08dc, 0xe09c,
-    0x027a, 0x0000, 0x0000, 0x0000, 0x2b90, 0xc7e3, 0x025c, 0x0000, 0x0000, 0x0000,
-    0x5a7c, 0xf8ef, 0x023c, 0x0000, 0x0000, 0x0000, 0x5022, 0x9d58, 0x021e, 0x0000,
-    0x0000, 0x0000, 0x553a, 0xe242, 0x01ff, 0x0000, 0x0000, 0x0000, 0x7e6e, 0xb54d,
-    0x01e0, 0x0000, 0x0000, 0x0000, 0xd2d4, 0xa88c, 0x01c1, 0x0000, 0x0000, 0x0000,
-    0x75b6, 0xfe6d, 0x01a2, 0x0000, 0x0000, 0x0000, 0x3bb2, 0xf04c, 0x0183, 0x0000,
-    0x0000, 0x0000, 0xc2d0, 0xc046, 0x0163, 0x0000, 0x0000, 0x0000, 0x250c, 0xf9d6,
-    0x0145, 0x0000, 0x0000, 0x0000, 0xb7b4, 0x8a0d, 0x0126, 0x0000, 0x0000, 0x0000,
-    0x1a72, 0xe4f5, 0x0107, 0x0000, 0x0000, 0x0000, 0x825c, 0xa9b8, 0x00e8, 0x0000,
-    0x0000, 0x0000, 0x6c90, 0xc9ad, 0x00c6, 0x0000, 0x0000, 0x0000, 0x4d00, 0xd1bb,
-    0x00aa, 0x0000, 0x0000, 0x0000, 0xa4a0, 0xee01, 0x0087, 0x0000, 0x0000, 0x0000,
-    0x89a8, 0xbe9f, 0x006b, 0x0000, 0x0000, 0x0000, 0x038e, 0xc80c, 0x004d, 0x0000,
-    0x0000, 0x0000, 0xfe26, 0x8384, 0x002e, 0x0000, 0x0000, 0x0000, 0xcd90, 0xca57,
-    0x000e, 0x0000
-};
-
-void MacroAssembler::libm_reduce_pi04l(Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) {
-  Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12;
-  Label B1_13, B1_14, B1_15;
-
-  assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp);
-
-  address zero_none = (address)_zero_none;
-  address _4onpi_d = (address)__4onpi_d;
-  address TWO_32H = (address)_TWO_32H;
-  address pi04_3d = (address)_pi04_3d;
-  address pi04_5d = (address)_pi04_5d;
-  address SCALE = (address)_SCALE;
-  address zeros = (address)_zeros;
-  address pi04_2d = (address)_pi04_2d;
-  address TWO_12H = (address)_TWO_12H;
-  address _4onpi_31l = (address)__4onpi_31l;
-
-  bind(B1_1);
-  push(ebp);
-  movl(ebp, esp);
-  andl(esp, -16);
-  push(esi);
-  push(edi);
-  push(ebx);
-  subl(esp, 20);
-  movzwl(ebx, Address(ebp, 16));
-  andl(ebx, 32767);
-  movl(eax, Address(ebp, 20));
-  cmpl(ebx, 16413);
-  movl(esi, Address(ebp, 24));
-  movl(Address(esp, 4), eax);
-  jcc(Assembler::greaterEqual, B1_8);
-
-  bind(B1_2);
-  fld_x(Address(ebp, 8));
-  fld_d(ExternalAddress(_4onpi_d));    //0x6dc9c883UL, 0x3ff45f30UL
-  fmul(1);
-  fstp_x(Address(esp, 8));
-  movzwl(ecx, Address(esp, 16));
-  negl(ecx);
-  addl(ecx, 30);
-  movl(eax, Address(esp, 12));
-  shrl(eax);
-  cmpl(Address(esp, 4), 0);
-  jcc(Assembler::notEqual, B1_4);
-
-  bind(B1_3);
-  lea(ecx, Address(eax, 1));
-  andl(ecx, -2);
-  jmp(B1_5);
-
-  bind(B1_4);
-  movl(ecx, eax);
-  addl(eax, Address(esp, 4));
-  movl(edx, eax);
-  andl(edx, 1);
-  addl(ecx, edx);
-
-  bind(B1_5);
-  fld_d(ExternalAddress(TWO_32H));    //0x00000000UL, 0x41f80000UL
-  cmpl(ebx, 16400);
-  movl(Address(esp, 0), ecx);
-  fild_s(Address(esp, 0));
-  jcc(Assembler::greaterEqual, B1_7);
-
-  bind(B1_6);
-  fld_d(ExternalAddress(pi04_3d));    //0x54442d00UL, 0x3fe921fbUL
-  fmul(1);
-  fsubp(3);
-  fxch(1);
-  fmul(2);
-  fld_s(2);
-  fadd(1);
-  fsubrp(1);
-  fld_s(0);
-  fxch(1);
-  fsuba(3);
-  fld_d(ExternalAddress(8 + pi04_3d));    //0x98cc5180UL, 0x3ce84698UL
-  fmul(3);
-  fsuba(2);
-  fxch(1);
-  fsub(2);
-  fsubrp(1);
-  faddp(3);
-  fld_d(ExternalAddress(16 + pi04_3d));    //0xcbb5bf6cUL, 0xb9dfc8f8UL
-  fmulp(2);
-  fld_s(1);
-  fsubr(1);
-  fsuba(1);
-  fxch(2);
-  fsubp(1);
-  faddp(2);
-  fxch(1);
-  jmp(B1_15);
-
-  bind(B1_7);
-  fld_d(ExternalAddress(pi04_5d));    //0x54400000UL, 0x3fe921fbUL
-  fmul(1);
-  fsubp(3);
-  fxch(1);
-  fmul(2);
-  fld_s(2);
-  fadd(1);
-  fsubrp(1);
-  fld_s(0);
-  fxch(1);
-  fsuba(3);
-  fld_d(ExternalAddress(8 + pi04_5d));    //0x1a600000UL, 0x3dc0b461UL
-  fmul(3);
-  fsuba(2);
-  fxch(1);
-  fsub(2);
-  fsubrp(1);
-  faddp(3);
-  fld_d(ExternalAddress(16 + pi04_5d));    //0x2e000000UL, 0x3b93198aUL
-  fmul(2);
-  fld_s(0);
-  fsubr(2);
-  fsuba(2);
-  fxch(1);
-  fsubp(2);
-  fxch(1);
-  faddp(3);
-  fld_d(ExternalAddress(24 + pi04_5d));    //0x25200000UL, 0x396b839aUL
-  fmul(2);
-  fld_s(0);
-  fsubr(2);
-  fsuba(2);
-  fxch(1);
-  fsubp(2);
-  fxch(1);
-  faddp(3);
-  fld_d(ExternalAddress(32 + pi04_5d));    //0x533e63a0UL, 0x37027044UL
-  fmulp(2);
-  fld_s(1);
-  fsubr(1);
-  fsuba(1);
-  fxch(2);
-  fsubp(1);
-  faddp(2);
-  fxch(1);
-  jmp(B1_15);
-
-  bind(B1_8);
-  fld_x(Address(ebp, 8));
-  addl(ebx, -16417);
-  fmul_d(as_Address(ExternalAddress(SCALE)));    //0x00000000UL, 0x32600000UL
-  movl(eax, -2078209981);
-  imull(ebx);
-  addl(edx, ebx);
-  movl(ecx, ebx);
-  sarl(edx, 4);
-  sarl(ecx, 31);
-  subl(edx, ecx);
-  movl(eax, edx);
-  shll(eax, 5);
-  fstp_x(Address(ebp, 8));
-  fld_x(Address(ebp, 8));
-  subl(eax, edx);
-  movl(Address(ebp, 8), 0);
-  subl(ebx, eax);
-  fld_x(Address(ebp, 8));
-  cmpl(ebx, 17);
-  fsuba(1);
-  jcc(Assembler::less, B1_10);
-
-  bind(B1_9);
-  lea(eax, Address(noreg, edx, Address::times_8));
-  lea(ecx, Address(eax, edx, Address::times_4));
-  incl(edx);
-  fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
-  fmul(2);
-  fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
-  fmul(2);
-  fld_s(0);
-  fadd(2);
-  fsuba(2);
-  fxch(1);
-  faddp(2);
-  fld_s(1);
-  fadd(1);
-  fstp_x(Address(esp, 8));
-  andl(Address(esp, 8), -16777216);
-  fld_x(Address(esp, 8));
-  fsubp(1);
-  jmp(B1_11);
-
-  bind(B1_10);
-  fld_d(ExternalAddress(zeros));    //0x00000000UL, 0x00000000UL
-  fld_s(0);
-
-  bind(B1_11);
-  fld_s(0);
-  lea(eax, Address(noreg, edx, Address::times_8));
-  fld_s(3);
-  lea(edx, Address(eax, edx, Address::times_4));
-  fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1));
-  fmul(6);
-  movl(Address(esp, 0), edx);
-  fadda(2);
-  fxch(2);
-  fsuba(3);
-  fxch(2);
-  faddp(3);
-  fxch(2);
-  faddp(3);
-  fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1));
-  fmula(2);
-  fld_s(2);
-  fadd(2);
-  fld_s(0);
-  fxch(1);
-  fsubra(3);
-  fxch(3);
-  fchs();
-  faddp(4);
-  fxch(3);
-  faddp(4);
-  fxch(2);
-  fadd(3);
-  fxch(2);
-  fmul(5);
-  fadda(2);
-  fld_s(4);
-  fld_x(Address(24 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1));
-  fmula(1);
-  fxch(1);
-  fadda(4);
-  fxch(4);
-  fstp_x(Address(esp, 8));
-  movzwl(ebx, Address(esp, 16));
-  andl(ebx, 32767);
-  cmpl(ebx, 16415);
-  jcc(Assembler::greaterEqual, B1_13);
-
-  bind(B1_12);
-  negl(ebx);
-  addl(ebx, 30);
-  movl(ecx, ebx);
-  movl(eax, Address(esp, 12));
-  shrl(eax);
-  shll(eax);
-  movl(Address(esp, 12), eax);
-  movl(Address(esp, 8), 0);
-  shrl(eax);
-  jmp(B1_14);
-
-  bind(B1_13);
-  negl(ebx);
-  addl(ebx, 30);
-  movl(ecx, ebx);
-  movl(edx, Address(esp, 8));
-  shrl(edx);
-  shll(edx);
-  negl(ecx);
-  movl(eax, Address(esp, 12));
-  shll(eax);
-  movl(ecx, ebx);
-  movl(Address(esp, 8), edx);
-  shrl(edx);
-  orl(eax, edx);
-
-  bind(B1_14);
-  fld_x(Address(esp, 8));
-  addl(eax, Address(esp, 4));
-  fsubp(3);
-  fmul(6);
-  fld_s(4);
-  movl(edx, eax);
-  andl(edx, 1);
-  fadd(3);
-  movl(ecx, Address(esp, 0));
-  fsuba(3);
-  fxch(3);
-  faddp(5);
-  fld_s(1);
-  fxch(3);
-  fadd_d(Address(zero_none, RelocationHolder::none).plus_disp(edx, Address::times_8));
-  fadda(3);
-  fsub(3);
-  faddp(2);
-  fxch(1);
-  faddp(4);
-  fld_s(2);
-  fadd(2);
-  fsuba(2);
-  fxch(3);
-  faddp(2);
-  fxch(1);
-  faddp(3);
-  fld_s(0);
-  fadd(2);
-  fsuba(2);
-  fxch(1);
-  faddp(2);
-  fxch(1);
-  faddp(2);
-  fld_s(2);
-  fld_x(Address(36 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
-  fmula(1);
-  fld_s(1);
-  fadd(3);
-  fsuba(3);
-  fxch(2);
-  faddp(3);
-  fxch(2);
-  faddp(3);
-  fxch(1);
-  fmul(4);
-  fld_s(0);
-  fadd(2);
-  fsuba(2);
-  fxch(1);
-  faddp(2);
-  fxch(1);
-  faddp(2);
-  fld_s(2);
-  fld_x(Address(48 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
-  fmula(1);
-  fld_s(1);
-  fadd(3);
-  fsuba(3);
-  fxch(2);
-  faddp(3);
-  fxch(2);
-  faddp(3);
-  fld_s(3);
-  fxch(2);
-  fmul(5);
-  fld_x(Address(60 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
-  fmula(3);
-  fxch(3);
-  faddp(1);
-  fld_s(0);
-  fadd(2);
-  fsuba(2);
-  fxch(1);
-  faddp(2);
-  fxch(1);
-  faddp(3);
-  fld_s(3);
-  fxch(2);
-  fmul(5);
-  fld_x(Address(72 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
-  fmula(3);
-  fxch(3);
-  faddp(1);
-  fld_s(0);
-  fadd(2);
-  fsuba(2);
-  fxch(1);
-  faddp(2);
-  fxch(1);
-  faddp(3);
-  fxch(1);
-  fmulp(4);
-  fld_x(Address(84 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
-  fmulp(3);
-  fxch(2);
-  faddp(3);
-  fld_s(2);
-  fadd(2);
-  fld_d(ExternalAddress(TWO_32H));    //0x00000000UL, 0x41f80000UL
-  fmul(1);
-  fadda(1);
-  fsubp(1);
-  fsuba(2);
-  fxch(3);
-  faddp(2);
-  faddp(1);
-  fld_d(ExternalAddress(pi04_2d));    //0x54400000UL, 0x3fe921fbUL
-  fld_s(0);
-  fmul(2);
-  fxch(2);
-  fadd(3);
-  fxch(1);
-  fmulp(3);
-  fmul_d(as_Address(ExternalAddress(8 + pi04_2d)));    //0x1a626331UL, 0x3dc0b461UL
-  faddp(1);
-
-  bind(B1_15);
-  fld_d(ExternalAddress(TWO_12H));    //0x00000000UL, 0x40b80000UL
-  fld_s(2);
-  fadd(2);
-  fmula(1);
-  fstp_x(Address(esp, 8));
-  fld_x(Address(esp, 8));
-  fadd(1);
-  fsubrp(1);
-  fst_d(Address(esi, 0));
-  fsubp(2);
-  faddp(1);
-  fstp_d(Address(esi, 8));
-  addl(esp, 20);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-}
-
-ALIGNED_(16) juint _L_2il0floatpacket_0[] =
-{
-    0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL
-};
-
-ALIGNED_(16) juint _Pi4Inv[] =
-{
-    0x6dc9c883UL, 0x3ff45f30UL
-};
-
-ALIGNED_(16) juint _Pi4x3[] =
-{
-    0x54443000UL, 0xbfe921fbUL, 0x3b39a000UL, 0x3d373dcbUL, 0xe0e68948UL,
-    0xba845c06UL
-};
-
-ALIGNED_(16) juint _Pi4x4[] =
-{
-    0x54400000UL, 0xbfe921fbUL, 0x1a600000UL, 0xbdc0b461UL, 0x2e000000UL,
-    0xbb93198aUL, 0x252049c1UL, 0xb96b839aUL
-};
-
-ALIGNED_(16) jushort _SP[] =
-{
-    0xaaab, 0xaaaa, 0xaaaa, 0xaaaa, 0xbffc, 0x0000, 0x8887, 0x8888, 0x8888, 0x8888,
-    0x3ff8, 0x0000, 0xc527, 0x0d00, 0x00d0, 0xd00d, 0xbff2, 0x0000, 0x45f6, 0xb616,
-    0x1d2a, 0xb8ef, 0x3fec, 0x0000, 0x825b, 0x3997, 0x2b3f, 0xd732, 0xbfe5, 0x0000,
-    0xbf33, 0x8bb4, 0x2fda, 0xb092, 0x3fde, 0x0000, 0x44a6, 0xed1a, 0x29ef, 0xd73e,
-    0xbfd6, 0x0000, 0x8610, 0x307f, 0x62a1, 0xc921, 0x3fce, 0x0000
-};
-
-ALIGNED_(16) jushort _CP[] =
-{
-    0x0000, 0x0000, 0x0000, 0x8000, 0xbffe, 0x0000, 0xaaa5, 0xaaaa, 0xaaaa, 0xaaaa,
-    0x3ffa, 0x0000, 0x9c2f, 0x0b60, 0x60b6, 0xb60b, 0xbff5, 0x0000, 0xf024, 0x0cac,
-    0x00d0, 0xd00d, 0x3fef, 0x0000, 0x03fe, 0x3f65, 0x7dbb, 0x93f2, 0xbfe9, 0x0000,
-    0xd84d, 0xadee, 0xc698, 0x8f76, 0x3fe2, 0x0000, 0xdaba, 0xfe79, 0xea36, 0xc9c9,
-    0xbfda, 0x0000, 0x3ac6, 0x0ba0, 0x07ce, 0xd585, 0x3fd2, 0x0000
-};
-
-ALIGNED_(16) juint _ones[] =
-{
-    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xbff00000UL
-};
-
-void MacroAssembler::libm_sincos_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) {
-  Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12;
-  Label B1_13, B1_14, B1_15, B1_16, B1_17, B1_18, B1_19, B1_20, B1_21, B1_22, B1_23;
-  Label B1_24, B1_25, B1_26, B1_27, B1_28, B1_29, B1_30, B1_31, B1_32, B1_33, B1_34;
-  Label B1_35, B1_36, B1_37, B1_38, B1_39, B1_40, B1_41, B1_42, B1_43, B1_44, B1_45, B1_46;
-
-  assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp);
-
-  address L_2il0floatpacket_0 = (address)_L_2il0floatpacket_0;
-  address Pi4Inv = (address)_Pi4Inv;
-  address Pi4x3 = (address)_Pi4x3;
-  address Pi4x4 = (address)_Pi4x4;
-  address ones = (address)_ones;
-  address CP = (address)_CP;
-  address SP = (address)_SP;
-
-  bind(B1_1);
-  push(ebp);
-  movl(ebp, esp);
-  andl(esp, -64);
-  push(esi);
-  push(edi);
-  push(ebx);
-  subl(esp, 52);
-  movl(eax, Address(ebp, 16));
-  movl(edx, Address(ebp, 20));
-  movl(Address(esp, 32), eax);
-  movl(Address(esp, 36), edx);
-
-  bind(B1_2);
-  fnstcw(Address(esp, 30));
-
-  bind(B1_3);
-  movsd(xmm1, Address(ebp, 8));
-  movl(esi, Address(ebp, 12));
-  movl(eax, esi);
-  andl(eax, 2147483647);
-  andps(xmm1, ExternalAddress(L_2il0floatpacket_0));    //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL
-  shrl(esi, 31);
-  movl(Address(esp, 40), eax);
-  cmpl(eax, 1104150528);
-  movsd(Address(ebp, 8), xmm1);
-  jcc(Assembler::aboveEqual, B1_11);
-
-  bind(B1_4);
-  movsd(xmm0, ExternalAddress(Pi4Inv));    //0x6dc9c883UL, 0x3ff45f30UL
-  mulsd(xmm0, xmm1);
-  movzwl(edx, Address(esp, 30));
-  movl(eax, edx);
-  andl(eax, 768);
-  movsd(Address(esp, 0), xmm0);
-  cmpl(eax, 768);
-  jcc(Assembler::equal, B1_42);
-
-  bind(B1_5);
-  orl(edx, -64768);
-  movw(Address(esp, 28), edx);
-
-  bind(B1_6);
-  fldcw(Address(esp, 28));
-
-  bind(B1_7);
-  movsd(xmm1, Address(ebp, 8));
-  movl(ebx, 1);
-
-  bind(B1_8);
-  movl(Address(esp, 12), ebx);
-  movl(ebx, Address(esp, 4));
-  movl(eax, ebx);
-  movl(Address(esp, 8), esi);
-  movl(esi, ebx);
-  shrl(esi, 20);
-  andl(eax, 1048575);
-  movl(ecx, esi);
-  orl(eax, 1048576);
-  negl(ecx);
-  movl(edx, eax);
-  addl(ecx, 19);
-  addl(esi, 13);
-  movl(Address(esp, 24), ecx);
-  shrl(edx);
-  movl(ecx, esi);
-  shll(eax);
-  movl(ecx, Address(esp, 24));
-  movl(esi, Address(esp, 0));
-  shrl(esi);
-  orl(eax, esi);
-  cmpl(ebx, 1094713344);
-  movsd(Address(esp, 16), xmm1);
-  fld_d(Address(esp, 16));
-  cmov32(Assembler::below, eax, edx);
-  movl(esi, Address(esp, 8));
-  lea(edx, Address(eax, 1));
-  movl(ebx, edx);
-  andl(ebx, -2);
-  movl(Address(esp, 16), ebx);
-  fild_s(Address(esp, 16));
-  movl(ebx, Address(esp, 12));
-  cmpl(Address(esp, 40), 1094713344);
-  jcc(Assembler::aboveEqual, B1_10);
-
-  bind(B1_9);
-  fld_d(ExternalAddress(Pi4x3));    //0x54443000UL, 0xbfe921fbUL
-  fmul(1);
-  faddp(2);
-  fld_d(ExternalAddress(8 + Pi4x3));    //0x3b39a000UL, 0x3d373dcbUL
-  fmul(1);
-  faddp(2);
-  fld_d(ExternalAddress(16 + Pi4x3));    //0xe0e68948UL, 0xba845c06UL
-  fmulp(1);
-  faddp(1);
-  jmp(B1_17);
-
-  bind(B1_10);
-  fld_d(ExternalAddress(Pi4x4));    //0x54400000UL, 0xbfe921fbUL
-  fmul(1);
-  faddp(2);
-  fld_d(ExternalAddress(8 + Pi4x4));    //0x1a600000UL, 0xbdc0b461UL
-  fmul(1);
-  faddp(2);
-  fld_d(ExternalAddress(16 + Pi4x4));    //0x2e000000UL, 0xbb93198aUL
-  fmul(1);
-  faddp(2);
-  fld_d(ExternalAddress(24 + Pi4x4));    //0x252049c1UL, 0xb96b839aUL
-  fmulp(1);
-  faddp(1);
-  jmp(B1_17);
-
-  bind(B1_11);
-  movzwl(edx, Address(esp, 30));
-  movl(eax, edx);
-  andl(eax, 768);
-  cmpl(eax, 768);
-  jcc(Assembler::equal, B1_43);
-  bind(B1_12);
-  orl(edx, -64768);
-  movw(Address(esp, 28), edx);
-
-  bind(B1_13);
-  fldcw(Address(esp, 28));
-
-  bind(B1_14);
-  movsd(xmm1, Address(ebp, 8));
-  movl(ebx, 1);
-
-  bind(B1_15);
-  movsd(Address(esp, 16), xmm1);
-  fld_d(Address(esp, 16));
-  addl(esp, -32);
-  lea(eax, Address(esp, 32));
-  fstp_x(Address(esp, 0));
-  movl(Address(esp, 12), 0);
-  movl(Address(esp, 16), eax);
-  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_reduce_pi04l())));
-
-  bind(B1_46);
-  addl(esp, 32);
-
-  bind(B1_16);
-  fld_d(Address(esp, 0));
-  lea(edx, Address(eax, 1));
-  fld_d(Address(esp, 8));
-  faddp(1);
-
-  bind(B1_17);
-  movl(ecx, edx);
-  addl(eax, 3);
-  shrl(ecx, 2);
-  andl(ecx, 1);
-  shrl(eax, 2);
-  xorl(esi, ecx);
-  movl(ecx, Address(esp, 36));
-  andl(eax, 1);
-  andl(ecx, 3);
-  cmpl(ecx, 3);
-  jcc(Assembler::notEqual, B1_25);
-
-  bind(B1_18);
-  fld_x(ExternalAddress(84 + SP));    //0x8610, 0x307f, 0x62
-  fld_s(1);
-  fmul((2));
-  testb(edx, 2);
-  fmula((1));
-  fld_x(ExternalAddress(72 + SP));    //0x44a6, 0xed1a, 0x29
-  faddp(2);
-  fmula(1);
-  fld_x(ExternalAddress(60 + SP));    //0xbf33, 0x8bb4, 0x2f
-  faddp(2);
-  fmula(1);
-  fld_x(ExternalAddress(48 + SP));    //0x825b, 0x3997, 0x2b
-  faddp(2);
-  fmula(1);
-  fld_x(ExternalAddress(36 + SP));    //0x45f6, 0xb616, 0x1d
-  faddp(2);
-  fmula(1);
-  fld_x(ExternalAddress(24 + SP));    //0xc527, 0x0d00, 0x00
-  faddp(2);
-  fmula(1);
-  fld_x(ExternalAddress(12 + SP));    //0x8887, 0x8888, 0x88
-  faddp(2);
-  fmula(1);
-  fld_x(ExternalAddress(SP));    //0xaaab, 0xaaaa, 0xaa
-  faddp(2);
-  fmula(1);
-  fld_x(ExternalAddress(84 + CP));    //0x3ac6, 0x0ba0, 0x07
-  fmul(1);
-  fld_x(ExternalAddress(72 + CP));    //0xdaba, 0xfe79, 0xea
-  faddp(1);
-  fmul(1);
-  fld_x(ExternalAddress(62 + CP));    //0xd84d, 0xadee, 0xc6
-  faddp(1);
-  fmul(1);
-  fld_x(ExternalAddress(48 + CP));    //0x03fe, 0x3f65, 0x7d
-  faddp(1);
-  fmul(1);
-  fld_x(ExternalAddress(36 + CP));    //0xf024, 0x0cac, 0x00
-  faddp(1);
-  fmul(1);
-  fld_x(ExternalAddress(24 + CP));    //0x9c2f, 0x0b60, 0x60
-  faddp(1);
-  fmul(1);
-  fld_x(ExternalAddress(12 + CP));    //0xaaa5, 0xaaaa, 0xaa
-  faddp(1);
-  fmul(1);
-  fld_x(ExternalAddress(CP));    //0x0000, 0x0000, 0x00
-  faddp(1);
-  fmulp(1);
-  fld_d(Address(ones, RelocationHolder::none).plus_disp(esi, Address::times_8));
-  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
-  jcc(Assembler::equal, B1_22);
-
-  bind(B1_19);
-  fmulp(4);
-  testl(ebx, ebx);
-  fxch(2);
-  fmul(3);
-  movl(eax, Address(esp, 2));
-  faddp(3);
-  fxch(2);
-  fstp_d(Address(eax, 0));
-  fmula(1);
-  faddp(1);
-  fstp_d(Address(eax, 8));
-  jcc(Assembler::equal, B1_21);
-
-  bind(B1_20);
-  fldcw(Address(esp, 30));
-
-  bind(B1_21);
-  addl(esp, 52);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-
-  bind(B1_22);
-  fxch(1);
-  fmulp(4);
-  testl(ebx, ebx);
-  fxch(2);
-  fmul(3);
-  movl(eax, Address(esp, 32));
-  faddp(3);
-  fxch(2);
-  fstp_d(Address(eax, 8));
-  fmula(1);
-  faddp(1);
-  fstp_d(Address(eax, 0));
-  jcc(Assembler::equal, B1_24);
-
-  bind(B1_23);
-  fldcw(Address(esp, 30));
-
-  bind(B1_24);
-  addl(esp, 52);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-
-  bind(B1_25);
-  testb(Address(esp, 36), 2);
-  jcc(Assembler::equal, B1_33);
-
-  bind(B1_26);
-  fld_s(0);
-  testb(edx, 2);
-  fmul(1);
-  fld_s(0);
-  fmul(1);
-  jcc(Assembler::equal, B1_30);
-
-  bind(B1_27);
-  fstp_d(2);
-  fld_x(ExternalAddress(84 + CP));    //0x3ac6, 0x0ba0, 0x07
-  testl(ebx, ebx);
-  fmul(2);
-  fld_x(ExternalAddress(72 + CP));    //0xdaba, 0xfe79, 0xea
-  fmul(3);
-  fld_x(ExternalAddress(60 + CP));    //0xd84d, 0xadee, 0xc6
-  movl(eax, Address(rsp, 32));
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(48 + CP));    //0x03fe, 0x3f65, 0x7d
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(36 + CP));    //0xf024, 0x0cac, 0x00
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(24 + CP));    //0x9c2f, 0x0b60, 0x60
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(12 + CP));    //0xaaa5, 0xaaaa, 0xaa
-  faddp(2);
-  fxch(1);
-  fmulp(3);
-  fld_x(ExternalAddress(CP));    //0x0000, 0x0000, 0x00
-  faddp(1);
-  fmulp(1);
-  faddp(1);
-  fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8));
-  fmula(1);
-  faddp(1);
-  fstp_d(Address(eax, 8));
-  jcc(Assembler::equal, B1_29);
-
-  bind(B1_28);
-  fldcw(Address(esp, 30));
-
-  bind(B1_29);
-  addl(esp, 52);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-
-  bind(B1_30);
-  fld_x(ExternalAddress(84 + SP));    //0x8610, 0x307f, 0x62
-  testl(ebx, ebx);
-  fmul(1);
-  fld_x(ExternalAddress(72 + SP));    //0x44a6, 0xed1a, 0x29
-  fmul(2);
-  fld_x(ExternalAddress(60 + SP));    //0xbf33, 0x8bb4, 0x2f
-  movl(eax, Address(rsp, 32));
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(48 + SP));    //0x825b, 0x3997, 0x2b
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(36 + SP));    //0x45f6, 0xb616, 0x1d
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(24 + SP));    //0xc527, 0x0d00, 0x00
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(12 + SP));    //0x8887, 0x8888, 0x88
-  faddp(2);
-  fxch(1);
-  fmulp(2);
-  fld_x(ExternalAddress(SP));    //0xaaab, 0xaaaa, 0xaa
-  faddp(1);
-  fmulp(2);
-  faddp(1);
-  fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8));
-  fmulp(2);
-  fmul(1);
-  faddp(1);
-  fstp_d(Address(eax, 8));
-  jcc(Assembler::equal, B1_32);
-
-  bind(B1_31);
-  fldcw(Address(esp, 30));
-
-  bind(B1_32);
-  addl(esp, 52);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-
-  bind(B1_33);
-  testb(Address(esp, 36), 1);
-  jcc(Assembler::equal, B1_41);
-
-  bind(B1_34);
-  fld_s(0);
-  testb(edx, 2);
-  fmul(1);
-  fld_s(0);
-  fmul(1);
-  jcc(Assembler::equal, B1_38);
-
-  bind(B1_35);
-  fld_x(ExternalAddress(84 + SP));    //0x8610, 0x307f, 0x62
-  testl(ebx, ebx);
-  fmul(1);
-  fld_x(ExternalAddress(72 + SP));    //0x44a6, 0xed1a, 0x29
-  fmul(2);
-  fld_x(ExternalAddress(60 + SP));    //0xbf33, 0x8bb4, 0x2f
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(48 + SP));    //0x825b, 0x3997, 0x2b
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(36 + SP));    //0x45f6, 0xb616, 0x1d
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(24 + SP));    //0xc527, 0x0d00, 0x00
-  faddp(2);
-  fxch(1);
-  fmul(2);
-  fld_x(ExternalAddress(12 + SP));    //0x8887, 0x8888, 0x88
-  faddp(2);
-  fxch(1);
-  fmulp(2);
-  fld_x(ExternalAddress(SP));    //0xaaab, 0xaaaa, 0xaa
-  faddp(1);
-  fmulp(2);
-  faddp(1);
-  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
-  fmulp(2);
-  fmul(1);
-  movl(eax, Address(esp, 32));
-  faddp(1);
-  fstp_d(Address(eax, 0));
-  jcc(Assembler::equal, B1_37);
-
-  bind(B1_36);
-  fldcw(Address(esp, 30));
-
-  bind(B1_37);
-  addl(esp, 52);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-
-  bind(B1_38);
-  fstp_d(2);
-  fld_x(ExternalAddress(84 + CP));    //0x3ac6, 0x0ba0, 0x07
-  testl(ebx, ebx);
-  fmul(2);
-  fld_x(ExternalAddress(72 + CP));    //0xdaba, 0xfe79, 0xea
-  fmul(3);
-  fld_x(ExternalAddress(60 + CP));    //0xd84d, 0xadee, 0xc6
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(48 + CP));    //0x03fe, 0x3f65, 0x7d
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(36 + CP));    //0xf024, 0x0cac, 0x00
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(24 + CP));    //0x9c2f, 0x0b60, 0x60
-  faddp(2);
-  fxch(1);
-  fmul(3);
-  fld_x(ExternalAddress(12 + CP));    //0xaaa5, 0xaaaa, 0xaa
-  faddp(2);
-  fxch(1);
-  fmulp(3);
-  fld_x(ExternalAddress(CP));    //0x0000, 0x0000, 0x00
-  faddp(1);
-  fmulp(1);
-  faddp(1);
-  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
-  fmula(1);
-  movl(eax, Address(esp, 32));
-  faddp(1);
-  fstp_d(Address(eax, 0));
-  jcc(Assembler::equal, B1_40);
-
-  bind(B1_39);
-  fldcw(Address(esp, 30));
-  bind(B1_40);
-  addl(esp, 52);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-  bind(B1_41);
-  fstp_d(0);
-  addl(esp, 52);
-  pop(ebx);
-  pop(edi);
-  pop(esi);
-  movl(esp, ebp);
-  pop(ebp);
-  ret(0);
-  bind(B1_42);
-  xorl(ebx, ebx);
-  jmp(B1_8);
-  bind(B1_43);
-  xorl(ebx, ebx);
-  jmp(B1_15);
-}
-
-ALIGNED_(16) juint _static_const_table_sin[] =
-{
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL,
-    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
-    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL,
-    0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL,
-    0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL,
-    0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL,
-    0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL,
-    0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL,
-    0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL,
-    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
-    0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL,
-    0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL,
-    0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL,
-    0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL,
-    0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL,
-    0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL,
-    0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL,
-    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
-    0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL,
-    0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL,
-    0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL,
-    0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL,
-    0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL,
-    0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL,
-    0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL,
-    0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL,
-    0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL,
-    0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL,
-    0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL,
-    0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL,
-    0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL,
-    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
-    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL,
-    0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL,
-    0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL,
-    0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL,
-    0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL,
-    0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL,
-    0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL,
-    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
-    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL,
-    0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL,
-    0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL,
-    0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL,
-    0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL,
-    0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL,
-    0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL,
-    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
-    0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL,
-    0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
-    0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL,
-    0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL,
-    0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL,
-    0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL,
-    0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL,
-    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL,
-    0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL,
-    0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
-    0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL,
-    0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL,
-    0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL,
-    0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL,
-    0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL,
-    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL,
-    0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL,
-    0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
-    0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL,
-    0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL,
-    0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL,
-    0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL,
-    0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL,
-    0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL,
-    0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL,
-    0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL,
-    0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL,
-    0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL,
-    0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL,
-    0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL,
-    0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL,
-    0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
-    0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL,
-    0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL,
-    0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL,
-    0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL,
-    0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL,
-    0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL,
-    0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL,
-    0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
-    0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL,
-    0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL,
-    0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL,
-    0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL,
-    0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL,
-    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL,
-    0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL,
-    0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
-    0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL,
-    0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL,
-    0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL,
-    0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL,
-    0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL,
-    0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL,
-    0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x43600000UL,
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3c800000UL, 0x00000000UL,
-    0x00000000UL, 0xffffffffUL, 0x3fefffffUL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x80000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x3fe00000UL,
-    0x00000000UL, 0x3fe00000UL
-};
-
-void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register edx) {
-
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, start;
-  assert_different_registers(eax, ebx, edx);
-  address static_const_table_sin = (address)_static_const_table_sin;
-
-  bind(start);
-  subl(rsp, 120);
-  movl(Address(rsp, 56), ebx);
-  lea(ebx, ExternalAddress(static_const_table_sin));
-  movsd(xmm0, Address(rsp, 128));
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32767);
-  subl(eax, 12336);
-  cmpl(eax, 4293);
-  jcc(Assembler::above, L_2TAG_PACKET_0_0_2);
-  movsd(xmm1, Address(ebx, 2160));
-  mulsd(xmm1, xmm0);
-  movsd(xmm5, Address(ebx, 2272));
-  movdqu(xmm4, Address(ebx, 2256));
-  pand(xmm4, xmm0);
-  por(xmm5, xmm4);
-  movsd(xmm3, Address(ebx, 2128));
-  movdqu(xmm2, Address(ebx, 2112));
-  addpd(xmm1, xmm5);
-  cvttsd2sil(edx, xmm1);
-  cvtsi2sdl(xmm1, edx);
-  mulsd(xmm3, xmm1);
-  unpcklpd(xmm1, xmm1);
-  addl(edx, 1865216);
-  movdqu(xmm4, xmm0);
-  andl(edx, 63);
-  movdqu(xmm5, Address(ebx, 2096));
-  lea(eax, Address(ebx, 0));
-  shll(edx, 5);
-  addl(eax, edx);
-  mulpd(xmm2, xmm1);
-  subsd(xmm0, xmm3);
-  mulsd(xmm1, Address(ebx, 2144));
-  subsd(xmm4, xmm3);
-  movsd(xmm7, Address(eax, 8));
-  unpcklpd(xmm0, xmm0);
-  movapd(xmm3, xmm4);
-  subsd(xmm4, xmm2);
-  mulpd(xmm5, xmm0);
-  subpd(xmm0, xmm2);
-  movdqu(xmm6, Address(ebx, 2064));
-  mulsd(xmm7, xmm4);
-  subsd(xmm3, xmm4);
-  mulpd(xmm5, xmm0);
-  mulpd(xmm0, xmm0);
-  subsd(xmm3, xmm2);
-  movdqu(xmm2, Address(eax, 0));
-  subsd(xmm1, xmm3);
-  movsd(xmm3, Address(eax, 24));
-  addsd(xmm2, xmm3);
-  subsd(xmm7, xmm2);
-  mulsd(xmm2, xmm4);
-  mulpd(xmm6, xmm0);
-  mulsd(xmm3, xmm4);
-  mulpd(xmm2, xmm0);
-  mulpd(xmm0, xmm0);
-  addpd(xmm5, Address(ebx, 2080));
-  mulsd(xmm4, Address(eax, 0));
-  addpd(xmm6, Address(ebx, 2048));
-  mulpd(xmm5, xmm0);
-  movapd(xmm0, xmm3);
-  addsd(xmm3, Address(eax, 8));
-  mulpd(xmm1, xmm7);
-  movapd(xmm7, xmm4);
-  addsd(xmm4, xmm3);
-  addpd(xmm6, xmm5);
-  movsd(xmm5, Address(eax, 8));
-  subsd(xmm5, xmm3);
-  subsd(xmm3, xmm4);
-  addsd(xmm1, Address(eax, 16));
-  mulpd(xmm6, xmm2);
-  addsd(xmm5, xmm0);
-  addsd(xmm3, xmm7);
-  addsd(xmm1, xmm5);
-  addsd(xmm1, xmm3);
-  addsd(xmm1, xmm6);
-  unpckhpd(xmm6, xmm6);
-  addsd(xmm1, xmm6);
-  addsd(xmm4, xmm1);
-  movsd(Address(rsp, 0), xmm4);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
-  shrl(eax, 4);
-  cmpl(eax, 268434685);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_3_0_2);
-  movsd(Address(rsp, 0), xmm0);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  movsd(xmm3, Address(ebx, 2192));
-  mulsd(xmm3, xmm0);
-  subsd(xmm3, xmm0);
-  mulsd(xmm3, Address(ebx, 2208));
-  movsd(Address(rsp, 0), xmm0);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  movl(eax, Address(rsp, 132));
-  andl(eax, 2146435072);
-  cmpl(eax, 2146435072);
-  jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
-  subl(rsp, 32);
-  movsd(Address(rsp, 0), xmm0);
-  lea(eax, Address(rsp, 40));
-  movl(Address(rsp, 8), eax);
-  movl(eax, 2);
-  movl(Address(rsp, 12), eax);
-  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge())));
-  addl(rsp, 32);
-  fld_d(Address(rsp, 16));
-  jmp(L_2TAG_PACKET_1_0_2);
-  bind(L_2TAG_PACKET_4_0_2);
-  fld_d(Address(rsp, 128));
-  fmul_d(Address(ebx, 2240));
-  bind(L_2TAG_PACKET_1_0_2);
-  movl(ebx, Address(rsp, 56));
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - COS()
-//                     ---------------------
-//
-//     1. RANGE REDUCTION
-//
-//     We perform an initial range reduction from X to r with
-//
-//          X =~= N * pi/32 + r
-//
-//     so that |r| <= pi/64 + epsilon. We restrict inputs to those
-//     where |N| <= 932560. Beyond this, the range reduction is
-//     insufficiently accurate. For extremely small inputs,
-//     denormalization can occur internally, impacting performance.
-//     This means that the main path is actually only taken for
-//     2^-252 <= |X| < 90112.
-//
-//     To avoid branches, we perform the range reduction to full
-//     accuracy each time.
-//
-//          X - N * (P_1 + P_2 + P_3)
-//
-//     where P_1 and P_2 are 32-bit numbers (so multiplication by N
-//     is exact) and P_3 is a 53-bit number. Together, these
-//     approximate pi well enough for all cases in the restricted
-//     range.
-//
-//     The main reduction sequence is:
-//
-//             y = 32/pi * x
-//             N = integer(y)
-//     (computed by adding and subtracting off SHIFTER)
-//
-//             m_1 = N * P_1
-//             m_2 = N * P_2
-//             r_1 = x - m_1
-//             r = r_1 - m_2
-//     (this r can be used for most of the calculation)
-//
-//             c_1 = r_1 - r
-//             m_3 = N * P_3
-//             c_2 = c_1 - m_2
-//             c = c_2 - m_3
-//
-//     2. MAIN ALGORITHM
-//
-//     The algorithm uses a table lookup based on B = M * pi / 32
-//     where M = N mod 64. The stored values are:
-//       sigma             closest power of 2 to cos(B)
-//       C_hl              53-bit cos(B) - sigma
-//       S_hi + S_lo       2 * 53-bit sin(B)
-//
-//     The computation is organized as follows:
-//
-//          sin(B + r + c) = [sin(B) + sigma * r] +
-//                           r * (cos(B) - sigma) +
-//                           sin(B) * [cos(r + c) - 1] +
-//                           cos(B) * [sin(r + c) - r]
-//
-//     which is approximately:
-//
-//          [S_hi + sigma * r] +
-//          C_hl * r +
-//          S_lo + S_hi * [(cos(r) - 1) - r * c] +
-//          (C_hl + sigma) * [(sin(r) - r) + c]
-//
-//     and this is what is actually computed. We separate this sum
-//     into four parts:
-//
-//          hi + med + pols + corr
-//
-//     where
-//
-//          hi       = S_hi + sigma r
-//          med      = C_hl * r
-//          pols     = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r)
-//          corr     = S_lo + c * ((C_hl + sigma) - S_hi * r)
-//
-//     3. POLYNOMIAL
-//
-//     The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) *
-//     (sin(r) - r) can be rearranged freely, since it is quite
-//     small, so we exploit parallelism to the fullest.
-//
-//          psc4       =   SC_4 * r_1
-//          msc4       =   psc4 * r
-//          r2         =   r * r
-//          msc2       =   SC_2 * r2
-//          r4         =   r2 * r2
-//          psc3       =   SC_3 + msc4
-//          psc1       =   SC_1 + msc2
-//          msc3       =   r4 * psc3
-//          sincospols =   psc1 + msc3
-//          pols       =   sincospols *
-//                         <S_hi * r^2 | (C_hl + sigma) * r^3>
-//
-//     4. CORRECTION TERM
-//
-//     This is where the "c" component of the range reduction is
-//     taken into account; recall that just "r" is used for most of
-//     the calculation.
-//
-//          -c   = m_3 - c_2
-//          -d   = S_hi * r - (C_hl + sigma)
-//          corr = -c * -d + S_lo
-//
-//     5. COMPENSATED SUMMATIONS
-//
-//     The two successive compensated summations add up the high
-//     and medium parts, leaving just the low parts to add up at
-//     the end.
-//
-//          rs        =  sigma * r
-//          res_int   =  S_hi + rs
-//          k_0       =  S_hi - res_int
-//          k_2       =  k_0 + rs
-//          med       =  C_hl * r
-//          res_hi    =  res_int + med
-//          k_1       =  res_int - res_hi
-//          k_3       =  k_1 + med
-//
-//     6. FINAL SUMMATION
-//
-//     We now add up all the small parts:
-//
-//          res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3
-//
-//     Now the overall result is just:
-//
-//          res_hi + res_lo
-//
-//     7. SMALL ARGUMENTS
-//
-//     Inputs with |X| < 2^-252 are treated specially as
-//     1 - |x|.
-//
-// Special cases:
-//  cos(NaN) = quiet NaN, and raise invalid exception
-//  cos(INF) = NaN and raise invalid exception
-//  cos(0) = 1
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _static_const_table_cos[] =
-{
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL,
-    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
-    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL,
-    0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL,
-    0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL,
-    0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL,
-    0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL,
-    0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL,
-    0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL,
-    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
-    0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL,
-    0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL,
-    0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL,
-    0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL,
-    0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL,
-    0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL,
-    0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL,
-    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
-    0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL,
-    0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL,
-    0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL,
-    0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL,
-    0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL,
-    0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL,
-    0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL,
-    0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL,
-    0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL,
-    0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL,
-    0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL,
-    0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL,
-    0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL,
-    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
-    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL,
-    0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL,
-    0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL,
-    0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL,
-    0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL,
-    0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL,
-    0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL,
-    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
-    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL,
-    0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL,
-    0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL,
-    0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL,
-    0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL,
-    0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL,
-    0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL,
-    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
-    0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL,
-    0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
-    0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL,
-    0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL,
-    0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL,
-    0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL,
-    0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL,
-    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL,
-    0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL,
-    0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
-    0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL,
-    0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL,
-    0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL,
-    0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL,
-    0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL,
-    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL,
-    0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL,
-    0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
-    0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL,
-    0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL,
-    0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL,
-    0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL,
-    0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL,
-    0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL,
-    0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL,
-    0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL,
-    0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL,
-    0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL,
-    0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL,
-    0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL,
-    0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL,
-    0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
-    0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL,
-    0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL,
-    0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL,
-    0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL,
-    0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL,
-    0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL,
-    0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL,
-    0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
-    0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL,
-    0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL,
-    0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL,
-    0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL,
-    0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL,
-    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL,
-    0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL,
-    0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
-    0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL,
-    0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL,
-    0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL,
-    0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL,
-    0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL,
-    0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL,
-    0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3ff00000UL,
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
-};
-
-//registers,
-// input: (rbp + 8)
-// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
-//          rax, rdx, rcx, rbx (tmp)
-
-// Code generated by Intel C compiler for LIBM library
-
-void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
-  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
-  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start;
-
-  assert_different_registers(tmp, eax, ecx, edx);
-
-  address static_const_table_cos = (address)_static_const_table_cos;
-
-  bind(start);
-  subl(rsp, 120);
-  movl(Address(rsp, 56), tmp);
-  lea(tmp, ExternalAddress(static_const_table_cos));
-  movsd(xmm0, Address(rsp, 128));
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32767);
-  subl(eax, 12336);
-  cmpl(eax, 4293);
-  jcc(Assembler::above, L_2TAG_PACKET_0_0_2);
-  movsd(xmm1, Address(tmp, 2160));
-  mulsd(xmm1, xmm0);
-  movdqu(xmm5, Address(tmp, 2240));
-  movsd(xmm4, Address(tmp, 2224));
-  pand(xmm4, xmm0);
-  por(xmm5, xmm4);
-  movsd(xmm3, Address(tmp, 2128));
-  movdqu(xmm2, Address(tmp, 2112));
-  addpd(xmm1, xmm5);
-  cvttsd2sil(edx, xmm1);
-  cvtsi2sdl(xmm1, edx);
-  mulsd(xmm3, xmm1);
-  unpcklpd(xmm1, xmm1);
-  addl(edx, 1865232);
-  movdqu(xmm4, xmm0);
-  andl(edx, 63);
-  movdqu(xmm5, Address(tmp, 2096));
-  lea(eax, Address(tmp, 0));
-  shll(edx, 5);
-  addl(eax, edx);
-  mulpd(xmm2, xmm1);
-  subsd(xmm0, xmm3);
-  mulsd(xmm1, Address(tmp, 2144));
-  subsd(xmm4, xmm3);
-  movsd(xmm7, Address(eax, 8));
-  unpcklpd(xmm0, xmm0);
-  movapd(xmm3, xmm4);
-  subsd(xmm4, xmm2);
-  mulpd(xmm5, xmm0);
-  subpd(xmm0, xmm2);
-  movdqu(xmm6, Address(tmp, 2064));
-  mulsd(xmm7, xmm4);
-  subsd(xmm3, xmm4);
-  mulpd(xmm5, xmm0);
-  mulpd(xmm0, xmm0);
-  subsd(xmm3, xmm2);
-  movdqu(xmm2, Address(eax, 0));
-  subsd(xmm1, xmm3);
-  movsd(xmm3, Address(eax, 24));
-  addsd(xmm2, xmm3);
-  subsd(xmm7, xmm2);
-  mulsd(xmm2, xmm4);
-  mulpd(xmm6, xmm0);
-  mulsd(xmm3, xmm4);
-  mulpd(xmm2, xmm0);
-  mulpd(xmm0, xmm0);
-  addpd(xmm5, Address(tmp, 2080));
-  mulsd(xmm4, Address(eax, 0));
-  addpd(xmm6, Address(tmp, 2048));
-  mulpd(xmm5, xmm0);
-  movapd(xmm0, xmm3);
-  addsd(xmm3, Address(eax, 8));
-  mulpd(xmm1, xmm7);
-  movapd(xmm7, xmm4);
-  addsd(xmm4, xmm3);
-  addpd(xmm6, xmm5);
-  movsd(xmm5, Address(eax, 8));
-  subsd(xmm5, xmm3);
-  subsd(xmm3, xmm4);
-  addsd(xmm1, Address(eax, 16));
-  mulpd(xmm6, xmm2);
-  addsd(xmm5, xmm0);
-  addsd(xmm3, xmm7);
-  addsd(xmm1, xmm5);
-  addsd(xmm1, xmm3);
-  addsd(xmm1, xmm6);
-  unpckhpd(xmm6, xmm6);
-  addsd(xmm1, xmm6);
-  addsd(xmm4, xmm1);
-  movsd(Address(rsp, 0), xmm4);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32767);
-  pinsrw(xmm0, eax, 3);
-  movsd(xmm1, Address(tmp, 2192));
-  subsd(xmm1, xmm0);
-  movsd(Address(rsp, 0), xmm1);
-  fld_d(Address(rsp, 0));
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  movl(eax, Address(rsp, 132));
-  andl(eax, 2146435072);
-  cmpl(eax, 2146435072);
-  jcc(Assembler::equal, L_2TAG_PACKET_3_0_2);
-  subl(rsp, 32);
-  movsd(Address(rsp, 0), xmm0);
-  lea(eax, Address(rsp, 40));
-  movl(Address(rsp, 8), eax);
-  movl(eax, 1);
-  movl(Address(rsp, 12), eax);
-  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge())));
-  addl(rsp, 32);
-  fld_d(Address(rsp, 8));
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  fld_d(Address(rsp, 128));
-  fmul_d(Address(tmp, 2208));
-
-  bind(L_2TAG_PACKET_1_0_2);
-  movl(tmp, Address(rsp, 56));
-}
-
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_64.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_64.cpp
deleted file mode 100644
index f2f2211..0000000
--- a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_64.cpp
+++ /dev/null
@@ -1,3945 +0,0 @@
-/*
- * Copyright (c) 2015, Intel Corporation.
- * Intel Math Library (LIBM) Source Code
- *
- * 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 "asm/assembler.hpp"
-#include "asm/assembler.inline.hpp"
-#include "macroAssembler_x86.hpp"
-
-#ifdef _MSC_VER
-#define ALIGNED_(x) __declspec(align(x))
-#else
-#define ALIGNED_(x) __attribute__ ((aligned(x)))
-#endif
-
-// The 64 bit code is at most SSE2 compliant
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - EXP()
-//                     ---------------------
-//
-// Description:
-//  Let K = 64 (table size).
-//        x    x/log(2)     n
-//       e  = 2          = 2 * T[j] * (1 + P(y))
-//  where
-//       x = m*log(2)/K + y,    y in [-log(2)/K..log(2)/K]
-//       m = n*K + j,           m,n,j - signed integer, j in [-K/2..K/2]
-//                  j/K
-//       values of 2   are tabulated as T[j] = T_hi[j] ( 1 + T_lo[j]).
-//
-//       P(y) is a minimax polynomial approximation of exp(x)-1
-//       on small interval [-log(2)/K..log(2)/K] (were calculated by Maple V).
-//
-//  To avoid problems with arithmetic overflow and underflow,
-//            n                        n1  n2
-//  value of 2  is safely computed as 2 * 2 where n1 in [-BIAS/2..BIAS/2]
-//  where BIAS is a value of exponent bias.
-//
-// Special cases:
-//  exp(NaN) = NaN
-//  exp(+INF) = +INF
-//  exp(-INF) = 0
-//  exp(x) = 1 for subnormals
-//  for finite argument, only exp(0)=1 is exact
-//  For IEEE double
-//    if x >  709.782712893383973096 then exp(x) overflow
-//    if x < -745.133219101941108420 then exp(x) underflow
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _cv[] =
-{
-    0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL, 0xfefa0000UL,
-    0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL, 0x3d1cf79aUL,
-    0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL,
-    0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL,
-    0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL
-};
-
-ALIGNED_(16) juint _shifter[] =
-{
-    0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL
-};
-
-ALIGNED_(16) juint _mmask[] =
-{
-    0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL
-};
-
-ALIGNED_(16) juint _bias[] =
-{
-    0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL
-};
-
-ALIGNED_(16) juint _Tbl_addr[] =
-{
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL,
-    0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL,
-    0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL,
-    0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL,
-    0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL,
-    0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL,
-    0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL,
-    0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL,
-    0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL,
-    0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL,
-    0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL,
-    0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL,
-    0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL,
-    0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL,
-    0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL,
-    0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL,
-    0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL,
-    0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL,
-    0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL,
-    0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL,
-    0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL,
-    0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL,
-    0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL,
-    0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL,
-    0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL,
-    0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL,
-    0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL,
-    0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL,
-    0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL,
-    0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL,
-    0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL,
-    0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL,
-    0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL,
-    0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL,
-    0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL,
-    0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL,
-    0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL,
-    0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL,
-    0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL,
-    0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL,
-    0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL,
-    0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL,
-    0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL,
-    0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL,
-    0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL,
-    0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL,
-    0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL,
-    0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL,
-    0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL,
-    0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL,
-    0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL,
-    0x000fa7c1UL
-};
-
-ALIGNED_(16) juint _ALLONES[] =
-{
-    0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL
-};
-
-ALIGNED_(16) juint _ebias[] =
-{
-    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL
-};
-
-ALIGNED_(4) juint _XMAX[] =
-{
-    0xffffffffUL, 0x7fefffffUL
-};
-
-ALIGNED_(4) juint _XMIN[] =
-{
-    0x00000000UL, 0x00100000UL
-};
-
-ALIGNED_(4) juint _INF[] =
-{
-    0x00000000UL, 0x7ff00000UL
-};
-
-ALIGNED_(4) juint _ZERO[] =
-{
-    0x00000000UL, 0x00000000UL
-};
-
-ALIGNED_(4) juint _ONE_val[] =
-{
-    0x00000000UL, 0x3ff00000UL
-};
-
-
-// Registers:
-// input: xmm0
-// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
-//          rax, rdx, rcx, tmp - r11
-
-// Code generated by Intel C compiler for LIBM library
-
-void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
-  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
-  Label L_2TAG_PACKET_12_0_2, B1_3, B1_5, start;
-
-  assert_different_registers(tmp, eax, ecx, edx);
-  jmp(start);
-  address cv = (address)_cv;
-  address Shifter = (address)_shifter;
-  address mmask = (address)_mmask;
-  address bias = (address)_bias;
-  address Tbl_addr = (address)_Tbl_addr;
-  address ALLONES = (address)_ALLONES;
-  address ebias = (address)_ebias;
-  address XMAX = (address)_XMAX;
-  address XMIN = (address)_XMIN;
-  address INF = (address)_INF;
-  address ZERO = (address)_ZERO;
-  address ONE_val = (address)_ONE_val;
-
-  bind(start);
-  subq(rsp, 24);
-  movsd(Address(rsp, 8), xmm0);
-  unpcklpd(xmm0, xmm0);
-  movdqu(xmm1, ExternalAddress(cv));       // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL
-  movdqu(xmm6, ExternalAddress(Shifter));  // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL
-  movdqu(xmm2, ExternalAddress(16+cv));    // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL
-  movdqu(xmm3, ExternalAddress(32+cv));    // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32767);
-  movl(edx, 16527);
-  subl(edx, eax);
-  subl(eax, 15504);
-  orl(edx, eax);
-  cmpl(edx, INT_MIN);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
-  mulpd(xmm1, xmm0);
-  addpd(xmm1, xmm6);
-  movapd(xmm7, xmm1);
-  subpd(xmm1, xmm6);
-  mulpd(xmm2, xmm1);
-  movdqu(xmm4, ExternalAddress(64+cv));    // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL
-  mulpd(xmm3, xmm1);
-  movdqu(xmm5, ExternalAddress(80+cv));    // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL
-  subpd(xmm0, xmm2);
-  movdl(eax, xmm7);
-  movl(ecx, eax);
-  andl(ecx, 63);
-  shll(ecx, 4);
-  sarl(eax, 6);
-  movl(edx, eax);
-  movdqu(xmm6, ExternalAddress(mmask));    // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL
-  pand(xmm7, xmm6);
-  movdqu(xmm6, ExternalAddress(bias));     // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL
-  paddq(xmm7, xmm6);
-  psllq(xmm7, 46);
-  subpd(xmm0, xmm3);
-  lea(tmp, ExternalAddress(Tbl_addr));
-  movdqu(xmm2, Address(ecx,tmp));
-  mulpd(xmm4, xmm0);
-  movapd(xmm6, xmm0);
-  movapd(xmm1, xmm0);
-  mulpd(xmm6, xmm6);
-  mulpd(xmm0, xmm6);
-  addpd(xmm5, xmm4);
-  mulsd(xmm0, xmm6);
-  mulpd(xmm6, ExternalAddress(48+cv));     // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL
-  addsd(xmm1, xmm2);
-  unpckhpd(xmm2, xmm2);
-  mulpd(xmm0, xmm5);
-  addsd(xmm1, xmm0);
-  por(xmm2, xmm7);
-  unpckhpd(xmm0, xmm0);
-  addsd(xmm0, xmm1);
-  addsd(xmm0, xmm6);
-  addl(edx, 894);
-  cmpl(edx, 1916);
-  jcc (Assembler::above, L_2TAG_PACKET_1_0_2);
-  mulsd(xmm0, xmm2);
-  addsd(xmm0, xmm2);
-  jmp (B1_5);
-
-  bind(L_2TAG_PACKET_1_0_2);
-  xorpd(xmm3, xmm3);
-  movdqu(xmm4, ExternalAddress(ALLONES));  // 0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL
-  movl(edx, -1022);
-  subl(edx, eax);
-  movdl(xmm5, edx);
-  psllq(xmm4, xmm5);
-  movl(ecx, eax);
-  sarl(eax, 1);
-  pinsrw(xmm3, eax, 3);
-  movdqu(xmm6, ExternalAddress(ebias));    // 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL
-  psllq(xmm3, 4);
-  psubd(xmm2, xmm3);
-  mulsd(xmm0, xmm2);
-  cmpl(edx, 52);
-  jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
-  pand(xmm4, xmm2);
-  paddd(xmm3, xmm6);
-  subsd(xmm2, xmm4);
-  addsd(xmm0, xmm2);
-  cmpl(ecx, 1023);
-  jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2);
-  pextrw(ecx, xmm0, 3);
-  andl(ecx, 32768);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
-  movapd(xmm6, xmm0);
-  addsd(xmm0, xmm4);
-  mulsd(xmm0, xmm3);
-  pextrw(ecx, xmm0, 3);
-  andl(ecx, 32752);
-  cmpl(ecx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_5_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_5_0_2);
-  mulsd(xmm6, xmm3);
-  mulsd(xmm4, xmm3);
-  movdqu(xmm0, xmm6);
-  pxor(xmm6, xmm4);
-  psrad(xmm6, 31);
-  pshufd(xmm6, xmm6, 85);
-  psllq(xmm0, 1);
-  psrlq(xmm0, 1);
-  pxor(xmm0, xmm6);
-  psrlq(xmm6, 63);
-  paddq(xmm0, xmm6);
-  paddq(xmm0, xmm4);
-  movl(Address(rsp,0), 15);
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_4_0_2);
-  addsd(xmm0, xmm4);
-  mulsd(xmm0, xmm3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  addsd(xmm0, xmm4);
-  mulsd(xmm0, xmm3);
-  pextrw(ecx, xmm0, 3);
-  andl(ecx, 32752);
-  cmpl(ecx, 32752);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  paddd(xmm3, xmm6);
-  addpd(xmm0, xmm2);
-  mulsd(xmm0, xmm3);
-  movl(Address(rsp,0), 15);
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_8_0_2);
-  cmpl(eax, 2146435072);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_9_0_2);
-  movl(eax, Address(rsp,12));
-  cmpl(eax, INT_MIN);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_10_0_2);
-  movsd(xmm0, ExternalAddress(XMAX));      // 0xffffffffUL, 0x7fefffffUL
-  mulsd(xmm0, xmm0);
-
-  bind(L_2TAG_PACKET_7_0_2);
-  movl(Address(rsp,0), 14);
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_10_0_2);
-  movsd(xmm0, ExternalAddress(XMIN));      // 0x00000000UL, 0x00100000UL
-  mulsd(xmm0, xmm0);
-  movl(Address(rsp,0), 15);
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_9_0_2);
-  movl(edx, Address(rsp,8));
-  cmpl(eax, 2146435072);
-  jcc(Assembler::above, L_2TAG_PACKET_11_0_2);
-  cmpl(edx, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2);
-  movl(eax, Address(rsp,12));
-  cmpl(eax, 2146435072);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_2);
-  movsd(xmm0, ExternalAddress(INF));       // 0x00000000UL, 0x7ff00000UL
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_12_0_2);
-  movsd(xmm0, ExternalAddress(ZERO));      // 0x00000000UL, 0x00000000UL
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_11_0_2);
-  movsd(xmm0, Address(rsp, 8));
-  addsd(xmm0, xmm0);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  movl(eax, Address(rsp, 12));
-  andl(eax, 2147483647);
-  cmpl(eax, 1083179008);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_8_0_2);
-  movsd(Address(rsp, 8), xmm0);
-  addsd(xmm0, ExternalAddress(ONE_val));   // 0x00000000UL, 0x3ff00000UL
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_6_0_2);
-  movq(Address(rsp, 16), xmm0);
-
-  bind(B1_3);
-  movq(xmm0, Address(rsp, 16));
-
-  bind(B1_5);
-  addq(rsp, 24);
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - LOG()
-//                     ---------------------
-//
-//    x=2^k * mx, mx in [1,2)
-//
-//    Get B~1/mx based on the output of rcpss instruction (B0)
-//    B = int((B0*2^7+0.5))/2^7
-//
-//    Reduced argument: r=B*mx-1.0 (computed accurately in high and low parts)
-//
-//    Result:  k*log(2) - log(B) + p(r) if |x-1| >= small value (2^-6)  and
-//             p(r) is a degree 7 polynomial
-//             -log(B) read from data table (high, low parts)
-//             Result is formed from high and low parts
-//
-// Special cases:
-//  log(NaN) = quiet NaN, and raise invalid exception
-//  log(+INF) = that INF
-//  log(0) = -INF with divide-by-zero exception raised
-//  log(1) = +0
-//  log(x) = NaN with invalid exception raised if x < -0, including -INF
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _L_tbl[] =
-{
-  0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL,
-  0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL,
-  0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL,
-  0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL,
-  0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL,
-  0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL,
-  0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL,
-  0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL,
-  0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL,
-  0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL,
-  0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL,
-  0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL,
-  0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL,
-  0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL,
-  0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL,
-  0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL,
-  0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL,
-  0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL,
-  0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL,
-  0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL,
-  0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL,
-  0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL,
-  0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL,
-  0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL,
-  0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL,
-  0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL,
-  0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL,
-  0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL,
-  0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL,
-  0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL,
-  0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL,
-  0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL,
-  0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL,
-  0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL,
-  0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL,
-  0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL,
-  0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL,
-  0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL,
-  0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL,
-  0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL,
-  0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL,
-  0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL,
-  0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL,
-  0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL,
-  0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL,
-  0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL,
-  0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL,
-  0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL,
-  0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL,
-  0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL,
-  0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL,
-  0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL,
-  0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL,
-  0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL,
-  0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL,
-  0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL,
-  0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL,
-  0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL,
-  0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL,
-  0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL,
-  0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL,
-  0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL,
-  0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL,
-  0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL,
-  0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL,
-  0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL,
-  0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL,
-  0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL,
-  0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL,
-  0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL,
-  0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL,
-  0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL,
-  0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL,
-  0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL,
-  0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL,
-  0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL,
-  0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL,
-  0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL,
-  0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL,
-  0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL,
-  0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL,
-  0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL,
-  0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL,
-  0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL,
-  0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL,
-  0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL,
-  0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL,
-  0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL,
-  0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL,
-  0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL,
-  0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL,
-  0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL,
-  0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL,
-  0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL,
-  0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL,
-  0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL,
-  0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL,
-  0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL,
-  0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL,
-  0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL,
-  0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL,
-  0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL,
-  0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-  0x80000000UL
-};
-
-ALIGNED_(16) juint _log2[] =
-{
-  0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL
-};
-
-ALIGNED_(16) juint _coeff[] =
-{
-  0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL,
-  0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL,
-  0x00000000UL, 0xbfe00000UL
-};
-
-//registers,
-// input: xmm0
-// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
-//          rax, rdx, rcx, r8, r11
-
-void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2) {
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
-  Label L_2TAG_PACKET_8_0_2;
-  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start;
-
-  assert_different_registers(tmp1, tmp2, eax, ecx, edx);
-  jmp(start);
-  address L_tbl = (address)_L_tbl;
-  address log2 = (address)_log2;
-  address coeff = (address)_coeff;
-
-  bind(start);
-  subq(rsp, 24);
-  movsd(Address(rsp, 0), xmm0);
-  mov64(rax, 0x3ff0000000000000);
-  movdq(xmm2, rax);
-  mov64(rdx, 0x77f0000000000000);
-  movdq(xmm3, rdx);
-  movl(ecx, 32768);
-  movdl(xmm4, rcx);
-  mov64(tmp1, 0xffffe00000000000);
-  movdq(xmm5, tmp1);
-  movdqu(xmm1, xmm0);
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  movl(ecx, 16352);
-  psrlq(xmm0, 27);
-  lea(tmp2, ExternalAddress(L_tbl));
-  psrld(xmm0, 2);
-  rcpps(xmm0, xmm0);
-  psllq(xmm1, 12);
-  pshufd(xmm6, xmm5, 228);
-  psrlq(xmm1, 12);
-  subl(eax, 16);
-  cmpl(eax, 32736);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
-
-  bind(L_2TAG_PACKET_1_0_2);
-  paddd(xmm0, xmm4);
-  por(xmm1, xmm3);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  pand(xmm5, xmm1);
-  pand(xmm0, xmm6);
-  subsd(xmm1, xmm5);
-  mulpd(xmm5, xmm0);
-  andl(eax, 32752);
-  subl(eax, ecx);
-  cvtsi2sdl(xmm7, eax);
-  mulsd(xmm1, xmm0);
-  movq(xmm6, ExternalAddress(log2));       // 0xfefa3800UL, 0x3fa62e42UL
-  movdqu(xmm3, ExternalAddress(coeff));    // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL
-  subsd(xmm5, xmm2);
-  andl(edx, 16711680);
-  shrl(edx, 12);
-  movdqu(xmm0, Address(tmp2, edx));
-  movdqu(xmm4, ExternalAddress(16 + coeff)); // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL
-  addsd(xmm1, xmm5);
-  movdqu(xmm2, ExternalAddress(32 + coeff)); // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL
-  mulsd(xmm6, xmm7);
-  if (VM_Version::supports_sse3()) {
-    movddup(xmm5, xmm1);
-  } else {
-    movdqu(xmm5, xmm1);
-    movlhps(xmm5, xmm5);
-  }
-  mulsd(xmm7, ExternalAddress(8 + log2));    // 0x93c76730UL, 0x3ceef357UL
-  mulsd(xmm3, xmm1);
-  addsd(xmm0, xmm6);
-  mulpd(xmm4, xmm5);
-  mulpd(xmm5, xmm5);
-  if (VM_Version::supports_sse3()) {
-    movddup(xmm6, xmm0);
-  } else {
-    movdqu(xmm6, xmm0);
-    movlhps(xmm6, xmm6);
-  }
-  addsd(xmm0, xmm1);
-  addpd(xmm4, xmm2);
-  mulpd(xmm3, xmm5);
-  subsd(xmm6, xmm0);
-  mulsd(xmm4, xmm1);
-  pshufd(xmm2, xmm0, 238);
-  addsd(xmm1, xmm6);
-  mulsd(xmm5, xmm5);
-  addsd(xmm7, xmm2);
-  addpd(xmm4, xmm3);
-  addsd(xmm1, xmm7);
-  mulpd(xmm4, xmm5);
-  addsd(xmm1, xmm4);
-  pshufd(xmm5, xmm4, 238);
-  addsd(xmm1, xmm5);
-  addsd(xmm0, xmm1);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  movq(xmm0, Address(rsp, 0));
-  movq(xmm1, Address(rsp, 0));
-  addl(eax, 16);
-  cmpl(eax, 32768);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_2_0_2);
-  cmpl(eax, 16);
-  jcc(Assembler::below, L_2TAG_PACKET_3_0_2);
-
-  bind(L_2TAG_PACKET_4_0_2);
-  addsd(xmm0, xmm0);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_5_0_2);
-  jcc(Assembler::above, L_2TAG_PACKET_4_0_2);
-  cmpl(edx, 0);
-  jcc(Assembler::above, L_2TAG_PACKET_4_0_2);
-  jmp(L_2TAG_PACKET_6_0_2);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  xorpd(xmm1, xmm1);
-  addsd(xmm1, xmm0);
-  movdl(edx, xmm1);
-  psrlq(xmm1, 32);
-  movdl(ecx, xmm1);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
-  xorpd(xmm1, xmm1);
-  movl(eax, 18416);
-  pinsrw(xmm1, eax, 3);
-  mulsd(xmm0, xmm1);
-  movdqu(xmm1, xmm0);
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  psrlq(xmm0, 27);
-  movl(ecx, 18416);
-  psrld(xmm0, 2);
-  rcpps(xmm0, xmm0);
-  psllq(xmm1, 12);
-  pshufd(xmm6, xmm5, 228);
-  psrlq(xmm1, 12);
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  movdl(edx, xmm1);
-  psrlq(xmm1, 32);
-  movdl(ecx, xmm1);
-  addl(ecx, ecx);
-  cmpl(ecx, -2097152);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
-
-  bind(L_2TAG_PACKET_6_0_2);
-  xorpd(xmm1, xmm1);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32752);
-  pinsrw(xmm1, eax, 3);
-  mulsd(xmm0, xmm1);
-  movl(Address(rsp, 16), 3);
-  jmp(L_2TAG_PACKET_8_0_2);
-  bind(L_2TAG_PACKET_7_0_2);
-  xorpd(xmm1, xmm1);
-  xorpd(xmm0, xmm0);
-  movl(eax, 49136);
-  pinsrw(xmm0, eax, 3);
-  divsd(xmm0, xmm1);
-  movl(Address(rsp, 16), 2);
-
-  bind(L_2TAG_PACKET_8_0_2);
-  movq(Address(rsp, 8), xmm0);
-
-  bind(B1_3);
-  movq(xmm0, Address(rsp, 8));
-
-  bind(B1_5);
-  addq(rsp, 24);
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION  - POW()
-//                     ---------------------
-//
-//    Let x=2^k * mx, mx in [1,2)
-//
-//    log2(x) calculation:
-//
-//    Get B~1/mx based on the output of rcpps instruction (B0)
-//    B = int((B0*LH*2^9+0.5))/2^9
-//    LH is a short approximation for log2(e)
-//
-//    Reduced argument, scaled by LH:
-//                r=B*mx-LH (computed accurately in high and low parts)
-//
-//    log2(x) result:  k - log2(B) + p(r)
-//             p(r) is a degree 8 polynomial
-//             -log2(B) read from data table (high, low parts)
-//             log2(x) is formed from high and low parts
-//    For |x| in [1-1/32, 1+1/16), a slower but more accurate computation
-//    based om the same table design is performed.
-//
-//   Main path is taken if | floor(log2(|log2(|x|)|) + floor(log2|y|) | < 8,
-//   to filter out all potential OF/UF cases.
-//   exp2(y*log2(x)) is computed using an 8-bit index table and a degree 5
-//   polynomial
-//
-// Special cases:
-//  pow(-0,y) = -INF and raises the divide-by-zero exception for y an odd
-//  integer < 0.
-//  pow(-0,y) = +INF and raises the divide-by-zero exception for y < 0 and
-//  not an odd integer.
-//  pow(-0,y) = -0 for y an odd integer > 0.
-//  pow(-0,y) = +0 for y > 0 and not an odd integer.
-//  pow(-1,-INF) = NaN.
-//  pow(+1,y) = NaN for any y, even a NaN.
-//  pow(x,-0) = 1 for any x, even a NaN.
-//  pow(x,y) = a NaN and raises the invalid exception for finite x < 0 and
-//  finite non-integer y.
-//  pow(x,-INF) = +INF for |x|<1.
-//  pow(x,-INF) = +0 for |x|>1.
-//  pow(x,+INF) = +0 for |x|<1.
-//  pow(x,+INF) = +INF for |x|>1.
-//  pow(-INF,y) = -0 for y an odd integer < 0.
-//  pow(-INF,y) = +0 for y < 0 and not an odd integer.
-//  pow(-INF,y) = -INF for y an odd integer > 0.
-//  pow(-INF,y) = +INF for y > 0 and not an odd integer.
-//  pow(+INF,y) = +0 for y <0.
-//  pow(+INF,y) = +INF for y >0.
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _HIGHSIGMASK[] =
-{
-  0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
-};
-
-ALIGNED_(16) juint _LOG2_E[] =
-{
-  0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
-};
-
-ALIGNED_(16) juint _HIGHMASK_Y[] =
-{
-  0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL
-};
-
-ALIGNED_(16) juint _T_exp[] =
-{
-  0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL, 0xfa5abcbfUL,
-  0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL, 0x3ff0163dUL,
-  0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL, 0x0fc54eb6UL,
-  0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL, 0xbc719083UL,
-  0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL, 0xe86e7f85UL,
-  0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL, 0x3ff04e5fUL,
-  0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL, 0xa475b465UL,
-  0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL, 0xbc95cb7bUL,
-  0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL, 0x2b72a836UL,
-  0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL, 0x3ff08745UL,
-  0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL, 0x800a3fd1UL,
-  0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL, 0x3c914878UL,
-  0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL, 0x6cf9890fUL,
-  0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL, 0x3ff0c0f1UL,
-  0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL, 0x16e24f71UL,
-  0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL, 0xbc9bc14dUL,
-  0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL, 0x5fdfa9c5UL,
-  0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL, 0x3ff0fb66UL,
-  0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL, 0x1692fdd5UL,
-  0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL, 0xbc96c510UL,
-  0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL, 0xc06c31ccUL,
-  0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL, 0x3ff136a8UL,
-  0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL, 0x9af1369eUL,
-  0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL, 0xbc8b91e8UL,
-  0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL, 0x5471c3c2UL,
-  0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL, 0x3ff172b8UL,
-  0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL, 0xe2ac5a64UL,
-  0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL, 0xbc911023UL,
-  0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL, 0xeb6fcb75UL,
-  0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL, 0x3ff1af99UL,
-  0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL, 0x352ef607UL,
-  0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL, 0x3c900977UL,
-  0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL, 0x5eb44027UL,
-  0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL, 0x3ff1ed50UL,
-  0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL, 0xa097af5cUL,
-  0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL, 0x3c8dc775UL,
-  0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL, 0x917ddc96UL,
-  0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL, 0x3ff22bddUL,
-  0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL, 0xb6c70573UL,
-  0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL, 0x3c8acfccUL,
-  0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL, 0x711ece75UL,
-  0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL, 0x3ff26b45UL,
-  0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL, 0x05f9e76cUL,
-  0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL, 0xbc9a4c3aUL,
-  0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL, 0xf51fdee1UL,
-  0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL, 0x3ff2ab8aUL,
-  0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL, 0xd6381aa4UL,
-  0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL, 0xbc950145UL,
-  0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL, 0x1f641589UL,
-  0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL, 0x3ff2ecafUL,
-  0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL, 0x532bda93UL,
-  0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL, 0x3c86f46aUL,
-  0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL, 0xfc4cd831UL,
-  0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL, 0x3ff32eb8UL,
-  0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL, 0x843659a6UL,
-  0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL, 0xbc835a75UL,
-  0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL, 0xa2de883bUL,
-  0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL, 0x3ff371a7UL,
-  0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL, 0x9eceb23cUL,
-  0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL, 0xbc9e958dUL,
-  0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL, 0x34e59ff7UL,
-  0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL, 0x3ff3b57fUL,
-  0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL, 0x375d29c3UL,
-  0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL, 0x3c7fe8d0UL,
-  0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL, 0xdf1c5175UL,
-  0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL, 0x3ff3fa45UL,
-  0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL, 0xb6f4d048UL,
-  0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL, 0xbc5ef369UL,
-  0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL, 0xd950a897UL,
-  0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL, 0x3ff43ffaUL,
-  0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL, 0x04ef80d0UL,
-  0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL, 0xbc686419UL,
-  0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL, 0x668b3237UL,
-  0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL, 0x3ff486a2UL,
-  0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL, 0x5e499ea0UL,
-  0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL, 0x3c99cb62UL,
-  0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL, 0xd5362a27UL,
-  0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL, 0x3ff4ce41UL,
-  0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL, 0xbc6a7833UL,
-  0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL, 0xbc95257dUL,
-  0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL, 0x7f4531eeUL,
-  0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL, 0x3ff516daUL,
-  0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL, 0x43efef71UL,
-  0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL, 0xbc807abeUL,
-  0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL, 0xca5d920fUL,
-  0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL, 0x3ff56070UL,
-  0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL, 0x011d93adUL,
-  0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL, 0xbc90b98cUL,
-  0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL, 0x27ff07ccUL,
-  0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL, 0x3ff5ab07UL,
-  0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL, 0x4c233e1aUL,
-  0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL, 0x3c3c4b1bUL,
-  0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL, 0x15ad2148UL,
-  0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL, 0x3ff5f6a3UL,
-  0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL, 0x9b56de47UL,
-  0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL, 0x3c9e4b3eUL,
-  0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL, 0x1d1929fdUL,
-  0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL, 0x3ff64346UL,
-  0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL, 0xc9a73e09UL,
-  0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL, 0xbc9bb609UL,
-  0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL, 0xd44ca973UL,
-  0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL, 0x3ff690f4UL,
-  0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL, 0x13b26456UL,
-  0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL, 0x3c7a38f5UL,
-  0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL, 0xddd47645UL,
-  0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL, 0x3ff6dfb2UL,
-  0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL, 0x9e1ac8b2UL,
-  0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL, 0xbc883c0fUL,
-  0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL, 0xe8ec5f74UL,
-  0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL, 0x3ff72f82UL,
-  0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL, 0x6c65d53cUL,
-  0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL, 0x3c9047fdUL,
-  0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL, 0xb1ab6e09UL,
-  0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL, 0x3ff78069UL,
-  0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL, 0x62aadd3eUL,
-  0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL, 0xbc841577UL,
-  0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL, 0x0130c132UL,
-  0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL, 0x3ff7d26aUL,
-  0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL, 0xba15797eUL,
-  0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL, 0xbc807f11UL,
-  0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL, 0xadd106d9UL,
-  0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL, 0x3ff82589UL,
-  0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL, 0x31df2bd5UL,
-  0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL, 0xbc88d684UL,
-  0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL, 0x9b4492edUL,
-  0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL, 0x3ff879caUL,
-  0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL, 0xf37cb53aUL,
-  0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL, 0x3c9d5395UL,
-  0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL, 0xbad61778UL,
-  0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL, 0x3ff8cf32UL,
-  0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL, 0x6fc9b2e6UL,
-  0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL, 0x3c85cc13UL,
-  0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL, 0x0b91ffc6UL,
-  0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL, 0x3ff925c3UL,
-  0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL, 0x81b57ebcUL,
-  0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL, 0xbc8dc3d6UL,
-  0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL, 0x9a7670b3UL,
-  0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL, 0x3ff97d82UL,
-  0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL, 0xa24c78ecUL,
-  0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL, 0xbc9173bdUL,
-  0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL, 0x82a3f090UL,
-  0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL, 0x3ff9d674UL,
-  0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL, 0x78e64c6eUL,
-  0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL, 0xbc84a9ceUL,
-  0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL, 0xed8eb8bbUL,
-  0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL, 0x3ffa309bUL,
-  0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL, 0x589fb120UL,
-  0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL, 0xbc9d2f6eUL,
-  0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL, 0x1330b358UL,
-  0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL, 0x3ffa8bfeUL,
-  0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL, 0x0ef7fd31UL,
-  0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL, 0x3c889c31UL,
-  0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL, 0x3a3c2774UL,
-  0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL, 0x3ffae89fUL,
-  0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL, 0x0f315ecdUL,
-  0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL, 0xbc9bdef5UL,
-  0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL, 0xb84f15fbUL,
-  0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL, 0x3ffb4684UL,
-  0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL, 0xbbba6de3UL,
-  0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL, 0x3c92a8f3UL,
-  0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL, 0xf22749e4UL,
-  0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL, 0x3ffba5b0UL,
-  0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL, 0xc9696205UL,
-  0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL, 0x3c823dd0UL,
-  0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL, 0x5bd71e09UL,
-  0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL, 0x3ffc0628UL,
-  0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL, 0x895048ddUL,
-  0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL, 0xbc96e516UL,
-  0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL, 0x78fafb22UL,
-  0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL, 0x3ffc67f1UL,
-  0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL, 0xbe255559UL,
-  0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL, 0x3c71acbcUL,
-  0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL, 0xdcef9069UL,
-  0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL, 0x3ffccb0fUL,
-  0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL, 0x53829d72UL,
-  0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL, 0xbc9a08e9UL,
-  0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL, 0x2b08c968UL,
-  0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL, 0x3ffd2f87UL,
-  0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL, 0xbf5a1614UL,
-  0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL, 0x3c82ed02UL,
-  0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL, 0x16c98398UL,
-  0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL, 0x3ffd955dUL,
-  0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL, 0x696db532UL,
-  0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL, 0xbc9b76f1UL,
-  0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL, 0x641c0658UL,
-  0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL, 0x3ffdfc97UL,
-  0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL, 0xbd5c7f44UL,
-  0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL, 0xbc97b627UL,
-  0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL, 0xe78b3ff6UL,
-  0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL, 0x3ffe6539UL,
-  0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL, 0xca0c8de2UL,
-  0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL, 0xbc910894UL,
-  0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL, 0x867cca6eUL,
-  0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL, 0x3ffecf48UL,
-  0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL, 0xa487568dUL,
-  0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL, 0x3c9dc7f4UL,
-  0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL, 0x376bba97UL,
-  0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL, 0x3fff3ac9UL,
-  0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL, 0x2dd8a18bUL,
-  0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL, 0x3c9fa37bUL,
-  0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL, 0x02243c89UL,
-  0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL, 0x3fffa7c1UL,
-  0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL, 0x15098eb6UL,
-  0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL, 0x3c62eb74UL,
-  0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL
-};
-
-ALIGNED_(16) juint _e_coeff[] =
-{
-  0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL,
-  0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL,
-  0x00000000UL, 0x00000000UL
-};
-
-ALIGNED_(16) juint _coeff_h[] =
-{
-  0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL
-};
-
-ALIGNED_(16) juint _HIGHMASK_LOG_X[] =
-{
-  0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL
-};
-
-ALIGNED_(8) juint _HALFMASK[] =
-{
-  0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL
-};
-
-ALIGNED_(16) juint _coeff_pow[] =
-{
-  0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL,
-  0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL,
-  0xac8349bbUL, 0x3fa76c9bUL, 0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL,
-  0xbf5dabe1UL, 0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL,
-  0x486ececbUL, 0x3fc4635eUL, 0x412055ccUL, 0xbdd61bb2UL
-};
-
-ALIGNED_(16) juint _L_tbl_pow[] =
-{
-  0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x20000000UL,
-  0x3feff00aUL, 0x96621f95UL, 0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL,
-  0xe5916f9eUL, 0xbe325278UL, 0x00000000UL, 0x3fefd02fUL, 0x859a1062UL,
-  0x3e595fb7UL, 0xc0000000UL, 0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL,
-  0xe0000000UL, 0x3fefb069UL, 0xad2880a7UL, 0xbe501230UL, 0x60000000UL,
-  0x3fefa08fUL, 0xc8e72420UL, 0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL,
-  0xc30c4500UL, 0xbe5d6c75UL, 0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL,
-  0x3e2e1318UL, 0xc0000000UL, 0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL,
-  0x00000000UL, 0x3fef615cUL, 0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL,
-  0x3fef519cUL, 0x65c5cd68UL, 0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL,
-  0x46d1306cUL, 0xbe5a840eUL, 0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL,
-  0x3e5071afUL, 0xa0000000UL, 0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL,
-  0xa0000000UL, 0x3fef12d4UL, 0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL,
-  0x3fef032fUL, 0xbc7247faUL, 0xbe2bab83UL, 0x80000000UL, 0x3feef390UL,
-  0xbcaa1e46UL, 0xbe53bb3bUL, 0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL,
-  0xbe54c619UL, 0x80000000UL, 0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL,
-  0xe0000000UL, 0x3feec4d1UL, 0xec678f76UL, 0xbe369af6UL, 0x80000000UL,
-  0x3feeb547UL, 0x41301f55UL, 0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL,
-  0x676da6bdUL, 0xbe4d8dd0UL, 0x60000000UL, 0x3fee9642UL, 0x57a891c4UL,
-  0x3e51f991UL, 0xa0000000UL, 0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL,
-  0x20000000UL, 0x3fee7752UL, 0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL,
-  0x3fee67e1UL, 0xd75b5bf1UL, 0xbe449531UL, 0x80000000UL, 0x3fee5876UL,
-  0xbd423b8eUL, 0x3df54fe4UL, 0x60000000UL, 0x3fee4910UL, 0x330e51b9UL,
-  0x3e54289cUL, 0x80000000UL, 0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL,
-  0xa0000000UL, 0x3fee2a53UL, 0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL,
-  0x3fee1afcUL, 0x0989328dUL, 0x3e23958cUL, 0x40000000UL, 0x3fee0babUL,
-  0xee642abdUL, 0xbe425dd8UL, 0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL,
-  0x3e526362UL, 0x20000000UL, 0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL,
-  0xc0000000UL, 0x3fedddd4UL, 0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL,
-  0x3fedce97UL, 0x0ecac52fUL, 0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL,
-  0x124cb3b8UL, 0x3e257024UL, 0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL,
-  0xbe2033eeUL, 0x20000000UL, 0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL,
-  0xc0000000UL, 0x3fed91d3UL, 0xef8a552aUL, 0xbe543390UL, 0x40000000UL,
-  0x3fed82afUL, 0xb8e85204UL, 0x3e513850UL, 0xe0000000UL, 0x3fed738fUL,
-  0x3d59fe08UL, 0xbe5db728UL, 0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL,
-  0x3e58804bUL, 0xc0000000UL, 0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL,
-  0x00000000UL, 0x3fed464fUL, 0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL,
-  0x3fed3743UL, 0xb0b0a190UL, 0x3e598635UL, 0x80000000UL, 0x3fed283cUL,
-  0xe2113295UL, 0xbe5c1119UL, 0x80000000UL, 0x3fed193aUL, 0xafbf1728UL,
-  0xbe492e9cUL, 0x60000000UL, 0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL,
-  0x20000000UL, 0x3fecfb45UL, 0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL,
-  0x3fecec51UL, 0x110f7dddUL, 0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL,
-  0x7dd7d508UL, 0xbe5a8943UL, 0x80000000UL, 0x3fecce79UL, 0x9b60f271UL,
-  0xbe50676aUL, 0x80000000UL, 0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL,
-  0x60000000UL, 0x3fecb0b4UL, 0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL,
-  0x3feca1d9UL, 0x38a6ec89UL, 0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL,
-  0x3a0b7d8eUL, 0x3e53dbfdUL, 0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL,
-  0xbe27c5c9UL, 0xc0000000UL, 0x3fec7563UL, 0x0c706381UL, 0xbe593653UL,
-  0x60000000UL, 0x3fec669bUL, 0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL,
-  0x3fec57d7UL, 0x40e5e7e8UL, 0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL,
-  0x5602770fUL, 0xbe55219dUL, 0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL,
-  0x3e5a5d25UL, 0x60000000UL, 0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL,
-  0x80000000UL, 0x3fec1cf8UL, 0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL,
-  0x3fec0e4cUL, 0x580798bdUL, 0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL,
-  0xb8282df6UL, 0xbe46b874UL, 0x20000000UL, 0x3febf102UL, 0xe33a6729UL,
-  0x3e54963fUL, 0x00000000UL, 0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL,
-  0x60000000UL, 0x3febd3caUL, 0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL,
-  0x3febc535UL, 0xa335c5eeUL, 0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL,
-  0x7325b04dUL, 0x3e42ba15UL, 0x60000000UL, 0x3feba819UL, 0x1564540fUL,
-  0x3e3a9f35UL, 0x40000000UL, 0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL,
-  0xa0000000UL, 0x3feb8b0fUL, 0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL,
-  0x3feb7c91UL, 0x6d6f1ea4UL, 0x3e557657UL, 0x00000000UL, 0x3feb6e18UL,
-  0x5e80a1bfUL, 0x3e4ddbb6UL, 0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL,
-  0x3e592877UL, 0xa0000000UL, 0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL,
-  0xa0000000UL, 0x3feb42c6UL, 0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL,
-  0x3feb345fUL, 0xa3e0cceeUL, 0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL,
-  0x8e752b50UL, 0xbe3da3c2UL, 0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL,
-  0x3e1fb481UL, 0xc0000000UL, 0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL,
-  0x20000000UL, 0x3feafaeeUL, 0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL,
-  0x3feaec9dUL, 0x3c3d640eUL, 0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL,
-  0x8f97a715UL, 0x3e3a8ec5UL, 0x20000000UL, 0x3fead008UL, 0x23ab2839UL,
-  0x3e2fe98aUL, 0x40000000UL, 0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL,
-  0xe0000000UL, 0x3feab384UL, 0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL,
-  0x3feaa549UL, 0x7c7b0eeaUL, 0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL,
-  0xf56f7013UL, 0x3e386200UL, 0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL,
-  0xbe514af5UL, 0xe0000000UL, 0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL,
-  0x60000000UL, 0x3fea6c89UL, 0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL,
-  0x3fea5e64UL, 0x3f19d970UL, 0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL,
-  0x09ea3e6bUL, 0x3e5065dcUL, 0x80000000UL, 0x3fea4226UL, 0x78df246cUL,
-  0x3e5e05f6UL, 0x40000000UL, 0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL,
-  0x40000000UL, 0x3fea25faUL, 0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL,
-  0x3fea17eaUL, 0x9436f40aUL, 0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL,
-  0x4b5253b3UL, 0x3e46380bUL, 0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL,
-  0xbe386f9bUL, 0x20000000UL, 0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL,
-  0x60000000UL, 0x3fe9dfd6UL, 0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL,
-  0x3fe9d1dcUL, 0xeabdff1dUL, 0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL,
-  0xafd30e73UL, 0xbe585e63UL, 0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL,
-  0xbe43e8f9UL, 0x20000000UL, 0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL,
-  0x80000000UL, 0x3fe99a1cUL, 0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL,
-  0x3fe98c37UL, 0x7c9a88fbUL, 0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL,
-  0xda015741UL, 0xbe5d13baUL, 0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL,
-  0x3e51b947UL, 0x00000000UL, 0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL,
-  0x40000000UL, 0x3fe954cbUL, 0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL,
-  0x3fe946faUL, 0xe63b3767UL, 0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL,
-  0xe57cc2a9UL, 0x3e34eda3UL, 0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL,
-  0x3e5766a0UL, 0xc0000000UL, 0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL,
-  0x80000000UL, 0x3fe90fe1UL, 0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL,
-  0x3fe90225UL, 0xdbd3f369UL, 0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL,
-  0x1c9be989UL, 0xbe5e2b0aUL, 0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL,
-  0x3e5c8618UL, 0xe0000000UL, 0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL,
-  0x20000000UL, 0x3fe8cb5eUL, 0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL,
-  0x3fe8bdb6UL, 0x49e58cc3UL, 0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL,
-  0xa7cfeb8fUL, 0x3e56c412UL, 0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL,
-  0x3e1429b8UL, 0x60000000UL, 0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL,
-  0xc0000000UL, 0x3fe8873fUL, 0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL,
-  0x3fe879acUL, 0x56aee828UL, 0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL,
-  0x7ceab8ecUL, 0x3e493365UL, 0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL,
-  0xbe4f7f25UL, 0x00000000UL, 0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL,
-  0x40000000UL, 0x3fe84385UL, 0x34ba4e15UL, 0x3e328077UL, 0x80000000UL,
-  0x3fe83605UL, 0xa670975aUL, 0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL,
-  0xf61b77b2UL, 0xbe43a20aUL, 0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL,
-  0x3e5e5fe5UL, 0xc0000000UL, 0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL,
-  0xa0000000UL, 0x3fe8002dUL, 0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL,
-  0x3fe7f2c1UL, 0x22a16f01UL, 0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL,
-  0xc38cd451UL, 0x3e506963UL, 0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL,
-  0x3e4503d7UL, 0x40000000UL, 0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL,
-  0xa0000000UL, 0x3fe7bd37UL, 0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL,
-  0x3fe7afdeUL, 0xe3b0be70UL, 0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL,
-  0xaf9f193cUL, 0xbe5dff6cUL, 0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL,
-  0xbe258ed0UL, 0xa0000000UL, 0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL,
-  0x40000000UL, 0x3fe77aa2UL, 0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL,
-  0x3fe76d5cUL, 0x7cb0b5e4UL, 0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL,
-  0x2b1bc4adUL, 0xbe32e8bbUL, 0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL,
-  0x3e41f57bUL, 0xc0000000UL, 0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL,
-  0x60000000UL, 0x3fe7386cUL, 0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL,
-  0x3fe72b39UL, 0x91d690f7UL, 0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL,
-  0x627a2159UL, 0xbe4425d5UL, 0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL,
-  0x3e422b7eUL, 0x60000000UL, 0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL,
-  0xe0000000UL, 0x3fe6f694UL, 0x84d628a2UL, 0xbe51f090UL, 0x00000000UL,
-  0x3fe6e975UL, 0x306d8894UL, 0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL,
-  0x30bf24aaUL, 0xbe4650caUL, 0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL,
-  0xbe5db007UL, 0xc0000000UL, 0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL,
-  0xc0000000UL, 0x3fe6b51aUL, 0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL,
-  0x3fe6a80dUL, 0xf3559341UL, 0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL,
-  0xa885899eUL, 0xbe5c2011UL, 0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL,
-  0x3e224a82UL, 0xa0000000UL, 0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL,
-  0x00000000UL, 0x3fe673fdUL, 0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL,
-  0x3fe66702UL, 0x5df10408UL, 0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL,
-  0xa4070568UL, 0xbe40b12fUL, 0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL,
-  0x3e5f5e8bUL, 0x00000000UL, 0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL,
-  0xa0000000UL, 0x3fe6333aUL, 0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL,
-  0x3fe62651UL, 0x6f538d61UL, 0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL,
-  0x14344120UL, 0xbe529af6UL, 0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL,
-  0xbe3e1e4fUL, 0x00000000UL, 0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL,
-  0x80000000UL, 0x3fe5f2d2UL, 0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL,
-  0x3fe5e5fbUL, 0xa4695699UL, 0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL,
-  0x80d118aeUL, 0x3e456b61UL, 0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL,
-  0x3e54dc29UL, 0x80000000UL, 0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL,
-  0xe0000000UL, 0x3fe5b2c3UL, 0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL,
-  0x3fe5a5feUL, 0x9292c7eaUL, 0x3e188650UL, 0x20000000UL, 0x3fe5993dUL,
-  0x33b4d380UL, 0x3e5d6d93UL, 0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL,
-  0x3e2fe961UL, 0xa0000000UL, 0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL,
-  0xa0000000UL, 0x3fe5730dUL, 0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL,
-  0x3fe5665aUL, 0x024acfeaUL, 0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL,
-  0xcc9edd09UL, 0xbe325403UL, 0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL,
-  0x3e5d500eUL, 0x60000000UL, 0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL,
-  0xc0000000UL, 0x3fe533aeUL, 0x154b0287UL, 0xbe401571UL, 0xa0000000UL,
-  0x3fe5270cUL, 0x0673f401UL, 0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL,
-  0x751b639cUL, 0x3e235269UL, 0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL,
-  0x3ddec887UL, 0xc0000000UL, 0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL,
-  0x60000000UL, 0x3fe4f4a6UL, 0x2e308668UL, 0x3e59aed6UL, 0x80000000UL,
-  0x3fe4e815UL, 0xf33e2a76UL, 0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL,
-  0x839f3e3eUL, 0x3e57db01UL, 0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL,
-  0x3e535e0fUL, 0x00000000UL, 0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL,
-  0xc0000000UL, 0x3fe4b5f3UL, 0x05192456UL, 0xbe4e8518UL, 0xc0000000UL,
-  0x3fe4a973UL, 0x4aa7cd1dUL, 0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL,
-  0x8e23025eUL, 0xbe5749f2UL, 0x00000000UL, 0x3fe4907eUL, 0x18d30215UL,
-  0x3e360f39UL, 0x20000000UL, 0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL,
-  0xc0000000UL, 0x3fe47795UL, 0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL,
-  0x3fe46b26UL, 0x8f0e62aaUL, 0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL,
-  0x5775c40cUL, 0xbe56aad4UL, 0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL,
-  0x3e48bd71UL, 0x40000000UL, 0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL,
-  0x80000000UL, 0x3fe4398bUL, 0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL,
-  0x3fe42d2dUL, 0x388e4d2eUL, 0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL,
-  0x6f797c18UL, 0x3e554b4cUL, 0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL,
-  0xbe5b1112UL, 0x80000000UL, 0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL,
-  0x40000000UL, 0x3fe3fbd4UL, 0x50201119UL, 0x3e40b701UL, 0x40000000UL,
-  0x3fe3ef86UL, 0x0a4db32cUL, 0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL,
-  0x0c9c148bUL, 0xbe50c1f6UL, 0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL,
-  0x3e533fa0UL, 0x00000000UL, 0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL,
-  0x20000000UL, 0x3fe3be6fUL, 0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL,
-  0x3fe3b231UL, 0x7f908258UL, 0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL,
-  0x1a09af78UL, 0x3e08038bUL, 0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL,
-  0xbe5dbe42UL, 0xe0000000UL, 0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL,
-  0x20000000UL, 0x3fe3815bUL, 0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL,
-  0x3fe3752dUL, 0x6182e429UL, 0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL,
-  0xab6eb1aeUL, 0x3e5a2cc5UL, 0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL,
-  0xbe5c5878UL, 0x40000000UL, 0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL,
-  0x80000000UL, 0x3fe34497UL, 0x857761aaUL, 0x3e5fff53UL, 0x00000000UL,
-  0x3fe3387aUL, 0xf872d68cUL, 0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL,
-  0x087e97c2UL, 0x3e52842eUL, 0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL,
-  0xbe503edfUL, 0x80000000UL, 0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL,
-  0xa0000000UL, 0x3fe30823UL, 0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL,
-  0x3fe2fc15UL, 0x855a7390UL, 0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL,
-  0xa2898287UL, 0x3e3d22a2UL, 0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL,
-  0xbe5aa5fdUL, 0x80000000UL, 0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL,
-  0x60000000UL, 0x3fe2cbfeUL, 0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL,
-  0x3fe2c000UL, 0x6b01bf10UL, 0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL,
-  0xb07a1cdfUL, 0x3e5c5cdaUL, 0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL,
-  0xbe5668b3UL, 0xc0000000UL, 0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL,
-  0x00000000UL, 0x3fe29027UL, 0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL,
-  0x3fe28438UL, 0x6433c727UL, 0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL,
-  0x41782631UL, 0xbe30750cUL, 0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL,
-  0xbe58290eUL, 0x40000000UL, 0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL,
-  0x00000000UL, 0x3fe2549dUL, 0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL,
-  0x3fe248bdUL, 0x4248b9fbUL, 0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL,
-  0xf35cf82fUL, 0x3e561b71UL, 0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL,
-  0x3e518fb9UL, 0x60000000UL, 0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL,
-  0x40000000UL, 0x3fe2195fUL, 0x80943911UL, 0xbe07f819UL, 0x40000000UL,
-  0x3fe20d8fUL, 0x386f2d6cUL, 0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL,
-  0xf29664acUL, 0xbe5eb815UL, 0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL,
-  0x3e5e320cUL, 0x20000000UL, 0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL,
-  0x40000000UL, 0x3fe1de6dUL, 0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL,
-  0x3fe1d2acUL, 0x4ae0b55eUL, 0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL,
-  0x28569a5eUL, 0x3e598a4fUL, 0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL,
-  0x3e46130aUL, 0x20000000UL, 0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL,
-  0x00000000UL, 0x3fe1a3c6UL, 0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL,
-  0x3fe19813UL, 0x2f02b836UL, 0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL,
-  0x28dec9d4UL, 0x3e09064fUL, 0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL,
-  0x3e5b1f46UL, 0x40000000UL, 0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL,
-  0x00000000UL, 0x3fe16969UL, 0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL,
-  0x3fe15dc5UL, 0x73bad6f8UL, 0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL,
-  0x5385769cUL, 0x3e5e8d76UL, 0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL,
-  0x3e571d08UL, 0x20000000UL, 0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL,
-  0x60000000UL, 0x3fe12f55UL, 0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL,
-  0x3fe123c0UL, 0x403638e1UL, 0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL,
-  0x557a092bUL, 0xbdd0116bUL, 0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL,
-  0x3e4a61baUL, 0xc0000000UL, 0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL,
-  0x20000000UL, 0x3fe0ea04UL, 0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL,
-  0x3fe0d300UL, 0x23190e54UL, 0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL,
-  0x1379a5a6UL, 0xbe51619dUL, 0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL,
-  0x3e5cf019UL, 0xa0000000UL, 0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL,
-  0x20000000UL, 0x3fe07762UL, 0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL,
-  0x3fe06097UL, 0xfd9cf274UL, 0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL,
-  0x3689b49dUL, 0xbe36d26dUL, 0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL,
-  0xbe54cd08UL, 0xa0000000UL, 0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL,
-  0x00000000UL, 0x3fe005daUL, 0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL,
-  0x3fdfde8dUL, 0xad67766dUL, 0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL,
-  0x644f4ae7UL, 0x3e1ee43bUL, 0x40000000UL, 0x3fdf8481UL, 0x903234d2UL,
-  0x3e501a86UL, 0x40000000UL, 0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL,
-  0x00000000UL, 0x3fdf2acdUL, 0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL,
-  0x3fdefe13UL, 0x3b94305eUL, 0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL,
-  0x5d95da61UL, 0xbe55c198UL, 0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL,
-  0xbdd99a19UL, 0x00000000UL, 0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL,
-  0x80000000UL, 0x3fde4c04UL, 0x83eec535UL, 0xbe3e1232UL, 0x40000000UL,
-  0x3fde1fb6UL, 0x3dfbffcbUL, 0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL,
-  0x7e1be4e0UL, 0xbe5b8f8fUL, 0x40000000UL, 0x3fddc759UL, 0x46dae887UL,
-  0xbe350458UL, 0x80000000UL, 0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL,
-  0x80000000UL, 0x3fdd6f50UL, 0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL,
-  0x3fdd436bUL, 0xf0bccb32UL, 0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL,
-  0x9bbfc779UL, 0xbe54a26aUL, 0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL,
-  0x3e43c6b7UL, 0x40000000UL, 0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL,
-  0x40000000UL, 0x3fdc94a7UL, 0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL,
-  0x3fdc6929UL, 0xf0a8f95aUL, 0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL,
-  0x6ee2693bUL, 0x3e0992e6UL, 0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL,
-  0xbe2834b6UL, 0x40000000UL, 0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL,
-  0x00000000UL, 0x3fdbbbffUL, 0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL,
-  0x3fdb90e7UL, 0x479664c0UL, 0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL,
-  0x5004975bUL, 0xbe55258fUL, 0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL,
-  0xbe588407UL, 0xc0000000UL, 0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL,
-  0x80000000UL, 0x3fdae54eUL, 0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL,
-  0x3fdaba9aUL, 0xe19d0913UL, 0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL,
-  0x43cfd006UL, 0xbe4cfdebUL, 0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL,
-  0x3e5e47a8UL, 0xc0000000UL, 0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL,
-  0xc0000000UL, 0x3fda108cUL, 0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL,
-  0x3fd9e63aUL, 0x396f8f2cUL, 0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL,
-  0xe32b25ddUL, 0x3e5c3a54UL, 0x40000000UL, 0x3fd991cfUL, 0x431e4035UL,
-  0xbe457925UL, 0x80000000UL, 0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL,
-  0x00000000UL, 0x3fd93db1UL, 0xd7449365UL, 0x3e306419UL, 0x80000000UL,
-  0x3fd913beUL, 0x1746e791UL, 0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL,
-  0xf3a9028bUL, 0xbe5041b9UL, 0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL,
-  0xbe26e20aUL, 0x40000000UL, 0x3fd89659UL, 0x19763102UL, 0xbe51f466UL,
-  0x80000000UL, 0x3fd86cb2UL, 0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL,
-  0x3fd8431eUL, 0xdeb39fabUL, 0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL,
-  0x5d01cbe0UL, 0xbe5425b3UL, 0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL,
-  0x3e146fa8UL, 0x80000000UL, 0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL,
-  0xc0000000UL, 0x3fd79d88UL, 0x8606c236UL, 0x3e423a08UL, 0x80000000UL,
-  0x3fd77451UL, 0x8fd1e1b7UL, 0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL,
-  0xe491456aUL, 0x3e42c1caUL, 0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL,
-  0x3e36a69aUL, 0x00000000UL, 0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL,
-  0x00000000UL, 0x3fd6d02cUL, 0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL,
-  0x3fd6a750UL, 0x1919fd61UL, 0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL,
-  0xaa7a994dUL, 0xbe3f3fbdUL, 0x00000000UL, 0x3fd655ceUL, 0x67db014cUL,
-  0x3e33c550UL, 0x00000000UL, 0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL,
-  0xc0000000UL, 0x3fd60493UL, 0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL,
-  0x3fd5dc11UL, 0x1222bd5cUL, 0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL,
-  0x6e8dc2d3UL, 0x3e5d4d79UL, 0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL,
-  0xbe517303UL, 0x80000000UL, 0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL,
-  0xc0000000UL, 0x3fd53ab8UL, 0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL,
-  0x3fd5128eUL, 0xea902207UL, 0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL,
-  0x9f911d79UL, 0x3e511735UL, 0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL,
-  0xbe5b1643UL, 0x40000000UL, 0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL,
-  0x80000000UL, 0x3fd47293UL, 0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL,
-  0x3fd44abfUL, 0xe04042f5UL, 0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL,
-  0x1d8bf2c8UL, 0x3e5d8810UL, 0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL,
-  0xbe311454UL, 0xc0000000UL, 0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL,
-  0x40000000UL, 0x3fd3ac1cUL, 0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL,
-  0x3fd3849dUL, 0xd4e34b9eUL, 0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL,
-  0x177204fbUL, 0xbe2b8cd7UL, 0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL,
-  0xbe4356e1UL, 0x80000000UL, 0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL,
-  0x00000000UL, 0x3fd2e74cUL, 0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL,
-  0x3fd2c021UL, 0x516dab3fUL, 0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL,
-  0x2bfb7313UL, 0x3e5674a2UL, 0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL,
-  0x3e385d29UL, 0xc0000000UL, 0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL,
-  0x00000000UL, 0x3fd2241cUL, 0x3f91953aUL, 0x3e389977UL, 0xc0000000UL,
-  0x3fd1fd43UL, 0xa1543f71UL, 0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL,
-  0x4ec8867cUL, 0x3df6a2dcUL, 0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL,
-  0x3e41d9c0UL, 0x80000000UL, 0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL,
-  0x40000000UL, 0x3fd16285UL, 0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL,
-  0x3fd13bfeUL, 0xb9aec164UL, 0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL,
-  0xd91e1316UL, 0xbe350630UL, 0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL,
-  0x3e3f5219UL, 0x40000000UL, 0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL,
-  0x00000000UL, 0x3fd0a281UL, 0x2a63447dUL, 0xbe541377UL, 0x80000000UL,
-  0x3fd07c49UL, 0xfac483b5UL, 0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL,
-  0x36b8a570UL, 0xbe4fd4bdUL, 0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL,
-  0xbe450388UL, 0x80000000UL, 0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL,
-  0x80000000UL, 0x3fcfc811UL, 0x707475acUL, 0x3e38806eUL, 0x80000000UL,
-  0x3fcf7c3fUL, 0xc91817fcUL, 0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL,
-  0xae05d5e9UL, 0xbe4919b8UL, 0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL,
-  0xbe530b94UL, 0x00000000UL, 0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL,
-  0x00000000UL, 0x3fce4e2dUL, 0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL,
-  0x3fce02f5UL, 0x8abe2c2eUL, 0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL,
-  0x1495450dUL, 0xbe0872ccUL, 0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL,
-  0xbe4f59a0UL, 0x00000000UL, 0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL,
-  0x00000000UL, 0x3fccd747UL, 0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL,
-  0x3fcc8ca7UL, 0xd305b56cUL, 0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL,
-  0x399a6910UL, 0xbe482a1cUL, 0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL,
-  0xbe587372UL, 0x80000000UL, 0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL,
-  0x00000000UL, 0x3fcb6355UL, 0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL,
-  0x3fcb194aUL, 0x8416c0bcUL, 0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL,
-  0x49f7f08fUL, 0x3e56da76UL, 0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL,
-  0x3e5f390cUL, 0x00000000UL, 0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL,
-  0x80000000UL, 0x3fc9f249UL, 0x33631553UL, 0x3e52aeb1UL, 0x00000000UL,
-  0x3fc9a8d3UL, 0xde8795a6UL, 0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL,
-  0x076bf41eUL, 0x3e5122feUL, 0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL,
-  0x3e3dd064UL, 0x00000000UL, 0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL,
-  0x80000000UL, 0x3fc8841aUL, 0xb2a96650UL, 0xbe575444UL, 0x80000000UL,
-  0x3fc83b34UL, 0x2376c0cbUL, 0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL,
-  0xd8a0b653UL, 0xbe5181b6UL, 0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL,
-  0xbe4a78b4UL, 0x00000000UL, 0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL,
-  0x80000000UL, 0x3fc718bbUL, 0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL,
-  0x3fc6d064UL, 0x3728b8cfUL, 0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL,
-  0xc79a4067UL, 0x3e5c380fUL, 0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL,
-  0x3e550a84UL, 0x80000000UL, 0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL,
-  0x80000000UL, 0x3fc5b022UL, 0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL,
-  0x3fc56858UL, 0x659b18beUL, 0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL,
-  0x66ee3631UL, 0xbe57d769UL, 0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL,
-  0x3e2427f7UL, 0x80000000UL, 0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL,
-  0x00000000UL, 0x3fc44a44UL, 0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL,
-  0x3fc40304UL, 0xcf1d3eabUL, 0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL,
-  0x79aba3eaUL, 0xbdf1b7c8UL, 0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL,
-  0xbe5130cfUL, 0x80000000UL, 0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL,
-  0x00000000UL, 0x3fc2e716UL, 0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL,
-  0x3fc2a05eUL, 0x6caed92eUL, 0xbe533924UL, 0x00000000UL, 0x3fc259c2UL,
-  0x9cb5034eUL, 0xbe510e31UL, 0x80000000UL, 0x3fc21340UL, 0x12c4d378UL,
-  0xbe540b43UL, 0x80000000UL, 0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL,
-  0x00000000UL, 0x3fc1868eUL, 0x921f4106UL, 0xbe528e67UL, 0x80000000UL,
-  0x3fc1405cUL, 0x3969441eUL, 0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL,
-  0xd941ef5bUL, 0x3e5f9079UL, 0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL,
-  0xbe567691UL, 0x00000000UL, 0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL,
-  0x00000000UL, 0x3fc028a2UL, 0x0a92a162UL, 0xbe52f394UL, 0x00000000UL,
-  0x3fbfc5eaUL, 0x209897e5UL, 0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL,
-  0x8458bd7bUL, 0x3e582831UL, 0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL,
-  0xbe486b4aUL, 0x00000000UL, 0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL,
-  0x00000000UL, 0x3fbd9a90UL, 0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL,
-  0x3fbd103cUL, 0x73eb6ab7UL, 0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL,
-  0x32ceaff5UL, 0xbe32dc5aUL, 0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL,
-  0xbe4a71a4UL, 0x00000000UL, 0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL,
-  0x00000000UL, 0x3fbae8eeUL, 0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL,
-  0x3fba5f9aUL, 0x95ce1114UL, 0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL,
-  0x6d7c0f78UL, 0x3e3abc2dUL, 0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL,
-  0xbe566cbcUL, 0x00000000UL, 0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL,
-  0x00000000UL, 0x3fb83c4aUL, 0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL,
-  0x3fb7b3f4UL, 0x2193d81eUL, 0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL,
-  0xdd70c122UL, 0x3e527a8cUL, 0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL,
-  0xbe450393UL, 0x00000000UL, 0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL,
-  0x00000000UL, 0x3fb59492UL, 0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL,
-  0x3fb50d36UL, 0x950f9f45UL, 0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL,
-  0x582cdcb1UL, 0x3e506d39UL, 0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL,
-  0x3e4aa719UL, 0x00000000UL, 0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL,
-  0x00000000UL, 0x3fb2f1b4UL, 0x7a138b41UL, 0xbe50b418UL, 0x00000000UL,
-  0x3fb26b4eUL, 0x2fbfd7eaUL, 0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL,
-  0x18913ccbUL, 0x3e465fc1UL, 0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL,
-  0x3e042843UL, 0x00000000UL, 0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL,
-  0x00000000UL, 0x3fb0539eUL, 0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL,
-  0x3faf9c56UL, 0x1777f657UL, 0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL,
-  0xc317b86aUL, 0xbe5a61e0UL, 0x00000000UL, 0x3fad87acUL, 0xb7664efbUL,
-  0xbe41f64eUL, 0x00000000UL, 0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL,
-  0x00000000UL, 0x3fab7480UL, 0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL,
-  0x3faa6b78UL, 0x06a253f1UL, 0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL,
-  0xa35f541bUL, 0x3e5a187aUL, 0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL,
-  0xbe508150UL, 0x00000000UL, 0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL,
-  0x00000000UL, 0x3fa64b10UL, 0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL,
-  0x3fa543e2UL, 0x97506fefUL, 0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL,
-  0xe75f7dd9UL, 0xbe388dd3UL, 0x00000000UL, 0x3fa3369cUL, 0xa4139632UL,
-  0xbdea5177UL, 0x00000000UL, 0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL,
-  0x00000000UL, 0x3fa12accUL, 0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL,
-  0x3fa0256eUL, 0x7478da78UL, 0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL,
-  0xf59cef7fUL, 0xbe539d0aUL, 0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL,
-  0x3e53c2c8UL, 0x00000000UL, 0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL,
-  0x00000000UL, 0x3f982724UL, 0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL,
-  0x3f962000UL, 0x130d9356UL, 0x3e475ba0UL, 0x00000000UL, 0x3f941994UL,
-  0x8f86f883UL, 0xbe513d0bUL, 0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL,
-  0xbe534335UL, 0x00000000UL, 0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL,
-  0x00000000UL, 0x3f8c1510UL, 0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL,
-  0x3f880de0UL, 0x8a27857eUL, 0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL,
-  0xda767328UL, 0x3e531b3dUL, 0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL,
-  0xbe5f04e3UL, 0x00000000UL, 0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL,
-  0x00000000UL, 0x3f6ffc40UL, 0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL,
-  0x3f5ff6c0UL, 0x1ad218afUL, 0xbe4c78a7UL, 0x00000000UL, 0x00000000UL,
-  0x00000000UL, 0x80000000UL
-};
-
-ALIGNED_(8) juint _log2_pow[] =
-{
-  0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL
-};
-
-//registers,
-// input: xmm0, xmm1
-// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
-//          rax, rdx, rcx, r8, r11
-
-// Code generated by Intel C compiler for LIBM library
-
-void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
-  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
-  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
-  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
-  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2;
-  Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2;
-  Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2;
-  Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2;
-  Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2;
-  Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2;
-  Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2;
-  Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2;
-  Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2;
-  Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2;
-  Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2;
-  Label L_2TAG_PACKET_56_0_2;
-  Label B1_2, B1_3, B1_5, start;
-
-  assert_different_registers(tmp1, tmp2, eax, ecx, edx);
-  jmp(start);
-  address HIGHSIGMASK = (address)_HIGHSIGMASK;
-  address LOG2_E = (address)_LOG2_E;
-  address coeff = (address)_coeff_pow;
-  address L_tbl = (address)_L_tbl_pow;
-  address HIGHMASK_Y = (address)_HIGHMASK_Y;
-  address T_exp = (address)_T_exp;
-  address e_coeff = (address)_e_coeff;
-  address coeff_h = (address)_coeff_h;
-  address HIGHMASK_LOG_X = (address)_HIGHMASK_LOG_X;
-  address HALFMASK = (address)_HALFMASK;
-  address log2 = (address)_log2_pow;
-
-
-  bind(start);
-  subq(rsp, 40);
-  movsd(Address(rsp, 8), xmm0);
-  movsd(Address(rsp, 16), xmm1);
-
-  bind(B1_2);
-  pextrw(eax, xmm0, 3);
-  xorpd(xmm2, xmm2);
-  mov64(tmp2, 0x3ff0000000000000);
-  movdq(xmm2, tmp2);
-  movl(tmp1, 1069088768);
-  movdq(xmm7, tmp1);
-  xorpd(xmm1, xmm1);
-  mov64(tmp3, 0x77f0000000000000);
-  movdq(xmm1, tmp3);
-  movdqu(xmm3, xmm0);
-  movl(edx, 32752);
-  andl(edx, eax);
-  subl(edx, 16368);
-  movl(ecx, edx);
-  sarl(edx, 31);
-  addl(ecx, edx);
-  xorl(ecx, edx);
-  por(xmm0, xmm2);
-  movdqu(xmm6, ExternalAddress(HIGHSIGMASK));    //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
-  psrlq(xmm0, 27);
-  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
-  psrld(xmm0, 2);
-  addl(ecx, 16);
-  bsrl(ecx, ecx);
-  rcpps(xmm0, xmm0);
-  psllq(xmm3, 12);
-  movl(tmp4, 8192);
-  movdq(xmm4, tmp4);
-  psrlq(xmm3, 12);
-  subl(eax, 16);
-  cmpl(eax, 32736);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
-  movl(tmp1, 0);
-
-  bind(L_2TAG_PACKET_1_0_2);
-  mulss(xmm0, xmm7);
-  movl(edx, -1);
-  subl(ecx, 4);
-  shll(edx);
-  shlq(edx, 32);
-  movdq(xmm5, edx);
-  por(xmm3, xmm1);
-  subl(eax, 16351);
-  cmpl(eax, 1);
-  jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2);
-  paddd(xmm0, xmm4);
-  pand(xmm5, xmm3);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-
-  bind(L_2TAG_PACKET_3_0_2);
-  subsd(xmm3, xmm5);
-  pand(xmm0, xmm6);
-  subl(eax, 1);
-  sarl(eax, 4);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-
-  bind(L_2TAG_PACKET_4_0_2);
-  mulsd(xmm3, xmm0);
-  movdqu(xmm1, ExternalAddress(coeff));    //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL
-  lea(tmp4, ExternalAddress(L_tbl));
-  subsd(xmm5, xmm2);
-  movdqu(xmm4, ExternalAddress(16 + coeff));    //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL
-  movl(ecx, eax);
-  sarl(eax, 31);
-  addl(ecx, eax);
-  xorl(eax, ecx);
-  addl(eax, 1);
-  bsrl(eax, eax);
-  unpcklpd(xmm5, xmm3);
-  movdqu(xmm6, ExternalAddress(32 + coeff));    //0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL
-  addsd(xmm3, xmm5);
-  andl(edx, 16760832);
-  shrl(edx, 10);
-  addpd(xmm5, Address(tmp4, edx, Address::times_1, -3648));
-  movdqu(xmm0, ExternalAddress(48 + coeff));    //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL
-  pshufd(xmm2, xmm3, 68);
-  mulsd(xmm3, xmm3);
-  mulpd(xmm1, xmm2);
-  mulpd(xmm4, xmm2);
-  addsd(xmm5, xmm7);
-  mulsd(xmm2, xmm3);
-  addpd(xmm6, xmm1);
-  mulsd(xmm3, xmm3);
-  addpd(xmm0, xmm4);
-  movq(xmm1, Address(rsp, 16));
-  movw(ecx, Address(rsp, 22));
-  pshufd(xmm7, xmm5, 238);
-  movq(xmm4, ExternalAddress(HIGHMASK_Y));    //0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL
-  mulpd(xmm6, xmm2);
-  pshufd(xmm3, xmm3, 68);
-  mulpd(xmm0, xmm2);
-  shll(eax, 4);
-  subl(eax, 15872);
-  andl(ecx, 32752);
-  addl(eax, ecx);
-  mulpd(xmm3, xmm6);
-  cmpl(eax, 624);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2);
-  xorpd(xmm6, xmm6);
-  movl(edx, 17080);
-  pinsrw(xmm6, edx, 3);
-  movdqu(xmm2, xmm1);
-  pand(xmm4, xmm1);
-  subsd(xmm1, xmm4);
-  mulsd(xmm4, xmm5);
-  addsd(xmm0, xmm7);
-  mulsd(xmm1, xmm5);
-  movdqu(xmm7, xmm6);
-  addsd(xmm6, xmm4);
-  lea(tmp4, ExternalAddress(T_exp));
-  addpd(xmm3, xmm0);
-  movdl(edx, xmm6);
-  subsd(xmm6, xmm7);
-  pshufd(xmm0, xmm3, 238);
-  subsd(xmm4, xmm6);
-  addsd(xmm0, xmm3);
-  movl(ecx, edx);
-  andl(edx, 255);
-  addl(edx, edx);
-  movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0));
-  addsd(xmm4, xmm1);
-  mulsd(xmm2, xmm0);
-  movdqu(xmm7, ExternalAddress(e_coeff));    //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL
-  movdqu(xmm3, ExternalAddress(16 + e_coeff));    //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL
-  shll(ecx, 12);
-  xorl(ecx, tmp1);
-  andl(rcx, -1048576);
-  movdq(xmm6, rcx);
-  addsd(xmm2, xmm4);
-  mov64(tmp2, 0x3fe62e42fefa39ef);
-  movdq(xmm1, tmp2);
-  pshufd(xmm0, xmm2, 68);
-  pshufd(xmm4, xmm2, 68);
-  mulsd(xmm1, xmm2);
-  pshufd(xmm6, xmm6, 17);
-  mulpd(xmm0, xmm0);
-  mulpd(xmm7, xmm4);
-  paddd(xmm5, xmm6);
-  mulsd(xmm1, xmm5);
-  pshufd(xmm6, xmm5, 238);
-  mulsd(xmm0, xmm0);
-  addpd(xmm3, xmm7);
-  addsd(xmm1, xmm6);
-  mulpd(xmm0, xmm3);
-  pshufd(xmm3, xmm0, 238);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm3, xmm5);
-  addsd(xmm0, xmm1);
-  addsd(xmm0, xmm3);
-  addsd(xmm0, xmm5);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_0_0_2);
-  addl(eax, 16);
-  movl(edx, 32752);
-  andl(edx, eax);
-  cmpl(edx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_6_0_2);
-  testl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_7_0_2);
-
-  bind(L_2TAG_PACKET_8_0_2);
-  movq(xmm0, Address(rsp, 8));
-  movq(xmm3, Address(rsp, 8));
-  movdl(edx, xmm3);
-  psrlq(xmm3, 32);
-  movdl(ecx, xmm3);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_9_0_2);
-  xorpd(xmm3, xmm3);
-  movl(eax, 18416);
-  pinsrw(xmm3, eax, 3);
-  mulsd(xmm0, xmm3);
-  xorpd(xmm2, xmm2);
-  movl(eax, 16368);
-  pinsrw(xmm2, eax, 3);
-  movdqu(xmm3, xmm0);
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  movl(ecx, 18416);
-  psrlq(xmm0, 27);
-  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
-  psrld(xmm0, 2);
-  rcpps(xmm0, xmm0);
-  psllq(xmm3, 12);
-  movdqu(xmm6, ExternalAddress(HIGHSIGMASK));    //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
-  psrlq(xmm3, 12);
-  mulss(xmm0, xmm7);
-  movl(edx, -1024);
-  movdl(xmm5, edx);
-  por(xmm3, xmm1);
-  paddd(xmm0, xmm4);
-  psllq(xmm5, 32);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  pand(xmm5, xmm3);
-  movl(tmp1, 0);
-  pand(xmm0, xmm6);
-  subsd(xmm3, xmm5);
-  andl(eax, 32752);
-  subl(eax, 18416);
-  sarl(eax, 4);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-  jmp(L_2TAG_PACKET_4_0_2);
-
-  bind(L_2TAG_PACKET_10_0_2);
-  movq(xmm0, Address(rsp, 8));
-  movq(xmm3, Address(rsp, 8));
-  movdl(edx, xmm3);
-  psrlq(xmm3, 32);
-  movdl(ecx, xmm3);
-  orl(edx, ecx);
-  cmpl(edx, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_9_0_2);
-  xorpd(xmm3, xmm3);
-  movl(eax, 18416);
-  pinsrw(xmm3, eax, 3);
-  mulsd(xmm0, xmm3);
-  xorpd(xmm2, xmm2);
-  movl(eax, 16368);
-  pinsrw(xmm2, eax, 3);
-  movdqu(xmm3, xmm0);
-  pextrw(eax, xmm0, 3);
-  por(xmm0, xmm2);
-  movl(ecx, 18416);
-  psrlq(xmm0, 27);
-  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
-  psrld(xmm0, 2);
-  rcpps(xmm0, xmm0);
-  psllq(xmm3, 12);
-  movdqu(xmm6, ExternalAddress(HIGHSIGMASK));    //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
-  psrlq(xmm3, 12);
-  mulss(xmm0, xmm7);
-  movl(edx, -1024);
-  movdl(xmm5, edx);
-  por(xmm3, xmm1);
-  paddd(xmm0, xmm4);
-  psllq(xmm5, 32);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  pand(xmm5, xmm3);
-  movl(tmp1, INT_MIN);
-  pand(xmm0, xmm6);
-  subsd(xmm3, xmm5);
-  andl(eax, 32752);
-  subl(eax, 18416);
-  sarl(eax, 4);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-  jmp(L_2TAG_PACKET_4_0_2);
-
-  bind(L_2TAG_PACKET_5_0_2);
-  cmpl(eax, 0);
-  jcc(Assembler::less, L_2TAG_PACKET_11_0_2);
-  cmpl(eax, 752);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_12_0_2);
-  addsd(xmm0, xmm7);
-  movq(xmm2, ExternalAddress(HALFMASK));    //0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL
-  addpd(xmm3, xmm0);
-  xorpd(xmm6, xmm6);
-  movl(eax, 17080);
-  pinsrw(xmm6, eax, 3);
-  pshufd(xmm0, xmm3, 238);
-  addsd(xmm0, xmm3);
-  movdqu(xmm3, xmm5);
-  addsd(xmm5, xmm0);
-  movdqu(xmm4, xmm2);
-  subsd(xmm3, xmm5);
-  movdqu(xmm7, xmm5);
-  pand(xmm5, xmm2);
-  movdqu(xmm2, xmm1);
-  pand(xmm4, xmm1);
-  subsd(xmm7, xmm5);
-  addsd(xmm0, xmm3);
-  subsd(xmm1, xmm4);
-  mulsd(xmm4, xmm5);
-  addsd(xmm0, xmm7);
-  mulsd(xmm2, xmm0);
-  movdqu(xmm7, xmm6);
-  mulsd(xmm1, xmm5);
-  addsd(xmm6, xmm4);
-  movdl(eax, xmm6);
-  subsd(xmm6, xmm7);
-  lea(tmp4, ExternalAddress(T_exp));
-  addsd(xmm2, xmm1);
-  movdqu(xmm7, ExternalAddress(e_coeff));    //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL
-  movdqu(xmm3, ExternalAddress(16 + e_coeff));    //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL
-  subsd(xmm4, xmm6);
-  pextrw(edx, xmm6, 3);
-  movl(ecx, eax);
-  andl(eax, 255);
-  addl(eax, eax);
-  movdqu(xmm5, Address(tmp4, rax, Address::times_8, 0));
-  addsd(xmm2, xmm4);
-  sarl(ecx, 8);
-  movl(eax, ecx);
-  sarl(ecx, 1);
-  subl(eax, ecx);
-  shll(ecx, 20);
-  xorl(ecx, tmp1);
-  movdl(xmm6, ecx);
-  movq(xmm1, ExternalAddress(32 + e_coeff));    //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL
-  andl(edx, 32767);
-  cmpl(edx, 16529);
-  jcc(Assembler::above, L_2TAG_PACKET_12_0_2);
-  pshufd(xmm0, xmm2, 68);
-  pshufd(xmm4, xmm2, 68);
-  mulpd(xmm0, xmm0);
-  mulpd(xmm7, xmm4);
-  pshufd(xmm6, xmm6, 17);
-  mulsd(xmm1, xmm2);
-  mulsd(xmm0, xmm0);
-  paddd(xmm5, xmm6);
-  addpd(xmm3, xmm7);
-  mulsd(xmm1, xmm5);
-  pshufd(xmm6, xmm5, 238);
-  mulpd(xmm0, xmm3);
-  addsd(xmm1, xmm6);
-  pshufd(xmm3, xmm0, 238);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm3, xmm5);
-  shll(eax, 4);
-  xorpd(xmm4, xmm4);
-  addl(eax, 16368);
-  pinsrw(xmm4, eax, 3);
-  addsd(xmm0, xmm1);
-  addsd(xmm0, xmm3);
-  movdqu(xmm1, xmm0);
-  addsd(xmm0, xmm5);
-  mulsd(xmm0, xmm4);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_13_0_2);
-  cmpl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_14_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_6_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movq(xmm0, Address(rsp, 8));
-  movdqu(xmm2, xmm0);
-  movdl(eax, xmm2);
-  psrlq(xmm2, 20);
-  movdl(edx, xmm2);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_15_0_2);
-  movdl(eax, xmm1);
-  psrlq(xmm1, 32);
-  movdl(edx, xmm1);
-  movl(ecx, edx);
-  addl(edx, edx);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_16_0_2);
-  addsd(xmm0, xmm0);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_16_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  movl(Address(rsp, 0), 29);
-  jmp(L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_18_0_2);
-  movq(xmm0, Address(rsp, 16));
-  addpd(xmm0, xmm0);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_15_0_2);
-  movdl(eax, xmm1);
-  movdqu(xmm2, xmm1);
-  psrlq(xmm1, 32);
-  movdl(edx, xmm1);
-  movl(ecx, edx);
-  addl(edx, edx);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_19_0_2);
-  pextrw(eax, xmm2, 3);
-  andl(eax, 32752);
-  cmpl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_20_0_2);
-  movdl(eax, xmm2);
-  psrlq(xmm2, 20);
-  movdl(edx, xmm2);
-  orl(eax, edx);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_20_0_2);
-  pextrw(eax, xmm0, 3);
-  testl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_21_0_2);
-  testl(ecx, INT_MIN);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_23_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movdl(eax, xmm1);
-  testl(eax, 1);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2);
-  testl(eax, 2);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2);
-  jmp(L_2TAG_PACKET_24_0_2);
-
-  bind(L_2TAG_PACKET_21_0_2);
-  shrl(ecx, 20);
-  andl(ecx, 2047);
-  cmpl(ecx, 1075);
-  jcc(Assembler::above, L_2TAG_PACKET_24_0_2);
-  jcc(Assembler::equal, L_2TAG_PACKET_26_0_2);
-  cmpl(ecx, 1074);
-  jcc(Assembler::above, L_2TAG_PACKET_23_0_2);
-  cmpl(ecx, 1023);
-  jcc(Assembler::below, L_2TAG_PACKET_24_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movl(eax, 17208);
-  xorpd(xmm3, xmm3);
-  pinsrw(xmm3, eax, 3);
-  movdqu(xmm4, xmm3);
-  addsd(xmm3, xmm1);
-  subsd(xmm4, xmm3);
-  addsd(xmm1, xmm4);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2);
-  movdl(eax, xmm3);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_24_0_2);
-
-  bind(L_2TAG_PACKET_25_0_2);
-  movq(xmm1, Address(rsp, 16));
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_27_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_27_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32768);
-  pinsrw(xmm0, eax, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_24_0_2);
-  movq(xmm1, Address(rsp, 16));
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32752);
-  pinsrw(xmm0, eax, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_26_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movdl(eax, xmm1);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_24_0_2);
-  jmp(L_2TAG_PACKET_25_0_2);
-
-  bind(L_2TAG_PACKET_28_0_2);
-  movdl(eax, xmm1);
-  psrlq(xmm1, 20);
-  movdl(edx, xmm1);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_29_0_2);
-  movq(xmm0, Address(rsp, 16));
-  addsd(xmm0, xmm0);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_29_0_2);
-  movq(xmm0, Address(rsp, 8));
-  pextrw(eax, xmm0, 3);
-  cmpl(eax, 49136);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2);
-  movdl(ecx, xmm0);
-  psrlq(xmm0, 20);
-  movdl(edx, xmm0);
-  orl(ecx, edx);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32760);
-  pinsrw(xmm0, eax, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_30_0_2);
-  movq(xmm1, Address(rsp, 16));
-  andl(eax, 32752);
-  subl(eax, 16368);
-  pextrw(edx, xmm1, 3);
-  xorpd(xmm0, xmm0);
-  xorl(eax, edx);
-  andl(eax, 32768);
-  jcc(Assembler::equal, L_2TAG_PACKET_31_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_31_0_2);
-  movl(ecx, 32752);
-  pinsrw(xmm0, ecx, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_32_0_2);
-  movdl(eax, xmm1);
-  cmpl(edx, 17184);
-  jcc(Assembler::above, L_2TAG_PACKET_33_0_2);
-  testl(eax, 1);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
-  testl(eax, 2);
-  jcc(Assembler::equal, L_2TAG_PACKET_35_0_2);
-  jmp(L_2TAG_PACKET_36_0_2);
-
-  bind(L_2TAG_PACKET_33_0_2);
-  testl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_35_0_2);
-  jmp(L_2TAG_PACKET_36_0_2);
-
-  bind(L_2TAG_PACKET_7_0_2);
-  movq(xmm2, Address(rsp, 8));
-  movdl(eax, xmm2);
-  psrlq(xmm2, 31);
-  movdl(ecx, xmm2);
-  orl(eax, ecx);
-  jcc(Assembler::equal, L_2TAG_PACKET_9_0_2);
-  movq(xmm1, Address(rsp, 16));
-  pextrw(edx, xmm1, 3);
-  movdl(eax, xmm1);
-  movdqu(xmm2, xmm1);
-  psrlq(xmm2, 32);
-  movdl(ecx, xmm2);
-  addl(ecx, ecx);
-  orl(ecx, eax);
-  jcc(Assembler::equal, L_2TAG_PACKET_37_0_2);
-  andl(edx, 32752);
-  cmpl(edx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_28_0_2);
-  cmpl(edx, 17200);
-  jcc(Assembler::above, L_2TAG_PACKET_35_0_2);
-  cmpl(edx, 17184);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_32_0_2);
-  cmpl(edx, 16368);
-  jcc(Assembler::below, L_2TAG_PACKET_34_0_2);
-  movl(eax, 17208);
-  xorpd(xmm2, xmm2);
-  pinsrw(xmm2, eax, 3);
-  movdqu(xmm4, xmm2);
-  addsd(xmm2, xmm1);
-  subsd(xmm4, xmm2);
-  addsd(xmm1, xmm4);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32767);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
-  movdl(eax, xmm2);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_35_0_2);
-
-  bind(L_2TAG_PACKET_36_0_2);
-  xorpd(xmm1, xmm1);
-  movl(edx, 30704);
-  pinsrw(xmm1, edx, 3);
-  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
-  movq(xmm4, Address(rsp, 8));
-  pextrw(eax, xmm4, 3);
-  movl(edx, 8192);
-  movdl(xmm4, edx);
-  andl(eax, 32767);
-  subl(eax, 16);
-  jcc(Assembler::less, L_2TAG_PACKET_10_0_2);
-  movl(edx, eax);
-  andl(edx, 32752);
-  subl(edx, 16368);
-  movl(ecx, edx);
-  sarl(edx, 31);
-  addl(ecx, edx);
-  xorl(ecx, edx);
-  addl(ecx, 16);
-  bsrl(ecx, ecx);
-  movl(tmp1, INT_MIN);
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_34_0_2);
-  xorpd(xmm1, xmm1);
-  movl(eax, 32752);
-  pinsrw(xmm1, eax, 3);
-  xorpd(xmm0, xmm0);
-  mulsd(xmm0, xmm1);
-  movl(Address(rsp, 0), 28);
-  jmp(L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_35_0_2);
-  xorpd(xmm1, xmm1);
-  movl(edx, 30704);
-  pinsrw(xmm1, edx, 3);
-  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
-  movq(xmm4, Address(rsp, 8));
-  pextrw(eax, xmm4, 3);
-  movl(edx, 8192);
-  movdl(xmm4, edx);
-  andl(eax, 32767);
-  subl(eax, 16);
-  jcc(Assembler::less, L_2TAG_PACKET_8_0_2);
-  movl(edx, eax);
-  andl(edx, 32752);
-  subl(edx, 16368);
-  movl(ecx, edx);
-  sarl(edx, 31);
-  addl(ecx, edx);
-  xorl(ecx, edx);
-  addl(ecx, 16);
-  bsrl(ecx, ecx);
-  movl(tmp1, 0);
-  jmp(L_2TAG_PACKET_1_0_2);
-
-  bind(L_2TAG_PACKET_19_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_22_0_2);
-  xorpd(xmm0, xmm0);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_11_0_2);
-  addl(eax, 384);
-  cmpl(eax, 0);
-  jcc(Assembler::less, L_2TAG_PACKET_38_0_2);
-  mulsd(xmm5, xmm1);
-  addsd(xmm0, xmm7);
-  shrl(tmp1, 31);
-  addpd(xmm3, xmm0);
-  pshufd(xmm0, xmm3, 238);
-  addsd(xmm3, xmm0);
-  lea(tmp4, ExternalAddress(log2));    //0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL
-  movq(xmm4, Address(tmp4, tmp1, Address::times_8, 0));
-  mulsd(xmm1, xmm3);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  shll(tmp1, 15);
-  orl(eax, tmp1);
-  pinsrw(xmm0, eax, 3);
-  addsd(xmm5, xmm1);
-  mulsd(xmm5, xmm4);
-  addsd(xmm0, xmm5);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_38_0_2);
-
-  bind(L_2TAG_PACKET_37_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_39_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 16368);
-  pinsrw(xmm0, eax, 3);
-  movl(Address(rsp, 0), 26);
-  jmp(L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_9_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movdqu(xmm2, xmm1);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32752);
-  cmpl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_40_0_2);
-  movdl(eax, xmm2);
-  psrlq(xmm2, 20);
-  movdl(edx, xmm2);
-  orl(eax, edx);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
-
-  bind(L_2TAG_PACKET_40_0_2);
-  movdl(eax, xmm1);
-  psrlq(xmm1, 32);
-  movdl(edx, xmm1);
-  movl(ecx, edx);
-  addl(edx, edx);
-  orl(eax, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_39_0_2);
-  shrl(edx, 21);
-  cmpl(edx, 1075);
-  jcc(Assembler::above, L_2TAG_PACKET_41_0_2);
-  jcc(Assembler::equal, L_2TAG_PACKET_42_0_2);
-  cmpl(edx, 1023);
-  jcc(Assembler::below, L_2TAG_PACKET_41_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movl(eax, 17208);
-  xorpd(xmm3, xmm3);
-  pinsrw(xmm3, eax, 3);
-  movdqu(xmm4, xmm3);
-  addsd(xmm3, xmm1);
-  subsd(xmm4, xmm3);
-  addsd(xmm1, xmm4);
-  pextrw(eax, xmm1, 3);
-  andl(eax, 32752);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_41_0_2);
-  movdl(eax, xmm3);
-  andl(eax, 1);
-  jcc(Assembler::equal, L_2TAG_PACKET_41_0_2);
-
-  bind(L_2TAG_PACKET_43_0_2);
-  movq(xmm0, Address(rsp, 8));
-  testl(ecx, INT_MIN);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_42_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movdl(eax, xmm1);
-  testl(eax, 1);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2);
-
-  bind(L_2TAG_PACKET_41_0_2);
-  testl(ecx, INT_MIN);
-  jcc(Assembler::equal, L_2TAG_PACKET_22_0_2);
-  xorpd(xmm0, xmm0);
-
-  bind(L_2TAG_PACKET_44_0_2);
-  movl(eax, 16368);
-  xorpd(xmm1, xmm1);
-  pinsrw(xmm1, eax, 3);
-  divsd(xmm1, xmm0);
-  movdqu(xmm0, xmm1);
-  movl(Address(rsp, 0), 27);
-  jmp(L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_12_0_2);
-  movq(xmm2, Address(rsp, 8));
-  movq(xmm6, Address(rsp, 16));
-  pextrw(eax, xmm2, 3);
-  pextrw(edx, xmm6, 3);
-  movl(ecx, 32752);
-  andl(ecx, edx);
-  cmpl(ecx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_45_0_2);
-  andl(eax, 32752);
-  subl(eax, 16368);
-  xorl(edx, eax);
-  testl(edx, 32768);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2);
-
-  bind(L_2TAG_PACKET_47_0_2);
-  movl(eax, 32736);
-  pinsrw(xmm0, eax, 3);
-  shrl(tmp1, 16);
-  orl(eax, tmp1);
-  pinsrw(xmm1, eax, 3);
-  mulsd(xmm0, xmm1);
-
-  bind(L_2TAG_PACKET_14_0_2);
-  movl(Address(rsp, 0), 24);
-  jmp(L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_46_0_2);
-  movl(eax, 16);
-  pinsrw(xmm0, eax, 3);
-  mulsd(xmm0, xmm0);
-  testl(tmp1, INT_MIN);
-  jcc(Assembler::equal, L_2TAG_PACKET_48_0_2);
-  mov64(tmp2, 0x8000000000000000);
-  movdq(xmm2, tmp2);
-  xorpd(xmm0, xmm2);
-
-  bind(L_2TAG_PACKET_48_0_2);
-  movl(Address(rsp, 0), 25);
-  jmp(L_2TAG_PACKET_17_0_2);
-
-  bind(L_2TAG_PACKET_13_0_2);
-  pextrw(ecx, xmm5, 3);
-  pextrw(edx, xmm4, 3);
-  movl(eax, -1);
-  andl(ecx, 32752);
-  subl(ecx, 16368);
-  andl(edx, 32752);
-  addl(edx, ecx);
-  movl(ecx, -31);
-  sarl(edx, 4);
-  subl(ecx, edx);
-  jcc(Assembler::lessEqual, L_2TAG_PACKET_49_0_2);
-  cmpl(ecx, 20);
-  jcc(Assembler::above, L_2TAG_PACKET_50_0_2);
-  shll(eax);
-
-  bind(L_2TAG_PACKET_49_0_2);
-  movdl(xmm0, eax);
-  psllq(xmm0, 32);
-  pand(xmm0, xmm5);
-  subsd(xmm5, xmm0);
-  addsd(xmm5, xmm1);
-  mulsd(xmm0, xmm4);
-  mulsd(xmm5, xmm4);
-  addsd(xmm0, xmm5);
-
-  bind(L_2TAG_PACKET_50_0_2);
-  jmp(L_2TAG_PACKET_48_0_2);
-
-  bind(L_2TAG_PACKET_2_0_2);
-  movw(ecx, Address(rsp, 22));
-  movl(edx, INT_MIN);
-  movdl(xmm1, rdx);
-  xorpd(xmm7, xmm7);
-  paddd(xmm0, xmm4);
-  movdl(edx, xmm0);
-  psllq(xmm0, 29);
-  paddq(xmm1, xmm3);
-  pand(xmm5, xmm1);
-  andl(ecx, 32752);
-  cmpl(ecx, 16560);
-  jcc(Assembler::less, L_2TAG_PACKET_3_0_2);
-  pand(xmm0, xmm6);
-  subsd(xmm3, xmm5);
-  addl(eax, 16351);
-  shrl(eax, 4);
-  subl(eax, 1022);
-  cvtsi2sdl(xmm7, eax);
-  mulpd(xmm5, xmm0);
-  lea(r11, ExternalAddress(L_tbl));
-  movq(xmm4, ExternalAddress(coeff_h));    //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL
-  mulsd(xmm3, xmm0);
-  movq(xmm6, ExternalAddress(coeff_h));    //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL
-  subsd(xmm5, xmm2);
-  movq(xmm1, ExternalAddress(8 + coeff_h));    //0x00000000UL, 0xbf5dabe1UL
-  pshufd(xmm2, xmm3, 68);
-  unpcklpd(xmm5, xmm3);
-  addsd(xmm3, xmm5);
-  movq(xmm0, ExternalAddress(8 + coeff_h));    //0x00000000UL, 0xbf5dabe1UL
-  andl(edx, 16760832);
-  shrl(edx, 10);
-  addpd(xmm7, Address(tmp4, edx, Address::times_1, -3648));
-  mulsd(xmm4, xmm5);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm6, xmm2);
-  mulsd(xmm1, xmm2);
-  movdqu(xmm2, xmm5);
-  mulsd(xmm4, xmm5);
-  addsd(xmm5, xmm0);
-  movdqu(xmm0, xmm7);
-  addsd(xmm2, xmm3);
-  addsd(xmm7, xmm5);
-  mulsd(xmm6, xmm2);
-  subsd(xmm0, xmm7);
-  movdqu(xmm2, xmm7);
-  addsd(xmm7, xmm4);
-  addsd(xmm0, xmm5);
-  subsd(xmm2, xmm7);
-  addsd(xmm4, xmm2);
-  pshufd(xmm2, xmm5, 238);
-  movdqu(xmm5, xmm7);
-  addsd(xmm7, xmm2);
-  addsd(xmm4, xmm0);
-  movdqu(xmm0, ExternalAddress(coeff));    //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL
-  subsd(xmm5, xmm7);
-  addsd(xmm6, xmm4);
-  movdqu(xmm4, xmm7);
-  addsd(xmm5, xmm2);
-  addsd(xmm7, xmm1);
-  movdqu(xmm2, ExternalAddress(64 + coeff));    //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL
-  subsd(xmm4, xmm7);
-  addsd(xmm6, xmm5);
-  addsd(xmm4, xmm1);
-  pshufd(xmm5, xmm7, 238);
-  movapd(xmm1, xmm7);
-  addsd(xmm7, xmm5);
-  subsd(xmm1, xmm7);
-  addsd(xmm1, xmm5);
-  movdqu(xmm5, ExternalAddress(80 + coeff));    //0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL
-  pshufd(xmm3, xmm3, 68);
-  addsd(xmm6, xmm4);
-  addsd(xmm6, xmm1);
-  movdqu(xmm1, ExternalAddress(32 + coeff));    //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL
-  mulpd(xmm0, xmm3);
-  mulpd(xmm2, xmm3);
-  pshufd(xmm4, xmm3, 68);
-  mulpd(xmm3, xmm3);
-  addpd(xmm0, xmm1);
-  addpd(xmm5, xmm2);
-  mulsd(xmm4, xmm3);
-  movq(xmm2, ExternalAddress(HIGHMASK_LOG_X));    //0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL
-  mulpd(xmm3, xmm3);
-  movq(xmm1, Address(rsp, 16));
-  movw(ecx, Address(rsp, 22));
-  mulpd(xmm0, xmm4);
-  pextrw(eax, xmm7, 3);
-  mulpd(xmm5, xmm4);
-  mulpd(xmm0, xmm3);
-  movq(xmm4, ExternalAddress(8 + HIGHMASK_Y));    //0x00000000UL, 0xffffffffUL
-  pand(xmm2, xmm7);
-  addsd(xmm5, xmm6);
-  subsd(xmm7, xmm2);
-  addpd(xmm5, xmm0);
-  andl(eax, 32752);
-  subl(eax, 16368);
-  andl(ecx, 32752);
-  cmpl(ecx, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_45_0_2);
-  addl(ecx, eax);
-  cmpl(ecx, 16576);
-  jcc(Assembler::aboveEqual, L_2TAG_PACKET_51_0_2);
-  pshufd(xmm0, xmm5, 238);
-  pand(xmm4, xmm1);
-  movdqu(xmm3, xmm1);
-  addsd(xmm5, xmm0);
-  subsd(xmm1, xmm4);
-  xorpd(xmm6, xmm6);
-  movl(edx, 17080);
-  pinsrw(xmm6, edx, 3);
-  addsd(xmm7, xmm5);
-  mulsd(xmm4, xmm2);
-  mulsd(xmm1, xmm2);
-  movdqu(xmm5, xmm6);
-  mulsd(xmm3, xmm7);
-  addsd(xmm6, xmm4);
-  addsd(xmm1, xmm3);
-  movdqu(xmm7, ExternalAddress(e_coeff));    //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL
-  movdl(edx, xmm6);
-  subsd(xmm6, xmm5);
-  lea(tmp4, ExternalAddress(T_exp));
-  movdqu(xmm3, ExternalAddress(16 + e_coeff));    //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL
-  movq(xmm2, ExternalAddress(32 + e_coeff));    //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL
-  subsd(xmm4, xmm6);
-  movl(ecx, edx);
-  andl(edx, 255);
-  addl(edx, edx);
-  movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0));
-  addsd(xmm4, xmm1);
-  pextrw(edx, xmm6, 3);
-  shrl(ecx, 8);
-  movl(eax, ecx);
-  shrl(ecx, 1);
-  subl(eax, ecx);
-  shll(ecx, 20);
-  movdl(xmm6, ecx);
-  pshufd(xmm0, xmm4, 68);
-  pshufd(xmm1, xmm4, 68);
-  mulpd(xmm0, xmm0);
-  mulpd(xmm7, xmm1);
-  pshufd(xmm6, xmm6, 17);
-  mulsd(xmm2, xmm4);
-  andl(edx, 32767);
-  cmpl(edx, 16529);
-  jcc(Assembler::above, L_2TAG_PACKET_12_0_2);
-  mulsd(xmm0, xmm0);
-  paddd(xmm5, xmm6);
-  addpd(xmm3, xmm7);
-  mulsd(xmm2, xmm5);
-  pshufd(xmm6, xmm5, 238);
-  mulpd(xmm0, xmm3);
-  addsd(xmm2, xmm6);
-  pshufd(xmm3, xmm0, 238);
-  addl(eax, 1023);
-  shll(eax, 20);
-  orl(eax, tmp1);
-  movdl(xmm4, eax);
-  mulsd(xmm0, xmm5);
-  mulsd(xmm3, xmm5);
-  addsd(xmm0, xmm2);
-  psllq(xmm4, 32);
-  addsd(xmm0, xmm3);
-  movdqu(xmm1, xmm0);
-  addsd(xmm0, xmm5);
-  mulsd(xmm0, xmm4);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_13_0_2);
-  cmpl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_14_0_2);
-
-  bind(L_2TAG_PACKET_52_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_45_0_2);
-  movq(xmm0, Address(rsp, 8));
-  xorpd(xmm2, xmm2);
-  movl(eax, 49136);
-  pinsrw(xmm2, eax, 3);
-  addsd(xmm2, xmm0);
-  pextrw(eax, xmm2, 3);
-  cmpl(eax, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_53_0_2);
-  xorpd(xmm0, xmm0);
-  movl(eax, 32760);
-  pinsrw(xmm0, eax, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_53_0_2);
-  movq(xmm1, Address(rsp, 16));
-  movdl(edx, xmm1);
-  movdqu(xmm3, xmm1);
-  psrlq(xmm3, 20);
-  movdl(ecx, xmm3);
-  orl(ecx, edx);
-  jcc(Assembler::equal, L_2TAG_PACKET_54_0_2);
-  addsd(xmm1, xmm1);
-  movdqu(xmm0, xmm1);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_51_0_2);
-  pextrw(eax, xmm1, 3);
-  pextrw(ecx, xmm2, 3);
-  xorl(eax, ecx);
-  testl(eax, 32768);
-  jcc(Assembler::equal, L_2TAG_PACKET_47_0_2);
-  jmp(L_2TAG_PACKET_46_0_2);
-
-  bind(L_2TAG_PACKET_54_0_2);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  pextrw(edx, xmm1, 3);
-  xorpd(xmm0, xmm0);
-  subl(eax, 16368);
-  xorl(eax, edx);
-  testl(eax, 32768);
-  jcc(Assembler::equal, L_2TAG_PACKET_55_0_2);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_55_0_2);
-  movl(edx, 32752);
-  pinsrw(xmm0, edx, 3);
-  jmp(B1_5);
-
-  bind(L_2TAG_PACKET_17_0_2);
-  movq(Address(rsp, 24), xmm0);
-
-  bind(B1_3);
-  movq(xmm0, Address(rsp, 24));
-
-  bind(L_2TAG_PACKET_56_0_2);
-
-  bind(B1_5);
-  addq(rsp, 40);
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - SIN()
-//                     ---------------------
-//
-//     1. RANGE REDUCTION
-//
-//     We perform an initial range reduction from X to r with
-//
-//          X =~= N * pi/32 + r
-//
-//     so that |r| <= pi/64 + epsilon. We restrict inputs to those
-//     where |N| <= 932560. Beyond this, the range reduction is
-//     insufficiently accurate. For extremely small inputs,
-//     denormalization can occur internally, impacting performance.
-//     This means that the main path is actually only taken for
-//     2^-252 <= |X| < 90112.
-//
-//     To avoid branches, we perform the range reduction to full
-//     accuracy each time.
-//
-//          X - N * (P_1 + P_2 + P_3)
-//
-//     where P_1 and P_2 are 32-bit numbers (so multiplication by N
-//     is exact) and P_3 is a 53-bit number. Together, these
-//     approximate pi well enough for all cases in the restricted
-//     range.
-//
-//     The main reduction sequence is:
-//
-//             y = 32/pi * x
-//             N = integer(y)
-//     (computed by adding and subtracting off SHIFTER)
-//
-//             m_1 = N * P_1
-//             m_2 = N * P_2
-//             r_1 = x - m_1
-//             r = r_1 - m_2
-//     (this r can be used for most of the calculation)
-//
-//             c_1 = r_1 - r
-//             m_3 = N * P_3
-//             c_2 = c_1 - m_2
-//             c = c_2 - m_3
-//
-//     2. MAIN ALGORITHM
-//
-//     The algorithm uses a table lookup based on B = M * pi / 32
-//     where M = N mod 64. The stored values are:
-//       sigma             closest power of 2 to cos(B)
-//       C_hl              53-bit cos(B) - sigma
-//       S_hi + S_lo       2 * 53-bit sin(B)
-//
-//     The computation is organized as follows:
-//
-//          sin(B + r + c) = [sin(B) + sigma * r] +
-//                           r * (cos(B) - sigma) +
-//                           sin(B) * [cos(r + c) - 1] +
-//                           cos(B) * [sin(r + c) - r]
-//
-//     which is approximately:
-//
-//          [S_hi + sigma * r] +
-//          C_hl * r +
-//          S_lo + S_hi * [(cos(r) - 1) - r * c] +
-//          (C_hl + sigma) * [(sin(r) - r) + c]
-//
-//     and this is what is actually computed. We separate this sum
-//     into four parts:
-//
-//          hi + med + pols + corr
-//
-//     where
-//
-//          hi       = S_hi + sigma r
-//          med      = C_hl * r
-//          pols     = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r)
-//          corr     = S_lo + c * ((C_hl + sigma) - S_hi * r)
-//
-//     3. POLYNOMIAL
-//
-//     The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) *
-//     (sin(r) - r) can be rearranged freely, since it is quite
-//     small, so we exploit parallelism to the fullest.
-//
-//          psc4       =   SC_4 * r_1
-//          msc4       =   psc4 * r
-//          r2         =   r * r
-//          msc2       =   SC_2 * r2
-//          r4         =   r2 * r2
-//          psc3       =   SC_3 + msc4
-//          psc1       =   SC_1 + msc2
-//          msc3       =   r4 * psc3
-//          sincospols =   psc1 + msc3
-//          pols       =   sincospols *
-//                         <S_hi * r^2 | (C_hl + sigma) * r^3>
-//
-//     4. CORRECTION TERM
-//
-//     This is where the "c" component of the range reduction is
-//     taken into account; recall that just "r" is used for most of
-//     the calculation.
-//
-//          -c   = m_3 - c_2
-//          -d   = S_hi * r - (C_hl + sigma)
-//          corr = -c * -d + S_lo
-//
-//     5. COMPENSATED SUMMATIONS
-//
-//     The two successive compensated summations add up the high
-//     and medium parts, leaving just the low parts to add up at
-//     the end.
-//
-//          rs        =  sigma * r
-//          res_int   =  S_hi + rs
-//          k_0       =  S_hi - res_int
-//          k_2       =  k_0 + rs
-//          med       =  C_hl * r
-//          res_hi    =  res_int + med
-//          k_1       =  res_int - res_hi
-//          k_3       =  k_1 + med
-//
-//     6. FINAL SUMMATION
-//
-//     We now add up all the small parts:
-//
-//          res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3
-//
-//     Now the overall result is just:
-//
-//          res_hi + res_lo
-//
-//     7. SMALL ARGUMENTS
-//
-//     If |x| < SNN (SNN meaning the smallest normal number), we
-//     simply perform 0.1111111 cdots 1111 * x. For SNN <= |x|, we
-//     do 2^-55 * (2^55 * x - x).
-//
-// Special cases:
-//  sin(NaN) = quiet NaN, and raise invalid exception
-//  sin(INF) = NaN and raise invalid exception
-//  sin(+/-0) = +/-0
-//
-/******************************************************************************/
-
-ALIGNED_(16) juint _ONEHALF[] =
-{
-    0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
-};
-
-ALIGNED_(16) juint _P_2[] =
-{
-    0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
-};
-
-ALIGNED_(16) juint _SC_4[] =
-{
-    0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
-};
-
-ALIGNED_(16) juint _Ctable[] =
-{
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL,
-    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
-    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL,
-    0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL,
-    0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL,
-    0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL,
-    0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL,
-    0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL,
-    0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL,
-    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
-    0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL,
-    0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL,
-    0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL,
-    0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL,
-    0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL,
-    0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL,
-    0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL,
-    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
-    0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL,
-    0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL,
-    0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL,
-    0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL,
-    0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL,
-    0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL,
-    0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL,
-    0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL,
-    0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL,
-    0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL,
-    0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL,
-    0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL,
-    0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL,
-    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
-    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL,
-    0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL,
-    0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL,
-    0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL,
-    0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL,
-    0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL,
-    0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL,
-    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
-    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL,
-    0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL,
-    0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL,
-    0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL,
-    0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL,
-    0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL,
-    0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL,
-    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
-    0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL,
-    0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
-    0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL,
-    0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL,
-    0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL,
-    0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL,
-    0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL,
-    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL,
-    0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL,
-    0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
-    0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL,
-    0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL,
-    0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL,
-    0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL,
-    0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL,
-    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL,
-    0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL,
-    0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
-    0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL,
-    0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL,
-    0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL,
-    0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL,
-    0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL,
-    0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL,
-    0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL,
-    0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL,
-    0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL,
-    0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL,
-    0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL,
-    0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL,
-    0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL,
-    0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL,
-    0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
-    0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL,
-    0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL,
-    0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL,
-    0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL,
-    0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL,
-    0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL,
-    0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL,
-    0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
-    0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL,
-    0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL,
-    0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL,
-    0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL,
-    0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL,
-    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL,
-    0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL,
-    0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
-    0x00000000UL, 0x3ff00000UL
-};
-
-ALIGNED_(16) juint _SC_2[] =
-{
-    0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
-};
-
-ALIGNED_(16) juint _SC_3[] =
-{
-    0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
-};
-
-ALIGNED_(16) juint _SC_1[] =
-{
-    0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
-};
-
-ALIGNED_(16) juint _PI_INV_TABLE[] =
-{
-    0x00000000UL, 0x00000000UL, 0xa2f9836eUL, 0x4e441529UL, 0xfc2757d1UL,
-    0xf534ddc0UL, 0xdb629599UL, 0x3c439041UL, 0xfe5163abUL, 0xdebbc561UL,
-    0xb7246e3aUL, 0x424dd2e0UL, 0x06492eeaUL, 0x09d1921cUL, 0xfe1deb1cUL,
-    0xb129a73eUL, 0xe88235f5UL, 0x2ebb4484UL, 0xe99c7026UL, 0xb45f7e41UL,
-    0x3991d639UL, 0x835339f4UL, 0x9c845f8bUL, 0xbdf9283bUL, 0x1ff897ffUL,
-    0xde05980fUL, 0xef2f118bUL, 0x5a0a6d1fUL, 0x6d367ecfUL, 0x27cb09b7UL,
-    0x4f463f66UL, 0x9e5fea2dUL, 0x7527bac7UL, 0xebe5f17bUL, 0x3d0739f7UL,
-    0x8a5292eaUL, 0x6bfb5fb1UL, 0x1f8d5d08UL, 0x56033046UL, 0xfc7b6babUL,
-    0xf0cfbc21UL
-};
-
-ALIGNED_(8) juint _PI_4[] =
-{
-    0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
-};
-
-ALIGNED_(8) juint _PI32INV[] =
-{
-    0x6dc9c883UL, 0x40245f30UL
-};
-
-ALIGNED_(8) juint _SHIFTER[] =
-{
-    0x00000000UL, 0x43380000UL
-};
-
-ALIGNED_(8) juint _SIGN_MASK[] =
-{
-    0x00000000UL, 0x80000000UL
-};
-
-ALIGNED_(8) juint _P_3[] =
-{
-    0x2e037073UL, 0x3b63198aUL
-};
-
-ALIGNED_(8) juint _ALL_ONES[] =
-{
-    0xffffffffUL, 0x3fefffffUL
-};
-
-ALIGNED_(8) juint _TWO_POW_55[] =
-{
-    0x00000000UL, 0x43600000UL
-};
-
-ALIGNED_(8) juint _TWO_POW_M55[] =
-{
-    0x00000000UL, 0x3c800000ULL
-};
-
-ALIGNED_(8) juint _P_1[] =
-{
-    0x54400000UL, 0x3fb921fbUL
-};
-
-ALIGNED_(8) juint _NEG_ZERO[] =
-{
-    0x00000000UL, 0x80000000UL
-};
-
-void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
-  Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1;
-  Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1;
-  Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1;
-  Label L_2TAG_PACKET_13_0_1, L_2TAG_PACKET_14_0_1;
-  Label L_2TAG_PACKET_12_0_1, B1_1, B1_2, B1_4, start;
-
-  assert_different_registers(tmp1, tmp2, tmp3, tmp4, eax, ebx, ecx, edx);
-  address ONEHALF = (address)_ONEHALF;
-  address P_2 = (address)_P_2;
-  address SC_4 = (address)_SC_4;
-  address Ctable = (address)_Ctable;
-  address SC_2 = (address)_SC_2;
-  address SC_3 = (address)_SC_3;
-  address SC_1 = (address)_SC_1;
-  address PI_INV_TABLE = (address)_PI_INV_TABLE;
-  address PI_4 = (address)_PI_4;
-  address PI32INV = (address)_PI32INV;
-  address SHIFTER = (address)_SHIFTER;
-  address SIGN_MASK = (address)_SIGN_MASK;
-  address P_3 = (address)_P_3;
-  address ALL_ONES = (address)_ALL_ONES;
-  address TWO_POW_55 = (address)_TWO_POW_55;
-  address TWO_POW_M55 = (address)_TWO_POW_M55;
-  address P_1 = (address)_P_1;
-  address NEG_ZERO = (address)_NEG_ZERO;
-
-  bind(start);
-  push(rbx);
-  subq(rsp, 16);
-  movsd(Address(rsp, 8), xmm0);
-  movl(eax, Address(rsp, 12));
-  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
-  movq(xmm2, ExternalAddress(SHIFTER));    //0x00000000UL, 0x43380000UL
-  andl(eax, 2147418112);
-  subl(eax, 808452096);
-  cmpl(eax, 281346048);
-  jcc(Assembler::above, L_2TAG_PACKET_0_0_1);
-  mulsd(xmm1, xmm0);
-  movdqu(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
-  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
-  pand(xmm4, xmm0);
-  por(xmm5, xmm4);
-  addpd(xmm1, xmm5);
-  cvttsd2sil(edx, xmm1);
-  cvtsi2sdl(xmm1, edx);
-  movdqu(xmm6, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
-  mov64(r8, 0x3fb921fb54400000);
-  movdq(xmm3, r8);
-  movdqu(xmm5, ExternalAddress(SC_4));    //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
-  pshufd(xmm4, xmm0, 68);
-  mulsd(xmm3, xmm1);
-  movddup(xmm1, xmm1);
-  andl(edx, 63);
-  shll(edx, 5);
-  lea(rax, ExternalAddress(Ctable));
-  addq(rax, rdx);
-  mulpd(xmm6, xmm1);
-  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
-  subsd(xmm4, xmm3);
-  movq(xmm7, Address(rax, 8));
-  subsd(xmm0, xmm3);
-  movddup(xmm3, xmm4);
-  subsd(xmm4, xmm6);
-  pshufd(xmm0, xmm0, 68);
-  movdqu(xmm2, Address(rax, 0));
-  mulpd(xmm5, xmm0);
-  subpd(xmm0, xmm6);
-  mulsd(xmm7, xmm4);
-  subsd(xmm3, xmm4);
-  mulpd(xmm5, xmm0);
-  mulpd(xmm0, xmm0);
-  subsd(xmm3, xmm6);
-  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
-  subsd(xmm1, xmm3);
-  movq(xmm3, Address(rax, 24));
-  addsd(xmm2, xmm3);
-  subsd(xmm7, xmm2);
-  mulsd(xmm2, xmm4);
-  mulpd(xmm6, xmm0);
-  mulsd(xmm3, xmm4);
-  mulpd(xmm2, xmm0);
-  mulpd(xmm0, xmm0);
-  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
-  mulsd(xmm4, Address(rax, 0));
-  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
-  mulpd(xmm5, xmm0);
-  movdqu(xmm0, xmm3);
-  addsd(xmm3, Address(rax, 8));
-  mulpd(xmm1, xmm7);
-  movdqu(xmm7, xmm4);
-  addsd(xmm4, xmm3);
-  addpd(xmm6, xmm5);
-  movq(xmm5, Address(rax, 8));
-  subsd(xmm5, xmm3);
-  subsd(xmm3, xmm4);
-  addsd(xmm1, Address(rax, 16));
-  mulpd(xmm6, xmm2);
-  addsd(xmm5, xmm0);
-  addsd(xmm3, xmm7);
-  addsd(xmm1, xmm5);
-  addsd(xmm1, xmm3);
-  addsd(xmm1, xmm6);
-  unpckhpd(xmm6, xmm6);
-  movdqu(xmm0, xmm4);
-  addsd(xmm1, xmm6);
-  addsd(xmm0, xmm1);
-  jmp(B1_4);
-
-  bind(L_2TAG_PACKET_0_0_1);
-  jcc(Assembler::greater, L_2TAG_PACKET_1_0_1);
-  shrl(eax, 20);
-  cmpl(eax, 3325);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_2_0_1);
-  mulsd(xmm0, ExternalAddress(ALL_ONES));    //0xffffffffUL, 0x3fefffffUL
-  jmp(B1_4);
-
-  bind(L_2TAG_PACKET_2_0_1);
-  movq(xmm3, ExternalAddress(TWO_POW_55));    //0x00000000UL, 0x43600000UL
-  mulsd(xmm3, xmm0);
-  subsd(xmm3, xmm0);
-  mulsd(xmm3, ExternalAddress(TWO_POW_M55));    //0x00000000UL, 0x3c800000UL
-  jmp(B1_4);
-
-  bind(L_2TAG_PACKET_1_0_1);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  cmpl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_3_0_1);
-  pextrw(ecx, xmm0, 3);
-  andl(ecx, 32752);
-  subl(ecx, 16224);
-  shrl(ecx, 7);
-  andl(ecx, 65532);
-  lea(r11, ExternalAddress(PI_INV_TABLE));
-  addq(rcx, r11);
-  movdq(rax, xmm0);
-  movl(r10, Address(rcx, 20));
-  movl(r8, Address(rcx, 24));
-  movl(edx, eax);
-  shrq(rax, 21);
-  orl(eax, INT_MIN);
-  shrl(eax, 11);
-  movl(r9, r10);
-  imulq(r10, rdx);
-  imulq(r9, rax);
-  imulq(r8, rax);
-  movl(rsi, Address(rcx, 16));
-  movl(rdi, Address(rcx, 12));
-  movl(r11, r10);
-  shrq(r10, 32);
-  addq(r9, r10);
-  addq(r11, r8);
-  movl(r8, r11);
-  shrq(r11, 32);
-  addq(r9, r11);
-  movl(r10, rsi);
-  imulq(rsi, rdx);
-  imulq(r10, rax);
-  movl(r11, rdi);
-  imulq(rdi, rdx);
-  movl(ebx, rsi);
-  shrq(rsi, 32);
-  addq(r9, rbx);
-  movl(ebx, r9);
-  shrq(r9, 32);
-  addq(r10, rsi);
-  addq(r10, r9);
-  shlq(rbx, 32);
-  orq(r8, rbx);
-  imulq(r11, rax);
-  movl(r9, Address(rcx, 8));
-  movl(rsi, Address(rcx, 4));
-  movl(ebx, rdi);
-  shrq(rdi, 32);
-  addq(r10, rbx);
-  movl(ebx, r10);
-  shrq(r10, 32);
-  addq(r11, rdi);
-  addq(r11, r10);
-  movq(rdi, r9);
-  imulq(r9, rdx);
-  imulq(rdi, rax);
-  movl(r10, r9);
-  shrq(r9, 32);
-  addq(r11, r10);
-  movl(r10, r11);
-  shrq(r11, 32);
-  addq(rdi, r9);
-  addq(rdi, r11);
-  movq(r9, rsi);
-  imulq(rsi, rdx);
-  imulq(r9, rax);
-  shlq(r10, 32);
-  orq(r10, rbx);
-  movl(eax, Address(rcx, 0));
-  movl(r11, rsi);
-  shrq(rsi, 32);
-  addq(rdi, r11);
-  movl(r11, rdi);
-  shrq(rdi, 32);
-  addq(r9, rsi);
-  addq(r9, rdi);
-  imulq(rdx, rax);
-  pextrw(ebx, xmm0, 3);
-  lea(rdi, ExternalAddress(PI_INV_TABLE));
-  subq(rcx, rdi);
-  addl(ecx, ecx);
-  addl(ecx, ecx);
-  addl(ecx, ecx);
-  addl(ecx, 19);
-  movl(rsi, 32768);
-  andl(rsi, ebx);
-  shrl(ebx, 4);
-  andl(ebx, 2047);
-  subl(ebx, 1023);
-  subl(ecx, ebx);
-  addq(r9, rdx);
-  movl(edx, ecx);
-  addl(edx, 32);
-  cmpl(ecx, 1);
-  jcc(Assembler::less, L_2TAG_PACKET_4_0_1);
-  negl(ecx);
-  addl(ecx, 29);
-  shll(r9);
-  movl(rdi, r9);
-  andl(r9, 536870911);
-  testl(r9, 268435456);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_5_0_1);
-  shrl(r9);
-  movl(ebx, 0);
-  shlq(r9, 32);
-  orq(r9, r11);
-
-  bind(L_2TAG_PACKET_6_0_1);
-
-  bind(L_2TAG_PACKET_7_0_1);
-
-  cmpq(r9, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_8_0_1);
-
-  bind(L_2TAG_PACKET_9_0_1);
-  bsrq(r11, r9);
-  movl(ecx, 29);
-  subl(ecx, r11);
-  jcc(Assembler::lessEqual, L_2TAG_PACKET_10_0_1);
-  shlq(r9);
-  movq(rax, r10);
-  shlq(r10);
-  addl(edx, ecx);
-  negl(ecx);
-  addl(ecx, 64);
-  shrq(rax);
-  shrq(r8);
-  orq(r9, rax);
-  orq(r10, r8);
-
-  bind(L_2TAG_PACKET_11_0_1);
-  cvtsi2sdq(xmm0, r9);
-  shrq(r10, 1);
-  cvtsi2sdq(xmm3, r10);
-  xorpd(xmm4, xmm4);
-  shll(edx, 4);
-  negl(edx);
-  addl(edx, 16368);
-  orl(edx, rsi);
-  xorl(edx, ebx);
-  pinsrw(xmm4, edx, 3);
-  movq(xmm2, ExternalAddress(PI_4));    //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
-  movq(xmm6, ExternalAddress(8 + PI_4));    //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
-  xorpd(xmm5, xmm5);
-  subl(edx, 1008);
-  pinsrw(xmm5, edx, 3);
-  mulsd(xmm0, xmm4);
-  shll(rsi, 16);
-  sarl(rsi, 31);
-  mulsd(xmm3, xmm5);
-  movdqu(xmm1, xmm0);
-  mulsd(xmm0, xmm2);
-  shrl(rdi, 29);
-  addsd(xmm1, xmm3);
-  mulsd(xmm3, xmm2);
-  addl(rdi, rsi);
-  xorl(rdi, rsi);
-  mulsd(xmm6, xmm1);
-  movl(eax, rdi);
-  addsd(xmm6, xmm3);
-  movdqu(xmm2, xmm0);
-  addsd(xmm0, xmm6);
-  subsd(xmm2, xmm0);
-  addsd(xmm6, xmm2);
-
-  bind(L_2TAG_PACKET_12_0_1);
-  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
-  mulsd(xmm1, xmm0);
-  movq(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
-  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
-  pand(xmm4, xmm0);
-  por(xmm5, xmm4);
-  addpd(xmm1, xmm5);
-  cvttsd2sil(edx, xmm1);
-  cvtsi2sdl(xmm1, edx);
-  movq(xmm3, ExternalAddress(P_1));    //0x54400000UL, 0x3fb921fbUL
-  movdqu(xmm2, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
-  mulsd(xmm3, xmm1);
-  unpcklpd(xmm1, xmm1);
-  shll(eax, 3);
-  addl(edx, 1865216);
-  movdqu(xmm4, xmm0);
-  addl(edx, eax);
-  andl(edx, 63);
-  movdqu(xmm5, ExternalAddress(SC_4));    //0x54400000UL, 0x3fb921fbUL
-  lea(rax, ExternalAddress(Ctable));
-  shll(edx, 5);
-  addq(rax, rdx);
-  mulpd(xmm2, xmm1);
-  subsd(xmm0, xmm3);
-  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
-  subsd(xmm4, xmm3);
-  movq(xmm7, Address(rax, 8));
-  unpcklpd(xmm0, xmm0);
-  movdqu(xmm3, xmm4);
-  subsd(xmm4, xmm2);
-  mulpd(xmm5, xmm0);
-  subpd(xmm0, xmm2);
-  mulsd(xmm7, xmm4);
-  subsd(xmm3, xmm4);
-  mulpd(xmm5, xmm0);
-  mulpd(xmm0, xmm0);
-  subsd(xmm3, xmm2);
-  movdqu(xmm2, Address(rax, 0));
-  subsd(xmm1, xmm3);
-  movq(xmm3, Address(rax, 24));
-  addsd(xmm2, xmm3);
-  subsd(xmm7, xmm2);
-  subsd(xmm1, xmm6);
-  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
-  mulsd(xmm2, xmm4);
-  mulpd(xmm6, xmm0);
-  mulsd(xmm3, xmm4);
-  mulpd(xmm2, xmm0);
-  mulpd(xmm0, xmm0);
-  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
-  mulsd(xmm4, Address(rax, 0));
-  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
-  mulpd(xmm5, xmm0);
-  movdqu(xmm0, xmm3);
-  addsd(xmm3, Address(rax, 8));
-  mulpd(xmm1, xmm7);
-  movdqu(xmm7, xmm4);
-  addsd(xmm4, xmm3);
-  addpd(xmm6, xmm5);
-  movq(xmm5, Address(rax, 8));
-  subsd(xmm5, xmm3);
-  subsd(xmm3, xmm4);
-  addsd(xmm1, Address(rax, 16));
-  mulpd(xmm6, xmm2);
-  addsd(xmm5, xmm0);
-  addsd(xmm3, xmm7);
-  addsd(xmm1, xmm5);
-  addsd(xmm1, xmm3);
-  addsd(xmm1, xmm6);
-  unpckhpd(xmm6, xmm6);
-  movdqu(xmm0, xmm4);
-  addsd(xmm1, xmm6);
-  addsd(xmm0, xmm1);
-  jmp(B1_4);
-
-  bind(L_2TAG_PACKET_8_0_1);
-  addl(edx, 64);
-  movq(r9, r10);
-  movq(r10, r8);
-  movl(r8, 0);
-  cmpq(r9, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1);
-  addl(edx, 64);
-  movq(r9, r10);
-  movq(r10, r8);
-  cmpq(r9, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1);
-  xorpd(xmm0, xmm0);
-  xorpd(xmm6, xmm6);
-  jmp(L_2TAG_PACKET_12_0_1);
-
-  bind(L_2TAG_PACKET_10_0_1);
-  jcc(Assembler::equal, L_2TAG_PACKET_11_0_1);
-  negl(ecx);
-  shrq(r10);
-  movq(rax, r9);
-  shrq(r9);
-  subl(edx, ecx);
-  negl(ecx);
-  addl(ecx, 64);
-  shlq(rax);
-  orq(r10, rax);
-  jmp(L_2TAG_PACKET_11_0_1);
-
-  bind(L_2TAG_PACKET_4_0_1);
-  negl(ecx);
-  shlq(r9, 32);
-  orq(r9, r11);
-  shlq(r9);
-  movq(rdi, r9);
-  testl(r9, INT_MIN);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_13_0_1);
-  shrl(r9);
-  movl(ebx, 0);
-  shrq(rdi, 3);
-  jmp(L_2TAG_PACKET_7_0_1);
-
-  bind(L_2TAG_PACKET_5_0_1);
-  shrl(r9);
-  movl(ebx, 536870912);
-  shrl(ebx);
-  shlq(r9, 32);
-  orq(r9, r11);
-  shlq(rbx, 32);
-  addl(rdi, 536870912);
-  movl(rcx, 0);
-  movl(r11, 0);
-  subq(rcx, r8);
-  sbbq(r11, r10);
-  sbbq(rbx, r9);
-  movq(r8, rcx);
-  movq(r10, r11);
-  movq(r9, rbx);
-  movl(ebx, 32768);
-  jmp(L_2TAG_PACKET_6_0_1);
-
-  bind(L_2TAG_PACKET_13_0_1);
-  shrl(r9);
-  mov64(rbx, 0x100000000);
-  shrq(rbx);
-  movl(rcx, 0);
-  movl(r11, 0);
-  subq(rcx, r8);
-  sbbq(r11, r10);
-  sbbq(rbx, r9);
-  movq(r8, rcx);
-  movq(r10, r11);
-  movq(r9, rbx);
-  movl(ebx, 32768);
-  shrq(rdi, 3);
-  addl(rdi, 536870912);
-  jmp(L_2TAG_PACKET_7_0_1);
-
-  bind(L_2TAG_PACKET_3_0_1);
-  movq(xmm0, Address(rsp, 8));
-  mulsd(xmm0, ExternalAddress(NEG_ZERO));    //0x00000000UL, 0x80000000UL
-  movq(Address(rsp, 0), xmm0);
-
-  bind(L_2TAG_PACKET_14_0_1);
-
-  bind(B1_4);
-  addq(rsp, 16);
-  pop(rbx);
-}
-
-/******************************************************************************/
-//                     ALGORITHM DESCRIPTION - COS()
-//                     ---------------------
-//
-//     1. RANGE REDUCTION
-//
-//     We perform an initial range reduction from X to r with
-//
-//          X =~= N * pi/32 + r
-//
-//     so that |r| <= pi/64 + epsilon. We restrict inputs to those
-//     where |N| <= 932560. Beyond this, the range reduction is
-//     insufficiently accurate. For extremely small inputs,
-//     denormalization can occur internally, impacting performance.
-//     This means that the main path is actually only taken for
-//     2^-252 <= |X| < 90112.
-//
-//     To avoid branches, we perform the range reduction to full
-//     accuracy each time.
-//
-//          X - N * (P_1 + P_2 + P_3)
-//
-//     where P_1 and P_2 are 32-bit numbers (so multiplication by N
-//     is exact) and P_3 is a 53-bit number. Together, these
-//     approximate pi well enough for all cases in the restricted
-//     range.
-//
-//     The main reduction sequence is:
-//
-//             y = 32/pi * x
-//             N = integer(y)
-//     (computed by adding and subtracting off SHIFTER)
-//
-//             m_1 = N * P_1
-//             m_2 = N * P_2
-//             r_1 = x - m_1
-//             r = r_1 - m_2
-//     (this r can be used for most of the calculation)
-//
-//             c_1 = r_1 - r
-//             m_3 = N * P_3
-//             c_2 = c_1 - m_2
-//             c = c_2 - m_3
-//
-//     2. MAIN ALGORITHM
-//
-//     The algorithm uses a table lookup based on B = M * pi / 32
-//     where M = N mod 64. The stored values are:
-//       sigma             closest power of 2 to cos(B)
-//       C_hl              53-bit cos(B) - sigma
-//       S_hi + S_lo       2 * 53-bit sin(B)
-//
-//     The computation is organized as follows:
-//
-//          sin(B + r + c) = [sin(B) + sigma * r] +
-//                           r * (cos(B) - sigma) +
-//                           sin(B) * [cos(r + c) - 1] +
-//                           cos(B) * [sin(r + c) - r]
-//
-//     which is approximately:
-//
-//          [S_hi + sigma * r] +
-//          C_hl * r +
-//          S_lo + S_hi * [(cos(r) - 1) - r * c] +
-//          (C_hl + sigma) * [(sin(r) - r) + c]
-//
-//     and this is what is actually computed. We separate this sum
-//     into four parts:
-//
-//          hi + med + pols + corr
-//
-//     where
-//
-//          hi       = S_hi + sigma r
-//          med      = C_hl * r
-//          pols     = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r)
-//          corr     = S_lo + c * ((C_hl + sigma) - S_hi * r)
-//
-//     3. POLYNOMIAL
-//
-//     The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) *
-//     (sin(r) - r) can be rearranged freely, since it is quite
-//     small, so we exploit parallelism to the fullest.
-//
-//          psc4       =   SC_4 * r_1
-//          msc4       =   psc4 * r
-//          r2         =   r * r
-//          msc2       =   SC_2 * r2
-//          r4         =   r2 * r2
-//          psc3       =   SC_3 + msc4
-//          psc1       =   SC_1 + msc2
-//          msc3       =   r4 * psc3
-//          sincospols =   psc1 + msc3
-//          pols       =   sincospols *
-//                         <S_hi * r^2 | (C_hl + sigma) * r^3>
-//
-//     4. CORRECTION TERM
-//
-//     This is where the "c" component of the range reduction is
-//     taken into account; recall that just "r" is used for most of
-//     the calculation.
-//
-//          -c   = m_3 - c_2
-//          -d   = S_hi * r - (C_hl + sigma)
-//          corr = -c * -d + S_lo
-//
-//     5. COMPENSATED SUMMATIONS
-//
-//     The two successive compensated summations add up the high
-//     and medium parts, leaving just the low parts to add up at
-//     the end.
-//
-//          rs        =  sigma * r
-//          res_int   =  S_hi + rs
-//          k_0       =  S_hi - res_int
-//          k_2       =  k_0 + rs
-//          med       =  C_hl * r
-//          res_hi    =  res_int + med
-//          k_1       =  res_int - res_hi
-//          k_3       =  k_1 + med
-//
-//     6. FINAL SUMMATION
-//
-//     We now add up all the small parts:
-//
-//          res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3
-//
-//     Now the overall result is just:
-//
-//          res_hi + res_lo
-//
-//     7. SMALL ARGUMENTS
-//
-//     Inputs with |X| < 2^-252 are treated specially as
-//     1 - |x|.
-//
-// Special cases:
-//  cos(NaN) = quiet NaN, and raise invalid exception
-//  cos(INF) = NaN and raise invalid exception
-//  cos(0) = 1
-//
-/******************************************************************************/
-
-ALIGNED_(8) juint _ONE[] =
-{
-    0x00000000UL, 0x3ff00000UL
-};
-
-void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r8, Register r9, Register r10, Register r11) {
-  Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1;
-  Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1;
-  Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1;
-  Label L_2TAG_PACKET_12_0_1, L_2TAG_PACKET_13_0_1, B1_2, B1_3, B1_4, B1_5, start;
-
-  assert_different_registers(r8, r9, r10, r11, eax, ecx, edx);
-
-  address ONEHALF = (address)_ONEHALF;
-  address P_2 = (address)_P_2;
-  address SC_4 = (address)_SC_4;
-  address Ctable = (address)_Ctable;
-  address SC_2 = (address)_SC_2;
-  address SC_3 = (address)_SC_3;
-  address SC_1 = (address)_SC_1;
-  address PI_INV_TABLE = (address)_PI_INV_TABLE;
-  address PI_4 = (address)_PI_4;
-  address PI32INV = (address)_PI32INV;
-  address SIGN_MASK = (address)_SIGN_MASK;
-  address P_1 = (address)_P_1;
-  address P_3 = (address)_P_3;
-  address ONE = (address)_ONE;
-  address NEG_ZERO = (address)_NEG_ZERO;
-
-  bind(start);
-  push(rbx);
-  subq(rsp, 16);
-  movsd(Address(rsp, 8), xmm0);
-
-  bind(B1_2);
-  movl(eax, Address(rsp, 12));
-  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
-  andl(eax, 2147418112);
-  subl(eax, 808452096);
-  cmpl(eax, 281346048);
-  jcc(Assembler::above, L_2TAG_PACKET_0_0_1);
-  mulsd(xmm1, xmm0);
-  movdqu(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
-  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
-  pand(xmm4, xmm0);
-  por(xmm5, xmm4);
-  addpd(xmm1, xmm5);
-  cvttsd2sil(edx, xmm1);
-  cvtsi2sdl(xmm1, edx);
-  movdqu(xmm2, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
-  movq(xmm3, ExternalAddress(P_1));    //0x54400000UL, 0x3fb921fbUL
-  mulsd(xmm3, xmm1);
-  unpcklpd(xmm1, xmm1);
-  addq(rdx, 1865232);
-  movdqu(xmm4, xmm0);
-  andq(rdx, 63);
-  movdqu(xmm5, ExternalAddress(SC_4));    //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
-  lea(rax, ExternalAddress(Ctable));
-  shlq(rdx, 5);
-  addq(rax, rdx);
-  mulpd(xmm2, xmm1);
-  subsd(xmm0, xmm3);
-  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
-  subsd(xmm4, xmm3);
-  movq(xmm7, Address(rax, 8));
-  unpcklpd(xmm0, xmm0);
-  movdqu(xmm3, xmm4);
-  subsd(xmm4, xmm2);
-  mulpd(xmm5, xmm0);
-  subpd(xmm0, xmm2);
-  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
-  mulsd(xmm7, xmm4);
-  subsd(xmm3, xmm4);
-  mulpd(xmm5, xmm0);
-  mulpd(xmm0, xmm0);
-  subsd(xmm3, xmm2);
-  movdqu(xmm2, Address(rax, 0));
-  subsd(xmm1, xmm3);
-  movq(xmm3, Address(rax, 24));
-  addsd(xmm2, xmm3);
-  subsd(xmm7, xmm2);
-  mulsd(xmm2, xmm4);
-  mulpd(xmm6, xmm0);
-  mulsd(xmm3, xmm4);
-  mulpd(xmm2, xmm0);
-  mulpd(xmm0, xmm0);
-  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
-  mulsd(xmm4, Address(rax, 0));
-  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
-  mulpd(xmm5, xmm0);
-  movdqu(xmm0, xmm3);
-  addsd(xmm3, Address(rax, 8));
-  mulpd(xmm1, xmm7);
-  movdqu(xmm7, xmm4);
-  addsd(xmm4, xmm3);
-  addpd(xmm6, xmm5);
-  movq(xmm5, Address(rax, 8));
-  subsd(xmm5, xmm3);
-  subsd(xmm3, xmm4);
-  addsd(xmm1, Address(rax, 16));
-  mulpd(xmm6, xmm2);
-  addsd(xmm0, xmm5);
-  addsd(xmm3, xmm7);
-  addsd(xmm0, xmm1);
-  addsd(xmm0, xmm3);
-  addsd(xmm0, xmm6);
-  unpckhpd(xmm6, xmm6);
-  addsd(xmm0, xmm6);
-  addsd(xmm0, xmm4);
-  jmp(B1_4);
-
-  bind(L_2TAG_PACKET_0_0_1);
-  jcc(Assembler::greater, L_2TAG_PACKET_1_0_1);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32767);
-  pinsrw(xmm0, eax, 3);
-  movq(xmm1, ExternalAddress(ONE));    //0x00000000UL, 0x3ff00000UL
-  subsd(xmm1, xmm0);
-  movdqu(xmm0, xmm1);
-  jmp(B1_4);
-
-  bind(L_2TAG_PACKET_1_0_1);
-  pextrw(eax, xmm0, 3);
-  andl(eax, 32752);
-  cmpl(eax, 32752);
-  jcc(Assembler::equal, L_2TAG_PACKET_2_0_1);
-  pextrw(ecx, xmm0, 3);
-  andl(ecx, 32752);
-  subl(ecx, 16224);
-  shrl(ecx, 7);
-  andl(ecx, 65532);
-  lea(r11, ExternalAddress(PI_INV_TABLE));
-  addq(rcx, r11);
-  movdq(rax, xmm0);
-  movl(r10, Address(rcx, 20));
-  movl(r8, Address(rcx, 24));
-  movl(edx, eax);
-  shrq(rax, 21);
-  orl(eax, INT_MIN);
-  shrl(eax, 11);
-  movl(r9, r10);
-  imulq(r10, rdx);
-  imulq(r9, rax);
-  imulq(r8, rax);
-  movl(rsi, Address(rcx, 16));
-  movl(rdi, Address(rcx, 12));
-  movl(r11, r10);
-  shrq(r10, 32);
-  addq(r9, r10);
-  addq(r11, r8);
-  movl(r8, r11);
-  shrq(r11, 32);
-  addq(r9, r11);
-  movl(r10, rsi);
-  imulq(rsi, rdx);
-  imulq(r10, rax);
-  movl(r11, rdi);
-  imulq(rdi, rdx);
-  movl(rbx, rsi);
-  shrq(rsi, 32);
-  addq(r9, rbx);
-  movl(rbx, r9);
-  shrq(r9, 32);
-  addq(r10, rsi);
-  addq(r10, r9);
-  shlq(rbx, 32);
-  orq(r8, rbx);
-  imulq(r11, rax);
-  movl(r9, Address(rcx, 8));
-  movl(rsi, Address(rcx, 4));
-  movl(rbx, rdi);
-  shrq(rdi, 32);
-  addq(r10, rbx);
-  movl(rbx, r10);
-  shrq(r10, 32);
-  addq(r11, rdi);
-  addq(r11, r10);
-  movq(rdi, r9);
-  imulq(r9, rdx);
-  imulq(rdi, rax);
-  movl(r10, r9);
-  shrq(r9, 32);
-  addq(r11, r10);
-  movl(r10, r11);
-  shrq(r11, 32);
-  addq(rdi, r9);
-  addq(rdi, r11);
-  movq(r9, rsi);
-  imulq(rsi, rdx);
-  imulq(r9, rax);
-  shlq(r10, 32);
-  orq(r10, rbx);
-  movl(eax, Address(rcx, 0));
-  movl(r11, rsi);
-  shrq(rsi, 32);
-  addq(rdi, r11);
-  movl(r11, rdi);
-  shrq(rdi, 32);
-  addq(r9, rsi);
-  addq(r9, rdi);
-  imulq(rdx, rax);
-  pextrw(rbx, xmm0, 3);
-  lea(rdi, ExternalAddress(PI_INV_TABLE));
-  subq(rcx, rdi);
-  addl(ecx, ecx);
-  addl(ecx, ecx);
-  addl(ecx, ecx);
-  addl(ecx, 19);
-  movl(rsi, 32768);
-  andl(rsi, rbx);
-  shrl(rbx, 4);
-  andl(rbx, 2047);
-  subl(rbx, 1023);
-  subl(ecx, rbx);
-  addq(r9, rdx);
-  movl(edx, ecx);
-  addl(edx, 32);
-  cmpl(ecx, 1);
-  jcc(Assembler::less, L_2TAG_PACKET_3_0_1);
-  negl(ecx);
-  addl(ecx, 29);
-  shll(r9);
-  movl(rdi, r9);
-  andl(r9, 536870911);
-  testl(r9, 268435456);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_4_0_1);
-  shrl(r9);
-  movl(rbx, 0);
-  shlq(r9, 32);
-  orq(r9, r11);
-
-  bind(L_2TAG_PACKET_5_0_1);
-
-  bind(L_2TAG_PACKET_6_0_1);
-  cmpq(r9, 0);
-  jcc(Assembler::equal, L_2TAG_PACKET_7_0_1);
-
-  bind(L_2TAG_PACKET_8_0_1);
-  bsrq(r11, r9);
-  movl(ecx, 29);
-  subl(ecx, r11);
-  jcc(Assembler::lessEqual, L_2TAG_PACKET_9_0_1);
-  shlq(r9);
-  movq(rax, r10);
-  shlq(r10);
-  addl(edx, ecx);
-  negl(ecx);
-  addl(ecx, 64);
-  shrq(rax);
-  shrq(r8);
-  orq(r9, rax);
-  orq(r10, r8);
-
-  bind(L_2TAG_PACKET_10_0_1);
-  cvtsi2sdq(xmm0, r9);
-  shrq(r10, 1);
-  cvtsi2sdq(xmm3, r10);
-  xorpd(xmm4, xmm4);
-  shll(edx, 4);
-  negl(edx);
-  addl(edx, 16368);
-  orl(edx, rsi);
-  xorl(edx, rbx);
-  pinsrw(xmm4, edx, 3);
-  movq(xmm2, ExternalAddress(PI_4));    //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
-  movq(xmm6, ExternalAddress(8 + PI_4));    //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
-  xorpd(xmm5, xmm5);
-  subl(edx, 1008);
-  pinsrw(xmm5, edx, 3);
-  mulsd(xmm0, xmm4);
-  shll(rsi, 16);
-  sarl(rsi, 31);
-  mulsd(xmm3, xmm5);
-  movdqu(xmm1, xmm0);
-  mulsd(xmm0, xmm2);
-  shrl(rdi, 29);
-  addsd(xmm1, xmm3);
-  mulsd(xmm3, xmm2);
-  addl(rdi, rsi);
-  xorl(rdi, rsi);
-  mulsd(xmm6, xmm1);
-  movl(eax, rdi);
-  addsd(xmm6, xmm3);
-  movdqu(xmm2, xmm0);
-  addsd(xmm0, xmm6);
-  subsd(xmm2, xmm0);
-  addsd(xmm6, xmm2);
-
-  bind(L_2TAG_PACKET_11_0_1);
-  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
-  mulsd(xmm1, xmm0);
-  movq(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
-  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
-  pand(xmm4, xmm0);
-  por(xmm5, xmm4);
-  addpd(xmm1, xmm5);
-  cvttsd2siq(rdx, xmm1);
-  cvtsi2sdq(xmm1, rdx);
-  movq(xmm3, ExternalAddress(P_1));    //0x54400000UL, 0x3fb921fbUL
-  movdqu(xmm2, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
-  mulsd(xmm3, xmm1);
-  unpcklpd(xmm1, xmm1);
-  shll(eax, 3);
-  addl(edx, 1865232);
-  movdqu(xmm4, xmm0);
-  addl(edx, eax);
-  andl(edx, 63);
-  movdqu(xmm5, ExternalAddress(SC_4));    //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
-  lea(rax, ExternalAddress(Ctable));
-  shll(edx, 5);
-  addq(rax, rdx);
-  mulpd(xmm2, xmm1);
-  subsd(xmm0, xmm3);
-  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
-  subsd(xmm4, xmm3);
-  movq(xmm7, Address(rax, 8));
-  unpcklpd(xmm0, xmm0);
-  movdqu(xmm3, xmm4);
-  subsd(xmm4, xmm2);
-  mulpd(xmm5, xmm0);
-  subpd(xmm0, xmm2);
-  mulsd(xmm7, xmm4);
-  subsd(xmm3, xmm4);
-  mulpd(xmm5, xmm0);
-  mulpd(xmm0, xmm0);
-  subsd(xmm3, xmm2);
-  movdqu(xmm2, Address(rax, 0));
-  subsd(xmm1, xmm3);
-  movq(xmm3, Address(rax, 24));
-  addsd(xmm2, xmm3);
-  subsd(xmm7, xmm2);
-  subsd(xmm1, xmm6);
-  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
-  mulsd(xmm2, xmm4);
-  mulpd(xmm6, xmm0);
-  mulsd(xmm3, xmm4);
-  mulpd(xmm2, xmm0);
-  mulpd(xmm0, xmm0);
-  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
-  mulsd(xmm4, Address(rax, 0));
-  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
-  mulpd(xmm5, xmm0);
-  movdqu(xmm0, xmm3);
-  addsd(xmm3, Address(rax, 8));
-  mulpd(xmm1, xmm7);
-  movdqu(xmm7, xmm4);
-  addsd(xmm4, xmm3);
-  addpd(xmm6, xmm5);
-  movq(xmm5, Address(rax, 8));
-  subsd(xmm5, xmm3);
-  subsd(xmm3, xmm4);
-  addsd(xmm1, Address(rax, 16));
-  mulpd(xmm6, xmm2);
-  addsd(xmm5, xmm0);
-  addsd(xmm3, xmm7);
-  addsd(xmm1, xmm5);
-  addsd(xmm1, xmm3);
-  addsd(xmm1, xmm6);
-  unpckhpd(xmm6, xmm6);
-  movdqu(xmm0, xmm4);
-  addsd(xmm1, xmm6);
-  addsd(xmm0, xmm1);
-  jmp(B1_4);
-
-  bind(L_2TAG_PACKET_7_0_1);
-  addl(edx, 64);
-  movq(r9, r10);
-  movq(r10, r8);
-  movl(r8, 0);
-  cmpq(r9, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1);
-  addl(edx, 64);
-  movq(r9, r10);
-  movq(r10, r8);
-  cmpq(r9, 0);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1);
-  xorpd(xmm0, xmm0);
-  xorpd(xmm6, xmm6);
-  jmp(L_2TAG_PACKET_11_0_1);
-
-  bind(L_2TAG_PACKET_9_0_1);
-  jcc(Assembler::equal, L_2TAG_PACKET_10_0_1);
-  negl(ecx);
-  shrq(r10);
-  movq(rax, r9);
-  shrq(r9);
-  subl(edx, ecx);
-  negl(ecx);
-  addl(ecx, 64);
-  shlq(rax);
-  orq(r10, rax);
-  jmp(L_2TAG_PACKET_10_0_1);
-  bind(L_2TAG_PACKET_3_0_1);
-  negl(ecx);
-  shlq(r9, 32);
-  orq(r9, r11);
-  shlq(r9);
-  movq(rdi, r9);
-  testl(r9, INT_MIN);
-  jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_1);
-  shrl(r9);
-  movl(rbx, 0);
-  shrq(rdi, 3);
-  jmp(L_2TAG_PACKET_6_0_1);
-
-  bind(L_2TAG_PACKET_4_0_1);
-  shrl(r9);
-  movl(rbx, 536870912);
-  shrl(rbx);
-  shlq(r9, 32);
-  orq(r9, r11);
-  shlq(rbx, 32);
-  addl(rdi, 536870912);
-  movl(rcx, 0);
-  movl(r11, 0);
-  subq(rcx, r8);
-  sbbq(r11, r10);
-  sbbq(rbx, r9);
-  movq(r8, rcx);
-  movq(r10, r11);
-  movq(r9, rbx);
-  movl(rbx, 32768);
-  jmp(L_2TAG_PACKET_5_0_1);
-
-  bind(L_2TAG_PACKET_12_0_1);
-  shrl(r9);
-  mov64(rbx, 0x100000000);
-  shrq(rbx);
-  movl(rcx, 0);
-  movl(r11, 0);
-  subq(rcx, r8);
-  sbbq(r11, r10);
-  sbbq(rbx, r9);
-  movq(r8, rcx);
-  movq(r10, r11);
-  movq(r9, rbx);
-  movl(rbx, 32768);
-  shrq(rdi, 3);
-  addl(rdi, 536870912);
-  jmp(L_2TAG_PACKET_6_0_1);
-
-  bind(L_2TAG_PACKET_2_0_1);
-  movsd(xmm0, Address(rsp, 8));
-  mulsd(xmm0, ExternalAddress(NEG_ZERO));    //0x00000000UL, 0x80000000UL
-  movq(Address(rsp, 0), xmm0);
-
-  bind(L_2TAG_PACKET_13_0_1);
-
-  bind(B1_4);
-  addq(rsp, 16);
-  pop(rbx);
-}
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp
index 7d2c73a..1a18af5 100644
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp
@@ -3399,6 +3399,18 @@
   }
 }
 
+void MacroAssembler::setvectmask(Register dst, Register src) {
+  Assembler::movl(dst, 1);
+  Assembler::shlxl(dst, dst, src);
+  Assembler::decl(dst);
+  Assembler::kmovdl(k1, dst);
+  Assembler::movl(dst, src);
+}
+
+void MacroAssembler::restorevectmask() {
+  Assembler::knotwl(k1, k0);
+}
+
 void MacroAssembler::movdbl(XMMRegister dst, AddressLiteral src) {
   if (reachable(src)) {
     if (UseXmmLoadAndClearUpper) {
@@ -4320,9 +4332,7 @@
   int nds_enc = nds->encoding();
   int src_enc = src->encoding();
   assert(dst_enc == nds_enc, "");
-  if (VM_Version::supports_avxonly() || VM_Version::supports_avx512bw()) {
-    Assembler::vpcmpeqb(dst, nds, src, vector_len);
-  } else if ((dst_enc < 16) && (src_enc < 16)) {
+  if ((dst_enc < 16) && (src_enc < 16)) {
     Assembler::vpcmpeqb(dst, nds, src, vector_len);
   } else if (src_enc < 16) {
     subptr(rsp, 64);
@@ -4360,9 +4370,7 @@
   int nds_enc = nds->encoding();
   int src_enc = src->encoding();
   assert(dst_enc == nds_enc, "");
-  if (VM_Version::supports_avxonly() || VM_Version::supports_avx512bw()) {
-    Assembler::vpcmpeqw(dst, nds, src, vector_len);
-  } else if ((dst_enc < 16) && (src_enc < 16)) {
+  if ((dst_enc < 16) && (src_enc < 16)) {
     Assembler::vpcmpeqw(dst, nds, src, vector_len);
   } else if (src_enc < 16) {
     subptr(rsp, 64);
@@ -6693,6 +6701,14 @@
 #endif // _LP64
 }
 
+void MacroAssembler::load_mirror(Register mirror, Register method) {
+  // get mirror
+  const int mirror_offset = in_bytes(Klass::java_mirror_offset());
+  movptr(mirror, Address(method, Method::const_offset()));
+  movptr(mirror, Address(mirror, ConstMethod::constants_offset()));
+  movptr(mirror, Address(mirror, ConstantPool::pool_holder_offset_in_bytes()));
+  movptr(mirror, Address(mirror, mirror_offset));
+}
 
 void MacroAssembler::load_klass(Register dst, Register src) {
 #ifdef _LP64
@@ -7318,7 +7334,7 @@
 
     decrementl(cnt1);     // Shift to next element
     cmpl(cnt1, cnt2);
-    jccb(Assembler::negative, RET_NOT_FOUND);  // Left less then substring
+    jcc(Assembler::negative, RET_NOT_FOUND);  // Left less then substring
 
     addptr(result, (1<<scale1));
 
@@ -7359,7 +7375,7 @@
 
   bind(RET_NOT_FOUND);
   movl(result, -1);
-  jmpb(EXIT);
+  jmp(EXIT);
 
   if (int_cnt2 > stride) {
     // This code is optimized for the case when whole substring
@@ -7367,7 +7383,7 @@
     bind(MATCH_SUBSTR_HEAD);
     pcmpestri(vec, Address(result, 0), mode);
     // Reload only string if does not match
-    jccb(Assembler::noOverflow, RELOAD_STR); // OF == 0
+    jcc(Assembler::noOverflow, RELOAD_STR); // OF == 0
 
     Label CONT_SCAN_SUBSTR;
     // Compare the rest of substring (> 8 chars).
@@ -7625,7 +7641,7 @@
     addl(cnt1, str1);
     decrementl(cnt1);   // Shift to next element
     cmpl(cnt1, cnt2);
-    jccb(Assembler::negative, RET_NOT_FOUND);  // Left less then substring
+    jcc(Assembler::negative, RET_NOT_FOUND);  // Left less then substring
 
     addptr(result, (1<<scale1));
   } // non constant
@@ -7730,7 +7746,7 @@
     } else {
       movdqu(vec, Address(str2, 0));
     }
-    jmpb(SCAN_SUBSTR);
+    jmp(SCAN_SUBSTR);
 
     bind(RET_FOUND_LONG);
     movptr(str1, Address(rsp, wordSize));
@@ -7763,9 +7779,9 @@
   movptr(result, str1);
   if (UseAVX >= 2) {
     cmpl(cnt1, stride);
-    jccb(Assembler::less, SCAN_TO_CHAR_LOOP);
+    jcc(Assembler::less, SCAN_TO_CHAR_LOOP);
     cmpl(cnt1, 2*stride);
-    jccb(Assembler::less, SCAN_TO_8_CHAR_INIT);
+    jcc(Assembler::less, SCAN_TO_8_CHAR_INIT);
     movdl(vec1, ch);
     vpbroadcastw(vec1, vec1);
     vpxor(vec2, vec2);
@@ -7791,9 +7807,9 @@
   bind(SCAN_TO_8_CHAR);
   cmpl(cnt1, stride);
   if (UseAVX >= 2) {
-    jccb(Assembler::less, SCAN_TO_CHAR);
+    jcc(Assembler::less, SCAN_TO_CHAR);
   } else {
-    jccb(Assembler::less, SCAN_TO_CHAR_LOOP);
+    jcc(Assembler::less, SCAN_TO_CHAR_LOOP);
     movdl(vec1, ch);
     pshuflw(vec1, vec1, 0x00);
     pshufd(vec1, vec1, 0);
@@ -8045,14 +8061,14 @@
     jcc(Assembler::notZero, VECTOR_NOT_EQUAL);
     addptr(result, stride2);
     subl(cnt2, stride2);
-    jccb(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP);
+    jcc(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP);
     // clean upper bits of YMM registers
     vpxor(vec1, vec1);
 
     // compare wide vectors tail
     bind(COMPARE_WIDE_TAIL);
     testptr(result, result);
-    jccb(Assembler::zero, LENGTH_DIFF_LABEL);
+    jcc(Assembler::zero, LENGTH_DIFF_LABEL);
 
     movl(result, stride2);
     movl(cnt2, result);
@@ -8076,7 +8092,7 @@
     bind(COMPARE_TAIL_LONG);
     movl(cnt2, result);
     cmpl(cnt2, stride);
-    jccb(Assembler::less, COMPARE_SMALL_STR);
+    jcc(Assembler::less, COMPARE_SMALL_STR);
 
     if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) {
       movdqu(vec1, Address(str1, 0));
@@ -8086,7 +8102,7 @@
     pcmpestri(vec1, Address(str2, 0), pcmpmask);
     jcc(Assembler::below, COMPARE_INDEX_CHAR);
     subptr(cnt2, stride);
-    jccb(Assembler::zero, LENGTH_DIFF_LABEL);
+    jcc(Assembler::zero, LENGTH_DIFF_LABEL);
     if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) {
       lea(str1, Address(str1, result, scale));
       lea(str2, Address(str2, result, scale));
@@ -8109,7 +8125,7 @@
     if (ae == StrIntrinsicNode::LL) {
       pcmpmask &= ~0x01;
     }
-    jccb(Assembler::zero, COMPARE_TAIL);
+    jcc(Assembler::zero, COMPARE_TAIL);
     if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) {
       lea(str1, Address(str1, result, scale));
       lea(str2, Address(str2, result, scale));
@@ -8148,7 +8164,7 @@
 
     // compare wide vectors tail
     testptr(result, result);
-    jccb(Assembler::zero, LENGTH_DIFF_LABEL);
+    jcc(Assembler::zero, LENGTH_DIFF_LABEL);
 
     movl(cnt2, stride);
     movl(result, stride);
@@ -8243,10 +8259,19 @@
 
 // Search for Non-ASCII character (Negative byte value) in a byte array,
 // return true if it has any and false otherwise.
+//   ..\jdk\src\java.base\share\classes\java\lang\StringCoding.java
+//   @HotSpotIntrinsicCandidate
+//   private static boolean hasNegatives(byte[] ba, int off, int len) {
+//     for (int i = off; i < off + len; i++) {
+//       if (ba[i] < 0) {
+//         return true;
+//       }
+//     }
+//     return false;
+//   }
 void MacroAssembler::has_negatives(Register ary1, Register len,
-                                   Register result, Register tmp1,
-                                   XMMRegister vec1, XMMRegister vec2) {
-
+  Register result, Register tmp1,
+  XMMRegister vec1, XMMRegister vec2) {
   // rsi: byte array
   // rcx: len
   // rax: result
@@ -8259,79 +8284,161 @@
   testl(len, len);
   jcc(Assembler::zero, FALSE_LABEL);
 
-  movl(result, len); // copy
+  if ((UseAVX > 2) && // AVX512
+    VM_Version::supports_avx512vlbw() &&
+    VM_Version::supports_bmi2()) {
 
-  if (UseAVX >= 2 && UseSSE >= 2) {
-    // With AVX2, use 32-byte vector compare
-    Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
+    set_vector_masking();  // opening of the stub context for programming mask registers
 
-    // Compare 32-byte vectors
-    andl(result, 0x0000001f);  //   tail count (in bytes)
-    andl(len, 0xffffffe0);   // vector count (in bytes)
-    jccb(Assembler::zero, COMPARE_TAIL);
+    Label test_64_loop, test_tail;
+    Register tmp3_aliased = len;
+
+    movl(tmp1, len);
+    vpxor(vec2, vec2, vec2, Assembler::AVX_512bit);
+
+    andl(tmp1, 64 - 1);   // tail count (in chars) 0x3F
+    andl(len, ~(64 - 1));    // vector count (in chars)
+    jccb(Assembler::zero, test_tail);
 
     lea(ary1, Address(ary1, len, Address::times_1));
     negptr(len);
 
-    movl(tmp1, 0x80808080);   // create mask to test for Unicode chars in vector
-    movdl(vec2, tmp1);
-    vpbroadcastd(vec2, vec2);
+    bind(test_64_loop);
+    // Check whether our 64 elements of size byte contain negatives
+    evpcmpgtb(k2, vec2, Address(ary1, len, Address::times_1), Assembler::AVX_512bit);
+    kortestql(k2, k2);
+    jcc(Assembler::notZero, TRUE_LABEL);
 
-    bind(COMPARE_WIDE_VECTORS);
-    vmovdqu(vec1, Address(ary1, len, Address::times_1));
-    vptest(vec1, vec2);
-    jccb(Assembler::notZero, TRUE_LABEL);
-    addptr(len, 32);
-    jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
+    addptr(len, 64);
+    jccb(Assembler::notZero, test_64_loop);
 
-    testl(result, result);
-    jccb(Assembler::zero, FALSE_LABEL);
 
-    vmovdqu(vec1, Address(ary1, result, Address::times_1, -32));
-    vptest(vec1, vec2);
-    jccb(Assembler::notZero, TRUE_LABEL);
-    jmpb(FALSE_LABEL);
+    bind(test_tail);
+    // bail out when there is nothing to be done
+    testl(tmp1, -1);
+    jcc(Assembler::zero, FALSE_LABEL);
 
-    bind(COMPARE_TAIL); // len is zero
-    movl(len, result);
-    // Fallthru to tail compare
-  } else if (UseSSE42Intrinsics) {
-    assert(UseSSE >= 4, "SSE4 must be  for SSE4.2 intrinsics to be available");
-    // With SSE4.2, use double quad vector compare
-    Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
+    // Save k1
+    kmovql(k3, k1);
 
-    // Compare 16-byte vectors
-    andl(result, 0x0000000f);  //   tail count (in bytes)
-    andl(len, 0xfffffff0);   // vector count (in bytes)
-    jccb(Assembler::zero, COMPARE_TAIL);
+    // ~(~0 << len) applied up to two times (for 32-bit scenario)
+#ifdef _LP64
+    mov64(tmp3_aliased, 0xFFFFFFFFFFFFFFFF);
+    shlxq(tmp3_aliased, tmp3_aliased, tmp1);
+    notq(tmp3_aliased);
+    kmovql(k1, tmp3_aliased);
+#else
+    Label k_init;
+    jmp(k_init);
 
-    lea(ary1, Address(ary1, len, Address::times_1));
-    negptr(len);
+    // We could not read 64-bits from a general purpose register thus we move
+    // data required to compose 64 1's to the instruction stream
+    // We emit 64 byte wide series of elements from 0..63 which later on would
+    // be used as a compare targets with tail count contained in tmp1 register.
+    // Result would be a k1 register having tmp1 consecutive number or 1
+    // counting from least significant bit.
+    address tmp = pc();
+    emit_int64(0x0706050403020100);
+    emit_int64(0x0F0E0D0C0B0A0908);
+    emit_int64(0x1716151413121110);
+    emit_int64(0x1F1E1D1C1B1A1918);
+    emit_int64(0x2726252423222120);
+    emit_int64(0x2F2E2D2C2B2A2928);
+    emit_int64(0x3736353433323130);
+    emit_int64(0x3F3E3D3C3B3A3938);
 
-    movl(tmp1, 0x80808080);
-    movdl(vec2, tmp1);
-    pshufd(vec2, vec2, 0);
+    bind(k_init);
+    lea(len, InternalAddress(tmp));
+    // create mask to test for negative byte inside a vector
+    evpbroadcastb(vec1, tmp1, Assembler::AVX_512bit);
+    evpcmpgtb(k1, vec1, Address(len, 0), Assembler::AVX_512bit);
 
-    bind(COMPARE_WIDE_VECTORS);
-    movdqu(vec1, Address(ary1, len, Address::times_1));
-    ptest(vec1, vec2);
-    jccb(Assembler::notZero, TRUE_LABEL);
-    addptr(len, 16);
-    jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
+#endif
+    evpcmpgtb(k2, k1, vec2, Address(ary1, 0), Assembler::AVX_512bit);
+    ktestq(k2, k1);
+    // Restore k1
+    kmovql(k1, k3);
+    jcc(Assembler::notZero, TRUE_LABEL);
 
-    testl(result, result);
-    jccb(Assembler::zero, FALSE_LABEL);
+    jmp(FALSE_LABEL);
 
-    movdqu(vec1, Address(ary1, result, Address::times_1, -16));
-    ptest(vec1, vec2);
-    jccb(Assembler::notZero, TRUE_LABEL);
-    jmpb(FALSE_LABEL);
-
-    bind(COMPARE_TAIL); // len is zero
-    movl(len, result);
-    // Fallthru to tail compare
+    clear_vector_masking();   // closing of the stub context for programming mask registers
   }
+  else {
+    movl(result, len); // copy
 
+    if (UseAVX == 2 && UseSSE >= 2) {
+      // With AVX2, use 32-byte vector compare
+      Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
+
+      // Compare 32-byte vectors
+      andl(result, 0x0000001f);  //   tail count (in bytes)
+      andl(len, 0xffffffe0);   // vector count (in bytes)
+      jccb(Assembler::zero, COMPARE_TAIL);
+
+      lea(ary1, Address(ary1, len, Address::times_1));
+      negptr(len);
+
+      movl(tmp1, 0x80808080);   // create mask to test for Unicode chars in vector
+      movdl(vec2, tmp1);
+      vpbroadcastd(vec2, vec2);
+
+      bind(COMPARE_WIDE_VECTORS);
+      vmovdqu(vec1, Address(ary1, len, Address::times_1));
+      vptest(vec1, vec2);
+      jccb(Assembler::notZero, TRUE_LABEL);
+      addptr(len, 32);
+      jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
+
+      testl(result, result);
+      jccb(Assembler::zero, FALSE_LABEL);
+
+      vmovdqu(vec1, Address(ary1, result, Address::times_1, -32));
+      vptest(vec1, vec2);
+      jccb(Assembler::notZero, TRUE_LABEL);
+      jmpb(FALSE_LABEL);
+
+      bind(COMPARE_TAIL); // len is zero
+      movl(len, result);
+      // Fallthru to tail compare
+    }
+    else if (UseSSE42Intrinsics) {
+      assert(UseSSE >= 4, "SSE4 must be  for SSE4.2 intrinsics to be available");
+      // With SSE4.2, use double quad vector compare
+      Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
+
+      // Compare 16-byte vectors
+      andl(result, 0x0000000f);  //   tail count (in bytes)
+      andl(len, 0xfffffff0);   // vector count (in bytes)
+      jccb(Assembler::zero, COMPARE_TAIL);
+
+      lea(ary1, Address(ary1, len, Address::times_1));
+      negptr(len);
+
+      movl(tmp1, 0x80808080);
+      movdl(vec2, tmp1);
+      pshufd(vec2, vec2, 0);
+
+      bind(COMPARE_WIDE_VECTORS);
+      movdqu(vec1, Address(ary1, len, Address::times_1));
+      ptest(vec1, vec2);
+      jccb(Assembler::notZero, TRUE_LABEL);
+      addptr(len, 16);
+      jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
+
+      testl(result, result);
+      jccb(Assembler::zero, FALSE_LABEL);
+
+      movdqu(vec1, Address(ary1, result, Address::times_1, -16));
+      ptest(vec1, vec2);
+      jccb(Assembler::notZero, TRUE_LABEL);
+      jmpb(FALSE_LABEL);
+
+      bind(COMPARE_TAIL); // len is zero
+      movl(len, result);
+      // Fallthru to tail compare
+    }
+  }
   // Compare 4-byte vectors
   andl(len, 0xfffffffc); // vector count (in bytes)
   jccb(Assembler::zero, COMPARE_CHAR);
@@ -8379,7 +8486,6 @@
     vpxor(vec2, vec2);
   }
 }
-
 // Compare char[] or byte[] arrays aligned to 4 bytes or substrings.
 void MacroAssembler::arrays_equals(bool is_array_equ, Register ary1, Register ary2,
                                    Register limit, Register result, Register chr,
@@ -8482,12 +8588,12 @@
     vpxor(vec1, vec2);
 
     vptest(vec1, vec1);
-    jccb(Assembler::notZero, FALSE_LABEL);
+    jcc(Assembler::notZero, FALSE_LABEL);
     addptr(limit, 32);
     jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
 
     testl(result, result);
-    jccb(Assembler::zero, TRUE_LABEL);
+    jcc(Assembler::zero, TRUE_LABEL);
 
     vmovdqu(vec1, Address(ary1, result, Address::times_1, -32));
     vmovdqu(vec2, Address(ary2, result, Address::times_1, -32));
@@ -8508,7 +8614,7 @@
     // Compare 16-byte vectors
     andl(result, 0x0000000f);  //   tail count (in bytes)
     andl(limit, 0xfffffff0);   // vector count (in bytes)
-    jccb(Assembler::zero, COMPARE_TAIL);
+    jcc(Assembler::zero, COMPARE_TAIL);
 
     lea(ary1, Address(ary1, limit, Address::times_1));
     lea(ary2, Address(ary2, limit, Address::times_1));
@@ -8520,12 +8626,12 @@
     pxor(vec1, vec2);
 
     ptest(vec1, vec1);
-    jccb(Assembler::notZero, FALSE_LABEL);
+    jcc(Assembler::notZero, FALSE_LABEL);
     addptr(limit, 16);
     jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
 
     testl(result, result);
-    jccb(Assembler::zero, TRUE_LABEL);
+    jcc(Assembler::zero, TRUE_LABEL);
 
     movdqu(vec1, Address(ary1, result, Address::times_1, -16));
     movdqu(vec2, Address(ary2, result, Address::times_1, -16));
@@ -8825,10 +8931,23 @@
 }
 
 // encode char[] to byte[] in ISO_8859_1
+   //@HotSpotIntrinsicCandidate
+   //private static int implEncodeISOArray(byte[] sa, int sp,
+   //byte[] da, int dp, int len) {
+   //  int i = 0;
+   //  for (; i < len; i++) {
+   //    char c = StringUTF16.getChar(sa, sp++);
+   //    if (c > '\u00FF')
+   //      break;
+   //    da[dp++] = (byte)c;
+   //  }
+   //  return i;
+   //}
 void MacroAssembler::encode_iso_array(Register src, Register dst, Register len,
-                                      XMMRegister tmp1Reg, XMMRegister tmp2Reg,
-                                      XMMRegister tmp3Reg, XMMRegister tmp4Reg,
-                                      Register tmp5, Register result) {
+  XMMRegister tmp1Reg, XMMRegister tmp2Reg,
+  XMMRegister tmp3Reg, XMMRegister tmp4Reg,
+  Register tmp5, Register result) {
+
   // rsi: src
   // rdi: dst
   // rdx: len
@@ -8843,6 +8962,7 @@
   // check for zero length
   testl(len, len);
   jcc(Assembler::zero, L_done);
+
   movl(result, len);
 
   // Setup pointers
@@ -8860,7 +8980,7 @@
       movl(tmp5, 0xff00ff00);   // create mask to test for Unicode chars in vector
       movdl(tmp1Reg, tmp5);
       vpbroadcastd(tmp1Reg, tmp1Reg);
-      jmpb(L_chars_32_check);
+      jmp(L_chars_32_check);
 
       bind(L_copy_32_chars);
       vmovdqu(tmp3Reg, Address(src, len, Address::times_2, -64));
@@ -8874,7 +8994,7 @@
 
       bind(L_chars_32_check);
       addptr(len, 32);
-      jccb(Assembler::lessEqual, L_copy_32_chars);
+      jcc(Assembler::lessEqual, L_copy_32_chars);
 
       bind(L_copy_32_chars_exit);
       subptr(len, 16);
@@ -8891,7 +9011,7 @@
     if (UseAVX >= 2) {
       vmovdqu(tmp2Reg, Address(src, len, Address::times_2, -32));
       vptest(tmp2Reg, tmp1Reg);
-      jccb(Assembler::notZero, L_copy_16_chars_exit);
+      jcc(Assembler::notZero, L_copy_16_chars_exit);
       vpackuswb(tmp2Reg, tmp2Reg, tmp1Reg, /* vector_len */ 1);
       vpermq(tmp3Reg, tmp2Reg, 0xD8, /* vector_len */ 1);
     } else {
@@ -8913,7 +9033,7 @@
 
     bind(L_chars_16_check);
     addptr(len, 16);
-    jccb(Assembler::lessEqual, L_copy_16_chars);
+    jcc(Assembler::lessEqual, L_copy_16_chars);
 
     bind(L_copy_16_chars_exit);
     if (UseAVX >= 2) {
@@ -8951,6 +9071,7 @@
 
   bind(L_copy_1_char_exit);
   addptr(result, len); // len is negative count of not processed elements
+
   bind(L_done);
 }
 
@@ -9417,6 +9538,7 @@
 void MacroAssembler::vectorized_mismatch(Register obja, Register objb, Register length, Register log2_array_indxscale,
   Register result, Register tmp1, Register tmp2, XMMRegister rymm0, XMMRegister rymm1, XMMRegister rymm2){
   assert(UseSSE42Intrinsics, "SSE4.2 must be enabled.");
+  Label VECTOR64_LOOP, VECTOR64_TAIL, VECTOR64_NOT_EQUAL, VECTOR32_TAIL;
   Label VECTOR32_LOOP, VECTOR16_LOOP, VECTOR8_LOOP, VECTOR4_LOOP;
   Label VECTOR16_TAIL, VECTOR8_TAIL, VECTOR4_TAIL;
   Label VECTOR32_NOT_EQUAL, VECTOR16_NOT_EQUAL, VECTOR8_NOT_EQUAL, VECTOR4_NOT_EQUAL;
@@ -9429,11 +9551,62 @@
   shlq(length);
   xorq(result, result);
 
+  if ((UseAVX > 2) &&
+      VM_Version::supports_avx512vlbw()) {
+    set_vector_masking();  // opening of the stub context for programming mask registers
+    cmpq(length, 64);
+    jcc(Assembler::less, VECTOR32_TAIL);
+    movq(tmp1, length);
+    andq(tmp1, 0x3F);      // tail count
+    andq(length, ~(0x3F)); //vector count
+
+    bind(VECTOR64_LOOP);
+    // AVX512 code to compare 64 byte vectors.
+    evmovdqub(rymm0, Address(obja, result), Assembler::AVX_512bit);
+    evpcmpeqb(k7, rymm0, Address(objb, result), Assembler::AVX_512bit);
+    kortestql(k7, k7);
+    jcc(Assembler::aboveEqual, VECTOR64_NOT_EQUAL);     // mismatch
+    addq(result, 64);
+    subq(length, 64);
+    jccb(Assembler::notZero, VECTOR64_LOOP);
+
+    //bind(VECTOR64_TAIL);
+    testq(tmp1, tmp1);
+    jcc(Assembler::zero, SAME_TILL_END);
+
+    bind(VECTOR64_TAIL);
+    // AVX512 code to compare upto 63 byte vectors.
+    // Save k1
+    kmovql(k3, k1);
+    mov64(tmp2, 0xFFFFFFFFFFFFFFFF);
+    shlxq(tmp2, tmp2, tmp1);
+    notq(tmp2);
+    kmovql(k1, tmp2);
+
+    evmovdqub(rymm0, k1, Address(obja, result), Assembler::AVX_512bit);
+    evpcmpeqb(k7, k1, rymm0, Address(objb, result), Assembler::AVX_512bit);
+
+    ktestql(k7, k1);
+    // Restore k1
+    kmovql(k1, k3);
+    jcc(Assembler::below, SAME_TILL_END);     // not mismatch
+
+    bind(VECTOR64_NOT_EQUAL);
+    kmovql(tmp1, k7);
+    notq(tmp1);
+    tzcntq(tmp1, tmp1);
+    addq(result, tmp1);
+    shrq(result);
+    jmp(DONE);
+    bind(VECTOR32_TAIL);
+    clear_vector_masking();   // closing of the stub context for programming mask registers
+  }
+
   cmpq(length, 8);
   jcc(Assembler::equal, VECTOR8_LOOP);
   jcc(Assembler::less, VECTOR4_TAIL);
 
-  if (UseAVX >= 2){
+  if (UseAVX >= 2) {
 
     cmpq(length, 16);
     jcc(Assembler::equal, VECTOR16_LOOP);
@@ -9541,7 +9714,7 @@
   jccb(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found
   jmpb(SAME_TILL_END);
 
-  if (UseAVX >= 2){
+  if (UseAVX >= 2) {
     bind(VECTOR32_NOT_EQUAL);
     vpcmpeqb(rymm2, rymm2, rymm2, Assembler::AVX_256bit);
     vpcmpeqb(rymm0, rymm0, rymm1, Assembler::AVX_256bit);
@@ -9554,7 +9727,7 @@
   }
 
   bind(VECTOR16_NOT_EQUAL);
-  if (UseAVX >= 2){
+  if (UseAVX >= 2) {
     vpcmpeqb(rymm2, rymm2, rymm2, Assembler::AVX_128bit);
     vpcmpeqb(rymm0, rymm0, rymm1, Assembler::AVX_128bit);
     pxor(rymm0, rymm2);
@@ -9585,7 +9758,6 @@
   bind(DONE);
 }
 
-
 //Helper functions for square_to_len()
 
 /**
@@ -10771,13 +10943,24 @@
 #undef BIND
 #undef BLOCK_COMMENT
 
-
 // Compress char[] array to byte[].
+//   ..\jdk\src\java.base\share\classes\java\lang\StringUTF16.java
+//   @HotSpotIntrinsicCandidate
+//   private static int compress(char[] src, int srcOff, byte[] dst, int dstOff, int len) {
+//     for (int i = 0; i < len; i++) {
+//       int c = src[srcOff++];
+//       if (c >>> 8 != 0) {
+//         return 0;
+//       }
+//       dst[dstOff++] = (byte)c;
+//     }
+//     return len;
+//   }
 void MacroAssembler::char_array_compress(Register src, Register dst, Register len,
-                                         XMMRegister tmp1Reg, XMMRegister tmp2Reg,
-                                         XMMRegister tmp3Reg, XMMRegister tmp4Reg,
-                                         Register tmp5, Register result) {
-  Label copy_chars_loop, return_length, return_zero, done;
+  XMMRegister tmp1Reg, XMMRegister tmp2Reg,
+  XMMRegister tmp3Reg, XMMRegister tmp4Reg,
+  Register tmp5, Register result) {
+  Label copy_chars_loop, return_length, return_zero, done, below_threshold;
 
   // rsi: src
   // rdi: dst
@@ -10794,11 +10977,141 @@
   // save length for return
   push(len);
 
+  if ((UseAVX > 2) && // AVX512
+    VM_Version::supports_avx512vlbw() &&
+    VM_Version::supports_bmi2()) {
+
+    set_vector_masking();  // opening of the stub context for programming mask registers
+
+    Label copy_32_loop, copy_loop_tail, copy_just_portion_of_candidates;
+
+    // alignement
+    Label post_alignement;
+
+    // if length of the string is less than 16, handle it in an old fashioned
+    // way
+    testl(len, -32);
+    jcc(Assembler::zero, below_threshold);
+
+    // First check whether a character is compressable ( <= 0xFF).
+    // Create mask to test for Unicode chars inside zmm vector
+    movl(result, 0x00FF);
+    evpbroadcastw(tmp2Reg, result, Assembler::AVX_512bit);
+
+    testl(len, -64);
+    jcc(Assembler::zero, post_alignement);
+
+    // Save k1
+    kmovql(k3, k1);
+
+    movl(tmp5, dst);
+    andl(tmp5, (64 - 1));
+    negl(tmp5);
+    andl(tmp5, (64 - 1));
+
+    // bail out when there is nothing to be done
+    testl(tmp5, 0xFFFFFFFF);
+    jcc(Assembler::zero, post_alignement);
+
+    // ~(~0 << len), where len is the # of remaining elements to process
+    movl(result, 0xFFFFFFFF);
+    shlxl(result, result, tmp5);
+    notl(result);
+
+    kmovdl(k1, result);
+
+    evmovdquw(tmp1Reg, k1, Address(src, 0), Assembler::AVX_512bit);
+    evpcmpuw(k2, k1, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit);
+    ktestd(k2, k1);
+    jcc(Assembler::carryClear, copy_just_portion_of_candidates);
+
+    evpmovwb(Address(dst, 0), k1, tmp1Reg, Assembler::AVX_512bit);
+
+    addptr(src, tmp5);
+    addptr(src, tmp5);
+    addptr(dst, tmp5);
+    subl(len, tmp5);
+
+    bind(post_alignement);
+    // end of alignement
+
+    movl(tmp5, len);
+    andl(tmp5, (32 - 1));   // tail count (in chars)
+    andl(len, ~(32 - 1));    // vector count (in chars)
+    jcc(Assembler::zero, copy_loop_tail);
+
+    lea(src, Address(src, len, Address::times_2));
+    lea(dst, Address(dst, len, Address::times_1));
+    negptr(len);
+
+    bind(copy_32_loop);
+    evmovdquw(tmp1Reg, Address(src, len, Address::times_2), Assembler::AVX_512bit);
+    evpcmpuw(k2, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit);
+    kortestdl(k2, k2);
+    jcc(Assembler::carryClear, copy_just_portion_of_candidates);
+
+    // All elements in current processed chunk are valid candidates for
+    // compression. Write a truncated byte elements to the memory.
+    evpmovwb(Address(dst, len, Address::times_1), tmp1Reg, Assembler::AVX_512bit);
+    addptr(len, 32);
+    jcc(Assembler::notZero, copy_32_loop);
+
+    bind(copy_loop_tail);
+    // bail out when there is nothing to be done
+    testl(tmp5, 0xFFFFFFFF);
+    jcc(Assembler::zero, return_length);
+
+    // Save k1
+    kmovql(k3, k1);
+
+    movl(len, tmp5);
+
+    // ~(~0 << len), where len is the # of remaining elements to process
+    movl(result, 0xFFFFFFFF);
+    shlxl(result, result, len);
+    notl(result);
+
+    kmovdl(k1, result);
+
+    evmovdquw(tmp1Reg, k1, Address(src, 0), Assembler::AVX_512bit);
+    evpcmpuw(k2, k1, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit);
+    ktestd(k2, k1);
+    jcc(Assembler::carryClear, copy_just_portion_of_candidates);
+
+    evpmovwb(Address(dst, 0), k1, tmp1Reg, Assembler::AVX_512bit);
+    // Restore k1
+    kmovql(k1, k3);
+
+    jmp(return_length);
+
+    bind(copy_just_portion_of_candidates);
+    kmovdl(tmp5, k2);
+    tzcntl(tmp5, tmp5);
+
+    // ~(~0 << tmp5), where tmp5 is a number of elements in an array from the
+    // result to the first element larger than 0xFF
+    movl(result, 0xFFFFFFFF);
+    shlxl(result, result, tmp5);
+    notl(result);
+
+    kmovdl(k1, result);
+
+    evpmovwb(Address(dst, 0), k1, tmp1Reg, Assembler::AVX_512bit);
+    // Restore k1
+    kmovql(k1, k3);
+
+    jmp(return_zero);
+
+    clear_vector_masking();   // closing of the stub context for programming mask registers
+  }
   if (UseSSE42Intrinsics) {
     assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available");
     Label copy_32_loop, copy_16, copy_tail;
 
+    bind(below_threshold);
+
     movl(result, len);
+
     movl(tmp5, 0xff00ff00);   // create mask to test for Unicode chars in vectors
 
     // vectored compression
@@ -10880,10 +11193,16 @@
 }
 
 // Inflate byte[] array to char[].
+//   ..\jdk\src\java.base\share\classes\java\lang\StringLatin1.java
+//   @HotSpotIntrinsicCandidate
+//   private static void inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
+//     for (int i = 0; i < len; i++) {
+//       dst[dstOff++] = (char)(src[srcOff++] & 0xff);
+//     }
+//   }
 void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len,
-                                        XMMRegister tmp1, Register tmp2) {
-  Label copy_chars_loop, done;
-
+  XMMRegister tmp1, Register tmp2) {
+  Label copy_chars_loop, done, below_threshold;
   // rsi: src
   // rdi: dst
   // rdx: len
@@ -10894,20 +11213,109 @@
   // rdx holds length
   assert_different_registers(src, dst, len, tmp2);
 
+  if ((UseAVX > 2) && // AVX512
+    VM_Version::supports_avx512vlbw() &&
+    VM_Version::supports_bmi2()) {
+
+    set_vector_masking();  // opening of the stub context for programming mask registers
+
+    Label copy_32_loop, copy_tail;
+    Register tmp3_aliased = len;
+
+    // if length of the string is less than 16, handle it in an old fashioned
+    // way
+    testl(len, -16);
+    jcc(Assembler::zero, below_threshold);
+
+    // In order to use only one arithmetic operation for the main loop we use
+    // this pre-calculation
+    movl(tmp2, len);
+    andl(tmp2, (32 - 1)); // tail count (in chars), 32 element wide loop
+    andl(len, -32);     // vector count
+    jccb(Assembler::zero, copy_tail);
+
+    lea(src, Address(src, len, Address::times_1));
+    lea(dst, Address(dst, len, Address::times_2));
+    negptr(len);
+
+
+    // inflate 32 chars per iter
+    bind(copy_32_loop);
+    vpmovzxbw(tmp1, Address(src, len, Address::times_1), Assembler::AVX_512bit);
+    evmovdquw(Address(dst, len, Address::times_2), tmp1, Assembler::AVX_512bit);
+    addptr(len, 32);
+    jcc(Assembler::notZero, copy_32_loop);
+
+    bind(copy_tail);
+    // bail out when there is nothing to be done
+    testl(tmp2, -1); // we don't destroy the contents of tmp2 here
+    jcc(Assembler::zero, done);
+
+    // Save k1
+    kmovql(k2, k1);
+
+    // ~(~0 << length), where length is the # of remaining elements to process
+    movl(tmp3_aliased, -1);
+    shlxl(tmp3_aliased, tmp3_aliased, tmp2);
+    notl(tmp3_aliased);
+    kmovdl(k1, tmp3_aliased);
+    evpmovzxbw(tmp1, k1, Address(src, 0), Assembler::AVX_512bit);
+    evmovdquw(Address(dst, 0), k1, tmp1, Assembler::AVX_512bit);
+
+    // Restore k1
+    kmovql(k1, k2);
+    jmp(done);
+
+    clear_vector_masking();   // closing of the stub context for programming mask registers
+  }
   if (UseSSE42Intrinsics) {
     assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available");
-    Label copy_8_loop, copy_bytes, copy_tail;
+    Label copy_16_loop, copy_8_loop, copy_bytes, copy_new_tail, copy_tail;
 
     movl(tmp2, len);
-    andl(tmp2, 0x00000007);   // tail count (in chars)
-    andl(len, 0xfffffff8);    // vector count (in chars)
-    jccb(Assembler::zero, copy_tail);
+
+    if (UseAVX > 1) {
+      andl(tmp2, (16 - 1));
+      andl(len, -16);
+      jccb(Assembler::zero, copy_new_tail);
+    } else {
+      andl(tmp2, 0x00000007);   // tail count (in chars)
+      andl(len, 0xfffffff8);    // vector count (in chars)
+      jccb(Assembler::zero, copy_tail);
+    }
 
     // vectored inflation
     lea(src, Address(src, len, Address::times_1));
     lea(dst, Address(dst, len, Address::times_2));
     negptr(len);
 
+    if (UseAVX > 1) {
+      bind(copy_16_loop);
+      vpmovzxbw(tmp1, Address(src, len, Address::times_1), Assembler::AVX_256bit);
+      vmovdqu(Address(dst, len, Address::times_2), tmp1);
+      addptr(len, 16);
+      jcc(Assembler::notZero, copy_16_loop);
+
+      bind(below_threshold);
+      bind(copy_new_tail);
+      if (UseAVX > 2) {
+        movl(tmp2, len);
+      }
+      else {
+        movl(len, tmp2);
+      }
+      andl(tmp2, 0x00000007);
+      andl(len, 0xFFFFFFF8);
+      jccb(Assembler::zero, copy_tail);
+
+      pmovzxbw(tmp1, Address(src, 0));
+      movdqu(Address(dst, 0), tmp1);
+      addptr(src, 8);
+      addptr(dst, 2 * 8);
+
+      jmp(copy_tail, true);
+    }
+
     // inflate 8 chars per iter
     bind(copy_8_loop);
     pmovzxbw(tmp1, Address(src, len, Address::times_1));  // unpack to 8 words
@@ -10946,7 +11354,6 @@
   bind(done);
 }
 
-
 Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
   switch (cond) {
     // Note some conditions are synonyms for others
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp
index 836f8c4..4897568 100644
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp
@@ -156,6 +156,10 @@
   void incrementq(Register reg, int value = 1);
   void incrementq(Address dst, int value = 1);
 
+  // special instructions for EVEX
+  void setvectmask(Register dst, Register src);
+  void restorevectmask();
+
   // Support optimal SSE move instructions.
   void movflt(XMMRegister dst, XMMRegister src) {
     if (UseXmmRegToRegMoveAll) { movaps(dst, src); return; }
@@ -319,6 +323,8 @@
   void movbool(Address dst, Register src);
   void testbool(Register dst);
 
+  void load_mirror(Register mirror, Register method);
+
   // oop manipulations
   void load_klass(Register dst, Register src);
   void store_klass(Register dst, Register src);
@@ -841,7 +847,7 @@
   void call(Label& L, relocInfo::relocType rtype);
   void call(Register entry);
 
-  // NOTE: this call tranfers to the effective address of entry NOT
+  // NOTE: this call transfers to the effective address of entry NOT
   // the address contained by entry. This is because this is more natural
   // for jumps/calls.
   void call(AddressLiteral entry);
@@ -902,6 +908,45 @@
   void ldmxcsr(Address src) { Assembler::ldmxcsr(src); }
   void ldmxcsr(AddressLiteral src);
 
+#ifdef _LP64
+ private:
+  void sha256_AVX2_one_round_compute(
+    Register  reg_old_h,
+    Register  reg_a,
+    Register  reg_b,
+    Register  reg_c,
+    Register  reg_d,
+    Register  reg_e,
+    Register  reg_f,
+    Register  reg_g,
+    Register  reg_h,
+    int iter);
+  void sha256_AVX2_four_rounds_compute_first(int start);
+  void sha256_AVX2_four_rounds_compute_last(int start);
+  void sha256_AVX2_one_round_and_sched(
+        XMMRegister xmm_0,     /* == ymm4 on 0, 1, 2, 3 iterations, then rotate 4 registers left on 4, 8, 12 iterations */
+        XMMRegister xmm_1,     /* ymm5 */  /* full cycle is 16 iterations */
+        XMMRegister xmm_2,     /* ymm6 */
+        XMMRegister xmm_3,     /* ymm7 */
+        Register    reg_a,      /* == eax on 0 iteration, then rotate 8 register right on each next iteration */
+        Register    reg_b,      /* ebx */    /* full cycle is 8 iterations */
+        Register    reg_c,      /* edi */
+        Register    reg_d,      /* esi */
+        Register    reg_e,      /* r8d */
+        Register    reg_f,      /* r9d */
+        Register    reg_g,      /* r10d */
+        Register    reg_h,      /* r11d */
+        int iter);
+
+  void addm(int disp, Register r1, Register r2);
+
+ public:
+  void sha256_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+                   XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+                   Register buf, Register state, Register ofs, Register limit, Register rsp,
+                   bool multi_block, XMMRegister shuf_mask);
+#endif
+
   void fast_sha1(XMMRegister abcd, XMMRegister e0, XMMRegister e1, XMMRegister msg0,
                  XMMRegister msg1, XMMRegister msg2, XMMRegister msg3, XMMRegister shuf_mask,
                  Register buf, Register state, Register ofs, Register limit, Register rsp,
@@ -928,6 +973,10 @@
                 XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
                 Register rax, Register rcx, Register rdx, Register tmp1, Register tmp2);
 
+  void fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
+                  XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                  Register rax, Register rcx, Register rdx, Register r11);
+
   void fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4,
                 XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx,
                 Register rdx, Register tmp1, Register tmp2, Register tmp3, Register tmp4);
@@ -941,11 +990,19 @@
                 XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
                 Register rax, Register rcx, Register rdx, Register tmp1,
                 Register tmp2, Register tmp3, Register tmp4);
+  void fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
+                XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                Register rax, Register rcx, Register rdx, Register tmp1,
+                Register tmp2, Register tmp3, Register tmp4);
 #else
   void fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
                 XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
                 Register rax, Register rcx, Register rdx, Register tmp1);
 
+  void fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
+                XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                Register rax, Register rcx, Register rdx, Register tmp);
+
   void fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4,
                 XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx,
                 Register rdx, Register tmp);
@@ -964,6 +1021,14 @@
 
   void libm_reduce_pi04l(Register eax, Register ecx, Register edx, Register ebx,
                          Register esi, Register edi, Register ebp, Register esp);
+
+  void libm_tancot_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx,
+                        Register edx, Register ebx, Register esi, Register edi,
+                        Register ebp, Register esp);
+
+  void fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
+                XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                Register rax, Register rcx, Register rdx, Register tmp);
 #endif
 
   void increase_precision();
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_cos.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_cos.cpp
new file mode 100644
index 0000000..1ebed35
--- /dev/null
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_cos.cpp
@@ -0,0 +1,889 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+* Intel Math Library (LIBM) Source Code
+*
+* 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 "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
+/******************************************************************************/
+//                     ALGORITHM DESCRIPTION - COS()
+//                     ---------------------
+//
+//     1. RANGE REDUCTION
+//
+//     We perform an initial range reduction from X to r with
+//
+//          X =~= N * pi/32 + r
+//
+//     so that |r| <= pi/64 + epsilon. We restrict inputs to those
+//     where |N| <= 932560. Beyond this, the range reduction is
+//     insufficiently accurate. For extremely small inputs,
+//     denormalization can occur internally, impacting performance.
+//     This means that the main path is actually only taken for
+//     2^-252 <= |X| < 90112.
+//
+//     To avoid branches, we perform the range reduction to full
+//     accuracy each time.
+//
+//          X - N * (P_1 + P_2 + P_3)
+//
+//     where P_1 and P_2 are 32-bit numbers (so multiplication by N
+//     is exact) and P_3 is a 53-bit number. Together, these
+//     approximate pi well enough for all cases in the restricted
+//     range.
+//
+//     The main reduction sequence is:
+//
+//             y = 32/pi * x
+//             N = integer(y)
+//     (computed by adding and subtracting off SHIFTER)
+//
+//             m_1 = N * P_1
+//             m_2 = N * P_2
+//             r_1 = x - m_1
+//             r = r_1 - m_2
+//     (this r can be used for most of the calculation)
+//
+//             c_1 = r_1 - r
+//             m_3 = N * P_3
+//             c_2 = c_1 - m_2
+//             c = c_2 - m_3
+//
+//     2. MAIN ALGORITHM
+//
+//     The algorithm uses a table lookup based on B = M * pi / 32
+//     where M = N mod 64. The stored values are:
+//       sigma             closest power of 2 to cos(B)
+//       C_hl              53-bit cos(B) - sigma
+//       S_hi + S_lo       2 * 53-bit sin(B)
+//
+//     The computation is organized as follows:
+//
+//          sin(B + r + c) = [sin(B) + sigma * r] +
+//                           r * (cos(B) - sigma) +
+//                           sin(B) * [cos(r + c) - 1] +
+//                           cos(B) * [sin(r + c) - r]
+//
+//     which is approximately:
+//
+//          [S_hi + sigma * r] +
+//          C_hl * r +
+//          S_lo + S_hi * [(cos(r) - 1) - r * c] +
+//          (C_hl + sigma) * [(sin(r) - r) + c]
+//
+//     and this is what is actually computed. We separate this sum
+//     into four parts:
+//
+//          hi + med + pols + corr
+//
+//     where
+//
+//          hi       = S_hi + sigma r
+//          med      = C_hl * r
+//          pols     = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r)
+//          corr     = S_lo + c * ((C_hl + sigma) - S_hi * r)
+//
+//     3. POLYNOMIAL
+//
+//     The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) *
+//     (sin(r) - r) can be rearranged freely, since it is quite
+//     small, so we exploit parallelism to the fullest.
+//
+//          psc4       =   SC_4 * r_1
+//          msc4       =   psc4 * r
+//          r2         =   r * r
+//          msc2       =   SC_2 * r2
+//          r4         =   r2 * r2
+//          psc3       =   SC_3 + msc4
+//          psc1       =   SC_1 + msc2
+//          msc3       =   r4 * psc3
+//          sincospols =   psc1 + msc3
+//          pols       =   sincospols *
+//                         <S_hi * r^2 | (C_hl + sigma) * r^3>
+//
+//     4. CORRECTION TERM
+//
+//     This is where the "c" component of the range reduction is
+//     taken into account; recall that just "r" is used for most of
+//     the calculation.
+//
+//          -c   = m_3 - c_2
+//          -d   = S_hi * r - (C_hl + sigma)
+//          corr = -c * -d + S_lo
+//
+//     5. COMPENSATED SUMMATIONS
+//
+//     The two successive compensated summations add up the high
+//     and medium parts, leaving just the low parts to add up at
+//     the end.
+//
+//          rs        =  sigma * r
+//          res_int   =  S_hi + rs
+//          k_0       =  S_hi - res_int
+//          k_2       =  k_0 + rs
+//          med       =  C_hl * r
+//          res_hi    =  res_int + med
+//          k_1       =  res_int - res_hi
+//          k_3       =  k_1 + med
+//
+//     6. FINAL SUMMATION
+//
+//     We now add up all the small parts:
+//
+//          res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3
+//
+//     Now the overall result is just:
+//
+//          res_hi + res_lo
+//
+//     7. SMALL ARGUMENTS
+//
+//     Inputs with |X| < 2^-252 are treated specially as
+//     1 - |x|.
+//
+// Special cases:
+//  cos(NaN) = quiet NaN, and raise invalid exception
+//  cos(INF) = NaN and raise invalid exception
+//  cos(0) = 1
+//
+/******************************************************************************/
+
+#ifdef _LP64
+// The 64 bit code is at most SSE2 compliant
+ALIGNED_(8) juint _ONE[] =
+{
+    0x00000000UL, 0x3ff00000UL
+};
+void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r8, Register r9, Register r10, Register r11) {
+
+  Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1;
+  Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1;
+  Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1;
+  Label L_2TAG_PACKET_12_0_1, L_2TAG_PACKET_13_0_1, B1_2, B1_3, B1_4, B1_5, start;
+
+  assert_different_registers(r8, r9, r10, r11, eax, ecx, edx);
+
+  address ONEHALF = StubRoutines::x86::_ONEHALF_addr();
+  address P_2 = StubRoutines::x86::_P_2_addr();
+  address SC_4 = StubRoutines::x86::_SC_4_addr();
+  address Ctable = StubRoutines::x86::_Ctable_addr();
+  address SC_2 = StubRoutines::x86::_SC_2_addr();
+  address SC_3 = StubRoutines::x86::_SC_3_addr();
+  address SC_1 = StubRoutines::x86::_SC_1_addr();
+  address PI_INV_TABLE = StubRoutines::x86::_PI_INV_TABLE_addr();
+  address PI_4 = (address)StubRoutines::x86::_PI_4_addr();
+  address PI32INV = (address)StubRoutines::x86::_PI32INV_addr();
+  address SIGN_MASK = (address)StubRoutines::x86::_SIGN_MASK_addr();
+  address P_1 = (address)StubRoutines::x86::_P_1_addr();
+  address P_3 = (address)StubRoutines::x86::_P_3_addr();
+  address ONE = (address)_ONE;
+  address NEG_ZERO = (address)StubRoutines::x86::_NEG_ZERO_addr();
+
+  bind(start);
+  push(rbx);
+  subq(rsp, 16);
+  movsd(Address(rsp, 8), xmm0);
+
+  bind(B1_2);
+  movl(eax, Address(rsp, 12));
+  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
+  andl(eax, 2147418112);
+  subl(eax, 808452096);
+  cmpl(eax, 281346048);
+  jcc(Assembler::above, L_2TAG_PACKET_0_0_1);
+  mulsd(xmm1, xmm0);
+  movdqu(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
+  pand(xmm4, xmm0);
+  por(xmm5, xmm4);
+  addpd(xmm1, xmm5);
+  cvttsd2sil(edx, xmm1);
+  cvtsi2sdl(xmm1, edx);
+  movdqu(xmm2, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
+  movq(xmm3, ExternalAddress(P_1));    //0x54400000UL, 0x3fb921fbUL
+  mulsd(xmm3, xmm1);
+  unpcklpd(xmm1, xmm1);
+  addq(rdx, 1865232);
+  movdqu(xmm4, xmm0);
+  andq(rdx, 63);
+  movdqu(xmm5, ExternalAddress(SC_4));    //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
+  lea(rax, ExternalAddress(Ctable));
+  shlq(rdx, 5);
+  addq(rax, rdx);
+  mulpd(xmm2, xmm1);
+  subsd(xmm0, xmm3);
+  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
+  subsd(xmm4, xmm3);
+  movq(xmm7, Address(rax, 8));
+  unpcklpd(xmm0, xmm0);
+  movdqu(xmm3, xmm4);
+  subsd(xmm4, xmm2);
+  mulpd(xmm5, xmm0);
+  subpd(xmm0, xmm2);
+  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
+  mulsd(xmm7, xmm4);
+  subsd(xmm3, xmm4);
+  mulpd(xmm5, xmm0);
+  mulpd(xmm0, xmm0);
+  subsd(xmm3, xmm2);
+  movdqu(xmm2, Address(rax, 0));
+  subsd(xmm1, xmm3);
+  movq(xmm3, Address(rax, 24));
+  addsd(xmm2, xmm3);
+  subsd(xmm7, xmm2);
+  mulsd(xmm2, xmm4);
+  mulpd(xmm6, xmm0);
+  mulsd(xmm3, xmm4);
+  mulpd(xmm2, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
+  mulsd(xmm4, Address(rax, 0));
+  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
+  mulpd(xmm5, xmm0);
+  movdqu(xmm0, xmm3);
+  addsd(xmm3, Address(rax, 8));
+  mulpd(xmm1, xmm7);
+  movdqu(xmm7, xmm4);
+  addsd(xmm4, xmm3);
+  addpd(xmm6, xmm5);
+  movq(xmm5, Address(rax, 8));
+  subsd(xmm5, xmm3);
+  subsd(xmm3, xmm4);
+  addsd(xmm1, Address(rax, 16));
+  mulpd(xmm6, xmm2);
+  addsd(xmm0, xmm5);
+  addsd(xmm3, xmm7);
+  addsd(xmm0, xmm1);
+  addsd(xmm0, xmm3);
+  addsd(xmm0, xmm6);
+  unpckhpd(xmm6, xmm6);
+  addsd(xmm0, xmm6);
+  addsd(xmm0, xmm4);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_0_0_1);
+  jcc(Assembler::greater, L_2TAG_PACKET_1_0_1);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  pinsrw(xmm0, eax, 3);
+  movq(xmm1, ExternalAddress(ONE));    //0x00000000UL, 0x3ff00000UL
+  subsd(xmm1, xmm0);
+  movdqu(xmm0, xmm1);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_1_0_1);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  cmpl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_2_0_1);
+  pextrw(ecx, xmm0, 3);
+  andl(ecx, 32752);
+  subl(ecx, 16224);
+  shrl(ecx, 7);
+  andl(ecx, 65532);
+  lea(r11, ExternalAddress(PI_INV_TABLE));
+  addq(rcx, r11);
+  movdq(rax, xmm0);
+  movl(r10, Address(rcx, 20));
+  movl(r8, Address(rcx, 24));
+  movl(edx, eax);
+  shrq(rax, 21);
+  orl(eax, INT_MIN);
+  shrl(eax, 11);
+  movl(r9, r10);
+  imulq(r10, rdx);
+  imulq(r9, rax);
+  imulq(r8, rax);
+  movl(rsi, Address(rcx, 16));
+  movl(rdi, Address(rcx, 12));
+  movl(r11, r10);
+  shrq(r10, 32);
+  addq(r9, r10);
+  addq(r11, r8);
+  movl(r8, r11);
+  shrq(r11, 32);
+  addq(r9, r11);
+  movl(r10, rsi);
+  imulq(rsi, rdx);
+  imulq(r10, rax);
+  movl(r11, rdi);
+  imulq(rdi, rdx);
+  movl(rbx, rsi);
+  shrq(rsi, 32);
+  addq(r9, rbx);
+  movl(rbx, r9);
+  shrq(r9, 32);
+  addq(r10, rsi);
+  addq(r10, r9);
+  shlq(rbx, 32);
+  orq(r8, rbx);
+  imulq(r11, rax);
+  movl(r9, Address(rcx, 8));
+  movl(rsi, Address(rcx, 4));
+  movl(rbx, rdi);
+  shrq(rdi, 32);
+  addq(r10, rbx);
+  movl(rbx, r10);
+  shrq(r10, 32);
+  addq(r11, rdi);
+  addq(r11, r10);
+  movq(rdi, r9);
+  imulq(r9, rdx);
+  imulq(rdi, rax);
+  movl(r10, r9);
+  shrq(r9, 32);
+  addq(r11, r10);
+  movl(r10, r11);
+  shrq(r11, 32);
+  addq(rdi, r9);
+  addq(rdi, r11);
+  movq(r9, rsi);
+  imulq(rsi, rdx);
+  imulq(r9, rax);
+  shlq(r10, 32);
+  orq(r10, rbx);
+  movl(eax, Address(rcx, 0));
+  movl(r11, rsi);
+  shrq(rsi, 32);
+  addq(rdi, r11);
+  movl(r11, rdi);
+  shrq(rdi, 32);
+  addq(r9, rsi);
+  addq(r9, rdi);
+  imulq(rdx, rax);
+  pextrw(rbx, xmm0, 3);
+  lea(rdi, ExternalAddress(PI_INV_TABLE));
+  subq(rcx, rdi);
+  addl(ecx, ecx);
+  addl(ecx, ecx);
+  addl(ecx, ecx);
+  addl(ecx, 19);
+  movl(rsi, 32768);
+  andl(rsi, rbx);
+  shrl(rbx, 4);
+  andl(rbx, 2047);
+  subl(rbx, 1023);
+  subl(ecx, rbx);
+  addq(r9, rdx);
+  movl(edx, ecx);
+  addl(edx, 32);
+  cmpl(ecx, 1);
+  jcc(Assembler::less, L_2TAG_PACKET_3_0_1);
+  negl(ecx);
+  addl(ecx, 29);
+  shll(r9);
+  movl(rdi, r9);
+  andl(r9, 536870911);
+  testl(r9, 268435456);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_4_0_1);
+  shrl(r9);
+  movl(rbx, 0);
+  shlq(r9, 32);
+  orq(r9, r11);
+
+  bind(L_2TAG_PACKET_5_0_1);
+
+  bind(L_2TAG_PACKET_6_0_1);
+  cmpq(r9, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_7_0_1);
+
+  bind(L_2TAG_PACKET_8_0_1);
+  bsrq(r11, r9);
+  movl(ecx, 29);
+  subl(ecx, r11);
+  jcc(Assembler::lessEqual, L_2TAG_PACKET_9_0_1);
+  shlq(r9);
+  movq(rax, r10);
+  shlq(r10);
+  addl(edx, ecx);
+  negl(ecx);
+  addl(ecx, 64);
+  shrq(rax);
+  shrq(r8);
+  orq(r9, rax);
+  orq(r10, r8);
+
+  bind(L_2TAG_PACKET_10_0_1);
+  cvtsi2sdq(xmm0, r9);
+  shrq(r10, 1);
+  cvtsi2sdq(xmm3, r10);
+  xorpd(xmm4, xmm4);
+  shll(edx, 4);
+  negl(edx);
+  addl(edx, 16368);
+  orl(edx, rsi);
+  xorl(edx, rbx);
+  pinsrw(xmm4, edx, 3);
+  movq(xmm2, ExternalAddress(PI_4));    //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
+  movq(xmm6, ExternalAddress(8 + PI_4));    //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
+  xorpd(xmm5, xmm5);
+  subl(edx, 1008);
+  pinsrw(xmm5, edx, 3);
+  mulsd(xmm0, xmm4);
+  shll(rsi, 16);
+  sarl(rsi, 31);
+  mulsd(xmm3, xmm5);
+  movdqu(xmm1, xmm0);
+  mulsd(xmm0, xmm2);
+  shrl(rdi, 29);
+  addsd(xmm1, xmm3);
+  mulsd(xmm3, xmm2);
+  addl(rdi, rsi);
+  xorl(rdi, rsi);
+  mulsd(xmm6, xmm1);
+  movl(eax, rdi);
+  addsd(xmm6, xmm3);
+  movdqu(xmm2, xmm0);
+  addsd(xmm0, xmm6);
+  subsd(xmm2, xmm0);
+  addsd(xmm6, xmm2);
+
+  bind(L_2TAG_PACKET_11_0_1);
+  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
+  mulsd(xmm1, xmm0);
+  movq(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
+  pand(xmm4, xmm0);
+  por(xmm5, xmm4);
+  addpd(xmm1, xmm5);
+  cvttsd2siq(rdx, xmm1);
+  cvtsi2sdq(xmm1, rdx);
+  movq(xmm3, ExternalAddress(P_1));    //0x54400000UL, 0x3fb921fbUL
+  movdqu(xmm2, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
+  mulsd(xmm3, xmm1);
+  unpcklpd(xmm1, xmm1);
+  shll(eax, 3);
+  addl(edx, 1865232);
+  movdqu(xmm4, xmm0);
+  addl(edx, eax);
+  andl(edx, 63);
+  movdqu(xmm5, ExternalAddress(SC_4));    //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
+  lea(rax, ExternalAddress(Ctable));
+  shll(edx, 5);
+  addq(rax, rdx);
+  mulpd(xmm2, xmm1);
+  subsd(xmm0, xmm3);
+  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
+  subsd(xmm4, xmm3);
+  movq(xmm7, Address(rax, 8));
+  unpcklpd(xmm0, xmm0);
+  movdqu(xmm3, xmm4);
+  subsd(xmm4, xmm2);
+  mulpd(xmm5, xmm0);
+  subpd(xmm0, xmm2);
+  mulsd(xmm7, xmm4);
+  subsd(xmm3, xmm4);
+  mulpd(xmm5, xmm0);
+  mulpd(xmm0, xmm0);
+  subsd(xmm3, xmm2);
+  movdqu(xmm2, Address(rax, 0));
+  subsd(xmm1, xmm3);
+  movq(xmm3, Address(rax, 24));
+  addsd(xmm2, xmm3);
+  subsd(xmm7, xmm2);
+  subsd(xmm1, xmm6);
+  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
+  mulsd(xmm2, xmm4);
+  mulpd(xmm6, xmm0);
+  mulsd(xmm3, xmm4);
+  mulpd(xmm2, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
+  mulsd(xmm4, Address(rax, 0));
+  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
+  mulpd(xmm5, xmm0);
+  movdqu(xmm0, xmm3);
+  addsd(xmm3, Address(rax, 8));
+  mulpd(xmm1, xmm7);
+  movdqu(xmm7, xmm4);
+  addsd(xmm4, xmm3);
+  addpd(xmm6, xmm5);
+  movq(xmm5, Address(rax, 8));
+  subsd(xmm5, xmm3);
+  subsd(xmm3, xmm4);
+  addsd(xmm1, Address(rax, 16));
+  mulpd(xmm6, xmm2);
+  addsd(xmm5, xmm0);
+  addsd(xmm3, xmm7);
+  addsd(xmm1, xmm5);
+  addsd(xmm1, xmm3);
+  addsd(xmm1, xmm6);
+  unpckhpd(xmm6, xmm6);
+  movdqu(xmm0, xmm4);
+  addsd(xmm1, xmm6);
+  addsd(xmm0, xmm1);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_7_0_1);
+  addl(edx, 64);
+  movq(r9, r10);
+  movq(r10, r8);
+  movl(r8, 0);
+  cmpq(r9, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1);
+  addl(edx, 64);
+  movq(r9, r10);
+  movq(r10, r8);
+  cmpq(r9, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1);
+  xorpd(xmm0, xmm0);
+  xorpd(xmm6, xmm6);
+  jmp(L_2TAG_PACKET_11_0_1);
+
+  bind(L_2TAG_PACKET_9_0_1);
+  jcc(Assembler::equal, L_2TAG_PACKET_10_0_1);
+  negl(ecx);
+  shrq(r10);
+  movq(rax, r9);
+  shrq(r9);
+  subl(edx, ecx);
+  negl(ecx);
+  addl(ecx, 64);
+  shlq(rax);
+  orq(r10, rax);
+  jmp(L_2TAG_PACKET_10_0_1);
+  bind(L_2TAG_PACKET_3_0_1);
+  negl(ecx);
+  shlq(r9, 32);
+  orq(r9, r11);
+  shlq(r9);
+  movq(rdi, r9);
+  testl(r9, INT_MIN);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_1);
+  shrl(r9);
+  movl(rbx, 0);
+  shrq(rdi, 3);
+  jmp(L_2TAG_PACKET_6_0_1);
+
+  bind(L_2TAG_PACKET_4_0_1);
+  shrl(r9);
+  movl(rbx, 536870912);
+  shrl(rbx);
+  shlq(r9, 32);
+  orq(r9, r11);
+  shlq(rbx, 32);
+  addl(rdi, 536870912);
+  movl(rcx, 0);
+  movl(r11, 0);
+  subq(rcx, r8);
+  sbbq(r11, r10);
+  sbbq(rbx, r9);
+  movq(r8, rcx);
+  movq(r10, r11);
+  movq(r9, rbx);
+  movl(rbx, 32768);
+  jmp(L_2TAG_PACKET_5_0_1);
+
+  bind(L_2TAG_PACKET_12_0_1);
+  shrl(r9);
+  mov64(rbx, 0x100000000);
+  shrq(rbx);
+  movl(rcx, 0);
+  movl(r11, 0);
+  subq(rcx, r8);
+  sbbq(r11, r10);
+  sbbq(rbx, r9);
+  movq(r8, rcx);
+  movq(r10, r11);
+  movq(r9, rbx);
+  movl(rbx, 32768);
+  shrq(rdi, 3);
+  addl(rdi, 536870912);
+  jmp(L_2TAG_PACKET_6_0_1);
+
+  bind(L_2TAG_PACKET_2_0_1);
+  movsd(xmm0, Address(rsp, 8));
+  mulsd(xmm0, ExternalAddress(NEG_ZERO));    //0x00000000UL, 0x80000000UL
+  movq(Address(rsp, 0), xmm0);
+
+  bind(L_2TAG_PACKET_13_0_1);
+
+  bind(B1_4);
+  addq(rsp, 16);
+  pop(rbx);
+}
+#else
+// The 32 bit code is at most SSE2 compliant
+
+ALIGNED_(16) juint _static_const_table_cos[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL,
+    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
+    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL,
+    0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL,
+    0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL,
+    0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL,
+    0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL,
+    0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL,
+    0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL,
+    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
+    0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL,
+    0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL,
+    0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL,
+    0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL,
+    0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL,
+    0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL,
+    0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL,
+    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
+    0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL,
+    0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL,
+    0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL,
+    0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL,
+    0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL,
+    0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL,
+    0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL,
+    0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL,
+    0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL,
+    0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL,
+    0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL,
+    0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL,
+    0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL,
+    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
+    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL,
+    0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL,
+    0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL,
+    0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL,
+    0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL,
+    0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL,
+    0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL,
+    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
+    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL,
+    0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL,
+    0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL,
+    0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL,
+    0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL,
+    0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL,
+    0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL,
+    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
+    0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL,
+    0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
+    0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL,
+    0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL,
+    0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL,
+    0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL,
+    0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL,
+    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL,
+    0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL,
+    0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
+    0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL,
+    0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL,
+    0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL,
+    0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL,
+    0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL,
+    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL,
+    0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL,
+    0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
+    0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL,
+    0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL,
+    0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL,
+    0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL,
+    0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL,
+    0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL,
+    0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL,
+    0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL,
+    0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL,
+    0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL,
+    0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL,
+    0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL,
+    0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL,
+    0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
+    0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL,
+    0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL,
+    0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL,
+    0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL,
+    0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL,
+    0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL,
+    0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL,
+    0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
+    0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL,
+    0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL,
+    0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL,
+    0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL,
+    0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL,
+    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL,
+    0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL,
+    0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
+    0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL,
+    0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL,
+    0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL,
+    0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL,
+    0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL,
+    0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL,
+    0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+};
+//registers,
+// input: (rbp + 8)
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, rbx (tmp)
+
+// Code generated by Intel C compiler for LIBM library
+
+void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
+  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start;
+
+  assert_different_registers(tmp, eax, ecx, edx);
+
+  address static_const_table_cos = (address)_static_const_table_cos;
+
+  bind(start);
+  subl(rsp, 120);
+  movl(Address(rsp, 56), tmp);
+  lea(tmp, ExternalAddress(static_const_table_cos));
+  movsd(xmm0, Address(rsp, 128));
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  subl(eax, 12336);
+  cmpl(eax, 4293);
+  jcc(Assembler::above, L_2TAG_PACKET_0_0_2);
+  movsd(xmm1, Address(tmp, 2160));
+  mulsd(xmm1, xmm0);
+  movdqu(xmm5, Address(tmp, 2240));
+  movsd(xmm4, Address(tmp, 2224));
+  pand(xmm4, xmm0);
+  por(xmm5, xmm4);
+  movsd(xmm3, Address(tmp, 2128));
+  movdqu(xmm2, Address(tmp, 2112));
+  addpd(xmm1, xmm5);
+  cvttsd2sil(edx, xmm1);
+  cvtsi2sdl(xmm1, edx);
+  mulsd(xmm3, xmm1);
+  unpcklpd(xmm1, xmm1);
+  addl(edx, 1865232);
+  movdqu(xmm4, xmm0);
+  andl(edx, 63);
+  movdqu(xmm5, Address(tmp, 2096));
+  lea(eax, Address(tmp, 0));
+  shll(edx, 5);
+  addl(eax, edx);
+  mulpd(xmm2, xmm1);
+  subsd(xmm0, xmm3);
+  mulsd(xmm1, Address(tmp, 2144));
+  subsd(xmm4, xmm3);
+  movsd(xmm7, Address(eax, 8));
+  unpcklpd(xmm0, xmm0);
+  movapd(xmm3, xmm4);
+  subsd(xmm4, xmm2);
+  mulpd(xmm5, xmm0);
+  subpd(xmm0, xmm2);
+  movdqu(xmm6, Address(tmp, 2064));
+  mulsd(xmm7, xmm4);
+  subsd(xmm3, xmm4);
+  mulpd(xmm5, xmm0);
+  mulpd(xmm0, xmm0);
+  subsd(xmm3, xmm2);
+  movdqu(xmm2, Address(eax, 0));
+  subsd(xmm1, xmm3);
+  movsd(xmm3, Address(eax, 24));
+  addsd(xmm2, xmm3);
+  subsd(xmm7, xmm2);
+  mulsd(xmm2, xmm4);
+  mulpd(xmm6, xmm0);
+  mulsd(xmm3, xmm4);
+  mulpd(xmm2, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm5, Address(tmp, 2080));
+  mulsd(xmm4, Address(eax, 0));
+  addpd(xmm6, Address(tmp, 2048));
+  mulpd(xmm5, xmm0);
+  movapd(xmm0, xmm3);
+  addsd(xmm3, Address(eax, 8));
+  mulpd(xmm1, xmm7);
+  movapd(xmm7, xmm4);
+  addsd(xmm4, xmm3);
+  addpd(xmm6, xmm5);
+  movsd(xmm5, Address(eax, 8));
+  subsd(xmm5, xmm3);
+  subsd(xmm3, xmm4);
+  addsd(xmm1, Address(eax, 16));
+  mulpd(xmm6, xmm2);
+  addsd(xmm5, xmm0);
+  addsd(xmm3, xmm7);
+  addsd(xmm1, xmm5);
+  addsd(xmm1, xmm3);
+  addsd(xmm1, xmm6);
+  unpckhpd(xmm6, xmm6);
+  addsd(xmm1, xmm6);
+  addsd(xmm4, xmm1);
+  movsd(Address(rsp, 0), xmm4);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  pinsrw(xmm0, eax, 3);
+  movsd(xmm1, Address(tmp, 2192));
+  subsd(xmm1, xmm0);
+  movsd(Address(rsp, 0), xmm1);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movl(eax, Address(rsp, 132));
+  andl(eax, 2146435072);
+  cmpl(eax, 2146435072);
+  jcc(Assembler::equal, L_2TAG_PACKET_3_0_2);
+  subl(rsp, 32);
+  movsd(Address(rsp, 0), xmm0);
+  lea(eax, Address(rsp, 40));
+  movl(Address(rsp, 8), eax);
+  movl(eax, 1);
+  movl(Address(rsp, 12), eax);
+  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge())));
+  addl(rsp, 32);
+  fld_d(Address(rsp, 8));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  fld_d(Address(rsp, 128));
+  fmul_d(Address(tmp, 2208));
+
+  bind(L_2TAG_PACKET_1_0_2);
+  movl(tmp, Address(rsp, 56));
+}
+#endif
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_exp.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_exp.cpp
new file mode 100644
index 0000000..faea7b9
--- /dev/null
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_exp.cpp
@@ -0,0 +1,674 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+* Intel Math Library (LIBM) Source Code
+*
+* 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 "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
+/******************************************************************************/
+//                     ALGORITHM DESCRIPTION - EXP()
+//                     ---------------------
+//
+// Description:
+//  Let K = 64 (table size).
+//        x    x/log(2)     n
+//       e  = 2          = 2 * T[j] * (1 + P(y))
+//  where
+//       x = m*log(2)/K + y,    y in [-log(2)/K..log(2)/K]
+//       m = n*K + j,           m,n,j - signed integer, j in [-K/2..K/2]
+//                  j/K
+//       values of 2   are tabulated as T[j] = T_hi[j] ( 1 + T_lo[j]).
+//
+//       P(y) is a minimax polynomial approximation of exp(x)-1
+//       on small interval [-log(2)/K..log(2)/K] (were calculated by Maple V).
+//
+//  To avoid problems with arithmetic overflow and underflow,
+//            n                        n1  n2
+//  value of 2  is safely computed as 2 * 2 where n1 in [-BIAS/2..BIAS/2]
+//  where BIAS is a value of exponent bias.
+//
+// Special cases:
+//  exp(NaN) = NaN
+//  exp(+INF) = +INF
+//  exp(-INF) = 0
+//  exp(x) = 1 for subnormals
+//  for finite argument, only exp(0)=1 is exact
+//  For IEEE double
+//    if x >  709.782712893383973096 then exp(x) overflow
+//    if x < -745.133219101941108420 then exp(x) underflow
+//
+/******************************************************************************/
+
+#ifdef _LP64
+// The 64 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _cv[] =
+{
+    0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL, 0xfefa0000UL,
+    0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL, 0x3d1cf79aUL,
+    0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL,
+    0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL,
+    0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL
+};
+
+ALIGNED_(16) juint _shifter[] =
+{
+    0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL
+};
+
+ALIGNED_(16) juint _mmask[] =
+{
+    0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL
+};
+
+ALIGNED_(16) juint _bias[] =
+{
+    0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL
+};
+
+ALIGNED_(16) juint _Tbl_addr[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL,
+    0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL,
+    0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL,
+    0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL,
+    0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL,
+    0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL,
+    0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL,
+    0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL,
+    0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL,
+    0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL,
+    0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL,
+    0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL,
+    0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL,
+    0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL,
+    0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL,
+    0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL,
+    0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL,
+    0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL,
+    0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL,
+    0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL,
+    0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL,
+    0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL,
+    0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL,
+    0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL,
+    0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL,
+    0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL,
+    0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL,
+    0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL,
+    0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL,
+    0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL,
+    0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL,
+    0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL,
+    0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL,
+    0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL,
+    0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL,
+    0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL,
+    0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL,
+    0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL,
+    0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL,
+    0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL,
+    0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL,
+    0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL,
+    0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL,
+    0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL,
+    0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL,
+    0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL,
+    0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL,
+    0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL,
+    0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL,
+    0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL,
+    0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL,
+    0x000fa7c1UL
+};
+
+ALIGNED_(16) juint _ALLONES[] =
+{
+    0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL
+};
+
+ALIGNED_(16) juint _ebias[] =
+{
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL
+};
+
+ALIGNED_(4) juint _XMAX[] =
+{
+    0xffffffffUL, 0x7fefffffUL
+};
+
+ALIGNED_(4) juint _XMIN[] =
+{
+    0x00000000UL, 0x00100000UL
+};
+
+ALIGNED_(4) juint _INF[] =
+{
+    0x00000000UL, 0x7ff00000UL
+};
+
+ALIGNED_(4) juint _ZERO[] =
+{
+    0x00000000UL, 0x00000000UL
+};
+
+ALIGNED_(4) juint _ONE_val[] =
+{
+    0x00000000UL, 0x3ff00000UL
+};
+
+
+// Registers:
+// input: xmm0
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, tmp - r11
+
+// Code generated by Intel C compiler for LIBM library
+
+void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
+  Label L_2TAG_PACKET_12_0_2, B1_3, B1_5, start;
+
+  assert_different_registers(tmp, eax, ecx, edx);
+  jmp(start);
+  address cv = (address)_cv;
+  address Shifter = (address)_shifter;
+  address mmask = (address)_mmask;
+  address bias = (address)_bias;
+  address Tbl_addr = (address)_Tbl_addr;
+  address ALLONES = (address)_ALLONES;
+  address ebias = (address)_ebias;
+  address XMAX = (address)_XMAX;
+  address XMIN = (address)_XMIN;
+  address INF = (address)_INF;
+  address ZERO = (address)_ZERO;
+  address ONE_val = (address)_ONE_val;
+
+  bind(start);
+  subq(rsp, 24);
+  movsd(Address(rsp, 8), xmm0);
+  unpcklpd(xmm0, xmm0);
+  movdqu(xmm1, ExternalAddress(cv));       // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL
+  movdqu(xmm6, ExternalAddress(Shifter));  // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL
+  movdqu(xmm2, ExternalAddress(16 + cv));    // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL
+  movdqu(xmm3, ExternalAddress(32 + cv));    // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  movl(edx, 16527);
+  subl(edx, eax);
+  subl(eax, 15504);
+  orl(edx, eax);
+  cmpl(edx, INT_MIN);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+  mulpd(xmm1, xmm0);
+  addpd(xmm1, xmm6);
+  movapd(xmm7, xmm1);
+  subpd(xmm1, xmm6);
+  mulpd(xmm2, xmm1);
+  movdqu(xmm4, ExternalAddress(64 + cv));    // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL
+  mulpd(xmm3, xmm1);
+  movdqu(xmm5, ExternalAddress(80 + cv));    // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL
+  subpd(xmm0, xmm2);
+  movdl(eax, xmm7);
+  movl(ecx, eax);
+  andl(ecx, 63);
+  shll(ecx, 4);
+  sarl(eax, 6);
+  movl(edx, eax);
+  movdqu(xmm6, ExternalAddress(mmask));    // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL
+  pand(xmm7, xmm6);
+  movdqu(xmm6, ExternalAddress(bias));     // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL
+  paddq(xmm7, xmm6);
+  psllq(xmm7, 46);
+  subpd(xmm0, xmm3);
+  lea(tmp, ExternalAddress(Tbl_addr));
+  movdqu(xmm2, Address(ecx, tmp));
+  mulpd(xmm4, xmm0);
+  movapd(xmm6, xmm0);
+  movapd(xmm1, xmm0);
+  mulpd(xmm6, xmm6);
+  mulpd(xmm0, xmm6);
+  addpd(xmm5, xmm4);
+  mulsd(xmm0, xmm6);
+  mulpd(xmm6, ExternalAddress(48 + cv));     // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL
+  addsd(xmm1, xmm2);
+  unpckhpd(xmm2, xmm2);
+  mulpd(xmm0, xmm5);
+  addsd(xmm1, xmm0);
+  por(xmm2, xmm7);
+  unpckhpd(xmm0, xmm0);
+  addsd(xmm0, xmm1);
+  addsd(xmm0, xmm6);
+  addl(edx, 894);
+  cmpl(edx, 1916);
+  jcc(Assembler::above, L_2TAG_PACKET_1_0_2);
+  mulsd(xmm0, xmm2);
+  addsd(xmm0, xmm2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  xorpd(xmm3, xmm3);
+  movdqu(xmm4, ExternalAddress(ALLONES));  // 0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL
+  movl(edx, -1022);
+  subl(edx, eax);
+  movdl(xmm5, edx);
+  psllq(xmm4, xmm5);
+  movl(ecx, eax);
+  sarl(eax, 1);
+  pinsrw(xmm3, eax, 3);
+  movdqu(xmm6, ExternalAddress(ebias));    // 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL
+  psllq(xmm3, 4);
+  psubd(xmm2, xmm3);
+  mulsd(xmm0, xmm2);
+  cmpl(edx, 52);
+  jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
+  pand(xmm4, xmm2);
+  paddd(xmm3, xmm6);
+  subsd(xmm2, xmm4);
+  addsd(xmm0, xmm2);
+  cmpl(ecx, 1023);
+  jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2);
+  pextrw(ecx, xmm0, 3);
+  andl(ecx, 32768);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
+  movapd(xmm6, xmm0);
+  addsd(xmm0, xmm4);
+  mulsd(xmm0, xmm3);
+  pextrw(ecx, xmm0, 3);
+  andl(ecx, 32752);
+  cmpl(ecx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_5_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  mulsd(xmm6, xmm3);
+  mulsd(xmm4, xmm3);
+  movdqu(xmm0, xmm6);
+  pxor(xmm6, xmm4);
+  psrad(xmm6, 31);
+  pshufd(xmm6, xmm6, 85);
+  psllq(xmm0, 1);
+  psrlq(xmm0, 1);
+  pxor(xmm0, xmm6);
+  psrlq(xmm6, 63);
+  paddq(xmm0, xmm6);
+  paddq(xmm0, xmm4);
+  movl(Address(rsp, 0), 15);
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  addsd(xmm0, xmm4);
+  mulsd(xmm0, xmm3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  addsd(xmm0, xmm4);
+  mulsd(xmm0, xmm3);
+  pextrw(ecx, xmm0, 3);
+  andl(ecx, 32752);
+  cmpl(ecx, 32752);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  paddd(xmm3, xmm6);
+  addpd(xmm0, xmm2);
+  mulsd(xmm0, xmm3);
+  movl(Address(rsp, 0), 15);
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  cmpl(eax, 2146435072);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_9_0_2);
+  movl(eax, Address(rsp, 12));
+  cmpl(eax, INT_MIN);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_10_0_2);
+  movsd(xmm0, ExternalAddress(XMAX));      // 0xffffffffUL, 0x7fefffffUL
+  mulsd(xmm0, xmm0);
+
+  bind(L_2TAG_PACKET_7_0_2);
+  movl(Address(rsp, 0), 14);
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_10_0_2);
+  movsd(xmm0, ExternalAddress(XMIN));      // 0x00000000UL, 0x00100000UL
+  mulsd(xmm0, xmm0);
+  movl(Address(rsp, 0), 15);
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_9_0_2);
+  movl(edx, Address(rsp, 8));
+  cmpl(eax, 2146435072);
+  jcc(Assembler::above, L_2TAG_PACKET_11_0_2);
+  cmpl(edx, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2);
+  movl(eax, Address(rsp, 12));
+  cmpl(eax, 2146435072);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_2);
+  movsd(xmm0, ExternalAddress(INF));       // 0x00000000UL, 0x7ff00000UL
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_12_0_2);
+  movsd(xmm0, ExternalAddress(ZERO));      // 0x00000000UL, 0x00000000UL
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_11_0_2);
+  movsd(xmm0, Address(rsp, 8));
+  addsd(xmm0, xmm0);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  movl(eax, Address(rsp, 12));
+  andl(eax, 2147483647);
+  cmpl(eax, 1083179008);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_8_0_2);
+  movsd(Address(rsp, 8), xmm0);
+  addsd(xmm0, ExternalAddress(ONE_val));   // 0x00000000UL, 0x3ff00000UL
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_6_0_2);
+  movq(Address(rsp, 16), xmm0);
+
+  bind(B1_3);
+  movq(xmm0, Address(rsp, 16));
+
+  bind(B1_5);
+  addq(rsp, 24);
+}
+#else
+// The 32 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _static_const_table[] =
+{
+    0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL, 0xffffffc0UL,
+    0x00000000UL, 0xffffffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL,
+    0x0000ffc0UL, 0x00000000UL, 0x00000000UL, 0x43380000UL, 0x00000000UL,
+    0x43380000UL, 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL,
+    0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL,
+    0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL,
+    0xfffffffeUL, 0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL,
+    0x3fa55555UL, 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL,
+    0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL,
+    0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL,
+    0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL,
+    0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL,
+    0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL,
+    0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL,
+    0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL,
+    0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL,
+    0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL,
+    0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL,
+    0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL,
+    0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL,
+    0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL,
+    0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL,
+    0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL,
+    0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL,
+    0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL,
+    0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL,
+    0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL,
+    0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL,
+    0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL,
+    0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL,
+    0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL,
+    0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL,
+    0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL,
+    0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL,
+    0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL,
+    0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL,
+    0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL,
+    0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL,
+    0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL,
+    0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL,
+    0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL,
+    0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL,
+    0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL,
+    0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL,
+    0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL,
+    0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL,
+    0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL,
+    0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL,
+    0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL,
+    0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL,
+    0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL,
+    0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL,
+    0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL,
+    0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL,
+    0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL,
+    0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL,
+    0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL,
+    0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL,
+    0x000fa7c1UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x7ff00000UL,
+    0x00000000UL, 0x00000000UL, 0xffffffffUL, 0x7fefffffUL, 0x00000000UL,
+    0x00100000UL
+};
+
+//registers,
+// input: (rbp + 8)
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, rbx (tmp)
+
+// Code generated by Intel C compiler for LIBM library
+
+void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
+  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start;
+
+  assert_different_registers(tmp, eax, ecx, edx);
+  jmp(start);
+  address static_const_table = (address)_static_const_table;
+
+  bind(start);
+  subl(rsp, 120);
+  movl(Address(rsp, 64), tmp);
+  lea(tmp, ExternalAddress(static_const_table));
+  movdqu(xmm0, Address(rsp, 128));
+  unpcklpd(xmm0, xmm0);
+  movdqu(xmm1, Address(tmp, 64));          // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL
+  movdqu(xmm6, Address(tmp, 48));          // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL
+  movdqu(xmm2, Address(tmp, 80));          // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL
+  movdqu(xmm3, Address(tmp, 96));          // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  movl(edx, 16527);
+  subl(edx, eax);
+  subl(eax, 15504);
+  orl(edx, eax);
+  cmpl(edx, INT_MIN);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+  mulpd(xmm1, xmm0);
+  addpd(xmm1, xmm6);
+  movapd(xmm7, xmm1);
+  subpd(xmm1, xmm6);
+  mulpd(xmm2, xmm1);
+  movdqu(xmm4, Address(tmp, 128));         // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL
+  mulpd(xmm3, xmm1);
+  movdqu(xmm5, Address(tmp, 144));         // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL
+  subpd(xmm0, xmm2);
+  movdl(eax, xmm7);
+  movl(ecx, eax);
+  andl(ecx, 63);
+  shll(ecx, 4);
+  sarl(eax, 6);
+  movl(edx, eax);
+  movdqu(xmm6, Address(tmp, 16));          // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL
+  pand(xmm7, xmm6);
+  movdqu(xmm6, Address(tmp, 32));          // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL
+  paddq(xmm7, xmm6);
+  psllq(xmm7, 46);
+  subpd(xmm0, xmm3);
+  movdqu(xmm2, Address(tmp, ecx, Address::times_1, 160));
+  mulpd(xmm4, xmm0);
+  movapd(xmm6, xmm0);
+  movapd(xmm1, xmm0);
+  mulpd(xmm6, xmm6);
+  mulpd(xmm0, xmm6);
+  addpd(xmm5, xmm4);
+  mulsd(xmm0, xmm6);
+  mulpd(xmm6, Address(tmp, 112));          // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL
+  addsd(xmm1, xmm2);
+  unpckhpd(xmm2, xmm2);
+  mulpd(xmm0, xmm5);
+  addsd(xmm1, xmm0);
+  por(xmm2, xmm7);
+  unpckhpd(xmm0, xmm0);
+  addsd(xmm0, xmm1);
+  addsd(xmm0, xmm6);
+  addl(edx, 894);
+  cmpl(edx, 1916);
+  jcc(Assembler::above, L_2TAG_PACKET_1_0_2);
+  mulsd(xmm0, xmm2);
+  addsd(xmm0, xmm2);
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  fnstcw(Address(rsp, 24));
+  movzwl(edx, Address(rsp, 24));
+  orl(edx, 768);
+  movw(Address(rsp, 28), edx);
+  fldcw(Address(rsp, 28));
+  movl(edx, eax);
+  sarl(eax, 1);
+  subl(edx, eax);
+  movdqu(xmm6, Address(tmp, 0));           // 0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL
+  pandn(xmm6, xmm2);
+  addl(eax, 1023);
+  movdl(xmm3, eax);
+  psllq(xmm3, 52);
+  por(xmm6, xmm3);
+  addl(edx, 1023);
+  movdl(xmm4, edx);
+  psllq(xmm4, 52);
+  movsd(Address(rsp, 8), xmm0);
+  fld_d(Address(rsp, 8));
+  movsd(Address(rsp, 16), xmm6);
+  fld_d(Address(rsp, 16));
+  fmula(1);
+  faddp(1);
+  movsd(Address(rsp, 8), xmm4);
+  fld_d(Address(rsp, 8));
+  fmulp(1);
+  fstp_d(Address(rsp, 8));
+  movsd(xmm0, Address(rsp, 8));
+  fldcw(Address(rsp, 24));
+  pextrw(ecx, xmm0, 3);
+  andl(ecx, 32752);
+  cmpl(ecx, 32752);
+  jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2);
+  cmpl(ecx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
+  jmp(L_2TAG_PACKET_2_0_2);
+  cmpl(ecx, INT_MIN);
+  jcc(Assembler::less, L_2TAG_PACKET_3_0_2);
+  cmpl(ecx, -1064950997);
+  jcc(Assembler::less, L_2TAG_PACKET_2_0_2);
+  jcc(Assembler::greater, L_2TAG_PACKET_4_0_2);
+  movl(edx, Address(rsp, 128));
+  cmpl(edx, -17155601);
+  jcc(Assembler::less, L_2TAG_PACKET_2_0_2);
+  jmp(L_2TAG_PACKET_4_0_2);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  movl(edx, 14);
+  jmp(L_2TAG_PACKET_5_0_2);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  movl(edx, 15);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  movsd(Address(rsp, 0), xmm0);
+  movsd(xmm0, Address(rsp, 128));
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_7_0_2);
+  cmpl(eax, 2146435072);
+  jcc(Assembler::greaterEqual, L_2TAG_PACKET_8_0_2);
+  movl(eax, Address(rsp, 132));
+  cmpl(eax, INT_MIN);
+  jcc(Assembler::greaterEqual, L_2TAG_PACKET_9_0_2);
+  movsd(xmm0, Address(tmp, 1208));         // 0xffffffffUL, 0x7fefffffUL
+  mulsd(xmm0, xmm0);
+  movl(edx, 14);
+  jmp(L_2TAG_PACKET_5_0_2);
+
+  bind(L_2TAG_PACKET_9_0_2);
+  movsd(xmm0, Address(tmp, 1216));
+  mulsd(xmm0, xmm0);
+  movl(edx, 15);
+  jmp(L_2TAG_PACKET_5_0_2);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  movl(edx, Address(rsp, 128));
+  cmpl(eax, 2146435072);
+  jcc(Assembler::above, L_2TAG_PACKET_10_0_2);
+  cmpl(edx, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_2);
+  movl(eax, Address(rsp, 132));
+  cmpl(eax, 2146435072);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2);
+  movsd(xmm0, Address(tmp, 1192));         // 0x00000000UL, 0x7ff00000UL
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_11_0_2);
+  movsd(xmm0, Address(tmp, 1200));         // 0x00000000UL, 0x00000000UL
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_10_0_2);
+  movsd(xmm0, Address(rsp, 128));
+  addsd(xmm0, xmm0);
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  movl(eax, Address(rsp, 132));
+  andl(eax, 2147483647);
+  cmpl(eax, 1083179008);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2);
+  movsd(xmm0, Address(rsp, 128));
+  addsd(xmm0, Address(tmp, 1184));         // 0x00000000UL, 0x3ff00000UL
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movsd(Address(rsp, 48), xmm0);
+  fld_d(Address(rsp, 48));
+
+  bind(L_2TAG_PACKET_6_0_2);
+  movl(tmp, Address(rsp, 64));
+}
+#endif
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_log.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log.cpp
new file mode 100644
index 0000000..cd4ed0d
--- /dev/null
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log.cpp
@@ -0,0 +1,655 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+* Intel Math Library (LIBM) Source Code
+*
+* 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 "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
+/******************************************************************************/
+//                     ALGORITHM DESCRIPTION - LOG()
+//                     ---------------------
+//
+//    x=2^k * mx, mx in [1,2)
+//
+//    Get B~1/mx based on the output of rcpss instruction (B0)
+//    B = int((B0*2^7+0.5))/2^7
+//
+//    Reduced argument: r=B*mx-1.0 (computed accurately in high and low parts)
+//
+//    Result:  k*log(2) - log(B) + p(r) if |x-1| >= small value (2^-6)  and
+//             p(r) is a degree 7 polynomial
+//             -log(B) read from data table (high, low parts)
+//             Result is formed from high and low parts
+//
+// Special cases:
+//  log(NaN) = quiet NaN, and raise invalid exception
+//  log(+INF) = that INF
+//  log(0) = -INF with divide-by-zero exception raised
+//  log(1) = +0
+//  log(x) = NaN with invalid exception raised if x < -0, including -INF
+//
+/******************************************************************************/
+
+#ifdef _LP64
+// The 64 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _L_tbl[] =
+{
+    0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL,
+    0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL,
+    0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL,
+    0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL,
+    0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL,
+    0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL,
+    0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL,
+    0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL,
+    0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL,
+    0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL,
+    0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL,
+    0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL,
+    0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL,
+    0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL,
+    0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL,
+    0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL,
+    0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL,
+    0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL,
+    0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL,
+    0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL,
+    0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL,
+    0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL,
+    0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL,
+    0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL,
+    0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL,
+    0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL,
+    0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL,
+    0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL,
+    0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL,
+    0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL,
+    0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL,
+    0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL,
+    0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL,
+    0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL,
+    0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL,
+    0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL,
+    0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL,
+    0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL,
+    0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL,
+    0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL,
+    0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL,
+    0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL,
+    0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL,
+    0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL,
+    0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL,
+    0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL,
+    0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL,
+    0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL,
+    0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL,
+    0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL,
+    0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL,
+    0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL,
+    0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL,
+    0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL,
+    0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL,
+    0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL,
+    0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL,
+    0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL,
+    0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL,
+    0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL,
+    0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL,
+    0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL,
+    0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL,
+    0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL,
+    0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL,
+    0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL,
+    0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL,
+    0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL,
+    0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL,
+    0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL,
+    0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL,
+    0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL,
+    0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL,
+    0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL,
+    0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL,
+    0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL,
+    0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL,
+    0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL,
+    0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL,
+    0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL,
+    0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL,
+    0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL,
+    0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL,
+    0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL,
+    0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL,
+    0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL,
+    0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL,
+    0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL,
+    0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL,
+    0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL,
+    0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL,
+    0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL,
+    0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL,
+    0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL,
+    0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL,
+    0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL,
+    0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL,
+    0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL,
+    0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL,
+    0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL,
+    0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL,
+    0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL,
+    0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x80000000UL
+};
+
+ALIGNED_(16) juint _log2[] =
+{
+    0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL
+};
+
+ALIGNED_(16) juint _coeff[] =
+{
+    0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL,
+    0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL,
+    0x00000000UL, 0xbfe00000UL
+};
+
+//registers,
+// input: xmm0
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, r8, r11
+
+void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2;
+  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start;
+
+  assert_different_registers(tmp1, tmp2, eax, ecx, edx);
+  jmp(start);
+  address L_tbl = (address)_L_tbl;
+  address log2 = (address)_log2;
+  address coeff = (address)_coeff;
+
+  bind(start);
+  subq(rsp, 24);
+  movsd(Address(rsp, 0), xmm0);
+  mov64(rax, 0x3ff0000000000000);
+  movdq(xmm2, rax);
+  mov64(rdx, 0x77f0000000000000);
+  movdq(xmm3, rdx);
+  movl(ecx, 32768);
+  movdl(xmm4, rcx);
+  mov64(tmp1, 0xffffe00000000000);
+  movdq(xmm5, tmp1);
+  movdqu(xmm1, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 16352);
+  psrlq(xmm0, 27);
+  lea(tmp2, ExternalAddress(L_tbl));
+  psrld(xmm0, 2);
+  rcpps(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 228);
+  psrlq(xmm1, 12);
+  subl(eax, 16);
+  cmpl(eax, 32736);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  paddd(xmm0, xmm4);
+  por(xmm1, xmm3);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  pand(xmm5, xmm1);
+  pand(xmm0, xmm6);
+  subsd(xmm1, xmm5);
+  mulpd(xmm5, xmm0);
+  andl(eax, 32752);
+  subl(eax, ecx);
+  cvtsi2sdl(xmm7, eax);
+  mulsd(xmm1, xmm0);
+  movq(xmm6, ExternalAddress(log2));       // 0xfefa3800UL, 0x3fa62e42UL
+  movdqu(xmm3, ExternalAddress(coeff));    // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL
+  subsd(xmm5, xmm2);
+  andl(edx, 16711680);
+  shrl(edx, 12);
+  movdqu(xmm0, Address(tmp2, edx));
+  movdqu(xmm4, ExternalAddress(16 + coeff)); // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL
+  addsd(xmm1, xmm5);
+  movdqu(xmm2, ExternalAddress(32 + coeff)); // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL
+  mulsd(xmm6, xmm7);
+  if (VM_Version::supports_sse3()) {
+    movddup(xmm5, xmm1);
+  }
+  else {
+    movdqu(xmm5, xmm1);
+    movlhps(xmm5, xmm5);
+  }
+  mulsd(xmm7, ExternalAddress(8 + log2));    // 0x93c76730UL, 0x3ceef357UL
+  mulsd(xmm3, xmm1);
+  addsd(xmm0, xmm6);
+  mulpd(xmm4, xmm5);
+  mulpd(xmm5, xmm5);
+  if (VM_Version::supports_sse3()) {
+    movddup(xmm6, xmm0);
+  }
+  else {
+    movdqu(xmm6, xmm0);
+    movlhps(xmm6, xmm6);
+  }
+  addsd(xmm0, xmm1);
+  addpd(xmm4, xmm2);
+  mulpd(xmm3, xmm5);
+  subsd(xmm6, xmm0);
+  mulsd(xmm4, xmm1);
+  pshufd(xmm2, xmm0, 238);
+  addsd(xmm1, xmm6);
+  mulsd(xmm5, xmm5);
+  addsd(xmm7, xmm2);
+  addpd(xmm4, xmm3);
+  addsd(xmm1, xmm7);
+  mulpd(xmm4, xmm5);
+  addsd(xmm1, xmm4);
+  pshufd(xmm5, xmm4, 238);
+  addsd(xmm1, xmm5);
+  addsd(xmm0, xmm1);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  movq(xmm0, Address(rsp, 0));
+  movq(xmm1, Address(rsp, 0));
+  addl(eax, 16);
+  cmpl(eax, 32768);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_2_0_2);
+  cmpl(eax, 16);
+  jcc(Assembler::below, L_2TAG_PACKET_3_0_2);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  addsd(xmm0, xmm0);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  jcc(Assembler::above, L_2TAG_PACKET_4_0_2);
+  cmpl(edx, 0);
+  jcc(Assembler::above, L_2TAG_PACKET_4_0_2);
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  xorpd(xmm1, xmm1);
+  addsd(xmm1, xmm0);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
+  xorpd(xmm1, xmm1);
+  movl(eax, 18416);
+  pinsrw(xmm1, eax, 3);
+  mulsd(xmm0, xmm1);
+  movdqu(xmm1, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  psrlq(xmm0, 27);
+  movl(ecx, 18416);
+  psrld(xmm0, 2);
+  rcpps(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 228);
+  psrlq(xmm1, 12);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  addl(ecx, ecx);
+  cmpl(ecx, -2097152);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
+
+  bind(L_2TAG_PACKET_6_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32752);
+  pinsrw(xmm1, eax, 3);
+  mulsd(xmm0, xmm1);
+  movl(Address(rsp, 16), 3);
+  jmp(L_2TAG_PACKET_8_0_2);
+  bind(L_2TAG_PACKET_7_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 49136);
+  pinsrw(xmm0, eax, 3);
+  divsd(xmm0, xmm1);
+  movl(Address(rsp, 16), 2);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  movq(Address(rsp, 8), xmm0);
+
+  bind(B1_3);
+  movq(xmm0, Address(rsp, 8));
+
+  bind(B1_5);
+  addq(rsp, 24);
+}
+#else
+// The 32 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _static_const_table_log[] =
+{
+    0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL,
+    0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL,
+    0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL,
+    0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL,
+    0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL,
+    0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL,
+    0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL,
+    0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL,
+    0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL,
+    0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL,
+    0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL,
+    0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL,
+    0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL,
+    0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL,
+    0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL,
+    0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL,
+    0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL,
+    0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL,
+    0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL,
+    0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL,
+    0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL,
+    0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL,
+    0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL,
+    0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL,
+    0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL,
+    0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL,
+    0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL,
+    0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL,
+    0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL,
+    0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL,
+    0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL,
+    0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL,
+    0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL,
+    0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL,
+    0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL,
+    0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL,
+    0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL,
+    0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL,
+    0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL,
+    0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL,
+    0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL,
+    0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL,
+    0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL,
+    0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL,
+    0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL,
+    0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL,
+    0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL,
+    0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL,
+    0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL,
+    0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL,
+    0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL,
+    0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL,
+    0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL,
+    0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL,
+    0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL,
+    0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL,
+    0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL,
+    0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL,
+    0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL,
+    0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL,
+    0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL,
+    0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL,
+    0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL,
+    0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL,
+    0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL,
+    0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL,
+    0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL,
+    0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL,
+    0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL,
+    0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL,
+    0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL,
+    0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL,
+    0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL,
+    0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL,
+    0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL,
+    0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL,
+    0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL,
+    0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL,
+    0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL,
+    0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL,
+    0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL,
+    0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL,
+    0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL,
+    0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL,
+    0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL,
+    0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL,
+    0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL,
+    0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL,
+    0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL,
+    0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL,
+    0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL,
+    0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL,
+    0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL,
+    0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL,
+    0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL,
+    0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL,
+    0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL,
+    0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL,
+    0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL,
+    0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL,
+    0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL,
+    0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL,
+    0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x80000000UL, 0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL,
+    0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL,
+    0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL,
+    0x00000000UL, 0xbfe00000UL, 0x00000000UL, 0xffffe000UL, 0x00000000UL,
+    0xffffe000UL
+};
+//registers,
+// input: xmm0
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, rbx (tmp)
+
+void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2;
+  Label L_2TAG_PACKET_10_0_2, start;
+
+  assert_different_registers(tmp, eax, ecx, edx);
+  jmp(start);
+  address static_const_table = (address)_static_const_table_log;
+
+  bind(start);
+  subl(rsp, 104);
+  movl(Address(rsp, 40), tmp);
+  lea(tmp, ExternalAddress(static_const_table));
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  xorpd(xmm3, xmm3);
+  movl(edx, 30704);
+  pinsrw(xmm3, edx, 3);
+  movsd(xmm0, Address(rsp, 112));
+  movapd(xmm1, xmm0);
+  movl(ecx, 32768);
+  movdl(xmm4, ecx);
+  movsd(xmm5, Address(tmp, 2128));         // 0x00000000UL, 0xffffe000UL
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  psllq(xmm0, 5);
+  movl(ecx, 16352);
+  psrlq(xmm0, 34);
+  rcpss(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 228);
+  psrlq(xmm1, 12);
+  subl(eax, 16);
+  cmpl(eax, 32736);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  paddd(xmm0, xmm4);
+  por(xmm1, xmm3);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  pand(xmm5, xmm1);
+  pand(xmm0, xmm6);
+  subsd(xmm1, xmm5);
+  mulpd(xmm5, xmm0);
+  andl(eax, 32752);
+  subl(eax, ecx);
+  cvtsi2sdl(xmm7, eax);
+  mulsd(xmm1, xmm0);
+  movsd(xmm6, Address(tmp, 2064));         // 0xfefa3800UL, 0x3fa62e42UL
+  movdqu(xmm3, Address(tmp, 2080));        // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL
+  subsd(xmm5, xmm2);
+  andl(edx, 16711680);
+  shrl(edx, 12);
+  movdqu(xmm0, Address(tmp, edx));
+  movdqu(xmm4, Address(tmp, 2096));        // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL
+  addsd(xmm1, xmm5);
+  movdqu(xmm2, Address(tmp, 2112));        // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL
+  mulsd(xmm6, xmm7);
+  pshufd(xmm5, xmm1, 68);
+  mulsd(xmm7, Address(tmp, 2072));         // 0x93c76730UL, 0x3ceef357UL, 0x92492492UL, 0x3fc24924UL
+  mulsd(xmm3, xmm1);
+  addsd(xmm0, xmm6);
+  mulpd(xmm4, xmm5);
+  mulpd(xmm5, xmm5);
+  pshufd(xmm6, xmm0, 228);
+  addsd(xmm0, xmm1);
+  addpd(xmm4, xmm2);
+  mulpd(xmm3, xmm5);
+  subsd(xmm6, xmm0);
+  mulsd(xmm4, xmm1);
+  pshufd(xmm2, xmm0, 238);
+  addsd(xmm1, xmm6);
+  mulsd(xmm5, xmm5);
+  addsd(xmm7, xmm2);
+  addpd(xmm4, xmm3);
+  addsd(xmm1, xmm7);
+  mulpd(xmm4, xmm5);
+  addsd(xmm1, xmm4);
+  pshufd(xmm5, xmm4, 238);
+  addsd(xmm1, xmm5);
+  addsd(xmm0, xmm1);
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  movsd(xmm0, Address(rsp, 112));
+  movdqu(xmm1, xmm0);
+  addl(eax, 16);
+  cmpl(eax, 32768);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_3_0_2);
+  cmpl(eax, 16);
+  jcc(Assembler::below, L_2TAG_PACKET_4_0_2);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  addsd(xmm0, xmm0);
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_6_0_2);
+  jcc(Assembler::above, L_2TAG_PACKET_5_0_2);
+  cmpl(edx, 0);
+  jcc(Assembler::above, L_2TAG_PACKET_5_0_2);
+  jmp(L_2TAG_PACKET_7_0_2);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  addl(ecx, ecx);
+  cmpl(ecx, -2097152);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_6_0_2);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
+
+  bind(L_2TAG_PACKET_7_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32752);
+  pinsrw(xmm1, eax, 3);
+  movl(edx, 3);
+  mulsd(xmm0, xmm1);
+
+  bind(L_2TAG_PACKET_9_0_2);
+  movsd(Address(rsp, 0), xmm0);
+  movsd(xmm0, Address(rsp, 112));
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_10_0_2);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 49136);
+  pinsrw(xmm0, eax, 3);
+  divsd(xmm0, xmm1);
+  movl(edx, 2);
+  jmp(L_2TAG_PACKET_9_0_2);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
+  xorpd(xmm1, xmm1);
+  movl(eax, 18416);
+  pinsrw(xmm1, eax, 3);
+  mulsd(xmm0, xmm1);
+  movapd(xmm1, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  psllq(xmm0, 5);
+  movl(ecx, 18416);
+  psrlq(xmm0, 34);
+  rcpss(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 228);
+  psrlq(xmm1, 12);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movsd(Address(rsp, 24), xmm0);
+  fld_d(Address(rsp, 24));
+
+  bind(L_2TAG_PACKET_10_0_2);
+  movl(tmp, Address(rsp, 40));
+}
+#endif
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_log10.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log10.cpp
new file mode 100644
index 0000000..72a8aba
--- /dev/null
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log10.cpp
@@ -0,0 +1,687 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+* Intel Math Library (LIBM) Source Code
+*
+* 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 "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
+/******************************************************************************/
+//                     ALGORITHM DESCRIPTION - LOG10()
+//                     ---------------------
+//
+//    Let x=2^k * mx, mx in [1,2)
+//
+//    Get B~1/mx based on the output of rcpss instruction (B0)
+//    B = int((B0*LH*2^7+0.5))/2^7
+//    LH is a short approximation for log10(e)
+//
+//    Reduced argument: r=B*mx-LH (computed accurately in high and low parts)
+//
+//    Result:  k*log10(2) - log(B) + p(r)
+//             p(r) is a degree 7 polynomial
+//             -log(B) read from data table (high, low parts)
+//             Result is formed from high and low parts
+//
+// Special cases:
+//  log10(0) = -INF with divide-by-zero exception raised
+//  log10(1) = +0
+//  log10(x) = NaN with invalid exception raised if x < -0, including -INF
+//  log10(+INF) = +INF
+//
+/******************************************************************************/
+
+#ifdef _LP64
+// The 64 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _HIGHSIGMASK_log10[] =
+{
+    0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xffffe000UL
+};
+
+ALIGNED_(16) juint _LOG10_E[] =
+{
+    0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL
+};
+
+ALIGNED_(16) juint _L_tbl_log10[] =
+{
+    0x509f7800UL, 0x3fd34413UL, 0x1f12b358UL, 0x3d1fef31UL, 0x80333400UL,
+    0x3fd32418UL, 0xc671d9d0UL, 0xbcf542bfUL, 0x51195000UL, 0x3fd30442UL,
+    0x78a4b0c3UL, 0x3d18216aUL, 0x6fc79400UL, 0x3fd2e490UL, 0x80fa389dUL,
+    0xbc902869UL, 0x89d04000UL, 0x3fd2c502UL, 0x75c2f564UL, 0x3d040754UL,
+    0x4ddd1c00UL, 0x3fd2a598UL, 0xd219b2c3UL, 0xbcfa1d84UL, 0x6baa7c00UL,
+    0x3fd28651UL, 0xfd9abec1UL, 0x3d1be6d3UL, 0x94028800UL, 0x3fd2672dUL,
+    0xe289a455UL, 0xbd1ede5eUL, 0x78b86400UL, 0x3fd2482cUL, 0x6734d179UL,
+    0x3d1fe79bUL, 0xcca3c800UL, 0x3fd2294dUL, 0x981a40b8UL, 0xbced34eaUL,
+    0x439c5000UL, 0x3fd20a91UL, 0xcc392737UL, 0xbd1a9cc3UL, 0x92752c00UL,
+    0x3fd1ebf6UL, 0x03c9afe7UL, 0x3d1e98f8UL, 0x6ef8dc00UL, 0x3fd1cd7dUL,
+    0x71dae7f4UL, 0x3d08a86cUL, 0x8fe4dc00UL, 0x3fd1af25UL, 0xee9185a1UL,
+    0xbcff3412UL, 0xace59400UL, 0x3fd190eeUL, 0xc2cab353UL, 0x3cf17ed9UL,
+    0x7e925000UL, 0x3fd172d8UL, 0x6952c1b2UL, 0x3cf1521cUL, 0xbe694400UL,
+    0x3fd154e2UL, 0xcacb79caUL, 0xbd0bdc78UL, 0x26cbac00UL, 0x3fd1370dUL,
+    0xf71f4de1UL, 0xbd01f8beUL, 0x72fa0800UL, 0x3fd11957UL, 0x55bf910bUL,
+    0x3c946e2bUL, 0x5f106000UL, 0x3fd0fbc1UL, 0x39e639c1UL, 0x3d14a84bUL,
+    0xa802a800UL, 0x3fd0de4aUL, 0xd3f31d5dUL, 0xbd178385UL, 0x0b992000UL,
+    0x3fd0c0f3UL, 0x3843106fUL, 0xbd1f602fUL, 0x486ce800UL, 0x3fd0a3baUL,
+    0x8819497cUL, 0x3cef987aUL, 0x1de49400UL, 0x3fd086a0UL, 0x1caa0467UL,
+    0x3d0faec7UL, 0x4c30cc00UL, 0x3fd069a4UL, 0xa4424372UL, 0xbd1618fcUL,
+    0x94490000UL, 0x3fd04cc6UL, 0x946517d2UL, 0xbd18384bUL, 0xb7e84000UL,
+    0x3fd03006UL, 0xe0109c37UL, 0xbd19a6acUL, 0x798a0c00UL, 0x3fd01364UL,
+    0x5121e864UL, 0xbd164cf7UL, 0x38ce8000UL, 0x3fcfedbfUL, 0x46214d1aUL,
+    0xbcbbc402UL, 0xc8e62000UL, 0x3fcfb4efUL, 0xdab93203UL, 0x3d1e0176UL,
+    0x2cb02800UL, 0x3fcf7c5aUL, 0x2a2ea8e4UL, 0xbcfec86aUL, 0xeeeaa000UL,
+    0x3fcf43fdUL, 0xc18e49a4UL, 0x3cf110a8UL, 0x9bb6e800UL, 0x3fcf0bdaUL,
+    0x923cc9c0UL, 0xbd15ce99UL, 0xc093f000UL, 0x3fced3efUL, 0x4d4b51e9UL,
+    0x3d1a04c7UL, 0xec58f800UL, 0x3fce9c3cUL, 0x163cad59UL, 0x3cac8260UL,
+    0x9a907000UL, 0x3fce2d7dUL, 0x3fa93646UL, 0x3ce4a1c0UL, 0x37311000UL,
+    0x3fcdbf99UL, 0x32abd1fdUL, 0x3d07ea9dUL, 0x6744b800UL, 0x3fcd528cUL,
+    0x4dcbdfd4UL, 0xbd1b08e2UL, 0xe36de800UL, 0x3fcce653UL, 0x0b7b7f7fUL,
+    0xbd1b8f03UL, 0x77506800UL, 0x3fcc7aecUL, 0xa821c9fbUL, 0x3d13c163UL,
+    0x00ff8800UL, 0x3fcc1053UL, 0x536bca76UL, 0xbd074ee5UL, 0x70719800UL,
+    0x3fcba684UL, 0xd7da9b6bUL, 0xbd1fbf16UL, 0xc6f8d800UL, 0x3fcb3d7dUL,
+    0xe2220bb3UL, 0x3d1a295dUL, 0x16c15800UL, 0x3fcad53cUL, 0xe724911eUL,
+    0xbcf55822UL, 0x82533800UL, 0x3fca6dbcUL, 0x6d982371UL, 0x3cac567cUL,
+    0x3c19e800UL, 0x3fca06fcUL, 0x84d17d80UL, 0x3d1da204UL, 0x85ef8000UL,
+    0x3fc9a0f8UL, 0x54466a6aUL, 0xbd002204UL, 0xb0ac2000UL, 0x3fc93baeUL,
+    0xd601fd65UL, 0x3d18840cUL, 0x1bb9b000UL, 0x3fc8d71cUL, 0x7bf58766UL,
+    0xbd14f897UL, 0x34aae800UL, 0x3fc8733eUL, 0x3af6ac24UL, 0xbd0f5c45UL,
+    0x76d68000UL, 0x3fc81012UL, 0x4303e1a1UL, 0xbd1f9a80UL, 0x6af57800UL,
+    0x3fc7ad96UL, 0x43fbcb46UL, 0x3cf4c33eUL, 0xa6c51000UL, 0x3fc74bc7UL,
+    0x70f0eac5UL, 0xbd192e3bUL, 0xccab9800UL, 0x3fc6eaa3UL, 0xc0093dfeUL,
+    0xbd0faf15UL, 0x8b60b800UL, 0x3fc68a28UL, 0xde78d5fdUL, 0xbc9ea4eeUL,
+    0x9d987000UL, 0x3fc62a53UL, 0x962bea6eUL, 0xbd194084UL, 0xc9b0e800UL,
+    0x3fc5cb22UL, 0x888dd999UL, 0x3d1fe201UL, 0xe1634800UL, 0x3fc56c93UL,
+    0x16ada7adUL, 0x3d1b1188UL, 0xc176c000UL, 0x3fc50ea4UL, 0x4159b5b5UL,
+    0xbcf09c08UL, 0x51766000UL, 0x3fc4b153UL, 0x84393d23UL, 0xbcf6a89cUL,
+    0x83695000UL, 0x3fc4549dUL, 0x9f0b8bbbUL, 0x3d1c4b8cUL, 0x538d5800UL,
+    0x3fc3f881UL, 0xf49df747UL, 0x3cf89b99UL, 0xc8138000UL, 0x3fc39cfcUL,
+    0xd503b834UL, 0xbd13b99fUL, 0xf0df0800UL, 0x3fc3420dUL, 0xf011b386UL,
+    0xbd05d8beUL, 0xe7466800UL, 0x3fc2e7b2UL, 0xf39c7bc2UL, 0xbd1bb94eUL,
+    0xcdd62800UL, 0x3fc28de9UL, 0x05e6d69bUL, 0xbd10ed05UL, 0xd015d800UL,
+    0x3fc234b0UL, 0xe29b6c9dUL, 0xbd1ff967UL, 0x224ea800UL, 0x3fc1dc06UL,
+    0x727711fcUL, 0xbcffb30dUL, 0x01540000UL, 0x3fc183e8UL, 0x39786c5aUL,
+    0x3cc23f57UL, 0xb24d9800UL, 0x3fc12c54UL, 0xc905a342UL, 0x3d003a1dUL,
+    0x82835800UL, 0x3fc0d54aUL, 0x9b9920c0UL, 0x3d03b25aUL, 0xc72ac000UL,
+    0x3fc07ec7UL, 0x46f26a24UL, 0x3cf0fa41UL, 0xdd35d800UL, 0x3fc028caUL,
+    0x41d9d6dcUL, 0x3d034a65UL, 0x52474000UL, 0x3fbfa6a4UL, 0x44f66449UL,
+    0x3d19cad3UL, 0x2da3d000UL, 0x3fbefcb8UL, 0x67832999UL, 0x3d18400fUL,
+    0x32a10000UL, 0x3fbe53ceUL, 0x9c0e3b1aUL, 0xbcff62fdUL, 0x556b7000UL,
+    0x3fbdabe3UL, 0x02976913UL, 0xbcf8243bUL, 0x97e88000UL, 0x3fbd04f4UL,
+    0xec793797UL, 0x3d1c0578UL, 0x09647000UL, 0x3fbc5effUL, 0x05fc0565UL,
+    0xbd1d799eUL, 0xc6426000UL, 0x3fbbb9ffUL, 0x4625f5edUL, 0x3d1f5723UL,
+    0xf7afd000UL, 0x3fbb15f3UL, 0xdd5aae61UL, 0xbd1a7e1eUL, 0xd358b000UL,
+    0x3fba72d8UL, 0x3314e4d3UL, 0x3d17bc91UL, 0x9b1f5000UL, 0x3fb9d0abUL,
+    0x9a4d514bUL, 0x3cf18c9bUL, 0x9cd4e000UL, 0x3fb92f69UL, 0x7e4496abUL,
+    0x3cf1f96dUL, 0x31f4f000UL, 0x3fb88f10UL, 0xf56479e7UL, 0x3d165818UL,
+    0xbf628000UL, 0x3fb7ef9cUL, 0x26bf486dUL, 0xbd1113a6UL, 0xb526b000UL,
+    0x3fb7510cUL, 0x1a1c3384UL, 0x3ca9898dUL, 0x8e31e000UL, 0x3fb6b35dUL,
+    0xb3875361UL, 0xbd0661acUL, 0xd01de000UL, 0x3fb6168cUL, 0x2a7cacfaUL,
+    0xbd1bdf10UL, 0x0af23000UL, 0x3fb57a98UL, 0xff868816UL, 0x3cf046d0UL,
+    0xd8ea0000UL, 0x3fb4df7cUL, 0x1515fbe7UL, 0xbd1fd529UL, 0xde3b2000UL,
+    0x3fb44538UL, 0x6e59a132UL, 0x3d1faeeeUL, 0xc8df9000UL, 0x3fb3abc9UL,
+    0xf1322361UL, 0xbd198807UL, 0x505f1000UL, 0x3fb3132dUL, 0x0888e6abUL,
+    0x3d1e5380UL, 0x359bd000UL, 0x3fb27b61UL, 0xdfbcbb22UL, 0xbcfe2724UL,
+    0x429ee000UL, 0x3fb1e463UL, 0x6eb4c58cUL, 0xbcfe4dd6UL, 0x4a673000UL,
+    0x3fb14e31UL, 0x4ce1ac9bUL, 0x3d1ba691UL, 0x28b96000UL, 0x3fb0b8c9UL,
+    0x8c7813b8UL, 0xbd0b3872UL, 0xc1f08000UL, 0x3fb02428UL, 0xc2bc8c2cUL,
+    0x3cb5ea6bUL, 0x05a1a000UL, 0x3faf209cUL, 0x72e8f18eUL, 0xbce8df84UL,
+    0xc0b5e000UL, 0x3fadfa6dUL, 0x9fdef436UL, 0x3d087364UL, 0xaf416000UL,
+    0x3facd5c2UL, 0x1068c3a9UL, 0x3d0827e7UL, 0xdb356000UL, 0x3fabb296UL,
+    0x120a34d3UL, 0x3d101a9fUL, 0x5dfea000UL, 0x3faa90e6UL, 0xdaded264UL,
+    0xbd14c392UL, 0x6034c000UL, 0x3fa970adUL, 0x1c9d06a9UL, 0xbd1b705eUL,
+    0x194c6000UL, 0x3fa851e8UL, 0x83996ad9UL, 0xbd0117bcUL, 0xcf4ac000UL,
+    0x3fa73492UL, 0xb1a94a62UL, 0xbca5ea42UL, 0xd67b4000UL, 0x3fa618a9UL,
+    0x75aed8caUL, 0xbd07119bUL, 0x9126c000UL, 0x3fa4fe29UL, 0x5291d533UL,
+    0x3d12658fUL, 0x6f4d4000UL, 0x3fa3e50eUL, 0xcd2c5cd9UL, 0x3d1d5c70UL,
+    0xee608000UL, 0x3fa2cd54UL, 0xd1008489UL, 0x3d1a4802UL, 0x9900e000UL,
+    0x3fa1b6f9UL, 0x54fb5598UL, 0xbd16593fUL, 0x06bb6000UL, 0x3fa0a1f9UL,
+    0x64ef57b4UL, 0xbd17636bUL, 0xb7940000UL, 0x3f9f1c9fUL, 0xee6a4737UL,
+    0x3cb5d479UL, 0x91aa0000UL, 0x3f9cf7f5UL, 0x3a16373cUL, 0x3d087114UL,
+    0x156b8000UL, 0x3f9ad5edUL, 0x836c554aUL, 0x3c6900b0UL, 0xd4764000UL,
+    0x3f98b67fUL, 0xed12f17bUL, 0xbcffc974UL, 0x77dec000UL, 0x3f9699a7UL,
+    0x232ce7eaUL, 0x3d1e35bbUL, 0xbfbf4000UL, 0x3f947f5dUL, 0xd84ffa6eUL,
+    0x3d0e0a49UL, 0x82c7c000UL, 0x3f92679cUL, 0x8d170e90UL, 0xbd14d9f2UL,
+    0xadd20000UL, 0x3f90525dUL, 0x86d9f88eUL, 0x3cdeb986UL, 0x86f10000UL,
+    0x3f8c7f36UL, 0xb9e0a517UL, 0x3ce29faaUL, 0xb75c8000UL, 0x3f885e9eUL,
+    0x542568cbUL, 0xbd1f7bdbUL, 0x46b30000UL, 0x3f8442e8UL, 0xb954e7d9UL,
+    0x3d1e5287UL, 0xb7e60000UL, 0x3f802c07UL, 0x22da0b17UL, 0xbd19fb27UL,
+    0x6c8b0000UL, 0x3f7833e3UL, 0x821271efUL, 0xbd190f96UL, 0x29910000UL,
+    0x3f701936UL, 0xbc3491a5UL, 0xbd1bcf45UL, 0x354a0000UL, 0x3f600fe3UL,
+    0xc0ff520aUL, 0xbd19d71cUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL
+};
+
+ALIGNED_(16) juint _log2_log10[] =
+{
+    0x509f7800UL, 0x3f934413UL, 0x1f12b358UL, 0x3cdfef31UL
+};
+
+ALIGNED_(16) juint _coeff_log10[] =
+{
+    0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL, 0xc0089309UL, 0x385593b1UL,
+    0xc025c917UL, 0xdc963467UL, 0x3ffc6a02UL, 0x7f9d3aa1UL, 0x4016ab9fUL,
+    0xdc77b115UL, 0xbff27af2UL
+};
+
+// Registers:
+// input: xmm0
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, tmp - r11
+
+// Code generated by Intel C compiler for LIBM library
+
+void MacroAssembler::fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r11) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, B1_2, B1_3, B1_4, B1_5, start;
+
+  assert_different_registers(r11, eax, ecx, edx);
+
+  address HIGHSIGMASK = (address)_HIGHSIGMASK_log10;
+  address LOG10_E = (address)_LOG10_E;
+  address L_tbl = (address)_L_tbl_log10;
+  address log2 = (address)_log2_log10;
+  address coeff = (address)_coeff_log10;
+
+  bind(start);
+  subq(rsp, 24);
+  movsd(Address(rsp, 0), xmm0);
+
+  bind(B1_2);
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movl(ecx, 1054736384);
+  movdl(xmm7, ecx);
+  xorpd(xmm3, xmm3);
+  movl(edx, 30704);
+  pinsrw(xmm3, edx, 3);
+  movdqu(xmm1, xmm0);
+  movl(edx, 32768);
+  movdl(xmm4, edx);
+  movdqu(xmm5, ExternalAddress(HIGHSIGMASK));    //0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xffffe000UL
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 16352);
+  psrlq(xmm0, 27);
+  movdqu(xmm2, ExternalAddress(LOG10_E));    //0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL
+  psrld(xmm0, 2);
+  rcpps(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 78);
+  psrlq(xmm1, 12);
+  subl(eax, 16);
+  cmpl(eax, 32736);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  mulss(xmm0, xmm7);
+  por(xmm1, xmm3);
+  lea(r11, ExternalAddress(L_tbl));
+  andpd(xmm5, xmm1);
+  paddd(xmm0, xmm4);
+  subsd(xmm1, xmm5);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  andpd(xmm0, xmm6);
+  andl(eax, 32752);
+  subl(eax, ecx);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  mulsd(xmm1, xmm0);
+  movq(xmm6, ExternalAddress(log2));    //0x509f7800UL, 0x3f934413UL, 0x1f12b358UL, 0x3cdfef31UL
+  movdqu(xmm3, ExternalAddress(coeff));    //0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL, 0xc0089309UL
+  subsd(xmm5, xmm2);
+  andl(edx, 16711680);
+  shrl(edx, 12);
+  movdqu(xmm0, Address(r11, rdx, Address::times_1, -1504));
+  movdqu(xmm4, ExternalAddress(16 + coeff));    //0x385593b1UL, 0xc025c917UL, 0xdc963467UL, 0x3ffc6a02UL
+  addsd(xmm1, xmm5);
+  movdqu(xmm2, ExternalAddress(32 + coeff));    //0x7f9d3aa1UL, 0x4016ab9fUL, 0xdc77b115UL, 0xbff27af2UL
+  mulsd(xmm6, xmm7);
+  pshufd(xmm5, xmm1, 68);
+  mulsd(xmm7, ExternalAddress(8 + log2));    //0x1f12b358UL, 0x3cdfef31UL
+  mulsd(xmm3, xmm1);
+  addsd(xmm0, xmm6);
+  mulpd(xmm4, xmm5);
+  movq(xmm6, ExternalAddress(8 + LOG10_E));    //0xbf2e4108UL, 0x3f5a7a6cUL
+  mulpd(xmm5, xmm5);
+  addpd(xmm4, xmm2);
+  mulpd(xmm3, xmm5);
+  pshufd(xmm2, xmm0, 228);
+  addsd(xmm0, xmm1);
+  mulsd(xmm4, xmm1);
+  subsd(xmm2, xmm0);
+  mulsd(xmm6, xmm1);
+  addsd(xmm1, xmm2);
+  pshufd(xmm2, xmm0, 238);
+  mulsd(xmm5, xmm5);
+  addsd(xmm7, xmm2);
+  addsd(xmm1, xmm6);
+  addpd(xmm4, xmm3);
+  addsd(xmm1, xmm7);
+  mulpd(xmm4, xmm5);
+  addsd(xmm1, xmm4);
+  pshufd(xmm5, xmm4, 238);
+  addsd(xmm1, xmm5);
+  addsd(xmm0, xmm1);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  movq(xmm0, Address(rsp, 0));
+  movq(xmm1, Address(rsp, 0));
+  addl(eax, 16);
+  cmpl(eax, 32768);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_2_0_2);
+  cmpl(eax, 16);
+  jcc(Assembler::below, L_2TAG_PACKET_3_0_2);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  addsd(xmm0, xmm0);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  jcc(Assembler::above, L_2TAG_PACKET_4_0_2);
+  cmpl(edx, 0);
+  jcc(Assembler::above, L_2TAG_PACKET_4_0_2);
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  xorpd(xmm1, xmm1);
+  addsd(xmm1, xmm0);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
+  xorpd(xmm1, xmm1);
+  movl(eax, 18416);
+  pinsrw(xmm1, eax, 3);
+  mulsd(xmm0, xmm1);
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm1, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 18416);
+  psrlq(xmm0, 27);
+  movdqu(xmm2, ExternalAddress(LOG10_E));    //0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL
+  psrld(xmm0, 2);
+  rcpps(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 78);
+  psrlq(xmm1, 12);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  addl(ecx, ecx);
+  cmpl(ecx, -2097152);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
+
+  bind(L_2TAG_PACKET_6_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32752);
+  pinsrw(xmm1, eax, 3);
+  mulsd(xmm0, xmm1);
+  movl(Address(rsp, 16), 9);
+  jmp(L_2TAG_PACKET_8_0_2);
+
+  bind(L_2TAG_PACKET_7_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 49136);
+  pinsrw(xmm0, eax, 3);
+  divsd(xmm0, xmm1);
+  movl(Address(rsp, 16), 8);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  movq(Address(rsp, 8), xmm0);
+
+  bind(B1_3);
+  movq(xmm0, Address(rsp, 8));
+
+  bind(L_2TAG_PACKET_9_0_2);
+
+  bind(B1_5);
+  addq(rsp, 24);
+
+}
+#else
+// The 32 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _static_const_table_log10[] =
+{
+    0x509f7800UL, 0x3fd34413UL, 0x1f12b358UL, 0x3d1fef31UL, 0x80333400UL,
+    0x3fd32418UL, 0xc671d9d0UL, 0xbcf542bfUL, 0x51195000UL, 0x3fd30442UL,
+    0x78a4b0c3UL, 0x3d18216aUL, 0x6fc79400UL, 0x3fd2e490UL, 0x80fa389dUL,
+    0xbc902869UL, 0x89d04000UL, 0x3fd2c502UL, 0x75c2f564UL, 0x3d040754UL,
+    0x4ddd1c00UL, 0x3fd2a598UL, 0xd219b2c3UL, 0xbcfa1d84UL, 0x6baa7c00UL,
+    0x3fd28651UL, 0xfd9abec1UL, 0x3d1be6d3UL, 0x94028800UL, 0x3fd2672dUL,
+    0xe289a455UL, 0xbd1ede5eUL, 0x78b86400UL, 0x3fd2482cUL, 0x6734d179UL,
+    0x3d1fe79bUL, 0xcca3c800UL, 0x3fd2294dUL, 0x981a40b8UL, 0xbced34eaUL,
+    0x439c5000UL, 0x3fd20a91UL, 0xcc392737UL, 0xbd1a9cc3UL, 0x92752c00UL,
+    0x3fd1ebf6UL, 0x03c9afe7UL, 0x3d1e98f8UL, 0x6ef8dc00UL, 0x3fd1cd7dUL,
+    0x71dae7f4UL, 0x3d08a86cUL, 0x8fe4dc00UL, 0x3fd1af25UL, 0xee9185a1UL,
+    0xbcff3412UL, 0xace59400UL, 0x3fd190eeUL, 0xc2cab353UL, 0x3cf17ed9UL,
+    0x7e925000UL, 0x3fd172d8UL, 0x6952c1b2UL, 0x3cf1521cUL, 0xbe694400UL,
+    0x3fd154e2UL, 0xcacb79caUL, 0xbd0bdc78UL, 0x26cbac00UL, 0x3fd1370dUL,
+    0xf71f4de1UL, 0xbd01f8beUL, 0x72fa0800UL, 0x3fd11957UL, 0x55bf910bUL,
+    0x3c946e2bUL, 0x5f106000UL, 0x3fd0fbc1UL, 0x39e639c1UL, 0x3d14a84bUL,
+    0xa802a800UL, 0x3fd0de4aUL, 0xd3f31d5dUL, 0xbd178385UL, 0x0b992000UL,
+    0x3fd0c0f3UL, 0x3843106fUL, 0xbd1f602fUL, 0x486ce800UL, 0x3fd0a3baUL,
+    0x8819497cUL, 0x3cef987aUL, 0x1de49400UL, 0x3fd086a0UL, 0x1caa0467UL,
+    0x3d0faec7UL, 0x4c30cc00UL, 0x3fd069a4UL, 0xa4424372UL, 0xbd1618fcUL,
+    0x94490000UL, 0x3fd04cc6UL, 0x946517d2UL, 0xbd18384bUL, 0xb7e84000UL,
+    0x3fd03006UL, 0xe0109c37UL, 0xbd19a6acUL, 0x798a0c00UL, 0x3fd01364UL,
+    0x5121e864UL, 0xbd164cf7UL, 0x38ce8000UL, 0x3fcfedbfUL, 0x46214d1aUL,
+    0xbcbbc402UL, 0xc8e62000UL, 0x3fcfb4efUL, 0xdab93203UL, 0x3d1e0176UL,
+    0x2cb02800UL, 0x3fcf7c5aUL, 0x2a2ea8e4UL, 0xbcfec86aUL, 0xeeeaa000UL,
+    0x3fcf43fdUL, 0xc18e49a4UL, 0x3cf110a8UL, 0x9bb6e800UL, 0x3fcf0bdaUL,
+    0x923cc9c0UL, 0xbd15ce99UL, 0xc093f000UL, 0x3fced3efUL, 0x4d4b51e9UL,
+    0x3d1a04c7UL, 0xec58f800UL, 0x3fce9c3cUL, 0x163cad59UL, 0x3cac8260UL,
+    0x9a907000UL, 0x3fce2d7dUL, 0x3fa93646UL, 0x3ce4a1c0UL, 0x37311000UL,
+    0x3fcdbf99UL, 0x32abd1fdUL, 0x3d07ea9dUL, 0x6744b800UL, 0x3fcd528cUL,
+    0x4dcbdfd4UL, 0xbd1b08e2UL, 0xe36de800UL, 0x3fcce653UL, 0x0b7b7f7fUL,
+    0xbd1b8f03UL, 0x77506800UL, 0x3fcc7aecUL, 0xa821c9fbUL, 0x3d13c163UL,
+    0x00ff8800UL, 0x3fcc1053UL, 0x536bca76UL, 0xbd074ee5UL, 0x70719800UL,
+    0x3fcba684UL, 0xd7da9b6bUL, 0xbd1fbf16UL, 0xc6f8d800UL, 0x3fcb3d7dUL,
+    0xe2220bb3UL, 0x3d1a295dUL, 0x16c15800UL, 0x3fcad53cUL, 0xe724911eUL,
+    0xbcf55822UL, 0x82533800UL, 0x3fca6dbcUL, 0x6d982371UL, 0x3cac567cUL,
+    0x3c19e800UL, 0x3fca06fcUL, 0x84d17d80UL, 0x3d1da204UL, 0x85ef8000UL,
+    0x3fc9a0f8UL, 0x54466a6aUL, 0xbd002204UL, 0xb0ac2000UL, 0x3fc93baeUL,
+    0xd601fd65UL, 0x3d18840cUL, 0x1bb9b000UL, 0x3fc8d71cUL, 0x7bf58766UL,
+    0xbd14f897UL, 0x34aae800UL, 0x3fc8733eUL, 0x3af6ac24UL, 0xbd0f5c45UL,
+    0x76d68000UL, 0x3fc81012UL, 0x4303e1a1UL, 0xbd1f9a80UL, 0x6af57800UL,
+    0x3fc7ad96UL, 0x43fbcb46UL, 0x3cf4c33eUL, 0xa6c51000UL, 0x3fc74bc7UL,
+    0x70f0eac5UL, 0xbd192e3bUL, 0xccab9800UL, 0x3fc6eaa3UL, 0xc0093dfeUL,
+    0xbd0faf15UL, 0x8b60b800UL, 0x3fc68a28UL, 0xde78d5fdUL, 0xbc9ea4eeUL,
+    0x9d987000UL, 0x3fc62a53UL, 0x962bea6eUL, 0xbd194084UL, 0xc9b0e800UL,
+    0x3fc5cb22UL, 0x888dd999UL, 0x3d1fe201UL, 0xe1634800UL, 0x3fc56c93UL,
+    0x16ada7adUL, 0x3d1b1188UL, 0xc176c000UL, 0x3fc50ea4UL, 0x4159b5b5UL,
+    0xbcf09c08UL, 0x51766000UL, 0x3fc4b153UL, 0x84393d23UL, 0xbcf6a89cUL,
+    0x83695000UL, 0x3fc4549dUL, 0x9f0b8bbbUL, 0x3d1c4b8cUL, 0x538d5800UL,
+    0x3fc3f881UL, 0xf49df747UL, 0x3cf89b99UL, 0xc8138000UL, 0x3fc39cfcUL,
+    0xd503b834UL, 0xbd13b99fUL, 0xf0df0800UL, 0x3fc3420dUL, 0xf011b386UL,
+    0xbd05d8beUL, 0xe7466800UL, 0x3fc2e7b2UL, 0xf39c7bc2UL, 0xbd1bb94eUL,
+    0xcdd62800UL, 0x3fc28de9UL, 0x05e6d69bUL, 0xbd10ed05UL, 0xd015d800UL,
+    0x3fc234b0UL, 0xe29b6c9dUL, 0xbd1ff967UL, 0x224ea800UL, 0x3fc1dc06UL,
+    0x727711fcUL, 0xbcffb30dUL, 0x01540000UL, 0x3fc183e8UL, 0x39786c5aUL,
+    0x3cc23f57UL, 0xb24d9800UL, 0x3fc12c54UL, 0xc905a342UL, 0x3d003a1dUL,
+    0x82835800UL, 0x3fc0d54aUL, 0x9b9920c0UL, 0x3d03b25aUL, 0xc72ac000UL,
+    0x3fc07ec7UL, 0x46f26a24UL, 0x3cf0fa41UL, 0xdd35d800UL, 0x3fc028caUL,
+    0x41d9d6dcUL, 0x3d034a65UL, 0x52474000UL, 0x3fbfa6a4UL, 0x44f66449UL,
+    0x3d19cad3UL, 0x2da3d000UL, 0x3fbefcb8UL, 0x67832999UL, 0x3d18400fUL,
+    0x32a10000UL, 0x3fbe53ceUL, 0x9c0e3b1aUL, 0xbcff62fdUL, 0x556b7000UL,
+    0x3fbdabe3UL, 0x02976913UL, 0xbcf8243bUL, 0x97e88000UL, 0x3fbd04f4UL,
+    0xec793797UL, 0x3d1c0578UL, 0x09647000UL, 0x3fbc5effUL, 0x05fc0565UL,
+    0xbd1d799eUL, 0xc6426000UL, 0x3fbbb9ffUL, 0x4625f5edUL, 0x3d1f5723UL,
+    0xf7afd000UL, 0x3fbb15f3UL, 0xdd5aae61UL, 0xbd1a7e1eUL, 0xd358b000UL,
+    0x3fba72d8UL, 0x3314e4d3UL, 0x3d17bc91UL, 0x9b1f5000UL, 0x3fb9d0abUL,
+    0x9a4d514bUL, 0x3cf18c9bUL, 0x9cd4e000UL, 0x3fb92f69UL, 0x7e4496abUL,
+    0x3cf1f96dUL, 0x31f4f000UL, 0x3fb88f10UL, 0xf56479e7UL, 0x3d165818UL,
+    0xbf628000UL, 0x3fb7ef9cUL, 0x26bf486dUL, 0xbd1113a6UL, 0xb526b000UL,
+    0x3fb7510cUL, 0x1a1c3384UL, 0x3ca9898dUL, 0x8e31e000UL, 0x3fb6b35dUL,
+    0xb3875361UL, 0xbd0661acUL, 0xd01de000UL, 0x3fb6168cUL, 0x2a7cacfaUL,
+    0xbd1bdf10UL, 0x0af23000UL, 0x3fb57a98UL, 0xff868816UL, 0x3cf046d0UL,
+    0xd8ea0000UL, 0x3fb4df7cUL, 0x1515fbe7UL, 0xbd1fd529UL, 0xde3b2000UL,
+    0x3fb44538UL, 0x6e59a132UL, 0x3d1faeeeUL, 0xc8df9000UL, 0x3fb3abc9UL,
+    0xf1322361UL, 0xbd198807UL, 0x505f1000UL, 0x3fb3132dUL, 0x0888e6abUL,
+    0x3d1e5380UL, 0x359bd000UL, 0x3fb27b61UL, 0xdfbcbb22UL, 0xbcfe2724UL,
+    0x429ee000UL, 0x3fb1e463UL, 0x6eb4c58cUL, 0xbcfe4dd6UL, 0x4a673000UL,
+    0x3fb14e31UL, 0x4ce1ac9bUL, 0x3d1ba691UL, 0x28b96000UL, 0x3fb0b8c9UL,
+    0x8c7813b8UL, 0xbd0b3872UL, 0xc1f08000UL, 0x3fb02428UL, 0xc2bc8c2cUL,
+    0x3cb5ea6bUL, 0x05a1a000UL, 0x3faf209cUL, 0x72e8f18eUL, 0xbce8df84UL,
+    0xc0b5e000UL, 0x3fadfa6dUL, 0x9fdef436UL, 0x3d087364UL, 0xaf416000UL,
+    0x3facd5c2UL, 0x1068c3a9UL, 0x3d0827e7UL, 0xdb356000UL, 0x3fabb296UL,
+    0x120a34d3UL, 0x3d101a9fUL, 0x5dfea000UL, 0x3faa90e6UL, 0xdaded264UL,
+    0xbd14c392UL, 0x6034c000UL, 0x3fa970adUL, 0x1c9d06a9UL, 0xbd1b705eUL,
+    0x194c6000UL, 0x3fa851e8UL, 0x83996ad9UL, 0xbd0117bcUL, 0xcf4ac000UL,
+    0x3fa73492UL, 0xb1a94a62UL, 0xbca5ea42UL, 0xd67b4000UL, 0x3fa618a9UL,
+    0x75aed8caUL, 0xbd07119bUL, 0x9126c000UL, 0x3fa4fe29UL, 0x5291d533UL,
+    0x3d12658fUL, 0x6f4d4000UL, 0x3fa3e50eUL, 0xcd2c5cd9UL, 0x3d1d5c70UL,
+    0xee608000UL, 0x3fa2cd54UL, 0xd1008489UL, 0x3d1a4802UL, 0x9900e000UL,
+    0x3fa1b6f9UL, 0x54fb5598UL, 0xbd16593fUL, 0x06bb6000UL, 0x3fa0a1f9UL,
+    0x64ef57b4UL, 0xbd17636bUL, 0xb7940000UL, 0x3f9f1c9fUL, 0xee6a4737UL,
+    0x3cb5d479UL, 0x91aa0000UL, 0x3f9cf7f5UL, 0x3a16373cUL, 0x3d087114UL,
+    0x156b8000UL, 0x3f9ad5edUL, 0x836c554aUL, 0x3c6900b0UL, 0xd4764000UL,
+    0x3f98b67fUL, 0xed12f17bUL, 0xbcffc974UL, 0x77dec000UL, 0x3f9699a7UL,
+    0x232ce7eaUL, 0x3d1e35bbUL, 0xbfbf4000UL, 0x3f947f5dUL, 0xd84ffa6eUL,
+    0x3d0e0a49UL, 0x82c7c000UL, 0x3f92679cUL, 0x8d170e90UL, 0xbd14d9f2UL,
+    0xadd20000UL, 0x3f90525dUL, 0x86d9f88eUL, 0x3cdeb986UL, 0x86f10000UL,
+    0x3f8c7f36UL, 0xb9e0a517UL, 0x3ce29faaUL, 0xb75c8000UL, 0x3f885e9eUL,
+    0x542568cbUL, 0xbd1f7bdbUL, 0x46b30000UL, 0x3f8442e8UL, 0xb954e7d9UL,
+    0x3d1e5287UL, 0xb7e60000UL, 0x3f802c07UL, 0x22da0b17UL, 0xbd19fb27UL,
+    0x6c8b0000UL, 0x3f7833e3UL, 0x821271efUL, 0xbd190f96UL, 0x29910000UL,
+    0x3f701936UL, 0xbc3491a5UL, 0xbd1bcf45UL, 0x354a0000UL, 0x3f600fe3UL,
+    0xc0ff520aUL, 0xbd19d71cUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x509f7800UL, 0x3f934413UL, 0x1f12b358UL, 0x3cdfef31UL,
+    0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL, 0xc0089309UL, 0x385593b1UL,
+    0xc025c917UL, 0xdc963467UL, 0x3ffc6a02UL, 0x7f9d3aa1UL, 0x4016ab9fUL,
+    0xdc77b115UL, 0xbff27af2UL, 0xf8000000UL, 0xffffffffUL, 0x00000000UL,
+    0xffffe000UL, 0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL
+};
+//registers,
+// input: xmm0
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, rbx (tmp)
+
+void MacroAssembler::fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
+
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, start;
+
+  assert_different_registers(tmp, eax, ecx, edx);
+
+  address static_const_table_log10 = (address)_static_const_table_log10;
+
+  bind(start);
+  subl(rsp, 104);
+  movl(Address(rsp, 40), tmp);
+  lea(tmp, ExternalAddress(static_const_table_log10));
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movl(ecx, 1054736384);
+  movdl(xmm7, ecx);
+  xorpd(xmm3, xmm3);
+  movl(edx, 30704);
+  pinsrw(xmm3, edx, 3);
+  movsd(xmm0, Address(rsp, 112));
+  movdqu(xmm1, xmm0);
+  movl(edx, 32768);
+  movdl(xmm4, edx);
+  movdqu(xmm5, Address(tmp, 2128));    //0x3ffc6a02UL, 0x7f9d3aa1UL, 0x4016ab9fUL, 0xdc77b115UL
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 16352);
+  psllq(xmm0, 5);
+  movsd(xmm2, Address(tmp, 2144));    //0xbff27af2UL, 0xf8000000UL, 0xffffffffUL, 0x00000000UL
+  psrlq(xmm0, 34);
+  rcpss(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 78);
+  psrlq(xmm1, 12);
+  subl(eax, 16);
+  cmpl(eax, 32736);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  mulss(xmm0, xmm7);
+  por(xmm1, xmm3);
+  andpd(xmm5, xmm1);
+  paddd(xmm0, xmm4);
+  subsd(xmm1, xmm5);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  andpd(xmm0, xmm6);
+  andl(eax, 32752);
+  subl(eax, ecx);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  mulsd(xmm1, xmm0);
+  movsd(xmm6, Address(tmp, 2064));    //0xbd19d71cUL, 0x00000000UL, 0x00000000UL, 0x00000000UL
+  movdqu(xmm3, Address(tmp, 2080));    //0x00000000UL, 0x509f7800UL, 0x3f934413UL, 0x1f12b358UL
+  subsd(xmm5, xmm2);
+  andl(edx, 16711680);
+  shrl(edx, 12);
+  movdqu(xmm0, Address(tmp, edx, Address::times_1, -1504));
+  movdqu(xmm4, Address(tmp, 2096));    //0x3cdfef31UL, 0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL
+  addsd(xmm1, xmm5);
+  movdqu(xmm2, Address(tmp, 2112));    //0xc0089309UL, 0x385593b1UL, 0xc025c917UL, 0xdc963467UL
+  mulsd(xmm6, xmm7);
+  pshufd(xmm5, xmm1, 68);
+  mulsd(xmm7, Address(tmp, 2072));    //0x00000000UL, 0x00000000UL, 0x00000000UL, 0x509f7800UL
+  mulsd(xmm3, xmm1);
+  addsd(xmm0, xmm6);
+  mulpd(xmm4, xmm5);
+  movsd(xmm6, Address(tmp, 2152));    //0xffffffffUL, 0x00000000UL, 0xffffe000UL, 0x00000000UL
+  mulpd(xmm5, xmm5);
+  addpd(xmm4, xmm2);
+  mulpd(xmm3, xmm5);
+  pshufd(xmm2, xmm0, 228);
+  addsd(xmm0, xmm1);
+  mulsd(xmm4, xmm1);
+  subsd(xmm2, xmm0);
+  mulsd(xmm6, xmm1);
+  addsd(xmm1, xmm2);
+  pshufd(xmm2, xmm0, 238);
+  mulsd(xmm5, xmm5);
+  addsd(xmm7, xmm2);
+  addsd(xmm1, xmm6);
+  addpd(xmm4, xmm3);
+  addsd(xmm1, xmm7);
+  mulpd(xmm4, xmm5);
+  addsd(xmm1, xmm4);
+  pshufd(xmm5, xmm4, 238);
+  addsd(xmm1, xmm5);
+  addsd(xmm0, xmm1);
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  movsd(xmm0, Address(rsp, 112));    //0xbcfa1d84UL, 0x6baa7c00UL, 0x3fd28651UL, 0xfd9abec1UL
+  movdqu(xmm1, xmm0);
+  addl(eax, 16);
+  cmpl(eax, 32768);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_3_0_2);
+  cmpl(eax, 16);
+  jcc(Assembler::below, L_2TAG_PACKET_4_0_2);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  addsd(xmm0, xmm0);
+  jmp(L_2TAG_PACKET_2_0_2);
+
+  bind(L_2TAG_PACKET_6_0_2);
+  jcc(Assembler::above, L_2TAG_PACKET_5_0_2);
+  cmpl(edx, 0);
+  jcc(Assembler::above, L_2TAG_PACKET_5_0_2);
+  jmp(L_2TAG_PACKET_7_0_2);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  addl(ecx, ecx);
+  cmpl(ecx, -2097152);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_6_0_2);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
+
+  bind(L_2TAG_PACKET_7_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32752);
+  pinsrw(xmm1, eax, 3);
+  movl(edx, 9);
+  mulsd(xmm0, xmm1);
+
+  bind(L_2TAG_PACKET_9_0_2);
+  movsd(Address(rsp, 0), xmm0);
+  movsd(xmm0, Address(rsp, 112));    //0xbcfa1d84UL, 0x6baa7c00UL, 0x3fd28651UL, 0xfd9abec1UL
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_10_0_2);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  xorpd(xmm1, xmm1);
+  xorpd(xmm0, xmm0);
+  movl(eax, 49136);
+  pinsrw(xmm0, eax, 3);
+  divsd(xmm0, xmm1);
+  movl(edx, 8);
+  jmp(L_2TAG_PACKET_9_0_2);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  movdl(edx, xmm1);
+  psrlq(xmm1, 32);
+  movdl(ecx, xmm1);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
+  xorpd(xmm1, xmm1);
+  movl(eax, 18416);
+  pinsrw(xmm1, eax, 3);
+  mulsd(xmm0, xmm1);
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm1, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 18416);
+  psllq(xmm0, 5);
+  movsd(xmm2, Address(tmp, 2144));    //0xbff27af2UL, 0xf8000000UL, 0xffffffffUL, 0x00000000UL
+  psrlq(xmm0, 34);
+  rcpss(xmm0, xmm0);
+  psllq(xmm1, 12);
+  pshufd(xmm6, xmm5, 78);
+  psrlq(xmm1, 12);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movsd(Address(rsp, 24), xmm0);
+  fld_d(Address(rsp, 24));
+
+  bind(L_2TAG_PACKET_10_0_2);
+  movl(tmp, Address(rsp, 40));
+
+}
+#endif
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_pow.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_pow.cpp
new file mode 100644
index 0000000..12b38d8
--- /dev/null
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_pow.cpp
@@ -0,0 +1,3592 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+* Intel Math Library (LIBM) Source Code
+*
+* 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 "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
+/******************************************************************************/
+//                     ALGORITHM DESCRIPTION  - POW()
+//                     ---------------------
+//
+//    Let x=2^k * mx, mx in [1,2)
+//
+//    log2(x) calculation:
+//
+//    Get B~1/mx based on the output of rcpps instruction (B0)
+//    B = int((B0*LH*2^9+0.5))/2^9
+//    LH is a short approximation for log2(e)
+//
+//    Reduced argument, scaled by LH:
+//                r=B*mx-LH (computed accurately in high and low parts)
+//
+//    log2(x) result:  k - log2(B) + p(r)
+//             p(r) is a degree 8 polynomial
+//             -log2(B) read from data table (high, low parts)
+//             log2(x) is formed from high and low parts
+//    For |x| in [1-1/32, 1+1/16), a slower but more accurate computation
+//    based om the same table design is performed.
+//
+//   Main path is taken if | floor(log2(|log2(|x|)|) + floor(log2|y|) | < 8,
+//   to filter out all potential OF/UF cases.
+//   exp2(y*log2(x)) is computed using an 8-bit index table and a degree 5
+//   polynomial
+//
+// Special cases:
+//  pow(-0,y) = -INF and raises the divide-by-zero exception for y an odd
+//  integer < 0.
+//  pow(-0,y) = +INF and raises the divide-by-zero exception for y < 0 and
+//  not an odd integer.
+//  pow(-0,y) = -0 for y an odd integer > 0.
+//  pow(-0,y) = +0 for y > 0 and not an odd integer.
+//  pow(-1,-INF) = NaN.
+//  pow(+1,y) = NaN for any y, even a NaN.
+//  pow(x,-0) = 1 for any x, even a NaN.
+//  pow(x,y) = a NaN and raises the invalid exception for finite x < 0 and
+//  finite non-integer y.
+//  pow(x,-INF) = +INF for |x|<1.
+//  pow(x,-INF) = +0 for |x|>1.
+//  pow(x,+INF) = +0 for |x|<1.
+//  pow(x,+INF) = +INF for |x|>1.
+//  pow(-INF,y) = -0 for y an odd integer < 0.
+//  pow(-INF,y) = +0 for y < 0 and not an odd integer.
+//  pow(-INF,y) = -INF for y an odd integer > 0.
+//  pow(-INF,y) = +INF for y > 0 and not an odd integer.
+//  pow(+INF,y) = +0 for y <0.
+//  pow(+INF,y) = +INF for y >0.
+//
+/******************************************************************************/
+
+#ifdef _LP64
+// The 64 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _HIGHSIGMASK[] =
+{
+    0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
+};
+
+ALIGNED_(16) juint _LOG2_E[] =
+{
+    0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
+};
+
+ALIGNED_(16) juint _HIGHMASK_Y[] =
+{
+    0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL
+};
+
+ALIGNED_(16) juint _T_exp[] =
+{
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL, 0xfa5abcbfUL,
+    0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL, 0x3ff0163dUL,
+    0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL, 0x0fc54eb6UL,
+    0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL, 0xbc719083UL,
+    0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL, 0xe86e7f85UL,
+    0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL, 0x3ff04e5fUL,
+    0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL, 0xa475b465UL,
+    0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL, 0xbc95cb7bUL,
+    0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL, 0x2b72a836UL,
+    0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL, 0x3ff08745UL,
+    0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL, 0x800a3fd1UL,
+    0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL, 0x3c914878UL,
+    0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL, 0x6cf9890fUL,
+    0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL, 0x3ff0c0f1UL,
+    0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL, 0x16e24f71UL,
+    0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL, 0xbc9bc14dUL,
+    0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL, 0x5fdfa9c5UL,
+    0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL, 0x3ff0fb66UL,
+    0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL, 0x1692fdd5UL,
+    0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL, 0xbc96c510UL,
+    0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL, 0xc06c31ccUL,
+    0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL, 0x3ff136a8UL,
+    0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL, 0x9af1369eUL,
+    0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL, 0xbc8b91e8UL,
+    0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL, 0x5471c3c2UL,
+    0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL, 0x3ff172b8UL,
+    0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL, 0xe2ac5a64UL,
+    0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL, 0xbc911023UL,
+    0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL, 0xeb6fcb75UL,
+    0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL, 0x3ff1af99UL,
+    0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL, 0x352ef607UL,
+    0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL, 0x3c900977UL,
+    0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL, 0x5eb44027UL,
+    0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL, 0x3ff1ed50UL,
+    0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL, 0xa097af5cUL,
+    0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL, 0x3c8dc775UL,
+    0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL, 0x917ddc96UL,
+    0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL, 0x3ff22bddUL,
+    0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL, 0xb6c70573UL,
+    0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL, 0x3c8acfccUL,
+    0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL, 0x711ece75UL,
+    0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL, 0x3ff26b45UL,
+    0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL, 0x05f9e76cUL,
+    0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL, 0xbc9a4c3aUL,
+    0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL, 0xf51fdee1UL,
+    0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL, 0x3ff2ab8aUL,
+    0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL, 0xd6381aa4UL,
+    0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL, 0xbc950145UL,
+    0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL, 0x1f641589UL,
+    0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL, 0x3ff2ecafUL,
+    0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL, 0x532bda93UL,
+    0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL, 0x3c86f46aUL,
+    0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL, 0xfc4cd831UL,
+    0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL, 0x3ff32eb8UL,
+    0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL, 0x843659a6UL,
+    0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL, 0xbc835a75UL,
+    0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL, 0xa2de883bUL,
+    0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL, 0x3ff371a7UL,
+    0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL, 0x9eceb23cUL,
+    0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL, 0xbc9e958dUL,
+    0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL, 0x34e59ff7UL,
+    0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL, 0x3ff3b57fUL,
+    0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL, 0x375d29c3UL,
+    0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL, 0x3c7fe8d0UL,
+    0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL, 0xdf1c5175UL,
+    0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL, 0x3ff3fa45UL,
+    0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL, 0xb6f4d048UL,
+    0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL, 0xbc5ef369UL,
+    0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL, 0xd950a897UL,
+    0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL, 0x3ff43ffaUL,
+    0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL, 0x04ef80d0UL,
+    0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL, 0xbc686419UL,
+    0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL, 0x668b3237UL,
+    0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL, 0x3ff486a2UL,
+    0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL, 0x5e499ea0UL,
+    0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL, 0x3c99cb62UL,
+    0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL, 0xd5362a27UL,
+    0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL, 0x3ff4ce41UL,
+    0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL, 0xbc6a7833UL,
+    0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL, 0xbc95257dUL,
+    0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL, 0x7f4531eeUL,
+    0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL, 0x3ff516daUL,
+    0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL, 0x43efef71UL,
+    0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL, 0xbc807abeUL,
+    0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL, 0xca5d920fUL,
+    0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL, 0x3ff56070UL,
+    0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL, 0x011d93adUL,
+    0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL, 0xbc90b98cUL,
+    0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL, 0x27ff07ccUL,
+    0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL, 0x3ff5ab07UL,
+    0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL, 0x4c233e1aUL,
+    0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL, 0x3c3c4b1bUL,
+    0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL, 0x15ad2148UL,
+    0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL, 0x3ff5f6a3UL,
+    0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL, 0x9b56de47UL,
+    0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL, 0x3c9e4b3eUL,
+    0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL, 0x1d1929fdUL,
+    0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL, 0x3ff64346UL,
+    0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL, 0xc9a73e09UL,
+    0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL, 0xbc9bb609UL,
+    0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL, 0xd44ca973UL,
+    0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL, 0x3ff690f4UL,
+    0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL, 0x13b26456UL,
+    0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL, 0x3c7a38f5UL,
+    0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL, 0xddd47645UL,
+    0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL, 0x3ff6dfb2UL,
+    0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL, 0x9e1ac8b2UL,
+    0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL, 0xbc883c0fUL,
+    0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL, 0xe8ec5f74UL,
+    0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL, 0x3ff72f82UL,
+    0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL, 0x6c65d53cUL,
+    0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL, 0x3c9047fdUL,
+    0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL, 0xb1ab6e09UL,
+    0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL, 0x3ff78069UL,
+    0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL, 0x62aadd3eUL,
+    0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL, 0xbc841577UL,
+    0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL, 0x0130c132UL,
+    0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL, 0x3ff7d26aUL,
+    0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL, 0xba15797eUL,
+    0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL, 0xbc807f11UL,
+    0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL, 0xadd106d9UL,
+    0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL, 0x3ff82589UL,
+    0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL, 0x31df2bd5UL,
+    0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL, 0xbc88d684UL,
+    0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL, 0x9b4492edUL,
+    0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL, 0x3ff879caUL,
+    0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL, 0xf37cb53aUL,
+    0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL, 0x3c9d5395UL,
+    0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL, 0xbad61778UL,
+    0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL, 0x3ff8cf32UL,
+    0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL, 0x6fc9b2e6UL,
+    0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL, 0x3c85cc13UL,
+    0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL, 0x0b91ffc6UL,
+    0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL, 0x3ff925c3UL,
+    0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL, 0x81b57ebcUL,
+    0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL, 0xbc8dc3d6UL,
+    0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL, 0x9a7670b3UL,
+    0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL, 0x3ff97d82UL,
+    0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL, 0xa24c78ecUL,
+    0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL, 0xbc9173bdUL,
+    0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL, 0x82a3f090UL,
+    0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL, 0x3ff9d674UL,
+    0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL, 0x78e64c6eUL,
+    0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL, 0xbc84a9ceUL,
+    0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL, 0xed8eb8bbUL,
+    0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL, 0x3ffa309bUL,
+    0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL, 0x589fb120UL,
+    0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL, 0xbc9d2f6eUL,
+    0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL, 0x1330b358UL,
+    0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL, 0x3ffa8bfeUL,
+    0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL, 0x0ef7fd31UL,
+    0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL, 0x3c889c31UL,
+    0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL, 0x3a3c2774UL,
+    0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL, 0x3ffae89fUL,
+    0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL, 0x0f315ecdUL,
+    0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL, 0xbc9bdef5UL,
+    0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL, 0xb84f15fbUL,
+    0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL, 0x3ffb4684UL,
+    0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL, 0xbbba6de3UL,
+    0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL, 0x3c92a8f3UL,
+    0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL, 0xf22749e4UL,
+    0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL, 0x3ffba5b0UL,
+    0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL, 0xc9696205UL,
+    0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL, 0x3c823dd0UL,
+    0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL, 0x5bd71e09UL,
+    0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL, 0x3ffc0628UL,
+    0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL, 0x895048ddUL,
+    0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL, 0xbc96e516UL,
+    0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL, 0x78fafb22UL,
+    0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL, 0x3ffc67f1UL,
+    0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL, 0xbe255559UL,
+    0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL, 0x3c71acbcUL,
+    0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL, 0xdcef9069UL,
+    0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL, 0x3ffccb0fUL,
+    0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL, 0x53829d72UL,
+    0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL, 0xbc9a08e9UL,
+    0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL, 0x2b08c968UL,
+    0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL, 0x3ffd2f87UL,
+    0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL, 0xbf5a1614UL,
+    0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL, 0x3c82ed02UL,
+    0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL, 0x16c98398UL,
+    0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL, 0x3ffd955dUL,
+    0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL, 0x696db532UL,
+    0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL, 0xbc9b76f1UL,
+    0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL, 0x641c0658UL,
+    0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL, 0x3ffdfc97UL,
+    0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL, 0xbd5c7f44UL,
+    0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL, 0xbc97b627UL,
+    0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL, 0xe78b3ff6UL,
+    0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL, 0x3ffe6539UL,
+    0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL, 0xca0c8de2UL,
+    0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL, 0xbc910894UL,
+    0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL, 0x867cca6eUL,
+    0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL, 0x3ffecf48UL,
+    0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL, 0xa487568dUL,
+    0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL, 0x3c9dc7f4UL,
+    0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL, 0x376bba97UL,
+    0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL, 0x3fff3ac9UL,
+    0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL, 0x2dd8a18bUL,
+    0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL, 0x3c9fa37bUL,
+    0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL, 0x02243c89UL,
+    0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL, 0x3fffa7c1UL,
+    0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL, 0x15098eb6UL,
+    0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL, 0x3c62eb74UL,
+    0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL
+};
+
+ALIGNED_(16) juint _e_coeff[] =
+{
+    0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL,
+    0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL,
+    0x00000000UL, 0x00000000UL
+};
+
+ALIGNED_(16) juint _coeff_h[] =
+{
+    0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL
+};
+
+ALIGNED_(16) juint _HIGHMASK_LOG_X[] =
+{
+    0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL
+};
+
+ALIGNED_(8) juint _HALFMASK[] =
+{
+    0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL
+};
+
+ALIGNED_(16) juint _coeff_pow[] =
+{
+    0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL,
+    0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL,
+    0xac8349bbUL, 0x3fa76c9bUL, 0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL,
+    0xbf5dabe1UL, 0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL,
+    0x486ececbUL, 0x3fc4635eUL, 0x412055ccUL, 0xbdd61bb2UL
+};
+
+ALIGNED_(16) juint _L_tbl_pow[] =
+{
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x20000000UL,
+    0x3feff00aUL, 0x96621f95UL, 0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL,
+    0xe5916f9eUL, 0xbe325278UL, 0x00000000UL, 0x3fefd02fUL, 0x859a1062UL,
+    0x3e595fb7UL, 0xc0000000UL, 0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL,
+    0xe0000000UL, 0x3fefb069UL, 0xad2880a7UL, 0xbe501230UL, 0x60000000UL,
+    0x3fefa08fUL, 0xc8e72420UL, 0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL,
+    0xc30c4500UL, 0xbe5d6c75UL, 0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL,
+    0x3e2e1318UL, 0xc0000000UL, 0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL,
+    0x00000000UL, 0x3fef615cUL, 0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL,
+    0x3fef519cUL, 0x65c5cd68UL, 0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL,
+    0x46d1306cUL, 0xbe5a840eUL, 0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL,
+    0x3e5071afUL, 0xa0000000UL, 0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL,
+    0xa0000000UL, 0x3fef12d4UL, 0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL,
+    0x3fef032fUL, 0xbc7247faUL, 0xbe2bab83UL, 0x80000000UL, 0x3feef390UL,
+    0xbcaa1e46UL, 0xbe53bb3bUL, 0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL,
+    0xbe54c619UL, 0x80000000UL, 0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL,
+    0xe0000000UL, 0x3feec4d1UL, 0xec678f76UL, 0xbe369af6UL, 0x80000000UL,
+    0x3feeb547UL, 0x41301f55UL, 0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL,
+    0x676da6bdUL, 0xbe4d8dd0UL, 0x60000000UL, 0x3fee9642UL, 0x57a891c4UL,
+    0x3e51f991UL, 0xa0000000UL, 0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL,
+    0x20000000UL, 0x3fee7752UL, 0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL,
+    0x3fee67e1UL, 0xd75b5bf1UL, 0xbe449531UL, 0x80000000UL, 0x3fee5876UL,
+    0xbd423b8eUL, 0x3df54fe4UL, 0x60000000UL, 0x3fee4910UL, 0x330e51b9UL,
+    0x3e54289cUL, 0x80000000UL, 0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL,
+    0xa0000000UL, 0x3fee2a53UL, 0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL,
+    0x3fee1afcUL, 0x0989328dUL, 0x3e23958cUL, 0x40000000UL, 0x3fee0babUL,
+    0xee642abdUL, 0xbe425dd8UL, 0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL,
+    0x3e526362UL, 0x20000000UL, 0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL,
+    0xc0000000UL, 0x3fedddd4UL, 0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL,
+    0x3fedce97UL, 0x0ecac52fUL, 0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL,
+    0x124cb3b8UL, 0x3e257024UL, 0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL,
+    0xbe2033eeUL, 0x20000000UL, 0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL,
+    0xc0000000UL, 0x3fed91d3UL, 0xef8a552aUL, 0xbe543390UL, 0x40000000UL,
+    0x3fed82afUL, 0xb8e85204UL, 0x3e513850UL, 0xe0000000UL, 0x3fed738fUL,
+    0x3d59fe08UL, 0xbe5db728UL, 0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL,
+    0x3e58804bUL, 0xc0000000UL, 0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL,
+    0x00000000UL, 0x3fed464fUL, 0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL,
+    0x3fed3743UL, 0xb0b0a190UL, 0x3e598635UL, 0x80000000UL, 0x3fed283cUL,
+    0xe2113295UL, 0xbe5c1119UL, 0x80000000UL, 0x3fed193aUL, 0xafbf1728UL,
+    0xbe492e9cUL, 0x60000000UL, 0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL,
+    0x20000000UL, 0x3fecfb45UL, 0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL,
+    0x3fecec51UL, 0x110f7dddUL, 0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL,
+    0x7dd7d508UL, 0xbe5a8943UL, 0x80000000UL, 0x3fecce79UL, 0x9b60f271UL,
+    0xbe50676aUL, 0x80000000UL, 0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL,
+    0x60000000UL, 0x3fecb0b4UL, 0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL,
+    0x3feca1d9UL, 0x38a6ec89UL, 0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL,
+    0x3a0b7d8eUL, 0x3e53dbfdUL, 0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL,
+    0xbe27c5c9UL, 0xc0000000UL, 0x3fec7563UL, 0x0c706381UL, 0xbe593653UL,
+    0x60000000UL, 0x3fec669bUL, 0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL,
+    0x3fec57d7UL, 0x40e5e7e8UL, 0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL,
+    0x5602770fUL, 0xbe55219dUL, 0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL,
+    0x3e5a5d25UL, 0x60000000UL, 0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL,
+    0x80000000UL, 0x3fec1cf8UL, 0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL,
+    0x3fec0e4cUL, 0x580798bdUL, 0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL,
+    0xb8282df6UL, 0xbe46b874UL, 0x20000000UL, 0x3febf102UL, 0xe33a6729UL,
+    0x3e54963fUL, 0x00000000UL, 0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL,
+    0x60000000UL, 0x3febd3caUL, 0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL,
+    0x3febc535UL, 0xa335c5eeUL, 0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL,
+    0x7325b04dUL, 0x3e42ba15UL, 0x60000000UL, 0x3feba819UL, 0x1564540fUL,
+    0x3e3a9f35UL, 0x40000000UL, 0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL,
+    0xa0000000UL, 0x3feb8b0fUL, 0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL,
+    0x3feb7c91UL, 0x6d6f1ea4UL, 0x3e557657UL, 0x00000000UL, 0x3feb6e18UL,
+    0x5e80a1bfUL, 0x3e4ddbb6UL, 0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL,
+    0x3e592877UL, 0xa0000000UL, 0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL,
+    0xa0000000UL, 0x3feb42c6UL, 0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL,
+    0x3feb345fUL, 0xa3e0cceeUL, 0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL,
+    0x8e752b50UL, 0xbe3da3c2UL, 0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL,
+    0x3e1fb481UL, 0xc0000000UL, 0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL,
+    0x20000000UL, 0x3feafaeeUL, 0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL,
+    0x3feaec9dUL, 0x3c3d640eUL, 0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL,
+    0x8f97a715UL, 0x3e3a8ec5UL, 0x20000000UL, 0x3fead008UL, 0x23ab2839UL,
+    0x3e2fe98aUL, 0x40000000UL, 0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL,
+    0xe0000000UL, 0x3feab384UL, 0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL,
+    0x3feaa549UL, 0x7c7b0eeaUL, 0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL,
+    0xf56f7013UL, 0x3e386200UL, 0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL,
+    0xbe514af5UL, 0xe0000000UL, 0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL,
+    0x60000000UL, 0x3fea6c89UL, 0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL,
+    0x3fea5e64UL, 0x3f19d970UL, 0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL,
+    0x09ea3e6bUL, 0x3e5065dcUL, 0x80000000UL, 0x3fea4226UL, 0x78df246cUL,
+    0x3e5e05f6UL, 0x40000000UL, 0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL,
+    0x40000000UL, 0x3fea25faUL, 0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL,
+    0x3fea17eaUL, 0x9436f40aUL, 0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL,
+    0x4b5253b3UL, 0x3e46380bUL, 0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL,
+    0xbe386f9bUL, 0x20000000UL, 0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL,
+    0x60000000UL, 0x3fe9dfd6UL, 0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL,
+    0x3fe9d1dcUL, 0xeabdff1dUL, 0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL,
+    0xafd30e73UL, 0xbe585e63UL, 0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL,
+    0xbe43e8f9UL, 0x20000000UL, 0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL,
+    0x80000000UL, 0x3fe99a1cUL, 0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL,
+    0x3fe98c37UL, 0x7c9a88fbUL, 0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL,
+    0xda015741UL, 0xbe5d13baUL, 0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL,
+    0x3e51b947UL, 0x00000000UL, 0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL,
+    0x40000000UL, 0x3fe954cbUL, 0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL,
+    0x3fe946faUL, 0xe63b3767UL, 0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL,
+    0xe57cc2a9UL, 0x3e34eda3UL, 0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL,
+    0x3e5766a0UL, 0xc0000000UL, 0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL,
+    0x80000000UL, 0x3fe90fe1UL, 0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL,
+    0x3fe90225UL, 0xdbd3f369UL, 0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL,
+    0x1c9be989UL, 0xbe5e2b0aUL, 0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL,
+    0x3e5c8618UL, 0xe0000000UL, 0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL,
+    0x20000000UL, 0x3fe8cb5eUL, 0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL,
+    0x3fe8bdb6UL, 0x49e58cc3UL, 0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL,
+    0xa7cfeb8fUL, 0x3e56c412UL, 0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL,
+    0x3e1429b8UL, 0x60000000UL, 0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL,
+    0xc0000000UL, 0x3fe8873fUL, 0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL,
+    0x3fe879acUL, 0x56aee828UL, 0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL,
+    0x7ceab8ecUL, 0x3e493365UL, 0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL,
+    0xbe4f7f25UL, 0x00000000UL, 0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL,
+    0x40000000UL, 0x3fe84385UL, 0x34ba4e15UL, 0x3e328077UL, 0x80000000UL,
+    0x3fe83605UL, 0xa670975aUL, 0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL,
+    0xf61b77b2UL, 0xbe43a20aUL, 0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL,
+    0x3e5e5fe5UL, 0xc0000000UL, 0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL,
+    0xa0000000UL, 0x3fe8002dUL, 0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL,
+    0x3fe7f2c1UL, 0x22a16f01UL, 0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL,
+    0xc38cd451UL, 0x3e506963UL, 0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL,
+    0x3e4503d7UL, 0x40000000UL, 0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL,
+    0xa0000000UL, 0x3fe7bd37UL, 0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL,
+    0x3fe7afdeUL, 0xe3b0be70UL, 0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL,
+    0xaf9f193cUL, 0xbe5dff6cUL, 0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL,
+    0xbe258ed0UL, 0xa0000000UL, 0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL,
+    0x40000000UL, 0x3fe77aa2UL, 0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL,
+    0x3fe76d5cUL, 0x7cb0b5e4UL, 0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL,
+    0x2b1bc4adUL, 0xbe32e8bbUL, 0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL,
+    0x3e41f57bUL, 0xc0000000UL, 0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL,
+    0x60000000UL, 0x3fe7386cUL, 0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL,
+    0x3fe72b39UL, 0x91d690f7UL, 0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL,
+    0x627a2159UL, 0xbe4425d5UL, 0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL,
+    0x3e422b7eUL, 0x60000000UL, 0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL,
+    0xe0000000UL, 0x3fe6f694UL, 0x84d628a2UL, 0xbe51f090UL, 0x00000000UL,
+    0x3fe6e975UL, 0x306d8894UL, 0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL,
+    0x30bf24aaUL, 0xbe4650caUL, 0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL,
+    0xbe5db007UL, 0xc0000000UL, 0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL,
+    0xc0000000UL, 0x3fe6b51aUL, 0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL,
+    0x3fe6a80dUL, 0xf3559341UL, 0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL,
+    0xa885899eUL, 0xbe5c2011UL, 0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL,
+    0x3e224a82UL, 0xa0000000UL, 0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL,
+    0x00000000UL, 0x3fe673fdUL, 0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL,
+    0x3fe66702UL, 0x5df10408UL, 0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL,
+    0xa4070568UL, 0xbe40b12fUL, 0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL,
+    0x3e5f5e8bUL, 0x00000000UL, 0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL,
+    0xa0000000UL, 0x3fe6333aUL, 0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL,
+    0x3fe62651UL, 0x6f538d61UL, 0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL,
+    0x14344120UL, 0xbe529af6UL, 0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL,
+    0xbe3e1e4fUL, 0x00000000UL, 0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL,
+    0x80000000UL, 0x3fe5f2d2UL, 0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL,
+    0x3fe5e5fbUL, 0xa4695699UL, 0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL,
+    0x80d118aeUL, 0x3e456b61UL, 0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL,
+    0x3e54dc29UL, 0x80000000UL, 0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL,
+    0xe0000000UL, 0x3fe5b2c3UL, 0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL,
+    0x3fe5a5feUL, 0x9292c7eaUL, 0x3e188650UL, 0x20000000UL, 0x3fe5993dUL,
+    0x33b4d380UL, 0x3e5d6d93UL, 0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL,
+    0x3e2fe961UL, 0xa0000000UL, 0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL,
+    0xa0000000UL, 0x3fe5730dUL, 0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL,
+    0x3fe5665aUL, 0x024acfeaUL, 0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL,
+    0xcc9edd09UL, 0xbe325403UL, 0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL,
+    0x3e5d500eUL, 0x60000000UL, 0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL,
+    0xc0000000UL, 0x3fe533aeUL, 0x154b0287UL, 0xbe401571UL, 0xa0000000UL,
+    0x3fe5270cUL, 0x0673f401UL, 0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL,
+    0x751b639cUL, 0x3e235269UL, 0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL,
+    0x3ddec887UL, 0xc0000000UL, 0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL,
+    0x60000000UL, 0x3fe4f4a6UL, 0x2e308668UL, 0x3e59aed6UL, 0x80000000UL,
+    0x3fe4e815UL, 0xf33e2a76UL, 0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL,
+    0x839f3e3eUL, 0x3e57db01UL, 0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL,
+    0x3e535e0fUL, 0x00000000UL, 0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL,
+    0xc0000000UL, 0x3fe4b5f3UL, 0x05192456UL, 0xbe4e8518UL, 0xc0000000UL,
+    0x3fe4a973UL, 0x4aa7cd1dUL, 0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL,
+    0x8e23025eUL, 0xbe5749f2UL, 0x00000000UL, 0x3fe4907eUL, 0x18d30215UL,
+    0x3e360f39UL, 0x20000000UL, 0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL,
+    0xc0000000UL, 0x3fe47795UL, 0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL,
+    0x3fe46b26UL, 0x8f0e62aaUL, 0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL,
+    0x5775c40cUL, 0xbe56aad4UL, 0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL,
+    0x3e48bd71UL, 0x40000000UL, 0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL,
+    0x80000000UL, 0x3fe4398bUL, 0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL,
+    0x3fe42d2dUL, 0x388e4d2eUL, 0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL,
+    0x6f797c18UL, 0x3e554b4cUL, 0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL,
+    0xbe5b1112UL, 0x80000000UL, 0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL,
+    0x40000000UL, 0x3fe3fbd4UL, 0x50201119UL, 0x3e40b701UL, 0x40000000UL,
+    0x3fe3ef86UL, 0x0a4db32cUL, 0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL,
+    0x0c9c148bUL, 0xbe50c1f6UL, 0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL,
+    0x3e533fa0UL, 0x00000000UL, 0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL,
+    0x20000000UL, 0x3fe3be6fUL, 0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL,
+    0x3fe3b231UL, 0x7f908258UL, 0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL,
+    0x1a09af78UL, 0x3e08038bUL, 0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL,
+    0xbe5dbe42UL, 0xe0000000UL, 0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL,
+    0x20000000UL, 0x3fe3815bUL, 0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL,
+    0x3fe3752dUL, 0x6182e429UL, 0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL,
+    0xab6eb1aeUL, 0x3e5a2cc5UL, 0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL,
+    0xbe5c5878UL, 0x40000000UL, 0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL,
+    0x80000000UL, 0x3fe34497UL, 0x857761aaUL, 0x3e5fff53UL, 0x00000000UL,
+    0x3fe3387aUL, 0xf872d68cUL, 0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL,
+    0x087e97c2UL, 0x3e52842eUL, 0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL,
+    0xbe503edfUL, 0x80000000UL, 0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL,
+    0xa0000000UL, 0x3fe30823UL, 0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL,
+    0x3fe2fc15UL, 0x855a7390UL, 0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL,
+    0xa2898287UL, 0x3e3d22a2UL, 0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL,
+    0xbe5aa5fdUL, 0x80000000UL, 0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL,
+    0x60000000UL, 0x3fe2cbfeUL, 0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL,
+    0x3fe2c000UL, 0x6b01bf10UL, 0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL,
+    0xb07a1cdfUL, 0x3e5c5cdaUL, 0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL,
+    0xbe5668b3UL, 0xc0000000UL, 0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL,
+    0x00000000UL, 0x3fe29027UL, 0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL,
+    0x3fe28438UL, 0x6433c727UL, 0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL,
+    0x41782631UL, 0xbe30750cUL, 0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL,
+    0xbe58290eUL, 0x40000000UL, 0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL,
+    0x00000000UL, 0x3fe2549dUL, 0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL,
+    0x3fe248bdUL, 0x4248b9fbUL, 0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL,
+    0xf35cf82fUL, 0x3e561b71UL, 0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL,
+    0x3e518fb9UL, 0x60000000UL, 0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL,
+    0x40000000UL, 0x3fe2195fUL, 0x80943911UL, 0xbe07f819UL, 0x40000000UL,
+    0x3fe20d8fUL, 0x386f2d6cUL, 0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL,
+    0xf29664acUL, 0xbe5eb815UL, 0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL,
+    0x3e5e320cUL, 0x20000000UL, 0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL,
+    0x40000000UL, 0x3fe1de6dUL, 0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL,
+    0x3fe1d2acUL, 0x4ae0b55eUL, 0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL,
+    0x28569a5eUL, 0x3e598a4fUL, 0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL,
+    0x3e46130aUL, 0x20000000UL, 0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL,
+    0x00000000UL, 0x3fe1a3c6UL, 0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL,
+    0x3fe19813UL, 0x2f02b836UL, 0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL,
+    0x28dec9d4UL, 0x3e09064fUL, 0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL,
+    0x3e5b1f46UL, 0x40000000UL, 0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL,
+    0x00000000UL, 0x3fe16969UL, 0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL,
+    0x3fe15dc5UL, 0x73bad6f8UL, 0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL,
+    0x5385769cUL, 0x3e5e8d76UL, 0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL,
+    0x3e571d08UL, 0x20000000UL, 0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL,
+    0x60000000UL, 0x3fe12f55UL, 0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL,
+    0x3fe123c0UL, 0x403638e1UL, 0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL,
+    0x557a092bUL, 0xbdd0116bUL, 0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL,
+    0x3e4a61baUL, 0xc0000000UL, 0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL,
+    0x20000000UL, 0x3fe0ea04UL, 0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL,
+    0x3fe0d300UL, 0x23190e54UL, 0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL,
+    0x1379a5a6UL, 0xbe51619dUL, 0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL,
+    0x3e5cf019UL, 0xa0000000UL, 0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL,
+    0x20000000UL, 0x3fe07762UL, 0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL,
+    0x3fe06097UL, 0xfd9cf274UL, 0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL,
+    0x3689b49dUL, 0xbe36d26dUL, 0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL,
+    0xbe54cd08UL, 0xa0000000UL, 0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL,
+    0x00000000UL, 0x3fe005daUL, 0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL,
+    0x3fdfde8dUL, 0xad67766dUL, 0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL,
+    0x644f4ae7UL, 0x3e1ee43bUL, 0x40000000UL, 0x3fdf8481UL, 0x903234d2UL,
+    0x3e501a86UL, 0x40000000UL, 0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL,
+    0x00000000UL, 0x3fdf2acdUL, 0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL,
+    0x3fdefe13UL, 0x3b94305eUL, 0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL,
+    0x5d95da61UL, 0xbe55c198UL, 0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL,
+    0xbdd99a19UL, 0x00000000UL, 0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL,
+    0x80000000UL, 0x3fde4c04UL, 0x83eec535UL, 0xbe3e1232UL, 0x40000000UL,
+    0x3fde1fb6UL, 0x3dfbffcbUL, 0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL,
+    0x7e1be4e0UL, 0xbe5b8f8fUL, 0x40000000UL, 0x3fddc759UL, 0x46dae887UL,
+    0xbe350458UL, 0x80000000UL, 0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL,
+    0x80000000UL, 0x3fdd6f50UL, 0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL,
+    0x3fdd436bUL, 0xf0bccb32UL, 0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL,
+    0x9bbfc779UL, 0xbe54a26aUL, 0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL,
+    0x3e43c6b7UL, 0x40000000UL, 0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL,
+    0x40000000UL, 0x3fdc94a7UL, 0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL,
+    0x3fdc6929UL, 0xf0a8f95aUL, 0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL,
+    0x6ee2693bUL, 0x3e0992e6UL, 0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL,
+    0xbe2834b6UL, 0x40000000UL, 0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL,
+    0x00000000UL, 0x3fdbbbffUL, 0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL,
+    0x3fdb90e7UL, 0x479664c0UL, 0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL,
+    0x5004975bUL, 0xbe55258fUL, 0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL,
+    0xbe588407UL, 0xc0000000UL, 0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL,
+    0x80000000UL, 0x3fdae54eUL, 0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL,
+    0x3fdaba9aUL, 0xe19d0913UL, 0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL,
+    0x43cfd006UL, 0xbe4cfdebUL, 0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL,
+    0x3e5e47a8UL, 0xc0000000UL, 0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL,
+    0xc0000000UL, 0x3fda108cUL, 0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL,
+    0x3fd9e63aUL, 0x396f8f2cUL, 0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL,
+    0xe32b25ddUL, 0x3e5c3a54UL, 0x40000000UL, 0x3fd991cfUL, 0x431e4035UL,
+    0xbe457925UL, 0x80000000UL, 0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL,
+    0x00000000UL, 0x3fd93db1UL, 0xd7449365UL, 0x3e306419UL, 0x80000000UL,
+    0x3fd913beUL, 0x1746e791UL, 0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL,
+    0xf3a9028bUL, 0xbe5041b9UL, 0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL,
+    0xbe26e20aUL, 0x40000000UL, 0x3fd89659UL, 0x19763102UL, 0xbe51f466UL,
+    0x80000000UL, 0x3fd86cb2UL, 0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL,
+    0x3fd8431eUL, 0xdeb39fabUL, 0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL,
+    0x5d01cbe0UL, 0xbe5425b3UL, 0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL,
+    0x3e146fa8UL, 0x80000000UL, 0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL,
+    0xc0000000UL, 0x3fd79d88UL, 0x8606c236UL, 0x3e423a08UL, 0x80000000UL,
+    0x3fd77451UL, 0x8fd1e1b7UL, 0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL,
+    0xe491456aUL, 0x3e42c1caUL, 0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL,
+    0x3e36a69aUL, 0x00000000UL, 0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL,
+    0x00000000UL, 0x3fd6d02cUL, 0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL,
+    0x3fd6a750UL, 0x1919fd61UL, 0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL,
+    0xaa7a994dUL, 0xbe3f3fbdUL, 0x00000000UL, 0x3fd655ceUL, 0x67db014cUL,
+    0x3e33c550UL, 0x00000000UL, 0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL,
+    0xc0000000UL, 0x3fd60493UL, 0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL,
+    0x3fd5dc11UL, 0x1222bd5cUL, 0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL,
+    0x6e8dc2d3UL, 0x3e5d4d79UL, 0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL,
+    0xbe517303UL, 0x80000000UL, 0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL,
+    0xc0000000UL, 0x3fd53ab8UL, 0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL,
+    0x3fd5128eUL, 0xea902207UL, 0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL,
+    0x9f911d79UL, 0x3e511735UL, 0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL,
+    0xbe5b1643UL, 0x40000000UL, 0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL,
+    0x80000000UL, 0x3fd47293UL, 0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL,
+    0x3fd44abfUL, 0xe04042f5UL, 0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL,
+    0x1d8bf2c8UL, 0x3e5d8810UL, 0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL,
+    0xbe311454UL, 0xc0000000UL, 0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL,
+    0x40000000UL, 0x3fd3ac1cUL, 0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL,
+    0x3fd3849dUL, 0xd4e34b9eUL, 0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL,
+    0x177204fbUL, 0xbe2b8cd7UL, 0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL,
+    0xbe4356e1UL, 0x80000000UL, 0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL,
+    0x00000000UL, 0x3fd2e74cUL, 0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL,
+    0x3fd2c021UL, 0x516dab3fUL, 0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL,
+    0x2bfb7313UL, 0x3e5674a2UL, 0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL,
+    0x3e385d29UL, 0xc0000000UL, 0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL,
+    0x00000000UL, 0x3fd2241cUL, 0x3f91953aUL, 0x3e389977UL, 0xc0000000UL,
+    0x3fd1fd43UL, 0xa1543f71UL, 0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL,
+    0x4ec8867cUL, 0x3df6a2dcUL, 0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL,
+    0x3e41d9c0UL, 0x80000000UL, 0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL,
+    0x40000000UL, 0x3fd16285UL, 0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL,
+    0x3fd13bfeUL, 0xb9aec164UL, 0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL,
+    0xd91e1316UL, 0xbe350630UL, 0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL,
+    0x3e3f5219UL, 0x40000000UL, 0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL,
+    0x00000000UL, 0x3fd0a281UL, 0x2a63447dUL, 0xbe541377UL, 0x80000000UL,
+    0x3fd07c49UL, 0xfac483b5UL, 0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL,
+    0x36b8a570UL, 0xbe4fd4bdUL, 0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL,
+    0xbe450388UL, 0x80000000UL, 0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL,
+    0x80000000UL, 0x3fcfc811UL, 0x707475acUL, 0x3e38806eUL, 0x80000000UL,
+    0x3fcf7c3fUL, 0xc91817fcUL, 0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL,
+    0xae05d5e9UL, 0xbe4919b8UL, 0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL,
+    0xbe530b94UL, 0x00000000UL, 0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL,
+    0x00000000UL, 0x3fce4e2dUL, 0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL,
+    0x3fce02f5UL, 0x8abe2c2eUL, 0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL,
+    0x1495450dUL, 0xbe0872ccUL, 0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL,
+    0xbe4f59a0UL, 0x00000000UL, 0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL,
+    0x00000000UL, 0x3fccd747UL, 0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL,
+    0x3fcc8ca7UL, 0xd305b56cUL, 0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL,
+    0x399a6910UL, 0xbe482a1cUL, 0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL,
+    0xbe587372UL, 0x80000000UL, 0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL,
+    0x00000000UL, 0x3fcb6355UL, 0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL,
+    0x3fcb194aUL, 0x8416c0bcUL, 0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL,
+    0x49f7f08fUL, 0x3e56da76UL, 0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL,
+    0x3e5f390cUL, 0x00000000UL, 0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL,
+    0x80000000UL, 0x3fc9f249UL, 0x33631553UL, 0x3e52aeb1UL, 0x00000000UL,
+    0x3fc9a8d3UL, 0xde8795a6UL, 0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL,
+    0x076bf41eUL, 0x3e5122feUL, 0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL,
+    0x3e3dd064UL, 0x00000000UL, 0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL,
+    0x80000000UL, 0x3fc8841aUL, 0xb2a96650UL, 0xbe575444UL, 0x80000000UL,
+    0x3fc83b34UL, 0x2376c0cbUL, 0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL,
+    0xd8a0b653UL, 0xbe5181b6UL, 0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL,
+    0xbe4a78b4UL, 0x00000000UL, 0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL,
+    0x80000000UL, 0x3fc718bbUL, 0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL,
+    0x3fc6d064UL, 0x3728b8cfUL, 0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL,
+    0xc79a4067UL, 0x3e5c380fUL, 0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL,
+    0x3e550a84UL, 0x80000000UL, 0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL,
+    0x80000000UL, 0x3fc5b022UL, 0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL,
+    0x3fc56858UL, 0x659b18beUL, 0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL,
+    0x66ee3631UL, 0xbe57d769UL, 0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL,
+    0x3e2427f7UL, 0x80000000UL, 0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL,
+    0x00000000UL, 0x3fc44a44UL, 0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL,
+    0x3fc40304UL, 0xcf1d3eabUL, 0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL,
+    0x79aba3eaUL, 0xbdf1b7c8UL, 0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL,
+    0xbe5130cfUL, 0x80000000UL, 0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL,
+    0x00000000UL, 0x3fc2e716UL, 0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL,
+    0x3fc2a05eUL, 0x6caed92eUL, 0xbe533924UL, 0x00000000UL, 0x3fc259c2UL,
+    0x9cb5034eUL, 0xbe510e31UL, 0x80000000UL, 0x3fc21340UL, 0x12c4d378UL,
+    0xbe540b43UL, 0x80000000UL, 0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL,
+    0x00000000UL, 0x3fc1868eUL, 0x921f4106UL, 0xbe528e67UL, 0x80000000UL,
+    0x3fc1405cUL, 0x3969441eUL, 0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL,
+    0xd941ef5bUL, 0x3e5f9079UL, 0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL,
+    0xbe567691UL, 0x00000000UL, 0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL,
+    0x00000000UL, 0x3fc028a2UL, 0x0a92a162UL, 0xbe52f394UL, 0x00000000UL,
+    0x3fbfc5eaUL, 0x209897e5UL, 0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL,
+    0x8458bd7bUL, 0x3e582831UL, 0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL,
+    0xbe486b4aUL, 0x00000000UL, 0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL,
+    0x00000000UL, 0x3fbd9a90UL, 0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL,
+    0x3fbd103cUL, 0x73eb6ab7UL, 0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL,
+    0x32ceaff5UL, 0xbe32dc5aUL, 0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL,
+    0xbe4a71a4UL, 0x00000000UL, 0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL,
+    0x00000000UL, 0x3fbae8eeUL, 0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL,
+    0x3fba5f9aUL, 0x95ce1114UL, 0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL,
+    0x6d7c0f78UL, 0x3e3abc2dUL, 0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL,
+    0xbe566cbcUL, 0x00000000UL, 0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL,
+    0x00000000UL, 0x3fb83c4aUL, 0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL,
+    0x3fb7b3f4UL, 0x2193d81eUL, 0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL,
+    0xdd70c122UL, 0x3e527a8cUL, 0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL,
+    0xbe450393UL, 0x00000000UL, 0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL,
+    0x00000000UL, 0x3fb59492UL, 0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL,
+    0x3fb50d36UL, 0x950f9f45UL, 0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL,
+    0x582cdcb1UL, 0x3e506d39UL, 0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL,
+    0x3e4aa719UL, 0x00000000UL, 0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL,
+    0x00000000UL, 0x3fb2f1b4UL, 0x7a138b41UL, 0xbe50b418UL, 0x00000000UL,
+    0x3fb26b4eUL, 0x2fbfd7eaUL, 0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL,
+    0x18913ccbUL, 0x3e465fc1UL, 0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL,
+    0x3e042843UL, 0x00000000UL, 0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL,
+    0x00000000UL, 0x3fb0539eUL, 0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL,
+    0x3faf9c56UL, 0x1777f657UL, 0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL,
+    0xc317b86aUL, 0xbe5a61e0UL, 0x00000000UL, 0x3fad87acUL, 0xb7664efbUL,
+    0xbe41f64eUL, 0x00000000UL, 0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL,
+    0x00000000UL, 0x3fab7480UL, 0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL,
+    0x3faa6b78UL, 0x06a253f1UL, 0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL,
+    0xa35f541bUL, 0x3e5a187aUL, 0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL,
+    0xbe508150UL, 0x00000000UL, 0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL,
+    0x00000000UL, 0x3fa64b10UL, 0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL,
+    0x3fa543e2UL, 0x97506fefUL, 0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL,
+    0xe75f7dd9UL, 0xbe388dd3UL, 0x00000000UL, 0x3fa3369cUL, 0xa4139632UL,
+    0xbdea5177UL, 0x00000000UL, 0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL,
+    0x00000000UL, 0x3fa12accUL, 0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL,
+    0x3fa0256eUL, 0x7478da78UL, 0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL,
+    0xf59cef7fUL, 0xbe539d0aUL, 0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL,
+    0x3e53c2c8UL, 0x00000000UL, 0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL,
+    0x00000000UL, 0x3f982724UL, 0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL,
+    0x3f962000UL, 0x130d9356UL, 0x3e475ba0UL, 0x00000000UL, 0x3f941994UL,
+    0x8f86f883UL, 0xbe513d0bUL, 0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL,
+    0xbe534335UL, 0x00000000UL, 0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL,
+    0x00000000UL, 0x3f8c1510UL, 0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL,
+    0x3f880de0UL, 0x8a27857eUL, 0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL,
+    0xda767328UL, 0x3e531b3dUL, 0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL,
+    0xbe5f04e3UL, 0x00000000UL, 0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL,
+    0x00000000UL, 0x3f6ffc40UL, 0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL,
+    0x3f5ff6c0UL, 0x1ad218afUL, 0xbe4c78a7UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x80000000UL
+};
+
+ALIGNED_(8) juint _log2_pow[] =
+{
+    0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL
+};
+
+//registers,
+// input: xmm0, xmm1
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          rax, rdx, rcx, r8, r11
+
+// Code generated by Intel C compiler for LIBM library
+
+void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
+  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2;
+  Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2;
+  Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2;
+  Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2;
+  Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2;
+  Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2;
+  Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2;
+  Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2;
+  Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2;
+  Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2;
+  Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2;
+  Label L_2TAG_PACKET_56_0_2;
+  Label B1_2, B1_3, B1_5, start;
+
+  assert_different_registers(tmp1, tmp2, eax, ecx, edx);
+  jmp(start);
+  address HIGHSIGMASK = (address)_HIGHSIGMASK;
+  address LOG2_E = (address)_LOG2_E;
+  address coeff = (address)_coeff_pow;
+  address L_tbl = (address)_L_tbl_pow;
+  address HIGHMASK_Y = (address)_HIGHMASK_Y;
+  address T_exp = (address)_T_exp;
+  address e_coeff = (address)_e_coeff;
+  address coeff_h = (address)_coeff_h;
+  address HIGHMASK_LOG_X = (address)_HIGHMASK_LOG_X;
+  address HALFMASK = (address)_HALFMASK;
+  address log2 = (address)_log2_pow;
+
+
+  bind(start);
+  subq(rsp, 40);
+  movsd(Address(rsp, 8), xmm0);
+  movsd(Address(rsp, 16), xmm1);
+
+  bind(B1_2);
+  pextrw(eax, xmm0, 3);
+  xorpd(xmm2, xmm2);
+  mov64(tmp2, 0x3ff0000000000000);
+  movdq(xmm2, tmp2);
+  movl(tmp1, 1069088768);
+  movdq(xmm7, tmp1);
+  xorpd(xmm1, xmm1);
+  mov64(tmp3, 0x77f0000000000000);
+  movdq(xmm1, tmp3);
+  movdqu(xmm3, xmm0);
+  movl(edx, 32752);
+  andl(edx, eax);
+  subl(edx, 16368);
+  movl(ecx, edx);
+  sarl(edx, 31);
+  addl(ecx, edx);
+  xorl(ecx, edx);
+  por(xmm0, xmm2);
+  movdqu(xmm6, ExternalAddress(HIGHSIGMASK));    //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
+  psrlq(xmm0, 27);
+  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
+  psrld(xmm0, 2);
+  addl(ecx, 16);
+  bsrl(ecx, ecx);
+  rcpps(xmm0, xmm0);
+  psllq(xmm3, 12);
+  movl(tmp4, 8192);
+  movdq(xmm4, tmp4);
+  psrlq(xmm3, 12);
+  subl(eax, 16);
+  cmpl(eax, 32736);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+  movl(tmp1, 0);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  mulss(xmm0, xmm7);
+  movl(edx, -1);
+  subl(ecx, 4);
+  shll(edx);
+  shlq(edx, 32);
+  movdq(xmm5, edx);
+  por(xmm3, xmm1);
+  subl(eax, 16351);
+  cmpl(eax, 1);
+  jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2);
+  paddd(xmm0, xmm4);
+  pand(xmm5, xmm3);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  subsd(xmm3, xmm5);
+  pand(xmm0, xmm6);
+  subl(eax, 1);
+  sarl(eax, 4);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  mulsd(xmm3, xmm0);
+  movdqu(xmm1, ExternalAddress(coeff));    //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL
+  lea(tmp4, ExternalAddress(L_tbl));
+  subsd(xmm5, xmm2);
+  movdqu(xmm4, ExternalAddress(16 + coeff));    //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL
+  movl(ecx, eax);
+  sarl(eax, 31);
+  addl(ecx, eax);
+  xorl(eax, ecx);
+  addl(eax, 1);
+  bsrl(eax, eax);
+  unpcklpd(xmm5, xmm3);
+  movdqu(xmm6, ExternalAddress(32 + coeff));    //0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL
+  addsd(xmm3, xmm5);
+  andl(edx, 16760832);
+  shrl(edx, 10);
+  addpd(xmm5, Address(tmp4, edx, Address::times_1, -3648));
+  movdqu(xmm0, ExternalAddress(48 + coeff));    //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL
+  pshufd(xmm2, xmm3, 68);
+  mulsd(xmm3, xmm3);
+  mulpd(xmm1, xmm2);
+  mulpd(xmm4, xmm2);
+  addsd(xmm5, xmm7);
+  mulsd(xmm2, xmm3);
+  addpd(xmm6, xmm1);
+  mulsd(xmm3, xmm3);
+  addpd(xmm0, xmm4);
+  movq(xmm1, Address(rsp, 16));
+  movw(ecx, Address(rsp, 22));
+  pshufd(xmm7, xmm5, 238);
+  movq(xmm4, ExternalAddress(HIGHMASK_Y));    //0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL
+  mulpd(xmm6, xmm2);
+  pshufd(xmm3, xmm3, 68);
+  mulpd(xmm0, xmm2);
+  shll(eax, 4);
+  subl(eax, 15872);
+  andl(ecx, 32752);
+  addl(eax, ecx);
+  mulpd(xmm3, xmm6);
+  cmpl(eax, 624);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2);
+  xorpd(xmm6, xmm6);
+  movl(edx, 17080);
+  pinsrw(xmm6, edx, 3);
+  movdqu(xmm2, xmm1);
+  pand(xmm4, xmm1);
+  subsd(xmm1, xmm4);
+  mulsd(xmm4, xmm5);
+  addsd(xmm0, xmm7);
+  mulsd(xmm1, xmm5);
+  movdqu(xmm7, xmm6);
+  addsd(xmm6, xmm4);
+  lea(tmp4, ExternalAddress(T_exp));
+  addpd(xmm3, xmm0);
+  movdl(edx, xmm6);
+  subsd(xmm6, xmm7);
+  pshufd(xmm0, xmm3, 238);
+  subsd(xmm4, xmm6);
+  addsd(xmm0, xmm3);
+  movl(ecx, edx);
+  andl(edx, 255);
+  addl(edx, edx);
+  movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0));
+  addsd(xmm4, xmm1);
+  mulsd(xmm2, xmm0);
+  movdqu(xmm7, ExternalAddress(e_coeff));    //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL
+  movdqu(xmm3, ExternalAddress(16 + e_coeff));    //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL
+  shll(ecx, 12);
+  xorl(ecx, tmp1);
+  andl(rcx, -1048576);
+  movdq(xmm6, rcx);
+  addsd(xmm2, xmm4);
+  mov64(tmp2, 0x3fe62e42fefa39ef);
+  movdq(xmm1, tmp2);
+  pshufd(xmm0, xmm2, 68);
+  pshufd(xmm4, xmm2, 68);
+  mulsd(xmm1, xmm2);
+  pshufd(xmm6, xmm6, 17);
+  mulpd(xmm0, xmm0);
+  mulpd(xmm7, xmm4);
+  paddd(xmm5, xmm6);
+  mulsd(xmm1, xmm5);
+  pshufd(xmm6, xmm5, 238);
+  mulsd(xmm0, xmm0);
+  addpd(xmm3, xmm7);
+  addsd(xmm1, xmm6);
+  mulpd(xmm0, xmm3);
+  pshufd(xmm3, xmm0, 238);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm3, xmm5);
+  addsd(xmm0, xmm1);
+  addsd(xmm0, xmm3);
+  addsd(xmm0, xmm5);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  addl(eax, 16);
+  movl(edx, 32752);
+  andl(edx, eax);
+  cmpl(edx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_6_0_2);
+  testl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_7_0_2);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  movq(xmm0, Address(rsp, 8));
+  movq(xmm3, Address(rsp, 8));
+  movdl(edx, xmm3);
+  psrlq(xmm3, 32);
+  movdl(ecx, xmm3);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_9_0_2);
+  xorpd(xmm3, xmm3);
+  movl(eax, 18416);
+  pinsrw(xmm3, eax, 3);
+  mulsd(xmm0, xmm3);
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm3, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 18416);
+  psrlq(xmm0, 27);
+  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
+  psrld(xmm0, 2);
+  rcpps(xmm0, xmm0);
+  psllq(xmm3, 12);
+  movdqu(xmm6, ExternalAddress(HIGHSIGMASK));    //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
+  psrlq(xmm3, 12);
+  mulss(xmm0, xmm7);
+  movl(edx, -1024);
+  movdl(xmm5, edx);
+  por(xmm3, xmm1);
+  paddd(xmm0, xmm4);
+  psllq(xmm5, 32);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  pand(xmm5, xmm3);
+  movl(tmp1, 0);
+  pand(xmm0, xmm6);
+  subsd(xmm3, xmm5);
+  andl(eax, 32752);
+  subl(eax, 18416);
+  sarl(eax, 4);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  jmp(L_2TAG_PACKET_4_0_2);
+
+  bind(L_2TAG_PACKET_10_0_2);
+  movq(xmm0, Address(rsp, 8));
+  movq(xmm3, Address(rsp, 8));
+  movdl(edx, xmm3);
+  psrlq(xmm3, 32);
+  movdl(ecx, xmm3);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_9_0_2);
+  xorpd(xmm3, xmm3);
+  movl(eax, 18416);
+  pinsrw(xmm3, eax, 3);
+  mulsd(xmm0, xmm3);
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm3, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 18416);
+  psrlq(xmm0, 27);
+  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
+  psrld(xmm0, 2);
+  rcpps(xmm0, xmm0);
+  psllq(xmm3, 12);
+  movdqu(xmm6, ExternalAddress(HIGHSIGMASK));    //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL
+  psrlq(xmm3, 12);
+  mulss(xmm0, xmm7);
+  movl(edx, -1024);
+  movdl(xmm5, edx);
+  por(xmm3, xmm1);
+  paddd(xmm0, xmm4);
+  psllq(xmm5, 32);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  pand(xmm5, xmm3);
+  movl(tmp1, INT_MIN);
+  pand(xmm0, xmm6);
+  subsd(xmm3, xmm5);
+  andl(eax, 32752);
+  subl(eax, 18416);
+  sarl(eax, 4);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  jmp(L_2TAG_PACKET_4_0_2);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  cmpl(eax, 0);
+  jcc(Assembler::less, L_2TAG_PACKET_11_0_2);
+  cmpl(eax, 752);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_12_0_2);
+  addsd(xmm0, xmm7);
+  movq(xmm2, ExternalAddress(HALFMASK));    //0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL
+  addpd(xmm3, xmm0);
+  xorpd(xmm6, xmm6);
+  movl(eax, 17080);
+  pinsrw(xmm6, eax, 3);
+  pshufd(xmm0, xmm3, 238);
+  addsd(xmm0, xmm3);
+  movdqu(xmm3, xmm5);
+  addsd(xmm5, xmm0);
+  movdqu(xmm4, xmm2);
+  subsd(xmm3, xmm5);
+  movdqu(xmm7, xmm5);
+  pand(xmm5, xmm2);
+  movdqu(xmm2, xmm1);
+  pand(xmm4, xmm1);
+  subsd(xmm7, xmm5);
+  addsd(xmm0, xmm3);
+  subsd(xmm1, xmm4);
+  mulsd(xmm4, xmm5);
+  addsd(xmm0, xmm7);
+  mulsd(xmm2, xmm0);
+  movdqu(xmm7, xmm6);
+  mulsd(xmm1, xmm5);
+  addsd(xmm6, xmm4);
+  movdl(eax, xmm6);
+  subsd(xmm6, xmm7);
+  lea(tmp4, ExternalAddress(T_exp));
+  addsd(xmm2, xmm1);
+  movdqu(xmm7, ExternalAddress(e_coeff));    //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL
+  movdqu(xmm3, ExternalAddress(16 + e_coeff));    //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL
+  subsd(xmm4, xmm6);
+  pextrw(edx, xmm6, 3);
+  movl(ecx, eax);
+  andl(eax, 255);
+  addl(eax, eax);
+  movdqu(xmm5, Address(tmp4, rax, Address::times_8, 0));
+  addsd(xmm2, xmm4);
+  sarl(ecx, 8);
+  movl(eax, ecx);
+  sarl(ecx, 1);
+  subl(eax, ecx);
+  shll(ecx, 20);
+  xorl(ecx, tmp1);
+  movdl(xmm6, ecx);
+  movq(xmm1, ExternalAddress(32 + e_coeff));    //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL
+  andl(edx, 32767);
+  cmpl(edx, 16529);
+  jcc(Assembler::above, L_2TAG_PACKET_12_0_2);
+  pshufd(xmm0, xmm2, 68);
+  pshufd(xmm4, xmm2, 68);
+  mulpd(xmm0, xmm0);
+  mulpd(xmm7, xmm4);
+  pshufd(xmm6, xmm6, 17);
+  mulsd(xmm1, xmm2);
+  mulsd(xmm0, xmm0);
+  paddd(xmm5, xmm6);
+  addpd(xmm3, xmm7);
+  mulsd(xmm1, xmm5);
+  pshufd(xmm6, xmm5, 238);
+  mulpd(xmm0, xmm3);
+  addsd(xmm1, xmm6);
+  pshufd(xmm3, xmm0, 238);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm3, xmm5);
+  shll(eax, 4);
+  xorpd(xmm4, xmm4);
+  addl(eax, 16368);
+  pinsrw(xmm4, eax, 3);
+  addsd(xmm0, xmm1);
+  addsd(xmm0, xmm3);
+  movdqu(xmm1, xmm0);
+  addsd(xmm0, xmm5);
+  mulsd(xmm0, xmm4);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_13_0_2);
+  cmpl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_14_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_6_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movq(xmm0, Address(rsp, 8));
+  movdqu(xmm2, xmm0);
+  movdl(eax, xmm2);
+  psrlq(xmm2, 20);
+  movdl(edx, xmm2);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_15_0_2);
+  movdl(eax, xmm1);
+  psrlq(xmm1, 32);
+  movdl(edx, xmm1);
+  movl(ecx, edx);
+  addl(edx, edx);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_16_0_2);
+  addsd(xmm0, xmm0);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_16_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  movl(Address(rsp, 0), 29);
+  jmp(L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_18_0_2);
+  movq(xmm0, Address(rsp, 16));
+  addpd(xmm0, xmm0);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_15_0_2);
+  movdl(eax, xmm1);
+  movdqu(xmm2, xmm1);
+  psrlq(xmm1, 32);
+  movdl(edx, xmm1);
+  movl(ecx, edx);
+  addl(edx, edx);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_19_0_2);
+  pextrw(eax, xmm2, 3);
+  andl(eax, 32752);
+  cmpl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_20_0_2);
+  movdl(eax, xmm2);
+  psrlq(xmm2, 20);
+  movdl(edx, xmm2);
+  orl(eax, edx);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_20_0_2);
+  pextrw(eax, xmm0, 3);
+  testl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_21_0_2);
+  testl(ecx, INT_MIN);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_23_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movdl(eax, xmm1);
+  testl(eax, 1);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2);
+  testl(eax, 2);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2);
+  jmp(L_2TAG_PACKET_24_0_2);
+
+  bind(L_2TAG_PACKET_21_0_2);
+  shrl(ecx, 20);
+  andl(ecx, 2047);
+  cmpl(ecx, 1075);
+  jcc(Assembler::above, L_2TAG_PACKET_24_0_2);
+  jcc(Assembler::equal, L_2TAG_PACKET_26_0_2);
+  cmpl(ecx, 1074);
+  jcc(Assembler::above, L_2TAG_PACKET_23_0_2);
+  cmpl(ecx, 1023);
+  jcc(Assembler::below, L_2TAG_PACKET_24_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movl(eax, 17208);
+  xorpd(xmm3, xmm3);
+  pinsrw(xmm3, eax, 3);
+  movdqu(xmm4, xmm3);
+  addsd(xmm3, xmm1);
+  subsd(xmm4, xmm3);
+  addsd(xmm1, xmm4);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2);
+  movdl(eax, xmm3);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_24_0_2);
+
+  bind(L_2TAG_PACKET_25_0_2);
+  movq(xmm1, Address(rsp, 16));
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_27_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_27_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32768);
+  pinsrw(xmm0, eax, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_24_0_2);
+  movq(xmm1, Address(rsp, 16));
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32752);
+  pinsrw(xmm0, eax, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_26_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movdl(eax, xmm1);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_24_0_2);
+  jmp(L_2TAG_PACKET_25_0_2);
+
+  bind(L_2TAG_PACKET_28_0_2);
+  movdl(eax, xmm1);
+  psrlq(xmm1, 20);
+  movdl(edx, xmm1);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_29_0_2);
+  movq(xmm0, Address(rsp, 16));
+  addsd(xmm0, xmm0);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_29_0_2);
+  movq(xmm0, Address(rsp, 8));
+  pextrw(eax, xmm0, 3);
+  cmpl(eax, 49136);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2);
+  movdl(ecx, xmm0);
+  psrlq(xmm0, 20);
+  movdl(edx, xmm0);
+  orl(ecx, edx);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32760);
+  pinsrw(xmm0, eax, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_30_0_2);
+  movq(xmm1, Address(rsp, 16));
+  andl(eax, 32752);
+  subl(eax, 16368);
+  pextrw(edx, xmm1, 3);
+  xorpd(xmm0, xmm0);
+  xorl(eax, edx);
+  andl(eax, 32768);
+  jcc(Assembler::equal, L_2TAG_PACKET_31_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_31_0_2);
+  movl(ecx, 32752);
+  pinsrw(xmm0, ecx, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_32_0_2);
+  movdl(eax, xmm1);
+  cmpl(edx, 17184);
+  jcc(Assembler::above, L_2TAG_PACKET_33_0_2);
+  testl(eax, 1);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
+  testl(eax, 2);
+  jcc(Assembler::equal, L_2TAG_PACKET_35_0_2);
+  jmp(L_2TAG_PACKET_36_0_2);
+
+  bind(L_2TAG_PACKET_33_0_2);
+  testl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_35_0_2);
+  jmp(L_2TAG_PACKET_36_0_2);
+
+  bind(L_2TAG_PACKET_7_0_2);
+  movq(xmm2, Address(rsp, 8));
+  movdl(eax, xmm2);
+  psrlq(xmm2, 31);
+  movdl(ecx, xmm2);
+  orl(eax, ecx);
+  jcc(Assembler::equal, L_2TAG_PACKET_9_0_2);
+  movq(xmm1, Address(rsp, 16));
+  pextrw(edx, xmm1, 3);
+  movdl(eax, xmm1);
+  movdqu(xmm2, xmm1);
+  psrlq(xmm2, 32);
+  movdl(ecx, xmm2);
+  addl(ecx, ecx);
+  orl(ecx, eax);
+  jcc(Assembler::equal, L_2TAG_PACKET_37_0_2);
+  andl(edx, 32752);
+  cmpl(edx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_28_0_2);
+  cmpl(edx, 17200);
+  jcc(Assembler::above, L_2TAG_PACKET_35_0_2);
+  cmpl(edx, 17184);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_32_0_2);
+  cmpl(edx, 16368);
+  jcc(Assembler::below, L_2TAG_PACKET_34_0_2);
+  movl(eax, 17208);
+  xorpd(xmm2, xmm2);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm4, xmm2);
+  addsd(xmm2, xmm1);
+  subsd(xmm4, xmm2);
+  addsd(xmm1, xmm4);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32767);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
+  movdl(eax, xmm2);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_35_0_2);
+
+  bind(L_2TAG_PACKET_36_0_2);
+  xorpd(xmm1, xmm1);
+  movl(edx, 30704);
+  pinsrw(xmm1, edx, 3);
+  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
+  movq(xmm4, Address(rsp, 8));
+  pextrw(eax, xmm4, 3);
+  movl(edx, 8192);
+  movdl(xmm4, edx);
+  andl(eax, 32767);
+  subl(eax, 16);
+  jcc(Assembler::less, L_2TAG_PACKET_10_0_2);
+  movl(edx, eax);
+  andl(edx, 32752);
+  subl(edx, 16368);
+  movl(ecx, edx);
+  sarl(edx, 31);
+  addl(ecx, edx);
+  xorl(ecx, edx);
+  addl(ecx, 16);
+  bsrl(ecx, ecx);
+  movl(tmp1, INT_MIN);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_34_0_2);
+  xorpd(xmm1, xmm1);
+  movl(eax, 32752);
+  pinsrw(xmm1, eax, 3);
+  xorpd(xmm0, xmm0);
+  mulsd(xmm0, xmm1);
+  movl(Address(rsp, 0), 28);
+  jmp(L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_35_0_2);
+  xorpd(xmm1, xmm1);
+  movl(edx, 30704);
+  pinsrw(xmm1, edx, 3);
+  movq(xmm2, ExternalAddress(LOG2_E));    //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL
+  movq(xmm4, Address(rsp, 8));
+  pextrw(eax, xmm4, 3);
+  movl(edx, 8192);
+  movdl(xmm4, edx);
+  andl(eax, 32767);
+  subl(eax, 16);
+  jcc(Assembler::less, L_2TAG_PACKET_8_0_2);
+  movl(edx, eax);
+  andl(edx, 32752);
+  subl(edx, 16368);
+  movl(ecx, edx);
+  sarl(edx, 31);
+  addl(ecx, edx);
+  xorl(ecx, edx);
+  addl(ecx, 16);
+  bsrl(ecx, ecx);
+  movl(tmp1, 0);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_19_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_22_0_2);
+  xorpd(xmm0, xmm0);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_11_0_2);
+  addl(eax, 384);
+  cmpl(eax, 0);
+  jcc(Assembler::less, L_2TAG_PACKET_38_0_2);
+  mulsd(xmm5, xmm1);
+  addsd(xmm0, xmm7);
+  shrl(tmp1, 31);
+  addpd(xmm3, xmm0);
+  pshufd(xmm0, xmm3, 238);
+  addsd(xmm3, xmm0);
+  lea(tmp4, ExternalAddress(log2));    //0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL
+  movq(xmm4, Address(tmp4, tmp1, Address::times_8, 0));
+  mulsd(xmm1, xmm3);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  shll(tmp1, 15);
+  orl(eax, tmp1);
+  pinsrw(xmm0, eax, 3);
+  addsd(xmm5, xmm1);
+  mulsd(xmm5, xmm4);
+  addsd(xmm0, xmm5);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_38_0_2);
+
+  bind(L_2TAG_PACKET_37_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_39_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  movl(Address(rsp, 0), 26);
+  jmp(L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_9_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movdqu(xmm2, xmm1);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32752);
+  cmpl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_40_0_2);
+  movdl(eax, xmm2);
+  psrlq(xmm2, 20);
+  movdl(edx, xmm2);
+  orl(eax, edx);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_40_0_2);
+  movdl(eax, xmm1);
+  psrlq(xmm1, 32);
+  movdl(edx, xmm1);
+  movl(ecx, edx);
+  addl(edx, edx);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_39_0_2);
+  shrl(edx, 21);
+  cmpl(edx, 1075);
+  jcc(Assembler::above, L_2TAG_PACKET_41_0_2);
+  jcc(Assembler::equal, L_2TAG_PACKET_42_0_2);
+  cmpl(edx, 1023);
+  jcc(Assembler::below, L_2TAG_PACKET_41_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movl(eax, 17208);
+  xorpd(xmm3, xmm3);
+  pinsrw(xmm3, eax, 3);
+  movdqu(xmm4, xmm3);
+  addsd(xmm3, xmm1);
+  subsd(xmm4, xmm3);
+  addsd(xmm1, xmm4);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_41_0_2);
+  movdl(eax, xmm3);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_41_0_2);
+
+  bind(L_2TAG_PACKET_43_0_2);
+  movq(xmm0, Address(rsp, 8));
+  testl(ecx, INT_MIN);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_42_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movdl(eax, xmm1);
+  testl(eax, 1);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2);
+
+  bind(L_2TAG_PACKET_41_0_2);
+  testl(ecx, INT_MIN);
+  jcc(Assembler::equal, L_2TAG_PACKET_22_0_2);
+  xorpd(xmm0, xmm0);
+
+  bind(L_2TAG_PACKET_44_0_2);
+  movl(eax, 16368);
+  xorpd(xmm1, xmm1);
+  pinsrw(xmm1, eax, 3);
+  divsd(xmm1, xmm0);
+  movdqu(xmm0, xmm1);
+  movl(Address(rsp, 0), 27);
+  jmp(L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_12_0_2);
+  movq(xmm2, Address(rsp, 8));
+  movq(xmm6, Address(rsp, 16));
+  pextrw(eax, xmm2, 3);
+  pextrw(edx, xmm6, 3);
+  movl(ecx, 32752);
+  andl(ecx, edx);
+  cmpl(ecx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_45_0_2);
+  andl(eax, 32752);
+  subl(eax, 16368);
+  xorl(edx, eax);
+  testl(edx, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2);
+
+  bind(L_2TAG_PACKET_47_0_2);
+  movl(eax, 32736);
+  pinsrw(xmm0, eax, 3);
+  shrl(tmp1, 16);
+  orl(eax, tmp1);
+  pinsrw(xmm1, eax, 3);
+  mulsd(xmm0, xmm1);
+
+  bind(L_2TAG_PACKET_14_0_2);
+  movl(Address(rsp, 0), 24);
+  jmp(L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_46_0_2);
+  movl(eax, 16);
+  pinsrw(xmm0, eax, 3);
+  mulsd(xmm0, xmm0);
+  testl(tmp1, INT_MIN);
+  jcc(Assembler::equal, L_2TAG_PACKET_48_0_2);
+  mov64(tmp2, 0x8000000000000000);
+  movdq(xmm2, tmp2);
+  xorpd(xmm0, xmm2);
+
+  bind(L_2TAG_PACKET_48_0_2);
+  movl(Address(rsp, 0), 25);
+  jmp(L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_13_0_2);
+  pextrw(ecx, xmm5, 3);
+  pextrw(edx, xmm4, 3);
+  movl(eax, -1);
+  andl(ecx, 32752);
+  subl(ecx, 16368);
+  andl(edx, 32752);
+  addl(edx, ecx);
+  movl(ecx, -31);
+  sarl(edx, 4);
+  subl(ecx, edx);
+  jcc(Assembler::lessEqual, L_2TAG_PACKET_49_0_2);
+  cmpl(ecx, 20);
+  jcc(Assembler::above, L_2TAG_PACKET_50_0_2);
+  shll(eax);
+
+  bind(L_2TAG_PACKET_49_0_2);
+  movdl(xmm0, eax);
+  psllq(xmm0, 32);
+  pand(xmm0, xmm5);
+  subsd(xmm5, xmm0);
+  addsd(xmm5, xmm1);
+  mulsd(xmm0, xmm4);
+  mulsd(xmm5, xmm4);
+  addsd(xmm0, xmm5);
+
+  bind(L_2TAG_PACKET_50_0_2);
+  jmp(L_2TAG_PACKET_48_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movw(ecx, Address(rsp, 22));
+  movl(edx, INT_MIN);
+  movdl(xmm1, rdx);
+  xorpd(xmm7, xmm7);
+  paddd(xmm0, xmm4);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  paddq(xmm1, xmm3);
+  pand(xmm5, xmm1);
+  andl(ecx, 32752);
+  cmpl(ecx, 16560);
+  jcc(Assembler::less, L_2TAG_PACKET_3_0_2);
+  pand(xmm0, xmm6);
+  subsd(xmm3, xmm5);
+  addl(eax, 16351);
+  shrl(eax, 4);
+  subl(eax, 1022);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  lea(r11, ExternalAddress(L_tbl));
+  movq(xmm4, ExternalAddress(coeff_h));    //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL
+  mulsd(xmm3, xmm0);
+  movq(xmm6, ExternalAddress(coeff_h));    //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL
+  subsd(xmm5, xmm2);
+  movq(xmm1, ExternalAddress(8 + coeff_h));    //0x00000000UL, 0xbf5dabe1UL
+  pshufd(xmm2, xmm3, 68);
+  unpcklpd(xmm5, xmm3);
+  addsd(xmm3, xmm5);
+  movq(xmm0, ExternalAddress(8 + coeff_h));    //0x00000000UL, 0xbf5dabe1UL
+  andl(edx, 16760832);
+  shrl(edx, 10);
+  addpd(xmm7, Address(tmp4, edx, Address::times_1, -3648));
+  mulsd(xmm4, xmm5);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm6, xmm2);
+  mulsd(xmm1, xmm2);
+  movdqu(xmm2, xmm5);
+  mulsd(xmm4, xmm5);
+  addsd(xmm5, xmm0);
+  movdqu(xmm0, xmm7);
+  addsd(xmm2, xmm3);
+  addsd(xmm7, xmm5);
+  mulsd(xmm6, xmm2);
+  subsd(xmm0, xmm7);
+  movdqu(xmm2, xmm7);
+  addsd(xmm7, xmm4);
+  addsd(xmm0, xmm5);
+  subsd(xmm2, xmm7);
+  addsd(xmm4, xmm2);
+  pshufd(xmm2, xmm5, 238);
+  movdqu(xmm5, xmm7);
+  addsd(xmm7, xmm2);
+  addsd(xmm4, xmm0);
+  movdqu(xmm0, ExternalAddress(coeff));    //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL
+  subsd(xmm5, xmm7);
+  addsd(xmm6, xmm4);
+  movdqu(xmm4, xmm7);
+  addsd(xmm5, xmm2);
+  addsd(xmm7, xmm1);
+  movdqu(xmm2, ExternalAddress(64 + coeff));    //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL
+  subsd(xmm4, xmm7);
+  addsd(xmm6, xmm5);
+  addsd(xmm4, xmm1);
+  pshufd(xmm5, xmm7, 238);
+  movapd(xmm1, xmm7);
+  addsd(xmm7, xmm5);
+  subsd(xmm1, xmm7);
+  addsd(xmm1, xmm5);
+  movdqu(xmm5, ExternalAddress(80 + coeff));    //0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL
+  pshufd(xmm3, xmm3, 68);
+  addsd(xmm6, xmm4);
+  addsd(xmm6, xmm1);
+  movdqu(xmm1, ExternalAddress(32 + coeff));    //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL
+  mulpd(xmm0, xmm3);
+  mulpd(xmm2, xmm3);
+  pshufd(xmm4, xmm3, 68);
+  mulpd(xmm3, xmm3);
+  addpd(xmm0, xmm1);
+  addpd(xmm5, xmm2);
+  mulsd(xmm4, xmm3);
+  movq(xmm2, ExternalAddress(HIGHMASK_LOG_X));    //0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL
+  mulpd(xmm3, xmm3);
+  movq(xmm1, Address(rsp, 16));
+  movw(ecx, Address(rsp, 22));
+  mulpd(xmm0, xmm4);
+  pextrw(eax, xmm7, 3);
+  mulpd(xmm5, xmm4);
+  mulpd(xmm0, xmm3);
+  movq(xmm4, ExternalAddress(8 + HIGHMASK_Y));    //0x00000000UL, 0xffffffffUL
+  pand(xmm2, xmm7);
+  addsd(xmm5, xmm6);
+  subsd(xmm7, xmm2);
+  addpd(xmm5, xmm0);
+  andl(eax, 32752);
+  subl(eax, 16368);
+  andl(ecx, 32752);
+  cmpl(ecx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_45_0_2);
+  addl(ecx, eax);
+  cmpl(ecx, 16576);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_51_0_2);
+  pshufd(xmm0, xmm5, 238);
+  pand(xmm4, xmm1);
+  movdqu(xmm3, xmm1);
+  addsd(xmm5, xmm0);
+  subsd(xmm1, xmm4);
+  xorpd(xmm6, xmm6);
+  movl(edx, 17080);
+  pinsrw(xmm6, edx, 3);
+  addsd(xmm7, xmm5);
+  mulsd(xmm4, xmm2);
+  mulsd(xmm1, xmm2);
+  movdqu(xmm5, xmm6);
+  mulsd(xmm3, xmm7);
+  addsd(xmm6, xmm4);
+  addsd(xmm1, xmm3);
+  movdqu(xmm7, ExternalAddress(e_coeff));    //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL
+  movdl(edx, xmm6);
+  subsd(xmm6, xmm5);
+  lea(tmp4, ExternalAddress(T_exp));
+  movdqu(xmm3, ExternalAddress(16 + e_coeff));    //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL
+  movq(xmm2, ExternalAddress(32 + e_coeff));    //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL
+  subsd(xmm4, xmm6);
+  movl(ecx, edx);
+  andl(edx, 255);
+  addl(edx, edx);
+  movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0));
+  addsd(xmm4, xmm1);
+  pextrw(edx, xmm6, 3);
+  shrl(ecx, 8);
+  movl(eax, ecx);
+  shrl(ecx, 1);
+  subl(eax, ecx);
+  shll(ecx, 20);
+  movdl(xmm6, ecx);
+  pshufd(xmm0, xmm4, 68);
+  pshufd(xmm1, xmm4, 68);
+  mulpd(xmm0, xmm0);
+  mulpd(xmm7, xmm1);
+  pshufd(xmm6, xmm6, 17);
+  mulsd(xmm2, xmm4);
+  andl(edx, 32767);
+  cmpl(edx, 16529);
+  jcc(Assembler::above, L_2TAG_PACKET_12_0_2);
+  mulsd(xmm0, xmm0);
+  paddd(xmm5, xmm6);
+  addpd(xmm3, xmm7);
+  mulsd(xmm2, xmm5);
+  pshufd(xmm6, xmm5, 238);
+  mulpd(xmm0, xmm3);
+  addsd(xmm2, xmm6);
+  pshufd(xmm3, xmm0, 238);
+  addl(eax, 1023);
+  shll(eax, 20);
+  orl(eax, tmp1);
+  movdl(xmm4, eax);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm3, xmm5);
+  addsd(xmm0, xmm2);
+  psllq(xmm4, 32);
+  addsd(xmm0, xmm3);
+  movdqu(xmm1, xmm0);
+  addsd(xmm0, xmm5);
+  mulsd(xmm0, xmm4);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_13_0_2);
+  cmpl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_14_0_2);
+
+  bind(L_2TAG_PACKET_52_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_45_0_2);
+  movq(xmm0, Address(rsp, 8));
+  xorpd(xmm2, xmm2);
+  movl(eax, 49136);
+  pinsrw(xmm2, eax, 3);
+  addsd(xmm2, xmm0);
+  pextrw(eax, xmm2, 3);
+  cmpl(eax, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_53_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32760);
+  pinsrw(xmm0, eax, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_53_0_2);
+  movq(xmm1, Address(rsp, 16));
+  movdl(edx, xmm1);
+  movdqu(xmm3, xmm1);
+  psrlq(xmm3, 20);
+  movdl(ecx, xmm3);
+  orl(ecx, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_54_0_2);
+  addsd(xmm1, xmm1);
+  movdqu(xmm0, xmm1);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_51_0_2);
+  pextrw(eax, xmm1, 3);
+  pextrw(ecx, xmm2, 3);
+  xorl(eax, ecx);
+  testl(eax, 32768);
+  jcc(Assembler::equal, L_2TAG_PACKET_47_0_2);
+  jmp(L_2TAG_PACKET_46_0_2);
+
+  bind(L_2TAG_PACKET_54_0_2);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  pextrw(edx, xmm1, 3);
+  xorpd(xmm0, xmm0);
+  subl(eax, 16368);
+  xorl(eax, edx);
+  testl(eax, 32768);
+  jcc(Assembler::equal, L_2TAG_PACKET_55_0_2);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_55_0_2);
+  movl(edx, 32752);
+  pinsrw(xmm0, edx, 3);
+  jmp(B1_5);
+
+  bind(L_2TAG_PACKET_17_0_2);
+  movq(Address(rsp, 24), xmm0);
+
+  bind(B1_3);
+  movq(xmm0, Address(rsp, 24));
+
+  bind(L_2TAG_PACKET_56_0_2);
+
+  bind(B1_5);
+  addq(rsp, 40);
+}
+#else
+// The 32 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _static_const_table_pow[] =
+{
+    0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL, 0xf8000000UL,
+    0xffffffffUL, 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0x00000000UL, 0x20000000UL, 0x3feff00aUL, 0x96621f95UL,
+    0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL, 0xe5916f9eUL, 0xbe325278UL,
+    0x00000000UL, 0x3fefd02fUL, 0x859a1062UL, 0x3e595fb7UL, 0xc0000000UL,
+    0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL, 0xe0000000UL, 0x3fefb069UL,
+    0xad2880a7UL, 0xbe501230UL, 0x60000000UL, 0x3fefa08fUL, 0xc8e72420UL,
+    0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL, 0xc30c4500UL, 0xbe5d6c75UL,
+    0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL, 0x3e2e1318UL, 0xc0000000UL,
+    0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL, 0x00000000UL, 0x3fef615cUL,
+    0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL, 0x3fef519cUL, 0x65c5cd68UL,
+    0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL, 0x46d1306cUL, 0xbe5a840eUL,
+    0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL, 0x3e5071afUL, 0xa0000000UL,
+    0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL, 0xa0000000UL, 0x3fef12d4UL,
+    0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL, 0x3fef032fUL, 0xbc7247faUL,
+    0xbe2bab83UL, 0x80000000UL, 0x3feef390UL, 0xbcaa1e46UL, 0xbe53bb3bUL,
+    0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL, 0xbe54c619UL, 0x80000000UL,
+    0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL, 0xe0000000UL, 0x3feec4d1UL,
+    0xec678f76UL, 0xbe369af6UL, 0x80000000UL, 0x3feeb547UL, 0x41301f55UL,
+    0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL, 0x676da6bdUL, 0xbe4d8dd0UL,
+    0x60000000UL, 0x3fee9642UL, 0x57a891c4UL, 0x3e51f991UL, 0xa0000000UL,
+    0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL, 0x20000000UL, 0x3fee7752UL,
+    0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL, 0x3fee67e1UL, 0xd75b5bf1UL,
+    0xbe449531UL, 0x80000000UL, 0x3fee5876UL, 0xbd423b8eUL, 0x3df54fe4UL,
+    0x60000000UL, 0x3fee4910UL, 0x330e51b9UL, 0x3e54289cUL, 0x80000000UL,
+    0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL, 0xa0000000UL, 0x3fee2a53UL,
+    0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL, 0x3fee1afcUL, 0x0989328dUL,
+    0x3e23958cUL, 0x40000000UL, 0x3fee0babUL, 0xee642abdUL, 0xbe425dd8UL,
+    0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL, 0x3e526362UL, 0x20000000UL,
+    0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL, 0xc0000000UL, 0x3fedddd4UL,
+    0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL, 0x3fedce97UL, 0x0ecac52fUL,
+    0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL, 0x124cb3b8UL, 0x3e257024UL,
+    0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL, 0xbe2033eeUL, 0x20000000UL,
+    0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL, 0xc0000000UL, 0x3fed91d3UL,
+    0xef8a552aUL, 0xbe543390UL, 0x40000000UL, 0x3fed82afUL, 0xb8e85204UL,
+    0x3e513850UL, 0xe0000000UL, 0x3fed738fUL, 0x3d59fe08UL, 0xbe5db728UL,
+    0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL, 0x3e58804bUL, 0xc0000000UL,
+    0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL, 0x00000000UL, 0x3fed464fUL,
+    0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL, 0x3fed3743UL, 0xb0b0a190UL,
+    0x3e598635UL, 0x80000000UL, 0x3fed283cUL, 0xe2113295UL, 0xbe5c1119UL,
+    0x80000000UL, 0x3fed193aUL, 0xafbf1728UL, 0xbe492e9cUL, 0x60000000UL,
+    0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL, 0x20000000UL, 0x3fecfb45UL,
+    0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL, 0x3fecec51UL, 0x110f7dddUL,
+    0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL, 0x7dd7d508UL, 0xbe5a8943UL,
+    0x80000000UL, 0x3fecce79UL, 0x9b60f271UL, 0xbe50676aUL, 0x80000000UL,
+    0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL, 0x60000000UL, 0x3fecb0b4UL,
+    0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL, 0x3feca1d9UL, 0x38a6ec89UL,
+    0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL, 0x3a0b7d8eUL, 0x3e53dbfdUL,
+    0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL, 0xbe27c5c9UL, 0xc0000000UL,
+    0x3fec7563UL, 0x0c706381UL, 0xbe593653UL, 0x60000000UL, 0x3fec669bUL,
+    0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL, 0x3fec57d7UL, 0x40e5e7e8UL,
+    0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL, 0x5602770fUL, 0xbe55219dUL,
+    0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL, 0x3e5a5d25UL, 0x60000000UL,
+    0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL, 0x80000000UL, 0x3fec1cf8UL,
+    0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL, 0x3fec0e4cUL, 0x580798bdUL,
+    0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL, 0xb8282df6UL, 0xbe46b874UL,
+    0x20000000UL, 0x3febf102UL, 0xe33a6729UL, 0x3e54963fUL, 0x00000000UL,
+    0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL, 0x60000000UL, 0x3febd3caUL,
+    0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL, 0x3febc535UL, 0xa335c5eeUL,
+    0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL, 0x7325b04dUL, 0x3e42ba15UL,
+    0x60000000UL, 0x3feba819UL, 0x1564540fUL, 0x3e3a9f35UL, 0x40000000UL,
+    0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL, 0xa0000000UL, 0x3feb8b0fUL,
+    0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL, 0x3feb7c91UL, 0x6d6f1ea4UL,
+    0x3e557657UL, 0x00000000UL, 0x3feb6e18UL, 0x5e80a1bfUL, 0x3e4ddbb6UL,
+    0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL, 0x3e592877UL, 0xa0000000UL,
+    0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL, 0xa0000000UL, 0x3feb42c6UL,
+    0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL, 0x3feb345fUL, 0xa3e0cceeUL,
+    0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL, 0x8e752b50UL, 0xbe3da3c2UL,
+    0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL, 0x3e1fb481UL, 0xc0000000UL,
+    0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL, 0x20000000UL, 0x3feafaeeUL,
+    0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL, 0x3feaec9dUL, 0x3c3d640eUL,
+    0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL, 0x8f97a715UL, 0x3e3a8ec5UL,
+    0x20000000UL, 0x3fead008UL, 0x23ab2839UL, 0x3e2fe98aUL, 0x40000000UL,
+    0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL, 0xe0000000UL, 0x3feab384UL,
+    0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL, 0x3feaa549UL, 0x7c7b0eeaUL,
+    0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL, 0xf56f7013UL, 0x3e386200UL,
+    0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL, 0xbe514af5UL, 0xe0000000UL,
+    0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL, 0x60000000UL, 0x3fea6c89UL,
+    0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL, 0x3fea5e64UL, 0x3f19d970UL,
+    0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL, 0x09ea3e6bUL, 0x3e5065dcUL,
+    0x80000000UL, 0x3fea4226UL, 0x78df246cUL, 0x3e5e05f6UL, 0x40000000UL,
+    0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL, 0x40000000UL, 0x3fea25faUL,
+    0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL, 0x3fea17eaUL, 0x9436f40aUL,
+    0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL, 0x4b5253b3UL, 0x3e46380bUL,
+    0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL, 0xbe386f9bUL, 0x20000000UL,
+    0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL, 0x60000000UL, 0x3fe9dfd6UL,
+    0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL, 0x3fe9d1dcUL, 0xeabdff1dUL,
+    0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL, 0xafd30e73UL, 0xbe585e63UL,
+    0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL, 0xbe43e8f9UL, 0x20000000UL,
+    0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL, 0x80000000UL, 0x3fe99a1cUL,
+    0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL, 0x3fe98c37UL, 0x7c9a88fbUL,
+    0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL, 0xda015741UL, 0xbe5d13baUL,
+    0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL, 0x3e51b947UL, 0x00000000UL,
+    0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL, 0x40000000UL, 0x3fe954cbUL,
+    0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL, 0x3fe946faUL, 0xe63b3767UL,
+    0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL, 0xe57cc2a9UL, 0x3e34eda3UL,
+    0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL, 0x3e5766a0UL, 0xc0000000UL,
+    0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL, 0x80000000UL, 0x3fe90fe1UL,
+    0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL, 0x3fe90225UL, 0xdbd3f369UL,
+    0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL, 0x1c9be989UL, 0xbe5e2b0aUL,
+    0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL, 0x3e5c8618UL, 0xe0000000UL,
+    0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL, 0x20000000UL, 0x3fe8cb5eUL,
+    0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL, 0x3fe8bdb6UL, 0x49e58cc3UL,
+    0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL, 0xa7cfeb8fUL, 0x3e56c412UL,
+    0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL, 0x3e1429b8UL, 0x60000000UL,
+    0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL, 0xc0000000UL, 0x3fe8873fUL,
+    0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL, 0x3fe879acUL, 0x56aee828UL,
+    0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL, 0x7ceab8ecUL, 0x3e493365UL,
+    0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL, 0xbe4f7f25UL, 0x00000000UL,
+    0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL, 0x40000000UL, 0x3fe84385UL,
+    0x34ba4e15UL, 0x3e328077UL, 0x80000000UL, 0x3fe83605UL, 0xa670975aUL,
+    0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL, 0xf61b77b2UL, 0xbe43a20aUL,
+    0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL, 0x3e5e5fe5UL, 0xc0000000UL,
+    0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL, 0xa0000000UL, 0x3fe8002dUL,
+    0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL, 0x3fe7f2c1UL, 0x22a16f01UL,
+    0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL, 0xc38cd451UL, 0x3e506963UL,
+    0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL, 0x3e4503d7UL, 0x40000000UL,
+    0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL, 0xa0000000UL, 0x3fe7bd37UL,
+    0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL, 0x3fe7afdeUL, 0xe3b0be70UL,
+    0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL, 0xaf9f193cUL, 0xbe5dff6cUL,
+    0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL, 0xbe258ed0UL, 0xa0000000UL,
+    0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL, 0x40000000UL, 0x3fe77aa2UL,
+    0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL, 0x3fe76d5cUL, 0x7cb0b5e4UL,
+    0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL, 0x2b1bc4adUL, 0xbe32e8bbUL,
+    0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL, 0x3e41f57bUL, 0xc0000000UL,
+    0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL, 0x60000000UL, 0x3fe7386cUL,
+    0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL, 0x3fe72b39UL, 0x91d690f7UL,
+    0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL, 0x627a2159UL, 0xbe4425d5UL,
+    0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL, 0x3e422b7eUL, 0x60000000UL,
+    0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL, 0xe0000000UL, 0x3fe6f694UL,
+    0x84d628a2UL, 0xbe51f090UL, 0x00000000UL, 0x3fe6e975UL, 0x306d8894UL,
+    0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL, 0x30bf24aaUL, 0xbe4650caUL,
+    0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL, 0xbe5db007UL, 0xc0000000UL,
+    0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL, 0xc0000000UL, 0x3fe6b51aUL,
+    0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL, 0x3fe6a80dUL, 0xf3559341UL,
+    0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL, 0xa885899eUL, 0xbe5c2011UL,
+    0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL, 0x3e224a82UL, 0xa0000000UL,
+    0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL, 0x00000000UL, 0x3fe673fdUL,
+    0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL, 0x3fe66702UL, 0x5df10408UL,
+    0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL, 0xa4070568UL, 0xbe40b12fUL,
+    0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL, 0x3e5f5e8bUL, 0x00000000UL,
+    0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL, 0xa0000000UL, 0x3fe6333aUL,
+    0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL, 0x3fe62651UL, 0x6f538d61UL,
+    0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL, 0x14344120UL, 0xbe529af6UL,
+    0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL, 0xbe3e1e4fUL, 0x00000000UL,
+    0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL, 0x80000000UL, 0x3fe5f2d2UL,
+    0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL, 0x3fe5e5fbUL, 0xa4695699UL,
+    0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL, 0x80d118aeUL, 0x3e456b61UL,
+    0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL, 0x3e54dc29UL, 0x80000000UL,
+    0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL, 0xe0000000UL, 0x3fe5b2c3UL,
+    0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL, 0x3fe5a5feUL, 0x9292c7eaUL,
+    0x3e188650UL, 0x20000000UL, 0x3fe5993dUL, 0x33b4d380UL, 0x3e5d6d93UL,
+    0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL, 0x3e2fe961UL, 0xa0000000UL,
+    0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL, 0xa0000000UL, 0x3fe5730dUL,
+    0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL, 0x3fe5665aUL, 0x024acfeaUL,
+    0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL, 0xcc9edd09UL, 0xbe325403UL,
+    0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL, 0x3e5d500eUL, 0x60000000UL,
+    0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL, 0xc0000000UL, 0x3fe533aeUL,
+    0x154b0287UL, 0xbe401571UL, 0xa0000000UL, 0x3fe5270cUL, 0x0673f401UL,
+    0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL, 0x751b639cUL, 0x3e235269UL,
+    0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL, 0x3ddec887UL, 0xc0000000UL,
+    0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL, 0x60000000UL, 0x3fe4f4a6UL,
+    0x2e308668UL, 0x3e59aed6UL, 0x80000000UL, 0x3fe4e815UL, 0xf33e2a76UL,
+    0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL, 0x839f3e3eUL, 0x3e57db01UL,
+    0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL, 0x3e535e0fUL, 0x00000000UL,
+    0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL, 0xc0000000UL, 0x3fe4b5f3UL,
+    0x05192456UL, 0xbe4e8518UL, 0xc0000000UL, 0x3fe4a973UL, 0x4aa7cd1dUL,
+    0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL, 0x8e23025eUL, 0xbe5749f2UL,
+    0x00000000UL, 0x3fe4907eUL, 0x18d30215UL, 0x3e360f39UL, 0x20000000UL,
+    0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL, 0xc0000000UL, 0x3fe47795UL,
+    0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL, 0x3fe46b26UL, 0x8f0e62aaUL,
+    0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL, 0x5775c40cUL, 0xbe56aad4UL,
+    0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL, 0x3e48bd71UL, 0x40000000UL,
+    0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL, 0x80000000UL, 0x3fe4398bUL,
+    0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL, 0x3fe42d2dUL, 0x388e4d2eUL,
+    0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL, 0x6f797c18UL, 0x3e554b4cUL,
+    0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL, 0xbe5b1112UL, 0x80000000UL,
+    0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL, 0x40000000UL, 0x3fe3fbd4UL,
+    0x50201119UL, 0x3e40b701UL, 0x40000000UL, 0x3fe3ef86UL, 0x0a4db32cUL,
+    0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL, 0x0c9c148bUL, 0xbe50c1f6UL,
+    0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL, 0x3e533fa0UL, 0x00000000UL,
+    0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL, 0x20000000UL, 0x3fe3be6fUL,
+    0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL, 0x3fe3b231UL, 0x7f908258UL,
+    0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL, 0x1a09af78UL, 0x3e08038bUL,
+    0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL, 0xbe5dbe42UL, 0xe0000000UL,
+    0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL, 0x20000000UL, 0x3fe3815bUL,
+    0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL, 0x3fe3752dUL, 0x6182e429UL,
+    0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL, 0xab6eb1aeUL, 0x3e5a2cc5UL,
+    0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL, 0xbe5c5878UL, 0x40000000UL,
+    0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL, 0x80000000UL, 0x3fe34497UL,
+    0x857761aaUL, 0x3e5fff53UL, 0x00000000UL, 0x3fe3387aUL, 0xf872d68cUL,
+    0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL, 0x087e97c2UL, 0x3e52842eUL,
+    0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL, 0xbe503edfUL, 0x80000000UL,
+    0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL, 0xa0000000UL, 0x3fe30823UL,
+    0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL, 0x3fe2fc15UL, 0x855a7390UL,
+    0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL, 0xa2898287UL, 0x3e3d22a2UL,
+    0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL, 0xbe5aa5fdUL, 0x80000000UL,
+    0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL, 0x60000000UL, 0x3fe2cbfeUL,
+    0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL, 0x3fe2c000UL, 0x6b01bf10UL,
+    0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL, 0xb07a1cdfUL, 0x3e5c5cdaUL,
+    0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL, 0xbe5668b3UL, 0xc0000000UL,
+    0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL, 0x00000000UL, 0x3fe29027UL,
+    0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL, 0x3fe28438UL, 0x6433c727UL,
+    0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL, 0x41782631UL, 0xbe30750cUL,
+    0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL, 0xbe58290eUL, 0x40000000UL,
+    0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL, 0x00000000UL, 0x3fe2549dUL,
+    0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL, 0x3fe248bdUL, 0x4248b9fbUL,
+    0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL, 0xf35cf82fUL, 0x3e561b71UL,
+    0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL, 0x3e518fb9UL, 0x60000000UL,
+    0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL, 0x40000000UL, 0x3fe2195fUL,
+    0x80943911UL, 0xbe07f819UL, 0x40000000UL, 0x3fe20d8fUL, 0x386f2d6cUL,
+    0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL, 0xf29664acUL, 0xbe5eb815UL,
+    0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL, 0x3e5e320cUL, 0x20000000UL,
+    0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL, 0x40000000UL, 0x3fe1de6dUL,
+    0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL, 0x3fe1d2acUL, 0x4ae0b55eUL,
+    0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL, 0x28569a5eUL, 0x3e598a4fUL,
+    0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL, 0x3e46130aUL, 0x20000000UL,
+    0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL, 0x00000000UL, 0x3fe1a3c6UL,
+    0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL, 0x3fe19813UL, 0x2f02b836UL,
+    0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL, 0x28dec9d4UL, 0x3e09064fUL,
+    0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL, 0x3e5b1f46UL, 0x40000000UL,
+    0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL, 0x00000000UL, 0x3fe16969UL,
+    0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL, 0x3fe15dc5UL, 0x73bad6f8UL,
+    0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL, 0x5385769cUL, 0x3e5e8d76UL,
+    0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL, 0x3e571d08UL, 0x20000000UL,
+    0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL, 0x60000000UL, 0x3fe12f55UL,
+    0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL, 0x3fe123c0UL, 0x403638e1UL,
+    0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL, 0x557a092bUL, 0xbdd0116bUL,
+    0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL, 0x3e4a61baUL, 0xc0000000UL,
+    0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL, 0x20000000UL, 0x3fe0ea04UL,
+    0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL, 0x3fe0d300UL, 0x23190e54UL,
+    0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL, 0x1379a5a6UL, 0xbe51619dUL,
+    0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL, 0x3e5cf019UL, 0xa0000000UL,
+    0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL, 0x20000000UL, 0x3fe07762UL,
+    0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL, 0x3fe06097UL, 0xfd9cf274UL,
+    0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL, 0x3689b49dUL, 0xbe36d26dUL,
+    0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL, 0xbe54cd08UL, 0xa0000000UL,
+    0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL, 0x00000000UL, 0x3fe005daUL,
+    0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL, 0x3fdfde8dUL, 0xad67766dUL,
+    0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL, 0x644f4ae7UL, 0x3e1ee43bUL,
+    0x40000000UL, 0x3fdf8481UL, 0x903234d2UL, 0x3e501a86UL, 0x40000000UL,
+    0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL, 0x00000000UL, 0x3fdf2acdUL,
+    0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL, 0x3fdefe13UL, 0x3b94305eUL,
+    0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL, 0x5d95da61UL, 0xbe55c198UL,
+    0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL, 0xbdd99a19UL, 0x00000000UL,
+    0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL, 0x80000000UL, 0x3fde4c04UL,
+    0x83eec535UL, 0xbe3e1232UL, 0x40000000UL, 0x3fde1fb6UL, 0x3dfbffcbUL,
+    0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL, 0x7e1be4e0UL, 0xbe5b8f8fUL,
+    0x40000000UL, 0x3fddc759UL, 0x46dae887UL, 0xbe350458UL, 0x80000000UL,
+    0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL, 0x80000000UL, 0x3fdd6f50UL,
+    0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL, 0x3fdd436bUL, 0xf0bccb32UL,
+    0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL, 0x9bbfc779UL, 0xbe54a26aUL,
+    0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL, 0x3e43c6b7UL, 0x40000000UL,
+    0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL, 0x40000000UL, 0x3fdc94a7UL,
+    0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL, 0x3fdc6929UL, 0xf0a8f95aUL,
+    0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL, 0x6ee2693bUL, 0x3e0992e6UL,
+    0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL, 0xbe2834b6UL, 0x40000000UL,
+    0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL, 0x00000000UL, 0x3fdbbbffUL,
+    0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL, 0x3fdb90e7UL, 0x479664c0UL,
+    0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL, 0x5004975bUL, 0xbe55258fUL,
+    0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL, 0xbe588407UL, 0xc0000000UL,
+    0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL, 0x80000000UL, 0x3fdae54eUL,
+    0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL, 0x3fdaba9aUL, 0xe19d0913UL,
+    0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL, 0x43cfd006UL, 0xbe4cfdebUL,
+    0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL, 0x3e5e47a8UL, 0xc0000000UL,
+    0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL, 0xc0000000UL, 0x3fda108cUL,
+    0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL, 0x3fd9e63aUL, 0x396f8f2cUL,
+    0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL, 0xe32b25ddUL, 0x3e5c3a54UL,
+    0x40000000UL, 0x3fd991cfUL, 0x431e4035UL, 0xbe457925UL, 0x80000000UL,
+    0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL, 0x00000000UL, 0x3fd93db1UL,
+    0xd7449365UL, 0x3e306419UL, 0x80000000UL, 0x3fd913beUL, 0x1746e791UL,
+    0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL, 0xf3a9028bUL, 0xbe5041b9UL,
+    0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL, 0xbe26e20aUL, 0x40000000UL,
+    0x3fd89659UL, 0x19763102UL, 0xbe51f466UL, 0x80000000UL, 0x3fd86cb2UL,
+    0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL, 0x3fd8431eUL, 0xdeb39fabUL,
+    0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL, 0x5d01cbe0UL, 0xbe5425b3UL,
+    0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL, 0x3e146fa8UL, 0x80000000UL,
+    0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL, 0xc0000000UL, 0x3fd79d88UL,
+    0x8606c236UL, 0x3e423a08UL, 0x80000000UL, 0x3fd77451UL, 0x8fd1e1b7UL,
+    0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL, 0xe491456aUL, 0x3e42c1caUL,
+    0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL, 0x3e36a69aUL, 0x00000000UL,
+    0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL, 0x00000000UL, 0x3fd6d02cUL,
+    0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL, 0x3fd6a750UL, 0x1919fd61UL,
+    0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL, 0xaa7a994dUL, 0xbe3f3fbdUL,
+    0x00000000UL, 0x3fd655ceUL, 0x67db014cUL, 0x3e33c550UL, 0x00000000UL,
+    0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL, 0xc0000000UL, 0x3fd60493UL,
+    0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL, 0x3fd5dc11UL, 0x1222bd5cUL,
+    0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL, 0x6e8dc2d3UL, 0x3e5d4d79UL,
+    0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL, 0xbe517303UL, 0x80000000UL,
+    0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL, 0xc0000000UL, 0x3fd53ab8UL,
+    0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL, 0x3fd5128eUL, 0xea902207UL,
+    0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL, 0x9f911d79UL, 0x3e511735UL,
+    0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL, 0xbe5b1643UL, 0x40000000UL,
+    0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL, 0x80000000UL, 0x3fd47293UL,
+    0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL, 0x3fd44abfUL, 0xe04042f5UL,
+    0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL, 0x1d8bf2c8UL, 0x3e5d8810UL,
+    0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL, 0xbe311454UL, 0xc0000000UL,
+    0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL, 0x40000000UL, 0x3fd3ac1cUL,
+    0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL, 0x3fd3849dUL, 0xd4e34b9eUL,
+    0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL, 0x177204fbUL, 0xbe2b8cd7UL,
+    0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL, 0xbe4356e1UL, 0x80000000UL,
+    0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL, 0x00000000UL, 0x3fd2e74cUL,
+    0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL, 0x3fd2c021UL, 0x516dab3fUL,
+    0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL, 0x2bfb7313UL, 0x3e5674a2UL,
+    0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL, 0x3e385d29UL, 0xc0000000UL,
+    0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL, 0x00000000UL, 0x3fd2241cUL,
+    0x3f91953aUL, 0x3e389977UL, 0xc0000000UL, 0x3fd1fd43UL, 0xa1543f71UL,
+    0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL, 0x4ec8867cUL, 0x3df6a2dcUL,
+    0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL, 0x3e41d9c0UL, 0x80000000UL,
+    0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL, 0x40000000UL, 0x3fd16285UL,
+    0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL, 0x3fd13bfeUL, 0xb9aec164UL,
+    0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL, 0xd91e1316UL, 0xbe350630UL,
+    0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL, 0x3e3f5219UL, 0x40000000UL,
+    0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL, 0x00000000UL, 0x3fd0a281UL,
+    0x2a63447dUL, 0xbe541377UL, 0x80000000UL, 0x3fd07c49UL, 0xfac483b5UL,
+    0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL, 0x36b8a570UL, 0xbe4fd4bdUL,
+    0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL, 0xbe450388UL, 0x80000000UL,
+    0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL, 0x80000000UL, 0x3fcfc811UL,
+    0x707475acUL, 0x3e38806eUL, 0x80000000UL, 0x3fcf7c3fUL, 0xc91817fcUL,
+    0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL, 0xae05d5e9UL, 0xbe4919b8UL,
+    0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL, 0xbe530b94UL, 0x00000000UL,
+    0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL, 0x00000000UL, 0x3fce4e2dUL,
+    0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL, 0x3fce02f5UL, 0x8abe2c2eUL,
+    0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL, 0x1495450dUL, 0xbe0872ccUL,
+    0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL, 0xbe4f59a0UL, 0x00000000UL,
+    0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL, 0x00000000UL, 0x3fccd747UL,
+    0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL, 0x3fcc8ca7UL, 0xd305b56cUL,
+    0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL, 0x399a6910UL, 0xbe482a1cUL,
+    0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL, 0xbe587372UL, 0x80000000UL,
+    0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL, 0x00000000UL, 0x3fcb6355UL,
+    0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL, 0x3fcb194aUL, 0x8416c0bcUL,
+    0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL, 0x49f7f08fUL, 0x3e56da76UL,
+    0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL, 0x3e5f390cUL, 0x00000000UL,
+    0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL, 0x80000000UL, 0x3fc9f249UL,
+    0x33631553UL, 0x3e52aeb1UL, 0x00000000UL, 0x3fc9a8d3UL, 0xde8795a6UL,
+    0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL, 0x076bf41eUL, 0x3e5122feUL,
+    0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL, 0x3e3dd064UL, 0x00000000UL,
+    0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL, 0x80000000UL, 0x3fc8841aUL,
+    0xb2a96650UL, 0xbe575444UL, 0x80000000UL, 0x3fc83b34UL, 0x2376c0cbUL,
+    0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL, 0xd8a0b653UL, 0xbe5181b6UL,
+    0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL, 0xbe4a78b4UL, 0x00000000UL,
+    0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL, 0x80000000UL, 0x3fc718bbUL,
+    0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL, 0x3fc6d064UL, 0x3728b8cfUL,
+    0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL, 0xc79a4067UL, 0x3e5c380fUL,
+    0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL, 0x3e550a84UL, 0x80000000UL,
+    0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL, 0x80000000UL, 0x3fc5b022UL,
+    0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL, 0x3fc56858UL, 0x659b18beUL,
+    0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL, 0x66ee3631UL, 0xbe57d769UL,
+    0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL, 0x3e2427f7UL, 0x80000000UL,
+    0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL, 0x00000000UL, 0x3fc44a44UL,
+    0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL, 0x3fc40304UL, 0xcf1d3eabUL,
+    0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL, 0x79aba3eaUL, 0xbdf1b7c8UL,
+    0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL, 0xbe5130cfUL, 0x80000000UL,
+    0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL, 0x00000000UL, 0x3fc2e716UL,
+    0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL, 0x3fc2a05eUL, 0x6caed92eUL,
+    0xbe533924UL, 0x00000000UL, 0x3fc259c2UL, 0x9cb5034eUL, 0xbe510e31UL,
+    0x80000000UL, 0x3fc21340UL, 0x12c4d378UL, 0xbe540b43UL, 0x80000000UL,
+    0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL, 0x00000000UL, 0x3fc1868eUL,
+    0x921f4106UL, 0xbe528e67UL, 0x80000000UL, 0x3fc1405cUL, 0x3969441eUL,
+    0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL, 0xd941ef5bUL, 0x3e5f9079UL,
+    0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL, 0xbe567691UL, 0x00000000UL,
+    0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL, 0x00000000UL, 0x3fc028a2UL,
+    0x0a92a162UL, 0xbe52f394UL, 0x00000000UL, 0x3fbfc5eaUL, 0x209897e5UL,
+    0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL, 0x8458bd7bUL, 0x3e582831UL,
+    0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL, 0xbe486b4aUL, 0x00000000UL,
+    0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL, 0x00000000UL, 0x3fbd9a90UL,
+    0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL, 0x3fbd103cUL, 0x73eb6ab7UL,
+    0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL, 0x32ceaff5UL, 0xbe32dc5aUL,
+    0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL, 0xbe4a71a4UL, 0x00000000UL,
+    0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL, 0x00000000UL, 0x3fbae8eeUL,
+    0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL, 0x3fba5f9aUL, 0x95ce1114UL,
+    0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL, 0x6d7c0f78UL, 0x3e3abc2dUL,
+    0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL, 0xbe566cbcUL, 0x00000000UL,
+    0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL, 0x00000000UL, 0x3fb83c4aUL,
+    0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL, 0x3fb7b3f4UL, 0x2193d81eUL,
+    0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL, 0xdd70c122UL, 0x3e527a8cUL,
+    0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL, 0xbe450393UL, 0x00000000UL,
+    0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL, 0x00000000UL, 0x3fb59492UL,
+    0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL, 0x3fb50d36UL, 0x950f9f45UL,
+    0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL, 0x582cdcb1UL, 0x3e506d39UL,
+    0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL, 0x3e4aa719UL, 0x00000000UL,
+    0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL, 0x00000000UL, 0x3fb2f1b4UL,
+    0x7a138b41UL, 0xbe50b418UL, 0x00000000UL, 0x3fb26b4eUL, 0x2fbfd7eaUL,
+    0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL, 0x18913ccbUL, 0x3e465fc1UL,
+    0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL, 0x3e042843UL, 0x00000000UL,
+    0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL, 0x00000000UL, 0x3fb0539eUL,
+    0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL, 0x3faf9c56UL, 0x1777f657UL,
+    0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL, 0xc317b86aUL, 0xbe5a61e0UL,
+    0x00000000UL, 0x3fad87acUL, 0xb7664efbUL, 0xbe41f64eUL, 0x00000000UL,
+    0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL, 0x00000000UL, 0x3fab7480UL,
+    0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL, 0x3faa6b78UL, 0x06a253f1UL,
+    0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL, 0xa35f541bUL, 0x3e5a187aUL,
+    0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL, 0xbe508150UL, 0x00000000UL,
+    0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL, 0x00000000UL, 0x3fa64b10UL,
+    0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL, 0x3fa543e2UL, 0x97506fefUL,
+    0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL, 0xe75f7dd9UL, 0xbe388dd3UL,
+    0x00000000UL, 0x3fa3369cUL, 0xa4139632UL, 0xbdea5177UL, 0x00000000UL,
+    0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL, 0x00000000UL, 0x3fa12accUL,
+    0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL, 0x3fa0256eUL, 0x7478da78UL,
+    0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL, 0xf59cef7fUL, 0xbe539d0aUL,
+    0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL, 0x3e53c2c8UL, 0x00000000UL,
+    0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL, 0x00000000UL, 0x3f982724UL,
+    0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL, 0x3f962000UL, 0x130d9356UL,
+    0x3e475ba0UL, 0x00000000UL, 0x3f941994UL, 0x8f86f883UL, 0xbe513d0bUL,
+    0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL, 0xbe534335UL, 0x00000000UL,
+    0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL, 0x00000000UL, 0x3f8c1510UL,
+    0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL, 0x3f880de0UL, 0x8a27857eUL,
+    0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL, 0xda767328UL, 0x3e531b3dUL,
+    0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL, 0xbe5f04e3UL, 0x00000000UL,
+    0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL, 0x00000000UL, 0x3f6ffc40UL,
+    0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL, 0x3f5ff6c0UL, 0x1ad218afUL,
+    0xbe4c78a7UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL,
+    0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL, 0x00000000UL,
+    0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL, 0x6dc96112UL, 0xbf836578UL,
+    0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL,
+    0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL,
+    0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL, 0x9f95985aUL,
+    0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL, 0x486ececbUL, 0x3fc4635eUL,
+    0x412055ccUL, 0xbdd61bb2UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL,
+    0xffffffffUL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL,
+    0xfa5abcbfUL, 0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL,
+    0x3ff0163dUL, 0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL,
+    0x0fc54eb6UL, 0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL,
+    0xbc719083UL, 0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL,
+    0xe86e7f85UL, 0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL,
+    0x3ff04e5fUL, 0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL,
+    0xa475b465UL, 0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL,
+    0xbc95cb7bUL, 0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL,
+    0x2b72a836UL, 0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL,
+    0x3ff08745UL, 0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL,
+    0x800a3fd1UL, 0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL,
+    0x3c914878UL, 0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL,
+    0x6cf9890fUL, 0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL,
+    0x3ff0c0f1UL, 0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL,
+    0x16e24f71UL, 0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL,
+    0xbc9bc14dUL, 0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL,
+    0x5fdfa9c5UL, 0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL,
+    0x3ff0fb66UL, 0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL,
+    0x1692fdd5UL, 0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL,
+    0xbc96c510UL, 0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL,
+    0xc06c31ccUL, 0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL,
+    0x3ff136a8UL, 0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL,
+    0x9af1369eUL, 0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL,
+    0xbc8b91e8UL, 0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL,
+    0x5471c3c2UL, 0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL,
+    0x3ff172b8UL, 0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL,
+    0xe2ac5a64UL, 0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL,
+    0xbc911023UL, 0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL,
+    0xeb6fcb75UL, 0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL,
+    0x3ff1af99UL, 0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL,
+    0x352ef607UL, 0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL,
+    0x3c900977UL, 0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL,
+    0x5eb44027UL, 0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL,
+    0x3ff1ed50UL, 0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL,
+    0xa097af5cUL, 0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL,
+    0x3c8dc775UL, 0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL,
+    0x917ddc96UL, 0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL,
+    0x3ff22bddUL, 0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL,
+    0xb6c70573UL, 0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL,
+    0x3c8acfccUL, 0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL,
+    0x711ece75UL, 0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL,
+    0x3ff26b45UL, 0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL,
+    0x05f9e76cUL, 0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL,
+    0xbc9a4c3aUL, 0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL,
+    0xf51fdee1UL, 0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL,
+    0x3ff2ab8aUL, 0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL,
+    0xd6381aa4UL, 0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL,
+    0xbc950145UL, 0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL,
+    0x1f641589UL, 0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL,
+    0x3ff2ecafUL, 0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL,
+    0x532bda93UL, 0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL,
+    0x3c86f46aUL, 0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL,
+    0xfc4cd831UL, 0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL,
+    0x3ff32eb8UL, 0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL,
+    0x843659a6UL, 0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL,
+    0xbc835a75UL, 0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL,
+    0xa2de883bUL, 0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL,
+    0x3ff371a7UL, 0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL,
+    0x9eceb23cUL, 0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL,
+    0xbc9e958dUL, 0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL,
+    0x34e59ff7UL, 0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL,
+    0x3ff3b57fUL, 0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL,
+    0x375d29c3UL, 0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL,
+    0x3c7fe8d0UL, 0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL,
+    0xdf1c5175UL, 0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL,
+    0x3ff3fa45UL, 0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL,
+    0xb6f4d048UL, 0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL,
+    0xbc5ef369UL, 0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL,
+    0xd950a897UL, 0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL,
+    0x3ff43ffaUL, 0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL,
+    0x04ef80d0UL, 0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL,
+    0xbc686419UL, 0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL,
+    0x668b3237UL, 0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL,
+    0x3ff486a2UL, 0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL,
+    0x5e499ea0UL, 0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL,
+    0x3c99cb62UL, 0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL,
+    0xd5362a27UL, 0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL,
+    0x3ff4ce41UL, 0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL,
+    0xbc6a7833UL, 0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL,
+    0xbc95257dUL, 0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL,
+    0x7f4531eeUL, 0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL,
+    0x3ff516daUL, 0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL,
+    0x43efef71UL, 0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL,
+    0xbc807abeUL, 0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL,
+    0xca5d920fUL, 0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL,
+    0x3ff56070UL, 0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL,
+    0x011d93adUL, 0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL,
+    0xbc90b98cUL, 0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL,
+    0x27ff07ccUL, 0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL,
+    0x3ff5ab07UL, 0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL,
+    0x4c233e1aUL, 0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL,
+    0x3c3c4b1bUL, 0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL,
+    0x15ad2148UL, 0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL,
+    0x3ff5f6a3UL, 0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL,
+    0x9b56de47UL, 0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL,
+    0x3c9e4b3eUL, 0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL,
+    0x1d1929fdUL, 0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL,
+    0x3ff64346UL, 0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL,
+    0xc9a73e09UL, 0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL,
+    0xbc9bb609UL, 0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL,
+    0xd44ca973UL, 0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL,
+    0x3ff690f4UL, 0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL,
+    0x13b26456UL, 0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL,
+    0x3c7a38f5UL, 0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL,
+    0xddd47645UL, 0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL,
+    0x3ff6dfb2UL, 0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL,
+    0x9e1ac8b2UL, 0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL,
+    0xbc883c0fUL, 0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL,
+    0xe8ec5f74UL, 0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL,
+    0x3ff72f82UL, 0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL,
+    0x6c65d53cUL, 0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL,
+    0x3c9047fdUL, 0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL,
+    0xb1ab6e09UL, 0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL,
+    0x3ff78069UL, 0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL,
+    0x62aadd3eUL, 0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL,
+    0xbc841577UL, 0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL,
+    0x0130c132UL, 0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL,
+    0x3ff7d26aUL, 0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL,
+    0xba15797eUL, 0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL,
+    0xbc807f11UL, 0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL,
+    0xadd106d9UL, 0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL,
+    0x3ff82589UL, 0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL,
+    0x31df2bd5UL, 0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL,
+    0xbc88d684UL, 0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL,
+    0x9b4492edUL, 0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL,
+    0x3ff879caUL, 0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL,
+    0xf37cb53aUL, 0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL,
+    0x3c9d5395UL, 0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL,
+    0xbad61778UL, 0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL,
+    0x3ff8cf32UL, 0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL,
+    0x6fc9b2e6UL, 0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL,
+    0x3c85cc13UL, 0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL,
+    0x0b91ffc6UL, 0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL,
+    0x3ff925c3UL, 0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL,
+    0x81b57ebcUL, 0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL,
+    0xbc8dc3d6UL, 0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL,
+    0x9a7670b3UL, 0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL,
+    0x3ff97d82UL, 0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL,
+    0xa24c78ecUL, 0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL,
+    0xbc9173bdUL, 0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL,
+    0x82a3f090UL, 0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL,
+    0x3ff9d674UL, 0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL,
+    0x78e64c6eUL, 0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL,
+    0xbc84a9ceUL, 0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL,
+    0xed8eb8bbUL, 0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL,
+    0x3ffa309bUL, 0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL,
+    0x589fb120UL, 0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL,
+    0xbc9d2f6eUL, 0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL,
+    0x1330b358UL, 0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL,
+    0x3ffa8bfeUL, 0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL,
+    0x0ef7fd31UL, 0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL,
+    0x3c889c31UL, 0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL,
+    0x3a3c2774UL, 0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL,
+    0x3ffae89fUL, 0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL,
+    0x0f315ecdUL, 0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL,
+    0xbc9bdef5UL, 0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL,
+    0xb84f15fbUL, 0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL,
+    0x3ffb4684UL, 0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL,
+    0xbbba6de3UL, 0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL,
+    0x3c92a8f3UL, 0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL,
+    0xf22749e4UL, 0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL,
+    0x3ffba5b0UL, 0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL,
+    0xc9696205UL, 0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL,
+    0x3c823dd0UL, 0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL,
+    0x5bd71e09UL, 0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL,
+    0x3ffc0628UL, 0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL,
+    0x895048ddUL, 0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL,
+    0xbc96e516UL, 0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL,
+    0x78fafb22UL, 0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL,
+    0x3ffc67f1UL, 0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL,
+    0xbe255559UL, 0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL,
+    0x3c71acbcUL, 0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL,
+    0xdcef9069UL, 0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL,
+    0x3ffccb0fUL, 0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL,
+    0x53829d72UL, 0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL,
+    0xbc9a08e9UL, 0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL,
+    0x2b08c968UL, 0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL,
+    0x3ffd2f87UL, 0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL,
+    0xbf5a1614UL, 0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL,
+    0x3c82ed02UL, 0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL,
+    0x16c98398UL, 0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL,
+    0x3ffd955dUL, 0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL,
+    0x696db532UL, 0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL,
+    0xbc9b76f1UL, 0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL,
+    0x641c0658UL, 0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL,
+    0x3ffdfc97UL, 0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL,
+    0xbd5c7f44UL, 0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL,
+    0xbc97b627UL, 0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL,
+    0xe78b3ff6UL, 0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL,
+    0x3ffe6539UL, 0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL,
+    0xca0c8de2UL, 0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL,
+    0xbc910894UL, 0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL,
+    0x867cca6eUL, 0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL,
+    0x3ffecf48UL, 0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL,
+    0xa487568dUL, 0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL,
+    0x3c9dc7f4UL, 0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL,
+    0x376bba97UL, 0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL,
+    0x3fff3ac9UL, 0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL,
+    0x2dd8a18bUL, 0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL,
+    0x3c9fa37bUL, 0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL,
+    0x02243c89UL, 0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL,
+    0x3fffa7c1UL, 0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL,
+    0x15098eb6UL, 0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL,
+    0x3c62eb74UL, 0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL,
+    0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL,
+    0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL,
+    0x00000000UL, 0x00000000UL, 0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL,
+    0xbfe62e42UL, 0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL,
+    0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL
+
+};
+
+//registers,
+// input: xmm0, xmm1
+// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
+//          eax, edx, ecx, ebx
+
+// Code generated by Intel C compiler for LIBM library
+
+void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
+  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2;
+  Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2;
+  Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2;
+  Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2;
+  Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2;
+  Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2;
+  Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2;
+  Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2;
+  Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2;
+  Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2;
+  Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2;
+  Label L_2TAG_PACKET_56_0_2, L_2TAG_PACKET_57_0_2, L_2TAG_PACKET_58_0_2, start;
+
+  assert_different_registers(tmp, eax, ecx, edx);
+
+  address static_const_table_pow = (address)_static_const_table_pow;
+
+  bind(start);
+  subl(rsp, 120);
+  movl(Address(rsp, 64), tmp);
+  lea(tmp, ExternalAddress(static_const_table_pow));
+  movsd(xmm0, Address(rsp, 128));
+  movsd(xmm1, Address(rsp, 136));
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movl(ecx, 1069088768);
+  movdl(xmm7, ecx);
+  movsd(Address(rsp, 16), xmm1);
+  xorpd(xmm1, xmm1);
+  movl(edx, 30704);
+  pinsrw(xmm1, edx, 3);
+  movsd(Address(rsp, 8), xmm0);
+  movdqu(xmm3, xmm0);
+  movl(edx, 8192);
+  movdl(xmm4, edx);
+  movdqu(xmm6, Address(tmp, 8240));
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  psllq(xmm0, 5);
+  movsd(xmm2, Address(tmp, 8256));
+  psrlq(xmm0, 34);
+  movl(edx, eax);
+  andl(edx, 32752);
+  subl(edx, 16368);
+  movl(ecx, edx);
+  sarl(edx, 31);
+  addl(ecx, edx);
+  xorl(ecx, edx);
+  rcpss(xmm0, xmm0);
+  psllq(xmm3, 12);
+  addl(ecx, 16);
+  bsrl(ecx, ecx);
+  psrlq(xmm3, 12);
+  movl(Address(rsp, 24), rsi);
+  subl(eax, 16);
+  cmpl(eax, 32736);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
+  movl(rsi, 0);
+
+  bind(L_2TAG_PACKET_1_0_2);
+  mulss(xmm0, xmm7);
+  movl(edx, -1);
+  subl(ecx, 4);
+  shll(edx);
+  movdl(xmm5, edx);
+  por(xmm3, xmm1);
+  subl(eax, 16351);
+  cmpl(eax, 1);
+  jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2);
+  paddd(xmm0, xmm4);
+  psllq(xmm5, 32);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  pand(xmm5, xmm3);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  pand(xmm0, xmm6);
+  subsd(xmm3, xmm5);
+  subl(eax, 1);
+  sarl(eax, 4);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  mulsd(xmm3, xmm0);
+  movdqu(xmm1, Address(tmp, 8272));
+  subsd(xmm5, xmm2);
+  movdqu(xmm4, Address(tmp, 8288));
+  movl(ecx, eax);
+  sarl(eax, 31);
+  addl(ecx, eax);
+  xorl(eax, ecx);
+  addl(eax, 1);
+  bsrl(eax, eax);
+  unpcklpd(xmm5, xmm3);
+  movdqu(xmm6, Address(tmp, 8304));
+  addsd(xmm3, xmm5);
+  andl(edx, 16760832);
+  shrl(edx, 10);
+  addpd(xmm5, Address(tmp, edx, Address::times_1, -3616));
+  movdqu(xmm0, Address(tmp, 8320));
+  pshufd(xmm2, xmm3, 68);
+  mulsd(xmm3, xmm3);
+  mulpd(xmm1, xmm2);
+  mulpd(xmm4, xmm2);
+  addsd(xmm5, xmm7);
+  mulsd(xmm2, xmm3);
+  addpd(xmm6, xmm1);
+  mulsd(xmm3, xmm3);
+  addpd(xmm0, xmm4);
+  movsd(xmm1, Address(rsp, 16));
+  movzwl(ecx, Address(rsp, 22));
+  pshufd(xmm7, xmm5, 238);
+  movsd(xmm4, Address(tmp, 8368));
+  mulpd(xmm6, xmm2);
+  pshufd(xmm3, xmm3, 68);
+  mulpd(xmm0, xmm2);
+  shll(eax, 4);
+  subl(eax, 15872);
+  andl(ecx, 32752);
+  addl(eax, ecx);
+  mulpd(xmm3, xmm6);
+  cmpl(eax, 624);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2);
+  xorpd(xmm6, xmm6);
+  movl(edx, 17080);
+  pinsrw(xmm6, edx, 3);
+  movdqu(xmm2, xmm1);
+  pand(xmm4, xmm1);
+  subsd(xmm1, xmm4);
+  mulsd(xmm4, xmm5);
+  addsd(xmm0, xmm7);
+  mulsd(xmm1, xmm5);
+  movdqu(xmm7, xmm6);
+  addsd(xmm6, xmm4);
+  addpd(xmm3, xmm0);
+  movdl(edx, xmm6);
+  subsd(xmm6, xmm7);
+  pshufd(xmm0, xmm3, 238);
+  subsd(xmm4, xmm6);
+  addsd(xmm0, xmm3);
+  movl(ecx, edx);
+  andl(edx, 255);
+  addl(edx, edx);
+  movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384));
+  addsd(xmm4, xmm1);
+  mulsd(xmm2, xmm0);
+  movdqu(xmm7, Address(tmp, 12480));
+  movdqu(xmm3, Address(tmp, 12496));
+  shll(ecx, 12);
+  xorl(ecx, rsi);
+  andl(ecx, -1048576);
+  movdl(xmm6, ecx);
+  addsd(xmm2, xmm4);
+  movsd(xmm1, Address(tmp, 12512));
+  pshufd(xmm0, xmm2, 68);
+  pshufd(xmm4, xmm2, 68);
+  mulpd(xmm0, xmm0);
+  movl(rsi, Address(rsp, 24));
+  mulpd(xmm7, xmm4);
+  pshufd(xmm6, xmm6, 17);
+  mulsd(xmm1, xmm2);
+  mulsd(xmm0, xmm0);
+  paddd(xmm5, xmm6);
+  addpd(xmm3, xmm7);
+  mulsd(xmm1, xmm5);
+  pshufd(xmm6, xmm5, 238);
+  mulpd(xmm0, xmm3);
+  addsd(xmm1, xmm6);
+  pshufd(xmm3, xmm0, 238);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm3, xmm5);
+  addsd(xmm0, xmm1);
+  addsd(xmm0, xmm3);
+  addsd(xmm0, xmm5);
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_7_0_2);
+  movsd(xmm0, Address(rsp, 128));
+  movsd(xmm1, Address(rsp, 136));
+  mulsd(xmm0, xmm1);
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  addl(eax, 16);
+  movl(edx, 32752);
+  andl(edx, eax);
+  cmpl(edx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_8_0_2);
+  testl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_2);
+
+  bind(L_2TAG_PACKET_10_0_2);
+  movl(ecx, Address(rsp, 16));
+  xorl(edx, edx);
+  testl(ecx, ecx);
+  movl(ecx, 1);
+  cmovl(Assembler::notEqual, edx, ecx);
+  orl(edx, Address(rsp, 20));
+  cmpl(edx, 1072693248);
+  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
+  movsd(xmm0, Address(rsp, 8));
+  movsd(xmm3, Address(rsp, 8));
+  movdl(edx, xmm3);
+  psrlq(xmm3, 32);
+  movdl(ecx, xmm3);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_11_0_2);
+  xorpd(xmm3, xmm3);
+  movl(eax, 18416);
+  pinsrw(xmm3, eax, 3);
+  mulsd(xmm0, xmm3);
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm3, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 18416);
+  psllq(xmm0, 5);
+  movsd(xmm2, Address(tmp, 8256));
+  psrlq(xmm0, 34);
+  rcpss(xmm0, xmm0);
+  psllq(xmm3, 12);
+  movdqu(xmm6, Address(tmp, 8240));
+  psrlq(xmm3, 12);
+  mulss(xmm0, xmm7);
+  movl(edx, -1024);
+  movdl(xmm5, edx);
+  por(xmm3, xmm1);
+  paddd(xmm0, xmm4);
+  psllq(xmm5, 32);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  pand(xmm5, xmm3);
+  movl(rsi, 0);
+  pand(xmm0, xmm6);
+  subsd(xmm3, xmm5);
+  andl(eax, 32752);
+  subl(eax, 18416);
+  sarl(eax, 4);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  jmp(L_2TAG_PACKET_4_0_2);
+
+  bind(L_2TAG_PACKET_12_0_2);
+  movl(ecx, Address(rsp, 16));
+  xorl(edx, edx);
+  testl(ecx, ecx);
+  movl(ecx, 1);
+  cmovl(Assembler::notEqual, edx, ecx);
+  orl(edx, Address(rsp, 20));
+  cmpl(edx, 1072693248);
+  jcc(Assembler::equal, L_2TAG_PACKET_7_0_2);
+  movsd(xmm0, Address(rsp, 8));
+  movsd(xmm3, Address(rsp, 8));
+  movdl(edx, xmm3);
+  psrlq(xmm3, 32);
+  movdl(ecx, xmm3);
+  orl(edx, ecx);
+  cmpl(edx, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_11_0_2);
+  xorpd(xmm3, xmm3);
+  movl(eax, 18416);
+  pinsrw(xmm3, eax, 3);
+  mulsd(xmm0, xmm3);
+  xorpd(xmm2, xmm2);
+  movl(eax, 16368);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm3, xmm0);
+  pextrw(eax, xmm0, 3);
+  por(xmm0, xmm2);
+  movl(ecx, 18416);
+  psllq(xmm0, 5);
+  movsd(xmm2, Address(tmp, 8256));
+  psrlq(xmm0, 34);
+  rcpss(xmm0, xmm0);
+  psllq(xmm3, 12);
+  movdqu(xmm6, Address(tmp, 8240));
+  psrlq(xmm3, 12);
+  mulss(xmm0, xmm7);
+  movl(edx, -1024);
+  movdl(xmm5, edx);
+  por(xmm3, xmm1);
+  paddd(xmm0, xmm4);
+  psllq(xmm5, 32);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  pand(xmm5, xmm3);
+  movl(rsi, INT_MIN);
+  pand(xmm0, xmm6);
+  subsd(xmm3, xmm5);
+  andl(eax, 32752);
+  subl(eax, 18416);
+  sarl(eax, 4);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  jmp(L_2TAG_PACKET_4_0_2);
+
+  bind(L_2TAG_PACKET_5_0_2);
+  cmpl(eax, 0);
+  jcc(Assembler::less, L_2TAG_PACKET_13_0_2);
+  cmpl(eax, 752);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_14_0_2);
+
+  bind(L_2TAG_PACKET_15_0_2);
+  addsd(xmm0, xmm7);
+  movsd(xmm2, Address(tmp, 12544));
+  addpd(xmm3, xmm0);
+  xorpd(xmm6, xmm6);
+  movl(eax, 17080);
+  pinsrw(xmm6, eax, 3);
+  pshufd(xmm0, xmm3, 238);
+  addsd(xmm0, xmm3);
+  movdqu(xmm3, xmm5);
+  addsd(xmm5, xmm0);
+  movdqu(xmm4, xmm2);
+  subsd(xmm3, xmm5);
+  movdqu(xmm7, xmm5);
+  pand(xmm5, xmm2);
+  movdqu(xmm2, xmm1);
+  pand(xmm4, xmm1);
+  subsd(xmm7, xmm5);
+  addsd(xmm0, xmm3);
+  subsd(xmm1, xmm4);
+  mulsd(xmm4, xmm5);
+  addsd(xmm0, xmm7);
+  mulsd(xmm2, xmm0);
+  movdqu(xmm7, xmm6);
+  mulsd(xmm1, xmm5);
+  addsd(xmm6, xmm4);
+  movdl(eax, xmm6);
+  subsd(xmm6, xmm7);
+  addsd(xmm2, xmm1);
+  movdqu(xmm7, Address(tmp, 12480));
+  movdqu(xmm3, Address(tmp, 12496));
+  subsd(xmm4, xmm6);
+  pextrw(edx, xmm6, 3);
+  movl(ecx, eax);
+  andl(eax, 255);
+  addl(eax, eax);
+  movdqu(xmm5, Address(tmp, eax, Address::times_8, 8384));
+  addsd(xmm2, xmm4);
+  sarl(ecx, 8);
+  movl(eax, ecx);
+  sarl(ecx, 1);
+  subl(eax, ecx);
+  shll(ecx, 20);
+  xorl(ecx, rsi);
+  movdl(xmm6, ecx);
+  movsd(xmm1, Address(tmp, 12512));
+  andl(edx, 32767);
+  cmpl(edx, 16529);
+  jcc(Assembler::above, L_2TAG_PACKET_14_0_2);
+  pshufd(xmm0, xmm2, 68);
+  pshufd(xmm4, xmm2, 68);
+  mulpd(xmm0, xmm0);
+  mulpd(xmm7, xmm4);
+  pshufd(xmm6, xmm6, 17);
+  mulsd(xmm1, xmm2);
+  mulsd(xmm0, xmm0);
+  paddd(xmm5, xmm6);
+  addpd(xmm3, xmm7);
+  mulsd(xmm1, xmm5);
+  pshufd(xmm6, xmm5, 238);
+  mulpd(xmm0, xmm3);
+  addsd(xmm1, xmm6);
+  pshufd(xmm3, xmm0, 238);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm3, xmm5);
+  shll(eax, 4);
+  xorpd(xmm4, xmm4);
+  addl(eax, 16368);
+  pinsrw(xmm4, eax, 3);
+  addsd(xmm0, xmm1);
+  movl(rsi, Address(rsp, 24));
+  addsd(xmm0, xmm3);
+  movdqu(xmm1, xmm0);
+  addsd(xmm0, xmm5);
+  mulsd(xmm0, xmm4);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_16_0_2);
+  cmpl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_18_0_2);
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_8_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  movsd(xmm0, Address(rsp, 8));
+  movdqu(xmm2, xmm0);
+  movdl(eax, xmm2);
+  psrlq(xmm2, 20);
+  movdl(edx, xmm2);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_19_0_2);
+  addsd(xmm0, xmm0);
+  movdl(eax, xmm1);
+  psrlq(xmm1, 32);
+  movdl(edx, xmm1);
+  movl(ecx, edx);
+  addl(edx, edx);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_20_0_2);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_20_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  movl(edx, 29);
+  jmp(L_2TAG_PACKET_21_0_2);
+
+  bind(L_2TAG_PACKET_22_0_2);
+  movsd(xmm0, Address(rsp, 16));
+  addpd(xmm0, xmm0);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_19_0_2);
+  movdl(eax, xmm1);
+  movdqu(xmm2, xmm1);
+  psrlq(xmm1, 32);
+  movdl(edx, xmm1);
+  movl(ecx, edx);
+  addl(edx, edx);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_23_0_2);
+  pextrw(eax, xmm2, 3);
+  andl(eax, 32752);
+  cmpl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2);
+  movdl(eax, xmm2);
+  psrlq(xmm2, 20);
+  movdl(edx, xmm2);
+  orl(eax, edx);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
+
+  bind(L_2TAG_PACKET_24_0_2);
+  pextrw(eax, xmm0, 3);
+  testl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2);
+  testl(ecx, INT_MIN);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_27_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  movdl(eax, xmm1);
+  testl(eax, 1);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2);
+  testl(eax, 2);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_29_0_2);
+  jmp(L_2TAG_PACKET_28_0_2);
+
+  bind(L_2TAG_PACKET_25_0_2);
+  shrl(ecx, 20);
+  andl(ecx, 2047);
+  cmpl(ecx, 1075);
+  jcc(Assembler::above, L_2TAG_PACKET_28_0_2);
+  jcc(Assembler::equal, L_2TAG_PACKET_30_0_2);
+  cmpl(ecx, 1074);
+  jcc(Assembler::above, L_2TAG_PACKET_27_0_2);
+  cmpl(ecx, 1023);
+  jcc(Assembler::below, L_2TAG_PACKET_28_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  movl(eax, 17208);
+  xorpd(xmm3, xmm3);
+  pinsrw(xmm3, eax, 3);
+  movdqu(xmm4, xmm3);
+  addsd(xmm3, xmm1);
+  subsd(xmm4, xmm3);
+  addsd(xmm1, xmm4);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2);
+  movdl(eax, xmm3);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_28_0_2);
+
+  bind(L_2TAG_PACKET_29_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32768);
+  jcc(Assembler::equal, L_2TAG_PACKET_18_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32768);
+  pinsrw(xmm0, eax, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_28_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2);
+
+  bind(L_2TAG_PACKET_31_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32752);
+  pinsrw(xmm0, eax, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_30_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  movdl(eax, xmm1);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_28_0_2);
+  jmp(L_2TAG_PACKET_29_0_2);
+
+  bind(L_2TAG_PACKET_32_0_2);
+  movdl(eax, xmm1);
+  psrlq(xmm1, 20);
+  movdl(edx, xmm1);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_33_0_2);
+  movsd(xmm0, Address(rsp, 16));
+  addsd(xmm0, xmm0);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_33_0_2);
+  movsd(xmm0, Address(rsp, 8));
+  pextrw(eax, xmm0, 3);
+  cmpl(eax, 49136);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
+  movdl(ecx, xmm0);
+  psrlq(xmm0, 20);
+  movdl(edx, xmm0);
+  orl(ecx, edx);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32760);
+  pinsrw(xmm0, eax, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_34_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  andl(eax, 32752);
+  subl(eax, 16368);
+  pextrw(edx, xmm1, 3);
+  xorpd(xmm0, xmm0);
+  xorl(eax, edx);
+  andl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
+  movl(ecx, 32752);
+  pinsrw(xmm0, ecx, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_35_0_2);
+  movdl(eax, xmm1);
+  cmpl(edx, 17184);
+  jcc(Assembler::above, L_2TAG_PACKET_36_0_2);
+  testl(eax, 1);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2);
+  testl(eax, 2);
+  jcc(Assembler::equal, L_2TAG_PACKET_38_0_2);
+  jmp(L_2TAG_PACKET_39_0_2);
+
+  bind(L_2TAG_PACKET_36_0_2);
+  testl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_38_0_2);
+  jmp(L_2TAG_PACKET_39_0_2);
+
+  bind(L_2TAG_PACKET_9_0_2);
+  movsd(xmm2, Address(rsp, 8));
+  movdl(eax, xmm2);
+  psrlq(xmm2, 31);
+  movdl(ecx, xmm2);
+  orl(eax, ecx);
+  jcc(Assembler::equal, L_2TAG_PACKET_11_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  pextrw(edx, xmm1, 3);
+  movdl(eax, xmm1);
+  movdqu(xmm2, xmm1);
+  psrlq(xmm2, 32);
+  movdl(ecx, xmm2);
+  addl(ecx, ecx);
+  orl(ecx, eax);
+  jcc(Assembler::equal, L_2TAG_PACKET_40_0_2);
+  andl(edx, 32752);
+  cmpl(edx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_32_0_2);
+  cmpl(edx, 17200);
+  jcc(Assembler::above, L_2TAG_PACKET_38_0_2);
+  cmpl(edx, 17184);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_35_0_2);
+  cmpl(edx, 16368);
+  jcc(Assembler::below, L_2TAG_PACKET_37_0_2);
+  movl(eax, 17208);
+  xorpd(xmm2, xmm2);
+  pinsrw(xmm2, eax, 3);
+  movdqu(xmm4, xmm2);
+  addsd(xmm2, xmm1);
+  subsd(xmm4, xmm2);
+  addsd(xmm1, xmm4);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32767);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2);
+  movdl(eax, xmm2);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_38_0_2);
+
+  bind(L_2TAG_PACKET_39_0_2);
+  xorpd(xmm1, xmm1);
+  movl(edx, 30704);
+  pinsrw(xmm1, edx, 3);
+  movsd(xmm2, Address(tmp, 8256));
+  movsd(xmm4, Address(rsp, 8));
+  pextrw(eax, xmm4, 3);
+  movl(edx, 8192);
+  movdl(xmm4, edx);
+  andl(eax, 32767);
+  subl(eax, 16);
+  jcc(Assembler::less, L_2TAG_PACKET_12_0_2);
+  movl(edx, eax);
+  andl(edx, 32752);
+  subl(edx, 16368);
+  movl(ecx, edx);
+  sarl(edx, 31);
+  addl(ecx, edx);
+  xorl(ecx, edx);
+  addl(ecx, 16);
+  bsrl(ecx, ecx);
+  movl(rsi, INT_MIN);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_37_0_2);
+  xorpd(xmm1, xmm1);
+  movl(eax, 32752);
+  pinsrw(xmm1, eax, 3);
+  xorpd(xmm0, xmm0);
+  mulsd(xmm0, xmm1);
+  movl(edx, 28);
+  jmp(L_2TAG_PACKET_21_0_2);
+
+  bind(L_2TAG_PACKET_38_0_2);
+  xorpd(xmm1, xmm1);
+  movl(edx, 30704);
+  pinsrw(xmm1, edx, 3);
+  movsd(xmm2, Address(tmp, 8256));
+  movsd(xmm4, Address(rsp, 8));
+  pextrw(eax, xmm4, 3);
+  movl(edx, 8192);
+  movdl(xmm4, edx);
+  andl(eax, 32767);
+  subl(eax, 16);
+  jcc(Assembler::less, L_2TAG_PACKET_10_0_2);
+  movl(edx, eax);
+  andl(edx, 32752);
+  subl(edx, 16368);
+  movl(ecx, edx);
+  sarl(edx, 31);
+  addl(ecx, edx);
+  xorl(ecx, edx);
+  addl(ecx, 16);
+  bsrl(ecx, ecx);
+  movl(rsi, 0);
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_23_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_26_0_2);
+  xorpd(xmm0, xmm0);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_13_0_2);
+  addl(eax, 384);
+  cmpl(eax, 0);
+  jcc(Assembler::less, L_2TAG_PACKET_41_0_2);
+  mulsd(xmm5, xmm1);
+  addsd(xmm0, xmm7);
+  shrl(rsi, 31);
+  addpd(xmm3, xmm0);
+  pshufd(xmm0, xmm3, 238);
+  addsd(xmm3, xmm0);
+  movsd(xmm4, Address(tmp, rsi, Address::times_8, 12528));
+  mulsd(xmm1, xmm3);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  shll(rsi, 15);
+  orl(eax, rsi);
+  pinsrw(xmm0, eax, 3);
+  addsd(xmm5, xmm1);
+  movl(rsi, Address(rsp, 24));
+  mulsd(xmm5, xmm4);
+  addsd(xmm0, xmm5);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_41_0_2);
+  movl(rsi, Address(rsp, 24));
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_40_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_42_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 16368);
+  pinsrw(xmm0, eax, 3);
+  movl(edx, 26);
+  jmp(L_2TAG_PACKET_21_0_2);
+
+  bind(L_2TAG_PACKET_11_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  movdqu(xmm2, xmm1);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32752);
+  cmpl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2);
+  movdl(eax, xmm2);
+  psrlq(xmm2, 20);
+  movdl(edx, xmm2);
+  orl(eax, edx);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2);
+
+  bind(L_2TAG_PACKET_43_0_2);
+  movdl(eax, xmm1);
+  psrlq(xmm1, 32);
+  movdl(edx, xmm1);
+  movl(ecx, edx);
+  addl(edx, edx);
+  orl(eax, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_42_0_2);
+  shrl(edx, 21);
+  cmpl(edx, 1075);
+  jcc(Assembler::above, L_2TAG_PACKET_44_0_2);
+  jcc(Assembler::equal, L_2TAG_PACKET_45_0_2);
+  cmpl(edx, 1023);
+  jcc(Assembler::below, L_2TAG_PACKET_44_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  movl(eax, 17208);
+  xorpd(xmm3, xmm3);
+  pinsrw(xmm3, eax, 3);
+  movdqu(xmm4, xmm3);
+  addsd(xmm3, xmm1);
+  subsd(xmm4, xmm3);
+  addsd(xmm1, xmm4);
+  pextrw(eax, xmm1, 3);
+  andl(eax, 32752);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2);
+  movdl(eax, xmm3);
+  andl(eax, 1);
+  jcc(Assembler::equal, L_2TAG_PACKET_44_0_2);
+
+  bind(L_2TAG_PACKET_46_0_2);
+  movsd(xmm0, Address(rsp, 8));
+  testl(ecx, INT_MIN);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_47_0_2);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_45_0_2);
+  movsd(xmm1, Address(rsp, 16));
+  movdl(eax, xmm1);
+  testl(eax, 1);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2);
+
+  bind(L_2TAG_PACKET_44_0_2);
+  testl(ecx, INT_MIN);
+  jcc(Assembler::equal, L_2TAG_PACKET_26_0_2);
+  xorpd(xmm0, xmm0);
+
+  bind(L_2TAG_PACKET_47_0_2);
+  movl(eax, 16368);
+  xorpd(xmm1, xmm1);
+  pinsrw(xmm1, eax, 3);
+  divsd(xmm1, xmm0);
+  movdqu(xmm0, xmm1);
+  movl(edx, 27);
+  jmp(L_2TAG_PACKET_21_0_2);
+
+  bind(L_2TAG_PACKET_14_0_2);
+  movsd(xmm2, Address(rsp, 8));
+  movsd(xmm6, Address(rsp, 16));
+  pextrw(eax, xmm2, 3);
+  pextrw(edx, xmm6, 3);
+  movl(ecx, 32752);
+  andl(ecx, edx);
+  cmpl(ecx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_48_0_2);
+  andl(eax, 32752);
+  subl(eax, 16368);
+  xorl(edx, eax);
+  testl(edx, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_49_0_2);
+
+  bind(L_2TAG_PACKET_50_0_2);
+  movl(eax, 32736);
+  pinsrw(xmm0, eax, 3);
+  shrl(rsi, 16);
+  orl(eax, rsi);
+  pinsrw(xmm1, eax, 3);
+  movl(rsi, Address(rsp, 24));
+  mulsd(xmm0, xmm1);
+
+  bind(L_2TAG_PACKET_17_0_2);
+  movl(edx, 24);
+
+  bind(L_2TAG_PACKET_21_0_2);
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_49_0_2);
+  movl(eax, 16);
+  pinsrw(xmm0, eax, 3);
+  mulsd(xmm0, xmm0);
+  testl(rsi, INT_MIN);
+  jcc(Assembler::equal, L_2TAG_PACKET_51_0_2);
+  movsd(xmm2, Address(tmp, 12560));
+  xorpd(xmm0, xmm2);
+
+  bind(L_2TAG_PACKET_51_0_2);
+  movl(rsi, Address(rsp, 24));
+  movl(edx, 25);
+  jmp(L_2TAG_PACKET_21_0_2);
+
+  bind(L_2TAG_PACKET_16_0_2);
+  pextrw(ecx, xmm5, 3);
+  pextrw(edx, xmm4, 3);
+  movl(eax, -1);
+  andl(ecx, 32752);
+  subl(ecx, 16368);
+  andl(edx, 32752);
+  addl(edx, ecx);
+  movl(ecx, -31);
+  sarl(edx, 4);
+  subl(ecx, edx);
+  jcc(Assembler::lessEqual, L_2TAG_PACKET_52_0_2);
+  cmpl(ecx, 20);
+  jcc(Assembler::above, L_2TAG_PACKET_53_0_2);
+  shll(eax);
+
+  bind(L_2TAG_PACKET_52_0_2);
+  movdl(xmm0, eax);
+  psllq(xmm0, 32);
+  pand(xmm0, xmm5);
+  subsd(xmm5, xmm0);
+  addsd(xmm5, xmm1);
+  mulsd(xmm0, xmm4);
+  mulsd(xmm5, xmm4);
+  addsd(xmm0, xmm5);
+
+  bind(L_2TAG_PACKET_53_0_2);
+  movl(edx, 25);
+  jmp(L_2TAG_PACKET_21_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movzwl(ecx, Address(rsp, 22));
+  movl(edx, INT_MIN);
+  movdl(xmm1, edx);
+  xorpd(xmm7, xmm7);
+  paddd(xmm0, xmm4);
+  psllq(xmm5, 32);
+  movdl(edx, xmm0);
+  psllq(xmm0, 29);
+  paddq(xmm1, xmm3);
+  pand(xmm5, xmm1);
+  andl(ecx, 32752);
+  cmpl(ecx, 16560);
+  jcc(Assembler::below, L_2TAG_PACKET_3_0_2);
+  pand(xmm0, xmm6);
+  subsd(xmm3, xmm5);
+  addl(eax, 16351);
+  shrl(eax, 4);
+  subl(eax, 1022);
+  cvtsi2sdl(xmm7, eax);
+  mulpd(xmm5, xmm0);
+  movsd(xmm4, Address(tmp, 0));
+  mulsd(xmm3, xmm0);
+  movsd(xmm6, Address(tmp, 0));
+  subsd(xmm5, xmm2);
+  movsd(xmm1, Address(tmp, 8));
+  pshufd(xmm2, xmm3, 68);
+  unpcklpd(xmm5, xmm3);
+  addsd(xmm3, xmm5);
+  movsd(xmm0, Address(tmp, 8));
+  andl(edx, 16760832);
+  shrl(edx, 10);
+  addpd(xmm7, Address(tmp, edx, Address::times_1, -3616));
+  mulsd(xmm4, xmm5);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm6, xmm2);
+  mulsd(xmm1, xmm2);
+  movdqu(xmm2, xmm5);
+  mulsd(xmm4, xmm5);
+  addsd(xmm5, xmm0);
+  movdqu(xmm0, xmm7);
+  addsd(xmm2, xmm3);
+  addsd(xmm7, xmm5);
+  mulsd(xmm6, xmm2);
+  subsd(xmm0, xmm7);
+  movdqu(xmm2, xmm7);
+  addsd(xmm7, xmm4);
+  addsd(xmm0, xmm5);
+  subsd(xmm2, xmm7);
+  addsd(xmm4, xmm2);
+  pshufd(xmm2, xmm5, 238);
+  movdqu(xmm5, xmm7);
+  addsd(xmm7, xmm2);
+  addsd(xmm4, xmm0);
+  movdqu(xmm0, Address(tmp, 8272));
+  subsd(xmm5, xmm7);
+  addsd(xmm6, xmm4);
+  movdqu(xmm4, xmm7);
+  addsd(xmm5, xmm2);
+  addsd(xmm7, xmm1);
+  movdqu(xmm2, Address(tmp, 8336));
+  subsd(xmm4, xmm7);
+  addsd(xmm6, xmm5);
+  addsd(xmm4, xmm1);
+  pshufd(xmm5, xmm7, 238);
+  movdqu(xmm1, xmm7);
+  addsd(xmm7, xmm5);
+  subsd(xmm1, xmm7);
+  addsd(xmm1, xmm5);
+  movdqu(xmm5, Address(tmp, 8352));
+  pshufd(xmm3, xmm3, 68);
+  addsd(xmm6, xmm4);
+  addsd(xmm6, xmm1);
+  movdqu(xmm1, Address(tmp, 8304));
+  mulpd(xmm0, xmm3);
+  mulpd(xmm2, xmm3);
+  pshufd(xmm4, xmm3, 68);
+  mulpd(xmm3, xmm3);
+  addpd(xmm0, xmm1);
+  addpd(xmm5, xmm2);
+  mulsd(xmm4, xmm3);
+  movsd(xmm2, Address(tmp, 16));
+  mulpd(xmm3, xmm3);
+  movsd(xmm1, Address(rsp, 16));
+  movzwl(ecx, Address(rsp, 22));
+  mulpd(xmm0, xmm4);
+  pextrw(eax, xmm7, 3);
+  mulpd(xmm5, xmm4);
+  mulpd(xmm0, xmm3);
+  movsd(xmm4, Address(tmp, 8376));
+  pand(xmm2, xmm7);
+  addsd(xmm5, xmm6);
+  subsd(xmm7, xmm2);
+  addpd(xmm5, xmm0);
+  andl(eax, 32752);
+  subl(eax, 16368);
+  andl(ecx, 32752);
+  cmpl(ecx, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_48_0_2);
+  addl(ecx, eax);
+  cmpl(ecx, 16576);
+  jcc(Assembler::aboveEqual, L_2TAG_PACKET_54_0_2);
+  pshufd(xmm0, xmm5, 238);
+  pand(xmm4, xmm1);
+  movdqu(xmm3, xmm1);
+  addsd(xmm5, xmm0);
+  subsd(xmm1, xmm4);
+  xorpd(xmm6, xmm6);
+  movl(edx, 17080);
+  pinsrw(xmm6, edx, 3);
+  addsd(xmm7, xmm5);
+  mulsd(xmm4, xmm2);
+  mulsd(xmm1, xmm2);
+  movdqu(xmm5, xmm6);
+  mulsd(xmm3, xmm7);
+  addsd(xmm6, xmm4);
+  addsd(xmm1, xmm3);
+  movdqu(xmm7, Address(tmp, 12480));
+  movdl(edx, xmm6);
+  subsd(xmm6, xmm5);
+  movdqu(xmm3, Address(tmp, 12496));
+  movsd(xmm2, Address(tmp, 12512));
+  subsd(xmm4, xmm6);
+  movl(ecx, edx);
+  andl(edx, 255);
+  addl(edx, edx);
+  movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384));
+  addsd(xmm4, xmm1);
+  pextrw(edx, xmm6, 3);
+  shrl(ecx, 8);
+  movl(eax, ecx);
+  shrl(ecx, 1);
+  subl(eax, ecx);
+  shll(ecx, 20);
+  movdl(xmm6, ecx);
+  pshufd(xmm0, xmm4, 68);
+  pshufd(xmm1, xmm4, 68);
+  mulpd(xmm0, xmm0);
+  mulpd(xmm7, xmm1);
+  pshufd(xmm6, xmm6, 17);
+  mulsd(xmm2, xmm4);
+  andl(edx, 32767);
+  cmpl(edx, 16529);
+  jcc(Assembler::above, L_2TAG_PACKET_14_0_2);
+  mulsd(xmm0, xmm0);
+  paddd(xmm5, xmm6);
+  addpd(xmm3, xmm7);
+  mulsd(xmm2, xmm5);
+  pshufd(xmm6, xmm5, 238);
+  mulpd(xmm0, xmm3);
+  addsd(xmm2, xmm6);
+  pshufd(xmm3, xmm0, 238);
+  addl(eax, 1023);
+  shll(eax, 20);
+  orl(eax, rsi);
+  movdl(xmm4, eax);
+  mulsd(xmm0, xmm5);
+  mulsd(xmm3, xmm5);
+  addsd(xmm0, xmm2);
+  psllq(xmm4, 32);
+  addsd(xmm0, xmm3);
+  movdqu(xmm1, xmm0);
+  addsd(xmm0, xmm5);
+  movl(rsi, Address(rsp, 24));
+  mulsd(xmm0, xmm4);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_16_0_2);
+  cmpl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_17_0_2);
+
+  bind(L_2TAG_PACKET_55_0_2);
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_6_0_2);
+
+  bind(L_2TAG_PACKET_48_0_2);
+  movl(rsi, Address(rsp, 24));
+
+  bind(L_2TAG_PACKET_56_0_2);
+  movsd(xmm0, Address(rsp, 8));
+  movsd(xmm1, Address(rsp, 16));
+  addsd(xmm1, xmm1);
+  xorpd(xmm2, xmm2);
+  movl(eax, 49136);
+  pinsrw(xmm2, eax, 3);
+  addsd(xmm2, xmm0);
+  pextrw(eax, xmm2, 3);
+  cmpl(eax, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_57_0_2);
+  xorpd(xmm0, xmm0);
+  movl(eax, 32760);
+  pinsrw(xmm0, eax, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_57_0_2);
+  movdl(edx, xmm1);
+  movdqu(xmm3, xmm1);
+  psrlq(xmm3, 20);
+  movdl(ecx, xmm3);
+  orl(ecx, edx);
+  jcc(Assembler::equal, L_2TAG_PACKET_58_0_2);
+  addsd(xmm1, xmm1);
+  movdqu(xmm0, xmm1);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_58_0_2);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  pextrw(edx, xmm1, 3);
+  xorpd(xmm0, xmm0);
+  subl(eax, 16368);
+  xorl(eax, edx);
+  testl(eax, 32768);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2);
+  movl(edx, 32752);
+  pinsrw(xmm0, edx, 3);
+  jmp(L_2TAG_PACKET_18_0_2);
+
+  bind(L_2TAG_PACKET_54_0_2);
+  pextrw(eax, xmm1, 3);
+  pextrw(ecx, xmm2, 3);
+  xorl(eax, ecx);
+  testl(eax, 32768);
+  jcc(Assembler::equal, L_2TAG_PACKET_50_0_2);
+  jmp(L_2TAG_PACKET_49_0_2);
+
+  bind(L_2TAG_PACKET_6_0_2);
+  movl(tmp, Address(rsp, 64));
+
+}
+#endif
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp
index bbc9615..a0910f3 100644
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp
@@ -493,3 +493,543 @@
   bind(done_hash);
 
 }
+
+#ifdef _LP64
+/*
+  The algorithm below is based on Intel publication:
+  "Fast SHA-256 Implementations on Intelë Architecture Processors" by Jim Guilford, Kirk Yap and Vinodh Gopal.
+  The assembly code was originally provided by Sean Gulley and in many places preserves
+  the original assembly NAMES and comments to simplify matching Java assembly with its original.
+  The Java version was substantially redesigned to replace 1200 assembly instruction with
+  much shorter run-time generator of the same code in memory.
+*/
+
+void MacroAssembler::sha256_AVX2_one_round_compute(
+    Register  reg_old_h,
+    Register  reg_a,
+    Register  reg_b,
+    Register  reg_c,
+    Register  reg_d,
+    Register  reg_e,
+    Register  reg_f,
+    Register  reg_g,
+    Register  reg_h,
+    int iter) {
+  const Register& reg_y0     = r13;
+  const Register& reg_y1     = r14;
+  const Register& reg_y2     = r15;
+  const Register& reg_y3     = rcx;
+  const Register& reg_T1     = r12;
+  //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RND iter ;;;;;;;;;;;;;;;;;;;;;;;;;;;
+  if (iter%4 > 0) {
+    addl(reg_old_h, reg_y2);   // reg_h = k + w + reg_h + S0 + S1 + CH = t1 + S0; --
+  }
+  movl(reg_y2, reg_f);         // reg_y2 = reg_f                                ; CH
+  rorxd(reg_y0, reg_e, 25);    // reg_y0 = reg_e >> 25   ; S1A
+  rorxd(reg_y1, reg_e, 11);    // reg_y1 = reg_e >> 11    ; S1B
+  xorl(reg_y2, reg_g);         // reg_y2 = reg_f^reg_g                              ; CH
+
+  xorl(reg_y0, reg_y1);        // reg_y0 = (reg_e>>25) ^ (reg_h>>11)  ; S1
+  rorxd(reg_y1, reg_e, 6);     // reg_y1 = (reg_e >> 6)    ; S1
+  andl(reg_y2, reg_e);         // reg_y2 = (reg_f^reg_g)&reg_e                          ; CH
+
+  if (iter%4 > 0) {
+    addl(reg_old_h, reg_y3);   // reg_h = t1 + S0 + MAJ                     ; --
+  }
+
+  xorl(reg_y0, reg_y1);       // reg_y0 = (reg_e>>25) ^ (reg_e>>11) ^ (reg_e>>6) ; S1
+  rorxd(reg_T1, reg_a, 13);   // reg_T1 = reg_a >> 13    ; S0B
+  xorl(reg_y2, reg_g);        // reg_y2 = CH = ((reg_f^reg_g)&reg_e)^reg_g                 ; CH
+  rorxd(reg_y1, reg_a, 22);   // reg_y1 = reg_a >> 22    ; S0A
+  movl(reg_y3, reg_a);        // reg_y3 = reg_a                                ; MAJA
+
+  xorl(reg_y1, reg_T1);       // reg_y1 = (reg_a>>22) ^ (reg_a>>13)  ; S0
+  rorxd(reg_T1, reg_a, 2);    // reg_T1 = (reg_a >> 2)    ; S0
+  addl(reg_h, Address(rsp, rdx, Address::times_1, 4*iter)); // reg_h = k + w + reg_h ; --
+  orl(reg_y3, reg_c);         // reg_y3 = reg_a|reg_c                              ; MAJA
+
+  xorl(reg_y1, reg_T1);       // reg_y1 = (reg_a>>22) ^ (reg_a>>13) ^ (reg_a>>2) ; S0
+  movl(reg_T1, reg_a);        // reg_T1 = reg_a                                ; MAJB
+  andl(reg_y3, reg_b);        // reg_y3 = (reg_a|reg_c)&reg_b                          ; MAJA
+  andl(reg_T1, reg_c);        // reg_T1 = reg_a&reg_c                              ; MAJB
+  addl(reg_y2, reg_y0);       // reg_y2 = S1 + CH                          ; --
+
+
+  addl(reg_d, reg_h);         // reg_d = k + w + reg_h + reg_d                     ; --
+  orl(reg_y3, reg_T1);        // reg_y3 = MAJ = (reg_a|reg_c)&reg_b)|(reg_a&reg_c)             ; MAJ
+  addl(reg_h, reg_y1);        // reg_h = k + w + reg_h + S0                    ; --
+
+  addl(reg_d, reg_y2);        // reg_d = k + w + reg_h + reg_d + S1 + CH = reg_d + t1  ; --
+
+
+  if (iter%4 == 3) {
+    addl(reg_h, reg_y2);      // reg_h = k + w + reg_h + S0 + S1 + CH = t1 + S0; --
+    addl(reg_h, reg_y3);      // reg_h = t1 + S0 + MAJ                     ; --
+  }
+}
+
+void MacroAssembler::sha256_AVX2_four_rounds_compute_first(int start) {
+    sha256_AVX2_one_round_compute(rax, rax, rbx, rdi, rsi,  r8,  r9, r10, r11, start + 0);
+    sha256_AVX2_one_round_compute(r11, r11, rax, rbx, rdi, rsi,  r8,  r9, r10, start + 1);
+    sha256_AVX2_one_round_compute(r10, r10, r11, rax, rbx, rdi, rsi,  r8,  r9, start + 2);
+    sha256_AVX2_one_round_compute(r9,  r9,  r10, r11, rax, rbx, rdi, rsi,  r8, start + 3);
+}
+
+void MacroAssembler::sha256_AVX2_four_rounds_compute_last(int start) {
+    sha256_AVX2_one_round_compute(r8,  r8,   r9, r10, r11, rax, rbx, rdi, rsi, start + 0);
+    sha256_AVX2_one_round_compute(rsi, rsi,  r8,  r9, r10, r11, rax, rbx, rdi, start + 1);
+    sha256_AVX2_one_round_compute(rdi, rdi, rsi,  r8,  r9, r10, r11, rax, rbx, start + 2);
+    sha256_AVX2_one_round_compute(rbx, rbx, rdi, rsi,  r8,  r9, r10, r11, rax, start + 3);
+}
+
+void MacroAssembler::sha256_AVX2_one_round_and_sched(
+        XMMRegister  xmm_0,     /* == ymm4 on 0, 1, 2, 3 iterations, then rotate 4 registers left on 4, 8, 12 iterations */
+        XMMRegister  xmm_1,     /* ymm5 */  /* full cycle is 16 iterations */
+        XMMRegister  xmm_2,     /* ymm6 */
+        XMMRegister  xmm_3,     /* ymm7 */
+        Register  reg_a,        /* == rax on 0 iteration, then rotate 8 register right on each next iteration */
+        Register  reg_b,        /* rbx */    /* full cycle is 8 iterations */
+        Register  reg_c,        /* rdi */
+        Register  reg_d,        /* rsi */
+        Register  reg_e,        /* r8 */
+        Register  reg_f,        /* r9d */
+        Register  reg_g,        /* r10d */
+        Register  reg_h,        /* r11d */
+        int iter)
+{
+  movl(rcx, reg_a);           // rcx = reg_a               ; MAJA
+  rorxd(r13, reg_e, 25);      // r13 = reg_e >> 25    ; S1A
+  rorxd(r14, reg_e, 11);      //  r14 = reg_e >> 11    ; S1B
+  addl(reg_h, Address(rsp, rdx, Address::times_1, 4*iter));
+  orl(rcx, reg_c);            // rcx = reg_a|reg_c          ; MAJA
+
+  movl(r15, reg_f);           // r15 = reg_f               ; CH
+  rorxd(r12, reg_a, 13);      // r12 = reg_a >> 13      ; S0B
+  xorl(r13, r14);             // r13 = (reg_e>>25) ^ (reg_e>>11)  ; S1
+  xorl(r15, reg_g);           // r15 = reg_f^reg_g         ; CH
+
+  rorxd(r14, reg_e, 6);       // r14 = (reg_e >> 6)    ; S1
+  andl(r15, reg_e);           // r15 = (reg_f^reg_g)&reg_e ; CH
+
+  xorl(r13, r14);             // r13 = (reg_e>>25) ^ (reg_e>>11) ^ (reg_e>>6) ; S1
+  rorxd(r14, reg_a, 22);      // r14 = reg_a >> 22    ; S0A
+  addl(reg_d, reg_h);         // reg_d = k + w + reg_h + reg_d                     ; --
+
+  andl(rcx, reg_b);          // rcx = (reg_a|reg_c)&reg_b                          ; MAJA
+  xorl(r14, r12);            // r14 = (reg_a>>22) ^ (reg_a>>13)  ; S0
+
+  rorxd(r12, reg_a, 2);      // r12 = (reg_a >> 2)    ; S0
+  xorl(r15, reg_g);          // r15 = CH = ((reg_f^reg_g)&reg_e)^reg_g                 ; CH
+
+  xorl(r14, r12);            // r14 = (reg_a>>22) ^ (reg_a>>13) ^ (reg_a>>2) ; S0
+  movl(r12, reg_a);          // r12 = reg_a                                ; MAJB
+  andl(r12, reg_c);          // r12 = reg_a&reg_c                              ; MAJB
+  addl(r15, r13);            // r15 = S1 + CH                          ; --
+
+  orl(rcx, r12);             // rcx = MAJ = (reg_a|reg_c)&reg_b)|(reg_a&reg_c)             ; MAJ
+  addl(reg_h, r14);          // reg_h = k + w + reg_h + S0                    ; --
+  addl(reg_d, r15);          // reg_d = k + w + reg_h + reg_d + S1 + CH = reg_d + t1  ; --
+
+  addl(reg_h, r15);          // reg_h = k + w + reg_h + S0 + S1 + CH = t1 + S0; --
+  addl(reg_h, rcx);          // reg_h = t1 + S0 + MAJ                     ; --
+
+  if (iter%4 == 0) {
+    vpalignr(xmm0, xmm_3, xmm_2, 4, AVX_256bit);   // ymm0 = W[-7]
+    vpaddd(xmm0, xmm0, xmm_0, AVX_256bit);         // ymm0 = W[-7] + W[-16]; y1 = (e >> 6)     ; S1
+    vpalignr(xmm1, xmm_1, xmm_0, 4, AVX_256bit);   // ymm1 = W[-15]
+    vpsrld(xmm2, xmm1, 7, AVX_256bit);
+    vpslld(xmm3, xmm1, 32-7, AVX_256bit);
+    vpor(xmm3, xmm3, xmm2, AVX_256bit);            // ymm3 = W[-15] ror 7
+    vpsrld(xmm2, xmm1,18, AVX_256bit);
+  } else if (iter%4 == 1 ) {
+    vpsrld(xmm8, xmm1, 3, AVX_256bit);             // ymm8 = W[-15] >> 3
+    vpslld(xmm1, xmm1, 32-18, AVX_256bit);
+    vpxor(xmm3, xmm3, xmm1, AVX_256bit);
+    vpxor(xmm3, xmm3, xmm2, AVX_256bit);           // ymm3 = W[-15] ror 7 ^ W[-15] ror 18
+    vpxor(xmm1, xmm3, xmm8, AVX_256bit);           // ymm1 = s0
+    vpshufd(xmm2, xmm_3, 0xFA, AVX_256bit);        // 11111010b ; ymm2 = W[-2] {BBAA}
+    vpaddd(xmm0, xmm0, xmm1, AVX_256bit);          // ymm0 = W[-16] + W[-7] + s0
+    vpsrld(xmm8, xmm2, 10, AVX_256bit);            // ymm8 = W[-2] >> 10 {BBAA}
+  } else if (iter%4 == 2) {
+    vpsrlq(xmm3, xmm2, 19, AVX_256bit);            // ymm3 = W[-2] ror 19 {xBxA}
+    vpsrlq(xmm2, xmm2, 17, AVX_256bit);            // ymm2 = W[-2] ror 17 {xBxA}
+    vpxor(xmm2, xmm2, xmm3, AVX_256bit);
+    vpxor(xmm8, xmm8, xmm2, AVX_256bit);           // ymm8 = s1 {xBxA}
+    vpshufb(xmm8, xmm8, xmm10, AVX_256bit);        // ymm8 = s1 {00BA}
+    vpaddd(xmm0, xmm0, xmm8, AVX_256bit);          // ymm0 = {..., ..., W[1], W[0]}
+    vpshufd(xmm2, xmm0, 0x50, AVX_256bit);         // 01010000b ; ymm2 = W[-2] {DDCC}
+  } else if (iter%4 == 3) {
+    vpsrld(xmm11, xmm2, 10, AVX_256bit);           // ymm11 = W[-2] >> 10 {DDCC}
+    vpsrlq(xmm3, xmm2, 19, AVX_256bit);            // ymm3 = W[-2] ror 19 {xDxC}
+    vpsrlq(xmm2, xmm2, 17, AVX_256bit);            // ymm2 = W[-2] ror 17 {xDxC}
+    vpxor(xmm2, xmm2, xmm3, AVX_256bit);
+    vpxor(xmm11, xmm11, xmm2, AVX_256bit);         // ymm11 = s1 {xDxC}
+    vpshufb(xmm11, xmm11, xmm12, AVX_256bit);      // ymm11 = s1 {DC00}
+    vpaddd(xmm_0, xmm11, xmm0, AVX_256bit);        // xmm_0 = {W[3], W[2], W[1], W[0]}
+  }
+}
+
+void MacroAssembler::addm(int disp, Register r1, Register r2) {
+  addl(r2, Address(r1, disp));
+  movl(Address(r1, disp), r2);
+}
+
+void MacroAssembler::sha256_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+  XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+  Register buf, Register state, Register ofs, Register limit, Register rsp,
+  bool multi_block, XMMRegister shuf_mask) {
+
+  Label loop0, loop1, loop2, loop3,
+        last_block_enter, do_last_block, only_one_block, done_hash,
+        compute_size, compute_size_end,
+        compute_size1, compute_size_end1;
+
+  address K256_W = StubRoutines::x86::k256_W_addr();
+  address pshuffle_byte_flip_mask = StubRoutines::x86::pshuffle_byte_flip_mask_addr();
+  address pshuffle_byte_flip_mask_addr = 0;
+
+const XMMRegister& SHUF_00BA        = xmm10;    // ymm10: shuffle xBxA -> 00BA
+const XMMRegister& SHUF_DC00        = xmm12;    // ymm12: shuffle xDxC -> DC00
+const XMMRegister& BYTE_FLIP_MASK   = xmm13;   // ymm13
+
+const XMMRegister& X_BYTE_FLIP_MASK = xmm13;   //XMM version of BYTE_FLIP_MASK
+
+const Register& NUM_BLKS = r8;   // 3rd arg
+const Register& CTX      = rdx;  // 2nd arg
+const Register& INP      = rcx;  // 1st arg
+
+const Register& c        = rdi;
+const Register& d        = rsi;
+const Register& e        = r8;    // clobbers NUM_BLKS
+const Register& y3       = rcx;  // clobbers INP
+
+const Register& TBL      = rbp;
+const Register& SRND     = CTX;   // SRND is same register as CTX
+
+const Register& a        = rax;
+const Register& b        = rbx;
+const Register& f        = r9;
+const Register& g        = r10;
+const Register& h        = r11;
+
+const Register& T1       = r12;
+const Register& y0       = r13;
+const Register& y1       = r14;
+const Register& y2       = r15;
+
+
+enum {
+  _XFER_SIZE = 2*64*4, // 2 blocks, 64 rounds, 4 bytes/round
+#ifndef _WIN64
+  _XMM_SAVE_SIZE = 0,
+#else
+  _XMM_SAVE_SIZE = 8*16,
+#endif
+  _INP_END_SIZE = 8,
+  _INP_SIZE = 8,
+  _CTX_SIZE = 8,
+  _RSP_SIZE = 8,
+
+  _XFER = 0,
+  _XMM_SAVE  = _XFER     + _XFER_SIZE,
+  _INP_END   = _XMM_SAVE + _XMM_SAVE_SIZE,
+  _INP       = _INP_END  + _INP_END_SIZE,
+  _CTX       = _INP      + _INP_SIZE,
+  _RSP       = _CTX      + _CTX_SIZE,
+  STACK_SIZE = _RSP      + _RSP_SIZE
+};
+
+#ifndef _WIN64
+  push(rcx);    // linux: this is limit, need at the end
+  push(rdx);    // linux: this is ofs
+#else
+  push(r8);     // win64: this is ofs
+  push(r9);     // win64: this is limit, we need them again at the very and
+#endif
+
+
+  push(rbx);
+#ifdef _WIN64
+  push(rsi);
+  push(rdi);
+#endif
+  push(rbp);
+  push(r12);
+  push(r13);
+  push(r14);
+  push(r15);
+
+  movq(rax, rsp);
+  subq(rsp, STACK_SIZE);
+  andq(rsp, -32);
+  movq(Address(rsp, _RSP), rax);
+
+#ifndef _WIN64
+  // copy linux params to win64 params, therefore the rest of code will be the same for both
+  movq(r9,  rcx);
+  movq(r8,  rdx);
+  movq(rdx, rsi);
+  movq(rcx, rdi);
+#endif
+
+  // setting original assembly ABI
+  /** message to encrypt in INP */
+  lea(INP, Address(rcx, 0));    // rcx == message (buf)     ;; linux: INP = buf = rdi
+  /** digest in CTX             */
+  movq(CTX, rdx);               // rdx = digest  (state)    ;; linux: CTX = state = rsi
+
+  /** NUM_BLK is the length of message, need to set it from ofs and limit  */
+  if (multi_block) {
+
+    // Win64: cannot directly update NUM_BLKS, since NUM_BLKS = ofs = r8
+    // on entry r8 = ofs
+    // on exit  r8 = NUM_BLKS
+
+    xorq(rax, rax);
+
+    bind(compute_size);
+    cmpptr(r8, r9); // assume the original ofs <= limit ;; linux:  cmp rcx, rdx
+    jccb(Assembler::aboveEqual, compute_size_end);
+    addq(r8, 64);                                          //;; linux: ofs = rdx
+    addq(rax, 64);
+    jmpb(compute_size);
+
+    bind(compute_size_end);
+    movq(NUM_BLKS, rax);  // NUM_BLK (r8)                  ;; linux: NUM_BLK = rdx
+
+    cmpq(NUM_BLKS, 0);
+    jcc(Assembler::equal, done_hash);
+
+    } else {
+    xorq(NUM_BLKS, NUM_BLKS);
+    addq(NUM_BLKS, 64);
+  }//if (!multi_block)
+
+  lea(NUM_BLKS, Address(INP, NUM_BLKS, Address::times_1, -64)); // pointer to the last block
+  movq(Address(rsp, _INP_END), NUM_BLKS);  //
+
+  cmpptr(INP, NUM_BLKS);                   //cmp INP, NUM_BLKS
+  jcc(Assembler::equal, only_one_block);   //je only_one_block
+
+  // load initial digest
+  movl(a, Address(CTX, 4*0));
+  movl(b, Address(CTX, 4*1));
+  movl(c, Address(CTX, 4*2));
+  movl(d, Address(CTX, 4*3));
+  movl(e, Address(CTX, 4*4));
+  movl(f, Address(CTX, 4*5));
+  movl(g, Address(CTX, 4*6));
+  movl(h, Address(CTX, 4*7));
+
+  pshuffle_byte_flip_mask_addr = pshuffle_byte_flip_mask;
+  vmovdqu(BYTE_FLIP_MASK, ExternalAddress(pshuffle_byte_flip_mask_addr +0)); //[PSHUFFLE_BYTE_FLIP_MASK wrt rip]
+  vmovdqu(SHUF_00BA, ExternalAddress(pshuffle_byte_flip_mask_addr + 32));     //[_SHUF_00BA wrt rip]
+  vmovdqu(SHUF_DC00, ExternalAddress(pshuffle_byte_flip_mask_addr + 64));     //[_SHUF_DC00 wrt rip]
+
+  movq(Address(rsp, _CTX), CTX);           // store
+
+bind(loop0);
+  lea(TBL, ExternalAddress(K256_W));
+
+  // assume buffers not aligned
+
+  // Load first 16 dwords from two blocks
+  vmovdqu(xmm0, Address(INP, 0*32));
+  vmovdqu(xmm1, Address(INP, 1*32));
+  vmovdqu(xmm2, Address(INP, 2*32));
+  vmovdqu(xmm3, Address(INP, 3*32));
+
+  // byte swap data
+  vpshufb(xmm0, xmm0, BYTE_FLIP_MASK, AVX_256bit);
+  vpshufb(xmm1, xmm1, BYTE_FLIP_MASK, AVX_256bit);
+  vpshufb(xmm2, xmm2, BYTE_FLIP_MASK, AVX_256bit);
+  vpshufb(xmm3, xmm3, BYTE_FLIP_MASK, AVX_256bit);
+
+  // transpose data into high/low halves
+  vperm2i128(xmm4, xmm0, xmm2, 0x20);
+  vperm2i128(xmm5, xmm0, xmm2, 0x31);
+  vperm2i128(xmm6, xmm1, xmm3, 0x20);
+  vperm2i128(xmm7, xmm1, xmm3, 0x31);
+
+bind(last_block_enter);
+  addq(INP, 64);
+  movq(Address(rsp, _INP), INP);
+
+  //;; schedule 48 input dwords, by doing 3 rounds of 12 each
+  xorq(SRND, SRND);
+
+align(16);
+bind(loop1);
+  vpaddd(xmm9, xmm4, Address(TBL, SRND, Address::times_1, 0*32), AVX_256bit);
+  vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 0*32), xmm9);
+  sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, rax, rbx, rdi, rsi, r8,  r9,  r10, r11, 0);
+  sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, r11, rax, rbx, rdi, rsi, r8,  r9,  r10, 1);
+  sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, r10, r11, rax, rbx, rdi, rsi, r8,  r9,  2);
+  sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, r9,  r10, r11, rax, rbx, rdi, rsi, r8,  3);
+
+  vpaddd(xmm9, xmm5, Address(TBL, SRND, Address::times_1, 1*32), AVX_256bit);
+  vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 1*32), xmm9);
+  sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, r8,  r9,  r10, r11, rax, rbx, rdi, rsi,  8+0);
+  sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, rsi, r8,  r9,  r10, r11, rax, rbx, rdi,  8+1);
+  sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, rdi, rsi, r8,  r9,  r10, r11, rax, rbx,  8+2);
+  sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, rbx, rdi, rsi, r8,  r9,  r10, r11, rax,  8+3);
+
+  vpaddd(xmm9, xmm6, Address(TBL, SRND, Address::times_1, 2*32), AVX_256bit);
+  vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 2*32), xmm9);
+  sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, rax, rbx, rdi, rsi, r8,  r9,  r10, r11, 16+0);
+  sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, r11, rax, rbx, rdi, rsi, r8,  r9,  r10, 16+1);
+  sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, r10, r11, rax, rbx, rdi, rsi, r8,  r9,  16+2);
+  sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, r9,  r10, r11, rax, rbx, rdi, rsi, r8,  16+3);
+
+  vpaddd(xmm9, xmm7, Address(TBL, SRND, Address::times_1, 3*32), AVX_256bit);
+  vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 3*32), xmm9);
+
+  sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, r8,  r9,  r10, r11, rax, rbx, rdi, rsi,  24+0);
+  sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, rsi, r8,  r9,  r10, r11, rax, rbx, rdi,  24+1);
+  sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, rdi, rsi, r8,  r9,  r10, r11, rax, rbx,  24+2);
+  sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, rbx, rdi, rsi, r8,  r9,  r10, r11, rax,  24+3);
+
+  addq(SRND, 4*32);
+  cmpq(SRND, 3 * 4*32);
+  jcc(Assembler::below, loop1);
+
+bind(loop2);
+  // Do last 16 rounds with no scheduling
+  vpaddd(xmm9, xmm4, Address(TBL, SRND, Address::times_1, 0*32), AVX_256bit);
+  vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 0*32), xmm9);
+  sha256_AVX2_four_rounds_compute_first(0);
+
+  vpaddd(xmm9, xmm5, Address(TBL, SRND, Address::times_1, 1*32), AVX_256bit);
+  vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 1*32), xmm9);
+  sha256_AVX2_four_rounds_compute_last(0 + 8);
+
+  addq(SRND, 2*32);
+
+  vmovdqu(xmm4, xmm6);
+  vmovdqu(xmm5, xmm7);
+
+  cmpq(SRND, 4 * 4*32);
+  jcc(Assembler::below, loop2);
+
+  movq(CTX, Address(rsp, _CTX));
+  movq(INP, Address(rsp, _INP));
+
+  addm(4*0, CTX, a);
+  addm(4*1, CTX, b);
+  addm(4*2, CTX, c);
+  addm(4*3, CTX, d);
+  addm(4*4, CTX, e);
+  addm(4*5, CTX, f);
+  addm(4*6, CTX, g);
+  addm(4*7, CTX, h);
+
+  cmpq(INP, Address(rsp, _INP_END));
+  jcc(Assembler::above, done_hash);
+
+  //Do second block using previously scheduled results
+  xorq(SRND, SRND);
+align(16);
+bind(loop3);
+  sha256_AVX2_four_rounds_compute_first(4);
+  sha256_AVX2_four_rounds_compute_last(4+8);
+
+  addq(SRND, 2*32);
+  cmpq(SRND, 4 * 4*32);
+  jcc(Assembler::below, loop3);
+
+  movq(CTX, Address(rsp, _CTX));
+  movq(INP, Address(rsp, _INP));
+  addq(INP, 64);
+
+  addm(4*0, CTX, a);
+  addm(4*1, CTX, b);
+  addm(4*2, CTX, c);
+  addm(4*3, CTX, d);
+  addm(4*4, CTX, e);
+  addm(4*5, CTX, f);
+  addm(4*6, CTX, g);
+  addm(4*7, CTX, h);
+
+  cmpq(INP, Address(rsp, _INP_END));
+  jcc(Assembler::below, loop0);
+  jccb(Assembler::above, done_hash);
+
+bind(do_last_block);
+  lea(TBL, ExternalAddress(K256_W));
+
+  movdqu(xmm4, Address(INP, 0*16));
+  movdqu(xmm5, Address(INP, 1*16));
+  movdqu(xmm6, Address(INP, 2*16));
+  movdqu(xmm7, Address(INP, 3*16));
+
+  vpshufb(xmm4, xmm4, xmm13, AVX_128bit);
+  vpshufb(xmm5, xmm5, xmm13, AVX_128bit);
+  vpshufb(xmm6, xmm6, xmm13, AVX_128bit);
+  vpshufb(xmm7, xmm7, xmm13, AVX_128bit);
+
+  jmp(last_block_enter);
+
+bind(only_one_block);
+
+  // load initial digest ;; table should be preloaded with following values
+  movl(a, Address(CTX, 4*0));   // 0x6a09e667
+  movl(b, Address(CTX, 4*1));   // 0xbb67ae85
+  movl(c, Address(CTX, 4*2));   // 0x3c6ef372
+  movl(d, Address(CTX, 4*3));   // 0xa54ff53a
+  movl(e, Address(CTX, 4*4));   // 0x510e527f
+  movl(f, Address(CTX, 4*5));   // 0x9b05688c
+  movl(g, Address(CTX, 4*6));   // 0x1f83d9ab
+  movl(h, Address(CTX, 4*7));   // 0x5be0cd19
+
+
+  pshuffle_byte_flip_mask_addr = pshuffle_byte_flip_mask;
+  vmovdqu(BYTE_FLIP_MASK, ExternalAddress(pshuffle_byte_flip_mask_addr + 0)); //[PSHUFFLE_BYTE_FLIP_MASK wrt rip]
+  vmovdqu(SHUF_00BA, ExternalAddress(pshuffle_byte_flip_mask_addr + 32));     //[_SHUF_00BA wrt rip]
+  vmovdqu(SHUF_DC00, ExternalAddress(pshuffle_byte_flip_mask_addr + 64));     //[_SHUF_DC00 wrt rip]
+
+  movq(Address(rsp, _CTX), CTX);
+  jmpb(do_last_block);
+
+bind(done_hash);
+
+  movq(rsp, Address(rsp, _RSP));
+
+  pop(r15);
+  pop(r14);
+  pop(r13);
+  pop(r12);
+  pop(rbp);
+#ifdef _WIN64
+  pop(rdi);
+  pop(rsi);
+#endif
+  pop(rbx);
+
+#ifdef _WIN64
+  pop(r9);
+  pop(r8);
+#else
+  pop(rdx);
+  pop(rcx);
+#endif
+
+  if (multi_block) {
+#ifdef _WIN64
+const Register& limit_end = r9;
+const Register& ofs_end   = r8;
+#else
+const Register& limit_end = rcx;
+const Register& ofs_end   = rdx;
+#endif
+    movq(rax, ofs_end);
+
+bind(compute_size1);
+    cmpptr(rax, limit_end); // assume the original ofs <= limit
+    jccb(Assembler::aboveEqual, compute_size_end1);
+    addq(rax, 64);
+    jmpb(compute_size1);
+
+bind(compute_size_end1);
+  }
+}
+#endif //#ifdef _LP64
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp
new file mode 100644
index 0000000..68547ee
--- /dev/null
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp
@@ -0,0 +1,2448 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+* Intel Math Library (LIBM) Source Code
+*
+* 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 "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "stubRoutines_x86.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
+/******************************************************************************/
+//                     ALGORITHM DESCRIPTION - SIN()
+//                     ---------------------
+//
+//     1. RANGE REDUCTION
+//
+//     We perform an initial range reduction from X to r with
+//
+//          X =~= N * pi/32 + r
+//
+//     so that |r| <= pi/64 + epsilon. We restrict inputs to those
+//     where |N| <= 932560. Beyond this, the range reduction is
+//     insufficiently accurate. For extremely small inputs,
+//     denormalization can occur internally, impacting performance.
+//     This means that the main path is actually only taken for
+//     2^-252 <= |X| < 90112.
+//
+//     To avoid branches, we perform the range reduction to full
+//     accuracy each time.
+//
+//          X - N * (P_1 + P_2 + P_3)
+//
+//     where P_1 and P_2 are 32-bit numbers (so multiplication by N
+//     is exact) and P_3 is a 53-bit number. Together, these
+//     approximate pi well enough for all cases in the restricted
+//     range.
+//
+//     The main reduction sequence is:
+//
+//             y = 32/pi * x
+//             N = integer(y)
+//     (computed by adding and subtracting off SHIFTER)
+//
+//             m_1 = N * P_1
+//             m_2 = N * P_2
+//             r_1 = x - m_1
+//             r = r_1 - m_2
+//     (this r can be used for most of the calculation)
+//
+//             c_1 = r_1 - r
+//             m_3 = N * P_3
+//             c_2 = c_1 - m_2
+//             c = c_2 - m_3
+//
+//     2. MAIN ALGORITHM
+//
+//     The algorithm uses a table lookup based on B = M * pi / 32
+//     where M = N mod 64. The stored values are:
+//       sigma             closest power of 2 to cos(B)
+//       C_hl              53-bit cos(B) - sigma
+//       S_hi + S_lo       2 * 53-bit sin(B)
+//
+//     The computation is organized as follows:
+//
+//          sin(B + r + c) = [sin(B) + sigma * r] +
+//                           r * (cos(B) - sigma) +
+//                           sin(B) * [cos(r + c) - 1] +
+//                           cos(B) * [sin(r + c) - r]
+//
+//     which is approximately:
+//
+//          [S_hi + sigma * r] +
+//          C_hl * r +
+//          S_lo + S_hi * [(cos(r) - 1) - r * c] +
+//          (C_hl + sigma) * [(sin(r) - r) + c]
+//
+//     and this is what is actually computed. We separate this sum
+//     into four parts:
+//
+//          hi + med + pols + corr
+//
+//     where
+//
+//          hi       = S_hi + sigma r
+//          med      = C_hl * r
+//          pols     = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r)
+//          corr     = S_lo + c * ((C_hl + sigma) - S_hi * r)
+//
+//     3. POLYNOMIAL
+//
+//     The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) *
+//     (sin(r) - r) can be rearranged freely, since it is quite
+//     small, so we exploit parallelism to the fullest.
+//
+//          psc4       =   SC_4 * r_1
+//          msc4       =   psc4 * r
+//          r2         =   r * r
+//          msc2       =   SC_2 * r2
+//          r4         =   r2 * r2
+//          psc3       =   SC_3 + msc4
+//          psc1       =   SC_1 + msc2
+//          msc3       =   r4 * psc3
+//          sincospols =   psc1 + msc3
+//          pols       =   sincospols *
+//                         <S_hi * r^2 | (C_hl + sigma) * r^3>
+//
+//     4. CORRECTION TERM
+//
+//     This is where the "c" component of the range reduction is
+//     taken into account; recall that just "r" is used for most of
+//     the calculation.
+//
+//          -c   = m_3 - c_2
+//          -d   = S_hi * r - (C_hl + sigma)
+//          corr = -c * -d + S_lo
+//
+//     5. COMPENSATED SUMMATIONS
+//
+//     The two successive compensated summations add up the high
+//     and medium parts, leaving just the low parts to add up at
+//     the end.
+//
+//          rs        =  sigma * r
+//          res_int   =  S_hi + rs
+//          k_0       =  S_hi - res_int
+//          k_2       =  k_0 + rs
+//          med       =  C_hl * r
+//          res_hi    =  res_int + med
+//          k_1       =  res_int - res_hi
+//          k_3       =  k_1 + med
+//
+//     6. FINAL SUMMATION
+//
+//     We now add up all the small parts:
+//
+//          res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3
+//
+//     Now the overall result is just:
+//
+//          res_hi + res_lo
+//
+//     7. SMALL ARGUMENTS
+//
+//     If |x| < SNN (SNN meaning the smallest normal number), we
+//     simply perform 0.1111111 cdots 1111 * x. For SNN <= |x|, we
+//     do 2^-55 * (2^55 * x - x).
+//
+// Special cases:
+//  sin(NaN) = quiet NaN, and raise invalid exception
+//  sin(INF) = NaN and raise invalid exception
+//  sin(+/-0) = +/-0
+//
+/******************************************************************************/
+
+#ifdef _LP64
+// The 64 bit code is at most SSE2 compliant
+ALIGNED_(16) juint StubRoutines::x86::_ONEHALF[] =
+{
+    0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_P_2[] =
+{
+    0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_SC_4[] =
+{
+    0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_Ctable[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL,
+    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
+    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL,
+    0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL,
+    0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL,
+    0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL,
+    0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL,
+    0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL,
+    0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL,
+    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
+    0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL,
+    0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL,
+    0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL,
+    0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL,
+    0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL,
+    0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL,
+    0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL,
+    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
+    0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL,
+    0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL,
+    0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL,
+    0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL,
+    0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL,
+    0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL,
+    0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL,
+    0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL,
+    0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL,
+    0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL,
+    0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL,
+    0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL,
+    0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL,
+    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
+    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL,
+    0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL,
+    0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL,
+    0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL,
+    0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL,
+    0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL,
+    0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL,
+    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
+    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL,
+    0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL,
+    0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL,
+    0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL,
+    0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL,
+    0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL,
+    0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL,
+    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
+    0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL,
+    0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
+    0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL,
+    0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL,
+    0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL,
+    0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL,
+    0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL,
+    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL,
+    0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL,
+    0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
+    0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL,
+    0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL,
+    0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL,
+    0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL,
+    0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL,
+    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL,
+    0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL,
+    0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
+    0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL,
+    0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL,
+    0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL,
+    0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL,
+    0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL,
+    0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL,
+    0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL,
+    0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL,
+    0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL,
+    0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL,
+    0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL,
+    0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL,
+    0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL,
+    0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
+    0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL,
+    0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL,
+    0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL,
+    0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL,
+    0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL,
+    0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL,
+    0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL,
+    0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
+    0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL,
+    0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL,
+    0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL,
+    0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL,
+    0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL,
+    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL,
+    0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL,
+    0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
+    0x00000000UL, 0x3ff00000UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_SC_2[] =
+{
+    0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_SC_3[] =
+{
+    0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_SC_1[] =
+{
+    0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_PI_INV_TABLE[] =
+{
+    0x00000000UL, 0x00000000UL, 0xa2f9836eUL, 0x4e441529UL, 0xfc2757d1UL,
+    0xf534ddc0UL, 0xdb629599UL, 0x3c439041UL, 0xfe5163abUL, 0xdebbc561UL,
+    0xb7246e3aUL, 0x424dd2e0UL, 0x06492eeaUL, 0x09d1921cUL, 0xfe1deb1cUL,
+    0xb129a73eUL, 0xe88235f5UL, 0x2ebb4484UL, 0xe99c7026UL, 0xb45f7e41UL,
+    0x3991d639UL, 0x835339f4UL, 0x9c845f8bUL, 0xbdf9283bUL, 0x1ff897ffUL,
+    0xde05980fUL, 0xef2f118bUL, 0x5a0a6d1fUL, 0x6d367ecfUL, 0x27cb09b7UL,
+    0x4f463f66UL, 0x9e5fea2dUL, 0x7527bac7UL, 0xebe5f17bUL, 0x3d0739f7UL,
+    0x8a5292eaUL, 0x6bfb5fb1UL, 0x1f8d5d08UL, 0x56033046UL, 0xfc7b6babUL,
+    0xf0cfbc21UL
+};
+
+ALIGNED_(8) juint StubRoutines::x86::_PI_4[] =
+{
+    0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
+};
+
+ALIGNED_(8) juint StubRoutines::x86::_PI32INV[] =
+{
+    0x6dc9c883UL, 0x40245f30UL
+};
+
+ALIGNED_(8) juint _SHIFTER[] =
+{
+    0x00000000UL, 0x43380000UL
+};
+
+ALIGNED_(8) juint StubRoutines::x86::_SIGN_MASK[] =
+{
+    0x00000000UL, 0x80000000UL
+};
+
+ALIGNED_(8) juint StubRoutines::x86::_P_3[] =
+{
+    0x2e037073UL, 0x3b63198aUL
+};
+
+ALIGNED_(8) juint _ALL_ONES[] =
+{
+    0xffffffffUL, 0x3fefffffUL
+};
+
+ALIGNED_(8) juint _TWO_POW_55[] =
+{
+    0x00000000UL, 0x43600000UL
+};
+
+ALIGNED_(8) juint _TWO_POW_M55[] =
+{
+    0x00000000UL, 0x3c800000UL
+};
+
+ALIGNED_(8) juint StubRoutines::x86::_P_1[] =
+{
+    0x54400000UL, 0x3fb921fbUL
+};
+
+ALIGNED_(8) juint StubRoutines::x86::_NEG_ZERO[] =
+{
+    0x00000000UL, 0x80000000UL
+};
+
+void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
+  Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1;
+  Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1;
+  Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1;
+  Label L_2TAG_PACKET_13_0_1, L_2TAG_PACKET_14_0_1;
+  Label L_2TAG_PACKET_12_0_1, B1_1, B1_2, B1_4, start;
+
+  assert_different_registers(tmp1, tmp2, tmp3, tmp4, eax, ebx, ecx, edx);
+  address ONEHALF = StubRoutines::x86::_ONEHALF_addr();
+  address P_2 = StubRoutines::x86::_P_2_addr();
+  address SC_4 = StubRoutines::x86::_SC_4_addr();
+  address Ctable = StubRoutines::x86::_Ctable_addr();
+  address SC_2 = StubRoutines::x86::_SC_2_addr();
+  address SC_3 = StubRoutines::x86::_SC_3_addr();
+  address SC_1 = StubRoutines::x86::_SC_1_addr();
+  address PI_INV_TABLE = StubRoutines::x86::_PI_INV_TABLE_addr();
+  address PI_4 = (address)StubRoutines::x86::_PI_4_addr();
+  address PI32INV = (address)StubRoutines::x86::_PI32INV_addr();
+  address SHIFTER = (address)_SHIFTER;
+  address SIGN_MASK = (address)StubRoutines::x86::_SIGN_MASK_addr();
+  address P_3 = (address)StubRoutines::x86::_P_3_addr();
+  address ALL_ONES = (address)_ALL_ONES;
+  address TWO_POW_55 = (address)_TWO_POW_55;
+  address TWO_POW_M55 = (address)_TWO_POW_M55;
+  address P_1 = (address)StubRoutines::x86::_P_1_addr();
+  address NEG_ZERO = (address)StubRoutines::x86::_NEG_ZERO_addr();
+
+  bind(start);
+  push(rbx);
+  subq(rsp, 16);
+  movsd(Address(rsp, 8), xmm0);
+  movl(eax, Address(rsp, 12));
+  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
+  movq(xmm2, ExternalAddress(SHIFTER));    //0x00000000UL, 0x43380000UL
+  andl(eax, 2147418112);
+  subl(eax, 808452096);
+  cmpl(eax, 281346048);
+  jcc(Assembler::above, L_2TAG_PACKET_0_0_1);
+  mulsd(xmm1, xmm0);
+  movdqu(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
+  pand(xmm4, xmm0);
+  por(xmm5, xmm4);
+  addpd(xmm1, xmm5);
+  cvttsd2sil(edx, xmm1);
+  cvtsi2sdl(xmm1, edx);
+  movdqu(xmm6, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
+  mov64(r8, 0x3fb921fb54400000);
+  movdq(xmm3, r8);
+  movdqu(xmm5, ExternalAddress(SC_4));    //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL
+  pshufd(xmm4, xmm0, 68);
+  mulsd(xmm3, xmm1);
+  if (VM_Version::supports_sse3()) {
+    movddup(xmm1, xmm1);
+  }
+  else {
+    movlhps(xmm1, xmm1);
+  }
+  andl(edx, 63);
+  shll(edx, 5);
+  lea(rax, ExternalAddress(Ctable));
+  addq(rax, rdx);
+  mulpd(xmm6, xmm1);
+  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
+  subsd(xmm4, xmm3);
+  movq(xmm7, Address(rax, 8));
+  subsd(xmm0, xmm3);
+  if (VM_Version::supports_sse3()) {
+    movddup(xmm3, xmm4);
+  }
+  else {
+    movdqu(xmm3, xmm4);
+    movlhps(xmm3, xmm3);
+  }
+  subsd(xmm4, xmm6);
+  pshufd(xmm0, xmm0, 68);
+  movdqu(xmm2, Address(rax, 0));
+  mulpd(xmm5, xmm0);
+  subpd(xmm0, xmm6);
+  mulsd(xmm7, xmm4);
+  subsd(xmm3, xmm4);
+  mulpd(xmm5, xmm0);
+  mulpd(xmm0, xmm0);
+  subsd(xmm3, xmm6);
+  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
+  subsd(xmm1, xmm3);
+  movq(xmm3, Address(rax, 24));
+  addsd(xmm2, xmm3);
+  subsd(xmm7, xmm2);
+  mulsd(xmm2, xmm4);
+  mulpd(xmm6, xmm0);
+  mulsd(xmm3, xmm4);
+  mulpd(xmm2, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
+  mulsd(xmm4, Address(rax, 0));
+  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
+  mulpd(xmm5, xmm0);
+  movdqu(xmm0, xmm3);
+  addsd(xmm3, Address(rax, 8));
+  mulpd(xmm1, xmm7);
+  movdqu(xmm7, xmm4);
+  addsd(xmm4, xmm3);
+  addpd(xmm6, xmm5);
+  movq(xmm5, Address(rax, 8));
+  subsd(xmm5, xmm3);
+  subsd(xmm3, xmm4);
+  addsd(xmm1, Address(rax, 16));
+  mulpd(xmm6, xmm2);
+  addsd(xmm5, xmm0);
+  addsd(xmm3, xmm7);
+  addsd(xmm1, xmm5);
+  addsd(xmm1, xmm3);
+  addsd(xmm1, xmm6);
+  unpckhpd(xmm6, xmm6);
+  movdqu(xmm0, xmm4);
+  addsd(xmm1, xmm6);
+  addsd(xmm0, xmm1);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_0_0_1);
+  jcc(Assembler::greater, L_2TAG_PACKET_1_0_1);
+  shrl(eax, 20);
+  cmpl(eax, 3325);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_2_0_1);
+  mulsd(xmm0, ExternalAddress(ALL_ONES));    //0xffffffffUL, 0x3fefffffUL
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_2_0_1);
+  movq(xmm3, ExternalAddress(TWO_POW_55));    //0x00000000UL, 0x43600000UL
+  mulsd(xmm3, xmm0);
+  subsd(xmm3, xmm0);
+  mulsd(xmm3, ExternalAddress(TWO_POW_M55));    //0x00000000UL, 0x3c800000UL
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_1_0_1);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  cmpl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_3_0_1);
+  pextrw(ecx, xmm0, 3);
+  andl(ecx, 32752);
+  subl(ecx, 16224);
+  shrl(ecx, 7);
+  andl(ecx, 65532);
+  lea(r11, ExternalAddress(PI_INV_TABLE));
+  addq(rcx, r11);
+  movdq(rax, xmm0);
+  movl(r10, Address(rcx, 20));
+  movl(r8, Address(rcx, 24));
+  movl(edx, eax);
+  shrq(rax, 21);
+  orl(eax, INT_MIN);
+  shrl(eax, 11);
+  movl(r9, r10);
+  imulq(r10, rdx);
+  imulq(r9, rax);
+  imulq(r8, rax);
+  movl(rsi, Address(rcx, 16));
+  movl(rdi, Address(rcx, 12));
+  movl(r11, r10);
+  shrq(r10, 32);
+  addq(r9, r10);
+  addq(r11, r8);
+  movl(r8, r11);
+  shrq(r11, 32);
+  addq(r9, r11);
+  movl(r10, rsi);
+  imulq(rsi, rdx);
+  imulq(r10, rax);
+  movl(r11, rdi);
+  imulq(rdi, rdx);
+  movl(ebx, rsi);
+  shrq(rsi, 32);
+  addq(r9, rbx);
+  movl(ebx, r9);
+  shrq(r9, 32);
+  addq(r10, rsi);
+  addq(r10, r9);
+  shlq(rbx, 32);
+  orq(r8, rbx);
+  imulq(r11, rax);
+  movl(r9, Address(rcx, 8));
+  movl(rsi, Address(rcx, 4));
+  movl(ebx, rdi);
+  shrq(rdi, 32);
+  addq(r10, rbx);
+  movl(ebx, r10);
+  shrq(r10, 32);
+  addq(r11, rdi);
+  addq(r11, r10);
+  movq(rdi, r9);
+  imulq(r9, rdx);
+  imulq(rdi, rax);
+  movl(r10, r9);
+  shrq(r9, 32);
+  addq(r11, r10);
+  movl(r10, r11);
+  shrq(r11, 32);
+  addq(rdi, r9);
+  addq(rdi, r11);
+  movq(r9, rsi);
+  imulq(rsi, rdx);
+  imulq(r9, rax);
+  shlq(r10, 32);
+  orq(r10, rbx);
+  movl(eax, Address(rcx, 0));
+  movl(r11, rsi);
+  shrq(rsi, 32);
+  addq(rdi, r11);
+  movl(r11, rdi);
+  shrq(rdi, 32);
+  addq(r9, rsi);
+  addq(r9, rdi);
+  imulq(rdx, rax);
+  pextrw(ebx, xmm0, 3);
+  lea(rdi, ExternalAddress(PI_INV_TABLE));
+  subq(rcx, rdi);
+  addl(ecx, ecx);
+  addl(ecx, ecx);
+  addl(ecx, ecx);
+  addl(ecx, 19);
+  movl(rsi, 32768);
+  andl(rsi, ebx);
+  shrl(ebx, 4);
+  andl(ebx, 2047);
+  subl(ebx, 1023);
+  subl(ecx, ebx);
+  addq(r9, rdx);
+  movl(edx, ecx);
+  addl(edx, 32);
+  cmpl(ecx, 1);
+  jcc(Assembler::less, L_2TAG_PACKET_4_0_1);
+  negl(ecx);
+  addl(ecx, 29);
+  shll(r9);
+  movl(rdi, r9);
+  andl(r9, 536870911);
+  testl(r9, 268435456);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_5_0_1);
+  shrl(r9);
+  movl(ebx, 0);
+  shlq(r9, 32);
+  orq(r9, r11);
+
+  bind(L_2TAG_PACKET_6_0_1);
+
+  bind(L_2TAG_PACKET_7_0_1);
+
+  cmpq(r9, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_8_0_1);
+
+  bind(L_2TAG_PACKET_9_0_1);
+  bsrq(r11, r9);
+  movl(ecx, 29);
+  subl(ecx, r11);
+  jcc(Assembler::lessEqual, L_2TAG_PACKET_10_0_1);
+  shlq(r9);
+  movq(rax, r10);
+  shlq(r10);
+  addl(edx, ecx);
+  negl(ecx);
+  addl(ecx, 64);
+  shrq(rax);
+  shrq(r8);
+  orq(r9, rax);
+  orq(r10, r8);
+
+  bind(L_2TAG_PACKET_11_0_1);
+  cvtsi2sdq(xmm0, r9);
+  shrq(r10, 1);
+  cvtsi2sdq(xmm3, r10);
+  xorpd(xmm4, xmm4);
+  shll(edx, 4);
+  negl(edx);
+  addl(edx, 16368);
+  orl(edx, rsi);
+  xorl(edx, ebx);
+  pinsrw(xmm4, edx, 3);
+  movq(xmm2, ExternalAddress(PI_4));    //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
+  movq(xmm6, ExternalAddress(8 + PI_4));    //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL
+  xorpd(xmm5, xmm5);
+  subl(edx, 1008);
+  pinsrw(xmm5, edx, 3);
+  mulsd(xmm0, xmm4);
+  shll(rsi, 16);
+  sarl(rsi, 31);
+  mulsd(xmm3, xmm5);
+  movdqu(xmm1, xmm0);
+  mulsd(xmm0, xmm2);
+  shrl(rdi, 29);
+  addsd(xmm1, xmm3);
+  mulsd(xmm3, xmm2);
+  addl(rdi, rsi);
+  xorl(rdi, rsi);
+  mulsd(xmm6, xmm1);
+  movl(eax, rdi);
+  addsd(xmm6, xmm3);
+  movdqu(xmm2, xmm0);
+  addsd(xmm0, xmm6);
+  subsd(xmm2, xmm0);
+  addsd(xmm6, xmm2);
+
+  bind(L_2TAG_PACKET_12_0_1);
+  movq(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x40245f30UL
+  mulsd(xmm1, xmm0);
+  movq(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+  movq(xmm4, ExternalAddress(SIGN_MASK));    //0x00000000UL, 0x80000000UL
+  pand(xmm4, xmm0);
+  por(xmm5, xmm4);
+  addpd(xmm1, xmm5);
+  cvttsd2sil(edx, xmm1);
+  cvtsi2sdl(xmm1, edx);
+  movq(xmm3, ExternalAddress(P_1));    //0x54400000UL, 0x3fb921fbUL
+  movdqu(xmm2, ExternalAddress(P_2));    //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL
+  mulsd(xmm3, xmm1);
+  unpcklpd(xmm1, xmm1);
+  shll(eax, 3);
+  addl(edx, 1865216);
+  movdqu(xmm4, xmm0);
+  addl(edx, eax);
+  andl(edx, 63);
+  movdqu(xmm5, ExternalAddress(SC_4));    //0x54400000UL, 0x3fb921fbUL
+  lea(rax, ExternalAddress(Ctable));
+  shll(edx, 5);
+  addq(rax, rdx);
+  mulpd(xmm2, xmm1);
+  subsd(xmm0, xmm3);
+  mulsd(xmm1, ExternalAddress(P_3));    //0x2e037073UL, 0x3b63198aUL
+  subsd(xmm4, xmm3);
+  movq(xmm7, Address(rax, 8));
+  unpcklpd(xmm0, xmm0);
+  movdqu(xmm3, xmm4);
+  subsd(xmm4, xmm2);
+  mulpd(xmm5, xmm0);
+  subpd(xmm0, xmm2);
+  mulsd(xmm7, xmm4);
+  subsd(xmm3, xmm4);
+  mulpd(xmm5, xmm0);
+  mulpd(xmm0, xmm0);
+  subsd(xmm3, xmm2);
+  movdqu(xmm2, Address(rax, 0));
+  subsd(xmm1, xmm3);
+  movq(xmm3, Address(rax, 24));
+  addsd(xmm2, xmm3);
+  subsd(xmm7, xmm2);
+  subsd(xmm1, xmm6);
+  movdqu(xmm6, ExternalAddress(SC_2));    //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL
+  mulsd(xmm2, xmm4);
+  mulpd(xmm6, xmm0);
+  mulsd(xmm3, xmm4);
+  mulpd(xmm2, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm5, ExternalAddress(SC_3));    //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL
+  mulsd(xmm4, Address(rax, 0));
+  addpd(xmm6, ExternalAddress(SC_1));    //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL
+  mulpd(xmm5, xmm0);
+  movdqu(xmm0, xmm3);
+  addsd(xmm3, Address(rax, 8));
+  mulpd(xmm1, xmm7);
+  movdqu(xmm7, xmm4);
+  addsd(xmm4, xmm3);
+  addpd(xmm6, xmm5);
+  movq(xmm5, Address(rax, 8));
+  subsd(xmm5, xmm3);
+  subsd(xmm3, xmm4);
+  addsd(xmm1, Address(rax, 16));
+  mulpd(xmm6, xmm2);
+  addsd(xmm5, xmm0);
+  addsd(xmm3, xmm7);
+  addsd(xmm1, xmm5);
+  addsd(xmm1, xmm3);
+  addsd(xmm1, xmm6);
+  unpckhpd(xmm6, xmm6);
+  movdqu(xmm0, xmm4);
+  addsd(xmm1, xmm6);
+  addsd(xmm0, xmm1);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_8_0_1);
+  addl(edx, 64);
+  movq(r9, r10);
+  movq(r10, r8);
+  movl(r8, 0);
+  cmpq(r9, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1);
+  addl(edx, 64);
+  movq(r9, r10);
+  movq(r10, r8);
+  cmpq(r9, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1);
+  xorpd(xmm0, xmm0);
+  xorpd(xmm6, xmm6);
+  jmp(L_2TAG_PACKET_12_0_1);
+
+  bind(L_2TAG_PACKET_10_0_1);
+  jcc(Assembler::equal, L_2TAG_PACKET_11_0_1);
+  negl(ecx);
+  shrq(r10);
+  movq(rax, r9);
+  shrq(r9);
+  subl(edx, ecx);
+  negl(ecx);
+  addl(ecx, 64);
+  shlq(rax);
+  orq(r10, rax);
+  jmp(L_2TAG_PACKET_11_0_1);
+
+  bind(L_2TAG_PACKET_4_0_1);
+  negl(ecx);
+  shlq(r9, 32);
+  orq(r9, r11);
+  shlq(r9);
+  movq(rdi, r9);
+  testl(r9, INT_MIN);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_13_0_1);
+  shrl(r9);
+  movl(ebx, 0);
+  shrq(rdi, 3);
+  jmp(L_2TAG_PACKET_7_0_1);
+
+  bind(L_2TAG_PACKET_5_0_1);
+  shrl(r9);
+  movl(ebx, 536870912);
+  shrl(ebx);
+  shlq(r9, 32);
+  orq(r9, r11);
+  shlq(rbx, 32);
+  addl(rdi, 536870912);
+  movl(rcx, 0);
+  movl(r11, 0);
+  subq(rcx, r8);
+  sbbq(r11, r10);
+  sbbq(rbx, r9);
+  movq(r8, rcx);
+  movq(r10, r11);
+  movq(r9, rbx);
+  movl(ebx, 32768);
+  jmp(L_2TAG_PACKET_6_0_1);
+
+  bind(L_2TAG_PACKET_13_0_1);
+  shrl(r9);
+  mov64(rbx, 0x100000000);
+  shrq(rbx);
+  movl(rcx, 0);
+  movl(r11, 0);
+  subq(rcx, r8);
+  sbbq(r11, r10);
+  sbbq(rbx, r9);
+  movq(r8, rcx);
+  movq(r10, r11);
+  movq(r9, rbx);
+  movl(ebx, 32768);
+  shrq(rdi, 3);
+  addl(rdi, 536870912);
+  jmp(L_2TAG_PACKET_7_0_1);
+
+  bind(L_2TAG_PACKET_3_0_1);
+  movq(xmm0, Address(rsp, 8));
+  mulsd(xmm0, ExternalAddress(NEG_ZERO));    //0x00000000UL, 0x80000000UL
+  movq(Address(rsp, 0), xmm0);
+
+  bind(L_2TAG_PACKET_14_0_1);
+
+  bind(B1_4);
+  addq(rsp, 16);
+  pop(rbx);
+}
+#else
+// The 32 bit code is at most SSE2 compliant
+ALIGNED_(8) juint _zero_none[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL
+};
+
+ALIGNED_(4) juint __4onpi_d[] =
+{
+    0x6dc9c883UL, 0x3ff45f30UL
+};
+
+ALIGNED_(4) juint _TWO_32H[] =
+{
+    0x00000000UL, 0x41f80000UL
+};
+
+ALIGNED_(4) juint _pi04_3d[] =
+{
+    0x54442d00UL, 0x3fe921fbUL, 0x98cc5180UL, 0x3ce84698UL, 0xcbb5bf6cUL,
+    0xb9dfc8f8UL
+};
+
+ALIGNED_(4) juint _pi04_5d[] =
+{
+    0x54400000UL, 0x3fe921fbUL, 0x1a600000UL, 0x3dc0b461UL, 0x2e000000UL,
+    0x3b93198aUL, 0x25200000UL, 0x396b839aUL, 0x533e63a0UL, 0x37027044UL
+};
+
+ALIGNED_(4) juint _SCALE[] =
+{
+    0x00000000UL, 0x32600000UL
+};
+
+ALIGNED_(4) juint _zeros[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL
+};
+
+ALIGNED_(4) juint _pi04_2d[] =
+{
+    0x54400000UL, 0x3fe921fbUL, 0x1a626331UL, 0x3dc0b461UL
+};
+
+ALIGNED_(4) juint _TWO_12H[] =
+{
+    0x00000000UL, 0x40b80000UL
+};
+
+ALIGNED_(2) jushort __4onpi_31l[] =
+{
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x836e, 0xa2f9,
+    0x40d8, 0x0000, 0x0000, 0x0000, 0x2a50, 0x9c88, 0x40b7, 0x0000, 0x0000, 0x0000,
+    0xabe8, 0xfe13, 0x4099, 0x0000, 0x0000, 0x0000, 0x6ee0, 0xfa9a, 0x4079, 0x0000,
+    0x0000, 0x0000, 0x9580, 0xdb62, 0x4058, 0x0000, 0x0000, 0x0000, 0x1c82, 0xc9e2,
+    0x403d, 0x0000, 0x0000, 0x0000, 0xb1c0, 0xff28, 0x4019, 0x0000, 0x0000, 0x0000,
+    0xef14, 0xaf7a, 0x3ffe, 0x0000, 0x0000, 0x0000, 0x48dc, 0xc36e, 0x3fdf, 0x0000,
+    0x0000, 0x0000, 0x3740, 0xe909, 0x3fbe, 0x0000, 0x0000, 0x0000, 0x924a, 0xb801,
+    0x3fa2, 0x0000, 0x0000, 0x0000, 0x3a32, 0xdd41, 0x3f83, 0x0000, 0x0000, 0x0000,
+    0x8778, 0x873f, 0x3f62, 0x0000, 0x0000, 0x0000, 0x1298, 0xb1cb, 0x3f44, 0x0000,
+    0x0000, 0x0000, 0xa208, 0x9cfb, 0x3f26, 0x0000, 0x0000, 0x0000, 0xbaec, 0xd7d4,
+    0x3f06, 0x0000, 0x0000, 0x0000, 0xd338, 0x8909, 0x3ee7, 0x0000, 0x0000, 0x0000,
+    0x68b8, 0xe04d, 0x3ec7, 0x0000, 0x0000, 0x0000, 0x4e64, 0xdf90, 0x3eaa, 0x0000,
+    0x0000, 0x0000, 0xc1a8, 0xeb1c, 0x3e89, 0x0000, 0x0000, 0x0000, 0x2720, 0xce7d,
+    0x3e6a, 0x0000, 0x0000, 0x0000, 0x77b8, 0x8bf1, 0x3e4b, 0x0000, 0x0000, 0x0000,
+    0xec7e, 0xe4a0, 0x3e2e, 0x0000, 0x0000, 0x0000, 0xffbc, 0xf12f, 0x3e0f, 0x0000,
+    0x0000, 0x0000, 0xfdc0, 0xb301, 0x3deb, 0x0000, 0x0000, 0x0000, 0xc5ac, 0x9788,
+    0x3dd1, 0x0000, 0x0000, 0x0000, 0x47da, 0x829b, 0x3db2, 0x0000, 0x0000, 0x0000,
+    0xd9e4, 0xa6cf, 0x3d93, 0x0000, 0x0000, 0x0000, 0x36e8, 0xf961, 0x3d73, 0x0000,
+    0x0000, 0x0000, 0xf668, 0xf463, 0x3d54, 0x0000, 0x0000, 0x0000, 0x5168, 0xf2ff,
+    0x3d35, 0x0000, 0x0000, 0x0000, 0x758e, 0xea4f, 0x3d17, 0x0000, 0x0000, 0x0000,
+    0xf17a, 0xebe5, 0x3cf8, 0x0000, 0x0000, 0x0000, 0x9cfa, 0x9e83, 0x3cd9, 0x0000,
+    0x0000, 0x0000, 0xa4ba, 0xe294, 0x3cba, 0x0000, 0x0000, 0x0000, 0xd7ec, 0x9afe,
+    0x3c9a, 0x0000, 0x0000, 0x0000, 0xae80, 0x8fc6, 0x3c79, 0x0000, 0x0000, 0x0000,
+    0x3304, 0x8560, 0x3c5c, 0x0000, 0x0000, 0x0000, 0x6d70, 0xdf8f, 0x3c3b, 0x0000,
+    0x0000, 0x0000, 0x3ef0, 0xafc3, 0x3c1e, 0x0000, 0x0000, 0x0000, 0xd0d8, 0x826b,
+    0x3bfe, 0x0000, 0x0000, 0x0000, 0x1c80, 0xed4f, 0x3bdd, 0x0000, 0x0000, 0x0000,
+    0x730c, 0xb0af, 0x3bc1, 0x0000, 0x0000, 0x0000, 0x6660, 0xc219, 0x3ba2, 0x0000,
+    0x0000, 0x0000, 0x940c, 0xabe2, 0x3b83, 0x0000, 0x0000, 0x0000, 0xdffc, 0x8408,
+    0x3b64, 0x0000, 0x0000, 0x0000, 0x6b98, 0xc402, 0x3b45, 0x0000, 0x0000, 0x0000,
+    0x1818, 0x9cc4, 0x3b26, 0x0000, 0x0000, 0x0000, 0x5390, 0xaab6, 0x3b05, 0x0000,
+    0x0000, 0x0000, 0xb070, 0xd464, 0x3ae9, 0x0000, 0x0000, 0x0000, 0x231a, 0x9ef0,
+    0x3aca, 0x0000, 0x0000, 0x0000, 0x0670, 0xd1f1, 0x3aaa, 0x0000, 0x0000, 0x0000,
+    0x7738, 0xd9f3, 0x3a8a, 0x0000, 0x0000, 0x0000, 0xa834, 0x8092, 0x3a6c, 0x0000,
+    0x0000, 0x0000, 0xb45c, 0xce23, 0x3a4d, 0x0000, 0x0000, 0x0000, 0x36e8, 0xb0e5,
+    0x3a2d, 0x0000, 0x0000, 0x0000, 0xd156, 0xaf44, 0x3a10, 0x0000, 0x0000, 0x0000,
+    0x9f52, 0x8c82, 0x39f1, 0x0000, 0x0000, 0x0000, 0x829c, 0xff83, 0x39d1, 0x0000,
+    0x0000, 0x0000, 0x7d06, 0xefc6, 0x39b3, 0x0000, 0x0000, 0x0000, 0x93e0, 0xb0b7,
+    0x3992, 0x0000, 0x0000, 0x0000, 0xedde, 0xc193, 0x3975, 0x0000, 0x0000, 0x0000,
+    0xbbc0, 0xcf49, 0x3952, 0x0000, 0x0000, 0x0000, 0xbdf0, 0xd63c, 0x3937, 0x0000,
+    0x0000, 0x0000, 0x1f34, 0x9f3a, 0x3918, 0x0000, 0x0000, 0x0000, 0x3f8e, 0xe579,
+    0x38f9, 0x0000, 0x0000, 0x0000, 0x90c8, 0xc3f8, 0x38d9, 0x0000, 0x0000, 0x0000,
+    0x48c0, 0xf8f8, 0x38b7, 0x0000, 0x0000, 0x0000, 0xed56, 0xafa6, 0x389c, 0x0000,
+    0x0000, 0x0000, 0x8218, 0xb969, 0x387d, 0x0000, 0x0000, 0x0000, 0x1852, 0xec57,
+    0x385e, 0x0000, 0x0000, 0x0000, 0x670c, 0xd674, 0x383e, 0x0000, 0x0000, 0x0000,
+    0xad40, 0xc2c4, 0x3820, 0x0000, 0x0000, 0x0000, 0x2e80, 0xa696, 0x3801, 0x0000,
+    0x0000, 0x0000, 0xd800, 0xc467, 0x37dc, 0x0000, 0x0000, 0x0000, 0x3c72, 0xc5ae,
+    0x37c3, 0x0000, 0x0000, 0x0000, 0xb006, 0xac69, 0x37a4, 0x0000, 0x0000, 0x0000,
+    0x34a0, 0x8cdf, 0x3782, 0x0000, 0x0000, 0x0000, 0x9ed2, 0xd25e, 0x3766, 0x0000,
+    0x0000, 0x0000, 0x6fec, 0xaaaa, 0x3747, 0x0000, 0x0000, 0x0000, 0x6040, 0xfb5c,
+    0x3726, 0x0000, 0x0000, 0x0000, 0x764c, 0xa3fc, 0x3708, 0x0000, 0x0000, 0x0000,
+    0xb254, 0x954e, 0x36e9, 0x0000, 0x0000, 0x0000, 0x3e1c, 0xf5dc, 0x36ca, 0x0000,
+    0x0000, 0x0000, 0x7b06, 0xc635, 0x36ac, 0x0000, 0x0000, 0x0000, 0xa8ba, 0xd738,
+    0x368d, 0x0000, 0x0000, 0x0000, 0x06cc, 0xb24e, 0x366d, 0x0000, 0x0000, 0x0000,
+    0x7108, 0xac76, 0x364f, 0x0000, 0x0000, 0x0000, 0x2324, 0xa7cb, 0x3630, 0x0000,
+    0x0000, 0x0000, 0xac40, 0xef15, 0x360f, 0x0000, 0x0000, 0x0000, 0xae46, 0xd516,
+    0x35f2, 0x0000, 0x0000, 0x0000, 0x615e, 0xe003, 0x35d3, 0x0000, 0x0000, 0x0000,
+    0x0cf0, 0xefe7, 0x35b1, 0x0000, 0x0000, 0x0000, 0xfb50, 0xf98c, 0x3595, 0x0000,
+    0x0000, 0x0000, 0x0abc, 0xf333, 0x3575, 0x0000, 0x0000, 0x0000, 0xdd60, 0xca3f,
+    0x3555, 0x0000, 0x0000, 0x0000, 0x7eb6, 0xd87f, 0x3538, 0x0000, 0x0000, 0x0000,
+    0x44f4, 0xb291, 0x3519, 0x0000, 0x0000, 0x0000, 0xff80, 0xc982, 0x34f6, 0x0000,
+    0x0000, 0x0000, 0x9de0, 0xd9b8, 0x34db, 0x0000, 0x0000, 0x0000, 0xcd42, 0x9366,
+    0x34bc, 0x0000, 0x0000, 0x0000, 0xbef0, 0xfaee, 0x349d, 0x0000, 0x0000, 0x0000,
+    0xdac4, 0xb6f1, 0x347d, 0x0000, 0x0000, 0x0000, 0xf140, 0x94de, 0x345d, 0x0000,
+    0x0000, 0x0000, 0xa218, 0x8b4b, 0x343e, 0x0000, 0x0000, 0x0000, 0x6380, 0xa135,
+    0x341e, 0x0000, 0x0000, 0x0000, 0xb184, 0x8cb2, 0x3402, 0x0000, 0x0000, 0x0000,
+    0x196e, 0xdc61, 0x33e3, 0x0000, 0x0000, 0x0000, 0x0c00, 0xde05, 0x33c4, 0x0000,
+    0x0000, 0x0000, 0xef9a, 0xbd38, 0x33a5, 0x0000, 0x0000, 0x0000, 0xc1a0, 0xdf00,
+    0x3385, 0x0000, 0x0000, 0x0000, 0x1090, 0x9973, 0x3365, 0x0000, 0x0000, 0x0000,
+    0x4882, 0x8301, 0x3348, 0x0000, 0x0000, 0x0000, 0x7abe, 0xadc7, 0x3329, 0x0000,
+    0x0000, 0x0000, 0x7cba, 0xec2b, 0x330a, 0x0000, 0x0000, 0x0000, 0xa520, 0x8f21,
+    0x32e9, 0x0000, 0x0000, 0x0000, 0x710c, 0x8d36, 0x32cc, 0x0000, 0x0000, 0x0000,
+    0x5212, 0xc6ed, 0x32ad, 0x0000, 0x0000, 0x0000, 0x7308, 0xfd76, 0x328d, 0x0000,
+    0x0000, 0x0000, 0x5014, 0xd548, 0x326f, 0x0000, 0x0000, 0x0000, 0xd3f2, 0xb499,
+    0x3250, 0x0000, 0x0000, 0x0000, 0x7f74, 0xa606, 0x3230, 0x0000, 0x0000, 0x0000,
+    0xf0a8, 0xd720, 0x3212, 0x0000, 0x0000, 0x0000, 0x185c, 0xe20f, 0x31f2, 0x0000,
+    0x0000, 0x0000, 0xa5a8, 0x8738, 0x31d4, 0x0000, 0x0000, 0x0000, 0xdd74, 0xcafb,
+    0x31b4, 0x0000, 0x0000, 0x0000, 0x98b6, 0xbd8e, 0x3196, 0x0000, 0x0000, 0x0000,
+    0xe9de, 0x977f, 0x3177, 0x0000, 0x0000, 0x0000, 0x67c0, 0x818d, 0x3158, 0x0000,
+    0x0000, 0x0000, 0xe52a, 0x9322, 0x3139, 0x0000, 0x0000, 0x0000, 0xe568, 0x9b6c,
+    0x3119, 0x0000, 0x0000, 0x0000, 0x2358, 0xaa0a, 0x30fa, 0x0000, 0x0000, 0x0000,
+    0xe480, 0xe13b, 0x30d9, 0x0000, 0x0000, 0x0000, 0x3024, 0x90a1, 0x30bd, 0x0000,
+    0x0000, 0x0000, 0x9620, 0xda30, 0x309d, 0x0000, 0x0000, 0x0000, 0x898a, 0xb388,
+    0x307f, 0x0000, 0x0000, 0x0000, 0xb24c, 0xc891, 0x3060, 0x0000, 0x0000, 0x0000,
+    0x8056, 0xf98b, 0x3041, 0x0000, 0x0000, 0x0000, 0x72a4, 0xa1ea, 0x3021, 0x0000,
+    0x0000, 0x0000, 0x6af8, 0x9488, 0x3001, 0x0000, 0x0000, 0x0000, 0xe00c, 0xdfcb,
+    0x2fe4, 0x0000, 0x0000, 0x0000, 0xeeec, 0xc941, 0x2fc4, 0x0000, 0x0000, 0x0000,
+    0x53e0, 0xe70f, 0x2fa4, 0x0000, 0x0000, 0x0000, 0x8f60, 0x9c07, 0x2f85, 0x0000,
+    0x0000, 0x0000, 0xb328, 0xc3e7, 0x2f68, 0x0000, 0x0000, 0x0000, 0x9404, 0xf8c7,
+    0x2f48, 0x0000, 0x0000, 0x0000, 0x38e0, 0xc99f, 0x2f29, 0x0000, 0x0000, 0x0000,
+    0x9778, 0xd984, 0x2f09, 0x0000, 0x0000, 0x0000, 0xe700, 0xd142, 0x2eea, 0x0000,
+    0x0000, 0x0000, 0xd904, 0x9443, 0x2ecd, 0x0000, 0x0000, 0x0000, 0xd4ba, 0xae7e,
+    0x2eae, 0x0000, 0x0000, 0x0000, 0x8e5e, 0x8524, 0x2e8f, 0x0000, 0x0000, 0x0000,
+    0xb550, 0xc9ed, 0x2e6e, 0x0000, 0x0000, 0x0000, 0x53b8, 0x8648, 0x2e51, 0x0000,
+    0x0000, 0x0000, 0xdae4, 0x87f9, 0x2e32, 0x0000, 0x0000, 0x0000, 0x2942, 0xd966,
+    0x2e13, 0x0000, 0x0000, 0x0000, 0x4f28, 0xcf3c, 0x2df3, 0x0000, 0x0000, 0x0000,
+    0xfa40, 0xc4ef, 0x2dd1, 0x0000, 0x0000, 0x0000, 0x4424, 0xbca7, 0x2db5, 0x0000,
+    0x0000, 0x0000, 0x2e62, 0xcdc5, 0x2d97, 0x0000, 0x0000, 0x0000, 0xed88, 0x996b,
+    0x2d78, 0x0000, 0x0000, 0x0000, 0x7c30, 0xd97d, 0x2d56, 0x0000, 0x0000, 0x0000,
+    0xed26, 0xbf6e, 0x2d3a, 0x0000, 0x0000, 0x0000, 0x2918, 0x921b, 0x2d1a, 0x0000,
+    0x0000, 0x0000, 0x4e24, 0xe84e, 0x2cfb, 0x0000, 0x0000, 0x0000, 0x6dc0, 0x92ec,
+    0x2cdd, 0x0000, 0x0000, 0x0000, 0x4f2c, 0xacf8, 0x2cbd, 0x0000, 0x0000, 0x0000,
+    0xc634, 0xf094, 0x2c9e, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe5d3, 0x2c7e, 0x0000,
+    0x0000, 0x0000, 0x2180, 0xa600, 0x2c5b, 0x0000, 0x0000, 0x0000, 0x8480, 0xd680,
+    0x2c3c, 0x0000, 0x0000, 0x0000, 0x8b24, 0xd63b, 0x2c22, 0x0000, 0x0000, 0x0000,
+    0x02e0, 0xaa47, 0x2c00, 0x0000, 0x0000, 0x0000, 0x9ad0, 0xee84, 0x2be3, 0x0000,
+    0x0000, 0x0000, 0xf7dc, 0xf699, 0x2bc6, 0x0000, 0x0000, 0x0000, 0xddde, 0xe490,
+    0x2ba7, 0x0000, 0x0000, 0x0000, 0x34a0, 0xb4fd, 0x2b85, 0x0000, 0x0000, 0x0000,
+    0x91b4, 0x8ef6, 0x2b68, 0x0000, 0x0000, 0x0000, 0xa3e0, 0xa2a7, 0x2b47, 0x0000,
+    0x0000, 0x0000, 0xcce4, 0x82b3, 0x2b2a, 0x0000, 0x0000, 0x0000, 0xe4be, 0x8207,
+    0x2b0c, 0x0000, 0x0000, 0x0000, 0x1d92, 0xab43, 0x2aed, 0x0000, 0x0000, 0x0000,
+    0xe818, 0xf9f6, 0x2acd, 0x0000, 0x0000, 0x0000, 0xff12, 0xba80, 0x2aaf, 0x0000,
+    0x0000, 0x0000, 0x5254, 0x8529, 0x2a90, 0x0000, 0x0000, 0x0000, 0x1b88, 0xe032,
+    0x2a71, 0x0000, 0x0000, 0x0000, 0x3248, 0xd86d, 0x2a50, 0x0000, 0x0000, 0x0000,
+    0x3140, 0xc9d5, 0x2a2e, 0x0000, 0x0000, 0x0000, 0x14e6, 0xbd47, 0x2a14, 0x0000,
+    0x0000, 0x0000, 0x5c10, 0xe544, 0x29f4, 0x0000, 0x0000, 0x0000, 0x9f50, 0x90b6,
+    0x29d4, 0x0000, 0x0000, 0x0000, 0x9850, 0xab55, 0x29b6, 0x0000, 0x0000, 0x0000,
+    0x2750, 0x9d07, 0x2998, 0x0000, 0x0000, 0x0000, 0x6700, 0x8bbb, 0x2973, 0x0000,
+    0x0000, 0x0000, 0x5dba, 0xed31, 0x295a, 0x0000, 0x0000, 0x0000, 0x61dc, 0x85fe,
+    0x293a, 0x0000, 0x0000, 0x0000, 0x9ba2, 0xd6b4, 0x291c, 0x0000, 0x0000, 0x0000,
+    0x2d30, 0xe3a5, 0x28fb, 0x0000, 0x0000, 0x0000, 0x6630, 0xb566, 0x28dd, 0x0000,
+    0x0000, 0x0000, 0x5ad4, 0xa829, 0x28bf, 0x0000, 0x0000, 0x0000, 0x89d8, 0xe290,
+    0x28a0, 0x0000, 0x0000, 0x0000, 0x3916, 0xc428, 0x2881, 0x0000, 0x0000, 0x0000,
+    0x0490, 0xbea4, 0x2860, 0x0000, 0x0000, 0x0000, 0xee06, 0x80ee, 0x2843, 0x0000,
+    0x0000, 0x0000, 0xfc00, 0xf327, 0x2820, 0x0000, 0x0000, 0x0000, 0xea40, 0xa871,
+    0x2800, 0x0000, 0x0000, 0x0000, 0x63d8, 0x9c26, 0x27e4, 0x0000, 0x0000, 0x0000,
+    0x07ba, 0xc0c9, 0x27c7, 0x0000, 0x0000, 0x0000, 0x3fa2, 0x9797, 0x27a8, 0x0000,
+    0x0000, 0x0000, 0x21c6, 0xfeca, 0x2789, 0x0000, 0x0000, 0x0000, 0xde40, 0x860d,
+    0x2768, 0x0000, 0x0000, 0x0000, 0x9cc8, 0x98ce, 0x2749, 0x0000, 0x0000, 0x0000,
+    0x3778, 0xa31c, 0x272a, 0x0000, 0x0000, 0x0000, 0xe778, 0xf6e2, 0x270b, 0x0000,
+    0x0000, 0x0000, 0x59b8, 0xf841, 0x26ed, 0x0000, 0x0000, 0x0000, 0x02e0, 0xad04,
+    0x26cd, 0x0000, 0x0000, 0x0000, 0x5a92, 0x9380, 0x26b0, 0x0000, 0x0000, 0x0000,
+    0xc740, 0x8886, 0x268d, 0x0000, 0x0000, 0x0000, 0x0680, 0xfaf8, 0x266c, 0x0000,
+    0x0000, 0x0000, 0xfb60, 0x897f, 0x2653, 0x0000, 0x0000, 0x0000, 0x8760, 0xf903,
+    0x2634, 0x0000, 0x0000, 0x0000, 0xad2a, 0xc2c8, 0x2615, 0x0000, 0x0000, 0x0000,
+    0x2d86, 0x8aef, 0x25f6, 0x0000, 0x0000, 0x0000, 0x1ef4, 0xe627, 0x25d6, 0x0000,
+    0x0000, 0x0000, 0x09e4, 0x8020, 0x25b7, 0x0000, 0x0000, 0x0000, 0x7548, 0xd227,
+    0x2598, 0x0000, 0x0000, 0x0000, 0x75dc, 0xfb5b, 0x2579, 0x0000, 0x0000, 0x0000,
+    0xea84, 0xc8b6, 0x255a, 0x0000, 0x0000, 0x0000, 0xe4d0, 0x8145, 0x253b, 0x0000,
+    0x0000, 0x0000, 0x3640, 0x9768, 0x251c, 0x0000, 0x0000, 0x0000, 0x246a, 0xccec,
+    0x24fe, 0x0000, 0x0000, 0x0000, 0x51d0, 0xa075, 0x24dd, 0x0000, 0x0000, 0x0000,
+    0x4638, 0xa385, 0x24bf, 0x0000, 0x0000, 0x0000, 0xd788, 0xd776, 0x24a1, 0x0000,
+    0x0000, 0x0000, 0x1370, 0x8997, 0x2482, 0x0000, 0x0000, 0x0000, 0x1e88, 0x9b67,
+    0x2462, 0x0000, 0x0000, 0x0000, 0x6c08, 0xd975, 0x2444, 0x0000, 0x0000, 0x0000,
+    0xfdb0, 0xcfc0, 0x2422, 0x0000, 0x0000, 0x0000, 0x3100, 0xc026, 0x2406, 0x0000,
+    0x0000, 0x0000, 0xc5b4, 0xae64, 0x23e6, 0x0000, 0x0000, 0x0000, 0x2280, 0xf687,
+    0x23c3, 0x0000, 0x0000, 0x0000, 0x2de0, 0x9006, 0x23a9, 0x0000, 0x0000, 0x0000,
+    0x24bc, 0xf631, 0x238a, 0x0000, 0x0000, 0x0000, 0xb8d4, 0xa975, 0x236b, 0x0000,
+    0x0000, 0x0000, 0xd9a4, 0xb949, 0x234b, 0x0000, 0x0000, 0x0000, 0xb54e, 0xbd39,
+    0x232d, 0x0000, 0x0000, 0x0000, 0x4aac, 0x9a52, 0x230e, 0x0000, 0x0000, 0x0000,
+    0xbbbc, 0xd085, 0x22ef, 0x0000, 0x0000, 0x0000, 0xdf18, 0xc633, 0x22cf, 0x0000,
+    0x0000, 0x0000, 0x16d0, 0xeca5, 0x22af, 0x0000, 0x0000, 0x0000, 0xf2a0, 0xdf6f,
+    0x228e, 0x0000, 0x0000, 0x0000, 0x8c44, 0xe86b, 0x2272, 0x0000, 0x0000, 0x0000,
+    0x35c0, 0xbbf4, 0x2253, 0x0000, 0x0000, 0x0000, 0x0c40, 0xdafb, 0x2230, 0x0000,
+    0x0000, 0x0000, 0x92dc, 0x9935, 0x2216, 0x0000, 0x0000, 0x0000, 0x0ca0, 0xbda6,
+    0x21f3, 0x0000, 0x0000, 0x0000, 0x5958, 0xa6fd, 0x21d6, 0x0000, 0x0000, 0x0000,
+    0xa3dc, 0x9d7f, 0x21b9, 0x0000, 0x0000, 0x0000, 0x79dc, 0xfcb5, 0x2199, 0x0000,
+    0x0000, 0x0000, 0xf264, 0xcebb, 0x217b, 0x0000, 0x0000, 0x0000, 0x0abe, 0x8308,
+    0x215c, 0x0000, 0x0000, 0x0000, 0x30ae, 0xb463, 0x213d, 0x0000, 0x0000, 0x0000,
+    0x6228, 0xb040, 0x211c, 0x0000, 0x0000, 0x0000, 0xc9b2, 0xf43b, 0x20ff, 0x0000,
+    0x0000, 0x0000, 0x3d8e, 0xa4b3, 0x20e0, 0x0000, 0x0000, 0x0000, 0x84e6, 0x8dab,
+    0x20c1, 0x0000, 0x0000, 0x0000, 0xa124, 0x9b74, 0x20a1, 0x0000, 0x0000, 0x0000,
+    0xc276, 0xd497, 0x2083, 0x0000, 0x0000, 0x0000, 0x6354, 0xa466, 0x2063, 0x0000,
+    0x0000, 0x0000, 0x8654, 0xaf0a, 0x2044, 0x0000, 0x0000, 0x0000, 0x1d20, 0xfa5c,
+    0x2024, 0x0000, 0x0000, 0x0000, 0xbcd0, 0xf3f0, 0x2004, 0x0000, 0x0000, 0x0000,
+    0xedf0, 0xf0b6, 0x1fe7, 0x0000, 0x0000, 0x0000, 0x45bc, 0x9182, 0x1fc9, 0x0000,
+    0x0000, 0x0000, 0xe254, 0xdc85, 0x1faa, 0x0000, 0x0000, 0x0000, 0xb898, 0xe9b1,
+    0x1f8a, 0x0000, 0x0000, 0x0000, 0x0ebe, 0xe6f0, 0x1f6c, 0x0000, 0x0000, 0x0000,
+    0xa9b8, 0xf584, 0x1f4c, 0x0000, 0x0000, 0x0000, 0x12e8, 0xdf6b, 0x1f2e, 0x0000,
+    0x0000, 0x0000, 0x9f9e, 0xcd55, 0x1f0f, 0x0000, 0x0000, 0x0000, 0x05a0, 0xec3a,
+    0x1eef, 0x0000, 0x0000, 0x0000, 0xd8e0, 0x96f8, 0x1ed1, 0x0000, 0x0000, 0x0000,
+    0x3bd4, 0xccc6, 0x1eb1, 0x0000, 0x0000, 0x0000, 0x4910, 0xb87b, 0x1e93, 0x0000,
+    0x0000, 0x0000, 0xbefc, 0xd40b, 0x1e73, 0x0000, 0x0000, 0x0000, 0x317e, 0xa406,
+    0x1e55, 0x0000, 0x0000, 0x0000, 0x6bb2, 0xc2b2, 0x1e36, 0x0000, 0x0000, 0x0000,
+    0xb87e, 0xbb78, 0x1e17, 0x0000, 0x0000, 0x0000, 0xa03c, 0xdbbd, 0x1df7, 0x0000,
+    0x0000, 0x0000, 0x5b6c, 0xe3c8, 0x1dd9, 0x0000, 0x0000, 0x0000, 0x8968, 0xca8e,
+    0x1dba, 0x0000, 0x0000, 0x0000, 0xc024, 0xe6ab, 0x1d9a, 0x0000, 0x0000, 0x0000,
+    0x4110, 0xd4eb, 0x1d7a, 0x0000, 0x0000, 0x0000, 0xa168, 0xbdb5, 0x1d5d, 0x0000,
+    0x0000, 0x0000, 0x012e, 0xa5fa, 0x1d3e, 0x0000, 0x0000, 0x0000, 0x6838, 0x9c1f,
+    0x1d1e, 0x0000, 0x0000, 0x0000, 0xa158, 0xaa76, 0x1d00, 0x0000, 0x0000, 0x0000,
+    0x090a, 0xbd95, 0x1ce1, 0x0000, 0x0000, 0x0000, 0xf73e, 0x8b6d, 0x1cc2, 0x0000,
+    0x0000, 0x0000, 0x5fda, 0xbcbf, 0x1ca3, 0x0000, 0x0000, 0x0000, 0xdbe8, 0xb89f,
+    0x1c84, 0x0000, 0x0000, 0x0000, 0x6e4c, 0x96c7, 0x1c64, 0x0000, 0x0000, 0x0000,
+    0x19c2, 0xf2a4, 0x1c46, 0x0000, 0x0000, 0x0000, 0xb800, 0xf855, 0x1c1e, 0x0000,
+    0x0000, 0x0000, 0x87fc, 0x85ff, 0x1c08, 0x0000, 0x0000, 0x0000, 0x1418, 0x839f,
+    0x1be9, 0x0000, 0x0000, 0x0000, 0x6186, 0xd9d8, 0x1bca, 0x0000, 0x0000, 0x0000,
+    0xf500, 0xabaa, 0x1ba6, 0x0000, 0x0000, 0x0000, 0x7b36, 0xdafe, 0x1b8c, 0x0000,
+    0x0000, 0x0000, 0xf394, 0xe6d8, 0x1b6c, 0x0000, 0x0000, 0x0000, 0x6efc, 0x9e55,
+    0x1b4e, 0x0000, 0x0000, 0x0000, 0x5e10, 0xc523, 0x1b2e, 0x0000, 0x0000, 0x0000,
+    0x8210, 0xb6f9, 0x1b0d, 0x0000, 0x0000, 0x0000, 0x9ab0, 0x96e3, 0x1af1, 0x0000,
+    0x0000, 0x0000, 0x3864, 0x92e7, 0x1ad1, 0x0000, 0x0000, 0x0000, 0x9878, 0xdc65,
+    0x1ab1, 0x0000, 0x0000, 0x0000, 0xfa20, 0xd6cb, 0x1a94, 0x0000, 0x0000, 0x0000,
+    0x6c00, 0xa4e4, 0x1a70, 0x0000, 0x0000, 0x0000, 0xab40, 0xb41b, 0x1a53, 0x0000,
+    0x0000, 0x0000, 0x43a4, 0x8ede, 0x1a37, 0x0000, 0x0000, 0x0000, 0x22e0, 0x9314,
+    0x1a15, 0x0000, 0x0000, 0x0000, 0x6170, 0xb949, 0x19f8, 0x0000, 0x0000, 0x0000,
+    0x6b00, 0xe056, 0x19d8, 0x0000, 0x0000, 0x0000, 0x9ba8, 0xa94c, 0x19b9, 0x0000,
+    0x0000, 0x0000, 0xfaa0, 0xaa16, 0x199b, 0x0000, 0x0000, 0x0000, 0x899a, 0xf627,
+    0x197d, 0x0000, 0x0000, 0x0000, 0x9f20, 0xfb70, 0x195d, 0x0000, 0x0000, 0x0000,
+    0xa4b8, 0xc176, 0x193e, 0x0000, 0x0000, 0x0000, 0xb21c, 0x85c3, 0x1920, 0x0000,
+    0x0000, 0x0000, 0x50d2, 0x9b19, 0x1901, 0x0000, 0x0000, 0x0000, 0xd4b0, 0xb708,
+    0x18e0, 0x0000, 0x0000, 0x0000, 0xfb88, 0xf510, 0x18c1, 0x0000, 0x0000, 0x0000,
+    0x31ec, 0xdc8d, 0x18a3, 0x0000, 0x0000, 0x0000, 0x3c00, 0xbff9, 0x1885, 0x0000,
+    0x0000, 0x0000, 0x5020, 0xc30b, 0x1862, 0x0000, 0x0000, 0x0000, 0xd4f0, 0xda0c,
+    0x1844, 0x0000, 0x0000, 0x0000, 0x20d2, 0x99a5, 0x1828, 0x0000, 0x0000, 0x0000,
+    0x852e, 0xd159, 0x1809, 0x0000, 0x0000, 0x0000, 0x7cd8, 0x97a1, 0x17e9, 0x0000,
+    0x0000, 0x0000, 0x423a, 0x997b, 0x17cb, 0x0000, 0x0000, 0x0000, 0xc1c0, 0xbe7d,
+    0x17a8, 0x0000, 0x0000, 0x0000, 0xe8bc, 0xdcdd, 0x178d, 0x0000, 0x0000, 0x0000,
+    0x8b28, 0xae06, 0x176e, 0x0000, 0x0000, 0x0000, 0x102e, 0xb8d4, 0x174f, 0x0000,
+    0x0000, 0x0000, 0xaa00, 0xaa5c, 0x172f, 0x0000, 0x0000, 0x0000, 0x51f0, 0x9fc0,
+    0x170e, 0x0000, 0x0000, 0x0000, 0xf858, 0xe181, 0x16f2, 0x0000, 0x0000, 0x0000,
+    0x91a8, 0x8162, 0x16d3, 0x0000, 0x0000, 0x0000, 0x5f40, 0xcb6f, 0x16b1, 0x0000,
+    0x0000, 0x0000, 0xbb50, 0xe55f, 0x1693, 0x0000, 0x0000, 0x0000, 0xacd2, 0xd895,
+    0x1676, 0x0000, 0x0000, 0x0000, 0xef30, 0x97bf, 0x1654, 0x0000, 0x0000, 0x0000,
+    0xf700, 0xb3d7, 0x1633, 0x0000, 0x0000, 0x0000, 0x3454, 0xa7b5, 0x1619, 0x0000,
+    0x0000, 0x0000, 0x6b00, 0xa929, 0x15f6, 0x0000, 0x0000, 0x0000, 0x9f04, 0x89f7,
+    0x15db, 0x0000, 0x0000, 0x0000, 0xad78, 0xd985, 0x15bc, 0x0000, 0x0000, 0x0000,
+    0xa46a, 0xae3f, 0x159d, 0x0000, 0x0000, 0x0000, 0x63a0, 0xd0da, 0x157c, 0x0000,
+    0x0000, 0x0000, 0x5e90, 0x817d, 0x155e, 0x0000, 0x0000, 0x0000, 0x1494, 0xb13f,
+    0x1540, 0x0000, 0x0000, 0x0000, 0x0090, 0x9c40, 0x1521, 0x0000, 0x0000, 0x0000,
+    0xdd70, 0xcc86, 0x1500, 0x0000, 0x0000, 0x0000, 0x64f8, 0xdb6f, 0x14e1, 0x0000,
+    0x0000, 0x0000, 0xe22c, 0xac17, 0x14c3, 0x0000, 0x0000, 0x0000, 0x60e0, 0xa9ad,
+    0x14a3, 0x0000, 0x0000, 0x0000, 0x4640, 0xd658, 0x1481, 0x0000, 0x0000, 0x0000,
+    0x6490, 0xa181, 0x1467, 0x0000, 0x0000, 0x0000, 0x1df4, 0xaaa2, 0x1447, 0x0000,
+    0x0000, 0x0000, 0xb94a, 0x8f61, 0x1429, 0x0000, 0x0000, 0x0000, 0x5198, 0x9d83,
+    0x1409, 0x0000, 0x0000, 0x0000, 0x0f7a, 0xa818, 0x13eb, 0x0000, 0x0000, 0x0000,
+    0xc45e, 0xc06c, 0x13cc, 0x0000, 0x0000, 0x0000, 0x4ec0, 0xfa29, 0x13a8, 0x0000,
+    0x0000, 0x0000, 0x6418, 0x8cad, 0x138c, 0x0000, 0x0000, 0x0000, 0xbcc8, 0xe7d1,
+    0x136f, 0x0000, 0x0000, 0x0000, 0xc934, 0xf9b0, 0x134f, 0x0000, 0x0000, 0x0000,
+    0x6ce0, 0x98df, 0x1331, 0x0000, 0x0000, 0x0000, 0x3516, 0xe5e9, 0x1312, 0x0000,
+    0x0000, 0x0000, 0xc6c0, 0xef8b, 0x12ef, 0x0000, 0x0000, 0x0000, 0xaf02, 0x913d,
+    0x12d4, 0x0000, 0x0000, 0x0000, 0xd230, 0xe1d5, 0x12b5, 0x0000, 0x0000, 0x0000,
+    0xfba8, 0xc232, 0x1295, 0x0000, 0x0000, 0x0000, 0x7ba4, 0xabeb, 0x1277, 0x0000,
+    0x0000, 0x0000, 0x6e5c, 0xc692, 0x1258, 0x0000, 0x0000, 0x0000, 0x76a2, 0x9756,
+    0x1239, 0x0000, 0x0000, 0x0000, 0xe180, 0xe423, 0x1214, 0x0000, 0x0000, 0x0000,
+    0x8c3c, 0x90f8, 0x11fb, 0x0000, 0x0000, 0x0000, 0x9f3c, 0x9fd2, 0x11dc, 0x0000,
+    0x0000, 0x0000, 0x53e0, 0xb73e, 0x11bd, 0x0000, 0x0000, 0x0000, 0x45be, 0x88d6,
+    0x119e, 0x0000, 0x0000, 0x0000, 0x111a, 0x8bc0, 0x117f, 0x0000, 0x0000, 0x0000,
+    0xe26a, 0xd7ff, 0x1160, 0x0000, 0x0000, 0x0000, 0xfb60, 0xdd8d, 0x113f, 0x0000,
+    0x0000, 0x0000, 0x9370, 0xc108, 0x1120, 0x0000, 0x0000, 0x0000, 0x9654, 0x8baf,
+    0x1103, 0x0000, 0x0000, 0x0000, 0xd6ec, 0xd6b9, 0x10e4, 0x0000, 0x0000, 0x0000,
+    0x23e4, 0xd7b7, 0x10c4, 0x0000, 0x0000, 0x0000, 0x1aa6, 0xa847, 0x10a6, 0x0000,
+    0x0000, 0x0000, 0xbee6, 0x9fef, 0x1087, 0x0000, 0x0000, 0x0000, 0x26d0, 0xa6eb,
+    0x1066, 0x0000, 0x0000, 0x0000, 0x5b86, 0xa880, 0x1049, 0x0000, 0x0000, 0x0000,
+    0x125c, 0xd971, 0x1029, 0x0000, 0x0000, 0x0000, 0x1f78, 0x9d18, 0x100a, 0x0000,
+    0x0000, 0x0000, 0x0e84, 0xb15b, 0x0feb, 0x0000, 0x0000, 0x0000, 0xd0c0, 0xc150,
+    0x0fcc, 0x0000, 0x0000, 0x0000, 0xa330, 0xc40c, 0x0fad, 0x0000, 0x0000, 0x0000,
+    0x5202, 0xfc2c, 0x0f8f, 0x0000, 0x0000, 0x0000, 0x3f7c, 0xecf5, 0x0f6f, 0x0000,
+    0x0000, 0x0000, 0xef44, 0xfdfd, 0x0f50, 0x0000, 0x0000, 0x0000, 0x3f6c, 0xab1b,
+    0x0f31, 0x0000, 0x0000, 0x0000, 0xf658, 0x89ec, 0x0f11, 0x0000, 0x0000, 0x0000,
+    0xbfc8, 0x9ba8, 0x0ef4, 0x0000, 0x0000, 0x0000, 0x3d40, 0xbe21, 0x0ed5, 0x0000,
+    0x0000, 0x0000, 0xbbc4, 0xc70d, 0x0eb6, 0x0000, 0x0000, 0x0000, 0x5158, 0xdb16,
+    0x0e96, 0x0000, 0x0000, 0x0000, 0xb5a8, 0xa8d8, 0x0e78, 0x0000, 0x0000, 0x0000,
+    0xcccc, 0xb40e, 0x0e58, 0x0000, 0x0000, 0x0000, 0x448c, 0xcb62, 0x0e3a, 0x0000,
+    0x0000, 0x0000, 0xf12a, 0x8aed, 0x0e1b, 0x0000, 0x0000, 0x0000, 0x79d0, 0xc59c,
+    0x0dfb, 0x0000, 0x0000, 0x0000, 0x06b4, 0xcdc9, 0x0ddd, 0x0000, 0x0000, 0x0000,
+    0xae70, 0xa979, 0x0dbe, 0x0000, 0x0000, 0x0000, 0x317c, 0xa8fb, 0x0d9e, 0x0000,
+    0x0000, 0x0000, 0x5fe0, 0x8a50, 0x0d7d, 0x0000, 0x0000, 0x0000, 0x70b6, 0xfdfa,
+    0x0d61, 0x0000, 0x0000, 0x0000, 0x1640, 0x9dc7, 0x0d41, 0x0000, 0x0000, 0x0000,
+    0x9a9c, 0xdc50, 0x0d23, 0x0000, 0x0000, 0x0000, 0x4fcc, 0x9a9b, 0x0d04, 0x0000,
+    0x0000, 0x0000, 0x7e48, 0x8f77, 0x0ce5, 0x0000, 0x0000, 0x0000, 0x84e4, 0xd4b9,
+    0x0cc6, 0x0000, 0x0000, 0x0000, 0x84e0, 0xbd10, 0x0ca6, 0x0000, 0x0000, 0x0000,
+    0x1b0a, 0xc8d9, 0x0c88, 0x0000, 0x0000, 0x0000, 0x6a48, 0xfc81, 0x0c68, 0x0000,
+    0x0000, 0x0000, 0x070a, 0xbef6, 0x0c4a, 0x0000, 0x0000, 0x0000, 0x8a70, 0xf096,
+    0x0c2b, 0x0000, 0x0000, 0x0000, 0xecc2, 0xc994, 0x0c0c, 0x0000, 0x0000, 0x0000,
+    0x1540, 0x9537, 0x0bea, 0x0000, 0x0000, 0x0000, 0x1b02, 0xab5b, 0x0bce, 0x0000,
+    0x0000, 0x0000, 0x5dc0, 0xb0c8, 0x0bad, 0x0000, 0x0000, 0x0000, 0xc928, 0xe034,
+    0x0b8f, 0x0000, 0x0000, 0x0000, 0x2d12, 0xb4b0, 0x0b71, 0x0000, 0x0000, 0x0000,
+    0x8fc2, 0xbb94, 0x0b52, 0x0000, 0x0000, 0x0000, 0xe236, 0xe22f, 0x0b33, 0x0000,
+    0x0000, 0x0000, 0xb97c, 0xbe9e, 0x0b13, 0x0000, 0x0000, 0x0000, 0xe1a6, 0xe16d,
+    0x0af5, 0x0000, 0x0000, 0x0000, 0xd330, 0xbaf0, 0x0ad6, 0x0000, 0x0000, 0x0000,
+    0xc0bc, 0xbbd0, 0x0ab7, 0x0000, 0x0000, 0x0000, 0x8e66, 0xdd9b, 0x0a98, 0x0000,
+    0x0000, 0x0000, 0xc95c, 0xf799, 0x0a79, 0x0000, 0x0000, 0x0000, 0xdac0, 0xbe4c,
+    0x0a55, 0x0000, 0x0000, 0x0000, 0xafc0, 0xc378, 0x0a37, 0x0000, 0x0000, 0x0000,
+    0xa880, 0xe341, 0x0a19, 0x0000, 0x0000, 0x0000, 0xc242, 0x81f6, 0x09fd, 0x0000,
+    0x0000, 0x0000, 0x7470, 0xc777, 0x09de, 0x0000, 0x0000, 0x0000, 0x62bc, 0xb684,
+    0x09be, 0x0000, 0x0000, 0x0000, 0x43ac, 0x8c58, 0x099f, 0x0000, 0x0000, 0x0000,
+    0xcc3c, 0xf9ac, 0x0981, 0x0000, 0x0000, 0x0000, 0x1526, 0xb670, 0x0962, 0x0000,
+    0x0000, 0x0000, 0xc9fe, 0xdf50, 0x0943, 0x0000, 0x0000, 0x0000, 0x6ae6, 0xc065,
+    0x0924, 0x0000, 0x0000, 0x0000, 0xb114, 0xcf29, 0x0905, 0x0000, 0x0000, 0x0000,
+    0xd388, 0x922a, 0x08e4, 0x0000, 0x0000, 0x0000, 0xcf54, 0xb926, 0x08c7, 0x0000,
+    0x0000, 0x0000, 0x3826, 0xe855, 0x08a8, 0x0000, 0x0000, 0x0000, 0xe7c8, 0x829b,
+    0x0888, 0x0000, 0x0000, 0x0000, 0x546c, 0xa903, 0x086a, 0x0000, 0x0000, 0x0000,
+    0x8768, 0x99cc, 0x0849, 0x0000, 0x0000, 0x0000, 0x00ac, 0xf529, 0x082b, 0x0000,
+    0x0000, 0x0000, 0x2658, 0x9f0b, 0x080c, 0x0000, 0x0000, 0x0000, 0xfe5c, 0x9e21,
+    0x07ee, 0x0000, 0x0000, 0x0000, 0x6da2, 0x9910, 0x07cf, 0x0000, 0x0000, 0x0000,
+    0x9220, 0xf9b3, 0x07b0, 0x0000, 0x0000, 0x0000, 0x3d90, 0xa541, 0x0791, 0x0000,
+    0x0000, 0x0000, 0x6e4c, 0xe7cc, 0x0771, 0x0000, 0x0000, 0x0000, 0xa8fa, 0xe80a,
+    0x0753, 0x0000, 0x0000, 0x0000, 0x4e14, 0xc3a7, 0x0734, 0x0000, 0x0000, 0x0000,
+    0xf7e0, 0xbad9, 0x0712, 0x0000, 0x0000, 0x0000, 0xfea0, 0xeff2, 0x06f5, 0x0000,
+    0x0000, 0x0000, 0xcef6, 0xbd48, 0x06d7, 0x0000, 0x0000, 0x0000, 0x7544, 0xf559,
+    0x06b7, 0x0000, 0x0000, 0x0000, 0x2388, 0xf655, 0x0698, 0x0000, 0x0000, 0x0000,
+    0xe900, 0xad56, 0x0676, 0x0000, 0x0000, 0x0000, 0x2cc0, 0x8437, 0x0659, 0x0000,
+    0x0000, 0x0000, 0x3068, 0xc544, 0x063b, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe73c,
+    0x061b, 0x0000, 0x0000, 0x0000, 0xee50, 0x9d49, 0x05fc, 0x0000, 0x0000, 0x0000,
+    0x93d2, 0x81f6, 0x05df, 0x0000, 0x0000, 0x0000, 0x941c, 0xadff, 0x05bf, 0x0000,
+    0x0000, 0x0000, 0x2ce2, 0x8e45, 0x05a1, 0x0000, 0x0000, 0x0000, 0x4a60, 0x95fd,
+    0x0581, 0x0000, 0x0000, 0x0000, 0x79f8, 0xb83a, 0x0563, 0x0000, 0x0000, 0x0000,
+    0xcb58, 0xa1f5, 0x0543, 0x0000, 0x0000, 0x0000, 0x2a3a, 0xdc36, 0x0525, 0x0000,
+    0x0000, 0x0000, 0x14ee, 0x890e, 0x0506, 0x0000, 0x0000, 0x0000, 0x8f20, 0xc432,
+    0x04e3, 0x0000, 0x0000, 0x0000, 0x8440, 0xb21d, 0x04c6, 0x0000, 0x0000, 0x0000,
+    0x5430, 0xf698, 0x04a7, 0x0000, 0x0000, 0x0000, 0x04ae, 0x8b20, 0x048a, 0x0000,
+    0x0000, 0x0000, 0x04d0, 0xe872, 0x046b, 0x0000, 0x0000, 0x0000, 0xc78e, 0x8893,
+    0x044c, 0x0000, 0x0000, 0x0000, 0x0f78, 0x9895, 0x042b, 0x0000, 0x0000, 0x0000,
+    0x11d4, 0xdf2e, 0x040d, 0x0000, 0x0000, 0x0000, 0xe84c, 0x89d5, 0x03ef, 0x0000,
+    0x0000, 0x0000, 0xf7be, 0x8a67, 0x03d0, 0x0000, 0x0000, 0x0000, 0x95d0, 0xc906,
+    0x03b1, 0x0000, 0x0000, 0x0000, 0x64ce, 0xd96c, 0x0392, 0x0000, 0x0000, 0x0000,
+    0x97ba, 0xa16f, 0x0373, 0x0000, 0x0000, 0x0000, 0x463c, 0xc51a, 0x0354, 0x0000,
+    0x0000, 0x0000, 0xef0a, 0xe93e, 0x0335, 0x0000, 0x0000, 0x0000, 0x526a, 0xa466,
+    0x0316, 0x0000, 0x0000, 0x0000, 0x4140, 0xa94d, 0x02f5, 0x0000, 0x0000, 0x0000,
+    0xb4ec, 0xce68, 0x02d8, 0x0000, 0x0000, 0x0000, 0x4fa2, 0x8490, 0x02b9, 0x0000,
+    0x0000, 0x0000, 0x4e60, 0xca98, 0x0298, 0x0000, 0x0000, 0x0000, 0x08dc, 0xe09c,
+    0x027a, 0x0000, 0x0000, 0x0000, 0x2b90, 0xc7e3, 0x025c, 0x0000, 0x0000, 0x0000,
+    0x5a7c, 0xf8ef, 0x023c, 0x0000, 0x0000, 0x0000, 0x5022, 0x9d58, 0x021e, 0x0000,
+    0x0000, 0x0000, 0x553a, 0xe242, 0x01ff, 0x0000, 0x0000, 0x0000, 0x7e6e, 0xb54d,
+    0x01e0, 0x0000, 0x0000, 0x0000, 0xd2d4, 0xa88c, 0x01c1, 0x0000, 0x0000, 0x0000,
+    0x75b6, 0xfe6d, 0x01a2, 0x0000, 0x0000, 0x0000, 0x3bb2, 0xf04c, 0x0183, 0x0000,
+    0x0000, 0x0000, 0xc2d0, 0xc046, 0x0163, 0x0000, 0x0000, 0x0000, 0x250c, 0xf9d6,
+    0x0145, 0x0000, 0x0000, 0x0000, 0xb7b4, 0x8a0d, 0x0126, 0x0000, 0x0000, 0x0000,
+    0x1a72, 0xe4f5, 0x0107, 0x0000, 0x0000, 0x0000, 0x825c, 0xa9b8, 0x00e8, 0x0000,
+    0x0000, 0x0000, 0x6c90, 0xc9ad, 0x00c6, 0x0000, 0x0000, 0x0000, 0x4d00, 0xd1bb,
+    0x00aa, 0x0000, 0x0000, 0x0000, 0xa4a0, 0xee01, 0x0087, 0x0000, 0x0000, 0x0000,
+    0x89a8, 0xbe9f, 0x006b, 0x0000, 0x0000, 0x0000, 0x038e, 0xc80c, 0x004d, 0x0000,
+    0x0000, 0x0000, 0xfe26, 0x8384, 0x002e, 0x0000, 0x0000, 0x0000, 0xcd90, 0xca57,
+    0x000e, 0x0000
+};
+
+void MacroAssembler::libm_reduce_pi04l(Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) {
+  Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12;
+  Label B1_13, B1_14, B1_15;
+
+  assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp);
+
+  address zero_none = (address)_zero_none;
+  address _4onpi_d = (address)__4onpi_d;
+  address TWO_32H = (address)_TWO_32H;
+  address pi04_3d = (address)_pi04_3d;
+  address pi04_5d = (address)_pi04_5d;
+  address SCALE = (address)_SCALE;
+  address zeros = (address)_zeros;
+  address pi04_2d = (address)_pi04_2d;
+  address TWO_12H = (address)_TWO_12H;
+  address _4onpi_31l = (address)__4onpi_31l;
+
+  bind(B1_1);
+  push(ebp);
+  movl(ebp, esp);
+  andl(esp, -16);
+  push(esi);
+  push(edi);
+  push(ebx);
+  subl(esp, 20);
+  movzwl(ebx, Address(ebp, 16));
+  andl(ebx, 32767);
+  movl(eax, Address(ebp, 20));
+  cmpl(ebx, 16413);
+  movl(esi, Address(ebp, 24));
+  movl(Address(esp, 4), eax);
+  jcc(Assembler::greaterEqual, B1_8);
+
+  bind(B1_2);
+  fld_x(Address(ebp, 8));
+  fld_d(ExternalAddress(_4onpi_d));    //0x6dc9c883UL, 0x3ff45f30UL
+  fmul(1);
+  fstp_x(Address(esp, 8));
+  movzwl(ecx, Address(esp, 16));
+  negl(ecx);
+  addl(ecx, 30);
+  movl(eax, Address(esp, 12));
+  shrl(eax);
+  cmpl(Address(esp, 4), 0);
+  jcc(Assembler::notEqual, B1_4);
+
+  bind(B1_3);
+  lea(ecx, Address(eax, 1));
+  andl(ecx, -2);
+  jmp(B1_5);
+
+  bind(B1_4);
+  movl(ecx, eax);
+  addl(eax, Address(esp, 4));
+  movl(edx, eax);
+  andl(edx, 1);
+  addl(ecx, edx);
+
+  bind(B1_5);
+  fld_d(ExternalAddress(TWO_32H));    //0x00000000UL, 0x41f80000UL
+  cmpl(ebx, 16400);
+  movl(Address(esp, 0), ecx);
+  fild_s(Address(esp, 0));
+  jcc(Assembler::greaterEqual, B1_7);
+
+  bind(B1_6);
+  fld_d(ExternalAddress(pi04_3d));    //0x54442d00UL, 0x3fe921fbUL
+  fmul(1);
+  fsubp(3);
+  fxch(1);
+  fmul(2);
+  fld_s(2);
+  fadd(1);
+  fsubrp(1);
+  fld_s(0);
+  fxch(1);
+  fsuba(3);
+  fld_d(ExternalAddress(8 + pi04_3d));    //0x98cc5180UL, 0x3ce84698UL
+  fmul(3);
+  fsuba(2);
+  fxch(1);
+  fsub(2);
+  fsubrp(1);
+  faddp(3);
+  fld_d(ExternalAddress(16 + pi04_3d));    //0xcbb5bf6cUL, 0xb9dfc8f8UL
+  fmulp(2);
+  fld_s(1);
+  fsubr(1);
+  fsuba(1);
+  fxch(2);
+  fsubp(1);
+  faddp(2);
+  fxch(1);
+  jmp(B1_15);
+
+  bind(B1_7);
+  fld_d(ExternalAddress(pi04_5d));    //0x54400000UL, 0x3fe921fbUL
+  fmul(1);
+  fsubp(3);
+  fxch(1);
+  fmul(2);
+  fld_s(2);
+  fadd(1);
+  fsubrp(1);
+  fld_s(0);
+  fxch(1);
+  fsuba(3);
+  fld_d(ExternalAddress(8 + pi04_5d));    //0x1a600000UL, 0x3dc0b461UL
+  fmul(3);
+  fsuba(2);
+  fxch(1);
+  fsub(2);
+  fsubrp(1);
+  faddp(3);
+  fld_d(ExternalAddress(16 + pi04_5d));    //0x2e000000UL, 0x3b93198aUL
+  fmul(2);
+  fld_s(0);
+  fsubr(2);
+  fsuba(2);
+  fxch(1);
+  fsubp(2);
+  fxch(1);
+  faddp(3);
+  fld_d(ExternalAddress(24 + pi04_5d));    //0x25200000UL, 0x396b839aUL
+  fmul(2);
+  fld_s(0);
+  fsubr(2);
+  fsuba(2);
+  fxch(1);
+  fsubp(2);
+  fxch(1);
+  faddp(3);
+  fld_d(ExternalAddress(32 + pi04_5d));    //0x533e63a0UL, 0x37027044UL
+  fmulp(2);
+  fld_s(1);
+  fsubr(1);
+  fsuba(1);
+  fxch(2);
+  fsubp(1);
+  faddp(2);
+  fxch(1);
+  jmp(B1_15);
+
+  bind(B1_8);
+  fld_x(Address(ebp, 8));
+  addl(ebx, -16417);
+  fmul_d(as_Address(ExternalAddress(SCALE)));    //0x00000000UL, 0x32600000UL
+  movl(eax, -2078209981);
+  imull(ebx);
+  addl(edx, ebx);
+  movl(ecx, ebx);
+  sarl(edx, 4);
+  sarl(ecx, 31);
+  subl(edx, ecx);
+  movl(eax, edx);
+  shll(eax, 5);
+  fstp_x(Address(ebp, 8));
+  fld_x(Address(ebp, 8));
+  subl(eax, edx);
+  movl(Address(ebp, 8), 0);
+  subl(ebx, eax);
+  fld_x(Address(ebp, 8));
+  cmpl(ebx, 17);
+  fsuba(1);
+  jcc(Assembler::less, B1_10);
+
+  bind(B1_9);
+  lea(eax, Address(noreg, edx, Address::times_8));
+  lea(ecx, Address(eax, edx, Address::times_4));
+  incl(edx);
+  fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
+  fmul(2);
+  fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
+  fmul(2);
+  fld_s(0);
+  fadd(2);
+  fsuba(2);
+  fxch(1);
+  faddp(2);
+  fld_s(1);
+  fadd(1);
+  fstp_x(Address(esp, 8));
+  andl(Address(esp, 8), -16777216);
+  fld_x(Address(esp, 8));
+  fsubp(1);
+  jmp(B1_11);
+
+  bind(B1_10);
+  fld_d(ExternalAddress(zeros));    //0x00000000UL, 0x00000000UL
+  fld_s(0);
+
+  bind(B1_11);
+  fld_s(0);
+  lea(eax, Address(noreg, edx, Address::times_8));
+  fld_s(3);
+  lea(edx, Address(eax, edx, Address::times_4));
+  fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1));
+  fmul(6);
+  movl(Address(esp, 0), edx);
+  fadda(2);
+  fxch(2);
+  fsuba(3);
+  fxch(2);
+  faddp(3);
+  fxch(2);
+  faddp(3);
+  fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1));
+  fmula(2);
+  fld_s(2);
+  fadd(2);
+  fld_s(0);
+  fxch(1);
+  fsubra(3);
+  fxch(3);
+  fchs();
+  faddp(4);
+  fxch(3);
+  faddp(4);
+  fxch(2);
+  fadd(3);
+  fxch(2);
+  fmul(5);
+  fadda(2);
+  fld_s(4);
+  fld_x(Address(24 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1));
+  fmula(1);
+  fxch(1);
+  fadda(4);
+  fxch(4);
+  fstp_x(Address(esp, 8));
+  movzwl(ebx, Address(esp, 16));
+  andl(ebx, 32767);
+  cmpl(ebx, 16415);
+  jcc(Assembler::greaterEqual, B1_13);
+
+  bind(B1_12);
+  negl(ebx);
+  addl(ebx, 30);
+  movl(ecx, ebx);
+  movl(eax, Address(esp, 12));
+  shrl(eax);
+  shll(eax);
+  movl(Address(esp, 12), eax);
+  movl(Address(esp, 8), 0);
+  shrl(eax);
+  jmp(B1_14);
+
+  bind(B1_13);
+  negl(ebx);
+  addl(ebx, 30);
+  movl(ecx, ebx);
+  movl(edx, Address(esp, 8));
+  shrl(edx);
+  shll(edx);
+  negl(ecx);
+  movl(eax, Address(esp, 12));
+  shll(eax);
+  movl(ecx, ebx);
+  movl(Address(esp, 8), edx);
+  shrl(edx);
+  orl(eax, edx);
+
+  bind(B1_14);
+  fld_x(Address(esp, 8));
+  addl(eax, Address(esp, 4));
+  fsubp(3);
+  fmul(6);
+  fld_s(4);
+  movl(edx, eax);
+  andl(edx, 1);
+  fadd(3);
+  movl(ecx, Address(esp, 0));
+  fsuba(3);
+  fxch(3);
+  faddp(5);
+  fld_s(1);
+  fxch(3);
+  fadd_d(Address(zero_none, RelocationHolder::none).plus_disp(edx, Address::times_8));
+  fadda(3);
+  fsub(3);
+  faddp(2);
+  fxch(1);
+  faddp(4);
+  fld_s(2);
+  fadd(2);
+  fsuba(2);
+  fxch(3);
+  faddp(2);
+  fxch(1);
+  faddp(3);
+  fld_s(0);
+  fadd(2);
+  fsuba(2);
+  fxch(1);
+  faddp(2);
+  fxch(1);
+  faddp(2);
+  fld_s(2);
+  fld_x(Address(36 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
+  fmula(1);
+  fld_s(1);
+  fadd(3);
+  fsuba(3);
+  fxch(2);
+  faddp(3);
+  fxch(2);
+  faddp(3);
+  fxch(1);
+  fmul(4);
+  fld_s(0);
+  fadd(2);
+  fsuba(2);
+  fxch(1);
+  faddp(2);
+  fxch(1);
+  faddp(2);
+  fld_s(2);
+  fld_x(Address(48 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
+  fmula(1);
+  fld_s(1);
+  fadd(3);
+  fsuba(3);
+  fxch(2);
+  faddp(3);
+  fxch(2);
+  faddp(3);
+  fld_s(3);
+  fxch(2);
+  fmul(5);
+  fld_x(Address(60 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
+  fmula(3);
+  fxch(3);
+  faddp(1);
+  fld_s(0);
+  fadd(2);
+  fsuba(2);
+  fxch(1);
+  faddp(2);
+  fxch(1);
+  faddp(3);
+  fld_s(3);
+  fxch(2);
+  fmul(5);
+  fld_x(Address(72 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
+  fmula(3);
+  fxch(3);
+  faddp(1);
+  fld_s(0);
+  fadd(2);
+  fsuba(2);
+  fxch(1);
+  faddp(2);
+  fxch(1);
+  faddp(3);
+  fxch(1);
+  fmulp(4);
+  fld_x(Address(84 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1));
+  fmulp(3);
+  fxch(2);
+  faddp(3);
+  fld_s(2);
+  fadd(2);
+  fld_d(ExternalAddress(TWO_32H));    //0x00000000UL, 0x41f80000UL
+  fmul(1);
+  fadda(1);
+  fsubp(1);
+  fsuba(2);
+  fxch(3);
+  faddp(2);
+  faddp(1);
+  fld_d(ExternalAddress(pi04_2d));    //0x54400000UL, 0x3fe921fbUL
+  fld_s(0);
+  fmul(2);
+  fxch(2);
+  fadd(3);
+  fxch(1);
+  fmulp(3);
+  fmul_d(as_Address(ExternalAddress(8 + pi04_2d)));    //0x1a626331UL, 0x3dc0b461UL
+  faddp(1);
+
+  bind(B1_15);
+  fld_d(ExternalAddress(TWO_12H));    //0x00000000UL, 0x40b80000UL
+  fld_s(2);
+  fadd(2);
+  fmula(1);
+  fstp_x(Address(esp, 8));
+  fld_x(Address(esp, 8));
+  fadd(1);
+  fsubrp(1);
+  fst_d(Address(esi, 0));
+  fsubp(2);
+  faddp(1);
+  fstp_d(Address(esi, 8));
+  addl(esp, 20);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+}
+
+ALIGNED_(16) juint StubRoutines::x86::_L_2il0floatpacket_0[] =
+{
+    0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_Pi4Inv[] =
+{
+    0x6dc9c883UL, 0x3ff45f30UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_Pi4x3[] =
+{
+    0x54443000UL, 0xbfe921fbUL, 0x3b39a000UL, 0x3d373dcbUL, 0xe0e68948UL,
+    0xba845c06UL
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_Pi4x4[] =
+{
+    0x54400000UL, 0xbfe921fbUL, 0x1a600000UL, 0xbdc0b461UL, 0x2e000000UL,
+    0xbb93198aUL, 0x252049c1UL, 0xb96b839aUL
+};
+
+ALIGNED_(16) jushort _SP[] =
+{
+    0xaaab, 0xaaaa, 0xaaaa, 0xaaaa, 0xbffc, 0x0000, 0x8887, 0x8888, 0x8888, 0x8888,
+    0x3ff8, 0x0000, 0xc527, 0x0d00, 0x00d0, 0xd00d, 0xbff2, 0x0000, 0x45f6, 0xb616,
+    0x1d2a, 0xb8ef, 0x3fec, 0x0000, 0x825b, 0x3997, 0x2b3f, 0xd732, 0xbfe5, 0x0000,
+    0xbf33, 0x8bb4, 0x2fda, 0xb092, 0x3fde, 0x0000, 0x44a6, 0xed1a, 0x29ef, 0xd73e,
+    0xbfd6, 0x0000, 0x8610, 0x307f, 0x62a1, 0xc921, 0x3fce, 0x0000
+};
+
+ALIGNED_(16) jushort _CP[] =
+{
+    0x0000, 0x0000, 0x0000, 0x8000, 0xbffe, 0x0000, 0xaaa5, 0xaaaa, 0xaaaa, 0xaaaa,
+    0x3ffa, 0x0000, 0x9c2f, 0x0b60, 0x60b6, 0xb60b, 0xbff5, 0x0000, 0xf024, 0x0cac,
+    0x00d0, 0xd00d, 0x3fef, 0x0000, 0x03fe, 0x3f65, 0x7dbb, 0x93f2, 0xbfe9, 0x0000,
+    0xd84d, 0xadee, 0xc698, 0x8f76, 0x3fe2, 0x0000, 0xdaba, 0xfe79, 0xea36, 0xc9c9,
+    0xbfda, 0x0000, 0x3ac6, 0x0ba0, 0x07ce, 0xd585, 0x3fd2, 0x0000
+};
+
+ALIGNED_(16) juint StubRoutines::x86::_ones[] =
+{
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xbff00000UL
+};
+
+void MacroAssembler::libm_sincos_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) {
+  Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12;
+  Label B1_13, B1_14, B1_15, B1_16, B1_17, B1_18, B1_19, B1_20, B1_21, B1_22, B1_23;
+  Label B1_24, B1_25, B1_26, B1_27, B1_28, B1_29, B1_30, B1_31, B1_32, B1_33, B1_34;
+  Label B1_35, B1_36, B1_37, B1_38, B1_39, B1_40, B1_41, B1_42, B1_43, B1_44, B1_45, B1_46;
+
+  assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp);
+
+  address L_2il0floatpacket_0 = StubRoutines::x86::_L_2il0floatpacket_0_addr();
+  address Pi4Inv = StubRoutines::x86::_Pi4Inv_addr();
+  address Pi4x3 = StubRoutines::x86::_Pi4x3_addr();
+  address Pi4x4 = StubRoutines::x86::_Pi4x4_addr();
+  address ones = StubRoutines::x86::_ones_addr();
+  address CP = (address)_CP;
+  address SP = (address)_SP;
+
+  bind(B1_1);
+  push(ebp);
+  movl(ebp, esp);
+  andl(esp, -64);
+  push(esi);
+  push(edi);
+  push(ebx);
+  subl(esp, 52);
+  movl(eax, Address(ebp, 16));
+  movl(edx, Address(ebp, 20));
+  movl(Address(esp, 32), eax);
+  movl(Address(esp, 36), edx);
+
+  bind(B1_2);
+  fnstcw(Address(esp, 30));
+
+  bind(B1_3);
+  movsd(xmm1, Address(ebp, 8));
+  movl(esi, Address(ebp, 12));
+  movl(eax, esi);
+  andl(eax, 2147483647);
+  andps(xmm1, ExternalAddress(L_2il0floatpacket_0));    //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL
+  shrl(esi, 31);
+  movl(Address(esp, 40), eax);
+  cmpl(eax, 1104150528);
+  movsd(Address(ebp, 8), xmm1);
+  jcc(Assembler::aboveEqual, B1_11);
+
+  bind(B1_4);
+  movsd(xmm0, ExternalAddress(Pi4Inv));    //0x6dc9c883UL, 0x3ff45f30UL
+  mulsd(xmm0, xmm1);
+  movzwl(edx, Address(esp, 30));
+  movl(eax, edx);
+  andl(eax, 768);
+  movsd(Address(esp, 0), xmm0);
+  cmpl(eax, 768);
+  jcc(Assembler::equal, B1_42);
+
+  bind(B1_5);
+  orl(edx, -64768);
+  movw(Address(esp, 28), edx);
+
+  bind(B1_6);
+  fldcw(Address(esp, 28));
+
+  bind(B1_7);
+  movsd(xmm1, Address(ebp, 8));
+  movl(ebx, 1);
+
+  bind(B1_8);
+  movl(Address(esp, 12), ebx);
+  movl(ebx, Address(esp, 4));
+  movl(eax, ebx);
+  movl(Address(esp, 8), esi);
+  movl(esi, ebx);
+  shrl(esi, 20);
+  andl(eax, 1048575);
+  movl(ecx, esi);
+  orl(eax, 1048576);
+  negl(ecx);
+  movl(edx, eax);
+  addl(ecx, 19);
+  addl(esi, 13);
+  movl(Address(esp, 24), ecx);
+  shrl(edx);
+  movl(ecx, esi);
+  shll(eax);
+  movl(ecx, Address(esp, 24));
+  movl(esi, Address(esp, 0));
+  shrl(esi);
+  orl(eax, esi);
+  cmpl(ebx, 1094713344);
+  movsd(Address(esp, 16), xmm1);
+  fld_d(Address(esp, 16));
+  cmov32(Assembler::below, eax, edx);
+  movl(esi, Address(esp, 8));
+  lea(edx, Address(eax, 1));
+  movl(ebx, edx);
+  andl(ebx, -2);
+  movl(Address(esp, 16), ebx);
+  fild_s(Address(esp, 16));
+  movl(ebx, Address(esp, 12));
+  cmpl(Address(esp, 40), 1094713344);
+  jcc(Assembler::aboveEqual, B1_10);
+
+  bind(B1_9);
+  fld_d(ExternalAddress(Pi4x3));    //0x54443000UL, 0xbfe921fbUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(8 + Pi4x3));    //0x3b39a000UL, 0x3d373dcbUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(16 + Pi4x3));    //0xe0e68948UL, 0xba845c06UL
+  fmulp(1);
+  faddp(1);
+  jmp(B1_17);
+
+  bind(B1_10);
+  fld_d(ExternalAddress(Pi4x4));    //0x54400000UL, 0xbfe921fbUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(8 + Pi4x4));    //0x1a600000UL, 0xbdc0b461UL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(16 + Pi4x4));    //0x2e000000UL, 0xbb93198aUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(24 + Pi4x4));    //0x252049c1UL, 0xb96b839aUL
+  fmulp(1);
+  faddp(1);
+  jmp(B1_17);
+
+  bind(B1_11);
+  movzwl(edx, Address(esp, 30));
+  movl(eax, edx);
+  andl(eax, 768);
+  cmpl(eax, 768);
+  jcc(Assembler::equal, B1_43);
+  bind(B1_12);
+  orl(edx, -64768);
+  movw(Address(esp, 28), edx);
+
+  bind(B1_13);
+  fldcw(Address(esp, 28));
+
+  bind(B1_14);
+  movsd(xmm1, Address(ebp, 8));
+  movl(ebx, 1);
+
+  bind(B1_15);
+  movsd(Address(esp, 16), xmm1);
+  fld_d(Address(esp, 16));
+  addl(esp, -32);
+  lea(eax, Address(esp, 32));
+  fstp_x(Address(esp, 0));
+  movl(Address(esp, 12), 0);
+  movl(Address(esp, 16), eax);
+  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_reduce_pi04l())));
+
+  bind(B1_46);
+  addl(esp, 32);
+
+  bind(B1_16);
+  fld_d(Address(esp, 0));
+  lea(edx, Address(eax, 1));
+  fld_d(Address(esp, 8));
+  faddp(1);
+
+  bind(B1_17);
+  movl(ecx, edx);
+  addl(eax, 3);
+  shrl(ecx, 2);
+  andl(ecx, 1);
+  shrl(eax, 2);
+  xorl(esi, ecx);
+  movl(ecx, Address(esp, 36));
+  andl(eax, 1);
+  andl(ecx, 3);
+  cmpl(ecx, 3);
+  jcc(Assembler::notEqual, B1_25);
+
+  bind(B1_18);
+  fld_x(ExternalAddress(84 + SP));    //0x8610, 0x307f, 0x62
+  fld_s(1);
+  fmul((2));
+  testb(edx, 2);
+  fmula((1));
+  fld_x(ExternalAddress(72 + SP));    //0x44a6, 0xed1a, 0x29
+  faddp(2);
+  fmula(1);
+  fld_x(ExternalAddress(60 + SP));    //0xbf33, 0x8bb4, 0x2f
+  faddp(2);
+  fmula(1);
+  fld_x(ExternalAddress(48 + SP));    //0x825b, 0x3997, 0x2b
+  faddp(2);
+  fmula(1);
+  fld_x(ExternalAddress(36 + SP));    //0x45f6, 0xb616, 0x1d
+  faddp(2);
+  fmula(1);
+  fld_x(ExternalAddress(24 + SP));    //0xc527, 0x0d00, 0x00
+  faddp(2);
+  fmula(1);
+  fld_x(ExternalAddress(12 + SP));    //0x8887, 0x8888, 0x88
+  faddp(2);
+  fmula(1);
+  fld_x(ExternalAddress(SP));    //0xaaab, 0xaaaa, 0xaa
+  faddp(2);
+  fmula(1);
+  fld_x(ExternalAddress(84 + CP));    //0x3ac6, 0x0ba0, 0x07
+  fmul(1);
+  fld_x(ExternalAddress(72 + CP));    //0xdaba, 0xfe79, 0xea
+  faddp(1);
+  fmul(1);
+  fld_x(ExternalAddress(62 + CP));    //0xd84d, 0xadee, 0xc6
+  faddp(1);
+  fmul(1);
+  fld_x(ExternalAddress(48 + CP));    //0x03fe, 0x3f65, 0x7d
+  faddp(1);
+  fmul(1);
+  fld_x(ExternalAddress(36 + CP));    //0xf024, 0x0cac, 0x00
+  faddp(1);
+  fmul(1);
+  fld_x(ExternalAddress(24 + CP));    //0x9c2f, 0x0b60, 0x60
+  faddp(1);
+  fmul(1);
+  fld_x(ExternalAddress(12 + CP));    //0xaaa5, 0xaaaa, 0xaa
+  faddp(1);
+  fmul(1);
+  fld_x(ExternalAddress(CP));    //0x0000, 0x0000, 0x00
+  faddp(1);
+  fmulp(1);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(esi, Address::times_8));
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  jcc(Assembler::equal, B1_22);
+
+  bind(B1_19);
+  fmulp(4);
+  testl(ebx, ebx);
+  fxch(2);
+  fmul(3);
+  movl(eax, Address(esp, 2));
+  faddp(3);
+  fxch(2);
+  fstp_d(Address(eax, 0));
+  fmula(1);
+  faddp(1);
+  fstp_d(Address(eax, 8));
+  jcc(Assembler::equal, B1_21);
+
+  bind(B1_20);
+  fldcw(Address(esp, 30));
+
+  bind(B1_21);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_22);
+  fxch(1);
+  fmulp(4);
+  testl(ebx, ebx);
+  fxch(2);
+  fmul(3);
+  movl(eax, Address(esp, 32));
+  faddp(3);
+  fxch(2);
+  fstp_d(Address(eax, 8));
+  fmula(1);
+  faddp(1);
+  fstp_d(Address(eax, 0));
+  jcc(Assembler::equal, B1_24);
+
+  bind(B1_23);
+  fldcw(Address(esp, 30));
+
+  bind(B1_24);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_25);
+  testb(Address(esp, 36), 2);
+  jcc(Assembler::equal, B1_33);
+
+  bind(B1_26);
+  fld_s(0);
+  testb(edx, 2);
+  fmul(1);
+  fld_s(0);
+  fmul(1);
+  jcc(Assembler::equal, B1_30);
+
+  bind(B1_27);
+  fstp_d(2);
+  fld_x(ExternalAddress(84 + CP));    //0x3ac6, 0x0ba0, 0x07
+  testl(ebx, ebx);
+  fmul(2);
+  fld_x(ExternalAddress(72 + CP));    //0xdaba, 0xfe79, 0xea
+  fmul(3);
+  fld_x(ExternalAddress(60 + CP));    //0xd84d, 0xadee, 0xc6
+  movl(eax, Address(rsp, 32));
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(48 + CP));    //0x03fe, 0x3f65, 0x7d
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(36 + CP));    //0xf024, 0x0cac, 0x00
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(24 + CP));    //0x9c2f, 0x0b60, 0x60
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(12 + CP));    //0xaaa5, 0xaaaa, 0xaa
+  faddp(2);
+  fxch(1);
+  fmulp(3);
+  fld_x(ExternalAddress(CP));    //0x0000, 0x0000, 0x00
+  faddp(1);
+  fmulp(1);
+  faddp(1);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8));
+  fmula(1);
+  faddp(1);
+  fstp_d(Address(eax, 8));
+  jcc(Assembler::equal, B1_29);
+
+  bind(B1_28);
+  fldcw(Address(esp, 30));
+
+  bind(B1_29);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_30);
+  fld_x(ExternalAddress(84 + SP));    //0x8610, 0x307f, 0x62
+  testl(ebx, ebx);
+  fmul(1);
+  fld_x(ExternalAddress(72 + SP));    //0x44a6, 0xed1a, 0x29
+  fmul(2);
+  fld_x(ExternalAddress(60 + SP));    //0xbf33, 0x8bb4, 0x2f
+  movl(eax, Address(rsp, 32));
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(48 + SP));    //0x825b, 0x3997, 0x2b
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(36 + SP));    //0x45f6, 0xb616, 0x1d
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(24 + SP));    //0xc527, 0x0d00, 0x00
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(12 + SP));    //0x8887, 0x8888, 0x88
+  faddp(2);
+  fxch(1);
+  fmulp(2);
+  fld_x(ExternalAddress(SP));    //0xaaab, 0xaaaa, 0xaa
+  faddp(1);
+  fmulp(2);
+  faddp(1);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8));
+  fmulp(2);
+  fmul(1);
+  faddp(1);
+  fstp_d(Address(eax, 8));
+  jcc(Assembler::equal, B1_32);
+
+  bind(B1_31);
+  fldcw(Address(esp, 30));
+
+  bind(B1_32);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_33);
+  testb(Address(esp, 36), 1);
+  jcc(Assembler::equal, B1_41);
+
+  bind(B1_34);
+  fld_s(0);
+  testb(edx, 2);
+  fmul(1);
+  fld_s(0);
+  fmul(1);
+  jcc(Assembler::equal, B1_38);
+
+  bind(B1_35);
+  fld_x(ExternalAddress(84 + SP));    //0x8610, 0x307f, 0x62
+  testl(ebx, ebx);
+  fmul(1);
+  fld_x(ExternalAddress(72 + SP));    //0x44a6, 0xed1a, 0x29
+  fmul(2);
+  fld_x(ExternalAddress(60 + SP));    //0xbf33, 0x8bb4, 0x2f
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(48 + SP));    //0x825b, 0x3997, 0x2b
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(36 + SP));    //0x45f6, 0xb616, 0x1d
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(24 + SP));    //0xc527, 0x0d00, 0x00
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(12 + SP));    //0x8887, 0x8888, 0x88
+  faddp(2);
+  fxch(1);
+  fmulp(2);
+  fld_x(ExternalAddress(SP));    //0xaaab, 0xaaaa, 0xaa
+  faddp(1);
+  fmulp(2);
+  faddp(1);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmulp(2);
+  fmul(1);
+  movl(eax, Address(esp, 32));
+  faddp(1);
+  fstp_d(Address(eax, 0));
+  jcc(Assembler::equal, B1_37);
+
+  bind(B1_36);
+  fldcw(Address(esp, 30));
+
+  bind(B1_37);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_38);
+  fstp_d(2);
+  fld_x(ExternalAddress(84 + CP));    //0x3ac6, 0x0ba0, 0x07
+  testl(ebx, ebx);
+  fmul(2);
+  fld_x(ExternalAddress(72 + CP));    //0xdaba, 0xfe79, 0xea
+  fmul(3);
+  fld_x(ExternalAddress(60 + CP));    //0xd84d, 0xadee, 0xc6
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(48 + CP));    //0x03fe, 0x3f65, 0x7d
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(36 + CP));    //0xf024, 0x0cac, 0x00
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(24 + CP));    //0x9c2f, 0x0b60, 0x60
+  faddp(2);
+  fxch(1);
+  fmul(3);
+  fld_x(ExternalAddress(12 + CP));    //0xaaa5, 0xaaaa, 0xaa
+  faddp(2);
+  fxch(1);
+  fmulp(3);
+  fld_x(ExternalAddress(CP));    //0x0000, 0x0000, 0x00
+  faddp(1);
+  fmulp(1);
+  faddp(1);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmula(1);
+  movl(eax, Address(esp, 32));
+  faddp(1);
+  fstp_d(Address(eax, 0));
+  jcc(Assembler::equal, B1_40);
+
+  bind(B1_39);
+  fldcw(Address(esp, 30));
+  bind(B1_40);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+  bind(B1_41);
+  fstp_d(0);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+  bind(B1_42);
+  xorl(ebx, ebx);
+  jmp(B1_8);
+  bind(B1_43);
+  xorl(ebx, ebx);
+  jmp(B1_15);
+}
+
+ALIGNED_(16) juint _static_const_table_sin[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL,
+    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
+    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL,
+    0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL,
+    0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL,
+    0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL,
+    0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL,
+    0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL,
+    0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL,
+    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
+    0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL,
+    0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL,
+    0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL,
+    0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL,
+    0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL,
+    0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL,
+    0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL,
+    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
+    0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL,
+    0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL,
+    0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL,
+    0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL,
+    0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL,
+    0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL,
+    0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL,
+    0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL,
+    0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL,
+    0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL,
+    0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL,
+    0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL,
+    0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL,
+    0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL,
+    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL,
+    0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL,
+    0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL,
+    0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL,
+    0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL,
+    0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL,
+    0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL,
+    0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL,
+    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL,
+    0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL,
+    0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL,
+    0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL,
+    0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL,
+    0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL,
+    0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL,
+    0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL,
+    0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL,
+    0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
+    0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL,
+    0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL,
+    0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL,
+    0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL,
+    0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL,
+    0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL,
+    0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL,
+    0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
+    0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL,
+    0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL,
+    0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL,
+    0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL,
+    0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL,
+    0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL,
+    0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL,
+    0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
+    0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL,
+    0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL,
+    0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL,
+    0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL,
+    0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL,
+    0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL,
+    0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL,
+    0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL,
+    0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL,
+    0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL,
+    0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL,
+    0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL,
+    0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL,
+    0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL,
+    0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL,
+    0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL,
+    0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL,
+    0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL,
+    0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL,
+    0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL,
+    0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL,
+    0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL,
+    0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL,
+    0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL,
+    0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL,
+    0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL,
+    0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL,
+    0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL,
+    0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL,
+    0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL,
+    0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL,
+    0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL,
+    0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL,
+    0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL,
+    0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL,
+    0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL,
+    0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x43600000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3c800000UL, 0x00000000UL,
+    0x00000000UL, 0xffffffffUL, 0x3fefffffUL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x80000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x3fe00000UL,
+    0x00000000UL, 0x3fe00000UL
+};
+
+void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register edx) {
+
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, start;
+  assert_different_registers(eax, ebx, edx);
+  address static_const_table_sin = (address)_static_const_table_sin;
+
+  bind(start);
+  subl(rsp, 120);
+  movl(Address(rsp, 56), ebx);
+  lea(ebx, ExternalAddress(static_const_table_sin));
+  movsd(xmm0, Address(rsp, 128));
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  subl(eax, 12336);
+  cmpl(eax, 4293);
+  jcc(Assembler::above, L_2TAG_PACKET_0_0_2);
+  movsd(xmm1, Address(ebx, 2160));
+  mulsd(xmm1, xmm0);
+  movsd(xmm5, Address(ebx, 2272));
+  movdqu(xmm4, Address(ebx, 2256));
+  pand(xmm4, xmm0);
+  por(xmm5, xmm4);
+  movsd(xmm3, Address(ebx, 2128));
+  movdqu(xmm2, Address(ebx, 2112));
+  addpd(xmm1, xmm5);
+  cvttsd2sil(edx, xmm1);
+  cvtsi2sdl(xmm1, edx);
+  mulsd(xmm3, xmm1);
+  unpcklpd(xmm1, xmm1);
+  addl(edx, 1865216);
+  movdqu(xmm4, xmm0);
+  andl(edx, 63);
+  movdqu(xmm5, Address(ebx, 2096));
+  lea(eax, Address(ebx, 0));
+  shll(edx, 5);
+  addl(eax, edx);
+  mulpd(xmm2, xmm1);
+  subsd(xmm0, xmm3);
+  mulsd(xmm1, Address(ebx, 2144));
+  subsd(xmm4, xmm3);
+  movsd(xmm7, Address(eax, 8));
+  unpcklpd(xmm0, xmm0);
+  movapd(xmm3, xmm4);
+  subsd(xmm4, xmm2);
+  mulpd(xmm5, xmm0);
+  subpd(xmm0, xmm2);
+  movdqu(xmm6, Address(ebx, 2064));
+  mulsd(xmm7, xmm4);
+  subsd(xmm3, xmm4);
+  mulpd(xmm5, xmm0);
+  mulpd(xmm0, xmm0);
+  subsd(xmm3, xmm2);
+  movdqu(xmm2, Address(eax, 0));
+  subsd(xmm1, xmm3);
+  movsd(xmm3, Address(eax, 24));
+  addsd(xmm2, xmm3);
+  subsd(xmm7, xmm2);
+  mulsd(xmm2, xmm4);
+  mulpd(xmm6, xmm0);
+  mulsd(xmm3, xmm4);
+  mulpd(xmm2, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm5, Address(ebx, 2080));
+  mulsd(xmm4, Address(eax, 0));
+  addpd(xmm6, Address(ebx, 2048));
+  mulpd(xmm5, xmm0);
+  movapd(xmm0, xmm3);
+  addsd(xmm3, Address(eax, 8));
+  mulpd(xmm1, xmm7);
+  movapd(xmm7, xmm4);
+  addsd(xmm4, xmm3);
+  addpd(xmm6, xmm5);
+  movsd(xmm5, Address(eax, 8));
+  subsd(xmm5, xmm3);
+  subsd(xmm3, xmm4);
+  addsd(xmm1, Address(eax, 16));
+  mulpd(xmm6, xmm2);
+  addsd(xmm5, xmm0);
+  addsd(xmm3, xmm7);
+  addsd(xmm1, xmm5);
+  addsd(xmm1, xmm3);
+  addsd(xmm1, xmm6);
+  unpckhpd(xmm6, xmm6);
+  addsd(xmm1, xmm6);
+  addsd(xmm4, xmm1);
+  movsd(Address(rsp, 0), xmm4);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
+  shrl(eax, 4);
+  cmpl(eax, 268434685);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_3_0_2);
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_3_0_2);
+  movsd(xmm3, Address(ebx, 2192));
+  mulsd(xmm3, xmm0);
+  subsd(xmm3, xmm0);
+  mulsd(xmm3, Address(ebx, 2208));
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movl(eax, Address(rsp, 132));
+  andl(eax, 2146435072);
+  cmpl(eax, 2146435072);
+  jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
+  subl(rsp, 32);
+  movsd(Address(rsp, 0), xmm0);
+  lea(eax, Address(rsp, 40));
+  movl(Address(rsp, 8), eax);
+  movl(eax, 2);
+  movl(Address(rsp, 12), eax);
+  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge())));
+  addl(rsp, 32);
+  fld_d(Address(rsp, 16));
+  jmp(L_2TAG_PACKET_1_0_2);
+  bind(L_2TAG_PACKET_4_0_2);
+  fld_d(Address(rsp, 128));
+  fmul_d(Address(ebx, 2240));
+  bind(L_2TAG_PACKET_1_0_2);
+  movl(ebx, Address(rsp, 56));
+}
+#endif
diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_tan.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_tan.cpp
new file mode 100644
index 0000000..18fe151
--- /dev/null
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_tan.cpp
@@ -0,0 +1,2144 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+* Intel Math Library (LIBM) Source Code
+*
+* 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 "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
+/******************************************************************************/
+//                     ALGORITHM DESCRIPTION - TAN()
+//                     ---------------------
+//
+// Polynomials coefficients and other constants.
+//
+// Note that in this algorithm, there is a different polynomial for
+// each breakpoint, so there are 32 sets of polynomial coefficients
+// as well as 32 instances of the other constants.
+//
+// The polynomial coefficients and constants are offset from the start
+// of the main block as follows:
+//
+//   0:  c8 | c0
+//  16:  c9 | c1
+//  32: c10 | c2
+//  48: c11 | c3
+//  64: c12 | c4
+//  80: c13 | c5
+//  96: c14 | c6
+// 112: c15 | c7
+// 128: T_hi
+// 136: T_lo
+// 144: Sigma
+// 152: T_hl
+// 160: Tau
+// 168: Mask
+// 176: (end of block)
+//
+// The total table size is therefore 5632 bytes.
+//
+// Note that c0 and c1 are always zero. We could try storing
+// other constants here, and just loading the low part of the
+// SIMD register in these cases, after ensuring the high part
+// is zero.
+//
+// The higher terms of the polynomial are computed in the *low*
+// part of the SIMD register. This is so we can overlap the
+// multiplication by r^8 and the unpacking of the other part.
+//
+// The constants are:
+// T_hi + T_lo = accurate constant term in power series
+// Sigma + T_hl = accurate coefficient of r in power series (Sigma=1 bit)
+// Tau = multiplier for the reciprocal, always -1 or 0
+//
+// The basic reconstruction formula using these constants is:
+//
+// High = tau * recip_hi + t_hi
+// Med = (sgn * r + t_hl * r)_hi
+// Low = (sgn * r + t_hl * r)_lo +
+//       tau * recip_lo + T_lo + (T_hl + sigma) * c + pol
+//
+// where pol = c0 + c1 * r + c2 * r^2 + ... + c15 * r^15
+//
+// (c0 = c1 = 0, but using them keeps SIMD regularity)
+//
+// We then do a compensated sum High + Med, add the low parts together
+// and then do the final sum.
+//
+// Here recip_hi + recip_lo is an accurate reciprocal of the remainder
+// modulo pi/2
+//
+// Special cases:
+//  tan(NaN) = quiet NaN, and raise invalid exception
+//  tan(INF) = NaN and raise invalid exception
+//  tan(+/-0) = +/-0
+//
+/******************************************************************************/
+
+#ifdef _LP64
+// The 64 bit code is at most SSE2 compliant
+ALIGNED_(16) juint _ONEHALF_tan[] =
+{
+    0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+};
+
+ALIGNED_(16) juint _MUL16[] =
+{
+    0x00000000UL, 0x40300000UL, 0x00000000UL, 0x3ff00000UL
+};
+
+ALIGNED_(16) juint _sign_mask_tan[] =
+{
+    0x00000000UL, 0x80000000UL, 0x00000000UL, 0x80000000UL
+};
+
+ALIGNED_(16) juint _PI32INV_tan[] =
+{
+    0x6dc9c883UL, 0x3fe45f30UL, 0x6dc9c883UL, 0x40245f30UL
+};
+
+ALIGNED_(16) juint _P_1_tan[] =
+{
+    0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL
+};
+
+ALIGNED_(16) juint _P_2_tan[] =
+{
+    0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL
+};
+
+ALIGNED_(16) juint _P_3_tan[] =
+{
+    0x3707344aUL, 0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL
+};
+
+ALIGNED_(16) juint _Ctable_tan[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x882c10faUL,
+    0x3f9664f4UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x55e6c23dUL, 0x3f8226e3UL, 0x55555555UL,
+    0x3fd55555UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x0e157de0UL, 0x3f6d6d3dUL, 0x11111111UL, 0x3fc11111UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x452b75e3UL, 0x3f57da36UL,
+    0x1ba1ba1cUL, 0x3faba1baUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL,
+    0x3f953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL,
+    0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0x3f85ad63UL, 0xdc230b9bUL,
+    0x3fb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL,
+    0x77bb08baUL, 0x3f757c85UL, 0xb6247521UL, 0x3fb1381eUL, 0x5922170cUL,
+    0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0x3f64e391UL,
+    0x3e666320UL, 0x3fa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL,
+    0x3fafa8aeUL, 0x8c5b2da2UL, 0x3fb936bbUL, 0x4e88f7a5UL, 0x3c587d05UL,
+    0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x5a279ea3UL, 0x3faa3407UL,
+    0x00000000UL, 0x00000000UL, 0x432d65faUL, 0x3fa70153UL, 0x00000000UL,
+    0x00000000UL, 0x891a4602UL, 0x3f9d03efUL, 0xd62ca5f8UL, 0x3fca77d9UL,
+    0xb35f4628UL, 0x3f97a265UL, 0x433258faUL, 0x3fd8cf51UL, 0xb58fd909UL,
+    0x3f8f88e3UL, 0x01771ceaUL, 0x3fc2b154UL, 0xf3562f8eUL, 0x3f888f57UL,
+    0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL, 0x3f80f44cUL, 0x214368e9UL,
+    0x3fb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL, 0x172dbbf0UL, 0x3fb6cb8eUL,
+    0xe0553158UL, 0x3fc975f5UL, 0x593fe814UL, 0x3c2ef5d3UL, 0x00000000UL,
+    0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x9314533eUL, 0x3fbb8ec5UL, 0x00000000UL,
+    0x00000000UL, 0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL,
+    0xdcb427fdUL, 0x3fb13950UL, 0xd87ab0bbUL, 0x3fd5335eUL, 0xce0ae8a5UL,
+    0x3fabb382UL, 0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0x3fa552f1UL,
+    0x59f21a6dUL, 0x3fd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL,
+    0x3fd0576cUL, 0x8f2c2950UL, 0x3f9a4898UL, 0xc0b3f22cUL, 0x3fc59462UL,
+    0x1883a4b8UL, 0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL,
+    0x3fd36a08UL, 0x1dce993dUL, 0xbc6d704dUL, 0x00000000UL, 0x3ff00000UL,
+    0x2b82ab63UL, 0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x56f37042UL, 0x3fccfc56UL, 0x00000000UL, 0x00000000UL,
+    0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL, 0x3d0e7c5dUL,
+    0x3fc50533UL, 0x9bed9b2eUL, 0x3fdf0ed9UL, 0x5fe7c47cUL, 0x3fc1f250UL,
+    0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0x3fbe5c71UL, 0x86362c20UL,
+    0x3fda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL, 0x3fd911bdUL,
+    0xb56658beUL, 0x3fb5e4c7UL, 0x93a2fd76UL, 0x3fd3c092UL, 0xda271794UL,
+    0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL, 0x3fda8279UL,
+    0xb68c1467UL, 0x3c708b2fUL, 0x00000000UL, 0x3ff00000UL, 0x980c4337UL,
+    0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0xcc03e501UL, 0x3fdff10fUL, 0x00000000UL, 0x00000000UL, 0x44a4e845UL,
+    0x3fddb63bUL, 0x00000000UL, 0x00000000UL, 0x3768ad9fUL, 0x3fdb72a4UL,
+    0x3dd01ccaUL, 0x3fe5fdb9UL, 0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL,
+    0x3fe977f9UL, 0xd013b3abUL, 0x3fd78ca3UL, 0xbf0bf914UL, 0x3fe4f192UL,
+    0x4d53e730UL, 0x3fd5d060UL, 0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL,
+    0x3fd4322aUL, 0x5936a835UL, 0x3fe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL,
+    0xef478605UL, 0x3fe1659eUL, 0x190834ecUL, 0x3fe11ab7UL, 0xcdb625eaUL,
+    0xbc8e564bUL, 0x00000000UL, 0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL,
+    0x3ff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL,
+    0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0x3ff3972eUL, 0xe93463bdUL,
+    0x3feeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL,
+    0xa04e8ea3UL, 0x3ff4541aUL, 0x386accd3UL, 0x3ff1369eUL, 0x222a66ddUL,
+    0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0x3ff5178fUL,
+    0xddaa0031UL, 0x3ff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL,
+    0x3ff29311UL, 0x2ab7f990UL, 0x3fe561b8UL, 0x209c7df1UL, 0x3c87a8c5UL,
+    0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc7ab4d5aUL, 0x40085e24UL,
+    0x00000000UL, 0x00000000UL, 0xe93ea75dUL, 0x400b963dUL, 0x00000000UL,
+    0x00000000UL, 0x94a7f25aUL, 0x400f37e2UL, 0x4b6261cbUL, 0x3ff5f984UL,
+    0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL, 0x3ffaf5a5UL, 0x7f2ce8e3UL,
+    0x4013fe8bUL, 0xfe8e54faUL, 0x3ffd7334UL, 0x670d618dUL, 0x4016a10cUL,
+    0x4db97058UL, 0x4000e012UL, 0x24df44ddUL, 0x40199c5fUL, 0x697d6eceUL,
+    0x4003006eUL, 0x83298b82UL, 0x401cfc4dUL, 0x19d490d6UL, 0x40058c19UL,
+    0x2ae42850UL, 0x3fea4300UL, 0x118e20e6UL, 0xbc7a6db8UL, 0x00000000UL,
+    0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x65965966UL, 0x40219659UL, 0x00000000UL,
+    0x00000000UL, 0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL,
+    0x83cd3723UL, 0x402c8342UL, 0x00000000UL, 0x40000000UL, 0x55e6c23dUL,
+    0x403226e3UL, 0x55555555UL, 0x40055555UL, 0x34451939UL, 0x40371c96UL,
+    0xaaaaaaabUL, 0x400aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL,
+    0x40111111UL, 0xa738201fUL, 0x4042bbceUL, 0x05b05b06UL, 0x4015b05bUL,
+    0x452b75e3UL, 0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x4f48b8d3UL, 0xbf33eaf9UL, 0x00000000UL, 0x00000000UL,
+    0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL, 0xd0258911UL,
+    0xbf0abaf3UL, 0x23e49fe9UL, 0xbfab5a8cUL, 0x2d53222eUL, 0x3ef60d15UL,
+    0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0xbee1d3b5UL, 0xdbf93b8eUL,
+    0xbf84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL, 0x3f743924UL,
+    0x794a8297UL, 0xbeb7b7b9UL, 0xe015f797UL, 0xbf5d41f5UL, 0xe41a4a56UL,
+    0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL, 0xbfce49ceUL,
+    0x8c743719UL, 0x3d1eb860UL, 0x00000000UL, 0x00000000UL, 0x1b4863cfUL,
+    0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL,
+    0x535ad890UL, 0xbf2b9320UL, 0x00000000UL, 0x00000000UL, 0x018fdf1fUL,
+    0x3f16d61dUL, 0x00000000UL, 0x00000000UL, 0x0359f1beUL, 0xbf0139e4UL,
+    0xa4317c6dUL, 0xbfa67e17UL, 0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL,
+    0x3f9f455bUL, 0x51ccf238UL, 0xbed55317UL, 0xf437b9acUL, 0xbf804beeUL,
+    0xc791a2b5UL, 0x3ec0e993UL, 0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL,
+    0xbeaa48a2UL, 0x0a268358UL, 0xbf55a443UL, 0xdfd978e4UL, 0x3e94b61fUL,
+    0xd7767a58UL, 0x3f431806UL, 0x2aea0000UL, 0xbfc9bbe8UL, 0x7723ea61UL,
+    0xbd3a2369UL, 0x00000000UL, 0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL,
+    0xbf231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL,
+    0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0xbef66191UL, 0x848a46c6UL,
+    0xbfa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL,
+    0xfdd299efUL, 0xbec9dd1aUL, 0x3f8dbaafUL, 0xbf793363UL, 0x309fc6eaUL,
+    0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0xbe9dae11UL,
+    0x3e5c67b3UL, 0xbf4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL,
+    0x3f3d1eb1UL, 0x29cfc000UL, 0xbfc549ceUL, 0xbf159358UL, 0xbd397b33UL,
+    0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x7d98a556UL, 0xbf1a3958UL,
+    0x00000000UL, 0x00000000UL, 0x9d88dc01UL, 0x3f0704c2UL, 0x00000000UL,
+    0x00000000UL, 0x73742a2bUL, 0xbeed054aUL, 0x58844587UL, 0xbf9c2a13UL,
+    0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL, 0x3f9a48f4UL, 0xa8dc9888UL,
+    0xbebf8939UL, 0xaad4b5b8UL, 0xbf72f746UL, 0x9102efa1UL, 0x3ea88f82UL,
+    0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL, 0xbe90f456UL, 0x741fb4edUL,
+    0xbf46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL, 0xca89ff3fUL, 0x3f36db70UL,
+    0xa8a2a000UL, 0xbfc0ee13UL, 0x3da24be1UL, 0xbd338b9fUL, 0x00000000UL,
+    0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0xfffffff8UL, 0x1a154b97UL, 0xbf116b01UL, 0x00000000UL,
+    0x00000000UL, 0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL,
+    0xb93820c8UL, 0xbee264d4UL, 0xbb6cbb18UL, 0xbf94ab8cUL, 0x888d4d92UL,
+    0x3ed0568bUL, 0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0xbeb2f950UL,
+    0x22cf9f74UL, 0xbf6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL,
+    0x3f64aad7UL, 0x637b73afUL, 0xbe83487cUL, 0xe522591aUL, 0xbf3fc092UL,
+    0xa158e8bcUL, 0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL,
+    0xbfb9477fUL, 0xc2c2d2bcUL, 0xbd135ef9UL, 0x00000000UL, 0x00000000UL,
+    0xf2fdb123UL, 0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL,
+    0xfffffff8UL, 0xc41acb64UL, 0xbf05448dUL, 0x00000000UL, 0x00000000UL,
+    0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL, 0x9e42962dUL,
+    0xbed5aea5UL, 0x2579f8efUL, 0xbf8b2398UL, 0x288a1ed9UL, 0x3ec81441UL,
+    0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0xbea57cd3UL, 0x5766336fUL,
+    0xbf617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL, 0x3f62c646UL,
+    0x6b8fb29cUL, 0xbe74e3a3UL, 0xdc4c0409UL, 0xbf33f952UL, 0x9bffe365UL,
+    0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL, 0xbfb0cc62UL,
+    0x016b907fUL, 0xbd119cbcUL, 0x00000000UL, 0x00000000UL, 0xe6b9d8faUL,
+    0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL,
+    0x5daf22a6UL, 0xbef429d7UL, 0x00000000UL, 0x00000000UL, 0x06bca545UL,
+    0x3ef7a27dUL, 0x00000000UL, 0x00000000UL, 0x7211c19aUL, 0xbec41c3eUL,
+    0x956ed53eUL, 0xbf7ae3f4UL, 0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL,
+    0x3f96f713UL, 0x36661e6cUL, 0xbe936e09UL, 0x506f9381UL, 0xbf5122e8UL,
+    0xcb6dd43fUL, 0x3e9041b9UL, 0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL,
+    0xbe625a8aUL, 0xe5a0e9dcUL, 0xbf23499dUL, 0x110384ddUL, 0x3e5b1c2cUL,
+    0x68d43db6UL, 0x3f2cb899UL, 0x6ecac000UL, 0xbfa0c414UL, 0xcd7dd58cUL,
+    0x3d13500fUL, 0x00000000UL, 0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2bf70ebeUL, 0x3ef66a8fUL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0xd644267fUL, 0x3ec22805UL, 0x16c16c17UL, 0x3f96c16cUL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc4e09162UL,
+    0x3e8d6db2UL, 0xbc011567UL, 0x3f61566aUL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x1f79955cUL, 0x3e57da4eUL, 0x9334ef0bUL,
+    0x3f2bbd77UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x55555555UL, 0x3fd55555UL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x5daf22a6UL, 0x3ef429d7UL,
+    0x00000000UL, 0x00000000UL, 0x06bca545UL, 0x3ef7a27dUL, 0x00000000UL,
+    0x00000000UL, 0x7211c19aUL, 0x3ec41c3eUL, 0x956ed53eUL, 0x3f7ae3f4UL,
+    0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL, 0x3f96f713UL, 0x36661e6cUL,
+    0x3e936e09UL, 0x506f9381UL, 0x3f5122e8UL, 0xcb6dd43fUL, 0x3e9041b9UL,
+    0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL, 0x3e625a8aUL, 0xe5a0e9dcUL,
+    0x3f23499dUL, 0x110384ddUL, 0x3e5b1c2cUL, 0x68d43db6UL, 0x3f2cb899UL,
+    0x6ecac000UL, 0x3fa0c414UL, 0xcd7dd58cUL, 0xbd13500fUL, 0x00000000UL,
+    0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0xfffffff8UL, 0xc41acb64UL, 0x3f05448dUL, 0x00000000UL,
+    0x00000000UL, 0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL,
+    0x9e42962dUL, 0x3ed5aea5UL, 0x2579f8efUL, 0x3f8b2398UL, 0x288a1ed9UL,
+    0x3ec81441UL, 0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0x3ea57cd3UL,
+    0x5766336fUL, 0x3f617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL,
+    0x3f62c646UL, 0x6b8fb29cUL, 0x3e74e3a3UL, 0xdc4c0409UL, 0x3f33f952UL,
+    0x9bffe365UL, 0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL,
+    0x3fb0cc62UL, 0x016b907fUL, 0x3d119cbcUL, 0x00000000UL, 0x00000000UL,
+    0xe6b9d8faUL, 0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL,
+    0xfffffff8UL, 0x1a154b97UL, 0x3f116b01UL, 0x00000000UL, 0x00000000UL,
+    0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL, 0xb93820c8UL,
+    0x3ee264d4UL, 0xbb6cbb18UL, 0x3f94ab8cUL, 0x888d4d92UL, 0x3ed0568bUL,
+    0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0x3eb2f950UL, 0x22cf9f74UL,
+    0x3f6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL, 0x3f64aad7UL,
+    0x637b73afUL, 0x3e83487cUL, 0xe522591aUL, 0x3f3fc092UL, 0xa158e8bcUL,
+    0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL, 0x3fb9477fUL,
+    0xc2c2d2bcUL, 0x3d135ef9UL, 0x00000000UL, 0x00000000UL, 0xf2fdb123UL,
+    0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL,
+    0x7d98a556UL, 0x3f1a3958UL, 0x00000000UL, 0x00000000UL, 0x9d88dc01UL,
+    0x3f0704c2UL, 0x00000000UL, 0x00000000UL, 0x73742a2bUL, 0x3eed054aUL,
+    0x58844587UL, 0x3f9c2a13UL, 0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL,
+    0x3f9a48f4UL, 0xa8dc9888UL, 0x3ebf8939UL, 0xaad4b5b8UL, 0x3f72f746UL,
+    0x9102efa1UL, 0x3ea88f82UL, 0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL,
+    0x3e90f456UL, 0x741fb4edUL, 0x3f46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL,
+    0xca89ff3fUL, 0x3f36db70UL, 0xa8a2a000UL, 0x3fc0ee13UL, 0x3da24be1UL,
+    0x3d338b9fUL, 0x00000000UL, 0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL,
+    0x3f231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL,
+    0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0x3ef66191UL, 0x848a46c6UL,
+    0x3fa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL,
+    0xfdd299efUL, 0x3ec9dd1aUL, 0x3f8dbaafUL, 0x3f793363UL, 0x309fc6eaUL,
+    0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0x3e9dae11UL,
+    0x3e5c67b3UL, 0x3f4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL,
+    0x3f3d1eb1UL, 0x29cfc000UL, 0x3fc549ceUL, 0xbf159358UL, 0x3d397b33UL,
+    0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x535ad890UL, 0x3f2b9320UL,
+    0x00000000UL, 0x00000000UL, 0x018fdf1fUL, 0x3f16d61dUL, 0x00000000UL,
+    0x00000000UL, 0x0359f1beUL, 0x3f0139e4UL, 0xa4317c6dUL, 0x3fa67e17UL,
+    0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL, 0x3f9f455bUL, 0x51ccf238UL,
+    0x3ed55317UL, 0xf437b9acUL, 0x3f804beeUL, 0xc791a2b5UL, 0x3ec0e993UL,
+    0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL, 0x3eaa48a2UL, 0x0a268358UL,
+    0x3f55a443UL, 0xdfd978e4UL, 0x3e94b61fUL, 0xd7767a58UL, 0x3f431806UL,
+    0x2aea0000UL, 0x3fc9bbe8UL, 0x7723ea61UL, 0x3d3a2369UL, 0x00000000UL,
+    0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0xfffffff8UL, 0x4f48b8d3UL, 0x3f33eaf9UL, 0x00000000UL,
+    0x00000000UL, 0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL,
+    0xd0258911UL, 0x3f0abaf3UL, 0x23e49fe9UL, 0x3fab5a8cUL, 0x2d53222eUL,
+    0x3ef60d15UL, 0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0x3ee1d3b5UL,
+    0xdbf93b8eUL, 0x3f84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL,
+    0x3f743924UL, 0x794a8297UL, 0x3eb7b7b9UL, 0xe015f797UL, 0x3f5d41f5UL,
+    0xe41a4a56UL, 0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL,
+    0x3fce49ceUL, 0x8c743719UL, 0xbd1eb860UL, 0x00000000UL, 0x00000000UL,
+    0x1b4863cfUL, 0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL,
+    0xfffffff8UL, 0x65965966UL, 0xc0219659UL, 0x00000000UL, 0x00000000UL,
+    0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL, 0x83cd3723UL,
+    0xc02c8342UL, 0x00000000UL, 0xc0000000UL, 0x55e6c23dUL, 0x403226e3UL,
+    0x55555555UL, 0x40055555UL, 0x34451939UL, 0xc0371c96UL, 0xaaaaaaabUL,
+    0xc00aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL, 0x40111111UL,
+    0xa738201fUL, 0xc042bbceUL, 0x05b05b06UL, 0xc015b05bUL, 0x452b75e3UL,
+    0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL, 0xbff00000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0xc7ab4d5aUL, 0xc0085e24UL, 0x00000000UL, 0x00000000UL, 0xe93ea75dUL,
+    0x400b963dUL, 0x00000000UL, 0x00000000UL, 0x94a7f25aUL, 0xc00f37e2UL,
+    0x4b6261cbUL, 0xbff5f984UL, 0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL,
+    0x3ffaf5a5UL, 0x7f2ce8e3UL, 0xc013fe8bUL, 0xfe8e54faUL, 0xbffd7334UL,
+    0x670d618dUL, 0x4016a10cUL, 0x4db97058UL, 0x4000e012UL, 0x24df44ddUL,
+    0xc0199c5fUL, 0x697d6eceUL, 0xc003006eUL, 0x83298b82UL, 0x401cfc4dUL,
+    0x19d490d6UL, 0x40058c19UL, 0x2ae42850UL, 0xbfea4300UL, 0x118e20e6UL,
+    0x3c7a6db8UL, 0x00000000UL, 0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL,
+    0xbff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL,
+    0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0xbff3972eUL, 0xe93463bdUL,
+    0xbfeeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL,
+    0xa04e8ea3UL, 0xbff4541aUL, 0x386accd3UL, 0xbff1369eUL, 0x222a66ddUL,
+    0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0xbff5178fUL,
+    0xddaa0031UL, 0xbff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL,
+    0x3ff29311UL, 0x2ab7f990UL, 0xbfe561b8UL, 0x209c7df1UL, 0xbc87a8c5UL,
+    0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xcc03e501UL, 0xbfdff10fUL,
+    0x00000000UL, 0x00000000UL, 0x44a4e845UL, 0x3fddb63bUL, 0x00000000UL,
+    0x00000000UL, 0x3768ad9fUL, 0xbfdb72a4UL, 0x3dd01ccaUL, 0xbfe5fdb9UL,
+    0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL, 0x3fe977f9UL, 0xd013b3abUL,
+    0xbfd78ca3UL, 0xbf0bf914UL, 0xbfe4f192UL, 0x4d53e730UL, 0x3fd5d060UL,
+    0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL, 0xbfd4322aUL, 0x5936a835UL,
+    0xbfe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL, 0xef478605UL, 0x3fe1659eUL,
+    0x190834ecUL, 0xbfe11ab7UL, 0xcdb625eaUL, 0x3c8e564bUL, 0x00000000UL,
+    0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x56f37042UL, 0xbfccfc56UL, 0x00000000UL,
+    0x00000000UL, 0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL,
+    0x3d0e7c5dUL, 0xbfc50533UL, 0x9bed9b2eUL, 0xbfdf0ed9UL, 0x5fe7c47cUL,
+    0x3fc1f250UL, 0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0xbfbe5c71UL,
+    0x86362c20UL, 0xbfda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL,
+    0x3fd911bdUL, 0xb56658beUL, 0xbfb5e4c7UL, 0x93a2fd76UL, 0xbfd3c092UL,
+    0xda271794UL, 0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL,
+    0xbfda8279UL, 0xb68c1467UL, 0xbc708b2fUL, 0x00000000UL, 0x3ff00000UL,
+    0x980c4337UL, 0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x9314533eUL, 0xbfbb8ec5UL, 0x00000000UL, 0x00000000UL,
+    0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL, 0xdcb427fdUL,
+    0xbfb13950UL, 0xd87ab0bbUL, 0xbfd5335eUL, 0xce0ae8a5UL, 0x3fabb382UL,
+    0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0xbfa552f1UL, 0x59f21a6dUL,
+    0xbfd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL, 0x3fd0576cUL,
+    0x8f2c2950UL, 0xbf9a4898UL, 0xc0b3f22cUL, 0xbfc59462UL, 0x1883a4b8UL,
+    0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL, 0xbfd36a08UL,
+    0x1dce993dUL, 0x3c6d704dUL, 0x00000000UL, 0x3ff00000UL, 0x2b82ab63UL,
+    0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x5a279ea3UL, 0xbfaa3407UL, 0x00000000UL, 0x00000000UL, 0x432d65faUL,
+    0x3fa70153UL, 0x00000000UL, 0x00000000UL, 0x891a4602UL, 0xbf9d03efUL,
+    0xd62ca5f8UL, 0xbfca77d9UL, 0xb35f4628UL, 0x3f97a265UL, 0x433258faUL,
+    0x3fd8cf51UL, 0xb58fd909UL, 0xbf8f88e3UL, 0x01771ceaUL, 0xbfc2b154UL,
+    0xf3562f8eUL, 0x3f888f57UL, 0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL,
+    0xbf80f44cUL, 0x214368e9UL, 0xbfb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL,
+    0x172dbbf0UL, 0x3fb6cb8eUL, 0xe0553158UL, 0xbfc975f5UL, 0x593fe814UL,
+    0xbc2ef5d3UL, 0x00000000UL, 0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL,
+    0xbf953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL,
+    0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0xbf85ad63UL, 0xdc230b9bUL,
+    0xbfb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL,
+    0x77bb08baUL, 0xbf757c85UL, 0xb6247521UL, 0xbfb1381eUL, 0x5922170cUL,
+    0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0xbf64e391UL,
+    0x3e666320UL, 0xbfa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL,
+    0x3fafa8aeUL, 0x8c5b2da2UL, 0xbfb936bbUL, 0x4e88f7a5UL, 0xbc587d05UL,
+    0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL
+};
+
+ALIGNED_(16) juint _MASK_35_tan[] =
+{
+    0xfffc0000UL, 0xffffffffUL, 0x00000000UL, 0x00000000UL
+};
+
+ALIGNED_(16) juint _Q_11_tan[] =
+{
+    0xb8fe4d77UL, 0x3f82609aUL
+};
+
+ALIGNED_(16) juint _Q_9_tan[] =
+{
+    0xbf847a43UL, 0x3f9664a0UL
+};
+
+ALIGNED_(16) juint _Q_7_tan[] =
+{
+    0x52c4c8abUL, 0x3faba1baUL
+};
+
+ALIGNED_(16) juint _Q_5_tan[] =
+{
+    0x11092746UL, 0x3fc11111UL
+};
+
+ALIGNED_(16) juint _Q_3_tan[] =
+{
+    0x55555612UL, 0x3fd55555UL
+};
+
+ALIGNED_(16) juint _PI_INV_TABLE_tan[] =
+{
+    0x00000000UL, 0x00000000UL, 0xa2f9836eUL, 0x4e441529UL, 0xfc2757d1UL,
+    0xf534ddc0UL, 0xdb629599UL, 0x3c439041UL, 0xfe5163abUL, 0xdebbc561UL,
+    0xb7246e3aUL, 0x424dd2e0UL, 0x06492eeaUL, 0x09d1921cUL, 0xfe1deb1cUL,
+    0xb129a73eUL, 0xe88235f5UL, 0x2ebb4484UL, 0xe99c7026UL, 0xb45f7e41UL,
+    0x3991d639UL, 0x835339f4UL, 0x9c845f8bUL, 0xbdf9283bUL, 0x1ff897ffUL,
+    0xde05980fUL, 0xef2f118bUL, 0x5a0a6d1fUL, 0x6d367ecfUL, 0x27cb09b7UL,
+    0x4f463f66UL, 0x9e5fea2dUL, 0x7527bac7UL, 0xebe5f17bUL, 0x3d0739f7UL,
+    0x8a5292eaUL, 0x6bfb5fb1UL, 0x1f8d5d08UL, 0x56033046UL, 0xfc7b6babUL,
+    0xf0cfbc21UL
+};
+
+ALIGNED_(8) juint _PI_4_tan[] =
+{
+    0x00000000UL, 0x3fe921fbUL, 0x4611a626UL, 0x3e85110bUL
+};
+
+ALIGNED_(8) juint _QQ_2_tan[] =
+{
+    0x676733afUL, 0x3d32e7b9UL
+};
+
+ALIGNED_(8) juint _ONE_tan[] =
+{
+    0x00000000UL, 0x3ff00000UL
+};
+
+ALIGNED_(8) juint _TWO_POW_55_tan[] =
+{
+    0x00000000UL, 0x43600000UL
+};
+
+ALIGNED_(4) juint _TWO_POW_M55_tan[] =
+{
+    0x00000000UL, 0x3c800000UL
+};
+
+ALIGNED_(4) juint _NEG_ZERO_tan[] =
+{
+    0x00000000UL, 0x80000000UL
+};
+
+void MacroAssembler::fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r8, Register r9, Register r10, Register r11) {
+
+  Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1;
+  Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1;
+  Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1;
+  Label L_2TAG_PACKET_12_0_1, L_2TAG_PACKET_13_0_1, L_2TAG_PACKET_14_0_1, B1_2, B1_3, B1_4, B1_5, start;
+
+  address ONEHALF = (address)_ONEHALF_tan;
+  address MUL16 = (address)_MUL16;
+  address sign_mask = (address)_sign_mask_tan;
+  address PI32INV = (address)_PI32INV_tan;
+  address P_1 = (address)_P_1_tan;
+  address P_2 = (address)_P_2_tan;
+  address P_3 = (address)_P_3_tan;
+  address Ctable = (address)_Ctable_tan;
+  address MASK_35 = (address)_MASK_35_tan;
+  address Q_11 = (address)_Q_11_tan;
+  address Q_9 = (address)_Q_9_tan;
+  address Q_7 = (address)_Q_7_tan;
+  address Q_5 = (address)_Q_5_tan;
+  address Q_3 = (address)_Q_3_tan;
+  address PI_INV_TABLE = (address)_PI_INV_TABLE_tan;
+  address PI_4 = (address)_PI_4_tan;
+  address QQ_2 = (address)_QQ_2_tan;
+  address ONE = (address)_ONE_tan;
+  address TWO_POW_55 = (address)_TWO_POW_55_tan;
+  address TWO_POW_M55 = (address)_TWO_POW_M55_tan;
+  address NEG_ZERO = (address)_NEG_ZERO_tan;
+
+  bind(start);
+  push(rbx);
+  subq(rsp, 16);
+  movsd(Address(rsp, 8), xmm0);
+
+  bind(B1_2);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  subl(eax, 16314);
+  cmpl(eax, 270);
+  jcc(Assembler::above, L_2TAG_PACKET_0_0_1);
+  movdqu(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+  movdqu(xmm6, ExternalAddress(MUL16));    //0x00000000UL, 0x40300000UL, 0x00000000UL, 0x3ff00000UL
+  unpcklpd(xmm0, xmm0);
+  movdqu(xmm4, ExternalAddress(sign_mask));    //0x00000000UL, 0x80000000UL, 0x00000000UL, 0x80000000UL
+  andpd(xmm4, xmm0);
+  movdqu(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x3fe45f30UL, 0x6dc9c883UL, 0x40245f30UL
+  mulpd(xmm1, xmm0);
+  por(xmm5, xmm4);
+  addpd(xmm1, xmm5);
+  movdqu(xmm7, xmm1);
+  unpckhpd(xmm7, xmm7);
+  cvttsd2sil(edx, xmm7);
+  cvttpd2dq(xmm1, xmm1);
+  cvtdq2pd(xmm1, xmm1);
+  mulpd(xmm1, xmm6);
+  movdqu(xmm3, ExternalAddress(P_1));    //0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL
+  movq(xmm5, ExternalAddress(QQ_2));    //0x676733afUL, 0x3d32e7b9UL
+  addq(rdx, 469248);
+  movdqu(xmm4, ExternalAddress(P_2));    //0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL
+  mulpd(xmm3, xmm1);
+  andq(rdx, 31);
+  mulsd(xmm5, xmm1);
+  movq(rcx, rdx);
+  mulpd(xmm4, xmm1);
+  shlq(rcx, 1);
+  subpd(xmm0, xmm3);
+  mulpd(xmm1, ExternalAddress(P_3));    //0x3707344aUL, 0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL
+  addq(rdx, rcx);
+  shlq(rcx, 2);
+  addq(rdx, rcx);
+  addsd(xmm5, xmm0);
+  movdqu(xmm2, xmm0);
+  subpd(xmm0, xmm4);
+  movq(xmm6, ExternalAddress(ONE));    //0x00000000UL, 0x3ff00000UL
+  shlq(rdx, 4);
+  lea(rax, ExternalAddress(Ctable));
+  andpd(xmm5, ExternalAddress(MASK_35));    //0xfffc0000UL, 0xffffffffUL, 0x00000000UL, 0x00000000UL
+  movdqu(xmm3, xmm0);
+  addq(rax, rdx);
+  subpd(xmm2, xmm0);
+  unpckhpd(xmm0, xmm0);
+  divsd(xmm6, xmm5);
+  subpd(xmm2, xmm4);
+  movdqu(xmm7, Address(rax, 16));
+  subsd(xmm3, xmm5);
+  mulpd(xmm7, xmm0);
+  subpd(xmm2, xmm1);
+  movdqu(xmm1, Address(rax, 48));
+  mulpd(xmm1, xmm0);
+  movdqu(xmm4, Address(rax, 96));
+  mulpd(xmm4, xmm0);
+  addsd(xmm2, xmm3);
+  movdqu(xmm3, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm7, Address(rax, 0));
+  addpd(xmm1, Address(rax, 32));
+  mulpd(xmm1, xmm0);
+  addpd(xmm4, Address(rax, 80));
+  addpd(xmm7, xmm1);
+  movdqu(xmm1, Address(rax, 112));
+  mulpd(xmm1, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm4, xmm1);
+  movdqu(xmm1, Address(rax, 64));
+  mulpd(xmm1, xmm0);
+  addpd(xmm7, xmm1);
+  movdqu(xmm1, xmm3);
+  mulpd(xmm3, xmm0);
+  mulsd(xmm0, xmm0);
+  mulpd(xmm1, Address(rax, 144));
+  mulpd(xmm4, xmm3);
+  movdqu(xmm3, xmm1);
+  addpd(xmm7, xmm4);
+  movdqu(xmm4, xmm1);
+  mulsd(xmm0, xmm7);
+  unpckhpd(xmm7, xmm7);
+  addsd(xmm0, xmm7);
+  unpckhpd(xmm1, xmm1);
+  addsd(xmm3, xmm1);
+  subsd(xmm4, xmm3);
+  addsd(xmm1, xmm4);
+  movdqu(xmm4, xmm2);
+  movq(xmm7, Address(rax, 144));
+  unpckhpd(xmm2, xmm2);
+  addsd(xmm7, Address(rax, 152));
+  mulsd(xmm7, xmm2);
+  addsd(xmm7, Address(rax, 136));
+  addsd(xmm7, xmm1);
+  addsd(xmm0, xmm7);
+  movq(xmm7, ExternalAddress(ONE));    //0x00000000UL, 0x3ff00000UL
+  mulsd(xmm4, xmm6);
+  movq(xmm2, Address(rax, 168));
+  andpd(xmm2, xmm6);
+  mulsd(xmm5, xmm2);
+  mulsd(xmm6, Address(rax, 160));
+  subsd(xmm7, xmm5);
+  subsd(xmm2, Address(rax, 128));
+  subsd(xmm7, xmm4);
+  mulsd(xmm7, xmm6);
+  movdqu(xmm4, xmm3);
+  subsd(xmm3, xmm2);
+  addsd(xmm2, xmm3);
+  subsd(xmm4, xmm2);
+  addsd(xmm0, xmm4);
+  subsd(xmm0, xmm7);
+  addsd(xmm0, xmm3);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_0_0_1);
+  jcc(Assembler::greater, L_2TAG_PACKET_1_0_1);
+  pextrw(eax, xmm0, 3);
+  movl(edx, eax);
+  andl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_2_0_1);
+  andl(edx, 32767);
+  cmpl(edx, 15904);
+  jcc(Assembler::below, L_2TAG_PACKET_3_0_1);
+  movdqu(xmm2, xmm0);
+  movdqu(xmm3, xmm0);
+  movq(xmm1, ExternalAddress(Q_11));    //0xb8fe4d77UL, 0x3f82609aUL
+  mulsd(xmm2, xmm0);
+  mulsd(xmm3, xmm2);
+  mulsd(xmm1, xmm2);
+  addsd(xmm1, ExternalAddress(Q_9));    //0xbf847a43UL, 0x3f9664a0UL
+  mulsd(xmm1, xmm2);
+  addsd(xmm1, ExternalAddress(Q_7));    //0x52c4c8abUL, 0x3faba1baUL
+  mulsd(xmm1, xmm2);
+  addsd(xmm1, ExternalAddress(Q_5));    //0x11092746UL, 0x3fc11111UL
+  mulsd(xmm1, xmm2);
+  addsd(xmm1, ExternalAddress(Q_3));    //0x55555612UL, 0x3fd55555UL
+  mulsd(xmm1, xmm3);
+  addsd(xmm0, xmm1);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_3_0_1);
+  movq(xmm3, ExternalAddress(TWO_POW_55));    //0x00000000UL, 0x43600000UL
+  mulsd(xmm3, xmm0);
+  addsd(xmm0, xmm3);
+  mulsd(xmm0, ExternalAddress(TWO_POW_M55));    //0x00000000UL, 0x3c800000UL
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_2_0_1);
+  movdqu(xmm1, xmm0);
+  mulsd(xmm1, xmm1);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_1_0_1);
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32752);
+  cmpl(eax, 32752);
+  jcc(Assembler::equal, L_2TAG_PACKET_4_0_1);
+  pextrw(ecx, xmm0, 3);
+  andl(ecx, 32752);
+  subl(ecx, 16224);
+  shrl(ecx, 7);
+  andl(ecx, 65532);
+  lea(r11, ExternalAddress(PI_INV_TABLE));
+  addq(rcx, r11);
+  movdq(rax, xmm0);
+  movl(r10, Address(rcx, 20));
+  movl(r8, Address(rcx, 24));
+  movl(edx, eax);
+  shrq(rax, 21);
+  orl(eax, INT_MIN);
+  shrl(eax, 11);
+  movl(r9, r10);
+  imulq(r10, rdx);
+  imulq(r9, rax);
+  imulq(r8, rax);
+  movl(rsi, Address(rcx, 16));
+  movl(rdi, Address(rcx, 12));
+  movl(r11, r10);
+  shrq(r10, 32);
+  addq(r9, r10);
+  addq(r11, r8);
+  movl(r8, r11);
+  shrq(r11, 32);
+  addq(r9, r11);
+  movl(r10, rsi);
+  imulq(rsi, rdx);
+  imulq(r10, rax);
+  movl(r11, rdi);
+  imulq(rdi, rdx);
+  movl(rbx, rsi);
+  shrq(rsi, 32);
+  addq(r9, rbx);
+  movl(rbx, r9);
+  shrq(r9, 32);
+  addq(r10, rsi);
+  addq(r10, r9);
+  shlq(rbx, 32);
+  orq(r8, rbx);
+  imulq(r11, rax);
+  movl(r9, Address(rcx, 8));
+  movl(rsi, Address(rcx, 4));
+  movl(rbx, rdi);
+  shrq(rdi, 32);
+  addq(r10, rbx);
+  movl(rbx, r10);
+  shrq(r10, 32);
+  addq(r11, rdi);
+  addq(r11, r10);
+  movq(rdi, r9);
+  imulq(r9, rdx);
+  imulq(rdi, rax);
+  movl(r10, r9);
+  shrq(r9, 32);
+  addq(r11, r10);
+  movl(r10, r11);
+  shrq(r11, 32);
+  addq(rdi, r9);
+  addq(rdi, r11);
+  movq(r9, rsi);
+  imulq(rsi, rdx);
+  imulq(r9, rax);
+  shlq(r10, 32);
+  orq(r10, rbx);
+  movl(eax, Address(rcx, 0));
+  movl(r11, rsi);
+  shrq(rsi, 32);
+  addq(rdi, r11);
+  movl(r11, rdi);
+  shrq(rdi, 32);
+  addq(r9, rsi);
+  addq(r9, rdi);
+  imulq(rdx, rax);
+  pextrw(rbx, xmm0, 3);
+  lea(rdi, ExternalAddress(PI_INV_TABLE));
+  subq(rcx, rdi);
+  addl(ecx, ecx);
+  addl(ecx, ecx);
+  addl(ecx, ecx);
+  addl(ecx, 19);
+  movl(rsi, 32768);
+  andl(rsi, rbx);
+  shrl(rbx, 4);
+  andl(rbx, 2047);
+  subl(rbx, 1023);
+  subl(ecx, rbx);
+  addq(r9, rdx);
+  movl(edx, ecx);
+  addl(edx, 32);
+  cmpl(ecx, 0);
+  jcc(Assembler::less, L_2TAG_PACKET_5_0_1);
+  negl(ecx);
+  addl(ecx, 29);
+  shll(r9);
+  movl(rdi, r9);
+  andl(r9, 1073741823);
+  testl(r9, 536870912);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_6_0_1);
+  shrl(r9);
+  movl(rbx, 0);
+  shlq(r9, 32);
+  orq(r9, r11);
+
+  bind(L_2TAG_PACKET_7_0_1);
+
+  bind(L_2TAG_PACKET_8_0_1);
+  cmpq(r9, 0);
+  jcc(Assembler::equal, L_2TAG_PACKET_9_0_1);
+
+  bind(L_2TAG_PACKET_10_0_1);
+  bsrq(r11, r9);
+  movl(ecx, 29);
+  subl(ecx, r11);
+  jcc(Assembler::lessEqual, L_2TAG_PACKET_11_0_1);
+  shlq(r9);
+  movq(rax, r10);
+  shlq(r10);
+  addl(edx, ecx);
+  negl(ecx);
+  addl(ecx, 64);
+  shrq(rax);
+  shrq(r8);
+  orq(r9, rax);
+  orq(r10, r8);
+
+  bind(L_2TAG_PACKET_12_0_1);
+  cvtsi2sdq(xmm0, r9);
+  shrq(r10, 1);
+  cvtsi2sdq(xmm3, r10);
+  xorpd(xmm4, xmm4);
+  shll(edx, 4);
+  negl(edx);
+  addl(edx, 16368);
+  orl(edx, rsi);
+  xorl(edx, rbx);
+  pinsrw(xmm4, edx, 3);
+  movq(xmm2, ExternalAddress(PI_4));    //0x00000000UL, 0x3fe921fbUL, 0x4611a626UL, 0x3e85110bUL
+  movq(xmm7, ExternalAddress(8 + PI_4));    //0x3fe921fbUL, 0x4611a626UL, 0x3e85110bUL
+  xorpd(xmm5, xmm5);
+  subl(edx, 1008);
+  pinsrw(xmm5, edx, 3);
+  mulsd(xmm0, xmm4);
+  shll(rsi, 16);
+  sarl(rsi, 31);
+  mulsd(xmm3, xmm5);
+  movdqu(xmm1, xmm0);
+  mulsd(xmm0, xmm2);
+  shrl(rdi, 30);
+  addsd(xmm1, xmm3);
+  mulsd(xmm3, xmm2);
+  addl(rdi, rsi);
+  xorl(rdi, rsi);
+  mulsd(xmm7, xmm1);
+  movl(eax, rdi);
+  addsd(xmm7, xmm3);
+  movdqu(xmm2, xmm0);
+  addsd(xmm0, xmm7);
+  subsd(xmm2, xmm0);
+  addsd(xmm7, xmm2);
+  movdqu(xmm1, ExternalAddress(PI32INV));    //0x6dc9c883UL, 0x3fe45f30UL, 0x6dc9c883UL, 0x40245f30UL
+  if (VM_Version::supports_sse3()) {
+    movddup(xmm0, xmm0);
+  }
+  else {
+    movlhps(xmm0, xmm0);
+  }
+  movdqu(xmm4, ExternalAddress(sign_mask));    //0x00000000UL, 0x80000000UL, 0x00000000UL, 0x80000000UL
+  andpd(xmm4, xmm0);
+  mulpd(xmm1, xmm0);
+  if (VM_Version::supports_sse3()) {
+    movddup(xmm7, xmm7);
+  }
+  else {
+    movlhps(xmm7, xmm7);
+  }
+  movdqu(xmm5, ExternalAddress(ONEHALF));    //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL
+  movdqu(xmm6, ExternalAddress(MUL16));    //0x00000000UL, 0x40300000UL, 0x00000000UL, 0x3ff00000UL
+  por(xmm5, xmm4);
+  addpd(xmm1, xmm5);
+  movdqu(xmm5, xmm1);
+  unpckhpd(xmm5, xmm5);
+  cvttsd2sil(edx, xmm5);
+  cvttpd2dq(xmm1, xmm1);
+  cvtdq2pd(xmm1, xmm1);
+  mulpd(xmm1, xmm6);
+  movdqu(xmm3, ExternalAddress(P_1));    //0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL
+  movq(xmm5, ExternalAddress(QQ_2));    //0x676733afUL, 0x3d32e7b9UL
+  shll(eax, 4);
+  addl(edx, 469248);
+  movdqu(xmm4, ExternalAddress(P_2));    //0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL
+  mulpd(xmm3, xmm1);
+  addl(edx, eax);
+  andl(edx, 31);
+  mulsd(xmm5, xmm1);
+  movl(ecx, edx);
+  mulpd(xmm4, xmm1);
+  shll(ecx, 1);
+  subpd(xmm0, xmm3);
+  mulpd(xmm1, ExternalAddress(P_3));    //0x3707344aUL, 0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL
+  addl(edx, ecx);
+  shll(ecx, 2);
+  addl(edx, ecx);
+  addsd(xmm5, xmm0);
+  movdqu(xmm2, xmm0);
+  subpd(xmm0, xmm4);
+  movq(xmm6, ExternalAddress(ONE));    //0x00000000UL, 0x3ff00000UL
+  shll(edx, 4);
+  lea(rax, ExternalAddress(Ctable));
+  andpd(xmm5, ExternalAddress(MASK_35));    //0xfffc0000UL, 0xffffffffUL, 0x00000000UL, 0x00000000UL
+  movdqu(xmm3, xmm0);
+  addq(rax, rdx);
+  subpd(xmm2, xmm0);
+  unpckhpd(xmm0, xmm0);
+  divsd(xmm6, xmm5);
+  subpd(xmm2, xmm4);
+  subsd(xmm3, xmm5);
+  subpd(xmm2, xmm1);
+  movdqu(xmm1, Address(rax, 48));
+  addpd(xmm2, xmm7);
+  movdqu(xmm7, Address(rax, 16));
+  mulpd(xmm7, xmm0);
+  movdqu(xmm4, Address(rax, 96));
+  mulpd(xmm1, xmm0);
+  mulpd(xmm4, xmm0);
+  addsd(xmm2, xmm3);
+  movdqu(xmm3, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm7, Address(rax, 0));
+  addpd(xmm1, Address(rax, 32));
+  mulpd(xmm1, xmm0);
+  addpd(xmm4, Address(rax, 80));
+  addpd(xmm7, xmm1);
+  movdqu(xmm1, Address(rax, 112));
+  mulpd(xmm1, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm4, xmm1);
+  movdqu(xmm1, Address(rax, 64));
+  mulpd(xmm1, xmm0);
+  addpd(xmm7, xmm1);
+  movdqu(xmm1, xmm3);
+  mulpd(xmm3, xmm0);
+  mulsd(xmm0, xmm0);
+  mulpd(xmm1, Address(rax, 144));
+  mulpd(xmm4, xmm3);
+  movdqu(xmm3, xmm1);
+  addpd(xmm7, xmm4);
+  movdqu(xmm4, xmm1);
+  mulsd(xmm0, xmm7);
+  unpckhpd(xmm7, xmm7);
+  addsd(xmm0, xmm7);
+  unpckhpd(xmm1, xmm1);
+  addsd(xmm3, xmm1);
+  subsd(xmm4, xmm3);
+  addsd(xmm1, xmm4);
+  movdqu(xmm4, xmm2);
+  movq(xmm7, Address(rax, 144));
+  unpckhpd(xmm2, xmm2);
+  addsd(xmm7, Address(rax, 152));
+  mulsd(xmm7, xmm2);
+  addsd(xmm7, Address(rax, 136));
+  addsd(xmm7, xmm1);
+  addsd(xmm0, xmm7);
+  movq(xmm7, ExternalAddress(ONE));    //0x00000000UL, 0x3ff00000UL
+  mulsd(xmm4, xmm6);
+  movq(xmm2, Address(rax, 168));
+  andpd(xmm2, xmm6);
+  mulsd(xmm5, xmm2);
+  mulsd(xmm6, Address(rax, 160));
+  subsd(xmm7, xmm5);
+  subsd(xmm2, Address(rax, 128));
+  subsd(xmm7, xmm4);
+  mulsd(xmm7, xmm6);
+  movdqu(xmm4, xmm3);
+  subsd(xmm3, xmm2);
+  addsd(xmm2, xmm3);
+  subsd(xmm4, xmm2);
+  addsd(xmm0, xmm4);
+  subsd(xmm0, xmm7);
+  addsd(xmm0, xmm3);
+  jmp(B1_4);
+
+  bind(L_2TAG_PACKET_9_0_1);
+  addl(edx, 64);
+  movq(r9, r10);
+  movq(r10, r8);
+  movl(r8, 0);
+  cmpq(r9, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_1);
+  addl(edx, 64);
+  movq(r9, r10);
+  movq(r10, r8);
+  cmpq(r9, 0);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_1);
+  jmp(L_2TAG_PACKET_12_0_1);
+
+  bind(L_2TAG_PACKET_11_0_1);
+  jcc(Assembler::equal, L_2TAG_PACKET_12_0_1);
+  negl(ecx);
+  shrq(r10);
+  movq(rax, r9);
+  shrq(r9);
+  subl(edx, ecx);
+  negl(ecx);
+  addl(ecx, 64);
+  shlq(rax);
+  orq(r10, rax);
+  jmp(L_2TAG_PACKET_12_0_1);
+
+  bind(L_2TAG_PACKET_5_0_1);
+  notl(ecx);
+  shlq(r9, 32);
+  orq(r9, r11);
+  shlq(r9);
+  movq(rdi, r9);
+  testl(r9, INT_MIN);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_13_0_1);
+  shrl(r9);
+  movl(rbx, 0);
+  shrq(rdi, 2);
+  jmp(L_2TAG_PACKET_8_0_1);
+
+  bind(L_2TAG_PACKET_6_0_1);
+  shrl(r9);
+  movl(rbx, 1073741824);
+  shrl(rbx);
+  shlq(r9, 32);
+  orq(r9, r11);
+  shlq(rbx, 32);
+  addl(rdi, 1073741824);
+  movl(rcx, 0);
+  movl(r11, 0);
+  subq(rcx, r8);
+  sbbq(r11, r10);
+  sbbq(rbx, r9);
+  movq(r8, rcx);
+  movq(r10, r11);
+  movq(r9, rbx);
+  movl(rbx, 32768);
+  jmp(L_2TAG_PACKET_7_0_1);
+
+  bind(L_2TAG_PACKET_13_0_1);
+  shrl(r9);
+  mov64(rbx, 0x100000000);
+  shrq(rbx);
+  movl(rcx, 0);
+  movl(r11, 0);
+  subq(rcx, r8);
+  sbbq(r11, r10);
+  sbbq(rbx, r9);
+  movq(r8, rcx);
+  movq(r10, r11);
+  movq(r9, rbx);
+  movl(rbx, 32768);
+  shrq(rdi, 2);
+  addl(rdi, 1073741824);
+  jmp(L_2TAG_PACKET_8_0_1);
+
+  bind(L_2TAG_PACKET_4_0_1);
+  movq(xmm0, Address(rsp, 8));
+  mulsd(xmm0, ExternalAddress(NEG_ZERO));    //0x00000000UL, 0x80000000UL
+  movq(Address(rsp, 0), xmm0);
+
+  bind(L_2TAG_PACKET_14_0_1);
+
+  bind(B1_4);
+  addq(rsp, 16);
+
+}
+#else
+// The 32 bit code is at most SSE2 compliant
+ALIGNED_(16) jushort _TP[] =
+{
+    0x4cd6, 0xaf6c, 0xc710, 0xc662, 0xbffd, 0x0000, 0x4b06, 0xb0ac, 0xd3b2, 0xcc2c,
+    0x3ff9, 0x0000, 0x00e3, 0xc850, 0xaa28, 0x9533, 0xbff3, 0x0000, 0x2ff0, 0x466d,
+    0x1a3b, 0xb266, 0x3fe5, 0x0000
+};
+
+ALIGNED_(16) jushort _TQ[] =
+{
+    0x399c, 0x8391, 0x154c, 0x94ca, 0xbfff, 0x0000, 0xb6a3, 0xc36a, 0x44e2, 0x8a2c,
+    0x3ffe, 0x0000, 0xb70f, 0xd068, 0xa6ce, 0xe9dd, 0xbff9, 0x0000, 0x820f, 0x51ce,
+    0x7d76, 0x9bff, 0x3ff3, 0x0000
+};
+
+ALIGNED_(16) jushort _GP[] =
+{
+    0xaaab, 0xaaaa, 0xaaaa, 0xaaaa, 0xbffd, 0x0000, 0xb62f, 0x0b60, 0x60b6, 0xb60b,
+    0xbff9, 0x0000, 0xdfa7, 0x08aa, 0x55e0, 0x8ab3, 0xbff6, 0x0000, 0x85a0, 0xa819,
+    0xbc99, 0xddeb, 0xbff2, 0x0000, 0x7065, 0x6a37, 0x795f, 0xb354, 0xbfef, 0x0000,
+    0xa8f9, 0x83f1, 0x2ec8, 0x9140, 0xbfec, 0x0000, 0xf3ca, 0x8c96, 0x8e0b, 0xeb6d,
+    0xbfe8, 0x0000, 0x355b, 0xd910, 0x67c9, 0xbed3, 0xbfe5, 0x0000, 0x286b, 0xb49e,
+    0xb854, 0x9a98, 0xbfe2, 0x0000, 0x0871, 0x1a2f, 0x6477, 0xfcc4, 0xbfde, 0x0000,
+    0xa559, 0x1da9, 0xaed2, 0xba76, 0xbfdb, 0x0000, 0x00a3, 0x7fea, 0x9bc3, 0xf205,
+    0xbfd8, 0x0000
+};
+
+void MacroAssembler::libm_tancot_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) {
+  Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12;
+  Label B1_13, B1_14, B1_15, B1_16, B1_17, B1_18, B1_19, B1_20, B1_21, B1_22, B1_23;
+  Label B1_24, B1_25, B1_26, B1_27, B1_28, B1_29, B1_30, B1_31, B1_32, B1_33, B1_34;
+  Label B1_35, B1_36, B1_37, B1_38, B1_39, B1_40, B1_41, B1_42, B1_43, B1_44, B1_45, B1_46;
+
+  assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp);
+
+  address L_2il0floatpacket_0 = StubRoutines::x86::_L_2il0floatpacket_0_addr();
+  address Pi4Inv = StubRoutines::x86::_Pi4Inv_addr();
+  address Pi4x3 = StubRoutines::x86::_Pi4x3_addr();
+  address Pi4x4 = StubRoutines::x86::_Pi4x4_addr();
+  address ones = StubRoutines::x86::_ones_addr();
+  address TP = (address)_TP;
+  address TQ = (address)_TQ;
+  address GP = (address)_GP;
+
+  bind(B1_1);
+  push(ebp);
+  movl(ebp, esp);
+  andl(esp, -64);
+  push(esi);
+  push(edi);
+  push(ebx);
+  subl(esp, 52);
+  movl(eax, Address(ebp, 16));
+  movl(ebx, Address(ebp, 20));
+  movl(Address(esp, 40), eax);
+
+  bind(B1_2);
+  fnstcw(Address(esp, 38));
+
+  bind(B1_3);
+  movl(edx, Address(ebp, 12));
+  movl(eax, edx);
+  andl(eax, 2147483647);
+  shrl(edx, 31);
+  movl(Address(esp, 44), edx);
+  cmpl(eax, 1104150528);
+  jcc(Assembler::aboveEqual, B1_11);
+
+  bind(B1_4);
+  movsd(xmm1, Address(ebp, 8));
+  movzwl(ecx, Address(esp, 38));
+  movl(edx, ecx);
+  andl(edx, 768);
+  andps(xmm1, ExternalAddress(L_2il0floatpacket_0));    //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL
+  cmpl(edx, 768);
+  movsd(xmm0, ExternalAddress(Pi4Inv));    ////0x6dc9c883UL, 0x3ff45f30UL
+  mulsd(xmm0, xmm1);
+  movsd(Address(ebp, 8), xmm1);
+  movsd(Address(esp, 0), xmm0);
+  jcc(Assembler::equal, B1_39);
+
+  bind(B1_5);
+  orl(ecx, -64768);
+  movw(Address(esp, 36), ecx);
+
+  bind(B1_6);
+  fldcw(Address(esp, 36));
+
+  bind(B1_7);
+  movsd(xmm1, Address(ebp, 8));
+  movl(edi, 1);
+
+  bind(B1_8);
+  movl(Address(esp, 12), esi);
+  movl(esi, Address(esp, 4));
+  movl(edx, esi);
+  movl(Address(esp, 24), edi);
+  movl(edi, esi);
+  shrl(edi, 20);
+  andl(edx, 1048575);
+  movl(ecx, edi);
+  orl(edx, 1048576);
+  negl(ecx);
+  addl(edi, 13);
+  movl(Address(esp, 8), ebx);
+  addl(ecx, 19);
+  movl(ebx, edx);
+  movl(Address(esp, 28), ecx);
+  shrl(ebx);
+  movl(ecx, edi);
+  shll(edx);
+  movl(ecx, Address(esp, 28));
+  movl(edi, Address(esp, 0));
+  shrl(edi);
+  orl(edx, edi);
+  cmpl(esi, 1094713344);
+  movsd(Address(esp, 16), xmm1);
+  fld_d(Address(esp, 16));
+  cmov32(Assembler::below, edx, ebx);
+  movl(edi, Address(esp, 24));
+  movl(esi, Address(esp, 12));
+  lea(ebx, Address(edx, 1));
+  andl(ebx, -2);
+  movl(Address(esp, 16), ebx);
+  cmpl(eax, 1094713344);
+  fild_s(Address(esp, 16));
+  movl(ebx, Address(esp, 8));
+  jcc(Assembler::aboveEqual, B1_10);
+
+  bind(B1_9);
+  fld_d(ExternalAddress(Pi4x3));    //0x54443000UL, 0xbfe921fbUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(8 + Pi4x3));    //0x3b39a000UL, 0x3d373dcbUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(16 + Pi4x3));    //0xe0e68948UL, 0xba845c06UL
+  fmulp(1);
+  faddp(1);
+  jmp(B1_17);
+
+  bind(B1_10);
+  fld_d(ExternalAddress(Pi4x4));    //0x54400000UL, 0xbfe921fbUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(8 + Pi4x4));    //0x1a600000UL, 0xbdc0b461UL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(16 + Pi4x4));    //0x2e000000UL, 0xbb93198aUL
+  fmul(1);
+  faddp(2);
+  fld_d(ExternalAddress(24 + Pi4x4));    //0x252049c1UL, 0xb96b839aUL
+  fmulp(1);
+  faddp(1);
+  jmp(B1_17);
+
+  bind(B1_11);
+  movzwl(edx, Address(esp, 38));
+  movl(eax, edx);
+  andl(eax, 768);
+  cmpl(eax, 768);
+  jcc(Assembler::equal, B1_40);
+
+  bind(B1_12);
+  orl(edx, -64768);
+  movw(Address(esp, 36), edx);
+
+  bind(B1_13);
+  fldcw(Address(esp, 36));
+
+  bind(B1_14);
+  movl(edi, 1);
+
+  bind(B1_15);
+  movsd(xmm0, Address(ebp, 8));
+  addl(esp, -32);
+  andps(xmm0, ExternalAddress(L_2il0floatpacket_0));    //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL
+  lea(eax, Address(esp, 32));
+  movsd(Address(eax, 16), xmm0);
+  fld_d(Address(eax, 16));
+  fstp_x(Address(esp, 0));
+  movl(Address(esp, 12), 0);
+  movl(Address(esp, 16), eax);
+  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_reduce_pi04l())));
+
+  bind(B1_43);
+  movl(edx, eax);
+  addl(esp, 32);
+
+  bind(B1_16);
+  fld_d(Address(esp, 0));
+  fld_d(Address(esp, 8));
+  faddp(1);
+
+  bind(B1_17);
+  movl(eax, ebx);
+  andl(eax, 3);
+  cmpl(eax, 3);
+  jcc(Assembler::notEqual, B1_24);
+
+  bind(B1_18);
+  fld_d(ExternalAddress(ones));
+  incl(edx);
+  fdiv(1);
+  testb(edx, 2);
+  fstp_x(Address(esp, 24));
+  fld_s(0);
+  fmul(1);
+  fld_s(0);
+  fmul(1);
+  fld_x(ExternalAddress(36 + TP));    //0x2ff0, 0x466d, 0x1a
+  fmul(2);
+  fld_x(ExternalAddress(24 + TP));    //0x00e3, 0xc850, 0xaa
+  faddp(1);
+  fmul(2);
+  fld_x(ExternalAddress(12 + TP));    //0x4b06, 0xb0ac, 0xd3
+  faddp(1);
+  fmul(2);
+  fld_x(ExternalAddress(36 + TQ));    //0x820f, 0x51ce, 0x7d
+  fmul(3);
+  fld_x(ExternalAddress(24 + TQ));    //0xb70f, 0xd068, 0xa6
+  faddp(1);
+  fmul(3);
+  fld_x(ExternalAddress(12 + TQ));    //0xb6a3, 0xc36a, 0x44
+  faddp(1);
+  fmul(3);
+  fld_x(ExternalAddress(TQ));    //0x399c, 0x8391, 0x15
+  faddp(1);
+  fld_x(ExternalAddress(TP));    //0x4cd6, 0xaf6c, 0xc7
+  faddp(2);
+  fld_x(ExternalAddress(132 + GP));    //0x00a3, 0x7fea, 0x9b
+  fmul(3);
+  fld_x(ExternalAddress(120 + GP));    //0xa559, 0x1da9, 0xae
+  fmul(4);
+  fld_x(ExternalAddress(108 + GP));    //0x0871, 0x1a2f, 0x64
+  faddp(2);
+  fxch(1);
+  fmul(4);
+  fld_x(ExternalAddress(96 + GP));    //0x286b, 0xb49e, 0xb8
+  faddp(2);
+  fxch(1);
+  fmul(4);
+  fld_x(ExternalAddress(84 + GP));    //0x355b, 0xd910, 0x67
+  faddp(2);
+  fxch(1);
+  fmul(4);
+  fld_x(ExternalAddress(72 + GP));    //0x8c96, 0x8e0b, 0xeb
+  faddp(2);
+  fxch(1);
+  fmul(4);
+  fld_x(ExternalAddress(60 + GP));    //0xa8f9, 0x83f1, 0x2e
+  faddp(2);
+  fxch(1);
+  fmul(4);
+  fld_x(ExternalAddress(48 + GP));    //0x7065, 0x6a37, 0x79
+  faddp(2);
+  fxch(1);
+  fmul(4);
+  fld_x(ExternalAddress(36 + GP));    //0x85a0, 0xa819, 0xbc
+  faddp(2);
+  fxch(1);
+  fmul(4);
+  fld_x(ExternalAddress(24 + GP));    //0xdfa7, 0x08aa, 0x55
+  faddp(2);
+  fxch(1);
+  fmulp(4);
+  fld_x(ExternalAddress(12 + GP));    //0xb62f, 0x0b60, 0x60
+  faddp(1);
+  fmul(4);
+  fmul(5);
+  fld_x(ExternalAddress(GP));    //0xaaab, 0xaaaa, 0xaa
+  faddp(4);
+  fxch(3);
+  fmul(5);
+  faddp(3);
+  jcc(Assembler::equal, B1_20);
+
+  bind(B1_19);
+  fld_x(Address(esp, 24));
+  fxch(1);
+  fdivrp(2);
+  fxch(1);
+  fmulp(3);
+  movl(eax, Address(esp, 44));
+  xorl(eax, 1);
+  fxch(2);
+  fmul(3);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmula(2);
+  fmula(3);
+  fxch(3);
+  faddp(2);
+  fxch(1);
+  fstp_d(Address(esp, 16));
+  fmul(1);
+  fxch(1);
+  fmulp(2);
+  movsd(xmm0, Address(esp, 16));
+  faddp(1);
+  fstp_d(Address(esp, 16));
+  movsd(xmm1, Address(esp, 16));
+  jmp(B1_21);
+
+  bind(B1_20);
+  fdivrp(1);
+  fmulp(2);
+  fxch(1);
+  fmul(2);
+  movl(eax, Address(esp, 44));
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmula(1);
+  fmula(3);
+  fxch(3);
+  faddp(1);
+  fstp_d(Address(esp, 16));
+  fmul(1);
+  fld_x(Address(esp, 24));
+  fmulp(2);
+  movsd(xmm0, Address(esp, 16));
+  faddp(1);
+  fstp_d(Address(esp, 16));
+  movsd(xmm1, Address(esp, 16));
+
+  bind(B1_21);
+  testl(edi, edi);
+  jcc(Assembler::equal, B1_23);
+
+  bind(B1_22);
+  fldcw(Address(esp, 38));
+
+  bind(B1_23);
+  movl(eax, Address(esp, 40));
+  movsd(Address(eax, 0), xmm0);
+  movsd(Address(eax, 8), xmm1);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_24);
+  testb(ebx, 2);
+  jcc(Assembler::equal, B1_31);
+
+  bind(B1_25);
+  incl(edx);
+  fld_s(0);
+  fmul(1);
+  testb(edx, 2);
+  jcc(Assembler::equal, B1_27);
+
+  bind(B1_26);
+  fld_d(ExternalAddress(ones));
+  fdiv(2);
+  fld_s(1);
+  fmul(2);
+  fld_x(ExternalAddress(132 + GP));    //0x00a3, 0x7fea, 0x9b
+  fmul(1);
+  fld_x(ExternalAddress(120 + GP));    //0xa559, 0x1da9, 0xae
+  fmul(2);
+  fld_x(ExternalAddress(108 + GP));    //0x67c9, 0xbed3, 0xbf
+  movl(eax, Address(esp, 44));
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  xorl(eax, 1);
+  fld_x(ExternalAddress(96 + GP));    //0x286b, 0xb49e, 0xb8
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(84 + GP));    //0x355b, 0xd910, 0x67
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(72 + GP));    //0xf3ca, 0x8c96, 0x8e
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(60 + GP));    //0xa8f9, 0x83f1, 0x2e
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(48 + GP));    //0x7065, 0x6a37, 0x79
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(36 + GP));    //0x85a0, 0xa819, 0xbc
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(24 + GP));    //0xdfa7, 0x08aa, 0x55
+  faddp(2);
+  fxch(1);
+  fmulp(2);
+  fld_x(ExternalAddress(12 + GP));    //0xb62f, 0x0b60, 0x60
+  faddp(1);
+  fmulp(3);
+  fld_x(ExternalAddress(GP));    //0xaaab, 0xaaaa, 0xaa
+  faddp(1);
+  fmul(3);
+  fxch(2);
+  fmulp(3);
+  fxch(1);
+  faddp(2);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmula(2);
+  fmulp(1);
+  faddp(1);
+  fstp_d(Address(esp, 16));
+  movsd(xmm0, Address(esp, 16));
+  jmp(B1_28);
+
+  bind(B1_27);
+  fld_x(ExternalAddress(36 + TP));    //0x2ff0, 0x466d, 0x1a
+  fmul(1);
+  fld_x(ExternalAddress(24 + TP));    //0x00e3, 0xc850, 0xaa
+  movl(eax, Address(esp, 44));
+  faddp(1);
+  fmul(1);
+  fld_x(ExternalAddress(36 + TQ));    //0x820f, 0x51ce, 0x7d
+  fmul(2);
+  fld_x(ExternalAddress(24 + TQ));    //0xb70f, 0xd068, 0xa6
+  faddp(1);
+  fmul(2);
+  fld_x(ExternalAddress(12 + TQ));    //0xb6a3, 0xc36a, 0x44
+  faddp(1);
+  fmul(2);
+  fld_x(ExternalAddress(TQ));    //0x399c, 0x8391, 0x15
+  faddp(1);
+  fld_x(ExternalAddress(12 + TP));    //0x4b06, 0xb0ac, 0xd3
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(TP));    //0x4cd6, 0xaf6c, 0xc7
+  faddp(1);
+  fdivrp(1);
+  fmulp(1);
+  fmul(1);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmula(1);
+  fmulp(2);
+  faddp(1);
+  fstp_d(Address(esp, 16));
+  movsd(xmm0, Address(esp, 16));
+
+  bind(B1_28);
+  testl(edi, edi);
+  jcc(Assembler::equal, B1_30);
+
+  bind(B1_29);
+  fldcw(Address(esp, 38));
+
+  bind(B1_30);
+  movl(eax, Address(esp, 40));
+  movsd(Address(eax, 0), xmm0);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  movl(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_31);
+  testb(ebx, 1);
+  jcc(Assembler::equal, B1_38);
+
+  bind(B1_32);
+  incl(edx);
+  fld_s(0);
+  fmul(1);
+  testb(edx, 2);
+  jcc(Assembler::equal, B1_34);
+
+  bind(B1_33);
+  fld_x(ExternalAddress(36 + TP));    //0x2ff0, 0x466d, 0x1a
+  fmul(1);
+  fld_x(ExternalAddress(24 + TP));    //0x00e3, 0xc850, 0xaa
+  movl(eax, Address(esp, 44));
+  faddp(1);
+  fmul(1);
+  xorl(eax, 1);
+  fld_x(ExternalAddress(36 + TQ));    //0x820f, 0x51ce, 0x7d
+  fmul(2);
+  fld_x(ExternalAddress(24 + TQ));    //0xb70f, 0xd068, 0xa6
+  faddp(1);
+  fmul(2);
+  fld_x(ExternalAddress(12 + TQ));    //0xb6a3, 0xc36a, 0x44
+  faddp(1);
+  fmul(2);
+  fld_x(ExternalAddress(TQ));    //0x399c, 0x8391, 0x15
+  faddp(1);
+  fld_x(ExternalAddress(12 + TP));    //0x4b06, 0xb0ac, 0xd3
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(TP));    //0x4cd6, 0xaf6c, 0xc7
+  faddp(1);
+  fdivrp(1);
+  fmulp(1);
+  fmul(1);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmula(1);
+  fmulp(2);
+  faddp(1);
+  fstp_d(Address(esp, 16));
+  movsd(xmm0, Address(esp, 16));
+  jmp(B1_35);
+
+  bind(B1_34);
+  fld_d(ExternalAddress(ones));
+  fdiv(2);
+  fld_s(1);
+  fmul(2);
+  fld_x(ExternalAddress(132 + GP));    //0x00a3, 0x7fea, 0x9b
+  fmul(1);
+  fld_x(ExternalAddress(120 + GP));    //0xa559, 0x1da9, 0xae
+  fmul(2);
+  fld_x(ExternalAddress(108 + GP));    //0x67c9, 0xbed3, 0xbf
+  movl(eax, Address(esp, 44));
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(96 + GP));    //0x286b, 0xb49e, 0xb8
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(84 + GP));    //0x355b, 0xd910, 0x67
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(72 + GP));    //0xf3ca, 0x8c96, 0x8e
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(60 + GP));    //0xa8f9, 0x83f1, 0x2e
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(48 + GP));    //0x7065, 0x6a37, 0x79
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(36 + GP));    //0x85a0, 0xa819, 0xbc
+  faddp(2);
+  fxch(1);
+  fmul(2);
+  fld_x(ExternalAddress(24 + GP));    //0xdfa7, 0x08aa, 0x55
+  faddp(2);
+  fxch(1);
+  fmulp(2);
+  fld_x(ExternalAddress(12 + GP));    //0xb62f, 0x0b60, 0x60
+  faddp(1);
+  fmulp(3);
+  fld_x(ExternalAddress(GP));    //0xaaab, 0xaaaa, 0xaa
+  faddp(1);
+  fmul(3);
+  fxch(2);
+  fmulp(3);
+  fxch(1);
+  faddp(2);
+  fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8));
+  fmula(2);
+  fmulp(1);
+  faddp(1);
+  fstp_d(Address(esp, 16));
+  movsd(xmm0, Address(esp, 16));
+
+  bind(B1_35);
+  testl(edi, edi);
+  jcc(Assembler::equal, B1_37);
+
+  bind(B1_36);
+  fldcw(Address(esp, 38));
+
+  bind(B1_37);
+  movl(eax, Address(esp, 40));
+  movsd(Address(eax, 8), xmm0);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  mov(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_38);
+  fstp_d(0);
+  addl(esp, 52);
+  pop(ebx);
+  pop(edi);
+  pop(esi);
+  mov(esp, ebp);
+  pop(ebp);
+  ret(0);
+
+  bind(B1_39);
+  xorl(edi, edi);
+  jmp(B1_8);
+
+  bind(B1_40);
+  xorl(edi, edi);
+  jmp(B1_15);
+}
+
+ALIGNED_(16) juint _static_const_table_tan[] =
+{
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x882c10faUL,
+    0x3f9664f4UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x55e6c23dUL, 0x3f8226e3UL, 0x55555555UL,
+    0x3fd55555UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x0e157de0UL, 0x3f6d6d3dUL, 0x11111111UL, 0x3fc11111UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x452b75e3UL, 0x3f57da36UL,
+    0x1ba1ba1cUL, 0x3faba1baUL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL,
+    0x3f953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL,
+    0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0x3f85ad63UL, 0xdc230b9bUL,
+    0x3fb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL,
+    0x77bb08baUL, 0x3f757c85UL, 0xb6247521UL, 0x3fb1381eUL, 0x5922170cUL,
+    0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0x3f64e391UL,
+    0x3e666320UL, 0x3fa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL,
+    0x3fafa8aeUL, 0x8c5b2da2UL, 0x3fb936bbUL, 0x4e88f7a5UL, 0x3c587d05UL,
+    0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x5a279ea3UL, 0x3faa3407UL,
+    0x00000000UL, 0x00000000UL, 0x432d65faUL, 0x3fa70153UL, 0x00000000UL,
+    0x00000000UL, 0x891a4602UL, 0x3f9d03efUL, 0xd62ca5f8UL, 0x3fca77d9UL,
+    0xb35f4628UL, 0x3f97a265UL, 0x433258faUL, 0x3fd8cf51UL, 0xb58fd909UL,
+    0x3f8f88e3UL, 0x01771ceaUL, 0x3fc2b154UL, 0xf3562f8eUL, 0x3f888f57UL,
+    0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL, 0x3f80f44cUL, 0x214368e9UL,
+    0x3fb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL, 0x172dbbf0UL, 0x3fb6cb8eUL,
+    0xe0553158UL, 0x3fc975f5UL, 0x593fe814UL, 0x3c2ef5d3UL, 0x00000000UL,
+    0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x9314533eUL, 0x3fbb8ec5UL, 0x00000000UL,
+    0x00000000UL, 0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL,
+    0xdcb427fdUL, 0x3fb13950UL, 0xd87ab0bbUL, 0x3fd5335eUL, 0xce0ae8a5UL,
+    0x3fabb382UL, 0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0x3fa552f1UL,
+    0x59f21a6dUL, 0x3fd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL,
+    0x3fd0576cUL, 0x8f2c2950UL, 0x3f9a4898UL, 0xc0b3f22cUL, 0x3fc59462UL,
+    0x1883a4b8UL, 0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL,
+    0x3fd36a08UL, 0x1dce993dUL, 0xbc6d704dUL, 0x00000000UL, 0x3ff00000UL,
+    0x2b82ab63UL, 0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x56f37042UL, 0x3fccfc56UL, 0x00000000UL, 0x00000000UL,
+    0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL, 0x3d0e7c5dUL,
+    0x3fc50533UL, 0x9bed9b2eUL, 0x3fdf0ed9UL, 0x5fe7c47cUL, 0x3fc1f250UL,
+    0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0x3fbe5c71UL, 0x86362c20UL,
+    0x3fda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL, 0x3fd911bdUL,
+    0xb56658beUL, 0x3fb5e4c7UL, 0x93a2fd76UL, 0x3fd3c092UL, 0xda271794UL,
+    0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL, 0x3fda8279UL,
+    0xb68c1467UL, 0x3c708b2fUL, 0x00000000UL, 0x3ff00000UL, 0x980c4337UL,
+    0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0xcc03e501UL, 0x3fdff10fUL, 0x00000000UL, 0x00000000UL, 0x44a4e845UL,
+    0x3fddb63bUL, 0x00000000UL, 0x00000000UL, 0x3768ad9fUL, 0x3fdb72a4UL,
+    0x3dd01ccaUL, 0x3fe5fdb9UL, 0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL,
+    0x3fe977f9UL, 0xd013b3abUL, 0x3fd78ca3UL, 0xbf0bf914UL, 0x3fe4f192UL,
+    0x4d53e730UL, 0x3fd5d060UL, 0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL,
+    0x3fd4322aUL, 0x5936a835UL, 0x3fe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL,
+    0xef478605UL, 0x3fe1659eUL, 0x190834ecUL, 0x3fe11ab7UL, 0xcdb625eaUL,
+    0xbc8e564bUL, 0x00000000UL, 0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL,
+    0x3ff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL,
+    0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0x3ff3972eUL, 0xe93463bdUL,
+    0x3feeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL,
+    0xa04e8ea3UL, 0x3ff4541aUL, 0x386accd3UL, 0x3ff1369eUL, 0x222a66ddUL,
+    0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0x3ff5178fUL,
+    0xddaa0031UL, 0x3ff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL,
+    0x3ff29311UL, 0x2ab7f990UL, 0x3fe561b8UL, 0x209c7df1UL, 0x3c87a8c5UL,
+    0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc7ab4d5aUL, 0x40085e24UL,
+    0x00000000UL, 0x00000000UL, 0xe93ea75dUL, 0x400b963dUL, 0x00000000UL,
+    0x00000000UL, 0x94a7f25aUL, 0x400f37e2UL, 0x4b6261cbUL, 0x3ff5f984UL,
+    0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL, 0x3ffaf5a5UL, 0x7f2ce8e3UL,
+    0x4013fe8bUL, 0xfe8e54faUL, 0x3ffd7334UL, 0x670d618dUL, 0x4016a10cUL,
+    0x4db97058UL, 0x4000e012UL, 0x24df44ddUL, 0x40199c5fUL, 0x697d6eceUL,
+    0x4003006eUL, 0x83298b82UL, 0x401cfc4dUL, 0x19d490d6UL, 0x40058c19UL,
+    0x2ae42850UL, 0x3fea4300UL, 0x118e20e6UL, 0xbc7a6db8UL, 0x00000000UL,
+    0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x65965966UL, 0x40219659UL, 0x00000000UL,
+    0x00000000UL, 0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL,
+    0x83cd3723UL, 0x402c8342UL, 0x00000000UL, 0x40000000UL, 0x55e6c23dUL,
+    0x403226e3UL, 0x55555555UL, 0x40055555UL, 0x34451939UL, 0x40371c96UL,
+    0xaaaaaaabUL, 0x400aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL,
+    0x40111111UL, 0xa738201fUL, 0x4042bbceUL, 0x05b05b06UL, 0x4015b05bUL,
+    0x452b75e3UL, 0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x4f48b8d3UL, 0xbf33eaf9UL, 0x00000000UL, 0x00000000UL,
+    0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL, 0xd0258911UL,
+    0xbf0abaf3UL, 0x23e49fe9UL, 0xbfab5a8cUL, 0x2d53222eUL, 0x3ef60d15UL,
+    0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0xbee1d3b5UL, 0xdbf93b8eUL,
+    0xbf84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL, 0x3f743924UL,
+    0x794a8297UL, 0xbeb7b7b9UL, 0xe015f797UL, 0xbf5d41f5UL, 0xe41a4a56UL,
+    0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL, 0xbfce49ceUL,
+    0x8c743719UL, 0x3d1eb860UL, 0x00000000UL, 0x00000000UL, 0x1b4863cfUL,
+    0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL,
+    0x535ad890UL, 0xbf2b9320UL, 0x00000000UL, 0x00000000UL, 0x018fdf1fUL,
+    0x3f16d61dUL, 0x00000000UL, 0x00000000UL, 0x0359f1beUL, 0xbf0139e4UL,
+    0xa4317c6dUL, 0xbfa67e17UL, 0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL,
+    0x3f9f455bUL, 0x51ccf238UL, 0xbed55317UL, 0xf437b9acUL, 0xbf804beeUL,
+    0xc791a2b5UL, 0x3ec0e993UL, 0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL,
+    0xbeaa48a2UL, 0x0a268358UL, 0xbf55a443UL, 0xdfd978e4UL, 0x3e94b61fUL,
+    0xd7767a58UL, 0x3f431806UL, 0x2aea0000UL, 0xbfc9bbe8UL, 0x7723ea61UL,
+    0xbd3a2369UL, 0x00000000UL, 0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL,
+    0xbf231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL,
+    0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0xbef66191UL, 0x848a46c6UL,
+    0xbfa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL,
+    0xfdd299efUL, 0xbec9dd1aUL, 0x3f8dbaafUL, 0xbf793363UL, 0x309fc6eaUL,
+    0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0xbe9dae11UL,
+    0x3e5c67b3UL, 0xbf4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL,
+    0x3f3d1eb1UL, 0x29cfc000UL, 0xbfc549ceUL, 0xbf159358UL, 0xbd397b33UL,
+    0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x7d98a556UL, 0xbf1a3958UL,
+    0x00000000UL, 0x00000000UL, 0x9d88dc01UL, 0x3f0704c2UL, 0x00000000UL,
+    0x00000000UL, 0x73742a2bUL, 0xbeed054aUL, 0x58844587UL, 0xbf9c2a13UL,
+    0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL, 0x3f9a48f4UL, 0xa8dc9888UL,
+    0xbebf8939UL, 0xaad4b5b8UL, 0xbf72f746UL, 0x9102efa1UL, 0x3ea88f82UL,
+    0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL, 0xbe90f456UL, 0x741fb4edUL,
+    0xbf46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL, 0xca89ff3fUL, 0x3f36db70UL,
+    0xa8a2a000UL, 0xbfc0ee13UL, 0x3da24be1UL, 0xbd338b9fUL, 0x00000000UL,
+    0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0xfffffff8UL, 0x1a154b97UL, 0xbf116b01UL, 0x00000000UL,
+    0x00000000UL, 0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL,
+    0xb93820c8UL, 0xbee264d4UL, 0xbb6cbb18UL, 0xbf94ab8cUL, 0x888d4d92UL,
+    0x3ed0568bUL, 0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0xbeb2f950UL,
+    0x22cf9f74UL, 0xbf6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL,
+    0x3f64aad7UL, 0x637b73afUL, 0xbe83487cUL, 0xe522591aUL, 0xbf3fc092UL,
+    0xa158e8bcUL, 0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL,
+    0xbfb9477fUL, 0xc2c2d2bcUL, 0xbd135ef9UL, 0x00000000UL, 0x00000000UL,
+    0xf2fdb123UL, 0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL,
+    0xfffffff8UL, 0xc41acb64UL, 0xbf05448dUL, 0x00000000UL, 0x00000000UL,
+    0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL, 0x9e42962dUL,
+    0xbed5aea5UL, 0x2579f8efUL, 0xbf8b2398UL, 0x288a1ed9UL, 0x3ec81441UL,
+    0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0xbea57cd3UL, 0x5766336fUL,
+    0xbf617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL, 0x3f62c646UL,
+    0x6b8fb29cUL, 0xbe74e3a3UL, 0xdc4c0409UL, 0xbf33f952UL, 0x9bffe365UL,
+    0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL, 0xbfb0cc62UL,
+    0x016b907fUL, 0xbd119cbcUL, 0x00000000UL, 0x00000000UL, 0xe6b9d8faUL,
+    0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL,
+    0x5daf22a6UL, 0xbef429d7UL, 0x00000000UL, 0x00000000UL, 0x06bca545UL,
+    0x3ef7a27dUL, 0x00000000UL, 0x00000000UL, 0x7211c19aUL, 0xbec41c3eUL,
+    0x956ed53eUL, 0xbf7ae3f4UL, 0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL,
+    0x3f96f713UL, 0x36661e6cUL, 0xbe936e09UL, 0x506f9381UL, 0xbf5122e8UL,
+    0xcb6dd43fUL, 0x3e9041b9UL, 0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL,
+    0xbe625a8aUL, 0xe5a0e9dcUL, 0xbf23499dUL, 0x110384ddUL, 0x3e5b1c2cUL,
+    0x68d43db6UL, 0x3f2cb899UL, 0x6ecac000UL, 0xbfa0c414UL, 0xcd7dd58cUL,
+    0x3d13500fUL, 0x00000000UL, 0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2bf70ebeUL, 0x3ef66a8fUL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0xd644267fUL, 0x3ec22805UL, 0x16c16c17UL, 0x3f96c16cUL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc4e09162UL,
+    0x3e8d6db2UL, 0xbc011567UL, 0x3f61566aUL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x1f79955cUL, 0x3e57da4eUL, 0x9334ef0bUL,
+    0x3f2bbd77UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x55555555UL, 0x3fd55555UL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x5daf22a6UL, 0x3ef429d7UL,
+    0x00000000UL, 0x00000000UL, 0x06bca545UL, 0x3ef7a27dUL, 0x00000000UL,
+    0x00000000UL, 0x7211c19aUL, 0x3ec41c3eUL, 0x956ed53eUL, 0x3f7ae3f4UL,
+    0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL, 0x3f96f713UL, 0x36661e6cUL,
+    0x3e936e09UL, 0x506f9381UL, 0x3f5122e8UL, 0xcb6dd43fUL, 0x3e9041b9UL,
+    0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL, 0x3e625a8aUL, 0xe5a0e9dcUL,
+    0x3f23499dUL, 0x110384ddUL, 0x3e5b1c2cUL, 0x68d43db6UL, 0x3f2cb899UL,
+    0x6ecac000UL, 0x3fa0c414UL, 0xcd7dd58cUL, 0xbd13500fUL, 0x00000000UL,
+    0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0xfffffff8UL, 0xc41acb64UL, 0x3f05448dUL, 0x00000000UL,
+    0x00000000UL, 0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL,
+    0x9e42962dUL, 0x3ed5aea5UL, 0x2579f8efUL, 0x3f8b2398UL, 0x288a1ed9UL,
+    0x3ec81441UL, 0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0x3ea57cd3UL,
+    0x5766336fUL, 0x3f617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL,
+    0x3f62c646UL, 0x6b8fb29cUL, 0x3e74e3a3UL, 0xdc4c0409UL, 0x3f33f952UL,
+    0x9bffe365UL, 0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL,
+    0x3fb0cc62UL, 0x016b907fUL, 0x3d119cbcUL, 0x00000000UL, 0x00000000UL,
+    0xe6b9d8faUL, 0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL,
+    0xfffffff8UL, 0x1a154b97UL, 0x3f116b01UL, 0x00000000UL, 0x00000000UL,
+    0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL, 0xb93820c8UL,
+    0x3ee264d4UL, 0xbb6cbb18UL, 0x3f94ab8cUL, 0x888d4d92UL, 0x3ed0568bUL,
+    0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0x3eb2f950UL, 0x22cf9f74UL,
+    0x3f6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL, 0x3f64aad7UL,
+    0x637b73afUL, 0x3e83487cUL, 0xe522591aUL, 0x3f3fc092UL, 0xa158e8bcUL,
+    0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL, 0x3fb9477fUL,
+    0xc2c2d2bcUL, 0x3d135ef9UL, 0x00000000UL, 0x00000000UL, 0xf2fdb123UL,
+    0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL,
+    0x7d98a556UL, 0x3f1a3958UL, 0x00000000UL, 0x00000000UL, 0x9d88dc01UL,
+    0x3f0704c2UL, 0x00000000UL, 0x00000000UL, 0x73742a2bUL, 0x3eed054aUL,
+    0x58844587UL, 0x3f9c2a13UL, 0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL,
+    0x3f9a48f4UL, 0xa8dc9888UL, 0x3ebf8939UL, 0xaad4b5b8UL, 0x3f72f746UL,
+    0x9102efa1UL, 0x3ea88f82UL, 0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL,
+    0x3e90f456UL, 0x741fb4edUL, 0x3f46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL,
+    0xca89ff3fUL, 0x3f36db70UL, 0xa8a2a000UL, 0x3fc0ee13UL, 0x3da24be1UL,
+    0x3d338b9fUL, 0x00000000UL, 0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL,
+    0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL,
+    0x3f231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL,
+    0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0x3ef66191UL, 0x848a46c6UL,
+    0x3fa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL,
+    0xfdd299efUL, 0x3ec9dd1aUL, 0x3f8dbaafUL, 0x3f793363UL, 0x309fc6eaUL,
+    0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0x3e9dae11UL,
+    0x3e5c67b3UL, 0x3f4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL,
+    0x3f3d1eb1UL, 0x29cfc000UL, 0x3fc549ceUL, 0xbf159358UL, 0x3d397b33UL,
+    0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL,
+    0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x535ad890UL, 0x3f2b9320UL,
+    0x00000000UL, 0x00000000UL, 0x018fdf1fUL, 0x3f16d61dUL, 0x00000000UL,
+    0x00000000UL, 0x0359f1beUL, 0x3f0139e4UL, 0xa4317c6dUL, 0x3fa67e17UL,
+    0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL, 0x3f9f455bUL, 0x51ccf238UL,
+    0x3ed55317UL, 0xf437b9acUL, 0x3f804beeUL, 0xc791a2b5UL, 0x3ec0e993UL,
+    0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL, 0x3eaa48a2UL, 0x0a268358UL,
+    0x3f55a443UL, 0xdfd978e4UL, 0x3e94b61fUL, 0xd7767a58UL, 0x3f431806UL,
+    0x2aea0000UL, 0x3fc9bbe8UL, 0x7723ea61UL, 0x3d3a2369UL, 0x00000000UL,
+    0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL, 0x00000000UL, 0x3ff00000UL,
+    0x00000000UL, 0xfffffff8UL, 0x4f48b8d3UL, 0x3f33eaf9UL, 0x00000000UL,
+    0x00000000UL, 0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL,
+    0xd0258911UL, 0x3f0abaf3UL, 0x23e49fe9UL, 0x3fab5a8cUL, 0x2d53222eUL,
+    0x3ef60d15UL, 0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0x3ee1d3b5UL,
+    0xdbf93b8eUL, 0x3f84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL,
+    0x3f743924UL, 0x794a8297UL, 0x3eb7b7b9UL, 0xe015f797UL, 0x3f5d41f5UL,
+    0xe41a4a56UL, 0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL,
+    0x3fce49ceUL, 0x8c743719UL, 0xbd1eb860UL, 0x00000000UL, 0x00000000UL,
+    0x1b4863cfUL, 0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL,
+    0xfffffff8UL, 0x65965966UL, 0xc0219659UL, 0x00000000UL, 0x00000000UL,
+    0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL, 0x83cd3723UL,
+    0xc02c8342UL, 0x00000000UL, 0xc0000000UL, 0x55e6c23dUL, 0x403226e3UL,
+    0x55555555UL, 0x40055555UL, 0x34451939UL, 0xc0371c96UL, 0xaaaaaaabUL,
+    0xc00aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL, 0x40111111UL,
+    0xa738201fUL, 0xc042bbceUL, 0x05b05b06UL, 0xc015b05bUL, 0x452b75e3UL,
+    0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL, 0xbff00000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0xc7ab4d5aUL, 0xc0085e24UL, 0x00000000UL, 0x00000000UL, 0xe93ea75dUL,
+    0x400b963dUL, 0x00000000UL, 0x00000000UL, 0x94a7f25aUL, 0xc00f37e2UL,
+    0x4b6261cbUL, 0xbff5f984UL, 0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL,
+    0x3ffaf5a5UL, 0x7f2ce8e3UL, 0xc013fe8bUL, 0xfe8e54faUL, 0xbffd7334UL,
+    0x670d618dUL, 0x4016a10cUL, 0x4db97058UL, 0x4000e012UL, 0x24df44ddUL,
+    0xc0199c5fUL, 0x697d6eceUL, 0xc003006eUL, 0x83298b82UL, 0x401cfc4dUL,
+    0x19d490d6UL, 0x40058c19UL, 0x2ae42850UL, 0xbfea4300UL, 0x118e20e6UL,
+    0x3c7a6db8UL, 0x00000000UL, 0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL,
+    0xbff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL,
+    0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0xbff3972eUL, 0xe93463bdUL,
+    0xbfeeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL,
+    0xa04e8ea3UL, 0xbff4541aUL, 0x386accd3UL, 0xbff1369eUL, 0x222a66ddUL,
+    0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0xbff5178fUL,
+    0xddaa0031UL, 0xbff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL,
+    0x3ff29311UL, 0x2ab7f990UL, 0xbfe561b8UL, 0x209c7df1UL, 0xbc87a8c5UL,
+    0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0xcc03e501UL, 0xbfdff10fUL,
+    0x00000000UL, 0x00000000UL, 0x44a4e845UL, 0x3fddb63bUL, 0x00000000UL,
+    0x00000000UL, 0x3768ad9fUL, 0xbfdb72a4UL, 0x3dd01ccaUL, 0xbfe5fdb9UL,
+    0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL, 0x3fe977f9UL, 0xd013b3abUL,
+    0xbfd78ca3UL, 0xbf0bf914UL, 0xbfe4f192UL, 0x4d53e730UL, 0x3fd5d060UL,
+    0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL, 0xbfd4322aUL, 0x5936a835UL,
+    0xbfe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL, 0xef478605UL, 0x3fe1659eUL,
+    0x190834ecUL, 0xbfe11ab7UL, 0xcdb625eaUL, 0x3c8e564bUL, 0x00000000UL,
+    0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x56f37042UL, 0xbfccfc56UL, 0x00000000UL,
+    0x00000000UL, 0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL,
+    0x3d0e7c5dUL, 0xbfc50533UL, 0x9bed9b2eUL, 0xbfdf0ed9UL, 0x5fe7c47cUL,
+    0x3fc1f250UL, 0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0xbfbe5c71UL,
+    0x86362c20UL, 0xbfda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL,
+    0x3fd911bdUL, 0xb56658beUL, 0xbfb5e4c7UL, 0x93a2fd76UL, 0xbfd3c092UL,
+    0xda271794UL, 0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL,
+    0xbfda8279UL, 0xb68c1467UL, 0xbc708b2fUL, 0x00000000UL, 0x3ff00000UL,
+    0x980c4337UL, 0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x9314533eUL, 0xbfbb8ec5UL, 0x00000000UL, 0x00000000UL,
+    0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL, 0xdcb427fdUL,
+    0xbfb13950UL, 0xd87ab0bbUL, 0xbfd5335eUL, 0xce0ae8a5UL, 0x3fabb382UL,
+    0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0xbfa552f1UL, 0x59f21a6dUL,
+    0xbfd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL, 0x3fd0576cUL,
+    0x8f2c2950UL, 0xbf9a4898UL, 0xc0b3f22cUL, 0xbfc59462UL, 0x1883a4b8UL,
+    0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL, 0xbfd36a08UL,
+    0x1dce993dUL, 0x3c6d704dUL, 0x00000000UL, 0x3ff00000UL, 0x2b82ab63UL,
+    0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL,
+    0x5a279ea3UL, 0xbfaa3407UL, 0x00000000UL, 0x00000000UL, 0x432d65faUL,
+    0x3fa70153UL, 0x00000000UL, 0x00000000UL, 0x891a4602UL, 0xbf9d03efUL,
+    0xd62ca5f8UL, 0xbfca77d9UL, 0xb35f4628UL, 0x3f97a265UL, 0x433258faUL,
+    0x3fd8cf51UL, 0xb58fd909UL, 0xbf8f88e3UL, 0x01771ceaUL, 0xbfc2b154UL,
+    0xf3562f8eUL, 0x3f888f57UL, 0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL,
+    0xbf80f44cUL, 0x214368e9UL, 0xbfb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL,
+    0x172dbbf0UL, 0x3fb6cb8eUL, 0xe0553158UL, 0xbfc975f5UL, 0x593fe814UL,
+    0xbc2ef5d3UL, 0x00000000UL, 0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL,
+    0xbf953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL,
+    0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0xbf85ad63UL, 0xdc230b9bUL,
+    0xbfb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL,
+    0x77bb08baUL, 0xbf757c85UL, 0xb6247521UL, 0xbfb1381eUL, 0x5922170cUL,
+    0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0xbf64e391UL,
+    0x3e666320UL, 0xbfa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL,
+    0x3fafa8aeUL, 0x8c5b2da2UL, 0xbfb936bbUL, 0x4e88f7a5UL, 0xbc587d05UL,
+    0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x6dc9c883UL, 0x3fe45f30UL,
+    0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x43780000UL, 0x00000000UL,
+    0x43380000UL, 0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL,
+    0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL, 0x3707344aUL,
+    0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL, 0x00000000UL, 0x80000000UL,
+    0x00000000UL, 0x80000000UL, 0x676733afUL, 0x3d32e7b9UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x7ff00000UL, 0x00000000UL, 0x00000000UL, 0xfffc0000UL,
+    0xffffffffUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x43600000UL,
+    0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3c800000UL, 0x00000000UL,
+    0x00000000UL, 0x00000000UL, 0x3ca00000UL, 0x00000000UL, 0x00000000UL,
+    0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL, 0x00000000UL,
+    0x40300000UL, 0x00000000UL, 0x3ff00000UL
+};
+
+void MacroAssembler::fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) {
+
+  Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
+  Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
+  Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
+  Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start;
+
+  assert_different_registers(tmp, eax, ecx, edx);
+
+  address static_const_table_tan = (address)_static_const_table_tan;
+
+  bind(start);
+  subl(rsp, 120);
+  movl(Address(rsp, 56), tmp);
+  lea(tmp, ExternalAddress(static_const_table_tan));
+  movsd(xmm0, Address(rsp, 128));
+  pextrw(eax, xmm0, 3);
+  andl(eax, 32767);
+  subl(eax, 14368);
+  cmpl(eax, 2216);
+  jcc(Assembler::above, L_2TAG_PACKET_0_0_2);
+  movdqu(xmm5, Address(tmp, 5840));
+  movdqu(xmm6, Address(tmp, 5856));
+  unpcklpd(xmm0, xmm0);
+  movdqu(xmm4, Address(tmp, 5712));
+  andpd(xmm4, xmm0);
+  movdqu(xmm1, Address(tmp, 5632));
+  mulpd(xmm1, xmm0);
+  por(xmm5, xmm4);
+  addpd(xmm1, xmm5);
+  movdqu(xmm7, xmm1);
+  unpckhpd(xmm7, xmm7);
+  cvttsd2sil(edx, xmm7);
+  cvttpd2dq(xmm1, xmm1);
+  cvtdq2pd(xmm1, xmm1);
+  mulpd(xmm1, xmm6);
+  movdqu(xmm3, Address(tmp, 5664));
+  movsd(xmm5, Address(tmp, 5728));
+  addl(edx, 469248);
+  movdqu(xmm4, Address(tmp, 5680));
+  mulpd(xmm3, xmm1);
+  andl(edx, 31);
+  mulsd(xmm5, xmm1);
+  movl(ecx, edx);
+  mulpd(xmm4, xmm1);
+  shll(ecx, 1);
+  subpd(xmm0, xmm3);
+  mulpd(xmm1, Address(tmp, 5696));
+  addl(edx, ecx);
+  shll(ecx, 2);
+  addl(edx, ecx);
+  addsd(xmm5, xmm0);
+  movdqu(xmm2, xmm0);
+  subpd(xmm0, xmm4);
+  movsd(xmm6, Address(tmp, 5744));
+  shll(edx, 4);
+  lea(eax, Address(tmp, 0));
+  andpd(xmm5, Address(tmp, 5776));
+  movdqu(xmm3, xmm0);
+  addl(eax, edx);
+  subpd(xmm2, xmm0);
+  unpckhpd(xmm0, xmm0);
+  divsd(xmm6, xmm5);
+  subpd(xmm2, xmm4);
+  movdqu(xmm7, Address(eax, 16));
+  subsd(xmm3, xmm5);
+  mulpd(xmm7, xmm0);
+  subpd(xmm2, xmm1);
+  movdqu(xmm1, Address(eax, 48));
+  mulpd(xmm1, xmm0);
+  movdqu(xmm4, Address(eax, 96));
+  mulpd(xmm4, xmm0);
+  addsd(xmm2, xmm3);
+  movdqu(xmm3, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm7, Address(eax, 0));
+  addpd(xmm1, Address(eax, 32));
+  mulpd(xmm1, xmm0);
+  addpd(xmm4, Address(eax, 80));
+  addpd(xmm7, xmm1);
+  movdqu(xmm1, Address(eax, 112));
+  mulpd(xmm1, xmm0);
+  mulpd(xmm0, xmm0);
+  addpd(xmm4, xmm1);
+  movdqu(xmm1, Address(eax, 64));
+  mulpd(xmm1, xmm0);
+  addpd(xmm7, xmm1);
+  movdqu(xmm1, xmm3);
+  mulpd(xmm3, xmm0);
+  mulsd(xmm0, xmm0);
+  mulpd(xmm1, Address(eax, 144));
+  mulpd(xmm4, xmm3);
+  movdqu(xmm3, xmm1);
+  addpd(xmm7, xmm4);
+  movdqu(xmm4, xmm1);
+  mulsd(xmm0, xmm7);
+  unpckhpd(xmm7, xmm7);
+  addsd(xmm0, xmm7);
+  unpckhpd(xmm1, xmm1);
+  addsd(xmm3, xmm1);
+  subsd(xmm4, xmm3);
+  addsd(xmm1, xmm4);
+  movdqu(xmm4, xmm2);
+  movsd(xmm7, Address(eax, 144));
+  unpckhpd(xmm2, xmm2);
+  addsd(xmm7, Address(eax, 152));
+  mulsd(xmm7, xmm2);
+  addsd(xmm7, Address(eax, 136));
+  addsd(xmm7, xmm1);
+  addsd(xmm0, xmm7);
+  movsd(xmm7, Address(tmp, 5744));
+  mulsd(xmm4, xmm6);
+  movsd(xmm2, Address(eax, 168));
+  andpd(xmm2, xmm6);
+  mulsd(xmm5, xmm2);
+  mulsd(xmm6, Address(eax, 160));
+  subsd(xmm7, xmm5);
+  subsd(xmm2, Address(eax, 128));
+  subsd(xmm7, xmm4);
+  mulsd(xmm7, xmm6);
+  movdqu(xmm4, xmm3);
+  subsd(xmm3, xmm2);
+  addsd(xmm2, xmm3);
+  subsd(xmm4, xmm2);
+  addsd(xmm0, xmm4);
+  subsd(xmm0, xmm7);
+  addsd(xmm0, xmm3);
+  movsd(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_0_0_2);
+  jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
+  shrl(eax, 4);
+  cmpl(eax, 268434558);
+  jcc(Assembler::notEqual, L_2TAG_PACKET_3_0_2);
+  movdqu(xmm3, xmm0);
+  mulsd(xmm3, Address(tmp, 5808));
+
+  bind(L_2TAG_PACKET_3_0_2);
+  movsd(xmm3, Address(tmp, 5792));
+  mulsd(xmm3, xmm0);
+  addsd(xmm3, xmm0);
+  mulsd(xmm3, Address(tmp, 5808));
+  movsd(Address(rsp, 0), xmm3);
+  fld_d(Address(rsp, 0));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_2_0_2);
+  movq(xmm7, Address(tmp, 5712));
+  andpd(xmm7, xmm0);
+  xorpd(xmm7, xmm0);
+  ucomisd(xmm7, Address(tmp, 5760));
+  jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
+  subl(rsp, 32);
+  movsd(Address(rsp, 0), xmm0);
+  lea(eax, Address(rsp, 40));
+  movl(Address(rsp, 8), eax);
+  movl(eax, 2);
+  movl(Address(rsp, 12), eax);
+  call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_tan_cot_huge())));
+  addl(rsp, 32);
+  fld_d(Address(rsp, 8));
+  jmp(L_2TAG_PACKET_1_0_2);
+
+  bind(L_2TAG_PACKET_4_0_2);
+  movq(Address(rsp, 0), xmm0);
+  fld_d(Address(rsp, 0));
+  fsub_d(Address(rsp, 0));
+
+  bind(L_2TAG_PACKET_1_0_2);
+  movl(tmp, Address(rsp, 56));
+}
+#endif
diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
index 3763b05..a24397f 100644
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
@@ -29,9 +29,9 @@
 #include "code/icBuffer.hpp"
 #include "code/vtableStubs.hpp"
 #include "interpreter/interpreter.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/compiledICHolder.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vframeArray.hpp"
 #include "vmreg_x86.inline.hpp"
@@ -1953,7 +1953,7 @@
   }
 
   // RedefineClasses() tracing support for obsolete method entry
-  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete)) {
     __ mov_metadata(rax, method());
     __ call_VM_leaf(
          CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
index 8fca552..81ed472f 100644
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
@@ -32,9 +32,9 @@
 #include "code/icBuffer.hpp"
 #include "code/vtableStubs.hpp"
 #include "interpreter/interpreter.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/compiledICHolder.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vframeArray.hpp"
 #include "vmreg_x86.inline.hpp"
@@ -2322,7 +2322,7 @@
   }
 
   // RedefineClasses() tracing support for obsolete method entry
-  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete)) {
     // protect the args we've loaded
     save_args(masm, total_c_args, c_arg, out_regs);
     __ mov_metadata(c_rarg1, method());
diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp
index 0f11b9c..adcfe63 100644
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,21 +63,6 @@
 // -------------------------------------------------------------------------------------------------------------------------
 // Stub Code definitions
 
-static address handle_unsafe_access() {
-  JavaThread* thread = JavaThread::current();
-  address pc  = thread->saved_exception_pc();
-  // pc is the instruction which we must emulate
-  // doing a no-op is fine:  return garbage from the load
-  // therefore, compute npc
-  address npc = Assembler::locate_next_instruction(pc);
-
-  // request an async exception
-  thread->set_pending_unsafe_access_error();
-
-  // return address of next instruction to execute
-  return npc;
-}
-
 class StubGenerator: public StubCodeGenerator {
  private:
 
@@ -623,27 +608,6 @@
   }
 
 
-  //---------------------------------------------------------------------------
-  // The following routine generates a subroutine to throw an asynchronous
-  // UnknownError when an unsafe access gets a fault that could not be
-  // reasonably prevented by the programmer.  (Example: SIGBUS/OBJERR.)
-  address generate_handler_for_unsafe_access() {
-    StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access");
-    address start = __ pc();
-
-    __ push(0);                       // hole for return address-to-be
-    __ pusha();                       // push registers
-    Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord);
-    BLOCK_COMMENT("call handle_unsafe_access");
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access)));
-    __ movptr(next_pc, rax);          // stuff next address
-    __ popa();
-    __ ret(0);                        // jump to next address
-
-    return start;
-  }
-
-
   //----------------------------------------------------------------------------------------------------
   // Non-destructive plausibility checks for oops
 
@@ -2092,25 +2056,6 @@
                                entry_checkcast_arraycopy);
   }
 
-  void generate_math_stubs() {
-    {
-      StubCodeMark mark(this, "StubRoutines", "log10");
-      StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc();
-
-      __ fld_d(Address(rsp, 4));
-      __ flog10();
-      __ ret(0);
-    }
-    {
-      StubCodeMark mark(this, "StubRoutines", "tan");
-      StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc();
-
-      __ fld_d(Address(rsp, 4));
-      __ trigfunc('t');
-      __ ret(0);
-    }
-  }
-
   // AES intrinsic stubs
   enum {AESBlockSize = 16};
 
@@ -3533,6 +3478,31 @@
 
  }
 
+ address generate_libmLog10() {
+   address start = __ pc();
+
+   const XMMRegister x0 = xmm0;
+   const XMMRegister x1 = xmm1;
+   const XMMRegister x2 = xmm2;
+   const XMMRegister x3 = xmm3;
+
+   const XMMRegister x4 = xmm4;
+   const XMMRegister x5 = xmm5;
+   const XMMRegister x6 = xmm6;
+   const XMMRegister x7 = xmm7;
+
+   const Register tmp = rbx;
+
+   BLOCK_COMMENT("Entry:");
+   __ enter(); // required for proper stackwalking of RuntimeStub frame
+   __ fast_log10(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
+   __ leave(); // required for proper stackwalking of RuntimeStub frame
+   __ ret(0);
+
+   return start;
+
+ }
+
  address generate_libmPow() {
    address start = __ pc();
 
@@ -3629,6 +3599,44 @@
 
  }
 
+ address generate_libm_tan_cot_huge() {
+   address start = __ pc();
+
+   const XMMRegister x0 = xmm0;
+   const XMMRegister x1 = xmm1;
+
+   BLOCK_COMMENT("Entry:");
+   __ libm_tancot_huge(x0, x1, rax, rcx, rdx, rbx, rsi, rdi, rbp, rsp);
+
+   return start;
+
+ }
+
+ address generate_libmTan() {
+   address start = __ pc();
+
+   const XMMRegister x0 = xmm0;
+   const XMMRegister x1 = xmm1;
+   const XMMRegister x2 = xmm2;
+   const XMMRegister x3 = xmm3;
+
+   const XMMRegister x4 = xmm4;
+   const XMMRegister x5 = xmm5;
+   const XMMRegister x6 = xmm6;
+   const XMMRegister x7 = xmm7;
+
+   const Register tmp = rbx;
+
+   BLOCK_COMMENT("Entry:");
+   __ enter(); // required for proper stackwalking of RuntimeStub frame
+   __ fast_tan(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
+   __ leave(); // required for proper stackwalking of RuntimeStub frame
+   __ ret(0);
+
+   return start;
+
+ }
+
   // Safefetch stubs.
   void generate_safefetch(const char* name, int size, address* entry,
                           address* fault_pc, address* continuation_pc) {
@@ -3821,9 +3829,6 @@
     // These are currently used by Solaris/Intel
     StubRoutines::_atomic_xchg_entry            = generate_atomic_xchg();
 
-    StubRoutines::_handler_for_unsafe_access_entry =
-      generate_handler_for_unsafe_access();
-
     // platform dependent
     create_control_words();
 
@@ -3852,24 +3857,25 @@
       StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table;
       StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul);
     }
-    if (VM_Version::supports_sse2()) {
+    if (VM_Version::supports_sse2() && UseLibmIntrinsic) {
+      StubRoutines::x86::_L_2il0floatpacket_0_adr = (address)StubRoutines::x86::_L_2il0floatpacket_0;
+      StubRoutines::x86::_Pi4Inv_adr = (address)StubRoutines::x86::_Pi4Inv;
+      StubRoutines::x86::_Pi4x3_adr = (address)StubRoutines::x86::_Pi4x3;
+      StubRoutines::x86::_Pi4x4_adr = (address)StubRoutines::x86::_Pi4x4;
+      StubRoutines::x86::_ones_adr = (address)StubRoutines::x86::_ones;
       StubRoutines::_dexp = generate_libmExp();
       StubRoutines::_dlog = generate_libmLog();
+      StubRoutines::_dlog10 = generate_libmLog10();
       StubRoutines::_dpow = generate_libmPow();
-      if (UseLibmSinIntrinsic || UseLibmCosIntrinsic) {
-        StubRoutines::_dlibm_reduce_pi04l = generate_libm_reduce_pi04l();
-        StubRoutines::_dlibm_sin_cos_huge = generate_libm_sin_cos_huge();
-      }
-      if (UseLibmSinIntrinsic) {
-        StubRoutines::_dsin = generate_libmSin();
-      }
-      if (UseLibmCosIntrinsic) {
-        StubRoutines::_dcos = generate_libmCos();
-      }
+      StubRoutines::_dlibm_reduce_pi04l = generate_libm_reduce_pi04l();
+      StubRoutines::_dlibm_sin_cos_huge = generate_libm_sin_cos_huge();
+      StubRoutines::_dsin = generate_libmSin();
+      StubRoutines::_dcos = generate_libmCos();
+      StubRoutines::_dlibm_tan_cot_huge = generate_libm_tan_cot_huge();
+      StubRoutines::_dtan = generate_libmTan();
     }
   }
 
-
   void generate_all() {
     // Generates all stubs and initializes the entry points
 
@@ -3888,8 +3894,6 @@
     // arraycopy stubs used by compilers
     generate_arraycopy_stubs();
 
-    generate_math_stubs();
-
     // don't bother generating these AES intrinsic stubs unless global flag is set
     if (UseAESIntrinsics) {
       StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask();  // might be needed by the others
diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp
index d51f3a6..768cff7 100644
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,21 +61,6 @@
 
 // Stub Code definitions
 
-static address handle_unsafe_access() {
-  JavaThread* thread = JavaThread::current();
-  address pc = thread->saved_exception_pc();
-  // pc is the instruction which we must emulate
-  // doing a no-op is fine:  return garbage from the load
-  // therefore, compute npc
-  address npc = Assembler::locate_next_instruction(pc);
-
-  // request an async exception
-  thread->set_pending_unsafe_access_error();
-
-  // return address of next instruction to execute
-  return npc;
-}
-
 class StubGenerator: public StubCodeGenerator {
  private:
 
@@ -989,32 +974,6 @@
     return start;
   }
 
-  // The following routine generates a subroutine to throw an
-  // asynchronous UnknownError when an unsafe access gets a fault that
-  // could not be reasonably prevented by the programmer.  (Example:
-  // SIGBUS/OBJERR.)
-  address generate_handler_for_unsafe_access() {
-    StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access");
-    address start = __ pc();
-
-    __ push(0);                       // hole for return address-to-be
-    __ pusha();                       // push registers
-    Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord);
-
-    // FIXME: this probably needs alignment logic
-
-    __ subptr(rsp, frame::arg_reg_save_area_bytes);
-    BLOCK_COMMENT("call handle_unsafe_access");
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access)));
-    __ addptr(rsp, frame::arg_reg_save_area_bytes);
-
-    __ movptr(next_pc, rax);          // stuff next address
-    __ popa();
-    __ ret(0);                        // jump to next address
-
-    return start;
-  }
-
   // Non-destructive plausibility checks for oops
   //
   // Arguments:
@@ -2971,35 +2930,6 @@
     StubRoutines::_arrayof_oop_arraycopy_uninit             = StubRoutines::_oop_arraycopy_uninit;
   }
 
-  void generate_math_stubs() {
-    {
-      StubCodeMark mark(this, "StubRoutines", "log10");
-      StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc();
-
-      __ subq(rsp, 8);
-      __ movdbl(Address(rsp, 0), xmm0);
-      __ fld_d(Address(rsp, 0));
-      __ flog10();
-      __ fstp_d(Address(rsp, 0));
-      __ movdbl(xmm0, Address(rsp, 0));
-      __ addq(rsp, 8);
-      __ ret(0);
-    }
-    {
-      StubCodeMark mark(this, "StubRoutines", "tan");
-      StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc();
-
-      __ subq(rsp, 8);
-      __ movdbl(Address(rsp, 0), xmm0);
-      __ fld_d(Address(rsp, 0));
-      __ trigfunc('t');
-      __ fstp_d(Address(rsp, 0));
-      __ movdbl(xmm0, Address(rsp, 0));
-      __ addq(rsp, 8);
-      __ ret(0);
-    }
-  }
-
   // AES intrinsic stubs
   enum {AESBlockSize = 16};
 
@@ -3800,12 +3730,29 @@
     address start = __ pc();
     __ emit_data64(0x0405060700010203, relocInfo::none);
     __ emit_data64(0x0c0d0e0f08090a0b, relocInfo::none);
+
+    if (VM_Version::supports_avx2()) {
+      __ emit_data64(0x0405060700010203, relocInfo::none); // second copy
+      __ emit_data64(0x0c0d0e0f08090a0b, relocInfo::none);
+      // _SHUF_00BA
+      __ emit_data64(0x0b0a090803020100, relocInfo::none);
+      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
+      __ emit_data64(0x0b0a090803020100, relocInfo::none);
+      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
+      // _SHUF_DC00
+      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
+      __ emit_data64(0x0b0a090803020100, relocInfo::none);
+      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
+      __ emit_data64(0x0b0a090803020100, relocInfo::none);
+    }
+
     return start;
   }
 
 // ofs and limit are use for multi-block byte array.
 // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
   address generate_sha256_implCompress(bool multi_block, const char *name) {
+    assert(VM_Version::supports_sha() || VM_Version::supports_avx2(), "");
     __ align(CodeEntryAlignment);
     StubCodeMark mark(this, "StubRoutines", name);
     address start = __ pc();
@@ -3834,16 +3781,37 @@
     __ movdqu(Address(rsp, 0), xmm6);
     __ movdqu(Address(rsp, 2 * wordSize), xmm7);
     __ movdqu(Address(rsp, 4 * wordSize), xmm8);
+
+    if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) {
+      __ subptr(rsp, 10 * wordSize);
+      __ movdqu(Address(rsp, 0), xmm9);
+      __ movdqu(Address(rsp, 2 * wordSize), xmm10);
+      __ movdqu(Address(rsp, 4 * wordSize), xmm11);
+      __ movdqu(Address(rsp, 6 * wordSize), xmm12);
+      __ movdqu(Address(rsp, 8 * wordSize), xmm13);
+    }
 #endif
 
     __ subptr(rsp, 4 * wordSize);
 
-    __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
-      buf, state, ofs, limit, rsp, multi_block, shuf_mask);
-
+    if (VM_Version::supports_sha()) {
+      __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
+        buf, state, ofs, limit, rsp, multi_block, shuf_mask);
+    } else if (VM_Version::supports_avx2()) {
+      __ sha256_AVX2(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
+        buf, state, ofs, limit, rsp, multi_block, shuf_mask);
+    }
     __ addptr(rsp, 4 * wordSize);
 #ifdef _WIN64
     // restore xmm regs belonging to calling function
+    if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) {
+      __ movdqu(xmm9, Address(rsp, 0));
+      __ movdqu(xmm10, Address(rsp, 2 * wordSize));
+      __ movdqu(xmm11, Address(rsp, 4 * wordSize));
+      __ movdqu(xmm12, Address(rsp, 6 * wordSize));
+      __ movdqu(xmm13, Address(rsp, 8 * wordSize));
+      __ addptr(rsp, 10 * wordSize);
+    }
     __ movdqu(xmm6, Address(rsp, 0));
     __ movdqu(xmm7, Address(rsp, 2 * wordSize));
     __ movdqu(xmm8, Address(rsp, 4 * wordSize));
@@ -4400,7 +4368,7 @@
   *   c_rarg0   - int crc
   *   c_rarg1   - byte* buf
   *   c_rarg2   - long length
-  *   c_rarg3   - table_start - optional (present only when doing a library_calll,
+  *   c_rarg3   - table_start - optional (present only when doing a library_call,
   *              not used by x86 algorithm)
   *
   * Ouput:
@@ -4523,6 +4491,9 @@
   *    c_rarg1   - objb     address
   *    c_rarg3   - length   length
   *    c_rarg4   - scale    log2_array_indxscale
+  *
+  *  Output:
+  *        rax   - int >= mismatched index, < 0 bitwise complement of tail
   */
   address generate_vectorizedMismatch() {
     __ align(CodeEntryAlignment);
@@ -4744,6 +4715,46 @@
 
   }
 
+  address generate_libmLog10() {
+    address start = __ pc();
+
+    const XMMRegister x0 = xmm0;
+    const XMMRegister x1 = xmm1;
+    const XMMRegister x2 = xmm2;
+    const XMMRegister x3 = xmm3;
+
+    const XMMRegister x4 = xmm4;
+    const XMMRegister x5 = xmm5;
+    const XMMRegister x6 = xmm6;
+    const XMMRegister x7 = xmm7;
+
+    const Register tmp = r11;
+
+    BLOCK_COMMENT("Entry:");
+    __ enter(); // required for proper stackwalking of RuntimeStub frame
+
+#ifdef _WIN64
+    // save the xmm registers which must be preserved 6-7
+    __ subptr(rsp, 4 * wordSize);
+    __ movdqu(Address(rsp, 0), xmm6);
+    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
+#endif
+    __ fast_log10(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
+
+#ifdef _WIN64
+    // restore xmm regs belonging to calling function
+    __ movdqu(xmm6, Address(rsp, 0));
+    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
+    __ addptr(rsp, 4 * wordSize);
+#endif
+
+    __ leave(); // required for proper stackwalking of RuntimeStub frame
+    __ ret(0);
+
+    return start;
+
+  }
+
   address generate_libmPow() {
     address start = __ pc();
 
@@ -4809,6 +4820,8 @@
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
 #ifdef _WIN64
+    __ push(rsi);
+    __ push(rdi);
     // save the xmm registers which must be preserved 6-7
     __ subptr(rsp, 4 * wordSize);
     __ movdqu(Address(rsp, 0), xmm6);
@@ -4821,6 +4834,8 @@
     __ movdqu(xmm6, Address(rsp, 0));
     __ movdqu(xmm7, Address(rsp, 2 * wordSize));
     __ addptr(rsp, 4 * wordSize);
+    __ pop(rdi);
+    __ pop(rsi);
 #endif
 
     __ leave(); // required for proper stackwalking of RuntimeStub frame
@@ -4852,6 +4867,8 @@
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
 #ifdef _WIN64
+    __ push(rsi);
+    __ push(rdi);
     // save the xmm registers which must be preserved 6-7
     __ subptr(rsp, 4 * wordSize);
     __ movdqu(Address(rsp, 0), xmm6);
@@ -4864,6 +4881,55 @@
     __ movdqu(xmm6, Address(rsp, 0));
     __ movdqu(xmm7, Address(rsp, 2 * wordSize));
     __ addptr(rsp, 4 * wordSize);
+    __ pop(rdi);
+    __ pop(rsi);
+#endif
+
+    __ leave(); // required for proper stackwalking of RuntimeStub frame
+    __ ret(0);
+
+    return start;
+
+  }
+
+  address generate_libmTan() {
+    address start = __ pc();
+
+    const XMMRegister x0 = xmm0;
+    const XMMRegister x1 = xmm1;
+    const XMMRegister x2 = xmm2;
+    const XMMRegister x3 = xmm3;
+
+    const XMMRegister x4 = xmm4;
+    const XMMRegister x5 = xmm5;
+    const XMMRegister x6 = xmm6;
+    const XMMRegister x7 = xmm7;
+
+    const Register tmp1 = r8;
+    const Register tmp2 = r9;
+    const Register tmp3 = r10;
+    const Register tmp4 = r11;
+
+    BLOCK_COMMENT("Entry:");
+    __ enter(); // required for proper stackwalking of RuntimeStub frame
+
+#ifdef _WIN64
+    __ push(rsi);
+    __ push(rdi);
+    // save the xmm registers which must be preserved 6-7
+    __ subptr(rsp, 4 * wordSize);
+    __ movdqu(Address(rsp, 0), xmm6);
+    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
+#endif
+    __ fast_tan(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
+
+#ifdef _WIN64
+    // restore xmm regs belonging to calling function
+    __ movdqu(xmm6, Address(rsp, 0));
+    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
+    __ addptr(rsp, 4 * wordSize);
+    __ pop(rdi);
+    __ pop(rsi);
 #endif
 
     __ leave(); // required for proper stackwalking of RuntimeStub frame
@@ -5032,9 +5098,6 @@
     StubRoutines::_atomic_add_ptr_entry      = generate_atomic_add_ptr();
     StubRoutines::_fence_entry               = generate_orderaccess_fence();
 
-    StubRoutines::_handler_for_unsafe_access_entry =
-      generate_handler_for_unsafe_access();
-
     // platform dependent
     StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp();
     StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp();
@@ -5064,16 +5127,28 @@
       StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table;
       StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul);
     }
-    if (VM_Version::supports_sse2()) {
+    if (VM_Version::supports_sse2() && UseLibmIntrinsic) {
+      StubRoutines::x86::_ONEHALF_adr = (address)StubRoutines::x86::_ONEHALF;
+      StubRoutines::x86::_P_2_adr = (address)StubRoutines::x86::_P_2;
+      StubRoutines::x86::_SC_4_adr = (address)StubRoutines::x86::_SC_4;
+      StubRoutines::x86::_Ctable_adr = (address)StubRoutines::x86::_Ctable;
+      StubRoutines::x86::_SC_2_adr = (address)StubRoutines::x86::_SC_2;
+      StubRoutines::x86::_SC_3_adr = (address)StubRoutines::x86::_SC_3;
+      StubRoutines::x86::_SC_1_adr = (address)StubRoutines::x86::_SC_1;
+      StubRoutines::x86::_PI_INV_TABLE_adr = (address)StubRoutines::x86::_PI_INV_TABLE;
+      StubRoutines::x86::_PI_4_adr = (address)StubRoutines::x86::_PI_4;
+      StubRoutines::x86::_PI32INV_adr = (address)StubRoutines::x86::_PI32INV;
+      StubRoutines::x86::_SIGN_MASK_adr = (address)StubRoutines::x86::_SIGN_MASK;
+      StubRoutines::x86::_P_1_adr = (address)StubRoutines::x86::_P_1;
+      StubRoutines::x86::_P_3_adr = (address)StubRoutines::x86::_P_3;
+      StubRoutines::x86::_NEG_ZERO_adr = (address)StubRoutines::x86::_NEG_ZERO;
       StubRoutines::_dexp = generate_libmExp();
       StubRoutines::_dlog = generate_libmLog();
+      StubRoutines::_dlog10 = generate_libmLog10();
       StubRoutines::_dpow = generate_libmPow();
-      if (UseLibmSinIntrinsic) {
-        StubRoutines::_dsin = generate_libmSin();
-      }
-      if (UseLibmCosIntrinsic) {
-        StubRoutines::_dcos = generate_libmCos();
-      }
+      StubRoutines::_dtan = generate_libmTan();
+      StubRoutines::_dsin = generate_libmSin();
+      StubRoutines::_dcos = generate_libmCos();
     }
   }
 
@@ -5118,8 +5193,6 @@
     // arraycopy stubs used by compilers
     generate_arraycopy_stubs();
 
-    generate_math_stubs();
-
     // don't bother generating these AES intrinsic stubs unless global flag is set
     if (UseAESIntrinsics) {
       StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask();  // needed by the others
@@ -5141,6 +5214,13 @@
     }
     if (UseSHA256Intrinsics) {
       StubRoutines::x86::_k256_adr = (address)StubRoutines::x86::_k256;
+      char* dst = (char*)StubRoutines::x86::_k256_W;
+      char* src = (char*)StubRoutines::x86::_k256;
+      for (int ii = 0; ii < 16; ++ii) {
+        memcpy(dst + 32 * ii,      src + 16 * ii, 16);
+        memcpy(dst + 32 * ii + 16, src + 16 * ii, 16);
+      }
+      StubRoutines::x86::_k256_W_adr = (address)StubRoutines::x86::_k256_W;
       StubRoutines::x86::_pshuffle_byte_flip_mask_addr = generate_pshuffle_byte_flip_mask();
       StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress");
       StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB");
@@ -5170,9 +5250,6 @@
     if (UseMulAddIntrinsic) {
       StubRoutines::_mulAdd = generate_mulAdd();
     }
-    if (UseVectorizedMismatchIntrinsic) {
-      StubRoutines::_vectorizedMismatch = generate_vectorizedMismatch();
-    }
 #ifndef _WINDOWS
     if (UseMontgomeryMultiplyIntrinsic) {
       StubRoutines::_montgomeryMultiply
@@ -5184,6 +5261,10 @@
     }
 #endif // WINDOWS
 #endif // COMPILER2
+
+    if (UseVectorizedMismatchIntrinsic) {
+      StubRoutines::_vectorizedMismatch = generate_vectorizedMismatch();
+    }
   }
 
  public:
diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp
index 141fbf0..ea7952e 100644
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp
@@ -46,8 +46,34 @@
 address StubRoutines::x86::_upper_word_mask_addr = NULL;
 address StubRoutines::x86::_shuffle_byte_flip_mask_addr = NULL;
 address StubRoutines::x86::_k256_adr = NULL;
+#ifdef _LP64
+address StubRoutines::x86::_k256_W_adr = NULL;
+#endif
 address StubRoutines::x86::_pshuffle_byte_flip_mask_addr = NULL;
 
+//tables common for sin and cos
+address StubRoutines::x86::_ONEHALF_adr = NULL;
+address StubRoutines::x86::_P_2_adr = NULL;
+address StubRoutines::x86::_SC_4_adr = NULL;
+address StubRoutines::x86::_Ctable_adr = NULL;
+address StubRoutines::x86::_SC_2_adr = NULL;
+address StubRoutines::x86::_SC_3_adr = NULL;
+address StubRoutines::x86::_SC_1_adr = NULL;
+address StubRoutines::x86::_PI_INV_TABLE_adr = NULL;
+address StubRoutines::x86::_PI_4_adr = NULL;
+address StubRoutines::x86::_PI32INV_adr = NULL;
+address StubRoutines::x86::_SIGN_MASK_adr = NULL;
+address StubRoutines::x86::_P_1_adr = NULL;
+address StubRoutines::x86::_P_3_adr = NULL;
+address StubRoutines::x86::_NEG_ZERO_adr = NULL;
+
+//tables common for sincos and tancot
+address StubRoutines::x86::_L_2il0floatpacket_0_adr = NULL;
+address StubRoutines::x86::_Pi4Inv_adr = NULL;
+address StubRoutines::x86::_Pi4x3_adr = NULL;
+address StubRoutines::x86::_Pi4x4_adr = NULL;
+address StubRoutines::x86::_ones_adr = NULL;
+
 uint64_t StubRoutines::x86::_crc_by128_masks[] =
 {
   /* The fields in this structure are arranged so that they can be
@@ -266,3 +292,9 @@
     0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
     0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
 };
+
+#ifdef _LP64
+// used in MacroAssembler::sha256_AVX2
+// dynamically built from _k256
+ALIGNED_(64) juint StubRoutines::x86::_k256_W[2*sizeof(StubRoutines::x86::_k256)];
+#endif
diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp
index 4c9ce01..eeceb01 100644
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp
@@ -54,9 +54,55 @@
   //k256 table for sha256
   static juint _k256[];
   static address _k256_adr;
+#ifdef _LP64
+  static juint _k256_W[];
+  static address _k256_W_adr;
+#endif
   // byte flip mask for sha256
   static address _pshuffle_byte_flip_mask_addr;
 
+  //tables common for LIBM sin and cos
+  static juint _ONEHALF[];
+  static address _ONEHALF_adr;
+  static juint _P_2[];
+  static address _P_2_adr;
+  static juint _SC_4[];
+  static address _SC_4_adr;
+  static juint _Ctable[];
+  static address _Ctable_adr;
+  static juint _SC_2[];
+  static address _SC_2_adr;
+  static juint _SC_3[];
+  static address _SC_3_adr;
+  static juint _SC_1[];
+  static address _SC_1_adr;
+  static juint _PI_INV_TABLE[];
+  static address _PI_INV_TABLE_adr;
+  static juint _PI_4[];
+  static address _PI_4_adr;
+  static juint _PI32INV[];
+  static address _PI32INV_adr;
+  static juint _SIGN_MASK[];
+  static address _SIGN_MASK_adr;
+  static juint _P_1[];
+  static address _P_1_adr;
+  static juint _P_3[];
+  static address _P_3_adr;
+  static juint _NEG_ZERO[];
+  static address _NEG_ZERO_adr;
+
+  //tables common for LIBM sincos and tancot
+  static juint _L_2il0floatpacket_0[];
+  static address _L_2il0floatpacket_0_adr;
+  static juint _Pi4Inv[];
+  static address _Pi4Inv_adr;
+  static juint _Pi4x3[];
+  static address _Pi4x3_adr;
+  static juint _Pi4x4[];
+  static address _Pi4x4_adr;
+  static juint _ones[];
+  static address _ones_adr;
+
  public:
   static address verify_mxcsr_entry()    { return _verify_mxcsr_entry; }
   static address key_shuffle_mask_addr() { return _key_shuffle_mask_addr; }
@@ -67,6 +113,29 @@
   static address upper_word_mask_addr() { return _upper_word_mask_addr; }
   static address shuffle_byte_flip_mask_addr() { return _shuffle_byte_flip_mask_addr; }
   static address k256_addr()      { return _k256_adr; }
+#ifdef _LP64
+  static address k256_W_addr()    { return _k256_W_adr; }
+#endif
   static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; }
   static void generate_CRC32C_table(bool is_pclmulqdq_supported);
+  static address _ONEHALF_addr()      { return _ONEHALF_adr; }
+  static address _P_2_addr()      { return _P_2_adr; }
+  static address _SC_4_addr()      { return _SC_4_adr; }
+  static address _Ctable_addr()      { return _Ctable_adr; }
+  static address _SC_2_addr()      { return _SC_2_adr; }
+  static address _SC_3_addr()      { return _SC_3_adr; }
+  static address _SC_1_addr()      { return _SC_1_adr; }
+  static address _PI_INV_TABLE_addr()      { return _PI_INV_TABLE_adr; }
+  static address _PI_4_addr()      { return _PI_4_adr; }
+  static address _PI32INV_addr()      { return _PI32INV_adr; }
+  static address _SIGN_MASK_addr()      { return _SIGN_MASK_adr; }
+  static address _P_1_addr()      { return _P_1_adr; }
+  static address _P_3_addr()      { return _P_3_adr; }
+  static address _NEG_ZERO_addr()      { return _NEG_ZERO_adr; }
+  static address _L_2il0floatpacket_0_addr()      { return _L_2il0floatpacket_0_adr; }
+  static address _Pi4Inv_addr()      { return _Pi4Inv_adr; }
+  static address _Pi4x3_addr()      { return _Pi4x3_adr; }
+  static address _Pi4x4_addr()      { return _Pi4x4_adr; }
+  static address _ones_addr()      { return _ones_adr; }
+
 #endif // CPU_X86_VM_STUBROUTINES_X86_32_HPP
diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp
index 84d0796..6d07051 100644
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp
@@ -608,18 +608,13 @@
 
   // get synchronization object
   {
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
     Label done;
     __ movl(rax, access_flags);
     __ testl(rax, JVM_ACC_STATIC);
     // get receiver (assume this is frequent case)
     __ movptr(rax, Address(rlocals, Interpreter::local_offset_in_bytes(0)));
     __ jcc(Assembler::zero, done);
-    __ movptr(rax, Address(rbx, Method::const_offset()));
-    __ movptr(rax, Address(rax, ConstMethod::constants_offset()));
-    __ movptr(rax, Address(rax,
-                           ConstantPool::pool_holder_offset_in_bytes()));
-    __ movptr(rax, Address(rax, mirror_offset));
+    __ load_mirror(rax, rbx);
 
 #ifdef ASSERT
     {
@@ -662,6 +657,9 @@
   __ movptr(rbcp, Address(rbx, Method::const_offset()));      // get ConstMethod*
   __ lea(rbcp, Address(rbcp, ConstMethod::codes_offset())); // get codebase
   __ push(rbx);        // save Method*
+  // Get mirror and store it in the frame as GC root for this Method*
+  __ load_mirror(rdx, rbx);
+  __ push(rdx);
   if (ProfileInterpreter) {
     Label method_data_continue;
     __ movptr(rdx, Address(rbx, in_bytes(Method::method_data_offset())));
@@ -999,15 +997,11 @@
   // pass mirror handle if static call
   {
     Label L;
-    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
     __ movl(t, Address(method, Method::access_flags_offset()));
     __ testl(t, JVM_ACC_STATIC);
     __ jcc(Assembler::zero, L);
     // get mirror
-    __ movptr(t, Address(method, Method::const_offset()));
-    __ movptr(t, Address(t, ConstMethod::constants_offset()));
-    __ movptr(t, Address(t, ConstantPool::pool_holder_offset_in_bytes()));
-    __ movptr(t, Address(t, mirror_offset));
+    __ load_mirror(t, method);
     // copy mirror into activation frame
     __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize),
             t);
diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp
index f5c286e..1339b1e 100644
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp
@@ -345,13 +345,34 @@
   __ fld_d(Address(rsp, 1*wordSize));
   switch (kind) {
     case Interpreter::java_lang_math_sin :
-        __ trigfunc('s');
+        __ subptr(rsp, 2 * wordSize);
+        __ fstp_d(Address(rsp, 0));
+        if (VM_Version::supports_sse2() && StubRoutines::dsin() != NULL) {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
+        } else {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin)));
+        }
+        __ addptr(rsp, 2 * wordSize);
         break;
     case Interpreter::java_lang_math_cos :
-        __ trigfunc('c');
+        __ subptr(rsp, 2 * wordSize);
+        __ fstp_d(Address(rsp, 0));
+        if (VM_Version::supports_sse2() && StubRoutines::dcos() != NULL) {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
+        } else {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos)));
+        }
+        __ addptr(rsp, 2 * wordSize);
         break;
     case Interpreter::java_lang_math_tan :
-        __ trigfunc('t');
+        __ subptr(rsp, 2 * wordSize);
+        __ fstp_d(Address(rsp, 0));
+        if (StubRoutines::dtan() != NULL) {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan())));
+        } else {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtan)));
+        }
+        __ addptr(rsp, 2 * wordSize);
         break;
     case Interpreter::java_lang_math_sqrt:
         __ fsqrt();
@@ -362,26 +383,29 @@
     case Interpreter::java_lang_math_log:
         __ subptr(rsp, 2 * wordSize);
         __ fstp_d(Address(rsp, 0));
-        if (VM_Version::supports_sse2()) {
+        if (StubRoutines::dlog() != NULL) {
           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
-        }
-        else {
+        } else {
           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
         }
         __ addptr(rsp, 2 * wordSize);
         break;
     case Interpreter::java_lang_math_log10:
-        __ flog10();
-        // Store to stack to convert 80bit precision back to 64bits
-        __ push_fTOS();
-        __ pop_fTOS();
+        __ subptr(rsp, 2 * wordSize);
+        __ fstp_d(Address(rsp, 0));
+        if (StubRoutines::dlog10() != NULL) {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10())));
+        } else {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10)));
+        }
+        __ addptr(rsp, 2 * wordSize);
         break;
     case Interpreter::java_lang_math_pow:
       __ fld_d(Address(rsp, 3*wordSize)); // second argument
       __ subptr(rsp, 4 * wordSize);
       __ fstp_d(Address(rsp, 0));
       __ fstp_d(Address(rsp, 2 * wordSize));
-      if (VM_Version::supports_sse2()) {
+      if (StubRoutines::dpow() != NULL) {
         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
       } else {
         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow)));
@@ -391,7 +415,7 @@
     case Interpreter::java_lang_math_exp:
       __ subptr(rsp, 2*wordSize);
       __ fstp_d(Address(rsp, 0));
-      if (VM_Version::supports_sse2()) {
+      if (StubRoutines::dexp() != NULL) {
         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
       } else {
         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp
index 3345cfe..a9cb796 100644
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp
@@ -29,6 +29,7 @@
 #include "interpreter/interpreterRuntime.hpp"
 #include "interpreter/templateInterpreterGenerator.hpp"
 #include "runtime/arguments.hpp"
+#include "runtime/sharedRuntime.hpp"
 
 #define __ _masm->
 
@@ -288,9 +289,9 @@
 }
 
 /**
-* Method entry for static native methods:
+* Method entry for static (non-native) methods:
 *   int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end)
-*   int java.util.zip.CRC32C.updateByteBuffer(int crc, long address, int off, int end)
+*   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long address, int off, int end)
 */
 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
   if (UseCRC32CIntrinsics) {
@@ -305,7 +306,7 @@
     // Arguments are reversed on java expression stack
     // Calculate address of start element
     if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) {
-      __ movptr(buf, Address(rsp, 3 * wordSize)); // long buf
+      __ movptr(buf, Address(rsp, 3 * wordSize)); // long address
       __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
       __ addq(buf, off); // + offset
       __ movl(crc, Address(rsp, 5 * wordSize)); // Initial CRC
@@ -373,32 +374,60 @@
     __ sqrtsd(xmm0, Address(rsp, wordSize));
   } else if (kind == Interpreter::java_lang_math_exp) {
     __ movdbl(xmm0, Address(rsp, wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
+    if (StubRoutines::dexp() != NULL) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
+    }
   } else if (kind == Interpreter::java_lang_math_log) {
     __ movdbl(xmm0, Address(rsp, wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
+    if (StubRoutines::dlog() != NULL) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
+    }
+  } else if (kind == Interpreter::java_lang_math_log10) {
+    __ movdbl(xmm0, Address(rsp, wordSize));
+    if (StubRoutines::dlog10() != NULL) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10())));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10)));
+    }
+  } else if (kind == Interpreter::java_lang_math_sin) {
+    __ movdbl(xmm0, Address(rsp, wordSize));
+    if (StubRoutines::dsin() != NULL) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin)));
+    }
+  } else if (kind == Interpreter::java_lang_math_cos) {
+    __ movdbl(xmm0, Address(rsp, wordSize));
+    if (StubRoutines::dcos() != NULL) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos)));
+    }
   } else if (kind == Interpreter::java_lang_math_pow) {
     __ movdbl(xmm1, Address(rsp, wordSize));
     __ movdbl(xmm0, Address(rsp, 3 * wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
+    if (StubRoutines::dpow() != NULL) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow)));
+    }
+  } else if (kind == Interpreter::java_lang_math_tan) {
+    __ movdbl(xmm0, Address(rsp, wordSize));
+    if (StubRoutines::dtan() != NULL) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan())));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtan)));
+    }
   } else {
     __ fld_d(Address(rsp, wordSize));
     switch (kind) {
-      case Interpreter::java_lang_math_sin :
-          __ trigfunc('s');
-          break;
-      case Interpreter::java_lang_math_cos :
-          __ trigfunc('c');
-          break;
-      case Interpreter::java_lang_math_tan :
-          __ trigfunc('t');
-          break;
       case Interpreter::java_lang_math_abs:
           __ fabs();
           break;
-      case Interpreter::java_lang_math_log10:
-          __ flog10();
-          break;
       default                              :
           ShouldNotReachHere();
     }
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
index 6d871ce..65acaff 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
@@ -732,7 +732,7 @@
     FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
   }
 
-  if (supports_sha()) {
+  if (supports_sha() LP64_ONLY(|| supports_avx2() && supports_bmi2())) {
     if (FLAG_IS_DEFAULT(UseSHA)) {
       UseSHA = true;
     }
@@ -741,7 +741,7 @@
     FLAG_SET_DEFAULT(UseSHA, false);
   }
 
-  if (UseSHA) {
+  if (supports_sha() && UseSHA) {
     if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) {
       FLAG_SET_DEFAULT(UseSHA1Intrinsics, true);
     }
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
index 8dca27b..a4c0265 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
@@ -844,6 +844,11 @@
   static uint32_t get_xsave_header_upper_segment() {
     return _cpuid_info.xem_xcr0_edx;
   }
+
+  // SSE2 and later processors implement a 'pause' instruction
+  // that can be used for efficient implementation of
+  // the intrinsic for java.lang.Thread.onSpinWait()
+  static bool supports_on_spin_wait() { return supports_sse2(); }
 };
 
 #endif // CPU_X86_VM_VM_VERSION_X86_HPP
diff --git a/hotspot/src/cpu/x86/vm/x86.ad b/hotspot/src/cpu/x86/vm/x86.ad
index 603e00b..ce14f4c 100644
--- a/hotspot/src/cpu/x86/vm/x86.ad
+++ b/hotspot/src/cpu/x86/vm/x86.ad
@@ -1586,6 +1586,8 @@
 
 source %{
 
+#include "opto/addnode.hpp"
+
 // Emit exception handler code.
 // Stuff framesize into a register and call a VM stub routine.
 int HandlerImpl::emit_exception_handler(CodeBuffer& cbuf) {
@@ -1719,6 +1721,10 @@
       if (!(UseSSE > 4))
         ret_value = false;
       break;
+    case Op_OnSpinWait:
+      if (VM_Version::supports_on_spin_wait() == false)
+        ret_value = false;
+      break;
   }
 
   return ret_value;  // Per default match rules are supported.
@@ -1754,6 +1760,15 @@
   return ret_value;  // Per default match rules are supported.
 }
 
+const bool Matcher::has_predicated_vectors(void) {
+  bool ret_value = false;
+  if (UseAVX > 2) {
+    ret_value = VM_Version::supports_avx512vl();
+  }
+
+  return ret_value;
+}
+
 const int Matcher::float_pressure(int default_pressure_threshold) {
   int float_pressure_threshold = default_pressure_threshold;
 #ifdef _LP64
@@ -1848,6 +1863,79 @@
   return false;
 }
 
+
+const bool Matcher::convi2l_type_required = true;
+
+// Check for shift by small constant as well
+static bool clone_shift(Node* shift, Matcher* matcher, Matcher::MStack& mstack, VectorSet& address_visited) {
+  if (shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() &&
+      shift->in(2)->get_int() <= 3 &&
+      // Are there other uses besides address expressions?
+      !matcher->is_visited(shift)) {
+    address_visited.set(shift->_idx); // Flag as address_visited
+    mstack.push(shift->in(2), Matcher::Visit);
+    Node *conv = shift->in(1);
+#ifdef _LP64
+    // Allow Matcher to match the rule which bypass
+    // ConvI2L operation for an array index on LP64
+    // if the index value is positive.
+    if (conv->Opcode() == Op_ConvI2L &&
+        conv->as_Type()->type()->is_long()->_lo >= 0 &&
+        // Are there other uses besides address expressions?
+        !matcher->is_visited(conv)) {
+      address_visited.set(conv->_idx); // Flag as address_visited
+      mstack.push(conv->in(1), Matcher::Pre_Visit);
+    } else
+#endif
+      mstack.push(conv, Matcher::Pre_Visit);
+    return true;
+  }
+  return false;
+}
+
+// Should the Matcher clone shifts on addressing modes, expecting them
+// to be subsumed into complex addressing expressions or compute them
+// into registers?
+bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) {
+  Node *off = m->in(AddPNode::Offset);
+  if (off->is_Con()) {
+    address_visited.test_set(m->_idx); // Flag as address_visited
+    Node *adr = m->in(AddPNode::Address);
+
+    // Intel can handle 2 adds in addressing mode
+    // AtomicAdd is not an addressing expression.
+    // Cheap to find it by looking for screwy base.
+    if (adr->is_AddP() &&
+        !adr->in(AddPNode::Base)->is_top() &&
+        // Are there other uses besides address expressions?
+        !is_visited(adr)) {
+      address_visited.set(adr->_idx); // Flag as address_visited
+      Node *shift = adr->in(AddPNode::Offset);
+      if (!clone_shift(shift, this, mstack, address_visited)) {
+        mstack.push(shift, Pre_Visit);
+      }
+      mstack.push(adr->in(AddPNode::Address), Pre_Visit);
+      mstack.push(adr->in(AddPNode::Base), Pre_Visit);
+    } else {
+      mstack.push(adr, Pre_Visit);
+    }
+
+    // Clone X+offset as it also folds into most addressing expressions
+    mstack.push(off, Visit);
+    mstack.push(m->in(AddPNode::Base), Pre_Visit);
+    return true;
+  } else if (clone_shift(off, this, mstack, address_visited)) {
+    address_visited.test_set(m->_idx); // Flag as address_visited
+    mstack.push(m->in(AddPNode::Address), Pre_Visit);
+    mstack.push(m->in(AddPNode::Base), Pre_Visit);
+    return true;
+  }
+  return false;
+}
+
+void Compile::reshape_address(AddPNode* addp) {
+}
+
 // Helper methods for MachSpillCopyNode::implementation().
 static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo,
                           int src_hi, int dst_hi, uint ireg, outputStream* st) {
@@ -1871,7 +1959,7 @@
       __ vmovdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]));
       break;
     case Op_VecZ:
-      __ evmovdqul(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 2);
+      __ evmovdquq(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 2);
       break;
     default:
       ShouldNotReachHere();
@@ -1926,7 +2014,7 @@
         __ vmovdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset));
         break;
       case Op_VecZ:
-        __ evmovdqul(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset), 2);
+        __ evmovdquq(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset), 2);
         break;
       default:
         ShouldNotReachHere();
@@ -1946,7 +2034,7 @@
         __ vmovdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]));
         break;
       case Op_VecZ:
-        __ evmovdqul(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), 2);
+        __ evmovdquq(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), 2);
         break;
       default:
         ShouldNotReachHere();
@@ -2172,6 +2260,19 @@
   ins_pipe(pipe_slow);
 %}
 
+// =================================EVEX special===============================
+
+instruct setMask(rRegI dst, rRegI src) %{
+  predicate(Matcher::has_predicated_vectors());
+  match(Set dst (SetVectMaskI  src));
+  effect(TEMP dst);
+  format %{ "setvectmask   $dst, $src" %}
+  ins_encode %{
+    __ setvectmask($dst$$Register, $src$$Register);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
 // ============================================================================
 
 instruct addF_reg(regF dst, regF src) %{
@@ -2996,6 +3097,24 @@
   ins_pipe(pipe_slow);
 %}
 
+instruct onspinwait() %{
+  match(OnSpinWait);
+  ins_cost(200);
+
+  format %{
+    $$template
+    if (os::is_MP()) {
+      $$emit$$"pause\t! membar_onspinwait"
+    } else {
+      $$emit$$"MEMBAR-onspinwait ! (empty encoding)"
+    }
+  %}
+  ins_encode %{
+    __ pause();
+  %}
+  ins_pipe(pipe_slow);
+%}
+
 // ====================VECTOR INSTRUCTIONS=====================================
 
 // Load vectors (4 bytes long)
@@ -3047,11 +3166,11 @@
 %}
 
 // Load vectors (64 bytes long)
-instruct loadV64(vecZ dst, memory mem) %{
-  predicate(n->as_LoadVector()->memory_size() == 64);
+instruct loadV64_dword(vecZ dst, memory mem) %{
+  predicate(n->as_LoadVector()->memory_size() == 64 && n->as_LoadVector()->element_size() <= 4);
   match(Set dst (LoadVector mem));
   ins_cost(125);
-  format %{ "vmovdqu $dst k0,$mem\t! load vector (64 bytes)" %}
+  format %{ "vmovdqul $dst k0,$mem\t! load vector (64 bytes)" %}
   ins_encode %{
     int vector_len = 2;
     __ evmovdqul($dst$$XMMRegister, $mem$$Address, vector_len);
@@ -3059,6 +3178,19 @@
   ins_pipe( pipe_slow );
 %}
 
+// Load vectors (64 bytes long)
+instruct loadV64_qword(vecZ dst, memory mem) %{
+  predicate(n->as_LoadVector()->memory_size() == 64 && n->as_LoadVector()->element_size() > 4);
+  match(Set dst (LoadVector mem));
+  ins_cost(125);
+  format %{ "vmovdquq $dst k0,$mem\t! load vector (64 bytes)" %}
+  ins_encode %{
+    int vector_len = 2;
+    __ evmovdquq($dst$$XMMRegister, $mem$$Address, vector_len);
+  %}
+  ins_pipe( pipe_slow );
+%}
+
 // Store vectors
 instruct storeV4(memory mem, vecS src) %{
   predicate(n->as_StoreVector()->memory_size() == 4);
@@ -3104,11 +3236,11 @@
   ins_pipe( pipe_slow );
 %}
 
-instruct storeV64(memory mem, vecZ src) %{
-  predicate(n->as_StoreVector()->memory_size() == 64);
+instruct storeV64_dword(memory mem, vecZ src) %{
+  predicate(n->as_StoreVector()->memory_size() == 64 && n->as_StoreVector()->element_size() <= 4);
   match(Set mem (StoreVector mem src));
   ins_cost(145);
-  format %{ "vmovdqu $mem k0,$src\t! store vector (64 bytes)" %}
+  format %{ "vmovdqul $mem k0,$src\t! store vector (64 bytes)" %}
   ins_encode %{
     int vector_len = 2;
     __ evmovdqul($mem$$Address, $src$$XMMRegister, vector_len);
@@ -3116,6 +3248,18 @@
   ins_pipe( pipe_slow );
 %}
 
+instruct storeV64_qword(memory mem, vecZ src) %{
+  predicate(n->as_StoreVector()->memory_size() == 64 && n->as_StoreVector()->element_size() > 4);
+  match(Set mem (StoreVector mem src));
+  ins_cost(145);
+  format %{ "vmovdquq $mem k0,$src\t! store vector (64 bytes)" %}
+  ins_encode %{
+    int vector_len = 2;
+    __ evmovdquq($mem$$Address, $src$$XMMRegister, vector_len);
+  %}
+  ins_pipe( pipe_slow );
+%}
+
 // ====================LEGACY REPLICATE=======================================
 
 instruct Repl4B_mem(vecS dst, memory mem) %{
diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad
index a7ee85d..a45cb55 100644
--- a/hotspot/src/cpu/x86/vm/x86_32.ad
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad
@@ -1021,10 +1021,10 @@
       __ vmovdqu(xmm0, Address(rsp, -32));
       break;
     case Op_VecZ:
-      __ evmovdqul(Address(rsp, -64), xmm0, 2);
-      __ evmovdqul(xmm0, Address(rsp, src_offset), 2);
-      __ evmovdqul(Address(rsp, dst_offset), xmm0, 2);
-      __ evmovdqul(xmm0, Address(rsp, -64), 2);
+      __ evmovdquq(Address(rsp, -64), xmm0, 2);
+      __ evmovdquq(xmm0, Address(rsp, src_offset), 2);
+      __ evmovdquq(Address(rsp, dst_offset), xmm0, 2);
+      __ evmovdquq(xmm0, Address(rsp, -64), 2);
       break;
     default:
       ShouldNotReachHere();
@@ -1438,11 +1438,6 @@
 // Does the CPU require late expand (see block.cpp for description of late expand)?
 const bool Matcher::require_postalloc_expand = false;
 
-// Should the Matcher clone shifts on addressing modes, expecting them to
-// be subsumed into complex addressing expressions or compute them into
-// registers?  True for Intel but false for most RISCs
-const bool Matcher::clone_shift_expressions = true;
-
 // Do we need to mask the count passed to shift instructions or does
 // the cpu only look at the lower 5/6 bits anyway?
 const bool Matcher::need_masked_shift_count = false;
@@ -9828,27 +9823,6 @@
   ins_pipe( pipe_slow );
 %}
 
-instruct tanDPR_reg(regDPR1 dst, regDPR1 src) %{
-  predicate (UseSSE<=1);
-  match(Set dst(TanD src));
-  format %{ "DTAN   $dst" %}
-  ins_encode( Opcode(0xD9), Opcode(0xF2),    // fptan
-              Opcode(0xDD), Opcode(0xD8));   // fstp st
-  ins_pipe( pipe_slow );
-%}
-
-instruct tanD_reg(regD dst, eFlagsReg cr) %{
-  predicate (UseSSE>=2);
-  match(Set dst(TanD dst));
-  effect(KILL cr); // Push_{Src|Result}D() uses "{SUB|ADD} ESP,8"
-  format %{ "DTAN   $dst" %}
-  ins_encode( Push_SrcD(dst),
-              Opcode(0xD9), Opcode(0xF2),    // fptan
-              Opcode(0xDD), Opcode(0xD8),   // fstp st
-              Push_ResultD(dst) );
-  ins_pipe( pipe_slow );
-%}
-
 instruct atanDPR_reg(regDPR dst, regDPR src) %{
   predicate (UseSSE<=1);
   match(Set dst(AtanD dst src));
@@ -9880,41 +9854,6 @@
   ins_pipe( pipe_slow );
 %}
 
-instruct log10DPR_reg(regDPR1 dst, regDPR1 src) %{
-  predicate (UseSSE<=1);
-  // The source Double operand on FPU stack
-  match(Set dst (Log10D src));
-  // fldlg2       ; push log_10(2) on the FPU stack; full 80-bit number
-  // fxch         ; swap ST(0) with ST(1)
-  // fyl2x        ; compute log_10(2) * log_2(x)
-  format %{ "FLDLG2 \t\t\t#Log10\n\t"
-            "FXCH   \n\t"
-            "FYL2X  \t\t\t# Q=Log10*Log_2(x)"
-         %}
-  ins_encode( Opcode(0xD9), Opcode(0xEC),   // fldlg2
-              Opcode(0xD9), Opcode(0xC9),   // fxch
-              Opcode(0xD9), Opcode(0xF1));  // fyl2x
-
-  ins_pipe( pipe_slow );
-%}
-
-instruct log10D_reg(regD dst, regD src, eFlagsReg cr) %{
-  predicate (UseSSE>=2);
-  effect(KILL cr);
-  match(Set dst (Log10D src));
-  // fldlg2       ; push log_10(2) on the FPU stack; full 80-bit number
-  // fyl2x        ; compute log_10(2) * log_2(x)
-  format %{ "FLDLG2 \t\t\t#Log10\n\t"
-            "FYL2X  \t\t\t# Q=Log10*Log_2(x)"
-         %}
-  ins_encode( Opcode(0xD9), Opcode(0xEC),   // fldlg2
-              Push_SrcD(src),
-              Opcode(0xD9), Opcode(0xF1),   // fyl2x
-              Push_ResultD(dst));
-
-  ins_pipe( pipe_slow );
-%}
-
 //-------------Float Instructions-------------------------------
 // Float Math
 
@@ -12103,6 +12042,7 @@
 
 // Jump Direct Conditional - Label defines a relative address from Jcc+1
 instruct jmpLoopEnd(cmpOp cop, eFlagsReg cr, label labl) %{
+  predicate(!n->has_vector_mask_set());
   match(CountedLoopEnd cop cr);
   effect(USE labl);
 
@@ -12118,6 +12058,7 @@
 
 // Jump Direct Conditional - Label defines a relative address from Jcc+1
 instruct jmpLoopEndU(cmpOpU cop, eFlagsRegU cmp, label labl) %{
+  predicate(!n->has_vector_mask_set());
   match(CountedLoopEnd cop cmp);
   effect(USE labl);
 
@@ -12132,6 +12073,7 @@
 %}
 
 instruct jmpLoopEndUCF(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
+  predicate(!n->has_vector_mask_set());
   match(CountedLoopEnd cop cmp);
   effect(USE labl);
 
@@ -12145,6 +12087,60 @@
   ins_pipe( pipe_jcc );
 %}
 
+// mask version
+// Jump Direct Conditional - Label defines a relative address from Jcc+1
+instruct jmpLoopEnd_and_restoreMask(cmpOp cop, eFlagsReg cr, label labl) %{
+  predicate(n->has_vector_mask_set());
+  match(CountedLoopEnd cop cr);
+  effect(USE labl);
+
+  ins_cost(400);
+  format %{ "J$cop    $labl\t# Loop end\n\t"
+            "restorevectmask \t# vector mask restore for loops" %}
+  size(10);
+  ins_encode %{
+    Label* L = $labl$$label;
+    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
+    __ restorevectmask();
+  %}
+  ins_pipe( pipe_jcc );
+%}
+
+// Jump Direct Conditional - Label defines a relative address from Jcc+1
+instruct jmpLoopEndU_and_restoreMask(cmpOpU cop, eFlagsRegU cmp, label labl) %{
+  predicate(n->has_vector_mask_set());
+  match(CountedLoopEnd cop cmp);
+  effect(USE labl);
+
+  ins_cost(400);
+  format %{ "J$cop,u  $labl\t# Loop end\n\t"
+            "restorevectmask \t# vector mask restore for loops" %}
+  size(10);
+  ins_encode %{
+    Label* L = $labl$$label;
+    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
+    __ restorevectmask();
+  %}
+  ins_pipe( pipe_jcc );
+%}
+
+instruct jmpLoopEndUCF_and_restoreMask(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
+  predicate(n->has_vector_mask_set());
+  match(CountedLoopEnd cop cmp);
+  effect(USE labl);
+
+  ins_cost(300);
+  format %{ "J$cop,u  $labl\t# Loop end\n\t"
+            "restorevectmask \t# vector mask restore for loops" %}
+  size(10);
+  ins_encode %{
+    Label* L = $labl$$label;
+    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
+    __ restorevectmask();
+  %}
+  ins_pipe( pipe_jcc );
+%}
+
 // Jump Direct Conditional - using unsigned comparison
 instruct jmpConU(cmpOpU cop, eFlagsRegU cmp, label labl) %{
   match(If cop cmp);
diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad
index 9579436..a680d60 100644
--- a/hotspot/src/cpu/x86/vm/x86_64.ad
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad
@@ -1081,10 +1081,10 @@
       __ vmovdqu(xmm0, Address(rsp, -32));
       break;
     case Op_VecZ:
-      __ evmovdqul(Address(rsp, -64), xmm0, 2);
-      __ evmovdqul(xmm0, Address(rsp, src_offset), 2);
-      __ evmovdqul(Address(rsp, dst_offset), xmm0, 2);
-      __ evmovdqul(xmm0, Address(rsp, -64), 2);
+      __ evmovdquq(Address(rsp, -64), xmm0, 2);
+      __ evmovdquq(xmm0, Address(rsp, src_offset), 2);
+      __ evmovdquq(Address(rsp, dst_offset), xmm0, 2);
+      __ evmovdquq(xmm0, Address(rsp, -64), 2);
       break;
     default:
       ShouldNotReachHere();
@@ -1646,11 +1646,6 @@
 // Does the CPU require late expand (see block.cpp for description of late expand)?
 const bool Matcher::require_postalloc_expand = false;
 
-// Should the Matcher clone shifts on addressing modes, expecting them
-// to be subsumed into complex addressing expressions or compute them
-// into registers?  True for Intel but false for most RISCs
-const bool Matcher::clone_shift_expressions = true;
-
 // Do we need to mask the count passed to shift instructions or does
 // the cpu only look at the lower 5/6 bits anyway?
 const bool Matcher::need_masked_shift_count = false;
@@ -9897,34 +9892,6 @@
   ins_pipe(pipe_slow);
 %}
 
-// -----------Trig and Trancendental Instructions------------------------------
-instruct tanD_reg(regD dst) %{
-  match(Set dst (TanD dst));
-
-  format %{ "dtan   $dst\n\t" %}
-  ins_encode( Push_SrcXD(dst),
-              Opcode(0xD9), Opcode(0xF2),   //fptan
-              Opcode(0xDD), Opcode(0xD8),   //fstp st
-              Push_ResultXD(dst) );
-  ins_pipe( pipe_slow );
-%}
-
-instruct log10D_reg(regD dst) %{
-  // The source and result Double operands in XMM registers
-  match(Set dst (Log10D dst));
-  // fldlg2       ; push log_10(2) on the FPU stack; full 80-bit number
-  // fyl2x        ; compute log_10(2) * log_2(x)
-  format %{ "fldlg2\t\t\t#Log10\n\t"
-            "fyl2x\t\t\t# Q=Log10*Log_2(x)\n\t"
-         %}
-   ins_encode(Opcode(0xD9), Opcode(0xEC),   // fldlg2
-              Push_SrcXD(dst),
-              Opcode(0xD9), Opcode(0xF1),   // fyl2x
-              Push_ResultXD(dst));
-
-  ins_pipe( pipe_slow );
-%}
-
 //----------Arithmetic Conversion Instructions---------------------------------
 
 instruct roundFloat_nop(regF dst)
@@ -11471,6 +11438,7 @@
 // Jump Direct Conditional - Label defines a relative address from Jcc+1
 instruct jmpLoopEnd(cmpOp cop, rFlagsReg cr, label labl)
 %{
+  predicate(!n->has_vector_mask_set());
   match(CountedLoopEnd cop cr);
   effect(USE labl);
 
@@ -11486,6 +11454,7 @@
 
 // Jump Direct Conditional - Label defines a relative address from Jcc+1
 instruct jmpLoopEndU(cmpOpU cop, rFlagsRegU cmp, label labl) %{
+  predicate(!n->has_vector_mask_set());
   match(CountedLoopEnd cop cmp);
   effect(USE labl);
 
@@ -11500,6 +11469,7 @@
 %}
 
 instruct jmpLoopEndUCF(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{
+  predicate(!n->has_vector_mask_set());
   match(CountedLoopEnd cop cmp);
   effect(USE labl);
 
@@ -11513,6 +11483,61 @@
   ins_pipe(pipe_jcc);
 %}
 
+// mask version
+// Jump Direct Conditional - Label defines a relative address from Jcc+1
+instruct jmpLoopEnd_and_restoreMask(cmpOp cop, rFlagsReg cr, label labl)
+%{
+  predicate(n->has_vector_mask_set());
+  match(CountedLoopEnd cop cr);
+  effect(USE labl);
+
+  ins_cost(400);
+  format %{ "j$cop     $labl\t# loop end\n\t"
+            "restorevectmask \t# vector mask restore for loops" %}
+  size(10);
+  ins_encode %{
+    Label* L = $labl$$label;
+    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
+    __ restorevectmask();
+  %}
+  ins_pipe(pipe_jcc);
+%}
+
+// Jump Direct Conditional - Label defines a relative address from Jcc+1
+instruct jmpLoopEndU_and_restoreMask(cmpOpU cop, rFlagsRegU cmp, label labl) %{
+  predicate(n->has_vector_mask_set());
+  match(CountedLoopEnd cop cmp);
+  effect(USE labl);
+
+  ins_cost(400);
+  format %{ "j$cop,u   $labl\t# loop end\n\t"
+            "restorevectmask \t# vector mask restore for loops" %}
+  size(10);
+  ins_encode %{
+    Label* L = $labl$$label;
+    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
+    __ restorevectmask();
+  %}
+  ins_pipe(pipe_jcc);
+%}
+
+instruct jmpLoopEndUCF_and_restoreMask(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{
+  predicate(n->has_vector_mask_set());
+  match(CountedLoopEnd cop cmp);
+  effect(USE labl);
+
+  ins_cost(300);
+  format %{ "j$cop,u   $labl\t# loop end\n\t"
+            "restorevectmask \t# vector mask restore for loops" %}
+  size(10);
+  ins_encode %{
+    Label* L = $labl$$label;
+    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
+    __ restorevectmask();
+  %}
+  ins_pipe(pipe_jcc);
+%}
+
 // Jump Direct Conditional - using unsigned comparison
 instruct jmpConU(cmpOpU cop, rFlagsRegU cmp, label labl) %{
   match(If cop cmp);
diff --git a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp
index 2290f59..1dbe94d 100644
--- a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp
+++ b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp
@@ -49,6 +49,7 @@
   DO(_locals);
   DO(_constants);
   DO(_method);
+  DO(_mirror);
   DO(_mdx);
   DO(_stack);
   DO(_msg);
@@ -77,6 +78,7 @@
                                                   bool      is_top_frame) {
   istate->set_locals(locals);
   istate->set_method(method);
+  istate->set_mirror(method->method_holder()->java_mirror());
   istate->set_self_link(istate);
   istate->set_prev_link(NULL);
   // thread will be set by a hacky repurposing of frame::patch_pc()
diff --git a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp
index f7bcb91..e7ef4c1 100644
--- a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp
+++ b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -44,6 +44,9 @@
   inline void set_method(Method* new_method) {
     _method = new_method;
   }
+  inline void set_mirror(oop new_mirror) {
+    _mirror = new_mirror;
+  }
   inline interpreterState self_link() {
     return _self_link;
   }
diff --git a/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp b/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp
index bc3e362..8f912db 100644
--- a/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp
+++ b/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,22 +42,6 @@
 #include "utilities/events.hpp"
 
 
-// Release the CompiledICHolder* associated with this call site is there is one.
-void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  if (is_icholder_entry(call->destination())) {
-    NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());
-    InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());
-  }
-}
-
-bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {
-  // This call site might have become stale so inspect it carefully.
-  NativeCall* call = nativeCall_at(call_site->addr());
-  return is_icholder_entry(call->destination());
-}
-
 // ----------------------------------------------------------------------------
 
 address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) {
diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
index e05e6d6..9e91f22 100644
--- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
+++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
@@ -221,9 +221,16 @@
   // Push our result
   for (int i = 0; i < result_slots; i++) {
     // Adjust result to smaller
-    intptr_t res = result[-i];
+    union {
+      intptr_t res;
+      jint res_jint;
+    };
+    res = result[-i];
     if (result_slots == 1) {
-      res = narrow(method->result_type(), res);
+      BasicType t = method->result_type();
+      if (is_subword_type(t)) {
+        res_jint = (jint)narrow(t, res_jint);
+      }
     }
     stack->push(res);
   }
@@ -748,6 +755,7 @@
 
   istate->set_locals(locals);
   istate->set_method(method);
+  istate->set_mirror(method->method_holder()->java_mirror());
   istate->set_self_link(istate);
   istate->set_prev_link(NULL);
   istate->set_thread(thread);
diff --git a/hotspot/src/cpu/zero/vm/frame_zero.cpp b/hotspot/src/cpu/zero/vm/frame_zero.cpp
index fe1ee4f..19acf03 100644
--- a/hotspot/src/cpu/zero/vm/frame_zero.cpp
+++ b/hotspot/src/cpu/zero/vm/frame_zero.cpp
@@ -360,7 +360,7 @@
   case pc_off:
     strncpy(fieldbuf, "pc", buflen);
     if (method()->is_method()) {
-      nmethod *code = method()->code();
+      CompiledMethod *code = method()->code();
       if (code && code->pc_desc_at(pc())) {
         SimpleScopeDesc ssd(code, pc());
         snprintf(valuebuf, buflen, PTR_FORMAT " (bci %d)",
diff --git a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp
index f8011a2..1ecd9db 100644
--- a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp
+++ b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -59,7 +59,7 @@
   case ZeroFrame::SHARK_FRAME: {
     _pc = zero_sharkframe()->pc();
     _cb = CodeCache::find_blob_unsafe(pc());
-    address original_pc = nmethod::get_deopt_original_pc(this);
+    address original_pc = CompiledMethod::get_deopt_original_pc(this);
     if (original_pc != NULL) {
       _pc = original_pc;
       _deopt_state = is_deoptimized;
@@ -115,6 +115,10 @@
   return &(get_interpreterState()->_method);
 }
 
+inline oop* frame::interpreter_frame_mirror_addr() const {
+  return &(get_interpreterState()->_mirror);
+}
+
 inline intptr_t* frame::interpreter_frame_mdp_addr() const {
   return (intptr_t*) &(get_interpreterState()->_mdx);
 }
diff --git a/hotspot/src/cpu/zero/vm/globals_zero.hpp b/hotspot/src/cpu/zero/vm/globals_zero.hpp
index 52a3cac..7ce33a9 100644
--- a/hotspot/src/cpu/zero/vm/globals_zero.hpp
+++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp
@@ -43,7 +43,12 @@
 define_pd_global(intx,  OptoLoopAlignment,    16);
 define_pd_global(intx,  InlineFrequencyCount, 100);
 define_pd_global(intx,  InlineSmallCode,      1000);
-define_pd_global(intx,  InitArrayShortSize,   -1); // not used
+
+// not used, but must satisfy following constraints:
+// 1.) <VALUE> must be in the allowed range for intx *and*
+// 2.) <VALUE> % BytesPerLong == 0 so as to not
+//     violate the constraint verifier on JVM start-up.
+define_pd_global(intx,  InitArrayShortSize,   0);
 
 #define DEFAULT_STACK_YELLOW_PAGES (2)
 #define DEFAULT_STACK_RED_PAGES (1)
@@ -75,7 +80,14 @@
 // No performance work done here yet.
 define_pd_global(bool, CompactStrings, false);
 
-#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint)  \
+#define ARCH_FLAGS(develop, \
+                   product, \
+                   diagnostic, \
+                   experimental, \
+                   notproduct, \
+                   range, \
+                   constraint, \
+                   writeable)  \
                                                                             \
   product(bool, UseFastEmptyMethods, true,                                  \
           "Use fast method entry code for empty methods")                   \
diff --git a/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp
index 0fb36b0..27b96b5 100644
--- a/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp
+++ b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp
@@ -31,7 +31,6 @@
 #include "code/vtableStubs.hpp"
 #include "interpreter/interpreter.hpp"
 #include "oops/compiledICHolder.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/vframeArray.hpp"
 #include "vmreg_zero.inline.hpp"
diff --git a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp
index bdaec67..9d64fb9 100644
--- a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp
+++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2010, 2015 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -261,10 +261,6 @@
     StubRoutines::_atomic_add_entry          = ShouldNotCallThisStub();
     StubRoutines::_atomic_add_ptr_entry      = ShouldNotCallThisStub();
     StubRoutines::_fence_entry               = ShouldNotCallThisStub();
-
-    // amd64 does this here, sparc does it in generate_all()
-    StubRoutines::_handler_for_unsafe_access_entry =
-      ShouldNotCallThisStub();
   }
 
   void generate_all() {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java
index 85b163b..65b804d 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java
@@ -28,7 +28,6 @@
     requires java.desktop;
     requires java.rmi;
     requires java.scripting;
-    requires jdk.jcmd;
     requires jdk.jdi;
 
     // RMI needs to serialize types in this package
@@ -37,13 +36,4 @@
     provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SADebugServerAttachingConnector;
     provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SAPIDAttachingConnector;
 
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.JStack;
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.JInfo;
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.ClassLoaderStats;
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.FinalizerInfo;
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.HeapDumper;
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.HeapSummary;
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.ObjectHistogram;
-    provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.PMap;
 }
-
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
index dfbbb6f..83c8605 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
@@ -73,6 +73,7 @@
         System.out.println("    <no option>\tto print same info as Solaris pmap");
         System.out.println("    --heap\tto print java heap summary");
         System.out.println("    --binaryheap\tto dump java heap in hprof binary format");
+        System.out.println("    --dumpfile\tname of the dump file");
         System.out.println("    --histo\tto print histogram of java object heap");
         System.out.println("    --clstats\tto print class loader statistics");
         System.out.println("    --finalizerinfo\tto print information on objects awaiting finalization");
@@ -241,13 +242,15 @@
     private static void runJMAP(String[] oldArgs) {
         SAGetopt sg = new SAGetopt(oldArgs);
         String[] longOpts = {"exe=", "core=", "pid=",
-              "heap", "binaryheap", "histo", "clstats", "finalizerinfo"};
+              "heap", "binaryheap", "dumpfile=", "histo", "clstats", "finalizerinfo"};
 
         ArrayList<String> newArgs = new ArrayList();
         String pid = null;
         String exe = null;
         String core = null;
         String s = null;
+        String dumpfile = null;
+        boolean requestHeapdump = false;
 
         while((s = sg.next(null, longOpts)) != null) {
             if (s.equals("exe")) {
@@ -267,7 +270,11 @@
                 continue;
             }
             if (s.equals("binaryheap")) {
-                newArgs.add("-heap:format=b");
+                requestHeapdump = true;
+                continue;
+            }
+            if (s.equals("dumpfile")) {
+                dumpfile = sg.getOptarg();
                 continue;
             }
             if (s.equals("histo")) {
@@ -284,6 +291,17 @@
             }
         }
 
+        if (!requestHeapdump && (dumpfile != null)) {
+            throw new IllegalArgumentException("Unexpected argument dumpfile");
+        }
+        if (requestHeapdump) {
+            if (dumpfile == null) {
+                newArgs.add("-heap:format=b");
+            } else {
+                newArgs.add("-heap:format=b,file=" + dumpfile);
+            }
+        }
+
         buildAttachArgs(newArgs, pid, exe, core, false);
         JMap.main(newArgs.toArray(new String[newArgs.size()]));
     }
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java
index 654a733..378e118 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.types.*;
 
-public class AdapterBlob extends CodeBlob {
+public class AdapterBlob extends RuntimeBlob {
   static {
     VM.registerVMInitializedObserver(new Observer() {
         public void update(Observable o, Object data) {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java
index 5fa98b6..d80eb9c 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.types.*;
 
-public class BufferBlob extends CodeBlob {
+public class BufferBlob extends RuntimeBlob {
   static {
     VM.registerVMInitializedObserver(new Observer() {
         public void update(Observable o, Object data) {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java
index a018ab83..89bc1fc 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -19,84 +19,142 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
-
 package sun.jvm.hotspot.code;
 
-import java.io.*;
-import java.util.*;
+import sun.jvm.hotspot.compiler.ImmutableOopMap;
+import sun.jvm.hotspot.compiler.ImmutableOopMapSet;
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObject;
+import sun.jvm.hotspot.types.AddressField;
+import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+import sun.jvm.hotspot.utilities.Assert;
 
-import sun.jvm.hotspot.compiler.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.types.*;
-import sun.jvm.hotspot.utilities.*;
+import java.io.PrintStream;
+import java.util.Observable;
+import java.util.Observer;
 
 public class CodeBlob extends VMObject {
-  private static AddressField  nameField;
+  private static AddressField nameField;
   private static CIntegerField sizeField;
   private static CIntegerField headerSizeField;
-  private static CIntegerField relocationSizeField;
-  private static CIntegerField contentOffsetField;
-  private static CIntegerField codeOffsetField;
+  private static AddressField  contentBeginField;
+  private static AddressField  codeBeginField;
+  private static AddressField  codeEndField;
+  private static AddressField  dataEndField;
   private static CIntegerField frameCompleteOffsetField;
   private static CIntegerField dataOffsetField;
   private static CIntegerField frameSizeField;
   private static AddressField  oopMapsField;
 
-  // Only used by server compiler on x86; computed over in SA rather
-  // than relying on computation in target VM
-  private static final int     NOT_YET_COMPUTED = -2;
-  private static final int     UNDEFINED        = -1;
-  private              int     linkOffset       = NOT_YET_COMPUTED;
-  private static       int     matcherInterpreterFramePointerReg;
-
-  static {
-    VM.registerVMInitializedObserver(new Observer() {
-        public void update(Observable o, Object data) {
-          initialize(VM.getVM().getTypeDataBase());
-        }
-      });
+  public CodeBlob(Address addr) {
+    super(addr);
   }
 
+  protected static       int     matcherInterpreterFramePointerReg;
+
   private static void initialize(TypeDataBase db) {
     Type type = db.lookupType("CodeBlob");
 
     nameField                = type.getAddressField("_name");
     sizeField                = type.getCIntegerField("_size");
     headerSizeField          = type.getCIntegerField("_header_size");
-    relocationSizeField      = type.getCIntegerField("_relocation_size");
     frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset");
-    contentOffsetField       = type.getCIntegerField("_content_offset");
-    codeOffsetField          = type.getCIntegerField("_code_offset");
+    contentBeginField        = type.getAddressField("_content_begin");
+    codeBeginField           = type.getAddressField("_code_begin");
+    codeEndField             = type.getAddressField("_code_end");
+    dataEndField             = type.getAddressField("_data_end");
     dataOffsetField          = type.getCIntegerField("_data_offset");
     frameSizeField           = type.getCIntegerField("_frame_size");
     oopMapsField             = type.getAddressField("_oop_maps");
 
     if (VM.getVM().isServerCompiler()) {
       matcherInterpreterFramePointerReg =
-        db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
+          db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
     }
   }
 
-  public CodeBlob(Address addr) {
-    super(addr);
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+      public void update(Observable o, Object data) {
+        initialize(VM.getVM().getTypeDataBase());
+      }
+    });
   }
 
+  public Address headerBegin() { return getAddress(); }
+
+  public Address headerEnd() { return getAddress().addOffsetTo(getHeaderSize()); }
+
+  public Address contentBegin() { return contentBeginField.getValue(addr); }
+
+  public Address contentEnd() { return headerBegin().addOffsetTo(getDataOffset()); }
+
+  public Address codeBegin() { return codeBeginField.getValue(addr); }
+
+  public Address codeEnd() { return codeEndField.getValue(addr); }
+
+  public Address dataBegin() { return headerBegin().addOffsetTo(getDataOffset()); }
+
+  public Address dataEnd() { return dataEndField.getValue(addr); }
+
+  public long getFrameCompleteOffset() { return frameCompleteOffsetField.getValue(addr); }
+
+  public int getDataOffset()       { return (int) dataOffsetField.getValue(addr); }
+
+  // Sizes
+  public int getSize()             { return (int) sizeField.getValue(addr); }
+
+  public int getHeaderSize()       { return (int) headerSizeField.getValue(addr); }
+
+  public long getFrameSizeWords() {
+    return (int) frameSizeField.getValue(addr);
+  }
+
+  public String getName() {
+    return getName();
+  }
+
+  /** OopMap for frame; can return null if none available */
+
+  public ImmutableOopMapSet getOopMaps() {
+    Address value = oopMapsField.getValue(addr);
+    if (value == null) {
+      return null;
+    }
+    return new ImmutableOopMapSet(value);
+  }
+
+
   // Typing
   public boolean isBufferBlob()         { return false; }
+
+  public boolean isAOT()                { return false; }
+
+  public boolean isCompiled()           { return false; }
+
   public boolean isNMethod()            { return false; }
+
   public boolean isRuntimeStub()        { return false; }
+
   public boolean isDeoptimizationStub() { return false; }
+
   public boolean isUncommonTrapStub()   { return false; }
+
   public boolean isExceptionStub()      { return false; }
+
   public boolean isSafepointStub()      { return false; }
+
   public boolean isAdapterBlob()        { return false; }
 
   // Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod()
   public boolean isJavaMethod()         { return false; }
+
   public boolean isNativeMethod()       { return false; }
+
   /** On-Stack Replacement method */
   public boolean isOSRMethod()          { return false; }
 
@@ -105,81 +163,32 @@
     return null;
   }
 
-  // Boundaries
-  public Address headerBegin() {
-    return addr;
-  }
-
-  public Address headerEnd() {
-    return addr.addOffsetTo(headerSizeField.getValue(addr));
-  }
-
-  // FIXME: add RelocInfo
-  //  public RelocInfo relocationBegin();
-  //  public RelocInfo relocationEnd();
-
-  public Address contentBegin() {
-    return headerBegin().addOffsetTo(contentOffsetField.getValue(addr));
-  }
-
-  public Address contentEnd() {
-    return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
-  }
-
-  public Address codeBegin() {
-    return headerBegin().addOffsetTo(contentOffsetField.getValue(addr));
-  }
-
-  public Address codeEnd() {
-    return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
-  }
-
-  public Address dataBegin() {
-    return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
-  }
-
-  public Address dataEnd() {
-    return headerBegin().addOffsetTo(sizeField.getValue(addr));
-  }
-
-  // Offsets
-  public int getRelocationOffset() { return (int) headerSizeField   .getValue(addr); }
-  public int getContentOffset()    { return (int) contentOffsetField.getValue(addr); }
-  public int getCodeOffset()       { return (int) codeOffsetField   .getValue(addr); }
-  public int getDataOffset()       { return (int) dataOffsetField   .getValue(addr); }
-
-  // Sizes
-  public int getSize()             { return (int) sizeField      .getValue(addr);     }
-  public int getHeaderSize()       { return (int) headerSizeField.getValue(addr);     }
   // FIXME: add getRelocationSize()
   public int getContentSize()      { return (int) contentEnd().minus(contentBegin()); }
+
   public int getCodeSize()         { return (int) codeEnd()   .minus(codeBegin());    }
+
   public int getDataSize()         { return (int) dataEnd()   .minus(dataBegin());    }
 
   // Containment
   public boolean blobContains(Address addr)    { return headerBegin() .lessThanOrEqual(addr) && dataEnd()   .greaterThan(addr); }
+
   // FIXME: add relocationContains
   public boolean contentContains(Address addr) { return contentBegin().lessThanOrEqual(addr) && contentEnd().greaterThan(addr); }
+
   public boolean codeContains(Address addr)    { return codeBegin()   .lessThanOrEqual(addr) && codeEnd()   .greaterThan(addr); }
+
   public boolean dataContains(Address addr)    { return dataBegin()   .lessThanOrEqual(addr) && dataEnd()   .greaterThan(addr); }
+
   public boolean contains(Address addr)        { return contentContains(addr);                                                  }
-  public boolean isFrameCompleteAt(Address a)  { return codeContains(a) && a.minus(codeBegin()) >= frameCompleteOffsetField.getValue(addr); }
+
+  public boolean isFrameCompleteAt(Address a)  { return codeContains(a) && a.minus(codeBegin()) >= getFrameCompleteOffset(); }
 
   // Reclamation support (really only used by the nmethods, but in order to get asserts to work
   // in the CodeCache they are defined virtual here)
   public boolean isZombie()             { return false; }
-  public boolean isLockedByVM()         { return false; }
 
-  /** OopMap for frame; can return null if none available */
-  public ImmutableOopMapSet getOopMaps() {
-    Address oopMapsAddr = oopMapsField.getValue(addr);
-    if (oopMapsAddr == null) {
-      return null;
-    }
-    return new ImmutableOopMapSet(oopMapsAddr);
-  }
-  // FIXME: not yet implementable
-  //  void set_oop_maps(ImmutableOopMapSet* p);
+  public boolean isLockedByVM()         { return false; }
 
   public ImmutableOopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) {
     Address pc = returnAddress;
@@ -189,25 +198,14 @@
     return getOopMaps().findMapAtOffset(pc.minus(codeBegin()), debugging);
   }
 
-  //  virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); }
-  //  FIXME;
-
   /** NOTE: this returns a size in BYTES in this system! */
   public long getFrameSize() {
-    return VM.getVM().getAddressSize() * frameSizeField.getValue(addr);
+    return VM.getVM().getAddressSize() * getFrameSizeWords();
   }
 
   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
   public boolean callerMustGCArguments() { return false; }
 
-  public String getName() {
-    return CStringUtilities.getString(nameField.getValue(addr));
-  }
-
-  // FIXME: NOT FINISHED
-
-  // FIXME: add more accessors
-
   public void print() {
     printOn(System.out);
   }
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CompiledMethod.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CompiledMethod.java
new file mode 100644
index 0000000..9f88336
--- /dev/null
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CompiledMethod.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.jvm.hotspot.code;
+
+import java.util.*;
+
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+public abstract class CompiledMethod extends CodeBlob {
+  private static AddressField  methodField;
+  private static AddressField  deoptHandlerBeginField;
+  private static AddressField  deoptMhHandlerBeginField;
+  private static AddressField  scopesDataBeginField;
+
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static void initialize(TypeDataBase db) {
+    Type type = db.lookupType("CompiledMethod");
+
+    methodField                 = type.getAddressField("_method");
+    deoptHandlerBeginField      = type.getAddressField("_deopt_handler_begin");
+    deoptMhHandlerBeginField    = type.getAddressField("_deopt_mh_handler_begin");
+    scopesDataBeginField        = type.getAddressField("_scopes_data_begin");
+  }
+
+  public CompiledMethod(Address addr) {
+    super(addr);
+  }
+
+  public Method getMethod() {
+    return (Method)Metadata.instantiateWrapperFor(methodField.getValue(addr));
+  }
+
+  public Address deoptHandlerBegin()    { return deoptHandlerBeginField.getValue(addr);              }
+  public Address deoptMhHandlerBegin()  { return deoptMhHandlerBeginField.getValue(addr);            }
+  public Address scopesDataBegin()      { return scopesDataBeginField.getValue(addr);                }
+
+  public static int getMethodOffset()                { return (int) methodField.getOffset();                }
+
+  @Override
+  public boolean isCompiled() {
+    return true;
+  }
+}
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java
index df8202d..f2ae000 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,15 +27,13 @@
 import java.io.*;
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
 
-public class NMethod extends CodeBlob {
+public class NMethod extends CompiledMethod {
   private static long          pcDescSize;
-  private static AddressField  methodField;
   /** != InvocationEntryBci if this nmethod is an on-stack replacement method */
   private static CIntegerField entryBCIField;
   /** To support simple linked-list chaining of nmethods */
@@ -45,13 +43,10 @@
 
   /** Offsets for different nmethod parts */
   private static CIntegerField exceptionOffsetField;
-  private static CIntegerField deoptOffsetField;
-  private static CIntegerField deoptMhOffsetField;
   private static CIntegerField origPCOffsetField;
   private static CIntegerField stubOffsetField;
   private static CIntegerField oopsOffsetField;
   private static CIntegerField metadataOffsetField;
-  private static CIntegerField scopesDataOffsetField;
   private static CIntegerField scopesPCsOffsetField;
   private static CIntegerField dependenciesOffsetField;
   private static CIntegerField handlerTableOffsetField;
@@ -91,20 +86,16 @@
   private static void initialize(TypeDataBase db) {
     Type type = db.lookupType("nmethod");
 
-    methodField                 = type.getAddressField("_method");
     entryBCIField               = type.getCIntegerField("_entry_bci");
     osrLinkField                = type.getAddressField("_osr_link");
     scavengeRootLinkField       = type.getAddressField("_scavenge_root_link");
     scavengeRootStateField      = type.getJByteField("_scavenge_root_state");
 
     exceptionOffsetField        = type.getCIntegerField("_exception_offset");
-    deoptOffsetField            = type.getCIntegerField("_deoptimize_offset");
-    deoptMhOffsetField          = type.getCIntegerField("_deoptimize_mh_offset");
     origPCOffsetField           = type.getCIntegerField("_orig_pc_offset");
     stubOffsetField             = type.getCIntegerField("_stub_offset");
     oopsOffsetField             = type.getCIntegerField("_oops_offset");
     metadataOffsetField         = type.getCIntegerField("_metadata_offset");
-    scopesDataOffsetField       = type.getCIntegerField("_scopes_data_offset");
     scopesPCsOffsetField        = type.getCIntegerField("_scopes_pcs_offset");
     dependenciesOffsetField     = type.getCIntegerField("_dependencies_offset");
     handlerTableOffsetField     = type.getCIntegerField("_handler_table_offset");
@@ -123,16 +114,11 @@
     super(addr);
   }
 
-
   // Accessors
   public Address getAddress() {
     return addr;
   }
 
-  public Method getMethod() {
-    return (Method)Metadata.instantiateWrapperFor(methodField.getValue(addr));
-  }
-
   // Type info
   public boolean isNMethod()      { return true;                    }
   public boolean isJavaMethod()   { return !getMethod().isNative(); }
@@ -145,15 +131,12 @@
   public Address instsBegin()           { return codeBegin();                                        }
   public Address instsEnd()             { return headerBegin().addOffsetTo(getStubOffset());         }
   public Address exceptionBegin()       { return headerBegin().addOffsetTo(getExceptionOffset());    }
-  public Address deoptHandlerBegin()    { return headerBegin().addOffsetTo(getDeoptOffset());        }
-  public Address deoptMhHandlerBegin()  { return headerBegin().addOffsetTo(getDeoptMhOffset());      }
   public Address stubBegin()            { return headerBegin().addOffsetTo(getStubOffset());         }
   public Address stubEnd()              { return headerBegin().addOffsetTo(getOopsOffset());         }
   public Address oopsBegin()            { return headerBegin().addOffsetTo(getOopsOffset());         }
   public Address oopsEnd()              { return headerBegin().addOffsetTo(getMetadataOffset());     }
   public Address metadataBegin()        { return headerBegin().addOffsetTo(getMetadataOffset());     }
-  public Address metadataEnd()          { return headerBegin().addOffsetTo(getScopesDataOffset());   }
-  public Address scopesDataBegin()      { return headerBegin().addOffsetTo(getScopesDataOffset());   }
+  public Address metadataEnd()          { return scopesDataBegin();                                  }
   public Address scopesDataEnd()        { return headerBegin().addOffsetTo(getScopesPCsOffset());    }
   public Address scopesPCsBegin()       { return headerBegin().addOffsetTo(getScopesPCsOffset());    }
   public Address scopesPCsEnd()         { return headerBegin().addOffsetTo(getDependenciesOffset()); }
@@ -462,8 +445,6 @@
   public static int getVerifiedEntryPointOffset()    { return (int) verifiedEntryPointField.getOffset();    }
   public static int getOSREntryPointOffset()         { return (int) osrEntryPointField.getOffset();         }
   public static int getEntryBCIOffset()              { return (int) entryBCIField.getOffset();              }
-  /** NOTE: renamed from "method_offset_in_bytes" */
-  public static int getMethodOffset()                { return (int) methodField.getOffset();                }
 
   public void print() {
     printOn(System.out);
@@ -541,12 +522,9 @@
 
   private int getEntryBCI()           { return (int) entryBCIField          .getValue(addr); }
   private int getExceptionOffset()    { return (int) exceptionOffsetField   .getValue(addr); }
-  private int getDeoptOffset()        { return (int) deoptOffsetField       .getValue(addr); }
-  private int getDeoptMhOffset()      { return (int) deoptMhOffsetField     .getValue(addr); }
   private int getStubOffset()         { return (int) stubOffsetField        .getValue(addr); }
   private int getOopsOffset()         { return (int) oopsOffsetField        .getValue(addr); }
   private int getMetadataOffset()     { return (int) metadataOffsetField    .getValue(addr); }
-  private int getScopesDataOffset()   { return (int) scopesDataOffsetField  .getValue(addr); }
   private int getScopesPCsOffset()    { return (int) scopesPCsOffsetField   .getValue(addr); }
   private int getDependenciesOffset() { return (int) dependenciesOffsetField.getValue(addr); }
   private int getHandlerTableOffset() { return (int) handlerTableOffsetField.getValue(addr); }
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeBlob.java
new file mode 100644
index 0000000..c4077f9
--- /dev/null
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeBlob.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.code;
+
+import java.util.*;
+
+import sun.jvm.hotspot.compiler.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+public class RuntimeBlob extends CodeBlob {
+
+  // Only used by server compiler on x86; computed over in SA rather
+  // than relying on computation in target VM
+  private static final int     NOT_YET_COMPUTED = -2;
+  private static final int     UNDEFINED        = -1;
+  private              int     linkOffset       = NOT_YET_COMPUTED;
+
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static void initialize(TypeDataBase db) {
+    Type type = db.lookupType("RuntimeBlob");
+  }
+
+  public RuntimeBlob(Address addr) {
+    super(addr);
+  }
+}
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java
index fd0d72a..98e3dc0 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.types.*;
 
-public class RuntimeStub extends CodeBlob {
+public class RuntimeStub extends RuntimeBlob {
   private static CIntegerField callerMustGCArgumentsField;
 
   static {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java
index 3261492..6d56f48 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.types.*;
 
-public class SingletonBlob extends CodeBlob {
+public class SingletonBlob extends RuntimeBlob {
   static {
     VM.registerVMInitializedObserver(new Observer() {
         public void update(Observable o, Object data) {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
index cefdcf2..46d0873 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,6 +85,12 @@
       tables. */
   public Symbol probe(byte[] name) {
     long hashValue = hashSymbol(name);
+
+    Symbol s = sharedTable.probe(name, hashValue);
+    if (s != null) {
+      return s;
+    }
+
     for (HashtableEntry e = (HashtableEntry) bucket(hashToIndex(hashValue)); e != null; e = (HashtableEntry) e.next()) {
       if (e.hash() == hashValue) {
          Symbol sym = Symbol.create(e.literalValue());
@@ -94,7 +100,7 @@
       }
     }
 
-    return sharedTable.probe(name, hashValue);
+    return null;
   }
 
   public interface SymbolVisitor {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java
index af62d29..207810d 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,11 @@
   }
 
   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    if (!VM.getVM().isJvmtiSupported()) {
+      // no BreakpointInfo support without JVMTI
+      return;
+    }
+
     Type type                  = db.lookupType("BreakpointInfo");
 
     origBytecodeField   = type.getCIntegerField("_orig_bytecode");
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
index d2f15f0..de12216 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
@@ -85,7 +85,9 @@
     isMarkedDependent    = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0);
     initState            = new CIntField(type.getCIntegerField("_init_state"), 0);
     itableLen            = new CIntField(type.getCIntegerField("_itable_len"), 0);
-    breakpoints          = type.getAddressField("_breakpoints");
+    if (VM.getVM().isJvmtiSupported()) {
+      breakpoints        = type.getAddressField("_breakpoints");
+    }
     genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0);
     majorVersion         = new CIntField(type.getCIntegerField("_major_version"), 0);
     minorVersion         = new CIntField(type.getCIntegerField("_minor_version"), 0);
@@ -837,6 +839,9 @@
 
   /** Breakpoint support (see methods on Method* for details) */
   public BreakpointInfo getBreakpoints() {
+    if (!VM.getVM().isJvmtiSupported()) {
+      return null;
+    }
     Address addr = getAddress().getAddressAt(breakpoints.getOffset());
     return (BreakpointInfo) VMObjectFactory.newObject(BreakpointInfo.class, addr);
   }
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java
index 09bb426..a69b3ce 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,6 +87,8 @@
   private StubRoutines stubRoutines;
   private Bytes        bytes;
 
+  /** Flag indicating if JVMTI support is included in the build */
+  private boolean      isJvmtiSupported;
   /** Flags indicating whether we are attached to a core, C1, or C2 build */
   private boolean      usingClientCompiler;
   private boolean      usingServerCompiler;
@@ -324,8 +326,9 @@
        Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
        vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr);
 
+       Type threadLocalAllocBuffer = db.lookupType("ThreadLocalAllocBuffer");
        CIntegerType intType = (CIntegerType) db.lookupType("int");
-       CIntegerField reserveForAllocationPrefetchField = vmVersion.getCIntegerField("_reserve_for_allocation_prefetch");
+       CIntegerField reserveForAllocationPrefetchField = threadLocalAllocBuffer.getCIntegerField("_reserve_for_allocation_prefetch");
        reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType);
     } catch (Exception exp) {
        throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
@@ -336,6 +339,16 @@
     stackBias    = db.lookupIntConstant("STACK_BIAS").intValue();
     invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue();
 
+    // We infer the presence of JVMTI from the presence of the InstanceKlass::_breakpoints field.
+    {
+      Type type = db.lookupType("InstanceKlass");
+      if (type.getField("_breakpoints", false, false) == null) {
+        isJvmtiSupported = false;
+      } else {
+        isJvmtiSupported = true;
+      }
+    }
+
     // We infer the presence of C1 or C2 from a couple of fields we
     // already have present in the type database
     {
@@ -701,6 +714,11 @@
     return isBigEndian;
   }
 
+  /** Returns true if JVMTI is supported, false otherwise */
+  public boolean isJvmtiSupported() {
+    return isJvmtiSupported;
+  }
+
   /** Returns true if this is a "core" build, false if either C1 or C2
       is present */
   public boolean isCore() {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java
index 558117e..80b6c79 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java
@@ -49,11 +49,12 @@
   private static final int SENDER_SP_OFFSET           =  2;
 
   // Interpreter frames
-  private static final int INTERPRETER_FRAME_MIRROR_OFFSET    =  2; // for native calls only
   private static final int INTERPRETER_FRAME_SENDER_SP_OFFSET = -1;
   private static final int INTERPRETER_FRAME_LAST_SP_OFFSET   = INTERPRETER_FRAME_SENDER_SP_OFFSET - 1;
   private static final int INTERPRETER_FRAME_METHOD_OFFSET    = INTERPRETER_FRAME_LAST_SP_OFFSET - 1;
   private static       int INTERPRETER_FRAME_MDX_OFFSET;         // Non-core builds only
+  private static       int INTERPRETER_FRAME_PADDING_OFFSET;
+  private static       int INTERPRETER_FRAME_MIRROR_OFFSET;
   private static       int INTERPRETER_FRAME_CACHE_OFFSET;
   private static       int INTERPRETER_FRAME_LOCALS_OFFSET;
   private static       int INTERPRETER_FRAME_BCX_OFFSET;
@@ -79,7 +80,9 @@
 
   private static synchronized void initialize(TypeDataBase db) {
     INTERPRETER_FRAME_MDX_OFFSET                  = INTERPRETER_FRAME_METHOD_OFFSET - 1;
-    INTERPRETER_FRAME_CACHE_OFFSET                = INTERPRETER_FRAME_MDX_OFFSET - 1;
+    INTERPRETER_FRAME_PADDING_OFFSET              = INTERPRETER_FRAME_MDX_OFFSET - 1;
+    INTERPRETER_FRAME_MIRROR_OFFSET               = INTERPRETER_FRAME_PADDING_OFFSET - 1;
+    INTERPRETER_FRAME_CACHE_OFFSET                = INTERPRETER_FRAME_MIRROR_OFFSET - 1;
     INTERPRETER_FRAME_LOCALS_OFFSET               = INTERPRETER_FRAME_CACHE_OFFSET - 1;
     INTERPRETER_FRAME_BCX_OFFSET                  = INTERPRETER_FRAME_LOCALS_OFFSET - 1;
     INTERPRETER_FRAME_INITIAL_SP_OFFSET           = INTERPRETER_FRAME_BCX_OFFSET - 1;
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java
index 34f5bfb..8dac3a8 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java
@@ -32,13 +32,12 @@
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.utilities.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
 /**
   A command line tool to print class loader statistics.
 */
 
-public class ClassLoaderStats extends Tool implements ToolProvider {
+public class ClassLoaderStats extends Tool {
    boolean verbose = true;
 
    public ClassLoaderStats() {
@@ -54,11 +53,6 @@
       return "classLoaderStats";
    }
 
-   @Override
-   public void run(String... arguments) {
-      execute(arguments);
-   }
-
    public static void main(String[] args) {
       ClassLoaderStats cls = new ClassLoaderStats();
       cls.execute(args);
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java
index 9da8e52..3f5c55a 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java
@@ -28,7 +28,6 @@
 
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -39,7 +38,7 @@
  * Iterates over the queue of object pending finalization and prints a
  * summary of these objects in the form of a histogram.
  */
-public class FinalizerInfo extends Tool implements ToolProvider {
+public class FinalizerInfo extends Tool {
 
     public FinalizerInfo() {
         super();
@@ -54,11 +53,6 @@
         return "finalizerInfo";
     }
 
-    @Override
-    public void run(String... arguments) {
-        execute(arguments);
-    }
-
     public static void main(String[] args) {
         FinalizerInfo finfo = new FinalizerInfo();
         finfo.execute(args);
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java
index d0a11ab..b2cf190 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java
@@ -26,7 +26,6 @@
 
 import sun.jvm.hotspot.utilities.HeapHprofBinWriter;
 import sun.jvm.hotspot.debugger.JVMDebugger;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
 import java.io.IOException;
 
@@ -35,7 +34,7 @@
  * process/core as a HPROF binary file. It can also be used as a standalone
  * tool if required.
  */
-public class HeapDumper extends Tool implements ToolProvider {
+public class HeapDumper extends Tool {
 
     private static String DEFAULT_DUMP_FILE = "heap.bin";
 
@@ -81,11 +80,10 @@
     //   HeapDumper -f <file> <args...>
     public static void main(String args[]) {
         HeapDumper dumper = new HeapDumper();
-        dumper.run(args);
+        dumper.runWithArgs(args);
     }
 
-    @Override
-    public void run(String... args) {
+    public void runWithArgs(String... args) {
         if (args.length > 2) {
             if (args[0].equals("-f")) {
                 this.dumpFile = args[1];
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java
index 5c1012b..643109b 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java
@@ -33,9 +33,8 @@
 import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.runtime.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
-public class HeapSummary extends Tool implements ToolProvider {
+public class HeapSummary extends Tool {
 
    public HeapSummary() {
       super();
@@ -55,11 +54,6 @@
       return "heapSummary";
    }
 
-   @Override
-   public void run(String... arguments) {
-      execute(arguments);
-   }
-
    public void run() {
       CollectedHeap heap = VM.getVM().getUniverse().heap();
       VM.Flag[] flags = VM.getVM().getCommandLineFlags();
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java
index 50f9c30..3e724b9 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java
@@ -27,9 +27,8 @@
 import sun.jvm.hotspot.debugger.JVMDebugger;
 import sun.jvm.hotspot.runtime.Arguments;
 import sun.jvm.hotspot.runtime.VM;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
-public class JInfo extends Tool implements ToolProvider {
+public class JInfo extends Tool {
     public JInfo() {
         super();
     }
@@ -46,6 +45,7 @@
         return false;
     }
 
+    @Override
     public String getName() {
         return "jinfo";
     }
@@ -95,8 +95,7 @@
         tool.run();
     }
 
-    @Override
-    public void run(String... args) {
+    public void runWithArgs(String... args) {
         int mode = -1;
         switch (args.length) {
         case 1:
@@ -142,7 +141,7 @@
 
     public static void main(String[] args) {
         JInfo jinfo = new JInfo();
-        jinfo.run(args);
+        jinfo.runWithArgs(args);
     }
 
     private void printVMFlags() {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java
index 847eac1..21842a8 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java
@@ -71,6 +71,8 @@
     public static final int MODE_HEAP_GRAPH_GXL = 5;
     public static final int MODE_FINALIZERINFO = 6;
 
+    private static String dumpfile = "heap.bin";
+
     public void run() {
         Tool tool = null;
         switch (mode) {
@@ -92,11 +94,11 @@
             break;
 
         case MODE_HEAP_GRAPH_HPROF_BIN:
-            writeHeapHprofBin();
+            writeHeapHprofBin(dumpfile);
             return;
 
         case MODE_HEAP_GRAPH_GXL:
-            writeHeapGXL();
+            writeHeapGXL(dumpfile);
             return;
 
         case MODE_FINALIZERINFO:
@@ -127,18 +129,34 @@
             } else if (modeFlag.equals("-finalizerinfo")) {
                 mode = MODE_FINALIZERINFO;
             } else {
-                int index = modeFlag.indexOf("-heap:format=");
+                int index = modeFlag.indexOf("-heap:");
                 if (index != -1) {
-                    String format = modeFlag.substring(1 + modeFlag.indexOf('='));
-                    if (format.equals("b")) {
-                        mode = MODE_HEAP_GRAPH_HPROF_BIN;
-                    } else if (format.equals("x")) {
-                        mode = MODE_HEAP_GRAPH_GXL;
-                    } else {
-                        System.err.println("unknown heap format:" + format);
+                    String[] options = modeFlag.substring(6).split(",");
+                    for (String option : options) {
+                        String[] keyValue = option.split("=");
+                        if (keyValue[0].equals("format")) {
+                            if (keyValue[1].equals("b")) {
+                                mode = MODE_HEAP_GRAPH_HPROF_BIN;
+                            } else if (keyValue[1].equals("x")) {
+                                mode = MODE_HEAP_GRAPH_GXL;
+                            } else {
+                                System.err.println("unknown heap format:" + keyValue[0]);
 
-                        // Exit with error status
-                        System.exit(1);
+                                // Exit with error status
+                                System.exit(1);
+                            }
+                        } else if (keyValue[0].equals("file")) {
+                            if ((keyValue[1] == null) || keyValue[1].equals("")) {
+                                System.err.println("File name must be set.");
+                                System.exit(1);
+                            }
+                            dumpfile = keyValue[1];
+                        } else {
+                            System.err.println("unknown option:" + keyValue[0]);
+
+                            // Exit with error status
+                            System.exit(1);
+                        }
                     }
                 } else {
                     copyArgs = false;
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java
index 821ed38..6575770 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java
@@ -25,9 +25,8 @@
 package sun.jvm.hotspot.tools;
 
 import sun.jvm.hotspot.debugger.JVMDebugger;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
-public class JStack extends Tool implements ToolProvider {
+public class JStack extends Tool {
     public JStack(boolean mixedMode, boolean concurrentLocks) {
         this.mixedMode = mixedMode;
         this.concurrentLocks = concurrentLocks;
@@ -45,6 +44,7 @@
         return false;
     }
 
+    @Override
     public String getName() {
         return "jstack";
     }
@@ -67,8 +67,7 @@
         tool.run();
     }
 
-    @Override
-    public void run(String... args) {
+    public void runWithArgs(String... args) {
         int used = 0;
         for (int i = 0; i < args.length; i++) {
             if (args[i].equals("-m")) {
@@ -93,7 +92,7 @@
 
     public static void main(String[] args) {
         JStack jstack = new JStack();
-        jstack.run(args);
+        jstack.runWithArgs(args);
     }
 
     private boolean mixedMode;
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java
index 0dc100e..414f857 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java
@@ -27,52 +27,46 @@
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.runtime.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
 import java.io.PrintStream;
 
 /** A sample tool which uses the Serviceability Agent's APIs to obtain
     an object histogram from a remote or crashed VM. */
-public class ObjectHistogram extends Tool implements ToolProvider {
+public class ObjectHistogram extends Tool {
 
     public ObjectHistogram() {
-       super();
+        super();
     }
 
     public ObjectHistogram(JVMDebugger d) {
-       super(d);
+        super(d);
     }
 
     @Override
     public String getName() {
-       return "objectHistogram";
+        return "objectHistogram";
     }
 
-    @Override
-    public void run(String... arguments) {
-        execute(arguments);
+    public void run() {
+        run(System.out, System.err);
     }
 
-   public void run() {
-      run(System.out, System.err);
-   }
-
-   public void run(PrintStream out, PrintStream err) {
-      // Ready to go with the database...
-      ObjectHeap heap = VM.getVM().getObjectHeap();
-      sun.jvm.hotspot.oops.ObjectHistogram histogram =
+    public void run(PrintStream out, PrintStream err) {
+        // Ready to go with the database...
+        ObjectHeap heap = VM.getVM().getObjectHeap();
+        sun.jvm.hotspot.oops.ObjectHistogram histogram =
         new sun.jvm.hotspot.oops.ObjectHistogram();
-      err.println("Iterating over heap. This may take a while...");
-      long startTime = System.currentTimeMillis();
-      heap.iterate(histogram);
-      long endTime = System.currentTimeMillis();
-      histogram.printOn(out);
-      float secs = (float) (endTime - startTime) / 1000.0f;
-      err.println("Heap traversal took " + secs + " seconds.");
-   }
+        err.println("Iterating over heap. This may take a while...");
+        long startTime = System.currentTimeMillis();
+        heap.iterate(histogram);
+        long endTime = System.currentTimeMillis();
+        histogram.printOn(out);
+        float secs = (float) (endTime - startTime) / 1000.0f;
+        err.println("Heap traversal took " + secs + " seconds.");
+    }
 
-   public static void main(String[] args) {
-      ObjectHistogram oh = new ObjectHistogram();
-      oh.execute(args);
-   }
+    public static void main(String[] args) {
+        ObjectHistogram oh = new ObjectHistogram();
+        oh.execute(args);
+    }
 }
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java
index 0c0ccbf..484994c 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java
@@ -28,9 +28,8 @@
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.debugger.cdbg.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
 
-public class PMap extends Tool implements ToolProvider {
+public class PMap extends Tool {
 
    public PMap() {
        super();
@@ -45,11 +44,6 @@
        return "pmap";
    }
 
-   @Override
-   public void run(String... arguments) {
-       execute(arguments);
-   }
-
    public void run() {
       run(System.out);
    }
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java
index 6316d35..a939700 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java
@@ -39,6 +39,7 @@
 
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
 
 import sun.jvm.hotspot.ui.action.*;
 
@@ -55,9 +56,19 @@
     private JavaThreadsTableModel dataModel;
     private StatusBar statusBar;
     private JTable     threadTable;
-    private java.util.List cachedThreads = new ArrayList();
+    private java.util.List<CachedThread> cachedThreads = new ArrayList();
+    private static AddressField crashThread;
 
 
+    static {
+        VM.registerVMInitializedObserver(
+                            (o, a) -> initialize(VM.getVM().getTypeDataBase()));
+    }
+
+    private static void initialize(TypeDataBase db) {
+        crashThread = db.lookupType("VMError").getAddressField("_thread");
+    }
+
     /** Constructor assumes the threads panel is created while the VM is
         suspended. Subsequent resume and suspend operations of the VM
         will cause the threads panel to clear and fill itself back in,
@@ -437,21 +448,14 @@
      * @return a flag which indicates if crashes were encountered.
      */
     private boolean fireShowThreadCrashes() {
-        boolean crash = false;
-        for (Iterator iter = cachedThreads.iterator(); iter.hasNext(); ) {
-            JavaThread t = (JavaThread) ((CachedThread) iter.next()).getThread();
-            sun.jvm.hotspot.runtime.Frame tmpFrame = t.getCurrentFrameGuess();
-            RegisterMap tmpMap = t.newRegisterMap(false);
-            while ((tmpFrame != null) && (!tmpFrame.isFirstFrame())) {
-                if (tmpFrame.isSignalHandlerFrameDbg()) {
-                    showThreadStackMemory(t);
-                    crash = true;
-                    break;
-                }
-                tmpFrame = tmpFrame.sender(tmpMap);
-            }
-        }
-        return crash;
+        Optional<JavaThread> crashed =
+                         cachedThreads.stream()
+                                      .map(t -> t.getThread())
+                                      .filter(t -> t.getAddress().equals(
+                                                        crashThread.getValue()))
+                                      .findAny();
+        crashed.ifPresent(this::showThreadStackMemory);
+        return crashed.isPresent();
     }
 
     private void cache() {
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java
index e5eefb0..e03a855 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,21 +44,23 @@
     Type type = db.lookupType("SymbolCompactHashTable");
     baseAddressField = type.getAddressField("_base_address");
     bucketCountField = type.getCIntegerField("_bucket_count");
-    tableEndOffsetField = type.getCIntegerField("_table_end_offset");
+    entryCountField = type.getCIntegerField("_entry_count");
     bucketsField = type.getAddressField("_buckets");
-    uintSize = db.lookupType("juint").getSize();
+    entriesField = type.getAddressField("_entries");
+    uintSize = db.lookupType("u4").getSize();
   }
 
   // Fields
   private static CIntegerField bucketCountField;
-  private static CIntegerField tableEndOffsetField;
+  private static CIntegerField entryCountField;
   private static AddressField  baseAddressField;
   private static AddressField  bucketsField;
+  private static AddressField  entriesField;
   private static long uintSize;
 
   private static int BUCKET_OFFSET_MASK = 0x3FFFFFFF;
   private static int BUCKET_TYPE_SHIFT = 30;
-  private static int COMPACT_BUCKET_TYPE = 1;
+  private static int VALUE_ONLY_BUCKET_TYPE = 1;
 
   public CompactHashTable(Address addr) {
     super(addr);
@@ -68,12 +70,8 @@
     return (int)bucketCountField.getValue(addr);
   }
 
-  private int tableEndOffset() {
-    return (int)tableEndOffsetField.getValue(addr);
-  }
-
-  private boolean isCompactBucket(int bucket_info) {
-    return (bucket_info >> BUCKET_TYPE_SHIFT) == COMPACT_BUCKET_TYPE;
+  private boolean isValueOnlyBucket(int bucket_info) {
+    return (bucket_info >> BUCKET_TYPE_SHIFT) == VALUE_ONLY_BUCKET_TYPE;
   }
 
   private int bucketOffset(int bucket_info) {
@@ -81,9 +79,8 @@
   }
 
   public Symbol probe(byte[] name, long hash) {
-
-    if (bucketCount() == 0) {
-      // The table is invalid, so don't try to lookup
+    if (bucketCount() <= 0) {
+      // This CompactHashTable is not in use
       return null;
     }
 
@@ -91,34 +88,33 @@
     Symbol  sym;
     Address baseAddress = baseAddressField.getValue(addr);
     Address bucket = bucketsField.getValue(addr);
-    Address bucketEnd = bucket;
     long index = hash % bucketCount();
     int bucketInfo = (int)bucket.getCIntegerAt(index * uintSize, uintSize, true);
     int bucketOffset = bucketOffset(bucketInfo);
     int nextBucketInfo = (int)bucket.getCIntegerAt((index+1) * uintSize, uintSize, true);
     int nextBucketOffset = bucketOffset(nextBucketInfo);
 
-    bucket = bucket.addOffsetTo(bucketOffset * uintSize);
+    Address entry = entriesField.getValue(addr).addOffsetTo(bucketOffset * uintSize);
 
-    if (isCompactBucket(bucketInfo)) {
-      symOffset = bucket.getCIntegerAt(0, uintSize, true);
+    if (isValueOnlyBucket(bucketInfo)) {
+      symOffset = entry.getCIntegerAt(0, uintSize, true);
       sym = Symbol.create(baseAddress.addOffsetTo(symOffset));
       if (sym.equals(name)) {
         return sym;
       }
     } else {
-      bucketEnd = bucket.addOffsetTo(nextBucketOffset * uintSize);
-      while (bucket.lessThan(bucketEnd)) {
-        long symHash = bucket.getCIntegerAt(0, uintSize, true);
+      Address entryMax = entriesField.getValue(addr).addOffsetTo(nextBucketOffset * uintSize);
+      while (entry.lessThan(entryMax)) {
+        long symHash = entry.getCIntegerAt(0, uintSize, true);
         if (symHash == hash) {
-          symOffset = bucket.getCIntegerAt(uintSize, uintSize, true);
+          symOffset = entry.getCIntegerAt(uintSize, uintSize, true);
           Address symAddr = baseAddress.addOffsetTo(symOffset);
           sym = Symbol.create(symAddr);
           if (sym.equals(name)) {
             return sym;
           }
         }
-        bucket = bucket.addOffsetTo(2 * uintSize);
+        entry = entry.addOffsetTo(2 * uintSize);
       }
     }
     return null;
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java
index 7668759..9b8f755 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java
@@ -22,7 +22,7 @@
  */
 package jdk.vm.ci.common;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Utilities for operating on raw memory with {@link Unsafe}.
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java
index 0990199..6f2d8c5 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java
@@ -39,7 +39,7 @@
 import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaType;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Calls from Java into HotSpot. The behavior of all the methods in this class that take a native
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java
index a01a304..dac0fb3 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java
@@ -120,7 +120,9 @@
             resultInstalledCode = installedCode;
         }
 
-        int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, (HotSpotSpeculationLog) log);
+        HotSpotSpeculationLog speculationLog = (log != null && log.hasSpeculations()) ? (HotSpotSpeculationLog) log : null;
+
+        int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, speculationLog);
         if (result != config.codeInstallResultOk) {
             String resultDesc = config.getCodeInstallResultDescription(result);
             if (compiledCode instanceof HotSpotCompiledNmethod) {
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java
index aa8368d..98fa181 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java
@@ -25,7 +25,7 @@
 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.inittimer.SuppressFBWarnings;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Implementation of {@link InstalledCode} for HotSpot.
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java
index 12cc525..7d6b4b2 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java
@@ -30,7 +30,7 @@
 import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.meta.ResolvedJavaType;
 import jdk.vm.ci.runtime.JVMCIRuntime;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 //JaCoCo Exclude
 
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
index b824f0c..6914926 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
@@ -146,6 +146,9 @@
 
     @Override
     public JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) {
+        if (kind == null) {
+            throw new IllegalArgumentException("null JavaKind");
+        }
         if (kind == JavaKind.Object) {
             Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops);
             return HotSpotObjectConstantImpl.forObject(o);
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java
index f42f9af..dfdc3eb 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java
@@ -39,7 +39,7 @@
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaType;
 import jdk.vm.ci.meta.TriState;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Access to a HotSpot MethodData structure (defined in methodData.hpp).
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java
index 87cf467..1293a10 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java
@@ -130,7 +130,7 @@
 
         /* Load non-public field: LambdaForm MethodHandle.form */
         JavaConstant lambdaForm = constantReflection.readFieldValue(LazyInitialization.methodHandleFormField, methodHandle);
-        if (lambdaForm.isNull()) {
+        if (lambdaForm == null || lambdaForm.isNull()) {
             return null;
         }
 
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java
index 6d192ef..75a76e8 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java
@@ -393,17 +393,12 @@
     }
 
     @Override
-    public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) {
-        ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType);
-        if (resolvedMethod == null || resolvedMethod.isAbstract()) {
-            return null;
-        }
-        return resolvedMethod;
-    }
-
-    @Override
     public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) {
         assert !callerType.isArray();
+        if (isInterface()) {
+            // Methods can only be resolved against concrete types
+            return null;
+        }
         if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic()) {
             return method;
         }
@@ -887,4 +882,9 @@
     public boolean isTrustedInterfaceType() {
         return TrustedInterface.class.isAssignableFrom(mirror());
     }
+
+    @Override
+    public boolean isCloneableWithAllocation() {
+        return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0;
+    }
 }
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java
index 06e03ae..64f9027 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java
@@ -169,11 +169,6 @@
     }
 
     @Override
-    public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) {
-        return null;
-    }
-
-    @Override
     public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) {
         return null;
     }
@@ -272,4 +267,9 @@
     public boolean isTrustedInterfaceType() {
         return false;
     }
+
+    @Override
+    public boolean isCloneableWithAllocation() {
+        return false;
+    }
 }
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java
index e619fb4..0cd643f 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java
@@ -38,7 +38,7 @@
     /** All speculations that have been a deoptimization reason. */
     private Set<SpeculationReason> failedSpeculations;
 
-    /** Strong references to all reasons embededded in the current nmethod. */
+    /** Strong references to all reasons embedded in the current nmethod. */
     private volatile Collection<SpeculationReason> speculations;
 
     @Override
@@ -81,4 +81,9 @@
 
         return HotSpotObjectConstantImpl.forObject(reason);
     }
+
+    @Override
+    public synchronized boolean hasSpeculations() {
+        return speculations != null && !speculations.isEmpty();
+    }
 }
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java
index 72c2552..1f7ffc1 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java
@@ -38,7 +38,7 @@
 import jdk.vm.ci.hotspotvmconfig.HotSpotVMField;
 import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag;
 import jdk.vm.ci.hotspotvmconfig.HotSpotVMType;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 //JaCoCo Exclude
 
@@ -1077,6 +1077,7 @@
     @HotSpotVMConstant(name = "JVM_ACC_FIELD_STABLE") @Stable public int jvmAccFieldStable;
     @HotSpotVMConstant(name = "JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE") @Stable public int jvmAccFieldHasGenericSignature;
     @HotSpotVMConstant(name = "JVM_ACC_WRITTEN_FLAGS") @Stable public int jvmAccWrittenFlags;
+    @HotSpotVMConstant(name = "JVM_ACC_IS_CLONEABLE_FAST") @Stable public int jvmAccIsCloneableFast;
 
     // Modifier.SYNTHETIC is not public so we get it via vmStructs.
     @HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int jvmAccSynthetic;
@@ -1230,7 +1231,7 @@
     @HotSpotVMField(name = "Method::_method_counters", type = "MethodCounters*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCountersOffset;
     @HotSpotVMField(name = "Method::_method_data", type = "MethodData*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset;
     @HotSpotVMField(name = "Method::_from_compiled_entry", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset;
-    @HotSpotVMField(name = "Method::_code", type = "nmethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset;
+    @HotSpotVMField(name = "Method::_code", type = "CompiledMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset;
 
     @HotSpotVMConstant(name = "Method::_jfr_towrite") @Stable public int methodFlagsJfrTowrite;
     @HotSpotVMConstant(name = "Method::_caller_sensitive") @Stable public int methodFlagsCallerSensitive;
@@ -1558,13 +1559,13 @@
 
     @HotSpotVMAddress(name = "os::javaTimeMillis") @Stable public long javaTimeMillisAddress;
     @HotSpotVMAddress(name = "os::javaTimeNanos") @Stable public long javaTimeNanosAddress;
-    @HotSpotVMAddress(name = "SharedRuntime::dsin") @Stable public long arithmeticSinAddress;
-    @HotSpotVMAddress(name = "SharedRuntime::dcos") @Stable public long arithmeticCosAddress;
-    @HotSpotVMAddress(name = "SharedRuntime::dtan") @Stable public long arithmeticTanAddress;
-    @HotSpotVMAddress(name = "SharedRuntime::dexp") @Stable public long arithmeticExpAddress;
-    @HotSpotVMAddress(name = "SharedRuntime::dlog") @Stable public long arithmeticLogAddress;
-    @HotSpotVMAddress(name = "SharedRuntime::dlog10") @Stable public long arithmeticLog10Address;
-    @HotSpotVMAddress(name = "SharedRuntime::dpow") @Stable public long arithmeticPowAddress;
+    @HotSpotVMField(name = "CompilerToVM::Data::dsin", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticSinAddress;
+    @HotSpotVMField(name = "CompilerToVM::Data::dcos", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticCosAddress;
+    @HotSpotVMField(name = "CompilerToVM::Data::dtan", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticTanAddress;
+    @HotSpotVMField(name = "CompilerToVM::Data::dexp", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticExpAddress;
+    @HotSpotVMField(name = "CompilerToVM::Data::dlog", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticLogAddress;
+    @HotSpotVMField(name = "CompilerToVM::Data::dlog10", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticLog10Address;
+    @HotSpotVMField(name = "CompilerToVM::Data::dpow", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticPowAddress;
 
     @HotSpotVMFlag(name = "JVMCICounterSize") @Stable public int jvmciCountersSize;
 
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java
index 5f82244..8995bd6 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java
@@ -40,7 +40,7 @@
 import jdk.internal.org.objectweb.asm.MethodVisitor;
 import jdk.internal.org.objectweb.asm.Opcodes;
 import jdk.internal.org.objectweb.asm.Type;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * A {@link ClassVisitor} that verifies {@link HotSpotVMConfig} does not access {@link Unsafe} from
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java
index 0e1398e..bcc2b8f 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java
@@ -24,7 +24,7 @@
 
 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Class to access the C++ {@code vmSymbols} table.
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java
index cff2ced..c75c449 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java
@@ -24,7 +24,7 @@
 
 import java.lang.reflect.Field;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Package private access to the {@link Unsafe} capability.
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java
index 2f10d10..f98461d 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java
@@ -35,8 +35,8 @@
      * @param displacement the displacement within the object in bytes
      * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the
      *         value cannot be read.
-     * @throws IllegalArgumentException if {@code kind} is {@link JavaKind#Void} or not
-     *             {@linkplain JavaKind#isPrimitive() primitive} kind
+     * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void} or
+     *             not {@linkplain JavaKind#isPrimitive() primitive} kind
      */
     JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant base, long displacement) throws IllegalArgumentException;
 
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java
index 3be863e..9a88297 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java
@@ -217,27 +217,34 @@
 
     /**
      * Resolves the method implementation for virtual dispatches on objects of this dynamic type.
-     * This resolution process only searches "up" the class hierarchy of this type.
+     * This resolution process only searches "up" the class hierarchy of this type. A broader search
+     * that also walks "down" the hierarchy is implemented by
+     * {@link #findUniqueConcreteMethod(ResolvedJavaMethod)}. For interface types it returns null
+     * since no concrete object can be an interface.
      *
      * @param method the method to select the implementation of
      * @param callerType the caller or context type used to perform access checks
-     * @return the link-time resolved method (might be abstract) or {@code null} if it can not be
-     *         linked
+     * @return the method that would be selected at runtime (might be abstract) or {@code null} if
+     *         it can not be resolved
      */
     ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType);
 
     /**
-     * Resolves the method implementation for virtual dispatches on objects of this dynamic type.
-     * This resolution process only searches "up" the class hierarchy of this type. A broader search
-     * that also walks "down" the hierarchy is implemented by
-     * {@link #findUniqueConcreteMethod(ResolvedJavaMethod)}.
+     * A convenience wrapper for {@link #resolveMethod(ResolvedJavaMethod, ResolvedJavaType)} that
+     * only returns non-abstract methods.
      *
      * @param method the method to select the implementation of
      * @param callerType the caller or context type used to perform access checks
      * @return the concrete method that would be selected at runtime, or {@code null} if there is no
      *         concrete implementation of {@code method} in this type or any of its superclasses
      */
-    ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType);
+    default ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) {
+        ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType);
+        if (resolvedMethod == null || resolvedMethod.isAbstract()) {
+            return null;
+        }
+        return resolvedMethod;
+    }
 
     /**
      * Given a {@link ResolvedJavaMethod} A, returns a concrete {@link ResolvedJavaMethod} B that is
@@ -352,4 +359,12 @@
         }
         return null;
     }
+
+    /**
+     * Returns true if this type is {@link Cloneable} and can be safely cloned by creating a normal
+     * Java allocation and populating it from the fields returned by
+     * {@link #getInstanceFields(boolean)}. Some types may require special handling by the platform
+     * so they would to go through the normal {@link Object#clone} path.
+     */
+    boolean isCloneableWithAllocation();
 }
diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java
index 4330e65..b81f5f2 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java
@@ -56,4 +56,11 @@
      *         argument to the deoptimization function.
      */
     JavaConstant speculate(SpeculationReason reason);
+
+    /**
+     * Returns if this log has speculations.
+     *
+     * @return true if there are speculations, false otherwise
+     */
+    boolean hasSpeculations();
 }
diff --git a/hotspot/src/jdk.vm.ci/share/classes/module-info.java b/hotspot/src/jdk.vm.ci/share/classes/module-info.java
index e105f01..a59a37d 100644
--- a/hotspot/src/jdk.vm.ci/share/classes/module-info.java
+++ b/hotspot/src/jdk.vm.ci/share/classes/module-info.java
@@ -24,9 +24,6 @@
  */
 
 module jdk.vm.ci {
-    // 8153756
-    requires jdk.unsupported;
-
     uses jdk.vm.ci.hotspot.HotSpotVMEventListener;
     uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
     uses jdk.vm.ci.runtime.JVMCICompilerFactory;
diff --git a/hotspot/src/os/aix/vm/globals_aix.hpp b/hotspot/src/os/aix/vm/globals_aix.hpp
index bfd244e..21f250b 100644
--- a/hotspot/src/os/aix/vm/globals_aix.hpp
+++ b/hotspot/src/os/aix/vm/globals_aix.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -30,7 +30,15 @@
 // Defines Aix specific flags. They are not available on other platforms.
 //
 // (Please keep the switches sorted alphabetically.)
-#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \
+#define RUNTIME_OS_FLAGS(develop, \
+                         develop_pd, \
+                         product, \
+                         product_pd, \
+                         diagnostic, \
+                         notproduct, \
+                         range, \
+                         constraint, \
+                         writeable) \
                                                                                     \
   /* Whether to allow the VM to run if EXTSHM=ON. EXTSHM is an environment */       \
   /* variable used on AIX to activate certain hacks which allow more shm segments */\
diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp
index 22e016b..20e3770 100644
--- a/hotspot/src/os/aix/vm/os_aix.cpp
+++ b/hotspot/src/os/aix/vm/os_aix.cpp
@@ -777,7 +777,7 @@
 // create new thread
 
 // Thread start routine for all newly created threads
-static void *java_start(Thread *thread) {
+static void *thread_native_entry(Thread *thread) {
 
   // find out my own stack dimensions
   {
@@ -838,6 +838,15 @@
   log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", kernel thread id: " UINTX_FORMAT ").",
     os::current_thread_id(), (uintx) kernel_thread_id);
 
+  // If a thread has not deleted itself ("delete this") as part of its
+  // termination sequence, we have to ensure thread-local-storage is
+  // cleared before we actually terminate. No threads should ever be
+  // deleted asynchronously with respect to their termination.
+  if (Thread::current_or_null_safe() != NULL) {
+    assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
+    thread->clear_thread_current();
+  }
+
   return 0;
 }
 
@@ -902,7 +911,7 @@
   pthread_attr_setstacksize(&attr, stack_size);
 
   pthread_t tid;
-  int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
+  int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread);
 
 
   char buf[64];
@@ -993,11 +1002,14 @@
 void os::free_thread(OSThread* osthread) {
   assert(osthread != NULL, "osthread not set");
 
-  if (Thread::current()->osthread() == osthread) {
-    // Restore caller's signal mask
-    sigset_t sigmask = osthread->caller_sigmask();
-    pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
-   }
+  // We are told to free resources of the argument thread,
+  // but we can only really operate on the current thread.
+  assert(Thread::current()->osthread() == osthread,
+         "os::free_thread but not current thread");
+
+  // Restore caller's signal mask
+  sigset_t sigmask = osthread->caller_sigmask();
+  pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
 
   delete osthread;
 }
@@ -4875,3 +4887,16 @@
   }
   return yes;
 }
+
+static inline time_t get_mtime(const char* filename) {
+  struct stat st;
+  int ret = os::stat(filename, &st);
+  assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno));
+  return st.st_mtime;
+}
+
+int os::compare_file_modified_times(const char* file1, const char* file2) {
+  time_t t1 = get_mtime(file1);
+  time_t t2 = get_mtime(file2);
+  return t1 - t2;
+}
diff --git a/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp b/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp
index 6e012a9..111f644 100644
--- a/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp
+++ b/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -256,8 +256,9 @@
 
   GEN_OFFS(CodeBlob, _name);
   GEN_OFFS(CodeBlob, _header_size);
-  GEN_OFFS(CodeBlob, _content_offset);
-  GEN_OFFS(CodeBlob, _code_offset);
+  GEN_OFFS(CodeBlob, _content_begin);
+  GEN_OFFS(CodeBlob, _code_begin);
+  GEN_OFFS(CodeBlob, _code_end);
   GEN_OFFS(CodeBlob, _data_offset);
   GEN_OFFS(CodeBlob, _frame_size);
   printf("\n");
@@ -265,10 +266,10 @@
   GEN_OFFS(nmethod, _method);
   GEN_OFFS(nmethod, _dependencies_offset);
   GEN_OFFS(nmethod, _metadata_offset);
-  GEN_OFFS(nmethod, _scopes_data_offset);
+  GEN_OFFS(nmethod, _scopes_data_begin);
   GEN_OFFS(nmethod, _scopes_pcs_offset);
   GEN_OFFS(nmethod, _handler_table_offset);
-  GEN_OFFS(nmethod, _deoptimize_offset);
+  GEN_OFFS(nmethod, _deopt_handler_begin);
   GEN_OFFS(nmethod, _orig_pc_offset);
 
   GEN_OFFS(PcDesc, _pc_offset);
diff --git a/hotspot/src/os/bsd/dtrace/libjvm_db.c b/hotspot/src/os/bsd/dtrace/libjvm_db.c
index 7a7105c..d68436c3 100644
--- a/hotspot/src/os/bsd/dtrace/libjvm_db.c
+++ b/hotspot/src/os/bsd/dtrace/libjvm_db.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -124,10 +124,10 @@
   uint64_t pc_desc;
 
   int32_t  orig_pc_offset;      /* _orig_pc_offset */
-  int32_t  instrs_beg;          /* _code_offset */
-  int32_t  instrs_end;
-  int32_t  deopt_beg;           /* _deoptimize_offset */
-  int32_t  scopes_data_beg;     /* _scopes_data_offset */
+  uint64_t  instrs_beg;          /* _code_offset */
+  uint64_t  instrs_end;
+  uint64_t  deopt_beg;           /* _deoptimize_offset */
+  uint64_t  scopes_data_beg;     /* _scopes_data_offset */
   int32_t  scopes_data_end;
   int32_t  metadata_beg;        /* _metadata_offset */
   int32_t  metadata_end;
@@ -617,11 +617,12 @@
       fprintf(stderr, "\t nmethod_info: BEGIN \n");
 
   /* Instructions */
-  err = ps_pread(J->P, nm + OFFSET_CodeBlob_code_offset, &N->instrs_beg, SZ32);
+  err = read_pointer(J, base + OFFSET_VMStructEntryaddress, &vmp->address);
+  err = read_pointer(J, nm + OFFSET_CodeBlob_code_begin, &N->instrs_beg);
   CHECK_FAIL(err);
-  err = ps_pread(J->P, nm + OFFSET_CodeBlob_data_offset, &N->instrs_end, SZ32);
+  err = read_pointer(J, nm + OFFSET_CodeBlob_code_end, &N->instrs_end);
   CHECK_FAIL(err);
-  err = ps_pread(J->P, nm + OFFSET_nmethod_deoptimize_offset, &N->deopt_beg, SZ32);
+  err = read_pointer(J, nm + OFFSET_nmethod_deopt_handler_begin, &N->deopt_beg);
   CHECK_FAIL(err);
   err = ps_pread(J->P, nm + OFFSET_nmethod_orig_pc_offset, &N->orig_pc_offset, SZ32);
   CHECK_FAIL(err);
@@ -639,7 +640,7 @@
   CHECK_FAIL(err);
 
   /* scopes_data */
-  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->scopes_data_beg, SZ32);
+  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->scopes_data_beg, POINTER_SIZE);
   CHECK_FAIL(err);
 
   if (debug > 2 ) {
@@ -868,7 +869,7 @@
   err = ps_pread(N->J->P, pc_desc + OFFSET_PcDesc_pc_offset, &pc_offset, SZ32);
   CHECK_FAIL(err);
 
-  *real_pc = N->nm + N->instrs_beg + pc_offset;
+  *real_pc = N->instrs_beg + pc_offset;
   if (debug > 2) {
       fprintf(stderr, "\t\t get_real_pc: pc_offset: %lx, real_pc: %llx\n",
                        pc_offset, *real_pc);
@@ -942,7 +943,7 @@
       fprintf(stderr, "\t\t scope_desc_at: BEGIN \n");
   }
 
-  buffer = N->nm + N->scopes_data_beg + decode_offset;
+  buffer = N->scopes_data_beg + decode_offset;
 
   err = raw_read_int(N->J, &buffer, &vf->sender_decode_offset);
   CHECK_FAIL(err);
@@ -1052,11 +1053,11 @@
   CHECK_FAIL(err);
   if (debug) {
       fprintf(stderr, "name_for_nmethod: pc: %#llx, deopt_pc:  %#llx\n",
-              pc, N->nm + N->deopt_beg);
+              pc, N->deopt_beg);
   }
 
   /* check for a deoptimized frame */
-  if ( pc == N->nm + N->deopt_beg) {
+  if ( pc == N->deopt_beg) {
     uint64_t base;
     if (debug) {
         fprintf(stderr, "name_for_nmethod: found deoptimized frame\n");
diff --git a/hotspot/src/os/bsd/vm/globals_bsd.hpp b/hotspot/src/os/bsd/vm/globals_bsd.hpp
index a085cbe..f3b076e 100644
--- a/hotspot/src/os/bsd/vm/globals_bsd.hpp
+++ b/hotspot/src/os/bsd/vm/globals_bsd.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,15 @@
 //
 // Defines Bsd specific flags. They are not available on other platforms.
 //
-#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \
+#define RUNTIME_OS_FLAGS(develop, \
+                         develop_pd, \
+                         product, \
+                         product_pd, \
+                         diagnostic, \
+                         notproduct, \
+                         range, \
+                         constraint, \
+                         writeable) \
                                                                                 \
   product(bool, UseOprofile, false,                                             \
         "enable support for Oprofile profiler")                                 \
diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp
index 78def16..6de7592 100644
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp
@@ -665,7 +665,7 @@
 #endif
 
 // Thread start routine for all newly created threads
-static void *java_start(Thread *thread) {
+static void *thread_native_entry(Thread *thread) {
   // Try to randomize the cache line index of hot stack frames.
   // This helps when threads of the same stack traces evict each other's
   // cache lines. The threads can be either from the same JVM instance, or
@@ -723,6 +723,15 @@
   log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").",
     os::current_thread_id(), (uintx) pthread_self());
 
+  // If a thread has not deleted itself ("delete this") as part of its
+  // termination sequence, we have to ensure thread-local-storage is
+  // cleared before we actually terminate. No threads should ever be
+  // deleted asynchronously with respect to their termination.
+  if (Thread::current_or_null_safe() != NULL) {
+    assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
+    thread->clear_thread_current();
+  }
+
   return 0;
 }
 
@@ -781,7 +790,7 @@
 
   {
     pthread_t tid;
-    int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
+    int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread);
 
     char buf[64];
     if (ret == 0) {
@@ -889,11 +898,14 @@
 void os::free_thread(OSThread* osthread) {
   assert(osthread != NULL, "osthread not set");
 
-  if (Thread::current()->osthread() == osthread) {
-    // Restore caller's signal mask
-    sigset_t sigmask = osthread->caller_sigmask();
-    pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
-  }
+  // We are told to free resources of the argument thread,
+  // but we can only really operate on the current thread.
+  assert(Thread::current()->osthread() == osthread,
+         "os::free_thread but not current thread");
+
+  // Restore caller's signal mask
+  sigset_t sigmask = osthread->caller_sigmask();
+  pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
 
   delete osthread;
 }
diff --git a/hotspot/src/os/linux/vm/globals_linux.hpp b/hotspot/src/os/linux/vm/globals_linux.hpp
index 05f4c18..39bedf3 100644
--- a/hotspot/src/os/linux/vm/globals_linux.hpp
+++ b/hotspot/src/os/linux/vm/globals_linux.hpp
@@ -28,7 +28,15 @@
 //
 // Defines Linux specific flags. They are not available on other platforms.
 //
-#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \
+#define RUNTIME_OS_FLAGS(develop, \
+                         develop_pd, \
+                         product, \
+                         product_pd, \
+                         diagnostic, \
+                         notproduct, \
+                         range, \
+                         constraint, \
+                         writeable) \
                                                                         \
   product(bool, UseOprofile, false,                                     \
         "enable support for Oprofile profiler")                         \
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 4889870..3becb38 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -638,7 +638,7 @@
 // create new thread
 
 // Thread start routine for all newly created threads
-static void *java_start(Thread *thread) {
+static void *thread_native_entry(Thread *thread) {
   // Try to randomize the cache line index of hot stack frames.
   // This helps when threads of the same stack traces evict each other's
   // cache lines. The threads can be either from the same JVM instance, or
@@ -690,6 +690,15 @@
   log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").",
     os::current_thread_id(), (uintx) pthread_self());
 
+  // If a thread has not deleted itself ("delete this") as part of its
+  // termination sequence, we have to ensure thread-local-storage is
+  // cleared before we actually terminate. No threads should ever be
+  // deleted asynchronously with respect to their termination.
+  if (Thread::current_or_null_safe() != NULL) {
+    assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
+    thread->clear_thread_current();
+  }
+
   return 0;
 }
 
@@ -753,7 +762,7 @@
 
   {
     pthread_t tid;
-    int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
+    int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread);
 
     char buf[64];
     if (ret == 0) {
@@ -881,18 +890,21 @@
 void os::free_thread(OSThread* osthread) {
   assert(osthread != NULL, "osthread not set");
 
-  if (Thread::current()->osthread() == osthread) {
+  // We are told to free resources of the argument thread,
+  // but we can only really operate on the current thread.
+  assert(Thread::current()->osthread() == osthread,
+         "os::free_thread but not current thread");
+
 #ifdef ASSERT
-    sigset_t current;
-    sigemptyset(&current);
-    pthread_sigmask(SIG_SETMASK, NULL, &current);
-    assert(!sigismember(&current, SR_signum), "SR signal should not be blocked!");
+  sigset_t current;
+  sigemptyset(&current);
+  pthread_sigmask(SIG_SETMASK, NULL, &current);
+  assert(!sigismember(&current, SR_signum), "SR signal should not be blocked!");
 #endif
 
-    // Restore caller's signal mask
-    sigset_t sigmask = osthread->caller_sigmask();
-    pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
-  }
+  // Restore caller's signal mask
+  sigset_t sigmask = osthread->caller_sigmask();
+  pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
 
   delete osthread;
 }
@@ -2013,8 +2025,8 @@
 // their own specific XXX-release file as well as a redhat-release file.
 // Because of this the XXX-release file needs to be searched for before the
 // redhat-release file.
-// Since Red Hat has a lsb-release file that is not very descriptive the
-// search for redhat-release needs to be before lsb-release.
+// Since Red Hat and SuSE have an lsb-release file that is not very descriptive the
+// search for redhat-release / SuSE-release needs to be before lsb-release.
 // Since the lsb-release file is the new standard it needs to be searched
 // before the older style release files.
 // Searching system-release (Red Hat) and os-release (other Linuxes) are a
@@ -2031,8 +2043,8 @@
   "/etc/mandrake-release",
   "/etc/sun-release",
   "/etc/redhat-release",
-  "/etc/lsb-release",
   "/etc/SuSE-release",
+  "/etc/lsb-release",
   "/etc/turbolinux-release",
   "/etc/gentoo-release",
   "/etc/ltib-release",
@@ -2062,14 +2074,11 @@
   st->cr();
 }
 
-static void parse_os_info(char* distro, size_t length, const char* file) {
-  FILE* fp = fopen(file, "r");
-  if (fp != NULL) {
-    char buf[256];
-    // get last line of the file.
-    while (fgets(buf, sizeof(buf), fp)) { }
-    // Edit out extra stuff in expected ubuntu format
-    if (strstr(buf, "DISTRIB_DESCRIPTION=") != NULL) {
+static void parse_os_info_helper(FILE* fp, char* distro, size_t length, bool get_first_line) {
+  char buf[256];
+  while (fgets(buf, sizeof(buf), fp)) {
+    // Edit out extra stuff in expected format
+    if (strstr(buf, "DISTRIB_DESCRIPTION=") != NULL || strstr(buf, "PRETTY_NAME=") != NULL) {
       char* ptr = strstr(buf, "\"");  // the name is in quotes
       if (ptr != NULL) {
         ptr++; // go beyond first quote
@@ -2083,13 +2092,26 @@
         if (nl != NULL) *nl = '\0';
         strncpy(distro, ptr, length);
       }
-    } else {
-      // if not in expected Ubuntu format, print out whole line minus \n
+      return;
+    } else if (get_first_line) {
       char* nl = strchr(buf, '\n');
       if (nl != NULL) *nl = '\0';
       strncpy(distro, buf, length);
+      return;
     }
-    // close distro file
+  }
+  // print last line and close
+  char* nl = strchr(buf, '\n');
+  if (nl != NULL) *nl = '\0';
+  strncpy(distro, buf, length);
+}
+
+static void parse_os_info(char* distro, size_t length, const char* file) {
+  FILE* fp = fopen(file, "r");
+  if (fp != NULL) {
+    // if suse format, print out first line
+    bool get_first_line = (strcmp(file, "/etc/SuSE-release") == 0);
+    parse_os_info_helper(fp, distro, length, get_first_line);
     fclose(fp);
   }
 }
@@ -3041,6 +3063,48 @@
   return addr == MAP_FAILED ? NULL : addr;
 }
 
+// Allocate (using mmap, NO_RESERVE, with small pages) at either a given request address
+//   (req_addr != NULL) or with a given alignment.
+//  - bytes shall be a multiple of alignment.
+//  - req_addr can be NULL. If not NULL, it must be a multiple of alignment.
+//  - alignment sets the alignment at which memory shall be allocated.
+//     It must be a multiple of allocation granularity.
+// Returns address of memory or NULL. If req_addr was not NULL, will only return
+//  req_addr or NULL.
+static char* anon_mmap_aligned(size_t bytes, size_t alignment, char* req_addr) {
+
+  size_t extra_size = bytes;
+  if (req_addr == NULL && alignment > 0) {
+    extra_size += alignment;
+  }
+
+  char* start = (char*) ::mmap(req_addr, extra_size, PROT_NONE,
+    MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
+    -1, 0);
+  if (start == MAP_FAILED) {
+    start = NULL;
+  } else {
+    if (req_addr != NULL) {
+      if (start != req_addr) {
+        ::munmap(start, extra_size);
+        start = NULL;
+      }
+    } else {
+      char* const start_aligned = (char*) align_ptr_up(start, alignment);
+      char* const end_aligned = start_aligned + bytes;
+      char* const end = start + extra_size;
+      if (start_aligned > start) {
+        ::munmap(start, start_aligned - start);
+      }
+      if (end_aligned < end) {
+        ::munmap(end_aligned, end - end_aligned);
+      }
+      start = start_aligned;
+    }
+  }
+  return start;
+}
+
 static int anon_munmap(char * addr, size_t size) {
   return ::munmap(addr, size) == 0;
 }
@@ -3317,29 +3381,113 @@
   #define SHM_HUGETLB 04000
 #endif
 
+#define shm_warning_format(format, ...)              \
+  do {                                               \
+    if (UseLargePages &&                             \
+        (!FLAG_IS_DEFAULT(UseLargePages) ||          \
+         !FLAG_IS_DEFAULT(UseSHM) ||                 \
+         !FLAG_IS_DEFAULT(LargePageSizeInBytes))) {  \
+      warning(format, __VA_ARGS__);                  \
+    }                                                \
+  } while (0)
+
+#define shm_warning(str) shm_warning_format("%s", str)
+
+#define shm_warning_with_errno(str)                \
+  do {                                             \
+    int err = errno;                               \
+    shm_warning_format(str " (error = %d)", err);  \
+  } while (0)
+
+static char* shmat_with_alignment(int shmid, size_t bytes, size_t alignment) {
+  assert(is_size_aligned(bytes, alignment), "Must be divisible by the alignment");
+
+  if (!is_size_aligned(alignment, SHMLBA)) {
+    assert(false, "Code below assumes that alignment is at least SHMLBA aligned");
+    return NULL;
+  }
+
+  // To ensure that we get 'alignment' aligned memory from shmat,
+  // we pre-reserve aligned virtual memory and then attach to that.
+
+  char* pre_reserved_addr = anon_mmap_aligned(bytes, alignment, NULL);
+  if (pre_reserved_addr == NULL) {
+    // Couldn't pre-reserve aligned memory.
+    shm_warning("Failed to pre-reserve aligned memory for shmat.");
+    return NULL;
+  }
+
+  // SHM_REMAP is needed to allow shmat to map over an existing mapping.
+  char* addr = (char*)shmat(shmid, pre_reserved_addr, SHM_REMAP);
+
+  if ((intptr_t)addr == -1) {
+    int err = errno;
+    shm_warning_with_errno("Failed to attach shared memory.");
+
+    assert(err != EACCES, "Unexpected error");
+    assert(err != EIDRM,  "Unexpected error");
+    assert(err != EINVAL, "Unexpected error");
+
+    // Since we don't know if the kernel unmapped the pre-reserved memory area
+    // we can't unmap it, since that would potentially unmap memory that was
+    // mapped from other threads.
+    return NULL;
+  }
+
+  return addr;
+}
+
+static char* shmat_at_address(int shmid, char* req_addr) {
+  if (!is_ptr_aligned(req_addr, SHMLBA)) {
+    assert(false, "Requested address needs to be SHMLBA aligned");
+    return NULL;
+  }
+
+  char* addr = (char*)shmat(shmid, req_addr, 0);
+
+  if ((intptr_t)addr == -1) {
+    shm_warning_with_errno("Failed to attach shared memory.");
+    return NULL;
+  }
+
+  return addr;
+}
+
+static char* shmat_large_pages(int shmid, size_t bytes, size_t alignment, char* req_addr) {
+  // If a req_addr has been provided, we assume that the caller has already aligned the address.
+  if (req_addr != NULL) {
+    assert(is_ptr_aligned(req_addr, os::large_page_size()), "Must be divisible by the large page size");
+    assert(is_ptr_aligned(req_addr, alignment), "Must be divisible by given alignment");
+    return shmat_at_address(shmid, req_addr);
+  }
+
+  // Since shmid has been setup with SHM_HUGETLB, shmat will automatically
+  // return large page size aligned memory addresses when req_addr == NULL.
+  // However, if the alignment is larger than the large page size, we have
+  // to manually ensure that the memory returned is 'alignment' aligned.
+  if (alignment > os::large_page_size()) {
+    assert(is_size_aligned(alignment, os::large_page_size()), "Must be divisible by the large page size");
+    return shmat_with_alignment(shmid, bytes, alignment);
+  } else {
+    return shmat_at_address(shmid, NULL);
+  }
+}
+
 char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment,
                                             char* req_addr, bool exec) {
   // "exec" is passed in but not used.  Creating the shared image for
   // the code cache doesn't have an SHM_X executable permission to check.
   assert(UseLargePages && UseSHM, "only for SHM large pages");
   assert(is_ptr_aligned(req_addr, os::large_page_size()), "Unaligned address");
+  assert(is_ptr_aligned(req_addr, alignment), "Unaligned address");
 
-  if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) {
+  if (!is_size_aligned(bytes, os::large_page_size())) {
     return NULL; // Fallback to small pages.
   }
 
-  key_t key = IPC_PRIVATE;
-  char *addr;
-
-  bool warn_on_failure = UseLargePages &&
-                        (!FLAG_IS_DEFAULT(UseLargePages) ||
-                         !FLAG_IS_DEFAULT(UseSHM) ||
-                         !FLAG_IS_DEFAULT(LargePageSizeInBytes));
-  char msg[128];
-
   // Create a large shared memory region to attach to based on size.
-  // Currently, size is the total size of the heap
-  int shmid = shmget(key, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
+  // Currently, size is the total size of the heap.
+  int shmid = shmget(IPC_PRIVATE, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
   if (shmid == -1) {
     // Possible reasons for shmget failure:
     // 1. shmmax is too small for Java heap.
@@ -3355,16 +3503,12 @@
     //            they are so fragmented after a long run that they can't
     //            coalesce into large pages. Try to reserve large pages when
     //            the system is still "fresh".
-    if (warn_on_failure) {
-      jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno);
-      warning("%s", msg);
-    }
+    shm_warning_with_errno("Failed to reserve shared memory.");
     return NULL;
   }
 
-  // attach to the region
-  addr = (char*)shmat(shmid, req_addr, 0);
-  int err = errno;
+  // Attach to the region.
+  char* addr = shmat_large_pages(shmid, bytes, alignment, req_addr);
 
   // Remove shmid. If shmat() is successful, the actual shared memory segment
   // will be deleted when it's detached by shmdt() or when the process
@@ -3372,14 +3516,6 @@
   // segment immediately.
   shmctl(shmid, IPC_RMID, NULL);
 
-  if ((intptr_t)addr == -1) {
-    if (warn_on_failure) {
-      jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
-      warning("%s", msg);
-    }
-    return NULL;
-  }
-
   return addr;
 }
 
@@ -3422,50 +3558,6 @@
   return addr;
 }
 
-// Helper for os::Linux::reserve_memory_special_huge_tlbfs_mixed().
-// Allocate (using mmap, NO_RESERVE, with small pages) at either a given request address
-//   (req_addr != NULL) or with a given alignment.
-//  - bytes shall be a multiple of alignment.
-//  - req_addr can be NULL. If not NULL, it must be a multiple of alignment.
-//  - alignment sets the alignment at which memory shall be allocated.
-//     It must be a multiple of allocation granularity.
-// Returns address of memory or NULL. If req_addr was not NULL, will only return
-//  req_addr or NULL.
-static char* anon_mmap_aligned(size_t bytes, size_t alignment, char* req_addr) {
-
-  size_t extra_size = bytes;
-  if (req_addr == NULL && alignment > 0) {
-    extra_size += alignment;
-  }
-
-  char* start = (char*) ::mmap(req_addr, extra_size, PROT_NONE,
-    MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
-    -1, 0);
-  if (start == MAP_FAILED) {
-    start = NULL;
-  } else {
-    if (req_addr != NULL) {
-      if (start != req_addr) {
-        ::munmap(start, extra_size);
-        start = NULL;
-      }
-    } else {
-      char* const start_aligned = (char*) align_ptr_up(start, alignment);
-      char* const end_aligned = start_aligned + bytes;
-      char* const end = start + extra_size;
-      if (start_aligned > start) {
-        ::munmap(start, start_aligned - start);
-      }
-      if (end_aligned < end) {
-        ::munmap(end_aligned, end - end_aligned);
-      }
-      start = start_aligned;
-    }
-  }
-  return start;
-
-}
-
 // Reserve memory using mmap(MAP_HUGETLB).
 //  - bytes shall be a multiple of alignment.
 //  - req_addr can be NULL. If not NULL, it must be a multiple of alignment.
diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp
index 1c6efe5..ad10c82 100644
--- a/hotspot/src/os/posix/vm/os_posix.cpp
+++ b/hotspot/src/os/posix/vm/os_posix.cpp
@@ -47,6 +47,12 @@
 
 // Check core dump limit and report possible place where core can be found
 void os::check_dump_limit(char* buffer, size_t bufferSize) {
+  if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {
+    jio_snprintf(buffer, bufferSize, "CreateCoredumpOnCrash is disabled from command line");
+    VMError::record_coredump_status(buffer, false);
+    return;
+  }
+
   int n;
   struct rlimit rlim;
   bool success;
@@ -181,8 +187,8 @@
     return vsnprintf(buf, len, fmt, args);
 }
 
-int os::fileno(FILE* fp) {
-  return ::fileno(fp);
+int os::get_fileno(FILE* fp) {
+  return NOT_AIX(::)fileno(fp);
 }
 
 void os::Posix::print_load_average(outputStream* st) {
@@ -321,6 +327,14 @@
   return ::fdopen(fd, mode);
 }
 
+void os::flockfile(FILE* fp) {
+  ::flockfile(fp);
+}
+
+void os::funlockfile(FILE* fp) {
+  ::funlockfile(fp);
+}
+
 // Builds a platform dependent Agent_OnLoad_<lib_name> function name
 // which is used to find statically linked in agents.
 // Parameters:
diff --git a/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp b/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp
index ddd74b1..7d23282 100644
--- a/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp
+++ b/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -251,8 +251,9 @@
 
   GEN_OFFS(CodeBlob, _name);
   GEN_OFFS(CodeBlob, _header_size);
-  GEN_OFFS(CodeBlob, _content_offset);
-  GEN_OFFS(CodeBlob, _code_offset);
+  GEN_OFFS(CodeBlob, _content_begin);
+  GEN_OFFS(CodeBlob, _code_begin);
+  GEN_OFFS(CodeBlob, _code_end);
   GEN_OFFS(CodeBlob, _data_offset);
   GEN_OFFS(CodeBlob, _frame_size);
   printf("\n");
@@ -260,10 +261,10 @@
   GEN_OFFS(nmethod, _method);
   GEN_OFFS(nmethod, _dependencies_offset);
   GEN_OFFS(nmethod, _metadata_offset);
-  GEN_OFFS(nmethod, _scopes_data_offset);
+  GEN_OFFS(nmethod, _scopes_data_begin);
   GEN_OFFS(nmethod, _scopes_pcs_offset);
   GEN_OFFS(nmethod, _handler_table_offset);
-  GEN_OFFS(nmethod, _deoptimize_offset);
+  GEN_OFFS(nmethod, _deopt_handler_begin);
   GEN_OFFS(nmethod, _orig_pc_offset);
 
   GEN_OFFS(PcDesc, _pc_offset);
diff --git a/hotspot/src/os/solaris/dtrace/libjvm_db.c b/hotspot/src/os/solaris/dtrace/libjvm_db.c
index e002845..73b26bc 100644
--- a/hotspot/src/os/solaris/dtrace/libjvm_db.c
+++ b/hotspot/src/os/solaris/dtrace/libjvm_db.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -124,10 +124,10 @@
   uint64_t pc_desc;
 
   int32_t  orig_pc_offset;      /* _orig_pc_offset */
-  int32_t  instrs_beg;          /* _code_offset */
-  int32_t  instrs_end;
-  int32_t  deopt_beg;           /* _deoptimize_offset */
-  int32_t  scopes_data_beg;     /* _scopes_data_offset */
+  uint64_t  instrs_beg;          /* _code_offset */
+  uint64_t  instrs_end;
+  uint64_t  deopt_beg;           /* _deoptimize_offset */
+  uint64_t  scopes_data_beg;     /* _scopes_data_begin */
   int32_t  scopes_data_end;
   int32_t  metadata_beg;        /* _metadata_offset */
   int32_t  metadata_end;
@@ -617,11 +617,11 @@
       fprintf(stderr, "\t nmethod_info: BEGIN \n");
 
   /* Instructions */
-  err = ps_pread(J->P, nm + OFFSET_CodeBlob_code_offset, &N->instrs_beg, SZ32);
+  err = read_pointer(J, nm + OFFSET_CodeBlob_code_begin, &N->instrs_beg);
   CHECK_FAIL(err);
-  err = ps_pread(J->P, nm + OFFSET_CodeBlob_data_offset, &N->instrs_end, SZ32);
+  err = read_pointer(J, nm + OFFSET_CodeBlob_code_end, &N->instrs_end);
   CHECK_FAIL(err);
-  err = ps_pread(J->P, nm + OFFSET_nmethod_deoptimize_offset, &N->deopt_beg, SZ32);
+  err = read_pointer(J, nm + OFFSET_nmethod_deopt_handler_begin, &N->deopt_beg);
   CHECK_FAIL(err);
   err = ps_pread(J->P, nm + OFFSET_nmethod_orig_pc_offset, &N->orig_pc_offset, SZ32);
   CHECK_FAIL(err);
@@ -629,7 +629,7 @@
   /* Metadata */
   err = ps_pread(J->P, nm + OFFSET_nmethod_metadata_offset, &N->metadata_beg, SZ32);
   CHECK_FAIL(err);
-  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->metadata_end, SZ32);
+  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->metadata_end, SZ32);
   CHECK_FAIL(err);
 
   /* scopes_pcs */
@@ -639,7 +639,7 @@
   CHECK_FAIL(err);
 
   /* scopes_data */
-  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->scopes_data_beg, SZ32);
+  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->scopes_data_beg, POINTER_SIZE);
   CHECK_FAIL(err);
 
   if (debug > 2 ) {
@@ -868,7 +868,7 @@
   err = ps_pread(N->J->P, pc_desc + OFFSET_PcDesc_pc_offset, &pc_offset, SZ32);
   CHECK_FAIL(err);
 
-  *real_pc = N->nm + N->instrs_beg + pc_offset;
+  *real_pc = N->instrs_beg + pc_offset;
   if (debug > 2) {
       fprintf(stderr, "\t\t get_real_pc: pc_offset: %lx, real_pc: %llx\n",
                        pc_offset, *real_pc);
@@ -942,7 +942,7 @@
       fprintf(stderr, "\t\t scope_desc_at: BEGIN \n");
   }
 
-  buffer = N->nm + N->scopes_data_beg + decode_offset;
+  buffer = N->scopes_data_beg + decode_offset;
 
   err = raw_read_int(N->J, &buffer, &vf->sender_decode_offset);
   CHECK_FAIL(err);
@@ -1052,11 +1052,11 @@
   CHECK_FAIL(err);
   if (debug) {
       fprintf(stderr, "name_for_nmethod: pc: %#llx, deopt_pc:  %#llx\n",
-              pc, N->nm + N->deopt_beg);
+              pc, N->deopt_beg);
   }
 
   /* check for a deoptimized frame */
-  if ( pc == N->nm + N->deopt_beg) {
+  if ( pc == N->deopt_beg) {
     uint64_t base;
     if (debug) {
         fprintf(stderr, "name_for_nmethod: found deoptimized frame\n");
diff --git a/hotspot/src/os/solaris/vm/globals_solaris.hpp b/hotspot/src/os/solaris/vm/globals_solaris.hpp
index 4e6d818..b3e2e34 100644
--- a/hotspot/src/os/solaris/vm/globals_solaris.hpp
+++ b/hotspot/src/os/solaris/vm/globals_solaris.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,15 @@
 //
 // Defines Solaris specific flags. They are not available on other platforms.
 //
-#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \
+#define RUNTIME_OS_FLAGS(develop, \
+                         develop_pd, \
+                         product, \
+                         product_pd, \
+                         diagnostic, \
+                         notproduct, \
+                         range, \
+                         constraint, \
+                         writeable) \
                                                                                \
   product(bool, UseExtendedFileIO, true,                                       \
           "Enable workaround for limitations of stdio FILE structure")
diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp
index 1d68dcc..1b02694 100644
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp
@@ -725,8 +725,8 @@
 
 static thread_t main_thread;
 
-// Thread start routine for all new Java threads
-extern "C" void* java_start(void* thread_addr) {
+// Thread start routine for all newly created threads
+extern "C" void* thread_native_entry(void* thread_addr) {
   // Try to randomize the cache line index of hot stack frames.
   // This helps when threads of the same stack traces evict each other's
   // cache lines. The threads can be either from the same JVM instance, or
@@ -796,6 +796,15 @@
 
   log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ").", os::current_thread_id());
 
+  // If a thread has not deleted itself ("delete this") as part of its
+  // termination sequence, we have to ensure thread-local-storage is
+  // cleared before we actually terminate. No threads should ever be
+  // deleted asynchronously with respect to their termination.
+  if (Thread::current_or_null_safe() != NULL) {
+    assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
+    thread->clear_thread_current();
+  }
+
   if (UseDetachedThreads) {
     thr_exit(NULL);
     ShouldNotReachHere();
@@ -1009,7 +1018,7 @@
   osthread->set_lwp_id(-1);
   osthread->set_thread_id(-1);
 
-  status = thr_create(NULL, stack_size, java_start, thread, flags, &tid);
+  status = thr_create(NULL, stack_size, thread_native_entry, thread, flags, &tid);
 
   char buf[64];
   if (status == 0) {
@@ -1221,18 +1230,15 @@
 void os::free_thread(OSThread* osthread) {
   assert(osthread != NULL, "os::free_thread but osthread not set");
 
-
   // We are told to free resources of the argument thread,
   // but we can only really operate on the current thread.
-  // The main thread must take the VMThread down synchronously
-  // before the main thread exits and frees up CodeHeap
-  guarantee((Thread::current()->osthread() == osthread
-             || (osthread == VMThread::vm_thread()->osthread())), "os::free_thread but not current thread");
-  if (Thread::current()->osthread() == osthread) {
-    // Restore caller's signal mask
-    sigset_t sigmask = osthread->caller_sigmask();
-    pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
-  }
+  assert(Thread::current()->osthread() == osthread,
+         "os::free_thread but not current thread");
+
+  // Restore caller's signal mask
+  sigset_t sigmask = osthread->caller_sigmask();
+  pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
+
   delete osthread;
 }
 
@@ -1351,24 +1357,29 @@
   return (double)gethrvtime() / (double)hrtime_hz;
 }
 
-// Used internally for comparisons only
-// getTimeMillis guaranteed to not move backwards on Solaris
-jlong getTimeMillis() {
-  jlong nanotime = getTimeNanos();
-  return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
-}
+// in-memory timestamp support - has update accuracy of 1ms
+typedef void (*_get_nsec_fromepoch_func_t)(hrtime_t*);
+static _get_nsec_fromepoch_func_t _get_nsec_fromepoch = NULL;
 
 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
 jlong os::javaTimeMillis() {
-  timeval t;
-  if (gettimeofday(&t, NULL) == -1) {
-    fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno));
+  if (_get_nsec_fromepoch != NULL) {
+    hrtime_t now;
+    _get_nsec_fromepoch(&now);
+    return now / NANOSECS_PER_MILLISEC;
   }
-  return jlong(t.tv_sec) * 1000  +  jlong(t.tv_usec) / 1000;
+  else {
+    timeval t;
+    if (gettimeofday(&t, NULL) == -1) {
+      fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno));
+    }
+    return jlong(t.tv_sec) * 1000  +  jlong(t.tv_usec) / 1000;
+  }
 }
 
 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
   timeval t;
+  // can't use get_nsec_fromepoch here as we need better accuracy than 1ms
   if (gettimeofday(&t, NULL) == -1) {
     fatal("os::javaTimeSystemUTC: gettimeofday (%s)", os::strerror(errno));
   }
@@ -4432,11 +4443,15 @@
   // enough to allow the thread to get to user bytecode execution.
   Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed);
 
-  // retrieve entry point for pthread_setname_np
+  // dynamic lookup of functions that may not be available in our lowest
+  // supported Solaris release
   void * handle = dlopen("libc.so.1", RTLD_LAZY);
   if (handle != NULL) {
-    Solaris::_pthread_setname_np =
+    Solaris::_pthread_setname_np =  // from 11.3
         (Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np");
+
+    _get_nsec_fromepoch =           // from 11.3.6
+        (_get_nsec_fromepoch_func_t) dlsym(handle, "get_nsec_fromepoch");
   }
 }
 
diff --git a/hotspot/src/os/windows/vm/globals_windows.hpp b/hotspot/src/os/windows/vm/globals_windows.hpp
index 1a2eb4f..3d831ec 100644
--- a/hotspot/src/os/windows/vm/globals_windows.hpp
+++ b/hotspot/src/os/windows/vm/globals_windows.hpp
@@ -28,7 +28,15 @@
 //
 // Defines Windows specific flags. They are not available on other platforms.
 //
-#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \
+#define RUNTIME_OS_FLAGS(develop, \
+                         develop_pd, \
+                         product, \
+                         product_pd, \
+                         diagnostic, \
+                         notproduct, \
+                         range, \
+                         constraint, \
+                         writeable) \
                                                                          \
   product(bool, UseUTCFileTimestamp, true,                               \
           "Adjust the timestamp returned from stat() to be UTC")
diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp
index fa40152..7c3b6da 100644
--- a/hotspot/src/os/windows/vm/os_windows.cpp
+++ b/hotspot/src/os/windows/vm/os_windows.cpp
@@ -409,8 +409,8 @@
 
 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
 
-// Thread start routine for all new Java threads
-static unsigned __stdcall java_start(Thread* thread) {
+// Thread start routine for all newly created threads
+static unsigned __stdcall thread_native_entry(Thread* thread) {
   // Try to randomize the cache line index of hot stack frames.
   // This helps when threads of the same stack traces evict each other's
   // cache lines. The threads can be either from the same JVM instance, or
@@ -459,6 +459,15 @@
     Atomic::dec_ptr((intptr_t*)&os::win32::_os_thread_count);
   }
 
+  // If a thread has not deleted itself ("delete this") as part of its
+  // termination sequence, we have to ensure thread-local-storage is
+  // cleared before we actually terminate. No threads should ever be
+  // deleted asynchronously with respect to their termination.
+  if (Thread::current_or_null_safe() != NULL) {
+    assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
+    thread->clear_thread_current();
+  }
+
   // Thread must not return from exit_process_or_thread(), but if it does,
   // let it proceed to exit normally
   return (unsigned)os::win32::exit_process_or_thread(os::win32::EPT_THREAD, res);
@@ -631,7 +640,7 @@
   HANDLE thread_handle =
     (HANDLE)_beginthreadex(NULL,
                            (unsigned)stack_size,
-                           (unsigned (__stdcall *)(void*)) java_start,
+                           (unsigned (__stdcall *)(void*)) thread_native_entry,
                            thread,
                            initflag,
                            &thread_id);
@@ -670,6 +679,12 @@
 // Free Win32 resources related to the OSThread
 void os::free_thread(OSThread* osthread) {
   assert(osthread != NULL, "osthread not set");
+
+  // We are told to free resources of the argument thread,
+  // but we can only really operate on the current thread.
+  assert(Thread::current()->osthread() == osthread,
+         "os::free_thread but not current thread");
+
   CloseHandle(osthread->thread_handle());
   CloseHandle(osthread->interrupt_event());
   delete osthread;
@@ -4602,7 +4617,7 @@
   return 0;
 }
 
-int os::fileno(FILE* fp) {
+int os::get_fileno(FILE* fp) {
   return _fileno(fp);
 }
 
@@ -4661,6 +4676,14 @@
   }
 }
 
+void os::flockfile(FILE* fp) {
+  _lock_file(fp);
+}
+
+void os::funlockfile(FILE* fp) {
+  _unlock_file(fp);
+}
+
 // This code is a copy of JDK's nonSeekAvailable
 // from src/windows/hpi/src/sys_api_md.c
 
diff --git a/hotspot/src/os/windows/vm/os_windows.hpp b/hotspot/src/os/windows/vm/os_windows.hpp
index 5bef412..9170dfe 100644
--- a/hotspot/src/os/windows/vm/os_windows.hpp
+++ b/hotspot/src/os/windows/vm/os_windows.hpp
@@ -36,7 +36,7 @@
 
 class win32 {
   friend class os;
-  friend unsigned __stdcall java_start(class Thread*);
+  friend unsigned __stdcall thread_native_entry(class Thread*);
 
  protected:
   static int    _vm_page_size;
diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp
index 537595f..211a2dc 100644
--- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp
+++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp
@@ -390,13 +390,11 @@
         // BugId 4454115: A read from a MappedByteBuffer can fault here if the
         // underlying file has been truncated. Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-        nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
+        CompiledMethod* nm = cb->as_compiled_method_or_null();
         if (nm != NULL && nm->has_unsafe_access()) {
-          // We don't really need a stub here! Just set the pending exeption and
-          // continue at the next instruction after the faulting read. Returning
-          // garbage from this read is ok.
-          thread->set_pending_unsafe_access_error();
-          os::Aix::ucontext_set_pc(uc, pc + 4);
+          address next_pc = pc + 4;
+          next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
+          os::Aix::ucontext_set_pc(uc, next_pc);
           return 1;
         }
       }
@@ -415,11 +413,9 @@
       }
       else if (thread->thread_state() == _thread_in_vm &&
                sig == SIGBUS && thread->doing_unsafe_access()) {
-        // We don't really need a stub here! Just set the pending exeption and
-        // continue at the next instruction after the faulting read. Returning
-        // garbage from this read is ok.
-        thread->set_pending_unsafe_access_error();
-        os::Aix::ucontext_set_pc(uc, pc + 4);
+        address next_pc = pc + 4;
+        next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
+        os::Aix::ucontext_set_pc(uc, next_pc);
         return 1;
       }
     }
diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp
index 73acdeb..9fe34fc 100644
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp
@@ -582,9 +582,10 @@
         // here if the underlying file has been truncated.
         // Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-        nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL;
+        CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
         if (nm != NULL && nm->has_unsafe_access()) {
-          stub = StubRoutines::handler_for_unsafe_access();
+          address next_pc = Assembler::locate_next_instruction(pc);
+          stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
         }
       }
       else
@@ -655,7 +656,8 @@
     } else if (thread->thread_state() == _thread_in_vm &&
                sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
                thread->doing_unsafe_access()) {
-        stub = StubRoutines::handler_for_unsafe_access();
+        address next_pc = Assembler::locate_next_instruction(pc);
+        stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
     }
 
     // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp
index 2a354fb..0417992 100644
--- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp
@@ -226,23 +226,6 @@
 extern "C" void FetchNResume () ;
 #endif
 
-// An operation in Unsafe has faulted.  We're going to return to the
-// instruction after the faulting load or store.  We also set
-// pending_unsafe_access_error so that at some point in the future our
-// user will get a helpful message.
-static address handle_unsafe_access(JavaThread* thread, address pc) {
-  // pc is the instruction which we must emulate
-  // doing a no-op is fine:  return garbage from the load
-  // therefore, compute npc
-  address npc = pc + NativeCall::instruction_size;
-
-  // request an async exception
-  thread->set_pending_unsafe_access_error();
-
-  // return address of next instruction to execute
-  return npc;
-}
-
 extern "C" JNIEXPORT int
 JVM_handle_linux_signal(int sig,
                         siginfo_t* info,
@@ -385,9 +368,10 @@
         // here if the underlying file has been truncated.
         // Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-        nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL;
+        CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
         if (nm != NULL && nm->has_unsafe_access()) {
-          stub = handle_unsafe_access(thread, pc);
+          address next_pc = pc + NativeCall::instruction_size;
+          stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
         }
       }
       else
@@ -408,7 +392,8 @@
     } else if (thread->thread_state() == _thread_in_vm &&
                sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
                thread->doing_unsafe_access()) {
-        stub = handle_unsafe_access(thread, pc);
+      address next_pc = pc + NativeCall::instruction_size;
+      stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
     }
 
     // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp
index 117bf10..8cd04dc 100644
--- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp
+++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp
@@ -315,7 +315,7 @@
                ((NativeInstruction*)pc)->is_safepoint_poll() &&
                CodeCache::contains((void*) pc) &&
                ((cb = CodeCache::find_blob(pc)) != NULL) &&
-               cb->is_nmethod()) {
+               cb->is_compiled()) {
         if (TraceTraps) {
           tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
         }
@@ -364,13 +364,11 @@
         // BugId 4454115: A read from a MappedByteBuffer can fault here if the
         // underlying file has been truncated. Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-        nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL;
+        CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
         if (nm != NULL && nm->has_unsafe_access()) {
-          // We don't really need a stub here! Just set the pending exeption and
-          // continue at the next instruction after the faulting read. Returning
-          // garbage from this read is ok.
-          thread->set_pending_unsafe_access_error();
-          os::Linux::ucontext_set_pc(uc, pc + 4);
+          address next_pc = pc + 4;
+          next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
+          os::Linux::ucontext_set_pc(uc, next_pc);
           return true;
         }
       }
@@ -385,10 +383,8 @@
       }
       else if (thread->thread_state() == _thread_in_vm &&
                sig == SIGBUS && thread->doing_unsafe_access()) {
-        // We don't really need a stub here! Just set the pending exeption and
-        // continue at the next instruction after the faulting read. Returning
-        // garbage from this read is ok.
-        thread->set_pending_unsafe_access_error();
+        address next_pc = pc + 4;
+        next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
         os::Linux::ucontext_set_pc(uc, pc + 4);
         return true;
       }
diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp
index 44a5a7d..4a0da12 100644
--- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp
+++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp
@@ -433,14 +433,14 @@
   return false;
 }
 
-inline static bool checkByteBuffer(address pc, address* stub) {
+inline static bool checkByteBuffer(address pc, address npc, address* stub) {
   // BugId 4454115: A read from a MappedByteBuffer can fault
   // here if the underlying file has been truncated.
   // Do not crash the VM in such a case.
   CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-  nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
+  CompiledMethod* nm = cb->as_compiled_method_or_null();
   if (nm != NULL && nm->has_unsafe_access()) {
-    *stub = StubRoutines::handler_for_unsafe_access();
+    *stub = SharedRuntime::handle_unsafe_access(thread, npc);
     return true;
   }
   return false;
@@ -613,7 +613,7 @@
     if (sig == SIGBUS &&
         thread->thread_state() == _thread_in_vm &&
         thread->doing_unsafe_access()) {
-      stub = StubRoutines::handler_for_unsafe_access();
+      stub = SharedRuntime::handle_unsafe_access(thread, npc);
     }
 
     if (thread->thread_state() == _thread_in_Java) {
@@ -625,7 +625,7 @@
           break;
         }
 
-        if ((sig == SIGBUS) && checkByteBuffer(pc, &stub)) {
+        if ((sig == SIGBUS) && checkByteBuffer(pc, npc, &stub)) {
           break;
         }
 
diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
index 0eb7a9e..b73658e 100644
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -418,9 +418,10 @@
         // here if the underlying file has been truncated.
         // Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-        nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL;
+        CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
         if (nm != NULL && nm->has_unsafe_access()) {
-          stub = StubRoutines::handler_for_unsafe_access();
+          address next_pc = Assembler::locate_next_instruction(pc);
+          stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
         }
       }
       else
@@ -469,7 +470,8 @@
     } else if (thread->thread_state() == _thread_in_vm &&
                sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
                thread->doing_unsafe_access()) {
-        stub = StubRoutines::handler_for_unsafe_access();
+        address next_pc = Assembler::locate_next_instruction(pc);
+        stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
     }
 
     // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp
index 389f2b3..39663ed 100644
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp
@@ -441,7 +441,7 @@
 
     if (thread->thread_state() == _thread_in_vm) {
       if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) {
-        stub = StubRoutines::handler_for_unsafe_access();
+        stub = SharedRuntime::handle_unsafe_access(thread, npc);
       }
     }
 
@@ -478,9 +478,9 @@
         // here if the underlying file has been truncated.
         // Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-        nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
+        CompiledMethod* nm = cb->as_compiled_method_or_null();
         if (nm != NULL && nm->has_unsafe_access()) {
-          stub = StubRoutines::handler_for_unsafe_access();
+          stub = SharedRuntime::handle_unsafe_access(thread, npc);
         }
       }
 
diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
index 0784f3f..695fc12 100644
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
@@ -503,7 +503,8 @@
 
     if (thread->thread_state() == _thread_in_vm) {
       if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) {
-        stub = StubRoutines::handler_for_unsafe_access();
+        address next_pc = Assembler::locate_next_instruction(pc);
+        stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
       }
     }
 
@@ -518,9 +519,10 @@
         // Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
         if (cb != NULL) {
-          nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
+          CompiledMethod* nm = cb->as_compiled_method_or_null();
           if (nm != NULL && nm->has_unsafe_access()) {
-            stub = StubRoutines::handler_for_unsafe_access();
+            address next_pc = Assembler::locate_next_instruction(pc);
+            stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
           }
         }
       }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java
index 713d7a1..8b526cf 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,13 @@
 
 import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
 import com.sun.hotspot.igv.data.*;
+import com.sun.hotspot.igv.util.PropertiesSheet;
 import java.awt.Image;
 import java.util.List;
 import org.openide.nodes.AbstractNode;
 import org.openide.nodes.Children;
 import org.openide.nodes.Node;
+import org.openide.nodes.Sheet;
 import org.openide.util.ImageUtilities;
 import org.openide.util.lookup.AbstractLookup;
 import org.openide.util.lookup.InstanceContent;
@@ -75,6 +77,16 @@
     }
 
     @Override
+    protected Sheet createSheet() {
+        Sheet s = super.createSheet();
+        if (children.folder instanceof Properties.Entity) {
+            Properties.Entity p = (Properties.Entity) children.folder;
+            PropertiesSheet.initializeSheet(p.getProperties(), s);
+        }
+        return s;
+    }
+
+    @Override
     public Image getIcon(int i) {
         return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png");
     }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java
index 292dcd4..ad43e6f 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -124,6 +124,8 @@
 
     public void clear() {
         document.clear();
+        root = new FolderNode(document);
+        manager.setRootContext(root);
     }
 
     @Override
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java
index 5bd6c19..ee643b2 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,31 +31,47 @@
 import com.sun.hotspot.igv.data.serialization.ParseMonitor;
 import com.sun.hotspot.igv.data.serialization.Parser;
 import com.sun.hotspot.igv.settings.Settings;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
+import java.awt.event.ActionEvent;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.channels.FileChannel;
 import java.nio.file.StandardOpenOption;
-import javax.swing.Action;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.swing.JFileChooser;
-import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
 import javax.swing.filechooser.FileFilter;
 import org.netbeans.api.progress.ProgressHandle;
 import org.netbeans.api.progress.ProgressHandleFactory;
 import org.openide.util.Exceptions;
+import org.openide.util.RequestProcessor;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
 import org.openide.util.HelpCtx;
 import org.openide.util.NbBundle;
-import org.openide.util.RequestProcessor;
-import org.openide.util.actions.CallableSystemAction;
+import org.openide.util.actions.SystemAction;
 
 /**
  *
  * @author Thomas Wuerthinger
  */
-public final class ImportAction extends CallableSystemAction {
+
+@ActionID(
+        category = "File",
+        id = "com.sun.hotspot.igv.coordinator.actions.ImportAction"
+)
+@ActionRegistration(
+        iconBase = "com/sun/hotspot/igv/coordinator/images/import.png",
+        displayName = "#CTL_ImportAction"
+)
+@ActionReferences({
+    @ActionReference(path = "Menu/File", position = 0),
+    @ActionReference(path = "Shortcuts", name = "C-O")
+})
+public final class ImportAction extends SystemAction {
     private static final int WORKUNITS = 10000;
 
     public static FileFilter getFileFilter() {
@@ -74,74 +90,77 @@
     }
 
     @Override
-    public void performAction() {
-
+    public void actionPerformed(ActionEvent e) {
         JFileChooser fc = new JFileChooser();
         fc.setFileFilter(ImportAction.getFileFilter());
         fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT)));
+        fc.setMultiSelectionEnabled(true);
 
         if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
-            File file = fc.getSelectedFile();
-
-            File dir = file;
-            if (!dir.isDirectory()) {
-                dir = dir.getParentFile();
-            }
-
-            Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
-            try {
-                final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
-                final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName());
-                handle.start(WORKUNITS);
-                final long start = channel.size();
-                ParseMonitor monitor = new ParseMonitor() {
-                    @Override
-                    public void updateProgress() {
-                        try {
-                            int prog = (int) (WORKUNITS * (double) channel.position() / (double) start);
-                            handle.progress(prog);
-                        } catch (IOException ex) {
-                        }
-                    }
-                    @Override
-                    public void setState(String state) {
-                        updateProgress();
-                        handle.progress(state);
-                    }
-                };
-                final GraphParser parser;
-                final OutlineTopComponent component = OutlineTopComponent.findInstance();
-                if (file.getName().endsWith(".xml")) {
-                    parser = new Parser(channel, monitor, null);
-                } else if (file.getName().endsWith(".bgv")) {
-                    parser = new BinaryParser(channel, monitor, component.getDocument(), null);
-                } else {
-                    parser = null;
+            for (final File file : fc.getSelectedFiles()) {
+                File dir = file;
+                if (!dir.isDirectory()) {
+                    dir = dir.getParentFile();
                 }
-                RequestProcessor.getDefault().post(new Runnable() {
-                    @Override
-                    public void run() {
-                        try {
-                            final GraphDocument document = parser.parse();
-                            if (document != null) {
-                                SwingUtilities.invokeLater(new Runnable(){
-                                    @Override
-                                    public void run() {
-                                        component.requestActive();
-                                        component.getDocument().addGraphDocument(document);
-                                    }
-                                });
+
+                Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
+                try {
+                    final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
+                    final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName());
+                    handle.start(WORKUNITS);
+                    final long startTime = System.currentTimeMillis();
+                    final long start = channel.size();
+                    ParseMonitor monitor = new ParseMonitor() {
+                            @Override
+                            public void updateProgress() {
+                                try {
+                                    int prog = (int) (WORKUNITS * (double) channel.position() / (double) start);
+                                    handle.progress(prog);
+                                } catch (IOException ex) {
+                                }
                             }
-                        } catch (IOException ex) {
-                            Exceptions.printStackTrace(ex);
-                        }
-                        handle.finish();
+                            @Override
+                            public void setState(String state) {
+                                updateProgress();
+                                handle.progress(state);
+                            }
+                        };
+                    final GraphParser parser;
+                    final OutlineTopComponent component = OutlineTopComponent.findInstance();
+                    if (file.getName().endsWith(".xml")) {
+                        parser = new Parser(channel, monitor, null);
+                    } else if (file.getName().endsWith(".bgv")) {
+                        parser = new BinaryParser(channel, monitor, component.getDocument(), null);
+                    } else {
+                        parser = null;
                     }
-                });
-            } catch (FileNotFoundException ex) {
-                Exceptions.printStackTrace(ex);
-            } catch (IOException ex) {
-                Exceptions.printStackTrace(ex);
+                    RequestProcessor.getDefault().post(new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    final GraphDocument document = parser.parse();
+                                    if (document != null) {
+                                        SwingUtilities.invokeLater(new Runnable(){
+                                                @Override
+                                                public void run() {
+                                                    component.requestActive();
+                                                    component.getDocument().addGraphDocument(document);
+                                                }
+                                            });
+                                    }
+                                } catch (IOException ex) {
+                                    Exceptions.printStackTrace(ex);
+                                }
+                                handle.finish();
+                                long stop = System.currentTimeMillis();
+                                Logger.getLogger(getClass().getName()).log(Level.INFO, "Loaded in " + file + " in " + ((stop - startTime) / 1000.0) + " seconds");
+                            }
+                        });
+                } catch (FileNotFoundException ex) {
+                    Exceptions.printStackTrace(ex);
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
+                }
             }
         }
     }
@@ -151,11 +170,6 @@
         return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction");
     }
 
-    public ImportAction() {
-        putValue(Action.SHORT_DESCRIPTION, "Open XML graph document...");
-        putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
-    }
-
     @Override
     protected String iconResource() {
         return "com/sun/hotspot/igv/coordinator/images/import.png";
@@ -165,9 +179,4 @@
     public HelpCtx getHelpCtx() {
         return HelpCtx.DEFAULT_HELP;
     }
-
-    @Override
-    protected boolean asynchronous() {
-        return false;
-    }
 }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java
index eb75dd9..df1ed46 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,14 +29,30 @@
 import java.awt.event.KeyEvent;
 import javax.swing.Action;
 import javax.swing.KeyStroke;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
 import org.openide.util.HelpCtx;
 import org.openide.util.NbBundle;
+import org.openide.util.NbBundle.Messages;
 import org.openide.util.actions.CallableSystemAction;
 
 /**
  *
  * @author Thomas Wuerthinger
  */
+@ActionID(
+        category = "File",
+        id = "com.sun.hotspot.igv.coordinator.actions.SaveAllAction"
+)
+@ActionRegistration(
+        displayName = "#CTL_SaveAllAction"
+)
+@ActionReferences({
+    @ActionReference(path = "Menu/File", position = 0),
+    @ActionReference(path = "Shortcuts", name = "C-S")
+})
 public final class SaveAllAction extends CallableSystemAction {
 
     @Override
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
index 49fbe2f..ef808ee 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
@@ -18,6 +18,8 @@
     
     <folder name="Menu">
         <folder name="File">
+            <file name="Export_hidden"/>
+            <file name="Import_hidden"/>
             <file name="Separator2.instance_hidden"/>
             <file name="Separator3.instance_hidden"/>
             <file name="SeparatorOpen.instance_hidden"/>
@@ -43,11 +45,11 @@
             </file>
             <file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.shadow">
                 <attr name="originalFile" stringvalue="Actions/Edit/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
-                <attr name="position" intvalue="400" />
+                <attr name="position" intvalue="400"/>
             </file>
             <file name="com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.shadow">
                 <attr name="originalFile" stringvalue="Actions/Edit/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
-                <attr name="position" intvalue="500" />
+                <attr name="position" intvalue="500"/>
             </file>
             
             <!-- Hidden menu entries from other modules -->
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
index 8c62573..85a0494 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,11 +51,13 @@
     }
 
     public void addGraphDocument(GraphDocument document) {
-        for (FolderElement e : document.elements) {
-            e.setParent(this);
-            this.addElement(e);
+        if (document != this) {
+            for (FolderElement e : document.elements) {
+                e.setParent(this);
+                this.addElement(e);
+            }
+            document.clear();
         }
-        document.clear();
         getChangedEvent().fire();
     }
 
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
index 2626e51..242623d 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -90,7 +90,9 @@
     public void addNode(int id) {
         InputNode node = graph.getNode(id);
         assert node != null;
-        assert !nodes.contains(node) : "duplicate : " + node;
+        // nodes.contains(node) is too expensive for large graphs so
+        // just make sure the Graph doesn't know it yet.
+        assert graph.getBlock(id) == null : "duplicate : " + node;
         graph.setBlock(node, this);
         nodes.add(node);
     }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
index 2646231..d0499c2 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,9 @@
 package com.sun.hotspot.igv.data;
 
 import java.io.Serializable;
+import java.lang.ref.WeakReference;
 import java.util.*;
+import java.util.Map.Entry;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
@@ -36,7 +38,7 @@
 public class Properties implements Serializable, Iterable<Property> {
 
     public static final long serialVersionUID = 1L;
-    private String[] map = new String[4];
+    protected String[] map = new String[4];
 
     public Properties() {
     }
@@ -102,6 +104,59 @@
         System.arraycopy(p.map, 0, map, 0, p.map.length);
     }
 
+    protected Properties(String[] map) {
+        this.map = map;
+    }
+
+    static class SharedProperties extends Properties {
+        int hashCode;
+
+        SharedProperties(String[] map) {
+            super(map);
+            this.hashCode = Arrays.hashCode(map);
+        }
+
+        @Override
+        protected void setPropertyInternal(String name, String value) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (this == other) {
+                return true;
+            }
+            if (!(other instanceof SharedProperties)) {
+                return super.equals(other);
+            }
+            SharedProperties props2 = (SharedProperties) other;
+            return Arrays.equals(map, props2.map);
+        }
+
+        @Override
+        public int hashCode() {
+            return hashCode;
+        }
+    }
+
+    private static class PropertyCache {
+        static WeakHashMap<SharedProperties, WeakReference<SharedProperties>> immutableCache = new WeakHashMap<>();
+
+        static synchronized SharedProperties intern(Properties properties) {
+            String[] map = properties.map;
+            SharedProperties key = new SharedProperties(map);
+            WeakReference<SharedProperties> entry = immutableCache.get(key);
+            if (entry != null) {
+                SharedProperties props = entry.get();
+                if (props != null) {
+                    return props;
+                }
+            }
+            immutableCache.put(key, new WeakReference<>(key));
+            return key;
+        }
+    }
+
     public static class Entity implements Provider {
 
         private Properties properties;
@@ -118,6 +173,10 @@
         public Properties getProperties() {
             return properties;
         }
+
+        public void internProperties() {
+            properties = PropertyCache.intern(properties);
+        }
     }
 
     public interface PropertyMatcher {
@@ -322,8 +381,8 @@
     public void setProperty(String name, String value) {
         setPropertyInternal(name.intern(), value != null ? value.intern() : null);
     }
-    private void setPropertyInternal(String name, String value) {
 
+    protected void setPropertyInternal(String name, String value) {
         for (int i = 0; i < map.length; i += 2) {
             if (map[i] != null && map[i].equals(name)) {
                 String p = map[i + 1];
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java
index 5529701..52d5a71 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.Charset;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -68,6 +69,8 @@
 
     private static final String NO_BLOCK = "noBlock";
 
+    private static final Charset utf8 = Charset.forName("UTF-8");
+
     private final GroupCallback callback;
     private final List<Object> constantPool;
     private final ByteBuffer buffer;
@@ -275,28 +278,36 @@
         hashStack = new LinkedList<>();
         this.monitor = monitor;
         try {
-            this.digest = MessageDigest.getInstance("SHA-256");
+            this.digest = MessageDigest.getInstance("SHA-1");
         } catch (NoSuchAlgorithmException e) {
         }
     }
 
     private void fill() throws IOException {
+        // All the data between lastPosition and position has been
+        // used so add it to the digest.
+        int position = buffer.position();
+        buffer.position(lastPosition);
+        byte[] remaining = new byte[position - buffer.position()];
+        buffer.get(remaining);
+        digest.update(remaining);
+        assert position == buffer.position();
+
         buffer.compact();
         if (channel.read(buffer) < 0) {
             throw new EOFException();
         }
         buffer.flip();
+        lastPosition = buffer.position();
     }
 
     private void ensureAvailable(int i) throws IOException {
+        if (i > buffer.capacity()) {
+            throw new IllegalArgumentException(String.format("Can not request %d bytes: buffer capacity is %d", i, buffer.capacity()));
+        }
         while (buffer.remaining() < i) {
             fill();
         }
-        buffer.mark();
-        byte[] result = new byte[i];
-        buffer.get(result);
-        digest.update(result);
-        buffer.reset();
     }
 
     private int readByte() throws IOException {
@@ -330,12 +341,7 @@
     }
 
     private String readString() throws IOException {
-        int len = readInt();
-        ensureAvailable(len * 2);
-        char[] chars = new char[len];
-        buffer.asCharBuffer().get(chars);
-        buffer.position(buffer.position() + len * 2);
-        return new String(chars).intern();
+        return new String(readBytes(), utf8).intern();
     }
 
     private byte[] readBytes() throws IOException {
@@ -343,10 +349,15 @@
         if (len < 0) {
             return null;
         }
-        ensureAvailable(len);
-        byte[] data = new byte[len];
-        buffer.get(data);
-        return data;
+        byte[] b = new byte[len];
+        int bytesRead = 0;
+        while (bytesRead < b.length) {
+            int toRead = Math.min(b.length - bytesRead, buffer.capacity());
+            ensureAvailable(toRead);
+            buffer.get(b, bytesRead, toRead);
+            bytesRead += toRead;
+        }
+        return b;
     }
 
     private String readIntsToString() throws IOException {
@@ -643,6 +654,7 @@
         int bci = readInt();
         Group group = new Group(parent);
         group.getProperties().setProperty("name", name);
+        parseProperties(group.getProperties());
         if (method != null) {
             InputMethod inMethod = new InputMethod(group, method.name, shortName, bci);
             inMethod.setBytecodes("TODO");
@@ -651,13 +663,25 @@
         return group;
     }
 
+    int lastPosition = 0;
+
     private InputGraph parseGraph() throws IOException {
         if (monitor != null) {
             monitor.updateProgress();
         }
         String title = readPoolObject(String.class);
         digest.reset();
+        lastPosition = buffer.position();
         InputGraph graph = parseGraph(title);
+
+        int position = buffer.position();
+        buffer.position(lastPosition);
+        byte[] remaining = new byte[position - buffer.position()];
+        buffer.get(remaining);
+        digest.update(remaining);
+        assert position == buffer.position();
+        lastPosition = buffer.position();
+
         byte[] d = digest.digest();
         byte[] hash = hashStack.peek();
         if (hash != null && Arrays.equals(hash, d)) {
@@ -669,11 +693,24 @@
         return graph;
     }
 
+    private void parseProperties(Properties properties) throws IOException {
+        int propCount = readShort();
+        for (int j = 0; j < propCount; j++) {
+            String key = readPoolObject(String.class);
+            Object value = readPropertyObject();
+            properties.setProperty(key, value != null ? value.toString() : "null");
+        }
+    }
+
     private InputGraph parseGraph(String title) throws IOException {
         InputGraph graph = new InputGraph(title);
+        parseProperties(graph.getProperties());
         parseNodes(graph);
         parseBlocks(graph);
         graph.ensureNodesInBlocks();
+        for (InputNode node : graph.getNodes()) {
+            node.internProperties();
+        }
         return graph;
     }
 
@@ -822,9 +859,10 @@
         }
     }
 
+    static final Pattern templatePattern = Pattern.compile("\\{(p|i)#([a-zA-Z0-9$_]+)(/(l|m|s))?\\}");
+
     private String createName(List<Edge> edges, Map<String, Object> properties, String template) {
-        Pattern p = Pattern.compile("\\{(p|i)#([a-zA-Z0-9$_]+)(/(l|m|s))?\\}");
-        Matcher m = p.matcher(template);
+        Matcher m = templatePattern.matcher(template);
         StringBuffer sb = new StringBuffer();
         while (m.find()) {
             String name = m.group(2);
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java
index 638a065..b3ef1fc 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,4 +37,14 @@
     InputGraph getGraph();
 
     void setSelectedNodes(Set<InputNode> nodes);
+
+    /**
+     * @return an iterator walking forward through the {@link InputGraph}s following the {@link #getGraph()}
+     */
+    Iterable<InputGraph> searchForward();
+
+    /**
+     * @return an iterator walking backward through the {@link InputGraph}s preceeding the {@link #getGraph()}
+     */
+    Iterable<InputGraph> searchBackward();
 }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml
index 7e3f062..a4aadaa 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml
@@ -22,6 +22,14 @@
                         <specification-version>1.0</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>com.sun.hotspot.igv.util</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.0</specification-version>
+                    </run-dependency>
+                </dependency>
             </module-dependencies>
             <public-packages>
                 <package>com.sun.hotspot.igv.graph</package>
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java
index da101bf7..79d1299 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import com.sun.hotspot.igv.data.Source;
 import com.sun.hotspot.igv.layout.Port;
 import com.sun.hotspot.igv.layout.Vertex;
+import com.sun.hotspot.igv.util.StringUtils;
 import java.awt.Color;
 import java.awt.Font;
 import java.awt.FontMetrics;
@@ -141,7 +142,7 @@
         sb.append(text);
 
         for (InputNode n : getSource().getSourceNodes()) {
-            sb.append("Node (ID=" + n.getId() + "): " + n.getProperties().get("name"));
+            sb.append(StringUtils.escapeHTML("Node (ID=" + n.getId() + "): " + n.getProperties().get("name")));
             sb.append("<br>");
         }
 
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java
index a1ccc65..cccca71 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -445,5 +445,48 @@
     void close() {
         filterChain.getChangedEvent().removeListener(filterChainChangedListener);
         sequenceFilterChain.getChangedEvent().removeListener(filterChainChangedListener);
-}
+    }
+
+    Iterable<InputGraph> getGraphsForward() {
+        return new Iterable<InputGraph>() {
+
+            @Override
+            public Iterator<InputGraph> iterator() {
+                return new Iterator<InputGraph>() {
+                    int index = getFirstPosition();
+
+                    @Override
+                    public boolean hasNext() {
+                        return index + 1 < graphs.size();
+                    }
+
+                    @Override
+                    public InputGraph next() {
+                        return graphs.get(++index);
+                    }
+                };
+            }
+        };
+    }
+
+    Iterable<InputGraph> getGraphsBackward() {
+        return new Iterable<InputGraph>() {
+            @Override
+            public Iterator<InputGraph> iterator() {
+                return new Iterator<InputGraph>() {
+                    int index = getFirstPosition();
+
+                    @Override
+                    public boolean hasNext() {
+                        return index - 1 > 0;
+                    }
+
+                    @Override
+                    public InputGraph next() {
+                        return graphs.get(--index);
+                    }
+                };
+            }
+        };
+    }
 }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java
index cb4c9f6..fd7a19a 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,4 +50,14 @@
     public void setSelectedNodes(Set<InputNode> nodes) {
         editor.setSelectedNodes(nodes);
     }
+
+    @Override
+    public Iterable<InputGraph> searchBackward() {
+        return editor.getDiagramModel().getGraphsBackward();
+    }
+
+    @Override
+    public Iterable<InputGraph> searchForward() {
+        return editor.getDiagramModel().getGraphsForward();
+    }
 }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java
index 6da842c..9a85838 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -289,7 +289,10 @@
             quicksearch = (Component) quicksearch.getClass().getConstructor(KeyStroke.class).newInstance(new Object[]{null});
         } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
         }
-        quicksearch.setMinimumSize(quicksearch.getPreferredSize()); // necessary for GTK LAF
+        Dimension preferredSize = quicksearch.getPreferredSize();
+        preferredSize = new Dimension((int) preferredSize.getWidth() * 2, (int) preferredSize.getHeight());
+        quicksearch.setMinimumSize(preferredSize); // necessary for GTK LAF
+        quicksearch.setPreferredSize(preferredSize);
         toolBar.add(quicksearch);
 
         centerPanel = new JPanel();
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java
index 53773a2..23b23ed 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
  */
 package com.sun.hotspot.igv.view;
 
+import com.sun.hotspot.igv.data.InputGraph;
 import com.sun.hotspot.igv.data.InputNode;
 import com.sun.hotspot.igv.data.Properties;
 import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher;
@@ -81,57 +82,67 @@
 
         final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);
         if (p != null && p.getGraph() != null) {
-            List<InputNode> matches = null;
-            try {
-                RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE);
-                Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(p.getGraph().getNodes());
-
-                matches = selector.selectMultiple(matcher);
-            } catch (Exception e) {
-                final String msg = e.getMessage();
-                response.addResult(new Runnable() {
-                    @Override
-                        public void run() {
-                            Message desc = new NotifyDescriptor.Message("An exception occurred during the search, "
-                                    + "perhaps due to a malformed query string:\n" + msg,
-                                    NotifyDescriptor.WARNING_MESSAGE);
-                            DialogDisplayer.getDefault().notify(desc);
-                        }
-                    },
-                    "(Error during search)"
-                );
+            InputGraph matchGraph = p.getGraph();
+            // Search the current graph
+            List<InputNode> matches = findMatches(name, value, p.getGraph(), response);
+            if (matches == null) {
+                // See if the it hits in a later graph
+                for (InputGraph graph : p.searchForward()) {
+                    matches = findMatches(name, value, graph, response);
+                    if (matches != null) {
+                        matchGraph = graph;
+                        break;
+                    }
+                }
+            }
+            if (matches == null) {
+                // See if it hits in a earlier graph
+                for (InputGraph graph : p.searchBackward()) {
+                    matches = findMatches(name, value, graph, response);
+                    if (matches != null) {
+                        matchGraph = graph;
+                        break;
+                    }
+                }
             }
 
             if (matches != null) {
                 final Set<InputNode> set = new HashSet<>(matches);
+                final InputGraph theGraph = p.getGraph() != matchGraph ? matchGraph : null;
                 response.addResult(new Runnable() {
                     @Override
-                        public void run() {
-                            final EditorTopComponent comp = EditorTopComponent.getActive();
-                            if (comp != null) {
-                                comp.setSelectedNodes(set);
-                                comp.requestActive();
+                    public void run() {
+                        final EditorTopComponent comp = EditorTopComponent.getActive();
+                        if (comp != null) {
+                            if (theGraph != null) {
+                                comp.getDiagramModel().selectGraph(theGraph);
                             }
+                            comp.setSelectedNodes(set);
+                            comp.requestActive();
                         }
-                    },
-                    "All " + matches.size() + " matching nodes (" + name + "=" + value + ")"
+                    }
+                },
+                        "All " + matches.size() + " matching nodes (" + name + "=" + value + ")" + (theGraph != null ? " in " + theGraph.getName() : "")
                 );
 
                 // Single matches
                 for (final InputNode n : matches) {
                     response.addResult(new Runnable() {
                         @Override
-                            public void run() {
-                                final EditorTopComponent comp = EditorTopComponent.getActive();
-                                if (comp != null) {
-                                    final Set<InputNode> tmpSet = new HashSet<>();
-                                    tmpSet.add(n);
-                                    comp.setSelectedNodes(tmpSet);
-                                    comp.requestActive();
+                        public void run() {
+                            final EditorTopComponent comp = EditorTopComponent.getActive();
+                            if (comp != null) {
+                                final Set<InputNode> tmpSet = new HashSet<>();
+                                tmpSet.add(n);
+                                if (theGraph != null) {
+                                    comp.getDiagramModel().selectGraph(theGraph);
                                 }
+                                comp.setSelectedNodes(tmpSet);
+                                comp.requestActive();
                             }
-                        },
-                        n.getProperties().get(name) + " (" + n.getId() + " " + n.getProperties().get("name") + ")"
+                        }
+                    },
+                            n.getProperties().get(name) + " (" + n.getId() + " " + n.getProperties().get("name") + ")" + (theGraph != null ? " in " + theGraph.getName() : "")
                     );
                 }
             }
@@ -139,4 +150,27 @@
             System.out.println("no input graph provider!");
         }
     }
+
+    private List<InputNode> findMatches(String name, String value, InputGraph inputGraph, SearchResponse response) {
+        try {
+            RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE);
+            Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(inputGraph.getNodes());
+            List<InputNode> matches = selector.selectMultiple(matcher);
+            return matches.size() == 0 ? null : matches;
+        } catch (Exception e) {
+            final String msg = e.getMessage();
+            response.addResult(new Runnable() {
+                @Override
+                public void run() {
+                    Message desc = new NotifyDescriptor.Message("An exception occurred during the search, "
+                            + "perhaps due to a malformed query string:\n" + msg,
+                            NotifyDescriptor.WARNING_MESSAGE);
+                    DialogDisplayer.getDefault().notify(desc);
+                }
+            },
+                    "(Error during search)"
+            );
+        }
+        return null;
+    }
 }
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml
index 66979b1..e37ac81 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml
@@ -61,14 +61,26 @@
                 <attr name="position" intvalue="710"/>
             </file>
         </folder>
+        <folder name="Window">
+            <file name="Tools_hidden"/>
+            <file name="Web_hidden"/>
+            <file name="org-netbeans-modules-tasks-ui-DashboardTopComponent.shadow_hidden"/>
+        </folder>
     </folder>
 
     <folder name="QuickSearch">
+        <file name="Actions_hidden"/>
+        <file name="GoToOption_hidden"/>
+        <file name="GoToSymbol_hidden"/>
+        <file name="GoToType_hidden"/>
+        <file name="Help_hidden"/>
+        <file name="Hudson_hidden"/>
         <folder name="Nodes">
             <attr name="command" stringvalue="n"/>
             <attr name="position" intvalue="0"/>
             <file name="com-sun-hotspot-igv-view-NodeQuickSearch.instance"/>
         </folder>
+        <file name="Projects_hidden"/>
     </folder>
     
     <folder name="QuickSearchShadow">
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java
index 2d9efb8..3cf39ca 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import com.sun.hotspot.igv.graph.Figure;
 import com.sun.hotspot.igv.graph.InputSlot;
 import com.sun.hotspot.igv.graph.OutputSlot;
+import com.sun.hotspot.igv.util.StringUtils;
 import com.sun.hotspot.igv.view.DiagramScene;
 import java.awt.*;
 import java.awt.geom.Line2D;
@@ -148,7 +149,7 @@
     private String generateToolTipText(List<Connection> conn) {
         StringBuilder sb = new StringBuilder();
         for (Connection c : conn) {
-            sb.append(c.getToolTipText());
+            sb.append(StringUtils.escapeHTML(c.getToolTipText()));
             sb.append("<br>");
         }
         return sb.toString();
diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties
index 39801a7..f9a657c 100644
--- a/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties
@@ -48,5 +48,5 @@
 
 # Disable assertions for RequestProcessor to prevent annoying messages in case
 # of multiple SceneAnimator update tasks in the default RequestProcessor.
-run.args.extra = -J-server -J-da:org.openide.util.RequestProcessor -J-Xms2g -J-Xmx8g -J-Djava.lang.Integer.IntegerCache.high=20000
+run.args.extra = -J-server -J-da:org.openide.util.RequestProcessor -J-Xms2g -J-Xmx8g -J-Djava.lang.Integer.IntegerCache.high=200000
 debug.args.extra = -J-server -J-da:org.openide.util.RequestProcessor
diff --git a/hotspot/src/share/vm/asm/codeBuffer.cpp b/hotspot/src/share/vm/asm/codeBuffer.cpp
index 0586fbe..c3fba97 100644
--- a/hotspot/src/share/vm/asm/codeBuffer.cpp
+++ b/hotspot/src/share/vm/asm/codeBuffer.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -604,7 +604,7 @@
 
 
 
-csize_t CodeBuffer::total_offset_of(CodeSection* cs) const {
+csize_t CodeBuffer::total_offset_of(const CodeSection* cs) const {
   csize_t size_so_far = 0;
   for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
     const CodeSection* cur_cs = code_section(n);
diff --git a/hotspot/src/share/vm/asm/codeBuffer.hpp b/hotspot/src/share/vm/asm/codeBuffer.hpp
index 534a81f..aefcbab 100644
--- a/hotspot/src/share/vm/asm/codeBuffer.hpp
+++ b/hotspot/src/share/vm/asm/codeBuffer.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -468,9 +468,11 @@
   // construction.
   void initialize(csize_t code_size, csize_t locs_size);
 
-  CodeSection* consts()            { return &_consts; }
-  CodeSection* insts()             { return &_insts; }
-  CodeSection* stubs()             { return &_stubs; }
+  CodeSection* consts() { return &_consts; }
+  CodeSection* insts() { return &_insts; }
+  CodeSection* stubs() { return &_stubs; }
+
+  const CodeSection* insts() const { return &_insts; }
 
   // present sections in order; return NULL at end; consts is #0, etc.
   CodeSection* code_section(int n) {
@@ -547,7 +549,7 @@
 
   // Combined offset (relative to start of first section) of given
   // section, as eventually found in the final CodeBlob.
-  csize_t total_offset_of(CodeSection* cs) const;
+  csize_t total_offset_of(const CodeSection* cs) const;
 
   // allocated size of all relocation data, including index, rounded up
   csize_t total_relocation_size() const;
diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
index 2b01e3a..7e65f3c 100644
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
@@ -247,7 +247,7 @@
 
   } else if ((lf = x->array()->as_LoadField()) != NULL) {
     ciField* field = lf->field();
-    if (field->is_constant() && field->is_static()) {
+    if (field->is_static_constant()) {
       assert(PatchALot || ScavengeRootsInCode < 2, "Constant field loads are folded during parsing");
       ciObject* c = field->constant_value().as_object();
       if (!c->is_null_object()) {
diff --git a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp
index 05a8c70..457c9cc 100644
--- a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp
+++ b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,17 +77,13 @@
   }
 };
 
-
-define_array(CodeStubArray, CodeStub*)
-define_stack(_CodeStubList, CodeStubArray)
-
-class CodeStubList: public _CodeStubList {
+class CodeStubList: public GrowableArray<CodeStub*> {
  public:
-  CodeStubList(): _CodeStubList() {}
+  CodeStubList(): GrowableArray<CodeStub*>() {}
 
   void append(CodeStub* stub) {
     if (!contains(stub)) {
-      _CodeStubList::append(stub);
+      GrowableArray<CodeStub*>::append(stub);
     }
   }
 };
diff --git a/hotspot/src/share/vm/c1/c1_Compilation.hpp b/hotspot/src/share/vm/c1/c1_Compilation.hpp
index 3bc07da..a60d1fd 100644
--- a/hotspot/src/share/vm/c1/c1_Compilation.hpp
+++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,12 +53,9 @@
 class CFGPrinter;
 typedef LIR_OprDesc* LIR_Opr;
 
-
-define_array(BasicTypeArray, BasicType)
-define_stack(BasicTypeList, BasicTypeArray)
-
-define_array(ExceptionInfoArray, ExceptionInfo*)
-define_stack(ExceptionInfoList,  ExceptionInfoArray)
+typedef GrowableArray<BasicType> BasicTypeArray;
+typedef GrowableArray<BasicType> BasicTypeList;
+typedef GrowableArray<ExceptionInfo*> ExceptionInfoList;
 
 class Compilation: public StackObj {
   friend class CompilationResourceObj;
diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp
index 1829ff8..e292574 100644
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -131,6 +131,9 @@
     if (!VM_Version::supports_atomic_getset4()) return false;
 #endif
     break;
+  case vmIntrinsics::_onSpinWait:
+    if (!VM_Version::supports_on_spin_wait()) return false;
+    break;
   case vmIntrinsics::_arraycopy:
   case vmIntrinsics::_currentTimeMillis:
   case vmIntrinsics::_nanoTime:
@@ -195,20 +198,6 @@
   case vmIntrinsics::_putLongVolatile:
   case vmIntrinsics::_putFloatVolatile:
   case vmIntrinsics::_putDoubleVolatile:
-  case vmIntrinsics::_getByte_raw:
-  case vmIntrinsics::_getShort_raw:
-  case vmIntrinsics::_getChar_raw:
-  case vmIntrinsics::_getInt_raw:
-  case vmIntrinsics::_getLong_raw:
-  case vmIntrinsics::_getFloat_raw:
-  case vmIntrinsics::_getDouble_raw:
-  case vmIntrinsics::_putByte_raw:
-  case vmIntrinsics::_putShort_raw:
-  case vmIntrinsics::_putChar_raw:
-  case vmIntrinsics::_putInt_raw:
-  case vmIntrinsics::_putLong_raw:
-  case vmIntrinsics::_putFloat_raw:
-  case vmIntrinsics::_putDouble_raw:
   case vmIntrinsics::_getShortUnaligned:
   case vmIntrinsics::_getCharUnaligned:
   case vmIntrinsics::_getIntUnaligned:
@@ -221,6 +210,11 @@
   case vmIntrinsics::_updateCRC32:
   case vmIntrinsics::_updateBytesCRC32:
   case vmIntrinsics::_updateByteBufferCRC32:
+#ifdef SPARC
+  case vmIntrinsics::_updateBytesCRC32C:
+  case vmIntrinsics::_updateDirectByteBufferCRC32C:
+#endif
+  case vmIntrinsics::_vectorizedMismatch:
   case vmIntrinsics::_compareAndSwapInt:
   case vmIntrinsics::_compareAndSwapObject:
   case vmIntrinsics::_getCharStringU:
diff --git a/hotspot/src/share/vm/c1/c1_FrameMap.cpp b/hotspot/src/share/vm/c1/c1_FrameMap.cpp
index a164d8c..d9e5acb 100644
--- a/hotspot/src/share/vm/c1/c1_FrameMap.cpp
+++ b/hotspot/src/share/vm/c1/c1_FrameMap.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -164,7 +164,7 @@
   _reserved_argument_area_size = MAX2(4, reserved_argument_area_size) * BytesPerWord;
 
   _argcount = method->arg_size();
-  _argument_locations = new intArray(_argcount, -1);
+  _argument_locations = new intArray(_argcount, _argcount, -1);
   _incoming_arguments = java_calling_convention(signature_type_array_for(method), false);
   _oop_map_arg_count = _incoming_arguments->reserved_stack_slots();
 
diff --git a/hotspot/src/share/vm/c1/c1_FrameMap.hpp b/hotspot/src/share/vm/c1/c1_FrameMap.hpp
index d5d12ed..5e29ca3 100644
--- a/hotspot/src/share/vm/c1/c1_FrameMap.hpp
+++ b/hotspot/src/share/vm/c1/c1_FrameMap.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,6 @@
 
 class ciMethod;
 class CallingConvention;
-class BasicTypeArray;
-class BasicTypeList;
 
 //--------------------------------------------------------
 //               FrameMap
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index 7eacc2c..69d475a 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -50,11 +50,11 @@
   BlockList*   _bci2block;             // mapping from bci to blocks for GraphBuilder
 
   // fields used by mark_loops
-  BitMap       _active;                // for iteration of control flow graph
-  BitMap       _visited;               // for iteration of control flow graph
-  intArray     _loop_map;              // caches the information if a block is contained in a loop
-  int          _next_loop_index;       // next free loop number
-  int          _next_block_number;     // for reverse postorder numbering of blocks
+  ResourceBitMap _active;              // for iteration of control flow graph
+  ResourceBitMap _visited;             // for iteration of control flow graph
+  intArray       _loop_map;            // caches the information if a block is contained in a loop
+  int            _next_loop_index;     // next free loop number
+  int            _next_block_number;   // for reverse postorder numbering of blocks
 
   // accessors
   Compilation*  compilation() const              { return _compilation; }
@@ -227,7 +227,7 @@
   // Without it, backward branches could jump to a bci where no block was created
   // during bytecode iteration. This would require the creation of a new block at the
   // branch target and a modification of the successor lists.
-  BitMap bci_block_start = method()->bci_block_start();
+  const BitMap& bci_block_start = method()->bci_block_start();
 
   ciBytecodeStream s(method());
   while (s.next() != ciBytecodeStream::EOBC()) {
@@ -355,15 +355,19 @@
 void BlockListBuilder::mark_loops() {
   ResourceMark rm;
 
-  _active = BitMap(BlockBegin::number_of_blocks());         _active.clear();
-  _visited = BitMap(BlockBegin::number_of_blocks());        _visited.clear();
-  _loop_map = intArray(BlockBegin::number_of_blocks(), 0);
+  _active.initialize(BlockBegin::number_of_blocks());
+  _visited.initialize(BlockBegin::number_of_blocks());
+  _loop_map = intArray(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), 0);
   _next_loop_index = 0;
   _next_block_number = _blocks.length();
 
   // recursively iterate the control flow graph
   mark_loops(_bci2block->at(0), false);
   assert(_next_block_number >= 0, "invalid block numbers");
+
+  // Remove dangling Resource pointers before the ResourceMark goes out-of-scope.
+  _active.resize(0);
+  _visited.resize(0);
 }
 
 void BlockListBuilder::make_loop_header(BlockBegin* block) {
@@ -1366,7 +1370,7 @@
   } else {
     // collect successors & keys
     BlockList* sux = new BlockList(l + 1, NULL);
-    intArray* keys = new intArray(l, 0);
+    intArray* keys = new intArray(l, l, 0);
     int i;
     bool has_bb = false;
     for (i = 0; i < l; i++) {
@@ -1563,6 +1567,8 @@
 }
 
 Value GraphBuilder::make_constant(ciConstant field_value, ciField* field) {
+  if (!field_value.is_valid())  return NULL;
+
   BasicType field_type = field_value.basic_type();
   ValueType* value = as_ValueType(field_value);
 
@@ -1630,9 +1636,8 @@
     case Bytecodes::_getstatic: {
       // check for compile-time constants, i.e., initialized static final fields
       Value constant = NULL;
-      if (field->is_constant() && !PatchALot) {
+      if (field->is_static_constant() && !PatchALot) {
         ciConstant field_value = field->constant_value();
-        // Stable static fields are checked for non-default values in ciField::initialize_from().
         assert(!field->is_stable() || !field_value.is_null_or_zero(),
                "stable static w/ default value shouldn't be a constant");
         constant = make_constant(field_value, field);
@@ -1665,31 +1670,18 @@
       Value constant = NULL;
       obj = apop();
       ObjectType* obj_type = obj->type()->as_ObjectType();
-      if (obj_type->is_constant() && !PatchALot) {
+      if (field->is_constant() && obj_type->is_constant() && !PatchALot) {
         ciObject* const_oop = obj_type->constant_value();
         if (!const_oop->is_null_object() && const_oop->is_loaded()) {
-          if (field->is_constant()) {
-            ciConstant field_value = field->constant_value_of(const_oop);
-            if (FoldStableValues && field->is_stable() && field_value.is_null_or_zero()) {
-              // Stable field with default value can't be constant.
-              constant = NULL;
-            } else {
-              constant = make_constant(field_value, field);
-            }
-          } else {
-            // For CallSite objects treat the target field as a compile time constant.
-            if (const_oop->is_call_site()) {
+          ciConstant field_value = field->constant_value_of(const_oop);
+          if (field_value.is_valid()) {
+            constant = make_constant(field_value, field);
+            // For CallSite objects add a dependency for invalidation of the optimization.
+            if (field->is_call_site_target()) {
               ciCallSite* call_site = const_oop->as_call_site();
-              if (field->is_call_site_target()) {
-                ciMethodHandle* target = call_site->get_target();
-                if (target != NULL) {  // just in case
-                  ciConstant field_val(T_OBJECT, target);
-                  constant = new Constant(as_ValueType(field_val));
-                  // Add a dependence for invalidation of the optimization.
-                  if (!call_site->is_constant_call_site()) {
-                    dependency_recorder()->assert_call_site_target_value(call_site, target);
-                  }
-                }
+              if (!call_site->is_constant_call_site()) {
+                ciMethodHandle* target = field_value.as_object()->as_method_handle();
+                dependency_recorder()->assert_call_site_target_value(call_site, target);
               }
             }
           }
@@ -1772,7 +1764,7 @@
   bool ignored_will_link;
   ciSignature* declared_signature = NULL;
   ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature);
-  assert(expected == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?");
+  assert(expected == obj_args->max_length() || real_target->is_method_handle_intrinsic(), "missed on arg?");
 #endif
 }
 
@@ -1783,7 +1775,7 @@
   if (obj_args == NULL) {
     return NULL;
   }
-  int s = obj_args->size();
+  int s = obj_args->max_length();
   // if called through method handle invoke, some arguments may have been popped
   for (int i = start, j = 0; j < s && i < args->length(); i++) {
     if (args->at(i)->type()->is_object_kind()) {
@@ -1804,25 +1796,14 @@
   const Bytecodes::Code bc_raw = stream()->cur_bc_raw();
   assert(declared_signature != NULL, "cannot be null");
 
-  // we have to make sure the argument size (incl. the receiver)
-  // is correct for compilation (the call would fail later during
-  // linkage anyway) - was bug (gri 7/28/99)
-  {
-    // Use raw to get rewritten bytecode.
-    const bool is_invokestatic = bc_raw == Bytecodes::_invokestatic;
-    const bool allow_static =
-          is_invokestatic ||
-          bc_raw == Bytecodes::_invokehandle ||
-          bc_raw == Bytecodes::_invokedynamic;
-    if (target->is_loaded()) {
-      if (( target->is_static() && !allow_static) ||
-          (!target->is_static() &&  is_invokestatic)) {
-        BAILOUT("will cause link error");
-      }
-    }
-  }
   ciInstanceKlass* klass = target->holder();
 
+  // Make sure there are no evident problems with linking the instruction.
+  bool is_resolved = true;
+  if (klass->is_loaded() && !target->is_loaded()) {
+    is_resolved = false; // method not found
+  }
+
   // check if CHA possible: if so, change the code to invoke_special
   ciInstanceKlass* calling_klass = method()->holder();
   ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder);
@@ -1866,10 +1847,6 @@
     apush(arg);
   }
 
-  // NEEDS_CLEANUP
-  // I've added the target->is_loaded() test below but I don't really understand
-  // how klass->is_loaded() can be true and yet target->is_loaded() is false.
-  // this happened while running the JCK invokevirtual tests under doit.  TKR
   ciMethod* cha_monomorphic_target = NULL;
   ciMethod* exact_target = NULL;
   Value better_receiver = NULL;
@@ -1993,12 +1970,11 @@
   }
 
   // check if we could do inlining
-  if (!PatchALot && Inline && klass->is_loaded() &&
+  if (!PatchALot && Inline && is_resolved &&
+      klass->is_loaded() && target->is_loaded() &&
       (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized())
-      && target->is_loaded()
       && !patch_for_appendix) {
     // callee is known => check if we have static binding
-    assert(target->is_loaded(), "callee must be known");
     if (code == Bytecodes::_invokestatic  ||
         code == Bytecodes::_invokespecial ||
         code == Bytecodes::_invokevirtual && target->is_final_method() ||
@@ -2055,7 +2031,7 @@
   // Currently only supported on Sparc.
   // The UseInlineCaches only controls dispatch to invokevirtuals for
   // loaded classes which we weren't able to statically bind.
-  if (!UseInlineCaches && is_loaded && code == Bytecodes::_invokevirtual
+  if (!UseInlineCaches && is_resolved && is_loaded && code == Bytecodes::_invokevirtual
       && !target->can_be_statically_bound()) {
     // Find a vtable index if one is available
     // For arrays, callee_holder is Object. Resolving the call with
@@ -2068,35 +2044,37 @@
   }
 #endif
 
-  if (recv != NULL &&
-      (code == Bytecodes::_invokespecial ||
-       !is_loaded || target->is_final())) {
-    // invokespecial always needs a NULL check.  invokevirtual where
-    // the target is final or where it's not known that whether the
-    // target is final requires a NULL check.  Otherwise normal
-    // invokevirtual will perform the null check during the lookup
-    // logic or the unverified entry point.  Profiling of calls
-    // requires that the null check is performed in all cases.
-    null_check(recv);
-  }
+  if (is_resolved) {
+    // invokespecial always needs a NULL check. invokevirtual where the target is
+    // final or where it's not known whether the target is final requires a NULL check.
+    // Otherwise normal invokevirtual will perform the null check during the lookup
+    // logic or the unverified entry point.  Profiling of calls requires that
+    // the null check is performed in all cases.
+    bool do_null_check = (recv != NULL) &&
+        (code == Bytecodes::_invokespecial || !is_loaded || target->is_final() || (is_profiling() && profile_calls()));
 
-  if (is_profiling()) {
-    if (recv != NULL && profile_calls()) {
+    if (do_null_check) {
       null_check(recv);
     }
-    // Note that we'd collect profile data in this method if we wanted it.
-    compilation()->set_would_profile(true);
 
-    if (profile_calls()) {
-      assert(cha_monomorphic_target == NULL || exact_target == NULL, "both can not be set");
-      ciKlass* target_klass = NULL;
-      if (cha_monomorphic_target != NULL) {
-        target_klass = cha_monomorphic_target->holder();
-      } else if (exact_target != NULL) {
-        target_klass = exact_target->holder();
+    if (is_profiling()) {
+      // Note that we'd collect profile data in this method if we wanted it.
+      compilation()->set_would_profile(true);
+
+      if (profile_calls()) {
+        assert(cha_monomorphic_target == NULL || exact_target == NULL, "both can not be set");
+        ciKlass* target_klass = NULL;
+        if (cha_monomorphic_target != NULL) {
+          target_klass = cha_monomorphic_target->holder();
+        } else if (exact_target != NULL) {
+          target_klass = exact_target->holder();
+        }
+        profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false);
       }
-      profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false);
     }
+  } else {
+    // No need in null check or profiling: linkage error will be thrown at runtime
+    // during resolution.
   }
 
   Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target, state_before);
@@ -2220,7 +2198,7 @@
   ciKlass* klass = stream()->get_klass(will_link);
   ValueStack* state_before = !klass->is_loaded() || PatchALot ? copy_state_before() : copy_state_exhandling();
 
-  Values* dims = new Values(dimensions, NULL);
+  Values* dims = new Values(dimensions, dimensions, NULL);
   // fill in all dimensions
   int i = dimensions;
   while (i-- > 0) dims->at_put(i, ipop());
@@ -3102,7 +3080,7 @@
   Value local;
 
   // find all the locals that the interpreter thinks contain live oops
-  const BitMap live_oops = method()->live_local_oops_at_bci(osr_bci);
+  const ResourceBitMap live_oops = method()->live_local_oops_at_bci(osr_bci);
 
   // compute the offset into the locals so that we can treat the buffer
   // as if the locals were still in the interpreter frame
@@ -3487,20 +3465,6 @@
   case vmIntrinsics::_putLongVolatile    : append_unsafe_put_obj(callee, T_LONG,    true); return;
   case vmIntrinsics::_putFloatVolatile   : append_unsafe_put_obj(callee, T_FLOAT,   true); return;
   case vmIntrinsics::_putDoubleVolatile  : append_unsafe_put_obj(callee, T_DOUBLE,  true); return;
-  case vmIntrinsics::_getByte_raw        : append_unsafe_get_raw(callee, T_BYTE  ); return;
-  case vmIntrinsics::_getShort_raw       : append_unsafe_get_raw(callee, T_SHORT ); return;
-  case vmIntrinsics::_getChar_raw        : append_unsafe_get_raw(callee, T_CHAR  ); return;
-  case vmIntrinsics::_getInt_raw         : append_unsafe_get_raw(callee, T_INT   ); return;
-  case vmIntrinsics::_getLong_raw        : append_unsafe_get_raw(callee, T_LONG  ); return;
-  case vmIntrinsics::_getFloat_raw       : append_unsafe_get_raw(callee, T_FLOAT ); return;
-  case vmIntrinsics::_getDouble_raw      : append_unsafe_get_raw(callee, T_DOUBLE); return;
-  case vmIntrinsics::_putByte_raw        : append_unsafe_put_raw(callee, T_BYTE  ); return;
-  case vmIntrinsics::_putShort_raw       : append_unsafe_put_raw(callee, T_SHORT ); return;
-  case vmIntrinsics::_putChar_raw        : append_unsafe_put_raw(callee, T_CHAR  ); return;
-  case vmIntrinsics::_putInt_raw         : append_unsafe_put_raw(callee, T_INT   ); return;
-  case vmIntrinsics::_putLong_raw        : append_unsafe_put_raw(callee, T_LONG  ); return;
-  case vmIntrinsics::_putFloat_raw       : append_unsafe_put_raw(callee, T_FLOAT ); return;
-  case vmIntrinsics::_putDouble_raw      : append_unsafe_put_raw(callee, T_DOUBLE);  return;
   case vmIntrinsics::_compareAndSwapLong:
   case vmIntrinsics::_compareAndSwapInt:
   case vmIntrinsics::_compareAndSwapObject: append_unsafe_CAS(callee); return;
@@ -3823,9 +3787,9 @@
       int start = 0;
       Values* obj_args = args_list_for_profiling(callee, start, has_receiver);
       if (obj_args != NULL) {
-        int s = obj_args->size();
+        int s = obj_args->max_length();
         // if called through method handle invoke, some arguments may have been popped
-        for (int i = args_base+start, j = 0; j < obj_args->size() && i < state()->stack_size(); ) {
+        for (int i = args_base+start, j = 0; j < obj_args->max_length() && i < state()->stack_size(); ) {
           Value v = state()->stack_at_inc(i);
           if (v->type()->is_object_kind()) {
             obj_args->push(v);
@@ -4142,7 +4106,7 @@
   // properly clone all blocks in jsr region as well as exception
   // handlers containing rets
   BlockList* new_bci2block = new BlockList(bci2block()->length());
-  new_bci2block->push_all(bci2block());
+  new_bci2block->appendAll(bci2block());
   data->set_bci2block(new_bci2block);
   data->set_scope(scope());
   data->setup_jsr_xhandlers();
diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp
index 459b377..c1c72cf 100644
--- a/hotspot/src/share/vm/c1/c1_IR.cpp
+++ b/hotspot/src/share/vm/c1/c1_IR.cpp
@@ -460,14 +460,14 @@
 
   BlockList* _linear_scan_order;   // the resulting list of blocks in correct order
 
-  BitMap     _visited_blocks;      // used for recursive processing of blocks
-  BitMap     _active_blocks;       // used for recursive processing of blocks
-  BitMap     _dominator_blocks;    // temproary BitMap used for computation of dominator
-  intArray   _forward_branches;    // number of incoming forward branches for each block
-  BlockList  _loop_end_blocks;     // list of all loop end blocks collected during count_edges
-  BitMap2D   _loop_map;            // two-dimensional bit set: a bit is set if a block is contained in a loop
-  BlockList  _work_list;           // temporary list (used in mark_loops and compute_order)
-  BlockList  _loop_headers;
+  ResourceBitMap _visited_blocks;   // used for recursive processing of blocks
+  ResourceBitMap _active_blocks;    // used for recursive processing of blocks
+  ResourceBitMap _dominator_blocks; // temproary BitMap used for computation of dominator
+  intArray       _forward_branches; // number of incoming forward branches for each block
+  BlockList      _loop_end_blocks;  // list of all loop end blocks collected during count_edges
+  BitMap2D       _loop_map;         // two-dimensional bit set: a bit is set if a block is contained in a loop
+  BlockList      _work_list;        // temporary list (used in mark_loops and compute_order)
+  BlockList      _loop_headers;
 
   Compilation* _compilation;
 
@@ -531,11 +531,11 @@
   _visited_blocks(_max_block_id),
   _active_blocks(_max_block_id),
   _dominator_blocks(_max_block_id),
-  _forward_branches(_max_block_id, 0),
+  _forward_branches(_max_block_id, _max_block_id, 0),
   _loop_end_blocks(8),
   _work_list(8),
   _linear_scan_order(NULL), // initialized later with correct size
-  _loop_map(0, 0),          // initialized later with correct size
+  _loop_map(0),             // initialized later with correct size
   _compilation(c)
 {
   TRACE_LINEAR_SCAN(2, tty->print_cr("***** computing linear-scan block order"));
@@ -849,13 +849,13 @@
     return false;
   }
 
-  assert(_linear_scan_order->index_of(cur) == -1, "block already processed (block can be ready only once)");
-  assert(_work_list.index_of(cur) == -1, "block already in work-list (block can be ready only once)");
+  assert(_linear_scan_order->find(cur) == -1, "block already processed (block can be ready only once)");
+  assert(_work_list.find(cur) == -1, "block already in work-list (block can be ready only once)");
   return true;
 }
 
 void ComputeLinearScanOrder::sort_into_work_list(BlockBegin* cur) {
-  assert(_work_list.index_of(cur) == -1, "block already in work list");
+  assert(_work_list.find(cur) == -1, "block already in work list");
 
   int cur_weight = compute_weight(cur);
 
@@ -891,7 +891,7 @@
 
 void ComputeLinearScanOrder::append_block(BlockBegin* cur) {
   TRACE_LINEAR_SCAN(3, tty->print_cr("appending block B%d (weight 0x%6x) to linear-scan order", cur->block_id(), cur->linear_scan_number()));
-  assert(_linear_scan_order->index_of(cur) == -1, "cannot add the same block twice");
+  assert(_linear_scan_order->find(cur) == -1, "cannot add the same block twice");
 
   // currently, the linear scan order and code emit order are equal.
   // therefore the linear_scan_number and the weight of a block must also
@@ -1116,13 +1116,13 @@
     BlockBegin* cur = _linear_scan_order->at(i);
 
     assert(cur->linear_scan_number() == i, "incorrect linear_scan_number");
-    assert(cur->linear_scan_number() >= 0 && cur->linear_scan_number() == _linear_scan_order->index_of(cur), "incorrect linear_scan_number");
+    assert(cur->linear_scan_number() >= 0 && cur->linear_scan_number() == _linear_scan_order->find(cur), "incorrect linear_scan_number");
 
     int j;
     for (j = cur->number_of_sux() - 1; j >= 0; j--) {
       BlockBegin* sux = cur->sux_at(j);
 
-      assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->index_of(sux), "incorrect linear_scan_number");
+      assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->find(sux), "incorrect linear_scan_number");
       if (!sux->is_set(BlockBegin::backward_branch_target_flag)) {
         assert(cur->linear_scan_number() < sux->linear_scan_number(), "invalid order");
       }
@@ -1134,7 +1134,7 @@
     for (j = cur->number_of_preds() - 1; j >= 0; j--) {
       BlockBegin* pred = cur->pred_at(j);
 
-      assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->index_of(pred), "incorrect linear_scan_number");
+      assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->find(pred), "incorrect linear_scan_number");
       if (!cur->is_set(BlockBegin::backward_branch_target_flag)) {
         assert(cur->linear_scan_number() > pred->linear_scan_number(), "invalid order");
       }
@@ -1256,8 +1256,7 @@
 }
 
 
-define_array(BlockListArray, BlockList*)
-define_stack(BlockListList, BlockListArray)
+typedef GrowableArray<BlockList*> BlockListList;
 
 class PredecessorValidator : public BlockClosure {
  private:
@@ -1271,7 +1270,7 @@
  public:
   PredecessorValidator(IR* hir) {
     ResourceMark rm;
-    _predecessors = new BlockListList(BlockBegin::number_of_blocks(), NULL);
+    _predecessors = new BlockListList(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL);
     _blocks = new BlockList();
 
     int i;
diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp
index 31d3b01..c40cf26 100644
--- a/hotspot/src/share/vm/c1/c1_IR.hpp
+++ b/hotspot/src/share/vm/c1/c1_IR.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -104,9 +104,7 @@
   bool equals(XHandler* other) const;
 };
 
-define_array(_XHandlerArray, XHandler*)
-define_stack(_XHandlerList, _XHandlerArray)
-
+typedef GrowableArray<XHandler*> _XHandlerList;
 
 // XHandlers is the C1 internal list of exception handlers for a method
 class XHandlers: public CompilationResourceObj {
@@ -132,8 +130,7 @@
 
 
 class IRScope;
-define_array(IRScopeArray, IRScope*)
-define_stack(IRScopeList, IRScopeArray)
+typedef GrowableArray<IRScope*> IRScopeList;
 
 class Compilation;
 class IRScope: public CompilationResourceObj {
@@ -154,7 +151,7 @@
   bool          _wrote_volatile;                 // has written volatile field
   BlockBegin*   _start;                          // the start block, successsors are method entries
 
-  BitMap        _requires_phi_function;          // bit is set if phi functions at loop headers are necessary for a local variable
+  ResourceBitMap _requires_phi_function;         // bit is set if phi functions at loop headers are necessary for a local variable
 
   // helper functions
   BlockBegin* build_graph(Compilation* compilation, int osr_bci);
diff --git a/hotspot/src/share/vm/c1/c1_Instruction.cpp b/hotspot/src/share/vm/c1/c1_Instruction.cpp
index a77b22f..ffb439d 100644
--- a/hotspot/src/share/vm/c1/c1_Instruction.cpp
+++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -564,7 +564,7 @@
   for (int s = 0; s < from->number_of_sux();) {
     BlockBegin* sux = from->sux_at(s);
     if (sux == to) {
-      int index = sux->_predecessors.index_of(from);
+      int index = sux->_predecessors.find(from);
       if (index >= 0) {
         sux->_predecessors.remove_at(index);
       }
@@ -664,7 +664,7 @@
 
 void BlockBegin::remove_successor(BlockBegin* pred) {
   int idx;
-  while ((idx = _successors.index_of(pred)) >= 0) {
+  while ((idx = _successors.find(pred)) >= 0) {
     _successors.remove_at(idx);
   }
 }
@@ -677,7 +677,7 @@
 
 void BlockBegin::remove_predecessor(BlockBegin* pred) {
   int idx;
-  while ((idx = _predecessors.index_of(pred)) >= 0) {
+  while ((idx = _predecessors.find(pred)) >= 0) {
     _predecessors.remove_at(idx);
   }
 }
@@ -722,13 +722,15 @@
 
 
 void BlockBegin::iterate_preorder(BlockClosure* closure) {
-  boolArray mark(number_of_blocks(), false);
+  int mark_len = number_of_blocks();
+  boolArray mark(mark_len, mark_len, false);
   iterate_preorder(mark, closure);
 }
 
 
 void BlockBegin::iterate_postorder(BlockClosure* closure) {
-  boolArray mark(number_of_blocks(), false);
+  int mark_len = number_of_blocks();
+  boolArray mark(mark_len, mark_len, false);
   iterate_postorder(mark, closure);
 }
 
@@ -785,7 +787,7 @@
         TRACE_PHI(tty->print_cr("creating phi-function %c%d for stack %d", new_state->stack_at(index)->type()->tchar(), new_state->stack_at(index)->id(), index));
       }
 
-      BitMap requires_phi_function = new_state->scope()->requires_phi_function();
+      BitMap& requires_phi_function = new_state->scope()->requires_phi_function();
 
       for_each_local_value(new_state, index, new_value) {
         bool requires_phi = requires_phi_function.at(index) || (new_value->type()->is_double_word() && requires_phi_function.at(index + 1));
diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp
index 38fcc56..426507d 100644
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -115,11 +115,8 @@
 
 // A Value is a reference to the instruction creating the value
 typedef Instruction* Value;
-define_array(ValueArray, Value)
-define_stack(Values, ValueArray)
-
-define_array(ValueStackArray, ValueStack*)
-define_stack(ValueStackStack, ValueStackArray)
+typedef GrowableArray<Value> Values;
+typedef GrowableArray<ValueStack*> ValueStackStack;
 
 // BlockClosure is the base class for block traversal/iteration.
 
@@ -137,14 +134,13 @@
 
 
 // Some array and list classes
-define_array(BlockBeginArray, BlockBegin*)
-define_stack(_BlockList, BlockBeginArray)
+typedef GrowableArray<BlockBegin*> BlockBeginArray;
 
-class BlockList: public _BlockList {
+class BlockList: public GrowableArray<BlockBegin*> {
  public:
-  BlockList(): _BlockList() {}
-  BlockList(const int size): _BlockList(size) {}
-  BlockList(const int size, BlockBegin* init): _BlockList(size, init) {}
+  BlockList(): GrowableArray<BlockBegin*>() {}
+  BlockList(const int size): GrowableArray<BlockBegin*>(size) {}
+  BlockList(const int size, BlockBegin* init): GrowableArray<BlockBegin*>(size, size, init) {}
 
   void iterate_forward(BlockClosure* closure);
   void iterate_backward(BlockClosure* closure);
@@ -1600,8 +1596,8 @@
   int        _flags;                             // the flags associated with this block
 
   // fields used by BlockListBuilder
-  int        _total_preds;                       // number of predecessors found by BlockListBuilder
-  BitMap     _stores_to_locals;                  // bit is set when a local variable is stored in the block
+  int            _total_preds;                   // number of predecessors found by BlockListBuilder
+  ResourceBitMap _stores_to_locals;              // bit is set when a local variable is stored in the block
 
   // SSA specific fields: (factor out later)
   BlockList   _successors;                       // the successors of this block
@@ -1618,15 +1614,15 @@
   Label      _label;                             // the label associated with this block
   LIR_List*  _lir;                               // the low level intermediate representation for this block
 
-  BitMap      _live_in;                          // set of live LIR_Opr registers at entry to this block
-  BitMap      _live_out;                         // set of live LIR_Opr registers at exit from this block
-  BitMap      _live_gen;                         // set of registers used before any redefinition in this block
-  BitMap      _live_kill;                        // set of registers defined in this block
+  ResourceBitMap _live_in;                       // set of live LIR_Opr registers at entry to this block
+  ResourceBitMap _live_out;                      // set of live LIR_Opr registers at exit from this block
+  ResourceBitMap _live_gen;                      // set of registers used before any redefinition in this block
+  ResourceBitMap _live_kill;                     // set of registers defined in this block
 
-  BitMap      _fpu_register_usage;
-  intArray*   _fpu_stack_state;                  // For x86 FPU code generation with UseLinearScan
-  int         _first_lir_instruction_id;         // ID of first LIR instruction in this block
-  int         _last_lir_instruction_id;          // ID of last LIR instruction in this block
+  ResourceBitMap _fpu_register_usage;
+  intArray*      _fpu_stack_state;               // For x86 FPU code generation with UseLinearScan
+  int            _first_lir_instruction_id;      // ID of first LIR instruction in this block
+  int            _last_lir_instruction_id;       // ID of last LIR instruction in this block
 
   void iterate_preorder (boolArray& mark, BlockClosure* closure);
   void iterate_postorder(boolArray& mark, BlockClosure* closure);
@@ -1697,11 +1693,11 @@
   Label* label()                                 { return &_label; }
   LIR_List* lir() const                          { return _lir; }
   int exception_handler_pco() const              { return _exception_handler_pco; }
-  BitMap& live_in()                              { return _live_in;        }
-  BitMap& live_out()                             { return _live_out;       }
-  BitMap& live_gen()                             { return _live_gen;       }
-  BitMap& live_kill()                            { return _live_kill;      }
-  BitMap& fpu_register_usage()                   { return _fpu_register_usage; }
+  ResourceBitMap& live_in()                      { return _live_in;        }
+  ResourceBitMap& live_out()                     { return _live_out;       }
+  ResourceBitMap& live_gen()                     { return _live_gen;       }
+  ResourceBitMap& live_kill()                    { return _live_kill;      }
+  ResourceBitMap& fpu_register_usage()           { return _fpu_register_usage; }
   intArray* fpu_stack_state() const              { return _fpu_stack_state;    }
   int first_lir_instruction_id() const           { return _first_lir_instruction_id; }
   int last_lir_instruction_id() const            { return _last_lir_instruction_id; }
@@ -1722,16 +1718,16 @@
   void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux);
   void set_lir(LIR_List* lir)                    { _lir = lir; }
   void set_exception_handler_pco(int pco)        { _exception_handler_pco = pco; }
-  void set_live_in       (BitMap map)            { _live_in = map;        }
-  void set_live_out      (BitMap map)            { _live_out = map;       }
-  void set_live_gen      (BitMap map)            { _live_gen = map;       }
-  void set_live_kill     (BitMap map)            { _live_kill = map;      }
-  void set_fpu_register_usage(BitMap map)        { _fpu_register_usage = map; }
+  void set_live_in  (const ResourceBitMap& map)  { _live_in = map;   }
+  void set_live_out (const ResourceBitMap& map)  { _live_out = map;  }
+  void set_live_gen (const ResourceBitMap& map)  { _live_gen = map;  }
+  void set_live_kill(const ResourceBitMap& map)  { _live_kill = map; }
+  void set_fpu_register_usage(const ResourceBitMap& map) { _fpu_register_usage = map; }
   void set_fpu_stack_state(intArray* state)      { _fpu_stack_state = state;  }
   void set_first_lir_instruction_id(int id)      { _first_lir_instruction_id = id;  }
   void set_last_lir_instruction_id(int id)       { _last_lir_instruction_id = id;  }
   void increment_total_preds(int n = 1)          { _total_preds += n; }
-  void init_stores_to_locals(int locals_count)   { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); }
+  void init_stores_to_locals(int locals_count)   { _stores_to_locals.initialize(locals_count); }
 
   // generic
   virtual void state_values_do(ValueVisitor* f);
@@ -1747,7 +1743,7 @@
   void remove_predecessor(BlockBegin* pred);
   bool is_predecessor(BlockBegin* pred) const    { return _predecessors.contains(pred); }
   int number_of_preds() const                    { return _predecessors.length(); }
-  BlockBegin* pred_at(int i) const               { return _predecessors[i]; }
+  BlockBegin* pred_at(int i) const               { return _predecessors.at(i); }
 
   // exception handlers potentially invoked by this block
   void add_exception_handler(BlockBegin* b);
@@ -2612,10 +2608,7 @@
   void set_from(BlockBegin* b) { _from = b; }
 };
 
-
-define_array(BlockPairArray, BlockPair*)
-define_stack(BlockPairList, BlockPairArray)
-
+typedef GrowableArray<BlockPair*> BlockPairList;
 
 inline int         BlockBegin::number_of_sux() const            { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); }
 inline BlockBegin* BlockBegin::sux_at(int i) const              { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch");          return _successors.at(i); }
diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp
index 6077c28..c650ec0 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp
@@ -483,6 +483,7 @@
     case lir_membar_storestore:        // result and info always invalid
     case lir_membar_loadstore:         // result and info always invalid
     case lir_membar_storeload:         // result and info always invalid
+    case lir_on_spin_wait:
     {
       assert(op->as_Op0() != NULL, "must be");
       assert(op->_info == NULL, "info not used by this instruction");
@@ -727,31 +728,6 @@
       break;
     }
 
-
-    case lir_tan:
-    case lir_log10: {
-      assert(op->as_Op2() != NULL, "must be");
-      LIR_Op2* op2 = (LIR_Op2*)op;
-
-      // On x86 tan/sin/cos need two temporary fpu stack slots and
-      // log/log10 need one so handle opr2 and tmp as temp inputs.
-      // Register input operand as temp to guarantee that it doesn't
-      // overlap with the input.
-      assert(op2->_info == NULL, "not used");
-      assert(op2->_tmp5->is_illegal(), "not used");
-      assert(op2->_opr1->is_valid(), "used");
-      do_input(op2->_opr1); do_temp(op2->_opr1);
-
-      if (op2->_opr2->is_valid())         do_temp(op2->_opr2);
-      if (op2->_tmp1->is_valid())         do_temp(op2->_tmp1);
-      if (op2->_tmp2->is_valid())         do_temp(op2->_tmp2);
-      if (op2->_tmp3->is_valid())         do_temp(op2->_tmp3);
-      if (op2->_tmp4->is_valid())         do_temp(op2->_tmp4);
-      if (op2->_result->is_valid())       do_output(op2->_result);
-
-      break;
-    }
-
 // LIR_Op3
     case lir_idiv:
     case lir_irem: {
@@ -1691,6 +1667,7 @@
      case lir_word_align:            s = "word_align";    break;
      case lir_label:                 s = "label";         break;
      case lir_nop:                   s = "nop";           break;
+     case lir_on_spin_wait:          s = "on_spin_wait";  break;
      case lir_backwardbranch_target: s = "backbranch";    break;
      case lir_std_entry:             s = "std_entry";     break;
      case lir_osr_entry:             s = "osr_entry";     break;
@@ -1738,8 +1715,6 @@
      case lir_rem:                   s = "rem";           break;
      case lir_abs:                   s = "abs";           break;
      case lir_sqrt:                  s = "sqrt";          break;
-     case lir_tan:                   s = "tan";           break;
-     case lir_log10:                 s = "log10";         break;
      case lir_logic_and:             s = "logic_and";     break;
      case lir_logic_or:              s = "logic_or";      break;
      case lir_logic_xor:             s = "logic_xor";     break;
diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp
index c5e52de..2943b38 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,17 +59,9 @@
 typedef LIR_OprDesc* LIR_Opr;
 typedef int          RegNr;
 
-define_array(LIR_OprArray, LIR_Opr)
-define_stack(LIR_OprList, LIR_OprArray)
-
-define_array(LIR_OprRefArray, LIR_Opr*)
-define_stack(LIR_OprRefList, LIR_OprRefArray)
-
-define_array(CodeEmitInfoArray, CodeEmitInfo*)
-define_stack(CodeEmitInfoList, CodeEmitInfoArray)
-
-define_array(LIR_OpArray, LIR_Op*)
-define_stack(LIR_OpList, LIR_OpArray)
+typedef GrowableArray<LIR_Opr> LIR_OprList;
+typedef GrowableArray<LIR_Op*> LIR_OpArray;
+typedef GrowableArray<LIR_Op*> LIR_OpList;
 
 // define LIR_OprPtr early so LIR_OprDesc can refer to it
 class LIR_OprPtr: public CompilationResourceObj {
@@ -920,6 +912,7 @@
       , lir_membar_loadstore
       , lir_membar_storeload
       , lir_get_thread
+      , lir_on_spin_wait
   , end_op0
   , begin_op1
       , lir_fxch
@@ -2101,6 +2094,8 @@
   void std_entry(LIR_Opr receiver)               { append(new LIR_Op0(lir_std_entry, receiver)); }
   void osr_entry(LIR_Opr osrPointer)             { append(new LIR_Op0(lir_osr_entry, osrPointer)); }
 
+  void on_spin_wait()                            { append(new LIR_Op0(lir_on_spin_wait)); }
+
   void branch_destination(Label* lbl)            { append(new LIR_OpLabel(lbl)); }
 
   void negate(LIR_Opr from, LIR_Opr to)          { append(new LIR_Op1(lir_neg, from, to)); }
diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
index 230a7bf..abd1fb4 100644
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,7 +127,7 @@
 
 void LIR_Assembler::emit_stubs(CodeStubList* stub_list) {
   for (int m = 0; m < stub_list->length(); m++) {
-    CodeStub* s = (*stub_list)[m];
+    CodeStub* s = stub_list->at(m);
 
     check_codespace();
     CHECK_BAILOUT();
@@ -678,6 +678,10 @@
       get_thread(op->result_opr());
       break;
 
+    case lir_on_spin_wait:
+      on_spin_wait();
+      break;
+
     default:
       ShouldNotReachHere();
       break;
diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp
index 42e6f66..c7d3170 100644
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp
@@ -250,6 +250,7 @@
   void membar_storestore();
   void membar_loadstore();
   void membar_storeload();
+  void on_spin_wait();
   void get_thread(LIR_Opr result);
 
   void verify_oop_map(CodeEmitInfo* info);
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
index 956bb65..ae49fc3 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
@@ -150,7 +150,7 @@
   int i;
   // resolve any cycles in moves from and to virtual registers
   for (i = virtual_operands().length() - 1; i >= 0; i --) {
-    ResolveNode* node = virtual_operands()[i];
+    ResolveNode* node = virtual_operands().at(i);
     if (!node->visited()) {
       _loop = NULL;
       move(NULL, node);
@@ -161,7 +161,7 @@
 
   // generate move for move from non virtual register to abitrary destination
   for (i = other_operands().length() - 1; i >= 0; i --) {
-    ResolveNode* node = other_operands()[i];
+    ResolveNode* node = other_operands().at(i);
     for (int j = node->no_of_destinations() - 1; j >= 0; j --) {
       emit_move(node->operand(), node->destination_at(j)->operand());
     }
@@ -177,7 +177,7 @@
     assert(node == NULL || node->operand() == opr, "");
     if (node == NULL) {
       node = new ResolveNode(opr);
-      vreg_table()[vreg_num] = node;
+      vreg_table().at_put(vreg_num, node);
     }
     // Make sure that all virtual operands show up in the list when
     // they are used as the source of a move.
@@ -3161,7 +3161,9 @@
   case vmIntrinsics::_fullFence :
     if (os::is_MP()) __ membar();
     break;
-
+  case vmIntrinsics::_onSpinWait:
+    __ on_spin_wait();
+    break;
   case vmIntrinsics::_Reference_get:
     do_Reference_get(x);
     break;
@@ -3172,6 +3174,15 @@
     do_update_CRC32(x);
     break;
 
+  case vmIntrinsics::_updateBytesCRC32C:
+  case vmIntrinsics::_updateDirectByteBufferCRC32C:
+    do_update_CRC32C(x);
+    break;
+
+  case vmIntrinsics::_vectorizedMismatch:
+    do_vectorizedMismatch(x);
+    break;
+
   default: ShouldNotReachHere(); break;
   }
 }
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
index 6885ff6..9153645 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,7 @@
 class SwitchRange;
 class LIRItem;
 
-define_array(LIRItemArray, LIRItem*)
-define_stack(LIRItemList, LIRItemArray)
+typedef GrowableArray<LIRItem*> LIRItemList;
 
 class SwitchRange: public CompilationResourceObj {
  private:
@@ -56,15 +55,12 @@
   BlockBegin* sux() const { return _sux; }
 };
 
-define_array(SwitchRangeArray, SwitchRange*)
-define_stack(SwitchRangeList, SwitchRangeArray)
-
+typedef GrowableArray<SwitchRange*> SwitchRangeArray;
+typedef GrowableArray<SwitchRange*> SwitchRangeList;
 
 class ResolveNode;
 
-define_array(NodeArray, ResolveNode*);
-define_stack(NodeList, NodeArray);
-
+typedef GrowableArray<ResolveNode*> NodeList;
 
 // Node objects form a directed graph of LIR_Opr
 // Edges between Nodes represent moves from one Node to its destinations
@@ -86,7 +82,7 @@
   // accessors
   LIR_Opr operand() const           { return _operand; }
   int no_of_destinations() const    { return _destinations.length(); }
-  ResolveNode* destination_at(int i)     { return _destinations[i]; }
+  ResolveNode* destination_at(int i)     { return _destinations.at(i); }
   bool assigned() const             { return _assigned; }
   bool visited() const              { return _visited; }
   bool start_node() const           { return _start_node; }
@@ -257,6 +253,8 @@
   void do_FPIntrinsics(Intrinsic* x);
   void do_Reference_get(Intrinsic* x);
   void do_update_CRC32(Intrinsic* x);
+  void do_update_CRC32C(Intrinsic* x);
+  void do_vectorizedMismatch(Intrinsic* x);
 
   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);
@@ -474,7 +472,7 @@
     : _compilation(compilation)
     , _method(method)
     , _virtual_register_number(LIR_OprDesc::vreg_base)
-    , _vreg_flags(NULL, 0, num_vreg_flags) {
+    , _vreg_flags(num_vreg_flags) {
     init();
   }
 
diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp
index 82e162c..991daa0 100644
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp
@@ -88,7 +88,7 @@
  , _has_info(0)
  , _has_call(0)
  , _scope_value_cache(0) // initialized later with correct length
- , _interval_in_loop(0, 0) // initialized later with correct length
+ , _interval_in_loop(0)  // initialized later with correct length
  , _cached_blocks(*ir->linear_scan_order())
 #ifdef X86
  , _fpu_stack_allocator(NULL)
@@ -496,8 +496,8 @@
   }
 
   // initialize with correct length
-  _lir_ops = LIR_OpArray(num_instructions);
-  _block_of_op = BlockBeginArray(num_instructions);
+  _lir_ops = LIR_OpArray(num_instructions, num_instructions, NULL);
+  _block_of_op = BlockBeginArray(num_instructions, num_instructions, NULL);
 
   int op_id = 0;
   int idx = 0;
@@ -524,8 +524,8 @@
   assert(idx == num_instructions, "must match");
   assert(idx * 2 == op_id, "must match");
 
-  _has_call = BitMap(num_instructions); _has_call.clear();
-  _has_info = BitMap(num_instructions); _has_info.clear();
+  _has_call.initialize(num_instructions);
+  _has_info.initialize(num_instructions);
 }
 
 
@@ -568,8 +568,8 @@
   for (int i = 0; i < num_blocks; i++) {
     BlockBegin* block = block_at(i);
 
-    BitMap live_gen(live_size);  live_gen.clear();
-    BitMap live_kill(live_size); live_kill.clear();
+    ResourceBitMap live_gen(live_size);  live_gen.clear();
+    ResourceBitMap live_kill(live_size); live_kill.clear();
 
     if (block->is_set(BlockBegin::exception_entry_flag)) {
       // Phi functions at the begin of an exception handler are
@@ -715,8 +715,8 @@
 
     block->set_live_gen (live_gen);
     block->set_live_kill(live_kill);
-    block->set_live_in  (BitMap(live_size)); block->live_in().clear();
-    block->set_live_out (BitMap(live_size)); block->live_out().clear();
+    block->set_live_in  (ResourceBitMap(live_size)); block->live_in().clear();
+    block->set_live_out (ResourceBitMap(live_size)); block->live_out().clear();
 
     TRACE_LINEAR_SCAN(4, tty->print("live_gen  B%d ", block->block_id()); print_bitmap(block->live_gen()));
     TRACE_LINEAR_SCAN(4, tty->print("live_kill B%d ", block->block_id()); print_bitmap(block->live_kill()));
@@ -741,7 +741,7 @@
   bool change_occurred;
   bool change_occurred_in_block;
   int  iteration_count = 0;
-  BitMap live_out(live_set_size()); live_out.clear(); // scratch set for calculations
+  ResourceBitMap live_out(live_set_size()); live_out.clear(); // scratch set for calculations
 
   // Perform a backward dataflow analysis to compute live_out and live_in for each block.
   // The loop is executed until a fixpoint is reached (no changes in an iteration)
@@ -775,7 +775,7 @@
 
         if (!block->live_out().is_same(live_out)) {
           // A change occurred.  Swap the old and new live out sets to avoid copying.
-          BitMap temp = block->live_out();
+          ResourceBitMap temp = block->live_out();
           block->set_live_out(live_out);
           live_out = temp;
 
@@ -787,7 +787,7 @@
       if (iteration_count == 0 || change_occurred_in_block) {
         // live_in(block) is the union of live_gen(block) with (live_out(block) & !live_kill(block))
         // note: live_in has to be computed only in first iteration or if live_out has changed!
-        BitMap live_in = block->live_in();
+        ResourceBitMap live_in = block->live_in();
         live_in.set_from(block->live_out());
         live_in.set_difference(block->live_kill());
         live_in.set_union(block->live_gen());
@@ -826,7 +826,7 @@
 #endif
 
   // check that the live_in set of the first block is empty
-  BitMap live_in_args(ir()->start()->live_in().size());
+  ResourceBitMap live_in_args(ir()->start()->live_in().size());
   live_in_args.clear();
   if (!ir()->start()->live_in().is_same(live_in_args)) {
 #ifdef ASSERT
@@ -1317,7 +1317,7 @@
     assert(block_to   == instructions->at(instructions->length() - 1)->id(), "must be");
 
     // Update intervals for registers live at the end of this block;
-    BitMap live = block->live_out();
+    ResourceBitMap live = block->live_out();
     int size = (int)live.size();
     for (int number = (int)live.get_next_one_offset(0, size); number < size; number = (int)live.get_next_one_offset(number + 1, size)) {
       assert(live.at(number), "should not stop here otherwise");
@@ -1717,7 +1717,7 @@
 
   const int num_regs = num_virtual_regs();
   const int size = live_set_size();
-  const BitMap live_at_edge = to_block->live_in();
+  const ResourceBitMap live_at_edge = to_block->live_in();
 
   // visit all registers where the live_at_edge bit is set
   for (int r = (int)live_at_edge.get_next_one_offset(0, size); r < size; r = (int)live_at_edge.get_next_one_offset(r + 1, size)) {
@@ -1774,8 +1774,8 @@
 
   int num_blocks = block_count();
   MoveResolver move_resolver(this);
-  BitMap block_completed(num_blocks);  block_completed.clear();
-  BitMap already_resolved(num_blocks); already_resolved.clear();
+  ResourceBitMap block_completed(num_blocks);  block_completed.clear();
+  ResourceBitMap already_resolved(num_blocks); already_resolved.clear();
 
   int i;
   for (i = 0; i < num_blocks; i++) {
@@ -2507,7 +2507,8 @@
 void LinearScan::init_compute_debug_info() {
   // cache for frequently used scope values
   // (cpu registers and stack slots)
-  _scope_value_cache = ScopeValueArray((LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2, NULL);
+  int cache_size = (LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2;
+  _scope_value_cache = ScopeValueArray(cache_size, cache_size, NULL);
 }
 
 MonitorValue* LinearScan::location_for_monitor_index(int monitor_index) {
@@ -3042,7 +3043,7 @@
         insert_point++;
       }
     }
-    instructions->truncate(insert_point);
+    instructions->trunc_to(insert_point);
   }
 }
 
@@ -3396,7 +3397,7 @@
 
   for (int i = 0; i < num_blocks; i++) {
     BlockBegin* block = block_at(i);
-    BitMap live_at_edge = block->live_in();
+    ResourceBitMap live_at_edge = block->live_in();
 
     // visit all registers where the live_at_edge bit is set
     for (int r = (int)live_at_edge.get_next_one_offset(0, size); r < size; r = (int)live_at_edge.get_next_one_offset(r + 1, size)) {
@@ -3446,7 +3447,7 @@
   RegisterVerifier(LinearScan* allocator)
     : _allocator(allocator)
     , _work_list(16)
-    , _saved_states(BlockBegin::number_of_blocks(), NULL)
+    , _saved_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL)
   { }
 
   void verify(BlockBegin* start);
@@ -3748,7 +3749,7 @@
   }
 
 
-  BitMap used_regs(LinearScan::nof_regs + allocator()->frame_map()->argcount() + allocator()->max_spills());
+  ResourceBitMap used_regs(LinearScan::nof_regs + allocator()->frame_map()->argcount() + allocator()->max_spills());
   used_regs.clear();
   if (!_multiple_reads_allowed) {
     for (i = 0; i < _mapping_from.length(); i++) {
@@ -4452,7 +4453,7 @@
     new_use_pos_and_kinds.append(_use_pos_and_kinds.at(i));
   }
 
-  _use_pos_and_kinds.truncate(start_idx + 2);
+  _use_pos_and_kinds.trunc_to(start_idx + 2);
   result->_use_pos_and_kinds = _use_pos_and_kinds;
   _use_pos_and_kinds = new_use_pos_and_kinds;
 
@@ -5540,7 +5541,7 @@
     IntervalList* processed = _spill_intervals[reg];
     for (int i = 0; i < _spill_intervals[regHi]->length(); i++) {
       Interval* it = _spill_intervals[regHi]->at(i);
-      if (processed->find_from_end(it) == -1) {
+      if (processed->find(it) == -1) {
         remove_from_list(it);
         split_and_spill_interval(it);
       }
@@ -6211,7 +6212,7 @@
       _original_preds.clear();
       for (j = block->number_of_preds() - 1; j >= 0; j--) {
         BlockBegin* pred = block->pred_at(j);
-        if (_original_preds.index_of(pred) == -1) {
+        if (_original_preds.find(pred) == -1) {
           _original_preds.append(pred);
         }
       }
@@ -6231,7 +6232,7 @@
     }
     old_pos++;
   }
-  code->truncate(new_pos);
+  code->trunc_to(new_pos);
 
   DEBUG_ONLY(verify(code));
 }
@@ -6256,7 +6257,7 @@
           TRACE_LINEAR_SCAN(3, tty->print_cr("Deleting unconditional branch at end of block B%d", block->block_id()));
 
           // delete last branch instruction
-          instructions->truncate(instructions->length() - 1);
+          instructions->trunc_to(instructions->length() - 1);
 
         } else {
           LIR_Op* prev_op = instructions->at(instructions->length() - 2);
@@ -6295,7 +6296,7 @@
                 prev_branch->change_block(last_branch->block());
                 prev_branch->negate_cond();
                 prev_cmp->set_condition(prev_branch->cond());
-                instructions->truncate(instructions->length() - 1);
+                instructions->trunc_to(instructions->length() - 1);
                 // if we do change the condition, we have to change the cmove as well
                 if (prev_cmove != NULL) {
                   prev_cmove->set_condition(prev_branch->cond());
@@ -6316,7 +6317,7 @@
 
 void ControlFlowOptimizer::delete_jumps_to_return(BlockList* code) {
 #ifdef ASSERT
-  BitMap return_converted(BlockBegin::number_of_blocks());
+  ResourceBitMap return_converted(BlockBegin::number_of_blocks());
   return_converted.clear();
 #endif
 
@@ -6378,19 +6379,19 @@
       LIR_OpBranch* op_branch = instructions->at(j)->as_OpBranch();
 
       if (op_branch != NULL) {
-        assert(op_branch->block() == NULL || code->index_of(op_branch->block()) != -1, "branch target not valid");
-        assert(op_branch->ublock() == NULL || code->index_of(op_branch->ublock()) != -1, "branch target not valid");
+        assert(op_branch->block() == NULL || code->find(op_branch->block()) != -1, "branch target not valid");
+        assert(op_branch->ublock() == NULL || code->find(op_branch->ublock()) != -1, "branch target not valid");
       }
     }
 
     for (j = 0; j < block->number_of_sux() - 1; j++) {
       BlockBegin* sux = block->sux_at(j);
-      assert(code->index_of(sux) != -1, "successor not valid");
+      assert(code->find(sux) != -1, "successor not valid");
     }
 
     for (j = 0; j < block->number_of_preds() - 1; j++) {
       BlockBegin* pred = block->pred_at(j);
-      assert(code->index_of(pred) != -1, "successor not valid");
+      assert(code->find(pred) != -1, "successor not valid");
     }
   }
 }
diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.hpp b/hotspot/src/share/vm/c1/c1_LinearScan.hpp
index 7d296e3..00ed78f 100644
--- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp
@@ -44,18 +44,9 @@
 
 typedef GrowableArray<Interval*> IntervalArray;
 typedef GrowableArray<Interval*> IntervalList;
-
-define_array(IntervalsArray, IntervalList*)
-define_stack(IntervalsList, IntervalsArray)
-
-define_array(OopMapArray, OopMap*)
-define_stack(OopMapList, OopMapArray)
-
-define_array(ScopeValueArray, ScopeValue*)
-
-define_array(LIR_OpListArray, LIR_OpList*);
-define_stack(LIR_OpListStack, LIR_OpListArray);
-
+typedef GrowableArray<IntervalList*> IntervalsList;
+typedef GrowableArray<ScopeValue*> ScopeValueArray;
+typedef GrowableArray<LIR_OpList*> LIR_OpListStack;
 
 enum IntervalUseKind {
   // priority of use kinds must be ascending
@@ -67,9 +58,6 @@
   firstValidKind = 1,
   lastValidKind = 3
 };
-define_array(UseKindArray, IntervalUseKind)
-define_stack(UseKindStack, UseKindArray)
-
 
 enum IntervalKind {
   fixedKind = 0,  // interval pre-colored by LIR_Generator
@@ -152,8 +140,8 @@
 
   LIR_OpArray               _lir_ops;           // mapping from LIR_Op id to LIR_Op node
   BlockBeginArray           _block_of_op;       // mapping from LIR_Op id to the BlockBegin containing this instruction
-  BitMap                    _has_info;          // bit set for each LIR_Op id that has a CodeEmitInfo
-  BitMap                    _has_call;          // bit set for each LIR_Op id that destroys all caller save registers
+  ResourceBitMap            _has_info;          // bit set for each LIR_Op id that has a CodeEmitInfo
+  ResourceBitMap            _has_call;          // bit set for each LIR_Op id that destroys all caller save registers
   BitMap2D                  _interval_in_loop;  // bit set for each virtual register that is contained in each loop
 
   // cached debug info to prevent multiple creation of same object
@@ -619,7 +607,7 @@
   void   add_range(int from, int to);
   Interval* split(int split_pos);
   Interval* split_from_start(int split_pos);
-  void remove_first_use_pos()                    { _use_pos_and_kinds.truncate(_use_pos_and_kinds.length() - 2); }
+  void remove_first_use_pos()                    { _use_pos_and_kinds.trunc_to(_use_pos_and_kinds.length() - 2); }
 
   // test intersection
   bool   covers(int op_id, LIR_OpVisitState::OprMode mode) const;
diff --git a/hotspot/src/share/vm/c1/c1_Optimizer.cpp b/hotspot/src/share/vm/c1/c1_Optimizer.cpp
index 3e61edd..edc133a 100644
--- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp
+++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp
@@ -32,9 +32,7 @@
 #include "utilities/bitMap.inline.hpp"
 #include "compiler/compileLog.hpp"
 
-define_array(ValueSetArray, ValueSet*);
-define_stack(ValueSetList, ValueSetArray);
-
+typedef GrowableArray<ValueSet*> ValueSetList;
 
 Optimizer::Optimizer(IR* ir) {
   assert(ir->is_valid(), "IR must be valid");
@@ -584,8 +582,8 @@
 
   ValueSet* state()                               { return _set; }
   void      set_state_from (ValueSet* state)      { _set->set_from(state); }
-  ValueSet* state_for      (BlockBegin* block)    { return _block_states[block->block_id()]; }
-  void      set_state_for  (BlockBegin* block, ValueSet* stack) { _block_states[block->block_id()] = stack; }
+  ValueSet* state_for      (BlockBegin* block)    { return _block_states.at(block->block_id()); }
+  void      set_state_for  (BlockBegin* block, ValueSet* stack) { _block_states.at_put(block->block_id(), stack); }
   // Returns true if caused a change in the block's state.
   bool      merge_state_for(BlockBegin* block,
                             ValueSet*   incoming_state);
@@ -596,7 +594,7 @@
     : _opt(opt)
     , _set(new ValueSet())
     , _last_explicit_null_check(NULL)
-    , _block_states(BlockBegin::number_of_blocks(), NULL)
+    , _block_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL)
     , _work_list(new BlockList()) {
     _visitable_instructions = new ValueSet();
     _visitor.set_eliminator(this);
@@ -1165,19 +1163,19 @@
   // handlers and iterate over them as well
   int nblocks = BlockBegin::number_of_blocks();
   BlockList blocks(nblocks);
-  boolArray visited_block(nblocks, false);
+  boolArray visited_block(nblocks, nblocks, false);
 
   blocks.push(ir()->start());
-  visited_block[ir()->start()->block_id()] = true;
+  visited_block.at_put(ir()->start()->block_id(), true);
   for (int i = 0; i < blocks.length(); i++) {
-    BlockBegin* b = blocks[i];
+    BlockBegin* b = blocks.at(i);
     // exception handlers need to be treated as additional roots
     for (int e = b->number_of_exception_handlers(); e-- > 0; ) {
       BlockBegin* excp = b->exception_handler_at(e);
       int id = excp->block_id();
-      if (!visited_block[id]) {
+      if (!visited_block.at(id)) {
         blocks.push(excp);
-        visited_block[id] = true;
+        visited_block.at_put(id, true);
         nce.iterate(excp);
       }
     }
@@ -1186,9 +1184,9 @@
     for (int s = end->number_of_sux(); s-- > 0; ) {
       BlockBegin* next = end->sux_at(s);
       int id = next->block_id();
-      if (!visited_block[id]) {
+      if (!visited_block.at(id)) {
         blocks.push(next);
-        visited_block[id] = true;
+        visited_block.at_put(id, true);
       }
     }
   }
diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp
index 71e9de0..0ec8d49 100644
--- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp
+++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,8 +53,8 @@
 
 // Constructor
 RangeCheckEliminator::RangeCheckEliminator(IR *ir) :
-  _bounds(Instruction::number_of_instructions(), NULL),
-  _access_indexed_info(Instruction::number_of_instructions(), NULL)
+  _bounds(Instruction::number_of_instructions(), Instruction::number_of_instructions(), NULL),
+  _access_indexed_info(Instruction::number_of_instructions(), Instruction::number_of_instructions(), NULL)
 {
   _visitor.set_range_check_eliminator(this);
   _ir = ir;
@@ -303,28 +303,28 @@
   // Wrong type or NULL -> No bound
   if (!v || (!v->type()->as_IntType() && !v->type()->as_ObjectType())) return NULL;
 
-  if (!_bounds[v->id()]) {
+  if (!_bounds.at(v->id())) {
     // First (default) bound is calculated
     // Create BoundStack
-    _bounds[v->id()] = new BoundStack();
+    _bounds.at_put(v->id(), new BoundStack());
     _visitor.clear_bound();
     Value visit_value = v;
     visit_value->visit(&_visitor);
     Bound *bound = _visitor.bound();
     if (bound) {
-      _bounds[v->id()]->push(bound);
+      _bounds.at(v->id())->push(bound);
     }
-    if (_bounds[v->id()]->length() == 0) {
+    if (_bounds.at(v->id())->length() == 0) {
       assert(!(v->as_Constant() && v->type()->as_IntConstant()), "constants not handled here");
-      _bounds[v->id()]->push(new Bound());
+      _bounds.at(v->id())->push(new Bound());
     }
-  } else if (_bounds[v->id()]->length() == 0) {
+  } else if (_bounds.at(v->id())->length() == 0) {
     // To avoid endless loops, bound is currently in calculation -> nothing known about it
     return new Bound();
   }
 
   // Return bound
-  return _bounds[v->id()]->top();
+  return _bounds.at(v->id())->top();
 }
 
 // Update bound
@@ -353,28 +353,28 @@
     // No bound update for constants
     return;
   }
-  if (!_bounds[v->id()]) {
+  if (!_bounds.at(v->id())) {
     get_bound(v);
-    assert(_bounds[v->id()], "Now Stack must exist");
+    assert(_bounds.at(v->id()), "Now Stack must exist");
   }
   Bound *top = NULL;
-  if (_bounds[v->id()]->length() > 0) {
-    top = _bounds[v->id()]->top();
+  if (_bounds.at(v->id())->length() > 0) {
+    top = _bounds.at(v->id())->top();
   }
   if (top) {
     bound->and_op(top);
   }
-  _bounds[v->id()]->push(bound);
+  _bounds.at(v->id())->push(bound);
   pushed.append(v->id());
 }
 
 // Add instruction + idx for in block motion
 void RangeCheckEliminator::add_access_indexed_info(InstructionList &indices, int idx, Value instruction, AccessIndexed *ai) {
   int id = instruction->id();
-  AccessIndexedInfo *aii = _access_indexed_info[id];
+  AccessIndexedInfo *aii = _access_indexed_info.at(id);
   if (aii == NULL) {
     aii = new AccessIndexedInfo();
-    _access_indexed_info[id] = aii;
+    _access_indexed_info.at_put(id, aii);
     indices.append(instruction);
     aii->_min = idx;
     aii->_max = idx;
@@ -461,7 +461,7 @@
     if (_optimistic) {
       for (int i = 0; i < indices.length(); i++) {
         Instruction *index_instruction = indices.at(i);
-        AccessIndexedInfo *info = _access_indexed_info[index_instruction->id()];
+        AccessIndexedInfo *info = _access_indexed_info.at(index_instruction->id());
         assert(info != NULL, "Info must not be null");
 
         // if idx < 0, max > 0, max + idx may fall between 0 and
@@ -562,7 +562,7 @@
     // Clear data structures for next array
     for (int i = 0; i < indices.length(); i++) {
       Instruction *index_instruction = indices.at(i);
-      _access_indexed_info[index_instruction->id()] = NULL;
+      _access_indexed_info.at_put(index_instruction->id(), NULL);
     }
     indices.clear();
   }
@@ -1005,7 +1005,7 @@
 
   // Reset stack
   for (int i=0; i<pushed.length(); i++) {
-    _bounds[pushed[i]]->pop();
+    _bounds.at(pushed.at(i))->pop();
   }
 }
 
@@ -1051,7 +1051,7 @@
 #endif
 
 // Verification or the IR
-RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), false) {
+RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), false) {
   this->_ir = ir;
   ir->iterate_linear_scan_order(this);
 }
@@ -1146,14 +1146,14 @@
   if (start == end) return start != dont_use;
   // Simple BSF from start to end
   //  BlockBeginList _current;
-  for (int i=0; i<_used.length(); i++) {
-    _used[i] = false;
+  for (int i=0; i < _used.length(); i++) {
+    _used.at_put(i, false);
   }
-  _current.truncate(0);
-  _successors.truncate(0);
+  _current.trunc_to(0);
+  _successors.trunc_to(0);
   if (start != dont_use) {
     _current.push(start);
-    _used[start->block_id()] = true;
+    _used.at_put(start->block_id(), true);
   }
 
   //  BlockBeginList _successors;
@@ -1180,17 +1180,17 @@
       }
     }
     for (int i=0; i<_successors.length(); i++) {
-      BlockBegin *sux = _successors[i];
+      BlockBegin *sux = _successors.at(i);
       assert(sux != NULL, "Successor must not be NULL!");
       if (sux == end) {
         return true;
       }
-      if (sux != dont_use && !_used[sux->block_id()]) {
-        _used[sux->block_id()] = true;
+      if (sux != dont_use && !_used.at(sux->block_id())) {
+        _used.at_put(sux->block_id(), true);
         _current.push(sux);
       }
     }
-    _successors.truncate(0);
+    _successors.trunc_to(0);
   }
 
   return false;
diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp
index 0552125..0fb97a1 100644
--- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp
+++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,10 +40,8 @@
   bool _optimistic; // Insert predicates and deoptimize when they fail
   IR *_ir;
 
-  define_array(BlockBeginArray, BlockBegin*)
-  define_stack(BlockBeginList, BlockBeginArray)
-  define_stack(IntegerStack, intArray)
-  define_array(IntegerMap, IntegerStack*)
+  typedef GrowableArray<BlockBegin*> BlockBeginList;
+  typedef GrowableArray<int> IntegerStack;
 
   class Verification : public BlockClosure {
   // RangeCheckEliminator::Verification should never get instatiated on the heap.
@@ -180,13 +178,10 @@
   void add_assertions(Bound *bound, Instruction *instruction, Instruction *position);
 #endif
 
-  define_array(BoundArray, Bound *)
-  define_stack(BoundStack, BoundArray)
-  define_array(BoundMap, BoundStack *)
-  define_array(AccessIndexedArray, AccessIndexed *)
-  define_stack(AccessIndexedList, AccessIndexedArray)
-  define_array(InstructionArray, Instruction *)
-  define_stack(InstructionList, InstructionArray)
+  typedef GrowableArray<Bound*> BoundStack;
+  typedef GrowableArray<BoundStack*> BoundMap;
+  typedef GrowableArray<AccessIndexed*> AccessIndexedList;
+  typedef GrowableArray<Instruction*> InstructionList;
 
   class AccessIndexedInfo : public CompilationResourceObj  {
   public:
@@ -195,7 +190,7 @@
     int _max;
   };
 
-  define_array(AccessIndexedInfoArray, AccessIndexedInfo *)
+  typedef GrowableArray<AccessIndexedInfo*> AccessIndexedInfoArray;
   BoundMap _bounds; // Mapping from Instruction's id to current bound
   AccessIndexedInfoArray _access_indexed_info; // Mapping from Instruction's id to AccessIndexedInfo for in block motion
   Visitor _visitor;
diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp
index 56531ae..be57ef5 100644
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp
@@ -318,11 +318,15 @@
   FUNCTION_CASE(entry, TRACE_TIME_METHOD);
 #endif
   FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32());
+  FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32C());
+  FUNCTION_CASE(entry, StubRoutines::vectorizedMismatch());
   FUNCTION_CASE(entry, StubRoutines::dexp());
   FUNCTION_CASE(entry, StubRoutines::dlog());
+  FUNCTION_CASE(entry, StubRoutines::dlog10());
   FUNCTION_CASE(entry, StubRoutines::dpow());
   FUNCTION_CASE(entry, StubRoutines::dsin());
   FUNCTION_CASE(entry, StubRoutines::dcos());
+  FUNCTION_CASE(entry, StubRoutines::dtan());
 
 #undef FUNCTION_CASE
 
diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.cpp b/hotspot/src/share/vm/c1/c1_ValueMap.cpp
index fb52819..fb277a5 100644
--- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 
 ValueMap::ValueMap()
   : _nesting(0)
-  , _entries(ValueMapInitialSize, NULL)
+  , _entries(ValueMapInitialSize, ValueMapInitialSize, NULL)
   , _killed_values()
   , _entry_count(0)
 {
@@ -56,7 +56,7 @@
 
 ValueMap::ValueMap(ValueMap* old)
   : _nesting(old->_nesting + 1)
-  , _entries(old->_entries.length())
+  , _entries(old->_entries.length(), old->_entries.length(), NULL)
   , _killed_values()
   , _entry_count(old->_entry_count)
 {
@@ -72,7 +72,7 @@
   int new_size = old_size * 2 + 1;
 
   ValueMapEntryList worklist(8);
-  ValueMapEntryArray new_entries(new_size, NULL);
+  ValueMapEntryArray new_entries(new_size, new_size, NULL);
   int new_entry_count = 0;
 
   TRACE_VALUE_NUMBERING(tty->print_cr("increasing table size from %d to %d", old_size, new_size));
@@ -486,7 +486,7 @@
 
 GlobalValueNumbering::GlobalValueNumbering(IR* ir)
   : _current_map(NULL)
-  , _value_maps(ir->linear_scan_order()->length(), NULL)
+  , _value_maps(ir->linear_scan_order()->length(), ir->linear_scan_order()->length(), NULL)
   , _compilation(ir->compilation())
 {
   TRACE_VALUE_NUMBERING(tty->print_cr("****** start of global value numbering"));
diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.hpp b/hotspot/src/share/vm/c1/c1_ValueMap.hpp
index 3b3b02e..e2e1c1b 100644
--- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,8 +53,8 @@
   void set_next(ValueMapEntry* next) { _next = next; }
 };
 
-define_array(ValueMapEntryArray, ValueMapEntry*)
-define_stack(ValueMapEntryList, ValueMapEntryArray)
+typedef GrowableArray<ValueMapEntry*> ValueMapEntryArray;
+typedef GrowableArray<ValueMapEntry*> ValueMapEntryList;
 
 // ValueMap implements nested hash tables for value numbering.  It
 // maintains a set _killed_values which represents the instructions
@@ -129,8 +129,7 @@
 #endif
 };
 
-define_array(ValueMapArray, ValueMap*)
-
+typedef GrowableArray<ValueMap*> ValueMapArray;
 
 class ValueNumberingVisitor: public InstructionVisitor {
  protected:
diff --git a/hotspot/src/share/vm/c1/c1_ValueSet.hpp b/hotspot/src/share/vm/c1/c1_ValueSet.hpp
index 2e8dd09..5053812 100644
--- a/hotspot/src/share/vm/c1/c1_ValueSet.hpp
+++ b/hotspot/src/share/vm/c1/c1_ValueSet.hpp
@@ -36,7 +36,7 @@
 
 class ValueSet: public CompilationResourceObj {
  private:
-  BitMap _map;
+  ResourceBitMap _map;
 
  public:
   ValueSet();
diff --git a/hotspot/src/share/vm/c1/c1_ValueStack.cpp b/hotspot/src/share/vm/c1/c1_ValueStack.cpp
index fcf8ba2..1394511 100644
--- a/hotspot/src/share/vm/c1/c1_ValueStack.cpp
+++ b/hotspot/src/share/vm/c1/c1_ValueStack.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 , _caller_state(caller_state)
 , _bci(-99)
 , _kind(Parsing)
-, _locals(scope->method()->max_locals(), NULL)
+, _locals(scope->method()->max_locals(), scope->method()->max_locals(), NULL)
 , _stack(scope->method()->max_stack())
 , _locks()
 {
@@ -178,7 +178,7 @@
 
   ValueType* t = stack_at(index)->type();
   Value phi = new Phi(t, b, -index - 1);
-  _stack[index] = phi;
+  _stack.at_put(index, phi);
 
   assert(!t->is_double_word() || _stack.at(index + 1) == NULL, "hi-word of doubleword value must be NULL");
 }
@@ -225,7 +225,7 @@
   if (locals_size() > 0) {
     InstructionPrinter ip;
     for (int i = 0; i < locals_size();) {
-      Value l = _locals[i];
+      Value l = _locals.at(i);
       tty->print("local %d ", i);
       if (l == NULL) {
         tty->print("null");
diff --git a/hotspot/src/share/vm/c1/c1_globals.cpp b/hotspot/src/share/vm/c1/c1_globals.cpp
index 18e324f..58bd059 100644
--- a/hotspot/src/share/vm/c1/c1_globals.cpp
+++ b/hotspot/src/share/vm/c1/c1_globals.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,4 +25,12 @@
 #include "precompiled.hpp"
 #include "c1/c1_globals.hpp"
 
-C1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG, IGNORE_RANGE, IGNORE_CONSTRAINT)
+C1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \
+         MATERIALIZE_PD_DEVELOPER_FLAG, \
+         MATERIALIZE_PRODUCT_FLAG, \
+         MATERIALIZE_PD_PRODUCT_FLAG, \
+         MATERIALIZE_DIAGNOSTIC_FLAG, \
+         MATERIALIZE_NOTPRODUCT_FLAG, \
+         IGNORE_RANGE, \
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp
index ad6548e..a1e8ce4 100644
--- a/hotspot/src/share/vm/c1/c1_globals.hpp
+++ b/hotspot/src/share/vm/c1/c1_globals.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,15 @@
 //
 // Defines all global flags used by the client compiler.
 //
-#define C1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \
+#define C1_FLAGS(develop, \
+                 develop_pd, \
+                 product, \
+                 product_pd, \
+                 diagnostic, \
+                 notproduct, \
+                 range, \
+                 constraint, \
+                 writeable) \
                                                                             \
   /* Printing */                                                            \
   notproduct(bool, PrintC1Statistics, false,                                \
@@ -176,7 +184,7 @@
   product(bool, InlineSynchronizedMethods, true,                            \
           "Inline synchronized methods")                                    \
                                                                             \
-  develop(bool, InlineNIOCheckIndex, true,                                  \
+  diagnostic(bool, InlineNIOCheckIndex, true,                               \
           "Intrinsify java.nio.Buffer.checkIndex")                          \
                                                                             \
   develop(bool, CanonicalizeNodes, true,                                    \
@@ -350,6 +358,7 @@
          DECLARE_DIAGNOSTIC_FLAG, \
          DECLARE_NOTPRODUCT_FLAG, \
          IGNORE_RANGE, \
-         IGNORE_CONSTRAINT)
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
 
 #endif // SHARE_VM_C1_C1_GLOBALS_HPP
diff --git a/hotspot/src/share/vm/ci/ciConstant.hpp b/hotspot/src/share/vm/ci/ciConstant.hpp
index 5af058f..5136533 100644
--- a/hotspot/src/share/vm/ci/ciConstant.hpp
+++ b/hotspot/src/share/vm/ci/ciConstant.hpp
@@ -124,6 +124,9 @@
     }
   }
 
+  bool is_valid() const {
+    return basic_type() != T_ILLEGAL;
+  }
   // Debugging output
   void print();
 };
diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp
index 697c559..001c7fd 100644
--- a/hotspot/src/share/vm/ci/ciEnv.cpp
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp
@@ -1055,14 +1055,14 @@
       if (entry_bci == InvocationEntryBci) {
         if (TieredCompilation) {
           // If there is an old version we're done with it
-          nmethod* old = method->code();
+          CompiledMethod* old = method->code();
           if (TraceMethodReplacement && old != NULL) {
             ResourceMark rm;
             char *method_name = method->name_and_sig_as_C_string();
             tty->print_cr("Replacing method %s", method_name);
           }
           if (old != NULL) {
-            old->make_not_entrant();
+            old->make_not_used();
           }
         }
         if (TraceNMethodInstalls) {
diff --git a/hotspot/src/share/vm/ci/ciField.cpp b/hotspot/src/share/vm/ci/ciField.cpp
index 0078f44..4d37c92 100644
--- a/hotspot/src/share/vm/ci/ciField.cpp
+++ b/hotspot/src/share/vm/ci/ciField.cpp
@@ -235,97 +235,78 @@
   _holder = CURRENT_ENV->get_instance_klass(fd->field_holder());
 
   // Check to see if the field is constant.
-  bool is_final = this->is_final();
-  bool is_stable = FoldStableValues && this->is_stable();
-  if (_holder->is_initialized() && (is_final || is_stable)) {
-    if (!this->is_static()) {
-      // A field can be constant if it's a final static field or if
-      // it's a final non-static field of a trusted class (classes in
-      // java.lang.invoke and sun.invoke packages and subpackages).
-      if (is_stable || trust_final_non_static_fields(_holder)) {
-        _is_constant = true;
-        return;
-      }
-      _is_constant = false;
-      return;
-    }
-
-    // This field just may be constant.  The only case where it will
-    // not be constant is when the field is a *special* static&final field
-    // whose value may change.  The three examples are java.lang.System.in,
-    // java.lang.System.out, and java.lang.System.err.
-
-    KlassHandle k = _holder->get_Klass();
-    assert( SystemDictionary::System_klass() != NULL, "Check once per vm");
-    if( k() == SystemDictionary::System_klass() ) {
-      // Check offsets for case 2: System.in, System.out, or System.err
-      if( _offset == java_lang_System::in_offset_in_bytes()  ||
-          _offset == java_lang_System::out_offset_in_bytes() ||
-          _offset == java_lang_System::err_offset_in_bytes() ) {
-        _is_constant = false;
-        return;
-      }
-    }
-
-    Handle mirror = k->java_mirror();
-
-    switch(type()->basic_type()) {
-    case T_BYTE:
-      _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset));
-      break;
-    case T_CHAR:
-      _constant_value = ciConstant(type()->basic_type(), mirror->char_field(_offset));
-      break;
-    case T_SHORT:
-      _constant_value = ciConstant(type()->basic_type(), mirror->short_field(_offset));
-      break;
-    case T_BOOLEAN:
-      _constant_value = ciConstant(type()->basic_type(), mirror->bool_field(_offset));
-      break;
-    case T_INT:
-      _constant_value = ciConstant(type()->basic_type(), mirror->int_field(_offset));
-      break;
-    case T_FLOAT:
-      _constant_value = ciConstant(mirror->float_field(_offset));
-      break;
-    case T_DOUBLE:
-      _constant_value = ciConstant(mirror->double_field(_offset));
-      break;
-    case T_LONG:
-      _constant_value = ciConstant(mirror->long_field(_offset));
-      break;
-    case T_OBJECT:
-    case T_ARRAY:
-      {
-        oop o = mirror->obj_field(_offset);
-
-        // A field will be "constant" if it is known always to be
-        // a non-null reference to an instance of a particular class,
-        // or to a particular array.  This can happen even if the instance
-        // or array is not perm.  In such a case, an "unloaded" ciArray
-        // or ciInstance is created.  The compiler may be able to use
-        // information about the object's class (which is exact) or length.
-
-        if (o == NULL) {
-          _constant_value = ciConstant(type()->basic_type(), ciNullObject::make());
-        } else {
-          _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o));
-          assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning");
+  Klass* k = _holder->get_Klass();
+  bool is_stable_field = FoldStableValues && is_stable();
+  if (is_final() || is_stable_field) {
+    if (is_static()) {
+      // This field just may be constant.  The only case where it will
+      // not be constant is when the field is a *special* static & final field
+      // whose value may change.  The three examples are java.lang.System.in,
+      // java.lang.System.out, and java.lang.System.err.
+      assert(SystemDictionary::System_klass() != NULL, "Check once per vm");
+      if (k == SystemDictionary::System_klass()) {
+        // Check offsets for case 2: System.in, System.out, or System.err
+        if( _offset == java_lang_System::in_offset_in_bytes()  ||
+            _offset == java_lang_System::out_offset_in_bytes() ||
+            _offset == java_lang_System::err_offset_in_bytes() ) {
+          _is_constant = false;
+          return;
         }
       }
-    }
-    if (is_stable && _constant_value.is_null_or_zero()) {
-      // It is not a constant after all; treat it as uninitialized.
-      _is_constant = false;
-    } else {
       _is_constant = true;
+    } else {
+      // An instance field can be constant if it's a final static field or if
+      // it's a final non-static field of a trusted class (classes in
+      // java.lang.invoke and sun.invoke packages and subpackages).
+      _is_constant = is_stable_field || trust_final_non_static_fields(_holder);
     }
   } else {
-    _is_constant = false;
+    // For CallSite objects treat the target field as a compile time constant.
+    assert(SystemDictionary::CallSite_klass() != NULL, "should be already initialized");
+    if (k == SystemDictionary::CallSite_klass() &&
+        _offset == java_lang_invoke_CallSite::target_offset_in_bytes()) {
+      _is_constant = true;
+    } else {
+      // Non-final & non-stable fields are not constants.
+      _is_constant = false;
+    }
   }
 }
 
 // ------------------------------------------------------------------
+// ciField::constant_value
+// Get the constant value of a this static field.
+ciConstant ciField::constant_value() {
+  assert(is_static() && is_constant(), "illegal call to constant_value()");
+  if (!_holder->is_initialized()) {
+    return ciConstant(); // Not initialized yet
+  }
+  if (_constant_value.basic_type() == T_ILLEGAL) {
+    // Static fields are placed in mirror objects.
+    VM_ENTRY_MARK;
+    ciInstance* mirror = CURRENT_ENV->get_instance(_holder->get_Klass()->java_mirror());
+    _constant_value = mirror->field_value_impl(type()->basic_type(), offset());
+  }
+  if (FoldStableValues && is_stable() && _constant_value.is_null_or_zero()) {
+    return ciConstant();
+  }
+  return _constant_value;
+}
+
+// ------------------------------------------------------------------
+// ciField::constant_value_of
+// Get the constant value of non-static final field in the given object.
+ciConstant ciField::constant_value_of(ciObject* object) {
+  assert(!is_static() && is_constant(), "only if field is non-static constant");
+  assert(object->is_instance(), "must be instance");
+  ciConstant field_value = object->as_instance()->field_value(this);
+  if (FoldStableValues && is_stable() && field_value.is_null_or_zero()) {
+    return ciConstant();
+  }
+  return field_value;
+}
+
+// ------------------------------------------------------------------
 // ciField::compute_type
 //
 // Lazily compute the type, if it is an instance klass.
diff --git a/hotspot/src/share/vm/ci/ciField.hpp b/hotspot/src/share/vm/ci/ciField.hpp
index dd07a99..f30e714 100644
--- a/hotspot/src/share/vm/ci/ciField.hpp
+++ b/hotspot/src/share/vm/ci/ciField.hpp
@@ -62,7 +62,7 @@
   void initialize_from(fieldDescriptor* fd);
 
 public:
-  ciFlags flags() { return _flags; }
+  ciFlags flags() const { return _flags; }
 
   // Of which klass is this field a member?
   //
@@ -89,13 +89,13 @@
   //
   //   In that case the declared holder of f would be B and
   //   the canonical holder of f would be A.
-  ciInstanceKlass* holder() { return _holder; }
+  ciInstanceKlass* holder() const { return _holder; }
 
   // Name of this field?
-  ciSymbol* name() { return _name; }
+  ciSymbol* name() const { return _name; }
 
   // Signature of this field?
-  ciSymbol* signature() { return _signature; }
+  ciSymbol* signature() const { return _signature; }
 
   // Of what type is this field?
   ciType* type() { return (_type == NULL) ? compute_type() : _type; }
@@ -107,13 +107,13 @@
   int size_in_bytes() { return type2aelembytes(layout_type()); }
 
   // What is the offset of this field?
-  int offset() {
+  int offset() const {
     assert(_offset >= 1, "illegal call to offset()");
     return _offset;
   }
 
   // Same question, explicit units.  (Fields are aligned to the byte level.)
-  int offset_in_bytes() {
+  int offset_in_bytes() const {
     return offset();
   }
 
@@ -127,31 +127,27 @@
   //
   // Clarification: A field is considered constant if:
   //   1. The field is both static and final
-  //   2. The canonical holder of the field has undergone
-  //      static initialization.
-  //   3. The field is not one of the special static/final
+  //   2. The field is not one of the special static/final
   //      non-constant fields.  These are java.lang.System.in
   //      and java.lang.System.out.  Abomination.
   //
   // A field is also considered constant if it is marked @Stable
   // and is non-null (or non-zero, if a primitive).
-  // For non-static fields, the null/zero check must be
-  // arranged by the user, as constant_value().is_null_or_zero().
-  bool is_constant() { return _is_constant; }
+  //
+  // A user should also check the field value (constant_value().is_valid()), since
+  // constant fields of non-initialized classes don't have values yet.
+  bool is_constant() const { return _is_constant; }
 
-  // Get the constant value of this field.
-  ciConstant constant_value() {
-    assert(is_static() && is_constant(), "illegal call to constant_value()");
-    return _constant_value;
+  // Get the constant value of the static field.
+  ciConstant constant_value();
+
+  bool is_static_constant() {
+    return is_static() && is_constant() && constant_value().is_valid();
   }
 
   // Get the constant value of non-static final field in the given
   // object.
-  ciConstant constant_value_of(ciObject* object) {
-    assert(!is_static() && is_constant(), "only if field is non-static constant");
-    assert(object->is_instance(), "must be instance");
-    return object->as_instance()->field_value(this);
-  }
+  ciConstant constant_value_of(ciObject* object);
 
   // Check for link time errors.  Accessing a field from a
   // certain class via a certain bytecode may or may not be legal.
@@ -165,14 +161,14 @@
                  Bytecodes::Code bc);
 
   // Java access flags
-  bool is_public      () { return flags().is_public(); }
-  bool is_private     () { return flags().is_private(); }
-  bool is_protected   () { return flags().is_protected(); }
-  bool is_static      () { return flags().is_static(); }
-  bool is_final       () { return flags().is_final(); }
-  bool is_stable      () { return flags().is_stable(); }
-  bool is_volatile    () { return flags().is_volatile(); }
-  bool is_transient   () { return flags().is_transient(); }
+  bool is_public      () const { return flags().is_public(); }
+  bool is_private     () const { return flags().is_private(); }
+  bool is_protected   () const { return flags().is_protected(); }
+  bool is_static      () const { return flags().is_static(); }
+  bool is_final       () const { return flags().is_final(); }
+  bool is_stable      () const { return flags().is_stable(); }
+  bool is_volatile    () const { return flags().is_volatile(); }
+  bool is_transient   () const { return flags().is_transient(); }
 
   bool is_call_site_target() {
     ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();
diff --git a/hotspot/src/share/vm/ci/ciInstance.cpp b/hotspot/src/share/vm/ci/ciInstance.cpp
index f276a53..d2073ab 100644
--- a/hotspot/src/share/vm/ci/ciInstance.cpp
+++ b/hotspot/src/share/vm/ci/ciInstance.cpp
@@ -56,49 +56,21 @@
 }
 
 // ------------------------------------------------------------------
-// ciInstance::field_value
-//
-// Constant value of a field.
-ciConstant ciInstance::field_value(ciField* field) {
-  assert(is_loaded(), "invalid access - must be loaded");
-  assert(field->holder()->is_loaded(), "invalid access - holder must be loaded");
-  assert(klass()->is_subclass_of(field->holder()), "invalid access - must be subclass");
-
-  VM_ENTRY_MARK;
-  ciConstant result;
+// ciInstance::field_value_impl
+ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) {
   Handle obj = get_oop();
   assert(!obj.is_null(), "bad oop");
-  BasicType field_btype = field->type()->basic_type();
-  int offset = field->offset();
-
   switch(field_btype) {
-  case T_BYTE:
-    return ciConstant(field_btype, obj->byte_field(offset));
-    break;
-  case T_CHAR:
-    return ciConstant(field_btype, obj->char_field(offset));
-    break;
-  case T_SHORT:
-    return ciConstant(field_btype, obj->short_field(offset));
-    break;
-  case T_BOOLEAN:
-    return ciConstant(field_btype, obj->bool_field(offset));
-    break;
-  case T_INT:
-    return ciConstant(field_btype, obj->int_field(offset));
-    break;
-  case T_FLOAT:
-    return ciConstant(obj->float_field(offset));
-    break;
-  case T_DOUBLE:
-    return ciConstant(obj->double_field(offset));
-    break;
-  case T_LONG:
-    return ciConstant(obj->long_field(offset));
-    break;
-  case T_OBJECT:
-  case T_ARRAY:
-    {
+    case T_BYTE:    return ciConstant(field_btype, obj->byte_field(offset));
+    case T_CHAR:    return ciConstant(field_btype, obj->char_field(offset));
+    case T_SHORT:   return ciConstant(field_btype, obj->short_field(offset));
+    case T_BOOLEAN: return ciConstant(field_btype, obj->bool_field(offset));
+    case T_INT:     return ciConstant(field_btype, obj->int_field(offset));
+    case T_FLOAT:   return ciConstant(obj->float_field(offset));
+    case T_DOUBLE:  return ciConstant(obj->double_field(offset));
+    case T_LONG:    return ciConstant(obj->long_field(offset));
+    case T_OBJECT:  // fall through
+    case T_ARRAY: {
       oop o = obj->obj_field(offset);
 
       // A field will be "constant" if it is known always to be
@@ -115,12 +87,23 @@
       }
     }
   }
-  ShouldNotReachHere();
-  // to shut up the compiler
+  fatal("no field value: %s", type2name(field_btype));
   return ciConstant();
 }
 
 // ------------------------------------------------------------------
+// ciInstance::field_value
+//
+// Constant value of a field.
+ciConstant ciInstance::field_value(ciField* field) {
+  assert(is_loaded(), "invalid access - must be loaded");
+  assert(field->holder()->is_loaded(), "invalid access - holder must be loaded");
+  assert(field->is_static() || klass()->is_subclass_of(field->holder()), "invalid access - must be subclass");
+
+  GUARDED_VM_ENTRY(return field_value_impl(field->type()->basic_type(), field->offset());)
+}
+
+// ------------------------------------------------------------------
 // ciInstance::field_value_by_offset
 //
 // Constant value of a field at the specified offset.
diff --git a/hotspot/src/share/vm/ci/ciInstance.hpp b/hotspot/src/share/vm/ci/ciInstance.hpp
index a33aabb..96c470e 100644
--- a/hotspot/src/share/vm/ci/ciInstance.hpp
+++ b/hotspot/src/share/vm/ci/ciInstance.hpp
@@ -36,6 +36,7 @@
 // instance of java.lang.Object.
 class ciInstance : public ciObject {
   CI_PACKAGE_ACCESS
+  friend class ciField;
 
 protected:
   ciInstance(instanceHandle h_i) : ciObject(h_i) {
@@ -50,6 +51,8 @@
 
   void print_impl(outputStream* st);
 
+  ciConstant field_value_impl(BasicType field_btype, int offset);
+
 public:
   // If this object is a java mirror, return the corresponding type.
   // Otherwise, return NULL.
diff --git a/hotspot/src/share/vm/ci/ciKlass.cpp b/hotspot/src/share/vm/ci/ciKlass.cpp
index 75c3c14..ab980fa 100644
--- a/hotspot/src/share/vm/ci/ciKlass.cpp
+++ b/hotspot/src/share/vm/ci/ciKlass.cpp
@@ -88,12 +88,7 @@
   assert(this->is_loaded(), "must be loaded: %s", this->name()->as_quoted_ascii());
   assert(that->is_loaded(), "must be loaded: %s", that->name()->as_quoted_ascii());
 
-  VM_ENTRY_MARK;
-  Klass* this_klass = get_Klass();
-  Klass* that_klass = that->get_Klass();
-  bool result = this_klass->is_subclass_of(that_klass);
-
-  return result;
+  GUARDED_VM_ENTRY(return get_Klass()->is_subclass_of(that->get_Klass());)
 }
 
 // ------------------------------------------------------------------
diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp
index cb98f25..8294024 100644
--- a/hotspot/src/share/vm/ci/ciMethod.cpp
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -202,6 +202,7 @@
   _code = (address)arena->Amalloc(code_size());
   memcpy(_code, me->code_base(), code_size());
 
+#if INCLUDE_JVMTI
   // Revert any breakpoint bytecodes in ci's copy
   if (me->number_of_breakpoints() > 0) {
     BreakpointInfo* bp = me->method_holder()->breakpoints();
@@ -211,6 +212,7 @@
       }
     }
   }
+#endif
 
   // And load the exception table.
   ExceptionTable exc_table(me);
@@ -441,12 +443,12 @@
 // gc'ing an interpreter frame we need to use its viewpoint  during
 // OSR when loading the locals.
 
-BitMap ciMethod::live_local_oops_at_bci(int bci) {
+ResourceBitMap ciMethod::live_local_oops_at_bci(int bci) {
   VM_ENTRY_MARK;
   InterpreterOopMap mask;
   OopMapCache::compute_one_oop_map(get_Method(), bci, &mask);
   int mask_size = max_locals();
-  BitMap result(mask_size);
+  ResourceBitMap result(mask_size);
   result.clear();
   int i;
   for (i = 0; i < mask_size ; i++ ) {
@@ -461,7 +463,7 @@
 // ciMethod::bci_block_start
 //
 // Marks all bcis where a new basic block starts
-const BitMap ciMethod::bci_block_start() {
+const BitMap& ciMethod::bci_block_start() {
   check_is_loaded();
   if (_liveness == NULL) {
     // Create the liveness analyzer.
@@ -1115,7 +1117,7 @@
 int ciMethod::comp_level() {
   check_is_loaded();
   VM_ENTRY_MARK;
-  nmethod* nm = get_Method()->code();
+  CompiledMethod* nm = get_Method()->code();
   if (nm != NULL) return nm->comp_level();
   return 0;
 }
@@ -1150,7 +1152,7 @@
 int ciMethod::instructions_size() {
   if (_instructions_size == -1) {
     GUARDED_VM_ENTRY(
-                     nmethod* code = get_Method()->code();
+                     CompiledMethod* code = get_Method()->code();
                      if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) {
                        _instructions_size = code->insts_end() - code->verified_entry_point();
                      } else {
@@ -1165,7 +1167,7 @@
 // ciMethod::log_nmethod_identity
 void ciMethod::log_nmethod_identity(xmlStream* log) {
   GUARDED_VM_ENTRY(
-    nmethod* code = get_Method()->code();
+    CompiledMethod* code = get_Method()->code();
     if (code != NULL) {
       code->log_identity(log);
     }
diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp
index 6e350b4..7a56f1c 100644
--- a/hotspot/src/share/vm/ci/ciMethod.hpp
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp
@@ -36,7 +36,6 @@
 
 class ciMethodBlocks;
 class MethodLiveness;
-class BitMap;
 class Arena;
 class BCEscapeAnalyzer;
 class InlineTree;
@@ -233,10 +232,10 @@
   // used when gc'ing an interpreter frame we need to use its viewpoint
   // during OSR when loading the locals.
 
-  BitMap  live_local_oops_at_bci(int bci);
+  ResourceBitMap live_local_oops_at_bci(int bci);
 
 #ifdef COMPILER1
-  const BitMap  bci_block_start();
+  const BitMap& bci_block_start();
 #endif
 
   ciTypeFlow*   get_flow_analysis();
diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp
index 65e77c1..8e3e6fb 100644
--- a/hotspot/src/share/vm/ci/ciReplay.cpp
+++ b/hotspot/src/share/vm/ci/ciReplay.cpp
@@ -546,13 +546,13 @@
       }
     }
     // Make sure the existence of a prior compile doesn't stop this one
-    nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code();
+    CompiledMethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code();
     if (nm != NULL) {
       nm->make_not_entrant();
     }
     replay_state = this;
     CompileBroker::compile_method(method, entry_bci, comp_level,
-                                  methodHandle(), 0, "replay", THREAD);
+                                  methodHandle(), 0, CompileTask::Reason_Replay, THREAD);
     replay_state = NULL;
     reset();
   }
diff --git a/hotspot/src/share/vm/ci/ciStreams.cpp b/hotspot/src/share/vm/ci/ciStreams.cpp
index 76520fd..a4eaf47 100644
--- a/hotspot/src/share/vm/ci/ciStreams.cpp
+++ b/hotspot/src/share/vm/ci/ciStreams.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -361,14 +361,14 @@
 ciMethod* ciBytecodeStream::get_method(bool& will_link, ciSignature* *declared_signature_result) {
   VM_ENTRY_MARK;
   ciEnv* env = CURRENT_ENV;
-  constantPoolHandle cpool(_method->get_Method()->constants());
+  constantPoolHandle cpool(THREAD, _method->get_Method()->constants());
   ciMethod* m = env->get_method_by_index(cpool, get_method_index(), cur_bc(), _holder);
   will_link = m->is_loaded();
 
   // Use the MethodType stored in the CP cache to create a signature
   // with correct types (in respect to class loaders).
   if (has_method_type()) {
-    ciSymbol*     sig_sym     = env->get_symbol(cpool->symbol_at(get_method_signature_index()));
+    ciSymbol*     sig_sym     = env->get_symbol(cpool->symbol_at(get_method_signature_index(cpool)));
     ciKlass*      pool_holder = env->get_klass(cpool->pool_holder());
     ciMethodType* method_type = get_method_type();
     ciSignature* declared_signature = new (env->arena()) ciSignature(pool_holder, sig_sym, method_type);
@@ -465,9 +465,8 @@
 // Get the constant pool index of the signature of the method
 // referenced by the current bytecode.  Used for generating
 // deoptimization information.
-int ciBytecodeStream::get_method_signature_index() {
+int ciBytecodeStream::get_method_signature_index(const constantPoolHandle& cpool) {
   GUARDED_VM_ENTRY(
-    ConstantPool* cpool = _holder->get_instanceKlass()->constants();
     const int method_index = get_method_index();
     const int name_and_type_index = cpool->name_and_type_ref_index_at(method_index);
     return cpool->signature_ref_index_at(name_and_type_index);
diff --git a/hotspot/src/share/vm/ci/ciStreams.hpp b/hotspot/src/share/vm/ci/ciStreams.hpp
index 091aa1b..07e573b 100644
--- a/hotspot/src/share/vm/ci/ciStreams.hpp
+++ b/hotspot/src/share/vm/ci/ciStreams.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -264,7 +264,7 @@
   ciMethodType* get_method_type();
   ciKlass*      get_declared_method_holder();
   int           get_method_holder_index();
-  int           get_method_signature_index();
+  int           get_method_signature_index(const constantPoolHandle& cpool);
 
   // Get the resolved references arrays from the constant pool
   ciObjArray* get_resolved_references();
diff --git a/hotspot/src/share/vm/ci/ciSymbol.cpp b/hotspot/src/share/vm/ci/ciSymbol.cpp
index f141832..fa4c165 100644
--- a/hotspot/src/share/vm/ci/ciSymbol.cpp
+++ b/hotspot/src/share/vm/ci/ciSymbol.cpp
@@ -58,9 +58,7 @@
 //
 // The text of the symbol as a null-terminated C string.
 const char* ciSymbol::as_utf8() {
-  VM_QUICK_ENTRY_MARK;
-  Symbol* s = get_symbol();
-  return s->as_utf8();
+  GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_utf8();)
 }
 
 // The text of the symbol as a null-terminated C string.
diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp
index 5a735d5..e561cdc 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp
@@ -2925,7 +2925,7 @@
   // If JVMTI original method ordering or sharing is enabled construct int
   // array remembering the original ordering
   if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) {
-    method_ordering = new intArray(length);
+    method_ordering = new intArray(length, length, -1);
     for (int index = 0; index < length; index++) {
       Method* const m = methods->at(index);
       const int old_index = m->vtable_index();
@@ -3967,7 +3967,7 @@
     next_nonstatic_padded_offset += ContendedPaddingWidth;
 
     // collect all contended groups
-    BitMap bm(cp->size());
+    ResourceBitMap bm(cp->size());
     for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
       // skip already laid out fields
       if (fs.is_offset_set()) continue;
@@ -5349,7 +5349,7 @@
   ClassLoadingService::notify_class_loaded(ik, false /* not shared class */);
 
   if (!is_internal()) {
-    if (log_is_enabled(Info, classload)) {
+    if (log_is_enabled(Info, class, load)) {
       ResourceMark rm;
       const char* module_name = NULL;
       static const size_t modules_image_name_len = strlen(MODULES_IMAGE_NAME);
@@ -5361,21 +5361,21 @@
         module_name = module_entry->name()->as_C_string();
       }
 
-      if (log_is_enabled(Info, classload)) {
+      if (log_is_enabled(Info, class, load)) {
         ik->print_loading_log(LogLevel::Info, _loader_data, module_name, _stream);
       }
       // No 'else' here as logging levels are not mutually exclusive
-      if (log_is_enabled(Debug, classload)) {
+      if (log_is_enabled(Debug, class, load)) {
         ik->print_loading_log(LogLevel::Debug, _loader_data, module_name, _stream);
       }
     }
 
-    if (log_is_enabled(Debug, classresolve))  {
+    if (log_is_enabled(Debug, class, resolve))  {
       ResourceMark rm;
       // print out the superclass.
       const char * from = ik->external_name();
       if (ik->java_super() != NULL) {
-        log_debug(classresolve)("%s %s (super)",
+        log_debug(class, resolve)("%s %s (super)",
                    from,
                    ik->java_super()->external_name());
       }
@@ -5386,7 +5386,7 @@
         for (int i = 0; i < length; i++) {
           const Klass* const k = local_interfaces->at(i);
           const char * to = k->external_name();
-          log_debug(classresolve)("%s %s (interface)", from, to);
+          log_debug(class, resolve)("%s %s (interface)", from, to);
         }
       }
     }
@@ -5696,9 +5696,9 @@
   }
 
   if (!is_internal()) {
-    if (log_is_enabled(Debug, classload, preorder)){
+    if (log_is_enabled(Debug, class, preorder)){
       ResourceMark rm(THREAD);
-      outputStream* log = Log(classload, preorder)::debug_stream();
+      outputStream* log = Log(class, preorder)::debug_stream();
       log->print("%s", _class_name->as_klass_external_name());
       if (stream->source() != NULL) {
         log->print(" source: %s", stream->source());
@@ -5708,8 +5708,10 @@
 
 #if INCLUDE_CDS
     if (DumpLoadedClassList != NULL && stream->source() != NULL && classlist_file->is_open()) {
-      // Only dump the classes that can be stored into CDS archive
-      if (SystemDictionaryShared::is_sharing_possible(_loader_data)) {
+      // Only dump the classes that can be stored into CDS archive.
+      // Anonymous classes such as generated LambdaForm classes are also not included.
+      if (SystemDictionaryShared::is_sharing_possible(_loader_data) &&
+          _host_klass == NULL) {
         ResourceMark rm(THREAD);
         classlist_file->print_cr("%s", _class_name->as_C_string());
         classlist_file->flush();
@@ -5800,8 +5802,8 @@
       guarantee_property(super_class_name == vmSymbols::java_lang_Object(),
         "Interfaces must have java.lang.Object as superclass in class file %s",
         CHECK);
-      }
-      _super_klass = (const InstanceKlass*)
+    }
+    _super_klass = (const InstanceKlass*)
                        SystemDictionary::resolve_super_or_fail(_class_name,
                                                                super_class_name,
                                                                _loader_data->class_loader(),
diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp
index 3ee99df..47ec539 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
 template <typename T>
 class GrowableArray;
 class InstanceKlass;
-class intArray;
 class Symbol;
 class TempNewSymbol;
 
diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp
index ebd7d84..d77aef2 100644
--- a/hotspot/src/share/vm/classfile/classLoader.cpp
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp
@@ -320,7 +320,7 @@
 #if INCLUDE_CDS
 u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TRAPS) {
   u1* buffer = NULL;
-  if (DumpSharedSpaces) {
+  if (DumpSharedSpaces && !_is_boot_append) {
     // We presume default is multi-release enabled
     const char* multi_ver = Arguments::get_property("jdk.util.jar.enableMultiRelease");
     const char* verstr = Arguments::get_property("jdk.util.jar.version");
@@ -539,7 +539,7 @@
 #if INCLUDE_CDS
 void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
   assert(DumpSharedSpaces, "only called at dump time");
-  tty->print_cr("Hint: enable -Xlog:classpath=info to diagnose the failure");
+  tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure");
   vm_exit_during_initialization(error, message);
 }
 #endif
@@ -572,9 +572,9 @@
 }
 
 void ClassLoader::trace_class_path(const char* msg, const char* name) {
-  if (log_is_enabled(Info, classpath)) {
+  if (log_is_enabled(Info, class, path)) {
     ResourceMark rm;
-    outputStream* out = Log(classpath)::info_stream();
+    outputStream* out = Log(class, path)::info_stream();
     if (msg) {
       out->print("%s", msg);
     }
@@ -795,12 +795,12 @@
         }
       }
     }
-    log_info(classpath)("opened: %s", path);
-    log_info(classload)("opened: %s", path);
+    log_info(class, path)("opened: %s", path);
+    log_info(class, load)("opened: %s", path);
   } else {
     // Directory
     new_entry = new ClassPathDirEntry(path);
-    log_info(classload)("path: %s", path);
+    log_info(class, load)("path: %s", path);
   }
   return new_entry;
 }
@@ -1046,6 +1046,10 @@
 
 #if INCLUDE_CDS
 void ClassLoader::initialize_module_loader_map(JImageFile* jimage) {
+  if (!DumpSharedSpaces) {
+    return; // only needed for CDS dump time
+  }
+
   ResourceMark rm;
   jlong size;
   JImageLocationRef location = (*JImageFindResource)(jimage, "java.base", get_jimage_version_string(), MODULE_LOADER_MAP, &size);
@@ -1053,7 +1057,8 @@
     vm_exit_during_initialization(
       "Cannot find ModuleLoaderMap location from modules jimage.", NULL);
   }
-  char* buffer = NEW_RESOURCE_ARRAY(char, size);
+  char* buffer = NEW_RESOURCE_ARRAY(char, size + 1);
+  buffer[size] = '\0';
   jlong read = (*JImageGetResource)(jimage, location, buffer, size);
   if (read != size) {
     vm_exit_during_initialization(
@@ -1190,6 +1195,7 @@
 #if INCLUDE_CDS
 s2 ClassLoader::module_to_classloader(const char* module_name) {
 
+  assert(DumpSharedSpaces, "dump time only");
   assert(_boot_modules_array != NULL, "_boot_modules_array is NULL");
   assert(_platform_modules_array != NULL, "_platform_modules_array is NULL");
 
@@ -1209,10 +1215,10 @@
 
   return APP_LOADER;
 }
-#endif
 
 s2 ClassLoader::classloader_type(Symbol* class_name, ClassPathEntry* e, int classpath_index, TRAPS) {
-#if INCLUDE_CDS
+  assert(DumpSharedSpaces, "Only used for CDS dump time");
+
   // obtain the classloader type based on the class name.
   // First obtain the package name based on the class name. Then obtain
   // the classloader type based on the package name from the jimage using
@@ -1237,10 +1243,8 @@
     loader_type = ClassLoader::BOOT_LOADER;
   }
   return loader_type;
-#endif
-  return ClassLoader::BOOT_LOADER; // the classloader type is ignored in non-CDS cases
 }
-
+#endif
 
 // caller needs ResourceMark
 const char* ClassLoader::file_name_for_class_name(const char* class_name,
@@ -1424,8 +1428,7 @@
     return NULL;
   }
 
-  jshort loader_type = classloader_type(name, e, classpath_index, CHECK_NULL);
-  return context.record_result(classpath_index, loader_type, e, result, THREAD);
+  return context.record_result(name, e, classpath_index, result, THREAD);
 }
 
 // Initialize the class loader's access to methods in libzip.  Parse and
@@ -1831,7 +1834,7 @@
               }
               // Force compilation
               CompileBroker::compile_method(m, InvocationEntryBci, comp_level,
-                                            methodHandle(), 0, "CTW", THREAD);
+                                            methodHandle(), 0, CompileTask::Reason_CTW, THREAD);
               if (HAS_PENDING_EXCEPTION) {
                 clear_pending_exception_if_not_oom(CHECK);
                 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string());
@@ -1840,14 +1843,14 @@
               }
               if (TieredCompilation && TieredStopAtLevel >= CompLevel_full_optimization) {
                 // Clobber the first compile and force second tier compilation
-                nmethod* nm = m->code();
+                CompiledMethod* nm = m->code();
                 if (nm != NULL && !m->is_method_handle_intrinsic()) {
                   // Throw out the code so that the code cache doesn't fill up
                   nm->make_not_entrant();
                   m->clear_code();
                 }
                 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_full_optimization,
-                                              methodHandle(), 0, "CTW", THREAD);
+                                              methodHandle(), 0, CompileTask::Reason_CTW, THREAD);
                 if (HAS_PENDING_EXCEPTION) {
                   clear_pending_exception_if_not_oom(CHECK);
                   tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string());
@@ -1859,7 +1862,7 @@
               tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string());
             }
 
-            nmethod* nm = m->code();
+            CompiledMethod* nm = m->code();
             if (nm != NULL && !m->is_method_handle_intrinsic()) {
               // Throw out the code so that the code cache doesn't fill up
               nm->make_not_entrant();
diff --git a/hotspot/src/share/vm/classfile/classLoader.hpp b/hotspot/src/share/vm/classfile/classLoader.hpp
index 1168f32..1688373 100644
--- a/hotspot/src/share/vm/classfile/classLoader.hpp
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp
@@ -406,9 +406,9 @@
 
   static s2 module_to_classloader(const char* module_name);
   static void initialize_module_loader_map(JImageFile* jimage);
-#endif
   static s2 classloader_type(Symbol* class_name, ClassPathEntry* e,
-                                 int classpath_index, TRAPS);
+                             int classpath_index, TRAPS);
+#endif
 
   static void  trace_class_path(const char* msg, const char* name = NULL);
 
diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp
index 0c0eb37..3ca97ef 100644
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp
@@ -84,7 +84,7 @@
   // An anonymous class loader data doesn't have anything to keep
   // it from being unloaded during parsing of the anonymous class.
   // The null-class-loader should always be kept alive.
-  _keep_alive(is_anonymous || h_class_loader.is_null()),
+  _keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
   _metaspace(NULL), _unloading(false), _klasses(NULL),
   _modules(NULL), _packages(NULL),
   _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
@@ -114,6 +114,21 @@
   return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0;
 }
 
+// Anonymous classes have their own ClassLoaderData that is marked to keep alive
+// while the class is being parsed, and if the class appears on the module fixup list.
+// Due to the uniqueness that no other class shares the anonymous class' name or
+// ClassLoaderData, no other non-GC thread has knowledge of the anonymous class while
+// it is being defined, therefore _keep_alive is not volatile or atomic.
+void ClassLoaderData::inc_keep_alive() {
+  assert(_keep_alive >= 0, "Invalid keep alive count");
+  _keep_alive++;
+}
+
+void ClassLoaderData::dec_keep_alive() {
+  assert(_keep_alive > 0, "Invalid keep alive count");
+  _keep_alive--;
+}
+
 void ClassLoaderData::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
   if (must_claim && !claim()) {
     return;
@@ -318,7 +333,7 @@
 
   if (publicize && k->class_loader_data() != NULL) {
     ResourceMark rm;
-    log_trace(classloaderdata)("Adding k: " PTR_FORMAT " %s to CLD: "
+    log_trace(class, loader, data)("Adding k: " PTR_FORMAT " %s to CLD: "
                   PTR_FORMAT " loader: " PTR_FORMAT " %s",
                   p2i(k),
                   k->external_name(),
@@ -356,9 +371,9 @@
   // Tell serviceability tools these classes are unloading
   classes_do(InstanceKlass::notify_unload_class);
 
-  if (log_is_enabled(Debug, classloaderdata)) {
+  if (log_is_enabled(Debug, class, loader, data)) {
     ResourceMark rm;
-    outputStream* log = Log(classloaderdata)::debug_stream();
+    outputStream* log = Log(class, loader, data)::debug_stream();
     log->print(": unload loader data " INTPTR_FORMAT, p2i(this));
     log->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()),
                loader_name());
@@ -491,12 +506,12 @@
       set_metaspace(new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType));
     } else if (is_anonymous()) {
       if (class_loader() != NULL) {
-        log_trace(classloaderdata)("is_anonymous: %s", class_loader()->klass()->internal_name());
+        log_trace(class, loader, data)("is_anonymous: %s", class_loader()->klass()->internal_name());
       }
       set_metaspace(new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType));
     } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
       if (class_loader() != NULL) {
-        log_trace(classloaderdata)("is_reflection: %s", class_loader()->klass()->internal_name());
+        log_trace(class, loader, data)("is_reflection: %s", class_loader()->klass()->internal_name());
       }
       set_metaspace(new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType));
     } else {
@@ -687,7 +702,7 @@
     cld->set_next(next);
     ClassLoaderData* exchanged = (ClassLoaderData*)Atomic::cmpxchg_ptr(cld, list_head, next);
     if (exchanged == next) {
-      if (log_is_enabled(Debug, classloaderdata)) {
+      if (log_is_enabled(Debug, class, loader, data)) {
        PauseNoSafepointVerifier pnsv(&no_safepoints); // Need safe points for JavaCalls::call_virtual
        log_creation(loader, cld, CHECK_NULL);
       }
@@ -715,7 +730,7 @@
   }
 
   ResourceMark rm;
-  outputStream* log = Log(classloaderdata)::debug_stream();
+  outputStream* log = Log(class, loader, data)::debug_stream();
   log->print("create class loader data " INTPTR_FORMAT, p2i(cld));
   log->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()),
              cld->loader_name());
@@ -856,8 +871,8 @@
     if (!curr->claimed()) {
       array->push(curr);
 
-      if (log_is_enabled(Debug, classloaderdata)) {
-        outputStream* log = Log(classloaderdata)::debug_stream();
+      if (log_is_enabled(Debug, class, loader, data)) {
+        outputStream* log = Log(class, loader, data)::debug_stream();
         log->print("found new CLD: ");
         curr->print_value_on(log);
         log->cr();
diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp
index 4b6d247..b1a136a 100644
--- a/hotspot/src/share/vm/classfile/classLoaderData.hpp
+++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp
@@ -175,8 +175,11 @@
                            // classes in the class loader are allocated.
   Mutex* _metaspace_lock;  // Locks the metaspace for allocations and setup.
   bool _unloading;         // true if this class loader goes away
-  bool _keep_alive;        // if this CLD is kept alive without a keep_alive_object().
   bool _is_anonymous;      // if this CLD is for an anonymous class
+  int _keep_alive;         // if this CLD is kept alive without a keep_alive_object().
+                           // Currently used solely for anonymous classes.
+                           // _keep_alive does not need to be volatile or
+                           // atomic since there is one unique CLD per anonymous class.
   volatile int _claimed;   // true if claimed, for example during GC traces.
                            // To avoid applying oop closure more than once.
                            // Has to be an int because we cas it.
@@ -224,7 +227,7 @@
   bool claim();
 
   void unload();
-  bool keep_alive() const       { return _keep_alive; }
+  bool keep_alive() const       { return _keep_alive > 0; }
   void classes_do(void f(Klass*));
   void loaded_classes_do(KlassClosure* klass_closure);
   void classes_do(void f(InstanceKlass*));
@@ -286,8 +289,8 @@
     return _unloading;
   }
 
-  // Used to make sure that this CLD is not unloaded.
-  void set_keep_alive(bool value) { _keep_alive = value; }
+  void inc_keep_alive();
+  void dec_keep_alive();
 
   inline unsigned int identity_hash() const;
 
diff --git a/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp b/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp
index 2427838..3da00ad 100644
--- a/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp
+++ b/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp
@@ -45,7 +45,7 @@
 
 
 inline ClassLoaderData *ClassLoaderDataGraph::find_or_create(Handle loader, TRAPS) {
-  assert(loader() != NULL,"Must be a class loader");
+  guarantee(loader() != NULL && loader()->is_oop(), "Loader must be oop");
   // Gets the class loader data out of the java/lang/ClassLoader object, if non-null
   // it's already in the loader_data, so no need to add
   ClassLoaderData* loader_data= java_lang_ClassLoader::loader_data(loader());
diff --git a/hotspot/src/share/vm/classfile/classLoaderExt.hpp b/hotspot/src/share/vm/classfile/classLoaderExt.hpp
index 7fa11b2..24426d1 100644
--- a/hotspot/src/share/vm/classfile/classLoaderExt.hpp
+++ b/hotspot/src/share/vm/classfile/classLoaderExt.hpp
@@ -49,12 +49,14 @@
       return false;
     }
 
-    instanceKlassHandle record_result(const s2 classpath_index,
-                                      const jshort classloader_type,
-                                      const ClassPathEntry* e,
+    instanceKlassHandle record_result(Symbol* class_name,
+                                      ClassPathEntry* e,
+                                      const s2 classpath_index,
                                       instanceKlassHandle result, TRAPS) {
       if (ClassLoader::add_package(_file_name, classpath_index, THREAD)) {
         if (DumpSharedSpaces) {
+          s2 classloader_type = ClassLoader::classloader_type(
+                          class_name, e, classpath_index, CHECK_(result));
           result->set_shared_classpath_index(classpath_index);
           result->set_class_loader_type(classloader_type);
         }
diff --git a/hotspot/src/share/vm/classfile/compactHashtable.cpp b/hotspot/src/share/vm/classfile/compactHashtable.cpp
index a2c507d3..c64a166 100644
--- a/hotspot/src/share/vm/classfile/compactHashtable.cpp
+++ b/hotspot/src/share/vm/classfile/compactHashtable.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/compactHashtable.inline.hpp"
 #include "classfile/javaClasses.hpp"
+#include "memory/metadataFactory.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "prims/jvm.h"
 #include "utilities/numberSeq.hpp"
@@ -34,270 +35,259 @@
 //
 // The compact hash table writer implementations
 //
-CompactHashtableWriter::CompactHashtableWriter(int table_type,
-                                               int num_entries,
+CompactHashtableWriter::CompactHashtableWriter(int num_buckets,
                                                CompactHashtableStats* stats) {
   assert(DumpSharedSpaces, "dump-time only");
-  _type = table_type;
-  _num_entries = num_entries;
-  _num_buckets = number_of_buckets(_num_entries);
-  _buckets = NEW_C_HEAP_ARRAY(Entry*, _num_buckets, mtSymbol);
-  memset(_buckets, 0, sizeof(Entry*) * _num_buckets);
+  _num_buckets = num_buckets;
+  _num_entries = 0;
+  _buckets = NEW_C_HEAP_ARRAY(GrowableArray<Entry>*, _num_buckets, mtSymbol);
+  for (int i=0; i<_num_buckets; i++) {
+    _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray<Entry>(0, true, mtSymbol);
+  }
 
-  /* bucket sizes table */
-  _bucket_sizes = NEW_C_HEAP_ARRAY(juint, _num_buckets, mtSymbol);
-  memset(_bucket_sizes, 0, sizeof(juint) * _num_buckets);
-
-  stats->hashentry_count = _num_entries;
-  // Compact buckets' entries will have only the 4-byte offset, but
-  // we don't know how many there will be at this point. So use a
-  // conservative estimate here. The size is adjusted later when we
-  // write out the buckets.
-  stats->hashentry_bytes = _num_entries * 8;
-  stats->bucket_count    = _num_buckets;
-  stats->bucket_bytes    = (_num_buckets + 1) * (sizeof(juint));
+  stats->bucket_count = _num_buckets;
+  stats->bucket_bytes = (_num_buckets + 1) * (sizeof(u4));
   _stats = stats;
-
-  // See compactHashtable.hpp for table layout
-  _required_bytes = sizeof(juint) * 2; // _base_address, written as 2 juints
-  _required_bytes+= sizeof(juint) +    // num_entries
-                    sizeof(juint) +    // num_buckets
-                    stats->hashentry_bytes +
-                    stats->bucket_bytes;
+  _compact_buckets = NULL;
+  _compact_entries = NULL;
+  _num_empty_buckets = 0;
+  _num_value_only_buckets = 0;
+  _num_other_buckets = 0;
 }
 
 CompactHashtableWriter::~CompactHashtableWriter() {
   for (int index = 0; index < _num_buckets; index++) {
-    Entry* next = NULL;
-    for (Entry* tent = _buckets[index]; tent; tent = next) {
-      next = tent->next();
-      delete tent;
-    }
+    GrowableArray<Entry>* bucket = _buckets[index];
+    delete bucket;
   }
 
-  FREE_C_HEAP_ARRAY(juint, _bucket_sizes);
-  FREE_C_HEAP_ARRAY(Entry*, _buckets);
-}
-
-// Calculate the number of buckets in the temporary hash table
-int CompactHashtableWriter::number_of_buckets(int num_entries) {
-  const int buksize = (int)SharedSymbolTableBucketSize;
-  int num_buckets = (num_entries + buksize - 1) / buksize;
-  num_buckets = (num_buckets + 1) & (~0x01);
-
-  return num_buckets;
+  FREE_C_HEAP_ARRAY(GrowableArray<Entry>*, _buckets);
 }
 
 // Add a symbol entry to the temporary hash table
-void CompactHashtableWriter::add(unsigned int hash, Entry* entry) {
+void CompactHashtableWriter::add(unsigned int hash, u4 value) {
   int index = hash % _num_buckets;
-  entry->set_next(_buckets[index]);
-  _buckets[index] = entry;
-  _bucket_sizes[index] ++;
+  _buckets[index]->append_if_missing(Entry(hash, value));
+  _num_entries++;
 }
 
-// Write the compact table's bucket infos
-juint* CompactHashtableWriter::dump_table(juint* p, juint** first_bucket,
-                                          NumberSeq* summary) {
-  int index;
-  juint* compact_table = p;
-  // Compute the start of the buckets, include the compact_bucket_infos table
-  // and the table end offset.
-  juint offset = _num_buckets + 1;
-  *first_bucket = compact_table + offset;
+void CompactHashtableWriter::allocate_table() {
+  int entries_space = 0;
+  for (int index = 0; index < _num_buckets; index++) {
+    GrowableArray<Entry>* bucket = _buckets[index];
+    int bucket_size = bucket->length();
+    if (bucket_size == 1) {
+      entries_space++;
+    } else {
+      entries_space += 2 * bucket_size;
+    }
+  }
 
-  for (index = 0; index < _num_buckets; index++) {
-    int bucket_size = _bucket_sizes[index];
+  if (entries_space & ~BUCKET_OFFSET_MASK) {
+    vm_exit_during_initialization("CompactHashtableWriter::allocate_table: Overflow! "
+                                  "Too many entries.");
+  }
+
+  Thread* THREAD = VMThread::vm_thread();
+  ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
+  _compact_buckets = MetadataFactory::new_array<u4>(loader_data, _num_buckets + 1, THREAD);
+  _compact_entries = MetadataFactory::new_array<u4>(loader_data, entries_space, THREAD);
+
+  _stats->hashentry_count = _num_entries;
+  _stats->hashentry_bytes = entries_space * sizeof(u4);
+}
+
+// Write the compact table's buckets
+void CompactHashtableWriter::dump_table(NumberSeq* summary) {
+  u4 offset = 0;
+  for (int index = 0; index < _num_buckets; index++) {
+    GrowableArray<Entry>* bucket = _buckets[index];
+    int bucket_size = bucket->length();
     if (bucket_size == 1) {
       // bucket with one entry is compacted and only has the symbol offset
-      compact_table[index] = BUCKET_INFO(offset, COMPACT_BUCKET_TYPE);
-      offset += bucket_size; // each entry contains symbol offset only
+      _compact_buckets->at_put(index, BUCKET_INFO(offset, VALUE_ONLY_BUCKET_TYPE));
+
+      Entry ent = bucket->at(0);
+      _compact_entries->at_put(offset++, ent.value());
+      _num_value_only_buckets++;
     } else {
       // regular bucket, each entry is a symbol (hash, offset) pair
-      compact_table[index] = BUCKET_INFO(offset, REGULAR_BUCKET_TYPE);
-      offset += bucket_size * 2; // each hash entry is 2 juints
-    }
-    if (offset & ~BUCKET_OFFSET_MASK) {
-      vm_exit_during_initialization("CompactHashtableWriter::dump_table: Overflow! "
-                                    "Too many symbols.");
+      _compact_buckets->at_put(index, BUCKET_INFO(offset, REGULAR_BUCKET_TYPE));
+
+      for (int i=0; i<bucket_size; i++) {
+        Entry ent = bucket->at(i);
+        _compact_entries->at_put(offset++, u4(ent.hash())); // write entry hash
+        _compact_entries->at_put(offset++, ent.value());
+      }
+      if (bucket_size == 0) {
+        _num_empty_buckets++;
+      } else {
+        _num_other_buckets++;
+      }
     }
     summary->add(bucket_size);
   }
-  // Mark the end of the table
-  compact_table[_num_buckets] = BUCKET_INFO(offset, TABLEEND_BUCKET_TYPE);
 
-  return compact_table;
+  // Mark the end of the buckets
+  _compact_buckets->at_put(_num_buckets, BUCKET_INFO(offset, TABLEEND_BUCKET_TYPE));
+  assert(offset == (u4)_compact_entries->length(), "sanity");
 }
 
-// Write the compact table's entries
-juint* CompactHashtableWriter::dump_buckets(juint* compact_table, juint* p,
-                                            NumberSeq* summary) {
-  uintx base_address = 0;
-  uintx max_delta = 0;
-  int num_compact_buckets = 0;
-  if (_type == CompactHashtable<Symbol*, char>::_symbol_table) {
-    base_address = uintx(MetaspaceShared::shared_rs()->base());
-    max_delta    = uintx(MetaspaceShared::shared_rs()->size());
-    assert(max_delta <= MAX_SHARED_DELTA, "range check");
-  } else {
-    assert((_type == CompactHashtable<oop, char>::_string_table), "unknown table");
-    assert(UseCompressedOops, "UseCompressedOops is required");
-  }
-
-  assert(p != NULL, "sanity");
-  for (int index = 0; index < _num_buckets; index++) {
-    juint count = 0;
-    int bucket_size = _bucket_sizes[index];
-    int bucket_type = BUCKET_TYPE(compact_table[index]);
-
-    if (bucket_size == 1) {
-      assert(bucket_type == COMPACT_BUCKET_TYPE, "Bad bucket type");
-      num_compact_buckets ++;
-    }
-    for (Entry* tent = _buckets[index]; tent;
-         tent = tent->next()) {
-      if (bucket_type == REGULAR_BUCKET_TYPE) {
-        *p++ = juint(tent->hash()); // write entry hash
-      }
-      if (_type == CompactHashtable<Symbol*, char>::_symbol_table) {
-        uintx deltax = uintx(tent->value()) - base_address;
-        assert(deltax < max_delta, "range check");
-        juint delta = juint(deltax);
-        *p++ = delta; // write entry offset
-      } else {
-        *p++ = oopDesc::encode_heap_oop(tent->string());
-      }
-      count ++;
-    }
-    assert(count == _bucket_sizes[index], "sanity");
-  }
-
-  // Adjust the hashentry_bytes in CompactHashtableStats. Each compact
-  // bucket saves 4-byte.
-  _stats->hashentry_bytes -= num_compact_buckets * 4;
-
-  return p;
-}
 
 // Write the compact table
-void CompactHashtableWriter::dump(char** top, char* end) {
+void CompactHashtableWriter::dump(SimpleCompactHashtable *cht, const char* table_name) {
   NumberSeq summary;
-  char* old_top = *top;
-  juint* p = (juint*)(*top);
+  allocate_table();
+  dump_table(&summary);
 
-  uintx base_address = uintx(MetaspaceShared::shared_rs()->base());
-
-  // Now write the following at the beginning of the table:
-  //      base_address (uintx)
-  //      num_entries  (juint)
-  //      num_buckets  (juint)
-  *p++ = high(base_address);
-  *p++ = low (base_address); // base address
-  *p++ = _num_entries;  // number of entries in the table
-  *p++ = _num_buckets;  // number of buckets in the table
-
-  juint* first_bucket = NULL;
-  juint* compact_table = dump_table(p, &first_bucket, &summary);
-  juint* bucket_end = dump_buckets(compact_table, first_bucket, &summary);
-
-  assert(bucket_end <= (juint*)end, "cannot write past end");
-  *top = (char*)bucket_end;
+  int table_bytes = _stats->bucket_bytes + _stats->hashentry_bytes;
+  address base_address = address(MetaspaceShared::shared_rs()->base());
+  cht->init(base_address,  _num_entries, _num_buckets,
+            _compact_buckets->data(), _compact_entries->data());
 
   if (PrintSharedSpaces) {
     double avg_cost = 0.0;
     if (_num_entries > 0) {
-      avg_cost = double(_required_bytes)/double(_num_entries);
+      avg_cost = double(table_bytes)/double(_num_entries);
     }
     tty->print_cr("Shared %s table stats -------- base: " PTR_FORMAT,
-                  table_name(), (intptr_t)base_address);
+                  table_name, (intptr_t)base_address);
     tty->print_cr("Number of entries       : %9d", _num_entries);
-    tty->print_cr("Total bytes used        : %9d", (int)((*top) - old_top));
+    tty->print_cr("Total bytes used        : %9d", table_bytes);
     tty->print_cr("Average bytes per entry : %9.3f", avg_cost);
     tty->print_cr("Average bucket size     : %9.3f", summary.avg());
     tty->print_cr("Variance of bucket size : %9.3f", summary.variance());
     tty->print_cr("Std. dev. of bucket size: %9.3f", summary.sd());
-    tty->print_cr("Maximum bucket size     : %9d", (int)summary.maximum());
+    tty->print_cr("Empty buckets           : %9d", _num_empty_buckets);
+    tty->print_cr("Value_Only buckets      : %9d", _num_value_only_buckets);
+    tty->print_cr("Other buckets           : %9d", _num_other_buckets);
   }
 }
 
-const char* CompactHashtableWriter::table_name() {
-  switch (_type) {
-  case CompactHashtable<Symbol*, char>::_symbol_table: return "symbol";
-  case CompactHashtable<oop, char>::_string_table: return "string";
-  default:
-    ;
-  }
-  return "unknown";
+/////////////////////////////////////////////////////////////
+//
+// Customization for dumping Symbol and String tables
+
+void CompactSymbolTableWriter::add(unsigned int hash, Symbol *symbol) {
+  address base_address = address(MetaspaceShared::shared_rs()->base());
+  uintx max_delta = uintx(MetaspaceShared::shared_rs()->size());
+  assert(max_delta <= MAX_SHARED_DELTA, "range check");
+
+  uintx deltax = address(symbol) - base_address;
+  assert(deltax < max_delta, "range check");
+  u4 delta = u4(deltax);
+
+  CompactHashtableWriter::add(hash, delta);
+}
+
+void CompactStringTableWriter::add(unsigned int hash, oop string) {
+  CompactHashtableWriter::add(hash, oopDesc::encode_heap_oop(string));
+}
+
+void CompactSymbolTableWriter::dump(CompactHashtable<Symbol*, char> *cht) {
+  CompactHashtableWriter::dump(cht, "symbol");
+}
+
+void CompactStringTableWriter::dump(CompactHashtable<oop, char> *cht) {
+  CompactHashtableWriter::dump(cht, "string");
 }
 
 /////////////////////////////////////////////////////////////
 //
 // The CompactHashtable implementation
 //
-template <class T, class N> const char* CompactHashtable<T, N>::init(
-                           CompactHashtableType type, const char* buffer) {
-  assert(!DumpSharedSpaces, "run-time only");
-  _type = type;
-  juint*p = (juint*)buffer;
-  juint upper = *p++;
-  juint lower = *p++;
-  _base_address = uintx(jlong_from(upper, lower));
-  _entry_count = *p++;
-  _bucket_count = *p++;
-  _buckets = p;
-  _table_end_offset = BUCKET_OFFSET(p[_bucket_count]); // located at the end of the bucket_info table
 
-  juint *end = _buckets + _table_end_offset;
-  return (const char*)end;
+void SimpleCompactHashtable::serialize(SerializeClosure* soc) {
+  soc->do_ptr((void**)&_base_address);
+  soc->do_u4(&_entry_count);
+  soc->do_u4(&_bucket_count);
+  soc->do_ptr((void**)&_buckets);
+  soc->do_ptr((void**)&_entries);
 }
 
+bool SimpleCompactHashtable::exists(u4 value) {
+  assert(!DumpSharedSpaces, "run-time only");
+
+  if (_entry_count == 0) {
+    return false;
+  }
+
+  unsigned int hash = (unsigned int)value;
+  int index = hash % _bucket_count;
+  u4 bucket_info = _buckets[index];
+  u4 bucket_offset = BUCKET_OFFSET(bucket_info);
+  int bucket_type = BUCKET_TYPE(bucket_info);
+  u4* entry = _entries + bucket_offset;
+
+  if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
+    return (entry[0] == value);
+  } else {
+    u4*entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
+    while (entry <entry_max) {
+      if (entry[1] == value) {
+        return true;
+      }
+      entry += 2;
+    }
+    return false;
+  }
+}
+
+template <class I>
+inline void SimpleCompactHashtable::iterate(const I& iterator) {
+  assert(!DumpSharedSpaces, "run-time only");
+  for (u4 i = 0; i < _bucket_count; i++) {
+    u4 bucket_info = _buckets[i];
+    u4 bucket_offset = BUCKET_OFFSET(bucket_info);
+    int bucket_type = BUCKET_TYPE(bucket_info);
+    u4* entry = _entries + bucket_offset;
+
+    if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
+      iterator.do_value(_base_address, entry[0]);
+    } else {
+      u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
+      while (entry < entry_max) {
+        iterator.do_value(_base_address, entry[0]);
+        entry += 2;
+      }
+    }
+  }
+}
+
+template <class T, class N> void CompactHashtable<T, N>::serialize(SerializeClosure* soc) {
+  SimpleCompactHashtable::serialize(soc);
+  soc->do_u4(&_type);
+}
+
+class CompactHashtable_SymbolIterator {
+  SymbolClosure* const _closure;
+public:
+  CompactHashtable_SymbolIterator(SymbolClosure *cl) : _closure(cl) {}
+  inline void do_value(address base_address, u4 offset) const {
+    Symbol* sym = (Symbol*)((void*)(base_address + offset));
+    _closure->do_symbol(&sym);
+  }
+};
+
 template <class T, class N> void CompactHashtable<T, N>::symbols_do(SymbolClosure *cl) {
-  assert(!DumpSharedSpaces, "run-time only");
-  for (juint i = 0; i < _bucket_count; i ++) {
-    juint bucket_info = _buckets[i];
-    juint bucket_offset = BUCKET_OFFSET(bucket_info);
-    int   bucket_type = BUCKET_TYPE(bucket_info);
-    juint* bucket = _buckets + bucket_offset;
-    juint* bucket_end = _buckets;
-
-    Symbol* sym;
-    if (bucket_type == COMPACT_BUCKET_TYPE) {
-      sym = (Symbol*)((void*)(_base_address + bucket[0]));
-      cl->do_symbol(&sym);
-    } else {
-      bucket_end += BUCKET_OFFSET(_buckets[i + 1]);
-      while (bucket < bucket_end) {
-        sym = (Symbol*)((void*)(_base_address + bucket[1]));
-        cl->do_symbol(&sym);
-        bucket += 2;
-      }
-    }
-  }
+  CompactHashtable_SymbolIterator iterator(cl);
+  iterate(iterator);
 }
 
-template <class T, class N> void CompactHashtable<T, N>::oops_do(OopClosure* f) {
-  assert(!DumpSharedSpaces, "run-time only");
-  assert(_type == _string_table || _bucket_count == 0, "sanity");
-  for (juint i = 0; i < _bucket_count; i ++) {
-    juint bucket_info = _buckets[i];
-    juint bucket_offset = BUCKET_OFFSET(bucket_info);
-    int   bucket_type = BUCKET_TYPE(bucket_info);
-    juint* bucket = _buckets + bucket_offset;
-    juint* bucket_end = _buckets;
-
-    narrowOop o;
-    if (bucket_type == COMPACT_BUCKET_TYPE) {
-      o = (narrowOop)bucket[0];
-      f->do_oop(&o);
-    } else {
-      bucket_end += BUCKET_OFFSET(_buckets[i + 1]);
-      while (bucket < bucket_end) {
-        o = (narrowOop)bucket[1];
-        f->do_oop(&o);
-        bucket += 2;
-      }
-    }
+class CompactHashtable_OopIterator {
+  OopClosure* const _closure;
+public:
+  CompactHashtable_OopIterator(OopClosure *cl) : _closure(cl) {}
+  inline void do_value(address base_address, u4 offset) const {
+    narrowOop o = (narrowOop)offset;
+    _closure->do_oop(&o);
   }
+};
+
+template <class T, class N> void CompactHashtable<T, N>::oops_do(OopClosure* cl) {
+  assert(_type == _string_table || _bucket_count == 0, "sanity");
+  CompactHashtable_OopIterator iterator(cl);
+  iterate(iterator);
 }
 
 // Explicitly instantiate these types
@@ -360,7 +350,7 @@
   } else {
     corrupted(_p, "Unexpected character");
   }
-  _line_no ++;
+  _line_no++;
   return true;
 }
 
@@ -390,7 +380,7 @@
 }
 
 void HashtableTextDump::scan_prefix_type() {
-  _p ++;
+  _p++;
   if (strncmp(_p, "SECTION: String", 15) == 0) {
     _p += 15;
     _prefix_type = StringPrefix;
diff --git a/hotspot/src/share/vm/classfile/compactHashtable.hpp b/hotspot/src/share/vm/classfile/compactHashtable.hpp
index ea60222..3dd870c 100644
--- a/hotspot/src/share/vm/classfile/compactHashtable.hpp
+++ b/hotspot/src/share/vm/classfile/compactHashtable.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,10 @@
 #include "services/diagnosticCommand.hpp"
 #include "utilities/hashtable.hpp"
 
+template <class T, class N> class CompactHashtable;
 class NumberSeq;
+class SimpleCompactHashtable;
+class SerializeClosure;
 
 // Stats for symbol tables in the CDS archive
 class CompactHashtableStats VALUE_OBJ_CLASS_SPEC {
@@ -70,66 +73,74 @@
 //
 class CompactHashtableWriter: public StackObj {
 public:
-  class Entry: public CHeapObj<mtSymbol> {
-    Entry* _next;
+  class Entry VALUE_OBJ_CLASS_SPEC {
     unsigned int _hash;
-    void* _literal;
+    u4 _value;
 
   public:
-    Entry(unsigned int hash, Symbol *symbol) : _next(NULL), _hash(hash), _literal(symbol) {}
-    Entry(unsigned int hash, oop string)     : _next(NULL), _hash(hash), _literal(string) {}
+    Entry() {}
+    Entry(unsigned int hash, u4 val) : _hash(hash), _value(val) {}
 
-    void *value() {
-      return _literal;
-    }
-    Symbol *symbol() {
-      return (Symbol*)_literal;
-    }
-    oop string() {
-      return (oop)_literal;
+    u4 value() {
+      return _value;
     }
     unsigned int hash() {
       return _hash;
     }
-    Entry *next()           {return _next;}
-    void set_next(Entry *p) {_next = p;}
+
+    bool operator==(const CompactHashtableWriter::Entry& other) {
+      return (_value == other._value && _hash == other._hash);
+    }
   }; // class CompactHashtableWriter::Entry
 
 private:
-  static int number_of_buckets(int num_entries);
-
-  int _type;
   int _num_entries;
   int _num_buckets;
-  juint* _bucket_sizes;
-  Entry** _buckets;
-  int _required_bytes;
+  int _num_empty_buckets;
+  int _num_value_only_buckets;
+  int _num_other_buckets;
+  GrowableArray<Entry>** _buckets;
   CompactHashtableStats* _stats;
+  Array<u4>* _compact_buckets;
+  Array<u4>* _compact_entries;
 
 public:
   // This is called at dump-time only
-  CompactHashtableWriter(int table_type, int num_entries, CompactHashtableStats* stats);
+  CompactHashtableWriter(int num_buckets, CompactHashtableStats* stats);
   ~CompactHashtableWriter();
 
-  int get_required_bytes() {
-    return _required_bytes;
+  void add(unsigned int hash, u4 value);
+  void add(u4 value) {
+    add((unsigned int)value, value);
   }
 
-  inline void add(unsigned int hash, Symbol* symbol);
-  inline void add(unsigned int hash, oop string);
-
 private:
-  void add(unsigned int hash, Entry* entry);
-  juint* dump_table(juint* p, juint** first_bucket, NumberSeq* summary);
-  juint* dump_buckets(juint* table, juint* p, NumberSeq* summary);
+  void allocate_table();
+  void dump_table(NumberSeq* summary);
 
 public:
-  void dump(char** top, char* end);
+  void dump(SimpleCompactHashtable *cht, const char* table_name);
   const char* table_name();
 };
 
+class CompactSymbolTableWriter: public CompactHashtableWriter {
+public:
+  CompactSymbolTableWriter(int num_buckets, CompactHashtableStats* stats) :
+    CompactHashtableWriter(num_buckets, stats) {}
+  void add(unsigned int hash, Symbol *symbol);
+  void dump(CompactHashtable<Symbol*, char> *cht);
+};
+
+class CompactStringTableWriter: public CompactHashtableWriter {
+public:
+  CompactStringTableWriter(int num_entries, CompactHashtableStats* stats) :
+    CompactHashtableWriter(num_entries, stats) {}
+  void add(unsigned int hash, oop string);
+  void dump(CompactHashtable<oop, char> *cht);
+};
+
 #define REGULAR_BUCKET_TYPE       0
-#define COMPACT_BUCKET_TYPE       1
+#define VALUE_ONLY_BUCKET_TYPE    1
 #define TABLEEND_BUCKET_TYPE      3
 #define BUCKET_OFFSET_MASK        0x3FFFFFFF
 #define BUCKET_OFFSET(info)       ((info) & BUCKET_OFFSET_MASK)
@@ -146,90 +157,106 @@
 // and tend to have large number of entries, we try to minimize the footprint
 // cost per entry.
 //
-// Layout of compact table in the shared archive:
+// The CompactHashtable is split into two arrays
 //
-//   uintx base_address;
-//   juint num_entries;
-//   juint num_buckets;
-//   juint bucket_infos[num_buckets+1]; // bit[31,30]: type; bit[29-0]: offset
-//   juint table[]
+//   u4 buckets[num_buckets+1]; // bit[31,30]: type; bit[29-0]: offset
+//   u4 entries[<variable size>]
 //
-// -----------------------------------
-// | base_address  | num_entries     |
-// |---------------------------------|
-// | num_buckets   | bucket_info0    |
-// |---------------------------------|
-// | bucket_info1  | bucket_info2    |
-// | bucket_info3    ...             |
-// | ....          | table_end_info  |
-// |---------------------------------|
-// | entry0                          |
-// | entry1                          |
-// | entry2                          |
-// |                                 |
-// | ...                             |
-// -----------------------------------
-//
-// The size of the bucket_info table is 'num_buckets + 1'. Each entry of the
-// bucket_info table is a 32-bit encoding of the bucket type and bucket offset,
+// The size of buckets[] is 'num_buckets + 1'. Each entry of
+// buckets[] is a 32-bit encoding of the bucket type and bucket offset,
 // with the type in the left-most 2-bit and offset in the remaining 30-bit.
-// The last entry is a special type. It contains the offset of the last
-// bucket end. We use that information when traversing the compact table.
+// The last entry is a special type. It contains the end of the last
+// bucket.
 //
-// There are two types of buckets, regular buckets and compact buckets. The
-// compact buckets have '01' in their highest 2-bit, and regular buckets have
+// There are two types of buckets, regular buckets and value_only buckets. The
+// value_only buckets have '01' in their highest 2-bit, and regular buckets have
 // '00' in their highest 2-bit.
 //
-// For normal buckets, each entry is 8 bytes in the table[]:
-//   juint hash;    /* symbol/string hash */
+// For normal buckets, each entry is 8 bytes in the entries[]:
+//   u4 hash;    /* symbol/string hash */
 //   union {
-//     juint offset;  /* Symbol* sym = (Symbol*)(base_address + offset) */
+//     u4 offset;  /* Symbol* sym = (Symbol*)(base_address + offset) */
 //     narrowOop str; /* String narrowOop encoding */
 //   }
 //
 //
-// For compact buckets, each entry has only the 4-byte 'offset' in the table[].
+// For value_only buckets, each entry has only the 4-byte 'offset' in the entries[].
+//
+// Example -- note that the second bucket is a VALUE_ONLY_BUCKET_TYPE so the hash code
+//            is skipped.
+// buckets[0, 4, 5, ....]
+//         |  |  |
+//         |  |  +---+
+//         |  |      |
+//         |  +----+ |
+//         v       v v
+// entries[H,O,H,O,O,H,O,H,O.....]
 //
 // See CompactHashtable::lookup() for how the table is searched at runtime.
 // See CompactHashtableWriter::dump() for how the table is written at CDS
 // dump time.
 //
-template <class T, class N> class CompactHashtable VALUE_OBJ_CLASS_SPEC {
+class SimpleCompactHashtable VALUE_OBJ_CLASS_SPEC {
+protected:
+  address  _base_address;
+  u4  _bucket_count;
+  u4  _entry_count;
+  u4* _buckets;
+  u4* _entries;
+
+public:
+  SimpleCompactHashtable() {
+    _entry_count = 0;
+    _bucket_count = 0;
+    _buckets = 0;
+    _entries = 0;
+  }
+
+  void reset() {
+    _bucket_count = 0;
+    _entry_count = 0;
+    _buckets = 0;
+    _entries = 0;
+  }
+
+  void init(address base_address, u4 entry_count, u4 bucket_count, u4* buckets, u4* entries) {
+    _base_address = base_address;
+    _bucket_count = bucket_count;
+    _entry_count = entry_count;
+    _buckets = buckets;
+    _entries = entries;
+  }
+
+  template <class I> inline void iterate(const I& iterator);
+
+  bool exists(u4 value);
+
+  // For reading from/writing to the CDS archive
+  void serialize(SerializeClosure* soc);
+};
+
+template <class T, class N> class CompactHashtable : public SimpleCompactHashtable {
   friend class VMStructs;
 
- public:
+public:
   enum CompactHashtableType {
     _symbol_table = 0,
     _string_table = 1
   };
 
 private:
-  CompactHashtableType _type;
-  uintx  _base_address;
-  juint  _entry_count;
-  juint  _bucket_count;
-  juint  _table_end_offset;
-  juint* _buckets;
+  u4 _type;
 
-  inline Symbol* lookup_entry(CompactHashtable<Symbol*, char>* const t,
-                              juint* addr, const char* name, int len);
+  inline Symbol* decode_entry(CompactHashtable<Symbol*, char>* const t,
+                              u4 offset, const char* name, int len);
 
-  inline oop lookup_entry(CompactHashtable<oop, char>* const t,
-                          juint* addr, const char* name, int len);
+  inline oop decode_entry(CompactHashtable<oop, char>* const t,
+                          u4 offset, const char* name, int len);
 public:
-  CompactHashtable() {
-    _entry_count = 0;
-    _bucket_count = 0;
-    _table_end_offset = 0;
-    _buckets = 0;
-  }
-  const char* init(CompactHashtableType type, const char *buffer);
+  CompactHashtable() : SimpleCompactHashtable() {}
 
-  void reset() {
-    _entry_count = 0;
-    _bucket_count = 0;
-    _table_end_offset = 0;
-    _buckets = 0;
+  void set_type(CompactHashtableType type) {
+    _type = (u4)type;
   }
 
   // Lookup an entry from the compact table
@@ -240,6 +267,9 @@
 
   // iterate over strings
   void oops_do(OopClosure* f);
+
+  // For reading from/writing to the CDS archive
+  void serialize(SerializeClosure* soc);
 };
 
 ////////////////////////////////////////////////////////////////////////
@@ -293,7 +323,7 @@
     u8 n = 0;
 
     while (p < end) {
-      char c = *p ++;
+      char c = *p++;
       if ('0' <= c && c <= '9') {
         n = n * 10 + (c - '0');
         if (n > (u8)INT_MAX) {
diff --git a/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp b/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp
index 96aeb55..24dbba1 100644
--- a/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp
+++ b/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,9 +30,9 @@
 #include "oops/oop.inline.hpp"
 
 template <class T, class N>
-inline Symbol* CompactHashtable<T, N>::lookup_entry(CompactHashtable<Symbol*, char>* const t,
-                                             juint* addr, const char* name, int len) {
-  Symbol* sym = (Symbol*)((void*)(_base_address + *addr));
+inline Symbol* CompactHashtable<T, N>::decode_entry(CompactHashtable<Symbol*, char>* const t,
+                                                    u4 offset, const char* name, int len) {
+  Symbol* sym = (Symbol*)(_base_address + offset);
   if (sym->equals(name, len)) {
     assert(sym->refcount() == -1, "must be shared");
     return sym;
@@ -42,9 +42,9 @@
 }
 
 template <class T, class N>
-inline oop CompactHashtable<T, N>::lookup_entry(CompactHashtable<oop, char>* const t,
-                                                juint* addr, const char* name, int len) {
-  narrowOop obj = (narrowOop)(*addr);
+inline oop CompactHashtable<T, N>::decode_entry(CompactHashtable<oop, char>* const t,
+                                                u4 offset, const char* name, int len) {
+  narrowOop obj = (narrowOop)offset;
   oop string = oopDesc::decode_heap_oop(obj);
   if (java_lang_String::equals(string, (jchar*)name, len)) {
     return string;
@@ -56,17 +56,14 @@
 template <class T, class N>
 inline T CompactHashtable<T,N>::lookup(const N* name, unsigned int hash, int len) {
   if (_entry_count > 0) {
-    assert(!DumpSharedSpaces, "run-time only");
     int index = hash % _bucket_count;
-    juint bucket_info = _buckets[index];
-    juint bucket_offset = BUCKET_OFFSET(bucket_info);
-    int   bucket_type = BUCKET_TYPE(bucket_info);
-    juint* bucket = _buckets + bucket_offset;
-    juint* bucket_end = _buckets;
+    u4 bucket_info = _buckets[index];
+    u4 bucket_offset = BUCKET_OFFSET(bucket_info);
+    int bucket_type = BUCKET_TYPE(bucket_info);
+    u4* entry = _entries + bucket_offset;
 
-    if (bucket_type == COMPACT_BUCKET_TYPE) {
-      // the compact bucket has one entry with entry offset only
-      T res = lookup_entry(this, &bucket[0], name, len);
+    if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
+      T res = decode_entry(this, entry[0], name, len);
       if (res != NULL) {
         return res;
       }
@@ -74,29 +71,20 @@
       // This is a regular bucket, which has more than one
       // entries. Each entry is a pair of entry (hash, offset).
       // Seek until the end of the bucket.
-      bucket_end += BUCKET_OFFSET(_buckets[index + 1]);
-      while (bucket < bucket_end) {
-        unsigned int h = (unsigned int)(bucket[0]);
+      u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
+      while (entry < entry_max) {
+        unsigned int h = (unsigned int)(entry[0]);
         if (h == hash) {
-          T res = lookup_entry(this, &bucket[1], name, len);
+          T res = decode_entry(this, entry[1], name, len);
           if (res != NULL) {
             return res;
           }
         }
-        bucket += 2;
+        entry += 2;
       }
     }
   }
   return NULL;
 }
 
-inline void CompactHashtableWriter::add(unsigned int hash, Symbol* symbol) {
-  add(hash, new Entry(hash, symbol));
-}
-
-inline void CompactHashtableWriter::add(unsigned int hash, oop string) {
-  add(hash, new Entry(hash, string));
-}
-
-
 #endif // SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP
diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp
index ee35194..c7ea145 100644
--- a/hotspot/src/share/vm/classfile/dictionary.cpp
+++ b/hotspot/src/share/vm/classfile/dictionary.cpp
@@ -31,7 +31,6 @@
 #include "memory/iterator.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/oop.inline.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "utilities/hashtable.inline.hpp"
 
diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp
index 6b3e45c..b99c918 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp
@@ -45,7 +45,6 @@
 #include "oops/oop.inline.hpp"
 #include "oops/symbol.hpp"
 #include "oops/typeArrayOop.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/fieldDescriptor.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/interfaceSupport.hpp"
@@ -131,7 +130,7 @@
       tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
     }
 #endif //PRODUCT
-    vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:classload=info to see the origin of the problem class");
+    vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class");
   }
   dest_offset = fd.offset();
 }
@@ -852,6 +851,7 @@
           new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(500, true);
         set_fixup_module_field_list(list);
       }
+      k->class_loader_data()->inc_keep_alive();
       fixup_module_field_list()->push(k());
     }
   } else {
@@ -1798,7 +1798,7 @@
         // Neither sourcename nor linenumber
         sprintf(buf + (int)strlen(buf), "Unknown Source)");
       }
-      nmethod* nm = method->code();
+      CompiledMethod* nm = method->code();
       if (WizardMode && nm != NULL) {
         sprintf(buf + (int)strlen(buf), "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm);
       }
@@ -1920,7 +1920,7 @@
   int total_count = 0;
   RegisterMap map(thread, false);
   int decode_offset = 0;
-  nmethod* nm = NULL;
+  CompiledMethod* nm = NULL;
   bool skip_fillInStackTrace_check = false;
   bool skip_throwableInit_check = false;
   bool skip_hidden = !ShowHiddenFrames;
@@ -1948,10 +1948,10 @@
         // HMMM QQQ might be nice to have frame return nm as NULL if cb is non-NULL
         // but non nmethod
         fr = fr.sender(&map);
-        if (cb == NULL || !cb->is_nmethod()) {
+        if (cb == NULL || !cb->is_compiled()) {
           continue;
         }
-        nm = (nmethod*)cb;
+        nm = cb->as_compiled_method();
         if (nm->method()->is_native()) {
           method = nm->method();
           bci = 0;
@@ -4058,7 +4058,7 @@
     tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
   }
 #endif //PRODUCT
-  vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:classload=info to see the origin of the problem class");
+  vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class");
   return -1;
 }
 
diff --git a/hotspot/src/share/vm/classfile/loaderConstraints.cpp b/hotspot/src/share/vm/classfile/loaderConstraints.cpp
index 3e5b033..5dfe4e3 100644
--- a/hotspot/src/share/vm/classfile/loaderConstraints.cpp
+++ b/hotspot/src/share/vm/classfile/loaderConstraints.cpp
@@ -111,9 +111,9 @@
       if (klass != NULL &&
           klass->class_loader_data()->is_unloading()) {
         probe->set_klass(NULL);
-        if (log_is_enabled(Info, constraints)) {
+        if (log_is_enabled(Info, class, loader, constraints)) {
           ResourceMark rm;
-          outputStream* out = Log(classload, constraints)::info_stream();
+          outputStream* out = Log(class, loader, constraints)::info_stream();
           out->print_cr("purging class object from constraint for name %s,"
                      " loader list:",
                      probe->name()->as_C_string());
@@ -127,9 +127,9 @@
       int n = 0;
       while (n < probe->num_loaders()) {
         if (probe->loader_data(n)->is_unloading()) {
-            if (log_is_enabled(Info, classload, constraints)) {
+            if (log_is_enabled(Info, class, loader, constraints)) {
               ResourceMark rm;
-              outputStream* out = Log(classload, constraints)::info_stream();
+              outputStream* out = Log(class, loader, constraints)::info_stream();
               out->print_cr("purging loader %s from constraint for name %s",
                             probe->loader_data(n)->loader_name(),
                             probe->name()->as_C_string()
@@ -142,9 +142,9 @@
           probe->set_loader_data(n, probe->loader_data(num));
           probe->set_loader_data(num, NULL);
 
-            if (log_is_enabled(Info, classload, constraints)) {
+            if (log_is_enabled(Info, class, loader, constraints)) {
               ResourceMark rm;
-              outputStream* out = Log(classload, constraints)::info_stream();
+              outputStream* out = Log(class, loader, constraints)::info_stream();
               out->print_cr("new loader list:");
               for (int i = 0; i < probe->num_loaders(); i++) {
                 out->print_cr("    [%d]: %s", i,
@@ -159,9 +159,9 @@
       }
       // Check whether entry should be purged
       if (probe->num_loaders() < 2) {
-            if (log_is_enabled(Info, classload, constraints)) {
+            if (log_is_enabled(Info, class, loader, constraints)) {
               ResourceMark rm;
-              outputStream* out = Log(classload, constraints)::info_stream();
+              outputStream* out = Log(class, loader, constraints)::info_stream();
               out->print_cr("purging complete constraint for name %s",
                          probe->name()->as_C_string());
             }
@@ -231,9 +231,9 @@
         p->set_klass(klass);
         p->set_next(bucket(index));
         set_entry(index, p);
-        if (log_is_enabled(Info, classload, constraints)) {
+        if (log_is_enabled(Info, class, loader, constraints)) {
           ResourceMark rm;
-          outputStream* out = Log(classload, constraints)::info_stream();
+          outputStream* out = Log(class, loader, constraints)::info_stream();
           out->print_cr("adding new constraint for name: %s, loader[0]: %s,"
                      " loader[1]: %s",
                      class_name->as_C_string(),
@@ -245,9 +245,9 @@
         /* constraint already imposed */
         if ((*pp1)->klass() == NULL) {
           (*pp1)->set_klass(klass);
-          if (log_is_enabled(Info, classload, constraints)) {
+          if (log_is_enabled(Info, class, loader, constraints)) {
             ResourceMark rm;
-            outputStream* out = Log(classload, constraints)::info_stream();
+            outputStream* out = Log(class, loader, constraints)::info_stream();
             out->print_cr("setting class object in existing constraint for"
                        " name: %s and loader %s",
                        class_name->as_C_string(),
@@ -267,9 +267,9 @@
     }
   }
 
-  if (failure_code != 0 && log_is_enabled(Info, classload, constraints)) {
+  if (failure_code != 0 && log_is_enabled(Info, class, loader, constraints)) {
     ResourceMark rm;
-    outputStream* out = Log(classload, constraints)::info_stream();
+    outputStream* out = Log(class, loader, constraints)::info_stream();
     const char* reason = "";
     switch(failure_code) {
     case 1: reason = "the class objects presented by loader[0] and loader[1]"
@@ -300,9 +300,9 @@
                                                    Symbol* name) {
   LoaderConstraintEntry* p = *(find_loader_constraint(name, loader));
   if (p && p->klass() != NULL && p->klass() != k()) {
-    if (log_is_enabled(Info, classload, constraints)) {
+    if (log_is_enabled(Info, class, loader, constraints)) {
       ResourceMark rm;
-      outputStream* out = Log(classload, constraints)::info_stream();
+      outputStream* out = Log(class, loader, constraints)::info_stream();
       out->print_cr("constraint check failed for name %s, loader %s: "
                  "the presented class object differs from that stored",
                  name->as_C_string(),
@@ -312,9 +312,9 @@
   } else {
     if (p && p->klass() == NULL) {
       p->set_klass(k());
-      if (log_is_enabled(Info, classload, constraints)) {
+      if (log_is_enabled(Info, class, loader, constraints)) {
         ResourceMark rm;
-        outputStream* out = Log(classload, constraints)::info_stream();
+        outputStream* out = Log(class, loader, constraints)::info_stream();
         out->print_cr("updating constraint for name %s, loader %s, "
                    "by setting class object",
                    name->as_C_string(),
@@ -362,9 +362,9 @@
   int num = p->num_loaders();
   p->set_loader(num, loader());
   p->set_num_loaders(num + 1);
-  if (log_is_enabled(Info, classload, constraints)) {
+  if (log_is_enabled(Info, class, loader, constraints)) {
     ResourceMark rm;
-    outputStream* out = Log(classload, constraints)::info_stream();
+    outputStream* out = Log(class, loader, constraints)::info_stream();
     out->print_cr("extending constraint for name %s by adding loader[%d]: %s %s",
                p->name()->as_C_string(),
                num,
@@ -402,9 +402,9 @@
     p1->set_num_loaders(num + 1);
   }
 
-  if (log_is_enabled(Info, classload, constraints)) {
+  if (log_is_enabled(Info, class, loader, constraints)) {
     ResourceMark rm;
-    outputStream* out = Log(classload, constraints)::info_stream();
+    outputStream* out = Log(class, loader, constraints)::info_stream();
     out->print_cr("merged constraints for name %s, new loader list:",
                   p1->name()->as_C_string()
                   );
diff --git a/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp b/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp
index 6df2d43..3a62c78 100644
--- a/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp
+++ b/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
 
   if (redefinition_walk) {
     Threads::metadata_do(Metadata::mark_on_stack);
-    CodeCache::alive_nmethods_do(nmethod::mark_on_stack);
+    CodeCache::metadata_do(Metadata::mark_on_stack);
     CompileBroker::mark_on_stack();
     JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack);
     ThreadService::metadata_do(Metadata::mark_on_stack);
diff --git a/hotspot/src/share/vm/classfile/moduleEntry.cpp b/hotspot/src/share/vm/classfile/moduleEntry.cpp
index 3386dc4..f26b95a 100644
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp
@@ -354,6 +354,7 @@
     Thread* THREAD = Thread::current();
     KlassHandle kh(THREAD, k);
     java_lang_Class::fixup_module_field(kh, module_handle);
+    k->class_loader_data()->dec_keep_alive();
   }
 
   delete java_lang_Class::fixup_module_field_list();
diff --git a/hotspot/src/share/vm/classfile/modules.cpp b/hotspot/src/share/vm/classfile/modules.cpp
index 10319b1..7c510bc 100644
--- a/hotspot/src/share/vm/classfile/modules.cpp
+++ b/hotspot/src/share/vm/classfile/modules.cpp
@@ -158,7 +158,7 @@
     HandleMark hm;
     Handle loader_lock = Handle(THREAD, SystemDictionary::system_loader_lock());
     ObjectLocker ol(loader_lock, THREAD);
-    log_info(classload)("opened: %s", path);
+    log_info(class, load)("opened: %s", path);
     ClassLoader::add_to_list(path);
   }
 }
@@ -240,6 +240,11 @@
   {
     MutexLocker m1(Module_lock, THREAD);
 
+    if (ModuleEntryTable::javabase_defined()) {
+      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+                "Module java.base is already defined");
+    }
+
     // Verify that all java.base packages created during bootstrapping are in
     // pkg_list.  If any are not in pkg_list, than a non-java.base class was
     // loaded erroneously pre java.base module definition.
diff --git a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp
index 302bb45..36cf234 100644
--- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp
+++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp
@@ -34,7 +34,7 @@
 #include "utilities/ostream.hpp"
 
 void SharedPathsMiscInfo::add_path(const char* path, int type) {
-  log_info(classpath)("type=%s ", type_name(type));
+  log_info(class, path)("type=%s ", type_name(type));
   ClassLoader::trace_class_path("add misc shared path ", path);
   write(path, strlen(path) + 1);
   write_jint(jint(type));
@@ -75,7 +75,7 @@
 
 void SharedPathsMiscInfo::print_path(int type, const char* path) {
   ResourceMark rm;
-  outputStream* out = Log(classpath)::info_stream();
+  outputStream* out = Log(class, path)::info_stream();
   switch (type) {
   case BOOT:
     out->print("Expecting BOOT path=%s", path);
@@ -109,7 +109,7 @@
     if (!read_jint(&type)) {
       return fail("Corrupted archive file header");
     }
-    log_info(classpath)("type=%s ", type_name(type));
+    log_info(class, path)("type=%s ", type_name(type));
     print_path(type, path);
     if (!check(type, path)) {
       if (!PrintSharedArchiveAndExit) {
diff --git a/hotspot/src/share/vm/classfile/stringTable.cpp b/hotspot/src/share/vm/classfile/stringTable.cpp
index 11aa554..5031a9c 100644
--- a/hotspot/src/share/vm/classfile/stringTable.cpp
+++ b/hotspot/src/share/vm/classfile/stringTable.cpp
@@ -662,7 +662,7 @@
 
 // Sharing
 bool StringTable::copy_shared_string(GrowableArray<MemRegion> *string_space,
-                                     CompactHashtableWriter* ch_table) {
+                                     CompactStringTableWriter* writer) {
 #if INCLUDE_CDS && INCLUDE_ALL_GCS && defined(_LP64) && !defined(_WINDOWS)
   assert(UseG1GC, "Only support G1 GC");
   assert(UseCompressedOops && UseCompressedClassPointers,
@@ -713,7 +713,7 @@
       }
 
       // add to the compact table
-      ch_table->add(hash, new_s);
+      writer->add(hash, new_s);
     }
   }
 
@@ -723,40 +723,45 @@
   return true;
 }
 
-bool StringTable::copy_compact_table(char** top, char *end, GrowableArray<MemRegion> *string_space,
-                                     size_t* space_size) {
+void StringTable::serialize(SerializeClosure* soc, GrowableArray<MemRegion> *string_space,
+                            size_t* space_size) {
 #if INCLUDE_CDS && defined(_LP64) && !defined(_WINDOWS)
-  if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) {
-    if (PrintSharedSpaces) {
-      tty->print_cr("Shared strings are excluded from the archive as UseG1GC, "
-                    "UseCompressedOops and UseCompressedClassPointers are required.");
+  _shared_table.reset();
+  if (soc->writing()) {
+    if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) {
+      if (PrintSharedSpaces) {
+        tty->print_cr(
+          "Shared strings are excluded from the archive as UseG1GC, "
+          "UseCompressedOops and UseCompressedClassPointers are required."
+          "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.",
+          BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops),
+          BOOL_TO_STR(UseCompressedClassPointers));
+      }
+    } else {
+      int num_buckets = the_table()->number_of_entries() /
+                             SharedSymbolTableBucketSize;
+      CompactStringTableWriter writer(num_buckets,
+                                      &MetaspaceShared::stats()->string);
+
+      // Copy the interned strings into the "string space" within the java heap
+      if (copy_shared_string(string_space, &writer)) {
+        for (int i = 0; i < string_space->length(); i++) {
+          *space_size += string_space->at(i).byte_size();
+        }
+        writer.dump(&_shared_table);
+      }
     }
-    return true;
   }
 
-  CompactHashtableWriter ch_table(CompactHashtable<oop, char>::_string_table,
-                                  the_table()->number_of_entries(),
-                                  &MetaspaceShared::stats()->string);
+  _shared_table.set_type(CompactHashtable<oop, char>::_string_table);
+  _shared_table.serialize(soc);
 
-  // Copy the interned strings into the "string space" within the java heap
-  if (!copy_shared_string(string_space, &ch_table)) {
-    return false;
+  if (soc->writing()) {
+    _shared_table.reset(); // Sanity. Make sure we don't use the shared table at dump time
+  } else if (_ignore_shared_strings) {
+    _shared_table.reset();
   }
-
-  for (int i = 0; i < string_space->length(); i++) {
-    *space_size += string_space->at(i).byte_size();
-  }
-
-  // Now dump the compact table
-  if (*top + ch_table.get_required_bytes() > end) {
-    // not enough space left
-    return false;
-  }
-  ch_table.dump(top, end);
-  *top = (char*)align_ptr_up(*top, sizeof(void*));
-
 #endif
-  return true;
 }
 
 void StringTable::shared_oops_do(OopClosure* f) {
@@ -765,25 +770,3 @@
 #endif
 }
 
-const char* StringTable::init_shared_table(FileMapInfo *mapinfo, char *buffer) {
-#if INCLUDE_CDS && defined(_LP64) && !defined(_WINDOWS)
-  if (mapinfo->space_capacity(MetaspaceShared::first_string) == 0) {
-    // no shared string data
-    return buffer;
-  }
-
-  // initialize the shared table
-  juint *p = (juint*)buffer;
-  const char* end = _shared_table.init(
-          CompactHashtable<oop, char>::_string_table, (char*)p);
-  const char* aligned_end = (const char*)align_ptr_up(end, sizeof(void*));
-
-  if (_ignore_shared_strings) {
-    _shared_table.reset();
-  }
-
-  return aligned_end;
-#endif
-
-  return buffer;
-}
diff --git a/hotspot/src/share/vm/classfile/stringTable.hpp b/hotspot/src/share/vm/classfile/stringTable.hpp
index 0840ba2..397cbbd 100644
--- a/hotspot/src/share/vm/classfile/stringTable.hpp
+++ b/hotspot/src/share/vm/classfile/stringTable.hpp
@@ -29,8 +29,9 @@
 #include "utilities/hashtable.hpp"
 
 template <class T, class N> class CompactHashtable;
-class CompactHashtableWriter;
+class CompactStringTableWriter;
 class FileMapInfo;
+class SerializeClosure;
 
 class StringTable : public RehashableHashtable<oop, mtSymbol> {
   friend class VMStructs;
@@ -155,10 +156,9 @@
   static bool shared_string_ignored()       { return _ignore_shared_strings; }
   static void shared_oops_do(OopClosure* f);
   static bool copy_shared_string(GrowableArray<MemRegion> *string_space,
-                                 CompactHashtableWriter* ch_table);
-  static bool copy_compact_table(char** top, char* end, GrowableArray<MemRegion> *string_space,
-                                 size_t* space_size);
-  static const char* init_shared_table(FileMapInfo *mapinfo, char* buffer);
+                                 CompactStringTableWriter* ch_table);
+  static void serialize(SerializeClosure* soc, GrowableArray<MemRegion> *string_space,
+                        size_t* space_size);
   static void reverse() {
     the_table()->Hashtable<oop, mtSymbol>::reverse();
   }
diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp
index 56d1dfb..ffbef4c 100644
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp
@@ -537,37 +537,42 @@
   }
 }
 
-bool SymbolTable::copy_compact_table(char** top, char*end) {
+void SymbolTable::serialize(SerializeClosure* soc) {
 #if INCLUDE_CDS
-  CompactHashtableWriter ch_table(CompactHashtable<Symbol*, char>::_symbol_table,
-                                  the_table()->number_of_entries(),
-                                  &MetaspaceShared::stats()->symbol);
-  if (*top + ch_table.get_required_bytes() > end) {
-    // not enough space left
-    return false;
-  }
-
-  for (int i = 0; i < the_table()->table_size(); ++i) {
-    HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
-    for ( ; p != NULL; p = p->next()) {
-      Symbol* s = (Symbol*)(p->literal());
+  _shared_table.reset();
+  if (soc->writing()) {
+    int num_buckets = the_table()->number_of_entries() /
+                            SharedSymbolTableBucketSize;
+    CompactSymbolTableWriter writer(num_buckets,
+                                    &MetaspaceShared::stats()->symbol);
+    for (int i = 0; i < the_table()->table_size(); ++i) {
+      HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
+      for ( ; p != NULL; p = p->next()) {
+        Symbol* s = (Symbol*)(p->literal());
       unsigned int fixed_hash =  hash_shared_symbol((char*)s->bytes(), s->utf8_length());
-      assert(fixed_hash == p->hash(), "must not rehash during dumping");
-      ch_table.add(fixed_hash, s);
+        assert(fixed_hash == p->hash(), "must not rehash during dumping");
+        writer.add(fixed_hash, s);
+      }
     }
+
+    writer.dump(&_shared_table);
   }
 
-  ch_table.dump(top, end);
+  _shared_table.set_type(CompactHashtable<Symbol*, char>::_symbol_table);
+  _shared_table.serialize(soc);
 
-  *top = (char*)align_ptr_up(*top, sizeof(void*));
+  if (soc->writing()) {
+    // Verify table is correct
+    Symbol* sym = vmSymbols::java_lang_Object();
+    const char* name = (const char*)sym->bytes();
+    int len = sym->utf8_length();
+    unsigned int hash = hash_symbol(name, len);
+    assert(sym == _shared_table.lookup(name, hash, len), "sanity");
+
+    // Sanity. Make sure we don't use the shared table at dump time
+    _shared_table.reset();
+  }
 #endif
-  return true;
-}
-
-const char* SymbolTable::init_shared_table(const char* buffer) {
-  const char* end = _shared_table.init(
-          CompactHashtable<Symbol*, char>::_symbol_table, buffer);
-  return (const char*)align_ptr_up(end, sizeof(void*));
 }
 
 //---------------------------------------------------------------------------
diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp
index f29698a..5a7db59 100644
--- a/hotspot/src/share/vm/classfile/symbolTable.hpp
+++ b/hotspot/src/share/vm/classfile/symbolTable.hpp
@@ -41,6 +41,7 @@
 
 class BoolObjectClosure;
 class outputStream;
+class SerializeClosure;
 
 // TempNewSymbol acts as a handle class in a handle/body idiom and is
 // responsible for proper resource management of the body (which is a Symbol*).
@@ -251,8 +252,7 @@
   static void read(const char* filename, TRAPS);
 
   // Sharing
-  static bool copy_compact_table(char** top, char* end);
-  static const char* init_shared_table(const char* buffer);
+  static void serialize(SerializeClosure* soc);
 
   // Rehash the symbol table if it gets out of balance
   static void rehash_table();
diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp
index 34c4394..ede6d4f 100644
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp
@@ -1388,12 +1388,12 @@
       ik->restore_unshareable_info(loader_data, protection_domain, CHECK_(nh));
     }
 
-    if (log_is_enabled(Info, classload)) {
+    if (log_is_enabled(Info, class, load)) {
       ik()->print_loading_log(LogLevel::Info, loader_data, NULL, NULL);
     }
     // No 'else' here as logging levels are not mutually exclusive
 
-    if (log_is_enabled(Debug, classload)) {
+    if (log_is_enabled(Debug, class, load)) {
       ik()->print_loading_log(LogLevel::Debug, loader_data, NULL, NULL);
     }
 
diff --git a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp
index 50b5dd8..51db47c 100644
--- a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp
+++ b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp
@@ -29,6 +29,7 @@
 #include "classfile/dictionary.hpp"
 
 class ClassFileStream;
+class SerializeClosure;
 
 class SystemDictionaryShared: public SystemDictionary {
 public:
@@ -77,6 +78,7 @@
                                            TRAPS) {
     return NULL;
   }
+  static void serialize(SerializeClosure* soc) {}
 };
 
 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
diff --git a/hotspot/src/share/vm/classfile/verificationType.cpp b/hotspot/src/share/vm/classfile/verificationType.cpp
index 6245fce..be4594f 100644
--- a/hotspot/src/share/vm/classfile/verificationType.cpp
+++ b/hotspot/src/share/vm/classfile/verificationType.cpp
@@ -61,7 +61,7 @@
     Klass* obj = SystemDictionary::resolve_or_fail(
         name(), Handle(THREAD, klass->class_loader()),
         Handle(THREAD, klass->protection_domain()), true, CHECK_false);
-    if (log_is_enabled(Debug, classresolve)) {
+    if (log_is_enabled(Debug, class, resolve)) {
       Verifier::trace_class_resolution(obj, klass());
     }
 
@@ -80,7 +80,7 @@
       Klass* from_class = SystemDictionary::resolve_or_fail(
           from.name(), Handle(THREAD, klass->class_loader()),
           Handle(THREAD, klass->protection_domain()), true, CHECK_false);
-      if (log_is_enabled(Debug, classresolve)) {
+      if (log_is_enabled(Debug, class, resolve)) {
         Verifier::trace_class_resolution(from_class, klass());
       }
       return InstanceKlass::cast(from_class)->is_subclass_of(this_class());
diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp
index 600ca8e..58200d1 100644
--- a/hotspot/src/share/vm/classfile/verifier.cpp
+++ b/hotspot/src/share/vm/classfile/verifier.cpp
@@ -107,9 +107,9 @@
   const char* resolve = resolve_class->external_name();
   // print in a single call to reduce interleaving between threads
   if (source_file != NULL) {
-    log_debug(classresolve)("%s %s %s (verification)", verify, resolve, source_file);
+    log_debug(class, resolve)("%s %s %s (verification)", verify, resolve, source_file);
   } else {
-    log_debug(classresolve)("%s %s (verification)", verify, resolve);
+    log_debug(class, resolve)("%s %s (verification)", verify, resolve);
   }
 }
 
@@ -169,7 +169,7 @@
   bool can_failover = FailOverToOldVerifier &&
      klass->major_version() < NOFAILOVER_MAJOR_VERSION;
 
-  log_info(classinit)("Start class verification for: %s", klassName);
+  log_info(class, init)("Start class verification for: %s", klassName);
   if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
     ClassVerifier split_verifier(klass, THREAD);
     split_verifier.verify_class(THREAD);
@@ -178,7 +178,7 @@
         (exception_name == vmSymbols::java_lang_VerifyError() ||
          exception_name == vmSymbols::java_lang_ClassFormatError())) {
       log_info(verification)("Fail over class verification to old verifier for: %s", klassName);
-      log_info(classinit)("Fail over class verification to old verifier for: %s", klassName);
+      log_info(class, init)("Fail over class verification to old verifier for: %s", klassName);
       exception_name = inference_verify(
         klass, message_buffer, message_buffer_len, THREAD);
     }
@@ -190,8 +190,8 @@
         klass, message_buffer, message_buffer_len, THREAD);
   }
 
-  if (log_is_enabled(Info, classinit)){
-    log_end_verification(Log(classinit)::info_stream(), klassName, exception_name, THREAD);
+  if (log_is_enabled(Info, class, init)){
+    log_end_verification(Log(class, init)::info_stream(), klassName, exception_name, THREAD);
   }
   if (log_is_enabled(Info, verification)){
     log_end_verification(Log(verification)::info_stream(), klassName, exception_name, THREAD);
@@ -205,7 +205,7 @@
     ResourceMark rm(THREAD);
     instanceKlassHandle kls =
       SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
-    if (log_is_enabled(Debug, classresolve)) {
+    if (log_is_enabled(Debug, class, resolve)) {
       Verifier::trace_class_resolution(kls(), klass());
     }
 
@@ -601,7 +601,7 @@
 
   if (was_recursively_verified()){
     log_info(verification)("Recursive verification detected for: %s", _klass->external_name());
-    log_info(classinit)("Recursive verification detected for: %s",
+    log_info(class, init)("Recursive verification detected for: %s",
                         _klass->external_name());
   }
 }
@@ -1994,7 +1994,7 @@
     name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
     true, THREAD);
 
-  if (log_is_enabled(Debug, classresolve)) {
+  if (log_is_enabled(Debug, class, resolve)) {
     instanceKlassHandle cur_class = current_class();
     Verifier::trace_class_resolution(kls, cur_class());
   }
diff --git a/hotspot/src/share/vm/classfile/verifier.hpp b/hotspot/src/share/vm/classfile/verifier.hpp
index 531ef93..a613c62 100644
--- a/hotspot/src/share/vm/classfile/verifier.hpp
+++ b/hotspot/src/share/vm/classfile/verifier.hpp
@@ -61,7 +61,7 @@
   // Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2.
   static bool relax_verify_for(oop class_loader);
 
-  // Print output for classresolve
+  // Print output for class+resolve
   static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class);
 
  private:
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp
index 4255505..95fa817 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp
@@ -353,6 +353,7 @@
   case vmIntrinsics::_updateCRC32:
   case vmIntrinsics::_updateBytesCRC32:
   case vmIntrinsics::_updateByteBufferCRC32:
+  case vmIntrinsics::_vectorizedMismatch:
     return true;
   default:
     return false;
@@ -384,6 +385,7 @@
   case vmIntrinsics::_updateCRC32:
   case vmIntrinsics::_updateBytesCRC32:
   case vmIntrinsics::_updateByteBufferCRC32:
+  case vmIntrinsics::_vectorizedMismatch:
     return false;
   default:
     return true;
@@ -578,20 +580,6 @@
   case vmIntrinsics::_putLongOpaque:
   case vmIntrinsics::_putFloatOpaque:
   case vmIntrinsics::_putDoubleOpaque:
-  case vmIntrinsics::_getByte_raw:
-  case vmIntrinsics::_getShort_raw:
-  case vmIntrinsics::_getChar_raw:
-  case vmIntrinsics::_getInt_raw:
-  case vmIntrinsics::_getLong_raw:
-  case vmIntrinsics::_getFloat_raw:
-  case vmIntrinsics::_getDouble_raw:
-  case vmIntrinsics::_putByte_raw:
-  case vmIntrinsics::_putShort_raw:
-  case vmIntrinsics::_putChar_raw:
-  case vmIntrinsics::_putInt_raw:
-  case vmIntrinsics::_putLong_raw:
-  case vmIntrinsics::_putFloat_raw:
-  case vmIntrinsics::_putDouble_raw:
   case vmIntrinsics::_getAndAddInt:
   case vmIntrinsics::_getAndAddLong:
   case vmIntrinsics::_getAndSetInt:
@@ -632,8 +620,6 @@
   case vmIntrinsics::_putIntUnaligned:
   case vmIntrinsics::_putLongUnaligned:
   case vmIntrinsics::_allocateInstance:
-  case vmIntrinsics::_getAddress_raw:
-  case vmIntrinsics::_putAddress_raw:
     if (!InlineUnsafeOps || !UseUnalignedAccesses) return true;
     break;
   case vmIntrinsics::_hashCode:
@@ -669,6 +655,9 @@
   case vmIntrinsics::_updateDirectByteBufferCRC32C:
     if (!UseCRC32CIntrinsics) return true;
     break;
+  case vmIntrinsics::_vectorizedMismatch:
+    if (!UseVectorizedMismatchIntrinsic) return true;
+    break;
   case vmIntrinsics::_updateBytesAdler32:
   case vmIntrinsics::_updateByteBufferAdler32:
     if (!UseAdler32Intrinsics) return true;
@@ -734,9 +723,6 @@
   case vmIntrinsics::_montgomerySquare:
     if (!UseMontgomerySquareIntrinsic) return true;
     break;
-  case vmIntrinsics::_vectorizedMismatch:
-    if (!UseVectorizedMismatchIntrinsic) return true;
-    break;
   case vmIntrinsics::_addExactI:
   case vmIntrinsics::_addExactL:
   case vmIntrinsics::_decrementExactI:
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp
index 7586786..6f69aaf 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp
@@ -117,6 +117,7 @@
   template(java_util_Hashtable,                       "java/util/Hashtable")                      \
   template(java_lang_Compiler,                        "java/lang/Compiler")                       \
   template(jdk_internal_misc_Signal,                  "jdk/internal/misc/Signal")                 \
+  template(jdk_internal_util_Preconditions,           "jdk/internal/util/Preconditions")          \
   template(java_lang_AssertionStatusDirectives,       "java/lang/AssertionStatusDirectives")      \
   template(getBootClassPathEntryForClass_name,        "getBootClassPathEntryForClass")            \
   template(jdk_internal_vm_PostVMInitHook,            "jdk/internal/vm/PostVMInitHook")           \
@@ -876,6 +877,10 @@
    do_name(     newArray_name,                                    "newArray")                                           \
    do_signature(newArray_signature,                               "(Ljava/lang/Class;I)Ljava/lang/Object;")             \
                                                                                                                         \
+  do_intrinsic(_onSpinWait,               java_lang_Thread,       onSpinWait_name, onSpinWait_signature,         F_S)   \
+   do_name(     onSpinWait_name,                                  "onSpinWait")                                         \
+   do_alias(    onSpinWait_signature,                             void_method_signature)                                \
+                                                                                                                        \
   do_intrinsic(_copyOf,                   java_util_Arrays,       copyOf_name, copyOf_signature,                 F_S)   \
    do_name(     copyOf_name,                                     "copyOf")                                              \
    do_signature(copyOf_signature,             "([Ljava/lang/Object;ILjava/lang/Class;)[Ljava/lang/Object;")             \
@@ -930,8 +935,8 @@
   do_intrinsic(_equalsL,                  java_lang_StringLatin1,equals_name, equalsB_signature,                 F_S)   \
   do_intrinsic(_equalsU,                  java_lang_StringUTF16, equals_name, equalsB_signature,                 F_S)   \
                                                                                                                         \
-  do_intrinsic(_Objects_checkIndex,       java_util_Objects,      checkIndex_name, Objects_checkIndex_signature, F_S)   \
-   do_signature(Objects_checkIndex_signature,                     "(IILjava/util/function/BiFunction;)I")               \
+  do_intrinsic(_Preconditions_checkIndex, jdk_internal_util_Preconditions, checkIndex_name, Preconditions_checkIndex_signature, F_S)   \
+   do_signature(Preconditions_checkIndex_signature,              "(IILjava/util/function/BiFunction;)I")                \
                                                                                                                         \
   do_class(java_nio_Buffer,               "java/nio/Buffer")                                                            \
   do_intrinsic(_checkIndex,               java_nio_Buffer,        checkIndex_name, int_int_signature,            F_R)   \
@@ -1227,43 +1232,6 @@
   do_intrinsic(_putIntUnaligned,           jdk_internal_misc_Unsafe,    putIntUnaligned_name, putInt_signature,         F_R)  \
   do_intrinsic(_putLongUnaligned,          jdk_internal_misc_Unsafe,    putLongUnaligned_name, putLong_signature,       F_R)  \
                                                                                                                         \
-  /* %%% these are redundant except perhaps for getAddress, but Unsafe has native methods for them */                   \
-  do_signature(getByte_raw_signature,     "(J)B")                                                                       \
-  do_signature(putByte_raw_signature,     "(JB)V")                                                                      \
-  do_signature(getShort_raw_signature,    "(J)S")                                                                       \
-  do_signature(putShort_raw_signature,    "(JS)V")                                                                      \
-  do_signature(getChar_raw_signature,     "(J)C")                                                                       \
-  do_signature(putChar_raw_signature,     "(JC)V")                                                                      \
-  do_signature(putInt_raw_signature,      "(JI)V")                                                                      \
-      do_alias(getLong_raw_signature,    /*(J)J*/ long_long_signature)                                                  \
-      do_alias(putLong_raw_signature,    /*(JJ)V*/ long_long_void_signature)                                            \
-  do_signature(getFloat_raw_signature,    "(J)F")                                                                       \
-  do_signature(putFloat_raw_signature,    "(JF)V")                                                                      \
-      do_alias(getDouble_raw_signature,  /*(J)D*/ long_double_signature)                                                \
-  do_signature(putDouble_raw_signature,   "(JD)V")                                                                      \
-      do_alias(getAddress_raw_signature, /*(J)J*/ long_long_signature)                                                  \
-      do_alias(putAddress_raw_signature, /*(JJ)V*/ long_long_void_signature)                                            \
-                                                                                                                        \
-   do_name(    getAddress_name,           "getAddress")                                                                 \
-   do_name(    putAddress_name,           "putAddress")                                                                 \
-                                                                                                                        \
-  do_intrinsic(_getByte_raw,              jdk_internal_misc_Unsafe,     getByte_name, getByte_raw_signature,           F_R)  \
-  do_intrinsic(_getShort_raw,             jdk_internal_misc_Unsafe,     getShort_name, getShort_raw_signature,         F_R)  \
-  do_intrinsic(_getChar_raw,              jdk_internal_misc_Unsafe,     getChar_name, getChar_raw_signature,           F_R)  \
-  do_intrinsic(_getInt_raw,               jdk_internal_misc_Unsafe,     getInt_name, long_int_signature,               F_R)  \
-  do_intrinsic(_getLong_raw,              jdk_internal_misc_Unsafe,     getLong_name, getLong_raw_signature,           F_R)  \
-  do_intrinsic(_getFloat_raw,             jdk_internal_misc_Unsafe,     getFloat_name, getFloat_raw_signature,         F_R)  \
-  do_intrinsic(_getDouble_raw,            jdk_internal_misc_Unsafe,     getDouble_name, getDouble_raw_signature,       F_R)  \
-  do_intrinsic(_getAddress_raw,           jdk_internal_misc_Unsafe,     getAddress_name, getAddress_raw_signature,     F_R)  \
-  do_intrinsic(_putByte_raw,              jdk_internal_misc_Unsafe,     putByte_name, putByte_raw_signature,           F_R)  \
-  do_intrinsic(_putShort_raw,             jdk_internal_misc_Unsafe,     putShort_name, putShort_raw_signature,         F_R)  \
-  do_intrinsic(_putChar_raw,              jdk_internal_misc_Unsafe,     putChar_name, putChar_raw_signature,           F_R)  \
-  do_intrinsic(_putInt_raw,               jdk_internal_misc_Unsafe,     putInt_name, putInt_raw_signature,             F_R)  \
-  do_intrinsic(_putLong_raw,              jdk_internal_misc_Unsafe,     putLong_name, putLong_raw_signature,           F_R)  \
-  do_intrinsic(_putFloat_raw,             jdk_internal_misc_Unsafe,     putFloat_name, putFloat_raw_signature,         F_R)  \
-  do_intrinsic(_putDouble_raw,            jdk_internal_misc_Unsafe,     putDouble_name, putDouble_raw_signature,       F_R)  \
-  do_intrinsic(_putAddress_raw,           jdk_internal_misc_Unsafe,     putAddress_name, putAddress_raw_signature,     F_R)  \
-                                                                                                                        \
   do_signature(compareAndSwapObject_signature,     "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z")        \
   do_signature(compareAndExchangeObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;") \
   do_signature(compareAndSwapLong_signature,       "(Ljava/lang/Object;JJJ)Z")                                          \
@@ -1287,12 +1255,15 @@
   do_name(weakCompareAndSwapObject_name,         "weakCompareAndSwapObject")                                            \
   do_name(weakCompareAndSwapObjectAcquire_name,  "weakCompareAndSwapObjectAcquire")                                     \
   do_name(weakCompareAndSwapObjectRelease_name,  "weakCompareAndSwapObjectRelease")                                     \
+  do_name(weakCompareAndSwapObjectVolatile_name, "weakCompareAndSwapObjectVolatile")                                    \
   do_name(weakCompareAndSwapLong_name,           "weakCompareAndSwapLong")                                              \
   do_name(weakCompareAndSwapLongAcquire_name,    "weakCompareAndSwapLongAcquire")                                       \
   do_name(weakCompareAndSwapLongRelease_name,    "weakCompareAndSwapLongRelease")                                       \
+  do_name(weakCompareAndSwapLongVolatile_name,   "weakCompareAndSwapLongVolatile")                                      \
   do_name(weakCompareAndSwapInt_name,            "weakCompareAndSwapInt")                                               \
   do_name(weakCompareAndSwapIntAcquire_name,     "weakCompareAndSwapIntAcquire")                                        \
   do_name(weakCompareAndSwapIntRelease_name,     "weakCompareAndSwapIntRelease")                                        \
+  do_name(weakCompareAndSwapIntVolatile_name,    "weakCompareAndSwapIntVolatile")                                       \
                                                                                                                         \
   do_intrinsic(_compareAndSwapObject,             jdk_internal_misc_Unsafe,  compareAndSwapObject_name,             compareAndSwapObject_signature,     F_RN) \
   do_intrinsic(_compareAndExchangeObjectVolatile, jdk_internal_misc_Unsafe,  compareAndExchangeObjectVolatile_name, compareAndExchangeObject_signature, F_RN) \
@@ -1310,12 +1281,15 @@
   do_intrinsic(_weakCompareAndSwapObject,         jdk_internal_misc_Unsafe,  weakCompareAndSwapObject_name,         compareAndSwapObject_signature,     F_R) \
   do_intrinsic(_weakCompareAndSwapObjectAcquire,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectAcquire_name,  compareAndSwapObject_signature,     F_R) \
   do_intrinsic(_weakCompareAndSwapObjectRelease,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectRelease_name,  compareAndSwapObject_signature,     F_R) \
+  do_intrinsic(_weakCompareAndSwapObjectVolatile, jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectVolatile_name, compareAndSwapObject_signature,     F_R) \
   do_intrinsic(_weakCompareAndSwapLong,           jdk_internal_misc_Unsafe,  weakCompareAndSwapLong_name,           compareAndSwapLong_signature,       F_R) \
   do_intrinsic(_weakCompareAndSwapLongAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSwapLongAcquire_name,    compareAndSwapLong_signature,       F_R) \
   do_intrinsic(_weakCompareAndSwapLongRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSwapLongRelease_name,    compareAndSwapLong_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSwapLongVolatile,   jdk_internal_misc_Unsafe,  weakCompareAndSwapLongVolatile_name,   compareAndSwapLong_signature,       F_R) \
   do_intrinsic(_weakCompareAndSwapInt,            jdk_internal_misc_Unsafe,  weakCompareAndSwapInt_name,            compareAndSwapInt_signature,        F_R) \
   do_intrinsic(_weakCompareAndSwapIntAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntAcquire_name,     compareAndSwapInt_signature,        F_R) \
   do_intrinsic(_weakCompareAndSwapIntRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntRelease_name,     compareAndSwapInt_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSwapIntVolatile,    jdk_internal_misc_Unsafe,  weakCompareAndSwapIntVolatile_name,    compareAndSwapInt_signature,        F_R) \
                                                                                                                         \
   do_intrinsic(_getAndAddInt,             jdk_internal_misc_Unsafe,     getAndAddInt_name, getAndAddInt_signature, F_R)       \
    do_name(     getAndAddInt_name,                                      "getAndAddInt")                                       \
diff --git a/hotspot/src/share/vm/code/codeBlob.cpp b/hotspot/src/share/vm/code/codeBlob.cpp
index 38cae60..91d231e 100644
--- a/hotspot/src/share/vm/code/codeBlob.cpp
+++ b/hotspot/src/share/vm/code/codeBlob.cpp
@@ -65,12 +65,67 @@
   return size;
 }
 
+CodeBlob::CodeBlob(const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :
+  _name(name),
+  _size(layout.size()),
+  _header_size(layout.header_size()),
+  _frame_complete_offset(frame_complete_offset),
+  _data_offset(layout.data_offset()),
+  _frame_size(frame_size),
+  _strings(CodeStrings()),
+  _oop_maps(oop_maps),
+  _caller_must_gc_arguments(caller_must_gc_arguments),
+  _code_begin(layout.code_begin()),
+  _code_end(layout.code_end()),
+  _data_end(layout.data_end()),
+  _relocation_begin(layout.relocation_begin()),
+  _relocation_end(layout.relocation_end()),
+  _content_begin(layout.content_begin())
+{
+  assert(layout.size()        == round_to(layout.size(),        oopSize), "unaligned size");
+  assert(layout.header_size() == round_to(layout.header_size(), oopSize), "unaligned size");
+  assert(layout.relocation_size() == round_to(layout.relocation_size(), oopSize), "unaligned size");
+  assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
+#ifdef COMPILER1
+  // probably wrong for tiered
+  assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
+#endif // COMPILER1
+}
+
+CodeBlob::CodeBlob(const char* name, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :
+  _name(name),
+  _size(layout.size()),
+  _header_size(layout.header_size()),
+  _frame_complete_offset(frame_complete_offset),
+  _data_offset(layout.data_offset()),
+  _frame_size(frame_size),
+  _strings(CodeStrings()),
+  _caller_must_gc_arguments(caller_must_gc_arguments),
+  _code_begin(layout.code_begin()),
+  _code_end(layout.code_end()),
+  _data_end(layout.data_end()),
+  _relocation_begin(layout.relocation_begin()),
+  _relocation_end(layout.relocation_end()),
+  _content_begin(layout.content_begin())
+{
+  assert(_size        == round_to(_size,        oopSize), "unaligned size");
+  assert(_header_size == round_to(_header_size, oopSize), "unaligned size");
+  assert(_data_offset <= _size, "codeBlob is too small");
+  assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
+
+  set_oop_maps(oop_maps);
+#ifdef COMPILER1
+  // probably wrong for tiered
+  assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
+#endif // COMPILER1
+}
+
 
 // Creates a simple CodeBlob. Sets up the size of the different regions.
-CodeBlob::CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size) {
-  assert(size        == round_to(size,        oopSize), "unaligned size");
+RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size)
+  : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)
+{
   assert(locs_size   == round_to(locs_size,   oopSize), "unaligned size");
-  assert(header_size == round_to(header_size, oopSize), "unaligned size");
   assert(!UseRelocIndex, "no space allocated for reloc index yet");
 
   // Note: If UseRelocIndex is enabled, there needs to be (at least) one
@@ -79,55 +134,31 @@
   //       mentation is not easily understandable and thus it is not clear
   //       what exactly the format is supposed to be. For now, we just turn
   //       off the use of this table (gri 7/6/2000).
-
-  _name                  = name;
-  _size                  = size;
-  _frame_complete_offset = frame_complete;
-  _header_size           = header_size;
-  _relocation_size       = locs_size;
-  _content_offset        = align_code_offset(header_size + _relocation_size);
-  _code_offset           = _content_offset;
-  _data_offset           = size;
-  _frame_size            =  0;
-  set_oop_maps(NULL);
-  _strings               = CodeStrings();
 }
 
 
-// Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions,
+// Creates a RuntimeBlob from a CodeBuffer
 // and copy code and relocation info.
-CodeBlob::CodeBlob(
+RuntimeBlob::RuntimeBlob(
   const char* name,
   CodeBuffer* cb,
   int         header_size,
   int         size,
   int         frame_complete,
   int         frame_size,
-  OopMapSet*  oop_maps
-) {
-  assert(size        == round_to(size,        oopSize), "unaligned size");
-  assert(header_size == round_to(header_size, oopSize), "unaligned size");
-
-  _name                  = name;
-  _size                  = size;
-  _frame_complete_offset = frame_complete;
-  _header_size           = header_size;
-  _relocation_size       = round_to(cb->total_relocation_size(), oopSize);
-  _content_offset        = align_code_offset(header_size + _relocation_size);
-  _code_offset           = _content_offset + cb->total_offset_of(cb->insts());
-  _data_offset           = _content_offset + round_to(cb->total_content_size(), oopSize);
-  assert(_data_offset <= size, "codeBlob is too small");
-  _strings               = CodeStrings();
-
+  OopMapSet*  oop_maps,
+  bool        caller_must_gc_arguments
+) : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) {
   cb->copy_code_and_locs_to(this);
-  set_oop_maps(oop_maps);
-  _frame_size = frame_size;
-#ifdef COMPILER1
-  // probably wrong for tiered
-  assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
-#endif // COMPILER1
 }
 
+void CodeBlob::flush() {
+  if (_oop_maps) {
+    FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
+    _oop_maps = NULL;
+  }
+  _strings.free();
+}
 
 void CodeBlob::set_oop_maps(OopMapSet* p) {
   // Danger Will Robinson! This method allocates a big
@@ -140,7 +171,7 @@
 }
 
 
-void CodeBlob::trace_new_stub(CodeBlob* stub, const char* name1, const char* name2) {
+void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) {
   // Do not hold the CodeCache lock during name formatting.
   assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");
 
@@ -167,19 +198,9 @@
   MemoryService::track_code_cache_memory_usage();
 }
 
-
-void CodeBlob::flush() {
-  if (_oop_maps) {
-    FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
-    _oop_maps = NULL;
-  }
-  _strings.free();
-}
-
-
 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
-  assert(oop_maps() != NULL, "nope");
-  return oop_maps()->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
+  assert(_oop_maps != NULL, "nope");
+  return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
 }
 
 void CodeBlob::print_code() {
@@ -193,7 +214,7 @@
 
 
 BufferBlob::BufferBlob(const char* name, int size)
-: CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
+: RuntimeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
 {}
 
 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
@@ -203,7 +224,7 @@
   unsigned int size = sizeof(BufferBlob);
   CodeCacheExtensions::size_blob(name, &buffer_size);
   // align the size to CodeEntryAlignment
-  size = align_code_offset(size);
+  size = CodeBlob::align_code_offset(size);
   size += round_to(buffer_size, oopSize);
   assert(name != NULL, "must provide a name");
   {
@@ -218,14 +239,14 @@
 
 
 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb)
-  : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL)
+  : RuntimeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL)
 {}
 
 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 
   BufferBlob* blob = NULL;
-  unsigned int size = allocation_size(cb, sizeof(BufferBlob));
+  unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));
   assert(name != NULL, "must provide a name");
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
@@ -246,7 +267,7 @@
   blob->flush();
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    CodeCache::free((CodeBlob*)blob);
+    CodeCache::free((RuntimeBlob*)blob);
   }
   // Track memory usage statistic after releasing CodeCache_lock
   MemoryService::track_code_cache_memory_usage();
@@ -265,7 +286,7 @@
   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 
   AdapterBlob* blob = NULL;
-  unsigned int size = allocation_size(cb, sizeof(AdapterBlob));
+  unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob));
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
     blob = new (size) AdapterBlob(size, cb);
@@ -287,7 +308,7 @@
   unsigned int size = sizeof(MethodHandlesAdapterBlob);
   CodeCacheExtensions::size_blob("MethodHandles adapters", &buffer_size);
   // align the size to CodeEntryAlignment
-  size = align_code_offset(size);
+  size = CodeBlob::align_code_offset(size);
   size += round_to(buffer_size, oopSize);
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
@@ -314,12 +335,10 @@
   OopMapSet*  oop_maps,
   bool        caller_must_gc_arguments
 )
-: CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps)
+: RuntimeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments)
 {
-  _caller_must_gc_arguments = caller_must_gc_arguments;
 }
 
-
 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
                                            CodeBuffer* cb,
                                            int frame_complete,
@@ -332,7 +351,7 @@
   if (!CodeCacheExtensions::skip_code_generation()) {
     // bypass useless code generation
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    unsigned int size = allocation_size(cb, sizeof(RuntimeStub));
+    unsigned int size = CodeBlob::allocation_size(cb, sizeof(RuntimeStub));
     stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
   }
   stub = (RuntimeStub*) CodeCacheExtensions::handle_generated_blob(stub, stub_name);
@@ -392,7 +411,7 @@
   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    unsigned int size = allocation_size(cb, sizeof(DeoptimizationBlob));
+    unsigned int size = CodeBlob::allocation_size(cb, sizeof(DeoptimizationBlob));
     blob = new (size) DeoptimizationBlob(cb,
                                          size,
                                          oop_maps,
@@ -431,7 +450,7 @@
   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    unsigned int size = allocation_size(cb, sizeof(UncommonTrapBlob));
+    unsigned int size = CodeBlob::allocation_size(cb, sizeof(UncommonTrapBlob));
     blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size);
   }
 
@@ -467,7 +486,7 @@
   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    unsigned int size = allocation_size(cb, sizeof(ExceptionBlob));
+    unsigned int size = CodeBlob::allocation_size(cb, sizeof(ExceptionBlob));
     blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size);
   }
 
@@ -502,7 +521,7 @@
   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    unsigned int size = allocation_size(cb, sizeof(SafepointBlob));
+    unsigned int size = CodeBlob::allocation_size(cb, sizeof(SafepointBlob));
     blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size);
   }
 
@@ -515,10 +534,6 @@
 //----------------------------------------------------------------------------------------------------
 // Verification and printing
 
-void CodeBlob::verify() {
-  ShouldNotReachHere();
-}
-
 void CodeBlob::print_on(outputStream* st) const {
   st->print_cr("[CodeBlob (" INTPTR_FORMAT ")]", p2i(this));
   st->print_cr("Framesize: %d", _frame_size);
@@ -528,12 +543,16 @@
   st->print_cr("[CodeBlob]");
 }
 
+void RuntimeBlob::verify() {
+  ShouldNotReachHere();
+}
+
 void BufferBlob::verify() {
   // unimplemented
 }
 
 void BufferBlob::print_on(outputStream* st) const {
-  CodeBlob::print_on(st);
+  RuntimeBlob::print_on(st);
   print_value_on(st);
 }
 
@@ -547,10 +566,10 @@
 
 void RuntimeStub::print_on(outputStream* st) const {
   ttyLocker ttyl;
-  CodeBlob::print_on(st);
+  RuntimeBlob::print_on(st);
   st->print("Runtime Stub (" INTPTR_FORMAT "): ", p2i(this));
   st->print_cr("%s", name());
-  Disassembler::decode((CodeBlob*)this, st);
+  Disassembler::decode((RuntimeBlob*)this, st);
 }
 
 void RuntimeStub::print_value_on(outputStream* st) const {
@@ -563,9 +582,9 @@
 
 void SingletonBlob::print_on(outputStream* st) const {
   ttyLocker ttyl;
-  CodeBlob::print_on(st);
+  RuntimeBlob::print_on(st);
   st->print_cr("%s", name());
-  Disassembler::decode((CodeBlob*)this, st);
+  Disassembler::decode((RuntimeBlob*)this, st);
 }
 
 void SingletonBlob::print_value_on(outputStream* st) const {
diff --git a/hotspot/src/share/vm/code/codeBlob.hpp b/hotspot/src/share/vm/code/codeBlob.hpp
index 4a45f6b..30105e3 100644
--- a/hotspot/src/share/vm/code/codeBlob.hpp
+++ b/hotspot/src/share/vm/code/codeBlob.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,12 +45,14 @@
 
 // CodeBlob - superclass for all entries in the CodeCache.
 //
-// Suptypes are:
-//   nmethod            : Compiled Java methods (include method that calls to native code)
-//   RuntimeStub        : Call to VM runtime methods
-//   DeoptimizationBlob : Used for deoptimizatation
-//   ExceptionBlob      : Used for stack unrolling
-//   SafepointBlob      : Used to handle illegal instruction exceptions
+// Subtypes are:
+//   CompiledMethod       : Compiled Java methods (include method that calls to native code)
+//     nmethod            : JIT Compiled Java methods
+//   RuntimeBlob          : Non-compiled method code; generated glue code
+//     RuntimeStub        : Call to VM runtime methods
+//     DeoptimizationBlob : Used for deoptimization
+//     ExceptionBlob      : Used for stack unrolling
+//     SafepointBlob      : Used to handle illegal instruction exceptions
 //
 //
 // Layout:
@@ -59,90 +61,79 @@
 //   - content space
 //     - instruction space
 //   - data space
-class DeoptimizationBlob;
+
+
+class CodeBlobLayout;
 
 class CodeBlob VALUE_OBJ_CLASS_SPEC {
-
   friend class VMStructs;
   friend class JVMCIVMStructs;
   friend class CodeCacheDumper;
 
- private:
+protected:
   const char* _name;
   int        _size;                              // total size of CodeBlob in bytes
   int        _header_size;                       // size of header (depends on subclass)
-  int        _relocation_size;                   // size of relocation
-  int        _content_offset;                    // offset to where content region begins (this includes consts, insts, stubs)
-  int        _code_offset;                       // offset to where instructions region begins (this includes insts, stubs)
   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
                                                  // not finished setting up their frame. Beware of pc's in
                                                  // that range. There is a similar range(s) on returns
                                                  // which we don't detect.
   int        _data_offset;                       // offset to where data region begins
   int        _frame_size;                        // size of stack frame
-  ImmutableOopMapSet* _oop_maps;                 // OopMap for this CodeBlob
-  CodeStrings _strings;
 
- public:
+  address    _code_begin;
+  address    _code_end;
+  address    _content_begin;                     // address to where content region begins (this includes consts, insts, stubs)
+                                                 // address    _content_end - not required, for all CodeBlobs _code_end == _content_end for now
+  address    _data_end;
+  address    _relocation_begin;
+  address    _relocation_end;
+
+  ImmutableOopMapSet* _oop_maps;                 // OopMap for this CodeBlob
+  bool                _caller_must_gc_arguments;
+  CodeStrings         _strings;
+
+  CodeBlob(const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
+  CodeBlob(const char* name, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
+public:
   // Returns the space needed for CodeBlob
   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
   static unsigned int align_code_offset(int offset);
 
-  // Creation
-  // a) simple CodeBlob
-  // frame_complete is the offset from the beginning of the instructions
-  // to where the frame setup (from stackwalk viewpoint) is complete.
-  CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
-
-  // b) full CodeBlob
-  CodeBlob(
-    const char* name,
-    CodeBuffer* cb,
-    int         header_size,
-    int         size,
-    int         frame_complete,
-    int         frame_size,
-    OopMapSet*  oop_maps
-  );
-
   // Deletion
-  void flush();
+  virtual void flush();
 
   // Typing
-  virtual bool is_buffer_blob() const            { return false; }
-  virtual bool is_nmethod() const                { return false; }
-  virtual bool is_runtime_stub() const           { return false; }
-  virtual bool is_deoptimization_stub() const    { return false; }
-  virtual bool is_uncommon_trap_stub() const     { return false; }
-  virtual bool is_exception_stub() const         { return false; }
+  virtual bool is_buffer_blob() const                 { return false; }
+  virtual bool is_nmethod() const                     { return false; }
+  virtual bool is_runtime_stub() const                { return false; }
+  virtual bool is_deoptimization_stub() const         { return false; }
+  virtual bool is_uncommon_trap_stub() const          { return false; }
+  virtual bool is_exception_stub() const              { return false; }
   virtual bool is_safepoint_stub() const              { return false; }
   virtual bool is_adapter_blob() const                { return false; }
   virtual bool is_method_handles_adapter_blob() const { return false; }
+  virtual bool is_compiled() const                    { return false; }
 
   virtual bool is_compiled_by_c2() const         { return false; }
   virtual bool is_compiled_by_c1() const         { return false; }
   virtual bool is_compiled_by_jvmci() const      { return false; }
 
   // Casting
-  nmethod* as_nmethod_or_null()                  { return is_nmethod() ? (nmethod*) this : NULL; }
+  nmethod* as_nmethod_or_null()                { return is_nmethod() ? (nmethod*) this : NULL; }
+  nmethod* as_nmethod()                        { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
+  CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; }
+  CompiledMethod* as_compiled_method()         { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
 
   // Boundaries
-  address    header_begin() const                { return (address)    this; }
-  address    header_end() const                  { return ((address)   this) + _header_size; };
-  relocInfo* relocation_begin() const            { return (relocInfo*) header_end(); };
-  relocInfo* relocation_end() const              { return (relocInfo*)(header_end()   + _relocation_size); }
-  address    content_begin() const               { return (address)    header_begin() + _content_offset; }
-  address    content_end() const                 { return (address)    header_begin() + _data_offset; }
-  address    code_begin() const                  { return (address)    header_begin() + _code_offset; }
-  address    code_end() const                    { return (address)    header_begin() + _data_offset; }
-  address    data_begin() const                  { return (address)    header_begin() + _data_offset; }
-  address    data_end() const                    { return (address)    header_begin() + _size; }
-
-  // Offsets
-  int relocation_offset() const                  { return _header_size; }
-  int content_offset() const                     { return _content_offset; }
-  int code_offset() const                        { return _code_offset; }
-  int data_offset() const                        { return _data_offset; }
+  address header_begin() const        { return (address) this; }
+  relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
+  relocInfo* relocation_end() const   { return (relocInfo*) _relocation_end; }
+  address content_begin() const       { return _content_begin; }
+  address content_end() const         { return _code_end; } // _code_end == _content_end is true for all types of blobs for now, it is also checked in the constructor
+  address code_begin() const          { return _code_begin;    }
+  address code_end() const            { return _code_end; }
+  address data_end() const            { return _data_end;      }
 
   // Sizes
   int size() const                               { return _size; }
@@ -150,17 +141,12 @@
   int relocation_size() const                    { return (address) relocation_end() - (address) relocation_begin(); }
   int content_size() const                       { return           content_end()    -           content_begin();    }
   int code_size() const                          { return           code_end()       -           code_begin();       }
-  int data_size() const                          { return           data_end()       -           data_begin();       }
 
   // Containment
   bool blob_contains(address addr) const         { return header_begin()       <= addr && addr < data_end();       }
-  bool relocation_contains(relocInfo* addr) const{ return relocation_begin()   <= addr && addr < relocation_end(); }
-  bool content_contains(address addr) const      { return content_begin()      <= addr && addr < content_end();    }
   bool code_contains(address addr) const         { return code_begin()         <= addr && addr < code_end();       }
-  bool data_contains(address addr) const         { return data_begin()         <= addr && addr < data_end();       }
-  bool contains(address addr) const              { return content_contains(addr); }
-  bool is_frame_complete_at(address addr) const  { return code_contains(addr) &&
-                                                          addr >= code_begin() + _frame_complete_offset; }
+  bool contains(address addr) const              { return content_begin()      <= addr && addr < content_end();    }
+  bool is_frame_complete_at(address addr) const  { return code_contains(addr) && addr >= code_begin() + _frame_complete_offset; }
 
   // CodeCache support: really only used by the nmethods, but in order to get
   // asserts and certain bookkeeping to work in the CodeCache they are defined
@@ -178,29 +164,26 @@
   ImmutableOopMapSet* oop_maps() const           { return _oop_maps; }
   void set_oop_maps(OopMapSet* p);
   const ImmutableOopMap* oop_map_for_return_address(address return_address);
-  virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { ShouldNotReachHere(); }
+  virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0;
 
   // Frame support
   int  frame_size() const                        { return _frame_size; }
   void set_frame_size(int size)                  { _frame_size = size; }
 
   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
-  virtual bool caller_must_gc_arguments(JavaThread* thread) const { return false; }
+  bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
 
   // Naming
   const char* name() const                       { return _name; }
   void set_name(const char* name)                { _name = name; }
 
   // Debugging
-  virtual void verify();
-  void print() const                             { print_on(tty); }
+  virtual void verify() = 0;
+  virtual void print() const                     { print_on(tty); };
   virtual void print_on(outputStream* st) const;
   virtual void print_value_on(outputStream* st) const;
   void print_code();
 
-  // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
-  static void trace_new_stub(CodeBlob* blob, const char* name1, const char* name2 = "");
-
   // Print the comment associated with offset on stream, if there is one
   virtual void print_block_comment(outputStream* stream, address block_begin) const {
     intptr_t offset = (intptr_t)(block_begin - code_begin());
@@ -221,11 +204,142 @@
   }
 };
 
+class CodeBlobLayout : public StackObj {
+private:
+  int _size;
+  int _header_size;
+  int _relocation_size;
+  int _content_offset;
+  int _code_offset;
+  int _data_offset;
+  address _code_begin;
+  address _code_end;
+  address _content_begin;
+  address _content_end;
+  address _data_end;
+  address _relocation_begin;
+  address _relocation_end;
+
+public:
+  CodeBlobLayout(address code_begin, address code_end, address content_begin, address content_end, address data_end, address relocation_begin, address relocation_end) :
+    _size(0),
+    _header_size(0),
+    _relocation_size(0),
+    _content_offset(0),
+    _code_offset(0),
+    _data_offset(0),
+    _content_begin(content_begin),
+    _content_end(content_end),
+    _code_begin(code_begin),
+    _code_end(code_end),
+    _data_end(data_end),
+    _relocation_begin(relocation_begin),
+    _relocation_end(relocation_end)
+  {
+  }
+
+  CodeBlobLayout(const address start, int size, int header_size, int relocation_size, int data_offset) :
+    _size(size),
+    _header_size(header_size),
+    _relocation_size(relocation_size),
+    _content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)),
+    _code_offset(_content_offset),
+    _data_offset(data_offset)
+  {
+    assert(_relocation_size == round_to(_relocation_size, oopSize), "unaligned size");
+
+    _code_begin = (address) start + _code_offset;
+    _code_end = (address) start + _data_offset;
+
+    _content_begin = (address) start + _content_offset;
+    _content_end = (address) start + _data_offset;
+
+    _data_end = (address) start + _size;
+    _relocation_begin = (address) start + _header_size;
+    _relocation_end = _relocation_begin + _relocation_size;
+  }
+
+  CodeBlobLayout(const address start, int size, int header_size, const CodeBuffer* cb) :
+    _size(size),
+    _header_size(header_size),
+    _relocation_size(round_to(cb->total_relocation_size(), oopSize)),
+    _content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)),
+    _code_offset(_content_offset + cb->total_offset_of(cb->insts())),
+    _data_offset(_content_offset + round_to(cb->total_content_size(), oopSize))
+  {
+    assert(_relocation_size == round_to(_relocation_size, oopSize), "unaligned size");
+
+    _code_begin = (address) start + _code_offset;
+    _code_end = (address) start + _data_offset;
+
+    _content_begin = (address) start + _content_offset;
+    _content_end = (address) start + _data_offset;
+
+    _data_end = (address) start + _size;
+    _relocation_begin = (address) start + _header_size;
+    _relocation_end = _relocation_begin + _relocation_size;
+  }
+
+  int size() const { return _size; }
+  int header_size() const { return _header_size; }
+  int relocation_size() const { return _relocation_size; }
+  int content_offset() const { return _content_offset; }
+  int code_offset() const { return _code_offset; }
+  int data_offset() const { return _data_offset; }
+  address code_begin() const { return _code_begin; }
+  address code_end() const { return _code_end; }
+  address data_end() const { return _data_end; }
+  address relocation_begin() const { return _relocation_begin; }
+  address relocation_end() const { return _relocation_end; }
+  address content_begin() const { return _content_begin; }
+  address content_end() const { return _content_end; }
+};
+
+
+class RuntimeBlob : public CodeBlob {
+  friend class VMStructs;
+ public:
+
+  // Creation
+  // a) simple CodeBlob
+  // frame_complete is the offset from the beginning of the instructions
+  // to where the frame setup (from stackwalk viewpoint) is complete.
+  RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
+
+  // b) full CodeBlob
+  RuntimeBlob(
+    const char* name,
+    CodeBuffer* cb,
+    int         header_size,
+    int         size,
+    int         frame_complete,
+    int         frame_size,
+    OopMapSet*  oop_maps,
+    bool        caller_must_gc_arguments = false
+  );
+
+  // GC support
+  virtual bool is_alive() const                  = 0;
+
+  void verify();
+
+  // OopMap for frame
+  virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { ShouldNotReachHere(); }
+
+  // Debugging
+  void print() const                             { print_on(tty); }
+  virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
+  virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }
+
+  // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
+  static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
+};
+
 class WhiteBox;
 //----------------------------------------------------------------------------------------------------
 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
 
-class BufferBlob: public CodeBlob {
+class BufferBlob: public RuntimeBlob {
   friend class VMStructs;
   friend class AdapterBlob;
   friend class MethodHandlesAdapterBlob;
@@ -293,11 +407,9 @@
 //----------------------------------------------------------------------------------------------------
 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
 
-class RuntimeStub: public CodeBlob {
+class RuntimeStub: public RuntimeBlob {
   friend class VMStructs;
  private:
-  bool        _caller_must_gc_arguments;
-
   // Creation support
   RuntimeStub(
     const char* name,
@@ -325,10 +437,7 @@
   // Typing
   bool is_runtime_stub() const                   { return true; }
 
-  // GC support
-  bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
-
-  address entry_point()                          { return code_begin(); }
+  address entry_point() const                    { return code_begin(); }
 
   // GC/Verification support
   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f)  { /* nothing to do */ }
@@ -343,7 +452,7 @@
 //----------------------------------------------------------------------------------------------------
 // Super-class for all blobs that exist in only one instance. Implements default behaviour.
 
-class SingletonBlob: public CodeBlob {
+class SingletonBlob: public RuntimeBlob {
   friend class VMStructs;
 
  protected:
@@ -358,13 +467,15 @@
      int         frame_size,
      OopMapSet*  oop_maps
    )
-   : CodeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
+   : RuntimeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
   {};
 
   address entry_point()                          { return code_begin(); }
 
   bool is_alive() const                          { return true; }
 
+  // GC/Verification support
+  void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f)  { /* nothing to do */ }
   void verify(); // does nothing
   void print_on(outputStream* st) const;
   void print_value_on(outputStream* st) const;
diff --git a/hotspot/src/share/vm/code/codeCache.cpp b/hotspot/src/share/vm/code/codeCache.cpp
index f2dfcee..36e33c4 100644
--- a/hotspot/src/share/vm/code/codeCache.cpp
+++ b/hotspot/src/share/vm/code/codeCache.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -336,7 +336,7 @@
   if (!SegmentedCodeCache) {
     // No segmentation: use a single code heap
     return (code_blob_type == CodeBlobType::All);
-  } else if (Arguments::mode() == Arguments::_int) {
+  } else if (Arguments::is_interpreter_only()) {
     // Interpreter only: we don't need any method code heaps
     return (code_blob_type == CodeBlobType::NonNMethod);
   } else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) {
@@ -561,12 +561,12 @@
 // what you are doing)
 CodeBlob* CodeCache::find_blob_unsafe(void* start) {
   // NMT can walk the stack before code cache is created
-  if (_heaps == NULL || _heaps->is_empty()) return NULL;
-
-  FOR_ALL_HEAPS(heap) {
-    CodeBlob* result = (CodeBlob*) (*heap)->find_start(start);
-    if (result != NULL && result->blob_contains((address)start)) {
-      return result;
+  if (_heaps != NULL && !_heaps->is_empty()) {
+    FOR_ALL_HEAPS(heap) {
+      CodeBlob* result = (CodeBlob*) (*heap)->find_start(start);
+      if (result != NULL && result->blob_contains((address)start)) {
+        return result;
+      }
     }
   }
   return NULL;
@@ -595,11 +595,11 @@
   }
 }
 
-void CodeCache::alive_nmethods_do(void f(nmethod* nm)) {
+void CodeCache::metadata_do(void f(Metadata* m)) {
   assert_locked_or_safepoint(CodeCache_lock);
   NMethodIterator iter;
   while(iter.next_alive()) {
-    f(iter.method());
+    iter.method()->metadata_do(f);
   }
 }
 
@@ -614,7 +614,7 @@
 // Mark nmethods for unloading if they contain otherwise unreachable oops.
 void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
   assert_locked_or_safepoint(CodeCache_lock);
-  NMethodIterator iter;
+  CompiledMethodIterator iter;
   while(iter.next_alive()) {
     iter.method()->do_unloading(is_alive, unloading_occurred);
   }
@@ -841,17 +841,18 @@
 void CodeCache::gc_epilogue() {
   assert_locked_or_safepoint(CodeCache_lock);
   NOT_DEBUG(if (needs_cache_clean())) {
-    NMethodIterator iter;
+    CompiledMethodIterator iter;
     while(iter.next_alive()) {
-      nmethod* nm = iter.method();
-      assert(!nm->is_unloaded(), "Tautology");
+      CompiledMethod* cm = iter.method();
+      assert(!cm->is_unloaded(), "Tautology");
       DEBUG_ONLY(if (needs_cache_clean())) {
-        nm->cleanup_inline_caches();
+        cm->cleanup_inline_caches();
       }
-      DEBUG_ONLY(nm->verify());
-      DEBUG_ONLY(nm->verify_oop_relocations());
+      DEBUG_ONLY(cm->verify());
+      DEBUG_ONLY(cm->verify_oop_relocations());
     }
   }
+
   set_needs_cache_clean(false);
   prune_scavenge_root_nmethods();
 
@@ -1036,7 +1037,7 @@
 
 void CodeCache::clear_inline_caches() {
   assert_locked_or_safepoint(CodeCache_lock);
-  NMethodIterator iter;
+  CompiledMethodIterator iter;
   while(iter.next_alive()) {
     iter.method()->clear_inline_caches();
   }
@@ -1083,6 +1084,11 @@
   return number_of_marked_CodeBlobs;
 }
 
+CompiledMethod* CodeCache::find_compiled(void* start) {
+  CodeBlob *cb = find_blob(start);
+  assert(cb == NULL || cb->is_compiled(), "did not find an compiled_method");
+  return (CompiledMethod*)cb;
+}
 
 #ifdef HOTSWAP
 int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) {
@@ -1094,16 +1100,16 @@
   for (int i = 0; i < old_methods->length(); i++) {
     ResourceMark rm;
     Method* old_method = old_methods->at(i);
-    nmethod *nm = old_method->code();
+    CompiledMethod* nm = old_method->code();
     if (nm != NULL) {
       nm->mark_for_deoptimization();
       number_of_marked_CodeBlobs++;
     }
   }
 
-  NMethodIterator iter;
+  CompiledMethodIterator iter;
   while(iter.next_alive()) {
-    nmethod* nm = iter.method();
+    CompiledMethod* nm = iter.method();
     if (nm->is_marked_for_deoptimization()) {
       // ...Already marked in the previous pass; don't count it again.
     } else if (nm->is_evol_dependent_on(dependee())) {
@@ -1124,9 +1130,9 @@
 // Deoptimize all methods
 void CodeCache::mark_all_nmethods_for_deoptimization() {
   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-  NMethodIterator iter;
+  CompiledMethodIterator iter;
   while(iter.next_alive()) {
-    nmethod* nm = iter.method();
+    CompiledMethod* nm = iter.method();
     if (!nm->method()->is_method_handle_intrinsic()) {
       nm->mark_for_deoptimization();
     }
@@ -1137,9 +1143,9 @@
   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   int number_of_marked_CodeBlobs = 0;
 
-  NMethodIterator iter;
+  CompiledMethodIterator iter;
   while(iter.next_alive()) {
-    nmethod* nm = iter.method();
+    CompiledMethod* nm = iter.method();
     if (nm->is_dependent_on_method(dependee)) {
       ResourceMark rm;
       nm->mark_for_deoptimization();
@@ -1152,9 +1158,9 @@
 
 void CodeCache::make_marked_nmethods_not_entrant() {
   assert_locked_or_safepoint(CodeCache_lock);
-  NMethodIterator iter;
+  CompiledMethodIterator iter;
   while(iter.next_alive()) {
-    nmethod* nm = iter.method();
+    CompiledMethod* nm = iter.method();
     if (nm->is_marked_for_deoptimization()) {
       nm->make_not_entrant();
     }
@@ -1549,3 +1555,36 @@
             blob_count(), nmethod_count(), adapter_count(),
             unallocated_capacity());
 }
+
+// Initialize iterator to given compiled method
+void CompiledMethodIterator::initialize(CompiledMethod* cm) {
+  _code_blob = (CodeBlob*)cm;
+  if (!SegmentedCodeCache) {
+    // Iterate over all CodeBlobs
+    _code_blob_type = CodeBlobType::All;
+  } else if (cm != NULL) {
+    _code_blob_type = CodeCache::get_code_blob_type(cm);
+  } else {
+    // Only iterate over method code heaps, starting with non-profiled
+    _code_blob_type = CodeBlobType::MethodNonProfiled;
+  }
+}
+
+// Advance iterator to the next compiled method in the current code heap
+bool CompiledMethodIterator::next_compiled_method() {
+  // Get first method CodeBlob
+  if (_code_blob == NULL) {
+    _code_blob = CodeCache::first_blob(_code_blob_type);
+    if (_code_blob == NULL) {
+      return false;
+    } else if (_code_blob->is_nmethod()) {
+      return true;
+    }
+  }
+  // Search for next method CodeBlob
+  _code_blob = CodeCache::next_blob(_code_blob);
+  while (_code_blob != NULL && !_code_blob->is_compiled()) {
+    _code_blob = CodeCache::next_blob(_code_blob);
+  }
+  return _code_blob != NULL;
+}
diff --git a/hotspot/src/share/vm/code/codeCache.hpp b/hotspot/src/share/vm/code/codeCache.hpp
index 47d2a7f..ba81a8a 100644
--- a/hotspot/src/share/vm/code/codeCache.hpp
+++ b/hotspot/src/share/vm/code/codeCache.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -78,6 +78,7 @@
   friend class VMStructs;
   friend class JVMCIVMStructs;
   friend class NMethodIterator;
+  friend class CompiledMethodIterator;
   friend class WhiteBox;
   friend class CodeCacheLoader;
  private:
@@ -134,12 +135,13 @@
   static void blobs_do(void f(CodeBlob* cb));              // iterates over all CodeBlobs
   static void blobs_do(CodeBlobClosure* f);                // iterates over all CodeBlobs
   static void nmethods_do(void f(nmethod* nm));            // iterates over all nmethods
-  static void alive_nmethods_do(void f(nmethod* nm));      // iterates over all alive nmethods
+  static void metadata_do(void f(Metadata* m));            // iterates over metadata in alive nmethods
 
   // Lookup
   static CodeBlob* find_blob(void* start);              // Returns the CodeBlob containing the given address
   static CodeBlob* find_blob_unsafe(void* start);       // Same as find_blob but does not fail if looking up a zombie method
   static nmethod*  find_nmethod(void* start);           // Returns the nmethod containing the given address
+  static CompiledMethod* find_compiled(void* start);
 
   static int       blob_count();                        // Returns the total number of CodeBlobs in the cache
   static int       blob_count(int code_blob_type);
@@ -207,8 +209,8 @@
   static bool heap_available(int code_blob_type);
 
   // Returns the CodeBlobType for the given nmethod
-  static int get_code_blob_type(nmethod* nm) {
-    return get_code_heap(nm)->code_blob_type();
+  static int get_code_blob_type(CompiledMethod* cm) {
+    return get_code_heap(cm)->code_blob_type();
   }
 
   // Returns the CodeBlobType for the given compilation level
@@ -337,4 +339,53 @@
   }
 };
 
+// Iterator to iterate over compiled methods in the CodeCache.
+class CompiledMethodIterator : public StackObj {
+ private:
+  CodeBlob* _code_blob;   // Current CodeBlob
+  int _code_blob_type;    // Refers to current CodeHeap
+
+ public:
+  CompiledMethodIterator() {
+    initialize(NULL); // Set to NULL, initialized by first call to next()
+  }
+
+  CompiledMethodIterator(CompiledMethod* cm) {
+    initialize(cm);
+  }
+
+  // Advance iterator to next compiled method
+  bool next() {
+    assert_locked_or_safepoint(CodeCache_lock);
+    assert(_code_blob_type < CodeBlobType::NumTypes, "end reached");
+
+    bool result = next_compiled_method();
+    while (!result && (_code_blob_type < CodeBlobType::MethodProfiled)) {
+      // Advance to next code heap if segmented code cache
+      _code_blob_type++;
+      result = next_compiled_method();
+    }
+    return result;
+  }
+
+  // Advance iterator to next alive compiled method
+  bool next_alive() {
+    bool result = next();
+    while(result && !_code_blob->is_alive()) {
+      result = next();
+    }
+    return result;
+  }
+
+  bool end()        const   { return _code_blob == NULL; }
+  CompiledMethod* method() const   { return (_code_blob != NULL) ? _code_blob->as_compiled_method() : NULL; }
+
+private:
+  // Initialize iterator to given compiled method
+  void initialize(CompiledMethod* cm);
+
+  // Advance iterator to the next compiled method in the current code heap
+  bool next_compiled_method();
+};
+
 #endif // SHARE_VM_CODE_CODECACHE_HPP
diff --git a/hotspot/src/share/vm/code/compiledIC.cpp b/hotspot/src/share/vm/code/compiledIC.cpp
index f3808bd..748589e 100644
--- a/hotspot/src/share/vm/code/compiledIC.cpp
+++ b/hotspot/src/share/vm/code/compiledIC.cpp
@@ -103,7 +103,7 @@
     MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag);
 #ifdef ASSERT
     CodeBlob* cb = CodeCache::find_blob_unsafe(_ic_call);
-    assert(cb != NULL && cb->is_nmethod(), "must be nmethod");
+    assert(cb != NULL && cb->is_compiled(), "must be compiled");
 #endif
      _ic_call->set_destination_mt_safe(entry_point);
   }
@@ -182,17 +182,17 @@
   }
 }
 
-CompiledIC::CompiledIC(nmethod* nm, NativeCall* call)
+CompiledIC::CompiledIC(CompiledMethod* cm, NativeCall* call)
   : _ic_call(call)
 {
   address ic_call = _ic_call->instruction_address();
 
   assert(ic_call != NULL, "ic_call address must be set");
-  assert(nm != NULL, "must pass nmethod");
-  assert(nm->contains(ic_call), "must be in nmethod");
+  assert(cm != NULL, "must pass compiled method");
+  assert(cm->contains(ic_call), "must be in compiled method");
 
   // Search for the ic_call at the given address.
-  RelocIterator iter(nm, ic_call, ic_call+1);
+  RelocIterator iter(cm, ic_call, ic_call+1);
   bool ret = iter.next();
   assert(ret == true, "relocInfo must exist at this address");
   assert(iter.addr() == ic_call, "must find ic_call");
@@ -205,10 +205,10 @@
 {
   address ic_call = _ic_call->instruction_address();
 
-  nmethod* nm = iter->code();
+  CompiledMethod* nm = iter->code();
   assert(ic_call != NULL, "ic_call address must be set");
-  assert(nm != NULL, "must pass nmethod");
-  assert(nm->contains(ic_call), "must be in nmethod");
+  assert(nm != NULL, "must pass compiled method");
+  assert(nm->contains(ic_call), "must be in compiled method");
 
   initialize_from_iter(iter);
 }
@@ -278,7 +278,7 @@
   // method is guaranteed to still exist, since we only remove methods after all inline caches
   // has been cleaned up
   CodeBlob* cb = CodeCache::find_blob_unsafe(ic_destination());
-  bool is_monomorphic = (cb != NULL && cb->is_nmethod());
+  bool is_monomorphic = (cb != NULL && cb->is_compiled());
   // Check that the cached_value is a klass for non-optimized monomorphic calls
   // This assertion is invalid for compiler1: a call that does not look optimized (no static stub) can be used
   // for calling directly to vep without using the inline cache (i.e., cached_value == NULL).
@@ -423,7 +423,7 @@
     bool static_bound = info.is_optimized() || (info.cached_metadata() == NULL);
 #ifdef ASSERT
     CodeBlob* cb = CodeCache::find_blob_unsafe(info.entry());
-    assert (cb->is_nmethod(), "must be compiled!");
+    assert (cb->is_compiled(), "must be compiled!");
 #endif /* ASSERT */
 
     // This is MT safe if we come from a clean-cache and go through a
@@ -469,9 +469,11 @@
                                            bool static_bound,
                                            CompiledICInfo& info,
                                            TRAPS) {
-  nmethod* method_code = method->code();
+  CompiledMethod* method_code = method->code();
+
   address entry = NULL;
   if (method_code != NULL && method_code->is_in_use()) {
+    assert(method_code->is_compiled(), "must be compiled");
     // Call to compiled code
     if (static_bound || is_optimized) {
       entry      = method_code->verified_entry_point();
@@ -520,6 +522,7 @@
       info.set_interpreter_entry(method()->get_c2i_entry(), method());
     } else {
       // Use icholder entry
+      assert(method_code == NULL || method_code->is_compiled(), "must be compiled");
       CompiledICHolder* holder = new CompiledICHolder(method(), receiver_klass());
       info.set_icholder_entry(method()->get_c2i_unverified_entry(), holder);
     }
@@ -533,6 +536,22 @@
   return (cb != NULL && cb->is_adapter_blob());
 }
 
+// Release the CompiledICHolder* associated with this call site is there is one.
+void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {
+  // This call site might have become stale so inspect it carefully.
+  NativeCall* call = nativeCall_at(call_site->addr());
+  if (is_icholder_entry(call->destination())) {
+    NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());
+    InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());
+  }
+}
+
+bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {
+  // This call site might have become stale so inspect it carefully.
+  NativeCall* call = nativeCall_at(call_site->addr());
+  return is_icholder_entry(call->destination());
+}
+
 // ----------------------------------------------------------------------------
 
 void CompiledStaticCall::set_to_clean() {
@@ -541,7 +560,7 @@
   MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag);
 #ifdef ASSERT
   CodeBlob* cb = CodeCache::find_blob_unsafe(this);
-  assert(cb != NULL && cb->is_nmethod(), "must be nmethod");
+  assert(cb != NULL && cb->is_compiled(), "must be compiled");
 #endif
   set_destination_mt_safe(SharedRuntime::get_resolve_static_call_stub());
 
@@ -563,8 +582,8 @@
 bool CompiledStaticCall::is_call_to_interpreted() const {
   // It is a call to interpreted, if it calls to a stub. Hence, the destination
   // must be in the stub part of the nmethod that contains the call
-  nmethod* nm = CodeCache::find_nmethod(instruction_address());
-  return nm->stub_contains(destination());
+  CompiledMethod* cm = CodeCache::find_compiled(instruction_address());
+  return cm->stub_contains(destination());
 }
 
 void CompiledStaticCall::set(const StaticCallInfo& info) {
@@ -596,7 +615,7 @@
 // Compute settings for a CompiledStaticCall. Since we might have to set
 // the stub when calling to the interpreter, we need to return arguments.
 void CompiledStaticCall::compute_entry(const methodHandle& m, StaticCallInfo& info) {
-  nmethod* m_code = m->code();
+  CompiledMethod* m_code = m->code();
   info._callee = m;
   if (m_code != NULL && m_code->is_in_use()) {
     info._to_interpreter = false;
diff --git a/hotspot/src/share/vm/code/compiledIC.hpp b/hotspot/src/share/vm/code/compiledIC.hpp
index cd1edbb..e4786c8 100644
--- a/hotspot/src/share/vm/code/compiledIC.hpp
+++ b/hotspot/src/share/vm/code/compiledIC.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -135,7 +135,7 @@
   NativeMovConstReg* _value;    // patchable value cell for this IC
   bool          _is_optimized;  // an optimized virtual call (i.e., no compiled IC)
 
-  CompiledIC(nmethod* nm, NativeCall* ic_call);
+  CompiledIC(CompiledMethod* cm, NativeCall* ic_call);
   CompiledIC(RelocIterator* iter);
 
   void initialize_from_iter(RelocIterator* iter);
@@ -169,8 +169,8 @@
 
  public:
   // conversion (machine PC to CompiledIC*)
-  friend CompiledIC* CompiledIC_before(nmethod* nm, address return_addr);
-  friend CompiledIC* CompiledIC_at(nmethod* nm, address call_site);
+  friend CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr);
+  friend CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site);
   friend CompiledIC* CompiledIC_at(Relocation* call_site);
   friend CompiledIC* CompiledIC_at(RelocIterator* reloc_iter);
 
@@ -234,13 +234,13 @@
   void verify()            PRODUCT_RETURN;
 };
 
-inline CompiledIC* CompiledIC_before(nmethod* nm, address return_addr) {
+inline CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr) {
   CompiledIC* c_ic = new CompiledIC(nm, nativeCall_before(return_addr));
   c_ic->verify();
   return c_ic;
 }
 
-inline CompiledIC* CompiledIC_at(nmethod* nm, address call_site) {
+inline CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site) {
   CompiledIC* c_ic = new CompiledIC(nm, nativeCall_at(call_site));
   c_ic->verify();
   return c_ic;
diff --git a/hotspot/src/share/vm/code/compiledMethod.cpp b/hotspot/src/share/vm/code/compiledMethod.cpp
new file mode 100644
index 0000000..5ca5945
--- /dev/null
+++ b/hotspot/src/share/vm/code/compiledMethod.cpp
@@ -0,0 +1,707 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "code/compiledIC.hpp"
+#include "code/scopeDesc.hpp"
+#include "code/codeCache.hpp"
+#include "prims/methodHandles.hpp"
+#include "interpreter/bytecode.hpp"
+#include "memory/resourceArea.hpp"
+#include "runtime/mutexLocker.hpp"
+
+CompiledMethod::CompiledMethod(Method* method, const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments)
+  : CodeBlob(name, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
+  _method(method), _mark_for_deoptimization_status(not_marked) {
+  init_defaults();
+}
+
+CompiledMethod::CompiledMethod(Method* method, const char* name, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments)
+  : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
+  _method(method), _mark_for_deoptimization_status(not_marked) {
+  init_defaults();
+}
+
+void CompiledMethod::init_defaults() {
+  _has_unsafe_access          = 0;
+  _has_method_handle_invokes  = 0;
+  _lazy_critical_native       = 0;
+  _has_wide_vectors           = 0;
+  _unloading_clock            = 0;
+}
+
+bool CompiledMethod::is_method_handle_return(address return_pc) {
+  if (!has_method_handle_invokes())  return false;
+  PcDesc* pd = pc_desc_at(return_pc);
+  if (pd == NULL)
+    return false;
+  return pd->is_method_handle_invoke();
+}
+
+// When using JVMCI the address might be off by the size of a call instruction.
+bool CompiledMethod::is_deopt_entry(address pc) {
+  return pc == deopt_handler_begin()
+#if INCLUDE_JVMCI
+    || pc == (deopt_handler_begin() + NativeCall::instruction_size)
+#endif
+    ;
+}
+
+// Returns a string version of the method state.
+const char* CompiledMethod::state() const {
+  int state = get_state();
+  switch (state) {
+  case in_use:
+    return "in use";
+  case not_used:
+    return "not_used";
+  case not_entrant:
+    return "not_entrant";
+  case zombie:
+    return "zombie";
+  case unloaded:
+    return "unloaded";
+  default:
+    fatal("unexpected method state: %d", state);
+    return NULL;
+  }
+}
+
+//-----------------------------------------------------------------------------
+
+void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) {
+  assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
+  assert(new_entry != NULL,"Must be non null");
+  assert(new_entry->next() == NULL, "Must be null");
+
+  ExceptionCache *ec = exception_cache();
+  if (ec != NULL) {
+    new_entry->set_next(ec);
+  }
+  release_set_exception_cache(new_entry);
+}
+
+void CompiledMethod::clean_exception_cache(BoolObjectClosure* is_alive) {
+  ExceptionCache* prev = NULL;
+  ExceptionCache* curr = exception_cache();
+
+  while (curr != NULL) {
+    ExceptionCache* next = curr->next();
+
+    Klass* ex_klass = curr->exception_type();
+    if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) {
+      if (prev == NULL) {
+        set_exception_cache(next);
+      } else {
+        prev->set_next(next);
+      }
+      delete curr;
+      // prev stays the same.
+    } else {
+      prev = curr;
+    }
+
+    curr = next;
+  }
+}
+
+// public method for accessing the exception cache
+// These are the public access methods.
+address CompiledMethod::handler_for_exception_and_pc(Handle exception, address pc) {
+  // We never grab a lock to read the exception cache, so we may
+  // have false negatives. This is okay, as it can only happen during
+  // the first few exception lookups for a given nmethod.
+  ExceptionCache* ec = exception_cache();
+  while (ec != NULL) {
+    address ret_val;
+    if ((ret_val = ec->match(exception,pc)) != NULL) {
+      return ret_val;
+    }
+    ec = ec->next();
+  }
+  return NULL;
+}
+
+void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) {
+  // There are potential race conditions during exception cache updates, so we
+  // must own the ExceptionCache_lock before doing ANY modifications. Because
+  // we don't lock during reads, it is possible to have several threads attempt
+  // to update the cache with the same data. We need to check for already inserted
+  // copies of the current data before adding it.
+
+  MutexLocker ml(ExceptionCache_lock);
+  ExceptionCache* target_entry = exception_cache_entry_for_exception(exception);
+
+  if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) {
+    target_entry = new ExceptionCache(exception,pc,handler);
+    add_exception_cache_entry(target_entry);
+  }
+}
+
+//-------------end of code for ExceptionCache--------------
+
+// private method for handling exception cache
+// These methods are private, and used to manipulate the exception cache
+// directly.
+ExceptionCache* CompiledMethod::exception_cache_entry_for_exception(Handle exception) {
+  ExceptionCache* ec = exception_cache();
+  while (ec != NULL) {
+    if (ec->match_exception_with_space(exception)) {
+      return ec;
+    }
+    ec = ec->next();
+  }
+  return NULL;
+}
+
+bool CompiledMethod::is_at_poll_return(address pc) {
+  RelocIterator iter(this, pc, pc+1);
+  while (iter.next()) {
+    if (iter.type() == relocInfo::poll_return_type)
+      return true;
+  }
+  return false;
+}
+
+
+bool CompiledMethod::is_at_poll_or_poll_return(address pc) {
+  RelocIterator iter(this, pc, pc+1);
+  while (iter.next()) {
+    relocInfo::relocType t = iter.type();
+    if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
+      return true;
+  }
+  return false;
+}
+
+void CompiledMethod::verify_oop_relocations() {
+  // Ensure sure that the code matches the current oop values
+  RelocIterator iter(this, NULL, NULL);
+  while (iter.next()) {
+    if (iter.type() == relocInfo::oop_type) {
+      oop_Relocation* reloc = iter.oop_reloc();
+      if (!reloc->oop_is_immediate()) {
+        reloc->verify_oop_relocation();
+      }
+    }
+  }
+}
+
+
+ScopeDesc* CompiledMethod::scope_desc_at(address pc) {
+  PcDesc* pd = pc_desc_at(pc);
+  guarantee(pd != NULL, "scope must be present");
+  return new ScopeDesc(this, pd->scope_decode_offset(),
+                       pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
+                       pd->return_oop());
+}
+
+void CompiledMethod::cleanup_inline_caches(bool clean_all/*=false*/) {
+  assert_locked_or_safepoint(CompiledIC_lock);
+
+  // If the method is not entrant or zombie then a JMP is plastered over the
+  // first few bytes.  If an oop in the old code was there, that oop
+  // should not get GC'd.  Skip the first few bytes of oops on
+  // not-entrant methods.
+  address low_boundary = verified_entry_point();
+  if (!is_in_use() && is_nmethod()) {
+    low_boundary += NativeJump::instruction_size;
+    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
+    // This means that the low_boundary is going to be a little too high.
+    // This shouldn't matter, since oops of non-entrant methods are never used.
+    // In fact, why are we bothering to look at oops in a non-entrant method??
+  }
+
+  // Find all calls in an nmethod and clear the ones that point to non-entrant,
+  // zombie and unloaded nmethods.
+  ResourceMark rm;
+  RelocIterator iter(this, low_boundary);
+  while(iter.next()) {
+    switch(iter.type()) {
+      case relocInfo::virtual_call_type:
+      case relocInfo::opt_virtual_call_type: {
+        CompiledIC *ic = CompiledIC_at(&iter);
+        // Ok, to lookup references to zombies here
+        CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
+        if( cb != NULL && cb->is_compiled() ) {
+          CompiledMethod* nm = cb->as_compiled_method();
+          // Clean inline caches pointing to zombie, non-entrant and unloaded methods
+          if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive());
+        }
+        break;
+      }
+      case relocInfo::static_call_type: {
+          CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
+          CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
+          if( cb != NULL && cb->is_compiled() ) {
+            CompiledMethod* cm = cb->as_compiled_method();
+            // Clean inline caches pointing to zombie, non-entrant and unloaded methods
+            if (clean_all || !cm->is_in_use() || (cm->method()->code() != cm)) {
+              csc->set_to_clean();
+            }
+          }
+        break;
+      }
+    }
+  }
+}
+
+int CompiledMethod::verify_icholder_relocations() {
+  ResourceMark rm;
+  int count = 0;
+
+  RelocIterator iter(this);
+  while(iter.next()) {
+    if (iter.type() == relocInfo::virtual_call_type) {
+      if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
+        CompiledIC *ic = CompiledIC_at(&iter);
+        if (TraceCompiledIC) {
+          tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
+          ic->print();
+        }
+        assert(ic->cached_icholder() != NULL, "must be non-NULL");
+        count++;
+      }
+    }
+  }
+
+  return count;
+}
+
+// Method that knows how to preserve outgoing arguments at call. This method must be
+// called with a frame corresponding to a Java invoke
+void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
+#ifndef SHARK
+  if (method() != NULL && !method()->is_native()) {
+    address pc = fr.pc();
+    SimpleScopeDesc ssd(this, pc);
+    Bytecode_invoke call(ssd.method(), ssd.bci());
+    bool has_receiver = call.has_receiver();
+    bool has_appendix = call.has_appendix();
+    Symbol* signature = call.signature();
+
+    // The method attached by JIT-compilers should be used, if present.
+    // Bytecode can be inaccurate in such case.
+    Method* callee = attached_method_before_pc(pc);
+    if (callee != NULL) {
+      has_receiver = !(callee->access_flags().is_static());
+      has_appendix = false;
+      signature = callee->signature();
+    }
+
+    fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f);
+  }
+#endif // !SHARK
+}
+
+// -----------------------------------------------------------------------------
+// CompiledMethod::get_deopt_original_pc
+//
+// Return the original PC for the given PC if:
+// (a) the given PC belongs to a nmethod and
+// (b) it is a deopt PC
+address CompiledMethod::get_deopt_original_pc(const frame* fr) {
+  if (fr->cb() == NULL)  return NULL;
+
+  CompiledMethod* cm = fr->cb()->as_compiled_method_or_null();
+  if (cm != NULL && cm->is_deopt_pc(fr->pc()))
+    return cm->get_original_pc(fr);
+
+  return NULL;
+}
+
+Method* CompiledMethod::attached_method(address call_instr) {
+  assert(code_contains(call_instr), "not part of the nmethod");
+  RelocIterator iter(this, call_instr, call_instr + 1);
+  while (iter.next()) {
+    if (iter.addr() == call_instr) {
+      switch(iter.type()) {
+        case relocInfo::static_call_type:      return iter.static_call_reloc()->method_value();
+        case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
+        case relocInfo::virtual_call_type:     return iter.virtual_call_reloc()->method_value();
+      }
+    }
+  }
+  return NULL; // not found
+}
+
+Method* CompiledMethod::attached_method_before_pc(address pc) {
+  if (NativeCall::is_call_before(pc)) {
+    NativeCall* ncall = nativeCall_before(pc);
+    return attached_method(ncall->instruction_address());
+  }
+  return NULL; // not a call
+}
+
+void CompiledMethod::clear_inline_caches() {
+  assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
+  if (is_zombie()) {
+    return;
+  }
+
+  RelocIterator iter(this);
+  while (iter.next()) {
+    iter.reloc()->clear_inline_cache();
+  }
+}
+
+// Clear ICStubs of all compiled ICs
+void CompiledMethod::clear_ic_stubs() {
+  assert_locked_or_safepoint(CompiledIC_lock);
+  RelocIterator iter(this);
+  while(iter.next()) {
+    if (iter.type() == relocInfo::virtual_call_type) {
+      CompiledIC* ic = CompiledIC_at(&iter);
+      ic->clear_ic_stub();
+    }
+  }
+}
+
+#ifdef ASSERT
+
+class CheckClass : AllStatic {
+  static BoolObjectClosure* _is_alive;
+
+  // Check class_loader is alive for this bit of metadata.
+  static void check_class(Metadata* md) {
+    Klass* klass = NULL;
+    if (md->is_klass()) {
+      klass = ((Klass*)md);
+    } else if (md->is_method()) {
+      klass = ((Method*)md)->method_holder();
+    } else if (md->is_methodData()) {
+      klass = ((MethodData*)md)->method()->method_holder();
+    } else {
+      md->print();
+      ShouldNotReachHere();
+    }
+    assert(klass->is_loader_alive(_is_alive), "must be alive");
+  }
+ public:
+  static void do_check_class(BoolObjectClosure* is_alive, CompiledMethod* nm) {
+    assert(SafepointSynchronize::is_at_safepoint(), "this is only ok at safepoint");
+    _is_alive = is_alive;
+    nm->metadata_do(check_class);
+  }
+};
+
+// This is called during a safepoint so can use static data
+BoolObjectClosure* CheckClass::_is_alive = NULL;
+#endif // ASSERT
+
+void CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive) {
+  if (ic->is_icholder_call()) {
+    // The only exception is compiledICHolder oops which may
+    // yet be marked below. (We check this further below).
+    CompiledICHolder* cichk_oop = ic->cached_icholder();
+
+    if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) &&
+        cichk_oop->holder_klass()->is_loader_alive(is_alive)) {
+      return;
+    }
+  } else {
+    Metadata* ic_oop = ic->cached_metadata();
+    if (ic_oop != NULL) {
+      if (ic_oop->is_klass()) {
+        if (((Klass*)ic_oop)->is_loader_alive(is_alive)) {
+          return;
+        }
+      } else if (ic_oop->is_method()) {
+        if (((Method*)ic_oop)->method_holder()->is_loader_alive(is_alive)) {
+          return;
+        }
+      } else {
+        ShouldNotReachHere();
+      }
+    }
+  }
+
+  ic->set_to_clean();
+}
+
+unsigned char CompiledMethod::_global_unloading_clock = 0;
+
+void CompiledMethod::increase_unloading_clock() {
+  _global_unloading_clock++;
+  if (_global_unloading_clock == 0) {
+    // _nmethods are allocated with _unloading_clock == 0,
+    // so 0 is never used as a clock value.
+    _global_unloading_clock = 1;
+  }
+}
+
+void CompiledMethod::set_unloading_clock(unsigned char unloading_clock) {
+  OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock);
+}
+
+unsigned char CompiledMethod::unloading_clock() {
+  return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock);
+}
+
+// Processing of oop references should have been sufficient to keep
+// all strong references alive.  Any weak references should have been
+// cleared as well.  Visit all the metadata and ensure that it's
+// really alive.
+void CompiledMethod::verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive) {
+#ifdef ASSERT
+    RelocIterator iter(this, low_boundary);
+    while (iter.next()) {
+    // static_stub_Relocations may have dangling references to
+    // Method*s so trim them out here.  Otherwise it looks like
+    // compiled code is maintaining a link to dead metadata.
+    address static_call_addr = NULL;
+    if (iter.type() == relocInfo::opt_virtual_call_type) {
+      CompiledIC* cic = CompiledIC_at(&iter);
+      if (!cic->is_call_to_interpreted()) {
+        static_call_addr = iter.addr();
+      }
+    } else if (iter.type() == relocInfo::static_call_type) {
+      CompiledStaticCall* csc = compiledStaticCall_at(iter.reloc());
+      if (!csc->is_call_to_interpreted()) {
+        static_call_addr = iter.addr();
+      }
+    }
+    if (static_call_addr != NULL) {
+      RelocIterator sciter(this, low_boundary);
+      while (sciter.next()) {
+        if (sciter.type() == relocInfo::static_stub_type &&
+            sciter.static_stub_reloc()->static_call() == static_call_addr) {
+          sciter.static_stub_reloc()->clear_inline_cache();
+        }
+      }
+    }
+  }
+  // Check that the metadata embedded in the nmethod is alive
+  CheckClass::do_check_class(is_alive, this);
+#endif
+}
+
+// This is called at the end of the strong tracing/marking phase of a
+// GC to unload an nmethod if it contains otherwise unreachable
+// oops.
+
+void CompiledMethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
+  // Make sure the oop's ready to receive visitors
+  assert(!is_zombie() && !is_unloaded(),
+         "should not call follow on zombie or unloaded nmethod");
+
+  // If the method is not entrant then a JMP is plastered over the
+  // first few bytes.  If an oop in the old code was there, that oop
+  // should not get GC'd.  Skip the first few bytes of oops on
+  // not-entrant methods.
+  address low_boundary = verified_entry_point();
+  if (is_not_entrant()) {
+    low_boundary += NativeJump::instruction_size;
+    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
+    // (See comment above.)
+  }
+
+  // The RedefineClasses() API can cause the class unloading invariant
+  // to no longer be true. See jvmtiExport.hpp for details.
+  // Also, leave a debugging breadcrumb in local flag.
+  if (JvmtiExport::has_redefined_a_class()) {
+    // This set of the unloading_occurred flag is done before the
+    // call to post_compiled_method_unload() so that the unloading
+    // of this nmethod is reported.
+    unloading_occurred = true;
+  }
+
+  // Exception cache
+  clean_exception_cache(is_alive);
+
+  // If class unloading occurred we first iterate over all inline caches and
+  // clear ICs where the cached oop is referring to an unloaded klass or method.
+  // The remaining live cached oops will be traversed in the relocInfo::oop_type
+  // iteration below.
+  if (unloading_occurred) {
+    RelocIterator iter(this, low_boundary);
+    while(iter.next()) {
+      if (iter.type() == relocInfo::virtual_call_type) {
+        CompiledIC *ic = CompiledIC_at(&iter);
+        clean_ic_if_metadata_is_dead(ic, is_alive);
+      }
+    }
+  }
+
+  if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
+    return;
+  }
+
+#if INCLUDE_JVMCI
+  if (do_unloading_jvmci(is_alive, unloading_occurred)) {
+    return;
+  }
+#endif
+
+  // Ensure that all metadata is still alive
+  verify_metadata_loaders(low_boundary, is_alive);
+}
+
+template <class CompiledICorStaticCall>
+static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, BoolObjectClosure *is_alive, CompiledMethod* from) {
+  // Ok, to lookup references to zombies here
+  CodeBlob *cb = CodeCache::find_blob_unsafe(addr);
+  CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
+  if (nm != NULL) {
+    if (nm->unloading_clock() != CompiledMethod::global_unloading_clock()) {
+      // The nmethod has not been processed yet.
+      return true;
+    }
+
+    // Clean inline caches pointing to both zombie and not_entrant methods
+    if (!nm->is_in_use() || (nm->method()->code() != nm)) {
+      ic->set_to_clean();
+      assert(ic->is_clean(), "nmethod " PTR_FORMAT "not clean %s", p2i(from), from->method()->name_and_sig_as_C_string());
+    }
+  }
+
+  return false;
+}
+
+static bool clean_if_nmethod_is_unloaded(CompiledIC *ic, BoolObjectClosure *is_alive, CompiledMethod* from) {
+  return clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), is_alive, from);
+}
+
+static bool clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, BoolObjectClosure *is_alive, CompiledMethod* from) {
+  return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from);
+}
+
+bool CompiledMethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) {
+  ResourceMark rm;
+
+  // Make sure the oop's ready to receive visitors
+  assert(!is_zombie() && !is_unloaded(),
+         "should not call follow on zombie or unloaded nmethod");
+
+  // If the method is not entrant then a JMP is plastered over the
+  // first few bytes.  If an oop in the old code was there, that oop
+  // should not get GC'd.  Skip the first few bytes of oops on
+  // not-entrant methods.
+  address low_boundary = verified_entry_point();
+  if (is_not_entrant()) {
+    low_boundary += NativeJump::instruction_size;
+    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
+    // (See comment above.)
+  }
+
+  // The RedefineClasses() API can cause the class unloading invariant
+  // to no longer be true. See jvmtiExport.hpp for details.
+  // Also, leave a debugging breadcrumb in local flag.
+  if (JvmtiExport::has_redefined_a_class()) {
+    // This set of the unloading_occurred flag is done before the
+    // call to post_compiled_method_unload() so that the unloading
+    // of this nmethod is reported.
+    unloading_occurred = true;
+  }
+
+  // Exception cache
+  clean_exception_cache(is_alive);
+
+  bool postponed = false;
+
+  RelocIterator iter(this, low_boundary);
+  while(iter.next()) {
+
+    switch (iter.type()) {
+
+    case relocInfo::virtual_call_type:
+      if (unloading_occurred) {
+        // If class unloading occurred we first iterate over all inline caches and
+        // clear ICs where the cached oop is referring to an unloaded klass or method.
+        clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive);
+      }
+
+      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
+      break;
+
+    case relocInfo::opt_virtual_call_type:
+      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
+      break;
+
+    case relocInfo::static_call_type:
+      postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
+      break;
+
+    case relocInfo::oop_type:
+      // handled by do_unloading_oops below
+      break;
+
+    case relocInfo::metadata_type:
+      break; // nothing to do.
+    }
+  }
+
+  if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
+    return postponed;
+  }
+
+#if INCLUDE_JVMCI
+  if (do_unloading_jvmci(is_alive, unloading_occurred)) {
+    return postponed;
+  }
+#endif
+
+  // Ensure that all metadata is still alive
+  verify_metadata_loaders(low_boundary, is_alive);
+
+  return postponed;
+}
+
+void CompiledMethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) {
+  ResourceMark rm;
+
+  // Make sure the oop's ready to receive visitors
+  assert(!is_zombie(),
+         "should not call follow on zombie nmethod");
+
+  // If the method is not entrant then a JMP is plastered over the
+  // first few bytes.  If an oop in the old code was there, that oop
+  // should not get GC'd.  Skip the first few bytes of oops on
+  // not-entrant methods.
+  address low_boundary = verified_entry_point();
+  if (is_not_entrant()) {
+    low_boundary += NativeJump::instruction_size;
+    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
+    // (See comment above.)
+  }
+
+  RelocIterator iter(this, low_boundary);
+  while(iter.next()) {
+
+    switch (iter.type()) {
+
+    case relocInfo::virtual_call_type:
+      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
+      break;
+
+    case relocInfo::opt_virtual_call_type:
+      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
+      break;
+
+    case relocInfo::static_call_type:
+      clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
+      break;
+    }
+  }
+}
diff --git a/hotspot/src/share/vm/code/compiledMethod.hpp b/hotspot/src/share/vm/code/compiledMethod.hpp
new file mode 100644
index 0000000..01485e7
--- /dev/null
+++ b/hotspot/src/share/vm/code/compiledMethod.hpp
@@ -0,0 +1,391 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_CODE_COMPILEDMETHOD_HPP
+#define SHARE_VM_CODE_COMPILEDMETHOD_HPP
+
+#include "code/codeBlob.hpp"
+#include "code/pcDesc.hpp"
+#include "oops/metadata.hpp"
+
+class Dependencies;
+class ExceptionHandlerTable;
+class ImplicitExceptionTable;
+class AbstractCompiler;
+class xmlStream;
+class CompiledStaticCall;
+
+// This class is used internally by nmethods, to cache
+// exception/pc/handler information.
+
+class ExceptionCache : public CHeapObj<mtCode> {
+  friend class VMStructs;
+ private:
+  enum { cache_size = 16 };
+  Klass*   _exception_type;
+  address  _pc[cache_size];
+  address  _handler[cache_size];
+  volatile int _count;
+  ExceptionCache* _next;
+
+  address pc_at(int index)                     { assert(index >= 0 && index < count(),""); return _pc[index]; }
+  void    set_pc_at(int index, address a)      { assert(index >= 0 && index < cache_size,""); _pc[index] = a; }
+  address handler_at(int index)                { assert(index >= 0 && index < count(),""); return _handler[index]; }
+  void    set_handler_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _handler[index] = a; }
+  int     count()                              { return OrderAccess::load_acquire(&_count); }
+  // increment_count is only called under lock, but there may be concurrent readers.
+  void    increment_count()                    { OrderAccess::release_store(&_count, _count + 1); }
+
+ public:
+
+  ExceptionCache(Handle exception, address pc, address handler);
+
+  Klass*    exception_type()                { return _exception_type; }
+  ExceptionCache* next()                    { return _next; }
+  void      set_next(ExceptionCache *ec)    { _next = ec; }
+
+  address match(Handle exception, address pc);
+  bool    match_exception_with_space(Handle exception) ;
+  address test_address(address addr);
+  bool    add_address_and_handler(address addr, address handler) ;
+};
+
+class nmethod;
+
+// cache pc descs found in earlier inquiries
+class PcDescCache VALUE_OBJ_CLASS_SPEC {
+  friend class VMStructs;
+ private:
+  enum { cache_size = 4 };
+  // The array elements MUST be volatile! Several threads may modify
+  // and read from the cache concurrently. find_pc_desc_internal has
+  // returned wrong results. C++ compiler (namely xlC12) may duplicate
+  // C++ field accesses if the elements are not volatile.
+  typedef PcDesc* PcDescPtr;
+  volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found
+ public:
+  PcDescCache() { debug_only(_pc_descs[0] = NULL); }
+  void    reset_to(PcDesc* initial_pc_desc);
+  PcDesc* find_pc_desc(int pc_offset, bool approximate);
+  void    add_pc_desc(PcDesc* pc_desc);
+  PcDesc* last_pc_desc() { return _pc_descs[0]; }
+};
+
+class PcDescSearch {
+private:
+  address _code_begin;
+  PcDesc* _lower;
+  PcDesc* _upper;
+public:
+  PcDescSearch(address code, PcDesc* lower, PcDesc* upper) :
+    _code_begin(code), _lower(lower), _upper(upper)
+  {
+  }
+
+  address code_begin() const { return _code_begin; }
+  PcDesc* scopes_pcs_begin() const { return _lower; }
+  PcDesc* scopes_pcs_end() const { return _upper; }
+};
+
+class PcDescContainer VALUE_OBJ_CLASS_SPEC {
+private:
+  PcDescCache _pc_desc_cache;
+public:
+  PcDescContainer() {}
+
+  PcDesc* find_pc_desc_internal(address pc, bool approximate, const PcDescSearch& search);
+  void    reset_to(PcDesc* initial_pc_desc) { _pc_desc_cache.reset_to(initial_pc_desc); }
+
+  PcDesc* find_pc_desc(address pc, bool approximate, const PcDescSearch& search) {
+    address base_address = search.code_begin();
+    PcDesc* desc = _pc_desc_cache.last_pc_desc();
+    if (desc != NULL && desc->pc_offset() == pc - base_address) {
+      return desc;
+    }
+    return find_pc_desc_internal(pc, approximate, search);
+  }
+};
+
+
+class CompiledMethod : public CodeBlob {
+  friend class VMStructs;
+  friend class NMethodSweeper;
+
+  void init_defaults();
+protected:
+  enum MarkForDeoptimizationStatus {
+    not_marked,
+    deoptimize,
+    deoptimize_noupdate
+  };
+
+  MarkForDeoptimizationStatus _mark_for_deoptimization_status; // Used for stack deoptimization
+
+  bool _is_far_code; // Code is far from CodeCache.
+                     // Have to use far call instructions to call it from code in CodeCache.
+  // set during construction
+  unsigned int _has_unsafe_access:1;         // May fault due to unsafe access.
+  unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
+  unsigned int _lazy_critical_native:1;      // Lazy JNI critical native
+  unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints
+
+  Method*   _method;
+  address _scopes_data_begin;
+  // All deoptee's will resume execution at this location described by
+  // this address.
+  address _deopt_handler_begin;
+  // All deoptee's at a MethodHandle call site will resume execution
+  // at this location described by this offset.
+  address _deopt_mh_handler_begin;
+
+  PcDescContainer _pc_desc_container;
+  ExceptionCache * volatile _exception_cache;
+
+  virtual void flush() = 0;
+protected:
+  CompiledMethod(Method* method, const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
+  CompiledMethod(Method* method, const char* name, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
+
+public:
+  virtual bool is_compiled() const                { return true; }
+
+  bool  has_unsafe_access() const                 { return _has_unsafe_access; }
+  void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
+
+  bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
+  void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
+
+  bool  is_lazy_critical_native() const           { return _lazy_critical_native; }
+  void  set_lazy_critical_native(bool z)          { _lazy_critical_native = z; }
+
+  bool  has_wide_vectors() const                  { return _has_wide_vectors; }
+  void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
+
+  enum { in_use       = 0,   // executable nmethod
+         not_used     = 1,   // not entrant, but revivable
+         not_entrant  = 2,   // marked for deoptimization but activations may still exist,
+                             // will be transformed to zombie when all activations are gone
+         zombie       = 3,   // no activations exist, nmethod is ready for purge
+         unloaded     = 4    // there should be no activations, should not be called,
+                             // will be transformed to zombie immediately
+  };
+
+  virtual AbstractCompiler* compiler() const = 0;
+  virtual bool  is_in_use() const = 0;
+  virtual int   comp_level() const = 0;
+  virtual int   compile_id() const = 0;
+
+
+  virtual address verified_entry_point() const = 0;
+  virtual void log_identity(xmlStream* log) const = 0;
+  virtual void log_state_change() const = 0;
+  virtual bool make_not_used() = 0;
+  virtual bool make_not_entrant() = 0;
+  virtual bool make_entrant() = 0;
+  virtual address entry_point() const = 0;
+  virtual bool make_zombie() = 0;
+  virtual bool is_osr_method() const = 0;
+  virtual int osr_entry_bci() const = 0;
+  Method* method() const                          { return _method; }
+  virtual void print_pcs() = 0;
+  bool is_native_method() const { return _method != NULL && _method->is_native(); }
+  bool is_java_method() const { return _method != NULL && !_method->is_native(); }
+
+  // ScopeDesc retrieval operation
+  PcDesc* pc_desc_at(address pc)   { return find_pc_desc(pc, false); }
+  // pc_desc_near returns the first PcDesc at or after the givne pc.
+  PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
+
+  // ScopeDesc for an instruction
+  ScopeDesc* scope_desc_at(address pc);
+
+  bool is_at_poll_return(address pc);
+  bool is_at_poll_or_poll_return(address pc);
+
+  bool  is_marked_for_deoptimization() const      { return _mark_for_deoptimization_status != not_marked; }
+  void  mark_for_deoptimization(bool inc_recompile_counts = true) {
+    _mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate);
+  }
+  bool update_recompile_counts() const {
+    // Update recompile counts when either the update is explicitly requested (deoptimize)
+    // or the nmethod is not marked for deoptimization at all (not_marked).
+    // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
+    return _mark_for_deoptimization_status != deoptimize_noupdate;
+  }
+
+  // tells whether frames described by this nmethod can be deoptimized
+  // note: native wrappers cannot be deoptimized.
+  bool can_be_deoptimized() const { return is_java_method(); }
+
+  virtual oop oop_at(int index) const = 0;
+  virtual Metadata* metadata_at(int index) const = 0;
+
+  address scopes_data_begin() const { return _scopes_data_begin; }
+  virtual address scopes_data_end() const = 0;
+  int scopes_data_size() const { return scopes_data_end() - scopes_data_begin(); }
+
+  virtual PcDesc* scopes_pcs_begin() const = 0;
+  virtual PcDesc* scopes_pcs_end() const = 0;
+  int scopes_pcs_size() const { return (intptr_t) scopes_pcs_end() - (intptr_t) scopes_pcs_begin(); }
+
+  address insts_begin() const { return code_begin(); }
+  address insts_end() const { return stub_begin(); }
+  bool insts_contains(address addr) const { return insts_begin() <= addr && addr < insts_end(); }
+  int insts_size() const { return insts_end() - insts_begin(); }
+
+  virtual address consts_begin() const = 0;
+  virtual address consts_end() const = 0;
+  bool consts_contains(address addr) const { return consts_begin() <= addr && addr < consts_end(); }
+  int consts_size() const { return consts_end() - consts_begin(); }
+
+  virtual address stub_begin() const = 0;
+  virtual address stub_end() const = 0;
+  bool stub_contains(address addr) const { return stub_begin() <= addr && addr < stub_end(); }
+  int stub_size() const { return stub_end() - stub_begin(); }
+
+  virtual address handler_table_begin() const = 0;
+  virtual address handler_table_end() const = 0;
+  bool handler_table_contains(address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
+  int handler_table_size() const { return handler_table_end() - handler_table_begin(); }
+
+  virtual address nul_chk_table_begin() const = 0;
+  virtual address nul_chk_table_end() const = 0;
+  bool nul_chk_table_contains(address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
+  int nul_chk_table_size() const { return nul_chk_table_end() - nul_chk_table_begin(); }
+
+  virtual oop* oop_addr_at(int index) const = 0;
+  virtual Metadata** metadata_addr_at(int index) const = 0;
+  virtual void    set_original_pc(const frame* fr, address pc) = 0;
+
+  // Exception cache support
+  // Note: _exception_cache may be read concurrently. We rely on memory_order_consume here.
+  ExceptionCache* exception_cache() const         { return _exception_cache; }
+  void set_exception_cache(ExceptionCache *ec)    { _exception_cache = ec; }
+  void release_set_exception_cache(ExceptionCache *ec) { OrderAccess::release_store_ptr(&_exception_cache, ec); }
+  address handler_for_exception_and_pc(Handle exception, address pc);
+  void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
+  void clean_exception_cache(BoolObjectClosure* is_alive);
+
+  void add_exception_cache_entry(ExceptionCache* new_entry);
+  ExceptionCache* exception_cache_entry_for_exception(Handle exception);
+
+  // MethodHandle
+  bool is_method_handle_return(address return_pc);
+  address deopt_mh_handler_begin() const  { return _deopt_mh_handler_begin; }
+
+  address deopt_handler_begin() const { return _deopt_handler_begin; }
+  virtual address get_original_pc(const frame* fr) = 0;
+  // Deopt
+  // Return true is the PC is one would expect if the frame is being deopted.
+  bool is_deopt_pc      (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); }
+  bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); }
+  bool is_deopt_entry(address pc);
+
+  virtual bool can_convert_to_zombie() = 0;
+  virtual const char* compile_kind() const = 0;
+  virtual int get_state() const = 0;
+
+  const char* state() const;
+
+  bool is_far_code() const { return _is_far_code; }
+
+  bool inlinecache_check_contains(address addr) const {
+    return (addr >= code_begin() && addr < verified_entry_point());
+  }
+
+  void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f);
+
+  // implicit exceptions support
+  virtual address continuation_for_implicit_exception(address pc) { return NULL; }
+
+  static address get_deopt_original_pc(const frame* fr);
+
+  // Inline cache support
+  void cleanup_inline_caches(bool clean_all = false);
+  virtual void clear_inline_caches();
+  void clear_ic_stubs();
+
+  // Verify and count cached icholder relocations.
+  int  verify_icholder_relocations();
+  void verify_oop_relocations();
+
+  virtual bool is_evol_dependent_on(Klass* dependee) = 0;
+  // Fast breakpoint support. Tells if this compiled method is
+  // dependent on the given method. Returns true if this nmethod
+  // corresponds to the given method as well.
+  virtual bool is_dependent_on_method(Method* dependee) = 0;
+
+  Method* attached_method(address call_pc);
+  Method* attached_method_before_pc(address pc);
+
+  virtual void metadata_do(void f(Metadata*)) = 0;
+
+  // GC support
+
+  void set_unloading_next(CompiledMethod* next) { _unloading_next = next; }
+  CompiledMethod* unloading_next()              { return _unloading_next; }
+
+  void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive);
+
+  // Check that all metadata is still alive
+  void verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive);
+
+  virtual void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
+  //  The parallel versions are used by G1.
+  virtual bool do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred);
+  virtual void do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred);
+
+  static unsigned char global_unloading_clock()   { return _global_unloading_clock; }
+  static void increase_unloading_clock();
+
+  void set_unloading_clock(unsigned char unloading_clock);
+  unsigned char unloading_clock();
+
+protected:
+  virtual bool do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred) = 0;
+#if INCLUDE_JVMCI
+  virtual bool do_unloading_jvmci(BoolObjectClosure* is_alive, bool unloading_occurred) = 0;
+#endif
+
+private:
+  // GC support to help figure out if an nmethod has been
+  // cleaned/unloaded by the current GC.
+  static unsigned char _global_unloading_clock;
+
+  volatile unsigned char _unloading_clock;   // Incremented after GC unloaded/cleaned the nmethod
+
+  PcDesc* find_pc_desc(address pc, bool approximate) {
+    return _pc_desc_container.find_pc_desc(pc, approximate, PcDescSearch(code_begin(), scopes_pcs_begin(), scopes_pcs_end()));
+  }
+
+protected:
+  union {
+    // Used by G1 to chain nmethods.
+    CompiledMethod* _unloading_next;
+    // Used by non-G1 GCs to chain nmethods.
+    nmethod* _scavenge_root_link; // from CodeCache::scavenge_root_nmethods
+  };
+};
+
+#endif //SHARE_VM_CODE_COMPILEDMETHOD_HPP
diff --git a/hotspot/src/share/vm/code/debugInfo.hpp b/hotspot/src/share/vm/code/debugInfo.hpp
index 7a1b666..ad59ede 100644
--- a/hotspot/src/share/vm/code/debugInfo.hpp
+++ b/hotspot/src/share/vm/code/debugInfo.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -261,11 +261,11 @@
 
 class DebugInfoReadStream : public CompressedReadStream {
  private:
-  const nmethod* _code;
-  const nmethod* code() const { return _code; }
+  const CompiledMethod* _code;
+  const CompiledMethod* code() const { return _code; }
   GrowableArray<ScopeValue*>* _obj_pool;
  public:
-  DebugInfoReadStream(const nmethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) :
+  DebugInfoReadStream(const CompiledMethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) :
     CompressedReadStream(code->scopes_data_begin(), offset) {
     _code = code;
     _obj_pool = obj_pool;
diff --git a/hotspot/src/share/vm/code/exceptionHandlerTable.cpp b/hotspot/src/share/vm/code/exceptionHandlerTable.cpp
index b2247b8..5308c23 100644
--- a/hotspot/src/share/vm/code/exceptionHandlerTable.cpp
+++ b/hotspot/src/share/vm/code/exceptionHandlerTable.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,9 +65,9 @@
 }
 
 
-ExceptionHandlerTable::ExceptionHandlerTable(const nmethod* nm) {
-  _table  = (HandlerTableEntry*)nm->handler_table_begin();
-  _length = nm->handler_table_size() / sizeof(HandlerTableEntry);
+ExceptionHandlerTable::ExceptionHandlerTable(const CompiledMethod* cm) {
+  _table  = (HandlerTableEntry*)cm->handler_table_begin();
+  _length = cm->handler_table_size() / sizeof(HandlerTableEntry);
   _size   = 0; // no space allocated by ExeptionHandlerTable!
 }
 
@@ -98,9 +98,9 @@
 }
 
 
-void ExceptionHandlerTable::copy_to(nmethod* nm) {
-  assert(size_in_bytes() == nm->handler_table_size(), "size of space allocated in nmethod incorrect");
-  copy_bytes_to(nm->handler_table_begin());
+void ExceptionHandlerTable::copy_to(CompiledMethod* cm) {
+  assert(size_in_bytes() == cm->handler_table_size(), "size of space allocated in compiled method incorrect");
+  copy_bytes_to(cm->handler_table_begin());
 }
 
 void ExceptionHandlerTable::copy_bytes_to(address addr) {
diff --git a/hotspot/src/share/vm/code/exceptionHandlerTable.hpp b/hotspot/src/share/vm/code/exceptionHandlerTable.hpp
index 338e8d5..4fc4fdc 100644
--- a/hotspot/src/share/vm/code/exceptionHandlerTable.hpp
+++ b/hotspot/src/share/vm/code/exceptionHandlerTable.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,7 +98,7 @@
   ExceptionHandlerTable(int initial_size = 8);
 
   // (run-time) construction from nmethod
-  ExceptionHandlerTable(const nmethod* nm);
+  ExceptionHandlerTable(const CompiledMethod* nm);
 
   // (compile-time) add entries
   void add_subtable(
@@ -115,7 +115,7 @@
 
   // nmethod support
   int  size_in_bytes() const { return round_to(_length * sizeof(HandlerTableEntry), oopSize); }
-  void copy_to(nmethod* nm);
+  void copy_to(CompiledMethod* nm);
   void copy_bytes_to(address addr);
 
   // lookup
diff --git a/hotspot/src/share/vm/code/icBuffer.cpp b/hotspot/src/share/vm/code/icBuffer.cpp
index 65ea0b8..abbe781 100644
--- a/hotspot/src/share/vm/code/icBuffer.cpp
+++ b/hotspot/src/share/vm/code/icBuffer.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,8 +49,8 @@
 void ICStub::finalize() {
   if (!is_empty()) {
     ResourceMark rm;
-    CompiledIC *ic = CompiledIC_at(CodeCache::find_nmethod(ic_site()), ic_site());
-    assert(CodeCache::find_nmethod(ic->instruction_address()) != NULL, "inline cache in non-nmethod?");
+    CompiledIC *ic = CompiledIC_at(CodeCache::find_compiled(ic_site()), ic_site());
+    assert(CodeCache::find_compiled(ic->instruction_address()) != NULL, "inline cache in non-compiled?");
 
     assert(this == ICStub_from_destination_address(ic->stub_address()), "wrong owner of ic buffer");
     ic->set_ic_destination_and_value(destination(), cached_value());
diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp
index 77939f0..e15e732 100644
--- a/hotspot/src/share/vm/code/nmethod.cpp
+++ b/hotspot/src/share/vm/code/nmethod.cpp
@@ -36,10 +36,10 @@
 #include "compiler/directivesParser.hpp"
 #include "compiler/disassembler.hpp"
 #include "interpreter/bytecode.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/methodData.hpp"
 #include "oops/oop.inline.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/jvmtiImpl.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/orderAccess.inline.hpp"
@@ -73,8 +73,6 @@
 #include "jvmci/jvmciJavaClasses.hpp"
 #endif
 
-unsigned char nmethod::_global_unloading_clock = 0;
-
 #ifdef DTRACE_ENABLED
 
 // Only bother with this argument setup if dtrace is available
@@ -313,7 +311,8 @@
 
 
 address ExceptionCache::test_address(address addr) {
-  for (int i=0; i<count(); i++) {
+  int limit = count();
+  for (int i = 0; i < limit; i++) {
     if (pc_at(i) == addr) {
       return handler_at(i);
     }
@@ -329,29 +328,12 @@
   if (index < cache_size) {
     set_pc_at(index, addr);
     set_handler_at(index, handler);
-    OrderAccess::storestore();
     increment_count();
     return true;
   }
   return false;
 }
 
-
-// private method for handling exception cache
-// These methods are private, and used to manipulate the exception cache
-// directly.
-ExceptionCache* nmethod::exception_cache_entry_for_exception(Handle exception) {
-  ExceptionCache* ec = exception_cache();
-  while (ec != NULL) {
-    if (ec->match_exception_with_space(exception)) {
-      return ec;
-    }
-    ec = ec->next();
-  }
-  return NULL;
-}
-
-
 //-----------------------------------------------------------------------------
 
 
@@ -434,81 +416,6 @@
   return nsize;
 }
 
-//-----------------------------------------------------------------------------
-
-
-void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) {
-  assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
-  assert(new_entry != NULL,"Must be non null");
-  assert(new_entry->next() == NULL, "Must be null");
-
-  if (exception_cache() != NULL) {
-    new_entry->set_next(exception_cache());
-  }
-  set_exception_cache(new_entry);
-}
-
-void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) {
-  ExceptionCache* prev = NULL;
-  ExceptionCache* curr = exception_cache();
-
-  while (curr != NULL) {
-    ExceptionCache* next = curr->next();
-
-    Klass* ex_klass = curr->exception_type();
-    if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) {
-      if (prev == NULL) {
-        set_exception_cache(next);
-      } else {
-        prev->set_next(next);
-      }
-      delete curr;
-      // prev stays the same.
-    } else {
-      prev = curr;
-    }
-
-    curr = next;
-  }
-}
-
-// public method for accessing the exception cache
-// These are the public access methods.
-address nmethod::handler_for_exception_and_pc(Handle exception, address pc) {
-  // We never grab a lock to read the exception cache, so we may
-  // have false negatives. This is okay, as it can only happen during
-  // the first few exception lookups for a given nmethod.
-  ExceptionCache* ec = exception_cache();
-  while (ec != NULL) {
-    address ret_val;
-    if ((ret_val = ec->match(exception,pc)) != NULL) {
-      return ret_val;
-    }
-    ec = ec->next();
-  }
-  return NULL;
-}
-
-
-void nmethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) {
-  // There are potential race conditions during exception cache updates, so we
-  // must own the ExceptionCache_lock before doing ANY modifications. Because
-  // we don't lock during reads, it is possible to have several threads attempt
-  // to update the cache with the same data. We need to check for already inserted
-  // copies of the current data before adding it.
-
-  MutexLocker ml(ExceptionCache_lock);
-  ExceptionCache* target_entry = exception_cache_entry_for_exception(exception);
-
-  if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) {
-    target_entry = new ExceptionCache(exception,pc,handler);
-    add_exception_cache_entry(target_entry);
-  }
-}
-
-
-//-------------end of code for ExceptionCache--------------
-
 
 int nmethod::total_size() const {
   return
@@ -530,13 +437,7 @@
 // Fill in default values for various flag fields
 void nmethod::init_defaults() {
   _state                      = in_use;
-  _unloading_clock            = 0;
   _has_flushed_dependencies   = 0;
-  _has_unsafe_access          = 0;
-  _has_method_handle_invokes  = 0;
-  _lazy_critical_native       = 0;
-  _has_wide_vectors           = 0;
-  _mark_for_deoptimization_status = not_marked;
   _lock_count                 = 0;
   _stack_traversal_mark       = 0;
   _unload_reported            = false; // jvmti state
@@ -578,7 +479,7 @@
   nmethod* nm = NULL;
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod));
+    int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod));
     CodeOffsets offsets;
     offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
     offsets.set_value(CodeOffsets::Frame_Complete, frame_complete);
@@ -624,7 +525,7 @@
   nmethod* nm = NULL;
   { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
     int nmethod_size =
-      allocation_size(code_buffer, sizeof(nmethod))
+      CodeBlob::allocation_size(code_buffer, sizeof(nmethod))
       + adjust_pcs_size(debug_info->pcs_size())
       + round_to(dependencies->size_in_bytes() , oopSize)
       + round_to(handler_table->size_in_bytes(), oopSize)
@@ -691,31 +592,31 @@
   ByteSize basic_lock_owner_sp_offset,
   ByteSize basic_lock_sp_offset,
   OopMapSet* oop_maps )
-  : CodeBlob("native nmethod", code_buffer, sizeof(nmethod),
-             nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps),
+  : CompiledMethod(method, "native nmethod", nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
   _native_receiver_sp_offset(basic_lock_owner_sp_offset),
   _native_basic_lock_sp_offset(basic_lock_sp_offset)
 {
   {
+    int scopes_data_offset = 0;
+    int deoptimize_offset       = 0;
+    int deoptimize_mh_offset    = 0;
+
     debug_only(NoSafepointVerifier 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;
     _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;
+    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;
@@ -726,9 +627,14 @@
     _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
     _osr_entry_point         = NULL;
     _exception_cache         = NULL;
-    _pc_desc_cache.reset_to(NULL);
+    _pc_desc_container.reset_to(NULL);
     _hotness_counter         = NMethodSweeper::hotness_counter_reset_val();
 
+    _scopes_data_begin = (address) this + scopes_data_offset;
+    _deopt_handler_begin = (address) this + deoptimize_offset;
+    _deopt_mh_handler_begin = (address) this + deoptimize_mh_offset;
+
+    code_buffer->copy_code_and_locs_to(this);
     code_buffer->copy_values_to(this);
     if (ScavengeRootsInCode) {
       if (detect_scavenge_root_oops()) {
@@ -794,8 +700,7 @@
   Handle speculation_log
 #endif
   )
-  : CodeBlob("nmethod", code_buffer, sizeof(nmethod),
-             nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps),
+  : CompiledMethod(method, "nmethod", nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
   _native_receiver_sp_offset(in_ByteSize(-1)),
   _native_basic_lock_sp_offset(in_ByteSize(-1))
 {
@@ -804,8 +709,10 @@
     debug_only(NoSafepointVerifier nsv;)
     assert_locked_or_safepoint(CodeCache_lock);
 
+    _deopt_handler_begin = (address) this;
+    _deopt_mh_handler_begin = (address) this;
+
     init_defaults();
-    _method                  = method;
     _entry_bci               = entry_bci;
     _compile_id              = compile_id;
     _comp_level              = comp_level;
@@ -829,14 +736,14 @@
         _exception_offset = -1;
       }
       if (offsets->value(CodeOffsets::Deopt) != -1) {
-        _deoptimize_offset       = code_offset()          + offsets->value(CodeOffsets::Deopt);
+        _deopt_handler_begin       = (address) this + code_offset()          + offsets->value(CodeOffsets::Deopt);
       } else {
-        _deoptimize_offset = -1;
+        _deopt_handler_begin = NULL;
       }
       if (offsets->value(CodeOffsets::DeoptMH) != -1) {
-        _deoptimize_mh_offset  = code_offset()          + offsets->value(CodeOffsets::DeoptMH);
+        _deopt_mh_handler_begin  = (address) this + code_offset()          + offsets->value(CodeOffsets::DeoptMH);
       } else {
-        _deoptimize_mh_offset  = -1;
+        _deopt_mh_handler_begin = NULL;
       }
     } else {
 #endif
@@ -844,12 +751,12 @@
     assert(offsets->value(CodeOffsets::Exceptions) != -1, "must be set");
     assert(offsets->value(CodeOffsets::Deopt     ) != -1, "must be set");
 
-    _exception_offset        = _stub_offset          + offsets->value(CodeOffsets::Exceptions);
-    _deoptimize_offset       = _stub_offset          + offsets->value(CodeOffsets::Deopt);
+    _exception_offset       = _stub_offset          + offsets->value(CodeOffsets::Exceptions);
+    _deopt_handler_begin    = (address) this + _stub_offset          + offsets->value(CodeOffsets::Deopt);
     if (offsets->value(CodeOffsets::DeoptMH) != -1) {
-      _deoptimize_mh_offset  = _stub_offset          + offsets->value(CodeOffsets::DeoptMH);
+      _deopt_mh_handler_begin  = (address) this + _stub_offset          + offsets->value(CodeOffsets::DeoptMH);
     } else {
-      _deoptimize_mh_offset  = -1;
+      _deopt_mh_handler_begin  = NULL;
 #if INCLUDE_JVMCI
     }
 #endif
@@ -862,20 +769,23 @@
 
     _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);
+    int scopes_data_offset   = _metadata_offset      + round_to(code_buffer->total_metadata_size(), wordSize);
 
-    _scopes_pcs_offset       = _scopes_data_offset   + round_to(debug_info->data_size       (), oopSize);
+    _scopes_pcs_offset       = scopes_data_offset    + round_to(debug_info->data_size       (), oopSize);
     _dependencies_offset     = _scopes_pcs_offset    + adjust_pcs_size(debug_info->pcs_size());
     _handler_table_offset    = _dependencies_offset  + round_to(dependencies->size_in_bytes (), oopSize);
     _nul_chk_table_offset    = _handler_table_offset + round_to(handler_table->size_in_bytes(), oopSize);
     _nmethod_end_offset      = _nul_chk_table_offset + round_to(nul_chk_table->size_in_bytes(), oopSize);
-
     _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
     _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
     _osr_entry_point         = code_begin()          + offsets->value(CodeOffsets::OSR_Entry);
     _exception_cache         = NULL;
-    _pc_desc_cache.reset_to(scopes_pcs_begin());
 
+    _scopes_data_begin = (address) this + scopes_data_offset;
+
+    _pc_desc_container.reset_to(scopes_pcs_begin());
+
+    code_buffer->copy_code_and_locs_to(this);
     // Copy contents of ScopeDescRecorder to nmethod
     code_buffer->copy_values_to(this);
     debug_info->copy_to(this);
@@ -1051,27 +961,6 @@
   }
 }
 
-bool nmethod::is_at_poll_return(address pc) {
-  RelocIterator iter(this, pc, pc+1);
-  while (iter.next()) {
-    if (iter.type() == relocInfo::poll_return_type)
-      return true;
-  }
-  return false;
-}
-
-
-bool nmethod::is_at_poll_or_poll_return(address pc) {
-  RelocIterator iter(this, pc, pc+1);
-  while (iter.next()) {
-    relocInfo::relocType t = iter.type();
-    if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
-      return true;
-  }
-  return false;
-}
-
-
 void nmethod::fix_oop_relocations(address begin, address end, bool initialize_immediates) {
   // re-patch all oop-bearing instructions, just in case some oops moved
   RelocIterator iter(this, begin, end);
@@ -1092,101 +981,6 @@
 }
 
 
-void nmethod::verify_oop_relocations() {
-  // Ensure sure that the code matches the current oop values
-  RelocIterator iter(this, NULL, NULL);
-  while (iter.next()) {
-    if (iter.type() == relocInfo::oop_type) {
-      oop_Relocation* reloc = iter.oop_reloc();
-      if (!reloc->oop_is_immediate()) {
-        reloc->verify_oop_relocation();
-      }
-    }
-  }
-}
-
-
-ScopeDesc* nmethod::scope_desc_at(address pc) {
-  PcDesc* pd = pc_desc_at(pc);
-  guarantee(pd != NULL, "scope must be present");
-  return new ScopeDesc(this, pd->scope_decode_offset(),
-                       pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
-                       pd->return_oop());
-}
-
-
-void nmethod::clear_inline_caches() {
-  assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
-  if (is_zombie()) {
-    return;
-  }
-
-  RelocIterator iter(this);
-  while (iter.next()) {
-    iter.reloc()->clear_inline_cache();
-  }
-}
-
-// Clear ICStubs of all compiled ICs
-void nmethod::clear_ic_stubs() {
-  assert_locked_or_safepoint(CompiledIC_lock);
-  RelocIterator iter(this);
-  while(iter.next()) {
-    if (iter.type() == relocInfo::virtual_call_type) {
-      CompiledIC* ic = CompiledIC_at(&iter);
-      ic->clear_ic_stub();
-    }
-  }
-}
-
-void nmethod::cleanup_inline_caches(bool clean_all/*=false*/) {
-  assert_locked_or_safepoint(CompiledIC_lock);
-
-  // If the method is not entrant or zombie then a JMP is plastered over the
-  // first few bytes.  If an oop in the old code was there, that oop
-  // should not get GC'd.  Skip the first few bytes of oops on
-  // not-entrant methods.
-  address low_boundary = verified_entry_point();
-  if (!is_in_use()) {
-    low_boundary += NativeJump::instruction_size;
-    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
-    // This means that the low_boundary is going to be a little too high.
-    // This shouldn't matter, since oops of non-entrant methods are never used.
-    // In fact, why are we bothering to look at oops in a non-entrant method??
-  }
-
-  // Find all calls in an nmethod and clear the ones that point to non-entrant,
-  // zombie and unloaded nmethods.
-  ResourceMark rm;
-  RelocIterator iter(this, low_boundary);
-  while(iter.next()) {
-    switch(iter.type()) {
-      case relocInfo::virtual_call_type:
-      case relocInfo::opt_virtual_call_type: {
-        CompiledIC *ic = CompiledIC_at(&iter);
-        // Ok, to lookup references to zombies here
-        CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
-        if( cb != NULL && cb->is_nmethod() ) {
-          nmethod* nm = (nmethod*)cb;
-          // Clean inline caches pointing to zombie, non-entrant and unloaded methods
-          if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive());
-        }
-        break;
-      }
-      case relocInfo::static_call_type: {
-        CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
-        CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
-        if( cb != NULL && cb->is_nmethod() ) {
-          nmethod* nm = (nmethod*)cb;
-          // Clean inline caches pointing to zombie, non-entrant and unloaded methods
-          if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) csc->set_to_clean();
-        }
-        break;
-      }
-    }
-  }
-}
-
 void nmethod::verify_clean_inline_caches() {
   assert_locked_or_safepoint(CompiledIC_lock);
 
@@ -1212,8 +1006,8 @@
         CompiledIC *ic = CompiledIC_at(&iter);
         // Ok, to lookup references to zombies here
         CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
-        if( cb != NULL && cb->is_nmethod() ) {
-          nmethod* nm = (nmethod*)cb;
+        nmethod* nm = cb->as_nmethod_or_null();
+        if( nm != NULL ) {
           // Verify that inline caches pointing to both zombie and not_entrant methods are clean
           if (!nm->is_in_use() || (nm->method()->code() != nm)) {
             assert(ic->is_clean(), "IC should be clean");
@@ -1224,8 +1018,8 @@
       case relocInfo::static_call_type: {
         CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
         CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
-        if( cb != NULL && cb->is_nmethod() ) {
-          nmethod* nm = (nmethod*)cb;
+        nmethod* nm = cb->as_nmethod_or_null();
+        if( nm != NULL ) {
           // Verify that inline caches pointing to both zombie and not_entrant methods are clean
           if (!nm->is_in_use() || (nm->method()->code() != nm)) {
             assert(csc->is_clean(), "IC should be clean");
@@ -1237,27 +1031,6 @@
   }
 }
 
-int nmethod::verify_icholder_relocations() {
-  int count = 0;
-
-  RelocIterator iter(this);
-  while(iter.next()) {
-    if (iter.type() == relocInfo::virtual_call_type) {
-      if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
-        CompiledIC *ic = CompiledIC_at(&iter);
-        if (TraceCompiledIC) {
-          tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
-          ic->print();
-        }
-        assert(ic->cached_icholder() != NULL, "must be non-NULL");
-        count++;
-      }
-    }
-  }
-
-  return count;
-}
-
 // This is a private interface with the sweeper.
 void nmethod::mark_as_seen_on_stack() {
   assert(is_alive(), "Must be an alive method");
@@ -1290,23 +1063,6 @@
   mdo->inc_decompile_count();
 }
 
-void nmethod::increase_unloading_clock() {
-  _global_unloading_clock++;
-  if (_global_unloading_clock == 0) {
-    // _nmethods are allocated with _unloading_clock == 0,
-    // so 0 is never used as a clock value.
-    _global_unloading_clock = 1;
-  }
-}
-
-void nmethod::set_unloading_clock(unsigned char unloading_clock) {
-  OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock);
-}
-
-unsigned char nmethod::unloading_clock() {
-  return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock);
-}
-
 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
 
   post_compiled_method_unload();
@@ -1320,8 +1076,8 @@
   flush_dependencies(is_alive);
 
   // Break cycle between nmethod & method
-  if (log_is_enabled(Trace, classunload)) {
-    outputStream* log = Log(classunload)::trace_stream();
+  if (log_is_enabled(Trace, class, unload)) {
+    outputStream* log = Log(class, unload)::trace_stream();
     log->print_cr("making nmethod " INTPTR_FORMAT
                   " unloadable, Method*(" INTPTR_FORMAT
                   "), cause(" INTPTR_FORMAT ")",
@@ -1607,8 +1363,7 @@
   ((SharkCompiler *) compiler())->free_compiled_method(insts_begin());
 #endif // SHARK
 
-  ((CodeBlob*)(this))->flush();
-
+  CodeBlob::flush();
   CodeCache::free(this);
 }
 
@@ -1752,171 +1507,6 @@
   set_unload_reported();
 }
 
-void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive) {
-  if (ic->is_icholder_call()) {
-    // The only exception is compiledICHolder oops which may
-    // yet be marked below. (We check this further below).
-    CompiledICHolder* cichk_oop = ic->cached_icholder();
-
-    if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) &&
-        cichk_oop->holder_klass()->is_loader_alive(is_alive)) {
-      return;
-    }
-  } else {
-    Metadata* ic_oop = ic->cached_metadata();
-    if (ic_oop != NULL) {
-      if (ic_oop->is_klass()) {
-        if (((Klass*)ic_oop)->is_loader_alive(is_alive)) {
-          return;
-        }
-      } else if (ic_oop->is_method()) {
-        if (((Method*)ic_oop)->method_holder()->is_loader_alive(is_alive)) {
-          return;
-        }
-      } else {
-        ShouldNotReachHere();
-      }
-    }
-  }
-
-  ic->set_to_clean();
-}
-
-// This is called at the end of the strong tracing/marking phase of a
-// GC to unload an nmethod if it contains otherwise unreachable
-// oops.
-
-void nmethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
-  // Make sure the oop's ready to receive visitors
-  assert(!is_zombie() && !is_unloaded(),
-         "should not call follow on zombie or unloaded nmethod");
-
-  // If the method is not entrant then a JMP is plastered over the
-  // first few bytes.  If an oop in the old code was there, that oop
-  // should not get GC'd.  Skip the first few bytes of oops on
-  // not-entrant methods.
-  address low_boundary = verified_entry_point();
-  if (is_not_entrant()) {
-    low_boundary += NativeJump::instruction_size;
-    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
-    // (See comment above.)
-  }
-
-  // The RedefineClasses() API can cause the class unloading invariant
-  // to no longer be true. See jvmtiExport.hpp for details.
-  // Also, leave a debugging breadcrumb in local flag.
-  if (JvmtiExport::has_redefined_a_class()) {
-    // This set of the unloading_occurred flag is done before the
-    // call to post_compiled_method_unload() so that the unloading
-    // of this nmethod is reported.
-    unloading_occurred = true;
-  }
-
-  // Exception cache
-  clean_exception_cache(is_alive);
-
-  // If class unloading occurred we first iterate over all inline caches and
-  // clear ICs where the cached oop is referring to an unloaded klass or method.
-  // The remaining live cached oops will be traversed in the relocInfo::oop_type
-  // iteration below.
-  if (unloading_occurred) {
-    RelocIterator iter(this, low_boundary);
-    while(iter.next()) {
-      if (iter.type() == relocInfo::virtual_call_type) {
-        CompiledIC *ic = CompiledIC_at(&iter);
-        clean_ic_if_metadata_is_dead(ic, is_alive);
-      }
-    }
-  }
-
-  // Compiled code
-  {
-  RelocIterator iter(this, low_boundary);
-  while (iter.next()) {
-    if (iter.type() == relocInfo::oop_type) {
-      oop_Relocation* r = iter.oop_reloc();
-      // In this loop, we must only traverse those oops directly embedded in
-      // the code.  Other oops (oop_index>0) are seen as part of scopes_oops.
-      assert(1 == (r->oop_is_immediate()) +
-                  (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
-             "oop must be found in exactly one place");
-      if (r->oop_is_immediate() && r->oop_value() != NULL) {
-        if (can_unload(is_alive, r->oop_addr(), unloading_occurred)) {
-          return;
-        }
-      }
-    }
-  }
-  }
-
-
-  // Scopes
-  for (oop* p = oops_begin(); p < oops_end(); p++) {
-    if (*p == Universe::non_oop_word())  continue;  // skip non-oops
-    if (can_unload(is_alive, p, unloading_occurred)) {
-      return;
-    }
-  }
-
-#if INCLUDE_JVMCI
-  // Follow JVMCI method
-  BarrierSet* bs = Universe::heap()->barrier_set();
-  if (_jvmci_installed_code != NULL) {
-    if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) {
-      if (!is_alive->do_object_b(_jvmci_installed_code)) {
-        clear_jvmci_installed_code();
-      }
-    } else {
-      if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) {
-        return;
-      }
-    }
-  }
-
-  if (_speculation_log != NULL) {
-    if (!is_alive->do_object_b(_speculation_log)) {
-      bs->write_ref_nmethod_pre(&_speculation_log, this);
-      _speculation_log = NULL;
-      bs->write_ref_nmethod_post(&_speculation_log, this);
-    }
-  }
-#endif
-
-
-  // Ensure that all metadata is still alive
-  verify_metadata_loaders(low_boundary, is_alive);
-}
-
-template <class CompiledICorStaticCall>
-static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, BoolObjectClosure *is_alive, nmethod* from) {
-  // Ok, to lookup references to zombies here
-  CodeBlob *cb = CodeCache::find_blob_unsafe(addr);
-  if (cb != NULL && cb->is_nmethod()) {
-    nmethod* nm = (nmethod*)cb;
-
-    if (nm->unloading_clock() != nmethod::global_unloading_clock()) {
-      // The nmethod has not been processed yet.
-      return true;
-    }
-
-    // Clean inline caches pointing to both zombie and not_entrant methods
-    if (!nm->is_in_use() || (nm->method()->code() != nm)) {
-      ic->set_to_clean();
-      assert(ic->is_clean(), "nmethod " PTR_FORMAT "not clean %s", p2i(from), from->method()->name_and_sig_as_C_string());
-    }
-  }
-
-  return false;
-}
-
-static bool clean_if_nmethod_is_unloaded(CompiledIC *ic, BoolObjectClosure *is_alive, nmethod* from) {
-  return clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), is_alive, from);
-}
-
-static bool clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, BoolObjectClosure *is_alive, nmethod* from) {
-  return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from);
-}
-
 bool nmethod::unload_if_dead_at(RelocIterator* iter_at_oop, BoolObjectClosure *is_alive, bool unloading_occurred) {
   assert(iter_at_oop->type() == relocInfo::oop_type, "Wrong relocation type");
 
@@ -1936,93 +1526,36 @@
   return false;
 }
 
-
-bool nmethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) {
-  ResourceMark rm;
-
-  // Make sure the oop's ready to receive visitors
-  assert(!is_zombie() && !is_unloaded(),
-         "should not call follow on zombie or unloaded nmethod");
-
-  // If the method is not entrant then a JMP is plastered over the
-  // first few bytes.  If an oop in the old code was there, that oop
-  // should not get GC'd.  Skip the first few bytes of oops on
-  // not-entrant methods.
-  address low_boundary = verified_entry_point();
-  if (is_not_entrant()) {
-    low_boundary += NativeJump::instruction_size;
-    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
-    // (See comment above.)
-  }
-
-  // The RedefineClasses() API can cause the class unloading invariant
-  // to no longer be true. See jvmtiExport.hpp for details.
-  // Also, leave a debugging breadcrumb in local flag.
-  if (JvmtiExport::has_redefined_a_class()) {
-    // This set of the unloading_occurred flag is done before the
-    // call to post_compiled_method_unload() so that the unloading
-    // of this nmethod is reported.
-    unloading_occurred = true;
-  }
-
-  // Exception cache
-  clean_exception_cache(is_alive);
-
-  bool is_unloaded = false;
-  bool postponed = false;
-
-  RelocIterator iter(this, low_boundary);
-  while(iter.next()) {
-
-    switch (iter.type()) {
-
-    case relocInfo::virtual_call_type:
-      if (unloading_occurred) {
-        // If class unloading occurred we first iterate over all inline caches and
-        // clear ICs where the cached oop is referring to an unloaded klass or method.
-        clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive);
-      }
-
-      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
-      break;
-
-    case relocInfo::opt_virtual_call_type:
-      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
-      break;
-
-    case relocInfo::static_call_type:
-      postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
-      break;
-
-    case relocInfo::oop_type:
-      if (!is_unloaded) {
-        is_unloaded = unload_if_dead_at(&iter, is_alive, unloading_occurred);
-      }
-      break;
-
-    case relocInfo::metadata_type:
-      break; // nothing to do.
-    }
-  }
-
-  if (is_unloaded) {
-    return postponed;
-  }
-
+bool nmethod::do_unloading_scopes(BoolObjectClosure* is_alive, bool unloading_occurred) {
   // Scopes
   for (oop* p = oops_begin(); p < oops_end(); p++) {
     if (*p == Universe::non_oop_word())  continue;  // skip non-oops
     if (can_unload(is_alive, p, unloading_occurred)) {
-      is_unloaded = true;
-      break;
+      return true;
     }
   }
+  return false;
+}
 
-  if (is_unloaded) {
-    return postponed;
+bool nmethod::do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred) {
+  // Compiled code
+  {
+  RelocIterator iter(this, low_boundary);
+  while (iter.next()) {
+    if (iter.type() == relocInfo::oop_type) {
+      if (unload_if_dead_at(&iter, is_alive, unloading_occurred)) {
+        return true;
+      }
+    }
+  }
   }
 
+  return do_unloading_scopes(is_alive, unloading_occurred);
+}
+
 #if INCLUDE_JVMCI
+bool nmethod::do_unloading_jvmci(BoolObjectClosure* is_alive, bool unloading_occurred) {
+  bool is_unloaded = false;
   // Follow JVMCI method
   BarrierSet* bs = Universe::heap()->barrier_set();
   if (_jvmci_installed_code != NULL) {
@@ -2032,7 +1565,7 @@
       }
     } else {
       if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) {
-        is_unloaded = true;
+        return true;
       }
     }
   }
@@ -2044,124 +1577,10 @@
       bs->write_ref_nmethod_post(&_speculation_log, this);
     }
   }
+  return is_unloaded;
+}
 #endif
 
-  // Ensure that all metadata is still alive
-  verify_metadata_loaders(low_boundary, is_alive);
-
-  return postponed;
-}
-
-void nmethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) {
-  ResourceMark rm;
-
-  // Make sure the oop's ready to receive visitors
-  assert(!is_zombie(),
-         "should not call follow on zombie nmethod");
-
-  // If the method is not entrant then a JMP is plastered over the
-  // first few bytes.  If an oop in the old code was there, that oop
-  // should not get GC'd.  Skip the first few bytes of oops on
-  // not-entrant methods.
-  address low_boundary = verified_entry_point();
-  if (is_not_entrant()) {
-    low_boundary += NativeJump::instruction_size;
-    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
-    // (See comment above.)
-  }
-
-  RelocIterator iter(this, low_boundary);
-  while(iter.next()) {
-
-    switch (iter.type()) {
-
-    case relocInfo::virtual_call_type:
-      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
-      break;
-
-    case relocInfo::opt_virtual_call_type:
-      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
-      break;
-
-    case relocInfo::static_call_type:
-      clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
-      break;
-    }
-  }
-}
-
-#ifdef ASSERT
-
-class CheckClass : AllStatic {
-  static BoolObjectClosure* _is_alive;
-
-  // Check class_loader is alive for this bit of metadata.
-  static void check_class(Metadata* md) {
-    Klass* klass = NULL;
-    if (md->is_klass()) {
-      klass = ((Klass*)md);
-    } else if (md->is_method()) {
-      klass = ((Method*)md)->method_holder();
-    } else if (md->is_methodData()) {
-      klass = ((MethodData*)md)->method()->method_holder();
-    } else {
-      md->print();
-      ShouldNotReachHere();
-    }
-    assert(klass->is_loader_alive(_is_alive), "must be alive");
-  }
- public:
-  static void do_check_class(BoolObjectClosure* is_alive, nmethod* nm) {
-    assert(SafepointSynchronize::is_at_safepoint(), "this is only ok at safepoint");
-    _is_alive = is_alive;
-    nm->metadata_do(check_class);
-  }
-};
-
-// This is called during a safepoint so can use static data
-BoolObjectClosure* CheckClass::_is_alive = NULL;
-#endif // ASSERT
-
-
-// Processing of oop references should have been sufficient to keep
-// all strong references alive.  Any weak references should have been
-// cleared as well.  Visit all the metadata and ensure that it's
-// really alive.
-void nmethod::verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive) {
-#ifdef ASSERT
-    RelocIterator iter(this, low_boundary);
-    while (iter.next()) {
-    // static_stub_Relocations may have dangling references to
-    // Method*s so trim them out here.  Otherwise it looks like
-    // compiled code is maintaining a link to dead metadata.
-    address static_call_addr = NULL;
-    if (iter.type() == relocInfo::opt_virtual_call_type) {
-      CompiledIC* cic = CompiledIC_at(&iter);
-      if (!cic->is_call_to_interpreted()) {
-        static_call_addr = iter.addr();
-      }
-    } else if (iter.type() == relocInfo::static_call_type) {
-      CompiledStaticCall* csc = compiledStaticCall_at(iter.reloc());
-      if (!csc->is_call_to_interpreted()) {
-        static_call_addr = iter.addr();
-      }
-    }
-    if (static_call_addr != NULL) {
-      RelocIterator sciter(this, low_boundary);
-      while (sciter.next()) {
-        if (sciter.type() == relocInfo::static_stub_type &&
-            sciter.static_stub_reloc()->static_call() == static_call_addr) {
-          sciter.static_stub_reloc()->clear_inline_cache();
-        }
-      }
-    }
-  }
-  // Check that the metadata embedded in the nmethod is alive
-  CheckClass::do_check_class(is_alive, this);
-#endif
-}
-
-
 // Iterate over metadata calling this function.   Used by RedefineClasses
 void nmethod::metadata_do(void f(Metadata*)) {
   address low_boundary = verified_entry_point();
@@ -2359,32 +1778,6 @@
   return detect_scavenge_root.detected_scavenge_root();
 }
 
-// Method that knows how to preserve outgoing arguments at call. This method must be
-// called with a frame corresponding to a Java invoke
-void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
-#ifndef SHARK
-  if (method() != NULL && !method()->is_native()) {
-    address pc = fr.pc();
-    SimpleScopeDesc ssd(this, pc);
-    Bytecode_invoke call(ssd.method(), ssd.bci());
-    bool has_receiver = call.has_receiver();
-    bool has_appendix = call.has_appendix();
-    Symbol* signature = call.signature();
-
-    // The method attached by JIT-compilers should be used, if present.
-    // Bytecode can be inaccurate in such case.
-    Method* callee = attached_method_before_pc(pc);
-    if (callee != NULL) {
-      has_receiver = !(callee->access_flags().is_static());
-      has_appendix = false;
-      signature = callee->signature();
-    }
-
-    fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f);
-  }
-#endif // !SHARK
-}
-
 inline bool includes(void* p, void* from, void* to) {
   return from <= p && p < to;
 }
@@ -2414,7 +1807,7 @@
       break;
     }
   }
-  assert(has_method_handle_invokes() == (_deoptimize_mh_offset != -1), "must have deopt mh handler");
+  assert(has_method_handle_invokes() == (_deopt_mh_handler_begin != NULL), "must have deopt mh handler");
 
   int size = count * sizeof(PcDesc);
   assert(scopes_pcs_size() >= size, "oob");
@@ -2440,19 +1833,10 @@
   memcpy(scopes_data_begin(), buffer, size);
 }
 
-// When using JVMCI the address might be off by the size of a call instruction.
-bool nmethod::is_deopt_entry(address pc) {
-  return pc == deopt_handler_begin()
-#if INCLUDE_JVMCI
-    || pc == (deopt_handler_begin() + NativeCall::instruction_size)
-#endif
-    ;
-}
-
 #ifdef ASSERT
-static PcDesc* linear_search(nmethod* nm, int pc_offset, bool approximate) {
-  PcDesc* lower = nm->scopes_pcs_begin();
-  PcDesc* upper = nm->scopes_pcs_end();
+static PcDesc* linear_search(const PcDescSearch& search, int pc_offset, bool approximate) {
+  PcDesc* lower = search.scopes_pcs_begin();
+  PcDesc* upper = search.scopes_pcs_end();
   lower += 1; // exclude initial sentinel
   PcDesc* res = NULL;
   for (PcDesc* p = lower; p < upper; p++) {
@@ -2470,8 +1854,8 @@
 
 
 // Finds a PcDesc with real-pc equal to "pc"
-PcDesc* nmethod::find_pc_desc_internal(address pc, bool approximate) {
-  address base_address = code_begin();
+PcDesc* PcDescContainer::find_pc_desc_internal(address pc, bool approximate, const PcDescSearch& search) {
+  address base_address = search.code_begin();
   if ((pc < base_address) ||
       (pc - base_address) >= (ptrdiff_t) PcDesc::upper_offset_limit) {
     return NULL;  // PC is wildly out of range
@@ -2482,7 +1866,7 @@
   // (This as an almost 100% hit rate.)
   PcDesc* res = _pc_desc_cache.find_pc_desc(pc_offset, approximate);
   if (res != NULL) {
-    assert(res == linear_search(this, pc_offset, approximate), "cache ok");
+    assert(res == linear_search(search, pc_offset, approximate), "cache ok");
     return res;
   }
 
@@ -2490,8 +1874,8 @@
   // Find the last pc_offset less than the given offset.
   // The successor must be the required match, if there is a match at all.
   // (Use a fixed radix to avoid expensive affine pointer arithmetic.)
-  PcDesc* lower = scopes_pcs_begin();
-  PcDesc* upper = scopes_pcs_end();
+  PcDesc* lower = search.scopes_pcs_begin();
+  PcDesc* upper = search.scopes_pcs_end();
   upper -= 1; // exclude final sentinel
   if (lower >= upper)  return NULL;  // native method; no PcDescs at all
 
@@ -2542,11 +1926,11 @@
 #undef assert_LU_OK
 
   if (match_desc(upper, pc_offset, approximate)) {
-    assert(upper == linear_search(this, pc_offset, approximate), "search ok");
+    assert(upper == linear_search(search, pc_offset, approximate), "search ok");
     _pc_desc_cache.add_pc_desc(upper);
     return upper;
   } else {
-    assert(NULL == linear_search(this, pc_offset, approximate), "search ok");
+    assert(NULL == linear_search(search, pc_offset, approximate), "search ok");
     return NULL;
   }
 }
@@ -2617,15 +2001,18 @@
       Method* method = deps.method_argument(0);
       for (int j = 0; j < dependee_methods->length(); j++) {
         if (dependee_methods->at(j) == method) {
-          // RC_TRACE macro has an embedded ResourceMark
-          RC_TRACE(0x01000000,
-            ("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on method %s.%s(%s)",
-            _method->method_holder()->external_name(),
-            _method->name()->as_C_string(),
-            _method->signature()->as_C_string(), compile_id(),
-            method->method_holder()->external_name(),
-            method->name()->as_C_string(),
-            method->signature()->as_C_string()));
+          if (log_is_enabled(Debug, redefine, class, nmethod)) {
+            ResourceMark rm;
+            log_debug(redefine, class, nmethod)
+              ("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on method %s.%s(%s)",
+               _method->method_holder()->external_name(),
+               _method->name()->as_C_string(),
+               _method->signature()->as_C_string(),
+               compile_id(),
+               method->method_holder()->external_name(),
+               method->name()->as_C_string(),
+               method->signature()->as_C_string());
+          }
           if (TraceDependencies || LogCompilation)
             deps.log_dependency(dependee);
           return true;
@@ -2700,53 +2087,27 @@
 // QQQ might we make this work from a frame??
 nmethodLocker::nmethodLocker(address pc) {
   CodeBlob* cb = CodeCache::find_blob(pc);
-  guarantee(cb != NULL && cb->is_nmethod(), "bad pc for a nmethod found");
-  _nm = (nmethod*)cb;
+  guarantee(cb != NULL && cb->is_compiled(), "bad pc for a nmethod found");
+  _nm = cb->as_compiled_method();
   lock_nmethod(_nm);
 }
 
 // Only JvmtiDeferredEvent::compiled_method_unload_event()
 // should pass zombie_ok == true.
-void nmethodLocker::lock_nmethod(nmethod* nm, bool zombie_ok) {
-  if (nm == NULL)  return;
+void nmethodLocker::lock_nmethod(CompiledMethod* cm, bool zombie_ok) {
+  if (cm == NULL)  return;
+  nmethod* nm = cm->as_nmethod();
   Atomic::inc(&nm->_lock_count);
   assert(zombie_ok || !nm->is_zombie(), "cannot lock a zombie method");
 }
 
-void nmethodLocker::unlock_nmethod(nmethod* nm) {
-  if (nm == NULL)  return;
+void nmethodLocker::unlock_nmethod(CompiledMethod* cm) {
+  if (cm == NULL)  return;
+  nmethod* nm = cm->as_nmethod();
   Atomic::dec(&nm->_lock_count);
   assert(nm->_lock_count >= 0, "unmatched nmethod lock/unlock");
 }
 
-// -----------------------------------------------------------------------------
-// nmethod::get_deopt_original_pc
-//
-// Return the original PC for the given PC if:
-// (a) the given PC belongs to a nmethod and
-// (b) it is a deopt PC
-address nmethod::get_deopt_original_pc(const frame* fr) {
-  if (fr->cb() == NULL)  return NULL;
-
-  nmethod* nm = fr->cb()->as_nmethod_or_null();
-  if (nm != NULL && nm->is_deopt_pc(fr->pc()))
-    return nm->get_original_pc(fr);
-
-  return NULL;
-}
-
-
-// -----------------------------------------------------------------------------
-// MethodHandle
-
-bool nmethod::is_method_handle_return(address return_pc) {
-  if (!has_method_handle_invokes())  return false;
-  PcDesc* pd = pc_desc_at(return_pc);
-  if (pd == NULL)
-    return false;
-  return pd->is_method_handle_invoke();
-}
-
 
 // -----------------------------------------------------------------------------
 // Verification
@@ -3200,7 +2561,7 @@
   if (block_begin == verified_entry_point())    stream->print_cr("[Verified Entry Point]");
   if (JVMCI_ONLY(_exception_offset >= 0 &&) block_begin == exception_begin())         stream->print_cr("[Exception Handler]");
   if (block_begin == stub_begin())              stream->print_cr("[Stub Code]");
-  if (JVMCI_ONLY(_deoptimize_offset >= 0 &&) block_begin == deopt_handler_begin())     stream->print_cr("[Deopt Handler Code]");
+  if (JVMCI_ONLY(_deopt_handler_begin != NULL &&) block_begin == deopt_handler_begin())     stream->print_cr("[Deopt Handler Code]");
 
   if (has_method_handle_invokes())
     if (block_begin == deopt_mh_handler_begin())  stream->print_cr("[Deopt MH Handler Code]");
@@ -3564,26 +2925,3 @@
 }
 #endif
 
-Method* nmethod::attached_method(address call_instr) {
-  assert(code_contains(call_instr), "not part of the nmethod");
-  RelocIterator iter(this, call_instr, call_instr + 1);
-  while (iter.next()) {
-    if (iter.addr() == call_instr) {
-      switch(iter.type()) {
-        case relocInfo::static_call_type:      return iter.static_call_reloc()->method_value();
-        case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
-        case relocInfo::virtual_call_type:     return iter.virtual_call_reloc()->method_value();
-      }
-    }
-  }
-  return NULL; // not found
-}
-
-Method* nmethod::attached_method_before_pc(address pc) {
-  if (NativeCall::is_call_before(pc)) {
-    NativeCall* ncall = nativeCall_before(pc);
-    return attached_method(ncall->instruction_address());
-  }
-  return NULL; // not a call
-}
-
diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp
index 1a8c82c..16ad01a 100644
--- a/hotspot/src/share/vm/code/nmethod.hpp
+++ b/hotspot/src/share/vm/code/nmethod.hpp
@@ -25,67 +25,11 @@
 #ifndef SHARE_VM_CODE_NMETHOD_HPP
 #define SHARE_VM_CODE_NMETHOD_HPP
 
-#include "code/codeBlob.hpp"
-#include "code/pcDesc.hpp"
-#include "oops/metadata.hpp"
+#include "code/compiledMethod.hpp"
 
+class DepChange;
 class DirectiveSet;
 
-// This class is used internally by nmethods, to cache
-// exception/pc/handler information.
-
-class ExceptionCache : public CHeapObj<mtCode> {
-  friend class VMStructs;
- private:
-  enum { cache_size = 16 };
-  Klass*   _exception_type;
-  address  _pc[cache_size];
-  address  _handler[cache_size];
-  int      _count;
-  ExceptionCache* _next;
-
-  address pc_at(int index)                     { assert(index >= 0 && index < count(),""); return _pc[index]; }
-  void    set_pc_at(int index, address a)      { assert(index >= 0 && index < cache_size,""); _pc[index] = a; }
-  address handler_at(int index)                { assert(index >= 0 && index < count(),""); return _handler[index]; }
-  void    set_handler_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _handler[index] = a; }
-  int     count()                              { return _count; }
-  void    increment_count()                    { _count++; }
-
- public:
-
-  ExceptionCache(Handle exception, address pc, address handler);
-
-  Klass*    exception_type()                { return _exception_type; }
-  ExceptionCache* next()                    { return _next; }
-  void      set_next(ExceptionCache *ec)    { _next = ec; }
-
-  address match(Handle exception, address pc);
-  bool    match_exception_with_space(Handle exception) ;
-  address test_address(address addr);
-  bool    add_address_and_handler(address addr, address handler) ;
-};
-
-
-// cache pc descs found in earlier inquiries
-class PcDescCache VALUE_OBJ_CLASS_SPEC {
-  friend class VMStructs;
- private:
-  enum { cache_size = 4 };
-  // The array elements MUST be volatile! Several threads may modify
-  // and read from the cache concurrently. find_pc_desc_internal has
-  // returned wrong results. C++ compiler (namely xlC12) may duplicate
-  // C++ field accesses if the elements are not volatile.
-  typedef PcDesc* PcDescPtr;
-  volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found
- public:
-  PcDescCache() { debug_only(_pc_descs[0] = NULL); }
-  void    reset_to(PcDesc* initial_pc_desc);
-  PcDesc* find_pc_desc(int pc_offset, bool approximate);
-  void    add_pc_desc(PcDesc* pc_desc);
-  PcDesc* last_pc_desc() { return _pc_descs[0]; }
-};
-
-
 // nmethods (native methods) are the compiled code versions of Java methods.
 //
 // An nmethod contains:
@@ -107,26 +51,14 @@
 //  [Implicit Null Pointer exception table]
 //  - implicit null table array
 
-class DepChange;
-class Dependencies;
-class ExceptionHandlerTable;
-class ImplicitExceptionTable;
-class AbstractCompiler;
-class xmlStream;
-
-class nmethod : public CodeBlob {
+class nmethod : public CompiledMethod {
   friend class VMStructs;
   friend class JVMCIVMStructs;
   friend class NMethodSweeper;
   friend class CodeCache;  // scavengable oops
  private:
 
-  // GC support to help figure out if an nmethod has been
-  // cleaned/unloaded by the current GC.
-  static unsigned char _global_unloading_clock;
-
   // Shared fields for all nmethod's
-  Method*   _method;
   int       _entry_bci;        // != InvocationEntryBci if this nmethod is an on-stack replacement method
   jmethodID _jmethod_id;       // Cache of method()->jmethod_id()
 
@@ -139,13 +71,6 @@
   // To support simple linked-list chaining of nmethods:
   nmethod*  _osr_link;         // from InstanceKlass::osr_nmethods_head
 
-  union {
-    // Used by G1 to chain nmethods.
-    nmethod* _unloading_next;
-    // Used by non-G1 GCs to chain nmethods.
-    nmethod* _scavenge_root_link; // from CodeCache::scavenge_root_nmethods
-  };
-
   static nmethod* volatile _oops_do_mark_nmethods;
   nmethod*        volatile _oops_do_mark_link;
 
@@ -157,13 +82,7 @@
   address _osr_entry_point;                  // entry point for on stack replacement
 
   // Offsets for different nmethod parts
-  int _exception_offset;
-  // All deoptee's will resume execution at this location described by
-  // this offset.
-  int _deoptimize_offset;
-  // All deoptee's at a MethodHandle call site will resume execution
-  // at this location described by this offset.
-  int _deoptimize_mh_offset;
+  int  _exception_offset;
   // Offset of the unwind handler if it exists
   int _unwind_handler_offset;
 
@@ -178,6 +97,8 @@
   int _nul_chk_table_offset;
   int _nmethod_end_offset;
 
+  int code_offset() const { return (address) code_begin() - header_begin(); }
+
   // location in frame (offset for sp) that deopt can store the original
   // pc during a deopt.
   int _orig_pc_offset;
@@ -188,27 +109,12 @@
   // protected by CodeCache_lock
   bool _has_flushed_dependencies;            // Used for maintenance of dependencies (CodeCache_lock)
 
-  enum MarkForDeoptimizationStatus {
-    not_marked,
-    deoptimize,
-    deoptimize_noupdate };
-
-  MarkForDeoptimizationStatus _mark_for_deoptimization_status; // Used for stack deoptimization
-
   // used by jvmti to track if an unload event has been posted for this nmethod.
   bool _unload_reported;
 
-  // set during construction
-  unsigned int _has_unsafe_access:1;         // May fault due to unsafe access.
-  unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
-  unsigned int _lazy_critical_native:1;      // Lazy JNI critical native
-  unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints
-
   // Protected by Patching_lock
   volatile unsigned char _state;             // {in_use, not_entrant, zombie, unloaded}
 
-  volatile unsigned char _unloading_clock;   // Incremented after GC unloaded/cleaned the nmethod
-
 #ifdef ASSERT
   bool _oops_are_stale;  // indicates that it's no longer safe to access oops section
 #endif
@@ -241,9 +147,6 @@
   // counter is decreased (by 1) while sweeping.
   int _hotness_counter;
 
-  ExceptionCache *_exception_cache;
-  PcDescCache     _pc_desc_cache;
-
   // These are used for compiled synchronized native methods to
   // locate the owner and stack slot for the BasicLock so that we can
   // properly revoke the bias of the owner if necessary. They are
@@ -301,18 +204,21 @@
   // Returns true if this thread changed the state of the nmethod or
   // false if another thread performed the transition.
   bool make_not_entrant_or_zombie(unsigned int state);
+  bool make_entrant() { Unimplemented(); return false; }
   void inc_decompile_count();
 
-  // Used to manipulate the exception cache
-  void add_exception_cache_entry(ExceptionCache* new_entry);
-  ExceptionCache* exception_cache_entry_for_exception(Handle exception);
-
   // Inform external interfaces that a compiled method has been unloaded
   void post_compiled_method_unload();
 
   // Initailize fields to their default values
   void init_defaults();
 
+  // Offsets
+  int content_offset() const                  { return content_begin() - header_begin(); }
+  int data_offset() const                     { return _data_offset; }
+
+  address header_end() const                  { return (address)    header_begin() + header_size(); }
+
  public:
   // create nmethod with entry_bci
   static nmethod* new_nmethod(const methodHandle& method,
@@ -333,7 +239,7 @@
                               , Handle installed_code = Handle(),
                               Handle speculation_log = Handle()
 #endif
-                             );
+  );
 
   static nmethod* new_native_nmethod(const methodHandle& method,
                                      int compile_id,
@@ -346,13 +252,10 @@
                                      OopMapSet* oop_maps);
 
   // accessors
-  Method* method() const                          { return _method; }
   AbstractCompiler* compiler() const              { return _compiler; }
 
   // type info
   bool is_nmethod() const                         { return true; }
-  bool is_java_method() const                     { return !method()->is_native(); }
-  bool is_native_method() const                   { return method()->is_native(); }
   bool is_osr_method() const                      { return _entry_bci != InvocationEntryBci; }
 
   bool is_compiled_by_c1() const;
@@ -362,22 +265,17 @@
 
   // boundaries for different parts
   address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
-  address consts_end            () const          { return           header_begin() +  code_offset()        ; }
-  address insts_begin           () const          { return           header_begin() +  code_offset()        ; }
-  address insts_end             () const          { return           header_begin() + _stub_offset          ; }
+  address consts_end            () const          { return           code_begin()                           ; }
   address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
   address stub_end              () const          { return           header_begin() + _oops_offset          ; }
   address exception_begin       () const          { return           header_begin() + _exception_offset     ; }
-  address deopt_handler_begin   () const          { return           header_begin() + _deoptimize_offset    ; }
-  address deopt_mh_handler_begin() const          { return           header_begin() + _deoptimize_mh_offset ; }
   address unwind_handler_begin  () const          { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
   oop*    oops_begin            () const          { return (oop*)   (header_begin() + _oops_offset)         ; }
   oop*    oops_end              () const          { return (oop*)   (header_begin() + _metadata_offset)     ; }
 
   Metadata** metadata_begin   () const            { return (Metadata**)  (header_begin() + _metadata_offset)     ; }
-  Metadata** metadata_end     () const            { return (Metadata**)  (header_begin() + _scopes_data_offset)  ; }
+  Metadata** metadata_end     () const            { return (Metadata**)  _scopes_data_begin; }
 
-  address scopes_data_begin     () const          { return           header_begin() + _scopes_data_offset   ; }
   address scopes_data_end       () const          { return           header_begin() + _scopes_pcs_offset    ; }
   PcDesc* scopes_pcs_begin      () const          { return (PcDesc*)(header_begin() + _scopes_pcs_offset   ); }
   PcDesc* scopes_pcs_end        () const          { return (PcDesc*)(header_begin() + _dependencies_offset) ; }
@@ -389,16 +287,9 @@
   address nul_chk_table_end     () const          { return           header_begin() + _nmethod_end_offset   ; }
 
   // Sizes
-  int consts_size       () const                  { return            consts_end       () -            consts_begin       (); }
-  int insts_size        () const                  { return            insts_end        () -            insts_begin        (); }
-  int stub_size         () const                  { return            stub_end         () -            stub_begin         (); }
   int oops_size         () const                  { return (address)  oops_end         () - (address)  oops_begin         (); }
   int metadata_size     () const                  { return (address)  metadata_end     () - (address)  metadata_begin     (); }
-  int scopes_data_size  () const                  { return            scopes_data_end  () -            scopes_data_begin  (); }
-  int scopes_pcs_size   () const                  { return (intptr_t) scopes_pcs_end   () - (intptr_t) scopes_pcs_begin   (); }
   int dependencies_size () const                  { return            dependencies_end () -            dependencies_begin (); }
-  int handler_table_size() const                  { return            handler_table_end() -            handler_table_begin(); }
-  int nul_chk_table_size() const                  { return            nul_chk_table_end() -            nul_chk_table_begin(); }
 
   int     oops_count() const { assert(oops_size() % oopSize == 0, "");  return (oops_size() / oopSize) + 1; }
   int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
@@ -410,15 +301,10 @@
   int  hotness_counter() const      { return _hotness_counter; }
 
   // Containment
-  bool consts_contains       (address addr) const { return consts_begin       () <= addr && addr < consts_end       (); }
-  bool insts_contains        (address addr) const { return insts_begin        () <= addr && addr < insts_end        (); }
-  bool stub_contains         (address addr) const { return stub_begin         () <= addr && addr < stub_end         (); }
   bool oops_contains         (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
   bool metadata_contains     (Metadata** addr) const   { return metadata_begin     () <= addr && addr < metadata_end     (); }
   bool scopes_data_contains  (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
   bool scopes_pcs_contains   (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
-  bool handler_table_contains(address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
-  bool nul_chk_table_contains(address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
 
   // entry points
   address entry_point() const                     { return _entry_point;             } // normal entry point
@@ -433,24 +319,11 @@
 
   // flag accessing and manipulation
   bool  is_in_use() const                         { return _state == in_use; }
-  bool  is_alive() const                          { return _state == in_use || _state == not_entrant; }
+  bool  is_alive() const                          { unsigned char s = _state; return s < zombie; }
   bool  is_not_entrant() const                    { return _state == not_entrant; }
   bool  is_zombie() const                         { return _state == zombie; }
   bool  is_unloaded() const                       { return _state == unloaded; }
 
-  // returns a string version of the nmethod state
-  const char* state() const {
-    switch(_state) {
-      case in_use:      return "in use";
-      case not_entrant: return "not_entrant";
-      case zombie:      return "zombie";
-      case unloaded:    return "unloaded";
-      default:
-        fatal("unexpected nmethod state: %d", _state);
-        return NULL;
-    }
-  }
-
 #if INCLUDE_RTM_OPT
   // rtm state accessing and manipulating
   RTMState  rtm_state() const                     { return _rtm_state; }
@@ -465,30 +338,15 @@
     assert(!method()->is_method_handle_intrinsic(), "Cannot make MH intrinsic not entrant");
     return make_not_entrant_or_zombie(not_entrant);
   }
+  bool  make_not_used()    { return make_not_entrant(); }
   bool  make_zombie()      { return make_not_entrant_or_zombie(zombie); }
 
   // used by jvmti to track if the unload event has been reported
   bool  unload_reported()                         { return _unload_reported; }
   void  set_unload_reported()                     { _unload_reported = true; }
 
-  void set_unloading_next(nmethod* next)          { _unloading_next = next; }
-  nmethod* unloading_next()                       { return _unloading_next; }
-
-  static unsigned char global_unloading_clock()   { return _global_unloading_clock; }
-  static void increase_unloading_clock();
-
-  void set_unloading_clock(unsigned char unloading_clock);
-  unsigned char unloading_clock();
-
-  bool  is_marked_for_deoptimization() const      { return _mark_for_deoptimization_status != not_marked; }
-  void  mark_for_deoptimization(bool inc_recompile_counts = true) {
-    _mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate);
-  }
-  bool update_recompile_counts() const {
-    // Update recompile counts when either the update is explicitly requested (deoptimize)
-    // or the nmethod is not marked for deoptimization at all (not_marked).
-    // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
-    return _mark_for_deoptimization_status != deoptimize_noupdate;
+  int get_state() const {
+    return _state;
   }
 
   void  make_unloaded(BoolObjectClosure* is_alive, oop cause);
@@ -501,18 +359,6 @@
     _has_flushed_dependencies = 1;
   }
 
-  bool  has_unsafe_access() const                 { return _has_unsafe_access; }
-  void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
-
-  bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
-  void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
-
-  bool  is_lazy_critical_native() const           { return _lazy_critical_native; }
-  void  set_lazy_critical_native(bool z)          { _lazy_critical_native = z; }
-
-  bool  has_wide_vectors() const                  { return _has_wide_vectors; }
-  void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
-
   int   comp_level() const                        { return _comp_level; }
 
   // Support for oops in scopes and relocs:
@@ -537,9 +383,6 @@
   void copy_values(GrowableArray<jobject>* oops);
   void copy_values(GrowableArray<Metadata*>* metadata);
 
-  Method* attached_method(address call_pc);
-  Method* attached_method_before_pc(address pc);
-
   // Relocation support
 private:
   void fix_oop_relocations(address begin, address end, bool initialize_immediates);
@@ -548,10 +391,6 @@
 public:
   void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); }
   void fix_oop_relocations()                           { fix_oop_relocations(NULL, NULL, false); }
-  void verify_oop_relocations();
-
-  bool is_at_poll_return(address pc);
-  bool is_at_poll_or_poll_return(address pc);
 
   // Scavengable oop support
   bool  on_scavenge_root_list() const                  { return (_scavenge_root_state & 1) != 0; }
@@ -575,13 +414,6 @@
   long  stack_traversal_mark()                    { return _stack_traversal_mark; }
   void  set_stack_traversal_mark(long l)          { _stack_traversal_mark = l; }
 
-  // Exception cache support
-  ExceptionCache* exception_cache() const         { return _exception_cache; }
-  void set_exception_cache(ExceptionCache *ec)    { _exception_cache = ec; }
-  address handler_for_exception_and_pc(Handle exception, address pc);
-  void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
-  void clean_exception_cache(BoolObjectClosure* is_alive);
-
   // implicit exceptions support
   address continuation_for_implicit_exception(address pc);
 
@@ -592,24 +424,8 @@
   nmethod* osr_link() const                       { return _osr_link; }
   void     set_osr_link(nmethod *n)               { _osr_link = n; }
 
-  // tells whether frames described by this nmethod can be deoptimized
-  // note: native wrappers cannot be deoptimized.
-  bool can_be_deoptimized() const { return is_java_method(); }
-
-  // Inline cache support
-  void clear_inline_caches();
-  void clear_ic_stubs();
-  void cleanup_inline_caches(bool clean_all = false);
-  bool inlinecache_check_contains(address addr) const {
-    return (addr >= code_begin() && addr < verified_entry_point());
-  }
-
   // Verify calls to dead methods have been cleaned.
   void verify_clean_inline_caches();
-  // Verify and count cached icholder relocations.
-  int  verify_icholder_relocations();
-  // Check that all metadata is still alive
-  void verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive);
 
   // unlink and deallocate this nmethod
   // Only NMethodSweeper class is expected to use this. NMethodSweeper is not
@@ -650,20 +466,19 @@
  public:
 #endif
 
-  // GC support
-  void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
-  //  The parallel versions are used by G1.
-  bool do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred);
-  void do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred);
+ protected:
+  virtual bool do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred);
+#if INCLUDE_JVMCI
+  virtual bool do_unloading_jvmci(BoolObjectClosure* is_alive, bool unloading_occurred);
+#endif
 
  private:
+  bool do_unloading_scopes(BoolObjectClosure* is_alive, bool unloading_occurred);
   //  Unload a nmethod if the *root object is dead.
   bool can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred);
   bool unload_if_dead_at(RelocIterator *iter_at_oop, BoolObjectClosure* is_alive, bool unloading_occurred);
 
  public:
-  void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map,
-                                     OopClosure* f);
   void oops_do(OopClosure* f) { oops_do(f, false); }
   void oops_do(OopClosure* f, bool allow_zombie);
   bool detect_scavenge_root_oops();
@@ -675,49 +490,20 @@
   static bool oops_do_marking_is_active() { return _oops_do_mark_nmethods != NULL; }
   bool test_oops_do_mark() { return _oops_do_mark_link != NULL; }
 
-  // ScopeDesc for an instruction
-  ScopeDesc* scope_desc_at(address pc);
-
  private:
   ScopeDesc* scope_desc_in(address begin, address end);
 
   address* orig_pc_addr(const frame* fr) { return (address*) ((address)fr->unextended_sp() + _orig_pc_offset); }
 
-  PcDesc* find_pc_desc_internal(address pc, bool approximate);
-
-  PcDesc* find_pc_desc(address pc, bool approximate) {
-    PcDesc* desc = _pc_desc_cache.last_pc_desc();
-    if (desc != NULL && desc->pc_offset() == pc - code_begin()) {
-      return desc;
-    }
-    return find_pc_desc_internal(pc, approximate);
-  }
-
- public:
-  // ScopeDesc retrieval operation
-  PcDesc* pc_desc_at(address pc)   { return find_pc_desc(pc, false); }
-  // pc_desc_near returns the first PcDesc at or after the givne pc.
-  PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
-
  public:
   // copying of debugging information
   void copy_scopes_pcs(PcDesc* pcs, int count);
   void copy_scopes_data(address buffer, int size);
 
-  // Deopt
-  // Return true is the PC is one would expect if the frame is being deopted.
-  bool is_deopt_pc      (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); }
-  bool is_deopt_entry   (address pc);
-  bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); }
   // Accessor/mutator for the original pc of a frame before a frame was deopted.
   address get_original_pc(const frame* fr) { return *orig_pc_addr(fr); }
   void    set_original_pc(const frame* fr, address pc) { *orig_pc_addr(fr) = pc; }
 
-  static address get_deopt_original_pc(const frame* fr);
-
-  // MethodHandle
-  bool is_method_handle_return(address return_pc);
-
   // jvmti support:
   void post_compiled_method_load_event();
   jmethodID get_and_cache_jmethod_id();
@@ -767,7 +553,7 @@
   // are numbered in an independent sequence if CICountOSR is true,
   // and native method wrappers are also numbered independently if
   // CICountNative is true.
-  int  compile_id() const                         { return _compile_id; }
+  virtual int compile_id() const { return _compile_id; }
   const char* compile_kind() const;
 
   // tells if any of this method's dependencies have been invalidated
@@ -786,7 +572,7 @@
   // Fast breakpoint support. Tells if this compiled method is
   // dependent on the given method. Returns true if this nmethod
   // corresponds to the given method as well.
-  bool is_dependent_on_method(Method* dependee);
+  virtual bool is_dependent_on_method(Method* dependee);
 
   // is it ok to patch at address?
   bool is_patchable_at(address instr_address);
@@ -804,12 +590,7 @@
   static int osr_entry_point_offset()             { return offset_of(nmethod, _osr_entry_point); }
   static int state_offset()                       { return offset_of(nmethod, _state); }
 
-  // RedefineClasses support.   Mark metadata in nmethods as on_stack so that
-  // redefine classes doesn't purge it.
-  static void mark_on_stack(nmethod* nm) {
-    nm->metadata_do(Metadata::mark_on_stack);
-  }
-  void metadata_do(void f(Metadata*));
+  virtual void metadata_do(void f(Metadata*));
 };
 
 // Locks an nmethod so its code will not get removed and it will not
@@ -818,26 +599,43 @@
 // needs to be done, then lock_nmethod() is used directly to keep the
 // generated code from being reused too early.
 class nmethodLocker : public StackObj {
-  nmethod* _nm;
+  CompiledMethod* _nm;
 
  public:
 
   // note: nm can be NULL
   // Only JvmtiDeferredEvent::compiled_method_unload_event()
   // should pass zombie_ok == true.
-  static void lock_nmethod(nmethod* nm, bool zombie_ok = false);
-  static void unlock_nmethod(nmethod* nm); // (ditto)
+  static void lock_nmethod(CompiledMethod* nm, bool zombie_ok = false);
+  static void unlock_nmethod(CompiledMethod* nm); // (ditto)
 
   nmethodLocker(address pc); // derive nm from pc
   nmethodLocker(nmethod *nm) { _nm = nm; lock_nmethod(_nm); }
-  nmethodLocker() { _nm = NULL; }
-  ~nmethodLocker() { unlock_nmethod(_nm); }
+  nmethodLocker(CompiledMethod *nm) {
+    _nm = nm;
+    lock(_nm);
+  }
 
-  nmethod* code() { return _nm; }
-  void set_code(nmethod* new_nm) {
-    unlock_nmethod(_nm);   // note:  This works even if _nm==new_nm.
+  static void lock(CompiledMethod* method) {
+    if (method == NULL) return;
+    lock_nmethod(method);
+  }
+
+  static void unlock(CompiledMethod* method) {
+    if (method == NULL) return;
+    unlock_nmethod(method);
+  }
+
+  nmethodLocker() { _nm = NULL; }
+  ~nmethodLocker() {
+    unlock(_nm);
+  }
+
+  CompiledMethod* code() { return _nm; }
+  void set_code(CompiledMethod* new_nm) {
+    unlock(_nm);   // note:  This works even if _nm==new_nm.
     _nm = new_nm;
-    lock_nmethod(_nm);
+    lock(_nm);
   }
 };
 
diff --git a/hotspot/src/share/vm/code/pcDesc.cpp b/hotspot/src/share/vm/code/pcDesc.cpp
index a860b5b..ebacd8f 100644
--- a/hotspot/src/share/vm/code/pcDesc.cpp
+++ b/hotspot/src/share/vm/code/pcDesc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,11 +36,11 @@
   _flags               = 0;
 }
 
-address PcDesc::real_pc(const nmethod* code) const {
+address PcDesc::real_pc(const CompiledMethod* code) const {
   return code->code_begin() + pc_offset();
 }
 
-void PcDesc::print(nmethod* code) {
+void PcDesc::print(CompiledMethod* code) {
 #ifndef PRODUCT
   ResourceMark rm;
   tty->print_cr("PcDesc(pc=" PTR_FORMAT " offset=%x bits=%x):", p2i(real_pc(code)), pc_offset(), _flags);
@@ -57,7 +57,7 @@
 #endif
 }
 
-bool PcDesc::verify(nmethod* code) {
+bool PcDesc::verify(CompiledMethod* code) {
   //Unimplemented();
   return true;
 }
diff --git a/hotspot/src/share/vm/code/pcDesc.hpp b/hotspot/src/share/vm/code/pcDesc.hpp
index 83734c8..435c8af 100644
--- a/hotspot/src/share/vm/code/pcDesc.hpp
+++ b/hotspot/src/share/vm/code/pcDesc.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 // PcDescs map a physical PC (given as offset from start of nmethod) to
 // the corresponding source scope and byte code index.
 
-class nmethod;
+class CompiledMethod;
 
 class PcDesc VALUE_OBJ_CLASS_SPEC {
   friend class VMStructs;
@@ -91,10 +91,10 @@
   void set_return_oop(bool z)                    { set_flag(PCDESC_return_oop, z); }
 
   // Returns the real pc
-  address real_pc(const nmethod* code) const;
+  address real_pc(const CompiledMethod* code) const;
 
-  void print(nmethod* code);
-  bool verify(nmethod* code);
+  void print(CompiledMethod* code);
+  bool verify(CompiledMethod* code);
 };
 
 #endif // SHARE_VM_CODE_PCDESC_HPP
diff --git a/hotspot/src/share/vm/code/relocInfo.cpp b/hotspot/src/share/vm/code/relocInfo.cpp
index 444c91c..45a39db 100644
--- a/hotspot/src/share/vm/code/relocInfo.cpp
+++ b/hotspot/src/share/vm/code/relocInfo.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,6 @@
   return (relocInfo*)prefix_limit;
 }
 
-
 void relocInfo::set_type(relocType t) {
   int old_offset = addr_offset();
   int old_format = format();
@@ -91,6 +90,9 @@
   assert(format()==old_format, "sanity check");
 }
 
+nmethod* RelocIterator::code_as_nmethod() const {
+  return _code->as_nmethod();
+}
 
 void relocInfo::set_format(int f) {
   int old_offset = addr_offset();
@@ -121,13 +123,13 @@
 // ----------------------------------------------------------------------------------------------------
 // Implementation of RelocIterator
 
-void RelocIterator::initialize(nmethod* nm, address begin, address limit) {
+void RelocIterator::initialize(CompiledMethod* nm, address begin, address limit) {
   initialize_misc();
 
   if (nm == NULL && begin != NULL) {
     // allow nmethod to be deduced from beginning address
     CodeBlob* cb = CodeCache::find_blob(begin);
-    nm = cb->as_nmethod_or_null();
+    nm = cb->as_compiled_method_or_null();
   }
   assert(nm != NULL, "must be able to deduce nmethod from other arguments");
 
diff --git a/hotspot/src/share/vm/code/relocInfo.hpp b/hotspot/src/share/vm/code/relocInfo.hpp
index 86a454c..deaa38c2 100644
--- a/hotspot/src/share/vm/code/relocInfo.hpp
+++ b/hotspot/src/share/vm/code/relocInfo.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
 #include "memory/allocation.hpp"
 #include "runtime/os.hpp"
 
+class nmethod;
+class CompiledMethod;
 class Metadata;
 class NativeMovConstReg;
 
@@ -539,7 +541,7 @@
   address         _limit;   // stop producing relocations after this _addr
   relocInfo*      _current; // the current relocation information
   relocInfo*      _end;     // end marker; we're done iterating when _current == _end
-  nmethod*        _code;    // compiled method containing _addr
+  CompiledMethod* _code;    // compiled method containing _addr
   address         _addr;    // instruction to which the relocation applies
   short           _databuf; // spare buffer for compressed data
   short*          _data;    // pointer to the relocation's data
@@ -570,13 +572,13 @@
 
   void initialize_misc();
 
-  void initialize(nmethod* nm, address begin, address limit);
+  void initialize(CompiledMethod* nm, address begin, address limit);
 
   RelocIterator() { initialize_misc(); }
 
  public:
   // constructor
-  RelocIterator(nmethod* nm, address begin = NULL, address limit = NULL);
+  RelocIterator(CompiledMethod* nm, address begin = NULL, address limit = NULL);
   RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL);
 
   // get next reloc info, return !eos
@@ -611,7 +613,8 @@
   relocType    type()         const { return current()->type(); }
   int          format()       const { return (relocInfo::have_format) ? current()->format() : 0; }
   address      addr()         const { return _addr; }
-  nmethod*     code()         const { return _code; }
+  CompiledMethod*     code()  const { return _code; }
+  nmethod*     code_as_nmethod() const;
   short*       data()         const { return _data; }
   int          datalen()      const { return _datalen; }
   bool     has_current()      const { return _datalen >= 0; }
@@ -810,9 +813,10 @@
 
  public:
   // accessors which only make sense for a bound Relocation
-  address  addr()         const { return binding()->addr(); }
-  nmethod* code()         const { return binding()->code(); }
-  bool     addr_in_const() const { return binding()->addr_in_const(); }
+  address         addr()            const { return binding()->addr(); }
+  CompiledMethod* code()            const { return binding()->code(); }
+  nmethod*        code_as_nmethod() const { return binding()->code_as_nmethod(); }
+  bool            addr_in_const()   const { return binding()->addr_in_const(); }
  protected:
   short*   data()         const { return binding()->data(); }
   int      datalen()      const { return binding()->datalen(); }
@@ -1371,7 +1375,7 @@
 APPLY_TO_RELOCATIONS(EACH_CASE);
 #undef EACH_CASE
 
-inline RelocIterator::RelocIterator(nmethod* nm, address begin, address limit) {
+inline RelocIterator::RelocIterator(CompiledMethod* nm, address begin, address limit) {
   initialize(nm, begin, limit);
 }
 
diff --git a/hotspot/src/share/vm/code/scopeDesc.cpp b/hotspot/src/share/vm/code/scopeDesc.cpp
index 55d4eb9..27eb37a 100644
--- a/hotspot/src/share/vm/code/scopeDesc.cpp
+++ b/hotspot/src/share/vm/code/scopeDesc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 #include "oops/oop.inline.hpp"
 #include "runtime/handles.inline.hpp"
 
-ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) {
+ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) {
   _code          = code;
   _decode_offset = decode_offset;
   _objects       = decode_object_values(obj_decode_offset);
@@ -40,7 +40,7 @@
   decode_body();
 }
 
-ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) {
+ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) {
   _code          = code;
   _decode_offset = decode_offset;
   _objects       = decode_object_values(DebugInformationRecorder::serialized_null);
diff --git a/hotspot/src/share/vm/code/scopeDesc.hpp b/hotspot/src/share/vm/code/scopeDesc.hpp
index 57082c0..d1eaaac 100644
--- a/hotspot/src/share/vm/code/scopeDesc.hpp
+++ b/hotspot/src/share/vm/code/scopeDesc.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
   int _bci;
 
  public:
-  SimpleScopeDesc(nmethod* code, address pc) {
+  SimpleScopeDesc(CompiledMethod* code, address pc) {
     PcDesc* pc_desc = code->pc_desc_at(pc);
     assert(pc_desc != NULL, "Must be able to find matching PcDesc");
     DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset());
@@ -60,12 +60,12 @@
 class ScopeDesc : public ResourceObj {
  public:
   // Constructor
-  ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop);
+  ScopeDesc(const CompiledMethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop);
 
   // Calls above, giving default value of "serialized_null" to the
   // "obj_decode_offset" argument.  (We don't use a default argument to
   // avoid a .hpp-.hpp dependency.)
-  ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop);
+  ScopeDesc(const CompiledMethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop);
 
   // JVM state
   Method* method()      const { return _method; }
@@ -110,7 +110,7 @@
   GrowableArray<ScopeValue*>* _objects;
 
   // Nmethod information
-  const nmethod* _code;
+  const CompiledMethod* _code;
 
   // Decoding operations
   void decode_body();
diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp
index c4758b2..22934de 100644
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp
@@ -169,6 +169,8 @@
 CompileQueue* CompileBroker::_c2_compile_queue   = NULL;
 CompileQueue* CompileBroker::_c1_compile_queue   = NULL;
 
+
+
 class CompilationLog : public StringEventLog {
  public:
   CompilationLog() : StringEventLog("Compilation events") {
@@ -844,7 +846,7 @@
                                         int comp_level,
                                         const methodHandle& hot_method,
                                         int hot_count,
-                                        const char* comment,
+                                        CompileTask::CompileReason compile_reason,
                                         bool blocking,
                                         Thread* thread) {
   guarantee(!method->is_abstract(), "cannot compile abstract methods");
@@ -860,7 +862,7 @@
     if (osr_bci != InvocationEntryBci) {
       tty->print(" osr_bci: %d", osr_bci);
     }
-    tty->print(" level: %d comment: %s count: %d", comp_level, comment, hot_count);
+    tty->print(" level: %d comment: %s count: %d", comp_level, CompileTask::reason_name(compile_reason), hot_count);
     if (!hot_method.is_null()) {
       tty->print(" hot: ");
       if (hot_method() != method()) {
@@ -1024,7 +1026,7 @@
     task = create_compile_task(queue,
                                compile_id, method,
                                osr_bci, comp_level,
-                               hot_method, hot_count, comment,
+                               hot_method, hot_count, compile_reason,
                                blocking);
   }
 
@@ -1036,15 +1038,18 @@
 nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
                                        int comp_level,
                                        const methodHandle& hot_method, int hot_count,
-                                       const char* comment, Thread* THREAD) {
-  // do nothing if compilebroker is not available
-  if (!_initialized) {
+                                       CompileTask::CompileReason compile_reason,
+                                       Thread* THREAD) {
+  // Do nothing if compilebroker is not initalized or compiles are submitted on level none
+  if (!_initialized || comp_level == CompLevel_none) {
     return NULL;
   }
+
   AbstractCompiler *comp = CompileBroker::compiler(comp_level);
-  assert(comp != NULL, "Ensure we don't compile before compilebroker init");
+  assert(comp != NULL, "Ensure we have a compiler");
+
   DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp);
-  nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, comment, directive, THREAD);
+  nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, directive, THREAD);
   DirectivesStack::release(directive);
   return nm;
 }
@@ -1052,7 +1057,8 @@
 nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
                                          int comp_level,
                                          const methodHandle& hot_method, int hot_count,
-                                         const char* comment, DirectiveSet* directive,
+                                         CompileTask::CompileReason compile_reason,
+                                         DirectiveSet* directive,
                                          Thread* THREAD) {
 
   // make sure arguments make sense
@@ -1060,6 +1066,7 @@
   assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
   assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods");
   assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized");
+  assert(!TieredCompilation || comp_level <= TieredStopAtLevel, "Invalid compilation level");
   // allow any levels for WhiteBox
   assert(WhiteBoxAPI || TieredCompilation || comp_level == CompLevel_highest_tier, "only CompLevel_highest_tier must be used in non-tiered");
   // return quickly if possible
@@ -1074,10 +1081,10 @@
 
   if (osr_bci == InvocationEntryBci) {
     // standard compilation
-    nmethod* method_code = method->code();
-    if (method_code != NULL) {
+    CompiledMethod* method_code = method->code();
+    if (method_code != NULL && method_code->is_nmethod()) {
       if (compilation_is_complete(method, osr_bci, comp_level)) {
-        return method_code;
+        return (nmethod*) method_code;
       }
     }
     if (method->is_not_compilable(comp_level)) {
@@ -1177,13 +1184,18 @@
       return NULL;
     }
     bool is_blocking = !directive->BackgroundCompilationOption || CompileTheWorld || ReplayCompiles;
-    compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, is_blocking, THREAD);
+    compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, is_blocking, THREAD);
   }
 
   // return requested nmethod
   // We accept a higher level osr method
   if (osr_bci == InvocationEntryBci) {
-    return method->code();
+    CompiledMethod* code = method->code();
+    if (code == NULL) {
+      return (nmethod*) code;
+    } else {
+      return code->as_nmethod_or_null();
+    }
   }
   return method->lookup_osr_nmethod_for(osr_bci, comp_level, false);
 }
@@ -1208,7 +1220,7 @@
     if (method->is_not_compilable(comp_level)) {
       return true;
     } else {
-      nmethod* result = method->code();
+      CompiledMethod* result = method->code();
       if (result == NULL) return false;
       return comp_level == result->comp_level();
     }
@@ -1336,11 +1348,11 @@
                                                 int                 comp_level,
                                                 const methodHandle& hot_method,
                                                 int                 hot_count,
-                                                const char*         comment,
+                                                CompileTask::CompileReason compile_reason,
                                                 bool                blocking) {
   CompileTask* new_task = CompileTask::allocate();
   new_task->initialize(compile_id, method, osr_bci, comp_level,
-                       hot_method, hot_count, comment,
+                       hot_method, hot_count, compile_reason,
                        blocking);
   queue->add(new_task);
   return new_task;
diff --git a/hotspot/src/share/vm/compiler/compileBroker.hpp b/hotspot/src/share/vm/compiler/compileBroker.hpp
index 01a85b5..b399078 100644
--- a/hotspot/src/share/vm/compiler/compileBroker.hpp
+++ b/hotspot/src/share/vm/compiler/compileBroker.hpp
@@ -232,7 +232,7 @@
                                           int                 comp_level,
                                           const methodHandle& hot_method,
                                           int                 hot_count,
-                                          const char*         comment,
+                                          CompileTask::CompileReason compile_reason,
                                           bool                blocking);
   static void wait_for_completion(CompileTask* task);
 #if INCLUDE_JVMCI
@@ -251,7 +251,7 @@
                                   int comp_level,
                                   const methodHandle& hot_method,
                                   int hot_count,
-                                  const char* comment,
+                                  CompileTask::CompileReason compile_reason,
                                   bool blocking,
                                   Thread* thread);
 
@@ -289,14 +289,15 @@
                                  int comp_level,
                                  const methodHandle& hot_method,
                                  int hot_count,
-                                 const char* comment, Thread* thread);
+                                 CompileTask::CompileReason compile_reason,
+                                 Thread* thread);
 
   static nmethod* compile_method(const methodHandle& method,
                                    int osr_bci,
                                    int comp_level,
                                    const methodHandle& hot_method,
                                    int hot_count,
-                                   const char* comment,
+                                   CompileTask::CompileReason compile_reason,
                                    DirectiveSet* directive,
                                    Thread* thread);
 
diff --git a/hotspot/src/share/vm/compiler/compileTask.cpp b/hotspot/src/share/vm/compiler/compileTask.cpp
index 75dbd83..9c3ea04 100644
--- a/hotspot/src/share/vm/compiler/compileTask.cpp
+++ b/hotspot/src/share/vm/compiler/compileTask.cpp
@@ -82,7 +82,7 @@
                              int comp_level,
                              const methodHandle& hot_method,
                              int hot_count,
-                             const char* comment,
+                             CompileTask::CompileReason compile_reason,
                              bool is_blocking) {
   assert(!_lock->is_locked(), "bad locking");
 
@@ -104,7 +104,7 @@
   _hot_method_holder = NULL;
   _hot_count = hot_count;
   _time_queued = 0;  // tidy
-  _comment = comment;
+  _compile_reason = compile_reason;
   _failure_reason = NULL;
 
   if (LogCompilation) {
@@ -135,7 +135,11 @@
 //
 nmethod* CompileTask::code() const {
   if (_code_handle == NULL)  return NULL;
-  return _code_handle->code();
+  CodeBlob *blob = _code_handle->code();
+  if (blob != NULL) {
+    return blob->as_nmethod();
+  }
+  return NULL;
 }
 
 void CompileTask::set_code(nmethod* nm) {
@@ -305,9 +309,9 @@
 
   xtty->begin_elem("task_queued");
   log_task(xtty);
-  if (_comment != NULL) {
-    xtty->print(" comment='%s'", _comment);
-  }
+  assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values");
+  xtty->print(" comment='%s'", reason_name(_compile_reason));
+
   if (_hot_method != NULL) {
     methodHandle hot(thread, _hot_method);
     methodHandle method(thread, _method);
@@ -436,3 +440,5 @@
   }
   st->cr();
 }
+
+
diff --git a/hotspot/src/share/vm/compiler/compileTask.hpp b/hotspot/src/share/vm/compiler/compileTask.hpp
index 1725b83..79a75b5 100644
--- a/hotspot/src/share/vm/compiler/compileTask.hpp
+++ b/hotspot/src/share/vm/compiler/compileTask.hpp
@@ -40,6 +40,39 @@
   friend class VMStructs;
   friend class JVMCIVMStructs;
 
+ public:
+  // Different reasons for a compilation
+  // The order is important - Reason_Whitebox and higher can not become
+  // stale, see CompileTask::can_become_stale()
+  // Also mapped to reason_names[]
+  enum CompileReason {
+      Reason_None,
+      Reason_InvocationCount,  // Simple/StackWalk-policy
+      Reason_BackedgeCount,    // Simple/StackWalk-policy
+      Reason_Tiered,           // Tiered-policy
+      Reason_CTW,              // Compile the world
+      Reason_Replay,           // ciReplay
+      Reason_Whitebox,         // Whitebox API
+      Reason_MustBeCompiled,   // Java callHelper, LinkResolver
+      Reason_Bootstrap,        // JVMCI bootstrap
+      Reason_Count
+  };
+
+  static const char* reason_name(CompileTask::CompileReason compile_reason) {
+    static const char* reason_names[] = {
+      "no_reason",
+      "count",
+      "backedge_count",
+      "tiered",
+      "CTW",
+      "replay",
+      "whitebox",
+      "must_be_compiled",
+      "bootstrap"
+    };
+    return reason_names[compile_reason];
+  }
+
  private:
   static CompileTask* _task_free_list;
 #ifdef ASSERT
@@ -69,7 +102,7 @@
   Method*      _hot_method;   // which method actually triggered this task
   jobject      _hot_method_holder;
   int          _hot_count;    // information about its invocation counter
-  const char*  _comment;      // more info about the task
+  CompileReason _compile_reason;      // more info about the task
   const char*  _failure_reason;
 
  public:
@@ -78,8 +111,8 @@
   }
 
   void initialize(int compile_id, const methodHandle& method, int osr_bci, int comp_level,
-                  const methodHandle& hot_method, int hot_count, const char* comment,
-                  bool is_blocking);
+                  const methodHandle& hot_method, int hot_count,
+                  CompileTask::CompileReason compile_reason, bool is_blocking);
 
   static CompileTask* allocate();
   static void         free(CompileTask* task);
@@ -91,6 +124,15 @@
   bool         is_complete() const               { return _is_complete; }
   bool         is_blocking() const               { return _is_blocking; }
   bool         is_success() const                { return _is_success; }
+  bool         can_become_stale() const          {
+    switch (_compile_reason) {
+      case Reason_BackedgeCount:
+      case Reason_InvocationCount:
+      case Reason_Tiered:
+        return !_is_blocking;
+    }
+    return false;
+  }
 #if INCLUDE_JVMCI
   bool         has_waiter() const                { return _has_waiter; }
   void         clear_waiter()                    { _has_waiter = false; }
diff --git a/hotspot/src/share/vm/compiler/directivesParser.cpp b/hotspot/src/share/vm/compiler/directivesParser.cpp
index 60a935b..036357f 100644
--- a/hotspot/src/share/vm/compiler/directivesParser.cpp
+++ b/hotspot/src/share/vm/compiler/directivesParser.cpp
@@ -57,7 +57,7 @@
 }
 
 int DirectivesParser::parse_string(const char* text, outputStream* st) {
-  DirectivesParser cd(text, st);
+  DirectivesParser cd(text, st, false);
   if (cd.valid()) {
     return cd.install_directives();
   } else {
@@ -132,8 +132,8 @@
   }
 }
 
-DirectivesParser::DirectivesParser(const char* text, outputStream* st)
-: JSON(text, false, st), depth(0), current_directive(NULL), current_directiveset(NULL), _tmp_top(NULL), _tmp_depth(0) {
+DirectivesParser::DirectivesParser(const char* text, outputStream* st, bool silent)
+: JSON(text, silent, st), depth(0), current_directive(NULL), current_directiveset(NULL), _tmp_top(NULL), _tmp_depth(0) {
 #ifndef PRODUCT
   memset(stack, 0, MAX_DEPTH * sizeof(stack[0]));
 #endif
@@ -594,7 +594,7 @@
 
 #ifndef PRODUCT
 void DirectivesParser::test(const char* text, bool should_pass) {
-  DirectivesParser cd(text, tty);
+  DirectivesParser cd(text, tty, !VerboseInternalVMTests);
   if (should_pass) {
     assert(cd.valid() == true, "failed on a valid DirectivesParser string");
     if (VerboseInternalVMTests) {
diff --git a/hotspot/src/share/vm/compiler/directivesParser.hpp b/hotspot/src/share/vm/compiler/directivesParser.hpp
index e7c404b..ef0b48b 100644
--- a/hotspot/src/share/vm/compiler/directivesParser.hpp
+++ b/hotspot/src/share/vm/compiler/directivesParser.hpp
@@ -55,7 +55,7 @@
   int install_directives();
 
 private:
-  DirectivesParser(const char* text, outputStream* st);
+  DirectivesParser(const char* text, outputStream* st, bool silent);
   ~DirectivesParser();
 
   bool callback(JSON_TYPE t, JSON_VAL* v, uint level);
diff --git a/hotspot/src/share/vm/compiler/methodLiveness.cpp b/hotspot/src/share/vm/compiler/methodLiveness.cpp
index 177c72f..e68d124 100644
--- a/hotspot/src/share/vm/compiler/methodLiveness.cpp
+++ b/hotspot/src/share/vm/compiler/methodLiveness.cpp
@@ -131,13 +131,13 @@
 
 MethodLiveness::MethodLiveness(Arena* arena, ciMethod* method)
 #ifdef COMPILER1
-  : _bci_block_start((uintptr_t*)arena->Amalloc((method->code_size() >> LogBitsPerByte) + 1), method->code_size())
+  : _bci_block_start(arena, method->code_size())
 #endif
 {
   _arena = arena;
   _method = method;
   _bit_map_size_bits = method->max_locals();
-  _bit_map_size_words = (_bit_map_size_bits / sizeof(unsigned int)) + 1;
+
 
 #ifdef COMPILER1
   _bci_block_start.clear();
@@ -475,7 +475,7 @@
     bci = 0;
   }
 
-  MethodLivenessResult answer((BitMap::bm_word_t*)NULL,0);
+  MethodLivenessResult answer;
 
   if (_block_count > 0) {
     if (TimeLivenessAnalysis) _time_total.start();
@@ -574,16 +574,11 @@
 
 
 MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int limit) :
-         _gen((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
-                         analyzer->bit_map_size_bits()),
-         _kill((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
-                         analyzer->bit_map_size_bits()),
-         _entry((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
-                         analyzer->bit_map_size_bits()),
-         _normal_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
-                         analyzer->bit_map_size_bits()),
-         _exception_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
-                         analyzer->bit_map_size_bits()),
+         _gen(analyzer->arena(),            analyzer->bit_map_size_bits()),
+         _kill(analyzer->arena(),           analyzer->bit_map_size_bits()),
+         _entry(analyzer->arena(),          analyzer->bit_map_size_bits()),
+         _normal_exit(analyzer->arena(),    analyzer->bit_map_size_bits()),
+         _exception_exit(analyzer->arena(), analyzer->bit_map_size_bits()),
          _last_bci(-1) {
   _analyzer = analyzer;
   _start_bci = start;
@@ -991,17 +986,16 @@
   }
 }
 
-bool MethodLiveness::BasicBlock::merge_normal(BitMap other) {
+bool MethodLiveness::BasicBlock::merge_normal(const BitMap& other) {
   return _normal_exit.set_union_with_result(other);
 }
 
-bool MethodLiveness::BasicBlock::merge_exception(BitMap other) {
+bool MethodLiveness::BasicBlock::merge_exception(const BitMap& other) {
   return _exception_exit.set_union_with_result(other);
 }
 
 MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* method, int bci) {
-  MethodLivenessResult answer(NEW_RESOURCE_ARRAY(BitMap::bm_word_t, _analyzer->bit_map_size_words()),
-                _analyzer->bit_map_size_bits());
+  MethodLivenessResult answer(_analyzer->bit_map_size_bits());
   answer.set_is_valid();
 
 #ifndef ASSERT
@@ -1013,8 +1007,8 @@
 
 #ifdef ASSERT
   ResourceMark rm;
-  BitMap g(_gen.size()); g.set_from(_gen);
-  BitMap k(_kill.size()); k.set_from(_kill);
+  ResourceBitMap g(_gen.size()); g.set_from(_gen);
+  ResourceBitMap k(_kill.size()); k.set_from(_kill);
 #endif
   if (_last_bci != bci || trueInDebug) {
     ciBytecodeStream bytes(method);
diff --git a/hotspot/src/share/vm/compiler/methodLiveness.hpp b/hotspot/src/share/vm/compiler/methodLiveness.hpp
index 0a63d2a..60ad42a 100644
--- a/hotspot/src/share/vm/compiler/methodLiveness.hpp
+++ b/hotspot/src/share/vm/compiler/methodLiveness.hpp
@@ -30,18 +30,18 @@
 
 class ciMethod;
 
-class MethodLivenessResult : public BitMap {
+class MethodLivenessResult : public ResourceBitMap {
  private:
   bool _is_valid;
 
  public:
-  MethodLivenessResult(BitMap::bm_word_t* map, idx_t size_in_bits)
-    : BitMap(map, size_in_bits)
+  MethodLivenessResult()
+    : ResourceBitMap()
     , _is_valid(false)
   {}
 
   MethodLivenessResult(idx_t size_in_bits)
-    : BitMap(size_in_bits)
+    : ResourceBitMap(size_in_bits)
     , _is_valid(false)
   {}
 
@@ -66,23 +66,23 @@
     int _limit_bci;
 
     // The liveness at the start of the block;
-    BitMap _entry;
+    ArenaBitMap _entry;
 
     // The summarized liveness effects of our direct successors reached
     // by normal control flow
-    BitMap _normal_exit;
+    ArenaBitMap _normal_exit;
 
     // The summarized liveness effects of our direct successors reached
     // by exceptional control flow
-    BitMap _exception_exit;
+    ArenaBitMap _exception_exit;
 
     // These members hold the results of the last call to
     // compute_gen_kill_range().  _gen is the set of locals
     // used before they are defined in the range.  _kill is the
     // set of locals defined before they are used.
-    BitMap _gen;
-    BitMap _kill;
-    int    _last_bci;
+    ArenaBitMap _gen;
+    ArenaBitMap _kill;
+    int         _last_bci;
 
     // A list of all blocks which could come directly before this one
     // in normal (non-exceptional) control flow.  We propagate liveness
@@ -100,11 +100,11 @@
 
     // Our successors call this method to merge liveness information into
     // our _normal_exit member.
-    bool merge_normal(BitMap other);
+    bool merge_normal(const BitMap& other);
 
     // Our successors call this method to merge liveness information into
     // our _exception_exit member.
-    bool merge_exception(BitMap other);
+    bool merge_exception(const BitMap& other);
 
     // This helper routine is used to help compute the gen/kill pair for
     // the block.  It is also used to answer queries.
@@ -181,7 +181,6 @@
 
   // The size of a BitMap.
   int _bit_map_size_bits;
-  int _bit_map_size_words;
 
   // A list of all BasicBlocks.
   BasicBlock **_block_list;
@@ -198,7 +197,7 @@
 
 #ifdef COMPILER1
   // bcis where blocks start are marked
-  BitMap _bci_block_start;
+  ArenaBitMap _bci_block_start;
 #endif // COMPILER1
 
   // -- Graph construction & Analysis
@@ -218,7 +217,6 @@
 
   // And accessors.
   int bit_map_size_bits() const { return _bit_map_size_bits; }
-  int bit_map_size_words() const { return _bit_map_size_words; }
 
   // Work list manipulation routines.  Called internally by BasicBlock.
   BasicBlock *work_list_get();
@@ -270,7 +268,7 @@
   MethodLivenessResult get_liveness_at(int bci);
 
 #ifdef COMPILER1
-  const BitMap get_bci_block_start() const { return _bci_block_start; }
+  const BitMap& get_bci_block_start() const { return _bci_block_start; }
 #endif // COMPILER1
 
   static void print_times() PRODUCT_RETURN;
diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
index 9e67c9b..af5e47d 100644
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
@@ -1019,7 +1019,7 @@
       return NULL;
     }
   }
-  assert(promoInfo->has_spooling_space(), "Control point invariant");
+  assert(!promoInfo->tracking() || promoInfo->has_spooling_space(), "Control point invariant");
   const size_t alloc_sz = CompactibleFreeListSpace::adjustObjectSize(word_sz);
   HeapWord* obj_ptr = ps->lab.alloc(alloc_sz);
   if (obj_ptr == NULL) {
@@ -1094,6 +1094,12 @@
   CMSParGCThreadState* ps = _par_gc_thread_states[thread_num];
   ParScanWithoutBarrierClosure* dummy_cl = NULL;
   ps->promo.promoted_oops_iterate_nv(dummy_cl);
+
+  // Because card-scanning has been completed, subsequent phases
+  // (e.g., reference processing) will not need to recognize which
+  // objects have been promoted during this GC. So, we can now disable
+  // promotion tracking.
+  ps->promo.stopTrackingPromotions();
 }
 
 bool ConcurrentMarkSweepGeneration::should_collect(bool   full,
@@ -2032,6 +2038,12 @@
   _capacity_at_prologue = capacity();
   _used_at_prologue = used();
 
+  // We enable promotion tracking so that card-scanning can recognize
+  // which objects have been promoted during this GC and skip them.
+  for (uint i = 0; i < ParallelGCThreads; i++) {
+    _par_gc_thread_states[i]->promo.startTrackingPromotions();
+  }
+
   // Delegate to CMScollector which knows how to coordinate between
   // this and any other CMS generations that it is responsible for
   // collecting.
@@ -2118,9 +2130,15 @@
 void ConcurrentMarkSweepGeneration::gc_epilogue(bool full) {
   collector()->gc_epilogue(full);
 
-  // Also reset promotion tracking in par gc thread states.
+  // When using ParNew, promotion tracking should have already been
+  // disabled. However, the prologue (which enables promotion
+  // tracking) and epilogue are called irrespective of the type of
+  // GC. So they will also be called before and after Full GCs, during
+  // which promotion tracking will not be explicitly disabled. So,
+  // it's safer to also disable it here too (to be symmetric with
+  // enabling it in the prologue).
   for (uint i = 0; i < ParallelGCThreads; i++) {
-    _par_gc_thread_states[i]->promo.stopTrackingPromotions(i);
+    _par_gc_thread_states[i]->promo.stopTrackingPromotions();
   }
 }
 
@@ -2431,9 +2449,6 @@
 void ConcurrentMarkSweepGeneration::save_marks() {
   // delegate to CMS space
   cmsSpace()->save_marks();
-  for (uint i = 0; i < ParallelGCThreads; i++) {
-    _par_gc_thread_states[i]->promo.startTrackingPromotions();
-  }
 }
 
 bool ConcurrentMarkSweepGeneration::no_allocs_since_save_marks() {
@@ -2769,10 +2784,10 @@
       _collector(collector),
       _n_workers(n_workers) {}
   // Work method in support of parallel rescan ... of young gen spaces
-  void do_young_space_rescan(uint worker_id, OopsInGenClosure* cl,
+  void do_young_space_rescan(OopsInGenClosure* cl,
                              ContiguousSpace* space,
                              HeapWord** chunk_array, size_t chunk_top);
-  void work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl);
+  void work_on_young_gen_roots(OopsInGenClosure* cl);
 };
 
 // Parallel initial mark task
@@ -4255,7 +4270,7 @@
 
   // ---------- young gen roots --------------
   {
-    work_on_young_gen_roots(worker_id, &par_mri_cl);
+    work_on_young_gen_roots(&par_mri_cl);
     _timer.stop();
     log_trace(gc, task)("Finished young gen initial mark scan work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
   }
@@ -4346,7 +4361,7 @@
   }
 };
 
-void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) {
+void CMSParMarkTask::work_on_young_gen_roots(OopsInGenClosure* cl) {
   ParNewGeneration* young_gen = _collector->_young_gen;
   ContiguousSpace* eden_space = young_gen->eden();
   ContiguousSpace* from_space = young_gen->from();
@@ -4360,9 +4375,9 @@
   assert(ect <= _collector->_eden_chunk_capacity, "out of bounds");
   assert(sct <= _collector->_survivor_chunk_capacity, "out of bounds");
 
-  do_young_space_rescan(worker_id, cl, to_space, NULL, 0);
-  do_young_space_rescan(worker_id, cl, from_space, sca, sct);
-  do_young_space_rescan(worker_id, cl, eden_space, eca, ect);
+  do_young_space_rescan(cl, to_space, NULL, 0);
+  do_young_space_rescan(cl, from_space, sca, sct);
+  do_young_space_rescan(cl, eden_space, eca, ect);
 }
 
 // work_queue(i) is passed to the closure
@@ -4389,7 +4404,7 @@
   // work first.
   // ---------- young gen roots --------------
   {
-    work_on_young_gen_roots(worker_id, &par_mrias_cl);
+    work_on_young_gen_roots(&par_mrias_cl);
     _timer.stop();
     log_trace(gc, task)("Finished young gen rescan work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
   }
@@ -4471,9 +4486,8 @@
   log_trace(gc, task)("Finished work stealing in %dth thread: %3.3f sec", worker_id, _timer.seconds());
 }
 
-// Note that parameter "i" is not used.
 void
-CMSParMarkTask::do_young_space_rescan(uint worker_id,
+CMSParMarkTask::do_young_space_rescan(
   OopsInGenClosure* cl, ContiguousSpace* space,
   HeapWord** chunk_array, size_t chunk_top) {
   // Until all tasks completed:
@@ -5667,10 +5681,9 @@
   }
   assert(_virtual_space.committed_size() == brs.size(),
          "didn't reserve backing store for all of CMS bit map?");
-  _bm.set_map((BitMap::bm_word_t*)_virtual_space.low());
   assert(_virtual_space.committed_size() << (_shifter + LogBitsPerByte) >=
          _bmWordSize, "inconsistency in bit map sizing");
-  _bm.set_size(_bmWordSize >> _shifter);
+  _bm = BitMapView((BitMap::bm_word_t*)_virtual_space.low(), _bmWordSize >> _shifter);
 
   // bm.clear(); // can we rely on getting zero'd memory? verify below
   assert(isAllClear(),
diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp
index 29636c6..cedd3e4 100644
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp
@@ -83,13 +83,12 @@
 class CMSBitMap VALUE_OBJ_CLASS_SPEC {
   friend class VMStructs;
 
-  HeapWord* _bmStartWord;   // base address of range covered by map
-  size_t    _bmWordSize;    // map size (in #HeapWords covered)
-  const int _shifter;       // shifts to convert HeapWord to bit position
+  HeapWord*    _bmStartWord;   // base address of range covered by map
+  size_t       _bmWordSize;    // map size (in #HeapWords covered)
+  const int    _shifter;       // shifts to convert HeapWord to bit position
   VirtualSpace _virtual_space; // underlying the bit map
-  BitMap    _bm;            // the bit map itself
- public:
-  Mutex* const _lock;       // mutex protecting _bm;
+  BitMapView   _bm;            // the bit map itself
+  Mutex* const _lock;          // mutex protecting _bm;
 
  public:
   // constructor
diff --git a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp
index ff88d15..adf5156 100644
--- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp
+++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp
@@ -287,7 +287,7 @@
   }
 }
 
-class ParScanThreadStateSet: private ResourceArray {
+class ParScanThreadStateSet: StackObj {
 public:
   // Initializes states for the specified number of threads;
   ParScanThreadStateSet(int                     num_threads,
@@ -322,8 +322,10 @@
   ParallelTaskTerminator& _term;
   ParNewGeneration&       _young_gen;
   Generation&             _old_gen;
+  ParScanThreadState*     _per_thread_states;
+  const int               _num_threads;
  public:
-  bool is_valid(int id) const { return id < length(); }
+  bool is_valid(int id) const { return id < _num_threads; }
   ParallelTaskTerminator* terminator() { return &_term; }
 };
 
@@ -336,30 +338,31 @@
                                              PreservedMarksSet& preserved_marks_set,
                                              size_t desired_plab_sz,
                                              ParallelTaskTerminator& term)
-  : ResourceArray(sizeof(ParScanThreadState), num_threads),
-    _young_gen(young_gen),
+  : _young_gen(young_gen),
     _old_gen(old_gen),
-    _term(term)
+    _term(term),
+    _per_thread_states(NEW_RESOURCE_ARRAY(ParScanThreadState, num_threads)),
+    _num_threads(num_threads)
 {
   assert(num_threads > 0, "sanity check!");
   assert(ParGCUseLocalOverflow == (overflow_stacks != NULL),
          "overflow_stack allocation mismatch");
   // Initialize states.
   for (int i = 0; i < num_threads; ++i) {
-    new ((ParScanThreadState*)_data + i)
-        ParScanThreadState(&to_space, &young_gen, &old_gen, i, &queue_set,
-                           overflow_stacks, preserved_marks_set.get(i),
-                           desired_plab_sz, term);
+    new(_per_thread_states + i)
+      ParScanThreadState(&to_space, &young_gen, &old_gen, i, &queue_set,
+                         overflow_stacks, preserved_marks_set.get(i),
+                         desired_plab_sz, term);
   }
 }
 
 inline ParScanThreadState& ParScanThreadStateSet::thread_state(int i) {
-  assert(i >= 0 && i < length(), "sanity check!");
-  return ((ParScanThreadState*)_data)[i];
+  assert(i >= 0 && i < _num_threads, "sanity check!");
+  return _per_thread_states[i];
 }
 
 void ParScanThreadStateSet::trace_promotion_failed(const YoungGCTracer* gc_tracer) {
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     if (thread_state(i).promotion_failed()) {
       gc_tracer->report_promotion_failed(thread_state(i).promotion_failed_info());
       thread_state(i).promotion_failed_info().reset();
@@ -370,7 +373,7 @@
 void ParScanThreadStateSet::reset(uint active_threads, bool promotion_failed) {
   _term.reset_for_reuse(active_threads);
   if (promotion_failed) {
-    for (int i = 0; i < length(); ++i) {
+    for (int i = 0; i < _num_threads; ++i) {
       thread_state(i).print_promotion_failure_size();
     }
   }
@@ -385,7 +388,7 @@
 }
 
 void ParScanThreadStateSet::reset_stats() {
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     thread_state(i).reset_stats();
   }
 }
@@ -408,7 +411,7 @@
 
   print_termination_stats_hdr(st);
 
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     const ParScanThreadState & pss = thread_state(i);
     const double elapsed_ms = pss.elapsed_time() * 1000.0;
     const double s_roots_ms = pss.strong_roots_time() * 1000.0;
@@ -436,7 +439,7 @@
   print_taskqueue_stats_hdr(st);
 
   TaskQueueStats totals;
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     const ParScanThreadState & pss = thread_state(i);
     const TaskQueueStats & stats = pss.taskqueue_stats();
     st->print("%3d ", i); stats.print(st); st->cr();
@@ -459,7 +462,7 @@
   // possible since this might otherwise become a bottleneck
   // to scaling. Should we add heavy-weight work into this
   // loop, consider parallelizing the loop into the worker threads.
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     ParScanThreadState& par_scan_state = thread_state(i);
 
     // Flush stats related to To-space PLAB activity and
@@ -473,7 +476,6 @@
 
     // Inform old gen that we're done.
     _old_gen.par_promote_alloc_done(i);
-    _old_gen.par_oop_since_save_marks_iterate_done(i);
   }
 
   if (UseConcMarkSweepGC) {
@@ -616,6 +618,16 @@
 
   // "evacuate followers".
   par_scan_state.evacuate_followers_closure().do_void();
+
+  // This will collapse this worker's promoted object list that's
+  // created during the main ParNew parallel phase of ParNew. This has
+  // to be called after all workers have finished promoting objects
+  // and scanning promoted objects. It should be safe calling it from
+  // here, given that we can only reach here after all thread have
+  // offered termination, i.e., after there is no more work to be
+  // done. It will also disable promotion tracking for the rest of
+  // this GC as it's not necessary to be on during reference processing.
+  _old_gen->par_oop_since_save_marks_iterate_done((int) worker_id);
 }
 
 ParNewGeneration::ParNewGeneration(ReservedSpace rs, size_t initial_byte_size)
diff --git a/hotspot/src/share/vm/gc/cms/promotionInfo.cpp b/hotspot/src/share/vm/gc/cms/promotionInfo.cpp
index 92c5725..40b4b39 100644
--- a/hotspot/src/share/vm/gc/cms/promotionInfo.cpp
+++ b/hotspot/src/share/vm/gc/cms/promotionInfo.cpp
@@ -252,13 +252,15 @@
 }
 
 void PromotionInfo::startTrackingPromotions() {
+  assert(noPromotions(), "sanity");
   assert(_spoolHead == _spoolTail && _firstIndex == _nextIndex,
          "spooling inconsistency?");
   _firstIndex = _nextIndex = 1;
   _tracking = true;
 }
 
-void PromotionInfo::stopTrackingPromotions(uint worker_id) {
+void PromotionInfo::stopTrackingPromotions() {
+  assert(noPromotions(), "we should have torn down the lists by now");
   assert(_spoolHead == _spoolTail && _firstIndex == _nextIndex,
          "spooling inconsistency?");
   _firstIndex = _nextIndex = 1;
diff --git a/hotspot/src/share/vm/gc/cms/promotionInfo.hpp b/hotspot/src/share/vm/gc/cms/promotionInfo.hpp
index 387da17..90ca062 100644
--- a/hotspot/src/share/vm/gc/cms/promotionInfo.hpp
+++ b/hotspot/src/share/vm/gc/cms/promotionInfo.hpp
@@ -144,7 +144,7 @@
     return _promoHead == NULL;
   }
   void startTrackingPromotions();
-  void stopTrackingPromotions(uint worker_id = 0);
+  void stopTrackingPromotions();
   bool tracking() const          { return _tracking;  }
   void track(PromotedObject* trackOop);      // keep track of a promoted oop
   // The following variant must be used when trackOop is not fully
diff --git a/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp b/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp
index e312d6b..5c9351b 100644
--- a/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp
+++ b/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp
@@ -33,7 +33,7 @@
                                                                                                                                      \
   nonstatic_field(CMSBitMap,                   _bmWordSize,                                   size_t)                                \
   nonstatic_field(CMSBitMap,                   _shifter,                                      const int)                             \
-  nonstatic_field(CMSBitMap,                      _bm,                                           BitMap)                             \
+  nonstatic_field(CMSBitMap,                   _bm,                                           BitMapView)                            \
   nonstatic_field(CMSBitMap,                   _virtual_space,                                VirtualSpace)                          \
   nonstatic_field(CMSCollector,                _markBitMap,                                   CMSBitMap)                             \
   nonstatic_field(ConcurrentMarkSweepGeneration, _cmsSpace,                                   CompactibleFreeListSpace*)             \
diff --git a/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp b/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp
index caa4595..cc9dbf4 100644
--- a/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp
+++ b/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp
@@ -25,7 +25,6 @@
 #include "precompiled.hpp"
 #include "gc/g1/collectionSetChooser.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/shared/space.inline.hpp"
 #include "runtime/atomic.inline.hpp"
 
diff --git a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp
index e67c893..06b3f1c 100644
--- a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp
+++ b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp
@@ -25,10 +25,10 @@
 #include "precompiled.hpp"
 #include "gc/g1/concurrentG1Refine.hpp"
 #include "gc/g1/concurrentG1RefineThread.hpp"
-#include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
-#include "gc/g1/g1Predictions.hpp"
+#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
+#include "logging/log.hpp"
 #include "runtime/java.hpp"
+#include "runtime/thread.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/pair.hpp"
@@ -112,8 +112,7 @@
                     green_zone + deactivate_offset);
 }
 
-ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h,
-                                       size_t green_zone,
+ConcurrentG1Refine::ConcurrentG1Refine(size_t green_zone,
                                        size_t yellow_zone,
                                        size_t red_zone,
                                        size_t min_yellow_zone_size) :
@@ -123,8 +122,7 @@
   _green_zone(green_zone),
   _yellow_zone(yellow_zone),
   _red_zone(red_zone),
-  _min_yellow_zone_size(min_yellow_zone_size),
-  _hot_card_cache(g1h)
+  _min_yellow_zone_size(min_yellow_zone_size)
 {
   assert_zone_constraints_gyr(green_zone, yellow_zone, red_zone);
 }
@@ -171,8 +169,7 @@
   return MIN2(yellow + size, max_red_zone);
 }
 
-ConcurrentG1Refine* ConcurrentG1Refine::create(G1CollectedHeap* g1h,
-                                               CardTableEntryClosure* refine_closure,
+ConcurrentG1Refine* ConcurrentG1Refine::create(CardTableEntryClosure* refine_closure,
                                                jint* ecode) {
   size_t min_yellow_zone_size = calc_min_yellow_zone_size();
   size_t green_zone = calc_init_green_zone();
@@ -186,8 +183,7 @@
             "min yellow size: " SIZE_FORMAT,
             green_zone, yellow_zone, red_zone, min_yellow_zone_size);
 
-  ConcurrentG1Refine* cg1r = new ConcurrentG1Refine(g1h,
-                                                    green_zone,
+  ConcurrentG1Refine* cg1r = new ConcurrentG1Refine(green_zone,
                                                     yellow_zone,
                                                     red_zone,
                                                     min_yellow_zone_size);
@@ -241,10 +237,6 @@
   return cg1r;
 }
 
-void ConcurrentG1Refine::init(G1RegionToSpaceMapper* card_counts_storage) {
-  _hot_card_cache.initialize(card_counts_storage);
-}
-
 void ConcurrentG1Refine::stop() {
   for (uint i = 0; i < _n_worker_threads; i++) {
     _threads[i]->stop();
diff --git a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp
index 098d49e..9c3461e 100644
--- a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp
+++ b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp
@@ -25,20 +25,15 @@
 #ifndef SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP
 #define SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP
 
-#include "gc/g1/g1HotCardCache.hpp"
-#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
 #include "memory/allocation.hpp"
-#include "runtime/thread.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 // Forward decl
+class CardTableEntryClosure;
 class ConcurrentG1RefineThread;
-class G1CollectedHeap;
-class G1HotCardCache;
-class G1Predictions;
-class G1RegionToSpaceMapper;
-class G1RemSet;
-class DirtyCardQueue;
+class G1YoungRemSetSamplingThread;
+class outputStream;
+class ThreadClosure;
 
 class ConcurrentG1Refine: public CHeapObj<mtGC> {
   G1YoungRemSetSamplingThread* _sample_thread;
@@ -67,11 +62,7 @@
   size_t _red_zone;
   size_t _min_yellow_zone_size;
 
-  // We delay the refinement of 'hot' cards using the hot card cache.
-  G1HotCardCache _hot_card_cache;
-
-  ConcurrentG1Refine(G1CollectedHeap* g1h,
-                     size_t green_zone,
+  ConcurrentG1Refine(size_t green_zone,
                      size_t yellow_zone,
                      size_t red_zone,
                      size_t min_yellow_zone_size);
@@ -89,9 +80,8 @@
 
   // Returns ConcurrentG1Refine instance if succeeded to create/initialize ConcurrentG1Refine and ConcurrentG1RefineThread.
   // Otherwise, returns NULL with error code.
-  static ConcurrentG1Refine* create(G1CollectedHeap* g1h, CardTableEntryClosure* refine_closure, jint* ecode);
+  static ConcurrentG1Refine* create(CardTableEntryClosure* refine_closure, jint* ecode);
 
-  void init(G1RegionToSpaceMapper* card_counts_storage);
   void stop();
 
   void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms);
@@ -112,10 +102,6 @@
   size_t green_zone() const      { return _green_zone;  }
   size_t yellow_zone() const     { return _yellow_zone; }
   size_t red_zone() const        { return _red_zone;    }
-
-  G1HotCardCache* hot_card_cache() { return &_hot_card_cache; }
-
-  static bool hot_card_cache_enabled() { return G1HotCardCache::default_use_cache(); }
 };
 
 #endif // SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP
diff --git a/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp b/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp
index 8f9ebfb..24826d5 100644
--- a/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp
+++ b/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp
@@ -26,7 +26,6 @@
 #include "gc/g1/concurrentG1Refine.hpp"
 #include "gc/g1/concurrentG1RefineThread.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/suspendibleThreadSet.hpp"
 #include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
diff --git a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp
index 9727b02..4694122 100644
--- a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp
+++ b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp
@@ -27,9 +27,9 @@
 #include "gc/g1/concurrentMarkThread.inline.hpp"
 #include "gc/g1/g1Analytics.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1ConcurrentMark.inline.hpp"
 #include "gc/g1/g1MMUTracker.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/suspendibleThreadSet.hpp"
 #include "gc/g1/vm_operations_g1.hpp"
 #include "gc/shared/gcId.hpp"
@@ -80,7 +80,7 @@
 };
 
 // Marking pauses can be scheduled flexibly, so we might delay marking to meet MMU.
-void ConcurrentMarkThread::delay_to_keep_mmu(G1CollectorPolicy* g1_policy, bool remark) {
+void ConcurrentMarkThread::delay_to_keep_mmu(G1Policy* g1_policy, bool remark) {
   const G1Analytics* analytics = g1_policy->analytics();
   if (g1_policy->adaptive_young_list_length()) {
     double now = os::elapsedTime();
@@ -111,7 +111,7 @@
   _vtime_start = os::elapsedVTime();
 
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  G1CollectorPolicy* g1_policy = g1h->g1_policy();
+  G1Policy* g1_policy = g1h->g1_policy();
 
   while (!should_terminate()) {
     // wait until started is set.
diff --git a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp
index 2bdd7f3..be24fe8 100644
--- a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp
+++ b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp
@@ -31,7 +31,7 @@
 // as well as handling various marking cleanup.
 
 class G1ConcurrentMark;
-class G1CollectorPolicy;
+class G1Policy;
 
 class ConcurrentMarkThread: public ConcurrentGCThread {
   friend class VMStructs;
@@ -51,7 +51,7 @@
   volatile State _state;
 
   void sleepBeforeNextCycle();
-  void delay_to_keep_mmu(G1CollectorPolicy* g1_policy, bool remark);
+  void delay_to_keep_mmu(G1Policy* g1_policy, bool remark);
 
   void run_service();
   void stop_service();
diff --git a/hotspot/src/share/vm/gc/g1/g1Allocator.cpp b/hotspot/src/share/vm/gc/g1/g1Allocator.cpp
index ad5aa0c..92c0093 100644
--- a/hotspot/src/share/vm/gc/g1/g1Allocator.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1Allocator.cpp
@@ -27,7 +27,6 @@
 #include "gc/g1/g1AllocRegion.inline.hpp"
 #include "gc/g1/g1EvacStats.inline.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1MarkSweep.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionSet.inline.hpp"
diff --git a/hotspot/src/share/vm/gc/g1/g1Analytics.cpp b/hotspot/src/share/vm/gc/g1/g1Analytics.cpp
index 16d4af9..c43b416 100644
--- a/hotspot/src/share/vm/gc/g1/g1Analytics.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1Analytics.cpp
@@ -284,6 +284,10 @@
   }
 }
 
+double G1Analytics::predict_cost_per_byte_ms() const {
+  return get_new_prediction(_cost_per_byte_ms_seq);
+}
+
 double G1Analytics::predict_constant_other_time_ms() const {
   return get_new_prediction(_constant_other_time_ms_seq);
 }
@@ -326,4 +330,3 @@
 void G1Analytics::report_concurrent_mark_cleanup_times_ms(double ms) {
   _concurrent_mark_cleanup_times_ms->add(ms);
 }
-
diff --git a/hotspot/src/share/vm/gc/g1/g1Analytics.hpp b/hotspot/src/share/vm/gc/g1/g1Analytics.hpp
index 603a751..a22d0dd 100644
--- a/hotspot/src/share/vm/gc/g1/g1Analytics.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1Analytics.hpp
@@ -149,6 +149,8 @@
   size_t predict_rs_lengths() const;
   size_t predict_pending_cards() const;
 
+  double predict_cost_per_byte_ms() const;
+
   // Add a new GC of the given duration and end time to the record.
   void update_recent_gc_times(double end_time_sec, double elapsed_ms);
   void compute_pause_time_ratio(double interval_ms, double pause_time_ms);
diff --git a/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp b/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp
index af078c2..efa35bc 100644
--- a/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp
@@ -25,8 +25,6 @@
 #include "precompiled.hpp"
 #include "gc/g1/g1CardCounts.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
-#include "gc/g1/g1GCPhaseTimes.hpp"
 #include "gc/shared/cardTableModRefBS.hpp"
 #include "services/memTracker.hpp"
 #include "utilities/copy.hpp"
diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp
index 0a2ed25..100b894 100644
--- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp
@@ -28,6 +28,7 @@
 #include "gc/g1/g1CardLiveData.inline.hpp"
 #include "gc/g1/suspendibleThreadSet.hpp"
 #include "gc/shared/workgroup.hpp"
+#include "logging/log.hpp"
 #include "memory/universe.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/globals.hpp"
@@ -38,6 +39,7 @@
 G1CardLiveData::G1CardLiveData() :
   _max_capacity(0),
   _cards_per_region(0),
+  _gc_timestamp_at_create(0),
   _live_regions(NULL),
   _live_regions_size_in_bits(0),
   _live_cards(NULL),
@@ -58,7 +60,7 @@
 }
 
 void G1CardLiveData::free_large_bitmap(bm_word_t* bitmap, size_t size_in_bits) {
-  MmapArrayAllocator<bm_word_t, mtGC>::free(bitmap, size_in_bits / BitsPerWord);
+  MmapArrayAllocator<bm_word_t, mtGC>::free(bitmap, BitMap::calc_size_in_words(size_in_bits));
 }
 
 void G1CardLiveData::initialize(size_t max_capacity, uint num_max_regions) {
@@ -93,8 +95,8 @@
 // information.
 class G1CardLiveDataHelper VALUE_OBJ_CLASS_SPEC {
 private:
-  BitMap _region_bm;
-  BitMap _card_bm;
+  BitMapView _region_bm;
+  BitMapView _card_bm;
 
   // The card number of the bottom of the G1 heap.
   // Used in biasing indices into accounting card bitmaps.
@@ -127,6 +129,13 @@
   // lots of work most of the time.
   BitMap::idx_t _last_marked_bit_idx;
 
+  void clear_card_bitmap_range(HeapWord* start, HeapWord* end) {
+    BitMap::idx_t start_idx = card_live_bitmap_index_for(start);
+    BitMap::idx_t end_idx = card_live_bitmap_index_for((HeapWord*)align_ptr_up(end, CardTableModRefBS::card_size));
+
+    _card_bm.clear_range(start_idx, end_idx);
+  }
+
   // Mark the card liveness bitmap for the object spanning from start to end.
   void mark_card_bitmap_range(HeapWord* start, HeapWord* end) {
     BitMap::idx_t start_idx = card_live_bitmap_index_for(start);
@@ -169,6 +178,10 @@
     _region_bm.par_set_bit(hr->hrm_index());
   }
 
+  void reset_live_data(HeapRegion* hr) {
+    clear_card_bitmap_range(hr->next_top_at_mark_start(), hr->end());
+  }
+
   // Mark the range of bits covered by allocations done since the last marking
   // in the given heap region, i.e. from NTAMS to top of the given region.
   // Returns if there has been some allocation in this region since the last marking.
@@ -305,6 +318,8 @@
 };
 
 void G1CardLiveData::create(WorkGang* workers, G1CMBitMap* mark_bitmap) {
+  _gc_timestamp_at_create = G1CollectedHeap::heap()->get_gc_time_stamp();
+
   uint n_workers = workers->active_workers();
 
   G1CreateCardLiveDataTask cl(mark_bitmap,
@@ -322,14 +337,24 @@
   class G1FinalizeCardLiveDataClosure: public HeapRegionClosure {
   private:
     G1CardLiveDataHelper _helper;
+
+    uint _gc_timestamp_at_create;
+
+    bool has_been_reclaimed(HeapRegion* hr) const {
+      return hr->get_gc_time_stamp() > _gc_timestamp_at_create;
+    }
   public:
     G1FinalizeCardLiveDataClosure(G1CollectedHeap* g1h,
                                   G1CMBitMap* bitmap,
                                   G1CardLiveData* live_data) :
       HeapRegionClosure(),
-      _helper(live_data, g1h->reserved_region().start()) { }
+      _helper(live_data, g1h->reserved_region().start()),
+      _gc_timestamp_at_create(live_data->gc_timestamp_at_create()) { }
 
     bool doHeapRegion(HeapRegion* hr) {
+      if (has_been_reclaimed(hr)) {
+        _helper.reset_live_data(hr);
+      }
       bool allocated_since_marking = _helper.mark_allocated_since_marking(hr);
       if (allocated_since_marking || hr->next_marked_bytes() > 0) {
         _helper.set_bit_for_region(hr);
@@ -368,11 +393,11 @@
 }
 
 class G1ClearCardLiveDataTask : public AbstractGangTask {
-  BitMap _bitmap;
-  size_t _num_chunks;
-  size_t _cur_chunk;
+  BitMapView _bitmap;
+  size_t     _num_chunks;
+  size_t     _cur_chunk;
 public:
-  G1ClearCardLiveDataTask(BitMap bitmap, size_t num_tasks) :
+  G1ClearCardLiveDataTask(const BitMapView& bitmap, size_t num_tasks) :
     AbstractGangTask("G1 Clear Card Live Data"),
     _bitmap(bitmap),
     _num_chunks(num_tasks),
@@ -399,9 +424,12 @@
   guarantee(Universe::is_fully_initialized(), "Should not call this during initialization.");
 
   size_t const num_chunks = align_size_up(live_cards_bm().size_in_bytes(), G1ClearCardLiveDataTask::chunk_size()) / G1ClearCardLiveDataTask::chunk_size();
+  uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers());
 
   G1ClearCardLiveDataTask cl(live_cards_bm(), num_chunks);
-  workers->run_task(&cl);
+
+  log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " work units.", cl.name(), num_workers, num_chunks);
+  workers->run_task(&cl, num_workers);
 
   // The region live bitmap is always very small, even for huge heaps. Clear
   // directly.
@@ -459,27 +487,26 @@
       // Verify the marked bytes for this region.
 
       if (exp_marked_bytes != act_marked_bytes) {
+        log_error(gc)("Expected marked bytes " SIZE_FORMAT " != actual marked bytes " SIZE_FORMAT " in region %u", exp_marked_bytes, act_marked_bytes, hr->hrm_index());
         failures += 1;
       } else if (exp_marked_bytes > HeapRegion::GrainBytes) {
+        log_error(gc)("Expected marked bytes " SIZE_FORMAT " larger than possible " SIZE_FORMAT " in region %u", exp_marked_bytes, HeapRegion::GrainBytes, hr->hrm_index());
         failures += 1;
       }
 
       // Verify the bit, for this region, in the actual and expected
       // (which was just calculated) region bit maps.
-      // We're not OK if the bit in the calculated expected region
-      // bitmap is set and the bit in the actual region bitmap is not.
       uint index = hr->hrm_index();
 
       bool expected = _exp_live_data->is_region_live(index);
       bool actual = _act_live_data->is_region_live(index);
-      if (expected && !actual) {
+      if (expected != actual) {
+        log_error(gc)("Expected liveness %d not equal actual %d in region %u", expected, actual, hr->hrm_index());
         failures += 1;
       }
 
       // Verify that the card bit maps for the cards spanned by the current
-      // region match. We have an error if we have a set bit in the expected
-      // bit map and the corresponding bit in the actual bitmap is not set.
-
+      // region match.
       BitMap::idx_t start_idx = _helper.card_live_bitmap_index_for(hr->bottom());
       BitMap::idx_t end_idx = _helper.card_live_bitmap_index_for(hr->top());
 
@@ -487,7 +514,8 @@
         expected = _exp_live_data->is_card_live_at(i);
         actual = _act_live_data->is_card_live_at(i);
 
-        if (expected && !actual) {
+        if (expected != actual) {
+          log_error(gc)("Expected card liveness %d not equal actual card liveness %d at card " SIZE_FORMAT " in region %u", expected, actual, i, hr->hrm_index());
           failures += 1;
         }
       }
diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp
index d76fa66..6672d45 100644
--- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp
@@ -46,6 +46,17 @@
   size_t _max_capacity;
   size_t _cards_per_region;
 
+  // Regions may be reclaimed while concurrently creating live data (e.g. due to humongous
+  // eager reclaim). This results in wrong live data for these regions at the end.
+  // So we need to somehow detect these regions, and during live data finalization completely
+  // recreate their information.
+  // This _gc_timestamp_at_create tracks the global timestamp when live data creation
+  // has started. Any regions with a higher time stamp have been cleared after that
+  // point in time, and need re-finalization.
+  // Unsynchronized access to this variable is okay, since this value is only set during a
+  // concurrent phase, and read only at the Cleanup safepoint. I.e. there is always
+  // full memory synchronization inbetween.
+  uint _gc_timestamp_at_create;
   // The per-card liveness bitmap.
   bm_word_t* _live_cards;
   size_t _live_cards_size_in_bits;
@@ -54,21 +65,23 @@
   size_t _live_regions_size_in_bits;
   // The bits in this bitmap contain for every card whether it contains
   // at least part of at least one live object.
-  BitMap live_cards_bm() const { return BitMap(_live_cards, _live_cards_size_in_bits); }
+  BitMapView live_cards_bm() const { return BitMapView(_live_cards, _live_cards_size_in_bits); }
   // The bits in this bitmap indicate that a given region contains some live objects.
-  BitMap live_regions_bm() const { return BitMap(_live_regions, _live_regions_size_in_bits); }
+  BitMapView live_regions_bm() const { return BitMapView(_live_regions, _live_regions_size_in_bits); }
 
   // Allocate a "large" bitmap from virtual memory with the given size in bits.
   bm_word_t* allocate_large_bitmap(size_t size_in_bits);
   void free_large_bitmap(bm_word_t* map, size_t size_in_bits);
 
-  inline BitMap live_card_bitmap(uint region);
+  inline BitMapView live_card_bitmap(uint region);
 
   inline bool is_card_live_at(BitMap::idx_t idx) const;
 
   size_t live_region_bitmap_size_in_bits() const;
   size_t live_card_bitmap_size_in_bits() const;
 public:
+  uint gc_timestamp_at_create() const { return _gc_timestamp_at_create; }
+
   inline bool is_region_live(uint region) const;
 
   inline void remove_nonlive_cards(uint region, BitMap* bm);
diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp
index fc14ed8..b524d59 100644
--- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp
@@ -29,8 +29,8 @@
 #include "utilities/bitMap.inline.hpp"
 #include "utilities/globalDefinitions.hpp"
 
-inline BitMap G1CardLiveData::live_card_bitmap(uint region) {
-  return BitMap(_live_cards + ((size_t)region * _cards_per_region >> LogBitsPerWord), _cards_per_region);
+inline BitMapView G1CardLiveData::live_card_bitmap(uint region) {
+  return BitMapView(_live_cards + ((size_t)region * _cards_per_region >> LogBitsPerWord), _cards_per_region);
 }
 
 inline bool G1CardLiveData::is_card_live_at(BitMap::idx_t idx) const {
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
index 3a775d5..90a7d35 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
@@ -42,9 +42,11 @@
 #include "gc/g1/g1HeapSizingPolicy.hpp"
 #include "gc/g1/g1HeapTransition.hpp"
 #include "gc/g1/g1HeapVerifier.hpp"
+#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1MarkSweep.hpp"
 #include "gc/g1/g1OopClosures.inline.hpp"
 #include "gc/g1/g1ParScanThreadState.inline.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1RegionToSpaceMapper.hpp"
 #include "gc/g1/g1RemSet.inline.hpp"
 #include "gc/g1/g1RootClosures.hpp"
@@ -64,6 +66,7 @@
 #include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/generationSpec.hpp"
 #include "gc/shared/isGCActiveMark.hpp"
+#include "gc/shared/preservedMarks.inline.hpp"
 #include "gc/shared/referenceProcessor.inline.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
 #include "logging/log.hpp"
@@ -97,7 +100,7 @@
   RefineCardTableEntryClosure() : _concurrent(true) { }
 
   bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
-    bool oops_into_cset = G1CollectedHeap::heap()->g1_rem_set()->refine_card(card_ptr, worker_i, false);
+    bool oops_into_cset = G1CollectedHeap::heap()->g1_rem_set()->refine_card(card_ptr, worker_i, NULL);
     // This path is executed by the concurrent refine or mutator threads,
     // concurrently, and so we do not care if card_ptr contains references
     // that point into the collection set.
@@ -161,59 +164,6 @@
   reset_from_card_cache(start_idx, num_regions);
 }
 
-void G1CollectedHeap::push_dirty_cards_region(HeapRegion* hr)
-{
-  // Claim the right to put the region on the dirty cards region list
-  // by installing a self pointer.
-  HeapRegion* next = hr->get_next_dirty_cards_region();
-  if (next == NULL) {
-    HeapRegion* res = (HeapRegion*)
-      Atomic::cmpxchg_ptr(hr, hr->next_dirty_cards_region_addr(),
-                          NULL);
-    if (res == NULL) {
-      HeapRegion* head;
-      do {
-        // Put the region to the dirty cards region list.
-        head = _dirty_cards_region_list;
-        next = (HeapRegion*)
-          Atomic::cmpxchg_ptr(hr, &_dirty_cards_region_list, head);
-        if (next == head) {
-          assert(hr->get_next_dirty_cards_region() == hr,
-                 "hr->get_next_dirty_cards_region() != hr");
-          if (next == NULL) {
-            // The last region in the list points to itself.
-            hr->set_next_dirty_cards_region(hr);
-          } else {
-            hr->set_next_dirty_cards_region(next);
-          }
-        }
-      } while (next != head);
-    }
-  }
-}
-
-HeapRegion* G1CollectedHeap::pop_dirty_cards_region()
-{
-  HeapRegion* head;
-  HeapRegion* hr;
-  do {
-    head = _dirty_cards_region_list;
-    if (head == NULL) {
-      return NULL;
-    }
-    HeapRegion* new_head = head->get_next_dirty_cards_region();
-    if (head == new_head) {
-      // The last region.
-      new_head = NULL;
-    }
-    hr = (HeapRegion*)Atomic::cmpxchg_ptr(new_head, &_dirty_cards_region_list,
-                                          head);
-  } while (hr != head);
-  assert(hr != NULL, "invariant");
-  hr->set_next_dirty_cards_region(NULL);
-  return hr;
-}
-
 // Returns true if the reference points to an object that
 // can move in an incremental collection.
 bool G1CollectedHeap::is_scavengable(const void* p) {
@@ -1373,10 +1323,9 @@
       // the compaction events.
       print_hrm_post_compaction();
 
-      G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
-      if (hot_card_cache->use_cache()) {
-        hot_card_cache->reset_card_counts();
-        hot_card_cache->reset_hot_cache();
+      if (_hot_card_cache->use_cache()) {
+        _hot_card_cache->reset_card_counts();
+        _hot_card_cache->reset_hot_cache();
       }
 
       // Rebuild remembered sets of all regions.
@@ -1406,8 +1355,7 @@
 
       // At this point there should be no regions in the
       // entire heap tagged as young.
-      assert(check_young_list_empty(true /* check_heap */),
-             "young list should be empty at this point");
+      assert(check_young_list_empty(), "young list should be empty at this point");
 
       // Update the number of full collections that have been completed.
       increment_old_marking_cycles_completed(false /* concurrent */);
@@ -1744,19 +1692,23 @@
 
 // Public methods.
 
-G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) :
+G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) :
   CollectedHeap(),
-  _g1_policy(policy_),
-  _collection_set(this),
+  _collector_policy(collector_policy),
+  _g1_policy(create_g1_policy()),
+  _collection_set(this, _g1_policy),
   _dirty_card_queue_set(false),
   _is_alive_closure_cm(this),
   _is_alive_closure_stw(this),
   _ref_processor_cm(NULL),
   _ref_processor_stw(NULL),
   _bot(NULL),
+  _hot_card_cache(NULL),
+  _g1_rem_set(NULL),
   _cg1r(NULL),
   _g1mm(NULL),
   _refine_cte_cl(NULL),
+  _preserved_marks_set(true /* in_c_heap */),
   _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()),
   _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()),
   _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()),
@@ -1764,7 +1716,6 @@
   _has_humongous_reclaim_candidates(false),
   _archive_allocator(NULL),
   _free_regions_coming(false),
-  _young_list(new YoungList(this)),
   _gc_time_stamp(0),
   _summary_bytes_used(0),
   _survivor_evac_stats("Young", YoungPLABSize, PLABWeight),
@@ -1773,7 +1724,6 @@
   _old_marking_cycles_started(0),
   _old_marking_cycles_completed(0),
   _in_cset_fast_test(),
-  _dirty_cards_region_list(NULL),
   _worker_cset_start_region(NULL),
   _worker_cset_start_region_time_stamp(NULL),
   _gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()),
@@ -1867,7 +1817,7 @@
   _refine_cte_cl = new RefineCardTableEntryClosure();
 
   jint ecode = JNI_OK;
-  _cg1r = ConcurrentG1Refine::create(this, _refine_cte_cl, &ecode);
+  _cg1r = ConcurrentG1Refine::create(_refine_cte_cl, &ecode);
   if (_cg1r == NULL) {
     return ecode;
   }
@@ -1897,8 +1847,11 @@
   assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity");
   set_barrier_set(bs);
 
+  // Create the hot card cache.
+  _hot_card_cache = new G1HotCardCache(this);
+
   // Also create a G1 rem set.
-  _g1_rem_set = new G1RemSet(this, g1_barrier_set());
+  _g1_rem_set = new G1RemSet(this, g1_barrier_set(), _hot_card_cache);
 
   // Carve out the G1 part of the heap.
   ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
@@ -1943,8 +1896,8 @@
 
   _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
   g1_barrier_set()->initialize(cardtable_storage);
-   // Do later initialization work for concurrent refinement.
-  _cg1r->init(card_counts_storage);
+  // Do later initialization work for concurrent refinement.
+  _hot_card_cache->initialize(card_counts_storage);
 
   // 6843694 - ensure that the maximum region index can fit
   // in the remembered set structures.
@@ -1987,7 +1940,7 @@
   }
 
   // Perform any initialization actions delegated to the policy.
-  g1_policy()->init();
+  g1_policy()->init(this, &_collection_set);
 
   JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon,
                                                SATB_Q_FL_lock,
@@ -2032,10 +1985,7 @@
 
   G1StringDedup::initialize();
 
-  _preserved_objs = NEW_C_HEAP_ARRAY(OopAndMarkOopStack, ParallelGCThreads, mtGC);
-  for (uint i = 0; i < ParallelGCThreads; i++) {
-    new (&_preserved_objs[i]) OopAndMarkOopStack();
-  }
+  _preserved_marks_set.init(ParallelGCThreads);
 
   return JNI_OK;
 }
@@ -2056,7 +2006,6 @@
 }
 
 void G1CollectedHeap::post_initialize() {
-  CollectedHeap::post_initialize();
   ref_processing_init();
 }
 
@@ -2134,7 +2083,7 @@
 }
 
 CollectorPolicy* G1CollectedHeap::collector_policy() const {
-  return g1_policy();
+  return _collector_policy;
 }
 
 size_t G1CollectedHeap::capacity() const {
@@ -2177,7 +2126,7 @@
 #endif // PRODUCT
 
 void G1CollectedHeap::iterate_hcc_closure(CardTableEntryClosure* cl, uint worker_i) {
-  _cg1r->hot_card_cache()->drain(cl, worker_i);
+  _hot_card_cache->drain(cl, worker_i);
 }
 
 void G1CollectedHeap::iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i) {
@@ -2612,11 +2561,11 @@
 }
 
 size_t G1CollectedHeap::tlab_capacity(Thread* ignored) const {
-  return (_g1_policy->young_list_target_length() - young_list()->survivor_length()) * HeapRegion::GrainBytes;
+  return (_g1_policy->young_list_target_length() - _survivor.length()) * HeapRegion::GrainBytes;
 }
 
 size_t G1CollectedHeap::tlab_used(Thread* ignored) const {
-  return young_list()->eden_used_bytes();
+  return _eden.length() * HeapRegion::GrainBytes;
 }
 
 // For G1 TLABs should not contain humongous objects, so the maximum TLAB size
@@ -2701,10 +2650,10 @@
             p2i(_hrm.reserved().end()));
   st->cr();
   st->print("  region size " SIZE_FORMAT "K, ", HeapRegion::GrainBytes / K);
-  uint young_regions = _young_list->length();
+  uint young_regions = young_regions_count();
   st->print("%u young (" SIZE_FORMAT "K), ", young_regions,
             (size_t) young_regions * HeapRegion::GrainBytes / K);
-  uint survivor_regions = _young_list->survivor_length();
+  uint survivor_regions = survivor_regions_count();
   st->print("%u survivors (" SIZE_FORMAT "K)", survivor_regions,
             (size_t) survivor_regions * HeapRegion::GrainBytes / K);
   st->cr();
@@ -2761,7 +2710,6 @@
 void G1CollectedHeap::print_tracing_info() const {
   g1_rem_set()->print_summary_info();
   concurrent_mark()->print_summary_info();
-  g1_policy()->print_yg_surv_rate_info();
 }
 
 #ifndef PRODUCT
@@ -2814,10 +2762,9 @@
 #endif // PRODUCT
 
 G1HeapSummary G1CollectedHeap::create_g1_heap_summary() {
-  YoungList* young_list = heap()->young_list();
 
-  size_t eden_used_bytes = young_list->eden_used_bytes();
-  size_t survivor_used_bytes = young_list->survivor_used_bytes();
+  size_t eden_used_bytes = heap()->eden_regions_count() * HeapRegion::GrainBytes;
+  size_t survivor_used_bytes = heap()->survivor_regions_count() * HeapRegion::GrainBytes;
   size_t heap_used = Heap_lock->owned_by_self() ? used() : used_unlocked();
 
   size_t eden_capacity_bytes =
@@ -3088,28 +3035,6 @@
     }
 };
 
-#ifdef ASSERT
-class VerifyCSetClosure: public HeapRegionClosure {
-public:
-  bool doHeapRegion(HeapRegion* hr) {
-    // Here we check that the CSet region's RSet is ready for parallel
-    // iteration. The fields that we'll verify are only manipulated
-    // when the region is part of a CSet and is collected. Afterwards,
-    // we reset these fields when we clear the region's RSet (when the
-    // region is freed) so they are ready when the region is
-    // re-allocated. The only exception to this is if there's an
-    // evacuation failure and instead of freeing the region we leave
-    // it in the heap. In that case, we reset these fields during
-    // evacuation failure handling.
-    guarantee(hr->rem_set()->verify_ready_for_par_iteration(), "verification");
-
-    // Here's a good place to add any other checks we'd like to
-    // perform on CSet regions.
-    return false;
-  }
-};
-#endif // ASSERT
-
 uint G1CollectedHeap::num_task_queues() const {
   return _task_queues->size();
 }
@@ -3182,6 +3107,8 @@
   SvcGCMarker sgcm(SvcGCMarker::MINOR);
   ResourceMark rm;
 
+  g1_policy()->note_gc_start();
+
   wait_for_root_region_scanning();
 
   print_heap_before_gc();
@@ -3241,8 +3168,6 @@
                                                                   Threads::number_of_non_daemon_threads());
     workers()->set_active_workers(active_workers);
 
-    g1_policy()->note_gc_start();
-
     TraceCollectorStats tcs(g1mm()->incremental_collection_counters());
     TraceMemoryManagerStats tms(false /* fullGC */, gc_cause());
 
@@ -3259,8 +3184,6 @@
     G1HeapTransition heap_transition(this);
     size_t heap_used_bytes_before_gc = used();
 
-    assert(check_young_list_well_formed(), "young list should be well formed");
-
     // Don't dynamically change the number of GC threads this early.  A value of
     // 0 is used to indicate serial work.  When parallel work is done,
     // it will be set.
@@ -3324,7 +3247,7 @@
           concurrent_mark()->checkpointRootsInitialPre();
         }
 
-        g1_policy()->finalize_collection_set(target_pause_time_ms);
+        g1_policy()->finalize_collection_set(target_pause_time_ms, &_survivor);
 
         evacuation_info.set_collectionset_regions(collection_set()->region_length());
 
@@ -3352,11 +3275,6 @@
           }
         }
 
-#ifdef ASSERT
-        VerifyCSetClosure cl;
-        collection_set_iterate(&cl);
-#endif // ASSERT
-
         // Initialize the GC alloc regions.
         _allocator->init_gc_alloc_regions(evacuation_info);
 
@@ -3384,14 +3302,8 @@
 
         clear_cset_fast_test();
 
-        // Don't check the whole heap at this point as the
-        // GC alloc regions from this pause have been tagged
-        // as survivors and moved on to the survivor list.
-        // Survivor regions will fail the !is_young() check.
-        assert(check_young_list_empty(false /* check_heap */),
-          "young list should be empty");
-
-        _young_list->reset_auxilary_lists();
+        guarantee(_eden.length() == 0, "eden should have been cleared");
+        g1_policy()->transfer_survivors_to_cset(survivor());
 
         if (evacuation_failed()) {
           set_used(recalculate_used());
@@ -3553,11 +3465,6 @@
   return true;
 }
 
-void G1CollectedHeap::restore_preserved_marks() {
-  G1RestorePreservedMarksTask rpm_task(_preserved_objs);
-  workers()->run_task(&rpm_task);
-}
-
 void G1CollectedHeap::remove_self_forwarding_pointers() {
   G1ParRemoveSelfForwardPtrsTask rsfp_task;
   workers()->run_task(&rsfp_task);
@@ -3567,7 +3474,7 @@
   double remove_self_forwards_start = os::elapsedTime();
 
   remove_self_forwarding_pointers();
-  restore_preserved_marks();
+  _preserved_marks_set.restore(workers());
 
   g1_policy()->phase_times()->record_evac_fail_remove_self_forwards((os::elapsedTime() - remove_self_forwards_start) * 1000.0);
 }
@@ -3578,13 +3485,7 @@
   }
 
   _evacuation_failed_info_array[worker_id].register_copy_failure(obj->size());
-
-  // We want to call the "for_promotion_failure" version only in the
-  // case of a promotion failure.
-  if (m->must_be_preserved_for_promotion_failure(obj)) {
-    OopAndMarkOop elem(obj, m);
-    _preserved_objs[worker_id].push(elem);
-  }
+  _preserved_marks_set.get(worker_id)->push_if_necessary(obj, m);
 }
 
 bool G1ParEvacuateFollowersClosure::offer_termination() {
@@ -3801,12 +3702,12 @@
   const uint               _num_workers;
 
   // Variables used to claim nmethods.
-  nmethod* _first_nmethod;
-  volatile nmethod* _claimed_nmethod;
+  CompiledMethod* _first_nmethod;
+  volatile CompiledMethod* _claimed_nmethod;
 
   // The list of nmethods that need to be processed by the second pass.
-  volatile nmethod* _postponed_list;
-  volatile uint     _num_entered_barrier;
+  volatile CompiledMethod* _postponed_list;
+  volatile uint            _num_entered_barrier;
 
  public:
   G1CodeCacheUnloadingTask(uint num_workers, BoolObjectClosure* is_alive, bool unloading_occurred) :
@@ -3818,13 +3719,13 @@
       _postponed_list(NULL),
       _num_entered_barrier(0)
   {
-    nmethod::increase_unloading_clock();
+    CompiledMethod::increase_unloading_clock();
     // Get first alive nmethod
-    NMethodIterator iter = NMethodIterator();
+    CompiledMethodIterator iter = CompiledMethodIterator();
     if(iter.next_alive()) {
       _first_nmethod = iter.method();
     }
-    _claimed_nmethod = (volatile nmethod*)_first_nmethod;
+    _claimed_nmethod = (volatile CompiledMethod*)_first_nmethod;
   }
 
   ~G1CodeCacheUnloadingTask() {
@@ -3837,15 +3738,15 @@
   }
 
  private:
-  void add_to_postponed_list(nmethod* nm) {
-      nmethod* old;
+  void add_to_postponed_list(CompiledMethod* nm) {
+      CompiledMethod* old;
       do {
-        old = (nmethod*)_postponed_list;
+        old = (CompiledMethod*)_postponed_list;
         nm->set_unloading_next(old);
-      } while ((nmethod*)Atomic::cmpxchg_ptr(nm, &_postponed_list, old) != old);
+      } while ((CompiledMethod*)Atomic::cmpxchg_ptr(nm, &_postponed_list, old) != old);
   }
 
-  void clean_nmethod(nmethod* nm) {
+  void clean_nmethod(CompiledMethod* nm) {
     bool postponed = nm->do_unloading_parallel(_is_alive, _unloading_occurred);
 
     if (postponed) {
@@ -3855,24 +3756,24 @@
 
     // Mark that this thread has been cleaned/unloaded.
     // After this call, it will be safe to ask if this nmethod was unloaded or not.
-    nm->set_unloading_clock(nmethod::global_unloading_clock());
+    nm->set_unloading_clock(CompiledMethod::global_unloading_clock());
   }
 
-  void clean_nmethod_postponed(nmethod* nm) {
+  void clean_nmethod_postponed(CompiledMethod* nm) {
     nm->do_unloading_parallel_postponed(_is_alive, _unloading_occurred);
   }
 
   static const int MaxClaimNmethods = 16;
 
-  void claim_nmethods(nmethod** claimed_nmethods, int *num_claimed_nmethods) {
-    nmethod* first;
-    NMethodIterator last;
+  void claim_nmethods(CompiledMethod** claimed_nmethods, int *num_claimed_nmethods) {
+    CompiledMethod* first;
+    CompiledMethodIterator last;
 
     do {
       *num_claimed_nmethods = 0;
 
-      first = (nmethod*)_claimed_nmethod;
-      last = NMethodIterator(first);
+      first = (CompiledMethod*)_claimed_nmethod;
+      last = CompiledMethodIterator(first);
 
       if (first != NULL) {
 
@@ -3885,22 +3786,22 @@
         }
       }
 
-    } while ((nmethod*)Atomic::cmpxchg_ptr(last.method(), &_claimed_nmethod, first) != first);
+    } while ((CompiledMethod*)Atomic::cmpxchg_ptr(last.method(), &_claimed_nmethod, first) != first);
   }
 
-  nmethod* claim_postponed_nmethod() {
-    nmethod* claim;
-    nmethod* next;
+  CompiledMethod* claim_postponed_nmethod() {
+    CompiledMethod* claim;
+    CompiledMethod* next;
 
     do {
-      claim = (nmethod*)_postponed_list;
+      claim = (CompiledMethod*)_postponed_list;
       if (claim == NULL) {
         return NULL;
       }
 
       next = claim->unloading_next();
 
-    } while ((nmethod*)Atomic::cmpxchg_ptr(next, &_postponed_list, claim) != claim);
+    } while ((CompiledMethod*)Atomic::cmpxchg_ptr(next, &_postponed_list, claim) != claim);
 
     return claim;
   }
@@ -3936,7 +3837,7 @@
     }
 
     int num_claimed_nmethods;
-    nmethod* claimed_nmethods[MaxClaimNmethods];
+    CompiledMethod* claimed_nmethods[MaxClaimNmethods];
 
     while (true) {
       claim_nmethods(claimed_nmethods, &num_claimed_nmethods);
@@ -3952,7 +3853,7 @@
   }
 
   void work_second_pass(uint worker_id) {
-    nmethod* nm;
+    CompiledMethod* nm;
     // Take care of postponed nmethods.
     while ((nm = claim_postponed_nmethod()) != NULL) {
       clean_nmethod_postponed(nm);
@@ -4602,11 +4503,11 @@
   _evacuation_failed = false;
 
   // Disable the hot card cache.
-  G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
-  hot_card_cache->reset_hot_cache_claimed_index();
-  hot_card_cache->set_use_cache(false);
+  _hot_card_cache->reset_hot_cache_claimed_index();
+  _hot_card_cache->set_use_cache(false);
 
   g1_rem_set()->prepare_for_oops_into_collection_set_do();
+  _preserved_marks_set.assert_empty();
 }
 
 void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
@@ -4684,6 +4585,8 @@
     NOT_PRODUCT(reset_evacuation_should_fail();)
   }
 
+  _preserved_marks_set.assert_empty();
+
   // Enqueue any remaining references remaining on the STW
   // reference processor's discovered lists. We need to do
   // this after the card table is cleaned (and verified) as
@@ -4704,9 +4607,8 @@
   // Reset and re-enable the hot card cache.
   // Note the counts for the cards in the regions in the
   // collection set are reset when the collection set is freed.
-  G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
-  hot_card_cache->reset_hot_cache();
-  hot_card_cache->set_use_cache(true);
+  _hot_card_cache->reset_hot_cache();
+  _hot_card_cache->set_use_cache(true);
 
   purge_code_root_memory();
 
@@ -4741,7 +4643,7 @@
   // Note: we only need to do this if the region is not young
   // (since we don't refine cards in young regions).
   if (!hr->is_young()) {
-    _cg1r->hot_card_cache()->reset_card_counts(hr);
+    _hot_card_cache->reset_card_counts(hr);
   }
   hr->hr_clear(par, true /* clear_space */, locked /* locked */);
   free_list->add_ordered(hr);
@@ -4778,31 +4680,6 @@
   decrease_used(bytes);
 }
 
-class G1ParCleanupCTTask : public AbstractGangTask {
-  G1SATBCardTableModRefBS* _ct_bs;
-  G1CollectedHeap* _g1h;
-  HeapRegion* volatile _su_head;
-public:
-  G1ParCleanupCTTask(G1SATBCardTableModRefBS* ct_bs,
-                     G1CollectedHeap* g1h) :
-    AbstractGangTask("G1 Par Cleanup CT Task"),
-    _ct_bs(ct_bs), _g1h(g1h) { }
-
-  void work(uint worker_id) {
-    HeapRegion* r;
-    while (r = _g1h->pop_dirty_cards_region()) {
-      clear_cards(r);
-    }
-  }
-
-  void clear_cards(HeapRegion* r) {
-    // Cards of the survivors should have already been dirtied.
-    if (!r->is_survivor()) {
-      _ct_bs->clear(MemRegion(r->bottom(), r->end()));
-    }
-  }
-};
-
 class G1ParScrubRemSetTask: public AbstractGangTask {
 protected:
   G1RemSet* _g1rs;
@@ -4826,27 +4703,6 @@
   workers()->run_task(&g1_par_scrub_rs_task);
 }
 
-void G1CollectedHeap::cleanUpCardTable() {
-  G1SATBCardTableModRefBS* ct_bs = g1_barrier_set();
-  double start = os::elapsedTime();
-
-  {
-    // Iterate over the dirty cards region list.
-    G1ParCleanupCTTask cleanup_task(ct_bs, this);
-
-    workers()->run_task(&cleanup_task);
-#ifndef PRODUCT
-    // Need to synchronize with concurrent cleanup since it needs to
-    // finish its card table clearing before we can verify.
-    wait_while_free_regions_coming();
-    _verifier->verify_card_table_cleanup();
-#endif
-  }
-
-  double elapsed = os::elapsedTime() - start;
-  g1_policy()->phase_times()->record_clear_ct_time(elapsed * 1000.0);
-}
-
 void G1CollectedHeap::free_collection_set(HeapRegion* cs_head, EvacuationInfo& evacuation_info, const size_t* surviving_young_words) {
   size_t pre_used = 0;
   FreeRegionList local_free_list("Local List for CSet Freeing");
@@ -4854,12 +4710,9 @@
   double young_time_ms     = 0.0;
   double non_young_time_ms = 0.0;
 
-  // Since the collection set is a superset of the the young list,
-  // all we need to do to clear the young list is clear its
-  // head and length, and unlink any young regions in the code below
-  _young_list->clear();
+  _eden.clear();
 
-  G1CollectorPolicy* policy = g1_policy();
+  G1Policy* policy = g1_policy();
 
   double start_sec = os::elapsedTime();
   bool non_young = true;
@@ -4904,11 +4757,6 @@
       size_t words_survived = surviving_young_words[index];
       cur->record_surv_words_in_group(words_survived);
 
-      // At this point the we have 'popped' cur from the collection set
-      // (linked via next_in_collection_set()) but it is still in the
-      // young list (linked via next_young_region()). Clear the
-      // _next_young_region field.
-      cur->set_next_young_region(NULL);
     } else {
       int index = cur->young_index_in_cset();
       assert(index == -1, "invariant");
@@ -5175,9 +5023,12 @@
 }
 
 void G1CollectedHeap::set_region_short_lived_locked(HeapRegion* hr) {
-  _young_list->push_region(hr);
+  _eden.add(hr);
+  _g1_policy->set_region_eden(hr);
 }
 
+#ifdef ASSERT
+
 class NoYoungRegionsClosure: public HeapRegionClosure {
 private:
   bool _success;
@@ -5194,18 +5045,18 @@
   bool success() { return _success; }
 };
 
-bool G1CollectedHeap::check_young_list_empty(bool check_heap) {
-  bool ret = _young_list->check_list_empty();
+bool G1CollectedHeap::check_young_list_empty() {
+  bool ret = (young_regions_count() == 0);
 
-  if (check_heap) {
-    NoYoungRegionsClosure closure;
-    heap_region_iterate(&closure);
-    ret = ret && closure.success();
-  }
+  NoYoungRegionsClosure closure;
+  heap_region_iterate(&closure);
+  ret = ret && closure.success();
 
   return ret;
 }
 
+#endif // ASSERT
+
 class TearDownRegionSetsClosure : public HeapRegionClosure {
 private:
   HeapRegionSet *_old_set;
@@ -5216,12 +5067,13 @@
   bool doHeapRegion(HeapRegion* r) {
     if (r->is_old()) {
       _old_set->remove(r);
+    } else if(r->is_young()) {
+      r->uninstall_surv_rate_group();
     } else {
       // We ignore free regions, we'll empty the free list afterwards.
-      // We ignore young regions, we'll empty the young list afterwards.
       // We ignore humongous regions, we're not tearing down the
       // humongous regions set.
-      assert(r->is_free() || r->is_young() || r->is_humongous(),
+      assert(r->is_free() || r->is_humongous(),
              "it cannot be another type");
     }
     return false;
@@ -5287,16 +5139,12 @@
       r->set_allocation_context(AllocationContext::system());
       _hrm->insert_into_free_list(r);
     } else if (!_free_list_only) {
-      assert(!r->is_young(), "we should not come across young regions");
 
       if (r->is_humongous()) {
         // We ignore humongous regions. We left the humongous set unchanged.
       } else {
-        // Objects that were compacted would have ended up on regions
-        // that were previously old or free.  Archive regions (which are
-        // old) will not have been touched.
-        assert(r->is_free() || r->is_old(), "invariant");
-        // We now consider them old, so register as such. Leave
+        assert(r->is_young() || r->is_free() || r->is_old(), "invariant");
+        // We now consider all regions old, so register as such. Leave
         // archive regions set that way, however, while still adding
         // them to the old set.
         if (!r->is_archive()) {
@@ -5319,7 +5167,8 @@
   assert_at_safepoint(true /* should_be_vm_thread */);
 
   if (!free_list_only) {
-    _young_list->empty_list();
+    _eden.clear();
+    _survivor.clear();
   }
 
   RebuildRegionSetsClosure cl(free_list_only, &_old_set, &_hrm);
@@ -5353,14 +5202,14 @@
   assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
   assert(!force || g1_policy()->can_expand_young_list(),
          "if force is true we should be able to expand the young list");
-  bool young_list_full = g1_policy()->is_young_list_full();
-  if (force || !young_list_full) {
+  bool should_allocate = g1_policy()->should_allocate_mutator_region();
+  if (force || should_allocate) {
     HeapRegion* new_alloc_region = new_region(word_size,
                                               false /* is_old */,
                                               false /* do_expand */);
     if (new_alloc_region != NULL) {
       set_region_short_lived_locked(new_alloc_region);
-      _hr_printer.alloc(new_alloc_region, young_list_full);
+      _hr_printer.alloc(new_alloc_region, !should_allocate);
       _verifier->check_bitmaps("Mutator Region Allocation", new_alloc_region);
       return new_alloc_region;
     }
@@ -5388,7 +5237,7 @@
   if (dest.is_old()) {
     return true;
   } else {
-    return young_list()->survivor_length() < g1_policy()->max_survivor_regions();
+    return survivor_regions_count() < g1_policy()->max_survivor_regions();
   }
 }
 
@@ -5411,7 +5260,7 @@
     new_alloc_region->record_timestamp();
     if (is_survivor) {
       new_alloc_region->set_survivor();
-      young_list()->add_survivor_region(new_alloc_region);
+      _survivor.add(new_alloc_region);
       _verifier->check_bitmaps("Survivor Region Allocation", new_alloc_region);
     } else {
       new_alloc_region->set_old();
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp
index e98d57a..6669965 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp
@@ -31,20 +31,23 @@
 #include "gc/g1/g1CollectionSet.hpp"
 #include "gc/g1/g1CollectorState.hpp"
 #include "gc/g1/g1ConcurrentMark.hpp"
+#include "gc/g1/g1EdenRegions.hpp"
+#include "gc/g1/g1EvacFailure.hpp"
+#include "gc/g1/g1EvacStats.hpp"
+#include "gc/g1/g1HeapVerifier.hpp"
 #include "gc/g1/g1HRPrinter.hpp"
 #include "gc/g1/g1InCSetState.hpp"
 #include "gc/g1/g1MonitoringSupport.hpp"
-#include "gc/g1/g1EvacFailure.hpp"
-#include "gc/g1/g1EvacStats.hpp"
 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
+#include "gc/g1/g1SurvivorRegions.hpp"
 #include "gc/g1/g1YCTypes.hpp"
 #include "gc/g1/hSpaceCounters.hpp"
 #include "gc/g1/heapRegionManager.hpp"
 #include "gc/g1/heapRegionSet.hpp"
-#include "gc/g1/youngList.hpp"
 #include "gc/shared/barrierSet.hpp"
 #include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/plab.hpp"
+#include "gc/shared/preservedMarks.hpp"
 #include "memory/memRegion.hpp"
 #include "utilities/stack.hpp"
 
@@ -68,6 +71,8 @@
 class Space;
 class G1CollectionSet;
 class G1CollectorPolicy;
+class G1Policy;
+class G1HotCardCache;
 class G1RemSet;
 class HeapRegionRemSetIterator;
 class G1ConcurrentMark;
@@ -137,6 +142,7 @@
 
 private:
   WorkGang* _workers;
+  G1CollectorPolicy* _collector_policy;
 
   static size_t _humongous_object_threshold_in_words;
 
@@ -243,7 +249,7 @@
   // If not, we can skip a few steps.
   bool _has_humongous_reclaim_candidates;
 
-  volatile unsigned _gc_time_stamp;
+  volatile uint _gc_time_stamp;
 
   G1HRPrinter _hr_printer;
 
@@ -290,6 +296,8 @@
                                                          size_t size,
                                                          size_t translation_factor);
 
+  static G1Policy* create_g1_policy();
+
   void trace_heap(GCWhen::Type when, const GCTracer* tracer);
 
   void process_weak_jni_handles();
@@ -357,10 +365,11 @@
 protected:
 
   // The young region list.
-  YoungList*  _young_list;
+  G1EdenRegions _eden;
+  G1SurvivorRegions _survivor;
 
   // The current policy object for the collector.
-  G1CollectorPolicy* _g1_policy;
+  G1Policy* _g1_policy;
   G1HeapSizingPolicy* _heap_sizing_policy;
 
   G1CollectionSet _collection_set;
@@ -756,6 +765,9 @@
   // Update object copying statistics.
   void record_obj_copy_mem_stats();
 
+  // The hot card cache for remembered set insertion optimization.
+  G1HotCardCache* _hot_card_cache;
+
   // The g1 remembered set of the heap.
   G1RemSet* _g1_rem_set;
 
@@ -793,16 +805,11 @@
   // forwarding pointers to themselves.  Reset them.
   void remove_self_forwarding_pointers();
 
-  // Restore the preserved mark words for objects with self-forwarding pointers.
-  void restore_preserved_marks();
-
   // Restore the objects in the regions in the collection set after an
   // evacuation failure.
   void restore_after_evac_failure();
 
-  // Stores marks with the corresponding oop that we need to preserve during evacuation
-  // failure.
-  OopAndMarkOopStack*  _preserved_objs;
+  PreservedMarksSet _preserved_marks_set;
 
   // Preserve the mark of "obj", if necessary, in preparation for its mark
   // word being overwritten with a self-forwarding-pointer.
@@ -979,7 +986,7 @@
   G1CollectorState* collector_state() { return &_collector_state; }
 
   // The current policy object for the collector.
-  G1CollectorPolicy* g1_policy() const { return _g1_policy; }
+  G1Policy* g1_policy() const { return _g1_policy; }
 
   const G1CollectionSet* collection_set() const { return &_collection_set; }
   G1CollectionSet* collection_set() { return &_collection_set; }
@@ -995,7 +1002,7 @@
   // Try to minimize the remembered set.
   void scrub_rem_set();
 
-  unsigned get_gc_time_stamp() {
+  uint get_gc_time_stamp() {
     return _gc_time_stamp;
   }
 
@@ -1165,10 +1172,6 @@
     return barrier_set_cast<G1SATBCardTableLoggingModRefBS>(barrier_set());
   }
 
-  // This resets the card table to all zeros.  It is used after
-  // a collection pause which used the card table to claim cards.
-  void cleanUpCardTable();
-
   // Iteration functions.
 
   // Iterate over all objects, calling "cl.do_object" on each.
@@ -1331,18 +1334,27 @@
   void set_region_short_lived_locked(HeapRegion* hr);
   // add appropriate methods for any other surv rate groups
 
-  YoungList* young_list() const { return _young_list; }
+  const G1SurvivorRegions* survivor() const { return &_survivor; }
+
+  uint survivor_regions_count() const {
+    return _survivor.length();
+  }
+
+  uint eden_regions_count() const {
+    return _eden.length();
+  }
+
+  uint young_regions_count() const {
+    return _eden.length() + _survivor.length();
+  }
 
   uint old_regions_count() const { return _old_set.length(); }
 
   uint humongous_regions_count() const { return _humongous_set.length(); }
 
-  // debugging
-  bool check_young_list_well_formed() {
-    return _young_list->check_list_well_formed();
-  }
-
-  bool check_young_list_empty(bool check_heap);
+#ifdef ASSERT
+  bool check_young_list_empty();
+#endif
 
   // *** Stuff related to concurrent marking.  It's not clear to me that so
   // many of these need to be public.
@@ -1394,16 +1406,6 @@
 
   ConcurrentG1Refine* concurrent_g1_refine() const { return _cg1r; }
 
-  // The dirty cards region list is used to record a subset of regions
-  // whose cards need clearing. The list if populated during the
-  // remembered set scanning and drained during the card table
-  // cleanup. Although the methods are reentrant, population/draining
-  // phases must not overlap. For synchronization purposes the last
-  // element on the list points to itself.
-  HeapRegion* _dirty_cards_region_list;
-  void push_dirty_cards_region(HeapRegion* hr);
-  HeapRegion* pop_dirty_cards_region();
-
   // Optimized nmethod scanning support routines
 
   // Register the given nmethod with the G1 heap.
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp
index 040367b..05b24e0 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp
@@ -26,7 +26,6 @@
 #define SHARE_VM_GC_G1_G1COLLECTEDHEAP_INLINE_HPP
 
 #include "gc/g1/g1CollectedHeap.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1CollectorState.hpp"
 #include "gc/g1/g1ConcurrentMark.inline.hpp"
 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp
index a4a9617..2976604 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.hpp"
+#include "gc/g1/g1DefaultPolicy.hpp"
 #include "gc/g1/g1ParScanThreadState.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 
@@ -38,3 +39,7 @@
                                              MemRegion mr) {
   return new HeapRegion(hrs_index, bot(), mr);
 }
+
+G1Policy* G1CollectedHeap::create_g1_policy() {
+  return new G1DefaultPolicy();
+}
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp
index 720c828..1e41dfd 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp
@@ -25,8 +25,8 @@
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.hpp"
 #include "gc/g1/g1CollectionSet.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1CollectorState.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/g1/heapRegionSet.hpp"
@@ -48,10 +48,9 @@
   return _policy->predict_region_elapsed_time_ms(hr, collector_state()->gcs_are_young());
 }
 
-
-G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h) :
+G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) :
   _g1(g1h),
-  _policy(NULL),
+  _policy(policy),
   _cset_chooser(new CollectionSetChooser()),
   _eden_region_length(0),
   _survivor_region_length(0),
@@ -68,7 +67,8 @@
   _inc_recorded_rs_lengths(0),
   _inc_recorded_rs_lengths_diffs(0),
   _inc_predicted_elapsed_time_ms(0.0),
-  _inc_predicted_elapsed_time_ms_diffs(0.0) {}
+  _inc_predicted_elapsed_time_ms_diffs(0.0),
+  _inc_region_length(0) {}
 
 G1CollectionSet::~G1CollectionSet() {
   delete _cset_chooser;
@@ -78,6 +78,9 @@
                                           uint survivor_cset_region_length) {
   _eden_region_length     = eden_cset_region_length;
   _survivor_region_length = survivor_cset_region_length;
+
+  assert(young_region_length() == _inc_region_length, "should match %u == %u", young_region_length(), _inc_region_length);
+
   _old_region_length      = 0;
 }
 
@@ -107,6 +110,7 @@
   _inc_head = NULL;
   _inc_tail = NULL;
   _inc_bytes_used_before = 0;
+  _inc_region_length = 0;
 
   _inc_recorded_rs_lengths = 0;
   _inc_recorded_rs_lengths_diffs = 0;
@@ -177,9 +181,11 @@
 
 void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
   assert(hr->is_young(), "invariant");
-  assert(hr->young_index_in_cset() > -1, "should have already been set");
   assert(_inc_build_state == Active, "Precondition");
 
+  hr->set_young_index_in_cset(_inc_region_length);
+  _inc_region_length++;
+
   // This routine is used when:
   // * adding survivor regions to the incremental cset at the end of an
   //   evacuation pause or
@@ -268,10 +274,9 @@
 }
 #endif // !PRODUCT
 
-double G1CollectionSet::finalize_young_part(double target_pause_time_ms) {
+double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors) {
   double young_start_time_sec = os::elapsedTime();
 
-  YoungList* young_list = _g1->young_list();
   finalize_incremental_building();
 
   guarantee(target_pause_time_ms > 0.0,
@@ -291,23 +296,14 @@
   // pause are appended to the RHS of the young list, i.e.
   //   [Newly Young Regions ++ Survivors from last pause].
 
-  uint survivor_region_length = young_list->survivor_length();
-  uint eden_region_length = young_list->eden_length();
+  uint survivor_region_length = survivors->length();
+  uint eden_region_length = _g1->eden_regions_count();
   init_region_lengths(eden_region_length, survivor_region_length);
 
-  HeapRegion* hr = young_list->first_survivor_region();
-  while (hr != NULL) {
-    assert(hr->is_survivor(), "badly formed young list");
-    // There is a convention that all the young regions in the CSet
-    // are tagged as "eden", so we do this for the survivors here. We
-    // use the special set_eden_pre_gc() as it doesn't check that the
-    // region is free (which is not the case here).
-    hr->set_eden_pre_gc();
-    hr = hr->get_next_young_region();
-  }
+  verify_young_cset_indices();
 
   // Clear the fields that point to the survivor list - they are all young now.
-  young_list->clear_survivors();
+  survivors->convert_to_eden();
 
   _head = _inc_head;
   _bytes_used_before = _inc_bytes_used_before;
@@ -424,3 +420,25 @@
   double non_young_end_time_sec = os::elapsedTime();
   phase_times()->record_non_young_cset_choice_time_ms((non_young_end_time_sec - non_young_start_time_sec) * 1000.0);
 }
+
+#ifdef ASSERT
+void G1CollectionSet::verify_young_cset_indices() const {
+  ResourceMark rm;
+  uint* heap_region_indices = NEW_RESOURCE_ARRAY(uint, young_region_length());
+  for (uint i = 0; i < young_region_length(); ++i) {
+    heap_region_indices[i] = (uint)-1;
+  }
+
+  for (HeapRegion* hr = _inc_head; hr != NULL; hr = hr->next_in_collection_set()) {
+    const int idx = hr->young_index_in_cset();
+    assert(idx > -1, "must be set for all inc cset regions");
+    assert((uint)idx < young_region_length(), "young cset index too large");
+
+    assert(heap_region_indices[idx] == (uint)-1,
+           "index %d used by multiple regions, first use by %u, second by %u",
+           idx, heap_region_indices[idx], hr->hrm_index());
+
+    heap_region_indices[idx] = hr->hrm_index();
+  }
+}
+#endif
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp
index 75f9307..bd6f41f 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp
@@ -31,14 +31,15 @@
 #include "utilities/globalDefinitions.hpp"
 
 class G1CollectedHeap;
-class G1CollectorPolicy;
 class G1CollectorState;
 class G1GCPhaseTimes;
+class G1Policy;
+class G1SurvivorRegions;
 class HeapRegion;
 
 class G1CollectionSet VALUE_OBJ_CLASS_SPEC {
   G1CollectedHeap* _g1;
-  G1CollectorPolicy* _policy;
+  G1Policy* _policy;
 
   CollectionSetChooser* _cset_chooser;
 
@@ -104,20 +105,18 @@
   // See the comment for _inc_recorded_rs_lengths_diffs.
   double _inc_predicted_elapsed_time_ms_diffs;
 
+  uint _inc_region_length;
+
   G1CollectorState* collector_state();
   G1GCPhaseTimes* phase_times();
 
   double predict_region_elapsed_time_ms(HeapRegion* hr);
 
+  void verify_young_cset_indices() const NOT_DEBUG_RETURN;
 public:
-  G1CollectionSet(G1CollectedHeap* g1h);
+  G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy);
   ~G1CollectionSet();
 
-  void set_policy(G1CollectorPolicy* g1p) {
-    assert(_policy == NULL, "should only initialize once");
-    _policy = g1p;
-  }
-
   CollectionSetChooser* cset_chooser();
 
   void init_region_lengths(uint eden_cset_region_length,
@@ -152,6 +151,7 @@
   void clear_incremental() {
     _inc_head = NULL;
     _inc_tail = NULL;
+    _inc_region_length = 0;
   }
 
   // Stop adding regions to the incremental collection set
@@ -176,7 +176,7 @@
   // Choose a new collection set.  Marks the chosen regions as being
   // "in_collection_set", and links them together.  The head and number of
   // the collection set are available via access methods.
-  double finalize_young_part(double target_pause_time_ms);
+  double finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors);
   void finalize_old_part(double time_remaining_ms);
 
   // Add old region "hr" to the CSet.
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp
index 75c75de..c0288ed 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp
@@ -23,43 +23,16 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/g1/concurrentG1Refine.hpp"
-#include "gc/g1/concurrentMarkThread.inline.hpp"
 #include "gc/g1/g1Analytics.hpp"
-#include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectionSet.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
-#include "gc/g1/g1ConcurrentMark.hpp"
-#include "gc/g1/g1IHOPControl.hpp"
-#include "gc/g1/g1GCPhaseTimes.hpp"
 #include "gc/g1/g1YoungGenSizer.hpp"
-#include "gc/g1/heapRegion.inline.hpp"
+#include "gc/g1/heapRegion.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/shared/gcPolicyCounters.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/java.hpp"
-#include "runtime/mutexLocker.hpp"
+#include "runtime/globals.hpp"
 #include "utilities/debug.hpp"
-#include "utilities/pair.hpp"
 
-G1CollectorPolicy::G1CollectorPolicy() :
-  _predictor(G1ConfidencePercent / 100.0),
-  _analytics(new G1Analytics(&_predictor)),
-  _pause_time_target_ms((double) MaxGCPauseMillis),
-  _rs_lengths_prediction(0),
-  _max_survivor_regions(0),
-  _survivors_age_table(true),
-
-  _bytes_allocated_in_old_since_last_gc(0),
-  _ihop_control(NULL),
-  _initial_mark_to_mixed() {
-
-  // SurvRateGroups below must be initialized after the predictor because they
-  // indirectly use it through this object passed to their constructor.
-  _short_lived_surv_rate_group =
-    new SurvRateGroup(&_predictor, "Short Lived", G1YoungSurvRateNumRegionsSummary);
-  _survivor_surv_rate_group =
-    new SurvRateGroup(&_predictor, "Survivor", G1YoungSurvRateNumRegionsSummary);
+G1CollectorPolicy::G1CollectorPolicy() {
 
   // Set up the region size and associated fields. Given that the
   // policy is created before the heap, we have to set this up here,
@@ -74,64 +47,6 @@
   // unaligned values for the heap.
   HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
   HeapRegionRemSet::setup_remset_size();
-
-  _phase_times = new G1GCPhaseTimes(ParallelGCThreads);
-
-  // Below, we might need to calculate the pause time target based on
-  // the pause interval. When we do so we are going to give G1 maximum
-  // flexibility and allow it to do pauses when it needs to. So, we'll
-  // arrange that the pause interval to be pause time target + 1 to
-  // ensure that a) the pause time target is maximized with respect to
-  // the pause interval and b) we maintain the invariant that pause
-  // time target < pause interval. If the user does not want this
-  // maximum flexibility, they will have to set the pause interval
-  // explicitly.
-
-  // First make sure that, if either parameter is set, its value is
-  // reasonable.
-  guarantee(MaxGCPauseMillis >= 1, "Range checking for MaxGCPauseMillis should guarantee that value is >= 1");
-
-  // Then, if the pause time target parameter was not set, set it to
-  // the default value.
-  if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
-    if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
-      // The default pause time target in G1 is 200ms
-      FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
-    } else {
-      // We do not allow the pause interval to be set without the
-      // pause time target
-      vm_exit_during_initialization("GCPauseIntervalMillis cannot be set "
-                                    "without setting MaxGCPauseMillis");
-    }
-  }
-
-  // Then, if the interval parameter was not set, set it according to
-  // the pause time target (this will also deal with the case when the
-  // pause time target is the default value).
-  if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
-    FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
-  }
-  guarantee(GCPauseIntervalMillis >= 1, "Constraint for GCPauseIntervalMillis should guarantee that value is >= 1");
-  guarantee(GCPauseIntervalMillis > MaxGCPauseMillis, "Constraint for GCPauseIntervalMillis should guarantee that GCPauseIntervalMillis > MaxGCPauseMillis");
-
-  double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
-  double time_slice  = (double) GCPauseIntervalMillis / 1000.0;
-  _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
-
-  _tenuring_threshold = MaxTenuringThreshold;
-
-
-  guarantee(G1ReservePercent <= 50, "Range checking should not allow values over 50.");
-  _reserve_factor = (double) G1ReservePercent / 100.0;
-  // This will be set when the heap is expanded
-  // for the first time during initialization.
-  _reserve_regions = 0;
-
-  _ihop_control = create_ihop_control();
-}
-
-G1CollectorPolicy::~G1CollectorPolicy() {
-  delete _ihop_control;
 }
 
 void G1CollectorPolicy::initialize_alignments() {
@@ -140,1133 +55,3 @@
   size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
   _heap_alignment = MAX3(card_table_alignment, _space_alignment, page_size);
 }
-
-G1CollectorState* G1CollectorPolicy::collector_state() const { return _g1->collector_state(); }
-
-void G1CollectorPolicy::post_heap_initialize() {
-  uintx max_regions = G1CollectedHeap::heap()->max_regions();
-  size_t max_young_size = (size_t)_young_gen_sizer->max_young_length(max_regions) * HeapRegion::GrainBytes;
-  if (max_young_size != MaxNewSize) {
-    FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size);
-  }
-}
-
-void G1CollectorPolicy::initialize_flags() {
-  if (G1HeapRegionSize != HeapRegion::GrainBytes) {
-    FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes);
-  }
-
-  guarantee(SurvivorRatio >= 1, "Range checking for SurvivorRatio should guarantee that value is >= 1");
-
-  CollectorPolicy::initialize_flags();
-  _young_gen_sizer = new G1YoungGenSizer(); // Must be after call to initialize_flags
-}
-
-
-void G1CollectorPolicy::init() {
-  // Set aside an initial future to_space.
-  _g1 = G1CollectedHeap::heap();
-  _collection_set = _g1->collection_set();
-  _collection_set->set_policy(this);
-
-  assert(Heap_lock->owned_by_self(), "Locking discipline.");
-
-  initialize_gc_policy_counters();
-
-  if (adaptive_young_list_length()) {
-    _young_list_fixed_length = 0;
-  } else {
-    _young_list_fixed_length = _young_gen_sizer->min_desired_young_length();
-  }
-  _free_regions_at_end_of_collection = _g1->num_free_regions();
-
-  update_young_list_max_and_target_length();
-  // We may immediately start allocating regions and placing them on the
-  // collection set list. Initialize the per-collection set info
-  _collection_set->start_incremental_building();
-}
-
-void G1CollectorPolicy::note_gc_start() {
-  phase_times()->note_gc_start();
-}
-
-// Create the jstat counters for the policy.
-void G1CollectorPolicy::initialize_gc_policy_counters() {
-  _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3);
-}
-
-bool G1CollectorPolicy::predict_will_fit(uint young_length,
-                                         double base_time_ms,
-                                         uint base_free_regions,
-                                         double target_pause_time_ms) const {
-  if (young_length >= base_free_regions) {
-    // end condition 1: not enough space for the young regions
-    return false;
-  }
-
-  double accum_surv_rate = accum_yg_surv_rate_pred((int) young_length - 1);
-  size_t bytes_to_copy =
-               (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes);
-  double copy_time_ms = _analytics->predict_object_copy_time_ms(bytes_to_copy,
-                                                                collector_state()->during_concurrent_mark());
-  double young_other_time_ms = _analytics->predict_young_other_time_ms(young_length);
-  double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms;
-  if (pause_time_ms > target_pause_time_ms) {
-    // end condition 2: prediction is over the target pause time
-    return false;
-  }
-
-  size_t free_bytes = (base_free_regions - young_length) * HeapRegion::GrainBytes;
-
-  // When copying, we will likely need more bytes free than is live in the region.
-  // Add some safety margin to factor in the confidence of our guess, and the
-  // natural expected waste.
-  // (100.0 / G1ConfidencePercent) is a scale factor that expresses the uncertainty
-  // of the calculation: the lower the confidence, the more headroom.
-  // (100 + TargetPLABWastePct) represents the increase in expected bytes during
-  // copying due to anticipated waste in the PLABs.
-  double safety_factor = (100.0 / G1ConfidencePercent) * (100 + TargetPLABWastePct) / 100.0;
-  size_t expected_bytes_to_copy = (size_t)(safety_factor * bytes_to_copy);
-
-  if (expected_bytes_to_copy > free_bytes) {
-    // end condition 3: out-of-space
-    return false;
-  }
-
-  // success!
-  return true;
-}
-
-void G1CollectorPolicy::record_new_heap_size(uint new_number_of_regions) {
-  // re-calculate the necessary reserve
-  double reserve_regions_d = (double) new_number_of_regions * _reserve_factor;
-  // We use ceiling so that if reserve_regions_d is > 0.0 (but
-  // smaller than 1.0) we'll get 1.
-  _reserve_regions = (uint) ceil(reserve_regions_d);
-
-  _young_gen_sizer->heap_size_changed(new_number_of_regions);
-
-  _ihop_control->update_target_occupancy(new_number_of_regions * HeapRegion::GrainBytes);
-}
-
-uint G1CollectorPolicy::calculate_young_list_desired_min_length(
-                                                       uint base_min_length) const {
-  uint desired_min_length = 0;
-  if (adaptive_young_list_length()) {
-    if (_analytics->num_alloc_rate_ms() > 3) {
-      double now_sec = os::elapsedTime();
-      double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
-      double alloc_rate_ms = _analytics->predict_alloc_rate_ms();
-      desired_min_length = (uint) ceil(alloc_rate_ms * when_ms);
-    } else {
-      // otherwise we don't have enough info to make the prediction
-    }
-  }
-  desired_min_length += base_min_length;
-  // make sure we don't go below any user-defined minimum bound
-  return MAX2(_young_gen_sizer->min_desired_young_length(), desired_min_length);
-}
-
-uint G1CollectorPolicy::calculate_young_list_desired_max_length() const {
-  // Here, we might want to also take into account any additional
-  // constraints (i.e., user-defined minimum bound). Currently, we
-  // effectively don't set this bound.
-  return _young_gen_sizer->max_desired_young_length();
-}
-
-uint G1CollectorPolicy::update_young_list_max_and_target_length() {
-  return update_young_list_max_and_target_length(_analytics->predict_rs_lengths());
-}
-
-uint G1CollectorPolicy::update_young_list_max_and_target_length(size_t rs_lengths) {
-  uint unbounded_target_length = update_young_list_target_length(rs_lengths);
-  update_max_gc_locker_expansion();
-  return unbounded_target_length;
-}
-
-uint G1CollectorPolicy::update_young_list_target_length(size_t rs_lengths) {
-  YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths);
-  _young_list_target_length = young_lengths.first;
-  return young_lengths.second;
-}
-
-G1CollectorPolicy::YoungTargetLengths G1CollectorPolicy::young_list_target_lengths(size_t rs_lengths) const {
-  YoungTargetLengths result;
-
-  // Calculate the absolute and desired min bounds first.
-
-  // This is how many young regions we already have (currently: the survivors).
-  const uint base_min_length = _g1->young_list()->survivor_length();
-  uint desired_min_length = calculate_young_list_desired_min_length(base_min_length);
-  // This is the absolute minimum young length. Ensure that we
-  // will at least have one eden region available for allocation.
-  uint absolute_min_length = base_min_length + MAX2(_g1->young_list()->eden_length(), (uint)1);
-  // If we shrank the young list target it should not shrink below the current size.
-  desired_min_length = MAX2(desired_min_length, absolute_min_length);
-  // Calculate the absolute and desired max bounds.
-
-  uint desired_max_length = calculate_young_list_desired_max_length();
-
-  uint young_list_target_length = 0;
-  if (adaptive_young_list_length()) {
-    if (collector_state()->gcs_are_young()) {
-      young_list_target_length =
-                        calculate_young_list_target_length(rs_lengths,
-                                                           base_min_length,
-                                                           desired_min_length,
-                                                           desired_max_length);
-    } else {
-      // Don't calculate anything and let the code below bound it to
-      // the desired_min_length, i.e., do the next GC as soon as
-      // possible to maximize how many old regions we can add to it.
-    }
-  } else {
-    // The user asked for a fixed young gen so we'll fix the young gen
-    // whether the next GC is young or mixed.
-    young_list_target_length = _young_list_fixed_length;
-  }
-
-  result.second = young_list_target_length;
-
-  // We will try our best not to "eat" into the reserve.
-  uint absolute_max_length = 0;
-  if (_free_regions_at_end_of_collection > _reserve_regions) {
-    absolute_max_length = _free_regions_at_end_of_collection - _reserve_regions;
-  }
-  if (desired_max_length > absolute_max_length) {
-    desired_max_length = absolute_max_length;
-  }
-
-  // Make sure we don't go over the desired max length, nor under the
-  // desired min length. In case they clash, desired_min_length wins
-  // which is why that test is second.
-  if (young_list_target_length > desired_max_length) {
-    young_list_target_length = desired_max_length;
-  }
-  if (young_list_target_length < desired_min_length) {
-    young_list_target_length = desired_min_length;
-  }
-
-  assert(young_list_target_length > base_min_length,
-         "we should be able to allocate at least one eden region");
-  assert(young_list_target_length >= absolute_min_length, "post-condition");
-
-  result.first = young_list_target_length;
-  return result;
-}
-
-uint
-G1CollectorPolicy::calculate_young_list_target_length(size_t rs_lengths,
-                                                     uint base_min_length,
-                                                     uint desired_min_length,
-                                                     uint desired_max_length) const {
-  assert(adaptive_young_list_length(), "pre-condition");
-  assert(collector_state()->gcs_are_young(), "only call this for young GCs");
-
-  // In case some edge-condition makes the desired max length too small...
-  if (desired_max_length <= desired_min_length) {
-    return desired_min_length;
-  }
-
-  // We'll adjust min_young_length and max_young_length not to include
-  // the already allocated young regions (i.e., so they reflect the
-  // min and max eden regions we'll allocate). The base_min_length
-  // will be reflected in the predictions by the
-  // survivor_regions_evac_time prediction.
-  assert(desired_min_length > base_min_length, "invariant");
-  uint min_young_length = desired_min_length - base_min_length;
-  assert(desired_max_length > base_min_length, "invariant");
-  uint max_young_length = desired_max_length - base_min_length;
-
-  double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0;
-  double survivor_regions_evac_time = predict_survivor_regions_evac_time();
-  size_t pending_cards = _analytics->predict_pending_cards();
-  size_t adj_rs_lengths = rs_lengths + _analytics->predict_rs_length_diff();
-  size_t scanned_cards = _analytics->predict_card_num(adj_rs_lengths, /* gcs_are_young */ true);
-  double base_time_ms =
-    predict_base_elapsed_time_ms(pending_cards, scanned_cards) +
-    survivor_regions_evac_time;
-  uint available_free_regions = _free_regions_at_end_of_collection;
-  uint base_free_regions = 0;
-  if (available_free_regions > _reserve_regions) {
-    base_free_regions = available_free_regions - _reserve_regions;
-  }
-
-  // Here, we will make sure that the shortest young length that
-  // makes sense fits within the target pause time.
-
-  if (predict_will_fit(min_young_length, base_time_ms,
-                       base_free_regions, target_pause_time_ms)) {
-    // The shortest young length will fit into the target pause time;
-    // we'll now check whether the absolute maximum number of young
-    // regions will fit in the target pause time. If not, we'll do
-    // a binary search between min_young_length and max_young_length.
-    if (predict_will_fit(max_young_length, base_time_ms,
-                         base_free_regions, target_pause_time_ms)) {
-      // The maximum young length will fit into the target pause time.
-      // We are done so set min young length to the maximum length (as
-      // the result is assumed to be returned in min_young_length).
-      min_young_length = max_young_length;
-    } else {
-      // The maximum possible number of young regions will not fit within
-      // the target pause time so we'll search for the optimal
-      // length. The loop invariants are:
-      //
-      // min_young_length < max_young_length
-      // min_young_length is known to fit into the target pause time
-      // max_young_length is known not to fit into the target pause time
-      //
-      // Going into the loop we know the above hold as we've just
-      // checked them. Every time around the loop we check whether
-      // the middle value between min_young_length and
-      // max_young_length fits into the target pause time. If it
-      // does, it becomes the new min. If it doesn't, it becomes
-      // the new max. This way we maintain the loop invariants.
-
-      assert(min_young_length < max_young_length, "invariant");
-      uint diff = (max_young_length - min_young_length) / 2;
-      while (diff > 0) {
-        uint young_length = min_young_length + diff;
-        if (predict_will_fit(young_length, base_time_ms,
-                             base_free_regions, target_pause_time_ms)) {
-          min_young_length = young_length;
-        } else {
-          max_young_length = young_length;
-        }
-        assert(min_young_length <  max_young_length, "invariant");
-        diff = (max_young_length - min_young_length) / 2;
-      }
-      // The results is min_young_length which, according to the
-      // loop invariants, should fit within the target pause time.
-
-      // These are the post-conditions of the binary search above:
-      assert(min_young_length < max_young_length,
-             "otherwise we should have discovered that max_young_length "
-             "fits into the pause target and not done the binary search");
-      assert(predict_will_fit(min_young_length, base_time_ms,
-                              base_free_regions, target_pause_time_ms),
-             "min_young_length, the result of the binary search, should "
-             "fit into the pause target");
-      assert(!predict_will_fit(min_young_length + 1, base_time_ms,
-                               base_free_regions, target_pause_time_ms),
-             "min_young_length, the result of the binary search, should be "
-             "optimal, so no larger length should fit into the pause target");
-    }
-  } else {
-    // Even the minimum length doesn't fit into the pause time
-    // target, return it as the result nevertheless.
-  }
-  return base_min_length + min_young_length;
-}
-
-double G1CollectorPolicy::predict_survivor_regions_evac_time() const {
-  double survivor_regions_evac_time = 0.0;
-  for (HeapRegion * r = _g1->young_list()->first_survivor_region();
-       r != NULL && r != _g1->young_list()->last_survivor_region()->get_next_young_region();
-       r = r->get_next_young_region()) {
-    survivor_regions_evac_time += predict_region_elapsed_time_ms(r, collector_state()->gcs_are_young());
-  }
-  return survivor_regions_evac_time;
-}
-
-void G1CollectorPolicy::revise_young_list_target_length_if_necessary(size_t rs_lengths) {
-  guarantee( adaptive_young_list_length(), "should not call this otherwise" );
-
-  if (rs_lengths > _rs_lengths_prediction) {
-    // add 10% to avoid having to recalculate often
-    size_t rs_lengths_prediction = rs_lengths * 1100 / 1000;
-    update_rs_lengths_prediction(rs_lengths_prediction);
-
-    update_young_list_max_and_target_length(rs_lengths_prediction);
-  }
-}
-
-void G1CollectorPolicy::update_rs_lengths_prediction() {
-  update_rs_lengths_prediction(_analytics->predict_rs_lengths());
-}
-
-void G1CollectorPolicy::update_rs_lengths_prediction(size_t prediction) {
-  if (collector_state()->gcs_are_young() && adaptive_young_list_length()) {
-    _rs_lengths_prediction = prediction;
-  }
-}
-
-#ifndef PRODUCT
-bool G1CollectorPolicy::verify_young_ages() {
-  HeapRegion* head = _g1->young_list()->first_region();
-  return
-    verify_young_ages(head, _short_lived_surv_rate_group);
-  // also call verify_young_ages on any additional surv rate groups
-}
-
-bool
-G1CollectorPolicy::verify_young_ages(HeapRegion* head,
-                                     SurvRateGroup *surv_rate_group) {
-  guarantee( surv_rate_group != NULL, "pre-condition" );
-
-  const char* name = surv_rate_group->name();
-  bool ret = true;
-  int prev_age = -1;
-
-  for (HeapRegion* curr = head;
-       curr != NULL;
-       curr = curr->get_next_young_region()) {
-    SurvRateGroup* group = curr->surv_rate_group();
-    if (group == NULL && !curr->is_survivor()) {
-      log_error(gc, verify)("## %s: encountered NULL surv_rate_group", name);
-      ret = false;
-    }
-
-    if (surv_rate_group == group) {
-      int age = curr->age_in_surv_rate_group();
-
-      if (age < 0) {
-        log_error(gc, verify)("## %s: encountered negative age", name);
-        ret = false;
-      }
-
-      if (age <= prev_age) {
-        log_error(gc, verify)("## %s: region ages are not strictly increasing (%d, %d)", name, age, prev_age);
-        ret = false;
-      }
-      prev_age = age;
-    }
-  }
-
-  return ret;
-}
-#endif // PRODUCT
-
-void G1CollectorPolicy::record_full_collection_start() {
-  _full_collection_start_sec = os::elapsedTime();
-  // Release the future to-space so that it is available for compaction into.
-  collector_state()->set_full_collection(true);
-}
-
-void G1CollectorPolicy::record_full_collection_end() {
-  // Consider this like a collection pause for the purposes of allocation
-  // since last pause.
-  double end_sec = os::elapsedTime();
-  double full_gc_time_sec = end_sec - _full_collection_start_sec;
-  double full_gc_time_ms = full_gc_time_sec * 1000.0;
-
-  _analytics->update_recent_gc_times(end_sec, full_gc_time_ms);
-
-  collector_state()->set_full_collection(false);
-
-  // "Nuke" the heuristics that control the young/mixed GC
-  // transitions and make sure we start with young GCs after the Full GC.
-  collector_state()->set_gcs_are_young(true);
-  collector_state()->set_last_young_gc(false);
-  collector_state()->set_initiate_conc_mark_if_possible(need_to_start_conc_mark("end of Full GC", 0));
-  collector_state()->set_during_initial_mark_pause(false);
-  collector_state()->set_in_marking_window(false);
-  collector_state()->set_in_marking_window_im(false);
-
-  _short_lived_surv_rate_group->start_adding_regions();
-  // also call this on any additional surv rate groups
-
-  _free_regions_at_end_of_collection = _g1->num_free_regions();
-  // Reset survivors SurvRateGroup.
-  _survivor_surv_rate_group->reset();
-  update_young_list_max_and_target_length();
-  update_rs_lengths_prediction();
-  cset_chooser()->clear();
-
-  _bytes_allocated_in_old_since_last_gc = 0;
-
-  record_pause(FullGC, _full_collection_start_sec, end_sec);
-}
-
-void G1CollectorPolicy::record_collection_pause_start(double start_time_sec) {
-  // We only need to do this here as the policy will only be applied
-  // to the GC we're about to start. so, no point is calculating this
-  // every time we calculate / recalculate the target young length.
-  update_survivors_policy();
-
-  assert(_g1->used() == _g1->recalculate_used(),
-         "sanity, used: " SIZE_FORMAT " recalculate_used: " SIZE_FORMAT,
-         _g1->used(), _g1->recalculate_used());
-
-  phase_times()->record_cur_collection_start_sec(start_time_sec);
-  _pending_cards = _g1->pending_card_num();
-
-  _collection_set->reset_bytes_used_before();
-  _bytes_copied_during_gc = 0;
-
-  collector_state()->set_last_gc_was_young(false);
-
-  // do that for any other surv rate groups
-  _short_lived_surv_rate_group->stop_adding_regions();
-  _survivors_age_table.clear();
-
-  assert( verify_young_ages(), "region age verification" );
-}
-
-void G1CollectorPolicy::record_concurrent_mark_init_end(double
-                                                   mark_init_elapsed_time_ms) {
-  collector_state()->set_during_marking(true);
-  assert(!collector_state()->initiate_conc_mark_if_possible(), "we should have cleared it by now");
-  collector_state()->set_during_initial_mark_pause(false);
-}
-
-void G1CollectorPolicy::record_concurrent_mark_remark_start() {
-  _mark_remark_start_sec = os::elapsedTime();
-  collector_state()->set_during_marking(false);
-}
-
-void G1CollectorPolicy::record_concurrent_mark_remark_end() {
-  double end_time_sec = os::elapsedTime();
-  double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0;
-  _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms);
-  _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms);
-
-  record_pause(Remark, _mark_remark_start_sec, end_time_sec);
-}
-
-void G1CollectorPolicy::record_concurrent_mark_cleanup_start() {
-  _mark_cleanup_start_sec = os::elapsedTime();
-}
-
-void G1CollectorPolicy::record_concurrent_mark_cleanup_completed() {
-  bool should_continue_with_reclaim = next_gc_should_be_mixed("request last young-only gc",
-                                                              "skip last young-only gc");
-  collector_state()->set_last_young_gc(should_continue_with_reclaim);
-  // We skip the marking phase.
-  if (!should_continue_with_reclaim) {
-    abort_time_to_mixed_tracking();
-  }
-  collector_state()->set_in_marking_window(false);
-}
-
-double G1CollectorPolicy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const {
-  return phase_times()->average_time_ms(phase);
-}
-
-double G1CollectorPolicy::young_other_time_ms() const {
-  return phase_times()->young_cset_choice_time_ms() +
-         phase_times()->young_free_cset_time_ms();
-}
-
-double G1CollectorPolicy::non_young_other_time_ms() const {
-  return phase_times()->non_young_cset_choice_time_ms() +
-         phase_times()->non_young_free_cset_time_ms();
-
-}
-
-double G1CollectorPolicy::other_time_ms(double pause_time_ms) const {
-  return pause_time_ms -
-         average_time_ms(G1GCPhaseTimes::UpdateRS) -
-         average_time_ms(G1GCPhaseTimes::ScanRS) -
-         average_time_ms(G1GCPhaseTimes::ObjCopy) -
-         average_time_ms(G1GCPhaseTimes::Termination);
-}
-
-double G1CollectorPolicy::constant_other_time_ms(double pause_time_ms) const {
-  return other_time_ms(pause_time_ms) - young_other_time_ms() - non_young_other_time_ms();
-}
-
-CollectionSetChooser* G1CollectorPolicy::cset_chooser() const {
-  return _collection_set->cset_chooser();
-}
-
-bool G1CollectorPolicy::about_to_start_mixed_phase() const {
-  return _g1->concurrent_mark()->cmThread()->during_cycle() || collector_state()->last_young_gc();
-}
-
-bool G1CollectorPolicy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) {
-  if (about_to_start_mixed_phase()) {
-    return false;
-  }
-
-  size_t marking_initiating_used_threshold = _ihop_control->get_conc_mark_start_threshold();
-
-  size_t cur_used_bytes = _g1->non_young_capacity_bytes();
-  size_t alloc_byte_size = alloc_word_size * HeapWordSize;
-  size_t marking_request_bytes = cur_used_bytes + alloc_byte_size;
-
-  bool result = false;
-  if (marking_request_bytes > marking_initiating_used_threshold) {
-    result = collector_state()->gcs_are_young() && !collector_state()->last_young_gc();
-    log_debug(gc, ergo, ihop)("%s occupancy: " SIZE_FORMAT "B allocation request: " SIZE_FORMAT "B threshold: " SIZE_FORMAT "B (%1.2f) source: %s",
-                              result ? "Request concurrent cycle initiation (occupancy higher than threshold)" : "Do not request concurrent cycle initiation (still doing mixed collections)",
-                              cur_used_bytes, alloc_byte_size, marking_initiating_used_threshold, (double) marking_initiating_used_threshold / _g1->capacity() * 100, source);
-  }
-
-  return result;
-}
-
-// Anything below that is considered to be zero
-#define MIN_TIMER_GRANULARITY 0.0000001
-
-void G1CollectorPolicy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) {
-  double end_time_sec = os::elapsedTime();
-
-  size_t cur_used_bytes = _g1->used();
-  assert(cur_used_bytes == _g1->recalculate_used(), "It should!");
-  bool last_pause_included_initial_mark = false;
-  bool update_stats = !_g1->evacuation_failed();
-
-  NOT_PRODUCT(_short_lived_surv_rate_group->print());
-
-  record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec);
-
-  last_pause_included_initial_mark = collector_state()->during_initial_mark_pause();
-  if (last_pause_included_initial_mark) {
-    record_concurrent_mark_init_end(0.0);
-  } else {
-    maybe_start_marking();
-  }
-
-  double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms());
-  if (app_time_ms < MIN_TIMER_GRANULARITY) {
-    // This usually happens due to the timer not having the required
-    // granularity. Some Linuxes are the usual culprits.
-    // We'll just set it to something (arbitrarily) small.
-    app_time_ms = 1.0;
-  }
-
-  if (update_stats) {
-    // We maintain the invariant that all objects allocated by mutator
-    // threads will be allocated out of eden regions. So, we can use
-    // the eden region number allocated since the previous GC to
-    // calculate the application's allocate rate. The only exception
-    // to that is humongous objects that are allocated separately. But
-    // given that humongous object allocations do not really affect
-    // either the pause's duration nor when the next pause will take
-    // place we can safely ignore them here.
-    uint regions_allocated = _collection_set->eden_region_length();
-    double alloc_rate_ms = (double) regions_allocated / app_time_ms;
-    _analytics->report_alloc_rate_ms(alloc_rate_ms);
-
-    double interval_ms =
-      (end_time_sec - _analytics->last_known_gc_end_time_sec()) * 1000.0;
-    _analytics->update_recent_gc_times(end_time_sec, pause_time_ms);
-    _analytics->compute_pause_time_ratio(interval_ms, pause_time_ms);
-  }
-
-  bool new_in_marking_window = collector_state()->in_marking_window();
-  bool new_in_marking_window_im = false;
-  if (last_pause_included_initial_mark) {
-    new_in_marking_window = true;
-    new_in_marking_window_im = true;
-  }
-
-  if (collector_state()->last_young_gc()) {
-    // This is supposed to to be the "last young GC" before we start
-    // doing mixed GCs. Here we decide whether to start mixed GCs or not.
-    assert(!last_pause_included_initial_mark, "The last young GC is not allowed to be an initial mark GC");
-
-    if (next_gc_should_be_mixed("start mixed GCs",
-                                "do not start mixed GCs")) {
-      collector_state()->set_gcs_are_young(false);
-    } else {
-      // We aborted the mixed GC phase early.
-      abort_time_to_mixed_tracking();
-    }
-
-    collector_state()->set_last_young_gc(false);
-  }
-
-  if (!collector_state()->last_gc_was_young()) {
-    // This is a mixed GC. Here we decide whether to continue doing
-    // mixed GCs or not.
-    if (!next_gc_should_be_mixed("continue mixed GCs",
-                                 "do not continue mixed GCs")) {
-      collector_state()->set_gcs_are_young(true);
-
-      maybe_start_marking();
-    }
-  }
-
-  _short_lived_surv_rate_group->start_adding_regions();
-  // Do that for any other surv rate groups
-
-  double scan_hcc_time_ms = ConcurrentG1Refine::hot_card_cache_enabled() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0;
-
-  if (update_stats) {
-    double cost_per_card_ms = 0.0;
-    if (_pending_cards > 0) {
-      cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms) / (double) _pending_cards;
-      _analytics->report_cost_per_card_ms(cost_per_card_ms);
-    }
-    _analytics->report_cost_scan_hcc(scan_hcc_time_ms);
-
-    double cost_per_entry_ms = 0.0;
-    if (cards_scanned > 10) {
-      cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned;
-      _analytics->report_cost_per_entry_ms(cost_per_entry_ms, collector_state()->last_gc_was_young());
-    }
-
-    if (_max_rs_lengths > 0) {
-      double cards_per_entry_ratio =
-        (double) cards_scanned / (double) _max_rs_lengths;
-      _analytics->report_cards_per_entry_ratio(cards_per_entry_ratio, collector_state()->last_gc_was_young());
-    }
-
-    // This is defensive. For a while _max_rs_lengths could get
-    // smaller than _recorded_rs_lengths which was causing
-    // rs_length_diff to get very large and mess up the RSet length
-    // predictions. The reason was unsafe concurrent updates to the
-    // _inc_cset_recorded_rs_lengths field which the code below guards
-    // against (see CR 7118202). This bug has now been fixed (see CR
-    // 7119027). However, I'm still worried that
-    // _inc_cset_recorded_rs_lengths might still end up somewhat
-    // inaccurate. The concurrent refinement thread calculates an
-    // RSet's length concurrently with other CR threads updating it
-    // which might cause it to calculate the length incorrectly (if,
-    // say, it's in mid-coarsening). So I'll leave in the defensive
-    // conditional below just in case.
-    size_t rs_length_diff = 0;
-    size_t recorded_rs_lengths = _collection_set->recorded_rs_lengths();
-    if (_max_rs_lengths > recorded_rs_lengths) {
-      rs_length_diff = _max_rs_lengths - recorded_rs_lengths;
-    }
-    _analytics->report_rs_length_diff((double) rs_length_diff);
-
-    size_t freed_bytes = heap_used_bytes_before_gc - cur_used_bytes;
-    size_t copied_bytes = _collection_set->bytes_used_before() - freed_bytes;
-    double cost_per_byte_ms = 0.0;
-
-    if (copied_bytes > 0) {
-      cost_per_byte_ms = average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes;
-      _analytics->report_cost_per_byte_ms(cost_per_byte_ms, collector_state()->in_marking_window());
-    }
-
-    if (_collection_set->young_region_length() > 0) {
-      _analytics->report_young_other_cost_per_region_ms(young_other_time_ms() /
-                                                        _collection_set->young_region_length());
-    }
-
-    if (_collection_set->old_region_length() > 0) {
-      _analytics->report_non_young_other_cost_per_region_ms(non_young_other_time_ms() /
-                                                            _collection_set->old_region_length());
-    }
-
-    _analytics->report_constant_other_time_ms(constant_other_time_ms(pause_time_ms));
-
-    _analytics->report_pending_cards((double) _pending_cards);
-    _analytics->report_rs_lengths((double) _max_rs_lengths);
-  }
-
-  collector_state()->set_in_marking_window(new_in_marking_window);
-  collector_state()->set_in_marking_window_im(new_in_marking_window_im);
-  _free_regions_at_end_of_collection = _g1->num_free_regions();
-  // IHOP control wants to know the expected young gen length if it were not
-  // restrained by the heap reserve. Using the actual length would make the
-  // prediction too small and the limit the young gen every time we get to the
-  // predicted target occupancy.
-  size_t last_unrestrained_young_length = update_young_list_max_and_target_length();
-  update_rs_lengths_prediction();
-
-  update_ihop_prediction(app_time_ms / 1000.0,
-                         _bytes_allocated_in_old_since_last_gc,
-                         last_unrestrained_young_length * HeapRegion::GrainBytes);
-  _bytes_allocated_in_old_since_last_gc = 0;
-
-  _ihop_control->send_trace_event(_g1->gc_tracer_stw());
-
-  // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
-  double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
-
-  if (update_rs_time_goal_ms < scan_hcc_time_ms) {
-    log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)."
-                                "Update RS time goal: %1.2fms Scan HCC time: %1.2fms",
-                                update_rs_time_goal_ms, scan_hcc_time_ms);
-
-    update_rs_time_goal_ms = 0;
-  } else {
-    update_rs_time_goal_ms -= scan_hcc_time_ms;
-  }
-  _g1->concurrent_g1_refine()->adjust(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms,
-                                      phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS),
-                                      update_rs_time_goal_ms);
-
-  cset_chooser()->verify();
-}
-
-G1IHOPControl* G1CollectorPolicy::create_ihop_control() const {
-  if (G1UseAdaptiveIHOP) {
-    return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent,
-                                     &_predictor,
-                                     G1ReservePercent,
-                                     G1HeapWastePercent);
-  } else {
-    return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent);
-  }
-}
-
-void G1CollectorPolicy::update_ihop_prediction(double mutator_time_s,
-                                               size_t mutator_alloc_bytes,
-                                               size_t young_gen_size) {
-  // Always try to update IHOP prediction. Even evacuation failures give information
-  // about e.g. whether to start IHOP earlier next time.
-
-  // Avoid using really small application times that might create samples with
-  // very high or very low values. They may be caused by e.g. back-to-back gcs.
-  double const min_valid_time = 1e-6;
-
-  bool report = false;
-
-  double marking_to_mixed_time = -1.0;
-  if (!collector_state()->last_gc_was_young() && _initial_mark_to_mixed.has_result()) {
-    marking_to_mixed_time = _initial_mark_to_mixed.last_marking_time();
-    assert(marking_to_mixed_time > 0.0,
-           "Initial mark to mixed time must be larger than zero but is %.3f",
-           marking_to_mixed_time);
-    if (marking_to_mixed_time > min_valid_time) {
-      _ihop_control->update_marking_length(marking_to_mixed_time);
-      report = true;
-    }
-  }
-
-  // As an approximation for the young gc promotion rates during marking we use
-  // all of them. In many applications there are only a few if any young gcs during
-  // marking, which makes any prediction useless. This increases the accuracy of the
-  // prediction.
-  if (collector_state()->last_gc_was_young() && mutator_time_s > min_valid_time) {
-    _ihop_control->update_allocation_info(mutator_time_s, mutator_alloc_bytes, young_gen_size);
-    report = true;
-  }
-
-  if (report) {
-    report_ihop_statistics();
-  }
-}
-
-void G1CollectorPolicy::report_ihop_statistics() {
-  _ihop_control->print();
-}
-
-void G1CollectorPolicy::print_phases() {
-  phase_times()->print();
-}
-
-double G1CollectorPolicy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const {
-  TruncatedSeq* seq = surv_rate_group->get_seq(age);
-  guarantee(seq->num() > 0, "There should be some young gen survivor samples available. Tried to access with age %d", age);
-  double pred = _predictor.get_new_prediction(seq);
-  if (pred > 1.0) {
-    pred = 1.0;
-  }
-  return pred;
-}
-
-double G1CollectorPolicy::predict_yg_surv_rate(int age) const {
-  return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
-}
-
-double G1CollectorPolicy::accum_yg_surv_rate_pred(int age) const {
-  return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
-}
-
-double G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards,
-                                                       size_t scanned_cards) const {
-  return
-    _analytics->predict_rs_update_time_ms(pending_cards) +
-    _analytics->predict_rs_scan_time_ms(scanned_cards, collector_state()->gcs_are_young()) +
-    _analytics->predict_constant_other_time_ms();
-}
-
-double G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards) const {
-  size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff();
-  size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->gcs_are_young());
-  return predict_base_elapsed_time_ms(pending_cards, card_num);
-}
-
-size_t G1CollectorPolicy::predict_bytes_to_copy(HeapRegion* hr) const {
-  size_t bytes_to_copy;
-  if (hr->is_marked())
-    bytes_to_copy = hr->max_live_bytes();
-  else {
-    assert(hr->is_young() && hr->age_in_surv_rate_group() != -1, "invariant");
-    int age = hr->age_in_surv_rate_group();
-    double yg_surv_rate = predict_yg_surv_rate(age, hr->surv_rate_group());
-    bytes_to_copy = (size_t) (hr->used() * yg_surv_rate);
-  }
-  return bytes_to_copy;
-}
-
-double G1CollectorPolicy::predict_region_elapsed_time_ms(HeapRegion* hr,
-                                                         bool for_young_gc) const {
-  size_t rs_length = hr->rem_set()->occupied();
-  // Predicting the number of cards is based on which type of GC
-  // we're predicting for.
-  size_t card_num = _analytics->predict_card_num(rs_length, for_young_gc);
-  size_t bytes_to_copy = predict_bytes_to_copy(hr);
-
-  double region_elapsed_time_ms =
-    _analytics->predict_rs_scan_time_ms(card_num, collector_state()->gcs_are_young()) +
-    _analytics->predict_object_copy_time_ms(bytes_to_copy, collector_state()->during_concurrent_mark());
-
-  // The prediction of the "other" time for this region is based
-  // upon the region type and NOT the GC type.
-  if (hr->is_young()) {
-    region_elapsed_time_ms += _analytics->predict_young_other_time_ms(1);
-  } else {
-    region_elapsed_time_ms += _analytics->predict_non_young_other_time_ms(1);
-  }
-  return region_elapsed_time_ms;
-}
-
-
-void G1CollectorPolicy::print_yg_surv_rate_info() const {
-#ifndef PRODUCT
-  _short_lived_surv_rate_group->print_surv_rate_summary();
-  // add this call for any other surv rate groups
-#endif // PRODUCT
-}
-
-bool G1CollectorPolicy::is_young_list_full() const {
-  uint young_list_length = _g1->young_list()->length();
-  uint young_list_target_length = _young_list_target_length;
-  return young_list_length >= young_list_target_length;
-}
-
-bool G1CollectorPolicy::can_expand_young_list() const {
-  uint young_list_length = _g1->young_list()->length();
-  uint young_list_max_length = _young_list_max_length;
-  return young_list_length < young_list_max_length;
-}
-
-bool G1CollectorPolicy::adaptive_young_list_length() const {
-  return _young_gen_sizer->adaptive_young_list_length();
-}
-
-void G1CollectorPolicy::update_max_gc_locker_expansion() {
-  uint expansion_region_num = 0;
-  if (GCLockerEdenExpansionPercent > 0) {
-    double perc = (double) GCLockerEdenExpansionPercent / 100.0;
-    double expansion_region_num_d = perc * (double) _young_list_target_length;
-    // We use ceiling so that if expansion_region_num_d is > 0.0 (but
-    // less than 1.0) we'll get 1.
-    expansion_region_num = (uint) ceil(expansion_region_num_d);
-  } else {
-    assert(expansion_region_num == 0, "sanity");
-  }
-  _young_list_max_length = _young_list_target_length + expansion_region_num;
-  assert(_young_list_target_length <= _young_list_max_length, "post-condition");
-}
-
-// Calculates survivor space parameters.
-void G1CollectorPolicy::update_survivors_policy() {
-  double max_survivor_regions_d =
-                 (double) _young_list_target_length / (double) SurvivorRatio;
-  // We use ceiling so that if max_survivor_regions_d is > 0.0 (but
-  // smaller than 1.0) we'll get 1.
-  _max_survivor_regions = (uint) ceil(max_survivor_regions_d);
-
-  _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(
-        HeapRegion::GrainWords * _max_survivor_regions, counters());
-}
-
-bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) {
-  // We actually check whether we are marking here and not if we are in a
-  // reclamation phase. This means that we will schedule a concurrent mark
-  // even while we are still in the process of reclaiming memory.
-  bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
-  if (!during_cycle) {
-    log_debug(gc, ergo)("Request concurrent cycle initiation (requested by GC cause). GC cause: %s", GCCause::to_string(gc_cause));
-    collector_state()->set_initiate_conc_mark_if_possible(true);
-    return true;
-  } else {
-    log_debug(gc, ergo)("Do not request concurrent cycle initiation (concurrent cycle already in progress). GC cause: %s", GCCause::to_string(gc_cause));
-    return false;
-  }
-}
-
-void G1CollectorPolicy::initiate_conc_mark() {
-  collector_state()->set_during_initial_mark_pause(true);
-  collector_state()->set_initiate_conc_mark_if_possible(false);
-}
-
-void G1CollectorPolicy::decide_on_conc_mark_initiation() {
-  // We are about to decide on whether this pause will be an
-  // initial-mark pause.
-
-  // First, collector_state()->during_initial_mark_pause() should not be already set. We
-  // will set it here if we have to. However, it should be cleared by
-  // the end of the pause (it's only set for the duration of an
-  // initial-mark pause).
-  assert(!collector_state()->during_initial_mark_pause(), "pre-condition");
-
-  if (collector_state()->initiate_conc_mark_if_possible()) {
-    // We had noticed on a previous pause that the heap occupancy has
-    // gone over the initiating threshold and we should start a
-    // concurrent marking cycle. So we might initiate one.
-
-    if (!about_to_start_mixed_phase() && collector_state()->gcs_are_young()) {
-      // Initiate a new initial mark if there is no marking or reclamation going on.
-      initiate_conc_mark();
-      log_debug(gc, ergo)("Initiate concurrent cycle (concurrent cycle initiation requested)");
-    } else if (_g1->is_user_requested_concurrent_full_gc(_g1->gc_cause())) {
-      // Initiate a user requested initial mark. An initial mark must be young only
-      // GC, so the collector state must be updated to reflect this.
-      collector_state()->set_gcs_are_young(true);
-      collector_state()->set_last_young_gc(false);
-
-      abort_time_to_mixed_tracking();
-      initiate_conc_mark();
-      log_debug(gc, ergo)("Initiate concurrent cycle (user requested concurrent cycle)");
-    } else {
-      // The concurrent marking thread is still finishing up the
-      // previous cycle. If we start one right now the two cycles
-      // overlap. In particular, the concurrent marking thread might
-      // be in the process of clearing the next marking bitmap (which
-      // we will use for the next cycle if we start one). Starting a
-      // cycle now will be bad given that parts of the marking
-      // information might get cleared by the marking thread. And we
-      // cannot wait for the marking thread to finish the cycle as it
-      // periodically yields while clearing the next marking bitmap
-      // and, if it's in a yield point, it's waiting for us to
-      // finish. So, at this point we will not start a cycle and we'll
-      // let the concurrent marking thread complete the last one.
-      log_debug(gc, ergo)("Do not initiate concurrent cycle (concurrent cycle already in progress)");
-    }
-  }
-}
-
-void G1CollectorPolicy::record_concurrent_mark_cleanup_end() {
-  cset_chooser()->rebuild(_g1->workers(), _g1->num_regions());
-
-  double end_sec = os::elapsedTime();
-  double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
-  _analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms);
-  _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms);
-
-  record_pause(Cleanup, _mark_cleanup_start_sec, end_sec);
-}
-
-double G1CollectorPolicy::reclaimable_bytes_perc(size_t reclaimable_bytes) const {
-  // Returns the given amount of reclaimable bytes (that represents
-  // the amount of reclaimable space still to be collected) as a
-  // percentage of the current heap capacity.
-  size_t capacity_bytes = _g1->capacity();
-  return (double) reclaimable_bytes * 100.0 / (double) capacity_bytes;
-}
-
-void G1CollectorPolicy::maybe_start_marking() {
-  if (need_to_start_conc_mark("end of GC")) {
-    // Note: this might have already been set, if during the last
-    // pause we decided to start a cycle but at the beginning of
-    // this pause we decided to postpone it. That's OK.
-    collector_state()->set_initiate_conc_mark_if_possible(true);
-  }
-}
-
-G1CollectorPolicy::PauseKind G1CollectorPolicy::young_gc_pause_kind() const {
-  assert(!collector_state()->full_collection(), "must be");
-  if (collector_state()->during_initial_mark_pause()) {
-    assert(collector_state()->last_gc_was_young(), "must be");
-    assert(!collector_state()->last_young_gc(), "must be");
-    return InitialMarkGC;
-  } else if (collector_state()->last_young_gc()) {
-    assert(!collector_state()->during_initial_mark_pause(), "must be");
-    assert(collector_state()->last_gc_was_young(), "must be");
-    return LastYoungGC;
-  } else if (!collector_state()->last_gc_was_young()) {
-    assert(!collector_state()->during_initial_mark_pause(), "must be");
-    assert(!collector_state()->last_young_gc(), "must be");
-    return MixedGC;
-  } else {
-    assert(collector_state()->last_gc_was_young(), "must be");
-    assert(!collector_state()->during_initial_mark_pause(), "must be");
-    assert(!collector_state()->last_young_gc(), "must be");
-    return YoungOnlyGC;
-  }
-}
-
-void G1CollectorPolicy::record_pause(PauseKind kind, double start, double end) {
-  // Manage the MMU tracker. For some reason it ignores Full GCs.
-  if (kind != FullGC) {
-    _mmu_tracker->add_pause(start, end);
-  }
-  // Manage the mutator time tracking from initial mark to first mixed gc.
-  switch (kind) {
-    case FullGC:
-      abort_time_to_mixed_tracking();
-      break;
-    case Cleanup:
-    case Remark:
-    case YoungOnlyGC:
-    case LastYoungGC:
-      _initial_mark_to_mixed.add_pause(end - start);
-      break;
-    case InitialMarkGC:
-      _initial_mark_to_mixed.record_initial_mark_end(end);
-      break;
-    case MixedGC:
-      _initial_mark_to_mixed.record_mixed_gc_start(start);
-      break;
-    default:
-      ShouldNotReachHere();
-  }
-}
-
-void G1CollectorPolicy::abort_time_to_mixed_tracking() {
-  _initial_mark_to_mixed.reset();
-}
-
-bool G1CollectorPolicy::next_gc_should_be_mixed(const char* true_action_str,
-                                                const char* false_action_str) const {
-  if (cset_chooser()->is_empty()) {
-    log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str);
-    return false;
-  }
-
-  // Is the amount of uncollected reclaimable space above G1HeapWastePercent?
-  size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes();
-  double reclaimable_perc = reclaimable_bytes_perc(reclaimable_bytes);
-  double threshold = (double) G1HeapWastePercent;
-  if (reclaimable_perc <= threshold) {
-    log_debug(gc, ergo)("%s (reclaimable percentage not over threshold). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT,
-                        false_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
-    return false;
-  }
-  log_debug(gc, ergo)("%s (candidate old regions available). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT,
-                      true_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
-  return true;
-}
-
-uint G1CollectorPolicy::calc_min_old_cset_length() const {
-  // The min old CSet region bound is based on the maximum desired
-  // number of mixed GCs after a cycle. I.e., even if some old regions
-  // look expensive, we should add them to the CSet anyway to make
-  // sure we go through the available old regions in no more than the
-  // maximum desired number of mixed GCs.
-  //
-  // The calculation is based on the number of marked regions we added
-  // to the CSet chooser in the first place, not how many remain, so
-  // that the result is the same during all mixed GCs that follow a cycle.
-
-  const size_t region_num = (size_t) cset_chooser()->length();
-  const size_t gc_num = (size_t) MAX2(G1MixedGCCountTarget, (uintx) 1);
-  size_t result = region_num / gc_num;
-  // emulate ceiling
-  if (result * gc_num < region_num) {
-    result += 1;
-  }
-  return (uint) result;
-}
-
-uint G1CollectorPolicy::calc_max_old_cset_length() const {
-  // The max old CSet region bound is based on the threshold expressed
-  // as a percentage of the heap size. I.e., it should bound the
-  // number of old regions added to the CSet irrespective of how many
-  // of them are available.
-
-  const G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  const size_t region_num = g1h->num_regions();
-  const size_t perc = (size_t) G1OldCSetRegionThresholdPercent;
-  size_t result = region_num * perc / 100;
-  // emulate ceiling
-  if (100 * result < region_num * perc) {
-    result += 1;
-  }
-  return (uint) result;
-}
-
-void G1CollectorPolicy::finalize_collection_set(double target_pause_time_ms) {
-  double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms);
-  _collection_set->finalize_old_part(time_remaining_ms);
-}
diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp
index 0139639..6e58448 100644
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp
@@ -25,419 +25,19 @@
 #ifndef SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP
 #define SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP
 
-#include "gc/g1/g1CollectorState.hpp"
-#include "gc/g1/g1GCPhaseTimes.hpp"
-#include "gc/g1/g1InCSetState.hpp"
-#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp"
-#include "gc/g1/g1MMUTracker.hpp"
-#include "gc/g1/g1Predictions.hpp"
 #include "gc/shared/collectorPolicy.hpp"
-#include "utilities/pair.hpp"
 
-// A G1CollectorPolicy makes policy decisions that determine the
-// characteristics of the collector.  Examples include:
-//   * choice of collection set.
-//   * when to collect.
+// G1CollectorPolicy is primarily used during initialization and to expose the
+// functionality of the CollectorPolicy interface to the rest of the VM.
 
-class HeapRegion;
-class G1CollectionSet;
-class CollectionSetChooser;
-class G1IHOPControl;
-class G1Analytics;
 class G1YoungGenSizer;
 
 class G1CollectorPolicy: public CollectorPolicy {
- private:
-  G1IHOPControl* _ihop_control;
-
-  G1IHOPControl* create_ihop_control() const;
-  // Update the IHOP control with necessary statistics.
-  void update_ihop_prediction(double mutator_time_s,
-                              size_t mutator_alloc_bytes,
-                              size_t young_gen_size);
-  void report_ihop_statistics();
-
-  G1Predictions _predictor;
-  G1Analytics* _analytics;
-  G1MMUTracker* _mmu_tracker;
-
-  void initialize_alignments();
-  void initialize_flags();
-
-  double _full_collection_start_sec;
-
-  uint _young_list_target_length;
-  uint _young_list_fixed_length;
-
-  // The max number of regions we can extend the eden by while the GC
-  // locker is active. This should be >= _young_list_target_length;
-  uint _young_list_max_length;
-
-  SurvRateGroup* _short_lived_surv_rate_group;
-  SurvRateGroup* _survivor_surv_rate_group;
-
-  double _reserve_factor;
-  uint   _reserve_regions;
-
-  G1YoungGenSizer* _young_gen_sizer;
-
-  uint _free_regions_at_end_of_collection;
-
-  size_t _max_rs_lengths;
-
-  size_t _rs_lengths_prediction;
-
-#ifndef PRODUCT
-  bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group);
-#endif // PRODUCT
-
-  double _pause_time_target_ms;
-
-  size_t _pending_cards;
-
-  // The amount of allocated bytes in old gen during the last mutator and the following
-  // young GC phase.
-  size_t _bytes_allocated_in_old_since_last_gc;
-
-  G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed;
-public:
-  const G1Predictions& predictor() const { return _predictor; }
-  const G1Analytics* analytics()   const { return const_cast<const G1Analytics*>(_analytics); }
-
-  // Add the given number of bytes to the total number of allocated bytes in the old gen.
-  void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; }
-
-  // Accessors
-
-  void set_region_eden(HeapRegion* hr, int young_index_in_cset) {
-    hr->set_eden();
-    hr->install_surv_rate_group(_short_lived_surv_rate_group);
-    hr->set_young_index_in_cset(young_index_in_cset);
-  }
-
-  void set_region_survivor(HeapRegion* hr, int young_index_in_cset) {
-    assert(hr->is_survivor(), "pre-condition");
-    hr->install_surv_rate_group(_survivor_surv_rate_group);
-    hr->set_young_index_in_cset(young_index_in_cset);
-  }
-
-#ifndef PRODUCT
-  bool verify_young_ages();
-#endif // PRODUCT
-
-  void record_max_rs_lengths(size_t rs_lengths) {
-    _max_rs_lengths = rs_lengths;
-  }
-
-
-  double predict_base_elapsed_time_ms(size_t pending_cards) const;
-  double predict_base_elapsed_time_ms(size_t pending_cards,
-                                      size_t scanned_cards) const;
-  size_t predict_bytes_to_copy(HeapRegion* hr) const;
-  double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const;
-
-  double predict_survivor_regions_evac_time() const;
-
-  bool should_update_surv_rate_group_predictors() {
-    return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window();
-  }
-
-  void cset_regions_freed() {
-    bool update = should_update_surv_rate_group_predictors();
-
-    _short_lived_surv_rate_group->all_surviving_words_recorded(update);
-    _survivor_surv_rate_group->all_surviving_words_recorded(update);
-  }
-
-  G1MMUTracker* mmu_tracker() {
-    return _mmu_tracker;
-  }
-
-  const G1MMUTracker* mmu_tracker() const {
-    return _mmu_tracker;
-  }
-
-  double max_pause_time_ms() const {
-    return _mmu_tracker->max_gc_time() * 1000.0;
-  }
-
-  // Returns an estimate of the survival rate of the region at yg-age
-  // "yg_age".
-  double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const;
-
-  double predict_yg_surv_rate(int age) const;
-
-  double accum_yg_surv_rate_pred(int age) const;
-
 protected:
-  G1CollectionSet* _collection_set;
-  virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const;
-  virtual double other_time_ms(double pause_time_ms) const;
-
-  double young_other_time_ms() const;
-  double non_young_other_time_ms() const;
-  double constant_other_time_ms(double pause_time_ms) const;
-
-  CollectionSetChooser* cset_chooser() const;
-private:
-
-  // The number of bytes copied during the GC.
-  size_t _bytes_copied_during_gc;
-
-  // Stash a pointer to the g1 heap.
-  G1CollectedHeap* _g1;
-
-  G1GCPhaseTimes* _phase_times;
-
-  // This set of variables tracks the collector efficiency, in order to
-  // determine whether we should initiate a new marking.
-  double _mark_remark_start_sec;
-  double _mark_cleanup_start_sec;
-
-  // Updates the internal young list maximum and target lengths. Returns the
-  // unbounded young list target length.
-  uint update_young_list_max_and_target_length();
-  uint update_young_list_max_and_target_length(size_t rs_lengths);
-
-  // Update the young list target length either by setting it to the
-  // desired fixed value or by calculating it using G1's pause
-  // prediction model. If no rs_lengths parameter is passed, predict
-  // the RS lengths using the prediction model, otherwise use the
-  // given rs_lengths as the prediction.
-  // Returns the unbounded young list target length.
-  uint update_young_list_target_length(size_t rs_lengths);
-
-  // Calculate and return the minimum desired young list target
-  // length. This is the minimum desired young list length according
-  // to the user's inputs.
-  uint calculate_young_list_desired_min_length(uint base_min_length) const;
-
-  // Calculate and return the maximum desired young list target
-  // length. This is the maximum desired young list length according
-  // to the user's inputs.
-  uint calculate_young_list_desired_max_length() const;
-
-  // Calculate and return the maximum young list target length that
-  // can fit into the pause time goal. The parameters are: rs_lengths
-  // represent the prediction of how large the young RSet lengths will
-  // be, base_min_length is the already existing number of regions in
-  // the young list, min_length and max_length are the desired min and
-  // max young list length according to the user's inputs.
-  uint calculate_young_list_target_length(size_t rs_lengths,
-                                          uint base_min_length,
-                                          uint desired_min_length,
-                                          uint desired_max_length) const;
-
-  // Result of the bounded_young_list_target_length() method, containing both the
-  // bounded as well as the unbounded young list target lengths in this order.
-  typedef Pair<uint, uint, StackObj> YoungTargetLengths;
-  YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const;
-
-  void update_rs_lengths_prediction();
-  void update_rs_lengths_prediction(size_t prediction);
-
-  // Check whether a given young length (young_length) fits into the
-  // given target pause time and whether the prediction for the amount
-  // of objects to be copied for the given length will fit into the
-  // given free space (expressed by base_free_regions).  It is used by
-  // calculate_young_list_target_length().
-  bool predict_will_fit(uint young_length, double base_time_ms,
-                        uint base_free_regions, double target_pause_time_ms) const;
+  void initialize_alignments();
 
 public:
-  size_t pending_cards() const { return _pending_cards; }
-
-  // Calculate the minimum number of old regions we'll add to the CSet
-  // during a mixed GC.
-  uint calc_min_old_cset_length() const;
-
-  // Calculate the maximum number of old regions we'll add to the CSet
-  // during a mixed GC.
-  uint calc_max_old_cset_length() const;
-
-  // Returns the given amount of uncollected reclaimable space
-  // as a percentage of the current heap capacity.
-  double reclaimable_bytes_perc(size_t reclaimable_bytes) const;
-
-private:
-  // Sets up marking if proper conditions are met.
-  void maybe_start_marking();
-
-  // The kind of STW pause.
-  enum PauseKind {
-    FullGC,
-    YoungOnlyGC,
-    MixedGC,
-    LastYoungGC,
-    InitialMarkGC,
-    Cleanup,
-    Remark
-  };
-
-  // Calculate PauseKind from internal state.
-  PauseKind young_gc_pause_kind() const;
-  // Record the given STW pause with the given start and end times (in s).
-  void record_pause(PauseKind kind, double start, double end);
-  // Indicate that we aborted marking before doing any mixed GCs.
-  void abort_time_to_mixed_tracking();
-public:
-
   G1CollectorPolicy();
-
-  virtual ~G1CollectorPolicy();
-
-  virtual G1CollectorPolicy* as_g1_policy() { return this; }
-
-  G1CollectorState* collector_state() const;
-
-  G1GCPhaseTimes* phase_times() const { return _phase_times; }
-
-  // Check the current value of the young list RSet lengths and
-  // compare it against the last prediction. If the current value is
-  // higher, recalculate the young list target length prediction.
-  void revise_young_list_target_length_if_necessary(size_t rs_lengths);
-
-  // This should be called after the heap is resized.
-  void record_new_heap_size(uint new_number_of_regions);
-
-  void init();
-
-  virtual void note_gc_start();
-
-  // Create jstat counters for the policy.
-  virtual void initialize_gc_policy_counters();
-
-  bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0);
-
-  bool about_to_start_mixed_phase() const;
-
-  // Record the start and end of an evacuation pause.
-  void record_collection_pause_start(double start_time_sec);
-  void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc);
-
-  // Record the start and end of a full collection.
-  void record_full_collection_start();
-  void record_full_collection_end();
-
-  // Must currently be called while the world is stopped.
-  void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms);
-
-  // Record start and end of remark.
-  void record_concurrent_mark_remark_start();
-  void record_concurrent_mark_remark_end();
-
-  // Record start, end, and completion of cleanup.
-  void record_concurrent_mark_cleanup_start();
-  void record_concurrent_mark_cleanup_end();
-  void record_concurrent_mark_cleanup_completed();
-
-  virtual void print_phases();
-
-  // Record how much space we copied during a GC. This is typically
-  // called when a GC alloc region is being retired.
-  void record_bytes_copied_during_gc(size_t bytes) {
-    _bytes_copied_during_gc += bytes;
-  }
-
-  // The amount of space we copied during a GC.
-  size_t bytes_copied_during_gc() const {
-    return _bytes_copied_during_gc;
-  }
-
-  // Determine whether there are candidate regions so that the
-  // next GC should be mixed. The two action strings are used
-  // in the ergo output when the method returns true or false.
-  bool next_gc_should_be_mixed(const char* true_action_str,
-                               const char* false_action_str) const;
-
-  virtual void finalize_collection_set(double target_pause_time_ms);
-private:
-  // Set the state to start a concurrent marking cycle and clear
-  // _initiate_conc_mark_if_possible because it has now been
-  // acted on.
-  void initiate_conc_mark();
-
-public:
-  // This sets the initiate_conc_mark_if_possible() flag to start a
-  // new cycle, as long as we are not already in one. It's best if it
-  // is called during a safepoint when the test whether a cycle is in
-  // progress or not is stable.
-  bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause);
-
-  // This is called at the very beginning of an evacuation pause (it
-  // has to be the first thing that the pause does). If
-  // initiate_conc_mark_if_possible() is true, and the concurrent
-  // marking thread has completed its work during the previous cycle,
-  // it will set during_initial_mark_pause() to so that the pause does
-  // the initial-mark work and start a marking cycle.
-  void decide_on_conc_mark_initiation();
-
-  // Print stats on young survival ratio
-  void print_yg_surv_rate_info() const;
-
-  void finished_recalculating_age_indexes(bool is_survivors) {
-    if (is_survivors) {
-      _survivor_surv_rate_group->finished_recalculating_age_indexes();
-    } else {
-      _short_lived_surv_rate_group->finished_recalculating_age_indexes();
-    }
-  }
-
-  size_t young_list_target_length() const { return _young_list_target_length; }
-
-  bool is_young_list_full() const;
-
-  bool can_expand_young_list() const;
-
-  uint young_list_max_length() const {
-    return _young_list_max_length;
-  }
-
-  bool adaptive_young_list_length() const;
-
-  virtual bool should_process_references() const {
-    return true;
-  }
-
-private:
-  //
-  // Survivor regions policy.
-  //
-
-  // Current tenuring threshold, set to 0 if the collector reaches the
-  // maximum amount of survivors regions.
-  uint _tenuring_threshold;
-
-  // The limit on the number of regions allocated for survivors.
-  uint _max_survivor_regions;
-
-  AgeTable _survivors_age_table;
-
-public:
-  uint tenuring_threshold() const { return _tenuring_threshold; }
-
-  uint max_survivor_regions() {
-    return _max_survivor_regions;
-  }
-
-  void note_start_adding_survivor_regions() {
-    _survivor_surv_rate_group->start_adding_regions();
-  }
-
-  void note_stop_adding_survivor_regions() {
-    _survivor_surv_rate_group->stop_adding_regions();
-  }
-
-  void record_age_table(AgeTable* age_table) {
-    _survivors_age_table.merge(age_table);
-  }
-
-  void update_max_gc_locker_expansion();
-
-  // Calculates survivor space parameters.
-  void update_survivors_policy();
-
-  virtual void post_heap_initialize();
 };
 
 #endif // SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP
diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp
index b36583e..a409304 100644
--- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp
@@ -28,12 +28,12 @@
 #include "code/codeCache.hpp"
 #include "gc/g1/concurrentMarkThread.inline.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1CollectorState.hpp"
 #include "gc/g1/g1ConcurrentMark.inline.hpp"
 #include "gc/g1/g1HeapVerifier.hpp"
 #include "gc/g1/g1OopClosures.inline.hpp"
 #include "gc/g1/g1CardLiveData.inline.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1StringDedup.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
@@ -57,6 +57,7 @@
 #include "runtime/java.hpp"
 #include "runtime/prefetch.inline.hpp"
 #include "services/memTracker.hpp"
+#include "utilities/growableArray.hpp"
 
 // Concurrent marking bit map wrapper
 
@@ -109,8 +110,7 @@
   _bmStartWord = heap.start();
   _bmWordSize = heap.word_size();
 
-  _bm.set_map((BitMap::bm_word_t*) storage->reserved().start());
-  _bm.set_size(_bmWordSize >> _shifter);
+  _bm = BitMapView((BitMap::bm_word_t*) storage->reserved().start(), _bmWordSize >> _shifter);
 
   storage->set_mapping_changed_listener(&_listener);
 }
@@ -260,11 +260,11 @@
 }
 
 G1CMRootRegions::G1CMRootRegions() :
-  _young_list(NULL), _cm(NULL), _scan_in_progress(false),
-  _should_abort(false),  _next_survivor(NULL) { }
+  _cm(NULL), _scan_in_progress(false),
+  _should_abort(false), _claimed_survivor_index(0) { }
 
-void G1CMRootRegions::init(G1CollectedHeap* g1h, G1ConcurrentMark* cm) {
-  _young_list = g1h->young_list();
+void G1CMRootRegions::init(const G1SurvivorRegions* survivors, G1ConcurrentMark* cm) {
+  _survivors = survivors;
   _cm = cm;
 }
 
@@ -272,9 +272,8 @@
   assert(!scan_in_progress(), "pre-condition");
 
   // Currently, only survivors can be root regions.
-  assert(_next_survivor == NULL, "pre-condition");
-  _next_survivor = _young_list->first_survivor_region();
-  _scan_in_progress = (_next_survivor != NULL);
+  _claimed_survivor_index = 0;
+  _scan_in_progress = _survivors->regions()->is_nonempty();
   _should_abort = false;
 }
 
@@ -286,27 +285,17 @@
   }
 
   // Currently, only survivors can be root regions.
-  HeapRegion* res = _next_survivor;
-  if (res != NULL) {
-    MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag);
-    // Read it again in case it changed while we were waiting for the lock.
-    res = _next_survivor;
-    if (res != NULL) {
-      if (res == _young_list->last_survivor_region()) {
-        // We just claimed the last survivor so store NULL to indicate
-        // that we're done.
-        _next_survivor = NULL;
-      } else {
-        _next_survivor = res->get_next_young_region();
-      }
-    } else {
-      // Someone else claimed the last survivor while we were trying
-      // to take the lock so nothing else to do.
-    }
-  }
-  assert(res == NULL || res->is_survivor(), "post-condition");
+  const GrowableArray<HeapRegion*>* survivor_regions = _survivors->regions();
 
-  return res;
+  int claimed_index = Atomic::add(1, &_claimed_survivor_index) - 1;
+  if (claimed_index < survivor_regions->length()) {
+    return survivor_regions->at(claimed_index);
+  }
+  return NULL;
+}
+
+uint G1CMRootRegions::num_root_regions() const {
+  return (uint)_survivors->regions()->length();
 }
 
 void G1CMRootRegions::notify_scan_done() {
@@ -324,9 +313,11 @@
 
   // Currently, only survivors can be root regions.
   if (!_should_abort) {
-    assert(_next_survivor == NULL, "we should have claimed all survivors");
+    assert(_claimed_survivor_index >= 0, "otherwise comparison is invalid: %d", _claimed_survivor_index);
+    assert((uint)_claimed_survivor_index >= _survivors->length(),
+           "we should have claimed all survivors, claimed index = %u, length = %u",
+           (uint)_claimed_survivor_index, _survivors->length());
   }
-  _next_survivor = NULL;
 
   notify_scan_done();
 }
@@ -407,7 +398,7 @@
   SATBMarkQueueSet& satb_qs = JavaThread::satb_mark_queue_set();
   satb_qs.set_buffer_size(G1SATBBufferSize);
 
-  _root_regions.init(_g1h, this);
+  _root_regions.init(_g1h->survivor(), this);
 
   if (ConcGCThreads > ParallelGCThreads) {
     log_warning(gc)("Can't have more ConcGCThreads (%u) than ParallelGCThreads (%u).",
@@ -609,6 +600,10 @@
 }
 
 class G1ClearBitMapTask : public AbstractGangTask {
+public:
+  static size_t chunk_size() { return M; }
+
+private:
   // Heap region closure used for clearing the given mark bitmap.
   class G1ClearBitmapHRClosure : public HeapRegionClosure {
   private:
@@ -619,7 +614,7 @@
     }
 
     virtual bool doHeapRegion(HeapRegion* r) {
-      size_t const chunk_size_in_words = M / HeapWordSize;
+      size_t const chunk_size_in_words = G1ClearBitMapTask::chunk_size() / HeapWordSize;
 
       HeapWord* cur = r->bottom();
       HeapWord* const end = r->end();
@@ -653,7 +648,7 @@
 
 public:
   G1ClearBitMapTask(G1CMBitMap* bitmap, G1ConcurrentMark* cm, uint n_workers, bool suspendible) :
-    AbstractGangTask("Parallel Clear Bitmap Task"),
+    AbstractGangTask("G1 Clear Bitmap"),
     _cl(bitmap, suspendible ? cm : NULL),
     _hr_claimer(n_workers),
     _suspendible(suspendible)
@@ -672,9 +667,16 @@
 void G1ConcurrentMark::clear_bitmap(G1CMBitMap* bitmap, WorkGang* workers, bool may_yield) {
   assert(may_yield || SafepointSynchronize::is_at_safepoint(), "Non-yielding bitmap clear only allowed at safepoint.");
 
-  G1ClearBitMapTask task(bitmap, this, workers->active_workers(), may_yield);
-  workers->run_task(&task);
-  guarantee(!may_yield || task.is_complete(), "Must have completed iteration when not yielding.");
+  size_t const num_bytes_to_clear = (HeapRegion::GrainBytes * _g1h->num_regions()) / G1CMBitMap::heap_map_factor();
+  size_t const num_chunks = align_size_up(num_bytes_to_clear, G1ClearBitMapTask::chunk_size()) / G1ClearBitMapTask::chunk_size();
+
+  uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers());
+
+  G1ClearBitMapTask cl(bitmap, this, num_workers, may_yield);
+
+  log_debug(gc, ergo)("Running %s with %u workers for " SIZE_FORMAT " work units.", cl.name(), num_workers, num_chunks);
+  workers->run_task(&cl, num_workers);
+  guarantee(!may_yield || cl.is_complete(), "Must have completed iteration when not yielding.");
 }
 
 void G1ConcurrentMark::cleanup_for_next_mark() {
@@ -739,8 +741,8 @@
 };
 
 void G1ConcurrentMark::checkpointRootsInitialPre() {
-  G1CollectedHeap*   g1h = G1CollectedHeap::heap();
-  G1CollectorPolicy* g1p = g1h->g1_policy();
+  G1CollectedHeap* g1h = G1CollectedHeap::heap();
+  G1Policy* g1p = g1h->g1_policy();
 
   _has_aborted = false;
 
@@ -914,15 +916,16 @@
     n_conc_workers = max_parallel_marking_threads();
   } else {
     n_conc_workers =
-      AdaptiveSizePolicy::calc_default_active_workers(
-                                   max_parallel_marking_threads(),
-                                   1, /* Minimum workers */
-                                   parallel_marking_threads(),
-                                   Threads::number_of_non_daemon_threads());
+      AdaptiveSizePolicy::calc_default_active_workers(max_parallel_marking_threads(),
+                                                      1, /* Minimum workers */
+                                                      parallel_marking_threads(),
+                                                      Threads::number_of_non_daemon_threads());
     // Don't scale down "n_conc_workers" by scale_parallel_threads() because
     // that scaling has already gone into "_max_parallel_marking_threads".
   }
-  assert(n_conc_workers > 0, "Always need at least 1");
+  assert(n_conc_workers > 0 && n_conc_workers <= max_parallel_marking_threads(),
+         "Calculated number of workers must be larger than zero and at most the maximum %u, but is %u",
+         max_parallel_marking_threads(), n_conc_workers);
   return n_conc_workers;
 }
 
@@ -949,7 +952,7 @@
 
 public:
   G1CMRootRegionScanTask(G1ConcurrentMark* cm) :
-    AbstractGangTask("Root Region Scan"), _cm(cm) { }
+    AbstractGangTask("G1 Root Region Scan"), _cm(cm) { }
 
   void work(uint worker_id) {
     assert(Thread::current()->is_ConcurrentGC_thread(),
@@ -971,14 +974,17 @@
   if (root_regions()->scan_in_progress()) {
     assert(!has_aborted(), "Aborting before root region scanning is finished not supported.");
 
-    _parallel_marking_threads = calc_parallel_marking_threads();
+    _parallel_marking_threads = MIN2(calc_parallel_marking_threads(),
+                                     // We distribute work on a per-region basis, so starting
+                                     // more threads than that is useless.
+                                     root_regions()->num_root_regions());
     assert(parallel_marking_threads() <= max_parallel_marking_threads(),
            "Maximum number of marking threads exceeded");
-    uint active_workers = MAX2(1U, parallel_marking_threads());
 
     G1CMRootRegionScanTask task(this);
-    _parallel_workers->set_active_workers(active_workers);
-    _parallel_workers->run_task(&task);
+    log_debug(gc, ergo)("Running %s using %u workers for %u work units.",
+                        task.name(), _parallel_marking_threads, root_regions()->num_root_regions());
+    _parallel_workers->run_task(&task, _parallel_marking_threads);
 
     // It's possible that has_aborted() is true here without actually
     // aborting the survivor scan earlier. This is OK as it's
@@ -1056,7 +1062,7 @@
   }
   g1h->verifier()->check_bitmaps("Remark Start");
 
-  G1CollectorPolicy* g1p = g1h->g1_policy();
+  G1Policy* g1p = g1h->g1_policy();
   g1p->record_concurrent_mark_remark_start();
 
   double start = os::elapsedTime();
@@ -1144,8 +1150,6 @@
     if (hr->is_archive()) {
       return false;
     }
-    // We use a claim value of zero here because all regions
-    // were claimed with value 1 in the FinalCount task.
     _g1->reset_gc_time_stamps(hr);
     hr->note_end_of_marking();
 
@@ -1240,7 +1244,7 @@
   }
   g1h->verifier()->check_bitmaps("Cleanup Start");
 
-  G1CollectorPolicy* g1p = g1h->g1_policy();
+  G1Policy* g1p = g1h->g1_policy();
   g1p->record_concurrent_mark_cleanup_start();
 
   double start = os::elapsedTime();
@@ -2609,7 +2613,7 @@
   assert(time_target_ms >= 1.0, "minimum granularity is 1ms");
   assert(concurrent() == _cm->concurrent(), "they should be the same");
 
-  G1CollectorPolicy* g1_policy = _g1h->g1_policy();
+  G1Policy* g1_policy = _g1h->g1_policy();
   assert(_task_queues != NULL, "invariant");
   assert(_task_queue != NULL, "invariant");
   assert(_task_queues->queue(_worker_id) == _task_queue, "invariant");
diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp
index 3b077d9..03e3346 100644
--- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp
@@ -36,6 +36,7 @@
 class G1ConcurrentMark;
 class ConcurrentGCTimer;
 class G1OldTracer;
+class G1SurvivorRegions;
 typedef GenericTaskQueue<oop, mtGC>              G1CMTaskQueue;
 typedef GenericTaskQueueSet<G1CMTaskQueue, mtGC> G1CMTaskQueueSet;
 
@@ -58,10 +59,10 @@
 
 class G1CMBitMapRO VALUE_OBJ_CLASS_SPEC {
  protected:
-  HeapWord* _bmStartWord;      // base address of range covered by map
-  size_t    _bmWordSize;       // map size (in #HeapWords covered)
-  const int _shifter;          // map to char or bit
-  BitMap    _bm;               // the bit map itself
+  HeapWord*  _bmStartWord; // base address of range covered by map
+  size_t     _bmWordSize;  // map size (in #HeapWords covered)
+  const int  _shifter;     // map to char or bit
+  BitMapView _bm;          // the bit map itself
 
  public:
   // constructor
@@ -204,8 +205,6 @@
   template<typename Fn> void iterate(Fn fn);
 };
 
-class YoungList;
-
 // Root Regions are regions that are not empty at the beginning of a
 // marking cycle and which we might collect during an evacuation pause
 // while the cycle is active. Given that, during evacuation pauses, we
@@ -221,19 +220,19 @@
 // regions populated during the initial-mark pause.
 class G1CMRootRegions VALUE_OBJ_CLASS_SPEC {
 private:
-  YoungList*           _young_list;
-  G1ConcurrentMark*    _cm;
+  const G1SurvivorRegions* _survivors;
+  G1ConcurrentMark*        _cm;
 
-  volatile bool        _scan_in_progress;
-  volatile bool        _should_abort;
-  HeapRegion* volatile _next_survivor;
+  volatile bool            _scan_in_progress;
+  volatile bool            _should_abort;
+  volatile int             _claimed_survivor_index;
 
   void notify_scan_done();
 
 public:
   G1CMRootRegions();
   // We actually do most of the initialization in this method.
-  void init(G1CollectedHeap* g1h, G1ConcurrentMark* cm);
+  void init(const G1SurvivorRegions* survivors, G1ConcurrentMark* cm);
 
   // Reset the claiming / scanning of the root regions.
   void prepare_for_scan();
@@ -249,6 +248,9 @@
   // all have been claimed.
   HeapRegion* claim_next();
 
+  // The number of root regions to scan.
+  uint num_root_regions() const;
+
   void cancel_scan();
 
   // Flag that we're done with root region scanning and notify anyone
diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp
new file mode 100644
index 0000000..37d7213
--- /dev/null
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp
@@ -0,0 +1,1171 @@
+/*
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/g1/concurrentG1Refine.hpp"
+#include "gc/g1/concurrentMarkThread.inline.hpp"
+#include "gc/g1/g1Analytics.hpp"
+#include "gc/g1/g1CollectedHeap.inline.hpp"
+#include "gc/g1/g1CollectionSet.hpp"
+#include "gc/g1/g1ConcurrentMark.hpp"
+#include "gc/g1/g1DefaultPolicy.hpp"
+#include "gc/g1/g1HotCardCache.hpp"
+#include "gc/g1/g1IHOPControl.hpp"
+#include "gc/g1/g1GCPhaseTimes.hpp"
+#include "gc/g1/g1Policy.hpp"
+#include "gc/g1/g1SurvivorRegions.hpp"
+#include "gc/g1/g1YoungGenSizer.hpp"
+#include "gc/g1/heapRegion.inline.hpp"
+#include "gc/g1/heapRegionRemSet.hpp"
+#include "gc/shared/gcPolicyCounters.hpp"
+#include "logging/logStream.hpp"
+#include "runtime/arguments.hpp"
+#include "runtime/java.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/pair.hpp"
+
+G1DefaultPolicy::G1DefaultPolicy() :
+  _predictor(G1ConfidencePercent / 100.0),
+  _analytics(new G1Analytics(&_predictor)),
+  _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)),
+  _ihop_control(create_ihop_control(&_predictor)),
+  _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)),
+  _young_list_fixed_length(0),
+  _short_lived_surv_rate_group(new SurvRateGroup()),
+  _survivor_surv_rate_group(new SurvRateGroup()),
+  _reserve_factor((double) G1ReservePercent / 100.0),
+  _reserve_regions(0),
+  _rs_lengths_prediction(0),
+  _bytes_allocated_in_old_since_last_gc(0),
+  _initial_mark_to_mixed(),
+  _collection_set(NULL),
+  _g1(NULL),
+  _phase_times(new G1GCPhaseTimes(ParallelGCThreads)),
+  _tenuring_threshold(MaxTenuringThreshold),
+  _max_survivor_regions(0),
+  _survivors_age_table(true) { }
+
+G1DefaultPolicy::~G1DefaultPolicy() {
+  delete _ihop_control;
+}
+
+G1CollectorState* G1DefaultPolicy::collector_state() const { return _g1->collector_state(); }
+
+void G1DefaultPolicy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) {
+  _g1 = g1h;
+  _collection_set = collection_set;
+
+  assert(Heap_lock->owned_by_self(), "Locking discipline.");
+
+  if (!adaptive_young_list_length()) {
+    _young_list_fixed_length = _young_gen_sizer.min_desired_young_length();
+  }
+  _young_gen_sizer.adjust_max_new_size(_g1->max_regions());
+
+  _free_regions_at_end_of_collection = _g1->num_free_regions();
+
+  update_young_list_max_and_target_length();
+  // We may immediately start allocating regions and placing them on the
+  // collection set list. Initialize the per-collection set info
+  _collection_set->start_incremental_building();
+}
+
+void G1DefaultPolicy::note_gc_start() {
+  phase_times()->note_gc_start();
+}
+
+bool G1DefaultPolicy::predict_will_fit(uint young_length,
+                                       double base_time_ms,
+                                       uint base_free_regions,
+                                       double target_pause_time_ms) const {
+  if (young_length >= base_free_regions) {
+    // end condition 1: not enough space for the young regions
+    return false;
+  }
+
+  double accum_surv_rate = accum_yg_surv_rate_pred((int) young_length - 1);
+  size_t bytes_to_copy =
+               (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes);
+  double copy_time_ms = _analytics->predict_object_copy_time_ms(bytes_to_copy,
+                                                                collector_state()->during_concurrent_mark());
+  double young_other_time_ms = _analytics->predict_young_other_time_ms(young_length);
+  double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms;
+  if (pause_time_ms > target_pause_time_ms) {
+    // end condition 2: prediction is over the target pause time
+    return false;
+  }
+
+  size_t free_bytes = (base_free_regions - young_length) * HeapRegion::GrainBytes;
+
+  // When copying, we will likely need more bytes free than is live in the region.
+  // Add some safety margin to factor in the confidence of our guess, and the
+  // natural expected waste.
+  // (100.0 / G1ConfidencePercent) is a scale factor that expresses the uncertainty
+  // of the calculation: the lower the confidence, the more headroom.
+  // (100 + TargetPLABWastePct) represents the increase in expected bytes during
+  // copying due to anticipated waste in the PLABs.
+  double safety_factor = (100.0 / G1ConfidencePercent) * (100 + TargetPLABWastePct) / 100.0;
+  size_t expected_bytes_to_copy = (size_t)(safety_factor * bytes_to_copy);
+
+  if (expected_bytes_to_copy > free_bytes) {
+    // end condition 3: out-of-space
+    return false;
+  }
+
+  // success!
+  return true;
+}
+
+void G1DefaultPolicy::record_new_heap_size(uint new_number_of_regions) {
+  // re-calculate the necessary reserve
+  double reserve_regions_d = (double) new_number_of_regions * _reserve_factor;
+  // We use ceiling so that if reserve_regions_d is > 0.0 (but
+  // smaller than 1.0) we'll get 1.
+  _reserve_regions = (uint) ceil(reserve_regions_d);
+
+  _young_gen_sizer.heap_size_changed(new_number_of_regions);
+
+  _ihop_control->update_target_occupancy(new_number_of_regions * HeapRegion::GrainBytes);
+}
+
+uint G1DefaultPolicy::calculate_young_list_desired_min_length(uint base_min_length) const {
+  uint desired_min_length = 0;
+  if (adaptive_young_list_length()) {
+    if (_analytics->num_alloc_rate_ms() > 3) {
+      double now_sec = os::elapsedTime();
+      double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
+      double alloc_rate_ms = _analytics->predict_alloc_rate_ms();
+      desired_min_length = (uint) ceil(alloc_rate_ms * when_ms);
+    } else {
+      // otherwise we don't have enough info to make the prediction
+    }
+  }
+  desired_min_length += base_min_length;
+  // make sure we don't go below any user-defined minimum bound
+  return MAX2(_young_gen_sizer.min_desired_young_length(), desired_min_length);
+}
+
+uint G1DefaultPolicy::calculate_young_list_desired_max_length() const {
+  // Here, we might want to also take into account any additional
+  // constraints (i.e., user-defined minimum bound). Currently, we
+  // effectively don't set this bound.
+  return _young_gen_sizer.max_desired_young_length();
+}
+
+uint G1DefaultPolicy::update_young_list_max_and_target_length() {
+  return update_young_list_max_and_target_length(_analytics->predict_rs_lengths());
+}
+
+uint G1DefaultPolicy::update_young_list_max_and_target_length(size_t rs_lengths) {
+  uint unbounded_target_length = update_young_list_target_length(rs_lengths);
+  update_max_gc_locker_expansion();
+  return unbounded_target_length;
+}
+
+uint G1DefaultPolicy::update_young_list_target_length(size_t rs_lengths) {
+  YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths);
+  _young_list_target_length = young_lengths.first;
+  return young_lengths.second;
+}
+
+G1DefaultPolicy::YoungTargetLengths G1DefaultPolicy::young_list_target_lengths(size_t rs_lengths) const {
+  YoungTargetLengths result;
+
+  // Calculate the absolute and desired min bounds first.
+
+  // This is how many young regions we already have (currently: the survivors).
+  const uint base_min_length = _g1->survivor_regions_count();
+  uint desired_min_length = calculate_young_list_desired_min_length(base_min_length);
+  // This is the absolute minimum young length. Ensure that we
+  // will at least have one eden region available for allocation.
+  uint absolute_min_length = base_min_length + MAX2(_g1->eden_regions_count(), (uint)1);
+  // If we shrank the young list target it should not shrink below the current size.
+  desired_min_length = MAX2(desired_min_length, absolute_min_length);
+  // Calculate the absolute and desired max bounds.
+
+  uint desired_max_length = calculate_young_list_desired_max_length();
+
+  uint young_list_target_length = 0;
+  if (adaptive_young_list_length()) {
+    if (collector_state()->gcs_are_young()) {
+      young_list_target_length =
+                        calculate_young_list_target_length(rs_lengths,
+                                                           base_min_length,
+                                                           desired_min_length,
+                                                           desired_max_length);
+    } else {
+      // Don't calculate anything and let the code below bound it to
+      // the desired_min_length, i.e., do the next GC as soon as
+      // possible to maximize how many old regions we can add to it.
+    }
+  } else {
+    // The user asked for a fixed young gen so we'll fix the young gen
+    // whether the next GC is young or mixed.
+    young_list_target_length = _young_list_fixed_length;
+  }
+
+  result.second = young_list_target_length;
+
+  // We will try our best not to "eat" into the reserve.
+  uint absolute_max_length = 0;
+  if (_free_regions_at_end_of_collection > _reserve_regions) {
+    absolute_max_length = _free_regions_at_end_of_collection - _reserve_regions;
+  }
+  if (desired_max_length > absolute_max_length) {
+    desired_max_length = absolute_max_length;
+  }
+
+  // Make sure we don't go over the desired max length, nor under the
+  // desired min length. In case they clash, desired_min_length wins
+  // which is why that test is second.
+  if (young_list_target_length > desired_max_length) {
+    young_list_target_length = desired_max_length;
+  }
+  if (young_list_target_length < desired_min_length) {
+    young_list_target_length = desired_min_length;
+  }
+
+  assert(young_list_target_length > base_min_length,
+         "we should be able to allocate at least one eden region");
+  assert(young_list_target_length >= absolute_min_length, "post-condition");
+
+  result.first = young_list_target_length;
+  return result;
+}
+
+uint
+G1DefaultPolicy::calculate_young_list_target_length(size_t rs_lengths,
+                                                    uint base_min_length,
+                                                    uint desired_min_length,
+                                                    uint desired_max_length) const {
+  assert(adaptive_young_list_length(), "pre-condition");
+  assert(collector_state()->gcs_are_young(), "only call this for young GCs");
+
+  // In case some edge-condition makes the desired max length too small...
+  if (desired_max_length <= desired_min_length) {
+    return desired_min_length;
+  }
+
+  // We'll adjust min_young_length and max_young_length not to include
+  // the already allocated young regions (i.e., so they reflect the
+  // min and max eden regions we'll allocate). The base_min_length
+  // will be reflected in the predictions by the
+  // survivor_regions_evac_time prediction.
+  assert(desired_min_length > base_min_length, "invariant");
+  uint min_young_length = desired_min_length - base_min_length;
+  assert(desired_max_length > base_min_length, "invariant");
+  uint max_young_length = desired_max_length - base_min_length;
+
+  double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0;
+  double survivor_regions_evac_time = predict_survivor_regions_evac_time();
+  size_t pending_cards = _analytics->predict_pending_cards();
+  size_t adj_rs_lengths = rs_lengths + _analytics->predict_rs_length_diff();
+  size_t scanned_cards = _analytics->predict_card_num(adj_rs_lengths, /* gcs_are_young */ true);
+  double base_time_ms =
+    predict_base_elapsed_time_ms(pending_cards, scanned_cards) +
+    survivor_regions_evac_time;
+  uint available_free_regions = _free_regions_at_end_of_collection;
+  uint base_free_regions = 0;
+  if (available_free_regions > _reserve_regions) {
+    base_free_regions = available_free_regions - _reserve_regions;
+  }
+
+  // Here, we will make sure that the shortest young length that
+  // makes sense fits within the target pause time.
+
+  if (predict_will_fit(min_young_length, base_time_ms,
+                       base_free_regions, target_pause_time_ms)) {
+    // The shortest young length will fit into the target pause time;
+    // we'll now check whether the absolute maximum number of young
+    // regions will fit in the target pause time. If not, we'll do
+    // a binary search between min_young_length and max_young_length.
+    if (predict_will_fit(max_young_length, base_time_ms,
+                         base_free_regions, target_pause_time_ms)) {
+      // The maximum young length will fit into the target pause time.
+      // We are done so set min young length to the maximum length (as
+      // the result is assumed to be returned in min_young_length).
+      min_young_length = max_young_length;
+    } else {
+      // The maximum possible number of young regions will not fit within
+      // the target pause time so we'll search for the optimal
+      // length. The loop invariants are:
+      //
+      // min_young_length < max_young_length
+      // min_young_length is known to fit into the target pause time
+      // max_young_length is known not to fit into the target pause time
+      //
+      // Going into the loop we know the above hold as we've just
+      // checked them. Every time around the loop we check whether
+      // the middle value between min_young_length and
+      // max_young_length fits into the target pause time. If it
+      // does, it becomes the new min. If it doesn't, it becomes
+      // the new max. This way we maintain the loop invariants.
+
+      assert(min_young_length < max_young_length, "invariant");
+      uint diff = (max_young_length - min_young_length) / 2;
+      while (diff > 0) {
+        uint young_length = min_young_length + diff;
+        if (predict_will_fit(young_length, base_time_ms,
+                             base_free_regions, target_pause_time_ms)) {
+          min_young_length = young_length;
+        } else {
+          max_young_length = young_length;
+        }
+        assert(min_young_length <  max_young_length, "invariant");
+        diff = (max_young_length - min_young_length) / 2;
+      }
+      // The results is min_young_length which, according to the
+      // loop invariants, should fit within the target pause time.
+
+      // These are the post-conditions of the binary search above:
+      assert(min_young_length < max_young_length,
+             "otherwise we should have discovered that max_young_length "
+             "fits into the pause target and not done the binary search");
+      assert(predict_will_fit(min_young_length, base_time_ms,
+                              base_free_regions, target_pause_time_ms),
+             "min_young_length, the result of the binary search, should "
+             "fit into the pause target");
+      assert(!predict_will_fit(min_young_length + 1, base_time_ms,
+                               base_free_regions, target_pause_time_ms),
+             "min_young_length, the result of the binary search, should be "
+             "optimal, so no larger length should fit into the pause target");
+    }
+  } else {
+    // Even the minimum length doesn't fit into the pause time
+    // target, return it as the result nevertheless.
+  }
+  return base_min_length + min_young_length;
+}
+
+double G1DefaultPolicy::predict_survivor_regions_evac_time() const {
+  double survivor_regions_evac_time = 0.0;
+  const GrowableArray<HeapRegion*>* survivor_regions = _g1->survivor()->regions();
+
+  for (GrowableArrayIterator<HeapRegion*> it = survivor_regions->begin();
+       it != survivor_regions->end();
+       ++it) {
+    survivor_regions_evac_time += predict_region_elapsed_time_ms(*it, collector_state()->gcs_are_young());
+  }
+  return survivor_regions_evac_time;
+}
+
+void G1DefaultPolicy::revise_young_list_target_length_if_necessary(size_t rs_lengths) {
+  guarantee( adaptive_young_list_length(), "should not call this otherwise" );
+
+  if (rs_lengths > _rs_lengths_prediction) {
+    // add 10% to avoid having to recalculate often
+    size_t rs_lengths_prediction = rs_lengths * 1100 / 1000;
+    update_rs_lengths_prediction(rs_lengths_prediction);
+
+    update_young_list_max_and_target_length(rs_lengths_prediction);
+  }
+}
+
+void G1DefaultPolicy::update_rs_lengths_prediction() {
+  update_rs_lengths_prediction(_analytics->predict_rs_lengths());
+}
+
+void G1DefaultPolicy::update_rs_lengths_prediction(size_t prediction) {
+  if (collector_state()->gcs_are_young() && adaptive_young_list_length()) {
+    _rs_lengths_prediction = prediction;
+  }
+}
+
+#ifndef PRODUCT
+bool G1DefaultPolicy::verify_young_ages() {
+  bool ret = true;
+
+  for (HeapRegion* curr = _collection_set->inc_head();
+       curr != NULL;
+       curr = curr->next_in_collection_set()) {
+    guarantee(curr->is_young(), "Region must be young");
+
+    SurvRateGroup* group = curr->surv_rate_group();
+
+    if (group == NULL) {
+      log_error(gc, verify)("## encountered NULL surv_rate_group in young region");
+      ret = false;
+    }
+
+    if (curr->age_in_surv_rate_group() < 0) {
+      log_error(gc, verify)("## encountered negative age in young region");
+      ret = false;
+    }
+  }
+
+  if (!ret) {
+    LogStreamHandle(Error, gc, verify) log;
+    _collection_set->print(_collection_set->inc_head(), &log);
+  }
+
+  return ret;
+}
+#endif // PRODUCT
+
+void G1DefaultPolicy::record_full_collection_start() {
+  _full_collection_start_sec = os::elapsedTime();
+  // Release the future to-space so that it is available for compaction into.
+  collector_state()->set_full_collection(true);
+}
+
+void G1DefaultPolicy::record_full_collection_end() {
+  // Consider this like a collection pause for the purposes of allocation
+  // since last pause.
+  double end_sec = os::elapsedTime();
+  double full_gc_time_sec = end_sec - _full_collection_start_sec;
+  double full_gc_time_ms = full_gc_time_sec * 1000.0;
+
+  _analytics->update_recent_gc_times(end_sec, full_gc_time_ms);
+
+  collector_state()->set_full_collection(false);
+
+  // "Nuke" the heuristics that control the young/mixed GC
+  // transitions and make sure we start with young GCs after the Full GC.
+  collector_state()->set_gcs_are_young(true);
+  collector_state()->set_last_young_gc(false);
+  collector_state()->set_initiate_conc_mark_if_possible(need_to_start_conc_mark("end of Full GC", 0));
+  collector_state()->set_during_initial_mark_pause(false);
+  collector_state()->set_in_marking_window(false);
+  collector_state()->set_in_marking_window_im(false);
+
+  _short_lived_surv_rate_group->start_adding_regions();
+  // also call this on any additional surv rate groups
+
+  _free_regions_at_end_of_collection = _g1->num_free_regions();
+  // Reset survivors SurvRateGroup.
+  _survivor_surv_rate_group->reset();
+  update_young_list_max_and_target_length();
+  update_rs_lengths_prediction();
+  cset_chooser()->clear();
+
+  _bytes_allocated_in_old_since_last_gc = 0;
+
+  record_pause(FullGC, _full_collection_start_sec, end_sec);
+}
+
+void G1DefaultPolicy::record_collection_pause_start(double start_time_sec) {
+  // We only need to do this here as the policy will only be applied
+  // to the GC we're about to start. so, no point is calculating this
+  // every time we calculate / recalculate the target young length.
+  update_survivors_policy();
+
+  assert(_g1->used() == _g1->recalculate_used(),
+         "sanity, used: " SIZE_FORMAT " recalculate_used: " SIZE_FORMAT,
+         _g1->used(), _g1->recalculate_used());
+
+  phase_times()->record_cur_collection_start_sec(start_time_sec);
+  _pending_cards = _g1->pending_card_num();
+
+  _collection_set->reset_bytes_used_before();
+  _bytes_copied_during_gc = 0;
+
+  collector_state()->set_last_gc_was_young(false);
+
+  // do that for any other surv rate groups
+  _short_lived_surv_rate_group->stop_adding_regions();
+  _survivors_age_table.clear();
+
+  assert( verify_young_ages(), "region age verification" );
+}
+
+void G1DefaultPolicy::record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) {
+  collector_state()->set_during_marking(true);
+  assert(!collector_state()->initiate_conc_mark_if_possible(), "we should have cleared it by now");
+  collector_state()->set_during_initial_mark_pause(false);
+}
+
+void G1DefaultPolicy::record_concurrent_mark_remark_start() {
+  _mark_remark_start_sec = os::elapsedTime();
+  collector_state()->set_during_marking(false);
+}
+
+void G1DefaultPolicy::record_concurrent_mark_remark_end() {
+  double end_time_sec = os::elapsedTime();
+  double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0;
+  _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms);
+  _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms);
+
+  record_pause(Remark, _mark_remark_start_sec, end_time_sec);
+}
+
+void G1DefaultPolicy::record_concurrent_mark_cleanup_start() {
+  _mark_cleanup_start_sec = os::elapsedTime();
+}
+
+void G1DefaultPolicy::record_concurrent_mark_cleanup_completed() {
+  bool should_continue_with_reclaim = next_gc_should_be_mixed("request last young-only gc",
+                                                              "skip last young-only gc");
+  collector_state()->set_last_young_gc(should_continue_with_reclaim);
+  // We skip the marking phase.
+  if (!should_continue_with_reclaim) {
+    abort_time_to_mixed_tracking();
+  }
+  collector_state()->set_in_marking_window(false);
+}
+
+double G1DefaultPolicy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const {
+  return phase_times()->average_time_ms(phase);
+}
+
+double G1DefaultPolicy::young_other_time_ms() const {
+  return phase_times()->young_cset_choice_time_ms() +
+         phase_times()->young_free_cset_time_ms();
+}
+
+double G1DefaultPolicy::non_young_other_time_ms() const {
+  return phase_times()->non_young_cset_choice_time_ms() +
+         phase_times()->non_young_free_cset_time_ms();
+
+}
+
+double G1DefaultPolicy::other_time_ms(double pause_time_ms) const {
+  return pause_time_ms - phase_times()->cur_collection_par_time_ms();
+}
+
+double G1DefaultPolicy::constant_other_time_ms(double pause_time_ms) const {
+  return other_time_ms(pause_time_ms) - young_other_time_ms() - non_young_other_time_ms();
+}
+
+CollectionSetChooser* G1DefaultPolicy::cset_chooser() const {
+  return _collection_set->cset_chooser();
+}
+
+bool G1DefaultPolicy::about_to_start_mixed_phase() const {
+  return _g1->concurrent_mark()->cmThread()->during_cycle() || collector_state()->last_young_gc();
+}
+
+bool G1DefaultPolicy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) {
+  if (about_to_start_mixed_phase()) {
+    return false;
+  }
+
+  size_t marking_initiating_used_threshold = _ihop_control->get_conc_mark_start_threshold();
+
+  size_t cur_used_bytes = _g1->non_young_capacity_bytes();
+  size_t alloc_byte_size = alloc_word_size * HeapWordSize;
+  size_t marking_request_bytes = cur_used_bytes + alloc_byte_size;
+
+  bool result = false;
+  if (marking_request_bytes > marking_initiating_used_threshold) {
+    result = collector_state()->gcs_are_young() && !collector_state()->last_young_gc();
+    log_debug(gc, ergo, ihop)("%s occupancy: " SIZE_FORMAT "B allocation request: " SIZE_FORMAT "B threshold: " SIZE_FORMAT "B (%1.2f) source: %s",
+                              result ? "Request concurrent cycle initiation (occupancy higher than threshold)" : "Do not request concurrent cycle initiation (still doing mixed collections)",
+                              cur_used_bytes, alloc_byte_size, marking_initiating_used_threshold, (double) marking_initiating_used_threshold / _g1->capacity() * 100, source);
+  }
+
+  return result;
+}
+
+// Anything below that is considered to be zero
+#define MIN_TIMER_GRANULARITY 0.0000001
+
+void G1DefaultPolicy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) {
+  double end_time_sec = os::elapsedTime();
+
+  size_t cur_used_bytes = _g1->used();
+  assert(cur_used_bytes == _g1->recalculate_used(), "It should!");
+  bool last_pause_included_initial_mark = false;
+  bool update_stats = !_g1->evacuation_failed();
+
+  record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec);
+
+  last_pause_included_initial_mark = collector_state()->during_initial_mark_pause();
+  if (last_pause_included_initial_mark) {
+    record_concurrent_mark_init_end(0.0);
+  } else {
+    maybe_start_marking();
+  }
+
+  double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms());
+  if (app_time_ms < MIN_TIMER_GRANULARITY) {
+    // This usually happens due to the timer not having the required
+    // granularity. Some Linuxes are the usual culprits.
+    // We'll just set it to something (arbitrarily) small.
+    app_time_ms = 1.0;
+  }
+
+  if (update_stats) {
+    // We maintain the invariant that all objects allocated by mutator
+    // threads will be allocated out of eden regions. So, we can use
+    // the eden region number allocated since the previous GC to
+    // calculate the application's allocate rate. The only exception
+    // to that is humongous objects that are allocated separately. But
+    // given that humongous object allocations do not really affect
+    // either the pause's duration nor when the next pause will take
+    // place we can safely ignore them here.
+    uint regions_allocated = _collection_set->eden_region_length();
+    double alloc_rate_ms = (double) regions_allocated / app_time_ms;
+    _analytics->report_alloc_rate_ms(alloc_rate_ms);
+
+    double interval_ms =
+      (end_time_sec - _analytics->last_known_gc_end_time_sec()) * 1000.0;
+    _analytics->update_recent_gc_times(end_time_sec, pause_time_ms);
+    _analytics->compute_pause_time_ratio(interval_ms, pause_time_ms);
+  }
+
+  bool new_in_marking_window = collector_state()->in_marking_window();
+  bool new_in_marking_window_im = false;
+  if (last_pause_included_initial_mark) {
+    new_in_marking_window = true;
+    new_in_marking_window_im = true;
+  }
+
+  if (collector_state()->last_young_gc()) {
+    // This is supposed to to be the "last young GC" before we start
+    // doing mixed GCs. Here we decide whether to start mixed GCs or not.
+    assert(!last_pause_included_initial_mark, "The last young GC is not allowed to be an initial mark GC");
+
+    if (next_gc_should_be_mixed("start mixed GCs",
+                                "do not start mixed GCs")) {
+      collector_state()->set_gcs_are_young(false);
+    } else {
+      // We aborted the mixed GC phase early.
+      abort_time_to_mixed_tracking();
+    }
+
+    collector_state()->set_last_young_gc(false);
+  }
+
+  if (!collector_state()->last_gc_was_young()) {
+    // This is a mixed GC. Here we decide whether to continue doing
+    // mixed GCs or not.
+    if (!next_gc_should_be_mixed("continue mixed GCs",
+                                 "do not continue mixed GCs")) {
+      collector_state()->set_gcs_are_young(true);
+
+      maybe_start_marking();
+    }
+  }
+
+  _short_lived_surv_rate_group->start_adding_regions();
+  // Do that for any other surv rate groups
+
+  double scan_hcc_time_ms = G1HotCardCache::default_use_cache() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0;
+
+  if (update_stats) {
+    double cost_per_card_ms = 0.0;
+    if (_pending_cards > 0) {
+      cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms) / (double) _pending_cards;
+      _analytics->report_cost_per_card_ms(cost_per_card_ms);
+    }
+    _analytics->report_cost_scan_hcc(scan_hcc_time_ms);
+
+    double cost_per_entry_ms = 0.0;
+    if (cards_scanned > 10) {
+      cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned;
+      _analytics->report_cost_per_entry_ms(cost_per_entry_ms, collector_state()->last_gc_was_young());
+    }
+
+    if (_max_rs_lengths > 0) {
+      double cards_per_entry_ratio =
+        (double) cards_scanned / (double) _max_rs_lengths;
+      _analytics->report_cards_per_entry_ratio(cards_per_entry_ratio, collector_state()->last_gc_was_young());
+    }
+
+    // This is defensive. For a while _max_rs_lengths could get
+    // smaller than _recorded_rs_lengths which was causing
+    // rs_length_diff to get very large and mess up the RSet length
+    // predictions. The reason was unsafe concurrent updates to the
+    // _inc_cset_recorded_rs_lengths field which the code below guards
+    // against (see CR 7118202). This bug has now been fixed (see CR
+    // 7119027). However, I'm still worried that
+    // _inc_cset_recorded_rs_lengths might still end up somewhat
+    // inaccurate. The concurrent refinement thread calculates an
+    // RSet's length concurrently with other CR threads updating it
+    // which might cause it to calculate the length incorrectly (if,
+    // say, it's in mid-coarsening). So I'll leave in the defensive
+    // conditional below just in case.
+    size_t rs_length_diff = 0;
+    size_t recorded_rs_lengths = _collection_set->recorded_rs_lengths();
+    if (_max_rs_lengths > recorded_rs_lengths) {
+      rs_length_diff = _max_rs_lengths - recorded_rs_lengths;
+    }
+    _analytics->report_rs_length_diff((double) rs_length_diff);
+
+    size_t freed_bytes = heap_used_bytes_before_gc - cur_used_bytes;
+    size_t copied_bytes = _collection_set->bytes_used_before() - freed_bytes;
+    double cost_per_byte_ms = 0.0;
+
+    if (copied_bytes > 0) {
+      cost_per_byte_ms = average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes;
+      _analytics->report_cost_per_byte_ms(cost_per_byte_ms, collector_state()->in_marking_window());
+    }
+
+    if (_collection_set->young_region_length() > 0) {
+      _analytics->report_young_other_cost_per_region_ms(young_other_time_ms() /
+                                                        _collection_set->young_region_length());
+    }
+
+    if (_collection_set->old_region_length() > 0) {
+      _analytics->report_non_young_other_cost_per_region_ms(non_young_other_time_ms() /
+                                                            _collection_set->old_region_length());
+    }
+
+    _analytics->report_constant_other_time_ms(constant_other_time_ms(pause_time_ms));
+
+    _analytics->report_pending_cards((double) _pending_cards);
+    _analytics->report_rs_lengths((double) _max_rs_lengths);
+  }
+
+  collector_state()->set_in_marking_window(new_in_marking_window);
+  collector_state()->set_in_marking_window_im(new_in_marking_window_im);
+  _free_regions_at_end_of_collection = _g1->num_free_regions();
+  // IHOP control wants to know the expected young gen length if it were not
+  // restrained by the heap reserve. Using the actual length would make the
+  // prediction too small and the limit the young gen every time we get to the
+  // predicted target occupancy.
+  size_t last_unrestrained_young_length = update_young_list_max_and_target_length();
+  update_rs_lengths_prediction();
+
+  update_ihop_prediction(app_time_ms / 1000.0,
+                         _bytes_allocated_in_old_since_last_gc,
+                         last_unrestrained_young_length * HeapRegion::GrainBytes);
+  _bytes_allocated_in_old_since_last_gc = 0;
+
+  _ihop_control->send_trace_event(_g1->gc_tracer_stw());
+
+  // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
+  double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
+
+  if (update_rs_time_goal_ms < scan_hcc_time_ms) {
+    log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)."
+                                "Update RS time goal: %1.2fms Scan HCC time: %1.2fms",
+                                update_rs_time_goal_ms, scan_hcc_time_ms);
+
+    update_rs_time_goal_ms = 0;
+  } else {
+    update_rs_time_goal_ms -= scan_hcc_time_ms;
+  }
+  _g1->concurrent_g1_refine()->adjust(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms,
+                                      phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS),
+                                      update_rs_time_goal_ms);
+
+  cset_chooser()->verify();
+}
+
+G1IHOPControl* G1DefaultPolicy::create_ihop_control(const G1Predictions* predictor){
+  if (G1UseAdaptiveIHOP) {
+    return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent,
+                                     predictor,
+                                     G1ReservePercent,
+                                     G1HeapWastePercent);
+  } else {
+    return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent);
+  }
+}
+
+void G1DefaultPolicy::update_ihop_prediction(double mutator_time_s,
+                                      size_t mutator_alloc_bytes,
+                                      size_t young_gen_size) {
+  // Always try to update IHOP prediction. Even evacuation failures give information
+  // about e.g. whether to start IHOP earlier next time.
+
+  // Avoid using really small application times that might create samples with
+  // very high or very low values. They may be caused by e.g. back-to-back gcs.
+  double const min_valid_time = 1e-6;
+
+  bool report = false;
+
+  double marking_to_mixed_time = -1.0;
+  if (!collector_state()->last_gc_was_young() && _initial_mark_to_mixed.has_result()) {
+    marking_to_mixed_time = _initial_mark_to_mixed.last_marking_time();
+    assert(marking_to_mixed_time > 0.0,
+           "Initial mark to mixed time must be larger than zero but is %.3f",
+           marking_to_mixed_time);
+    if (marking_to_mixed_time > min_valid_time) {
+      _ihop_control->update_marking_length(marking_to_mixed_time);
+      report = true;
+    }
+  }
+
+  // As an approximation for the young gc promotion rates during marking we use
+  // all of them. In many applications there are only a few if any young gcs during
+  // marking, which makes any prediction useless. This increases the accuracy of the
+  // prediction.
+  if (collector_state()->last_gc_was_young() && mutator_time_s > min_valid_time) {
+    _ihop_control->update_allocation_info(mutator_time_s, mutator_alloc_bytes, young_gen_size);
+    report = true;
+  }
+
+  if (report) {
+    report_ihop_statistics();
+  }
+}
+
+void G1DefaultPolicy::report_ihop_statistics() {
+  _ihop_control->print();
+}
+
+void G1DefaultPolicy::print_phases() {
+  phase_times()->print();
+}
+
+double G1DefaultPolicy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const {
+  TruncatedSeq* seq = surv_rate_group->get_seq(age);
+  guarantee(seq->num() > 0, "There should be some young gen survivor samples available. Tried to access with age %d", age);
+  double pred = _predictor.get_new_prediction(seq);
+  if (pred > 1.0) {
+    pred = 1.0;
+  }
+  return pred;
+}
+
+double G1DefaultPolicy::accum_yg_surv_rate_pred(int age) const {
+  return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
+}
+
+double G1DefaultPolicy::predict_base_elapsed_time_ms(size_t pending_cards,
+                                              size_t scanned_cards) const {
+  return
+    _analytics->predict_rs_update_time_ms(pending_cards) +
+    _analytics->predict_rs_scan_time_ms(scanned_cards, collector_state()->gcs_are_young()) +
+    _analytics->predict_constant_other_time_ms();
+}
+
+double G1DefaultPolicy::predict_base_elapsed_time_ms(size_t pending_cards) const {
+  size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff();
+  size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->gcs_are_young());
+  return predict_base_elapsed_time_ms(pending_cards, card_num);
+}
+
+size_t G1DefaultPolicy::predict_bytes_to_copy(HeapRegion* hr) const {
+  size_t bytes_to_copy;
+  if (hr->is_marked())
+    bytes_to_copy = hr->max_live_bytes();
+  else {
+    assert(hr->is_young() && hr->age_in_surv_rate_group() != -1, "invariant");
+    int age = hr->age_in_surv_rate_group();
+    double yg_surv_rate = predict_yg_surv_rate(age, hr->surv_rate_group());
+    bytes_to_copy = (size_t) (hr->used() * yg_surv_rate);
+  }
+  return bytes_to_copy;
+}
+
+double G1DefaultPolicy::predict_region_elapsed_time_ms(HeapRegion* hr,
+                                                bool for_young_gc) const {
+  size_t rs_length = hr->rem_set()->occupied();
+  // Predicting the number of cards is based on which type of GC
+  // we're predicting for.
+  size_t card_num = _analytics->predict_card_num(rs_length, for_young_gc);
+  size_t bytes_to_copy = predict_bytes_to_copy(hr);
+
+  double region_elapsed_time_ms =
+    _analytics->predict_rs_scan_time_ms(card_num, collector_state()->gcs_are_young()) +
+    _analytics->predict_object_copy_time_ms(bytes_to_copy, collector_state()->during_concurrent_mark());
+
+  // The prediction of the "other" time for this region is based
+  // upon the region type and NOT the GC type.
+  if (hr->is_young()) {
+    region_elapsed_time_ms += _analytics->predict_young_other_time_ms(1);
+  } else {
+    region_elapsed_time_ms += _analytics->predict_non_young_other_time_ms(1);
+  }
+  return region_elapsed_time_ms;
+}
+
+bool G1DefaultPolicy::should_allocate_mutator_region() const {
+  uint young_list_length = _g1->young_regions_count();
+  uint young_list_target_length = _young_list_target_length;
+  return young_list_length < young_list_target_length;
+}
+
+bool G1DefaultPolicy::can_expand_young_list() const {
+  uint young_list_length = _g1->young_regions_count();
+  uint young_list_max_length = _young_list_max_length;
+  return young_list_length < young_list_max_length;
+}
+
+bool G1DefaultPolicy::adaptive_young_list_length() const {
+  return _young_gen_sizer.adaptive_young_list_length();
+}
+
+void G1DefaultPolicy::update_max_gc_locker_expansion() {
+  uint expansion_region_num = 0;
+  if (GCLockerEdenExpansionPercent > 0) {
+    double perc = (double) GCLockerEdenExpansionPercent / 100.0;
+    double expansion_region_num_d = perc * (double) _young_list_target_length;
+    // We use ceiling so that if expansion_region_num_d is > 0.0 (but
+    // less than 1.0) we'll get 1.
+    expansion_region_num = (uint) ceil(expansion_region_num_d);
+  } else {
+    assert(expansion_region_num == 0, "sanity");
+  }
+  _young_list_max_length = _young_list_target_length + expansion_region_num;
+  assert(_young_list_target_length <= _young_list_max_length, "post-condition");
+}
+
+// Calculates survivor space parameters.
+void G1DefaultPolicy::update_survivors_policy() {
+  double max_survivor_regions_d =
+                 (double) _young_list_target_length / (double) SurvivorRatio;
+  // We use ceiling so that if max_survivor_regions_d is > 0.0 (but
+  // smaller than 1.0) we'll get 1.
+  _max_survivor_regions = (uint) ceil(max_survivor_regions_d);
+
+  _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(
+      HeapRegion::GrainWords * _max_survivor_regions, _policy_counters);
+}
+
+bool G1DefaultPolicy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) {
+  // We actually check whether we are marking here and not if we are in a
+  // reclamation phase. This means that we will schedule a concurrent mark
+  // even while we are still in the process of reclaiming memory.
+  bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
+  if (!during_cycle) {
+    log_debug(gc, ergo)("Request concurrent cycle initiation (requested by GC cause). GC cause: %s", GCCause::to_string(gc_cause));
+    collector_state()->set_initiate_conc_mark_if_possible(true);
+    return true;
+  } else {
+    log_debug(gc, ergo)("Do not request concurrent cycle initiation (concurrent cycle already in progress). GC cause: %s", GCCause::to_string(gc_cause));
+    return false;
+  }
+}
+
+void G1DefaultPolicy::initiate_conc_mark() {
+  collector_state()->set_during_initial_mark_pause(true);
+  collector_state()->set_initiate_conc_mark_if_possible(false);
+}
+
+void G1DefaultPolicy::decide_on_conc_mark_initiation() {
+  // We are about to decide on whether this pause will be an
+  // initial-mark pause.
+
+  // First, collector_state()->during_initial_mark_pause() should not be already set. We
+  // will set it here if we have to. However, it should be cleared by
+  // the end of the pause (it's only set for the duration of an
+  // initial-mark pause).
+  assert(!collector_state()->during_initial_mark_pause(), "pre-condition");
+
+  if (collector_state()->initiate_conc_mark_if_possible()) {
+    // We had noticed on a previous pause that the heap occupancy has
+    // gone over the initiating threshold and we should start a
+    // concurrent marking cycle. So we might initiate one.
+
+    if (!about_to_start_mixed_phase() && collector_state()->gcs_are_young()) {
+      // Initiate a new initial mark if there is no marking or reclamation going on.
+      initiate_conc_mark();
+      log_debug(gc, ergo)("Initiate concurrent cycle (concurrent cycle initiation requested)");
+    } else if (_g1->is_user_requested_concurrent_full_gc(_g1->gc_cause())) {
+      // Initiate a user requested initial mark. An initial mark must be young only
+      // GC, so the collector state must be updated to reflect this.
+      collector_state()->set_gcs_are_young(true);
+      collector_state()->set_last_young_gc(false);
+
+      abort_time_to_mixed_tracking();
+      initiate_conc_mark();
+      log_debug(gc, ergo)("Initiate concurrent cycle (user requested concurrent cycle)");
+    } else {
+      // The concurrent marking thread is still finishing up the
+      // previous cycle. If we start one right now the two cycles
+      // overlap. In particular, the concurrent marking thread might
+      // be in the process of clearing the next marking bitmap (which
+      // we will use for the next cycle if we start one). Starting a
+      // cycle now will be bad given that parts of the marking
+      // information might get cleared by the marking thread. And we
+      // cannot wait for the marking thread to finish the cycle as it
+      // periodically yields while clearing the next marking bitmap
+      // and, if it's in a yield point, it's waiting for us to
+      // finish. So, at this point we will not start a cycle and we'll
+      // let the concurrent marking thread complete the last one.
+      log_debug(gc, ergo)("Do not initiate concurrent cycle (concurrent cycle already in progress)");
+    }
+  }
+}
+
+void G1DefaultPolicy::record_concurrent_mark_cleanup_end() {
+  cset_chooser()->rebuild(_g1->workers(), _g1->num_regions());
+
+  double end_sec = os::elapsedTime();
+  double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
+  _analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms);
+  _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms);
+
+  record_pause(Cleanup, _mark_cleanup_start_sec, end_sec);
+}
+
+double G1DefaultPolicy::reclaimable_bytes_perc(size_t reclaimable_bytes) const {
+  // Returns the given amount of reclaimable bytes (that represents
+  // the amount of reclaimable space still to be collected) as a
+  // percentage of the current heap capacity.
+  size_t capacity_bytes = _g1->capacity();
+  return (double) reclaimable_bytes * 100.0 / (double) capacity_bytes;
+}
+
+void G1DefaultPolicy::maybe_start_marking() {
+  if (need_to_start_conc_mark("end of GC")) {
+    // Note: this might have already been set, if during the last
+    // pause we decided to start a cycle but at the beginning of
+    // this pause we decided to postpone it. That's OK.
+    collector_state()->set_initiate_conc_mark_if_possible(true);
+  }
+}
+
+G1DefaultPolicy::PauseKind G1DefaultPolicy::young_gc_pause_kind() const {
+  assert(!collector_state()->full_collection(), "must be");
+  if (collector_state()->during_initial_mark_pause()) {
+    assert(collector_state()->last_gc_was_young(), "must be");
+    assert(!collector_state()->last_young_gc(), "must be");
+    return InitialMarkGC;
+  } else if (collector_state()->last_young_gc()) {
+    assert(!collector_state()->during_initial_mark_pause(), "must be");
+    assert(collector_state()->last_gc_was_young(), "must be");
+    return LastYoungGC;
+  } else if (!collector_state()->last_gc_was_young()) {
+    assert(!collector_state()->during_initial_mark_pause(), "must be");
+    assert(!collector_state()->last_young_gc(), "must be");
+    return MixedGC;
+  } else {
+    assert(collector_state()->last_gc_was_young(), "must be");
+    assert(!collector_state()->during_initial_mark_pause(), "must be");
+    assert(!collector_state()->last_young_gc(), "must be");
+    return YoungOnlyGC;
+  }
+}
+
+void G1DefaultPolicy::record_pause(PauseKind kind, double start, double end) {
+  // Manage the MMU tracker. For some reason it ignores Full GCs.
+  if (kind != FullGC) {
+    _mmu_tracker->add_pause(start, end);
+  }
+  // Manage the mutator time tracking from initial mark to first mixed gc.
+  switch (kind) {
+    case FullGC:
+      abort_time_to_mixed_tracking();
+      break;
+    case Cleanup:
+    case Remark:
+    case YoungOnlyGC:
+    case LastYoungGC:
+      _initial_mark_to_mixed.add_pause(end - start);
+      break;
+    case InitialMarkGC:
+      _initial_mark_to_mixed.record_initial_mark_end(end);
+      break;
+    case MixedGC:
+      _initial_mark_to_mixed.record_mixed_gc_start(start);
+      break;
+    default:
+      ShouldNotReachHere();
+  }
+}
+
+void G1DefaultPolicy::abort_time_to_mixed_tracking() {
+  _initial_mark_to_mixed.reset();
+}
+
+bool G1DefaultPolicy::next_gc_should_be_mixed(const char* true_action_str,
+                                       const char* false_action_str) const {
+  if (cset_chooser()->is_empty()) {
+    log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str);
+    return false;
+  }
+
+  // Is the amount of uncollected reclaimable space above G1HeapWastePercent?
+  size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes();
+  double reclaimable_perc = reclaimable_bytes_perc(reclaimable_bytes);
+  double threshold = (double) G1HeapWastePercent;
+  if (reclaimable_perc <= threshold) {
+    log_debug(gc, ergo)("%s (reclaimable percentage not over threshold). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT,
+                        false_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
+    return false;
+  }
+  log_debug(gc, ergo)("%s (candidate old regions available). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT,
+                      true_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
+  return true;
+}
+
+uint G1DefaultPolicy::calc_min_old_cset_length() const {
+  // The min old CSet region bound is based on the maximum desired
+  // number of mixed GCs after a cycle. I.e., even if some old regions
+  // look expensive, we should add them to the CSet anyway to make
+  // sure we go through the available old regions in no more than the
+  // maximum desired number of mixed GCs.
+  //
+  // The calculation is based on the number of marked regions we added
+  // to the CSet chooser in the first place, not how many remain, so
+  // that the result is the same during all mixed GCs that follow a cycle.
+
+  const size_t region_num = (size_t) cset_chooser()->length();
+  const size_t gc_num = (size_t) MAX2(G1MixedGCCountTarget, (uintx) 1);
+  size_t result = region_num / gc_num;
+  // emulate ceiling
+  if (result * gc_num < region_num) {
+    result += 1;
+  }
+  return (uint) result;
+}
+
+uint G1DefaultPolicy::calc_max_old_cset_length() const {
+  // The max old CSet region bound is based on the threshold expressed
+  // as a percentage of the heap size. I.e., it should bound the
+  // number of old regions added to the CSet irrespective of how many
+  // of them are available.
+
+  const G1CollectedHeap* g1h = G1CollectedHeap::heap();
+  const size_t region_num = g1h->num_regions();
+  const size_t perc = (size_t) G1OldCSetRegionThresholdPercent;
+  size_t result = region_num * perc / 100;
+  // emulate ceiling
+  if (100 * result < region_num * perc) {
+    result += 1;
+  }
+  return (uint) result;
+}
+
+void G1DefaultPolicy::finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) {
+  double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms, survivor);
+  _collection_set->finalize_old_part(time_remaining_ms);
+}
+
+void G1DefaultPolicy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) {
+
+  // Add survivor regions to SurvRateGroup.
+  note_start_adding_survivor_regions();
+  finished_recalculating_age_indexes(true /* is_survivors */);
+
+  HeapRegion* last = NULL;
+  for (GrowableArrayIterator<HeapRegion*> it = survivors->regions()->begin();
+       it != survivors->regions()->end();
+       ++it) {
+    HeapRegion* curr = *it;
+    set_region_survivor(curr);
+
+    // The region is a non-empty survivor so let's add it to
+    // the incremental collection set for the next evacuation
+    // pause.
+    _collection_set->add_survivor_regions(curr);
+
+    last = curr;
+  }
+  note_stop_adding_survivor_regions();
+
+  // Don't clear the survivor list handles until the start of
+  // the next evacuation pause - we need it in order to re-tag
+  // the survivor regions from this evacuation pause as 'young'
+  // at the start of the next.
+
+  finished_recalculating_age_indexes(false /* is_survivors */);
+}
diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp
new file mode 100644
index 0000000..2627dc4
--- /dev/null
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp
@@ -0,0 +1,438 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP
+#define SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP
+
+#include "gc/g1/g1CollectorState.hpp"
+#include "gc/g1/g1GCPhaseTimes.hpp"
+#include "gc/g1/g1InCSetState.hpp"
+#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp"
+#include "gc/g1/g1MMUTracker.hpp"
+#include "gc/g1/g1Predictions.hpp"
+#include "gc/g1/g1Policy.hpp"
+#include "gc/g1/g1YoungGenSizer.hpp"
+#include "gc/shared/gcCause.hpp"
+#include "utilities/pair.hpp"
+
+// A G1Policy makes policy decisions that determine the
+// characteristics of the collector.  Examples include:
+//   * choice of collection set.
+//   * when to collect.
+
+class HeapRegion;
+class G1CollectionSet;
+class CollectionSetChooser;
+class G1IHOPControl;
+class G1Analytics;
+class G1SurvivorRegions;
+class G1YoungGenSizer;
+class GCPolicyCounters;
+
+class G1DefaultPolicy: public G1Policy {
+ private:
+
+  static G1IHOPControl* create_ihop_control(const G1Predictions* predictor);
+  // Update the IHOP control with necessary statistics.
+  void update_ihop_prediction(double mutator_time_s,
+                              size_t mutator_alloc_bytes,
+                              size_t young_gen_size);
+  void report_ihop_statistics();
+
+  G1Predictions _predictor;
+  G1Analytics* _analytics;
+  G1MMUTracker* _mmu_tracker;
+  G1IHOPControl* _ihop_control;
+
+  GCPolicyCounters* _policy_counters;
+
+  double _full_collection_start_sec;
+
+  uint _young_list_target_length;
+  uint _young_list_fixed_length;
+
+  // The max number of regions we can extend the eden by while the GC
+  // locker is active. This should be >= _young_list_target_length;
+  uint _young_list_max_length;
+
+  // SurvRateGroups below must be initialized after the predictor because they
+  // indirectly use it through this object passed to their constructor.
+  SurvRateGroup* _short_lived_surv_rate_group;
+  SurvRateGroup* _survivor_surv_rate_group;
+
+  double _reserve_factor;
+  // This will be set when the heap is expanded
+  // for the first time during initialization.
+  uint   _reserve_regions;
+
+  G1YoungGenSizer _young_gen_sizer;
+
+  uint _free_regions_at_end_of_collection;
+
+  size_t _max_rs_lengths;
+
+  size_t _rs_lengths_prediction;
+
+#ifndef PRODUCT
+  bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group);
+#endif // PRODUCT
+
+  size_t _pending_cards;
+
+  // The amount of allocated bytes in old gen during the last mutator and the following
+  // young GC phase.
+  size_t _bytes_allocated_in_old_since_last_gc;
+
+  G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed;
+public:
+  const G1Predictions& predictor() const { return _predictor; }
+  const G1Analytics* analytics()   const { return const_cast<const G1Analytics*>(_analytics); }
+
+  // Add the given number of bytes to the total number of allocated bytes in the old gen.
+  void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; }
+
+  // Accessors
+
+  void set_region_eden(HeapRegion* hr) {
+    hr->set_eden();
+    hr->install_surv_rate_group(_short_lived_surv_rate_group);
+  }
+
+  void set_region_survivor(HeapRegion* hr) {
+    assert(hr->is_survivor(), "pre-condition");
+    hr->install_surv_rate_group(_survivor_surv_rate_group);
+  }
+
+#ifndef PRODUCT
+  bool verify_young_ages();
+#endif // PRODUCT
+
+  void record_max_rs_lengths(size_t rs_lengths) {
+    _max_rs_lengths = rs_lengths;
+  }
+
+
+  double predict_base_elapsed_time_ms(size_t pending_cards) const;
+  double predict_base_elapsed_time_ms(size_t pending_cards,
+                                      size_t scanned_cards) const;
+  size_t predict_bytes_to_copy(HeapRegion* hr) const;
+  double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const;
+
+  double predict_survivor_regions_evac_time() const;
+
+  bool should_update_surv_rate_group_predictors() {
+    return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window();
+  }
+
+  void cset_regions_freed() {
+    bool update = should_update_surv_rate_group_predictors();
+
+    _short_lived_surv_rate_group->all_surviving_words_recorded(predictor(), update);
+    _survivor_surv_rate_group->all_surviving_words_recorded(predictor(), update);
+  }
+
+  G1MMUTracker* mmu_tracker() {
+    return _mmu_tracker;
+  }
+
+  const G1MMUTracker* mmu_tracker() const {
+    return _mmu_tracker;
+  }
+
+  double max_pause_time_ms() const {
+    return _mmu_tracker->max_gc_time() * 1000.0;
+  }
+
+  // Returns an estimate of the survival rate of the region at yg-age
+  // "yg_age".
+  double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const;
+
+  double predict_yg_surv_rate(int age) const;
+
+  double accum_yg_surv_rate_pred(int age) const;
+
+protected:
+  G1CollectionSet* _collection_set;
+  virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const;
+  virtual double other_time_ms(double pause_time_ms) const;
+
+  double young_other_time_ms() const;
+  double non_young_other_time_ms() const;
+  double constant_other_time_ms(double pause_time_ms) const;
+
+  CollectionSetChooser* cset_chooser() const;
+private:
+
+  // The number of bytes copied during the GC.
+  size_t _bytes_copied_during_gc;
+
+  // Stash a pointer to the g1 heap.
+  G1CollectedHeap* _g1;
+
+  G1GCPhaseTimes* _phase_times;
+
+  // This set of variables tracks the collector efficiency, in order to
+  // determine whether we should initiate a new marking.
+  double _mark_remark_start_sec;
+  double _mark_cleanup_start_sec;
+
+  // Updates the internal young list maximum and target lengths. Returns the
+  // unbounded young list target length.
+  uint update_young_list_max_and_target_length();
+  uint update_young_list_max_and_target_length(size_t rs_lengths);
+
+  // Update the young list target length either by setting it to the
+  // desired fixed value or by calculating it using G1's pause
+  // prediction model. If no rs_lengths parameter is passed, predict
+  // the RS lengths using the prediction model, otherwise use the
+  // given rs_lengths as the prediction.
+  // Returns the unbounded young list target length.
+  uint update_young_list_target_length(size_t rs_lengths);
+
+  // Calculate and return the minimum desired young list target
+  // length. This is the minimum desired young list length according
+  // to the user's inputs.
+  uint calculate_young_list_desired_min_length(uint base_min_length) const;
+
+  // Calculate and return the maximum desired young list target
+  // length. This is the maximum desired young list length according
+  // to the user's inputs.
+  uint calculate_young_list_desired_max_length() const;
+
+  // Calculate and return the maximum young list target length that
+  // can fit into the pause time goal. The parameters are: rs_lengths
+  // represent the prediction of how large the young RSet lengths will
+  // be, base_min_length is the already existing number of regions in
+  // the young list, min_length and max_length are the desired min and
+  // max young list length according to the user's inputs.
+  uint calculate_young_list_target_length(size_t rs_lengths,
+                                          uint base_min_length,
+                                          uint desired_min_length,
+                                          uint desired_max_length) const;
+
+  // Result of the bounded_young_list_target_length() method, containing both the
+  // bounded as well as the unbounded young list target lengths in this order.
+  typedef Pair<uint, uint, StackObj> YoungTargetLengths;
+  YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const;
+
+  void update_rs_lengths_prediction();
+  void update_rs_lengths_prediction(size_t prediction);
+
+  // Check whether a given young length (young_length) fits into the
+  // given target pause time and whether the prediction for the amount
+  // of objects to be copied for the given length will fit into the
+  // given free space (expressed by base_free_regions).  It is used by
+  // calculate_young_list_target_length().
+  bool predict_will_fit(uint young_length, double base_time_ms,
+                        uint base_free_regions, double target_pause_time_ms) const;
+
+public:
+  size_t pending_cards() const { return _pending_cards; }
+
+  // Calculate the minimum number of old regions we'll add to the CSet
+  // during a mixed GC.
+  uint calc_min_old_cset_length() const;
+
+  // Calculate the maximum number of old regions we'll add to the CSet
+  // during a mixed GC.
+  uint calc_max_old_cset_length() const;
+
+  // Returns the given amount of uncollected reclaimable space
+  // as a percentage of the current heap capacity.
+  double reclaimable_bytes_perc(size_t reclaimable_bytes) const;
+
+private:
+  // Sets up marking if proper conditions are met.
+  void maybe_start_marking();
+
+  // The kind of STW pause.
+  enum PauseKind {
+    FullGC,
+    YoungOnlyGC,
+    MixedGC,
+    LastYoungGC,
+    InitialMarkGC,
+    Cleanup,
+    Remark
+  };
+
+  // Calculate PauseKind from internal state.
+  PauseKind young_gc_pause_kind() const;
+  // Record the given STW pause with the given start and end times (in s).
+  void record_pause(PauseKind kind, double start, double end);
+  // Indicate that we aborted marking before doing any mixed GCs.
+  void abort_time_to_mixed_tracking();
+public:
+
+  G1DefaultPolicy();
+
+  virtual ~G1DefaultPolicy();
+
+  G1CollectorState* collector_state() const;
+
+  G1GCPhaseTimes* phase_times() const { return _phase_times; }
+
+  // Check the current value of the young list RSet lengths and
+  // compare it against the last prediction. If the current value is
+  // higher, recalculate the young list target length prediction.
+  void revise_young_list_target_length_if_necessary(size_t rs_lengths);
+
+  // This should be called after the heap is resized.
+  void record_new_heap_size(uint new_number_of_regions);
+
+  void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set);
+
+  virtual void note_gc_start();
+
+  bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0);
+
+  bool about_to_start_mixed_phase() const;
+
+  // Record the start and end of an evacuation pause.
+  void record_collection_pause_start(double start_time_sec);
+  void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc);
+
+  // Record the start and end of a full collection.
+  void record_full_collection_start();
+  void record_full_collection_end();
+
+  // Must currently be called while the world is stopped.
+  void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms);
+
+  // Record start and end of remark.
+  void record_concurrent_mark_remark_start();
+  void record_concurrent_mark_remark_end();
+
+  // Record start, end, and completion of cleanup.
+  void record_concurrent_mark_cleanup_start();
+  void record_concurrent_mark_cleanup_end();
+  void record_concurrent_mark_cleanup_completed();
+
+  virtual void print_phases();
+
+  // Record how much space we copied during a GC. This is typically
+  // called when a GC alloc region is being retired.
+  void record_bytes_copied_during_gc(size_t bytes) {
+    _bytes_copied_during_gc += bytes;
+  }
+
+  // The amount of space we copied during a GC.
+  size_t bytes_copied_during_gc() const {
+    return _bytes_copied_during_gc;
+  }
+
+  // Determine whether there are candidate regions so that the
+  // next GC should be mixed. The two action strings are used
+  // in the ergo output when the method returns true or false.
+  bool next_gc_should_be_mixed(const char* true_action_str,
+                               const char* false_action_str) const;
+
+  virtual void finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor);
+private:
+  // Set the state to start a concurrent marking cycle and clear
+  // _initiate_conc_mark_if_possible because it has now been
+  // acted on.
+  void initiate_conc_mark();
+
+public:
+  // This sets the initiate_conc_mark_if_possible() flag to start a
+  // new cycle, as long as we are not already in one. It's best if it
+  // is called during a safepoint when the test whether a cycle is in
+  // progress or not is stable.
+  bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause);
+
+  // This is called at the very beginning of an evacuation pause (it
+  // has to be the first thing that the pause does). If
+  // initiate_conc_mark_if_possible() is true, and the concurrent
+  // marking thread has completed its work during the previous cycle,
+  // it will set during_initial_mark_pause() to so that the pause does
+  // the initial-mark work and start a marking cycle.
+  void decide_on_conc_mark_initiation();
+
+  void finished_recalculating_age_indexes(bool is_survivors) {
+    if (is_survivors) {
+      _survivor_surv_rate_group->finished_recalculating_age_indexes();
+    } else {
+      _short_lived_surv_rate_group->finished_recalculating_age_indexes();
+    }
+  }
+
+  size_t young_list_target_length() const { return _young_list_target_length; }
+
+  bool should_allocate_mutator_region() const;
+
+  bool can_expand_young_list() const;
+
+  uint young_list_max_length() const {
+    return _young_list_max_length;
+  }
+
+  bool adaptive_young_list_length() const;
+
+  virtual bool should_process_references() const {
+    return true;
+  }
+
+  void transfer_survivors_to_cset(const G1SurvivorRegions* survivors);
+
+private:
+  //
+  // Survivor regions policy.
+  //
+
+  // Current tenuring threshold, set to 0 if the collector reaches the
+  // maximum amount of survivors regions.
+  uint _tenuring_threshold;
+
+  // The limit on the number of regions allocated for survivors.
+  uint _max_survivor_regions;
+
+  AgeTable _survivors_age_table;
+
+public:
+  uint tenuring_threshold() const { return _tenuring_threshold; }
+
+  uint max_survivor_regions() {
+    return _max_survivor_regions;
+  }
+
+  void note_start_adding_survivor_regions() {
+    _survivor_surv_rate_group->start_adding_regions();
+  }
+
+  void note_stop_adding_survivor_regions() {
+    _survivor_surv_rate_group->stop_adding_regions();
+  }
+
+  void record_age_table(AgeTable* age_table) {
+    _survivors_age_table.merge(age_table);
+  }
+
+  void update_max_gc_locker_expansion();
+
+  // Calculates survivor space parameters.
+  void update_survivors_policy();
+};
+
+#endif // SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp
similarity index 65%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp
index 135652e..c83261b 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp
@@ -19,14 +19,32 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
+ *
  */
 
-package sun.misc;
+#ifndef SHARE_VM_GC_G1_G1EDENREGIONS_HPP
+#define SHARE_VM_GC_G1_G1EDENREGIONS_HPP
 
-public class Unsafe {
-    private Unsafe() { }
+#include "gc/g1/heapRegion.hpp"
+#include "memory/allocation.hpp"
+#include "runtime/globals.hpp"
+#include "utilities/debug.hpp"
 
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class G1EdenRegions VALUE_OBJ_CLASS_SPEC {
+private:
+  int _length;
+
+public:
+  G1EdenRegions() : _length(0) {}
+
+  void add(HeapRegion* hr) {
+    assert(!hr->is_eden(), "should not already be set");
+    _length++;
+  }
+
+  void clear() { _length = 0; }
+
+  uint length() const { return _length; }
+};
+
+#endif // SHARE_VM_GC_G1_G1EDENREGIONS_HPP
diff --git a/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp b/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp
index 82d655e..f6c7371 100644
--- a/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp
@@ -33,6 +33,7 @@
 #include "gc/g1/g1_globals.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
+#include "gc/shared/preservedMarks.inline.hpp"
 
 class UpdateRSetDeferred : public OopsInHeapRegionClosure {
 private:
@@ -122,7 +123,7 @@
       size_t obj_size = obj->size();
 
       _marked_bytes += (obj_size * HeapWordSize);
-      obj->set_mark(markOopDesc::prototype());
+      PreservedMarks::init_forwarded_mark(obj);
 
       // While we were processing RSet buffers during the collection,
       // we actually didn't scan any cards on the collection set,
@@ -227,15 +228,6 @@
                                                during_conc_mark);
         _g1h->verifier()->check_bitmaps("Self-Forwarding Ptr Removal", hr);
 
-        // In the common case (i.e. when there is no evacuation
-        // failure) we make sure that the following is done when
-        // the region is freed so that it is "ready-to-go" when it's
-        // re-allocated. However, when evacuation failure happens, a
-        // region will remain in the heap and might ultimately be added
-        // to a CSet in the future. So we have to be careful here and
-        // make sure the region's RSet is ready for parallel iteration
-        // whenever this might be required in the future.
-        hr->rem_set()->reset_for_par_iteration();
         hr->reset_bot();
 
         size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark);
@@ -262,16 +254,3 @@
   HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id);
   _g1h->collection_set_iterate_from(hr, &rsfp_cl);
 }
-
-G1RestorePreservedMarksTask::G1RestorePreservedMarksTask(OopAndMarkOopStack* preserved_objs) :
-  AbstractGangTask("G1 Restore Preserved Marks"),
-  _preserved_objs(preserved_objs) {}
-
-void G1RestorePreservedMarksTask::work(uint worker_id) {
-  OopAndMarkOopStack& cur = _preserved_objs[worker_id];
-  while (!cur.is_empty()) {
-    OopAndMarkOop elem = cur.pop();
-    elem.set_mark();
-  }
-  cur.clear(true);
-}
diff --git a/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp b/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp
index eff37e8..9e1945e 100644
--- a/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp
@@ -27,7 +27,6 @@
 
 #include "gc/g1/g1OopClosures.hpp"
 #include "gc/g1/heapRegionManager.hpp"
- #include "gc/shared/preservedMarks.hpp"
 #include "gc/shared/workgroup.hpp"
 #include "utilities/globalDefinitions.hpp"
 
@@ -46,12 +45,4 @@
   void work(uint worker_id);
 };
 
-class G1RestorePreservedMarksTask : public AbstractGangTask {
-  OopAndMarkOopStack* _preserved_objs;
- public:
-  G1RestorePreservedMarksTask(OopAndMarkOopStack* preserved_objs);
-
-  void work(uint worker_id);
-};
-
 #endif // SHARE_VM_GC_G1_G1EVACFAILURE_HPP
diff --git a/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp b/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp
index 0a66488..2b6c391 100644
--- a/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "memory/allocation.inline.hpp"
+#include "gc/g1/g1_globals.hpp"
 #include "gc/g1/g1EvacStats.hpp"
 #include "gc/shared/gcId.hpp"
 #include "logging/log.hpp"
diff --git a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp
index bc7b17c..f7e8b1d 100644
--- a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp
@@ -23,9 +23,9 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/g1/concurrentG1Refine.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
+#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1StringDedup.hpp"
 #include "gc/g1/workerDataArray.inline.hpp"
 #include "memory/resourceArea.hpp"
@@ -60,7 +60,7 @@
   _gc_par_phases[SATBFiltering] = new WorkerDataArray<double>(max_gc_threads, "SATB Filtering (ms):");
 
   _gc_par_phases[UpdateRS] = new WorkerDataArray<double>(max_gc_threads, "Update RS (ms):");
-  if (ConcurrentG1Refine::hot_card_cache_enabled()) {
+  if (G1HotCardCache::default_use_cache()) {
     _gc_par_phases[ScanHCC] = new WorkerDataArray<double>(max_gc_threads, "Scan HCC (ms):");
   } else {
     _gc_par_phases[ScanHCC] = NULL;
@@ -255,7 +255,7 @@
     trace_phase(_gc_par_phases[i]);
   }
   debug_phase(_gc_par_phases[UpdateRS]);
-  if (ConcurrentG1Refine::hot_card_cache_enabled()) {
+  if (G1HotCardCache::default_use_cache()) {
     trace_phase(_gc_par_phases[ScanHCC]);
   }
   debug_phase(_gc_par_phases[ScanRS]);
diff --git a/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp b/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp
index 4843256..ec597f7 100644
--- a/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1HeapSizingPolicy.hpp"
+#include "memory/allocation.inline.hpp"
 
 G1HeapSizingPolicy* G1HeapSizingPolicy::create(const G1CollectedHeap* g1, const G1Analytics* analytics) {
   return new G1HeapSizingPolicy(g1, analytics);
diff --git a/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp b/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp
index 2d1562e..2250863 100644
--- a/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp
@@ -24,15 +24,14 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1HeapTransition.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "logging/log.hpp"
 #include "memory/metaspace.hpp"
 
 G1HeapTransition::Data::Data(G1CollectedHeap* g1_heap) {
-  YoungList* young_list = g1_heap->young_list();
-  _eden_length = young_list->eden_length();
-  _survivor_length = young_list->survivor_length();
+  _eden_length = g1_heap->eden_regions_count();
+  _survivor_length = g1_heap->survivor_regions_count();
   _old_length = g1_heap->old_regions_count();
   _humongous_length = g1_heap->humongous_regions_count();
   _metaspace_used_bytes = MetaspaceAux::used_bytes();
diff --git a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp
index ddbdfad..b8093e4 100644
--- a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp
@@ -29,13 +29,13 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1HeapVerifier.hpp"
 #include "gc/g1/g1MarkSweep.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1RemSet.hpp"
 #include "gc/g1/g1RootProcessor.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/g1/g1StringDedup.hpp"
-#include "gc/g1/youngList.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/oop.inline.hpp"
 
@@ -582,13 +582,13 @@
 
 void G1HeapVerifier::verify_dirty_young_list(HeapRegion* head) {
   G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set();
-  for (HeapRegion* hr = head; hr != NULL; hr = hr->get_next_young_region()) {
+  for (HeapRegion* hr = head; hr != NULL; hr = hr->next_in_collection_set()) {
     verify_dirty_region(hr);
   }
 }
 
 void G1HeapVerifier::verify_dirty_young_regions() {
-  verify_dirty_young_list(_g1h->young_list()->first_region());
+  verify_dirty_young_list(_g1h->collection_set()->inc_head());
 }
 
 bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap,
diff --git a/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp b/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp
index e8c7a4e..fdb99af 100644
--- a/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/g1/g1MMUTracker.hpp"
 #include "gc/shared/gcTrace.hpp"
+#include "logging/log.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "utilities/ostream.hpp"
 
@@ -107,6 +108,10 @@
   // Current entry needs to be added before calculating the value
   double slice_time = calculate_gc_time(end);
   G1MMUTracer::report_mmu(_time_slice, slice_time, _max_gc_time);
+
+  if (slice_time >= _max_gc_time) {
+    log_info(gc, mmu)("MMU target violated: %.1lfms (%.1lfms/%.1lfms)", slice_time * 1000.0, _max_gc_time * 1000.0, _time_slice * 1000);
+  }
 }
 
 // basically the _internal call does not remove expired entries
diff --git a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp
index 1dcbcc2..a0cf7c2 100644
--- a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp
@@ -24,8 +24,8 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1MonitoringSupport.hpp"
+#include "gc/g1/g1Policy.hpp"
 
 G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
                                            const char* name,
@@ -177,8 +177,8 @@
   // values we read here are possible (i.e., at a STW phase at the end
   // of a GC).
 
-  uint young_list_length = g1->young_list()->length();
-  uint survivor_list_length = g1->young_list()->survivor_length();
+  uint young_list_length = g1->young_regions_count();
+  uint survivor_list_length = g1->survivor_regions_count();
   assert(young_list_length >= survivor_list_length, "invariant");
   uint eden_list_length = young_list_length - survivor_list_length;
   // Max length includes any potential extensions to the young gen
@@ -237,7 +237,7 @@
   // When a new eden region is allocated, only the eden_used size is
   // affected (since we have recalculated everything else at the last GC).
 
-  uint young_region_num = g1h()->young_list()->length();
+  uint young_region_num = g1h()->young_regions_count();
   if (young_region_num > _young_region_num) {
     uint diff = young_region_num - _young_region_num;
     _eden_used += (size_t) diff * HeapRegion::GrainBytes;
diff --git a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp
index 0a42184..46cd63f 100644
--- a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp
@@ -75,19 +75,15 @@
 
   vmassert(_committed.size() == 0, "virtual space initialized more than once");
   BitMap::idx_t size_in_pages = rs.size() / page_size;
-  _committed.resize(size_in_pages, /* in_resource_area */ false);
+  _committed.initialize(size_in_pages);
   if (_special) {
-    _dirty.resize(size_in_pages, /* in_resource_area */ false);
+    _dirty.initialize(size_in_pages);
   }
 
   _tail_size = used_size % _page_size;
 }
 
 G1PageBasedVirtualSpace::~G1PageBasedVirtualSpace() {
-  release();
-}
-
-void G1PageBasedVirtualSpace::release() {
   // This does not release memory it never reserved.
   // Caller must release via rs.release();
   _low_boundary           = NULL;
@@ -96,8 +92,6 @@
   _executable             = false;
   _page_size              = 0;
   _tail_size              = 0;
-  _committed.resize(0, false);
-  _dirty.resize(0, false);
 }
 
 size_t G1PageBasedVirtualSpace::committed_size() const {
diff --git a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp
index 23a7d53..ed16fac 100644
--- a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp
@@ -57,13 +57,13 @@
   size_t _page_size;
 
   // Bitmap used for verification of commit/uncommit operations.
-  BitMap _committed;
+  CHeapBitMap _committed;
 
   // Bitmap used to keep track of which pages are dirty or not for _special
   // spaces. This is needed because for those spaces the underlying memory
   // will only be zero filled the first time it is committed. Calls to commit
   // will use this bitmap and return whether or not the memory is zero filled.
-  BitMap _dirty;
+  CHeapBitMap _dirty;
 
   // Indicates that the entire space has been committed and pinned in memory,
   // os::commit_memory() or os::uncommit_memory() have no function.
@@ -139,8 +139,6 @@
     return x;
   }
 
-  void release();
-
   void check_for_contiguity() PRODUCT_RETURN;
 
   // Debugging
diff --git a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp
index 6accb48..6b399ae 100644
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp
@@ -27,8 +27,8 @@
 
 #include "gc/g1/dirtyCardQueue.hpp"
 #include "gc/g1/g1CollectedHeap.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1OopClosures.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1RemSet.hpp"
 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
 #include "gc/shared/ageTable.hpp"
diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp
new file mode 100644
index 0000000..7824003
--- /dev/null
+++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_G1_G1POLICY_HPP
+#define SHARE_VM_GC_G1_G1POLICY_HPP
+
+#include "gc/g1/g1CollectorState.hpp"
+#include "gc/g1/g1GCPhaseTimes.hpp"
+#include "gc/g1/g1InCSetState.hpp"
+#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp"
+#include "gc/g1/g1MMUTracker.hpp"
+#include "gc/g1/g1Predictions.hpp"
+#include "gc/g1/g1YoungGenSizer.hpp"
+#include "gc/shared/gcCause.hpp"
+#include "utilities/pair.hpp"
+
+// A G1Policy makes policy decisions that determine the
+// characteristics of the collector.  Examples include:
+//   * choice of collection set.
+//   * when to collect.
+
+class HeapRegion;
+class G1CollectionSet;
+class CollectionSetChooser;
+class G1IHOPControl;
+class G1Analytics;
+class G1SurvivorRegions;
+class G1YoungGenSizer;
+
+class G1Policy: public CHeapObj<mtGC> {
+public:
+  virtual const G1Predictions& predictor() const = 0;
+  virtual const G1Analytics* analytics()   const = 0;
+
+  // Add the given number of bytes to the total number of allocated bytes in the old gen.
+  virtual void add_bytes_allocated_in_old_since_last_gc(size_t bytes) = 0;
+
+  // Accessors
+
+  virtual void set_region_eden(HeapRegion* hr) = 0;
+  virtual void set_region_survivor(HeapRegion* hr) = 0;
+
+  virtual void record_max_rs_lengths(size_t rs_lengths) = 0;
+
+  virtual double predict_base_elapsed_time_ms(size_t pending_cards) const = 0;
+  virtual double predict_base_elapsed_time_ms(size_t pending_cards,
+                                              size_t scanned_cards) const = 0;
+
+  virtual double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const = 0;
+
+  virtual void cset_regions_freed() = 0;
+
+  virtual G1MMUTracker* mmu_tracker() = 0;
+
+  virtual const G1MMUTracker* mmu_tracker() const = 0;
+
+  virtual double max_pause_time_ms() const = 0;
+
+  virtual size_t pending_cards() const = 0;
+
+  // Calculate the minimum number of old regions we'll add to the CSet
+  // during a mixed GC.
+  virtual uint calc_min_old_cset_length() const = 0;
+
+  // Calculate the maximum number of old regions we'll add to the CSet
+  // during a mixed GC.
+  virtual uint calc_max_old_cset_length() const = 0;
+
+  // Returns the given amount of uncollected reclaimable space
+  // as a percentage of the current heap capacity.
+  virtual double reclaimable_bytes_perc(size_t reclaimable_bytes) const = 0;
+
+  virtual ~G1Policy() {}
+
+  virtual G1CollectorState* collector_state() const = 0;
+
+  virtual G1GCPhaseTimes* phase_times() const = 0;
+
+  // Check the current value of the young list RSet lengths and
+  // compare it against the last prediction. If the current value is
+  // higher, recalculate the young list target length prediction.
+  virtual void revise_young_list_target_length_if_necessary(size_t rs_lengths) = 0;
+
+  // This should be called after the heap is resized.
+  virtual void record_new_heap_size(uint new_number_of_regions) = 0;
+
+  virtual void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) = 0;
+
+  virtual void note_gc_start() = 0;
+
+  virtual bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0) = 0;
+
+  // Record the start and end of an evacuation pause.
+  virtual void record_collection_pause_start(double start_time_sec) = 0;
+  virtual void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) = 0;
+
+  // Record the start and end of a full collection.
+  virtual void record_full_collection_start() = 0;
+  virtual void record_full_collection_end() = 0;
+
+  // Must currently be called while the world is stopped.
+  virtual void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) = 0;
+
+  // Record start and end of remark.
+  virtual void record_concurrent_mark_remark_start() = 0;
+  virtual void record_concurrent_mark_remark_end() = 0;
+
+  // Record start, end, and completion of cleanup.
+  virtual void record_concurrent_mark_cleanup_start() = 0;
+  virtual void record_concurrent_mark_cleanup_end() = 0;
+  virtual void record_concurrent_mark_cleanup_completed() = 0;
+
+  virtual void print_phases() = 0;
+
+  // Record how much space we copied during a GC. This is typically
+  // called when a GC alloc region is being retired.
+  virtual void record_bytes_copied_during_gc(size_t bytes) = 0;
+
+  // The amount of space we copied during a GC.
+  virtual size_t bytes_copied_during_gc() const = 0;
+
+  virtual void finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) = 0;
+
+  // This sets the initiate_conc_mark_if_possible() flag to start a
+  // new cycle, as long as we are not already in one. It's best if it
+  // is called during a safepoint when the test whether a cycle is in
+  // progress or not is stable.
+  virtual bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) = 0;
+
+  // This is called at the very beginning of an evacuation pause (it
+  // has to be the first thing that the pause does). If
+  // initiate_conc_mark_if_possible() is true, and the concurrent
+  // marking thread has completed its work during the previous cycle,
+  // it will set during_initial_mark_pause() to so that the pause does
+  // the initial-mark work and start a marking cycle.
+  virtual void decide_on_conc_mark_initiation() = 0;
+
+
+  virtual void finished_recalculating_age_indexes(bool is_survivors) = 0;
+
+  virtual void transfer_survivors_to_cset(const G1SurvivorRegions* survivors) = 0;
+
+  virtual size_t young_list_target_length() const = 0;
+
+  virtual bool should_allocate_mutator_region() const = 0;
+
+  virtual bool can_expand_young_list() const = 0;
+
+  virtual uint young_list_max_length() const = 0;
+
+  virtual bool adaptive_young_list_length() const = 0;
+
+  virtual bool should_process_references() const = 0;
+
+  virtual uint tenuring_threshold() const = 0;
+  virtual uint max_survivor_regions() = 0;
+
+  virtual void note_start_adding_survivor_regions() = 0;
+
+  virtual void note_stop_adding_survivor_regions() = 0;
+
+  virtual void record_age_table(AgeTable* age_table) = 0;
+};
+
+#endif // SHARE_VM_GC_G1_G1POLICY_HPP
diff --git a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp
index cfac671..80b7941 100644
--- a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp
@@ -34,11 +34,12 @@
                                              size_t used_size,
                                              size_t page_size,
                                              size_t region_granularity,
+                                             size_t commit_factor,
                                              MemoryType type) :
   _storage(rs, used_size, page_size),
   _region_granularity(region_granularity),
   _listener(NULL),
-  _commit_map() {
+  _commit_map(rs.size() * commit_factor / region_granularity) {
   guarantee(is_power_of_2(page_size), "must be");
   guarantee(is_power_of_2(region_granularity), "must be");
 
@@ -59,11 +60,10 @@
                                       size_t alloc_granularity,
                                       size_t commit_factor,
                                       MemoryType type) :
-    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type),
+    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
     _pages_per_region(alloc_granularity / (page_size * commit_factor)) {
 
     guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity");
-    _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false);
   }
 
   virtual void commit_regions(uint start_idx, size_t num_regions) {
@@ -103,12 +103,11 @@
                                        size_t alloc_granularity,
                                        size_t commit_factor,
                                        MemoryType type) :
-    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type),
+    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
     _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() {
 
     guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity");
     _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_size_up(rs.size(), page_size)), page_size);
-    _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false);
   }
 
   virtual void commit_regions(uint start_idx, size_t num_regions) {
diff --git a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp
index a6d085e..218ae15 100644
--- a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp
@@ -49,9 +49,9 @@
 
   size_t _region_granularity;
   // Mapping management
-  BitMap _commit_map;
+  CHeapBitMap _commit_map;
 
-  G1RegionToSpaceMapper(ReservedSpace rs, size_t used_size, size_t page_size, size_t region_granularity, MemoryType type);
+  G1RegionToSpaceMapper(ReservedSpace rs, size_t used_size, size_t page_size, size_t region_granularity, size_t commit_factor, MemoryType type);
 
   void fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled);
  public:
@@ -62,9 +62,7 @@
 
   void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; }
 
-  virtual ~G1RegionToSpaceMapper() {
-    _commit_map.resize(0, /* in_resource_area */ false);
-  }
+  virtual ~G1RegionToSpaceMapper() {}
 
   bool is_committed(uintptr_t idx) const {
     return _commit_map.at(idx);
diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp
index 12ed050..9871a7c 100644
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp
@@ -24,11 +24,9 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/concurrentG1Refine.hpp"
-#include "gc/g1/concurrentG1RefineThread.hpp"
 #include "gc/g1/dirtyCardQueue.hpp"
 #include "gc/g1/g1BlockOffsetTable.inline.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1FromCardCache.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
 #include "gc/g1/g1HotCardCache.hpp"
@@ -46,20 +44,213 @@
 #include "utilities/intHisto.hpp"
 #include "utilities/stack.inline.hpp"
 
-G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) :
+// Collects information about the overall remembered set scan progress during an evacuation.
+class G1RemSetScanState : public CHeapObj<mtGC> {
+private:
+  class G1ClearCardTableTask : public AbstractGangTask {
+    G1CollectedHeap* _g1h;
+    uint* _dirty_region_list;
+    size_t _num_dirty_regions;
+    size_t _chunk_length;
+
+    size_t volatile _cur_dirty_regions;
+  public:
+    G1ClearCardTableTask(G1CollectedHeap* g1h,
+                         uint* dirty_region_list,
+                         size_t num_dirty_regions,
+                         size_t chunk_length) :
+      AbstractGangTask("G1 Clear Card Table Task"),
+      _g1h(g1h),
+      _dirty_region_list(dirty_region_list),
+      _num_dirty_regions(num_dirty_regions),
+      _chunk_length(chunk_length),
+      _cur_dirty_regions(0) {
+
+      assert(chunk_length > 0, "must be");
+    }
+
+    static size_t chunk_size() { return M; }
+
+    void work(uint worker_id) {
+      G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set();
+
+      while (_cur_dirty_regions < _num_dirty_regions) {
+        size_t next = Atomic::add(_chunk_length, &_cur_dirty_regions) - _chunk_length;
+        size_t max = MIN2(next + _chunk_length, _num_dirty_regions);
+
+        for (size_t i = next; i < max; i++) {
+          HeapRegion* r = _g1h->region_at(_dirty_region_list[i]);
+          if (!r->is_survivor()) {
+            ct_bs->clear(MemRegion(r->bottom(), r->end()));
+          }
+        }
+      }
+    }
+  };
+
+  size_t _max_regions;
+
+  // Scan progress for the remembered set of a single region. Transitions from
+  // Unclaimed -> Claimed -> Complete.
+  // At each of the transitions the thread that does the transition needs to perform
+  // some special action once. This is the reason for the extra "Claimed" state.
+  typedef jint G1RemsetIterState;
+
+  static const G1RemsetIterState Unclaimed = 0; // The remembered set has not been scanned yet.
+  static const G1RemsetIterState Claimed = 1;   // The remembered set is currently being scanned.
+  static const G1RemsetIterState Complete = 2;  // The remembered set has been completely scanned.
+
+  G1RemsetIterState volatile* _iter_states;
+  // The current location where the next thread should continue scanning in a region's
+  // remembered set.
+  size_t volatile* _iter_claims;
+
+  // Temporary buffer holding the regions we used to store remembered set scan duplicate
+  // information. These are also called "dirty". Valid entries are from [0.._cur_dirty_region)
+  uint* _dirty_region_buffer;
+
+  typedef jbyte IsDirtyRegionState;
+  static const IsDirtyRegionState Clean = 0;
+  static const IsDirtyRegionState Dirty = 1;
+  // Holds a flag for every region whether it is in the _dirty_region_buffer already
+  // to avoid duplicates. Uses jbyte since there are no atomic instructions for bools.
+  IsDirtyRegionState* _in_dirty_region_buffer;
+  size_t _cur_dirty_region;
+public:
+  G1RemSetScanState() :
+    _max_regions(0),
+    _iter_states(NULL),
+    _iter_claims(NULL),
+    _dirty_region_buffer(NULL),
+    _in_dirty_region_buffer(NULL),
+    _cur_dirty_region(0) {
+
+  }
+
+  ~G1RemSetScanState() {
+    if (_iter_states != NULL) {
+      FREE_C_HEAP_ARRAY(G1RemsetIterState, _iter_states);
+    }
+    if (_iter_claims != NULL) {
+      FREE_C_HEAP_ARRAY(size_t, _iter_claims);
+    }
+    if (_dirty_region_buffer != NULL) {
+      FREE_C_HEAP_ARRAY(uint, _dirty_region_buffer);
+    }
+    if (_in_dirty_region_buffer != NULL) {
+      FREE_C_HEAP_ARRAY(IsDirtyRegionState, _in_dirty_region_buffer);
+    }
+  }
+
+  void initialize(uint max_regions) {
+    assert(_iter_states == NULL, "Must not be initialized twice");
+    assert(_iter_claims == NULL, "Must not be initialized twice");
+    _max_regions = max_regions;
+    _iter_states = NEW_C_HEAP_ARRAY(G1RemsetIterState, max_regions, mtGC);
+    _iter_claims = NEW_C_HEAP_ARRAY(size_t, max_regions, mtGC);
+    _dirty_region_buffer = NEW_C_HEAP_ARRAY(uint, max_regions, mtGC);
+    _in_dirty_region_buffer = NEW_C_HEAP_ARRAY(IsDirtyRegionState, max_regions, mtGC);
+  }
+
+  void reset() {
+    for (uint i = 0; i < _max_regions; i++) {
+      _iter_states[i] = Unclaimed;
+    }
+    memset((void*)_iter_claims, 0, _max_regions * sizeof(size_t));
+    memset(_in_dirty_region_buffer, Clean, _max_regions * sizeof(IsDirtyRegionState));
+    _cur_dirty_region = 0;
+  }
+
+  // Attempt to claim the remembered set of the region for iteration. Returns true
+  // if this call caused the transition from Unclaimed to Claimed.
+  inline bool claim_iter(uint region) {
+    assert(region < _max_regions, "Tried to access invalid region %u", region);
+    if (_iter_states[region] != Unclaimed) {
+      return false;
+    }
+    jint res = Atomic::cmpxchg(Claimed, (jint*)(&_iter_states[region]), Unclaimed);
+    return (res == Unclaimed);
+  }
+
+  // Try to atomically sets the iteration state to "complete". Returns true for the
+  // thread that caused the transition.
+  inline bool set_iter_complete(uint region) {
+    if (iter_is_complete(region)) {
+      return false;
+    }
+    jint res = Atomic::cmpxchg(Complete, (jint*)(&_iter_states[region]), Claimed);
+    return (res == Claimed);
+  }
+
+  // Returns true if the region's iteration is complete.
+  inline bool iter_is_complete(uint region) const {
+    assert(region < _max_regions, "Tried to access invalid region %u", region);
+    return _iter_states[region] == Complete;
+  }
+
+  // The current position within the remembered set of the given region.
+  inline size_t iter_claimed(uint region) const {
+    assert(region < _max_regions, "Tried to access invalid region %u", region);
+    return _iter_claims[region];
+  }
+
+  // Claim the next block of cards within the remembered set of the region with
+  // step size.
+  inline size_t iter_claimed_next(uint region, size_t step) {
+    return Atomic::add(step, &_iter_claims[region]) - step;
+  }
+
+  void add_dirty_region(uint region) {
+    if (_in_dirty_region_buffer[region] == Dirty) {
+      return;
+    }
+
+    bool marked_as_dirty = Atomic::cmpxchg(Dirty, &_in_dirty_region_buffer[region], Clean) == Clean;
+    if (marked_as_dirty) {
+      size_t allocated = Atomic::add(1, &_cur_dirty_region) - 1;
+      _dirty_region_buffer[allocated] = region;
+    }
+  }
+
+  // Clear the card table of "dirty" regions.
+  void clear_card_table(WorkGang* workers) {
+    if (_cur_dirty_region == 0) {
+      return;
+    }
+
+    size_t const num_chunks = align_size_up(_cur_dirty_region * HeapRegion::CardsPerRegion, G1ClearCardTableTask::chunk_size()) / G1ClearCardTableTask::chunk_size();
+    uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers());
+    size_t const chunk_length = G1ClearCardTableTask::chunk_size() / HeapRegion::CardsPerRegion;
+
+    // Iterate over the dirty cards region list.
+    G1ClearCardTableTask cl(G1CollectedHeap::heap(), _dirty_region_buffer, _cur_dirty_region, chunk_length);
+
+    log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " "
+                        "units of work for " SIZE_FORMAT " regions.",
+                        cl.name(), num_workers, num_chunks, _cur_dirty_region);
+    workers->run_task(&cl, num_workers);
+
+#ifndef PRODUCT
+    // Need to synchronize with concurrent cleanup since it needs to
+    // finish its card table clearing before we can verify.
+    G1CollectedHeap::heap()->wait_while_free_regions_coming();
+    G1CollectedHeap::heap()->verifier()->verify_card_table_cleanup();
+#endif
+  }
+};
+
+G1RemSet::G1RemSet(G1CollectedHeap* g1,
+                   CardTableModRefBS* ct_bs,
+                   G1HotCardCache* hot_card_cache) :
   _g1(g1),
+  _scan_state(new G1RemSetScanState()),
   _conc_refine_cards(0),
   _ct_bs(ct_bs),
   _g1p(_g1->g1_policy()),
-  _cg1r(g1->concurrent_g1_refine()),
-  _cset_rs_update_cl(NULL),
+  _hot_card_cache(hot_card_cache),
   _prev_period_summary(),
   _into_cset_dirty_card_queue_set(false)
 {
-  _cset_rs_update_cl = NEW_C_HEAP_ARRAY(G1ParPushHeapRSClosure*, n_workers(), mtGC);
-  for (uint i = 0; i < n_workers(); i++) {
-    _cset_rs_update_cl[i] = NULL;
-  }
   if (log_is_enabled(Trace, gc, remset)) {
     _prev_period_summary.initialize(this);
   }
@@ -75,10 +266,9 @@
 }
 
 G1RemSet::~G1RemSet() {
-  for (uint i = 0; i < n_workers(); i++) {
-    assert(_cset_rs_update_cl[i] == NULL, "it should be");
+  if (_scan_state != NULL) {
+    delete _scan_state;
   }
-  FREE_C_HEAP_ARRAY(G1ParPushHeapRSClosure*, _cset_rs_update_cl);
 }
 
 uint G1RemSet::num_par_rem_sets() {
@@ -87,6 +277,7 @@
 
 void G1RemSet::initialize(size_t capacity, uint max_regions) {
   G1FromCardCache::initialize(num_par_rem_sets(), max_regions);
+  _scan_state->initialize(max_regions);
   {
     GCTraceTime(Debug, gc, marking)("Initialize Card Live Data");
     _card_live_data.initialize(capacity, max_regions);
@@ -97,29 +288,29 @@
   }
 }
 
-ScanRSClosure::ScanRSClosure(G1ParPushHeapRSClosure* oc,
-                             CodeBlobClosure* code_root_cl,
-                             uint worker_i) :
-  _oc(oc),
+G1ScanRSClosure::G1ScanRSClosure(G1RemSetScanState* scan_state,
+                                 G1ParPushHeapRSClosure* push_heap_cl,
+                                 CodeBlobClosure* code_root_cl,
+                                 uint worker_i) :
+  _scan_state(scan_state),
+  _push_heap_cl(push_heap_cl),
   _code_root_cl(code_root_cl),
   _strong_code_root_scan_time_sec(0.0),
   _cards(0),
   _cards_done(0),
-  _worker_i(worker_i),
-  _try_claimed(false) {
+  _worker_i(worker_i) {
   _g1h = G1CollectedHeap::heap();
   _bot = _g1h->bot();
   _ct_bs = _g1h->g1_barrier_set();
   _block_size = MAX2<size_t>(G1RSetScanBlockSize, 1);
 }
 
-void ScanRSClosure::scanCard(size_t index, HeapRegion *r) {
+void G1ScanRSClosure::scan_card(size_t index, HeapRegion *r) {
   // Stack allocate the DirtyCardToOopClosure instance
-  HeapRegionDCTOC cl(_g1h, r, _oc,
-      CardTableModRefBS::Precise);
+  HeapRegionDCTOC cl(_g1h, r, _push_heap_cl, CardTableModRefBS::Precise);
 
   // Set the "from" region in the closure.
-  _oc->set_region(r);
+  _push_heap_cl->set_region(r);
   MemRegion card_region(_bot->address_for_index(index), BOTConstants::N_words);
   MemRegion pre_gc_allocated(r->bottom(), r->scan_top());
   MemRegion mr = pre_gc_allocated.intersection(card_region);
@@ -133,81 +324,76 @@
   }
 }
 
-void ScanRSClosure::scan_strong_code_roots(HeapRegion* r) {
+void G1ScanRSClosure::scan_strong_code_roots(HeapRegion* r) {
   double scan_start = os::elapsedTime();
   r->strong_code_roots_do(_code_root_cl);
   _strong_code_root_scan_time_sec += (os::elapsedTime() - scan_start);
 }
 
-bool ScanRSClosure::doHeapRegion(HeapRegion* r) {
+bool G1ScanRSClosure::doHeapRegion(HeapRegion* r) {
   assert(r->in_collection_set(), "should only be called on elements of CS.");
-  HeapRegionRemSet* hrrs = r->rem_set();
-  if (hrrs->iter_is_complete()) return false; // All done.
-  if (!_try_claimed && !hrrs->claim_iter()) return false;
-  // If we ever free the collection set concurrently, we should also
-  // clear the card table concurrently therefore we won't need to
-  // add regions of the collection set to the dirty cards region.
-  _g1h->push_dirty_cards_region(r);
-  // If we didn't return above, then
-  //   _try_claimed || r->claim_iter()
-  // is true: either we're supposed to work on claimed-but-not-complete
-  // regions, or we successfully claimed the region.
+  uint region_idx = r->hrm_index();
 
-  HeapRegionRemSetIterator iter(hrrs);
+  if (_scan_state->iter_is_complete(region_idx)) {
+    return false;
+  }
+  if (_scan_state->claim_iter(region_idx)) {
+    // If we ever free the collection set concurrently, we should also
+    // clear the card table concurrently therefore we won't need to
+    // add regions of the collection set to the dirty cards region.
+    _scan_state->add_dirty_region(region_idx);
+  }
+
+  HeapRegionRemSetIterator iter(r->rem_set());
   size_t card_index;
 
   // We claim cards in block so as to reduce the contention. The block size is determined by
   // the G1RSetScanBlockSize parameter.
-  size_t jump_to_card = hrrs->iter_claimed_next(_block_size);
+  size_t claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size);
   for (size_t current_card = 0; iter.has_next(card_index); current_card++) {
-    if (current_card >= jump_to_card + _block_size) {
-      jump_to_card = hrrs->iter_claimed_next(_block_size);
+    if (current_card >= claimed_card_block + _block_size) {
+      claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size);
     }
-    if (current_card < jump_to_card) continue;
+    if (current_card < claimed_card_block) {
+      continue;
+    }
     HeapWord* card_start = _g1h->bot()->address_for_index(card_index);
 
     HeapRegion* card_region = _g1h->heap_region_containing(card_start);
     _cards++;
 
-    if (!card_region->is_on_dirty_cards_region_list()) {
-      _g1h->push_dirty_cards_region(card_region);
-    }
+    _scan_state->add_dirty_region(card_region->hrm_index());
 
     // If the card is dirty, then we will scan it during updateRS.
     if (!card_region->in_collection_set() &&
         !_ct_bs->is_card_dirty(card_index)) {
-      scanCard(card_index, card_region);
+      scan_card(card_index, card_region);
     }
   }
-  if (!_try_claimed) {
+  if (_scan_state->set_iter_complete(region_idx)) {
     // Scan the strong code root list attached to the current region
     scan_strong_code_roots(r);
-
-    hrrs->set_iter_complete();
   }
   return false;
 }
 
-size_t G1RemSet::scanRS(G1ParPushHeapRSClosure* oc,
-                        CodeBlobClosure* heap_region_codeblobs,
-                        uint worker_i) {
+size_t G1RemSet::scan_rem_set(G1ParPushHeapRSClosure* oops_in_heap_closure,
+                              CodeBlobClosure* heap_region_codeblobs,
+                              uint worker_i) {
   double rs_time_start = os::elapsedTime();
 
   HeapRegion *startRegion = _g1->start_cset_region_for_worker(worker_i);
 
-  ScanRSClosure scanRScl(oc, heap_region_codeblobs, worker_i);
+  G1ScanRSClosure cl(_scan_state, oops_in_heap_closure, heap_region_codeblobs, worker_i);
+  _g1->collection_set_iterate_from(startRegion, &cl);
 
-  _g1->collection_set_iterate_from(startRegion, &scanRScl);
-  scanRScl.set_try_claimed();
-  _g1->collection_set_iterate_from(startRegion, &scanRScl);
-
-  double scan_rs_time_sec = (os::elapsedTime() - rs_time_start)
-                            - scanRScl.strong_code_root_scan_time_sec();
+   double scan_rs_time_sec = (os::elapsedTime() - rs_time_start) -
+                              cl.strong_code_root_scan_time_sec();
 
   _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, scan_rs_time_sec);
-  _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, scanRScl.strong_code_root_scan_time_sec());
+  _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, cl.strong_code_root_scan_time_sec());
 
-  return scanRScl.cards_done();
+  return cl.cards_done();
 }
 
 // Closure used for updating RSets and recording references that
@@ -217,10 +403,12 @@
 class RefineRecordRefsIntoCSCardTableEntryClosure: public CardTableEntryClosure {
   G1RemSet* _g1rs;
   DirtyCardQueue* _into_cset_dcq;
+  G1ParPushHeapRSClosure* _cl;
 public:
   RefineRecordRefsIntoCSCardTableEntryClosure(G1CollectedHeap* g1h,
-                                              DirtyCardQueue* into_cset_dcq) :
-    _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq)
+                                              DirtyCardQueue* into_cset_dcq,
+                                              G1ParPushHeapRSClosure* cl) :
+    _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq), _cl(cl)
   {}
 
   bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
@@ -231,7 +419,7 @@
     assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
     assert(worker_i < ParallelGCThreads, "should be a GC worker");
 
-    if (_g1rs->refine_card(card_ptr, worker_i, true)) {
+    if (_g1rs->refine_card(card_ptr, worker_i, _cl)) {
       // 'card_ptr' contains references that point into the collection
       // set. We need to record the card in the DCQS
       // (_into_cset_dirty_card_queue_set)
@@ -244,11 +432,13 @@
   }
 };
 
-void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i) {
-  RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq);
+void G1RemSet::update_rem_set(DirtyCardQueue* into_cset_dcq,
+                              G1ParPushHeapRSClosure* oops_in_heap_closure,
+                              uint worker_i) {
+  RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq, oops_in_heap_closure);
 
   G1GCParPhaseTimesTracker x(_g1p->phase_times(), G1GCPhaseTimes::UpdateRS, worker_i);
-  if (ConcurrentG1Refine::hot_card_cache_enabled()) {
+  if (G1HotCardCache::default_use_cache()) {
     // Apply the closure to the entries of the hot card cache.
     G1GCParPhaseTimesTracker y(_g1p->phase_times(), G1GCPhaseTimes::ScanHCC, worker_i);
     _g1->iterate_hcc_closure(&into_cset_update_rs_cl, worker_i);
@@ -261,14 +451,9 @@
   HeapRegionRemSet::cleanup();
 }
 
-size_t G1RemSet::oops_into_collection_set_do(G1ParPushHeapRSClosure* oc,
+size_t G1RemSet::oops_into_collection_set_do(G1ParPushHeapRSClosure* cl,
                                              CodeBlobClosure* heap_region_codeblobs,
                                              uint worker_i) {
-  // We cache the value of 'oc' closure into the appropriate slot in the
-  // _cset_rs_update_cl for this worker
-  assert(worker_i < n_workers(), "sanity");
-  _cset_rs_update_cl[worker_i] = oc;
-
   // A DirtyCardQueue that is used to hold cards containing references
   // that point into the collection set. This DCQ is associated with a
   // special DirtyCardQueueSet (see g1CollectedHeap.hpp).  Under normal
@@ -280,25 +465,27 @@
   // DirtyCardQueueSet that is used to manage RSet updates
   DirtyCardQueue into_cset_dcq(&_into_cset_dirty_card_queue_set);
 
-  updateRS(&into_cset_dcq, worker_i);
-  size_t cards_scanned = scanRS(oc, heap_region_codeblobs, worker_i);
-
-  // We now clear the cached values of _cset_rs_update_cl for this worker
-  _cset_rs_update_cl[worker_i] = NULL;
-  return cards_scanned;
+  update_rem_set(&into_cset_dcq, cl, worker_i);
+  return scan_rem_set(cl, heap_region_codeblobs, worker_i);;
 }
 
 void G1RemSet::prepare_for_oops_into_collection_set_do() {
   _g1->set_refine_cte_cl_concurrency(false);
   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
   dcqs.concatenate_logs();
+
+  _scan_state->reset();
 }
 
 void G1RemSet::cleanup_after_oops_into_collection_set_do() {
+  G1GCPhaseTimes* phase_times = _g1->g1_policy()->phase_times();
   // Cleanup after copy
   _g1->set_refine_cte_cl_concurrency(true);
+
   // Set all cards back to clean.
-  _g1->cleanUpCardTable();
+  double start = os::elapsedTime();
+  _scan_state->clear_card_table(_g1->workers());
+  phase_times->record_clear_ct_time((os::elapsedTime() - start) * 1000.0);
 
   DirtyCardQueueSet& into_cset_dcqs = _into_cset_dirty_card_queue_set;
 
@@ -310,7 +497,7 @@
     // used to hold cards that contain references that point into the collection set
     // to the DCQS used to hold the deferred RS updates.
     _g1->dirty_card_queue_set().merge_bufferlists(&into_cset_dcqs);
-    _g1->g1_policy()->phase_times()->record_evac_fail_restore_remsets((os::elapsedTime() - restore_remembered_set_start) * 1000.0);
+    phase_times->record_evac_fail_restore_remsets((os::elapsedTime() - restore_remembered_set_start) * 1000.0);
   }
 
   // Free any completed buffers in the DirtyCardQueueSet used to hold cards
@@ -366,8 +553,9 @@
 // into the collection set, if we're checking for such references;
 // false otherwise.
 
-bool G1RemSet::refine_card(jbyte* card_ptr, uint worker_i,
-                           bool check_for_refs_into_cset) {
+bool G1RemSet::refine_card(jbyte* card_ptr,
+                           uint worker_i,
+                           G1ParPushHeapRSClosure*  oops_in_heap_closure) {
   assert(_g1->is_in_exact(_ct_bs->addr_for(card_ptr)),
          "Card at " PTR_FORMAT " index " SIZE_FORMAT " representing heap at " PTR_FORMAT " (%u) must be in committed heap",
          p2i(card_ptr),
@@ -375,6 +563,8 @@
          p2i(_ct_bs->addr_for(card_ptr)),
          _g1->addr_to_region(_ct_bs->addr_for(card_ptr)));
 
+  bool check_for_refs_into_cset = oops_in_heap_closure != NULL;
+
   // If the card is no longer dirty, nothing to do.
   if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
     // No need to return that this card contains refs that point
@@ -425,12 +615,11 @@
   //   * a pointer to a "hot" card that was evicted from the "hot" cache.
   //
 
-  G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
-  if (hot_card_cache->use_cache()) {
+  if (_hot_card_cache->use_cache()) {
     assert(!check_for_refs_into_cset, "sanity");
     assert(!SafepointSynchronize::is_at_safepoint(), "sanity");
 
-    card_ptr = hot_card_cache->insert(card_ptr);
+    card_ptr = _hot_card_cache->insert(card_ptr);
     if (card_ptr == NULL) {
       // There was no eviction. Nothing to do.
       return false;
@@ -451,15 +640,6 @@
   HeapWord* end   = start + CardTableModRefBS::card_size_in_words;
   MemRegion dirtyRegion(start, end);
 
-  G1ParPushHeapRSClosure* oops_in_heap_closure = NULL;
-  if (check_for_refs_into_cset) {
-    // ConcurrentG1RefineThreads have worker numbers larger than what
-    // _cset_rs_update_cl[] is set up to handle. But those threads should
-    // only be active outside of a collection which means that when they
-    // reach here they should have check_for_refs_into_cset == false.
-    assert((size_t)worker_i < n_workers(), "index of worker larger than _cset_rs_update_cl[].length");
-    oops_in_heap_closure = _cset_rs_update_cl[worker_i];
-  }
   G1UpdateRSOrPushRefOopClosure update_rs_oop_cl(_g1,
                                                  _g1->g1_rem_set(),
                                                  oops_in_heap_closure,
@@ -574,15 +754,14 @@
       dcqs.concatenate_logs();
     }
 
-    G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
-    bool use_hot_card_cache = hot_card_cache->use_cache();
-    hot_card_cache->set_use_cache(false);
+    bool use_hot_card_cache = _hot_card_cache->use_cache();
+    _hot_card_cache->set_use_cache(false);
 
     DirtyCardQueue into_cset_dcq(&_into_cset_dirty_card_queue_set);
-    updateRS(&into_cset_dcq, 0);
+    update_rem_set(&into_cset_dcq, NULL, 0);
     _into_cset_dirty_card_queue_set.clear();
 
-    hot_card_cache->set_use_cache(use_hot_card_cache);
+    _hot_card_cache->set_use_cache(use_hot_card_cache);
     assert(JavaThread::dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed");
   }
 }
diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp
index 381d5fd..561b3cf 100644
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,11 +38,12 @@
 class BitMap;
 class CardTableModRefBS;
 class G1BlockOffsetTable;
-class ConcurrentG1Refine;
 class CodeBlobClosure;
 class G1CollectedHeap;
-class G1CollectorPolicy;
+class G1HotCardCache;
 class G1ParPushHeapRSClosure;
+class G1RemSetScanState;
+class G1Policy;
 class G1SATBCardTableModRefBS;
 class HeapRegionClaimer;
 
@@ -51,6 +52,7 @@
 // so that they can be used to update the individual region remsets.
 class G1RemSet: public CHeapObj<mtGC> {
 private:
+  G1RemSetScanState* _scan_state;
   G1CardLiveData _card_live_data;
 
   G1RemSetSummary _prev_period_summary;
@@ -68,13 +70,8 @@
 
 protected:
   CardTableModRefBS*     _ct_bs;
-  G1CollectorPolicy*     _g1p;
-
-  ConcurrentG1Refine*    _cg1r;
-
-  // Used for caching the closure that is responsible for scanning
-  // references into the collection set.
-  G1ParPushHeapRSClosure** _cset_rs_update_cl;
+  G1Policy*              _g1p;
+  G1HotCardCache*        _hot_card_cache;
 
 public:
   // Gives an approximation on how many threads can be expected to add records to
@@ -92,12 +89,14 @@
   // scanned.
   void cleanupHRRS();
 
-  G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs);
+  G1RemSet(G1CollectedHeap* g1,
+           CardTableModRefBS* ct_bs,
+           G1HotCardCache* hot_card_cache);
   ~G1RemSet();
 
-  // Invoke "blk->do_oop" on all pointers into the collection set
+  // Invoke "cl->do_oop" on all pointers into the collection set
   // from objects in regions outside the collection set (having
-  // invoked "blk->set_region" to set the "from" region correctly
+  // invoked "cl->set_region" to set the "from" region correctly
   // beforehand.)
   //
   // Apply non_heap_roots on the oops of the unmarked nmethods
@@ -112,7 +111,7 @@
   //
   // Returns the number of cards scanned while looking for pointers
   // into the collection set.
-  size_t oops_into_collection_set_do(G1ParPushHeapRSClosure* blk,
+  size_t oops_into_collection_set_do(G1ParPushHeapRSClosure* cl,
                                      CodeBlobClosure* heap_region_codeblobs,
                                      uint worker_i);
 
@@ -124,13 +123,15 @@
   void prepare_for_oops_into_collection_set_do();
   void cleanup_after_oops_into_collection_set_do();
 
-  size_t scanRS(G1ParPushHeapRSClosure* oc,
-                CodeBlobClosure* heap_region_codeblobs,
-                uint worker_i);
+  size_t scan_rem_set(G1ParPushHeapRSClosure* oops_in_heap_closure,
+                      CodeBlobClosure* heap_region_codeblobs,
+                      uint worker_i);
 
-  void updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i);
+  G1RemSetScanState* scan_state() const { return _scan_state; }
 
-  CardTableModRefBS* ct_bs() { return _ct_bs; }
+  // Flush remaining refinement buffers into the remembered set,
+  // applying oops_in_heap_closure on the references found.
+  void update_rem_set(DirtyCardQueue* into_cset_dcq, G1ParPushHeapRSClosure* oops_in_heap_closure, uint worker_i);
 
   // Record, if necessary, the fact that *p (where "p" is in region "from",
   // which is required to be non-NULL) has changed to a new non-NULL value.
@@ -145,12 +146,12 @@
   void scrub(uint worker_num, HeapRegionClaimer* hrclaimer);
 
   // Refine the card corresponding to "card_ptr".
-  // If check_for_refs_into_cset is true, a true result is returned
+  // If oops_in_heap_closure is not NULL, a true result is returned
   // if the given card contains oops that have references into the
   // current collection set.
   virtual bool refine_card(jbyte* card_ptr,
                            uint worker_i,
-                           bool check_for_refs_into_cset);
+                           G1ParPushHeapRSClosure* oops_in_heap_closure);
 
   // Print accumulated summary info from the start of the VM.
   virtual void print_summary_info();
@@ -179,11 +180,14 @@
 #endif
 };
 
-class ScanRSClosure : public HeapRegionClosure {
-  size_t _cards_done, _cards;
+class G1ScanRSClosure : public HeapRegionClosure {
+  G1RemSetScanState* _scan_state;
+
+  size_t _cards_done;
+  size_t _cards;
   G1CollectedHeap* _g1h;
 
-  G1ParPushHeapRSClosure* _oc;
+  G1ParPushHeapRSClosure* _push_heap_cl;
   CodeBlobClosure* _code_root_cl;
 
   G1BlockOffsetTable* _bot;
@@ -192,26 +196,23 @@
   double _strong_code_root_scan_time_sec;
   uint   _worker_i;
   size_t _block_size;
-  bool   _try_claimed;
 
+  void scan_card(size_t index, HeapRegion *r);
+  void scan_strong_code_roots(HeapRegion* r);
 public:
-  ScanRSClosure(G1ParPushHeapRSClosure* oc,
-                CodeBlobClosure* code_root_cl,
-                uint worker_i);
+  G1ScanRSClosure(G1RemSetScanState* scan_state,
+                  G1ParPushHeapRSClosure* push_heap_cl,
+                  CodeBlobClosure* code_root_cl,
+                  uint worker_i);
 
   bool doHeapRegion(HeapRegion* r);
 
   double strong_code_root_scan_time_sec() {
     return _strong_code_root_scan_time_sec;
   }
+
   size_t cards_done() { return _cards_done;}
   size_t cards_looked_up() { return _cards;}
-  void set_try_claimed() { _try_claimed = true; }
-private:
-  void scanCard(size_t index, HeapRegion *r);
-  void printCard(HeapRegion* card_region, size_t card_index,
-                 HeapWord* card_start);
-  void scan_strong_code_roots(HeapRegion* r);
 };
 
 class UpdateRSOopClosure: public ExtendedOopClosure {
diff --git a/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp b/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp
index 5b226d1..53fe119 100644
--- a/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp
@@ -28,6 +28,7 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1RemSet.inline.hpp"
 #include "gc/g1/g1RemSetSummary.hpp"
+#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "memory/allocation.inline.hpp"
@@ -143,10 +144,6 @@
   _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime;
 }
 
-static size_t round_to_K(size_t value) {
-  return value / K;
-}
-
 class RegionTypeCounter VALUE_OBJ_CLASS_SPEC {
 private:
   const char* _name;
@@ -197,8 +194,10 @@
   size_t code_root_elems() const { return _code_root_elems; }
 
   void print_rs_mem_info_on(outputStream * out, size_t total) {
-    out->print_cr("    " SIZE_FORMAT_W(8) "K (%5.1f%%) by " SIZE_FORMAT " %s regions",
-        round_to_K(rs_mem_size()), rs_mem_size_percent_of(total), amount(), _name);
+    out->print_cr("    " SIZE_FORMAT_W(8) "%s (%5.1f%%) by " SIZE_FORMAT " %s regions",
+        byte_size_in_proper_unit(rs_mem_size()),
+        proper_unit_for_byte_size(rs_mem_size()),
+        rs_mem_size_percent_of(total), amount(), _name);
   }
 
   void print_cards_occupied_info_on(outputStream * out, size_t total) {
@@ -207,8 +206,10 @@
   }
 
   void print_code_root_mem_info_on(outputStream * out, size_t total) {
-    out->print_cr("    " SIZE_FORMAT_W(8) "K (%5.1f%%) by " SIZE_FORMAT " %s regions",
-        round_to_K(code_root_mem_size()), code_root_mem_size_percent_of(total), amount(), _name);
+    out->print_cr("    " SIZE_FORMAT_W(8) "%s (%5.1f%%) by " SIZE_FORMAT " %s regions",
+        byte_size_in_proper_unit(code_root_mem_size()),
+        proper_unit_for_byte_size(code_root_mem_size()),
+        code_root_mem_size_percent_of(total), amount(), _name);
   }
 
   void print_code_root_elems_info_on(outputStream * out, size_t total) {
@@ -290,17 +291,22 @@
     RegionTypeCounter* counters[] = { &_young, &_humongous, &_free, &_old, NULL };
 
     out->print_cr(" Current rem set statistics");
-    out->print_cr("  Total per region rem sets sizes = " SIZE_FORMAT "K."
-                  " Max = " SIZE_FORMAT "K.",
-                  round_to_K(total_rs_mem_sz()), round_to_K(max_rs_mem_sz()));
+    out->print_cr("  Total per region rem sets sizes = " SIZE_FORMAT "%s."
+                  " Max = " SIZE_FORMAT "%s.",
+                  byte_size_in_proper_unit(total_rs_mem_sz()),
+                  proper_unit_for_byte_size(total_rs_mem_sz()),
+                  byte_size_in_proper_unit(max_rs_mem_sz()),
+                  proper_unit_for_byte_size(max_rs_mem_sz()));
     for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) {
       (*current)->print_rs_mem_info_on(out, total_rs_mem_sz());
     }
 
-    out->print_cr("   Static structures = " SIZE_FORMAT "K,"
-                  " free_lists = " SIZE_FORMAT "K.",
-                  round_to_K(HeapRegionRemSet::static_mem_size()),
-                  round_to_K(HeapRegionRemSet::fl_mem_size()));
+    out->print_cr("   Static structures = " SIZE_FORMAT "%s,"
+                  " free_lists = " SIZE_FORMAT "%s.",
+                  byte_size_in_proper_unit(HeapRegionRemSet::static_mem_size()),
+                  proper_unit_for_byte_size(HeapRegionRemSet::static_mem_size()),
+                  byte_size_in_proper_unit(HeapRegionRemSet::fl_mem_size()),
+                  proper_unit_for_byte_size(HeapRegionRemSet::fl_mem_size()));
 
     out->print_cr("    " SIZE_FORMAT " occupied cards represented.",
                   total_cards_occupied());
@@ -311,17 +317,20 @@
     // Largest sized rem set region statistics
     HeapRegionRemSet* rem_set = max_rs_mem_sz_region()->rem_set();
     out->print_cr("    Region with largest rem set = " HR_FORMAT ", "
-                  "size = " SIZE_FORMAT "K, occupied = " SIZE_FORMAT "K.",
+                  "size = " SIZE_FORMAT "%s, occupied = " SIZE_FORMAT "%s.",
                   HR_FORMAT_PARAMS(max_rs_mem_sz_region()),
-                  round_to_K(rem_set->mem_size()),
-                  round_to_K(rem_set->occupied()));
-
+                  byte_size_in_proper_unit(rem_set->mem_size()),
+                  proper_unit_for_byte_size(rem_set->mem_size()),
+                  byte_size_in_proper_unit(rem_set->occupied()),
+                  proper_unit_for_byte_size(rem_set->occupied()));
     // Strong code root statistics
     HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set();
-    out->print_cr("  Total heap region code root sets sizes = " SIZE_FORMAT "K."
-                  "  Max = " SIZE_FORMAT "K.",
-                  round_to_K(total_code_root_mem_sz()),
-                  round_to_K(max_code_root_rem_set->strong_code_roots_mem_size()));
+    out->print_cr("  Total heap region code root sets sizes = " SIZE_FORMAT "%s."
+                  "  Max = " SIZE_FORMAT "%s.",
+                  byte_size_in_proper_unit(total_code_root_mem_sz()),
+                  proper_unit_for_byte_size(total_code_root_mem_sz()),
+                  byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
+                  proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()));
     for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) {
       (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz());
     }
@@ -333,10 +342,11 @@
     }
 
     out->print_cr("    Region with largest amount of code roots = " HR_FORMAT ", "
-                  "size = " SIZE_FORMAT "K, num_elems = " SIZE_FORMAT ".",
+                  "size = " SIZE_FORMAT "%s, num_elems = " SIZE_FORMAT ".",
                   HR_FORMAT_PARAMS(max_code_root_mem_sz_region()),
-                  round_to_K(max_code_root_rem_set->strong_code_roots_mem_size()),
-                  round_to_K(max_code_root_rem_set->strong_code_roots_list_length()));
+                  byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
+                  proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()),
+                  max_code_root_rem_set->strong_code_roots_list_length());
   }
 };
 
diff --git a/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp b/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp
index 4e54a68..5ecdade 100644
--- a/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
 
   CLDClosure* weak_clds()             { return &_closures._clds; }
   CLDClosure* strong_clds()           { return &_closures._clds; }
-  CLDClosure* thread_root_clds()      { return NULL; }
   CLDClosure* second_pass_weak_clds() { return NULL; }
 
   CodeBlobClosure* strong_codeblobs()      { return &_closures._codeblobs; }
@@ -89,7 +88,6 @@
 
   // If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants
   // return a NULL closure for the following specialized versions in that case.
-  CLDClosure* thread_root_clds()      { return null_if<G1MarkFromRoot>(&_strong._clds); }
   CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); }
 
   CodeBlobClosure* strong_codeblobs()      { return &_strong._codeblobs; }
diff --git a/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp b/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp
index 34e58f0..571a263 100644
--- a/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,9 +41,6 @@
   virtual CLDClosure* weak_clds() = 0;
   virtual CLDClosure* strong_clds() = 0;
 
-  // Applied to the CLDs reachable from the thread stacks.
-  virtual CLDClosure* thread_root_clds() = 0;
-
   // Applied to code blobs reachable as strong roots.
   virtual CodeBlobClosure* strong_codeblobs() = 0;
 };
diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp
index 14b1753..f8526e7 100644
--- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,9 +30,9 @@
 #include "gc/g1/bufferingOopClosure.hpp"
 #include "gc/g1/g1CodeBlobClosure.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1CollectorState.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1RootClosures.hpp"
 #include "gc/g1/g1RootProcessor.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
@@ -152,7 +152,6 @@
 
   CLDClosure* weak_clds()        { return NULL; }
   CLDClosure* strong_clds()      { return _clds; }
-  CLDClosure* thread_root_clds() { return _clds; }
 
   CodeBlobClosure* strong_codeblobs() { return _blobs; }
 };
@@ -184,9 +183,6 @@
   // system.
   CLDClosure* weak_clds() { return _clds; }
   CLDClosure* strong_clds() { return _clds; }
-  // We don't want to visit CLDs more than once, so we return NULL for the
-  // thread root CLDs.
-  CLDClosure* thread_root_clds() { return NULL; }
 
   // We don't want to visit code blobs more than once, so we return NULL for the
   // strong case and walk the entire code cache as a separate step.
@@ -211,7 +207,6 @@
 void G1RootProcessor::process_java_roots(G1RootClosures* closures,
                                          G1GCPhaseTimes* phase_times,
                                          uint worker_i) {
-  assert(closures->thread_root_clds() == NULL || closures->weak_clds() == NULL, "There is overlap between those, only one may be set");
   // Iterating over the CLDG and the Threads are done early to allow us to
   // first process the strong CLDs and nmethods and then, after a barrier,
   // let the thread process the weak CLDs and nmethods.
@@ -227,7 +222,6 @@
     bool is_par = n_workers() > 1;
     Threads::possibly_parallel_oops_do(is_par,
                                        closures->strong_oops(),
-                                       closures->thread_root_clds(),
                                        closures->strong_codeblobs());
   }
 }
diff --git a/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.cpp b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.cpp
new file mode 100644
index 0000000..ec49aea
--- /dev/null
+++ b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/g1/g1SurvivorRegions.hpp"
+#include "gc/g1/heapRegion.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/debug.hpp"
+
+G1SurvivorRegions::G1SurvivorRegions() : _regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapRegion*>(8, true, mtGC)) {}
+
+void G1SurvivorRegions::add(HeapRegion* hr) {
+  assert(hr->is_survivor(), "should be flagged as survivor region");
+  _regions->append(hr);
+}
+
+uint G1SurvivorRegions::length() const {
+  return (uint)_regions->length();
+}
+
+void G1SurvivorRegions::convert_to_eden() {
+  for (GrowableArrayIterator<HeapRegion*> it = _regions->begin();
+       it != _regions->end();
+       ++it) {
+    HeapRegion* hr = *it;
+    hr->set_eden_pre_gc();
+  }
+  clear();
+}
+
+void G1SurvivorRegions::clear() {
+  _regions->clear();
+}
+
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.hpp
similarity index 64%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to hotspot/src/share/vm/gc/g1/g1SurvivorRegions.hpp
index 135652e..9a83337 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.hpp
@@ -19,14 +19,37 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
+ *
  */
 
-package sun.misc;
+#ifndef SHARE_VM_GC_G1_G1SURVIVORREGIONS_HPP
+#define SHARE_VM_GC_G1_G1SURVIVORREGIONS_HPP
 
-public class Unsafe {
-    private Unsafe() { }
+#include "memory/allocation.hpp"
+#include "runtime/globals.hpp"
 
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+template <typename T>
+class GrowableArray;
+class HeapRegion;
+
+class G1SurvivorRegions VALUE_OBJ_CLASS_SPEC {
+private:
+  GrowableArray<HeapRegion*>* _regions;
+
+public:
+  G1SurvivorRegions();
+
+  void add(HeapRegion* hr);
+
+  void convert_to_eden();
+
+  void clear();
+
+  uint length() const;
+
+  const GrowableArray<HeapRegion*>* regions() const {
+    return _regions;
+  }
+};
+
+#endif // SHARE_VM_GC_G1_G1SURVIVORREGIONS_HPP
diff --git a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp
index e049f4d..c505873 100644
--- a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp
@@ -108,13 +108,18 @@
   assert(*min_young_length <= *max_young_length, "Invalid min/max young gen size values");
 }
 
-uint G1YoungGenSizer::max_young_length(uint number_of_heap_regions) {
+void G1YoungGenSizer::adjust_max_new_size(uint number_of_heap_regions) {
+
   // We need to pass the desired values because recalculation may not update these
   // values in some cases.
   uint temp = _min_desired_young_length;
   uint result = _max_desired_young_length;
   recalculate_min_max_young_length(number_of_heap_regions, &temp, &result);
-  return result;
+
+  size_t max_young_size = result * HeapRegion::GrainBytes;
+  if (max_young_size != MaxNewSize) {
+    FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size);
+  }
 }
 
 void G1YoungGenSizer::heap_size_changed(uint new_number_of_heap_regions) {
diff --git a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp
index 1d5421b..895cf6e 100644
--- a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp
@@ -22,6 +22,9 @@
  *
  */
 
+#ifndef SHARE_VM_GC_G1_G1YOUNGGENSIZER_HPP
+#define SHARE_VM_GC_G1_G1YOUNGGENSIZER_HPP
+
 #include "memory/allocation.hpp"
 
 // There are three command line options related to the young gen size:
@@ -60,7 +63,7 @@
 //
 // NewSize and MaxNewSize override NewRatio. So, NewRatio is ignored if it is
 // combined with either NewSize or MaxNewSize. (A warning message is printed.)
-class G1YoungGenSizer : public CHeapObj<mtGC> {
+class G1YoungGenSizer VALUE_OBJ_CLASS_SPEC {
 private:
   enum SizerKind {
     SizerDefaults,
@@ -84,13 +87,13 @@
   G1YoungGenSizer();
   // Calculate the maximum length of the young gen given the number of regions
   // depending on the sizing algorithm.
-  uint max_young_length(uint number_of_heap_regions);
+  void adjust_max_new_size(uint number_of_heap_regions);
 
   void heap_size_changed(uint new_number_of_heap_regions);
-  uint min_desired_young_length() {
+  uint min_desired_young_length() const {
     return _min_desired_young_length;
   }
-  uint max_desired_young_length() {
+  uint max_desired_young_length() const {
     return _max_desired_young_length;
   }
 
@@ -99,3 +102,4 @@
   }
 };
 
+#endif // SHARE_VM_GC_G1_G1YOUNGGENSIZER_HPP
diff --git a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp
index b435c05..5e57885 100644
--- a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp
@@ -24,8 +24,8 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1CollectionSet.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1YoungRemSetSamplingThread.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
@@ -74,23 +74,19 @@
 void G1YoungRemSetSamplingThread::sample_young_list_rs_lengths() {
   SuspendibleThreadSetJoiner sts;
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  G1CollectorPolicy* g1p = g1h->g1_policy();
+  G1Policy* g1p = g1h->g1_policy();
+  G1CollectionSet* g1cs = g1h->collection_set();
   if (g1p->adaptive_young_list_length()) {
     int regions_visited = 0;
-    HeapRegion* hr = g1h->young_list()->first_region();
+    HeapRegion* hr = g1cs->inc_head();
     size_t sampled_rs_lengths = 0;
 
     while (hr != NULL) {
       size_t rs_length = hr->rem_set()->occupied();
       sampled_rs_lengths += rs_length;
 
-      // The current region may not yet have been added to the
-      // incremental collection set (it gets added when it is
-      // retired as the current allocation region).
-      if (hr->in_collection_set()) {
-        // Update the collection set policy information for this region
-        g1h->collection_set()->update_young_region_prediction(hr, rs_length);
-      }
+      // Update the collection set policy information for this region
+      g1cs->update_young_region_prediction(hr, rs_length);
 
       ++regions_visited;
 
@@ -99,12 +95,13 @@
         if (sts.should_yield()) {
           sts.yield();
           // A gc may have occurred and our sampling data is stale and further
-          // traversal of the young list is unsafe
+          // traversal of the collection set is unsafe
           return;
         }
         regions_visited = 0;
       }
-      hr = hr->get_next_young_region();
+      assert(hr == g1cs->inc_tail() || hr->next_in_collection_set() != NULL, "next should only be null at tail of icset");
+      hr = hr->next_in_collection_set();
     }
     g1p->revise_young_list_target_length_if_necessary(sampled_rs_lengths);
   }
diff --git a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp
index 31cf79e..b5215ef 100644
--- a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp
@@ -37,7 +37,7 @@
 // The assumption is that a significant part of the GC is spent on scanning
 // the remembered sets (and many other components), so this thread constantly
 // reevaluates the prediction for the remembered set scanning costs, and potentially
-// G1CollectorPolicy resizes the young gen. This may do a premature GC or even
+// G1Policy resizes the young gen. This may do a premature GC or even
 // increase the young gen size to keep pause time length goal.
 class G1YoungRemSetSamplingThread: public ConcurrentGCThread {
 private:
diff --git a/hotspot/src/share/vm/gc/g1/g1_globals.cpp b/hotspot/src/share/vm/gc/g1/g1_globals.cpp
index c1bf99e..0b25b03 100644
--- a/hotspot/src/share/vm/gc/g1/g1_globals.cpp
+++ b/hotspot/src/share/vm/gc/g1/g1_globals.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,4 +35,5 @@
          MATERIALIZE_MANAGEABLE_FLAG, \
          MATERIALIZE_PRODUCT_RW_FLAG, \
          IGNORE_RANGE, \
-         IGNORE_CONSTRAINT)
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
diff --git a/hotspot/src/share/vm/gc/g1/g1_globals.hpp b/hotspot/src/share/vm/gc/g1/g1_globals.hpp
index ce8d96e..3abcba4 100644
--- a/hotspot/src/share/vm/gc/g1/g1_globals.hpp
+++ b/hotspot/src/share/vm/gc/g1/g1_globals.hpp
@@ -31,7 +31,18 @@
 // Defines all globals flags used by the garbage-first compiler.
 //
 
-#define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw, range, constraint) \
+#define G1_FLAGS(develop, \
+                 develop_pd, \
+                 product, \
+                 product_pd, \
+                 diagnostic, \
+                 experimental, \
+                 notproduct, \
+                 manageable, \
+                 product_rw, \
+                 range, \
+                 constraint, \
+                 writeable) \
                                                                             \
   product(bool, G1UseAdaptiveIHOP, true,                                    \
           "Adaptively adjust the initiating heap occupancy from the "       \
@@ -179,12 +190,6 @@
   develop(bool, G1ScrubRemSets, true,                                       \
           "When true, do RS scrubbing after cleanup.")                      \
                                                                             \
-  develop(intx, G1YoungSurvRateNumRegionsSummary, 0,                        \
-          "the number of regions for which we'll print a surv rate "        \
-          "summary.")                                                       \
-          range(0, max_intx)                                                \
-          constraint(G1YoungSurvRateNumRegionsSummaryConstraintFunc,AfterErgo)\
-                                                                            \
   product(uintx, G1ReservePercent, 10,                                      \
           "It determines the minimum reserve we should have in the heap "   \
           "to minimize the probability of promotion failure.")              \
@@ -323,6 +328,7 @@
          DECLARE_MANAGEABLE_FLAG, \
          DECLARE_PRODUCT_RW_FLAG, \
          IGNORE_RANGE, \
-         IGNORE_CONSTRAINT)
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
 
 #endif // SHARE_VM_GC_G1_G1_GLOBALS_HPP
diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.cpp b/hotspot/src/share/vm/gc/g1/heapRegion.cpp
index b88145d..44ef494 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp
@@ -153,6 +153,10 @@
 
   guarantee(CardsPerRegion == 0, "we should only set it once");
   CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
+
+  if (G1HeapRegionSize != GrainBytes) {
+    FLAG_SET_ERGO(size_t, G1HeapRegionSize, GrainBytes);
+  }
 }
 
 void HeapRegion::reset_after_compaction() {
@@ -187,6 +191,7 @@
   zero_marked_bytes();
 
   init_top_at_mark_start();
+  _gc_time_stamp = G1CollectedHeap::heap()->get_gc_time_stamp();
   if (clear_space) clear(SpaceDecorator::Mangle);
 }
 
@@ -204,7 +209,7 @@
   // GC efficiency is the ratio of how much space would be
   // reclaimed over how long we predict it would take to reclaim it.
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  G1CollectorPolicy* g1p = g1h->g1_policy();
+  G1Policy* g1p = g1h->g1_policy();
 
   // Retrieve a prediction of the elapsed time for this region for
   // a mixed gc because the region will only be evacuated during a
@@ -282,8 +287,7 @@
     _next_in_special_set(NULL),
     _evacuation_failed(false),
     _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0),
-    _next_young_region(NULL),
-    _next_dirty_cards_region(NULL), _next(NULL), _prev(NULL),
+    _next(NULL), _prev(NULL),
 #ifdef ASSERT
     _containing_set(NULL),
 #endif // ASSERT
@@ -1044,7 +1048,7 @@
 
 void G1ContiguousSpace::record_timestamp() {
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp();
+  uint curr_gc_time_stamp = g1h->get_gc_time_stamp();
 
   if (_gc_time_stamp < curr_gc_time_stamp) {
     // Setting the time stamp here tells concurrent readers to look at
diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.hpp b/hotspot/src/share/vm/gc/g1/heapRegion.hpp
index 88d83cb..10d1cc5 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegion.hpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -124,7 +124,7 @@
  protected:
   G1BlockOffsetTablePart _bot_part;
   Mutex _par_alloc_lock;
-  volatile unsigned _gc_time_stamp;
+  volatile uint _gc_time_stamp;
   // When we need to retire an allocation region, while other threads
   // are also concurrently trying to allocate into it, we typically
   // allocate a dummy object at the end of the region to ensure that
@@ -174,7 +174,7 @@
   HeapWord* scan_top() const;
   void record_timestamp();
   void reset_gc_time_stamp() { _gc_time_stamp = 0; }
-  unsigned get_gc_time_stamp() { return _gc_time_stamp; }
+  uint get_gc_time_stamp() { return _gc_time_stamp; }
   void record_retained_region();
 
   // See the comment above in the declaration of _pre_dummy_top for an
@@ -267,12 +267,6 @@
   //   The collection set.
   HeapRegion* _next_in_special_set;
 
-  // next region in the young "generation" region set
-  HeapRegion* _next_young_region;
-
-  // Next region whose cards need cleaning
-  HeapRegion* _next_dirty_cards_region;
-
   // Fields used by the HeapRegionSetBase class and subclasses.
   HeapRegion* _next;
   HeapRegion* _prev;
@@ -526,15 +520,6 @@
   // to provide a dummy version of it.
 #endif // ASSERT
 
-  HeapRegion* get_next_young_region() { return _next_young_region; }
-  void set_next_young_region(HeapRegion* hr) {
-    _next_young_region = hr;
-  }
-
-  HeapRegion* get_next_dirty_cards_region() const { return _next_dirty_cards_region; }
-  HeapRegion** next_dirty_cards_region_addr() { return &_next_dirty_cards_region; }
-  void set_next_dirty_cards_region(HeapRegion* hr) { _next_dirty_cards_region = hr; }
-  bool is_on_dirty_cards_region_list() const { return get_next_dirty_cards_region() != NULL; }
 
   // Reset HR stuff to default values.
   void hr_clear(bool par, bool clear_space, bool locked = false);
diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp
index b5e01a0..06b04ee 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp
@@ -51,8 +51,7 @@
   MemRegion reserved = heap_storage->reserved();
   _regions.initialize(reserved.start(), reserved.end(), HeapRegion::GrainBytes);
 
-  _available_map.resize(_regions.length(), false);
-  _available_map.clear();
+  _available_map.initialize(_regions.length());
 }
 
 bool HeapRegionManager::is_available(uint region) const {
diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp
index 03bc3ed..8644d3e 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp
@@ -83,7 +83,7 @@
 
   // Each bit in this bitmap indicates that the corresponding region is available
   // for allocation.
-  BitMap _available_map;
+  CHeapBitMap _available_map;
 
    // The number of regions committed in the heap.
   uint _num_committed;
diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp
index 4fee9c4..ad4821a 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp
@@ -43,7 +43,7 @@
   friend class HeapRegionRemSetIterator;
 
   HeapRegion*     _hr;
-  BitMap          _bm;
+  CHeapBitMap     _bm;
   jint            _occupied;
 
   // next pointer for free/allocated 'all' list
@@ -69,7 +69,7 @@
   PerRegionTable(HeapRegion* hr) :
     _hr(hr),
     _occupied(0),
-    _bm(HeapRegion::CardsPerRegion, false /* in-resource-area */),
+    _bm(HeapRegion::CardsPerRegion),
     _collision_list_next(NULL), _next(NULL), _prev(NULL)
   {}
 
@@ -103,7 +103,7 @@
       CardIdx_t from_card = (CardIdx_t)
           hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize);
 
-      assert(0 <= from_card && (size_t)from_card < HeapRegion::CardsPerRegion,
+      assert((size_t)from_card < HeapRegion::CardsPerRegion,
              "Must be in range.");
       add_card_work(from_card, par);
     }
@@ -259,8 +259,7 @@
 OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) :
   _g1h(G1CollectedHeap::heap()),
   _hr(hr), _m(m),
-  _coarse_map(G1CollectedHeap::heap()->max_regions(),
-              false /* in-resource-area */),
+  _coarse_map(G1CollectedHeap::heap()->max_regions()),
   _fine_grain_regions(NULL),
   _first_all_fine_prts(NULL), _last_all_fine_prts(NULL),
   _n_fine_entries(0), _n_coarse_entries(0),
@@ -387,7 +386,7 @@
         uintptr_t(from_hr->bottom())
           >> CardTableModRefBS::card_shift;
       CardIdx_t card_index = from_card - from_hr_bot_card_index;
-      assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
+      assert((size_t)card_index < HeapRegion::CardsPerRegion,
              "Must be in range.");
       if (G1HRRSUseSparseTable &&
           _sparse_table.add_card(from_hrm_ind, card_index)) {
@@ -422,11 +421,9 @@
         // Transfer from sparse to fine-grain.
         SparsePRTEntry *sprt_entry = _sparse_table.get_entry(from_hrm_ind);
         assert(sprt_entry != NULL, "There should have been an entry");
-        for (int i = 0; i < SparsePRTEntry::cards_num(); i++) {
+        for (int i = 0; i < sprt_entry->num_valid_cards(); i++) {
           CardIdx_t c = sprt_entry->card(i);
-          if (c != SparsePRTEntry::NullEntry) {
-            prt->add_card(c);
-          }
+          prt->add_card(c);
         }
         // Now we can delete the sparse entry.
         bool res = _sparse_table.delete_entry(from_hrm_ind);
@@ -519,8 +516,10 @@
   log_develop_trace(gc, remset, scrub)("Scrubbing region %u:", _hr->hrm_index());
 
   log_develop_trace(gc, remset, scrub)("   Coarse map: before = " SIZE_FORMAT "...", _n_coarse_entries);
-  live_data->remove_nonlive_regions(&_coarse_map);
-  _n_coarse_entries = _coarse_map.count_one_bits();
+  if (_n_coarse_entries > 0) {
+    live_data->remove_nonlive_regions(&_coarse_map);
+    _n_coarse_entries = _coarse_map.count_one_bits();
+  }
   log_develop_trace(gc, remset, scrub)("   after = " SIZE_FORMAT ".", _n_coarse_entries);
 
   // Now do the fine-grained maps.
@@ -646,7 +645,9 @@
 
   _first_all_fine_prts = _last_all_fine_prts = NULL;
   _sparse_table.clear();
-  _coarse_map.clear();
+  if (_n_coarse_entries > 0) {
+    _coarse_map.clear();
+  }
   _n_fine_entries = 0;
   _n_coarse_entries = 0;
 
@@ -677,7 +678,7 @@
       uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift;
     assert(from_card >= hr_bot_card_index, "Inv");
     CardIdx_t card_index = from_card - hr_bot_card_index;
-    assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
+    assert((size_t)card_index < HeapRegion::CardsPerRegion,
            "Must be in range.");
     return _sparse_table.contains_card(hr_ind, card_index);
   }
@@ -692,8 +693,8 @@
                                    HeapRegion* hr)
   : _bot(bot),
     _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never),
-    _code_roots(), _other_regions(hr, &_m), _iter_state(Unclaimed), _iter_claimed(0) {
-  reset_for_par_iteration();
+    _code_roots(),
+    _other_regions(hr, &_m) {
 }
 
 void HeapRegionRemSet::setup_remset_size() {
@@ -710,20 +711,6 @@
   guarantee(G1RSetSparseRegionEntries > 0 && G1RSetRegionEntries > 0 , "Sanity");
 }
 
-bool HeapRegionRemSet::claim_iter() {
-  if (_iter_state != Unclaimed) return false;
-  jint res = Atomic::cmpxchg(Claimed, (jint*)(&_iter_state), Unclaimed);
-  return (res == Unclaimed);
-}
-
-void HeapRegionRemSet::set_iter_complete() {
-  _iter_state = Complete;
-}
-
-bool HeapRegionRemSet::iter_is_complete() {
-  return _iter_state == Complete;
-}
-
 #ifndef PRODUCT
 void HeapRegionRemSet::print() {
   HeapRegionRemSetIterator iter(this);
@@ -760,14 +747,6 @@
   _code_roots.clear();
   _other_regions.clear();
   assert(occupied_locked() == 0, "Should be clear.");
-  reset_for_par_iteration();
-}
-
-void HeapRegionRemSet::reset_for_par_iteration() {
-  _iter_state = Unclaimed;
-  _iter_claimed = 0;
-  // It's good to check this to make sure that the two methods are in sync.
-  assert(verify_ready_for_par_iteration(), "post-condition");
 }
 
 void HeapRegionRemSet::scrub(G1CardLiveData* live_data) {
diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp
index c884dab..7f740b6 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -79,7 +79,7 @@
   HeapRegion*      _hr;
 
   // These are protected by "_m".
-  BitMap      _coarse_map;
+  CHeapBitMap _coarse_map;
   size_t      _n_coarse_entries;
   static jint _n_coarsenings;
 
@@ -185,10 +185,6 @@
 
   OtherRegionsTable _other_regions;
 
-  enum ParIterState { Unclaimed, Claimed, Complete };
-  volatile ParIterState _iter_state;
-  volatile size_t _iter_claimed;
-
 public:
   HeapRegionRemSet(G1BlockOffsetTable* bot, HeapRegion* hr);
 
@@ -240,27 +236,6 @@
   void clear();
   void clear_locked();
 
-  // Attempt to claim the region.  Returns true iff this call caused an
-  // atomic transition from Unclaimed to Claimed.
-  bool claim_iter();
-  // Sets the iteration state to "complete".
-  void set_iter_complete();
-  // Returns "true" iff the region's iteration is complete.
-  bool iter_is_complete();
-
-  // Support for claiming blocks of cards during iteration
-  size_t iter_claimed() const { return _iter_claimed; }
-  // Claim the next block of cards
-  size_t iter_claimed_next(size_t step) {
-    return Atomic::add(step, &_iter_claimed) - step;
-  }
-
-  void reset_for_par_iteration();
-
-  bool verify_ready_for_par_iteration() {
-    return (_iter_state == Unclaimed) && (_iter_claimed == 0);
-  }
-
   // The actual # of bytes this hr_remset takes up.
   // Note also includes the strong code root set.
   size_t mem_size() {
diff --git a/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp
index 89b5a7f..83bbc71 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp
@@ -38,7 +38,6 @@
   assert(!hr->is_free() || hr->is_empty(), "Free region %u is not empty for set %s", hr->hrm_index(), name());
   assert(!hr->is_empty() || hr->is_free() || hr->is_archive(),
          "Empty region %u is not free or archive for set %s", hr->hrm_index(), name());
-  assert(hr->rem_set()->verify_ready_for_par_iteration(), "Wrong iteration state %u", hr->hrm_index());
 }
 #endif
 
diff --git a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp
index f282ae9..cab39b3 100644
--- a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp
+++ b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/heapRegion.hpp"
+#include "gc/g1/heapRegionBounds.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/g1/sparsePRT.hpp"
 #include "gc/shared/cardTableModRefBS.hpp"
@@ -32,57 +33,69 @@
 #include "runtime/atomic.inline.hpp"
 #include "runtime/mutexLocker.hpp"
 
-void SparsePRTEntry::init(RegionIdx_t region_ind) {
-  _region_ind = region_ind;
-  _next_index = NullEntry;
+// Check that the size of the SparsePRTEntry is evenly divisible by the maximum
+// member type to avoid SIGBUS when accessing them.
+STATIC_ASSERT(sizeof(SparsePRTEntry) % sizeof(int) == 0);
 
-  for (int i = 0; i < cards_num(); i++) {
-    _cards[i] = NullEntry;
-  }
+void SparsePRTEntry::init(RegionIdx_t region_ind) {
+  // Check that the card array element type can represent all cards in the region.
+  // Choose a large SparsePRTEntry::card_elem_t (e.g. CardIdx_t) if required.
+  assert(((size_t)1 << (sizeof(SparsePRTEntry::card_elem_t) * BitsPerByte)) *
+         G1SATBCardTableModRefBS::card_size >= HeapRegionBounds::max_size(), "precondition");
+  assert(G1RSetSparseRegionEntries > 0, "precondition");
+  _region_ind = region_ind;
+  _next_index = RSHashTable::NullEntry;
+  _next_null = 0;
 }
 
 bool SparsePRTEntry::contains_card(CardIdx_t card_index) const {
-  for (int i = 0; i < cards_num(); i++) {
-    if (_cards[i] == card_index) return true;
+  for (int i = 0; i < num_valid_cards(); i++) {
+    if (card(i) == card_index) {
+      return true;
+    }
   }
   return false;
 }
 
-int SparsePRTEntry::num_valid_cards() const {
-  int sum = 0;
-  for (int i = 0; i < cards_num(); i++) {
-    sum += (_cards[i] != NullEntry);
-  }
-  return sum;
-}
-
 SparsePRTEntry::AddCardResult SparsePRTEntry::add_card(CardIdx_t card_index) {
-  for (int i = 0; i < cards_num(); i++) {
-    CardIdx_t c = _cards[i];
-    if (c == card_index) return found;
-    if (c == NullEntry) { _cards[i] = card_index; return added; }
+  for (int i = 0; i < num_valid_cards(); i++) {
+    if (card(i) == card_index) {
+      return found;
+    }
   }
+  if (num_valid_cards() < cards_num() - 1) {
+    _cards[_next_null] = (card_elem_t)card_index;
+    _next_null++;
+    return added;
+   }
   // Otherwise, we're full.
   return overflow;
 }
 
-void SparsePRTEntry::copy_cards(CardIdx_t* cards) const {
-  memcpy(cards, _cards, cards_num() * sizeof(CardIdx_t));
+void SparsePRTEntry::copy_cards(card_elem_t* cards) const {
+  memcpy(cards, _cards, cards_num() * sizeof(card_elem_t));
 }
 
 void SparsePRTEntry::copy_cards(SparsePRTEntry* e) const {
-  copy_cards(&e->_cards[0]);
+  copy_cards(e->_cards);
+  assert(_next_null >= 0, "invariant");
+  assert(_next_null <= cards_num(), "invariant");
+  e->_next_null = _next_null;
 }
 
 // ----------------------------------------------------------------------
 
+float RSHashTable::TableOccupancyFactor = 0.5f;
+
 RSHashTable::RSHashTable(size_t capacity) :
   _capacity(capacity), _capacity_mask(capacity-1),
   _occupied_entries(0), _occupied_cards(0),
-  _entries((SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, SparsePRTEntry::size() * capacity, mtGC)),
+  _entries(NULL),
   _buckets(NEW_C_HEAP_ARRAY(int, capacity, mtGC)),
   _free_list(NullEntry), _free_region(0)
 {
+  _num_entries = (capacity * TableOccupancyFactor) + 1;
+  _entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC);
   clear();
 }
 
@@ -107,7 +120,7 @@
                 "_capacity too large");
 
   // This will put -1 == NullEntry in the key field of all entries.
-  memset(_entries, NullEntry, _capacity * SparsePRTEntry::size());
+  memset(_entries, NullEntry, _num_entries * SparsePRTEntry::size());
   memset(_buckets, NullEntry, _capacity * sizeof(int));
   _free_list = NullEntry;
   _free_region = 0;
@@ -123,16 +136,6 @@
   return res != SparsePRTEntry::overflow;
 }
 
-bool RSHashTable::get_cards(RegionIdx_t region_ind, CardIdx_t* cards) {
-  SparsePRTEntry* entry = get_entry(region_ind);
-  if (entry == NULL) {
-    return false;
-  }
-  // Otherwise...
-  entry->copy_cards(cards);
-  return true;
-}
-
 SparsePRTEntry* RSHashTable::get_entry(RegionIdx_t region_ind) const {
   int ind = (int) (region_ind & capacity_mask());
   int cur_ind = _buckets[ind];
@@ -174,7 +177,6 @@
   SparsePRTEntry* res = get_entry(region_ind);
   if (res == NULL) {
     int new_ind = alloc_entry();
-    assert(0 <= new_ind && (size_t)new_ind < capacity(), "There should be room.");
     res = entry(new_ind);
     res->init(region_ind);
     // Insert at front.
@@ -192,7 +194,7 @@
     res = _free_list;
     _free_list = entry(res)->next_index();
     return res;
-  } else if ((size_t) _free_region+1 < capacity()) {
+  } else if ((size_t)_free_region < _num_entries) {
     res = _free_region;
     _free_region++;
     return res;
@@ -215,17 +217,16 @@
 }
 
 CardIdx_t RSHashTableIter::find_first_card_in_list() {
-  CardIdx_t res;
   while (_bl_ind != RSHashTable::NullEntry) {
-    res = _rsht->entry(_bl_ind)->card(0);
-    if (res != SparsePRTEntry::NullEntry) {
-      return res;
+    SparsePRTEntry* sparse_entry = _rsht->entry(_bl_ind);
+    if (sparse_entry->num_valid_cards() > 0) {
+      return sparse_entry->card(0);
     } else {
-      _bl_ind = _rsht->entry(_bl_ind)->next_index();
+      _bl_ind = sparse_entry->next_index();
     }
   }
   // Otherwise, none found:
-  return SparsePRTEntry::NullEntry;
+  return NoCardFound;
 }
 
 size_t RSHashTableIter::compute_card_ind(CardIdx_t ci) {
@@ -234,20 +235,22 @@
 
 bool RSHashTableIter::has_next(size_t& card_index) {
   _card_ind++;
-  CardIdx_t ci;
-  if (_card_ind < SparsePRTEntry::cards_num() &&
-      ((ci = _rsht->entry(_bl_ind)->card(_card_ind)) !=
-       SparsePRTEntry::NullEntry)) {
-    card_index = compute_card_ind(ci);
-    return true;
+  if (_bl_ind >= 0) {
+    SparsePRTEntry* e = _rsht->entry(_bl_ind);
+    if (_card_ind < e->num_valid_cards()) {
+      CardIdx_t ci = e->card(_card_ind);
+      card_index = compute_card_ind(ci);
+      return true;
+    }
   }
+
   // Otherwise, must find the next valid entry.
   _card_ind = 0;
 
   if (_bl_ind != RSHashTable::NullEntry) {
       _bl_ind = _rsht->entry(_bl_ind)->next_index();
-      ci = find_first_card_in_list();
-      if (ci != SparsePRTEntry::NullEntry) {
+      CardIdx_t ci = find_first_card_in_list();
+      if (ci != NoCardFound) {
         card_index = compute_card_ind(ci);
         return true;
       }
@@ -256,8 +259,8 @@
   _tbl_ind++;
   while ((size_t)_tbl_ind < _rsht->capacity()) {
     _bl_ind = _rsht->_buckets[_tbl_ind];
-    ci = find_first_card_in_list();
-    if (ci != SparsePRTEntry::NullEntry) {
+    CardIdx_t ci = find_first_card_in_list();
+    if (ci != NoCardFound) {
       card_index = compute_card_ind(ci);
       return true;
     }
@@ -275,7 +278,7 @@
 
 size_t RSHashTable::mem_size() const {
   return sizeof(RSHashTable) +
-    capacity() * (SparsePRTEntry::size() + sizeof(int));
+    _num_entries * (SparsePRTEntry::size() + sizeof(int));
 }
 
 // ----------------------------------------------------------------------
@@ -380,16 +383,12 @@
 }
 
 bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) {
-  if (_next->occupied_entries() * 2 > _next->capacity()) {
+  if (_next->should_expand()) {
     expand();
   }
   return _next->add_card(region_id, card_index);
 }
 
-bool SparsePRT::get_cards(RegionIdx_t region_id, CardIdx_t* cards) {
-  return _next->get_cards(region_id, cards);
-}
-
 SparsePRTEntry* SparsePRT::get_entry(RegionIdx_t region_id) {
   return _next->get_entry(region_id);
 }
@@ -427,7 +426,7 @@
 void SparsePRT::expand() {
   RSHashTable* last = _next;
   _next = new RSHashTable(last->capacity() * 2);
-  for (size_t i = 0; i < last->capacity(); i++) {
+  for (size_t i = 0; i < last->num_entries(); i++) {
     SparsePRTEntry* e = last->entry((int)i);
     if (e->valid_entry()) {
       _next->add_entry(e);
diff --git a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp
index b5ea3cd..5ea825c 100644
--- a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp
+++ b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,26 +43,32 @@
 // old versions synchronously.
 
 class SparsePRTEntry: public CHeapObj<mtGC> {
-public:
-  enum SomePublicConstants {
-    NullEntry     = -1,
-    UnrollFactor  =  4
-  };
 private:
+  // The type of a card entry.
+  typedef uint16_t card_elem_t;
+
+  // We need to make sizeof(SparsePRTEntry) an even multiple of maximum member size,
+  // in order to force correct alignment that could otherwise cause SIGBUS errors
+  // when reading the member variables. This calculates the minimum number of card
+  // array elements required to get that alignment.
+  static const size_t card_array_alignment = sizeof(int) / sizeof(card_elem_t);
+
   RegionIdx_t _region_ind;
   int         _next_index;
-  CardIdx_t   _cards[1];
+  int         _next_null;
+  // The actual cards stored in this array.
   // WARNING: Don't put any data members beyond this line. Card array has, in fact, variable length.
   // It should always be the last data member.
+  card_elem_t _cards[card_array_alignment];
+
+  // Copy the current entry's cards into "cards".
+  inline void copy_cards(card_elem_t* cards) const;
 public:
   // Returns the size of the entry, used for entry allocation.
-  static size_t size() { return sizeof(SparsePRTEntry) + sizeof(CardIdx_t) * (cards_num() - 1); }
+  static size_t size() { return sizeof(SparsePRTEntry) + sizeof(card_elem_t) * (cards_num() - card_array_alignment); }
   // Returns the size of the card array.
   static int cards_num() {
-    // The number of cards should be a multiple of 4, because that's our current
-    // unrolling factor.
-    static const int s = MAX2<int>(G1RSetSparseRegionEntries & ~(UnrollFactor - 1), UnrollFactor);
-    return s;
+    return align_size_up(G1RSetSparseRegionEntries, card_array_alignment);
   }
 
   // Set the region_ind to the given value, and delete all cards.
@@ -80,7 +86,7 @@
   inline bool contains_card(CardIdx_t card_index) const;
 
   // Returns the number of non-NULL card entries.
-  inline int num_valid_cards() const;
+  inline int num_valid_cards() const { return _next_null; }
 
   // Requires that the entry not contain the given card index.  If there is
   // space available, add the given card index to the entry and return
@@ -92,22 +98,25 @@
   };
   inline AddCardResult add_card(CardIdx_t card_index);
 
-  // Copy the current entry's cards into "cards".
-  inline void copy_cards(CardIdx_t* cards) const;
   // Copy the current entry's cards into the "_card" array of "e."
   inline void copy_cards(SparsePRTEntry* e) const;
 
-  inline CardIdx_t card(int i) const { return _cards[i]; }
+  inline CardIdx_t card(int i) const {
+    assert(i >= 0, "must be nonnegative");
+    assert(i < cards_num(), "range checking");
+    return (CardIdx_t)_cards[i];
+  }
 };
 
-
 class RSHashTable : public CHeapObj<mtGC> {
 
   friend class RSHashTableIter;
 
-  enum SomePrivateConstants {
-    NullEntry = -1
-  };
+
+  // Inverse maximum hash table occupancy used.
+  static float TableOccupancyFactor;
+
+  size_t _num_entries;
 
   size_t _capacity;
   size_t _capacity_mask;
@@ -136,6 +145,10 @@
   RSHashTable(size_t capacity);
   ~RSHashTable();
 
+  static const int NullEntry = -1;
+
+  bool should_expand() const { return _occupied_entries == _num_entries; }
+
   // Attempts to ensure that the given card_index in the given region is in
   // the sparse table.  If successful (because the card was already
   // present, or because it was successfully added) returns "true".
@@ -156,27 +169,35 @@
 
   void clear();
 
-  size_t capacity() const      { return _capacity;       }
+  size_t capacity() const      { return _capacity; }
   size_t capacity_mask() const { return _capacity_mask;  }
   size_t occupied_entries() const { return _occupied_entries; }
-  size_t occupied_cards() const   { return _occupied_cards;   }
+  size_t occupied_cards() const   { return _occupied_cards; }
   size_t mem_size() const;
+  // The number of SparsePRTEntry instances available.
+  size_t num_entries() const { return _num_entries; }
 
-  SparsePRTEntry* entry(int i) const { return (SparsePRTEntry*)((char*)_entries + SparsePRTEntry::size() * i); }
+  SparsePRTEntry* entry(int i) const {
+    assert(i >= 0 && (size_t)i < _num_entries, "precondition");
+    return (SparsePRTEntry*)((char*)_entries + SparsePRTEntry::size() * i);
+  }
 
   void print();
 };
 
 // ValueObj because will be embedded in HRRS iterator.
 class RSHashTableIter VALUE_OBJ_CLASS_SPEC {
+  // Return value indicating "invalid/no card".
+  static const int NoCardFound = -1;
+
   int _tbl_ind;         // [-1, 0.._rsht->_capacity)
   int _bl_ind;          // [-1, 0.._rsht->_capacity)
   short _card_ind;      // [0..SparsePRTEntry::cards_num())
   RSHashTable* _rsht;
 
   // If the bucket list pointed to by _bl_ind contains a card, sets
-  // _bl_ind to the index of that entry, and returns the card.
-  // Otherwise, returns SparseEntry::NullEntry.
+  // _bl_ind to the index of that entry,
+  // Returns the card found if there is, otherwise returns InvalidCard.
   CardIdx_t find_first_card_in_list();
 
   // Computes the proper card index for the card whose offset in the
@@ -247,12 +268,6 @@
   // entries to a larger-capacity representation.
   bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
 
-  // If the table hold an entry for "region_ind",  Copies its
-  // cards into "cards", which must be an array of length at least
-  // "SparePRTEntry::cards_num()", and returns "true"; otherwise,
-  // returns "false".
-  bool get_cards(RegionIdx_t region_ind, CardIdx_t* cards);
-
   // Return the pointer to the entry associated with the given region.
   SparsePRTEntry* get_entry(RegionIdx_t region_ind);
 
diff --git a/hotspot/src/share/vm/gc/g1/survRateGroup.cpp b/hotspot/src/share/vm/gc/g1/survRateGroup.cpp
index e201d25..b59a726 100644
--- a/hotspot/src/share/vm/gc/g1/survRateGroup.cpp
+++ b/hotspot/src/share/vm/gc/g1/survRateGroup.cpp
@@ -30,33 +30,14 @@
 #include "logging/log.hpp"
 #include "memory/allocation.hpp"
 
-SurvRateGroup::SurvRateGroup(G1Predictions* predictor,
-                             const char* name,
-                             size_t summary_surv_rates_len) :
-    _predictor(predictor), _name(name),
-    _summary_surv_rates_len(summary_surv_rates_len),
-    _summary_surv_rates_max_len(0),
-    _summary_surv_rates(NULL),
-    _surv_rate(NULL),
+SurvRateGroup::SurvRateGroup() :
     _accum_surv_rate_pred(NULL),
     _surv_rate_pred(NULL),
     _stats_arrays_length(0) {
   reset();
-  if (summary_surv_rates_len > 0) {
-    size_t length = summary_surv_rates_len;
-      _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length, mtGC);
-    for (size_t i = 0; i < length; ++i) {
-      _summary_surv_rates[i] = new NumberSeq();
-    }
-  }
-
   start_adding_regions();
 }
 
-double SurvRateGroup::get_new_prediction(TruncatedSeq const* seq) const {
-  return _predictor->get_new_prediction(seq);
-}
-
 void SurvRateGroup::reset() {
   _all_regions_allocated = 0;
   _setup_seq_num         = 0;
@@ -73,10 +54,14 @@
   _stats_arrays_length = 0;
 
   stop_adding_regions();
+
+  // Seed initial _surv_rate_pred and _accum_surv_rate_pred values
   guarantee( _stats_arrays_length == 1, "invariant" );
   guarantee( _surv_rate_pred[0] != NULL, "invariant" );
-  _surv_rate_pred[0]->add(0.4);
-  all_surviving_words_recorded(false);
+  const double initial_surv_rate = 0.4;
+  _surv_rate_pred[0]->add(initial_surv_rate);
+  _last_pred = _accum_surv_rate_pred[0] = initial_surv_rate;
+
   _region_num = 0;
 }
 
@@ -87,131 +72,49 @@
 
 void SurvRateGroup::stop_adding_regions() {
   if (_region_num > _stats_arrays_length) {
-    double* old_surv_rate = _surv_rate;
-    double* old_accum_surv_rate_pred = _accum_surv_rate_pred;
-    TruncatedSeq** old_surv_rate_pred = _surv_rate_pred;
+    _accum_surv_rate_pred = REALLOC_C_HEAP_ARRAY(double, _accum_surv_rate_pred, _region_num, mtGC);
+    _surv_rate_pred = REALLOC_C_HEAP_ARRAY(TruncatedSeq*, _surv_rate_pred, _region_num, mtGC);
 
-    _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
-    _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
-    _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num, mtGC);
-
-    for (size_t i = 0; i < _stats_arrays_length; ++i) {
-      _surv_rate_pred[i] = old_surv_rate_pred[i];
-    }
     for (size_t i = _stats_arrays_length; i < _region_num; ++i) {
       _surv_rate_pred[i] = new TruncatedSeq(10);
     }
 
     _stats_arrays_length = _region_num;
-
-    if (old_surv_rate != NULL) {
-      FREE_C_HEAP_ARRAY(double, old_surv_rate);
-    }
-    if (old_accum_surv_rate_pred != NULL) {
-      FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred);
-    }
-    if (old_surv_rate_pred != NULL) {
-      FREE_C_HEAP_ARRAY(TruncatedSeq*, old_surv_rate_pred);
-    }
   }
-
-  for (size_t i = 0; i < _stats_arrays_length; ++i) {
-    _surv_rate[i] = 0.0;
-  }
-}
-
-int SurvRateGroup::next_age_index() {
-  ++_region_num;
-  return (int) ++_all_regions_allocated;
 }
 
 void SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) {
   guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num,
              "pre-condition" );
-  guarantee( _surv_rate[age_in_group] <= 0.00001,
-             "should only update each slot once" );
 
   double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords;
-  _surv_rate[age_in_group] = surv_rate;
   _surv_rate_pred[age_in_group]->add(surv_rate);
-  if ((size_t)age_in_group < _summary_surv_rates_len) {
-    _summary_surv_rates[age_in_group]->add(surv_rate);
-    if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len)
-      _summary_surv_rates_max_len = age_in_group+1;
-  }
 }
 
-void SurvRateGroup::all_surviving_words_recorded(bool update_predictors) {
-  if (update_predictors && _region_num > 0) { // conservative
+void SurvRateGroup::all_surviving_words_recorded(const G1Predictions& predictor, bool update_predictors) {
+  if (update_predictors) {
+    fill_in_last_surv_rates();
+  }
+  finalize_predictions(predictor);
+}
+
+void SurvRateGroup::fill_in_last_surv_rates() {
+  if (_region_num > 0) { // conservative
     double surv_rate = _surv_rate_pred[_region_num-1]->last();
     for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
-      guarantee( _surv_rate[i] <= 0.00001,
-                 "the slot should not have been updated" );
       _surv_rate_pred[i]->add(surv_rate);
     }
   }
+}
 
+void SurvRateGroup::finalize_predictions(const G1Predictions& predictor) {
   double accum = 0.0;
   double pred = 0.0;
   for (size_t i = 0; i < _stats_arrays_length; ++i) {
-    pred = get_new_prediction(_surv_rate_pred[i]);
+    pred = predictor.get_new_prediction(_surv_rate_pred[i]);
     if (pred > 1.0) pred = 1.0;
     accum += pred;
     _accum_surv_rate_pred[i] = accum;
   }
   _last_pred = pred;
 }
-
-#ifndef PRODUCT
-void SurvRateGroup::print() {
-  log_develop_trace(gc, survivor)("Surv Rate Group: %s (" SIZE_FORMAT " entries)", _name, _region_num);
-  for (size_t i = 0; i < _region_num; ++i) {
-    log_develop_trace(gc, survivor)("    age " SIZE_FORMAT_W(4) "   surv rate %6.2lf %%   pred %6.2lf %%",
-                                    i, _surv_rate[i] * 100.0,
-                                    _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0);
-  }
-}
-
-void
-SurvRateGroup::print_surv_rate_summary() {
-  size_t length = _summary_surv_rates_max_len;
-  if (length == 0)
-    return;
-
-  log_trace(gc, survivor)("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1);
-  log_trace(gc, survivor)("      age range     survival rate (avg)      samples (avg)");
-  log_trace(gc, survivor)("  ---------------------------------------------------------");
-
-  size_t index = 0;
-  size_t limit = MIN2((int) length, 10);
-  while (index < limit) {
-    log_trace(gc, survivor)("           " SIZE_FORMAT_W(4) "                 %6.2lf%%             %6.2lf",
-                            index, _summary_surv_rates[index]->avg() * 100.0,
-                            (double) _summary_surv_rates[index]->num());
-    ++index;
-  }
-
-  log_trace(gc, survivor)("  ---------------------------------------------------------");
-
-  int num = 0;
-  double sum = 0.0;
-  int samples = 0;
-  while (index < length) {
-    ++num;
-    sum += _summary_surv_rates[index]->avg() * 100.0;
-    samples += _summary_surv_rates[index]->num();
-    ++index;
-
-    if (index == length || num % 10 == 0) {
-      log_trace(gc, survivor)("   " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4) "                 %6.2lf%%             %6.2lf",
-                              (index-1) / 10 * 10, index-1, sum / (double) num,
-                              (double) samples / (double) num);
-      sum = 0.0;
-      num = 0;
-      samples = 0;
-    }
-  }
-
-  log_trace(gc, survivor)("  ---------------------------------------------------------");
-}
-#endif // PRODUCT
diff --git a/hotspot/src/share/vm/gc/g1/survRateGroup.hpp b/hotspot/src/share/vm/gc/g1/survRateGroup.hpp
index a4fbe3b..58f458c 100644
--- a/hotspot/src/share/vm/gc/g1/survRateGroup.hpp
+++ b/hotspot/src/share/vm/gc/g1/survRateGroup.hpp
@@ -31,37 +31,27 @@
 
 class SurvRateGroup : public CHeapObj<mtGC> {
 private:
-  G1Predictions* _predictor;
-
-  double get_new_prediction(TruncatedSeq const* seq) const;
-
-  const char* _name;
-
   size_t  _stats_arrays_length;
-  double* _surv_rate;
   double* _accum_surv_rate_pred;
   double  _last_pred;
   TruncatedSeq** _surv_rate_pred;
-  NumberSeq**    _summary_surv_rates;
-  size_t         _summary_surv_rates_len;
-  size_t         _summary_surv_rates_max_len;
 
   int _all_regions_allocated;
   size_t _region_num;
   size_t _setup_seq_num;
 
+  void fill_in_last_surv_rates();
+  void finalize_predictions(const G1Predictions& predictor);
 public:
-  SurvRateGroup(G1Predictions* predictor,
-                const char* name,
-                size_t summary_surv_rates_len);
+  SurvRateGroup();
   void reset();
   void start_adding_regions();
   void stop_adding_regions();
   void record_surviving_words(int age_in_group, size_t surv_words);
-  void all_surviving_words_recorded(bool update_predictors);
-  const char* name() { return _name; }
+  void all_surviving_words_recorded(const G1Predictions& predictor, bool update_predictors);
 
-  size_t region_num() { return _region_num; }
+  size_t region_num() const { return _region_num; }
+
   double accum_surv_rate_pred(int age) const {
     assert(age >= 0, "must be");
     if ((size_t)age < _stats_arrays_length)
@@ -82,8 +72,12 @@
     return seq;
   }
 
-  int next_age_index();
-  int age_in_group(int age_index) {
+  int next_age_index() {
+    ++_region_num;
+    return (int) ++_all_regions_allocated;
+  }
+
+  int age_in_group(int age_index) const {
     int ret = (int) (_all_regions_allocated - age_index);
     assert( ret >= 0, "invariant" );
     return ret;
@@ -92,10 +86,6 @@
     _all_regions_allocated = 0;
   }
 
-#ifndef PRODUCT
-  void print();
-  void print_surv_rate_summary();
-#endif // PRODUCT
 };
 
 #endif // SHARE_VM_GC_G1_SURVRATEGROUP_HPP
diff --git a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp
index 62d610d..333499a 100644
--- a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp
+++ b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp
@@ -25,7 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/g1/concurrentMarkThread.inline.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
+#include "gc/g1/g1Policy.hpp"
 #include "gc/shared/gcId.hpp"
 #include "gc/g1/vm_operations_g1.hpp"
 #include "gc/shared/gcTimer.hpp"
diff --git a/hotspot/src/share/vm/gc/g1/youngList.cpp b/hotspot/src/share/vm/gc/g1/youngList.cpp
deleted file mode 100644
index 5d57d5c..0000000
--- a/hotspot/src/share/vm/gc/g1/youngList.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "gc/g1/g1CollectedHeap.hpp"
-#include "gc/g1/g1CollectionSet.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
-#include "gc/g1/heapRegion.hpp"
-#include "gc/g1/heapRegion.inline.hpp"
-#include "gc/g1/heapRegionRemSet.hpp"
-#include "gc/g1/youngList.hpp"
-#include "logging/log.hpp"
-#include "utilities/ostream.hpp"
-
-YoungList::YoungList(G1CollectedHeap* g1h) :
-    _g1h(g1h), _head(NULL), _length(0),
-    _survivor_head(NULL), _survivor_tail(NULL), _survivor_length(0) {
-  guarantee(check_list_empty(), "just making sure...");
-}
-
-void YoungList::push_region(HeapRegion *hr) {
-  assert(!hr->is_young(), "should not already be young");
-  assert(hr->get_next_young_region() == NULL, "cause it should!");
-
-  hr->set_next_young_region(_head);
-  _head = hr;
-
-  _g1h->g1_policy()->set_region_eden(hr, (int) _length);
-  ++_length;
-}
-
-void YoungList::add_survivor_region(HeapRegion* hr) {
-  assert(hr->is_survivor(), "should be flagged as survivor region");
-  assert(hr->get_next_young_region() == NULL, "cause it should!");
-
-  hr->set_next_young_region(_survivor_head);
-  if (_survivor_head == NULL) {
-    _survivor_tail = hr;
-  }
-  _survivor_head = hr;
-  ++_survivor_length;
-}
-
-void YoungList::empty_list(HeapRegion* list) {
-  while (list != NULL) {
-    HeapRegion* next = list->get_next_young_region();
-    list->set_next_young_region(NULL);
-    list->uninstall_surv_rate_group();
-    // This is called before a Full GC and all the non-empty /
-    // non-humongous regions at the end of the Full GC will end up as
-    // old anyway.
-    list->set_old();
-    list = next;
-  }
-}
-
-void YoungList::empty_list() {
-  assert(check_list_well_formed(), "young list should be well formed");
-
-  empty_list(_head);
-  _head = NULL;
-  _length = 0;
-
-  empty_list(_survivor_head);
-  _survivor_head = NULL;
-  _survivor_tail = NULL;
-  _survivor_length = 0;
-
-  assert(check_list_empty(), "just making sure...");
-}
-
-bool YoungList::check_list_well_formed() {
-  bool ret = true;
-
-  uint length = 0;
-  HeapRegion* curr = _head;
-  HeapRegion* last = NULL;
-  while (curr != NULL) {
-    if (!curr->is_young()) {
-      log_error(gc, verify)("### YOUNG REGION " PTR_FORMAT "-" PTR_FORMAT " "
-                            "incorrectly tagged (y: %d, surv: %d)",
-                            p2i(curr->bottom()), p2i(curr->end()),
-                            curr->is_young(), curr->is_survivor());
-      ret = false;
-    }
-    ++length;
-    last = curr;
-    curr = curr->get_next_young_region();
-  }
-  ret = ret && (length == _length);
-
-  if (!ret) {
-    log_error(gc, verify)("### YOUNG LIST seems not well formed!");
-    log_error(gc, verify)("###   list has %u entries, _length is %u", length, _length);
-  }
-
-  return ret;
-}
-
-bool YoungList::check_list_empty() {
-  bool ret = true;
-
-  if (_length != 0) {
-    log_error(gc, verify)("### YOUNG LIST should have 0 length, not %u", _length);
-    ret = false;
-  }
-  if (_head != NULL) {
-    log_error(gc, verify)("### YOUNG LIST does not have a NULL head");
-    ret = false;
-  }
-  if (!ret) {
-    log_error(gc, verify)("### YOUNG LIST does not seem empty");
-  }
-
-  return ret;
-}
-
-void
-YoungList::reset_auxilary_lists() {
-  guarantee( is_empty(), "young list should be empty" );
-  assert(check_list_well_formed(), "young list should be well formed");
-
-  // Add survivor regions to SurvRateGroup.
-  _g1h->g1_policy()->note_start_adding_survivor_regions();
-  _g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */);
-
-  int young_index_in_cset = 0;
-  for (HeapRegion* curr = _survivor_head;
-       curr != NULL;
-       curr = curr->get_next_young_region()) {
-    _g1h->g1_policy()->set_region_survivor(curr, young_index_in_cset);
-
-    // The region is a non-empty survivor so let's add it to
-    // the incremental collection set for the next evacuation
-    // pause.
-    _g1h->collection_set()->add_survivor_regions(curr);
-    young_index_in_cset += 1;
-  }
-  assert((uint) young_index_in_cset == _survivor_length, "post-condition");
-  _g1h->g1_policy()->note_stop_adding_survivor_regions();
-
-  _head   = _survivor_head;
-  _length = _survivor_length;
-  if (_survivor_head != NULL) {
-    assert(_survivor_tail != NULL, "cause it shouldn't be");
-    assert(_survivor_length > 0, "invariant");
-    _survivor_tail->set_next_young_region(NULL);
-  }
-
-  // Don't clear the survivor list handles until the start of
-  // the next evacuation pause - we need it in order to re-tag
-  // the survivor regions from this evacuation pause as 'young'
-  // at the start of the next.
-
-  _g1h->g1_policy()->finished_recalculating_age_indexes(false /* is_survivors */);
-
-  assert(check_list_well_formed(), "young list should be well formed");
-}
-
-void YoungList::print() {
-  HeapRegion* lists[] = {_head,   _survivor_head};
-  const char* names[] = {"YOUNG", "SURVIVOR"};
-
-  for (uint list = 0; list < ARRAY_SIZE(lists); ++list) {
-    tty->print_cr("%s LIST CONTENTS", names[list]);
-    HeapRegion *curr = lists[list];
-    if (curr == NULL) {
-      tty->print_cr("  empty");
-    }
-    while (curr != NULL) {
-      tty->print_cr("  " HR_FORMAT ", P: " PTR_FORMAT ", N: " PTR_FORMAT ", age: %4d",
-                             HR_FORMAT_PARAMS(curr),
-                             p2i(curr->prev_top_at_mark_start()),
-                             p2i(curr->next_top_at_mark_start()),
-                             curr->age_in_surv_rate_group_cond());
-      curr = curr->get_next_young_region();
-    }
-  }
-
-  tty->cr();
-}
diff --git a/hotspot/src/share/vm/gc/g1/youngList.hpp b/hotspot/src/share/vm/gc/g1/youngList.hpp
deleted file mode 100644
index 1030b3f..0000000
--- a/hotspot/src/share/vm/gc/g1/youngList.hpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_GC_G1_YOUNGLIST_HPP
-#define SHARE_VM_GC_G1_YOUNGLIST_HPP
-
-#include "memory/allocation.hpp"
-#include "runtime/globals.hpp"
-
-class YoungList : public CHeapObj<mtGC> {
-private:
-  G1CollectedHeap* _g1h;
-
-  HeapRegion* _head;
-
-  HeapRegion* _survivor_head;
-  HeapRegion* _survivor_tail;
-
-  uint        _length;
-  uint        _survivor_length;
-
-  void         empty_list(HeapRegion* list);
-
-public:
-  YoungList(G1CollectedHeap* g1h);
-
-  void         push_region(HeapRegion* hr);
-  void         add_survivor_region(HeapRegion* hr);
-
-  void         empty_list();
-  bool         is_empty() { return _length == 0; }
-  uint         length() { return _length; }
-  uint         eden_length() { return length() - survivor_length(); }
-  uint         survivor_length() { return _survivor_length; }
-
-  // Currently we do not keep track of the used byte sum for the
-  // young list and the survivors and it'd be quite a lot of work to
-  // do so. When we'll eventually replace the young list with
-  // instances of HeapRegionLinkedList we'll get that for free. So,
-  // we'll report the more accurate information then.
-  size_t       eden_used_bytes() {
-    assert(length() >= survivor_length(), "invariant");
-    return (size_t) eden_length() * HeapRegion::GrainBytes;
-  }
-  size_t       survivor_used_bytes() {
-    return (size_t) survivor_length() * HeapRegion::GrainBytes;
-  }
-
-  // for development purposes
-  void reset_auxilary_lists();
-  void clear() { _head = NULL; _length = 0; }
-
-  void clear_survivors() {
-    _survivor_head    = NULL;
-    _survivor_tail    = NULL;
-    _survivor_length  = 0;
-  }
-
-  HeapRegion* first_region() { return _head; }
-  HeapRegion* first_survivor_region() { return _survivor_head; }
-  HeapRegion* last_survivor_region() { return _survivor_tail; }
-
-  // debugging
-  bool          check_list_well_formed();
-  bool          check_list_empty();
-  void          print();
-};
-
-#endif // SHARE_VM_GC_G1_YOUNGLIST_HPP
diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp b/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp
index 57e91b6..2ec5d19 100644
--- a/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,8 @@
 #include "precompiled.hpp"
 #include "gc/parallel/gcTaskManager.hpp"
 #include "gc/parallel/gcTaskThread.hpp"
-#include "gc/shared/adaptiveSizePolicy.hpp"
 #include "gc/shared/gcId.hpp"
+#include "gc/shared/workerManager.hpp"
 #include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
@@ -34,6 +34,7 @@
 #include "runtime/mutex.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/orderAccess.inline.hpp"
+#include "runtime/os.hpp"
 
 //
 // GCTask
@@ -372,10 +373,28 @@
 GCTaskManager::GCTaskManager(uint workers) :
   _workers(workers),
   _active_workers(0),
-  _idle_workers(0) {
+  _idle_workers(0),
+  _created_workers(0) {
   initialize();
 }
 
+GCTaskThread* GCTaskManager::install_worker(uint t) {
+  GCTaskThread* new_worker = GCTaskThread::create(this, t, _processor_assignment[t]);
+  set_thread(t, new_worker);
+  return new_worker;
+}
+
+void GCTaskManager::add_workers(bool initializing) {
+  os::ThreadType worker_type = os::pgc_thread;
+  _created_workers = WorkerManager::add_workers(this,
+                                                _active_workers,
+                                                (uint) _workers,
+                                                _created_workers,
+                                                worker_type,
+                                                initializing);
+  _active_workers = MIN2(_created_workers, _active_workers);
+}
+
 void GCTaskManager::initialize() {
   if (TraceGCTaskManager) {
     tty->print_cr("GCTaskManager::initialize: workers: %u", workers());
@@ -394,28 +413,30 @@
     // Set up worker threads.
     //     Distribute the workers among the available processors,
     //     unless we were told not to, or if the os doesn't want to.
-    uint* processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC);
+    _processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC);
     if (!BindGCTaskThreadsToCPUs ||
-        !os::distribute_processes(workers(), processor_assignment)) {
+        !os::distribute_processes(workers(), _processor_assignment)) {
       for (uint a = 0; a < workers(); a += 1) {
-        processor_assignment[a] = sentinel_worker();
+        _processor_assignment[a] = sentinel_worker();
       }
     }
+
     _thread = NEW_C_HEAP_ARRAY(GCTaskThread*, workers(), mtGC);
-    for (uint t = 0; t < workers(); t += 1) {
-      set_thread(t, GCTaskThread::create(this, t, processor_assignment[t]));
+    _active_workers = ParallelGCThreads;
+    if (UseDynamicNumberOfGCThreads && !FLAG_IS_CMDLINE(ParallelGCThreads)) {
+      _active_workers = 1U;
     }
+
     Log(gc, task, thread) log;
     if (log.is_trace()) {
       ResourceMark rm;
       outputStream* out = log.trace_stream();
       out->print("GCTaskManager::initialize: distribution:");
       for (uint t = 0; t < workers(); t += 1) {
-        out->print("  %u", processor_assignment[t]);
+        out->print("  %u", _processor_assignment[t]);
       }
       out->cr();
     }
-    FREE_C_HEAP_ARRAY(uint, processor_assignment);
   }
   reset_busy_workers();
   set_unblocked();
@@ -426,9 +447,8 @@
   reset_completed_tasks();
   reset_barriers();
   reset_emptied_queue();
-  for (uint s = 0; s < workers(); s += 1) {
-    thread(s)->start();
-  }
+
+  add_workers(true);
 }
 
 GCTaskManager::~GCTaskManager() {
@@ -437,13 +457,17 @@
   NoopGCTask::destroy(_noop_task);
   _noop_task = NULL;
   if (_thread != NULL) {
-    for (uint i = 0; i < workers(); i += 1) {
+    for (uint i = 0; i < created_workers(); i += 1) {
       GCTaskThread::destroy(thread(i));
       set_thread(i, NULL);
     }
     FREE_C_HEAP_ARRAY(GCTaskThread*, _thread);
     _thread = NULL;
   }
+  if (_processor_assignment != NULL) {
+    FREE_C_HEAP_ARRAY(uint, _processor_assignment);
+    _processor_assignment = NULL;
+  }
   if (_resource_flag != NULL) {
     FREE_C_HEAP_ARRAY(bool, _resource_flag);
     _resource_flag = NULL;
@@ -470,6 +494,9 @@
          "all_workers_active() is  incorrect: "
          "active %d  ParallelGCThreads %u", active_workers(),
          ParallelGCThreads);
+  _active_workers = MIN2(_active_workers, _workers);
+  // "add_workers" does not guarantee any additional workers
+  add_workers(false);
   log_trace(gc, task)("GCTaskManager::set_active_gang(): "
                       "all_workers_active()  %d  workers %d  "
                       "active  %d  ParallelGCThreads %u",
@@ -499,7 +526,7 @@
       // is starting).  Try later to release enough idle_workers
       // to allow the desired number of active_workers.
       more_inactive_workers =
-        workers() - active_workers() - idle_workers();
+        created_workers() - active_workers() - idle_workers();
       if (more_inactive_workers < 0) {
         int reduced_active_workers = active_workers() + more_inactive_workers;
         set_active_workers(reduced_active_workers);
@@ -507,7 +534,7 @@
       }
       log_trace(gc, task)("JT: %d  workers %d  active  %d  idle %d  more %d",
                           Threads::number_of_non_daemon_threads(),
-                          workers(),
+                          created_workers(),
                           active_workers(),
                           idle_workers(),
                           more_inactive_workers);
@@ -517,7 +544,7 @@
       q->enqueue(IdleGCTask::create_on_c_heap());
       increment_idle_workers();
     }
-    assert(workers() == active_workers() + idle_workers(),
+    assert(created_workers() == active_workers() + idle_workers(),
       "total workers should equal active + inactive");
     add_list(q);
     // GCTaskQueue* q was created in a ResourceArea so a
@@ -539,14 +566,15 @@
   if (!log_is_enabled(Debug, gc, task, time)) {
     return;
   }
-  for(uint i=0; i<ParallelGCThreads; i++) {
+  uint num_thr = created_workers();
+  for(uint i=0; i < num_thr; i++) {
     GCTaskThread* t = thread(i);
     t->print_task_time_stamps();
   }
 }
 
 void GCTaskManager::print_threads_on(outputStream* st) {
-  uint num_thr = workers();
+  uint num_thr = created_workers();
   for (uint i = 0; i < num_thr; i++) {
     thread(i)->print_on(st);
     st->cr();
@@ -555,19 +583,20 @@
 
 void GCTaskManager::threads_do(ThreadClosure* tc) {
   assert(tc != NULL, "Null ThreadClosure");
-  uint num_thr = workers();
+  uint num_thr = created_workers();
   for (uint i = 0; i < num_thr; i++) {
     tc->do_thread(thread(i));
   }
 }
 
 GCTaskThread* GCTaskManager::thread(uint which) {
-  assert(which < workers(), "index out of bounds");
+  assert(which < created_workers(), "index out of bounds");
   assert(_thread[which] != NULL, "shouldn't have null thread");
   return _thread[which];
 }
 
 void GCTaskManager::set_thread(uint which, GCTaskThread* value) {
+  // "_created_workers" may not have been updated yet so use workers()
   assert(which < workers(), "index out of bounds");
   assert(value != NULL, "shouldn't have null thread");
   _thread[which] = value;
@@ -728,7 +757,7 @@
 
 void GCTaskManager::release_all_resources() {
   // If you want this to be done atomically, do it in a WaitForBarrierGCTask.
-  for (uint i = 0; i < workers(); i += 1) {
+  for (uint i = 0; i < created_workers(); i += 1) {
     set_resource_flag(i, true);
   }
 }
diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp b/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp
index 9d46203..70ac6b2 100644
--- a/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -370,6 +370,7 @@
   Monitor*                  _monitor;           // Notification of changes.
   SynchronizedGCTaskQueue*  _queue;             // Queue of tasks.
   GCTaskThread**            _thread;            // Array of worker threads.
+  uint                      _created_workers;   // Number of workers created.
   uint                      _active_workers;    // Number of active workers.
   uint                      _busy_workers;      // Number of busy workers.
   uint                      _blocking_worker;   // The worker that's blocking.
@@ -381,6 +382,8 @@
   NoopGCTask*               _noop_task;         // The NoopGCTask instance.
   WaitHelper                _wait_helper;       // Used by inactive worker
   volatile uint             _idle_workers;      // Number of idled workers
+  uint*                     _processor_assignment; // Worker to cpu mappings. May
+                                                   // be used lazily
 public:
   // Factory create and destroy methods.
   static GCTaskManager* create(uint workers) {
@@ -546,6 +549,13 @@
   uint active_workers() const {
     return _active_workers;
   }
+  uint created_workers() const {
+    return _created_workers;
+  }
+  // Create a GC worker and install into GCTaskManager
+  GCTaskThread* install_worker(uint worker_id);
+  // Add GC workers as needed.
+  void add_workers(bool initializing);
 };
 
 //
diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp
index d81db69..f6fd1a3 100644
--- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp
@@ -44,9 +44,6 @@
   _time_stamps(NULL),
   _time_stamp_index(0)
 {
-  if (!os::create_thread(this, os::pgc_thread))
-    vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GC thread. Out of system resources.");
-
   set_id(which);
   set_name("ParGC Thread#%d", which);
 }
@@ -57,10 +54,6 @@
   }
 }
 
-void GCTaskThread::start() {
-  os::start_thread(this);
-}
-
 GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
   guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
   if (_time_stamps == NULL) {
diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp b/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp
index 49f9bd0..aa10a69 100644
--- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,13 +48,13 @@
 
   bool _is_working;                     // True if participating in GC tasks
 
- public:
   // Factory create and destroy methods.
   static GCTaskThread* create(GCTaskManager* manager,
                               uint           which,
                               uint           processor_id) {
     return new GCTaskThread(manager, which, processor_id);
   }
+ public:
   static void destroy(GCTaskThread* manager) {
     if (manager != NULL) {
       delete manager;
@@ -65,8 +65,6 @@
     return true;
   }
   virtual void run();
-  // Methods.
-  void start();
 
   void print_task_time_stamps();
 
diff --git a/hotspot/src/share/vm/gc/parallel/generationSizer.hpp b/hotspot/src/share/vm/gc/parallel/generationSizer.hpp
index 539629b..5584760 100644
--- a/hotspot/src/share/vm/gc/parallel/generationSizer.hpp
+++ b/hotspot/src/share/vm/gc/parallel/generationSizer.hpp
@@ -41,5 +41,11 @@
   void initialize_alignments();
   void initialize_flags();
   void initialize_size_info();
+
+ public:
+  // We don't have associated counters and complain if this is invoked.
+  void initialize_gc_policy_counters() {
+    ShouldNotReachHere();
+  }
 };
 #endif // SHARE_VM_GC_PARALLEL_GENERATIONSIZER_HPP
diff --git a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp
index 76241d9..39b63ac 100644
--- a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp
+++ b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp
@@ -59,10 +59,8 @@
     _region_start = covered_region.start();
     _region_size = covered_region.word_size();
     BitMap::bm_word_t* map = (BitMap::bm_word_t*)_virtual_space->reserved_low_addr();
-    _beg_bits.set_map(map);
-    _beg_bits.set_size(bits / 2);
-    _end_bits.set_map(map + words / 2);
-    _end_bits.set_size(bits / 2);
+    _beg_bits = BitMapView(map,             bits / 2);
+    _end_bits = BitMapView(map + words / 2, bits / 2);
     return true;
   }
 
diff --git a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp
index 3f29f94..9457d3e 100644
--- a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp
+++ b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp
@@ -182,8 +182,8 @@
 
   HeapWord*       _region_start;
   size_t          _region_size;
-  BitMap          _beg_bits;
-  BitMap          _end_bits;
+  BitMapView      _beg_bits;
+  BitMapView      _end_bits;
   PSVirtualSpace* _virtual_space;
   size_t          _reserved_byte_size;
 };
diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp
index bc58a0d..05efac3 100644
--- a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp
+++ b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp
@@ -58,19 +58,16 @@
     ParCompactionManager::gc_thread_compaction_manager(which);
 
   ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
-  CLDToOopClosure mark_and_push_from_clds(&mark_and_push_closure, true);
   MarkingCodeBlobClosure mark_and_push_in_blobs(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations);
 
   if (_java_thread != NULL)
     _java_thread->oops_do(
         &mark_and_push_closure,
-        &mark_and_push_from_clds,
         &mark_and_push_in_blobs);
 
   if (_vm_thread != NULL)
     _vm_thread->oops_do(
         &mark_and_push_closure,
-        &mark_and_push_from_clds,
         &mark_and_push_in_blobs);
 
   // Do the real work
@@ -99,8 +96,7 @@
     {
       ResourceMark rm;
       MarkingCodeBlobClosure each_active_code_blob(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations);
-      CLDToOopClosure mark_and_push_from_cld(&mark_and_push_closure);
-      Threads::oops_do(&mark_and_push_closure, &mark_and_push_from_cld, &each_active_code_blob);
+      Threads::oops_do(&mark_and_push_closure, &each_active_code_blob);
     }
     break;
 
@@ -224,48 +220,28 @@
 }
 
 //
-// StealRegionCompactionTask
+// CompactionWithStealingTask
 //
 
-StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t):
+CompactionWithStealingTask::CompactionWithStealingTask(ParallelTaskTerminator* t):
   _terminator(t) {}
 
-void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) {
+void CompactionWithStealingTask::do_it(GCTaskManager* manager, uint which) {
   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 
   ParCompactionManager* cm =
     ParCompactionManager::gc_thread_compaction_manager(which);
 
-
-  // If not all threads are active, get a draining stack
-  // from the list.  Else, just use this threads draining stack.
-  uint which_stack_index;
-  bool use_all_workers = manager->all_workers_active();
-  if (use_all_workers) {
-    which_stack_index = which;
-    assert(manager->active_workers() == ParallelGCThreads,
-           "all_workers_active has been incorrectly set: "
-           " active %d  ParallelGCThreads %u", manager->active_workers(),
-           ParallelGCThreads);
-  } else {
-    which_stack_index = ParCompactionManager::pop_recycled_stack_index();
-  }
-
-  cm->set_region_stack_index(which_stack_index);
-  cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
-
-  // Has to drain stacks first because there may be regions on
-  // preloaded onto the stack and this thread may never have
-  // done a draining task.  Are the draining tasks needed?
+  // Drain the stacks that have been preloaded with regions
+  // that are ready to fill.
 
   cm->drain_region_stacks();
 
+  guarantee(cm->region_stack()->is_empty(), "Not empty");
+
   size_t region_index = 0;
   int random_seed = 17;
 
-  // If we're the termination task, try 10 rounds of stealing before
-  // setting the termination flag
-
   while(true) {
     if (ParCompactionManager::steal(which, &random_seed, region_index)) {
       PSParallelCompact::fill_and_update_region(cm, region_index);
@@ -297,42 +273,3 @@
                                                          _region_index_start,
                                                          _region_index_end);
 }
-
-void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
-  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
-
-  ParCompactionManager* cm =
-    ParCompactionManager::gc_thread_compaction_manager(which);
-
-  uint which_stack_index;
-  bool use_all_workers = manager->all_workers_active();
-  if (use_all_workers) {
-    which_stack_index = which;
-    assert(manager->active_workers() == ParallelGCThreads,
-           "all_workers_active has been incorrectly set: "
-           " active %d  ParallelGCThreads %u", manager->active_workers(),
-           ParallelGCThreads);
-  } else {
-    which_stack_index = stack_index();
-  }
-
-  cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
-
-  cm->set_region_stack_index(which_stack_index);
-
-  // Process any regions already in the compaction managers stacks.
-  cm->drain_region_stacks();
-
-  assert(cm->region_stack()->is_empty(), "Not empty");
-
-  if (!use_all_workers) {
-    // Always give up the region stack.
-    assert(cm->region_stack() ==
-           ParCompactionManager::region_list(cm->region_stack_index()),
-           "region_stack and region_stack_index are inconsistent");
-    ParCompactionManager::push_recycled_stack_index(cm->region_stack_index());
-
-    cm->set_region_stack(NULL);
-    cm->set_region_stack_index((uint)max_uintx);
-  }
-}
diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp
index 40a2009..08bad72 100644
--- a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp
+++ b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -195,16 +195,16 @@
 };
 
 //
-// StealRegionCompactionTask
+// CompactionWithStealingTask
 //
 // This task is used to distribute work to idle threads.
 //
 
-class StealRegionCompactionTask : public GCTask {
+class CompactionWithStealingTask : public GCTask {
  private:
    ParallelTaskTerminator* const _terminator;
  public:
-  StealRegionCompactionTask(ParallelTaskTerminator* t);
+  CompactionWithStealingTask(ParallelTaskTerminator* t);
 
   char* name() { return (char *)"steal-region-task"; }
   ParallelTaskTerminator* terminator() { return _terminator; }
@@ -234,27 +234,4 @@
 
   virtual void do_it(GCTaskManager* manager, uint which);
 };
-
-//
-// DrainStacksCompactionTask
-//
-// This task processes regions that have been added to the stacks of each
-// compaction manager.
-//
-// Trying to use one draining thread does not work because there are no
-// guarantees about which task will be picked up by which thread.  For example,
-// if thread A gets all the preloaded regions, thread A may not get a draining
-// task (they may all be done by other threads).
-//
-
-class DrainStacksCompactionTask : public GCTask {
- uint _stack_index;
- uint stack_index() { return _stack_index; }
- public:
-  DrainStacksCompactionTask(uint stack_index) : GCTask(),
-                                                _stack_index(stack_index) {};
-  char* name() { return (char *)"drain-region-task"; }
-  virtual void do_it(GCTaskManager* manager, uint which);
-};
-
 #endif // SHARE_VM_GC_PARALLEL_PCTASKS_HPP
diff --git a/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp b/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp
index 433b4dc..2884b4c 100644
--- a/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp
+++ b/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp
@@ -43,8 +43,6 @@
 PSOldGen*            ParCompactionManager::_old_gen = NULL;
 ParCompactionManager**  ParCompactionManager::_manager_array = NULL;
 
-RegionTaskQueue**              ParCompactionManager::_region_list = NULL;
-
 OopTaskQueueSet*     ParCompactionManager::_stack_array = NULL;
 ParCompactionManager::ObjArrayTaskQueueSet*
   ParCompactionManager::_objarray_queues = NULL;
@@ -52,14 +50,8 @@
 ParMarkBitMap*       ParCompactionManager::_mark_bitmap = NULL;
 RegionTaskQueueSet*  ParCompactionManager::_region_array = NULL;
 
-uint*                 ParCompactionManager::_recycled_stack_index = NULL;
-int                   ParCompactionManager::_recycled_top = -1;
-int                   ParCompactionManager::_recycled_bottom = -1;
-
 ParCompactionManager::ParCompactionManager() :
-    _action(CopyAndUpdate),
-    _region_stack(NULL),
-    _region_stack_index((uint)max_uintx) {
+    _action(CopyAndUpdate) {
 
   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 
@@ -68,14 +60,11 @@
 
   marking_stack()->initialize();
   _objarray_stack.initialize();
+  _region_stack.initialize();
 
   reset_bitmap_query_cache();
 }
 
-ParCompactionManager::~ParCompactionManager() {
-  delete _recycled_stack_index;
-}
-
 void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
   assert(PSParallelCompact::gc_task_manager() != NULL,
     "Needed for initialization");
@@ -88,19 +77,6 @@
   _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1, mtGC);
   guarantee(_manager_array != NULL, "Could not allocate manager_array");
 
-  _region_list = NEW_C_HEAP_ARRAY(RegionTaskQueue*,
-                         parallel_gc_threads+1, mtGC);
-  guarantee(_region_list != NULL, "Could not initialize promotion manager");
-
-  _recycled_stack_index = NEW_C_HEAP_ARRAY(uint, parallel_gc_threads, mtGC);
-
-  // parallel_gc-threads + 1 to be consistent with the number of
-  // compaction managers.
-  for(uint i=0; i<parallel_gc_threads + 1; i++) {
-    _region_list[i] = new RegionTaskQueue();
-    region_list(i)->initialize();
-  }
-
   _stack_array = new OopTaskQueueSet(parallel_gc_threads);
   guarantee(_stack_array != NULL, "Could not allocate stack_array");
   _objarray_queues = new ObjArrayTaskQueueSet(parallel_gc_threads);
@@ -114,7 +90,7 @@
     guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
     stack_array()->register_queue(i, _manager_array[i]->marking_stack());
     _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack);
-    region_array()->register_queue(i, region_list(i));
+    region_array()->register_queue(i, _manager_array[i]->region_stack());
   }
 
   // The VMThread gets its own ParCompactionManager, which is not available
@@ -133,29 +109,6 @@
   }
 }
 
-int ParCompactionManager::pop_recycled_stack_index() {
-  assert(_recycled_bottom <= _recycled_top, "list is empty");
-  // Get the next available index
-  if (_recycled_bottom < _recycled_top) {
-    uint cur, next, last;
-    do {
-      cur = _recycled_bottom;
-      next = cur + 1;
-      last = Atomic::cmpxchg(next, &_recycled_bottom, cur);
-    } while (cur != last);
-    return _recycled_stack_index[next];
-  } else {
-    return -1;
-  }
-}
-
-void ParCompactionManager::push_recycled_stack_index(uint v) {
-  // Get the next available index
-  int cur = Atomic::add(1, &_recycled_top);
-  _recycled_stack_index[cur] = v;
-  assert(_recycled_bottom <= _recycled_top, "list top and bottom are wrong");
-}
-
 bool ParCompactionManager::should_update() {
   assert(action() != NotValid, "Action is not set");
   return (action() == ParCompactionManager::Update) ||
@@ -170,15 +123,6 @@
          (action() == ParCompactionManager::UpdateAndCopy);
 }
 
-void ParCompactionManager::region_list_push(uint list_index,
-                                            size_t region_index) {
-  region_list(list_index)->push(region_index);
-}
-
-void ParCompactionManager::verify_region_list_empty(uint list_index) {
-  assert(region_list(list_index)->is_empty(), "Not empty");
-}
-
 ParCompactionManager*
 ParCompactionManager::gc_thread_compaction_manager(uint index) {
   assert(index < ParallelGCThreads, "index out of range");
diff --git a/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp b/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp
index 9e35ff2..9eb8bce 100644
--- a/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp
+++ b/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp
@@ -40,7 +40,7 @@
   friend class ParallelTaskTerminator;
   friend class ParMarkBitMap;
   friend class PSParallelCompact;
-  friend class StealRegionCompactionTask;
+  friend class CompactionWithStealingTask;
   friend class UpdateAndFillClosure;
   friend class RefProcTaskExecutor;
   friend class IdleGCTask;
@@ -79,31 +79,7 @@
   // Is there a way to reuse the _marking_stack for the
   // saving empty regions?  For now just create a different
   // type of TaskQueue.
-  RegionTaskQueue*             _region_stack;
-
-  static RegionTaskQueue**     _region_list;
-  // Index in _region_list for current _region_stack.
-  uint _region_stack_index;
-
-  // Indexes of recycled region stacks/overflow stacks
-  // Stacks of regions to be compacted are embedded in the tasks doing
-  // the compaction.  A thread that executes the task extracts the
-  // region stack and drains it.  These threads keep these region
-  // stacks for use during compaction task stealing.  If a thread
-  // gets a second draining task, it pushed its current region stack
-  // index into the array _recycled_stack_index and gets a new
-  // region stack from the task.  A thread that is executing a
-  // compaction stealing task without ever having executing a
-  // draining task, will get a region stack from _recycled_stack_index.
-  //
-  // Array of indexes into the array of region stacks.
-  static uint*                    _recycled_stack_index;
-  // The index into _recycled_stack_index of the last region stack index
-  // pushed.  If -1, there are no entries into _recycled_stack_index.
-  static int                      _recycled_top;
-  // The index into _recycled_stack_index of the last region stack index
-  // popped.  If -1, there has not been any entry popped.
-  static int                      _recycled_bottom;
+  RegionTaskQueue              _region_stack;
 
   static ParMarkBitMap* _mark_bitmap;
 
@@ -151,32 +127,15 @@
 
   static void reset_all_bitmap_query_caches();
 
-  RegionTaskQueue* region_stack()                { return _region_stack; }
-  void set_region_stack(RegionTaskQueue* v)       { _region_stack = v; }
+  RegionTaskQueue* region_stack()                { return &_region_stack; }
 
   inline static ParCompactionManager* manager_array(uint index);
 
-  inline static RegionTaskQueue* region_list(int index) {
-    return _region_list[index];
-  }
-
-  uint region_stack_index() { return _region_stack_index; }
-  void set_region_stack_index(uint v) { _region_stack_index = v; }
-
-  // Pop and push unique reusable stack index
-  static int pop_recycled_stack_index();
-  static void push_recycled_stack_index(uint v);
-  static void reset_recycled_stack_index() {
-    _recycled_bottom = _recycled_top = -1;
-  }
-
   ParCompactionManager();
-  ~ParCompactionManager();
 
   // Pushes onto the region stack at the given index.  If the
   // region stack is full,
   // pushes onto the region overflow stack.
-  static void region_list_push(uint stack_index, size_t region_index);
   static void verify_region_list_empty(uint stack_index);
   ParMarkBitMap* mark_bitmap() { return _mark_bitmap; }
 
diff --git a/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp b/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp
index e2084e9..9fa9730 100644
--- a/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp
+++ b/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp
@@ -505,9 +505,8 @@
     ParallelScavengeHeap::ParStrongRootsScope psrs;
     Universe::oops_do(mark_and_push_closure());
     JNIHandles::oops_do(mark_and_push_closure());   // Global (strong) JNI handles
-    CLDToOopClosure mark_and_push_from_cld(mark_and_push_closure());
     MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations);
-    Threads::oops_do(mark_and_push_closure(), &mark_and_push_from_cld, &each_active_code_blob);
+    Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
     ObjectSynchronizer::oops_do(mark_and_push_closure());
     FlatProfiler::oops_do(mark_and_push_closure());
     Management::oops_do(mark_and_push_closure());
@@ -597,8 +596,7 @@
   // General strong roots.
   Universe::oops_do(adjust_pointer_closure());
   JNIHandles::oops_do(adjust_pointer_closure());   // Global (strong) JNI handles
-  CLDToOopClosure adjust_from_cld(adjust_pointer_closure());
-  Threads::oops_do(adjust_pointer_closure(), &adjust_from_cld, NULL);
+  Threads::oops_do(adjust_pointer_closure(), NULL);
   ObjectSynchronizer::oops_do(adjust_pointer_closure());
   FlatProfiler::oops_do(adjust_pointer_closure());
   Management::oops_do(adjust_pointer_closure());
diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp
index 6b145d1..d16e510 100644
--- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp
+++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp
@@ -249,7 +249,7 @@
   const size_t last = summary_data.addr_to_region_idx(end_addr);
   HeapWord* pdest = 0;
 
-  while (i <= last) {
+  while (i < last) {
     ParallelCompactData::RegionData* c = summary_data.region(i);
     if (c->data_size() != 0 || c->destination() != pdest) {
       print_generic_summary_region(i, c);
@@ -377,6 +377,26 @@
     print_generic_summary_data(summary_data, space->bottom(), space->top());
   } while (++id < PSParallelCompact::last_space_id);
 }
+
+void ParallelCompact_test() {
+  if (!UseParallelOldGC) {
+    return;
+  }
+  // Check that print_generic_summary_data() does not print the
+  // end region by placing a bad value in the destination of the
+  // end region.  The end region should not be printed because it
+  // corresponds to the space after the end of the heap.
+  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
+  ParCompactionManager* const vmthread_cm =
+    ParCompactionManager::manager_array(ParallelGCThreads);
+  HeapWord* begin_heap =
+    (HeapWord*) heap->old_gen()->virtual_space()->low_boundary();
+  HeapWord* end_heap =
+    (HeapWord*) heap->young_gen()->virtual_space()->high_boundary();
+
+  print_generic_summary_data(PSParallelCompact::summary_data(),
+    begin_heap, end_heap);
+}
 #endif  // #ifndef PRODUCT
 
 #ifdef  ASSERT
@@ -1902,7 +1922,7 @@
     ParCompactionManager* const cm =
       ParCompactionManager::manager_array(int(i));
     assert(cm->marking_stack()->is_empty(),       "should be empty");
-    assert(ParCompactionManager::region_list(int(i))->is_empty(), "should be empty");
+    assert(cm->region_stack()->is_empty(), "Region stack " SIZE_FORMAT " is not empty", i);
   }
 #endif // ASSERT
 
@@ -2148,8 +2168,7 @@
   // General strong roots.
   Universe::oops_do(&oop_closure);
   JNIHandles::oops_do(&oop_closure);   // Global (strong) JNI handles
-  CLDToOopClosure adjust_from_cld(&oop_closure);
-  Threads::oops_do(&oop_closure, &adjust_from_cld, NULL);
+  Threads::oops_do(&oop_closure, NULL);
   ObjectSynchronizer::oops_do(&oop_closure);
   FlatProfiler::oops_do(&oop_closure);
   Management::oops_do(&oop_closure);
@@ -2212,7 +2231,7 @@
   }
 };
 
-void PSParallelCompact::enqueue_region_draining_tasks(GCTaskQueue* q,
+void PSParallelCompact::prepare_region_draining_tasks(GCTaskQueue* q,
                                                       uint parallel_gc_threads)
 {
   GCTraceTime(Trace, gc, phases) tm("Drain Task Setup", &_gc_timer);
@@ -2220,29 +2239,12 @@
   // Find the threads that are active
   unsigned int which = 0;
 
-  const uint task_count = MAX2(parallel_gc_threads, 1U);
-  for (uint j = 0; j < task_count; j++) {
-    q->enqueue(new DrainStacksCompactionTask(j));
-    ParCompactionManager::verify_region_list_empty(j);
-    // Set the region stacks variables to "no" region stack values
-    // so that they will be recognized and needing a region stack
-    // in the stealing tasks if they do not get one by executing
-    // a draining stack.
-    ParCompactionManager* cm = ParCompactionManager::manager_array(j);
-    cm->set_region_stack(NULL);
-    cm->set_region_stack_index((uint)max_uintx);
-  }
-  ParCompactionManager::reset_recycled_stack_index();
-
   // Find all regions that are available (can be filled immediately) and
   // distribute them to the thread stacks.  The iteration is done in reverse
   // order (high to low) so the regions will be removed in ascending order.
 
   const ParallelCompactData& sd = PSParallelCompact::summary_data();
 
-  // A region index which corresponds to the tasks created above.
-  // "which" must be 0 <= which < task_count
-
   which = 0;
   // id + 1 is used to test termination so unsigned  can
   // be used with an old_space_id == 0.
@@ -2258,12 +2260,11 @@
 
     for (size_t cur = end_region - 1; cur + 1 > beg_region; --cur) {
       if (sd.region(cur)->claim_unsafe()) {
-        ParCompactionManager::region_list_push(which, cur);
+        ParCompactionManager* cm = ParCompactionManager::manager_array(which);
+        cm->region_stack()->push(cur);
         region_logger.handle(cur);
         // Assign regions to tasks in round-robin fashion.
-        if (++which == task_count) {
-          assert(which <= parallel_gc_threads,
-            "Inconsistent number of workers");
+        if (++which == parallel_gc_threads) {
           which = 0;
         }
       }
@@ -2362,10 +2363,8 @@
 
   // Once a thread has drained it's stack, it should try to steal regions from
   // other threads.
-  if (parallel_gc_threads > 1) {
-    for (uint j = 0; j < parallel_gc_threads; j++) {
-      q->enqueue(new StealRegionCompactionTask(terminator_ptr));
-    }
+  for (uint j = 0; j < parallel_gc_threads; j++) {
+    q->enqueue(new CompactionWithStealingTask(terminator_ptr));
   }
 }
 
@@ -2422,7 +2421,7 @@
   ParallelTaskTerminator terminator(active_gc_threads, qset);
 
   GCTaskQueue* q = GCTaskQueue::create();
-  enqueue_region_draining_tasks(q, active_gc_threads);
+  prepare_region_draining_tasks(q, active_gc_threads);
   enqueue_dense_prefix_tasks(q, active_gc_threads);
   enqueue_region_stealing_tasks(q, &terminator, active_gc_threads);
 
diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp
index ce0beda..50b7bfb 100644
--- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp
+++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp
@@ -631,8 +631,8 @@
 inline size_t
 ParallelCompactData::addr_to_region_idx(const HeapWord* addr) const
 {
-  assert(addr >= _region_start, "bad addr");
-  assert(addr <= _region_end, "bad addr");
+  assert(addr >= _region_start, "bad addr " PTR_FORMAT " _region_start " PTR_FORMAT, p2i(addr), p2i(_region_start));
+  assert(addr <= _region_end, "bad addr " PTR_FORMAT " _region_end " PTR_FORMAT, p2i(addr), p2i(_region_end));
   return pointer_delta(addr, _region_start) >> Log2RegionSize;
 }
 
@@ -1079,7 +1079,7 @@
   static void compact();
 
   // Add available regions to the stack and draining tasks to the task queue.
-  static void enqueue_region_draining_tasks(GCTaskQueue* q,
+  static void prepare_region_draining_tasks(GCTaskQueue* q,
                                             uint parallel_gc_threads);
 
   // Add dense prefix update tasks to the task queue.
diff --git a/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp b/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp
index a5bf579..bdd965b 100644
--- a/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp
+++ b/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp
@@ -237,6 +237,10 @@
   _preserved_marks = preserved_marks;
 }
 
+void PSPromotionManager::restore_preserved_marks() {
+  _preserved_marks_set->restore(PSScavenge::gc_task_manager());
+}
+
 void PSPromotionManager::drain_stacks_depth(bool totally_drain) {
   totally_drain = totally_drain || _totally_drain;
 
diff --git a/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp b/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp
index 32159e6..0946f10 100644
--- a/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp
+++ b/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,7 +180,7 @@
 
   void reset();
   void register_preserved_marks(PreservedMarks* preserved_marks);
-  static void restore_preserved_marks() { _preserved_marks_set->restore(); }
+  static void restore_preserved_marks();
 
   void flush_labs();
   void drain_stacks(bool totally_drain) {
diff --git a/hotspot/src/share/vm/gc/parallel/psScavenge.cpp b/hotspot/src/share/vm/gc/parallel/psScavenge.cpp
index b027d68..82caad3 100644
--- a/hotspot/src/share/vm/gc/parallel/psScavenge.cpp
+++ b/hotspot/src/share/vm/gc/parallel/psScavenge.cpp
@@ -443,7 +443,7 @@
     promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer);
     if (promotion_failure_occurred) {
       clean_up_failed_promotion();
-      log_info(gc)("Promotion failed");
+      log_info(gc, promotion)("Promotion failed");
     }
 
     _gc_tracer.report_tenuring_threshold(tenuring_threshold());
diff --git a/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp b/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp
index f7e9868..a944277 100644
--- a/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp
+++ b/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp
@@ -140,12 +140,6 @@
     // If the klass has not been dirtied we know that there's
     // no references into  the young gen and we can skip it.
 
-    NOT_PRODUCT(ResourceMark rm);
-    log_develop_trace(gc, scavenge)("PSScavengeKlassClosure::do_klass " PTR_FORMAT ", %s, dirty: %s",
-                                    p2i(klass),
-                                    klass->external_name(),
-                                    klass->has_modified_oops() ? "true" : "false");
-
     if (klass->has_modified_oops()) {
       // Clean the klass since we're going to scavenge all the metadata.
       klass->clear_modified_oops();
diff --git a/hotspot/src/share/vm/gc/parallel/psTasks.cpp b/hotspot/src/share/vm/gc/parallel/psTasks.cpp
index 4f372f9..9e95868 100644
--- a/hotspot/src/share/vm/gc/parallel/psTasks.cpp
+++ b/hotspot/src/share/vm/gc/parallel/psTasks.cpp
@@ -65,8 +65,7 @@
     case threads:
     {
       ResourceMark rm;
-      CLDClosure* cld_closure = NULL; // Not needed. All CLDs are already visited.
-      Threads::oops_do(&roots_closure, cld_closure, NULL);
+      Threads::oops_do(&roots_closure, NULL);
     }
     break;
 
@@ -122,14 +121,13 @@
 
   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   PSScavengeRootsClosure roots_closure(pm);
-  CLDClosure* roots_from_clds = NULL;  // Not needed. All CLDs are already visited.
   MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations);
 
   if (_java_thread != NULL)
-    _java_thread->oops_do(&roots_closure, roots_from_clds, &roots_in_blobs);
+    _java_thread->oops_do(&roots_closure, &roots_in_blobs);
 
   if (_vm_thread != NULL)
-    _vm_thread->oops_do(&roots_closure, roots_from_clds, &roots_in_blobs);
+    _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
 
   // Do the real work
   pm->drain_stacks(false);
diff --git a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp
index 247c7e3..c8d3e0f 100644
--- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp
+++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp
@@ -564,7 +564,7 @@
 
 void DefNewGeneration::adjust_desired_tenuring_threshold() {
   // Set the desired survivor size to half the real survivor space
-  GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->collector_policy()->counters();
+  GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters();
   _tenuring_threshold =
     age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters);
 }
@@ -945,7 +945,7 @@
 
   // update the generation and space performance counters
   update_counters();
-  gch->collector_policy()->counters()->update_counters();
+  gch->gen_policy()->counters()->update_counters();
 }
 
 void DefNewGeneration::record_spaces_top() {
diff --git a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp
index 8365c62..9aa3f79 100644
--- a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp
+++ b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -130,10 +130,7 @@
   uintx max_active_workers =
     MAX2(active_workers_by_JT, active_workers_by_heap_size);
 
-  // Limit the number of workers to the the number created,
-  // (workers()).
-  new_active_workers = MIN2(max_active_workers,
-                                (uintx) total_workers);
+  new_active_workers = MIN2(max_active_workers, (uintx) total_workers);
 
   // Increase GC workers instantly but decrease them more
   // slowly.
@@ -167,7 +164,7 @@
       "Jiggled active workers too much");
   }
 
-   log_trace(gc, task)("GCTaskManager::calc_default_active_workers() : "
+  log_trace(gc, task)("GCTaskManager::calc_default_active_workers() : "
      "active_workers(): " UINTX_FORMAT "  new_active_workers: " UINTX_FORMAT "  "
      "prev_active_workers: " UINTX_FORMAT "\n"
      " active_workers_by_JT: " UINTX_FORMAT "  active_workers_by_heap_size: " UINTX_FORMAT,
diff --git a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp
index eb48362..27bc4f3 100644
--- a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp
+++ b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp
index cfd55ad..e403260 100644
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp
@@ -510,10 +510,6 @@
   fill_with_object_impl(start, words, zap);
 }
 
-void CollectedHeap::post_initialize() {
-  collector_policy()->post_heap_initialize();
-}
-
 HeapWord* CollectedHeap::allocate_new_tlab(size_t size) {
   guarantee(false, "thread-local allocation buffers not supported");
   return NULL;
diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp
index 4c0e8d9..2b2fe90 100644
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp
@@ -209,7 +209,7 @@
   // In many heaps, there will be a need to perform some initialization activities
   // after the Universe is fully formed, but before general heap allocation is allowed.
   // This is the correct place to place such initialization methods.
-  virtual void post_initialize();
+  virtual void post_initialize() = 0;
 
   // Stop any onging concurrent work and prepare for exit.
   virtual void stop() {}
diff --git a/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp b/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp
index 82ac817..8c9b65e 100644
--- a/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp
+++ b/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp
@@ -58,8 +58,6 @@
 
 class CollectorPolicy : public CHeapObj<mtGC> {
  protected:
-  GCPolicyCounters* _gc_policy_counters;
-
   virtual void initialize_alignments() = 0;
   virtual void initialize_flags();
   virtual void initialize_size_info();
@@ -129,17 +127,14 @@
   virtual MarkSweepPolicy*              as_mark_sweep_policy()            { return NULL; }
 #if INCLUDE_ALL_GCS
   virtual ConcurrentMarkSweepPolicy*    as_concurrent_mark_sweep_policy() { return NULL; }
-  virtual G1CollectorPolicy*            as_g1_policy()                    { return NULL; }
 #endif // INCLUDE_ALL_GCS
   // Note that these are not virtual.
   bool is_generation_policy()            { return as_generation_policy() != NULL; }
   bool is_mark_sweep_policy()            { return as_mark_sweep_policy() != NULL; }
 #if INCLUDE_ALL_GCS
   bool is_concurrent_mark_sweep_policy() { return as_concurrent_mark_sweep_policy() != NULL; }
-  bool is_g1_policy()                    { return as_g1_policy() != NULL; }
 #else  // INCLUDE_ALL_GCS
   bool is_concurrent_mark_sweep_policy() { return false; }
-  bool is_g1_policy()                    { return false; }
 #endif // INCLUDE_ALL_GCS
 
 
@@ -148,19 +143,6 @@
   MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
                                                size_t size,
                                                Metaspace::MetadataType mdtype);
-
-  // Performance Counter support
-  GCPolicyCounters* counters()     { return _gc_policy_counters; }
-
-  // Create the jstat counters for the GC policy.  By default, policy's
-  // don't have associated counters, and we complain if this is invoked.
-  virtual void initialize_gc_policy_counters() {
-    ShouldNotReachHere();
-  }
-
-  // Do any updates required to global flags that are due to heap initialization
-  // changes
-  virtual void post_heap_initialize() = 0;
 };
 
 class ClearedAllSoftRefs : public StackObj {
@@ -197,6 +179,8 @@
   GenerationSpec* _young_gen_spec;
   GenerationSpec* _old_gen_spec;
 
+  GCPolicyCounters* _gc_policy_counters;
+
   // Return true if an allocation should be attempted in the older generation
   // if it fails in the younger generation.  Return false, otherwise.
   virtual bool should_try_older_generation_allocation(size_t word_size) const;
@@ -243,6 +227,12 @@
     return _old_gen_spec;
   }
 
+  // Performance Counter support
+  GCPolicyCounters* counters()     { return _gc_policy_counters; }
+
+  // Create the jstat counters for the GC policy.
+  virtual void initialize_gc_policy_counters() = 0;
+
   virtual GenCollectorPolicy* as_generation_policy() { return this; }
 
   virtual void initialize_generations() { };
@@ -266,10 +256,6 @@
   virtual void initialize_size_policy(size_t init_eden_size,
                                       size_t init_promo_size,
                                       size_t init_survivor_size);
-
-  virtual void post_heap_initialize() {
-    assert(_max_young_size == MaxNewSize, "Should be taken care of by initialize_size_info");
-  }
 };
 
 class MarkSweepPolicy : public GenCollectorPolicy {
diff --git a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp
index c60e3a0..049b675 100644
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp
@@ -179,7 +179,6 @@
 }
 
 void GenCollectedHeap::post_initialize() {
-  CollectedHeap::post_initialize();
   ref_processing_init();
   assert((_young_gen->kind() == Generation::DefNew) ||
          (_young_gen->kind() == Generation::ParNew),
@@ -583,14 +582,11 @@
     ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure);
   }
 
-  // Some CLDs contained in the thread frames should be considered strong.
-  // Don't process them if they will be processed during the ClassLoaderDataGraph phase.
-  CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL;
   // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway
   CodeBlobToOopClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
 
   bool is_par = scope->n_threads() > 1;
-  Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_clds_p, roots_from_code_p);
+  Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_code_p);
 
   if (!_process_strong_tasks->is_task_claimed(GCH_PS_Universe_oops_do)) {
     Universe::oops_do(strong_roots);
diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp
index 96d124e..9312c19 100644
--- a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp
+++ b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp
@@ -26,6 +26,11 @@
 #include "gc/shared/preservedMarks.inline.hpp"
 #include "gc/shared/workgroup.hpp"
 #include "memory/allocation.inline.hpp"
+#include "memory/resourceArea.hpp"
+#include "utilities/macros.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc/parallel/gcTaskManager.hpp"
+#endif
 
 void PreservedMarks::restore() {
   while (!_stack.is_empty()) {
@@ -106,10 +111,46 @@
   workers->run_task(&task);
 }
 
-// temporary, used by PS
-void PreservedMarksSet::restore() {
-  restore<WorkGang>(NULL);
+#if INCLUDE_ALL_GCS
+class ParRestoreGCTask : public GCTask {
+private:
+  const uint _id;
+  PreservedMarksSet* const _preserved_marks_set;
+  volatile size_t* const _total_size_addr;
+
+public:
+  virtual char* name() { return (char*) "preserved mark restoration task"; }
+
+  virtual void do_it(GCTaskManager* manager, uint which) {
+    PreservedMarks* const preserved_marks = _preserved_marks_set->get(_id);
+    const size_t size = preserved_marks->size();
+    preserved_marks->restore();
+    // Only do the atomic add if the size is > 0.
+    if (size > 0) {
+      Atomic::add(size, _total_size_addr);
+    }
+  }
+
+  ParRestoreGCTask(uint id,
+                   PreservedMarksSet* preserved_marks_set,
+                   volatile size_t* total_size_addr)
+    : _id(id),
+      _preserved_marks_set(preserved_marks_set),
+      _total_size_addr(total_size_addr) { }
+};
+
+void PreservedMarksSet::restore_internal(GCTaskManager* gc_task_manager,
+                                         volatile size_t* total_size_addr) {
+  // GCTask / GCTaskQueue are ResourceObjs
+  ResourceMark rm;
+
+  GCTaskQueue* q = GCTaskQueue::create();
+  for (uint i = 0; i < num(); i += 1) {
+    q->enqueue(new ParRestoreGCTask(i, this, total_size_addr));
+  }
+  gc_task_manager->execute_and_wait(q);
 }
+#endif
 
 void PreservedMarksSet::reclaim() {
   assert_empty();
diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp
index 6ab52ba..3c8ebd8 100644
--- a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp
+++ b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp
@@ -30,24 +30,25 @@
 #include "oops/oop.hpp"
 #include "utilities/stack.hpp"
 
-class OopAndMarkOop {
-private:
-  oop _o;
-  markOop _m;
-
-public:
-  OopAndMarkOop(oop obj, markOop m) : _o(obj), _m(m) { }
-
-  void set_mark() const {
-    _o->set_mark(_m);
-  }
-};
-typedef Stack<OopAndMarkOop, mtGC> OopAndMarkOopStack;
-
+class GCTaskManager;
 class WorkGang;
 
 class PreservedMarks VALUE_OBJ_CLASS_SPEC {
 private:
+  class OopAndMarkOop {
+  private:
+    oop _o;
+    markOop _m;
+
+  public:
+    OopAndMarkOop(oop obj, markOop m) : _o(obj), _m(m) { }
+
+    void set_mark() const {
+      _o->set_mark(_m);
+    }
+  };
+  typedef Stack<OopAndMarkOop, mtGC> OopAndMarkOopStack;
+
   OopAndMarkOopStack _stack;
 
   inline bool should_preserve_mark(oop obj, markOop m) const;
@@ -93,6 +94,10 @@
   // Internal version of restore() that uses a WorkGang for parallelism.
   void restore_internal(WorkGang* workers, volatile size_t* total_size_addr);
 
+  // Internal version of restore() that uses a GCTaskManager for parallelism.
+  void restore_internal(GCTaskManager* gc_task_manager,
+                        volatile size_t* total_size_addr);
+
 public:
   uint num() const { return _num; }
 
@@ -110,14 +115,11 @@
   // the memory taken up by the stack segments. If the executor is
   // NULL, restoration will be done serially. If the executor is not
   // NULL, restoration could be done in parallel (when it makes
-  // sense). Supported executors: WorkGang (Serial, CMS, G1)
+  // sense). Supported executors: WorkGang (Serial, CMS, G1),
+  // GCTaskManager (PS).
   template <class E>
   inline void restore(E* executor);
 
-  // Do the restoration serially. Temporary, to be used by PS until we
-  // can support GCTaskManager in restore(E*).
-  void restore();
-
   // Reclaim stack array.
   void reclaim();
 
diff --git a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp
index 0c975d1..a9fb53f 100644
--- a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp
+++ b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp
@@ -36,6 +36,7 @@
 
 // static member initialization
 size_t           ThreadLocalAllocBuffer::_max_size       = 0;
+int              ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch = 0;
 unsigned         ThreadLocalAllocBuffer::_target_refills = 0;
 GlobalTLABStats* ThreadLocalAllocBuffer::_global_stats   = NULL;
 
@@ -215,6 +216,23 @@
 
   _global_stats = new GlobalTLABStats();
 
+  // Need extra space at the end of TLAB, otherwise prefetching
+  // instructions will fault (due to accessing memory outside of heap).
+  // The amount of space is the max of the number of lines to
+  // prefetch for array and for instance allocations. (Extra space must be
+  // reserved to accommodate both types of allocations.)
+  //
+  // Only SPARC-specific BIS instructions are known to fault. (Those
+  // instructions are generated if AllocatePrefetchStyle==3 and
+  // AllocatePrefetchInstr==1). To be on the safe side, however,
+  // extra space is reserved for all combinations of
+  // AllocatePrefetchStyle and AllocatePrefetchInstr.
+
+  // +1 for rounding up to next cache line, +1 to be safe
+  int lines =  MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2;
+  _reserve_for_allocation_prefetch = (AllocatePrefetchDistance + AllocatePrefetchStepSize * lines) /
+                                     (int)HeapWordSize;
+
   // During jvm startup, the main (primordial) thread is initialized
   // before the heap is initialized.  So reinitialize it now.
   guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
diff --git a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp
index 2af1957..6a5ab49 100644
--- a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp
+++ b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp
@@ -49,8 +49,9 @@
   size_t    _refill_waste_limit;                 // hold onto tlab if free() is larger than this
   size_t    _allocated_before_last_gc;           // total bytes allocated up until the last gc
 
-  static size_t   _max_size;                     // maximum size of any TLAB
-  static unsigned _target_refills;               // expected number of refills between GCs
+  static size_t   _max_size;                          // maximum size of any TLAB
+  static int      _reserve_for_allocation_prefetch;   // Reserve at the end of the TLAB
+  static unsigned _target_refills;                    // expected number of refills between GCs
 
   unsigned  _number_of_refills;
   unsigned  _fast_refill_waste;
@@ -129,7 +130,7 @@
   // Reserve space at the end of TLAB
   static size_t end_reserve() {
     int reserve_size = typeArrayOopDesc::header_size(T_INT);
-    return MAX2(reserve_size, VM_Version::reserve_for_allocation_prefetch());
+    return MAX2(reserve_size, _reserve_for_allocation_prefetch);
   }
   static size_t alignment_reserve()              { return align_object_size(end_reserve()); }
   static size_t alignment_reserve_in_bytes()     { return alignment_reserve() * HeapWordSize; }
diff --git a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp
index 004a5f4..9ac7d42 100644
--- a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp
+++ b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp
@@ -40,6 +40,7 @@
 #include "utilities/preserveException.hpp"
 #if INCLUDE_ALL_GCS
 #include "gc/g1/g1CollectedHeap.inline.hpp"
+#include "gc/g1/g1Policy.hpp"
 #endif // INCLUDE_ALL_GCS
 
 VM_GC_Operation::~VM_GC_Operation() {
diff --git a/hotspot/src/share/vm/gc/shared/workerManager.hpp b/hotspot/src/share/vm/gc/shared/workerManager.hpp
new file mode 100644
index 0000000..9dfa7d7
--- /dev/null
+++ b/hotspot/src/share/vm/gc/shared/workerManager.hpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_SHARED_WORKERMANAGER_HPP
+#define SHARE_VM_GC_SHARED_WORKERMANAGER_HPP
+
+#include "gc/shared/adaptiveSizePolicy.hpp"
+
+class WorkerManager : public AllStatic {
+ public:
+  // Create additional workers as needed.
+  //   active_workers - number of workers being requested for an upcoming
+  // parallel task.
+  //   total_workers - total number of workers.  This is the maximum
+  // number possible.
+  //   created_workers - number of workers already created.  This maybe
+  // less than, equal to, or greater than active workers.  If greater than
+  // or equal to active_workers, nothing is done.
+  //   worker_type - type of thread.
+  //   initializing - true if this is called to get the initial number of
+  // GC workers.
+  // If initializing is true, do a vm exit if the workers cannot be created.
+  // The initializing = true case is for JVM start up and failing to
+  // create all the worker at start should considered a problem so exit.
+  // If initializing = false, there are already some number of worker
+  // threads and a failure would not be optimal but should not be fatal.
+  template <class WorkerType>
+  static uint add_workers (WorkerType* holder,
+                   uint active_workers,
+                   uint total_workers,
+                   uint created_workers,
+                   os::ThreadType worker_type,
+                   bool initializing) {
+    uint start = created_workers;
+    uint end = MIN2(active_workers, total_workers);
+    for (uint worker_id = start; worker_id < end; worker_id += 1) {
+      WorkerThread* new_worker = holder->install_worker(worker_id);
+      assert(new_worker != NULL, "Failed to allocate GangWorker");
+      if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
+        if(initializing) {
+          vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
+                  "Cannot create worker GC thread. Out of system resources.");
+        }
+      }
+      created_workers++;
+      os::start_thread(new_worker);
+    }
+
+    log_trace(gc, task)("AdaptiveSizePolicy::add_workers() : "
+       "active_workers: %u created_workers: %u",
+       active_workers, created_workers);
+
+    return created_workers;
+  }
+};
+#endif // SHARE_VM_GC_SHARED_WORKERMANAGER_HPP
diff --git a/hotspot/src/share/vm/gc/shared/workgroup.cpp b/hotspot/src/share/vm/gc/shared/workgroup.cpp
index a8da10d..0dfffcd 100644
--- a/hotspot/src/share/vm/gc/shared/workgroup.cpp
+++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/shared/gcId.hpp"
 #include "gc/shared/workgroup.hpp"
+#include "gc/shared/workerManager.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/atomic.inline.hpp"
@@ -35,37 +36,45 @@
 // Definitions of WorkGang methods.
 
 // The current implementation will exit if the allocation
-// of any worker fails.  Still, return a boolean so that
-// a future implementation can possibly do a partial
-// initialization of the workers and report such to the
-// caller.
-bool AbstractWorkGang::initialize_workers() {
+// of any worker fails.
+void  AbstractWorkGang::initialize_workers() {
   log_develop_trace(gc, workgang)("Constructing work gang %s with %u threads", name(), total_workers());
   _workers = NEW_C_HEAP_ARRAY(AbstractGangWorker*, total_workers(), mtInternal);
   if (_workers == NULL) {
     vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GangWorker array.");
-    return false;
   }
+
+  _active_workers = ParallelGCThreads;
+  if (UseDynamicNumberOfGCThreads && !FLAG_IS_CMDLINE(ParallelGCThreads)) {
+    _active_workers = 1U;
+  }
+
+  add_workers(true);
+}
+
+
+AbstractGangWorker* AbstractWorkGang::install_worker(uint worker_id) {
+  AbstractGangWorker* new_worker = allocate_worker(worker_id);
+  set_thread(worker_id, new_worker);
+  return new_worker;
+}
+
+void AbstractWorkGang::add_workers(bool initializing) {
+
   os::ThreadType worker_type;
   if (are_ConcurrentGC_threads()) {
     worker_type = os::cgc_thread;
   } else {
     worker_type = os::pgc_thread;
   }
-  for (uint worker = 0; worker < total_workers(); worker += 1) {
-    AbstractGangWorker* new_worker = allocate_worker(worker);
-    assert(new_worker != NULL, "Failed to allocate GangWorker");
-    _workers[worker] = new_worker;
-    if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
-      vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
-              "Cannot create worker GC thread. Out of system resources.");
-      return false;
-    }
-    if (!DisableStartThread) {
-      os::start_thread(new_worker);
-    }
-  }
-  return true;
+
+  _created_workers = WorkerManager::add_workers(this,
+                                                _active_workers,
+                                                _total_workers,
+                                                _created_workers,
+                                                worker_type,
+                                                initializing);
+  _active_workers = MIN2(_created_workers, _active_workers);
 }
 
 AbstractGangWorker* AbstractWorkGang::worker(uint i) const {
@@ -79,7 +88,7 @@
 }
 
 void AbstractWorkGang::print_worker_threads_on(outputStream* st) const {
-  uint workers = total_workers();
+  uint workers = created_workers();
   for (uint i = 0; i < workers; i++) {
     worker(i)->print_on(st);
     st->cr();
@@ -88,7 +97,7 @@
 
 void AbstractWorkGang::threads_do(ThreadClosure* tc) const {
   assert(tc != NULL, "Null ThreadClosure");
-  uint workers = total_workers();
+  uint workers = created_workers();
   for (uint i = 0; i < workers; i++) {
     tc->do_thread(worker(i));
   }
@@ -255,7 +264,15 @@
 }
 
 void WorkGang::run_task(AbstractGangTask* task) {
-  _dispatcher->coordinator_execute_on_workers(task, active_workers());
+  run_task(task, active_workers());
+}
+
+void WorkGang::run_task(AbstractGangTask* task, uint num_workers) {
+  guarantee(num_workers <= active_workers(),
+            "Trying to execute task %s with %u workers which is more than the amount of active workers %u.",
+            task->name(), num_workers, active_workers());
+  guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name());
+  _dispatcher->coordinator_execute_on_workers(task, num_workers);
 }
 
 AbstractGangWorker::AbstractGangWorker(AbstractWorkGang* gang, uint id) {
diff --git a/hotspot/src/share/vm/gc/shared/workgroup.hpp b/hotspot/src/share/vm/gc/shared/workgroup.hpp
index ee6b7be..3889091 100644
--- a/hotspot/src/share/vm/gc/shared/workgroup.hpp
+++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp
@@ -112,6 +112,8 @@
   uint _total_workers;
   // The currently active workers in this gang.
   uint _active_workers;
+  // The count of created workers in the gang.
+  uint _created_workers;
   // Printing support.
   const char* _name;
 
@@ -120,23 +122,32 @@
   const bool _are_GC_task_threads;
   const bool _are_ConcurrentGC_threads;
 
+  void set_thread(uint worker_id, AbstractGangWorker* worker) {
+    _workers[worker_id] = worker;
+  }
+
  public:
   AbstractWorkGang(const char* name, uint workers, bool are_GC_task_threads, bool are_ConcurrentGC_threads) :
       _name(name),
       _total_workers(workers),
       _active_workers(UseDynamicNumberOfGCThreads ? 1U : workers),
+      _created_workers(0),
       _are_GC_task_threads(are_GC_task_threads),
       _are_ConcurrentGC_threads(are_ConcurrentGC_threads)
   { }
 
   // Initialize workers in the gang.  Return true if initialization succeeded.
-  bool initialize_workers();
+  void initialize_workers();
 
   bool are_GC_task_threads()      const { return _are_GC_task_threads; }
   bool are_ConcurrentGC_threads() const { return _are_ConcurrentGC_threads; }
 
   uint total_workers() const { return _total_workers; }
 
+  uint created_workers() const {
+    return _created_workers;
+  }
+
   virtual uint active_workers() const {
     assert(_active_workers <= _total_workers,
            "_active_workers: %u > _total_workers: %u", _active_workers, _total_workers);
@@ -144,22 +155,29 @@
            "Unless dynamic should use total workers");
     return _active_workers;
   }
+
   void set_active_workers(uint v) {
     assert(v <= _total_workers,
            "Trying to set more workers active than there are");
     _active_workers = MIN2(v, _total_workers);
+    add_workers(false /* exit_on_failure */);
     assert(v != 0, "Trying to set active workers to 0");
-    _active_workers = MAX2(1U, _active_workers);
     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
            "Unless dynamic should use total workers");
     log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers);
   }
 
+  // Add GC workers as needed.
+  void add_workers(bool initializing);
+
   // Return the Ith worker.
   AbstractGangWorker* worker(uint i) const;
 
   void threads_do(ThreadClosure* tc) const;
 
+  // Create a GC worker and install it into the work gang.
+  virtual AbstractGangWorker* install_worker(uint which);
+
   // Debugging.
   const char* name() const { return _name; }
 
@@ -192,8 +210,12 @@
            bool are_GC_task_threads,
            bool are_ConcurrentGC_threads);
 
-  // Run a task, returns when the task is done.
+  // Run a task using the current active number of workers, returns when the task is done.
   virtual void run_task(AbstractGangTask* task);
+  // Run a task with the given number of workers, returns
+  // when the task is done. The number of workers must be at most the number of
+  // active workers.
+  void run_task(AbstractGangTask* task, uint num_workers);
 
 protected:
   virtual AbstractGangWorker* allocate_worker(uint which);
diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
index 2b42fab..179940d 100644
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
@@ -578,8 +578,9 @@
 /* 0xDC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
 
 /* 0xE0 */ &&opc_default,     &&opc_default,        &&opc_default,         &&opc_default,
-/* 0xE4 */ &&opc_default,     &&opc_fast_aldc,      &&opc_fast_aldc_w,     &&opc_return_register_finalizer,
-/* 0xE8 */ &&opc_invokehandle,&&opc_default,        &&opc_default,         &&opc_default,
+/* 0xE4 */ &&opc_default,     &&opc_default,        &&opc_fast_aldc,    &&opc_fast_aldc_w,
+/* 0xE8 */ &&opc_return_register_finalizer,
+                              &&opc_invokehandle,   &&opc_default,      &&opc_default,
 /* 0xEC */ &&opc_default,     &&opc_default,        &&opc_default,         &&opc_default,
 
 /* 0xF0 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp
index f7121d0..5adbe46 100644
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -110,6 +110,7 @@
     intptr_t*             _locals;        // local variable pointer
     ConstantPoolCache*    _constants;     // constant pool cache
     Method*               _method;        // method being executed
+    oop                   _mirror;        // mirror to klass containing method
     DataLayout*           _mdx;           // compiler profiling data for current bytecode
     intptr_t*             _stack;         // expression stack
     messages              _msg;           // frame manager <-> interpreter message
diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp
index eb29da8..0544e1c 100644
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp
@@ -127,30 +127,7 @@
   _resolved_appendix = Handle();
   DEBUG_ONLY(verify());  // verify before making side effects
 
-  if (CompilationPolicy::must_be_compiled(selected_method)) {
-    // This path is unusual, mostly used by the '-Xcomp' stress test mode.
-
-    // Note: with several active threads, the must_be_compiled may be true
-    //       while can_be_compiled is false; remove assert
-    // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile");
-    if (!THREAD->can_call_java()) {
-      // don't force compilation, resolve was on behalf of compiler
-      return;
-    }
-    if (selected_method->method_holder()->is_not_initialized()) {
-      // 'is_not_initialized' means not only '!is_initialized', but also that
-      // initialization has not been started yet ('!being_initialized')
-      // Do not force compilation of methods in uninitialized classes.
-      // Note that doing this would throw an assert later,
-      // in CompileBroker::compile_method.
-      // We sometimes use the link resolver to do reflective lookups
-      // even before classes are initialized.
-      return;
-    }
-    CompileBroker::compile_method(selected_method, InvocationEntryBci,
-                                  CompilationPolicy::policy()->initial_compile_level(),
-                                  methodHandle(), 0, "must_be_compiled", CHECK);
-  }
+  CompilationPolicy::compile_if_required(selected_method, THREAD);
 }
 
 // utility query for unreflecting a method
@@ -612,14 +589,13 @@
   }
 
   if (code == Bytecodes::_invokeinterface) {
-    return resolve_interface_method(link_info, true, THREAD);
+    return resolve_interface_method(link_info, code, THREAD);
   } else if (code == Bytecodes::_invokevirtual) {
     return resolve_method(link_info, /*require_methodref*/true, THREAD);
   } else if (!resolved_klass->is_interface()) {
     return resolve_method(link_info, /*require_methodref*/false, THREAD);
   } else {
-    bool nostatics = (code == Bytecodes::_invokestatic) ? false : true;
-    return resolve_interface_method(link_info, nostatics, THREAD);
+    return resolve_interface_method(link_info, code, THREAD);
   }
 }
 
@@ -777,8 +753,8 @@
 #endif // PRODUCT
 }
 
-methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info,
-                                                    bool nostatics, TRAPS) {
+// Do linktime resolution of a method in the interface within the context of the specied bytecode.
+methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) {
 
   KlassHandle resolved_klass = link_info.resolved_klass();
 
@@ -824,7 +800,7 @@
     check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL);
   }
 
-  if (nostatics && resolved_method->is_static()) {
+  if (code != Bytecodes::_invokestatic && resolved_method->is_static()) {
     ResourceMark rm(THREAD);
     char buf[200];
     jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
@@ -833,6 +809,19 @@
     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
+  if (code == Bytecodes::_invokeinterface && resolved_method->is_private()) {
+    ResourceMark rm(THREAD);
+    char buf[200];
+
+    KlassHandle current_klass = link_info.current_klass();
+    jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s, caller-class:%s",
+                 Method::name_and_sig_as_C_string(resolved_klass(),
+                                                  resolved_method->name(),
+                                                  resolved_method->signature()),
+                                                  (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()));
+     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+  }
+
   if (log_develop_is_enabled(Trace, itables)) {
     trace_method_resolution("invokeinterface resolved method: caller-class",
                             link_info.current_klass(), resolved_klass,
@@ -984,7 +973,7 @@
   if (!resolved_klass->is_interface()) {
     resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL);
   } else {
-    resolved_method = resolve_interface_method(link_info, /*nostatics*/false, CHECK_NULL);
+    resolved_method = resolve_interface_method(link_info, Bytecodes::_invokestatic, CHECK_NULL);
   }
   assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier");
 
@@ -1027,7 +1016,7 @@
   if (!resolved_klass->is_interface()) {
     resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL);
   } else {
-    resolved_method = resolve_interface_method(link_info, /*nostatics*/true, CHECK_NULL);
+    resolved_method = resolve_interface_method(link_info, Bytecodes::_invokespecial, CHECK_NULL);
   }
 
   // check if method name is <init>, that it is found in same klass as static type
@@ -1302,7 +1291,7 @@
 methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info,
                                                              TRAPS) {
   // normal interface method resolution
-  methodHandle resolved_method = resolve_interface_method(link_info, true, CHECK_NULL);
+  methodHandle resolved_method = resolve_interface_method(link_info, Bytecodes::_invokeinterface, CHECK_NULL);
   assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");
   assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
 
@@ -1321,17 +1310,6 @@
     THROW(vmSymbols::java_lang_NullPointerException());
   }
 
-  // check if private interface method
-  if (resolved_klass->is_interface() && resolved_method->is_private()) {
-    ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s",
-                 Method::name_and_sig_as_C_string(resolved_klass(),
-                                                  resolved_method->name(),
-                                                  resolved_method->signature()));
-    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
-  }
-
   // check if receiver klass implements the resolved interface
   if (!recv_klass->is_subtype_of(resolved_klass())) {
     ResourceMark rm(THREAD);
diff --git a/hotspot/src/share/vm/interpreter/linkResolver.hpp b/hotspot/src/share/vm/interpreter/linkResolver.hpp
index 4dae811..b319be9 100644
--- a/hotspot/src/share/vm/interpreter/linkResolver.hpp
+++ b/hotspot/src/share/vm/interpreter/linkResolver.hpp
@@ -191,7 +191,7 @@
                                              KlassHandle current_klass,
                                              KlassHandle sel_klass, TRAPS);
 
-  static methodHandle resolve_interface_method(const LinkInfo& link_info, bool nostatics, TRAPS);
+  static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS);
   static methodHandle resolve_method          (const LinkInfo& link_info, bool require_methodref, TRAPS);
 
   static methodHandle linktime_resolve_static_method    (const LinkInfo& link_info, TRAPS);
diff --git a/hotspot/src/share/vm/interpreter/oopMapCache.cpp b/hotspot/src/share/vm/interpreter/oopMapCache.cpp
index 7dcf024..a32949a 100644
--- a/hotspot/src/share/vm/interpreter/oopMapCache.cpp
+++ b/hotspot/src/share/vm/interpreter/oopMapCache.cpp
@@ -24,10 +24,10 @@
 
 #include "precompiled.hpp"
 #include "interpreter/oopMapCache.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/oop.inline.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/signature.hpp"
 
@@ -469,10 +469,12 @@
     if (!_array[i].is_empty() && _array[i].method()->is_old()) {
       // Cache entry is occupied by an old redefined method and we don't want
       // to pin it down so flush the entry.
-      RC_TRACE(0x08000000, ("flush: %s(%s): cached entry @%d",
-        _array[i].method()->name()->as_C_string(),
-        _array[i].method()->signature()->as_C_string(), i));
-
+      if (log_is_enabled(Debug, redefine, class, oopmap)) {
+        ResourceMark rm;
+        log_debug(redefine, class, oopmap)
+          ("flush: %s(%s): cached entry @%d",
+           _array[i].method()->name()->as_C_string(), _array[i].method()->signature()->as_C_string(), i);
+      }
       _array[i].flush();
     }
 }
diff --git a/hotspot/src/share/vm/interpreter/rewriter.cpp b/hotspot/src/share/vm/interpreter/rewriter.cpp
index 41e29a6..7680fbf 100644
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,11 +65,12 @@
   // Record limits of resolved reference map for constant pool cache indices
   record_map_limits();
 
-  guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1),
+  guarantee((int) _cp_cache_map.length() - 1 <= (int) ((u2)-1),
             "all cp cache indexes fit in a u2");
 
-  if (saw_mh_symbol)
-    _method_handle_invokers.initialize(length, (int)0);
+  if (saw_mh_symbol) {
+    _method_handle_invokers.at_grow(length, 0);
+  }
 }
 
 // Unrewrite the bytecodes if an error occurs.
@@ -193,7 +194,7 @@
       assert(_pool->tag_at(cp_index).is_method(), "wrong index");
       // Determine whether this is a signature-polymorphic method.
       if (cp_index >= _method_handle_invokers.length())  return;
-      int status = _method_handle_invokers[cp_index];
+      int status = _method_handle_invokers.at(cp_index);
       assert(status >= -1 && status <= 1, "oob tri-state");
       if (status == 0) {
         if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() &&
@@ -211,7 +212,7 @@
         } else {
           status = -1;
         }
-        _method_handle_invokers[cp_index] = status;
+        _method_handle_invokers.at(cp_index) = status;
       }
       // We use a special internal bytecode for such methods (if non-static).
       // The basic reason for this is that such methods need an extra "appendix" argument
@@ -287,7 +288,7 @@
       // add delta to each.
       int resolved_index = _patch_invokedynamic_refs->at(i);
       for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
-        assert(_invokedynamic_references_map[resolved_index+entry] == cache_index,
+        assert(_invokedynamic_references_map.at(resolved_index + entry) == cache_index,
              "should be the same index");
         _invokedynamic_references_map.at_put(resolved_index+entry,
                                              cache_index + delta);
@@ -520,7 +521,14 @@
 Rewriter::Rewriter(instanceKlassHandle klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS)
   : _klass(klass),
     _pool(cpool),
-    _methods(methods)
+    _methods(methods),
+    _cp_map(cpool->length()),
+    _cp_cache_map(cpool->length() / 2),
+    _reference_map(cpool->length()),
+    _resolved_references_map(cpool->length() / 2),
+    _invokedynamic_references_map(cpool->length() / 2),
+    _method_handle_invokers(cpool->length()),
+    _invokedynamic_cp_cache_map(cpool->length() / 4)
 {
 
   // Rewrite bytecodes - exception here exits.
diff --git a/hotspot/src/share/vm/interpreter/rewriter.hpp b/hotspot/src/share/vm/interpreter/rewriter.hpp
index de25b10..6865853 100644
--- a/hotspot/src/share/vm/interpreter/rewriter.hpp
+++ b/hotspot/src/share/vm/interpreter/rewriter.hpp
@@ -37,13 +37,13 @@
   instanceKlassHandle _klass;
   constantPoolHandle  _pool;
   Array<Method*>*     _methods;
-  intArray            _cp_map;
-  intStack            _cp_cache_map;        // for Methodref, Fieldref,
-                                            // InterfaceMethodref and InvokeDynamic
-  intArray            _reference_map;       // maps from cp index to resolved_refs index (or -1)
-  intStack            _resolved_references_map;    // for strings, methodHandle, methodType
-  intStack            _invokedynamic_references_map; // for invokedynamic resolved refs
-  intArray            _method_handle_invokers;
+  GrowableArray<int>  _cp_map;
+  GrowableArray<int>  _cp_cache_map;  // for Methodref, Fieldref,
+                                      // InterfaceMethodref and InvokeDynamic
+  GrowableArray<int>  _reference_map; // maps from cp index to resolved_refs index (or -1)
+  GrowableArray<int>  _resolved_references_map; // for strings, methodHandle, methodType
+  GrowableArray<int>  _invokedynamic_references_map; // for invokedynamic resolved refs
+  GrowableArray<int>  _method_handle_invokers;
   int                 _resolved_reference_limit;
 
   // For mapping invokedynamic bytecodes, which are discovered during method
@@ -51,28 +51,31 @@
   // If there are any invokespecial/InterfaceMethodref special case bytecodes,
   // these entries are added before invokedynamic entries so that the
   // invokespecial bytecode 16 bit index doesn't overflow.
-  intStack            _invokedynamic_cp_cache_map;
+  GrowableArray<int>      _invokedynamic_cp_cache_map;
 
   // For patching.
   GrowableArray<address>* _patch_invokedynamic_bcps;
   GrowableArray<int>*     _patch_invokedynamic_refs;
 
   void init_maps(int length) {
-    _cp_map.initialize(length, -1);
-    // Choose an initial value large enough that we don't get frequent
-    // calls to grow().
-    _cp_cache_map.initialize(length/2);
+    _cp_map.trunc_to(0);
+    _cp_map.at_grow(length, -1);
+
+    _cp_cache_map.trunc_to(0);
     // Also cache resolved objects, in another different cache.
-    _reference_map.initialize(length, -1);
-    _resolved_references_map.initialize(length/2);
-    _invokedynamic_references_map.initialize(length/2);
+    _reference_map.trunc_to(0);
+    _reference_map.at_grow(length, -1);
+
+    _method_handle_invokers.trunc_to(0);
+    _resolved_references_map.trunc_to(0);
+    _invokedynamic_references_map.trunc_to(0);
     _resolved_reference_limit = -1;
     _first_iteration_cp_cache_limit = -1;
 
     // invokedynamic specific fields
-    _invokedynamic_cp_cache_map.initialize(length/4);
-    _patch_invokedynamic_bcps = new GrowableArray<address>(length/4);
-    _patch_invokedynamic_refs = new GrowableArray<int>(length/4);
+    _invokedynamic_cp_cache_map.trunc_to(0);
+    _patch_invokedynamic_bcps = new GrowableArray<address>(length / 4);
+    _patch_invokedynamic_refs = new GrowableArray<int>(length / 4);
   }
 
   int _first_iteration_cp_cache_limit;
@@ -90,10 +93,10 @@
     return _cp_cache_map.length() - _first_iteration_cp_cache_limit;
   }
 
-  int  cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; }
-  bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; }
+  int  cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map.at(i); }
+  bool has_cp_cache(int i) { return (uint) i < (uint) _cp_map.length() && _cp_map.at(i) >= 0; }
 
-  int add_map_entry(int cp_index, intArray* cp_map, intStack* cp_cache_map) {
+  int add_map_entry(int cp_index, GrowableArray<int>* cp_map, GrowableArray<int>* cp_cache_map) {
     assert(cp_map->at(cp_index) == -1, "not twice on same cp_index");
     int cache_index = cp_cache_map->append(cp_index);
     cp_map->at_put(cp_index, cache_index);
@@ -121,7 +124,7 @@
   }
 
   int invokedynamic_cp_cache_entry_pool_index(int cache_index) {
-    int cp_index = _invokedynamic_cp_cache_map[cache_index];
+    int cp_index = _invokedynamic_cp_cache_map.at(cache_index);
     return cp_index;
   }
 
@@ -131,9 +134,9 @@
     assert(_first_iteration_cp_cache_limit >= 0, "add these special cache entries after first iteration");
     // Don't add InterfaceMethodref if it already exists at the end.
     for (int i = _first_iteration_cp_cache_limit; i < _cp_cache_map.length(); i++) {
-     if (cp_cache_entry_pool_index(i) == cp_index) {
-       return i;
-     }
+      if (cp_cache_entry_pool_index(i) == cp_index) {
+        return i;
+      }
     }
     int cache_index = _cp_cache_map.append(cp_index);
     assert(cache_index >= _first_iteration_cp_cache_limit, "");
@@ -144,10 +147,10 @@
 
   int  cp_entry_to_resolved_references(int cp_index) const {
     assert(has_entry_in_resolved_references(cp_index), "oob");
-    return _reference_map[cp_index];
+    return _reference_map.at(cp_index);
   }
   bool has_entry_in_resolved_references(int cp_index) const {
-    return (uint)cp_index < (uint)_reference_map.length() && _reference_map[cp_index] >= 0;
+    return (uint) cp_index < (uint) _reference_map.length() && _reference_map.at(cp_index) >= 0;
   }
 
   // add a new entry to the resolved_references map
@@ -174,13 +177,13 @@
   }
 
   int resolved_references_entry_to_pool_index(int ref_index) {
-    int cp_index = _resolved_references_map[ref_index];
+    int cp_index = _resolved_references_map.at(ref_index);
     return cp_index;
   }
 
   // Access the contents of _cp_cache_map to determine CP cache layout.
   int cp_cache_entry_pool_index(int cache_index) {
-    int cp_index = _cp_cache_map[cache_index];
+    int cp_index = _cp_cache_map.at(cache_index);
     return cp_index;
   }
 
diff --git a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp
index 3e948e3..8b34d14 100644
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp
@@ -85,7 +85,7 @@
     if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) {
       ResourceMark rm;
       int hot_count = 10; // TODO: what's the appropriate value?
-      CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD);
+      CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, CompileTask::Reason_Bootstrap, THREAD);
     }
   }
 
diff --git a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp
index 6ff1897..94108e6 100644
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp
@@ -154,6 +154,14 @@
 
 int CompilerToVM::Data::vm_page_size;
 
+address CompilerToVM::Data::dsin;
+address CompilerToVM::Data::dcos;
+address CompilerToVM::Data::dtan;
+address CompilerToVM::Data::dexp;
+address CompilerToVM::Data::dlog;
+address CompilerToVM::Data::dlog10;
+address CompilerToVM::Data::dpow;
+
 void CompilerToVM::Data::initialize() {
   Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset());
   Klass_vtable_length_offset = in_bytes(Klass::vtable_length_offset());
@@ -205,6 +213,23 @@
   }
 
   vm_page_size = os::vm_page_size();
+
+#define SET_TRIGFUNC(name)                                      \
+  if (StubRoutines::name() != NULL) {                           \
+    name = StubRoutines::name();                                \
+  } else {                                                      \
+    name = CAST_FROM_FN_PTR(address, SharedRuntime::name);      \
+  }
+
+  SET_TRIGFUNC(dsin);
+  SET_TRIGFUNC(dcos);
+  SET_TRIGFUNC(dtan);
+  SET_TRIGFUNC(dexp);
+  SET_TRIGFUNC(dlog10);
+  SET_TRIGFUNC(dlog);
+  SET_TRIGFUNC(dpow);
+
+#undef SET_TRIGFUNC
 }
 
 /**
@@ -628,65 +653,35 @@
 C2V_END
 
 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type))
-  Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type);
-  Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type);
-  Method* method = CompilerToVM::asMethod(jvmci_method);
+  KlassHandle recv_klass = CompilerToVM::asKlass(receiver_jvmci_type);
+  KlassHandle caller_klass = CompilerToVM::asKlass(caller_jvmci_type);
+  methodHandle method = CompilerToVM::asMethod(jvmci_method);
 
-  if (recv_klass->is_array_klass() || (InstanceKlass::cast(recv_klass)->is_linked())) {
-    Klass* holder_klass = method->method_holder();
-    Symbol* method_name = method->name();
-    Symbol* method_signature = method->signature();
+  KlassHandle h_resolved   (THREAD, method->method_holder());
+  Symbol* h_name      = method->name();
+  Symbol* h_signature = method->signature();
 
-    if (holder_klass->is_interface()) {
-      // do link-time resolution to check all access rules.
-      LinkInfo link_info(holder_klass, method_name, method_signature, caller_klass, true);
-      methodHandle resolved_method = LinkResolver::linktime_resolve_interface_method_or_null(link_info);
-      if (resolved_method.is_null() || resolved_method->is_private()) {
-        return NULL;
-      }
-      assert(recv_klass->is_subtype_of(holder_klass), "");
-      // do actual lookup
-      methodHandle sel_method = LinkResolver::lookup_instance_method_in_klasses(recv_klass, resolved_method->name(), resolved_method->signature(), CHECK_AND_CLEAR_0);
-      oop result = CompilerToVM::get_jvmci_method(sel_method, CHECK_NULL);
-      return JNIHandles::make_local(THREAD, result);
+  bool check_access = true;
+  LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass, check_access);
+  methodHandle m;
+  // Only do exact lookup if receiver klass has been linked.  Otherwise,
+  // the vtable has not been setup, and the LinkResolver will fail.
+  if (recv_klass->is_array_klass() ||
+      InstanceKlass::cast(recv_klass())->is_linked() && !recv_klass->is_interface()) {
+    if (h_resolved->is_interface()) {
+      m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info);
     } else {
-      // do link-time resolution to check all access rules.
-      LinkInfo link_info(holder_klass, method_name, method_signature, caller_klass, true);
-      methodHandle resolved_method = LinkResolver::linktime_resolve_virtual_method_or_null(link_info);
-      if (resolved_method.is_null()) {
-        return NULL;
-      }
-      // do actual lookup (see LinkResolver::runtime_resolve_virtual_method)
-      int vtable_index = Method::invalid_vtable_index;
-      Method* selected_method;
-
-      if (resolved_method->method_holder()->is_interface()) { // miranda method
-        vtable_index = LinkResolver::vtable_index_of_interface_method(holder_klass, resolved_method);
-        assert(vtable_index >= 0 , "we should have valid vtable index at this point");
-
-        selected_method = recv_klass->method_at_vtable(vtable_index);
-      } else {
-        // at this point we are sure that resolved_method is virtual and not
-        // a miranda method; therefore, it must have a valid vtable index.
-        assert(!resolved_method->has_itable_index(), "");
-        vtable_index = resolved_method->vtable_index();
-        // We could get a negative vtable_index for final methods,
-        // because as an optimization they are they are never put in the vtable,
-        // unless they override an existing method.
-        // If we do get a negative, it means the resolved method is the the selected
-        // method, and it can never be changed by an override.
-        if (vtable_index == Method::nonvirtual_vtable_index) {
-          assert(resolved_method->can_be_statically_bound(), "cannot override this method");
-          selected_method = resolved_method();
-        } else {
-          selected_method = recv_klass->method_at_vtable(vtable_index);
-        }
-      }
-      oop result = CompilerToVM::get_jvmci_method(selected_method, CHECK_NULL);
-      return JNIHandles::make_local(THREAD, result);
+      m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info);
     }
   }
-  return NULL;
+
+  if (m.is_null()) {
+    // Return NULL only if there was a problem with lookup (uninitialized class, etc.)
+    return NULL;
+  }
+
+  oop result = CompilerToVM::get_jvmci_method(m, CHECK_NULL);
+  return JNIHandles::make_local(THREAD, result);
 C2V_END
 
 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type))
@@ -992,7 +987,7 @@
   }
   NOT_PRODUCT(method->set_compiled_invocation_count(0));
 
-  nmethod* code = method->code();
+  CompiledMethod* code = method->code();
   if (code != NULL) {
     code->make_not_entrant();
   }
diff --git a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp
index 9ec78fd..f679037 100644
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp
@@ -65,6 +65,14 @@
 
     static int vm_page_size;
 
+    static address dsin;
+    static address dcos;
+    static address dtan;
+    static address dexp;
+    static address dlog;
+    static address dlog10;
+    static address dpow;
+
    public:
     static void initialize();
   };
diff --git a/hotspot/src/share/vm/jvmci/jvmciEnv.cpp b/hotspot/src/share/vm/jvmci/jvmciEnv.cpp
index eb39c27..502b2f7 100644
--- a/hotspot/src/share/vm/jvmci/jvmciEnv.cpp
+++ b/hotspot/src/share/vm/jvmci/jvmciEnv.cpp
@@ -546,7 +546,7 @@
           if (entry_bci == InvocationEntryBci) {
             if (TieredCompilation) {
               // If there is an old version we're done with it
-              nmethod* old = method->code();
+              CompiledMethod* old = method->code();
               if (TraceMethodReplacement && old != NULL) {
                 ResourceMark rm;
                 char *method_name = method->name_and_sig_as_C_string();
diff --git a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp
index 76545eb..219ad61 100644
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp
@@ -220,15 +220,15 @@
 // been deoptimized. If that is the case we return the deopt blob
 // unpack_with_exception entry instead. This makes life for the exception blob easier
 // because making that same check and diverting is painful from assembly language.
-JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm))
+JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, CompiledMethod*& cm))
   // Reset method handle flag.
   thread->set_is_method_handle_return(false);
 
   Handle exception(thread, ex);
-  nm = CodeCache::find_nmethod(pc);
-  assert(nm != NULL, "this is not a compiled method");
+  cm = CodeCache::find_compiled(pc);
+  assert(cm != NULL, "this is not a compiled method");
   // Adjust the pc as needed/
-  if (nm->is_deopt_pc(pc)) {
+  if (cm->is_deopt_pc(pc)) {
     RegisterMap map(thread, false);
     frame exception_frame = thread->last_frame().sender(&map);
     // if the frame isn't deopted then pc must not correspond to the caller of last_frame
@@ -275,10 +275,10 @@
 
   // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions
   if (guard_pages_enabled) {
-    address fast_continuation = nm->handler_for_exception_and_pc(exception, pc);
+    address fast_continuation = cm->handler_for_exception_and_pc(exception, pc);
     if (fast_continuation != NULL) {
       // Set flag if return address is a method handle call site.
-      thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
+      thread->set_is_method_handle_return(cm->is_method_handle_return(pc));
       return fast_continuation;
     }
   }
@@ -299,7 +299,7 @@
       stringStream tempst;
       tempst.print("compiled method <%s>\n"
                    " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT,
-                   nm->method()->print_value_string(), p2i(pc), p2i(thread));
+                   cm->method()->print_value_string(), p2i(pc), p2i(thread));
       Exceptions::log_exception(exception, tempst);
     }
     // for AbortVMOnException flag
@@ -311,19 +311,19 @@
     // normal bytecode execution.
     thread->clear_exception_oop_and_pc();
 
-    continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
+    continuation = SharedRuntime::compute_compiled_exc_handler(cm, pc, exception, false, false);
     // If an exception was thrown during exception dispatch, the exception oop may have changed
     thread->set_exception_oop(exception());
     thread->set_exception_pc(pc);
 
     // the exception cache is used only by non-implicit exceptions
     if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) {
-      nm->add_handler_for_exception_and_pc(exception, pc, continuation);
+      cm->add_handler_for_exception_and_pc(exception, pc, continuation);
     }
   }
 
   // Set flag if return address is a method handle call site.
-  thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
+  thread->set_is_method_handle_return(cm->is_method_handle_return(pc));
 
   if (log_is_enabled(Info, exceptions)) {
     ResourceMark rm;
@@ -345,18 +345,18 @@
   address pc = thread->exception_pc();
   // Still in Java mode
   DEBUG_ONLY(ResetNoHandleMark rnhm);
-  nmethod* nm = NULL;
+  CompiledMethod* cm = NULL;
   address continuation = NULL;
   {
     // Enter VM mode by calling the helper
     ResetNoHandleMark rnhm;
-    continuation = exception_handler_for_pc_helper(thread, exception, pc, nm);
+    continuation = exception_handler_for_pc_helper(thread, exception, pc, cm);
   }
   // Back in JAVA, use no oops DON'T safepoint
 
   // Now check to see if the compiled method we were called from is now deoptimized.
   // If so we must return to the deopt blob and deoptimize the nmethod
-  if (nm != NULL && caller_is_deopted()) {
+  if (cm != NULL && caller_is_deopted()) {
     continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
   }
 
@@ -425,19 +425,22 @@
   }
 JRT_END
 
-JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, Symbol* name, const char* message))
-  SharedRuntime::throw_and_post_jvmti_exception(thread, name, message);
+JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message))
+  TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
+  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
 JRT_END
 
-JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, Symbol* exception, Klass* klass))
+JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass))
   ResourceMark rm(thread);
-  SharedRuntime::throw_and_post_jvmti_exception(thread, exception, klass->external_name());
+  TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
+  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name());
 JRT_END
 
-JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, Symbol* exception, Klass* caster_klass, Klass* target_klass))
+JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass))
   ResourceMark rm(thread);
   const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass);
-  SharedRuntime::throw_and_post_jvmti_exception(thread, exception, message);
+  TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
+  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
 JRT_END
 
 JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
diff --git a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp
index 256872a..d3deb1d 100644
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp
@@ -156,10 +156,10 @@
   static void new_store_pre_barrier(JavaThread* thread);
 
   // used to throw exceptions from compiled JVMCI code
-  static void throw_and_post_jvmti_exception(JavaThread* thread, Symbol* exception, const char* message);
+  static void throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message);
   // helper methods to throw exception with complex messages
-  static void throw_klass_external_name_exception(JavaThread* thread, Symbol* exception, Klass* klass);
-  static void throw_class_cast_exception(JavaThread* thread, Symbol* exception, Klass* caster_klass, Klass* target_klass);
+  static void throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass);
+  static void throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass);
 
   // Test only function
   static int test_deoptimize_call_int(JavaThread* thread, int value);
diff --git a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp
index 9927469..2b2155a 100644
--- a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp
+++ b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,8 @@
             MATERIALIZE_EXPERIMENTAL_FLAG, \
             MATERIALIZE_NOTPRODUCT_FLAG,
             IGNORE_RANGE, \
-            IGNORE_CONSTRAINT)
+            IGNORE_CONSTRAINT, \
+            IGNORE_WRITEABLE)
 
 #define JVMCI_IGNORE_FLAG_FOUR_PARAM(type, name, value, doc)
 #define JVMCI_IGNORE_FLAG_THREE_PARAM(type, name, doc)
@@ -91,7 +92,8 @@
                 JVMCI_IGNORE_FLAG_FOUR_PARAM, \
                 JVMCI_IGNORE_FLAG_FOUR_PARAM, \
                 IGNORE_RANGE, \
-                IGNORE_CONSTRAINT)
+                IGNORE_CONSTRAINT, \
+                IGNORE_WRITEABLE)
   }
 
   // Check consistency of experimental flags if UnlockExperimentalVMOptions is
@@ -105,7 +107,8 @@
                 JVMCI_EXPERIMENTAL_FLAG_VALUE_CHANGED_CHECK_CODE, \
                 JVMCI_IGNORE_FLAG_FOUR_PARAM, \
                 IGNORE_RANGE, \
-                IGNORE_CONSTRAINT)
+                IGNORE_CONSTRAINT, \
+                IGNORE_WRITEABLE)
   }
 
 #ifndef PRODUCT
@@ -129,7 +132,8 @@
               JVMCI_IGNORE_FLAG_FOUR_PARAM, \
               JVMCI_NOTPRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \
               IGNORE_RANGE, \
-              IGNORE_CONSTRAINT)
+              IGNORE_CONSTRAINT, \
+              IGNORE_WRITEABLE)
 
 #undef EMIT_FLAG_VALUE_CHANGED_CHECK_CODE
 #undef JVMCI_DEVELOP_FLAG_VALUE_CHANGED_CHECK_CODE
@@ -167,7 +171,8 @@
                 JVMCI_IGNORE_FLAG_FOUR_PARAM, \
                 JVMCI_IGNORE_FLAG_FOUR_PARAM, \
                 IGNORE_RANGE, \
-                IGNORE_CONSTRAINT)
+                IGNORE_CONSTRAINT, \
+                IGNORE_WRITEABLE)
   }
 
   if (UnlockExperimentalVMOptions || !FLAG_IS_DEFAULT(UnlockExperimentalVMOptions)) {
@@ -179,7 +184,8 @@
                 JVMCI_EXPERIMENTAL_FLAG_CHECK_PRINT_ERR_MSG_CODE, \
                 JVMCI_IGNORE_FLAG_FOUR_PARAM, \
                 IGNORE_RANGE, \
-                IGNORE_CONSTRAINT)
+                IGNORE_CONSTRAINT, \
+                IGNORE_WRITEABLE)
   }
 
 #ifndef PRODUCT
@@ -203,7 +209,8 @@
               JVMCI_IGNORE_FLAG_FOUR_PARAM, \
               JVMCI_NOTPRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \
               IGNORE_RANGE, \
-              IGNORE_CONSTRAINT)
+              IGNORE_CONSTRAINT, \
+              IGNORE_WRITEABLE)
 
 #undef EMIT_CHECK_PRINT_ERR_MSG_CODE
 #undef JVMCI_DEVELOP_FLAG_CHECK_PRINT_ERR_MSG_CODE
diff --git a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp
index 03285e3..d42e09c 100644
--- a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp
+++ b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,16 @@
 // to be accessible to the JVMCI C++ code should be defined here. All other
 // JVMCI flags should be defined in JVMCIOptions.java.
 //
-#define JVMCI_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, range, constraint) \
+#define JVMCI_FLAGS(develop, \
+                    develop_pd, \
+                    product, \
+                    product_pd, \
+                    diagnostic, \
+                    experimental, \
+                    notproduct, \
+                    range, \
+                    constraint, \
+                    writeable) \
                                                                             \
   experimental(bool, EnableJVMCI, false,                                    \
           "Enable JVMCI")                                                   \
@@ -96,7 +105,8 @@
             DECLARE_EXPERIMENTAL_FLAG, \
             DECLARE_NOTPRODUCT_FLAG, \
             IGNORE_RANGE, \
-            IGNORE_CONSTRAINT)
+            IGNORE_CONSTRAINT, \
+            IGNORE_WRITEABLE)
 
 class JVMCIGlobals {
  public:
diff --git a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp
index b668737..a40a3e1 100644
--- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp
+++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp
@@ -76,6 +76,14 @@
                                                                                                                                      \
   static_field(CompilerToVM::Data,             vm_page_size,                           int)                                          \
                                                                                                                                      \
+  static_field(CompilerToVM::Data,             dsin,                                   address)                                      \
+  static_field(CompilerToVM::Data,             dcos,                                   address)                                      \
+  static_field(CompilerToVM::Data,             dtan,                                   address)                                      \
+  static_field(CompilerToVM::Data,             dexp,                                   address)                                      \
+  static_field(CompilerToVM::Data,             dlog,                                   address)                                      \
+  static_field(CompilerToVM::Data,             dlog10,                                 address)                                      \
+  static_field(CompilerToVM::Data,             dpow,                                   address)                                      \
+                                                                                                                                     \
   static_field(Abstract_VM_Version,            _features,                              uint64_t)                                     \
                                                                                                                                      \
   nonstatic_field(Array<int>,                  _length,                                int)                                          \
@@ -186,7 +194,7 @@
   nonstatic_field(Method,                      _vtable_index,                                 int)                                   \
   nonstatic_field(Method,                      _intrinsic_id,                                 u2)                                    \
   nonstatic_field(Method,                      _flags,                                        u2)                                    \
-  volatile_nonstatic_field(Method,             _code,                                         nmethod*)                              \
+  volatile_nonstatic_field(Method,             _code,                                         CompiledMethod*)                       \
   volatile_nonstatic_field(Method,             _from_compiled_entry,                          address)                               \
                                                                                                                                      \
   nonstatic_field(MethodCounters,              _invocation_counter,                           InvocationCounter)                     \
@@ -309,6 +317,7 @@
   declare_constant(JVM_ACC_MONITOR_MATCH)                                 \
   declare_constant(JVM_ACC_HAS_MONITOR_BYTECODES)                         \
   declare_constant(JVM_ACC_HAS_FINALIZER)                                 \
+  declare_constant(JVM_ACC_IS_CLONEABLE_FAST)                             \
   declare_constant(JVM_ACC_FIELD_INTERNAL)                                \
   declare_constant(JVM_ACC_FIELD_STABLE)                                  \
   declare_constant(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE)                   \
@@ -523,13 +532,6 @@
   declare_function(SharedRuntime::exception_handler_for_return_address)   \
   declare_function(SharedRuntime::OSR_migration_end)                      \
   declare_function(SharedRuntime::enable_stack_reserved_zone)             \
-  declare_function(SharedRuntime::dsin)                                   \
-  declare_function(SharedRuntime::dcos)                                   \
-  declare_function(SharedRuntime::dtan)                                   \
-  declare_function(SharedRuntime::dexp)                                   \
-  declare_function(SharedRuntime::dlog)                                   \
-  declare_function(SharedRuntime::dlog10)                                 \
-  declare_function(SharedRuntime::dpow)                                   \
                                                                           \
   declare_function(os::dll_load)                                          \
   declare_function(os::dll_lookup)                                        \
diff --git a/hotspot/src/share/vm/libadt/vectset.cpp b/hotspot/src/share/vm/libadt/vectset.cpp
index 256b0a9..2db1451 100644
--- a/hotspot/src/share/vm/libadt/vectset.cpp
+++ b/hotspot/src/share/vm/libadt/vectset.cpp
@@ -31,7 +31,7 @@
 // BitsInByte is a lookup table which tells the number of bits that
 // are in the looked-up number.  It is very useful in VectorSet_Size.
 
-uint8_t bitsInByte[256] = {
+uint8_t bitsInByte[BITS_IN_BYTE_ARRAY_SIZE] = {
   0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
diff --git a/hotspot/src/share/vm/libadt/vectset.hpp b/hotspot/src/share/vm/libadt/vectset.hpp
index d94ce44..887329d 100644
--- a/hotspot/src/share/vm/libadt/vectset.hpp
+++ b/hotspot/src/share/vm/libadt/vectset.hpp
@@ -27,6 +27,8 @@
 
 #include "libadt/set.hpp"
 
+#define BITS_IN_BYTE_ARRAY_SIZE 256
+
 // Vector Sets - An Abstract Data Type
 //INTERFACE
 
diff --git a/hotspot/src/share/vm/logging/log.cpp b/hotspot/src/share/vm/logging/log.cpp
index cdef6d8..59de3ef 100644
--- a/hotspot/src/share/vm/logging/log.cpp
+++ b/hotspot/src/share/vm/logging/log.cpp
@@ -32,9 +32,12 @@
 #include "logging/log.hpp"
 #include "logging/logConfiguration.hpp"
 #include "logging/logFileOutput.hpp"
+#include "logging/logMessage.hpp"
+#include "logging/logMessageBuffer.hpp"
 #include "logging/logOutput.hpp"
 #include "logging/logTagLevelExpression.hpp"
 #include "logging/logTagSet.hpp"
+#include "logging/logTagSetDescriptions.hpp"
 #include "logging/logStream.inline.hpp"
 #include "memory/resourceArea.hpp"
 
@@ -54,6 +57,102 @@
       LogTagLevelExpression::MaxCombinations, LogTagSet::ntagsets());
 }
 
+// Read a complete line from fp and return it as a resource allocated string.
+// Returns NULL on EOF.
+static char* read_line(FILE* fp) {
+  assert(fp != NULL, "bad fp");
+  int buflen = 512;
+  char* buf = NEW_RESOURCE_ARRAY(char, buflen);
+  long pos = ftell(fp);
+
+  char* ret = fgets(buf, buflen, fp);
+  while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) {
+    // retry with a larger buffer
+    buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2);
+    buflen *= 2;
+    // rewind to beginning of line
+    fseek(fp, pos, SEEK_SET);
+    // retry read with new buffer
+    ret = fgets(buf, buflen, fp);
+  }
+  return ret;
+}
+
+static bool file_contains_substrings_in_order(const char* filename, const char* substrs[]) {
+  FILE* fp = fopen(filename, "r");
+  assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno));
+
+  size_t idx = 0;
+  while (substrs[idx] != NULL) {
+    ResourceMark rm;
+    char* line = read_line(fp);
+    if (line == NULL) {
+      break;
+    }
+    for (char* match = strstr(line, substrs[idx]); match != NULL;) {
+      size_t match_len = strlen(substrs[idx]);
+      idx++;
+      if (substrs[idx] == NULL) {
+        break;
+      }
+      match = strstr(match + match_len, substrs[idx]);
+    }
+  }
+
+  fclose(fp);
+  return substrs[idx] == NULL;
+}
+
+static bool file_contains_substring(const char* filename, const char* substr) {
+  const char* strs[] = {substr, NULL};
+  return file_contains_substrings_in_order(filename, strs);
+}
+
+static size_t number_of_lines_with_substring_in_file(const char* filename,
+                                                     const char* substr) {
+  FILE* fp = fopen(filename, "r");
+  assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno));
+
+  size_t ret = 0;
+  for (;;) {
+    ResourceMark rm;
+    char* line = read_line(fp);
+    if (line == NULL) {
+      break;
+    }
+    if (strstr(line, substr) != NULL) {
+      ret++;
+    }
+  }
+
+  fclose(fp);
+  return ret;
+}
+
+static bool file_exists(const char* filename) {
+  struct stat st;
+  return os::stat(filename, &st) == 0;
+}
+
+static void delete_file(const char* filename) {
+  if (!file_exists(filename)) {
+    return;
+  }
+  int ret = remove(filename);
+  assert(ret == 0, "failed to remove file '%s': %s", filename, strerror(errno));
+}
+
+static void create_directory(const char* name) {
+  assert(!file_exists(name), "can't create directory: %s already exists", name);
+  bool failed;
+#ifdef _WINDOWS
+  failed = !CreateDirectory(name, NULL);
+#else
+  failed = mkdir(name, 0777);
+#endif
+  assert(!failed, "failed to create directory %s", name);
+}
+
 class TestLogFile {
  private:
   char file_name[256];
@@ -139,60 +238,6 @@
   assert_str_eq("all=off", stdoutput->config_string());
 }
 
-static size_t number_of_lines_with_substring_in_file(const char* filename,
-                                                     const char* substr) {
-  ResourceMark rm;
-  size_t ret = 0;
-  FILE* fp = fopen(filename, "r");
-  assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno));
-
-  int buflen = 512;
-  char* buf = NEW_RESOURCE_ARRAY(char, buflen);
-  long pos = 0;
-
-  while (fgets(buf, buflen, fp) != NULL) {
-    if (buf[strlen(buf) - 1] != '\n' && !feof(fp)) {
-      // retry with a larger buffer
-      buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2);
-      buflen *= 2;
-      // rewind to beginning of line
-      fseek(fp, pos, SEEK_SET);
-      continue;
-    }
-    pos = ftell(fp);
-    if (strstr(buf, substr) != NULL) {
-      ret++;
-    }
-  }
-
-  fclose(fp);
-  return ret;
-}
-
-static bool file_exists(const char* filename) {
-  struct stat st;
-  return os::stat(filename, &st) == 0;
-}
-
-static void delete_file(const char* filename) {
-  if (!file_exists(filename)) {
-    return;
-  }
-  int ret = remove(filename);
-  assert(ret == 0, "failed to remove file '%s': %s", filename, strerror(errno));
-}
-
-static void create_directory(const char* name) {
-  assert(!file_exists(name), "can't create directory: %s already exists", name);
-  bool failed;
-#ifdef _WINDOWS
-  failed = !CreateDirectory(name, NULL);
-#else
-  failed = mkdir(name, 0777);
-#endif
-  assert(!failed, "failed to create directory %s", name);
-}
-
 static const char* ExpectedLine = "a (hopefully) unique log line for testing";
 
 static void init_file(const char* filename, const char* options = "") {
@@ -264,6 +309,253 @@
   delete_file(archived_filename);
 }
 
+class LogMessageTest {
+ private:
+  static Log(logging) _log;
+  static const char* _level_filename[];
+
+  static void test_level_inclusion();
+  static void test_long_message();
+  static void test_message_with_many_lines();
+  static void test_line_order();
+  static void test_prefixing();
+  static void test_scoped_messages();
+  static void test_scoped_flushing();
+  static void test_scoped_reset();
+
+ public:
+  static void test();
+};
+
+const char* LogMessageTest::_level_filename[] = {
+  NULL, // LogLevel::Off
+#define LOG_LEVEL(name, printname) "multiline-" #printname ".log",
+  LOG_LEVEL_LIST
+#undef LOG_LEVEL
+};
+
+void Test_multiline_logging() {
+  LogMessageTest::test();
+}
+
+void LogMessageTest::test() {
+  ResourceMark rm;
+
+  for (int i = 0; i < LogLevel::Count; i++) {
+    char buf[32];
+    // Attempt to remove possibly pre-existing log files
+    remove(_level_filename[i]);
+
+    jio_snprintf(buf, sizeof(buf), "logging=%s", LogLevel::name(static_cast<LogLevelType>(i)));
+    bool success = LogConfiguration::parse_log_arguments(_level_filename[i], buf,
+                                                         NULL, NULL, _log.error_stream());
+    assert(success, "unable to configure logging to file '%s'", _level_filename[i]);
+  }
+
+  test_level_inclusion();
+  test_line_order();
+  test_long_message();
+  test_message_with_many_lines();
+  test_prefixing();
+  test_scoped_messages();
+  test_scoped_flushing();
+  test_scoped_reset();
+
+  // Stop logging to the files and remove them.
+  for (int i = 0; i < LogLevel::Count; i++) {
+    LogConfiguration::parse_log_arguments(_level_filename[i], "all=off", NULL, NULL, _log.error_stream());
+    remove(_level_filename[i]);
+  }
+}
+
+// Verify that messages with multiple levels are written
+// to outputs configured for all the corresponding levels
+void LogMessageTest::test_level_inclusion() {
+  const size_t message_count = 10;
+  LogMessageBuffer msg[message_count];
+
+  struct {
+    int message_number;
+    LogLevelType level;
+  } lines[] = {
+    { 0, LogLevel::Error },
+    { 1, LogLevel::Info },
+    { 2, LogLevel::Info }, { 2, LogLevel::Debug },
+    { 3, LogLevel::Info }, { 3, LogLevel::Warning },
+    { 4, LogLevel::Debug }, { 4, LogLevel::Warning },
+    { 5, LogLevel::Trace }, { 5, LogLevel::Debug },
+    { 6, LogLevel::Warning }, { 6, LogLevel::Error },
+    { 7, LogLevel::Trace }, { 7, LogLevel::Info }, { 7, LogLevel::Debug },
+    { 8, LogLevel::Trace }, { 8, LogLevel::Debug }, { 8, LogLevel::Info },
+    { 8, LogLevel::Warning }, { 8, LogLevel::Error},
+    { 9, LogLevel::Trace }
+  };
+
+  // Fill in messages with the above lines
+  for (size_t i = 0; i < ARRAY_SIZE(lines); i++) {
+    switch (lines[i].level) {
+#define LOG_LEVEL(name, printname) \
+    case LogLevel::name: \
+      msg[lines[i].message_number].printname("msg[%d]: " #printname, lines[i].message_number); \
+      break;
+LOG_LEVEL_LIST
+#undef LOG_LEVEL
+    }
+  }
+
+  for (size_t i = 0; i < message_count; i++) {
+    _log.write(msg[i]);
+  }
+
+  // Verify that lines are written to the expected log files
+  for (size_t i = 0; i < ARRAY_SIZE(lines); i++) {
+    char expected[256];
+    jio_snprintf(expected, sizeof(expected), "msg[%d]: %s",
+                 lines[i].message_number, LogLevel::name(lines[i].level));
+    for (int level = lines[i].level; level > 0; level--) {
+      assert(file_contains_substring(_level_filename[level], expected),
+      "line #" SIZE_FORMAT " missing from log file '%s'", i, _level_filename[level]);
+    }
+    for (int level = lines[i].level + 1; level < LogLevel::Count; level++) {
+      assert(!file_contains_substring(_level_filename[level], expected),
+      "line #" SIZE_FORMAT " erroneously included in log file '%s'", i, _level_filename[level]);
+    }
+  }
+}
+
+// Verify that messages are logged in the order they are added to the log message
+void LogMessageTest::test_line_order() {
+  LogMessageBuffer msg;
+  msg.info("info line").error("error line").trace("trace line")
+      .error("another error").warning("warning line").debug("debug line");
+  _log.write(msg);
+
+  const char* expected[] = { "info line", "error line", "trace line",
+                             "another error", "warning line", "debug line", NULL };
+  assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected),
+         "output missing or in incorrect order");
+}
+
+void LogMessageTest::test_long_message() {
+  // Write 10K bytes worth of log data
+  LogMessageBuffer msg;
+  const size_t size = 10 * K;
+  const char* start_marker = "#start#";
+  const char* end_marker = "#the end#";
+  char* data = NEW_C_HEAP_ARRAY(char, size, mtLogging);
+
+  // fill buffer with start_marker...some data...end_marker
+  sprintf(data, "%s", start_marker);
+  for (size_t i = strlen(start_marker); i < size; i++) {
+    data[i] = '0' + (i % 10);
+  }
+  sprintf(data + size - strlen(end_marker) - 1, "%s", end_marker);
+
+  msg.trace("%s", data); // Adds a newline, making the message exactly 10K in length.
+  _log.write(msg);
+
+  const char* expected[] = { start_marker, "0123456789", end_marker, NULL };
+  assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected),
+         "unable to print long line");
+  FREE_C_HEAP_ARRAY(char, data);
+}
+
+void LogMessageTest::test_message_with_many_lines() {
+  const size_t lines = 100;
+  const size_t line_length = 16;
+
+  LogMessageBuffer msg;
+  for (size_t i = 0; i < lines; i++) {
+    msg.info("Line #" SIZE_FORMAT, i);
+  }
+  _log.write(msg);
+
+  char expected_lines_data[lines][line_length];
+  const char* expected_lines[lines + 1];
+  for (size_t i = 0; i < lines; i++) {
+    jio_snprintf(&expected_lines_data[i][0], line_length, "Line #" SIZE_FORMAT, i);
+    expected_lines[i] = expected_lines_data[i];
+  }
+  expected_lines[lines] = NULL;
+
+  assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected_lines),
+         "couldn't find all lines in multiline message");
+}
+
+static size_t dummy_prefixer(char* buf, size_t len) {
+  static int i = 0;
+  const char* prefix = "some prefix: ";
+  const size_t prefix_len = strlen(prefix);
+  if (len < prefix_len) {
+    return prefix_len;
+  }
+  jio_snprintf(buf, len, "%s", prefix);
+  return prefix_len;
+}
+
+void LogMessageTest::test_prefixing() {
+  LogMessageBuffer msg;
+  msg.set_prefix(dummy_prefixer);
+  for (int i = 0; i < 3; i++) {
+    msg.info("test %d", i);
+  }
+  msg.set_prefix(NULL);
+  msg.info("test 3");
+  _log.write(msg);
+
+  const char* expected[] = {
+    "] some prefix: test 0",
+    "] some prefix: test 1",
+    "] some prefix: test 2",
+    "] test 3",
+    NULL
+  };
+  assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected), "error in prefixed output");
+}
+
+void LogMessageTest::test_scoped_messages() {
+  {
+    LogMessage(logging) msg;
+    msg.info("scoped info");
+    msg.warning("scoped warn");
+    assert(!file_contains_substring(_level_filename[LogLevel::Info], "scoped info"),
+           "scoped log message written prematurely");
+  }
+  assert(file_contains_substring(_level_filename[LogLevel::Info], "scoped info"),
+         "missing output from scoped log message");
+  assert(file_contains_substring(_level_filename[LogLevel::Warning], "scoped warn"),
+         "missing output from scoped log message");
+}
+
+void LogMessageTest::test_scoped_flushing() {
+  {
+    LogMessage(logging) msg;
+    msg.info("manual flush info");
+    msg.flush();
+    assert(file_contains_substring(_level_filename[LogLevel::Info], "manual flush info"),
+           "missing output from manually flushed scoped log message");
+  }
+  const char* tmp[] = {"manual flush info", "manual flush info", NULL};
+  assert(!file_contains_substrings_in_order(_level_filename[LogLevel::Info], tmp),
+         "log file contains duplicate lines from single scoped log message");
+}
+
+void LogMessageTest::test_scoped_reset() {
+  {
+    LogMessage(logging) msg, partial;
+    msg.info("%s", "info reset msg");
+    msg.reset();
+    partial.info("%s", "info reset msg");
+    partial.reset();
+    partial.trace("%s", "trace reset msg");
+  }
+  assert(!file_contains_substring(_level_filename[LogLevel::Info], "info reset msg"),
+         "reset message written anyway");
+  assert(file_contains_substring(_level_filename[LogLevel::Trace], "trace reset msg"),
+         "missing message from partially reset scoped log message");
+}
+
+
 static int Test_logconfiguration_subscribe_triggered = 0;
 
 static void Test_logconfiguration_subscribe_helper() {
@@ -883,4 +1175,28 @@
   remove(target_name);
 }
 
+// Ensure -Xlog:help and LogConfiguration::describe contain tagset descriptions
+void Test_logtagset_descriptions() {
+  for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) {
+    char expected[1024];
+    d->tagset->label(expected, sizeof(expected), "+");
+    jio_snprintf(expected + strlen(expected),
+                 sizeof(expected) - strlen(expected),
+                 ": %s", d->descr);
+
+    ResourceMark rm;
+    stringStream ss;
+    LogConfiguration::describe(&ss);
+    assert(strstr(ss.as_string(), expected) != NULL,
+           "missing log tag set descriptions in LogConfiguration::describe");
+
+    TestLogFile file("log_tagset_descriptions");
+    FILE* fp = fopen(file.name(), "w+");
+    assert(fp != NULL, "File open error");
+    LogConfiguration::print_command_line_help(fp);
+    fclose(fp);
+    assert(number_of_lines_with_substring_in_file(file.name(), expected) > 0,
+           "missing log tag set descriptions in -Xlog:help output");
+  }
+}
 #endif // PRODUCT
diff --git a/hotspot/src/share/vm/logging/log.hpp b/hotspot/src/share/vm/logging/log.hpp
index 64664a5..5d36a6b 100644
--- a/hotspot/src/share/vm/logging/log.hpp
+++ b/hotspot/src/share/vm/logging/log.hpp
@@ -32,6 +32,8 @@
 #include "runtime/os.hpp"
 #include "utilities/debug.hpp"
 
+class LogMessageBuffer;
+
 //
 // Logging macros
 //
@@ -138,6 +140,10 @@
     va_end(args);
   }
 
+  static void write(const LogMessageBuffer& msg) {
+    LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().log(msg);
+  };
+
   template <LogLevelType Level>
   ATTRIBUTE_PRINTF(1, 2)
   static void write(const char* fmt, ...) {
diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp
index 6f9f7bb..f09b3b5 100644
--- a/hotspot/src/share/vm/logging/logConfiguration.cpp
+++ b/hotspot/src/share/vm/logging/logConfiguration.cpp
@@ -29,6 +29,7 @@
 #include "logging/logDiagnosticCommand.hpp"
 #include "logging/logFileOutput.hpp"
 #include "logging/logOutput.hpp"
+#include "logging/logStream.hpp"
 #include "logging/logTagLevelExpression.hpp"
 #include "logging/logTagSet.hpp"
 #include "memory/allocation.inline.hpp"
@@ -75,11 +76,17 @@
 void LogConfiguration::post_initialize() {
   LogDiagnosticCommand::registerCommand();
   Log(logging) log;
-  log.info("Log configuration fully initialized.");
-  log_develop_info(logging)("Develop logging is available.");
-  if (log.is_trace()) {
-    ResourceMark rm;
-    describe(log.trace_stream());
+  if (log.is_info()) {
+    log.info("Log configuration fully initialized.");
+    log_develop_info(logging)("Develop logging is available.");
+    if (log.is_debug()) {
+      LogStream debug_stream(log.debug());
+      describe(&debug_stream);
+      if (log.is_trace()) {
+        LogStream trace_stream(log.trace());
+        LogTagSet::list_all_tagsets(&trace_stream);
+      }
+    }
   }
 }
 
@@ -382,7 +389,7 @@
   return true;
 }
 
-void LogConfiguration::describe(outputStream* out) {
+void LogConfiguration::describe_available(outputStream* out){
   out->print("Available log levels:");
   for (size_t i = 0; i < LogLevel::Count; i++) {
     out->print("%s %s", (i == 0 ? "" : ","), LogLevel::name(static_cast<LogLevelType>(i)));
@@ -402,20 +409,31 @@
   }
   out->cr();
 
-  ConfigurationLock cl;
+  LogTagSet::describe_tagsets(out);
+}
+
+void LogConfiguration::describe_current_configuration(outputStream* out){
   out->print_cr("Log output configuration:");
   for (size_t i = 0; i < _n_outputs; i++) {
     out->print("#" SIZE_FORMAT ": %s %s ", i, _outputs[i]->name(), _outputs[i]->config_string());
+    char delimiter[2] = {0};
     for (size_t d = 0; d < LogDecorators::Count; d++) {
       LogDecorators::Decorator decorator = static_cast<LogDecorators::Decorator>(d);
       if (_outputs[i]->decorators().is_decorator(decorator)) {
-        out->print("%s,", LogDecorators::name(decorator));
+        out->print("%s%s", delimiter, LogDecorators::name(decorator));
+        *delimiter = ',';
       }
     }
     out->cr();
   }
 }
 
+void LogConfiguration::describe(outputStream* out) {
+  describe_available(out);
+  ConfigurationLock cl;
+  describe_current_configuration(out);
+}
+
 void LogConfiguration::print_command_line_help(FILE* out) {
   jio_fprintf(out, "-Xlog Usage: -Xlog[:[what][:[output][:[decorators][:output-options]]]]\n"
               "\t where 'what' is a combination of tags and levels on the form tag1[+tag2...][*][=level][,...]\n"
@@ -439,7 +457,10 @@
   }
   jio_fprintf(out, "\n Specifying 'all' instead of a tag combination matches all tag combinations.\n\n");
 
-  jio_fprintf(out, "Available log outputs:\n"
+  fileStream stream(out, false);
+  LogTagSet::describe_tagsets(&stream);
+
+  jio_fprintf(out, "\nAvailable log outputs:\n"
               " stdout, stderr, file=<filename>\n"
               " Specifying %%p and/or %%t in the filename will expand to the JVM's PID and startup timestamp, respectively.\n\n"
 
@@ -454,7 +475,7 @@
               " -Xlog:gc=debug:file=gc.txt:none\n"
               "\t Log messages tagged with 'gc' tag using 'debug' level to file 'gc.txt' with no decorations.\n\n"
 
-              " -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024\n"
+              " -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1m\n"
               "\t Log messages tagged with 'gc' tag using 'trace' level to a rotating fileset of 5 files of size 1MB,\n"
               "\t using the base name 'gctrace.txt', with 'uptimemillis' and 'pid' decorations.\n\n"
 
diff --git a/hotspot/src/share/vm/logging/logConfiguration.hpp b/hotspot/src/share/vm/logging/logConfiguration.hpp
index 9b7325b..9efbadd 100644
--- a/hotspot/src/share/vm/logging/logConfiguration.hpp
+++ b/hotspot/src/share/vm/logging/logConfiguration.hpp
@@ -37,6 +37,7 @@
 // kept implicitly in the LogTagSets and their LogOutputLists. During configuration the tagsets
 // are iterated over and updated accordingly.
 class LogConfiguration : public AllStatic {
+ friend class VMError;
  public:
   // Function for listeners
   typedef void (*UpdateListenerFunction)(void);
@@ -79,6 +80,11 @@
   // This should be called after any configuration change while still holding ConfigurationLock
   static void notify_update_listeners();
 
+  // Respectively describe the built-in and runtime dependent portions of the configuration.
+  static void describe_available(outputStream* out);
+  static void describe_current_configuration(outputStream* out);
+
+
  public:
   // Initialization and finalization of log configuration, to be run at vm startup and shutdown respectively.
   static void initialize(jlong vm_start_time);
diff --git a/hotspot/src/share/vm/logging/logDecorations.cpp b/hotspot/src/share/vm/logging/logDecorations.cpp
index 210ab31..79c2215 100644
--- a/hotspot/src/share/vm/logging/logDecorations.cpp
+++ b/hotspot/src/share/vm/logging/logDecorations.cpp
@@ -32,7 +32,7 @@
 const char* LogDecorations::_host_name = "";
 
 LogDecorations::LogDecorations(LogLevelType level, const LogTagSet &tagset, const LogDecorators &decorators)
-  : _level(level), _tagset(tagset), _millis(-1) {
+    : _level(level), _tagset(tagset), _millis(-1) {
   create_decorations(decorators);
 }
 
@@ -110,8 +110,9 @@
 }
 
 char* LogDecorations::create_level_decoration(char* pos) {
-  int written = jio_snprintf(pos, DecorationsBufferSize - (pos - _decorations_buffer), "%s", LogLevel::name(_level));
-  ASSERT_AND_RETURN(written, pos)
+  // Avoid generating the level decoration because it may change.
+  // The decoration() method has a special case for level decorations.
+  return pos;
 }
 
 char* LogDecorations::create_tags_decoration(char* pos) {
diff --git a/hotspot/src/share/vm/logging/logDecorations.hpp b/hotspot/src/share/vm/logging/logDecorations.hpp
index fcc1661..3988bac 100644
--- a/hotspot/src/share/vm/logging/logDecorations.hpp
+++ b/hotspot/src/share/vm/logging/logDecorations.hpp
@@ -53,7 +53,18 @@
 
   LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators);
 
+  LogLevelType level() const {
+    return _level;
+  }
+
+  void set_level(LogLevelType level) {
+    _level = level;
+  }
+
   const char* decoration(LogDecorators::Decorator decorator) const {
+    if (decorator == LogDecorators::level_decorator) {
+      return LogLevel::name(_level);
+    }
     return _decoration_offset[decorator];
   }
 };
diff --git a/hotspot/src/share/vm/logging/logDecorators.hpp b/hotspot/src/share/vm/logging/logDecorators.hpp
index 1e52124..2d30700 100644
--- a/hotspot/src/share/vm/logging/logDecorators.hpp
+++ b/hotspot/src/share/vm/logging/logDecorators.hpp
@@ -102,6 +102,10 @@
     _decorators |= source._decorators;
   }
 
+  bool is_empty() const {
+    return _decorators == 0;
+  }
+
   bool is_decorator(LogDecorators::Decorator decorator) const {
     return (_decorators & mask(decorator)) != 0;
   }
diff --git a/hotspot/src/share/vm/logging/logFileOutput.cpp b/hotspot/src/share/vm/logging/logFileOutput.cpp
index 7f41bd9..3000e61 100644
--- a/hotspot/src/share/vm/logging/logFileOutput.cpp
+++ b/hotspot/src/share/vm/logging/logFileOutput.cpp
@@ -26,6 +26,7 @@
 #include "logging/logConfiguration.hpp"
 #include "logging/logFileOutput.hpp"
 #include "memory/allocation.inline.hpp"
+#include "runtime/arguments.hpp"
 #include "runtime/os.inline.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/defaultStream.hpp"
@@ -187,14 +188,15 @@
       }
       _file_count = static_cast<uint>(value);
     } else if (strcmp(FileSizeOptionKey, key) == 0) {
-      size_t value = parse_value(value_str);
-      if (value == SIZE_MAX || value > SIZE_MAX / K) {
+      julong value;
+      success = Arguments::atojulong(value_str, &value);
+      if (!success || (value > SIZE_MAX)) {
         errstream->print_cr("Invalid option: %s must be in range [0, "
-                            SIZE_FORMAT "]", FileSizeOptionKey, SIZE_MAX / K);
+                            SIZE_FORMAT "]", FileSizeOptionKey, SIZE_MAX);
         success = false;
         break;
       }
-      _rotate_size = value * K;
+      _rotate_size = static_cast<size_t>(value);
     } else {
       errstream->print_cr("Invalid option '%s' for log file output.", key);
       success = false;
@@ -252,7 +254,7 @@
 
   if (_file_count == 0 && is_regular_file(_file_name)) {
     log_trace(logging)("Truncating log file");
-    os::ftruncate(os::fileno(_stream), 0);
+    os::ftruncate(os::get_fileno(_stream), 0);
   }
 
   return true;
@@ -276,6 +278,24 @@
   return written;
 }
 
+int LogFileOutput::write(LogMessageBuffer::Iterator msg_iterator) {
+  if (_stream == NULL) {
+    // An error has occurred with this output, avoid writing to it.
+    return 0;
+  }
+
+  _rotation_semaphore.wait();
+  int written = LogFileStreamOutput::write(msg_iterator);
+  _current_size += written;
+
+  if (should_rotate()) {
+    rotate();
+  }
+  _rotation_semaphore.signal();
+
+  return written;
+}
+
 void LogFileOutput::archive() {
   assert(_archive_name != NULL && _archive_name_len > 0, "Rotation must be configured before using this function.");
   int ret = jio_snprintf(_archive_name, _archive_name_len, "%s.%0*u",
diff --git a/hotspot/src/share/vm/logging/logFileOutput.hpp b/hotspot/src/share/vm/logging/logFileOutput.hpp
index adfd372..1831016 100644
--- a/hotspot/src/share/vm/logging/logFileOutput.hpp
+++ b/hotspot/src/share/vm/logging/logFileOutput.hpp
@@ -83,6 +83,7 @@
   virtual ~LogFileOutput();
   virtual bool initialize(const char* options, outputStream* errstream);
   virtual int write(const LogDecorations& decorations, const char* msg);
+  virtual int write(LogMessageBuffer::Iterator msg_iterator);
   virtual void force_rotate();
 
   virtual const char* name() const {
diff --git a/hotspot/src/share/vm/logging/logFileStreamOutput.cpp b/hotspot/src/share/vm/logging/logFileStreamOutput.cpp
index 00dfcc5..20dfd2d 100644
--- a/hotspot/src/share/vm/logging/logFileStreamOutput.cpp
+++ b/hotspot/src/share/vm/logging/logFileStreamOutput.cpp
@@ -25,14 +25,13 @@
 #include "logging/logDecorators.hpp"
 #include "logging/logDecorations.hpp"
 #include "logging/logFileStreamOutput.hpp"
+#include "logging/logMessageBuffer.hpp"
 #include "memory/allocation.inline.hpp"
 
 LogStdoutOutput LogStdoutOutput::_instance;
 LogStderrOutput LogStderrOutput::_instance;
 
-int LogFileStreamOutput::write(const LogDecorations& decorations, const char* msg) {
-  char decoration_buf[LogDecorations::DecorationsBufferSize];
-  char* position = decoration_buf;
+int LogFileStreamOutput::write_decorations(const LogDecorations& decorations) {
   int total_written = 0;
 
   for (uint i = 0; i < LogDecorators::Count; i++) {
@@ -40,23 +39,50 @@
     if (!_decorators.is_decorator(decorator)) {
       continue;
     }
-    int written = jio_snprintf(position, sizeof(decoration_buf) - total_written, "[%-*s]",
-                               _decorator_padding[decorator],
-                               decorations.decoration(decorator));
+
+    int written = jio_fprintf(_stream, "[%-*s]",
+                              _decorator_padding[decorator],
+                              decorations.decoration(decorator));
     if (written <= 0) {
       return -1;
     } else if (static_cast<size_t>(written - 2) > _decorator_padding[decorator]) {
       _decorator_padding[decorator] = written - 2;
     }
-    position += written;
     total_written += written;
   }
+  return total_written;
+}
 
-  if (total_written == 0) {
-    total_written = jio_fprintf(_stream, "%s\n", msg);
-  } else {
-    total_written = jio_fprintf(_stream, "%s %s\n", decoration_buf, msg);
+int LogFileStreamOutput::write(const LogDecorations& decorations, const char* msg) {
+  const bool use_decorations = !_decorators.is_empty();
+
+  int written = 0;
+  os::flockfile(_stream);
+  if (use_decorations) {
+    written += write_decorations(decorations);
+    written += jio_fprintf(_stream, " ");
+  }
+  written += jio_fprintf(_stream, "%s\n", msg);
+  fflush(_stream);
+  os::funlockfile(_stream);
+
+  return written;
+}
+
+int LogFileStreamOutput::write(LogMessageBuffer::Iterator msg_iterator) {
+  const bool use_decorations = !_decorators.is_empty();
+
+  int written = 0;
+  os::flockfile(_stream);
+  for (; !msg_iterator.is_at_end(); msg_iterator++) {
+    if (use_decorations) {
+      written += write_decorations(msg_iterator.decorations());
+      written += jio_fprintf(_stream, " ");
+    }
+    written += jio_fprintf(_stream, "%s\n", msg_iterator.message());
   }
   fflush(_stream);
-  return total_written;
+  os::funlockfile(_stream);
+
+  return written;
 }
diff --git a/hotspot/src/share/vm/logging/logFileStreamOutput.hpp b/hotspot/src/share/vm/logging/logFileStreamOutput.hpp
index a4c739c..3a5c1b5 100644
--- a/hotspot/src/share/vm/logging/logFileStreamOutput.hpp
+++ b/hotspot/src/share/vm/logging/logFileStreamOutput.hpp
@@ -42,8 +42,11 @@
     }
   }
 
+  int write_decorations(const LogDecorations& decorations);
+
  public:
-  virtual int write(const LogDecorations &decorations, const char* msg);
+  virtual int write(const LogDecorations& decorations, const char* msg);
+  virtual int write(LogMessageBuffer::Iterator msg_iterator);
 };
 
 class LogStdoutOutput : public LogFileStreamOutput {
diff --git a/hotspot/src/share/vm/logging/logMessage.hpp b/hotspot/src/share/vm/logging/logMessage.hpp
new file mode 100644
index 0000000..e8172d1
--- /dev/null
+++ b/hotspot/src/share/vm/logging/logMessage.hpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#ifndef SHARE_VM_LOGGING_LOGMESSAGE_HPP
+#define SHARE_VM_LOGGING_LOGMESSAGE_HPP
+
+#include "logging/log.hpp"
+#include "logging/logMessageBuffer.hpp"
+#include "logging/logPrefix.hpp"
+#include "logging/logTag.hpp"
+
+// The LogMessage class represents a multi-part/multi-line message
+// that is guaranteed to be sent and written to the log outputs
+// in a way that prevents interleaving by other log messages.
+//
+// The interface of LogMessage is very similar to the Log class,
+// with printf functions for each level (trace(), debug(), etc).
+// The difference is that these functions will append/write to the
+// LogMessage, which only buffers the message-parts until the whole
+// message is sent to a log (using Log::write). Internal buffers
+// are C heap allocated lazily on first write. LogMessages are
+// automatically written when they go out of scope.
+//
+// Example usage:
+//
+// {
+//   LogMessage(logging) msg;
+//   if (msg.is_debug()) {
+//     msg.debug("debug message");
+//     msg.trace("additional trace information");
+//   }
+// }
+//
+// Log outputs on trace level will see both of the messages above,
+// and the trace line will immediately follow the debug line.
+// They will have identical decorations (apart from level).
+// Log outputs on debug level will see the debug message,
+// but not the trace message.
+//
+#define LogMessage(...) LogMessageImpl<LOG_TAGS(__VA_ARGS__)>
+template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG,
+          LogTagType T3 = LogTag::__NO_TAG, LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG>
+class LogMessageImpl : public LogMessageBuffer {
+ private:
+  LogImpl<T0, T1, T2, T3, T4, GuardTag> _log;
+  bool _has_content;
+
+ public:
+  LogMessageImpl() : _has_content(false) {
+  }
+
+  ~LogMessageImpl() {
+    if (_has_content) {
+      flush();
+    }
+  }
+
+  void flush() {
+    _log.write(*this);
+    reset();
+  }
+
+  void reset() {
+    _has_content = false;
+    LogMessageBuffer::reset();
+  }
+
+  ATTRIBUTE_PRINTF(3, 0)
+  void vwrite(LogLevelType level, const char* fmt, va_list args) {
+    if (!_has_content) {
+      _has_content = true;
+      set_prefix(LogPrefix<T0, T1, T2, T3, T4>::prefix);
+    }
+    LogMessageBuffer::vwrite(level, fmt, args);
+  }
+
+#define LOG_LEVEL(level, name) \
+  bool is_##name() const { \
+    return _log.is_level(LogLevel::level); \
+  }
+  LOG_LEVEL_LIST
+#undef LOG_LEVEL
+};
+
+#endif // SHARE_VM_LOGGING_LOGMESSAGE_HPP
diff --git a/hotspot/src/share/vm/logging/logMessageBuffer.cpp b/hotspot/src/share/vm/logging/logMessageBuffer.cpp
new file mode 100644
index 0000000..f652dc5
--- /dev/null
+++ b/hotspot/src/share/vm/logging/logMessageBuffer.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "logging/logMessageBuffer.hpp"
+#include "memory/allocation.inline.hpp"
+#include "runtime/thread.inline.hpp"
+
+template <typename T>
+static void grow(T*& buffer, size_t& capacity, size_t minimum_length = 0) {
+  size_t new_size = capacity * 2;
+  if (new_size < minimum_length) {
+    new_size = minimum_length;
+  }
+  buffer = REALLOC_C_HEAP_ARRAY(T, buffer, new_size, mtLogging);
+  capacity = new_size;
+}
+
+LogMessageBuffer::LogMessageBuffer() : _message_buffer_size(0),
+                                       _message_buffer_capacity(0),
+                                       _message_buffer(NULL),
+                                       _line_count(0),
+                                       _line_capacity(0),
+                                       _lines(NULL),
+                                       _allocated(false),
+                                       _least_detailed_level(LogLevel::Off),
+                                       _prefix_fn(NULL) {
+}
+
+LogMessageBuffer::~LogMessageBuffer() {
+  if (_allocated) {
+    FREE_C_HEAP_ARRAY(char, _message_buffer);
+    FREE_C_HEAP_ARRAY(LogLine, _lines);
+  }
+}
+
+void LogMessageBuffer::reset() {
+  _message_buffer_size = 0;
+  _line_count = 0;
+}
+
+void LogMessageBuffer::initialize_buffers() {
+  assert(!_allocated, "buffer already initialized/allocated");
+  _allocated = true;
+  _message_buffer = NEW_C_HEAP_ARRAY(char, InitialMessageBufferCapacity, mtLogging);
+  _lines = NEW_C_HEAP_ARRAY(LogLine, InitialLineCapacity, mtLogging);
+  _message_buffer_capacity = InitialMessageBufferCapacity;
+  _line_capacity = InitialLineCapacity;
+}
+
+void LogMessageBuffer::Iterator::skip_messages_with_finer_level() {
+  for (; _current_line_index < _message._line_count; _current_line_index++) {
+    if (_message._lines[_current_line_index].level >= _level) {
+      break;
+    }
+  }
+}
+
+void LogMessageBuffer::write(LogLevelType level, const char* fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  vwrite(level, fmt, args);
+  va_end(args);
+};
+
+void LogMessageBuffer::vwrite(LogLevelType level, const char* fmt, va_list args) {
+  if (!_allocated) {
+    initialize_buffers();
+  }
+
+  if (level > _least_detailed_level) {
+    _least_detailed_level = level;
+  }
+
+  size_t written;
+  for (int attempts = 0; attempts < 2; attempts++) {
+    written = 0;
+    size_t remaining_buffer_length = _message_buffer_capacity - _message_buffer_size;
+    char* current_buffer_position = _message_buffer + _message_buffer_size;
+
+    if (_prefix_fn != NULL) {
+      written += _prefix_fn(current_buffer_position, remaining_buffer_length);
+      current_buffer_position += written;
+      if (remaining_buffer_length < written) {
+        remaining_buffer_length = 0;
+      } else {
+        remaining_buffer_length -= written;
+      }
+    }
+
+    va_list copy;
+    va_copy(copy, args);
+    written += (size_t)os::log_vsnprintf(current_buffer_position, remaining_buffer_length, fmt, copy) + 1;
+    va_end(copy);
+    if (written > _message_buffer_capacity - _message_buffer_size) {
+      assert(attempts == 0, "Second attempt should always have a sufficiently large buffer (resized to fit).");
+      grow(_message_buffer, _message_buffer_capacity, _message_buffer_size + written);
+      continue;
+    }
+    break;
+  }
+
+  if (_line_count == _line_capacity) {
+    grow(_lines, _line_capacity);
+  }
+
+  _lines[_line_count].level = level;
+  _lines[_line_count].message_offset = _message_buffer_size;
+  _message_buffer_size += written;
+  _line_count++;
+}
+
+#define LOG_LEVEL(level, name) \
+LogMessageBuffer& LogMessageBuffer::v##name(const char* fmt, va_list args) { \
+  vwrite(LogLevel::level, fmt, args); \
+  return *this; \
+} \
+LogMessageBuffer& LogMessageBuffer::name(const char* fmt, ...) { \
+  va_list args; \
+  va_start(args, fmt); \
+  vwrite(LogLevel::level, fmt, args); \
+  va_end(args); \
+  return *this; \
+}
+LOG_LEVEL_LIST
+#undef LOG_LEVEL
diff --git a/hotspot/src/share/vm/logging/logMessageBuffer.hpp b/hotspot/src/share/vm/logging/logMessageBuffer.hpp
new file mode 100644
index 0000000..3b722d5
--- /dev/null
+++ b/hotspot/src/share/vm/logging/logMessageBuffer.hpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#ifndef SHARE_VM_LOGGING_LOGMESSAGEBUFFER_HPP
+#define SHARE_VM_LOGGING_LOGMESSAGEBUFFER_HPP
+
+#include "logging/logDecorations.hpp"
+#include "logging/logLevel.hpp"
+#include "memory/allocation.hpp"
+
+class LogMessageBuffer : public StackObj {
+  friend class LogMessageTest;
+ protected:
+  struct LogLine VALUE_OBJ_CLASS_SPEC {
+    LogLevelType level;
+    size_t message_offset;
+  };
+  static const size_t InitialLineCapacity = 10;
+  static const size_t InitialMessageBufferCapacity = 1024;
+
+  size_t _message_buffer_size;
+  size_t _message_buffer_capacity;
+  char* _message_buffer;
+
+  size_t _line_count;
+  size_t _line_capacity;
+  LogLine* _lines;
+
+  bool _allocated;
+  LogLevelType _least_detailed_level;
+  size_t (*_prefix_fn)(char*, size_t);
+
+  void initialize_buffers();
+
+ private:
+  // Forbid copy assignment and copy constructor.
+  void operator=(const LogMessageBuffer& ref) {}
+  LogMessageBuffer(const LogMessageBuffer& ref) {}
+
+ public:
+  LogMessageBuffer();
+  ~LogMessageBuffer();
+
+  class Iterator {
+   private:
+    const LogMessageBuffer& _message;
+    size_t _current_line_index;
+    LogLevelType _level;
+    LogDecorations &_decorations;
+
+    void skip_messages_with_finer_level();
+
+   public:
+    Iterator(const LogMessageBuffer& message, LogLevelType level, LogDecorations& decorations)
+        : _message(message), _level(level), _decorations(decorations), _current_line_index(0) {
+      skip_messages_with_finer_level();
+    }
+
+    void operator++(int) {
+      _current_line_index++;
+      skip_messages_with_finer_level();
+    }
+
+    bool is_at_end() {
+      return _current_line_index == _message._line_count;
+    }
+
+    const char* message() const {
+      return _message._message_buffer + _message._lines[_current_line_index].message_offset;
+    }
+
+    const LogDecorations& decorations() {
+      _decorations.set_level(_message._lines[_current_line_index].level);
+      return _decorations;
+    }
+  };
+
+  void reset();
+
+  LogLevelType least_detailed_level() const {
+    return _least_detailed_level;
+  }
+
+  Iterator iterator(LogLevelType level, LogDecorations& decorations) const {
+    return Iterator(*this, level, decorations);
+  }
+
+  // Lines in LogMessageBuffers are not automatically prefixed based on tags
+  // like regular simple messages (see LogPrefix.hpp for more about prefixes).
+  // It is, however, possible to specify a prefix per LogMessageBuffer,
+  // using set_prefix(). Lines added to the LogMessageBuffer after a prefix
+  // function has been set will be prefixed automatically.
+  // Setting this to NULL will disable prefixing.
+  void set_prefix(size_t (*prefix_fn)(char*, size_t)) {
+    _prefix_fn = prefix_fn;
+  }
+
+  ATTRIBUTE_PRINTF(3, 4)
+  void write(LogLevelType level, const char* fmt, ...);
+
+  ATTRIBUTE_PRINTF(3, 0)
+  virtual void vwrite(LogLevelType level, const char* fmt, va_list args);
+
+#define LOG_LEVEL(level, name) \
+  LogMessageBuffer& v##name(const char* fmt, va_list args) ATTRIBUTE_PRINTF(2, 0); \
+  LogMessageBuffer& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3);
+  LOG_LEVEL_LIST
+#undef LOG_LEVEL
+};
+
+#endif // SHARE_VM_LOGGING_LOGMESSAGEBUFFER_HPP
diff --git a/hotspot/src/share/vm/logging/logOutput.hpp b/hotspot/src/share/vm/logging/logOutput.hpp
index 5f06f38..cb5de53 100644
--- a/hotspot/src/share/vm/logging/logOutput.hpp
+++ b/hotspot/src/share/vm/logging/logOutput.hpp
@@ -26,10 +26,12 @@
 
 #include "logging/logDecorators.hpp"
 #include "logging/logLevel.hpp"
+#include "logging/logMessageBuffer.hpp"
 #include "memory/allocation.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 class LogDecorations;
+class LogMessageBuffer;
 class LogTagSet;
 
 // The base class/interface for log outputs.
@@ -83,7 +85,8 @@
 
   virtual const char* name() const = 0;
   virtual bool initialize(const char* options, outputStream* errstream) = 0;
-  virtual int write(const LogDecorations &decorations, const char* msg) = 0;
+  virtual int write(const LogDecorations& decorations, const char* msg) = 0;
+  virtual int write(LogMessageBuffer::Iterator msg_iterator) = 0;
 };
 
 #endif // SHARE_VM_LOGGING_LOGOUTPUT_HPP
diff --git a/hotspot/src/share/vm/logging/logOutputList.hpp b/hotspot/src/share/vm/logging/logOutputList.hpp
index c20edd5..e983cb0 100644
--- a/hotspot/src/share/vm/logging/logOutputList.hpp
+++ b/hotspot/src/share/vm/logging/logOutputList.hpp
@@ -113,6 +113,10 @@
     bool operator!=(const LogOutputNode *ref) const {
       return _current != ref;
     }
+
+    LogLevelType level() const {
+      return _current->_level;
+    }
   };
 
   Iterator iterator(LogLevelType level = LogLevel::Last) {
diff --git a/hotspot/src/share/vm/logging/logPrefix.hpp b/hotspot/src/share/vm/logging/logPrefix.hpp
index 8d2ae12..e4a97ca 100644
--- a/hotspot/src/share/vm/logging/logPrefix.hpp
+++ b/hotspot/src/share/vm/logging/logPrefix.hpp
@@ -64,6 +64,7 @@
   LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, liveness)) \
   LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, marking)) \
   LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, metaspace)) \
+  LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, mmu)) \
   LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases)) \
   LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, start)) \
   LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, task)) \
@@ -95,9 +96,14 @@
 #define LOG_PREFIX(fn, ...) \
 template <> struct LogPrefix<__VA_ARGS__> { \
   static size_t prefix(char* buf, size_t len) { \
-    DEBUG_ONLY(buf[0] = '\0';) \
     size_t ret = fn(buf, len); \
-    assert(ret == strlen(buf), "Length mismatch ret (" SIZE_FORMAT ") != buf length (" SIZE_FORMAT ")", ret, strlen(buf)); \
+    /* Either prefix did fit (strlen(buf) == ret && ret < len) */ \
+    /* or the prefix didn't fit in buffer (ret > len && strlen(buf) < len) */ \
+    assert(ret == 0 || strlen(buf) < len, \
+           "Buffer overrun by prefix function."); \
+    assert(ret == 0 || strlen(buf) == ret || ret >= len, \
+           "Prefix function should return length of prefix written," \
+           " or the intended length of prefix if the buffer was too small."); \
     return ret; \
   } \
 };
diff --git a/hotspot/src/share/vm/logging/logTag.hpp b/hotspot/src/share/vm/logging/logTag.hpp
index ede507d..f5dc582 100644
--- a/hotspot/src/share/vm/logging/logTag.hpp
+++ b/hotspot/src/share/vm/logging/logTag.hpp
@@ -32,26 +32,28 @@
 // (The tags 'all', 'disable' and 'help' are special tags that can
 // not be used in log calls, and should not be listed below.)
 #define LOG_TAG_LIST \
-  LOG_TAG(alloc) \
+  LOG_TAG(add) \
   LOG_TAG(age) \
+  LOG_TAG(alloc) \
   LOG_TAG(arguments) \
+  LOG_TAG(annotation) \
   LOG_TAG(barrier) \
   LOG_TAG(biasedlocking) \
   LOG_TAG(bot) \
+  LOG_TAG(breakpoint) \
   LOG_TAG(census) \
+  LOG_TAG(class) \
   LOG_TAG(classhisto) \
-  LOG_TAG(classresolve) \
-  LOG_TAG(classinit) \
-  LOG_TAG(classload) /* Trace all classes loaded */ \
-  LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \
-  LOG_TAG(classunload) /* Trace unloading of classes */ \
-  LOG_TAG(classpath) \
+  LOG_TAG(cleanup) \
   LOG_TAG(compaction) \
   LOG_TAG(constraints) \
+  LOG_TAG(constantpool) \
   LOG_TAG(coops) \
   LOG_TAG(cpu) \
   LOG_TAG(cset) \
+  LOG_TAG(data) \
   LOG_TAG(defaultmethods) \
+  LOG_TAG(dump) \
   LOG_TAG(ergo) \
   LOG_TAG(exceptions) \
   LOG_TAG(exit) \
@@ -60,28 +62,45 @@
   LOG_TAG(heap) \
   LOG_TAG(humongous) \
   LOG_TAG(ihop) \
+  LOG_TAG(iklass) \
+  LOG_TAG(init) \
   LOG_TAG(itables) \
   LOG_TAG(jni) \
+  LOG_TAG(jvmti) \
   LOG_TAG(liveness) \
+  LOG_TAG(load) /* Trace all classes loaded */ \
+  LOG_TAG(loader) \
   LOG_TAG(logging) \
+  LOG_TAG(mark) \
   LOG_TAG(marking) \
+  LOG_TAG(methodcomparator) \
+  LOG_TAG(metadata) \
   LOG_TAG(metaspace) \
+  LOG_TAG(mmu) \
   LOG_TAG(modules) \
   LOG_TAG(monitorinflation) \
   LOG_TAG(monitormismatch) \
+  LOG_TAG(nmethod) \
+  LOG_TAG(normalize) \
+  LOG_TAG(objecttagging) \
+  LOG_TAG(obsolete) \
+  LOG_TAG(oopmap) \
   LOG_TAG(os) \
   LOG_TAG(pagesize) \
+  LOG_TAG(path) \
   LOG_TAG(phases) \
   LOG_TAG(plab) \
   LOG_TAG(promotion) \
   LOG_TAG(preorder) /* Trace all classes loaded in order referenced (not loaded) */ \
   LOG_TAG(protectiondomain) /* "Trace protection domain verification" */ \
   LOG_TAG(ref) \
+  LOG_TAG(redefine) \
   LOG_TAG(refine) \
   LOG_TAG(region) \
   LOG_TAG(remset) \
+  LOG_TAG(purge) \
+  LOG_TAG(resolve) \
   LOG_TAG(safepoint) \
-  LOG_TAG(safepointcleanup) \
   LOG_TAG(scavenge) \
   LOG_TAG(scrub) \
   LOG_TAG(stacktrace) \
@@ -91,6 +110,8 @@
   LOG_TAG(stats) \
   LOG_TAG(stringdedup) \
   LOG_TAG(stringtable) \
+  LOG_TAG(stackmap) \
+  LOG_TAG(subclass) \
   LOG_TAG(survivor) \
   LOG_TAG(sweep) \
   LOG_TAG(task) \
@@ -98,6 +119,9 @@
   LOG_TAG(thread) \
   LOG_TAG(tlab) \
   LOG_TAG(time) \
+  LOG_TAG(timer) \
+  LOG_TAG(update) \
+  LOG_TAG(unload) /* Trace unloading of classes */ \
   LOG_TAG(verification) \
   LOG_TAG(verify) \
   LOG_TAG(vmoperation) \
diff --git a/hotspot/src/share/vm/logging/logTagSet.cpp b/hotspot/src/share/vm/logging/logTagSet.cpp
index 96aae62..446c2b4 100644
--- a/hotspot/src/share/vm/logging/logTagSet.cpp
+++ b/hotspot/src/share/vm/logging/logTagSet.cpp
@@ -24,10 +24,13 @@
 #include "precompiled.hpp"
 #include "logging/logDecorations.hpp"
 #include "logging/logLevel.hpp"
+#include "logging/logMessageBuffer.hpp"
 #include "logging/logOutput.hpp"
 #include "logging/logTag.hpp"
 #include "logging/logTagSet.hpp"
+#include "logging/logTagSetDescriptions.hpp"
 #include "memory/allocation.inline.hpp"
+#include "utilities/ostream.hpp"
 
 LogTagSet*  LogTagSet::_list      = NULL;
 size_t      LogTagSet::_ntagsets  = 0;
@@ -74,6 +77,13 @@
   }
 }
 
+void LogTagSet::log(const LogMessageBuffer& msg) {
+  LogDecorations decorations(LogLevel::Invalid, *this, _decorators);
+  for (LogOutputList::Iterator it = _output_list.iterator(msg.least_detailed_level()); it != _output_list.end(); it++) {
+    (*it)->write(msg.iterator(it.level(), decorations));
+  }
+}
+
 int LogTagSet::label(char* buf, size_t len, const char* separator) const {
   int tot_written = 0;
   for (size_t i = 0; i < _ntags; i++) {
@@ -119,3 +129,44 @@
   }
   va_end(saved_args);
 }
+
+static const size_t TagSetBufferSize = 128;
+
+void LogTagSet::describe_tagsets(outputStream* out) {
+  out->print_cr("Described tag combinations:");
+  for (const LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) {
+    char buf[TagSetBufferSize];
+    d->tagset->label(buf, sizeof(buf), "+");
+    out->print_cr(" %s: %s", buf, d->descr);
+  }
+}
+
+static int qsort_strcmp(const void* a, const void* b) {
+  return strcmp((*(const char**)a), (*(const char**)b));
+}
+
+void LogTagSet::list_all_tagsets(outputStream* out) {
+  char** tagset_labels = NEW_C_HEAP_ARRAY(char*, _ntagsets, mtLogging);
+
+  // Generate the list of tagset labels
+  size_t idx = 0;
+  for (LogTagSet* ts = first(); ts != NULL; ts = ts->next()) {
+    char buf[TagSetBufferSize];
+    ts->label(buf, sizeof(buf), "+");
+    tagset_labels[idx++] = os::strdup_check_oom(buf, mtLogging);
+  }
+  assert(idx == _ntagsets, "_ntagsets and list of tagsets not in sync");
+
+  // Sort them lexicographically
+  qsort(tagset_labels, _ntagsets, sizeof(*tagset_labels), qsort_strcmp);
+
+  // Print and then free the labels
+  out->print("All available tag sets: ");
+  for (idx = 0; idx < _ntagsets; idx++) {
+    out->print("%s%s", (idx == 0 ? "" : ", "), tagset_labels[idx]);
+    os::free(tagset_labels[idx]);
+  }
+  out->cr();
+  FREE_C_HEAP_ARRAY(char*, tagset_labels);
+}
+
diff --git a/hotspot/src/share/vm/logging/logTagSet.hpp b/hotspot/src/share/vm/logging/logTagSet.hpp
index 6008070..0b238b3 100644
--- a/hotspot/src/share/vm/logging/logTagSet.hpp
+++ b/hotspot/src/share/vm/logging/logTagSet.hpp
@@ -31,23 +31,25 @@
 #include "logging/logTag.hpp"
 #include "utilities/globalDefinitions.hpp"
 
+class LogMessageBuffer;
+
 // The tagset represents a combination of tags that occur in a log call somewhere.
 // Tagsets are created automatically by the LogTagSetMappings and should never be
 // instantiated directly somewhere else.
 class LogTagSet VALUE_OBJ_CLASS_SPEC {
  private:
   static LogTagSet* _list;
-  static size_t     _ntagsets;
+  static size_t _ntagsets;
 
-  LogTagSet* const  _next;
-  size_t            _ntags;
-  LogTagType        _tag[LogTag::MaxTags];
+  LogTagSet* const _next;
+  size_t _ntags;
+  LogTagType _tag[LogTag::MaxTags];
 
-  LogOutputList     _output_list;
-  LogDecorators     _decorators;
+  LogOutputList _output_list;
+  LogDecorators _decorators;
 
   typedef size_t (*PrefixWriter)(char* buf, size_t size);
-  PrefixWriter      _write_prefix;
+  PrefixWriter _write_prefix;
 
   // Keep constructor private to prevent incorrect instantiations of this class.
   // Only LogTagSetMappings can create/contain instances of this class.
@@ -60,6 +62,9 @@
   friend class LogTagSetMapping;
 
  public:
+  static void describe_tagsets(outputStream* out);
+  static void list_all_tagsets(outputStream* out);
+
   static LogTagSet* first() {
     return _list;
   }
@@ -110,6 +115,7 @@
     return _output_list.is_level(level);
   }
   void log(LogLevelType level, const char* msg);
+  void log(const LogMessageBuffer& msg);
 
   ATTRIBUTE_PRINTF(3, 4)
   void write(LogLevelType level, const char* fmt, ...);
diff --git a/hotspot/src/share/vm/logging/logTagSetDescriptions.cpp b/hotspot/src/share/vm/logging/logTagSetDescriptions.cpp
new file mode 100644
index 0000000..807e88d
--- /dev/null
+++ b/hotspot/src/share/vm/logging/logTagSetDescriptions.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "logging/logTag.hpp"
+#include "logging/logTagSet.hpp"
+#include "logging/logTagSetDescriptions.hpp"
+
+// List of described tag sets. Tags should be specified using the LOG_TAGS()
+// macro. Described tag sets can be listed from command line (or DCMD) using
+// -Xlog:help (or "VM.log list")
+#define LOG_TAG_SET_DESCRIPTION_LIST \
+  LOG_TAG_SET_DESCRIPTION(LOG_TAGS(logging), \
+                          "Logging for the log framework itself")
+
+#define LOG_TAG_SET_DESCRIPTION(tags, descr) \
+  { &LogTagSetMapping<tags>::tagset(), descr },
+
+struct LogTagSetDescription tagset_descriptions[] = {
+  LOG_TAG_SET_DESCRIPTION_LIST
+  { NULL, NULL }
+};
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/hotspot/src/share/vm/logging/logTagSetDescriptions.hpp
similarity index 71%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to hotspot/src/share/vm/logging/logTagSetDescriptions.hpp
index 135652e..60e3660 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/hotspot/src/share/vm/logging/logTagSetDescriptions.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -19,14 +19,18 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
+ *
  */
+#ifndef SHARE_VM_LOGGING_LOGTAGSETDESCRIPTIONS_HPP
+#define SHARE_VM_LOGGING_LOGTAGSETDESCRIPTIONS_HPP
 
-package sun.misc;
+class LogTagSet;
 
-public class Unsafe {
-    private Unsafe() { }
+struct LogTagSetDescription {
+  const LogTagSet* tagset;
+  const char* descr;
+};
 
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+extern struct LogTagSetDescription tagset_descriptions[];
+
+#endif // SHARE_VM_LOGGING_LOGTAGSETDESCRIPTIONS_HPP
diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp
index 5a3ae92..f7dea3d 100644
--- a/hotspot/src/share/vm/memory/allocation.cpp
+++ b/hotspot/src/share/vm/memory/allocation.cpp
@@ -664,64 +664,6 @@
 // Non-product code
 
 #ifndef PRODUCT
-// The global operator new should never be called since it will usually indicate
-// a memory leak.  Use CHeapObj as the base class of such objects to make it explicit
-// that they're allocated on the C heap.
-// Commented out in product version to avoid conflicts with third-party C++ native code.
-//
-// In C++98/03 the throwing new operators are defined with the following signature:
-//
-// void* operator new(std::size_tsize) throw(std::bad_alloc);
-// void* operator new[](std::size_tsize) throw(std::bad_alloc);
-//
-// while all the other (non-throwing) new and delete operators are defined with an empty
-// throw clause (i.e. "operator delete(void* p) throw()") which means that they do not
-// throw any exceptions (see section 18.4 of the C++ standard).
-//
-// In the new C++11/14 standard, the signature of the throwing new operators was changed
-// by completely omitting the throw clause (which effectively means they could throw any
-// exception) while all the other new/delete operators where changed to have a 'nothrow'
-// clause instead of an empty throw clause.
-//
-// Unfortunately, the support for exception specifications among C++ compilers is still
-// very fragile. While some more strict compilers like AIX xlC or HP aCC reject to
-// override the default throwing new operator with a user operator with an empty throw()
-// clause, the MS Visual C++ compiler warns for every non-empty throw clause like
-// throw(std::bad_alloc) that it will ignore the exception specification. The following
-// operator definitions have been checked to correctly work with all currently supported
-// compilers and they should be upwards compatible with C++11/14. Therefore
-// PLEASE BE CAREFUL if you change the signature of the following operators!
-
-static void * zero = (void *) 0;
-
-void* operator new(size_t size) /* throw(std::bad_alloc) */ {
-  fatal("Should not call global operator new");
-  return zero;
-}
-
-void* operator new [](size_t size) /* throw(std::bad_alloc) */ {
-  fatal("Should not call global operator new[]");
-  return zero;
-}
-
-void* operator new(size_t size, const std::nothrow_t&  nothrow_constant) throw() {
-  fatal("Should not call global operator new");
-  return 0;
-}
-
-void* operator new [](size_t size, std::nothrow_t&  nothrow_constant) throw() {
-  fatal("Should not call global operator new[]");
-  return 0;
-}
-
-void operator delete(void* p) throw() {
-  fatal("Should not call global delete");
-}
-
-void operator delete [](void* p) throw() {
-  fatal("Should not call global delete []");
-}
-
 void AllocatedObj::print() const       { print_on(tty); }
 void AllocatedObj::print_value() const { print_value_on(tty); }
 
diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp
index f952b3d..b442f4c 100644
--- a/hotspot/src/share/vm/memory/filemap.cpp
+++ b/hotspot/src/share/vm/memory/filemap.cpp
@@ -99,7 +99,8 @@
       fail(msg, ap);
     } else {
       if (PrintSharedSpaces) {
-        tty->print_cr("UseSharedSpaces: %s", msg);
+        tty->print("UseSharedSpaces: ");
+        tty->vprint_cr(msg, ap);
       }
     }
     UseSharedSpaces = false;
@@ -208,7 +209,7 @@
         count ++;
         bytes += (int)entry_size;
         bytes += name_bytes;
-        log_info(classpath)("add main shared path (%s) %s", (cpe->is_jar_file() ? "jar" : "dir"), name);
+        log_info(class, path)("add main shared path (%s) %s", (cpe->is_jar_file() ? "jar" : "dir"), name);
       } else {
         SharedClassPathEntry* ent = shared_classpath(cur_entry);
         if (cpe->is_jar_file()) {
@@ -282,7 +283,7 @@
     struct stat st;
     const char* name = ent->_name;
     bool ok = true;
-    log_info(classpath)("checking shared classpath entry: %s", name);
+    log_info(class, path)("checking shared classpath entry: %s", name);
     if (os::stat(name, &st) != 0) {
       fail_continue("Required classpath entry does not exist: %s", name);
       ok = false;
@@ -306,7 +307,7 @@
       }
     }
     if (ok) {
-      log_info(classpath)("ok");
+      log_info(class, path)("ok");
     } else if (!PrintSharedArchiveAndExit) {
       _validating_classpath_entry_table = false;
       return false;
@@ -896,8 +897,8 @@
   char header_version[JVM_IDENT_MAX];
   get_header_version(header_version);
   if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
-    log_info(classpath)("expected: %s", header_version);
-    log_info(classpath)("actual:   %s", _jvm_ident);
+    log_info(class, path)("expected: %s", header_version);
+    log_info(class, path)("actual:   %s", _jvm_ident);
     FileMapInfo::fail_continue("The shared archive file was created by a different"
                   " version or build of HotSpot");
     return false;
@@ -925,7 +926,7 @@
   if (status) {
     if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
       if (!PrintSharedArchiveAndExit) {
-        fail_continue("shared class paths mismatch (hint: enable -Xlog:classpath=info to diagnose the failure)");
+        fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)");
         status = false;
       }
     }
diff --git a/hotspot/src/share/vm/memory/heapInspection.cpp b/hotspot/src/share/vm/memory/heapInspection.cpp
index 2f8f40d..0f17689 100644
--- a/hotspot/src/share/vm/memory/heapInspection.cpp
+++ b/hotspot/src/share/vm/memory/heapInspection.cpp
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoaderData.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
@@ -105,10 +106,20 @@
   ResourceMark rm;
 
   // simplify the formatting (ILP32 vs LP64) - always cast the numbers to 64-bit
-  st->print_cr(INT64_FORMAT_W(13) "  " UINT64_FORMAT_W(13) "  %s",
-               (int64_t)_instance_count,
-               (uint64_t)_instance_words * HeapWordSize,
-               name());
+  ModuleEntry* module = _klass->module();
+  if (module->is_named()) {
+    st->print_cr(INT64_FORMAT_W(13) "  " UINT64_FORMAT_W(13) "  %s (%s@%s)",
+                 (int64_t)_instance_count,
+                 (uint64_t)_instance_words * HeapWordSize,
+                 name(),
+                 module->name()->as_C_string(),
+                 module->version() != NULL ? module->version()->as_C_string() : "");
+  } else {
+    st->print_cr(INT64_FORMAT_W(13) "  " UINT64_FORMAT_W(13) "  %s",
+                 (int64_t)_instance_count,
+                 (uint64_t)_instance_words * HeapWordSize,
+                 name());
+  }
 }
 
 KlassInfoEntry* KlassInfoBucket::lookup(Klass* const k) {
@@ -647,8 +658,8 @@
   if (print_stats) {
     print_class_stats(st, csv_format, columns);
   } else {
-    st->print_cr(" num     #instances         #bytes  class name");
-    st->print_cr("----------------------------------------------");
+    st->print_cr(" num     #instances         #bytes  class name (module)");
+    st->print_cr("-------------------------------------------------------");
     print_elements(st);
   }
 }
diff --git a/hotspot/src/share/vm/memory/iterator.hpp b/hotspot/src/share/vm/memory/iterator.hpp
index 3a36dc6..cd6df30 100644
--- a/hotspot/src/share/vm/memory/iterator.hpp
+++ b/hotspot/src/share/vm/memory/iterator.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -355,6 +355,9 @@
   // Read/write the void pointer pointed to by p.
   virtual void do_ptr(void** p) = 0;
 
+  // Read/write the 32-bit unsigned integer pointed to by p.
+  virtual void do_u4(u4* p) = 0;
+
   // Read/write the region specified.
   virtual void do_region(u_char* start, size_t size) = 0;
 
@@ -363,6 +366,10 @@
   // for verification that sections of the serialized data are of the
   // correct length.
   virtual void do_tag(int tag) = 0;
+
+  bool writing() {
+    return !reading();
+  }
 };
 
 class SymbolClosure : public StackObj {
diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp
index fa4d31a..b975e9e 100644
--- a/hotspot/src/share/vm/memory/metaspaceShared.cpp
+++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp
@@ -31,6 +31,7 @@
 #include "classfile/sharedClassUtil.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
+#include "classfile/systemDictionaryShared.hpp"
 #include "code/codeCache.hpp"
 #include "gc/shared/gcLocker.hpp"
 #include "interpreter/bytecodeStream.hpp"
@@ -106,7 +107,8 @@
 // Read/write a data stream for restoring/preserving metadata pointers and
 // miscellaneous data from/to the shared archive file.
 
-void MetaspaceShared::serialize(SerializeClosure* soc) {
+void MetaspaceShared::serialize(SerializeClosure* soc, GrowableArray<MemRegion> *string_space,
+                                size_t* space_size) {
   int tag = 0;
   soc->do_tag(--tag);
 
@@ -128,6 +130,15 @@
   vmSymbols::serialize(soc);
   soc->do_tag(--tag);
 
+  // Dump/restore the symbol and string tables
+  SymbolTable::serialize(soc);
+  StringTable::serialize(soc, string_space, space_size);
+  soc->do_tag(--tag);
+
+  // Dump/restore the misc information for system dictionary
+  SystemDictionaryShared::serialize(soc);
+  soc->do_tag(--tag);
+
   soc->do_tag(666);
 }
 
@@ -314,6 +325,11 @@
     ++top;
   }
 
+  void do_u4(u4* p) {
+    void* ptr = (void*)(uintx(*p));
+    do_ptr(&ptr);
+  }
+
   void do_tag(int tag) {
     check_space();
     *top = (intptr_t)tag;
@@ -348,6 +364,8 @@
   METASPACE_OBJ_TYPES_DO(f) \
   f(SymbolHashentry) \
   f(SymbolBucket) \
+  f(StringHashentry) \
+  f(StringBucket) \
   f(Other)
 
 #define SHAREDSPACE_OBJ_TYPE_DECLARE(name) name ## Type,
@@ -406,13 +424,22 @@
   MetaspaceSharedStats *stats = MetaspaceShared::stats();
 
   // symbols
-  _counts[RW][SymbolHashentryType] = stats->symbol.hashentry_count;
-  _bytes [RW][SymbolHashentryType] = stats->symbol.hashentry_bytes;
-  other_bytes -= stats->symbol.hashentry_bytes;
+  _counts[RO][SymbolHashentryType] = stats->symbol.hashentry_count;
+  _bytes [RO][SymbolHashentryType] = stats->symbol.hashentry_bytes;
+  _bytes [RO][TypeArrayU4Type]    -= stats->symbol.hashentry_bytes;
 
-  _counts[RW][SymbolBucketType] = stats->symbol.bucket_count;
-  _bytes [RW][SymbolBucketType] = stats->symbol.bucket_bytes;
-  other_bytes -= stats->symbol.bucket_bytes;
+  _counts[RO][SymbolBucketType] = stats->symbol.bucket_count;
+  _bytes [RO][SymbolBucketType] = stats->symbol.bucket_bytes;
+  _bytes [RO][TypeArrayU4Type] -= stats->symbol.bucket_bytes;
+
+  // strings
+  _counts[RO][StringHashentryType] = stats->string.hashentry_count;
+  _bytes [RO][StringHashentryType] = stats->string.hashentry_bytes;
+  _bytes [RO][TypeArrayU4Type]    -= stats->string.hashentry_bytes;
+
+  _counts[RO][StringBucketType] = stats->string.bucket_count;
+  _bytes [RO][StringBucketType] = stats->string.bucket_bytes;
+  _bytes [RO][TypeArrayU4Type] -= stats->string.bucket_bytes;
 
   // TODO: count things like dictionary, vtable, etc
   _bytes[RW][OtherType] =  other_bytes;
@@ -488,7 +515,6 @@
   GrowableArray<Klass*> *_class_promote_order;
   VirtualSpace _md_vs;
   VirtualSpace _mc_vs;
-  CompactHashtableWriter* _string_cht;
   GrowableArray<MemRegion> *_string_regions;
 
 public:
@@ -600,39 +626,27 @@
   // Not doing this either.
 
   SystemDictionary::reorder_dictionary();
-
   NOT_PRODUCT(SystemDictionary::verify();)
-
-  // Copy the symbol table, string table, and the system dictionary to the shared
-  // space in usable form.  Copy the hashtable
-  // buckets first [read-write], then copy the linked lists of entries
-  // [read-only].
-
-  NOT_PRODUCT(SymbolTable::verify());
-  handle_misc_data_space_failure(SymbolTable::copy_compact_table(&md_top, md_end));
-
-  size_t ss_bytes = 0;
-  char* ss_low;
-  // The string space has maximum two regions. See FileMapInfo::write_string_regions() for details.
-  _string_regions = new GrowableArray<MemRegion>(2);
-  NOT_PRODUCT(StringTable::verify());
-  handle_misc_data_space_failure(StringTable::copy_compact_table(&md_top, md_end, _string_regions,
-                                                                 &ss_bytes));
-  ss_low = _string_regions->is_empty() ? NULL : (char*)_string_regions->first().start();
-
   SystemDictionary::reverse();
   SystemDictionary::copy_buckets(&md_top, md_end);
 
   SystemDictionary::copy_table(&md_top, md_end);
 
   // Write the other data to the output array.
+  // SymbolTable, StringTable and extra information for system dictionary
+  NOT_PRODUCT(SymbolTable::verify());
+  NOT_PRODUCT(StringTable::verify());
+  size_t ss_bytes = 0;
+  char* ss_low;
+  // The string space has maximum two regions. See FileMapInfo::write_string_regions() for details.
+  _string_regions = new GrowableArray<MemRegion>(2);
+
   WriteClosure wc(md_top, md_end);
-  MetaspaceShared::serialize(&wc);
+  MetaspaceShared::serialize(&wc, _string_regions, &ss_bytes);
   md_top = wc.get_top();
+  ss_low = _string_regions->is_empty() ? NULL : (char*)_string_regions->first().start();
 
   // Print shared spaces all the time
-// To make fmt_space be a syntactic constant (for format warnings), use #define.
-#define fmt_space "%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%4.1f%% used] at " INTPTR_FORMAT
   Metaspace* ro_space = _loader_data->ro_metaspace();
   Metaspace* rw_space = _loader_data->rw_metaspace();
 
@@ -665,12 +679,13 @@
   const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0;
   const double total_u_perc = total_bytes / double(total_alloced) * 100.0;
 
+#define fmt_space "%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT
   tty->print_cr(fmt_space, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, p2i(ro_space->bottom()));
   tty->print_cr(fmt_space, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, p2i(rw_space->bottom()));
   tty->print_cr(fmt_space, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, p2i(md_low));
   tty->print_cr(fmt_space, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, p2i(mc_low));
   tty->print_cr(fmt_space, "st", ss_bytes, ss_t_perc, ss_bytes,   100.0,     p2i(ss_low));
-  tty->print_cr("total   : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%4.1f%% used]",
+  tty->print_cr("total   : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used]",
                  total_bytes, total_alloced, total_u_perc);
 
   // Update the vtable pointers in all of the Klass objects in the
@@ -904,7 +919,7 @@
 
         InstanceKlass* ik = InstanceKlass::cast(klass);
 
-        // Should be class load order as per -Xlog:classload+preorder
+        // Should be class load order as per -Xlog:class+preorder
         class_promote_order->append(ik);
 
         // Link the class to cause the bytecodes to be rewritten and the
@@ -974,6 +989,11 @@
     *p = (void*)obj;
   }
 
+  void do_u4(u4* p) {
+    intptr_t obj = nextPtr();
+    *p = (u4)(uintx(obj));
+  }
+
   void do_tag(int tag) {
     int old_tag;
     old_tag = (int)(intptr_t)nextPtr();
@@ -1097,21 +1117,6 @@
   buffer += sizeof(intptr_t);
   buffer += vtable_size;
 
-  // Create the shared symbol table using the compact table at this spot in the
-  // misc data space. (Todo: move this to read-only space. Currently
-  // this is mapped copy-on-write but will never be written into).
-
-  buffer = (char*)SymbolTable::init_shared_table(buffer);
-  SymbolTable::create_table();
-
-  // Create the shared string table using the compact table
-  buffer = (char*)StringTable::init_shared_table(mapinfo, buffer);
-
-  // Create the shared dictionary using the bucket array at this spot in
-  // the misc data space.  Since the shared dictionary table is never
-  // modified, this region (of mapped pages) will be (effectively, if
-  // not explicitly) read-only.
-
   int sharedDictionaryLen = *(intptr_t*)buffer;
   buffer += sizeof(intptr_t);
   int number_of_entries = *(intptr_t*)buffer;
@@ -1129,9 +1134,14 @@
   buffer += sizeof(intptr_t);
   buffer += len;
 
+  // Verify various attributes of the archive, plus initialize the
+  // shared string/symbol tables
   intptr_t* array = (intptr_t*)buffer;
   ReadClosure rc(&array);
-  serialize(&rc);
+  serialize(&rc, NULL, NULL);
+
+  // Initialize the run-time symbol table.
+  SymbolTable::create_table();
 
   // Close the mapinfo file
   mapinfo->close();
diff --git a/hotspot/src/share/vm/memory/metaspaceShared.hpp b/hotspot/src/share/vm/memory/metaspaceShared.hpp
index 7c39f63..be7b1ba 100644
--- a/hotspot/src/share/vm/memory/metaspaceShared.hpp
+++ b/hotspot/src/share/vm/memory/metaspaceShared.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,11 +43,11 @@
 // for the x64 platform
 #define DEFAULT_VTBL_COMMON_CODE_SIZE   (1*K) // conservative size of the "common_code" for the x64 platform
 
-#define DEFAULT_SHARED_READ_WRITE_SIZE  (NOT_LP64(8*M) LP64_ONLY(10*M))
+#define DEFAULT_SHARED_READ_WRITE_SIZE  (NOT_LP64(9*M) LP64_ONLY(10*M))
 #define MIN_SHARED_READ_WRITE_SIZE      (NOT_LP64(7*M) LP64_ONLY(10*M))
 
-#define DEFAULT_SHARED_READ_ONLY_SIZE   (NOT_LP64(8*M) LP64_ONLY(10*M))
-#define MIN_SHARED_READ_ONLY_SIZE       (NOT_LP64(8*M) LP64_ONLY(9*M))
+#define DEFAULT_SHARED_READ_ONLY_SIZE   (NOT_LP64(9*M) LP64_ONLY(10*M))
+#define MIN_SHARED_READ_ONLY_SIZE       (NOT_LP64(9*M) LP64_ONLY(10*M))
 
 // the MIN_SHARED_MISC_DATA_SIZE and MIN_SHARED_MISC_CODE_SIZE estimates are based on
 // the sizes required for dumping the archive using the default classlist. The sizes
@@ -193,7 +193,8 @@
                                       void** vtable,
                                       char** md_top, char* md_end,
                                       char** mc_top, char* mc_end);
-  static void serialize(SerializeClosure* sc);
+  static void serialize(SerializeClosure* sc, GrowableArray<MemRegion> *string_space,
+                        size_t* space_size);
 
   static MetaspaceSharedStats* stats() {
     return &_stats;
diff --git a/hotspot/src/share/vm/memory/operator_new.cpp b/hotspot/src/share/vm/memory/operator_new.cpp
new file mode 100644
index 0000000..69181a4
--- /dev/null
+++ b/hotspot/src/share/vm/memory/operator_new.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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 "utilities/debug.hpp"
+
+#include <new>
+
+//--------------------------------------------------------------------------------------
+// Non-product code
+
+#ifndef PRODUCT
+// The global operator new should never be called since it will usually indicate
+// a memory leak.  Use CHeapObj as the base class of such objects to make it explicit
+// that they're allocated on the C heap.
+// Commented out in product version to avoid conflicts with third-party C++ native code.
+//
+// In C++98/03 the throwing new operators are defined with the following signature:
+//
+// void* operator new(std::size_tsize) throw(std::bad_alloc);
+// void* operator new[](std::size_tsize) throw(std::bad_alloc);
+//
+// while all the other (non-throwing) new and delete operators are defined with an empty
+// throw clause (i.e. "operator delete(void* p) throw()") which means that they do not
+// throw any exceptions (see section 18.4 of the C++ standard).
+//
+// In the new C++11/14 standard, the signature of the throwing new operators was changed
+// by completely omitting the throw clause (which effectively means they could throw any
+// exception) while all the other new/delete operators where changed to have a 'nothrow'
+// clause instead of an empty throw clause.
+//
+// Unfortunately, the support for exception specifications among C++ compilers is still
+// very fragile. While some more strict compilers like AIX xlC or HP aCC reject to
+// override the default throwing new operator with a user operator with an empty throw()
+// clause, the MS Visual C++ compiler warns for every non-empty throw clause like
+// throw(std::bad_alloc) that it will ignore the exception specification. The following
+// operator definitions have been checked to correctly work with all currently supported
+// compilers and they should be upwards compatible with C++11/14. Therefore
+// PLEASE BE CAREFUL if you change the signature of the following operators!
+
+static void * zero = (void *) 0;
+
+void* operator new(size_t size) /* throw(std::bad_alloc) */ {
+  fatal("Should not call global operator new");
+  return zero;
+}
+
+void* operator new [](size_t size) /* throw(std::bad_alloc) */ {
+  fatal("Should not call global operator new[]");
+  return zero;
+}
+
+void* operator new(size_t size, const std::nothrow_t&  nothrow_constant) throw() {
+  fatal("Should not call global operator new");
+  return 0;
+}
+
+void* operator new [](size_t size, std::nothrow_t&  nothrow_constant) throw() {
+  fatal("Should not call global operator new[]");
+  return 0;
+}
+
+void operator delete(void* p) throw() {
+  fatal("Should not call global delete");
+}
+
+void operator delete [](void* p) throw() {
+  fatal("Should not call global delete []");
+}
+
+#endif // Non-product
diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp
index 11037c5..9c17574 100644
--- a/hotspot/src/share/vm/memory/universe.cpp
+++ b/hotspot/src/share/vm/memory/universe.cpp
@@ -55,7 +55,6 @@
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayKlass.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/commandLineFlagConstraintList.hpp"
diff --git a/hotspot/src/share/vm/memory/virtualspace.cpp b/hotspot/src/share/vm/memory/virtualspace.cpp
index 31fddb7..3cb6d21 100644
--- a/hotspot/src/share/vm/memory/virtualspace.cpp
+++ b/hotspot/src/share/vm/memory/virtualspace.cpp
@@ -751,6 +751,29 @@
   return low() <= (const char*) p && (const char*) p < high();
 }
 
+static void pretouch_expanded_memory(void* start, void* end) {
+  assert(is_ptr_aligned(start, os::vm_page_size()), "Unexpected alignment");
+  assert(is_ptr_aligned(end,   os::vm_page_size()), "Unexpected alignment");
+
+  os::pretouch_memory(start, end);
+}
+
+static bool commit_expanded(char* start, size_t size, size_t alignment, bool pre_touch, bool executable) {
+  if (os::commit_memory(start, size, alignment, executable)) {
+    if (pre_touch || AlwaysPreTouch) {
+      pretouch_expanded_memory(start, start + size);
+    }
+    return true;
+  }
+
+  debug_only(warning(
+      "INFO: os::commit_memory(" PTR_FORMAT ", " PTR_FORMAT
+      " size=" SIZE_FORMAT ", executable=%d) failed",
+      p2i(start), p2i(start + size), size, executable);)
+
+  return false;
+}
+
 /*
    First we need to determine if a particular virtual space is using large
    pages.  This is done at the initialize function and only virtual spaces
@@ -764,7 +787,9 @@
    allocated with default pages.
 */
 bool VirtualSpace::expand_by(size_t bytes, bool pre_touch) {
-  if (uncommitted_size() < bytes) return false;
+  if (uncommitted_size() < bytes) {
+    return false;
+  }
 
   if (special()) {
     // don't commit memory if the entire space is pinned in memory
@@ -774,30 +799,23 @@
 
   char* previous_high = high();
   char* unaligned_new_high = high() + bytes;
-  assert(unaligned_new_high <= high_boundary(),
-         "cannot expand by more than upper boundary");
+  assert(unaligned_new_high <= high_boundary(), "cannot expand by more than upper boundary");
 
   // Calculate where the new high for each of the regions should be.  If
   // the low_boundary() and high_boundary() are LargePageSizeInBytes aligned
   // then the unaligned lower and upper new highs would be the
   // lower_high() and upper_high() respectively.
-  char* unaligned_lower_new_high =
-    MIN2(unaligned_new_high, lower_high_boundary());
-  char* unaligned_middle_new_high =
-    MIN2(unaligned_new_high, middle_high_boundary());
-  char* unaligned_upper_new_high =
-    MIN2(unaligned_new_high, upper_high_boundary());
+  char* unaligned_lower_new_high =  MIN2(unaligned_new_high, lower_high_boundary());
+  char* unaligned_middle_new_high = MIN2(unaligned_new_high, middle_high_boundary());
+  char* unaligned_upper_new_high =  MIN2(unaligned_new_high, upper_high_boundary());
 
   // Align the new highs based on the regions alignment.  lower and upper
   // alignment will always be default page size.  middle alignment will be
   // LargePageSizeInBytes if the actual size of the virtual space is in
   // fact larger than LargePageSizeInBytes.
-  char* aligned_lower_new_high =
-    (char*) round_to((intptr_t) unaligned_lower_new_high, lower_alignment());
-  char* aligned_middle_new_high =
-    (char*) round_to((intptr_t) unaligned_middle_new_high, middle_alignment());
-  char* aligned_upper_new_high =
-    (char*) round_to((intptr_t) unaligned_upper_new_high, upper_alignment());
+  char* aligned_lower_new_high =  (char*) round_to((intptr_t) unaligned_lower_new_high, lower_alignment());
+  char* aligned_middle_new_high = (char*) round_to((intptr_t) unaligned_middle_new_high, middle_alignment());
+  char* aligned_upper_new_high =  (char*) round_to((intptr_t) unaligned_upper_new_high, upper_alignment());
 
   // Determine which regions need to grow in this expand_by call.
   // If you are growing in the lower region, high() must be in that
@@ -808,75 +826,48 @@
   // is an intra or inter region growth.
   size_t lower_needs = 0;
   if (aligned_lower_new_high > lower_high()) {
-    lower_needs =
-      pointer_delta(aligned_lower_new_high, lower_high(), sizeof(char));
+    lower_needs = pointer_delta(aligned_lower_new_high, lower_high(), sizeof(char));
   }
   size_t middle_needs = 0;
   if (aligned_middle_new_high > middle_high()) {
-    middle_needs =
-      pointer_delta(aligned_middle_new_high, middle_high(), sizeof(char));
+    middle_needs = pointer_delta(aligned_middle_new_high, middle_high(), sizeof(char));
   }
   size_t upper_needs = 0;
   if (aligned_upper_new_high > upper_high()) {
-    upper_needs =
-      pointer_delta(aligned_upper_new_high, upper_high(), sizeof(char));
+    upper_needs = pointer_delta(aligned_upper_new_high, upper_high(), sizeof(char));
   }
 
   // Check contiguity.
-  assert(low_boundary() <= lower_high() &&
-         lower_high() <= lower_high_boundary(),
+  assert(low_boundary() <= lower_high() && lower_high() <= lower_high_boundary(),
          "high address must be contained within the region");
-  assert(lower_high_boundary() <= middle_high() &&
-         middle_high() <= middle_high_boundary(),
+  assert(lower_high_boundary() <= middle_high() && middle_high() <= middle_high_boundary(),
          "high address must be contained within the region");
-  assert(middle_high_boundary() <= upper_high() &&
-         upper_high() <= upper_high_boundary(),
+  assert(middle_high_boundary() <= upper_high() && upper_high() <= upper_high_boundary(),
          "high address must be contained within the region");
 
   // Commit regions
   if (lower_needs > 0) {
-    assert(low_boundary() <= lower_high() &&
-           lower_high() + lower_needs <= lower_high_boundary(),
-           "must not expand beyond region");
-    if (!os::commit_memory(lower_high(), lower_needs, _executable)) {
-      debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT
-                         ", lower_needs=" SIZE_FORMAT ", %d) failed",
-                         p2i(lower_high()), lower_needs, _executable);)
+    assert(lower_high() + lower_needs <= lower_high_boundary(), "must not expand beyond region");
+    if (!commit_expanded(lower_high(), lower_needs, _lower_alignment, pre_touch, _executable)) {
       return false;
-    } else {
-      _lower_high += lower_needs;
     }
+    _lower_high += lower_needs;
   }
+
   if (middle_needs > 0) {
-    assert(lower_high_boundary() <= middle_high() &&
-           middle_high() + middle_needs <= middle_high_boundary(),
-           "must not expand beyond region");
-    if (!os::commit_memory(middle_high(), middle_needs, middle_alignment(),
-                           _executable)) {
-      debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT
-                         ", middle_needs=" SIZE_FORMAT ", " SIZE_FORMAT
-                         ", %d) failed", p2i(middle_high()), middle_needs,
-                         middle_alignment(), _executable);)
+    assert(middle_high() + middle_needs <= middle_high_boundary(), "must not expand beyond region");
+    if (!commit_expanded(middle_high(), middle_needs, _middle_alignment, pre_touch, _executable)) {
       return false;
     }
     _middle_high += middle_needs;
   }
-  if (upper_needs > 0) {
-    assert(middle_high_boundary() <= upper_high() &&
-           upper_high() + upper_needs <= upper_high_boundary(),
-           "must not expand beyond region");
-    if (!os::commit_memory(upper_high(), upper_needs, _executable)) {
-      debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT
-                         ", upper_needs=" SIZE_FORMAT ", %d) failed",
-                         p2i(upper_high()), upper_needs, _executable);)
-      return false;
-    } else {
-      _upper_high += upper_needs;
-    }
-  }
 
-  if (pre_touch || AlwaysPreTouch) {
-    os::pretouch_memory(previous_high, unaligned_new_high);
+  if (upper_needs > 0) {
+    assert(upper_high() + upper_needs <= upper_high_boundary(), "must not expand beyond region");
+    if (!commit_expanded(upper_high(), upper_needs, _upper_alignment, pre_touch, _executable)) {
+      return false;
+    }
+    _upper_high += upper_needs;
   }
 
   _high += bytes;
@@ -1092,6 +1083,12 @@
     test_log("test_reserved_space3(%p, %p, %d)",
         (void*)(uintptr_t)size, (void*)(uintptr_t)alignment, maybe_large);
 
+    if (size < alignment) {
+      // Tests might set -XX:LargePageSizeInBytes=<small pages> and cause unexpected input arguments for this test.
+      assert((size_t)os::vm_page_size() == os::large_page_size(), "Test needs further refinement");
+      return;
+    }
+
     assert(is_size_aligned(size, os::vm_allocation_granularity()), "Must be at least AG aligned");
     assert(is_size_aligned(size, alignment), "Must be at least aligned against alignment");
 
diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp
index 708c2f7..ec22e21 100644
--- a/hotspot/src/share/vm/oops/constantPool.cpp
+++ b/hotspot/src/share/vm/oops/constantPool.cpp
@@ -209,11 +209,11 @@
   if (k() != this_cp->pool_holder()) {
     // only print something if the classes are different
     if (source_file != NULL) {
-      log_debug(classresolve)("%s %s %s:%d",
+      log_debug(class, resolve)("%s %s %s:%d",
                  this_cp->pool_holder()->external_name(),
                  k->external_name(), source_file, line_number);
     } else {
-      log_debug(classresolve)("%s %s",
+      log_debug(class, resolve)("%s %s",
                  this_cp->pool_holder()->external_name(),
                  k->external_name());
     }
@@ -282,8 +282,8 @@
   ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
   this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
 
-  // logging for classresolve tag.
-  if (log_is_enabled(Debug, classresolve)){
+  // logging for class+resolve.
+  if (log_is_enabled(Debug, class, resolve)){
     trace_class_resolution(this_cp, k);
   }
   this_cp->klass_at_put(which, k());
@@ -341,7 +341,7 @@
   int cache_index = decode_cpcache_index(which, true);
   if (!(cache_index >= 0 && cache_index < cpool->cache()->length())) {
     // FIXME: should be an assert
-    log_debug(classresolve)("bad operand %d in:", which); cpool->print();
+    log_debug(class, resolve)("bad operand %d in:", which); cpool->print();
     return NULL;
   }
   ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
@@ -672,7 +672,7 @@
       Symbol*  name =      this_cp->method_handle_name_ref_at(index);
       Symbol*  signature = this_cp->method_handle_signature_ref_at(index);
       { ResourceMark rm(THREAD);
-        log_debug(classresolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
+        log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
                               ref_kind, index, this_cp->method_handle_index_at(index),
                               callee_index, name->as_C_string(), signature->as_C_string());
       }
@@ -695,7 +695,7 @@
     {
       Symbol*  signature = this_cp->method_type_signature_at(index);
       { ResourceMark rm(THREAD);
-        log_debug(classresolve)("resolve JVM_CONSTANT_MethodType [%d/%d] %s",
+        log_debug(class, resolve)("resolve JVM_CONSTANT_MethodType [%d/%d] %s",
                               index, this_cp->method_type_index_at(index),
                               signature->as_C_string());
       }
diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp
index 491688c..ee2425f 100644
--- a/hotspot/src/share/vm/oops/cpCache.cpp
+++ b/hotspot/src/share/vm/oops/cpCache.cpp
@@ -25,12 +25,12 @@
 #include "precompiled.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/rewriter.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.inline.hpp"
 #include "oops/cpCache.hpp"
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/methodHandles.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/handles.inline.hpp"
@@ -438,17 +438,14 @@
       // match old_method so need an update
       // NOTE: can't use set_f2_as_vfinal_method as it asserts on different values
       _f2 = (intptr_t)new_method;
-      if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
+      if (log_is_enabled(Info, redefine, class, update)) {
+        ResourceMark rm;
         if (!(*trace_name_printed)) {
-          // RC_TRACE_MESG macro has an embedded ResourceMark
-          RC_TRACE_MESG(("adjust: name=%s",
-            old_method->method_holder()->external_name()));
+          log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
           *trace_name_printed = true;
         }
-        // RC_TRACE macro has an embedded ResourceMark
-        RC_TRACE(0x00400000, ("cpc vf-entry update: %s(%s)",
-          new_method->name()->as_C_string(),
-          new_method->signature()->as_C_string()));
+        log_debug(redefine, class, update, constantpool)
+          ("cpc vf-entry update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string());
       }
       return true;
     }
@@ -465,17 +462,14 @@
 
   if (_f1 == old_method) {
     _f1 = new_method;
-    if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
+    if (log_is_enabled(Info, redefine, class, update)) {
+      ResourceMark rm;
       if (!(*trace_name_printed)) {
-        // RC_TRACE_MESG macro has an embedded ResourceMark
-        RC_TRACE_MESG(("adjust: name=%s",
-          old_method->method_holder()->external_name()));
+        log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
         *trace_name_printed = true;
       }
-      // RC_TRACE macro has an embedded ResourceMark
-      RC_TRACE(0x00400000, ("cpc entry update: %s(%s)",
-        new_method->name()->as_C_string(),
-        new_method->signature()->as_C_string()));
+      log_debug(redefine, class, update, constantpool)
+        ("cpc entry update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string());
     }
     return true;
   }
@@ -569,7 +563,7 @@
                                    const intArray& invokedynamic_references_map) {
   for (int i = 0; i < inverse_index_map.length(); i++) {
     ConstantPoolCacheEntry* e = entry_at(i);
-    int original_index = inverse_index_map[i];
+    int original_index = inverse_index_map.at(i);
     e->initialize_entry(original_index);
     assert(entry_at(i) == e, "sanity");
   }
@@ -579,19 +573,19 @@
   for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) {
     int offset = i + invokedynamic_offset;
     ConstantPoolCacheEntry* e = entry_at(offset);
-    int original_index = invokedynamic_inverse_index_map[i];
+    int original_index = invokedynamic_inverse_index_map.at(i);
     e->initialize_entry(original_index);
     assert(entry_at(offset) == e, "sanity");
   }
 
   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
-    const int cpci = invokedynamic_references_map[ref];
+    const int cpci = invokedynamic_references_map.at(ref);
     if (cpci >= 0) {
 #ifdef ASSERT
       // invokedynamic and invokehandle have more entries; check if they
       // all point to the same constant pool cache entry.
       for (int entry = 1; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
-        const int cpci_next = invokedynamic_references_map[ref + entry];
+        const int cpci_next = invokedynamic_references_map.at(ref + entry);
         assert(cpci == cpci_next, "%d == %d", cpci, cpci_next);
       }
 #endif
diff --git a/hotspot/src/share/vm/oops/generateOopMap.cpp b/hotspot/src/share/vm/oops/generateOopMap.cpp
index 60738d7..fe8cdbc 100644
--- a/hotspot/src/share/vm/oops/generateOopMap.cpp
+++ b/hotspot/src/share/vm/oops/generateOopMap.cpp
@@ -378,11 +378,10 @@
 // Basicblock handling methods
 //
 
-void GenerateOopMap ::initialize_bb() {
+void GenerateOopMap::initialize_bb() {
   _gc_points = 0;
   _bb_count  = 0;
-  _bb_hdr_bits.clear();
-  _bb_hdr_bits.resize(method()->code_size());
+  _bb_hdr_bits.reinitialize(method()->code_size());
 }
 
 void GenerateOopMap::bb_mark_fct(GenerateOopMap *c, int bci, int *data) {
@@ -1041,13 +1040,7 @@
   assert(new_method_size >= method()->code_size() + delta,
          "new method size is too small");
 
-  BitMap::bm_word_t* new_bb_hdr_bits =
-    NEW_RESOURCE_ARRAY(BitMap::bm_word_t,
-                       BitMap::word_align_up(new_method_size));
-  _bb_hdr_bits.set_map(new_bb_hdr_bits);
-  _bb_hdr_bits.set_size(new_method_size);
-  _bb_hdr_bits.clear();
-
+  _bb_hdr_bits.reinitialize(new_method_size);
 
   for(int k = 0; k < _bb_count; k++) {
     if (_basic_blocks[k]._bci > bci) {
diff --git a/hotspot/src/share/vm/oops/generateOopMap.hpp b/hotspot/src/share/vm/oops/generateOopMap.hpp
index 8822ee0..a41d14a 100644
--- a/hotspot/src/share/vm/oops/generateOopMap.hpp
+++ b/hotspot/src/share/vm/oops/generateOopMap.hpp
@@ -350,7 +350,7 @@
   BasicBlock *    _basic_blocks;             // Array of basicblock info
   int             _gc_points;
   int             _bb_count;
-  BitMap          _bb_hdr_bits;
+  ResourceBitMap  _bb_hdr_bits;
 
   // Basicblocks methods
   void          initialize_bb               ();
diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp
index f97f826..074fc00 100644
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp
@@ -53,7 +53,6 @@
 #include "oops/symbol.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "prims/jvmtiRedefineClasses.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/jvmtiThreadState.hpp"
 #include "prims/methodComparator.hpp"
 #include "runtime/atomic.inline.hpp"
@@ -450,9 +449,9 @@
     this_k->set_init_state (fully_initialized);
     this_k->fence_and_clear_init_lock();
     // trace
-    if (log_is_enabled(Info, classinit)) {
+    if (log_is_enabled(Info, class, init)) {
       ResourceMark rm(THREAD);
-      log_info(classinit)("[Initialized %s without side effects]", this_k->external_name());
+      log_info(class, init)("[Initialized %s without side effects]", this_k->external_name());
     }
   }
 }
@@ -1088,9 +1087,9 @@
 
   methodHandle h_method(THREAD, this_k->class_initializer());
   assert(!this_k->is_initialized(), "we cannot initialize twice");
-  if (log_is_enabled(Info, classinit)) {
+  if (log_is_enabled(Info, class, init)) {
     ResourceMark rm;
-    outputStream* log = Log(classinit)::info_stream();
+    outputStream* log = Log(class, init)::info_stream();
     log->print("%d Initializing ", call_class_initializer_impl_counter++);
     this_k->name()->print_value_on(log);
     log->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this_k()));
@@ -2032,10 +2031,11 @@
   return (old_state != is_in_error_state());
 }
 
+#if INCLUDE_JVMTI
 static void clear_all_breakpoints(Method* m) {
   m->clear_all_breakpoints();
 }
-
+#endif
 
 void InstanceKlass::notify_unload_class(InstanceKlass* ik) {
   // notify the debugger
@@ -2097,6 +2097,7 @@
   // DC::remove_all_dependents() when it touches unloaded nmethod.
   dependencies().wipe();
 
+#if INCLUDE_JVMTI
   // Deallocate breakpoint records
   if (breakpoints() != 0x0) {
     methods_do(clear_all_breakpoints);
@@ -2108,6 +2109,7 @@
     os::free(_cached_class_file);
     _cached_class_file = NULL;
   }
+#endif
 
   // Decrement symbol reference counts associated with the unloaded class.
   if (_name != NULL) _name->decrement_refcount();
@@ -2293,7 +2295,7 @@
   PackageEntry* classpkg2;
   if (class2->is_instance_klass()) {
     classloader2 = class2->class_loader();
-    classpkg2 = InstanceKlass::cast(class2)->package();
+    classpkg2 = class2->package();
   } else {
     assert(class2->is_typeArray_klass(), "should be type array");
     classloader2 = NULL;
@@ -2571,17 +2573,17 @@
       assert(old_method != new_method, "sanity check");
 
       default_methods()->at_put(index, new_method);
-      if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
+      if (log_is_enabled(Info, redefine, class, update)) {
+        ResourceMark rm;
         if (!(*trace_name_printed)) {
-          // RC_TRACE_MESG macro has an embedded ResourceMark
-          RC_TRACE_MESG(("adjust: klassname=%s default methods from name=%s",
-                         external_name(),
-                         old_method->method_holder()->external_name()));
+          log_info(redefine, class, update)
+            ("adjust: klassname=%s default methods from name=%s",
+             external_name(), old_method->method_holder()->external_name());
           *trace_name_printed = true;
         }
-        RC_TRACE(0x00100000, ("default method update: %s(%s) ",
-                              new_method->name()->as_C_string(),
-                              new_method->signature()->as_C_string()));
+        log_debug(redefine, class, update, vtables)
+          ("default method update: %s(%s) ",
+           new_method->name()->as_C_string(), new_method->signature()->as_C_string());
       }
     }
   }
@@ -2841,7 +2843,7 @@
   {
     bool have_pv = false;
     // previous versions are linked together through the InstanceKlass
-    for (InstanceKlass* pv_node = _previous_versions;
+    for (InstanceKlass* pv_node = previous_versions();
          pv_node != NULL;
          pv_node = pv_node->previous_versions()) {
       if (!have_pv)
@@ -3011,11 +3013,11 @@
   assert(type == LogLevel::Info || type == LogLevel::Debug, "sanity");
 
   if (type == LogLevel::Info) {
-    log = Log(classload)::info_stream();
+    log = Log(class, load)::info_stream();
   } else {
     assert(type == LogLevel::Debug,
            "print_loading_log supports only Debug and Info levels");
-    log = Log(classload)::debug_stream();
+    log = Log(class, load)::debug_stream();
   }
 
   // Name and class hierarchy info
@@ -3334,7 +3336,7 @@
 }
 #endif
 
-
+#if INCLUDE_JVMTI
 
 // RedefineClasses() support for previous versions:
 int InstanceKlass::_previous_version_count = 0;
@@ -3350,8 +3352,8 @@
     ClassLoaderData* loader_data = ik->class_loader_data();
     assert(loader_data != NULL, "should never be null");
 
-    // RC_TRACE macro has an embedded ResourceMark
-    RC_TRACE(0x00000200, ("purge: %s: previous versions", ik->external_name()));
+    ResourceMark rm;
+    log_trace(redefine, class, iklass, purge)("%s: previous versions", ik->external_name());
 
     // previous versions are linked together through the InstanceKlass
     InstanceKlass* pv_node = ik->previous_versions();
@@ -3369,8 +3371,7 @@
         // are executing.  Unlink this previous_version.
         // The previous version InstanceKlass is on the ClassLoaderData deallocate list
         // so will be deallocated during the next phase of class unloading.
-        RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is dead",
-                              p2i(pv_node)));
+        log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is dead", p2i(pv_node));
         // For debugging purposes.
         pv_node->set_is_scratch_class();
         pv_node->class_loader_data()->add_to_deallocate_list(pv_node);
@@ -3380,8 +3381,7 @@
         version++;
         continue;
       } else {
-        RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is alive",
-                              p2i(pv_node)));
+        log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is alive", p2i(pv_node));
         assert(pvcp->pool_holder() != NULL, "Constant pool with no holder");
         guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack");
         live_count++;
@@ -3393,8 +3393,7 @@
       // longer running.
       Array<Method*>* method_refs = pv_node->methods();
       if (method_refs != NULL) {
-        RC_TRACE(0x00000200, ("purge: previous methods length=%d",
-          method_refs->length()));
+        log_trace(redefine, class, iklass, purge)("previous methods length=%d", method_refs->length());
         for (int j = 0; j < method_refs->length(); j++) {
           Method* method = method_refs->at(j);
 
@@ -3406,11 +3405,9 @@
           } else {
             assert (method->is_obsolete() || method->is_running_emcp(),
                     "emcp method cannot run after emcp bit is cleared");
-            // RC_TRACE macro has an embedded ResourceMark
-            RC_TRACE(0x00000200,
+            log_trace(redefine, class, iklass, purge)
               ("purge: %s(%s): prev method @%d in version @%d is alive",
-              method->name()->as_C_string(),
-              method->signature()->as_C_string(), j, version));
+               method->name()->as_C_string(), method->signature()->as_C_string(), j, version);
           }
         }
       }
@@ -3419,9 +3416,9 @@
       pv_node = pv_node->previous_versions();
       version++;
     }
-    RC_TRACE(0x00000200,
-      ("purge: previous version stats: live=%d, deleted=%d", live_count,
-      deleted_count));
+    log_trace(redefine, class, iklass, purge)
+      ("previous version stats: live=%d, deleted=%d",
+       live_count, deleted_count);
   }
 }
 
@@ -3456,9 +3453,9 @@
                 method->signature() == m_signature) {
               // The current RedefineClasses() call has made all EMCP
               // versions of this method obsolete so mark it as obsolete
-              RC_TRACE(0x00000400,
-                ("add: %s(%s): flush obsolete method @%d in version @%d",
-                m_name->as_C_string(), m_signature->as_C_string(), k, j));
+              log_trace(redefine, class, iklass, add)
+                ("%s(%s): flush obsolete method @%d in version @%d",
+                 m_name->as_C_string(), m_signature->as_C_string(), k, j);
 
               method->set_is_obsolete();
               break;
@@ -3490,9 +3487,9 @@
   assert(Thread::current()->is_VM_thread(),
          "only VMThread can add previous versions");
 
-  // RC_TRACE macro has an embedded ResourceMark
-  RC_TRACE(0x00000400, ("adding previous version ref for %s, EMCP_cnt=%d",
-    scratch_class->external_name(), emcp_method_count));
+  ResourceMark rm;
+  log_trace(redefine, class, iklass, add)
+    ("adding previous version ref for %s, EMCP_cnt=%d", scratch_class->external_name(), emcp_method_count);
 
   // Clean out old previous versions
   purge_previous_versions(this);
@@ -3508,7 +3505,7 @@
   // we don't need to add this as a previous version.
   ConstantPool* cp_ref = scratch_class->constants();
   if (!cp_ref->on_stack()) {
-    RC_TRACE(0x00000400, ("add: scratch class not added; no methods are running"));
+    log_trace(redefine, class, iklass, add)("scratch class not added; no methods are running");
     // For debugging purposes.
     scratch_class->set_is_scratch_class();
     scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class());
@@ -3531,17 +3528,17 @@
         // method may exit.   If so, we would set a breakpoint in a method that
         // is never reached, but this won't be noticeable to the programmer.
         old_method->set_running_emcp(true);
-        RC_TRACE(0x00000400, ("add: EMCP method %s is on_stack " INTPTR_FORMAT,
-                              old_method->name_and_sig_as_C_string(), p2i(old_method)));
+        log_trace(redefine, class, iklass, add)
+          ("EMCP method %s is on_stack " INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method));
       } else if (!old_method->is_obsolete()) {
-        RC_TRACE(0x00000400, ("add: EMCP method %s is NOT on_stack " INTPTR_FORMAT,
-                              old_method->name_and_sig_as_C_string(), p2i(old_method)));
+        log_trace(redefine, class, iklass, add)
+          ("EMCP method %s is NOT on_stack " INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method));
       }
     }
   }
 
   // Add previous version if any methods are still running.
-  RC_TRACE(0x00000400, ("add: scratch class added; one of its methods is on_stack"));
+  log_trace(redefine, class, iklass, add)("scratch class added; one of its methods is on_stack");
   assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version");
   scratch_class->link_previous_versions(previous_versions());
   link_previous_versions(scratch_class());
@@ -3549,6 +3546,7 @@
   _previous_version_count++;
 } // end add_previous_version()
 
+#endif // INCLUDE_JVMTI
 
 Method* InstanceKlass::method_with_idnum(int idnum) {
   Method* m = NULL;
@@ -3598,7 +3596,7 @@
   return method;
 }
 
-
+#if INCLUDE_JVMTI
 jint InstanceKlass::get_cached_class_file_len() {
   return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file);
 }
@@ -3606,3 +3604,4 @@
 unsigned char * InstanceKlass::get_cached_class_file_bytes() {
   return VM_RedefineClasses::get_cached_class_file_bytes(_cached_class_file);
 }
+#endif
diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp
index 768b353..494173b 100644
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp
@@ -27,9 +27,9 @@
 
 #include "classfile/classLoader.hpp"
 #include "classfile/classLoaderData.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/packageEntry.hpp"
 #include "gc/shared/specialized_oop_closures.hpp"
-#include "classfile/moduleEntry.hpp"
 #include "logging/logLevel.hpp"
 #include "memory/referenceType.hpp"
 #include "oops/annotations.hpp"
@@ -57,7 +57,9 @@
 
 
 // forward declaration for class -- see below for definition
+#if INCLUDE_JVMTI
 class BreakpointInfo;
+#endif
 class ClassFileParser;
 class KlassDepChange;
 class DependencyContext;
@@ -188,6 +190,7 @@
   // _is_marked_dependent can be set concurrently, thus cannot be part of the
   // _misc_flags.
   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
+  bool            _is_being_redefined;   // used for locking redefinition
 
   // The low two bits of _misc_flags contains the kind field.
   // This can be used to quickly discriminate among the four kinds of
@@ -230,12 +233,14 @@
   jmethodID*      _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
   intptr_t        _dep_context;          // packed DependencyContext structure
   nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
+#if INCLUDE_JVMTI
   BreakpointInfo* _breakpoints;          // bpt lists, managed by Method*
   // Linked instanceKlasses of previous versions
   InstanceKlass* _previous_versions;
   // JVMTI fields can be moved to their own structure - see 6315920
   // JVMTI: cached class file, before retransformable agent modified it in CFLH
   JvmtiCachedClassFileData* _cached_class_file;
+#endif
 
   volatile u2     _idnum_allocated_count;         // JNI/JVMTI: increments with the addition of methods, old ids don't change
 
@@ -245,7 +250,9 @@
   u1              _init_state;                    // state of class
   u1              _reference_type;                // reference type
 
+#if INCLUDE_JVMTI
   JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map;  // JVMTI: used during heap iteration
+#endif
 
   NOT_PRODUCT(int _verify_count;)  // to avoid redundant verifies
 
@@ -315,7 +322,7 @@
     return (_misc_flags & _misc_is_shared_app_class) != 0;
   }
 
-  void set_class_loader_type(jshort loader_type) {
+  void set_class_loader_type(s2 loader_type) {
     assert(( _misc_flags & loader_type_bits()) == 0,
            "Should only be called once for each class.");
     switch (loader_type) {
@@ -687,10 +694,18 @@
     _nonstatic_oop_map_size = words;
   }
 
+#if INCLUDE_JVMTI
+  // Redefinition locking.  Class can only be redefined by one thread at a time.
+  bool is_being_redefined() const          { return _is_being_redefined; }
+  void set_is_being_redefined(bool value)  { _is_being_redefined = value; }
+
   // RedefineClasses() support for previous versions:
   void add_previous_version(instanceKlassHandle ikh, int emcp_method_count);
 
   InstanceKlass* previous_versions() const { return _previous_versions; }
+#else
+  InstanceKlass* previous_versions() const { return NULL; }
+#endif
 
   InstanceKlass* get_klass_version(int version) {
     for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) {
@@ -738,6 +753,8 @@
   bool is_mirror_instance_klass() const       { return is_kind(_misc_kind_mirror); }
   bool is_class_loader_instance_klass() const { return is_kind(_misc_kind_class_loader); }
 
+#if INCLUDE_JVMTI
+
   void init_previous_versions() {
     _previous_versions = NULL;
   }
@@ -764,6 +781,16 @@
     return _jvmti_cached_class_field_map;
   }
 
+#else // INCLUDE_JVMTI
+
+  static void purge_previous_versions(InstanceKlass* ik) { return; };
+  static bool has_previous_versions() { return false; }
+
+  void set_cached_class_file(JvmtiCachedClassFileData *data) { ShouldNotReachHere(); }
+  JvmtiCachedClassFileData * get_cached_class_file() { return (JvmtiCachedClassFileData *)NULL; }
+
+#endif // INCLUDE_JVMTI
+
   bool has_default_methods() const {
     return (_misc_flags & _misc_has_default_methods) != 0;
   }
@@ -882,9 +909,11 @@
   int mark_osr_nmethods(const Method* m);
   nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const;
 
+#if INCLUDE_JVMTI
   // Breakpoint support (see methods on Method* for details)
   BreakpointInfo* breakpoints() const       { return _breakpoints; };
   void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; };
+#endif
 
   // support for stub routines
   static ByteSize init_state_offset()  { return in_ByteSize(offset_of(InstanceKlass, _init_state)); }
@@ -1253,9 +1282,11 @@
   // Free CHeap allocated fields.
   void release_C_heap_structures();
 
+#if INCLUDE_JVMTI
   // RedefineClasses support
   void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }
   void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);
+#endif
 public:
   // CDS support - remove and restore oops from metadata. Oops are not shared.
   virtual void remove_unshareable_info();
diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp
index 8e32678..d31e9e5 100644
--- a/hotspot/src/share/vm/oops/klass.cpp
+++ b/hotspot/src/share/vm/oops/klass.cpp
@@ -401,9 +401,9 @@
     Klass* sub = current->subklass();
     while (sub != NULL && !sub->is_loader_alive(is_alive)) {
 #ifndef PRODUCT
-      if (log_is_enabled(Trace, classunload)) {
+      if (log_is_enabled(Trace, class, unload)) {
         ResourceMark rm;
-        log_trace(classunload)("unlinking class (subclass): %s", sub->external_name());
+        log_trace(class, unload)("unlinking class (subclass): %s", sub->external_name());
       }
 #endif
       sub = sub->next_sibling();
@@ -416,9 +416,9 @@
     // Find and set the first alive sibling
     Klass* sibling = current->next_sibling();
     while (sibling != NULL && !sibling->is_loader_alive(is_alive)) {
-      if (log_is_enabled(Trace, classunload)) {
+      if (log_is_enabled(Trace, class, unload)) {
         ResourceMark rm;
-        log_trace(classunload)("[Unlinking class (sibling) %s]", sibling->external_name());
+        log_trace(class, unload)("[Unlinking class (sibling) %s]", sibling->external_name());
       }
       sibling = sibling->next_sibling();
     }
diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp
index 14675aa..b6181d4 100644
--- a/hotspot/src/share/vm/oops/klass.hpp
+++ b/hotspot/src/share/vm/oops/klass.hpp
@@ -52,11 +52,13 @@
 template <class T> class Array;
 template <class T> class GrowableArray;
 class ClassLoaderData;
+class fieldDescriptor;
+class KlassSizeStats;
 class klassVtable;
+class ModuleEntry;
+class PackageEntry;
 class ParCompactionManager;
 class PSPromotionManager;
-class KlassSizeStats;
-class fieldDescriptor;
 class vtableEntry;
 
 class Klass : public Metadata {
@@ -274,6 +276,9 @@
     _shared_class_path_index = index;
   };
 
+  // Obtain the module or package for this class
+  virtual ModuleEntry* module() const = 0;
+  virtual PackageEntry* package() const = 0;
 
  protected:                                // internal accessors
   void     set_subklass(Klass* s);
diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp
index af4bde9..6d0c895 100644
--- a/hotspot/src/share/vm/oops/klassVtable.cpp
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp
@@ -34,7 +34,6 @@
 #include "oops/method.hpp"
 #include "oops/objArrayOop.hpp"
 #include "oops/oop.inline.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/handles.inline.hpp"
 #include "utilities/copy.hpp"
@@ -887,19 +886,17 @@
       updated_default = adjust_default_method(index, old_method, new_method);
     }
 
-    if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
+    if (log_is_enabled(Info, redefine, class, update)) {
+      ResourceMark rm;
       if (!(*trace_name_printed)) {
-        // RC_TRACE_MESG macro has an embedded ResourceMark
-        RC_TRACE_MESG(("adjust: klassname=%s for methods from name=%s",
-                       klass()->external_name(),
-                       old_method->method_holder()->external_name()));
+        log_info(redefine, class, update)
+          ("adjust: klassname=%s for methods from name=%s",
+           klass()->external_name(), old_method->method_holder()->external_name());
         *trace_name_printed = true;
       }
-      // RC_TRACE macro has an embedded ResourceMark
-      RC_TRACE(0x00100000, ("vtable method update: %s(%s), updated default = %s",
-                            new_method->name()->as_C_string(),
-                            new_method->signature()->as_C_string(),
-                            updated_default ? "true" : "false"));
+      log_debug(redefine, class, update, vtables)
+        ("vtable method update: %s(%s), updated default = %s",
+         new_method->name()->as_C_string(), new_method->signature()->as_C_string(), updated_default ? "true" : "false");
     }
   }
 }
@@ -1205,17 +1202,14 @@
 
     ime->initialize(new_method);
 
-    if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
+    if (log_is_enabled(Info, redefine, class, update)) {
+      ResourceMark rm;
       if (!(*trace_name_printed)) {
-        // RC_TRACE_MESG macro has an embedded ResourceMark
-        RC_TRACE_MESG(("adjust: name=%s",
-          old_method->method_holder()->external_name()));
+        log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
         *trace_name_printed = true;
       }
-      // RC_TRACE macro has an embedded ResourceMark
-      RC_TRACE(0x00200000, ("itable method update: %s(%s)",
-        new_method->name()->as_C_string(),
-        new_method->signature()->as_C_string()));
+      log_trace(redefine, class, update, itables)
+        ("itable method update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string());
     }
   }
 }
diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp
index 3491bda..8e7f9c8 100644
--- a/hotspot/src/share/vm/oops/method.cpp
+++ b/hotspot/src/share/vm/oops/method.cpp
@@ -737,7 +737,7 @@
   // This function can be called more than once. We must make sure that we always
   // use the latest registered method -> check if a stub already has been generated.
   // If so, we have to make it not_entrant.
-  nmethod* nm = code(); // Put it into local variable to guard against concurrent updates
+  CompiledMethod* nm = code(); // Put it into local variable to guard against concurrent updates
   if (nm != NULL) {
     nm->make_not_entrant();
   }
@@ -1037,12 +1037,12 @@
 // Not inline to avoid circular ref.
 bool Method::check_code() const {
   // cached in a register or local.  There's a race on the value of the field.
-  nmethod *code = (nmethod *)OrderAccess::load_ptr_acquire(&_code);
+  CompiledMethod *code = (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code);
   return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
 }
 
 // Install compiled code.  Instantly it can execute.
-void Method::set_code(methodHandle mh, nmethod *code) {
+void Method::set_code(methodHandle mh, CompiledMethod *code) {
   assert( code, "use clear_code to remove code" );
   assert( mh->check_code(), "" );
 
@@ -1628,6 +1628,7 @@
   return true;
 }
 
+#if INCLUDE_JVMTI
 
 Bytecodes::Code Method::orig_bytecode_at(int bci) const {
   BreakpointInfo* bp = method_holder()->breakpoints();
@@ -1708,6 +1709,7 @@
   clear_matches(this, -1);
 }
 
+#endif // INCLUDE_JVMTI
 
 int Method::invocation_count() {
   MethodCounters *mcs = method_counters();
@@ -1773,6 +1775,8 @@
   }
 }
 
+#if INCLUDE_JVMTI
+
 BreakpointInfo::BreakpointInfo(Method* m, int bci) {
   _bci = bci;
   _name_index = m->name_index();
@@ -1810,6 +1814,8 @@
   method->decr_number_of_breakpoints(Thread::current());
 }
 
+#endif // INCLUDE_JVMTI
+
 // jmethodID handling
 
 // This is a block allocating object, sort of like JNIHandleBlock, only a
diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp
index 264a07d..6b852d3 100644
--- a/hotspot/src/share/vm/oops/method.hpp
+++ b/hotspot/src/share/vm/oops/method.hpp
@@ -58,6 +58,7 @@
 class ConstMethod;
 class InlineTableSizes;
 class KlassSizeStats;
+class CompiledMethod;
 
 class Method : public Metadata {
  friend class VMStructs;
@@ -98,7 +99,7 @@
   // field can come and go.  It can transition from NULL to not-null at any
   // time (whenever a compile completes).  It can transition from not-null to
   // NULL only at safepoints (because of a de-opt).
-  nmethod* volatile _code;                       // Points to the corresponding piece of native code
+  CompiledMethod* volatile _code;                       // Points to the corresponding piece of native code
   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 
   // Constructor
@@ -187,8 +188,18 @@
   }
 
   // JVMTI breakpoints
+#if !INCLUDE_JVMTI
+  Bytecodes::Code orig_bytecode_at(int bci) const {
+    ShouldNotReachHere();
+    return Bytecodes::_shouldnotreachhere;
+  }
+  void set_orig_bytecode_at(int bci, Bytecodes::Code code) {
+    ShouldNotReachHere();
+  };
+  u2   number_of_breakpoints() const {return 0;}
+#else // !INCLUDE_JVMTI
   Bytecodes::Code orig_bytecode_at(int bci) const;
-  void        set_orig_bytecode_at(int bci, Bytecodes::Code code);
+  void set_orig_bytecode_at(int bci, Bytecodes::Code code);
   void set_breakpoint(int bci);
   void clear_breakpoint(int bci);
   void clear_all_breakpoints();
@@ -221,6 +232,7 @@
       mcs->clear_number_of_breakpoints();
     }
   }
+#endif // !INCLUDE_JVMTI
 
   // index into InstanceKlass methods() array
   // note: also used by jfr
@@ -423,9 +435,9 @@
   // nmethod/verified compiler entry
   address verified_code_entry();
   bool check_code() const;      // Not inline to avoid circular ref
-  nmethod* volatile code() const                 { assert( check_code(), "" ); return (nmethod *)OrderAccess::load_ptr_acquire(&_code); }
+  CompiledMethod* volatile code() const                 { assert( check_code(), "" ); return (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code); }
   void clear_code();            // Clear out any compiled code
-  static void set_code(methodHandle mh, nmethod* code);
+  static void set_code(methodHandle mh, CompiledMethod* code);
   void set_adapter_entry(AdapterHandlerEntry* adapter) {
     constMethod()->set_adapter_entry(adapter);
   }
@@ -1034,6 +1046,8 @@
 };
 
 
+#if INCLUDE_JVMTI
+
 /// Fast Breakpoints.
 
 // If this structure gets more complicated (because bpts get numerous),
@@ -1078,6 +1092,8 @@
   void clear(Method* method);
 };
 
+#endif // INCLUDE_JVMTI
+
 // Utility class for access exception handlers
 class ExceptionTable : public StackObj {
  private:
diff --git a/hotspot/src/share/vm/oops/methodCounters.hpp b/hotspot/src/share/vm/oops/methodCounters.hpp
index a0b96b6..2a06ab6 100644
--- a/hotspot/src/share/vm/oops/methodCounters.hpp
+++ b/hotspot/src/share/vm/oops/methodCounters.hpp
@@ -38,7 +38,9 @@
   int               _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
 #endif
+#if INCLUDE_JVMTI
   u2                _number_of_breakpoints;      // fullspeed debugging support
+#endif
   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
   // NMethod age is a counter for warm methods detection in the code cache sweeper.
@@ -62,8 +64,7 @@
   u1                _highest_osr_comp_level;      // Same for OSR level
 #endif
 
-  MethodCounters(methodHandle mh) : _number_of_breakpoints(0),
-                                    _nmethod_age(INT_MAX)
+  MethodCounters(methodHandle mh) : _nmethod_age(INT_MAX)
 #ifdef TIERED
                                  , _rate(0),
                                    _prev_time(0),
@@ -73,6 +74,7 @@
   {
     set_interpreter_invocation_count(0);
     set_interpreter_throwout_count(0);
+    JVMTI_ONLY(clear_number_of_breakpoints());
     invocation_counter()->init();
     backedge_counter()->init();
 
@@ -153,10 +155,12 @@
 
 #endif // defined(COMPILER2) || INCLUDE_JVMCI
 
+#if INCLUDE_JVMTI
   u2   number_of_breakpoints() const   { return _number_of_breakpoints; }
   void incr_number_of_breakpoints()    { ++_number_of_breakpoints; }
   void decr_number_of_breakpoints()    { --_number_of_breakpoints; }
   void clear_number_of_breakpoints()   { _number_of_breakpoints = 0; }
+#endif
 
 #ifdef TIERED
   jlong prev_time() const                        { return _prev_time; }
diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp
index 7f09047..1abcc15 100644
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp
@@ -23,6 +23,8 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -135,14 +137,7 @@
   // GC walks these as strong roots.
   loader_data->add_class(oak);
 
-  // The array is defined in the module of its bottom class
-  Klass* bottom_klass = oak->bottom_klass();
-  ModuleEntry* module;
-  if (bottom_klass->is_instance_klass()) {
-    module = InstanceKlass::cast(bottom_klass)->module();
-  } else {
-    module = ModuleEntryTable::javabase_module();
-  }
+  ModuleEntry* module = oak->module();
   assert(module != NULL, "No module entry for array");
 
   // Call complete_create_array_klass after all instance variables has been initialized.
@@ -422,6 +417,16 @@
                         | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
 }
 
+ModuleEntry* ObjArrayKlass::module() const {
+  assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
+  // The array is defined in the module of its bottom class
+  return bottom_klass()->module();
+}
+
+PackageEntry* ObjArrayKlass::package() const {
+  assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
+  return bottom_klass()->package();
+}
 
 // Printing
 
diff --git a/hotspot/src/share/vm/oops/objArrayKlass.hpp b/hotspot/src/share/vm/oops/objArrayKlass.hpp
index eabbec5..c2d1f79 100644
--- a/hotspot/src/share/vm/oops/objArrayKlass.hpp
+++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp
@@ -54,6 +54,9 @@
   void set_bottom_klass(Klass* k)   { _bottom_klass = k; }
   Klass** bottom_klass_addr()       { return &_bottom_klass; }
 
+  ModuleEntry* module() const;
+  PackageEntry* package() const;
+
   // Compiler/Interpreter offset
   static ByteSize element_klass_offset() { return in_ByteSize(offset_of(ObjArrayKlass, _element_klass)); }
 
diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.cpp b/hotspot/src/share/vm/oops/typeArrayKlass.cpp
index 3fa9770..76b2bb8 100644
--- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp
+++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -341,3 +343,12 @@
 const char* TypeArrayKlass::internal_name() const {
   return Klass::external_name();
 }
+
+// A TypeArrayKlass is an array of a primitive type, its defining module is java.base
+ModuleEntry* TypeArrayKlass::module() const {
+  return ModuleEntryTable::javabase_module();
+}
+
+PackageEntry* TypeArrayKlass::package() const {
+  return NULL;
+}
diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.hpp b/hotspot/src/share/vm/oops/typeArrayKlass.hpp
index 7f07e4f..031afe8 100644
--- a/hotspot/src/share/vm/oops/typeArrayKlass.hpp
+++ b/hotspot/src/share/vm/oops/typeArrayKlass.hpp
@@ -150,6 +150,9 @@
 
  public:
   const char* internal_name() const;
+
+  ModuleEntry* module() const;
+  PackageEntry* package() const;
 };
 
 #endif // SHARE_VM_OOPS_TYPEARRAYKLASS_HPP
diff --git a/hotspot/src/share/vm/opto/block.cpp b/hotspot/src/share/vm/opto/block.cpp
index 2dbd3e4..bc3d772 100644
--- a/hotspot/src/share/vm/opto/block.cpp
+++ b/hotspot/src/share/vm/opto/block.cpp
@@ -73,7 +73,7 @@
 }
 #endif
 
-uint Block::code_alignment() {
+uint Block::code_alignment() const {
   // Check for Root block
   if (_pre_order == 0) return CodeEntryAlignment;
   // Check for Start block
@@ -1727,8 +1727,14 @@
     first_block()->set_loop_alignment(targ_block);
 
   } else {
-    // Backbranch into the middle of a trace
-    targ_block->set_loop_alignment(targ_block);
+    // That loop may already have a loop top (we're reaching it again
+    // through the backedge of an outer loop)
+    Block* b = prev(targ_block);
+    bool has_top = targ_block->head()->is_Loop() && b->has_loop_alignment() && !b->head()->is_Loop();
+    if (!has_top) {
+      // Backbranch into the middle of a trace
+      targ_block->set_loop_alignment(targ_block);
+    }
   }
 
   return loop_rotated;
diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp
index d7aa5bb..e1d4874 100644
--- a/hotspot/src/share/vm/opto/block.hpp
+++ b/hotspot/src/share/vm/opto/block.hpp
@@ -197,7 +197,7 @@
 
   // Report the alignment required by this block.  Must be a power of 2.
   // The previous block will insert nops to get this alignment.
-  uint code_alignment();
+  uint code_alignment() const;
   uint compute_loop_alignment();
 
   // BLOCK_FREQUENCY is a sentinel to mark uses of constant block frequencies.
diff --git a/hotspot/src/share/vm/opto/c2_globals.cpp b/hotspot/src/share/vm/opto/c2_globals.cpp
index 16cdfa7..d0a1bae 100644
--- a/hotspot/src/share/vm/opto/c2_globals.cpp
+++ b/hotspot/src/share/vm/opto/c2_globals.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,5 @@
          MATERIALIZE_EXPERIMENTAL_FLAG, \
          MATERIALIZE_NOTPRODUCT_FLAG, \
          IGNORE_RANGE, \
-         IGNORE_CONSTRAINT)
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp
index ca02fd2..9b27630 100644
--- a/hotspot/src/share/vm/opto/c2_globals.hpp
+++ b/hotspot/src/share/vm/opto/c2_globals.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,16 @@
 // Defines all globals flags used by the server compiler.
 //
 
-#define C2_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, range, constraint) \
+#define C2_FLAGS(develop, \
+                 develop_pd, \
+                 product, \
+                 product_pd, \
+                 diagnostic, \
+                 experimental, \
+                 notproduct, \
+                 range, \
+                 constraint, \
+                 writeable) \
                                                                             \
   develop(bool, StressLCM, false,                                           \
           "Randomize instruction scheduling in LCM")                        \
@@ -587,28 +596,28 @@
           range(0, 100)                                                     \
                                                                             \
   product(bool, BlockLayoutRotateLoops, true,                               \
-          "Allow back branches to be fall throughs in the block layour")    \
+          "Allow back branches to be fall throughs in the block layout")    \
                                                                             \
-  develop(bool, InlineReflectionGetCallerClass, true,                       \
+  diagnostic(bool, InlineReflectionGetCallerClass, true,                    \
           "inline sun.reflect.Reflection.getCallerClass(), known to be "    \
           "part of base library DLL")                                       \
                                                                             \
-  develop(bool, InlineObjectCopy, true,                                     \
+  diagnostic(bool, InlineObjectCopy, true,                                  \
           "inline Object.clone and Arrays.copyOf[Range] intrinsics")        \
                                                                             \
-  develop(bool, SpecialStringCompareTo, true,                               \
+  diagnostic(bool, SpecialStringCompareTo, true,                            \
           "special version of string compareTo")                            \
                                                                             \
-  develop(bool, SpecialStringIndexOf, true,                                 \
+  diagnostic(bool, SpecialStringIndexOf, true,                              \
           "special version of string indexOf")                              \
                                                                             \
-  develop(bool, SpecialStringEquals, true,                                  \
+  diagnostic(bool, SpecialStringEquals, true,                               \
           "special version of string equals")                               \
                                                                             \
-  develop(bool, SpecialArraysEquals, true,                                  \
+  diagnostic(bool, SpecialArraysEquals, true,                               \
           "special version of Arrays.equals(char[],char[])")                \
                                                                             \
-  product(bool, SpecialEncodeISOArray, true,                                \
+  diagnostic(bool, SpecialEncodeISOArray, true,                             \
           "special version of ISO_8859_1$Encoder.encodeISOArray")           \
                                                                             \
   develop(bool, BailoutToInterpreterForThrows, false,                       \
@@ -710,22 +719,22 @@
   diagnostic(bool, OptimizeExpensiveOps, true,                              \
           "Find best control for expensive operations")                     \
                                                                             \
-  product(bool, UseMathExactIntrinsics, true,                               \
+  diagnostic(bool, UseMathExactIntrinsics, true,                            \
           "Enables intrinsification of various java.lang.Math functions")   \
                                                                             \
-  product(bool, UseMultiplyToLenIntrinsic, false,                           \
+  diagnostic(bool, UseMultiplyToLenIntrinsic, false,                        \
           "Enables intrinsification of BigInteger.multiplyToLen()")         \
                                                                             \
-  product(bool, UseSquareToLenIntrinsic, false,                             \
+  diagnostic(bool, UseSquareToLenIntrinsic, false,                          \
           "Enables intrinsification of BigInteger.squareToLen()")           \
                                                                             \
-  product(bool, UseMulAddIntrinsic, false,                                  \
+  diagnostic(bool, UseMulAddIntrinsic, false,                               \
           "Enables intrinsification of BigInteger.mulAdd()")                \
                                                                             \
-  product(bool, UseMontgomeryMultiplyIntrinsic, false,                      \
+  diagnostic(bool, UseMontgomeryMultiplyIntrinsic, false,                   \
           "Enables intrinsification of BigInteger.montgomeryMultiply()")    \
                                                                             \
-  product(bool, UseMontgomerySquareIntrinsic, false,                        \
+  diagnostic(bool, UseMontgomerySquareIntrinsic, false,                     \
           "Enables intrinsification of BigInteger.montgomerySquare()")      \
                                                                             \
   product(bool, UseTypeSpeculation, true,                                   \
@@ -758,6 +767,7 @@
          DECLARE_EXPERIMENTAL_FLAG, \
          DECLARE_NOTPRODUCT_FLAG, \
          IGNORE_RANGE, \
-         IGNORE_CONSTRAINT)
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
 
 #endif // SHARE_VM_OPTO_C2_GLOBALS_HPP
diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp
index a93742f..a91b1c2 100644
--- a/hotspot/src/share/vm/opto/c2compiler.cpp
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -361,6 +361,9 @@
   case vmIntrinsics::_getCallerClass:
     if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return false;
     break;
+  case vmIntrinsics::_onSpinWait:
+    if (!Matcher::match_rule_supported(Op_OnSpinWait)) return false;
+    break;
   case vmIntrinsics::_hashCode:
   case vmIntrinsics::_identityHashCode:
   case vmIntrinsics::_getClass:
@@ -406,22 +409,6 @@
   case vmIntrinsics::_putLong:
   case vmIntrinsics::_putFloat:
   case vmIntrinsics::_putDouble:
-  case vmIntrinsics::_getByte_raw:
-  case vmIntrinsics::_getShort_raw:
-  case vmIntrinsics::_getChar_raw:
-  case vmIntrinsics::_getInt_raw:
-  case vmIntrinsics::_getLong_raw:
-  case vmIntrinsics::_getFloat_raw:
-  case vmIntrinsics::_getDouble_raw:
-  case vmIntrinsics::_getAddress_raw:
-  case vmIntrinsics::_putByte_raw:
-  case vmIntrinsics::_putShort_raw:
-  case vmIntrinsics::_putChar_raw:
-  case vmIntrinsics::_putInt_raw:
-  case vmIntrinsics::_putLong_raw:
-  case vmIntrinsics::_putFloat_raw:
-  case vmIntrinsics::_putDouble_raw:
-  case vmIntrinsics::_putAddress_raw:
   case vmIntrinsics::_getObjectVolatile:
   case vmIntrinsics::_getBooleanVolatile:
   case vmIntrinsics::_getByteVolatile:
@@ -542,7 +529,7 @@
   case vmIntrinsics::_updateByteBufferAdler32:
   case vmIntrinsics::_profileBoolean:
   case vmIntrinsics::_isCompileConstant:
-  case vmIntrinsics::_Objects_checkIndex:
+  case vmIntrinsics::_Preconditions_checkIndex:
     break;
   default:
     return false;
diff --git a/hotspot/src/share/vm/opto/cfgnode.cpp b/hotspot/src/share/vm/opto/cfgnode.cpp
index 25e34e5..594ffd2 100644
--- a/hotspot/src/share/vm/opto/cfgnode.cpp
+++ b/hotspot/src/share/vm/opto/cfgnode.cpp
@@ -1703,16 +1703,19 @@
     }
 
     if (uncasted) {
-      // Wait until after parsing for the type information to propagate from the casts
+      // Add a cast node between the phi to be removed and its unique input.
+      // Wait until after parsing for the type information to propagate from the casts.
       assert(can_reshape, "Invalid during parsing");
       const Type* phi_type = bottom_type();
       assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
       int opcode;
+      // Determine the type of cast to be added.
       if (phi_type->isa_int()) {
         opcode = Op_CastII;
       } else {
         const Type* uin_type = phase->type(uin);
-        if (phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) {
+        if ((phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) ||
+            (!phi_type->isa_oopptr() && !uin_type->isa_oopptr())) {
           opcode = Op_CastPP;
         } else {
           opcode = Op_CheckCastPP;
diff --git a/hotspot/src/share/vm/opto/classes.hpp b/hotspot/src/share/vm/opto/classes.hpp
index ee36282..790f4f4 100644
--- a/hotspot/src/share/vm/opto/classes.hpp
+++ b/hotspot/src/share/vm/opto/classes.hpp
@@ -171,7 +171,6 @@
 macro(LoadRange)
 macro(LoadS)
 macro(Lock)
-macro(Log10D)
 macro(Loop)
 macro(LoopLimit)
 macro(Mach)
@@ -179,6 +178,7 @@
 macro(MaxI)
 macro(MemBarAcquire)
 macro(LoadFence)
+macro(SetVectMaskI)
 macro(MemBarAcquireLock)
 macro(MemBarCPUOrder)
 macro(MemBarRelease)
@@ -205,6 +205,7 @@
 macro(NegD)
 macro(NegF)
 macro(NeverBranch)
+macro(OnSpinWait)
 macro(Opaque1)
 macro(Opaque2)
 macro(Opaque3)
@@ -264,7 +265,6 @@
 macro(SubL)
 macro(TailCall)
 macro(TailJump)
-macro(TanD)
 macro(ThreadLocal)
 macro(Unlock)
 macro(URShiftI)
diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp
index cd212ea..5e1e50e 100644
--- a/hotspot/src/share/vm/opto/compile.cpp
+++ b/hotspot/src/share/vm/opto/compile.cpp
@@ -565,7 +565,7 @@
   relocInfo* locs_buf = scratch_locs_memory();
   address blob_begin = blob->content_begin();
   address blob_end   = (address)locs_buf;
-  assert(blob->content_contains(blob_end), "sanity");
+  assert(blob->contains(blob_end), "sanity");
   CodeBuffer buf(blob_begin, blob_end - blob_begin);
   buf.initialize_consts_size(_scratch_const_size);
   buf.initialize_stubs_size(MAX_stubs_size);
@@ -1623,6 +1623,17 @@
   }
 }
 
+BasicType Compile::AliasType::basic_type() const {
+  if (element() != NULL) {
+    const Type* element = adr_type()->is_aryptr()->elem();
+    return element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type();
+  } if (field() != NULL) {
+    return field()->layout_type();
+  } else {
+    return T_ILLEGAL; // unknown
+  }
+}
+
 //---------------------------------print_on------------------------------------
 #ifndef PRODUCT
 void Compile::AliasType::print_on(outputStream* st) {
@@ -2835,7 +2846,7 @@
     assert( !addp->is_AddP() ||
             addp->in(AddPNode::Base)->is_top() || // Top OK for allocation
             addp->in(AddPNode::Base) == n->in(AddPNode::Base),
-            "Base pointers must match" );
+            "Base pointers must match (addp %u)", addp->_idx );
 #ifdef _LP64
     if ((UseCompressedOops || UseCompressedClassPointers) &&
         addp->Opcode() == Op_ConP &&
@@ -2870,6 +2881,21 @@
           } else {
             nn = new DecodeNKlassNode(nn, t);
           }
+          // Check for succeeding AddP which uses the same Base.
+          // Otherwise we will run into the assertion above when visiting that guy.
+          for (uint i = 0; i < n->outcnt(); ++i) {
+            Node *out_i = n->raw_out(i);
+            if (out_i && out_i->is_AddP() && out_i->in(AddPNode::Base) == addp) {
+              out_i->set_req(AddPNode::Base, nn);
+#ifdef ASSERT
+              for (uint j = 0; j < out_i->outcnt(); ++j) {
+                Node *out_j = out_i->raw_out(j);
+                assert(out_j == NULL || !out_j->is_AddP() || out_j->in(AddPNode::Base) != addp,
+                       "more than 2 AddP nodes in a chain (out_j %u)", out_j->_idx);
+              }
+#endif
+            }
+          }
           n->set_req(AddPNode::Base, nn);
           n->set_req(AddPNode::Address, nn);
           if (addp->outcnt() == 0) {
@@ -2879,6 +2905,8 @@
       }
     }
 #endif
+    // platform dependent reshaping of the address expression
+    reshape_address(n->as_AddP());
     break;
   }
 
@@ -3237,6 +3265,43 @@
     frc._tests.push(iff);
     break;
   }
+  case Op_ConvI2L: {
+    if (!Matcher::convi2l_type_required) {
+      // Code generation on some platforms doesn't need accurate
+      // ConvI2L types. Widening the type can help remove redundant
+      // address computations.
+      n->as_Type()->set_type(TypeLong::INT);
+      ResourceMark rm;
+      Node_List wq;
+      wq.push(n);
+      for (uint next = 0; next < wq.size(); next++) {
+        Node *m = wq.at(next);
+
+        for(;;) {
+          // Loop over all nodes with identical inputs edges as m
+          Node* k = m->find_similar(m->Opcode());
+          if (k == NULL) {
+            break;
+          }
+          // Push their uses so we get a chance to remove node made
+          // redundant
+          for (DUIterator_Fast imax, i = k->fast_outs(imax); i < imax; i++) {
+            Node* u = k->fast_out(i);
+            assert(!wq.contains(u), "shouldn't process one node several times");
+            if (u->Opcode() == Op_LShiftL ||
+                u->Opcode() == Op_AddL ||
+                u->Opcode() == Op_SubL ||
+                u->Opcode() == Op_AddP) {
+              wq.push(u);
+            }
+          }
+          // Replace all nodes with identical edges as m with m
+          k->subsume_by(m, this);
+        }
+      }
+    }
+    break;
+  }
   default:
     assert( !n->is_Call(), "" );
     assert( !n->is_Mem(), "" );
diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp
index 7076f4a..f8743d8 100644
--- a/hotspot/src/share/vm/opto/compile.hpp
+++ b/hotspot/src/share/vm/opto/compile.hpp
@@ -44,6 +44,7 @@
 #include "trace/tracing.hpp"
 #include "utilities/ticks.hpp"
 
+class AddPNode;
 class Block;
 class Bundle;
 class C2Compiler;
@@ -213,6 +214,8 @@
       _element = e;
     }
 
+    BasicType basic_type() const;
+
     void print_on(outputStream* st) PRODUCT_RETURN;
   };
 
@@ -577,6 +580,8 @@
   int                   _scratch_const_size;    // For temporary code buffers.
   bool                  _in_scratch_emit_size;  // true when in scratch_emit_size.
 
+  void reshape_address(AddPNode* n);
+
  public:
   // Accessors
 
@@ -1099,7 +1104,7 @@
   int               code_size()                 { return _method_size; }
   CodeBuffer*       code_buffer()               { return &_code_buffer; }
   int               first_block_size()          { return _first_block_size; }
-  void              set_frame_complete(int off) { _code_offsets.set_value(CodeOffsets::Frame_Complete, off); }
+  void              set_frame_complete(int off) { if (!in_scratch_emit_size()) { _code_offsets.set_value(CodeOffsets::Frame_Complete, off); } }
   ExceptionHandlerTable*  handler_table()       { return &_handler_table; }
   ImplicitExceptionTable* inc_table()           { return &_inc_table; }
   OopMapSet*        oop_map_set()               { return _oop_map_set; }
diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp
index a9f1cd1..9350074 100644
--- a/hotspot/src/share/vm/opto/graphKit.cpp
+++ b/hotspot/src/share/vm/opto/graphKit.cpp
@@ -4467,6 +4467,25 @@
   set_memory(st, TypeAryPtr::BYTES);
 }
 
+Node* GraphKit::make_constant_from_field(ciField* field, Node* obj) {
+  if (!field->is_constant()) {
+    return NULL; // Field not marked as constant.
+  }
+  ciInstance* holder = NULL;
+  if (!field->is_static()) {
+    ciObject* const_oop = obj->bottom_type()->is_oopptr()->const_oop();
+    if (const_oop != NULL && const_oop->is_instance()) {
+      holder = const_oop->as_instance();
+    }
+  }
+  const Type* con_type = Type::make_constant_from_field(field, holder, field->layout_type(),
+                                                        /*is_unsigned_load=*/false);
+  if (con_type != NULL) {
+    return makecon(con_type);
+  }
+  return NULL;
+}
+
 Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) {
   // Reify the property as a CastPP node in Ideal graph to comply with monotonicity
   // assumption of CCP analysis.
diff --git a/hotspot/src/share/vm/opto/graphKit.hpp b/hotspot/src/share/vm/opto/graphKit.hpp
index 218e937..797705d 100644
--- a/hotspot/src/share/vm/opto/graphKit.hpp
+++ b/hotspot/src/share/vm/opto/graphKit.hpp
@@ -910,6 +910,8 @@
   void add_predicate(int nargs = 0);
   void add_predicate_impl(Deoptimization::DeoptReason reason, int nargs);
 
+  Node* make_constant_from_field(ciField* field, Node* obj);
+
   // Produce new array node of stable type
   Node* cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type);
 };
diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp
index 13d153c..5c14d3a 100644
--- a/hotspot/src/share/vm/opto/library_call.cpp
+++ b/hotspot/src/share/vm/opto/library_call.cpp
@@ -93,7 +93,7 @@
   Node*             _result;        // the result node, if any
   int               _reexecute_sp;  // the stack pointer when bytecode needs to be reexecuted
 
-  const TypeOopPtr* sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr = false);
+  const TypeOopPtr* sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type);
 
  public:
   LibraryCallKit(JVMState* jvms, LibraryIntrinsic* intrinsic)
@@ -247,7 +247,7 @@
   void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar);
 
   typedef enum { Relaxed, Opaque, Volatile, Acquire, Release } AccessKind;
-  bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, AccessKind kind, bool is_unaligned);
+  bool inline_unsafe_access(bool is_store, BasicType type, AccessKind kind, bool is_unaligned);
   static bool klass_needs_init_guard(Node* kls);
   bool inline_unsafe_allocate();
   bool inline_unsafe_newArray(bool uninitialized);
@@ -261,7 +261,7 @@
   bool inline_native_getLength();
   bool inline_array_copyOf(bool is_copyOfRange);
   bool inline_array_equals(StrIntrinsicNode::ArgEnc ae);
-  bool inline_objects_checkIndex();
+  bool inline_preconditions_checkIndex();
   void copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark);
   bool inline_native_clone(bool is_virtual);
   bool inline_native_Reflection_getCallerClass();
@@ -281,6 +281,7 @@
   MemNode::MemOrd access_kind_to_memord(AccessKind access_kind);
   bool inline_unsafe_load_store(BasicType type,  LoadStoreKind kind, AccessKind access_kind);
   bool inline_unsafe_fence(vmIntrinsics::ID id);
+  bool inline_onspinwait();
   bool inline_fp_conversions(vmIntrinsics::ID id);
   bool inline_number_methods(vmIntrinsics::ID id);
   bool inline_reference_get();
@@ -474,7 +475,6 @@
   // Handle symbolic names for otherwise undistinguished boolean switches:
   const bool is_store       = true;
   const bool is_compress    = true;
-  const bool is_native_ptr  = true;
   const bool is_static      = true;
   const bool is_volatile    = true;
 
@@ -554,113 +554,95 @@
   case vmIntrinsics::_inflateStringC:
   case vmIntrinsics::_inflateStringB:           return inline_string_copy(!is_compress);
 
-  case vmIntrinsics::_getObject:                return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT,   Relaxed, false);
-  case vmIntrinsics::_getBoolean:               return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN,  Relaxed, false);
-  case vmIntrinsics::_getByte:                  return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE,     Relaxed, false);
-  case vmIntrinsics::_getShort:                 return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT,    Relaxed, false);
-  case vmIntrinsics::_getChar:                  return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR,     Relaxed, false);
-  case vmIntrinsics::_getInt:                   return inline_unsafe_access(!is_native_ptr, !is_store, T_INT,      Relaxed, false);
-  case vmIntrinsics::_getLong:                  return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG,     Relaxed, false);
-  case vmIntrinsics::_getFloat:                 return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT,    Relaxed, false);
-  case vmIntrinsics::_getDouble:                return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE,   Relaxed, false);
+  case vmIntrinsics::_getObject:                return inline_unsafe_access(!is_store, T_OBJECT,   Relaxed, false);
+  case vmIntrinsics::_getBoolean:               return inline_unsafe_access(!is_store, T_BOOLEAN,  Relaxed, false);
+  case vmIntrinsics::_getByte:                  return inline_unsafe_access(!is_store, T_BYTE,     Relaxed, false);
+  case vmIntrinsics::_getShort:                 return inline_unsafe_access(!is_store, T_SHORT,    Relaxed, false);
+  case vmIntrinsics::_getChar:                  return inline_unsafe_access(!is_store, T_CHAR,     Relaxed, false);
+  case vmIntrinsics::_getInt:                   return inline_unsafe_access(!is_store, T_INT,      Relaxed, false);
+  case vmIntrinsics::_getLong:                  return inline_unsafe_access(!is_store, T_LONG,     Relaxed, false);
+  case vmIntrinsics::_getFloat:                 return inline_unsafe_access(!is_store, T_FLOAT,    Relaxed, false);
+  case vmIntrinsics::_getDouble:                return inline_unsafe_access(!is_store, T_DOUBLE,   Relaxed, false);
 
-  case vmIntrinsics::_putObject:                return inline_unsafe_access(!is_native_ptr,  is_store, T_OBJECT,   Relaxed, false);
-  case vmIntrinsics::_putBoolean:               return inline_unsafe_access(!is_native_ptr,  is_store, T_BOOLEAN,  Relaxed, false);
-  case vmIntrinsics::_putByte:                  return inline_unsafe_access(!is_native_ptr,  is_store, T_BYTE,     Relaxed, false);
-  case vmIntrinsics::_putShort:                 return inline_unsafe_access(!is_native_ptr,  is_store, T_SHORT,    Relaxed, false);
-  case vmIntrinsics::_putChar:                  return inline_unsafe_access(!is_native_ptr,  is_store, T_CHAR,     Relaxed, false);
-  case vmIntrinsics::_putInt:                   return inline_unsafe_access(!is_native_ptr,  is_store, T_INT,      Relaxed, false);
-  case vmIntrinsics::_putLong:                  return inline_unsafe_access(!is_native_ptr,  is_store, T_LONG,     Relaxed, false);
-  case vmIntrinsics::_putFloat:                 return inline_unsafe_access(!is_native_ptr,  is_store, T_FLOAT,    Relaxed, false);
-  case vmIntrinsics::_putDouble:                return inline_unsafe_access(!is_native_ptr,  is_store, T_DOUBLE,   Relaxed, false);
+  case vmIntrinsics::_putObject:                return inline_unsafe_access( is_store, T_OBJECT,   Relaxed, false);
+  case vmIntrinsics::_putBoolean:               return inline_unsafe_access( is_store, T_BOOLEAN,  Relaxed, false);
+  case vmIntrinsics::_putByte:                  return inline_unsafe_access( is_store, T_BYTE,     Relaxed, false);
+  case vmIntrinsics::_putShort:                 return inline_unsafe_access( is_store, T_SHORT,    Relaxed, false);
+  case vmIntrinsics::_putChar:                  return inline_unsafe_access( is_store, T_CHAR,     Relaxed, false);
+  case vmIntrinsics::_putInt:                   return inline_unsafe_access( is_store, T_INT,      Relaxed, false);
+  case vmIntrinsics::_putLong:                  return inline_unsafe_access( is_store, T_LONG,     Relaxed, false);
+  case vmIntrinsics::_putFloat:                 return inline_unsafe_access( is_store, T_FLOAT,    Relaxed, false);
+  case vmIntrinsics::_putDouble:                return inline_unsafe_access( is_store, T_DOUBLE,   Relaxed, false);
 
-  case vmIntrinsics::_getByte_raw:              return inline_unsafe_access( is_native_ptr, !is_store, T_BYTE,     Relaxed, false);
-  case vmIntrinsics::_getShort_raw:             return inline_unsafe_access( is_native_ptr, !is_store, T_SHORT,    Relaxed, false);
-  case vmIntrinsics::_getChar_raw:              return inline_unsafe_access( is_native_ptr, !is_store, T_CHAR,     Relaxed, false);
-  case vmIntrinsics::_getInt_raw:               return inline_unsafe_access( is_native_ptr, !is_store, T_INT,      Relaxed, false);
-  case vmIntrinsics::_getLong_raw:              return inline_unsafe_access( is_native_ptr, !is_store, T_LONG,     Relaxed, false);
-  case vmIntrinsics::_getFloat_raw:             return inline_unsafe_access( is_native_ptr, !is_store, T_FLOAT,    Relaxed, false);
-  case vmIntrinsics::_getDouble_raw:            return inline_unsafe_access( is_native_ptr, !is_store, T_DOUBLE,   Relaxed, false);
-  case vmIntrinsics::_getAddress_raw:           return inline_unsafe_access( is_native_ptr, !is_store, T_ADDRESS,  Relaxed, false);
+  case vmIntrinsics::_getObjectVolatile:        return inline_unsafe_access(!is_store, T_OBJECT,   Volatile, false);
+  case vmIntrinsics::_getBooleanVolatile:       return inline_unsafe_access(!is_store, T_BOOLEAN,  Volatile, false);
+  case vmIntrinsics::_getByteVolatile:          return inline_unsafe_access(!is_store, T_BYTE,     Volatile, false);
+  case vmIntrinsics::_getShortVolatile:         return inline_unsafe_access(!is_store, T_SHORT,    Volatile, false);
+  case vmIntrinsics::_getCharVolatile:          return inline_unsafe_access(!is_store, T_CHAR,     Volatile, false);
+  case vmIntrinsics::_getIntVolatile:           return inline_unsafe_access(!is_store, T_INT,      Volatile, false);
+  case vmIntrinsics::_getLongVolatile:          return inline_unsafe_access(!is_store, T_LONG,     Volatile, false);
+  case vmIntrinsics::_getFloatVolatile:         return inline_unsafe_access(!is_store, T_FLOAT,    Volatile, false);
+  case vmIntrinsics::_getDoubleVolatile:        return inline_unsafe_access(!is_store, T_DOUBLE,   Volatile, false);
 
-  case vmIntrinsics::_putByte_raw:              return inline_unsafe_access( is_native_ptr,  is_store, T_BYTE,     Relaxed, false);
-  case vmIntrinsics::_putShort_raw:             return inline_unsafe_access( is_native_ptr,  is_store, T_SHORT,    Relaxed, false);
-  case vmIntrinsics::_putChar_raw:              return inline_unsafe_access( is_native_ptr,  is_store, T_CHAR,     Relaxed, false);
-  case vmIntrinsics::_putInt_raw:               return inline_unsafe_access( is_native_ptr,  is_store, T_INT,      Relaxed, false);
-  case vmIntrinsics::_putLong_raw:              return inline_unsafe_access( is_native_ptr,  is_store, T_LONG,     Relaxed, false);
-  case vmIntrinsics::_putFloat_raw:             return inline_unsafe_access( is_native_ptr,  is_store, T_FLOAT,    Relaxed, false);
-  case vmIntrinsics::_putDouble_raw:            return inline_unsafe_access( is_native_ptr,  is_store, T_DOUBLE,   Relaxed, false);
-  case vmIntrinsics::_putAddress_raw:           return inline_unsafe_access( is_native_ptr,  is_store, T_ADDRESS,  Relaxed, false);
+  case vmIntrinsics::_putObjectVolatile:        return inline_unsafe_access( is_store, T_OBJECT,   Volatile, false);
+  case vmIntrinsics::_putBooleanVolatile:       return inline_unsafe_access( is_store, T_BOOLEAN,  Volatile, false);
+  case vmIntrinsics::_putByteVolatile:          return inline_unsafe_access( is_store, T_BYTE,     Volatile, false);
+  case vmIntrinsics::_putShortVolatile:         return inline_unsafe_access( is_store, T_SHORT,    Volatile, false);
+  case vmIntrinsics::_putCharVolatile:          return inline_unsafe_access( is_store, T_CHAR,     Volatile, false);
+  case vmIntrinsics::_putIntVolatile:           return inline_unsafe_access( is_store, T_INT,      Volatile, false);
+  case vmIntrinsics::_putLongVolatile:          return inline_unsafe_access( is_store, T_LONG,     Volatile, false);
+  case vmIntrinsics::_putFloatVolatile:         return inline_unsafe_access( is_store, T_FLOAT,    Volatile, false);
+  case vmIntrinsics::_putDoubleVolatile:        return inline_unsafe_access( is_store, T_DOUBLE,   Volatile, false);
 
-  case vmIntrinsics::_getObjectVolatile:        return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT,   Volatile, false);
-  case vmIntrinsics::_getBooleanVolatile:       return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN,  Volatile, false);
-  case vmIntrinsics::_getByteVolatile:          return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE,     Volatile, false);
-  case vmIntrinsics::_getShortVolatile:         return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT,    Volatile, false);
-  case vmIntrinsics::_getCharVolatile:          return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR,     Volatile, false);
-  case vmIntrinsics::_getIntVolatile:           return inline_unsafe_access(!is_native_ptr, !is_store, T_INT,      Volatile, false);
-  case vmIntrinsics::_getLongVolatile:          return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG,     Volatile, false);
-  case vmIntrinsics::_getFloatVolatile:         return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT,    Volatile, false);
-  case vmIntrinsics::_getDoubleVolatile:        return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE,   Volatile, false);
+  case vmIntrinsics::_getShortUnaligned:        return inline_unsafe_access(!is_store, T_SHORT,    Relaxed, true);
+  case vmIntrinsics::_getCharUnaligned:         return inline_unsafe_access(!is_store, T_CHAR,     Relaxed, true);
+  case vmIntrinsics::_getIntUnaligned:          return inline_unsafe_access(!is_store, T_INT,      Relaxed, true);
+  case vmIntrinsics::_getLongUnaligned:         return inline_unsafe_access(!is_store, T_LONG,     Relaxed, true);
 
-  case vmIntrinsics::_putObjectVolatile:        return inline_unsafe_access(!is_native_ptr,  is_store, T_OBJECT,   Volatile, false);
-  case vmIntrinsics::_putBooleanVolatile:       return inline_unsafe_access(!is_native_ptr,  is_store, T_BOOLEAN,  Volatile, false);
-  case vmIntrinsics::_putByteVolatile:          return inline_unsafe_access(!is_native_ptr,  is_store, T_BYTE,     Volatile, false);
-  case vmIntrinsics::_putShortVolatile:         return inline_unsafe_access(!is_native_ptr,  is_store, T_SHORT,    Volatile, false);
-  case vmIntrinsics::_putCharVolatile:          return inline_unsafe_access(!is_native_ptr,  is_store, T_CHAR,     Volatile, false);
-  case vmIntrinsics::_putIntVolatile:           return inline_unsafe_access(!is_native_ptr,  is_store, T_INT,      Volatile, false);
-  case vmIntrinsics::_putLongVolatile:          return inline_unsafe_access(!is_native_ptr,  is_store, T_LONG,     Volatile, false);
-  case vmIntrinsics::_putFloatVolatile:         return inline_unsafe_access(!is_native_ptr,  is_store, T_FLOAT,    Volatile, false);
-  case vmIntrinsics::_putDoubleVolatile:        return inline_unsafe_access(!is_native_ptr,  is_store, T_DOUBLE,   Volatile, false);
+  case vmIntrinsics::_putShortUnaligned:        return inline_unsafe_access( is_store, T_SHORT,    Relaxed, true);
+  case vmIntrinsics::_putCharUnaligned:         return inline_unsafe_access( is_store, T_CHAR,     Relaxed, true);
+  case vmIntrinsics::_putIntUnaligned:          return inline_unsafe_access( is_store, T_INT,      Relaxed, true);
+  case vmIntrinsics::_putLongUnaligned:         return inline_unsafe_access( is_store, T_LONG,     Relaxed, true);
 
-  case vmIntrinsics::_getShortUnaligned:        return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT,    Relaxed, true);
-  case vmIntrinsics::_getCharUnaligned:         return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR,     Relaxed, true);
-  case vmIntrinsics::_getIntUnaligned:          return inline_unsafe_access(!is_native_ptr, !is_store, T_INT,      Relaxed, true);
-  case vmIntrinsics::_getLongUnaligned:         return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG,     Relaxed, true);
+  case vmIntrinsics::_getObjectAcquire:         return inline_unsafe_access(!is_store, T_OBJECT,   Acquire, false);
+  case vmIntrinsics::_getBooleanAcquire:        return inline_unsafe_access(!is_store, T_BOOLEAN,  Acquire, false);
+  case vmIntrinsics::_getByteAcquire:           return inline_unsafe_access(!is_store, T_BYTE,     Acquire, false);
+  case vmIntrinsics::_getShortAcquire:          return inline_unsafe_access(!is_store, T_SHORT,    Acquire, false);
+  case vmIntrinsics::_getCharAcquire:           return inline_unsafe_access(!is_store, T_CHAR,     Acquire, false);
+  case vmIntrinsics::_getIntAcquire:            return inline_unsafe_access(!is_store, T_INT,      Acquire, false);
+  case vmIntrinsics::_getLongAcquire:           return inline_unsafe_access(!is_store, T_LONG,     Acquire, false);
+  case vmIntrinsics::_getFloatAcquire:          return inline_unsafe_access(!is_store, T_FLOAT,    Acquire, false);
+  case vmIntrinsics::_getDoubleAcquire:         return inline_unsafe_access(!is_store, T_DOUBLE,   Acquire, false);
 
-  case vmIntrinsics::_putShortUnaligned:        return inline_unsafe_access(!is_native_ptr,  is_store, T_SHORT,    Relaxed, true);
-  case vmIntrinsics::_putCharUnaligned:         return inline_unsafe_access(!is_native_ptr,  is_store, T_CHAR,     Relaxed, true);
-  case vmIntrinsics::_putIntUnaligned:          return inline_unsafe_access(!is_native_ptr,  is_store, T_INT,      Relaxed, true);
-  case vmIntrinsics::_putLongUnaligned:         return inline_unsafe_access(!is_native_ptr,  is_store, T_LONG,     Relaxed, true);
+  case vmIntrinsics::_putObjectRelease:         return inline_unsafe_access( is_store, T_OBJECT,   Release, false);
+  case vmIntrinsics::_putBooleanRelease:        return inline_unsafe_access( is_store, T_BOOLEAN,  Release, false);
+  case vmIntrinsics::_putByteRelease:           return inline_unsafe_access( is_store, T_BYTE,     Release, false);
+  case vmIntrinsics::_putShortRelease:          return inline_unsafe_access( is_store, T_SHORT,    Release, false);
+  case vmIntrinsics::_putCharRelease:           return inline_unsafe_access( is_store, T_CHAR,     Release, false);
+  case vmIntrinsics::_putIntRelease:            return inline_unsafe_access( is_store, T_INT,      Release, false);
+  case vmIntrinsics::_putLongRelease:           return inline_unsafe_access( is_store, T_LONG,     Release, false);
+  case vmIntrinsics::_putFloatRelease:          return inline_unsafe_access( is_store, T_FLOAT,    Release, false);
+  case vmIntrinsics::_putDoubleRelease:         return inline_unsafe_access( is_store, T_DOUBLE,   Release, false);
 
-  case vmIntrinsics::_getObjectAcquire:         return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT,   Acquire, false);
-  case vmIntrinsics::_getBooleanAcquire:        return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN,  Acquire, false);
-  case vmIntrinsics::_getByteAcquire:           return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE,     Acquire, false);
-  case vmIntrinsics::_getShortAcquire:          return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT,    Acquire, false);
-  case vmIntrinsics::_getCharAcquire:           return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR,     Acquire, false);
-  case vmIntrinsics::_getIntAcquire:            return inline_unsafe_access(!is_native_ptr, !is_store, T_INT,      Acquire, false);
-  case vmIntrinsics::_getLongAcquire:           return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG,     Acquire, false);
-  case vmIntrinsics::_getFloatAcquire:          return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT,    Acquire, false);
-  case vmIntrinsics::_getDoubleAcquire:         return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE,   Acquire, false);
+  case vmIntrinsics::_getObjectOpaque:          return inline_unsafe_access(!is_store, T_OBJECT,   Opaque, false);
+  case vmIntrinsics::_getBooleanOpaque:         return inline_unsafe_access(!is_store, T_BOOLEAN,  Opaque, false);
+  case vmIntrinsics::_getByteOpaque:            return inline_unsafe_access(!is_store, T_BYTE,     Opaque, false);
+  case vmIntrinsics::_getShortOpaque:           return inline_unsafe_access(!is_store, T_SHORT,    Opaque, false);
+  case vmIntrinsics::_getCharOpaque:            return inline_unsafe_access(!is_store, T_CHAR,     Opaque, false);
+  case vmIntrinsics::_getIntOpaque:             return inline_unsafe_access(!is_store, T_INT,      Opaque, false);
+  case vmIntrinsics::_getLongOpaque:            return inline_unsafe_access(!is_store, T_LONG,     Opaque, false);
+  case vmIntrinsics::_getFloatOpaque:           return inline_unsafe_access(!is_store, T_FLOAT,    Opaque, false);
+  case vmIntrinsics::_getDoubleOpaque:          return inline_unsafe_access(!is_store, T_DOUBLE,   Opaque, false);
 
-  case vmIntrinsics::_putObjectRelease:         return inline_unsafe_access(!is_native_ptr,  is_store, T_OBJECT,   Release, false);
-  case vmIntrinsics::_putBooleanRelease:        return inline_unsafe_access(!is_native_ptr,  is_store, T_BOOLEAN,  Release, false);
-  case vmIntrinsics::_putByteRelease:           return inline_unsafe_access(!is_native_ptr,  is_store, T_BYTE,     Release, false);
-  case vmIntrinsics::_putShortRelease:          return inline_unsafe_access(!is_native_ptr,  is_store, T_SHORT,    Release, false);
-  case vmIntrinsics::_putCharRelease:           return inline_unsafe_access(!is_native_ptr,  is_store, T_CHAR,     Release, false);
-  case vmIntrinsics::_putIntRelease:            return inline_unsafe_access(!is_native_ptr,  is_store, T_INT,      Release, false);
-  case vmIntrinsics::_putLongRelease:           return inline_unsafe_access(!is_native_ptr,  is_store, T_LONG,     Release, false);
-  case vmIntrinsics::_putFloatRelease:          return inline_unsafe_access(!is_native_ptr,  is_store, T_FLOAT,    Release, false);
-  case vmIntrinsics::_putDoubleRelease:         return inline_unsafe_access(!is_native_ptr,  is_store, T_DOUBLE,   Release, false);
-
-  case vmIntrinsics::_getObjectOpaque:          return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT,   Opaque, false);
-  case vmIntrinsics::_getBooleanOpaque:         return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN,  Opaque, false);
-  case vmIntrinsics::_getByteOpaque:            return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE,     Opaque, false);
-  case vmIntrinsics::_getShortOpaque:           return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT,    Opaque, false);
-  case vmIntrinsics::_getCharOpaque:            return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR,     Opaque, false);
-  case vmIntrinsics::_getIntOpaque:             return inline_unsafe_access(!is_native_ptr, !is_store, T_INT,      Opaque, false);
-  case vmIntrinsics::_getLongOpaque:            return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG,     Opaque, false);
-  case vmIntrinsics::_getFloatOpaque:           return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT,    Opaque, false);
-  case vmIntrinsics::_getDoubleOpaque:          return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE,   Opaque, false);
-
-  case vmIntrinsics::_putObjectOpaque:          return inline_unsafe_access(!is_native_ptr,  is_store, T_OBJECT,   Opaque, false);
-  case vmIntrinsics::_putBooleanOpaque:         return inline_unsafe_access(!is_native_ptr,  is_store, T_BOOLEAN,  Opaque, false);
-  case vmIntrinsics::_putByteOpaque:            return inline_unsafe_access(!is_native_ptr,  is_store, T_BYTE,     Opaque, false);
-  case vmIntrinsics::_putShortOpaque:           return inline_unsafe_access(!is_native_ptr,  is_store, T_SHORT,    Opaque, false);
-  case vmIntrinsics::_putCharOpaque:            return inline_unsafe_access(!is_native_ptr,  is_store, T_CHAR,     Opaque, false);
-  case vmIntrinsics::_putIntOpaque:             return inline_unsafe_access(!is_native_ptr,  is_store, T_INT,      Opaque, false);
-  case vmIntrinsics::_putLongOpaque:            return inline_unsafe_access(!is_native_ptr,  is_store, T_LONG,     Opaque, false);
-  case vmIntrinsics::_putFloatOpaque:           return inline_unsafe_access(!is_native_ptr,  is_store, T_FLOAT,    Opaque, false);
-  case vmIntrinsics::_putDoubleOpaque:          return inline_unsafe_access(!is_native_ptr,  is_store, T_DOUBLE,   Opaque, false);
+  case vmIntrinsics::_putObjectOpaque:          return inline_unsafe_access( is_store, T_OBJECT,   Opaque, false);
+  case vmIntrinsics::_putBooleanOpaque:         return inline_unsafe_access( is_store, T_BOOLEAN,  Opaque, false);
+  case vmIntrinsics::_putByteOpaque:            return inline_unsafe_access( is_store, T_BYTE,     Opaque, false);
+  case vmIntrinsics::_putShortOpaque:           return inline_unsafe_access( is_store, T_SHORT,    Opaque, false);
+  case vmIntrinsics::_putCharOpaque:            return inline_unsafe_access( is_store, T_CHAR,     Opaque, false);
+  case vmIntrinsics::_putIntOpaque:             return inline_unsafe_access( is_store, T_INT,      Opaque, false);
+  case vmIntrinsics::_putLongOpaque:            return inline_unsafe_access( is_store, T_LONG,     Opaque, false);
+  case vmIntrinsics::_putFloatOpaque:           return inline_unsafe_access( is_store, T_FLOAT,    Opaque, false);
+  case vmIntrinsics::_putDoubleOpaque:          return inline_unsafe_access( is_store, T_DOUBLE,   Opaque, false);
 
   case vmIntrinsics::_compareAndSwapObject:             return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap,      Volatile);
   case vmIntrinsics::_compareAndSwapInt:                return inline_unsafe_load_store(T_INT,    LS_cmp_swap,      Volatile);
@@ -669,12 +651,15 @@
   case vmIntrinsics::_weakCompareAndSwapObject:         return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed);
   case vmIntrinsics::_weakCompareAndSwapObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire);
   case vmIntrinsics::_weakCompareAndSwapObjectRelease:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSwapObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile);
   case vmIntrinsics::_weakCompareAndSwapInt:            return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Relaxed);
   case vmIntrinsics::_weakCompareAndSwapIntAcquire:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Acquire);
   case vmIntrinsics::_weakCompareAndSwapIntRelease:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSwapIntVolatile:    return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Volatile);
   case vmIntrinsics::_weakCompareAndSwapLong:           return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Relaxed);
   case vmIntrinsics::_weakCompareAndSwapLongAcquire:    return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Acquire);
   case vmIntrinsics::_weakCompareAndSwapLongRelease:    return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSwapLongVolatile:   return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Volatile);
 
   case vmIntrinsics::_compareAndExchangeObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Acquire);
@@ -696,6 +681,8 @@
   case vmIntrinsics::_storeFence:
   case vmIntrinsics::_fullFence:                return inline_unsafe_fence(intrinsic_id());
 
+  case vmIntrinsics::_onSpinWait:               return inline_onspinwait();
+
   case vmIntrinsics::_currentThread:            return inline_native_currentThread();
   case vmIntrinsics::_isInterrupted:            return inline_native_isInterrupted();
 
@@ -711,7 +698,7 @@
   case vmIntrinsics::_copyOfRange:              return inline_array_copyOf(true);
   case vmIntrinsics::_equalsB:                  return inline_array_equals(StrIntrinsicNode::LL);
   case vmIntrinsics::_equalsC:                  return inline_array_equals(StrIntrinsicNode::UU);
-  case vmIntrinsics::_Objects_checkIndex:       return inline_objects_checkIndex();
+  case vmIntrinsics::_Preconditions_checkIndex: return inline_preconditions_checkIndex();
   case vmIntrinsics::_clone:                    return inline_native_clone(intrinsic()->is_virtual());
 
   case vmIntrinsics::_allocateUninitializedArray: return inline_unsafe_newArray(true);
@@ -1138,7 +1125,7 @@
   return true;
 }
 
-bool LibraryCallKit::inline_objects_checkIndex() {
+bool LibraryCallKit::inline_preconditions_checkIndex() {
   Node* index = argument(0);
   Node* length = argument(1);
   if (too_many_traps(Deoptimization::Reason_intrinsic) || too_many_traps(Deoptimization::Reason_range_check)) {
@@ -1677,7 +1664,6 @@
   switch (id) {
   case vmIntrinsics::_dabs:   n = new AbsDNode(                arg);  break;
   case vmIntrinsics::_dsqrt:  n = new SqrtDNode(C, control(),  arg);  break;
-  case vmIntrinsics::_dlog10: n = new Log10DNode(C, control(), arg);  break;
   default:  fatal_unexpected_iid(id);  break;
   }
   set_result(_gvn.transform(n));
@@ -1691,10 +1677,6 @@
   Node* arg = round_double_node(argument(0));
   Node* n = NULL;
 
-  switch (id) {
-  case vmIntrinsics::_dtan:  n = new TanDNode(C, control(), arg);  break;
-  default:  fatal_unexpected_iid(id);  break;
-  }
   n = _gvn.transform(n);
 
   // Rounding required?  Check for argument reduction!
@@ -1812,15 +1794,18 @@
     return StubRoutines::dcos() != NULL ?
       runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dcos(), "dcos") :
       runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dcos),   "COS");
-  case vmIntrinsics::_dtan:   return Matcher::has_match_rule(Op_TanD)   ? inline_trig(id) :
-    runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dtan),   "TAN");
-
+  case vmIntrinsics::_dtan:
+    return StubRoutines::dtan() != NULL ?
+      runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dtan(), "dtan") :
+      runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dtan), "TAN");
   case vmIntrinsics::_dlog:
     return StubRoutines::dlog() != NULL ?
       runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dlog(), "dlog") :
       runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog),   "LOG");
-  case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D) ? inline_math(id) :
-    runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10");
+  case vmIntrinsics::_dlog10:
+    return StubRoutines::dlog10() != NULL ?
+      runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dlog10(), "dlog10") :
+      runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10");
 
     // These intrinsics are supported on all hardware
   case vmIntrinsics::_dsqrt:  return Matcher::match_rule_supported(Op_SqrtD) ? inline_math(id) : false;
@@ -2195,8 +2180,6 @@
 
 //----------------------------inline_unsafe_access----------------------------
 
-const static BasicType T_ADDRESS_HOLDER = T_LONG;
-
 // Helper that guards and inserts a pre-barrier.
 void LibraryCallKit::insert_pre_barrier(Node* base_oop, Node* offset,
                                         Node* pre_val, bool need_mem_bar) {
@@ -2297,13 +2280,12 @@
 }
 
 
-const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr) {
+const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type) {
   // Attempt to infer a sharper value type from the offset and base type.
   ciKlass* sharpened_klass = NULL;
 
   // See if it is an instance field, with an object type.
   if (alias_type->field() != NULL) {
-    assert(!is_native_ptr, "native pointer op cannot use a java address");
     if (alias_type->field()->type()->is_klass()) {
       sharpened_klass = alias_type->field()->type()->as_klass();
     }
@@ -2336,10 +2318,11 @@
   return NULL;
 }
 
-bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_store, const BasicType type, const AccessKind kind, const bool unaligned) {
+bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, const AccessKind kind, const bool unaligned) {
   if (callee()->is_static())  return false;  // caller must have the capability!
   guarantee(!is_store || kind != Acquire, "Acquire accesses can be produced only for loads");
   guarantee( is_store || kind != Release, "Release accesses can be produced only for stores");
+  assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type");
 
 #ifndef PRODUCT
   {
@@ -2350,31 +2333,17 @@
     if (!is_store) {
       // Object getObject(Object base, int/long offset), etc.
       BasicType rtype = sig->return_type()->basic_type();
-      if (rtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::getAddress_name())
-          rtype = T_ADDRESS;  // it is really a C void*
       assert(rtype == type, "getter must return the expected value");
-      if (!is_native_ptr) {
-        assert(sig->count() == 2, "oop getter has 2 arguments");
-        assert(sig->type_at(0)->basic_type() == T_OBJECT, "getter base is object");
-        assert(sig->type_at(1)->basic_type() == T_LONG, "getter offset is correct");
-      } else {
-        assert(sig->count() == 1, "native getter has 1 argument");
-        assert(sig->type_at(0)->basic_type() == T_LONG, "getter base is long");
-      }
+      assert(sig->count() == 2, "oop getter has 2 arguments");
+      assert(sig->type_at(0)->basic_type() == T_OBJECT, "getter base is object");
+      assert(sig->type_at(1)->basic_type() == T_LONG, "getter offset is correct");
     } else {
       // void putObject(Object base, int/long offset, Object x), etc.
       assert(sig->return_type()->basic_type() == T_VOID, "putter must not return a value");
-      if (!is_native_ptr) {
-        assert(sig->count() == 3, "oop putter has 3 arguments");
-        assert(sig->type_at(0)->basic_type() == T_OBJECT, "putter base is object");
-        assert(sig->type_at(1)->basic_type() == T_LONG, "putter offset is correct");
-      } else {
-        assert(sig->count() == 2, "native putter has 2 arguments");
-        assert(sig->type_at(0)->basic_type() == T_LONG, "putter base is long");
-      }
+      assert(sig->count() == 3, "oop putter has 3 arguments");
+      assert(sig->type_at(0)->basic_type() == T_OBJECT, "putter base is object");
+      assert(sig->type_at(1)->basic_type() == T_LONG, "putter offset is correct");
       BasicType vtype = sig->type_at(sig->count()-1)->basic_type();
-      if (vtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::putAddress_name())
-        vtype = T_ADDRESS;  // it is really a C void*
       assert(vtype == type, "putter must accept the expected value");
     }
 #endif // ASSERT
@@ -2391,38 +2360,54 @@
   Node* offset = top();
   Node* val;
 
-  if (!is_native_ptr) {
-    // The base is either a Java object or a value produced by Unsafe.staticFieldBase
-    Node* base = argument(1);  // type: oop
-    // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset
-    offset = argument(2);  // 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);
+  // The base is either a Java object or a value produced by Unsafe.staticFieldBase
+  Node* base = argument(1);  // type: oop
+  // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset
+  offset = argument(2);  // 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);
+  if (_gvn.type(base)->isa_ptr() != TypePtr::NULL_PTR) {
     heap_base_oop = base;
-    val = is_store ? argument(4) : NULL;
-  } else {
-    Node* ptr = argument(1);  // type: long
-    ptr = ConvL2X(ptr);  // adjust Java long to machine word
-    adr = make_unsafe_address(NULL, ptr);
-    val = is_store ? argument(3) : NULL;
   }
+  val = is_store ? argument(4) : NULL;
 
   const TypePtr *adr_type = _gvn.type(adr)->isa_ptr();
 
-  // First guess at the value type.
-  const Type *value_type = Type::get_const_basic_type(type);
-
   // Try to categorize the address.  If it comes up as TypeJavaPtr::BOTTOM,
   // there was not enough information to nail it down.
   Compile::AliasType* alias_type = C->alias_type(adr_type);
   assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here");
 
+  assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM ||
+         alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown");
+  bool mismatched = false;
+  BasicType bt = alias_type->basic_type();
+  if (bt != T_ILLEGAL) {
+    if (bt == T_BYTE && adr_type->isa_aryptr()) {
+      // Alias type doesn't differentiate between byte[] and boolean[]).
+      // Use address type to get the element type.
+      bt = adr_type->is_aryptr()->elem()->array_element_basic_type();
+    }
+    if (bt == T_ARRAY || bt == T_NARROWOOP) {
+      // accessing an array field with getObject is not a mismatch
+      bt = T_OBJECT;
+    }
+    if ((bt == T_OBJECT) != (type == T_OBJECT)) {
+      // Don't intrinsify mismatched object accesses
+      return false;
+    }
+    mismatched = (bt != type);
+  }
+
+  // First guess at the value type.
+  const Type *value_type = Type::get_const_basic_type(type);
+
   // We will need memory barriers unless we can determine a unique
   // alias category for this reference.  (Note:  If for some reason
   // the barriers get omitted and the unsafe reference begins to "pollute"
@@ -2449,9 +2434,10 @@
   bool requires_atomic_access = false;
   switch (kind) {
       case Relaxed:
-      case Opaque:
           requires_atomic_access = AlwaysAtomicAccesses;
           break;
+      case Opaque:
+          // Opaque accesses are atomic.
       case Acquire:
       case Release:
       case Volatile:
@@ -2471,11 +2457,11 @@
   // SATB log buffer using the pre-barrier mechanism.
   // Also we need to add memory barrier to prevent commoning reads
   // from this field across safepoint since GC can change its value.
-  bool need_read_barrier = !is_native_ptr && !is_store &&
+  bool need_read_barrier = !is_store &&
                            offset != top() && heap_base_oop != top();
 
   if (!is_store && type == T_OBJECT) {
-    const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type, is_native_ptr);
+    const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type);
     if (tjp != NULL) {
       value_type = tjp;
     }
@@ -2523,40 +2509,13 @@
   // of safe & unsafe memory.
   if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder);
 
-  assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM ||
-         alias_type->field() != NULL || alias_type->element() != NULL, "field, array element or unknown");
-  bool mismatched = false;
-  if (alias_type->element() != NULL || alias_type->field() != NULL) {
-    BasicType bt;
-    if (alias_type->element() != NULL) {
-      // Use address type to get the element type. Alias type doesn't provide
-      // enough information (e.g., doesn't differentiate between byte[] and boolean[]).
-      const Type* element = adr_type->is_aryptr()->elem();
-      bt = element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type();
-    } else {
-      bt = alias_type->field()->layout_type();
-    }
-    if (bt == T_ARRAY) {
-      // accessing an array field with getObject is not a mismatch
-      bt = T_OBJECT;
-    }
-    if (bt != type) {
-      mismatched = true;
-    }
-  }
-  assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type");
-
   if (!is_store) {
     Node* p = NULL;
     // Try to constant fold a load from a constant field
     ciField* field = alias_type->field();
-    if (heap_base_oop != top() &&
-        field != NULL && field->is_constant() && !mismatched) {
+    if (heap_base_oop != top() && field != NULL && field->is_constant() && !mismatched) {
       // final or stable field
-      const Type* con_type = Type::make_constant(alias_type->field(), heap_base_oop);
-      if (con_type != NULL) {
-        p = makecon(con_type);
-      }
+      p = make_constant_from_field(field, heap_base_oop);
     }
     if (p == NULL) {
       // To be valid, unsafe loads may depend on other conditions than
@@ -2817,11 +2776,20 @@
   Node* adr = make_unsafe_address(base, offset);
   const TypePtr *adr_type = _gvn.type(adr)->isa_ptr();
 
+  Compile::AliasType* alias_type = C->alias_type(adr_type);
+  assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM ||
+         alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown");
+  BasicType bt = alias_type->basic_type();
+  if (bt != T_ILLEGAL &&
+      ((bt == T_OBJECT || bt == T_ARRAY) != (type == T_OBJECT))) {
+    // Don't intrinsify mismatched object accesses.
+    return false;
+  }
+
   // For CAS, unlike inline_unsafe_access, there seems no point in
   // trying to refine types. Just use the coarse types here.
-  const Type *value_type = Type::get_const_basic_type(type);
-  Compile::AliasType* alias_type = C->alias_type(adr_type);
   assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here");
+  const Type *value_type = Type::get_const_basic_type(type);
 
   switch (kind) {
     case LS_get_set:
@@ -3127,6 +3095,11 @@
   }
 }
 
+bool LibraryCallKit::inline_onspinwait() {
+  insert_mem_bar(Op_OnSpinWait);
+  return true;
+}
+
 bool LibraryCallKit::klass_needs_init_guard(Node* kls) {
   if (!kls->is_Con()) {
     return true;
diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp
index f2bf2ef..7e33dc3 100644
--- a/hotspot/src/share/vm/opto/loopTransform.cpp
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp
@@ -2819,7 +2819,7 @@
       if (phase->do_range_check(this, old_new) != 0) {
         cl->mark_has_range_checks();
       }
-    } else {
+    } else if (PostLoopMultiversioning) {
       phase->has_range_checks(this);
     }
 
diff --git a/hotspot/src/share/vm/opto/loopUnswitch.cpp b/hotspot/src/share/vm/opto/loopUnswitch.cpp
index 697ff0c..72201c2 100644
--- a/hotspot/src/share/vm/opto/loopUnswitch.cpp
+++ b/hotspot/src/share/vm/opto/loopUnswitch.cpp
@@ -374,10 +374,17 @@
     return false; // skip malformed counted loop
   }
   if (!cl->is_main_loop()) {
-    if (TraceLoopOpts) {
-      tty->print_cr("CountedLoopReserveKit::create_reserve: %d not main loop", cl->_idx);
+    bool loop_not_canonical = true;
+    if (cl->is_post_loop() && (cl->slp_max_unroll() > 0)) {
+      loop_not_canonical = false;
     }
-    return false; // skip normal, pre, and post loops
+    // only reject some loop forms
+    if (loop_not_canonical) {
+      if (TraceLoopOpts) {
+        tty->print_cr("CountedLoopReserveKit::create_reserve: %d not canonical loop", cl->_idx);
+      }
+      return false; // skip normal, pre, and post (conditionally) loops
+    }
   }
 
   _lp = _lpt->_head->as_Loop();
diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp
index 33f5de7..4068e27bf 100644
--- a/hotspot/src/share/vm/opto/loopnode.cpp
+++ b/hotspot/src/share/vm/opto/loopnode.cpp
@@ -2369,11 +2369,13 @@
                   if (multi_version_post_loops(lpt, lpt_next) == false) {
                     // Cause the rce loop to be optimized away if we fail
                     cl->mark_is_multiversioned();
+                    cl->set_slp_max_unroll(0);
                     poison_rce_post_loop(lpt);
                   }
                 }
               }
             }
+            sw.transform_loop(lpt, true);
           }
         } else if (cl->is_main_loop()) {
           sw.transform_loop(lpt, true);
diff --git a/hotspot/src/share/vm/opto/machnode.cpp b/hotspot/src/share/vm/opto/machnode.cpp
index fc5b086..cd0839c 100644
--- a/hotspot/src/share/vm/opto/machnode.cpp
+++ b/hotspot/src/share/vm/opto/machnode.cpp
@@ -600,8 +600,8 @@
 void MachProjNode::dump_spec(outputStream *st) const {
   ProjNode::dump_spec(st);
   switch (_ideal_reg) {
-  case unmatched_proj:  st->print("/unmatched");                         break;
-  case fat_proj:        st->print("/fat"); if (WizardMode) _rout.dump(); break;
+  case unmatched_proj:  st->print("/unmatched");                           break;
+  case fat_proj:        st->print("/fat"); if (WizardMode) _rout.dump(st); break;
   }
 }
 #endif
diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp
index 06f443b..106257a 100644
--- a/hotspot/src/share/vm/opto/macro.cpp
+++ b/hotspot/src/share/vm/opto/macro.cpp
@@ -860,7 +860,7 @@
       if (basic_elem_type == T_OBJECT || basic_elem_type == T_ARRAY) {
         if (!elem_type->is_loaded()) {
           field_type = TypeInstPtr::BOTTOM;
-        } else if (field != NULL && field->is_constant() && field->is_static()) {
+        } else if (field != NULL && field->is_static_constant()) {
           // This can happen if the constant oop is non-perm.
           ciObject* con = field->constant_value().as_object();
           // Do not "join" in the previous type; it doesn't add value,
@@ -1897,7 +1897,7 @@
 
       Node *prefetch_adr;
       Node *prefetch;
-      uint lines = AllocatePrefetchDistance / AllocatePrefetchStepSize;
+      uint lines = (length != NULL) ? AllocatePrefetchLines : AllocateInstancePrefetchLines;
       uint step_size = AllocatePrefetchStepSize;
       uint distance = 0;
 
@@ -1926,12 +1926,8 @@
       contended_phi_rawmem = pf_phi_rawmem;
       i_o = pf_phi_abio;
    } else if( UseTLAB && AllocatePrefetchStyle == 3 ) {
-      // Insert a prefetch for each allocation.
-      // This code is used for Sparc with BIS.
-      Node *pf_region = new RegionNode(3);
-      Node *pf_phi_rawmem = new PhiNode( pf_region, Type::MEMORY,
-                                             TypeRawPtr::BOTTOM );
-      transform_later(pf_region);
+      // Insert a prefetch instruction for each allocation.
+      // This code is used for SPARC with BIS.
 
       // Generate several prefetch instructions.
       uint lines = (length != NULL) ? AllocatePrefetchLines : AllocateInstancePrefetchLines;
@@ -1940,10 +1936,15 @@
 
       // Next cache address.
       Node *cache_adr = new AddPNode(old_eden_top, old_eden_top,
-                                            _igvn.MakeConX(distance));
+                                     _igvn.MakeConX(step_size + distance));
       transform_later(cache_adr);
       cache_adr = new CastP2XNode(needgc_false, cache_adr);
       transform_later(cache_adr);
+      // For BIS instructions to be emitted, the address must be aligned at cache line size.
+      // (The VM sets AllocatePrefetchStepSize to the cache line size, unless a value is
+      // specified at the command line.) If the address is not aligned at cache line size
+      // boundary, a standard store instruction is triggered (instead of the BIS). For the
+      // latter, 8-byte alignment is necessary.
       Node* mask = _igvn.MakeConX(~(intptr_t)(step_size-1));
       cache_adr = new AndXNode(cache_adr, mask);
       transform_later(cache_adr);
diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp
index 2d91f41..44127f3 100644
--- a/hotspot/src/share/vm/opto/matcher.cpp
+++ b/hotspot/src/share/vm/opto/matcher.cpp
@@ -944,6 +944,7 @@
     case Op_MemBarCPUOrder: // %%% these ideals should have narrower adr_type?
     case Op_StrInflatedCopy:
     case Op_StrCompressedCopy:
+    case Op_OnSpinWait:
     case Op_EncodeISOArray:
       nidx = Compile::AliasIdxTop;
       nat = NULL;
@@ -962,44 +963,6 @@
 }
 #endif
 
-
-//------------------------------MStack-----------------------------------------
-// State and MStack class used in xform() and find_shared() iterative methods.
-enum Node_State { Pre_Visit,  // node has to be pre-visited
-                      Visit,  // visit node
-                 Post_Visit,  // post-visit node
-             Alt_Post_Visit   // alternative post-visit path
-                };
-
-class MStack: public Node_Stack {
-  public:
-    MStack(int size) : Node_Stack(size) { }
-
-    void push(Node *n, Node_State ns) {
-      Node_Stack::push(n, (uint)ns);
-    }
-    void push(Node *n, Node_State ns, Node *parent, int indx) {
-      ++_inode_top;
-      if ((_inode_top + 1) >= _inode_max) grow();
-      _inode_top->node = parent;
-      _inode_top->indx = (uint)indx;
-      ++_inode_top;
-      _inode_top->node = n;
-      _inode_top->indx = (uint)ns;
-    }
-    Node *parent() {
-      pop();
-      return node();
-    }
-    Node_State state() const {
-      return (Node_State)index();
-    }
-    void set_state(Node_State ns) {
-      set_index((uint)ns);
-    }
-};
-
-
 //------------------------------xform------------------------------------------
 // Given a Node in old-space, Match him (Label/Reduce) to produce a machine
 // Node in new-space.  Given a new-space Node, recursively walk his children.
@@ -2045,37 +2008,22 @@
 }
 #endif // X86
 
-// A method-klass-holder may be passed in the inline_cache_reg
-// and then expanded into the inline_cache_reg and a method_oop register
-//   defined in ad_<arch>.cpp
-
-// Check for shift by small constant as well
-static bool clone_shift(Node* shift, Matcher* matcher, MStack& mstack, VectorSet& address_visited) {
-  if (shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() &&
-      shift->in(2)->get_int() <= 3 &&
-      // Are there other uses besides address expressions?
-      !matcher->is_visited(shift)) {
-    address_visited.set(shift->_idx); // Flag as address_visited
-    mstack.push(shift->in(2), Visit);
-    Node *conv = shift->in(1);
-#ifdef _LP64
-    // Allow Matcher to match the rule which bypass
-    // ConvI2L operation for an array index on LP64
-    // if the index value is positive.
-    if (conv->Opcode() == Op_ConvI2L &&
-        conv->as_Type()->type()->is_long()->_lo >= 0 &&
-        // Are there other uses besides address expressions?
-        !matcher->is_visited(conv)) {
-      address_visited.set(conv->_idx); // Flag as address_visited
-      mstack.push(conv->in(1), Pre_Visit);
-    } else
-#endif
-      mstack.push(conv, Pre_Visit);
+bool Matcher::clone_base_plus_offset_address(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) {
+  Node *off = m->in(AddPNode::Offset);
+  if (off->is_Con()) {
+    address_visited.test_set(m->_idx); // Flag as address_visited
+    mstack.push(m->in(AddPNode::Address), Pre_Visit);
+    // Clone X+offset as it also folds into most addressing expressions
+    mstack.push(off, Visit);
+    mstack.push(m->in(AddPNode::Base), Pre_Visit);
     return true;
   }
   return false;
 }
 
+// A method-klass-holder may be passed in the inline_cache_reg
+// and then expanded into the inline_cache_reg and a method_oop register
+//   defined in ad_<arch>.cpp
 
 //------------------------------find_shared------------------------------------
 // Set bits if Node is shared or otherwise a root
@@ -2250,40 +2198,9 @@
           // But they should be marked as shared if there are other uses
           // besides address expressions.
 
-          Node *off = m->in(AddPNode::Offset);
-          if (off->is_Con()) {
-            address_visited.test_set(m->_idx); // Flag as address_visited
-            Node *adr = m->in(AddPNode::Address);
-
-            // Intel, ARM and friends can handle 2 adds in addressing mode
-            if( clone_shift_expressions && adr->is_AddP() &&
-                // AtomicAdd is not an addressing expression.
-                // Cheap to find it by looking for screwy base.
-                !adr->in(AddPNode::Base)->is_top() &&
-                // Are there other uses besides address expressions?
-                !is_visited(adr) ) {
-              address_visited.set(adr->_idx); // Flag as address_visited
-              Node *shift = adr->in(AddPNode::Offset);
-              if (!clone_shift(shift, this, mstack, address_visited)) {
-                mstack.push(shift, Pre_Visit);
-              }
-              mstack.push(adr->in(AddPNode::Address), Pre_Visit);
-              mstack.push(adr->in(AddPNode::Base), Pre_Visit);
-            } else {  // Sparc, Alpha, PPC and friends
-              mstack.push(adr, Pre_Visit);
-            }
-
-            // Clone X+offset as it also folds into most addressing expressions
-            mstack.push(off, Visit);
-            mstack.push(m->in(AddPNode::Base), Pre_Visit);
-            continue; // for(int i = ...)
-          } else if (clone_shift_expressions &&
-                     clone_shift(off, this, mstack, address_visited)) {
-              address_visited.test_set(m->_idx); // Flag as address_visited
-              mstack.push(m->in(AddPNode::Address), Pre_Visit);
-              mstack.push(m->in(AddPNode::Base), Pre_Visit);
-              continue;
-          } // if( off->is_Con() )
+          if (clone_address_expressions(m->as_AddP(), mstack, address_visited)) {
+            continue;
+          }
         }   // if( mem_op &&
         mstack.push(m, Pre_Visit);
       }     // for(int i = ...)
diff --git a/hotspot/src/share/vm/opto/matcher.hpp b/hotspot/src/share/vm/opto/matcher.hpp
index dad3854..74d7361 100644
--- a/hotspot/src/share/vm/opto/matcher.hpp
+++ b/hotspot/src/share/vm/opto/matcher.hpp
@@ -40,6 +40,45 @@
 //---------------------------Matcher-------------------------------------------
 class Matcher : public PhaseTransform {
   friend class VMStructs;
+
+public:
+
+  // State and MStack class used in xform() and find_shared() iterative methods.
+  enum Node_State { Pre_Visit,  // node has to be pre-visited
+                    Visit,  // visit node
+                    Post_Visit,  // post-visit node
+                    Alt_Post_Visit   // alternative post-visit path
+  };
+
+  class MStack: public Node_Stack {
+  public:
+    MStack(int size) : Node_Stack(size) { }
+
+    void push(Node *n, Node_State ns) {
+      Node_Stack::push(n, (uint)ns);
+    }
+    void push(Node *n, Node_State ns, Node *parent, int indx) {
+      ++_inode_top;
+      if ((_inode_top + 1) >= _inode_max) grow();
+      _inode_top->node = parent;
+      _inode_top->indx = (uint)indx;
+      ++_inode_top;
+      _inode_top->node = n;
+      _inode_top->indx = (uint)ns;
+    }
+    Node *parent() {
+      pop();
+      return node();
+    }
+    Node_State state() const {
+      return (Node_State)index();
+    }
+    void set_state(Node_State ns) {
+      set_index((uint)ns);
+    }
+  };
+
+private:
   // Private arena of State objects
   ResourceArea _states_arena;
 
@@ -273,6 +312,9 @@
   // e.g. Op_ vector nodes and other intrinsics while guarding with vlen
   static const bool match_rule_supported_vector(int opcode, int vlen);
 
+  // Some microarchitectures have mask registers used on vectors
+  static const bool has_predicated_vectors(void);
+
   // Some uarchs have different sized float register resources
   static const int float_pressure(int default_pressure_threshold);
 
@@ -408,7 +450,9 @@
   // Should the Matcher clone shifts on addressing modes, expecting them to
   // be subsumed into complex addressing expressions or compute them into
   // registers?  True for Intel but false for most RISCs
-  static const bool clone_shift_expressions;
+  bool clone_address_expressions(AddPNode* m, MStack& mstack, VectorSet& address_visited);
+  // Clone base + offset address expression
+  bool clone_base_plus_offset_address(AddPNode* m, MStack& mstack, VectorSet& address_visited);
 
   static bool narrow_oop_use_complex_address();
   static bool narrow_klass_use_complex_address();
@@ -485,6 +529,9 @@
   // ourselves.
   static const bool need_masked_shift_count;
 
+  // Whether code generation need accurate ConvI2L types.
+  static const bool convi2l_type_required;
+
   // This routine is run whenever a graph fails to match.
   // If it returns, the compiler should bailout to interpreter without error.
   // In non-product mode, SoftMatchFailure is false to detect non-canonical
diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp
index 5580c79..4be9e24 100644
--- a/hotspot/src/share/vm/opto/memnode.cpp
+++ b/hotspot/src/share/vm/opto/memnode.cpp
@@ -797,7 +797,7 @@
 #endif
     {
       assert(!adr->bottom_type()->is_ptr_to_narrowoop() && !adr->bottom_type()->is_ptr_to_narrowklass(), "should have got back a narrow oop");
-      load = new LoadPNode(ctl, mem, adr, adr_type, rt->is_oopptr(), mo, control_dependency);
+      load = new LoadPNode(ctl, mem, adr, adr_type, rt->is_ptr(), mo, control_dependency);
     }
     break;
   }
@@ -1621,72 +1621,6 @@
   return NULL;
 }
 
-static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) {
-  BasicType conbt = con.basic_type();
-  switch (conbt) {
-    case T_BOOLEAN: conbt = T_BYTE;   break;
-    case T_ARRAY:   conbt = T_OBJECT; break;
-  }
-  switch (loadbt) {
-    case T_BOOLEAN:   loadbt = T_BYTE;   break;
-    case T_NARROWOOP: loadbt = T_OBJECT; break;
-    case T_ARRAY:     loadbt = T_OBJECT; break;
-    case T_ADDRESS:   loadbt = T_OBJECT; break;
-  }
-  if (conbt == loadbt) {
-    if (is_unsigned && conbt == T_BYTE) {
-      // LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE).
-      return ciConstant(T_INT, con.as_int() & 0xFF);
-    } else {
-      return con;
-    }
-  }
-  if (conbt == T_SHORT && loadbt == T_CHAR) {
-    // LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR).
-    return ciConstant(T_INT, con.as_int() & 0xFFFF);
-  }
-  return ciConstant(); // T_ILLEGAL
-}
-
-// Try to constant-fold a stable array element.
-static const Type* fold_stable_ary_elem(const TypeAryPtr* ary, int off, bool is_unsigned_load, BasicType loadbt) {
-  assert(ary->const_oop(), "array should be constant");
-  assert(ary->is_stable(), "array should be stable");
-
-  // Decode the results of GraphKit::array_element_address.
-  ciArray* aobj = ary->const_oop()->as_array();
-  ciConstant element_value = aobj->element_value_by_offset(off);
-  if (element_value.basic_type() == T_ILLEGAL) {
-    return NULL; // wrong offset
-  }
-  ciConstant con = check_mismatched_access(element_value, loadbt, is_unsigned_load);
-  assert(con.basic_type() != T_ILLEGAL, "elembt=%s; loadbt=%s; unsigned=%d",
-         type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load);
-
-  if (con.basic_type() != T_ILLEGAL && // not a mismatched access
-      !con.is_null_or_zero()) {        // not a default value
-    const Type* con_type = Type::make_from_constant(con);
-    if (con_type != NULL) {
-      if (con_type->isa_aryptr()) {
-        // Join with the array element type, in case it is also stable.
-        int dim = ary->stable_dimension();
-        con_type = con_type->is_aryptr()->cast_to_stable(true, dim-1);
-      }
-      if (loadbt == T_NARROWOOP && con_type->isa_oopptr()) {
-        con_type = con_type->make_narrowoop();
-      }
-#ifndef PRODUCT
-      if (TraceIterativeGVN) {
-        tty->print("FoldStableValues: array element [off=%d]: con_type=", off);
-        con_type->dump(); tty->cr();
-      }
-#endif //PRODUCT
-      return con_type;
-    }
-  }
-  return NULL;
-}
-
 //------------------------------Value-----------------------------------------
 const Type* LoadNode::Value(PhaseGVN* phase) const {
   // Either input is TOP ==> the result is TOP
@@ -1715,10 +1649,14 @@
     const bool off_beyond_header = ((uint)off >= (uint)min_base_off);
 
     // Try to constant-fold a stable array element.
-    if (FoldStableValues && !is_mismatched_access() && ary->is_stable() && ary->const_oop() != NULL) {
+    if (FoldStableValues && !is_mismatched_access() && ary->is_stable()) {
       // Make sure the reference is not into the header and the offset is constant
-      if (off_beyond_header && adr->is_AddP() && off != Type::OffsetBot) {
-        const Type* con_type = fold_stable_ary_elem(ary, off, is_unsigned(), memory_type());
+      ciObject* aobj = ary->const_oop();
+      if (aobj != NULL && off_beyond_header && adr->is_AddP() && off != Type::OffsetBot) {
+        int stable_dimension = (ary->stable_dimension() > 0 ? ary->stable_dimension() - 1 : 0);
+        const Type* con_type = Type::make_constant_from_array_element(aobj->as_array(), off,
+                                                                      stable_dimension,
+                                                                      memory_type(), is_unsigned());
         if (con_type != NULL) {
           return con_type;
         }
@@ -1785,28 +1723,10 @@
     // For oop loads, we expect the _type to be precise.
     // Optimizations for constant objects
     ciObject* const_oop = tinst->const_oop();
-    if (const_oop != NULL) {
-      // For constant CallSites treat the target field as a compile time constant.
-      if (const_oop->is_call_site()) {
-        ciCallSite* call_site = const_oop->as_call_site();
-        ciField* field = call_site->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/ false);
-        if (field != NULL && field->is_call_site_target()) {
-          ciMethodHandle* target = call_site->get_target();
-          if (target != NULL) {  // just in case
-            ciConstant constant(T_OBJECT, target);
-            const Type* t;
-            if (adr->bottom_type()->is_ptr_to_narrowoop()) {
-              t = TypeNarrowOop::make_from_constant(constant.as_object(), true);
-            } else {
-              t = TypeOopPtr::make_from_constant(constant.as_object(), true);
-            }
-            // Add a dependence for invalidation of the optimization.
-            if (!call_site->is_constant_call_site()) {
-              C->dependencies()->assert_call_site_target_value(call_site, target);
-            }
-            return t;
-          }
-        }
+    if (const_oop != NULL && const_oop->is_instance()) {
+      const Type* con_type = Type::make_constant_from_field(const_oop->as_instance(), off, is_unsigned(), memory_type());
+      if (con_type != NULL) {
+        return con_type;
       }
     }
   } else if (tp->base() == Type::KlassPtr) {
@@ -2979,6 +2899,7 @@
   case Op_MemBarReleaseLock: return new MemBarReleaseLockNode(C, atp, pn);
   case Op_MemBarVolatile:    return new MemBarVolatileNode(C, atp, pn);
   case Op_MemBarCPUOrder:    return new MemBarCPUOrderNode(C, atp, pn);
+  case Op_OnSpinWait:        return new OnSpinWaitNode(C, atp, pn);
   case Op_Initialize:        return new InitializeNode(C, atp, pn);
   case Op_MemBarStoreStore:  return new MemBarStoreStoreNode(C, atp, pn);
   default: ShouldNotReachHere(); return NULL;
diff --git a/hotspot/src/share/vm/opto/memnode.hpp b/hotspot/src/share/vm/opto/memnode.hpp
index 87238ac..438fc74 100644
--- a/hotspot/src/share/vm/opto/memnode.hpp
+++ b/hotspot/src/share/vm/opto/memnode.hpp
@@ -1186,6 +1186,13 @@
   virtual uint ideal_reg() const { return 0; } // not matched in the AD file
 };
 
+class OnSpinWaitNode: public MemBarNode {
+public:
+  OnSpinWaitNode(Compile* C, int alias_idx, Node* precedent)
+    : MemBarNode(C, alias_idx, precedent) {}
+  virtual int Opcode() const;
+};
+
 // Isolation of object setup after an AllocateNode and before next safepoint.
 // (See comment in memnode.cpp near InitializeNode::InitializeNode for semantics.)
 class InitializeNode: public MemBarNode {
diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp
index 2973183..6d8b13a 100644
--- a/hotspot/src/share/vm/opto/node.cpp
+++ b/hotspot/src/share/vm/opto/node.cpp
@@ -2297,7 +2297,8 @@
     if (def && def->outcnt() >= 2) {
       for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) {
         Node* use = def->fast_out(i);
-        if (use->Opcode() == opc &&
+        if (use != this &&
+            use->Opcode() == opc &&
             use->req() == req()) {
           uint j;
           for (j = 0; j < use->req(); j++) {
diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp
index b14505d..e368e62 100644
--- a/hotspot/src/share/vm/opto/node.hpp
+++ b/hotspot/src/share/vm/opto/node.hpp
@@ -722,8 +722,9 @@
     Flag_avoid_back_to_back_after    = Flag_avoid_back_to_back_before << 1,
     Flag_has_call                    = Flag_avoid_back_to_back_after << 1,
     Flag_is_reduction                = Flag_has_call << 1,
-    Flag_is_scheduled                = Flag_is_reduction,
-    Flag_is_expensive                = Flag_is_scheduled << 1,
+    Flag_is_scheduled                = Flag_is_reduction << 1,
+    Flag_has_vector_mask_set         = Flag_is_scheduled << 1,
+    Flag_is_expensive                = Flag_has_vector_mask_set << 1,
     _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
   };
 
@@ -912,6 +913,9 @@
   // It must have the loop's phi as input and provide a def to the phi.
   bool is_reduction() const { return (_flags & Flag_is_reduction) != 0; }
 
+  // The node is a CountedLoopEnd with a mask annotation so as to emit a restore context
+  bool has_vector_mask_set() const { return (_flags & Flag_has_vector_mask_set) != 0; }
+
   // Used in lcm to mark nodes that have scheduled
   bool is_scheduled() const { return (_flags & Flag_is_scheduled) != 0; }
 
diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp
index 7d90d63..39f4abd 100644
--- a/hotspot/src/share/vm/opto/output.cpp
+++ b/hotspot/src/share/vm/opto/output.cpp
@@ -1483,8 +1483,6 @@
   // Compute the size of the first block
   _first_block_size = blk_labels[1].loc_pos() - blk_labels[0].loc_pos();
 
-  assert(cb->insts_size() < 500000, "method is unreasonably large");
-
 #ifdef ASSERT
   for (uint i = 0; i < nblocks; i++) { // For all blocks
     if (jmp_target[i] != 0) {
@@ -1550,6 +1548,10 @@
       }
       dump_asm(node_offsets, node_offset_limit);
       if (xtty != NULL) {
+        // print_metadata and dump_asm above may safepoint which makes us loose the ttylock.
+        // Retake lock too make sure the end tag is coherent, and that xmlStream->pop_tag is done
+        // thread safe
+        ttyLocker ttyl2;
         xtty->tail("opto_assembly");
       }
     }
diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp
index b26a59f..cb9a3e3 100644
--- a/hotspot/src/share/vm/opto/parse.hpp
+++ b/hotspot/src/share/vm/opto/parse.hpp
@@ -168,7 +168,7 @@
 
     // Use init_node/init_graph to initialize Blocks.
     // Block() : _live_locals((uintptr_t*)NULL,0) { ShouldNotReachHere(); }
-    Block() : _live_locals(NULL,0) { ShouldNotReachHere(); }
+    Block() : _live_locals() { ShouldNotReachHere(); }
 
    public:
 
diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp
index 22b3e27..80885d9 100644
--- a/hotspot/src/share/vm/opto/parse1.cpp
+++ b/hotspot/src/share/vm/opto/parse1.cpp
@@ -261,7 +261,7 @@
   Node *locals_addr = basic_plus_adr(osr_buf, osr_buf, (max_locals-1)*wordSize);
 
   // find all the locals that the interpreter thinks contain live oops
-  const BitMap live_oops = method()->live_local_oops_at_bci(osr_bci());
+  const ResourceBitMap live_oops = method()->live_local_oops_at_bci(osr_bci());
   for (index = 0; index < max_locals; index++) {
 
     if (!live_locals.at(index)) {
diff --git a/hotspot/src/share/vm/opto/parse3.cpp b/hotspot/src/share/vm/opto/parse3.cpp
index d9ad4ce..bd6dcf3 100644
--- a/hotspot/src/share/vm/opto/parse3.cpp
+++ b/hotspot/src/share/vm/opto/parse3.cpp
@@ -149,9 +149,9 @@
   // Does this field have a constant value?  If so, just push the value.
   if (field->is_constant()) {
     // final or stable field
-    const Type* con_type = Type::make_constant(field, obj);
-    if (con_type != NULL) {
-      push_node(con_type->basic_type(), makecon(con_type));
+    Node* con = make_constant_from_field(field, obj);
+    if (con != NULL) {
+      push_node(field->layout_type(), con);
       return;
     }
   }
@@ -174,12 +174,16 @@
     if (!field->type()->is_loaded()) {
       type = TypeInstPtr::BOTTOM;
       must_assert_null = true;
-    } else if (field->is_constant() && field->is_static()) {
+    } else if (field->is_static_constant()) {
       // This can happen if the constant oop is non-perm.
       ciObject* con = field->constant_value().as_object();
       // Do not "join" in the previous type; it doesn't add value,
       // and may yield a vacuous result if the field is of interface type.
-      type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
+      if (con->is_null_object()) {
+        type = TypePtr::NULL_PTR;
+      } else {
+        type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
+      }
       assert(type != NULL, "field singleton type must be consistent");
     } else {
       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
diff --git a/hotspot/src/share/vm/opto/regmask.cpp b/hotspot/src/share/vm/opto/regmask.cpp
index 80b418b..2e04c42 100644
--- a/hotspot/src/share/vm/opto/regmask.cpp
+++ b/hotspot/src/share/vm/opto/regmask.cpp
@@ -389,7 +389,7 @@
 //------------------------------Size-------------------------------------------
 // Compute size of register mask in bits
 uint RegMask::Size() const {
-  extern uint8_t bitsInByte[512];
+  extern uint8_t bitsInByte[BITS_IN_BYTE_ARRAY_SIZE];
   uint sum = 0;
   for( int i = 0; i < RM_SIZE; i++ )
     sum +=
diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp
index 37e33ef..53db5ec 100644
--- a/hotspot/src/share/vm/opto/runtime.cpp
+++ b/hotspot/src/share/vm/opto/runtime.cpp
@@ -1663,9 +1663,9 @@
   exception_oop->print_value_on(&tempst);
   tempst.print(" in ");
   CodeBlob* blob = CodeCache::find_blob(exception_pc);
-  if (blob->is_nmethod()) {
-    nmethod* nm = blob->as_nmethod_or_null();
-    nm->method()->print_value_on(&tempst);
+  if (blob->is_compiled()) {
+    CompiledMethod* cm = blob->as_compiled_method_or_null();
+    cm->method()->print_value_on(&tempst);
   } else if (blob->is_runtime_stub()) {
     tempst.print("<runtime-stub>");
   } else {
diff --git a/hotspot/src/share/vm/opto/stringopts.cpp b/hotspot/src/share/vm/opto/stringopts.cpp
index af5c5c4..4ec1419 100644
--- a/hotspot/src/share/vm/opto/stringopts.cpp
+++ b/hotspot/src/share/vm/opto/stringopts.cpp
@@ -1112,7 +1112,7 @@
   if( bt == T_OBJECT ) {
     if (!field->type()->is_loaded()) {
       type = TypeInstPtr::BOTTOM;
-    } else if (field->is_constant()) {
+    } else if (field->is_static_constant()) {
       // This can happen if the constant oop is non-perm.
       ciObject* con = field->constant_value().as_object();
       // Do not "join" in the previous type; it doesn't add value,
diff --git a/hotspot/src/share/vm/opto/subnode.cpp b/hotspot/src/share/vm/opto/subnode.cpp
index 0d06c08..022f28c 100644
--- a/hotspot/src/share/vm/opto/subnode.cpp
+++ b/hotspot/src/share/vm/opto/subnode.cpp
@@ -1533,25 +1533,3 @@
   if( d < 0.0 ) return Type::DOUBLE;
   return TypeD::make( sqrt( d ) );
 }
-
-//=============================================================================
-//------------------------------Value------------------------------------------
-// Compute tan
-const Type* TanDNode::Value(PhaseGVN* phase) const {
-  const Type *t1 = phase->type( in(1) );
-  if( t1 == Type::TOP ) return Type::TOP;
-  if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
-  double d = t1->getd();
-  return TypeD::make( StubRoutines::intrinsic_tan( d ) );
-}
-
-//=============================================================================
-//------------------------------Value------------------------------------------
-// Compute log10
-const Type* Log10DNode::Value(PhaseGVN* phase) const {
-  const Type *t1 = phase->type( in(1) );
-  if( t1 == Type::TOP ) return Type::TOP;
-  if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
-  double d = t1->getd();
-  return TypeD::make( StubRoutines::intrinsic_log10( d ) );
-}
diff --git a/hotspot/src/share/vm/opto/subnode.hpp b/hotspot/src/share/vm/opto/subnode.hpp
index 1812853..63bcd3c 100644
--- a/hotspot/src/share/vm/opto/subnode.hpp
+++ b/hotspot/src/share/vm/opto/subnode.hpp
@@ -408,21 +408,6 @@
   virtual uint ideal_reg() const { return Op_RegD; }
 };
 
-//------------------------------TanDNode---------------------------------------
-// tangens of a double
-class TanDNode : public Node {
-public:
-  TanDNode(Compile* C, Node *c,Node *in1) : Node(c, in1) {
-    init_flags(Flag_is_expensive);
-    C->add_expensive_node(this);
-  }
-  virtual int Opcode() const;
-  const Type *bottom_type() const { return Type::DOUBLE; }
-  virtual uint ideal_reg() const { return Op_RegD; }
-  virtual const Type* Value(PhaseGVN* phase) const;
-};
-
-
 //------------------------------AtanDNode--------------------------------------
 // arcus tangens of a double
 class AtanDNode : public Node {
@@ -448,20 +433,6 @@
   virtual const Type* Value(PhaseGVN* phase) const;
 };
 
-//------------------------------Log10DNode---------------------------------------
-// Log_10 of a double
-class Log10DNode : public Node {
-public:
-  Log10DNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
-    init_flags(Flag_is_expensive);
-    C->add_expensive_node(this);
-  }
-  virtual int Opcode() const;
-  const Type *bottom_type() const { return Type::DOUBLE; }
-  virtual uint ideal_reg() const { return Op_RegD; }
-  virtual const Type* Value(PhaseGVN* phase) const;
-};
-
 //-------------------------------ReverseBytesINode--------------------------------
 // reverse bytes of an integer
 class ReverseBytesINode : public Node {
diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp
index 0086202..695ab06 100644
--- a/hotspot/src/share/vm/opto/superword.cpp
+++ b/hotspot/src/share/vm/opto/superword.cpp
@@ -52,6 +52,7 @@
   _packset(arena(), 8,  0, NULL),         // packs for the current block
   _bb_idx(arena(), (int)(1.10 * phase->C->unique()), 0, 0), // node idx to index in bb
   _block(arena(), 8,  0, NULL),           // nodes in current block
+  _post_block(arena(), 8, 0, NULL),       // nodes common to current block which are marked as post loop vectorizable
   _data_entry(arena(), 8,  0, NULL),      // nodes with all inputs from outside
   _mem_slice_head(arena(), 8,  0, NULL),  // memory slice heads
   _mem_slice_tail(arena(), 8,  0, NULL),  // memory slice tails
@@ -100,10 +101,30 @@
 
   if (!cl->is_valid_counted_loop()) return; // skip malformed counted loop
 
-  if (!cl->is_main_loop() ) return; // skip normal, pre, and post loops
+  bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop());
+  if (post_loop_allowed) {
+    if (cl->is_reduction_loop()) return; // no predication mapping
+    Node *limit = cl->limit();
+    if (limit->is_Con()) return; // non constant limits only
+    // Now check the limit for expressions we do not handle
+    if (limit->is_Add()) {
+      Node *in2 = limit->in(2);
+      if (in2->is_Con()) {
+        int val = in2->get_int();
+        // should not try to program these cases
+        if (val < 0) return;
+      }
+    }
+  }
+
+  // skip any loop that has not been assigned max unroll by analysis
+  if (do_optimization) {
+    if (SuperWordLoopUnrollAnalysis && cl->slp_max_unroll() == 0) return;
+  }
+
   // Check for no control flow in body (other than exit)
   Node *cl_exit = cl->loopexit();
-  if (cl_exit->in(0) != lpt->_head) {
+  if (cl->is_main_loop() && (cl_exit->in(0) != lpt->_head)) {
     #ifndef PRODUCT
       if (TraceSuperWord) {
         tty->print_cr("SuperWord::transform_loop: loop too complicated, cl_exit->in(0) != lpt->_head");
@@ -121,15 +142,16 @@
     return;
   }
 
-  // We only re-enter slp when we vector mapped a queried loop and we want to
-  // continue unrolling, in this case, slp is not subsequently done.
-  if (cl->do_unroll_only()) return;
+  // Skip any loops already optimized by slp
+  if (cl->is_vectorized_loop()) return;
 
-  // Check for pre-loop ending with CountedLoopEnd(Bool(Cmp(x,Opaque1(limit))))
-  CountedLoopEndNode* pre_end = get_pre_loop_end(cl);
-  if (pre_end == NULL) return;
-  Node *pre_opaq1 = pre_end->limit();
-  if (pre_opaq1->Opcode() != Op_Opaque1) return;
+  if (cl->is_main_loop()) {
+    // Check for pre-loop ending with CountedLoopEnd(Bool(Cmp(x,Opaque1(limit))))
+    CountedLoopEndNode* pre_end = get_pre_loop_end(cl);
+    if (pre_end == NULL) return;
+    Node *pre_opaq1 = pre_end->limit();
+    if (pre_opaq1->Opcode() != Op_Opaque1) return;
+  }
 
   init(); // initialize data structures
 
@@ -142,6 +164,19 @@
   if (do_optimization) {
     assert(_packset.length() == 0, "packset must be empty");
     SLP_extract();
+    if (PostLoopMultiversioning && Matcher::has_predicated_vectors()) {
+      if (cl->is_vectorized_loop() && cl->is_main_loop() && !cl->is_reduction_loop()) {
+        IdealLoopTree *lpt_next = lpt->_next;
+        CountedLoopNode *cl_next = lpt_next->_head->as_CountedLoop();
+        _phase->has_range_checks(lpt_next);
+        if (cl_next->is_post_loop() && !cl_next->range_checks_present()) {
+          if (!cl_next->is_vectorized_loop()) {
+            int slp_max_unroll_factor = cl->slp_max_unroll();
+            cl_next->set_slp_max_unroll(slp_max_unroll_factor);
+          }
+        }
+      }
+    }
   }
 }
 
@@ -154,13 +189,17 @@
   Node_Stack nstack((int)ignored_size);
   CountedLoopNode *cl = lpt()->_head->as_CountedLoop();
   Node *cl_exit = cl->loopexit();
+  int rpo_idx = _post_block.length();
+
+  assert(rpo_idx == 0, "post loop block is empty");
 
   // First clear the entries
   for (uint i = 0; i < lpt()->_body.size(); i++) {
     ignored_loop_nodes[i] = -1;
   }
 
-  int max_vector = Matcher::max_vector_size(T_INT);
+  int max_vector = Matcher::max_vector_size(T_BYTE);
+  bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop());
 
   // Process the loop, some/all of the stack entries will not be in order, ergo
   // need to preprocess the ignored initial state before we process the loop
@@ -259,6 +298,7 @@
   if (is_slp) {
     // Now we try to find the maximum supported consistent vector which the machine
     // description can use
+    bool small_basic_type = false;
     for (uint i = 0; i < lpt()->_body.size(); i++) {
       if (ignored_loop_nodes[i] != -1) continue;
 
@@ -269,6 +309,26 @@
       } else {
         bt = n->bottom_type()->basic_type();
       }
+
+      if (post_loop_allowed) {
+        if (!small_basic_type) {
+          switch (bt) {
+          case T_CHAR:
+          case T_BYTE:
+          case T_SHORT:
+            small_basic_type = true;
+            break;
+
+          case T_LONG:
+            // TODO: Remove when support completed for mask context with LONG.
+            //       Support needs to be augmented for logical qword operations, currently we map to dword
+            //       buckets for vectors on logicals as these were legacy.
+            small_basic_type = true;
+            break;
+          }
+        }
+      }
+
       if (is_java_primitive(bt) == false) continue;
 
       int cur_max_vector = Matcher::max_vector_size(bt);
@@ -288,6 +348,12 @@
         if (cur_max_vector < max_vector) {
           max_vector = cur_max_vector;
         }
+
+        // We only process post loops on predicated targets where we want to
+        // mask map the loop to a single iteration
+        if (post_loop_allowed) {
+          _post_block.at_put_grow(rpo_idx++, n);
+        }
       }
     }
     if (is_slp) {
@@ -295,7 +361,14 @@
       cl->mark_passed_slp();
     }
     cl->mark_was_slp();
-    cl->set_slp_max_unroll(local_loop_unroll_factor);
+    if (cl->is_main_loop()) {
+      cl->set_slp_max_unroll(local_loop_unroll_factor);
+    } else if (post_loop_allowed) {
+      if (!small_basic_type) {
+        // avoid replication context for small basic types in programmable masked loops
+        cl->set_slp_max_unroll(local_loop_unroll_factor);
+      }
+    }
   }
 }
 
@@ -350,67 +423,104 @@
   if (!construct_bb()) {
     return; // Exit if no interesting nodes or complex graph.
   }
+
   // build    _dg, _disjoint_ptrs
   dependence_graph();
 
   // compute function depth(Node*)
   compute_max_depth();
 
-  if (_do_vector_loop) {
-    if (mark_generations() != -1) {
-      hoist_loads_in_graph(); // this only rebuild the graph; all basic structs need rebuild explicitly
+  CountedLoopNode *cl = lpt()->_head->as_CountedLoop();
+  bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop());
+  if (cl->is_main_loop()) {
+    if (_do_vector_loop) {
+      if (mark_generations() != -1) {
+        hoist_loads_in_graph(); // this only rebuild the graph; all basic structs need rebuild explicitly
 
-      if (!construct_bb()) {
-        return; // Exit if no interesting nodes or complex graph.
+        if (!construct_bb()) {
+          return; // Exit if no interesting nodes or complex graph.
+        }
+        dependence_graph();
+        compute_max_depth();
       }
-      dependence_graph();
-      compute_max_depth();
-    }
 
 #ifndef PRODUCT
-    if (TraceSuperWord) {
-      tty->print_cr("\nSuperWord::_do_vector_loop: graph after hoist_loads_in_graph");
-      _lpt->dump_head();
-      for (int j = 0; j < _block.length(); j++) {
-        Node* n = _block.at(j);
-        int d = depth(n);
-        for (int i = 0;  i < d; i++) tty->print("%s", "  ");
-        tty->print("%d :", d);
-        n->dump();
-      }
-    }
-#endif
-  }
-
-  compute_vector_element_type();
-
-  // Attempt vectorization
-
-  find_adjacent_refs();
-
-  extend_packlist();
-
-  if (_do_vector_loop) {
-    if (_packset.length() == 0) {
       if (TraceSuperWord) {
-        tty->print_cr("\nSuperWord::_do_vector_loop DFA could not build packset, now trying to build anyway");
+        tty->print_cr("\nSuperWord::_do_vector_loop: graph after hoist_loads_in_graph");
+        _lpt->dump_head();
+        for (int j = 0; j < _block.length(); j++) {
+          Node* n = _block.at(j);
+          int d = depth(n);
+          for (int i = 0; i < d; i++) tty->print("%s", "  ");
+          tty->print("%d :", d);
+          n->dump();
+        }
       }
-      pack_parallel();
+#endif
+    }
+
+    compute_vector_element_type();
+
+    // Attempt vectorization
+
+    find_adjacent_refs();
+
+    extend_packlist();
+
+    if (_do_vector_loop) {
+      if (_packset.length() == 0) {
+        if (TraceSuperWord) {
+          tty->print_cr("\nSuperWord::_do_vector_loop DFA could not build packset, now trying to build anyway");
+        }
+        pack_parallel();
+      }
+    }
+
+    combine_packs();
+
+    construct_my_pack_map();
+
+    if (_do_vector_loop) {
+      merge_packs_to_cmovd();
+    }
+
+    filter_packs();
+
+    schedule();
+  } else if (post_loop_allowed) {
+    int saved_mapped_unroll_factor = cl->slp_max_unroll();
+    if (saved_mapped_unroll_factor) {
+      int vector_mapped_unroll_factor = saved_mapped_unroll_factor;
+
+      // now reset the slp_unroll_factor so that we can check the analysis mapped
+      // what the vector loop was mapped to
+      cl->set_slp_max_unroll(0);
+
+      // do the analysis on the post loop
+      unrolling_analysis(vector_mapped_unroll_factor);
+
+      // if our analyzed loop is a canonical fit, start processing it
+      if (vector_mapped_unroll_factor == saved_mapped_unroll_factor) {
+        // now add the vector nodes to packsets
+        for (int i = 0; i < _post_block.length(); i++) {
+          Node* n = _post_block.at(i);
+          Node_List* singleton = new Node_List();
+          singleton->push(n);
+          _packset.append(singleton);
+          set_my_pack(n, singleton);
+        }
+
+        // map base types for vector usage
+        compute_vector_element_type();
+      } else {
+        return;
+      }
+    } else {
+      // for some reason we could not map the slp analysis state of the vectorized loop
+      return;
     }
   }
 
-  combine_packs();
-
-  construct_my_pack_map();
-
-  if (_do_vector_loop) {
-    merge_packs_to_cmovd();
-  }
-
-  filter_packs();
-
-  schedule();
-
   output();
 }
 
@@ -811,6 +921,7 @@
 // Add dependence edges to load/store nodes for memory dependence
 //    A.out()->DependNode.in(1) and DependNode.out()->B.prec(x)
 void SuperWord::dependence_graph() {
+  CountedLoopNode *cl = lpt()->_head->as_CountedLoop();
   // First, assign a dependence node to each memory node
   for (int i = 0; i < _block.length(); i++ ) {
     Node *n = _block.at(i);
@@ -825,7 +936,9 @@
     Node* n_tail = _mem_slice_tail.at(i);
 
     // Get slice in predecessor order (last is first)
-    mem_slice_preds(n_tail, n, _nlist);
+    if (cl->is_main_loop()) {
+      mem_slice_preds(n_tail, n, _nlist);
+    }
 
 #ifndef PRODUCT
     if(TraceSuperWord && Verbose) {
@@ -2029,20 +2142,23 @@
   }
 #endif
 
-  // MUST ENSURE main loop's initial value is properly aligned:
-  //  (iv_initial_value + min_iv_offset) % vector_width_in_bytes() == 0
+  CountedLoopNode *cl = lpt()->_head->as_CountedLoop();
+  if (cl->is_main_loop()) {
+    // MUST ENSURE main loop's initial value is properly aligned:
+    //  (iv_initial_value + min_iv_offset) % vector_width_in_bytes() == 0
 
-  align_initial_loop_index(align_to_ref());
+    align_initial_loop_index(align_to_ref());
 
-  // Insert extract (unpack) operations for scalar uses
-  for (int i = 0; i < _packset.length(); i++) {
-    insert_extracts(_packset.at(i));
+    // Insert extract (unpack) operations for scalar uses
+    for (int i = 0; i < _packset.length(); i++) {
+      insert_extracts(_packset.at(i));
+    }
   }
 
   Compile* C = _phase->C;
-  CountedLoopNode *cl = lpt()->_head->as_CountedLoop();
   uint max_vlen_in_bytes = 0;
   uint max_vlen = 0;
+  bool can_process_post_loop = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop());
 
   NOT_PRODUCT(if(is_trace_loop_reverse()) {tty->print_cr("SWPointer::output: print loop before create_reserve_version_of_loop"); print_loop(true);})
 
@@ -2064,6 +2180,10 @@
       Node* vn = NULL;
       Node* low_adr = p->at(0);
       Node* first   = executed_first(p);
+      if (can_process_post_loop) {
+        // override vlen with the main loops vector length
+        vlen = cl->slp_max_unroll();
+      }
       NOT_PRODUCT(if(is_trace_cmov()) {tty->print_cr("SWPointer::output: %d executed first, %d executed last in pack", first->_idx, n->_idx); print_pack(p);})
       int   opc = n->Opcode();
       if (n->is_Load()) {
@@ -2153,6 +2273,10 @@
         vn = VectorNode::make(opc, in, NULL, vlen, velt_basic_type(n));
         vlen_in_bytes = vn->as_Vector()->length_in_bytes();
       } else if (is_cmov_pack(p)) {
+        if (can_process_post_loop) {
+          // do not refactor of flow in post loop context
+          return;
+        }
         if (!n->is_CMove()) {
           continue;
         }
@@ -2217,6 +2341,7 @@
         ShouldNotReachHere();
       }
 
+      _block.at_put(i, vn);
       _igvn.register_new_node_with_optimizer(vn);
       _phase->set_ctrl(vn, _phase->get_ctrl(p->at(0)));
       for (uint j = 0; j < p->size(); j++) {
@@ -2225,6 +2350,14 @@
       }
       _igvn._worklist.push(vn);
 
+      if (can_process_post_loop) {
+        // first check if the vector size if the maximum vector which we can use on the machine,
+        // other vector size have reduced values for predicated data mapping.
+        if (vlen_in_bytes != (uint)MaxVectorSize) {
+          return;
+        }
+      }
+
       if (vlen_in_bytes > max_vlen_in_bytes) {
         max_vlen = vlen;
         max_vlen_in_bytes = vlen_in_bytes;
@@ -2247,15 +2380,38 @@
         if (TraceSuperWordLoopUnrollAnalysis) {
           tty->print_cr("vector loop(unroll=%d, len=%d)\n", max_vlen, max_vlen_in_bytes*BitsPerByte);
         }
-        // For atomic unrolled loops which are vector mapped, instigate more unrolling.
+
+        // For atomic unrolled loops which are vector mapped, instigate more unrolling
         cl->set_notpassed_slp();
-        // if vector resources are limited, do not allow additional unrolling
-        if (FLOATPRESSURE > 8) {
-          C->set_major_progress();
+        if (cl->is_main_loop()) {
+          // if vector resources are limited, do not allow additional unrolling, also
+          // do not unroll more on pure vector loops which were not reduced so that we can
+          // program the post loop to single iteration execution.
+          if (FLOATPRESSURE > 8) {
+            C->set_major_progress();
+            cl->mark_do_unroll_only();
+          }
         }
-        cl->mark_do_unroll_only();
+
         if (do_reserve_copy()) {
           cl->mark_loop_vectorized();
+          if (can_process_post_loop) {
+            // Now create the difference of trip and limit and use it as our mask index.
+            // Note: We limited the unroll of the vectorized loop so that
+            //       only vlen-1 size iterations can remain to be mask programmed.
+            Node *incr = cl->incr();
+            SubINode *index = new SubINode(cl->limit(), cl->init_trip());
+            _igvn.register_new_node_with_optimizer(index);
+            SetVectMaskINode  *mask = new SetVectMaskINode(_phase->get_ctrl(cl->init_trip()), index);
+            _igvn.register_new_node_with_optimizer(mask);
+            // make this a single iteration loop
+            AddINode *new_incr = new AddINode(incr->in(1), mask);
+            _igvn.register_new_node_with_optimizer(new_incr);
+            _phase->set_ctrl(new_incr, _phase->get_ctrl(incr));
+            _igvn.replace_node(incr, new_incr);
+            cl->mark_is_multiversioned();
+            cl->loopexit()->add_flag(Node::Flag_has_vector_mask_set);
+          }
         }
       }
     }
@@ -2274,6 +2430,12 @@
   Node* p0 = p->at(0);
   uint vlen = p->size();
   Node* opd = p0->in(opd_idx);
+  CountedLoopNode *cl = lpt()->_head->as_CountedLoop();
+
+  if (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop()) {
+    // override vlen with the main loops vector length
+    vlen = cl->slp_max_unroll();
+  }
 
   if (same_inputs(p, opd_idx)) {
     if (opd->is_Vector() || opd->is_LoadVector()) {
@@ -3068,8 +3230,7 @@
                  : (Node*) new MaxINode(lim, orig_limit);
   _igvn.register_new_node_with_optimizer(constrained);
   _phase->set_ctrl(constrained, pre_ctrl);
-  _igvn.hash_delete(pre_opaq);
-  pre_opaq->set_req(1, constrained);
+  _igvn.replace_input_of(pre_opaq, 1, constrained);
 }
 
 //----------------------------get_pre_loop_end---------------------------
@@ -3090,13 +3251,13 @@
   return pre_end;
 }
 
-
 //------------------------------init---------------------------
 void SuperWord::init() {
   _dg.init();
   _packset.clear();
   _disjoint_ptrs.clear();
   _block.clear();
+  _post_block.clear();
   _data_entry.clear();
   _mem_slice_head.clear();
   _mem_slice_tail.clear();
@@ -3120,6 +3281,7 @@
   _packset.clear();
   _disjoint_ptrs.clear();
   _block.clear();
+  _post_block.clear();
   _data_entry.clear();
   _mem_slice_head.clear();
   _mem_slice_tail.clear();
diff --git a/hotspot/src/share/vm/opto/superword.hpp b/hotspot/src/share/vm/opto/superword.hpp
index ccc154f..eea7c55 100644
--- a/hotspot/src/share/vm/opto/superword.hpp
+++ b/hotspot/src/share/vm/opto/superword.hpp
@@ -261,6 +261,7 @@
   GrowableArray<int> _bb_idx;            // Map from Node _idx to index within block
 
   GrowableArray<Node*> _block;           // Nodes in current block
+  GrowableArray<Node*> _post_block;      // Nodes in post loop block
   GrowableArray<Node*> _data_entry;      // Nodes with all inputs from outside
   GrowableArray<Node*> _mem_slice_head;  // Memory slice head nodes
   GrowableArray<Node*> _mem_slice_tail;  // Memory slice tail nodes
diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp
index babc67b..84cf9d2 100644
--- a/hotspot/src/share/vm/opto/type.cpp
+++ b/hotspot/src/share/vm/opto/type.cpp
@@ -225,74 +225,156 @@
 
 
 //-----------------------make_from_constant------------------------------------
-const Type* Type::make_from_constant(ciConstant constant, bool require_constant) {
+const Type* Type::make_from_constant(ciConstant constant, bool require_constant,
+                                     int stable_dimension, bool is_narrow_oop,
+                                     bool is_autobox_cache) {
   switch (constant.basic_type()) {
-  case T_BOOLEAN:  return TypeInt::make(constant.as_boolean());
-  case T_CHAR:     return TypeInt::make(constant.as_char());
-  case T_BYTE:     return TypeInt::make(constant.as_byte());
-  case T_SHORT:    return TypeInt::make(constant.as_short());
-  case T_INT:      return TypeInt::make(constant.as_int());
-  case T_LONG:     return TypeLong::make(constant.as_long());
-  case T_FLOAT:    return TypeF::make(constant.as_float());
-  case T_DOUBLE:   return TypeD::make(constant.as_double());
-  case T_ARRAY:
-  case T_OBJECT:
-    {
-      // cases:
-      //   can_be_constant    = (oop not scavengable || ScavengeRootsInCode != 0)
-      //   should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
-      // An oop is not scavengable if it is in the perm gen.
-      ciObject* oop_constant = constant.as_object();
-      if (oop_constant->is_null_object()) {
-        return Type::get_zero_type(T_OBJECT);
-      } else if (require_constant || oop_constant->should_be_constant()) {
-        return TypeOopPtr::make_from_constant(oop_constant, require_constant);
+    case T_BOOLEAN:  return TypeInt::make(constant.as_boolean());
+    case T_CHAR:     return TypeInt::make(constant.as_char());
+    case T_BYTE:     return TypeInt::make(constant.as_byte());
+    case T_SHORT:    return TypeInt::make(constant.as_short());
+    case T_INT:      return TypeInt::make(constant.as_int());
+    case T_LONG:     return TypeLong::make(constant.as_long());
+    case T_FLOAT:    return TypeF::make(constant.as_float());
+    case T_DOUBLE:   return TypeD::make(constant.as_double());
+    case T_ARRAY:
+    case T_OBJECT: {
+        // cases:
+        //   can_be_constant    = (oop not scavengable || ScavengeRootsInCode != 0)
+        //   should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
+        // An oop is not scavengable if it is in the perm gen.
+        const Type* con_type = NULL;
+        ciObject* oop_constant = constant.as_object();
+        if (oop_constant->is_null_object()) {
+          con_type = Type::get_zero_type(T_OBJECT);
+        } else if (require_constant || oop_constant->should_be_constant()) {
+          con_type = TypeOopPtr::make_from_constant(oop_constant, require_constant);
+          if (con_type != NULL) {
+            if (Compile::current()->eliminate_boxing() && is_autobox_cache) {
+              con_type = con_type->is_aryptr()->cast_to_autobox_cache(true);
+            }
+            if (stable_dimension > 0) {
+              assert(FoldStableValues, "sanity");
+              assert(!con_type->is_zero_type(), "default value for stable field");
+              con_type = con_type->is_aryptr()->cast_to_stable(true, stable_dimension);
+            }
+          }
+        }
+        if (is_narrow_oop) {
+          con_type = con_type->make_narrowoop();
+        }
+        return con_type;
       }
-    }
-  case T_ILLEGAL:
-    // Invalid ciConstant returned due to OutOfMemoryError in the CI
-    assert(Compile::current()->env()->failing(), "otherwise should not see this");
-    return NULL;
+    case T_ILLEGAL:
+      // Invalid ciConstant returned due to OutOfMemoryError in the CI
+      assert(Compile::current()->env()->failing(), "otherwise should not see this");
+      return NULL;
   }
   // Fall through to failure
   return NULL;
 }
 
+static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) {
+  BasicType conbt = con.basic_type();
+  switch (conbt) {
+    case T_BOOLEAN: conbt = T_BYTE;   break;
+    case T_ARRAY:   conbt = T_OBJECT; break;
+  }
+  switch (loadbt) {
+    case T_BOOLEAN:   loadbt = T_BYTE;   break;
+    case T_NARROWOOP: loadbt = T_OBJECT; break;
+    case T_ARRAY:     loadbt = T_OBJECT; break;
+    case T_ADDRESS:   loadbt = T_OBJECT; break;
+  }
+  if (conbt == loadbt) {
+    if (is_unsigned && conbt == T_BYTE) {
+      // LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE).
+      return ciConstant(T_INT, con.as_int() & 0xFF);
+    } else {
+      return con;
+    }
+  }
+  if (conbt == T_SHORT && loadbt == T_CHAR) {
+    // LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR).
+    return ciConstant(T_INT, con.as_int() & 0xFFFF);
+  }
+  return ciConstant(); // T_ILLEGAL
+}
 
-const Type* Type::make_constant(ciField* field, Node* obj) {
-  if (!field->is_constant())  return NULL;
+// Try to constant-fold a stable array element.
+const Type* Type::make_constant_from_array_element(ciArray* array, int off, int stable_dimension,
+                                                   BasicType loadbt, bool is_unsigned_load) {
+  // Decode the results of GraphKit::array_element_address.
+  ciConstant element_value = array->element_value_by_offset(off);
+  if (element_value.basic_type() == T_ILLEGAL) {
+    return NULL; // wrong offset
+  }
+  ciConstant con = check_mismatched_access(element_value, loadbt, is_unsigned_load);
 
-  const Type* con_type = NULL;
+  assert(con.basic_type() != T_ILLEGAL, "elembt=%s; loadbt=%s; unsigned=%d",
+         type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load);
+
+  if (con.is_valid() &&          // not a mismatched access
+      !con.is_null_or_zero()) {  // not a default value
+    bool is_narrow_oop = (loadbt == T_NARROWOOP);
+    return Type::make_from_constant(con, /*require_constant=*/true, stable_dimension, is_narrow_oop, /*is_autobox_cache=*/false);
+  }
+  return NULL;
+}
+
+const Type* Type::make_constant_from_field(ciInstance* holder, int off, bool is_unsigned_load, BasicType loadbt) {
+  ciField* field;
+  ciType* type = holder->java_mirror_type();
+  if (type != NULL && type->is_instance_klass() && off >= InstanceMirrorKlass::offset_of_static_fields()) {
+    // Static field
+    field = type->as_instance_klass()->get_field_by_offset(off, /*is_static=*/true);
+  } else {
+    // Instance field
+    field = holder->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/false);
+  }
+  if (field == NULL) {
+    return NULL; // Wrong offset
+  }
+  return Type::make_constant_from_field(field, holder, loadbt, is_unsigned_load);
+}
+
+const Type* Type::make_constant_from_field(ciField* field, ciInstance* holder,
+                                           BasicType loadbt, bool is_unsigned_load) {
+  if (!field->is_constant()) {
+    return NULL; // Non-constant field
+  }
+  ciConstant field_value;
   if (field->is_static()) {
     // final static field
-    con_type = Type::make_from_constant(field->constant_value(), /*require_const=*/true);
-    if (Compile::current()->eliminate_boxing() && field->is_autobox_cache() && con_type != NULL) {
-      con_type = con_type->is_aryptr()->cast_to_autobox_cache(true);
-    }
-  } else {
+    field_value = field->constant_value();
+  } else if (holder != NULL) {
     // final or stable non-static field
     // Treat final non-static fields of trusted classes (classes in
     // java.lang.invoke and sun.invoke packages and subpackages) as
     // compile time constants.
-    if (obj->is_Con()) {
-      const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
-      ciObject* constant_oop = oop_ptr->const_oop();
-      ciConstant constant = field->constant_value_of(constant_oop);
-      con_type = Type::make_from_constant(constant, /*require_const=*/true);
-    }
+    field_value = field->constant_value_of(holder);
   }
-  if (FoldStableValues && field->is_stable() && con_type != NULL) {
-    if (con_type->is_zero_type()) {
-      return NULL; // the field hasn't been initialized yet
-    } else if (con_type->isa_oopptr()) {
-      const Type* stable_type = Type::get_const_type(field->type());
-      if (field->type()->is_array_klass()) {
-        int stable_dimension = field->type()->as_array_klass()->dimension();
-        stable_type = stable_type->is_aryptr()->cast_to_stable(true, stable_dimension);
-      }
-      if (stable_type != NULL) {
-        con_type = con_type->join_speculative(stable_type);
-      }
+  if (!field_value.is_valid()) {
+    return NULL; // Not a constant
+  }
+
+  ciConstant con = check_mismatched_access(field_value, loadbt, is_unsigned_load);
+
+  assert(con.is_valid(), "elembt=%s; loadbt=%s; unsigned=%d",
+         type2name(field_value.basic_type()), type2name(loadbt), is_unsigned_load);
+
+  bool is_stable_array = FoldStableValues && field->is_stable() && field->type()->is_array_klass();
+  int stable_dimension = (is_stable_array ? field->type()->as_array_klass()->dimension() : 0);
+  bool is_narrow_oop = (loadbt == T_NARROWOOP);
+
+  const Type* con_type = make_from_constant(con, /*require_constant=*/ true,
+                                            stable_dimension, is_narrow_oop,
+                                            field->is_autobox_cache());
+  if (con_type != NULL && field->is_call_site_target()) {
+    ciCallSite* call_site = holder->as_call_site();
+    if (!call_site->is_constant_call_site()) {
+      ciMethodHandle* target = call_site->get_target();
+      Compile::current()->dependencies()->assert_call_site_target_value(call_site, target);
     }
   }
   return con_type;
diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp
index 6636af7..4c79e90 100644
--- a/hotspot/src/share/vm/opto/type.hpp
+++ b/hotspot/src/share/vm/opto/type.hpp
@@ -417,9 +417,26 @@
   static const Type* get_typeflow_type(ciType* type);
 
   static const Type* make_from_constant(ciConstant constant,
-                                        bool require_constant = false);
+                                        bool require_constant = false,
+                                        int stable_dimension = 0,
+                                        bool is_narrow = false,
+                                        bool is_autobox_cache = false);
 
-  static const Type* make_constant(ciField* field, Node* obj);
+  static const Type* make_constant_from_field(ciInstance* holder,
+                                              int off,
+                                              bool is_unsigned_load,
+                                              BasicType loadbt);
+
+  static const Type* make_constant_from_field(ciField* field,
+                                              ciInstance* holder,
+                                              BasicType loadbt,
+                                              bool is_unsigned_load);
+
+  static const Type* make_constant_from_array_element(ciArray* array,
+                                                      int off,
+                                                      int stable_dimension,
+                                                      BasicType loadbt,
+                                                      bool is_unsigned_load);
 
   // Speculative type helper methods. See TypePtr.
   virtual const TypePtr* speculative() const                                  { return NULL; }
diff --git a/hotspot/src/share/vm/opto/vectornode.hpp b/hotspot/src/share/vm/opto/vectornode.hpp
index ee7b736..04df1eb 100644
--- a/hotspot/src/share/vm/opto/vectornode.hpp
+++ b/hotspot/src/share/vm/opto/vectornode.hpp
@@ -529,6 +529,7 @@
                               Node* adr, const TypePtr* atyp,
                               uint vlen, BasicType bt,
                               ControlDependency control_dependency = LoadNode::DependsOnlyOnTest);
+  uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); }
 };
 
 //------------------------------StoreVectorNode--------------------------------
@@ -553,6 +554,8 @@
   static StoreVectorNode* make(int opc, Node* ctl, Node* mem,
                                Node* adr, const TypePtr* atyp, Node* val,
                                uint vlen);
+
+  uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); }
 };
 
 
@@ -791,4 +794,15 @@
   virtual uint ideal_reg() const { return Op_RegD; }
 };
 
+//------------------------------SetVectMaskINode-------------------------------
+// Provide a mask for a vector predicate machine
+class SetVectMaskINode : public Node {
+public:
+  SetVectMaskINode(Node *c, Node *in1) : Node(c, in1) {}
+  virtual int Opcode() const;
+  const Type *bottom_type() const { return TypeInt::INT; }
+  virtual uint ideal_reg() const { return Op_RegI; }
+  virtual const Type *Value(PhaseGVN *phase) const { return TypeInt::INT; }
+};
+
 #endif // SHARE_VM_OPTO_VECTORNODE_HPP
diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp
index 8c1a020..a6f10fc 100644
--- a/hotspot/src/share/vm/prims/jni.cpp
+++ b/hotspot/src/share/vm/prims/jni.cpp
@@ -350,7 +350,7 @@
                                                    &st,
                                                    CHECK_NULL);
 
-  if (log_is_enabled(Debug, classresolve) && k != NULL) {
+  if (log_is_enabled(Debug, class, resolve) && k != NULL) {
     trace_class_resolution(k);
   }
 
@@ -420,7 +420,7 @@
   result = find_class_from_class_loader(env, sym, true, loader,
                                         protection_domain, true, thread);
 
-  if (log_is_enabled(Debug, classresolve) && result != NULL) {
+  if (log_is_enabled(Debug, class, resolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
   }
 
@@ -3296,7 +3296,7 @@
   TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL);
   jclass result =  find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL);
 
-  if (log_is_enabled(Debug, classresolve) && result != NULL) {
+  if (log_is_enabled(Debug, class, resolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
   }
   return result;
diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp
index 834e1ae..a0cb118 100644
--- a/hotspot/src/share/vm/prims/jvm.cpp
+++ b/hotspot/src/share/vm/prims/jvm.cpp
@@ -210,9 +210,9 @@
       const char * to = to_class->external_name();
       // print in a single call to reduce interleaving between threads
       if (source_file != NULL) {
-        log_debug(classresolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace);
+        log_debug(class, resolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace);
       } else {
-        log_debug(classresolve)("%s %s (%s)", from, to, trace);
+        log_debug(class, resolve)("%s %s (%s)", from, to, trace);
       }
     }
   }
@@ -389,7 +389,7 @@
       PUTPROP(props, "sun.nio.MaxDirectMemorySize", "-1");
     } else {
       char as_chars[256];
-      jio_snprintf(as_chars, sizeof(as_chars), SIZE_FORMAT, MaxDirectMemorySize);
+      jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT, MaxDirectMemorySize);
       PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars);
     }
   }
@@ -805,7 +805,7 @@
     return NULL;
   }
 
-  if (log_is_enabled(Debug, classresolve)) {
+  if (log_is_enabled(Debug, class, resolve)) {
     trace_class_resolution(k);
   }
   return (jclass) JNIHandles::make_local(env, k->java_mirror());
@@ -842,7 +842,7 @@
   jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
                                                h_prot, false, THREAD);
 
-  if (log_is_enabled(Debug, classresolve) && result != NULL) {
+  if (log_is_enabled(Debug, class, resolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
   }
   return result;
@@ -872,7 +872,7 @@
   jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
                                                h_prot, true, thread);
 
-  if (log_is_enabled(Debug, classresolve) && result != NULL) {
+  if (log_is_enabled(Debug, class, resolve) && result != NULL) {
     // this function is generally only used for class loading during verification.
     ResourceMark rm;
     oop from_mirror = JNIHandles::resolve_non_null(from);
@@ -882,7 +882,7 @@
     oop mirror = JNIHandles::resolve_non_null(result);
     Klass* to_class = java_lang_Class::as_Klass(mirror);
     const char * to = to_class->external_name();
-    log_debug(classresolve)("%s %s (verification)", from_name, to);
+    log_debug(class, resolve)("%s %s (verification)", from_name, to);
   }
 
   return result;
@@ -950,7 +950,7 @@
                                                    &st,
                                                    CHECK_NULL);
 
-  if (log_is_enabled(Debug, classresolve) && k != NULL) {
+  if (log_is_enabled(Debug, class, resolve) && k != NULL) {
     trace_class_resolution(k);
   }
 
diff --git a/hotspot/src/share/vm/prims/jvmti.xml b/hotspot/src/share/vm/prims/jvmti.xml
index f6a18c7..54af064 100644
--- a/hotspot/src/share/vm/prims/jvmti.xml
+++ b/hotspot/src/share/vm/prims/jvmti.xml
@@ -6482,6 +6482,7 @@
       <synopsis>Get All Modules</synopsis>
       <description>
 	Return an array of all modules loaded in the virtual machine.
+        The array includes the unnamed module for each class loader.
 	The number of modules in the array is returned via
 	<code>module_count_ptr</code>, and the array itself via
 	<code>modules_ptr</code>.
@@ -9994,6 +9995,17 @@
           See <eventlink id="VMStart"/>.
         </description>
       </capabilityfield>
+      <capabilityfield id="can_generate_early_class_hook_events" since="9">
+        <description>
+          Can generate the <eventlink id="ClassFileLoadHook"/> events
+          in the primordial phase. If this capability and
+          <internallink id="jvmtiCapabilities.can_generate_all_class_hook_events">
+          <code>can_generate_all_class_hook_events</code></internallink>
+          are enabled then the <eventlink id="ClassFileLoadHook"/> events
+          can be posted for classes loaded in the primordial phase.
+          See <eventlink id="ClassFileLoadHook"/>.
+        </description>
+      </capabilityfield>
     </capabilitiestypedef>
 
     <function id="GetPotentialCapabilities" jkernel="yes" phase="onload" num="140">
@@ -12404,7 +12416,7 @@
     </parameters>
   </event>
 
-  <event label="Class File Load Hook" phase="start"
+  <event label="Class File Load Hook" phase="any"
 	 id="ClassFileLoadHook" const="JVMTI_EVENT_CLASS_FILE_LOAD_HOOK" num="54">
     <description>
       This event is sent when the VM obtains class file data,
@@ -12420,7 +12432,13 @@
       <internallink id="bci">bytecode instrumentation</internallink>
       for usage information.
       <p/>
-    This event may be sent before the VM is initialized (the start 
+    When the capabilities
+    <internallink id="jvmtiCapabilities.can_generate_early_class_hook_events">
+    <code>can_generate_early_class_hook_events</code></internallink> and
+    <internallink id="jvmtiCapabilities.can_generate_all_class_hook_events">
+    <code>can_generate_all_class_hook_events</code></internallink>
+    are enabled then this event may be sent in the primordial phase.
+    Otherwise, this event may be sent before the VM is initialized (the start 
     <functionlink id="GetPhase">phase</functionlink>).
     Some classes might not be compatible
     with the function (eg. ROMized classes) and this event will not be
@@ -12470,6 +12488,7 @@
   <origin>jvmpi</origin>
     <capabilities>
       <capability id="can_generate_all_class_hook_events"></capability>
+      <capability id="can_generate_early_class_hook_events"></capability>
     </capabilities>
     <parameters>
       <param id="jni_env">
@@ -12542,7 +12561,7 @@
   <event label="VM Start Event"
 	 id="VMStart" const="JVMTI_EVENT_VM_START" num="57" phase="start">
     <description>
-      The VM initialization event signals the start of the VM.
+      The VM start event signals the start of the VM.
       At this time JNI is live but the VM is not yet fully initialized.
       Once this event is generated, the agent is free to call any JNI function.
       This event signals the beginning of the start phase,
@@ -14419,6 +14438,10 @@
        - Add new capability can_generate_early_vmstart
        - Allow CompiledMethodLoad events at start phase
   </change>
+  <change date="14 April 2016" version="9.0.0">
+      Support for modules:
+       - Add new capability can_generate_early_class_hook_events
+  </change>
 </changehistory>
 
 </specification>
diff --git a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
index c48de41..c197919 100644
--- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -693,7 +693,7 @@
   if (JvmtiExport::can_maintain_original_method_order()) {
     int index;
     int original_index;
-    intArray method_order(num_methods, 0);
+    intArray method_order(num_methods, num_methods, 0);
 
     // invert the method order mapping
     for (index = 0; index < num_methods; index++) {
diff --git a/hotspot/src/share/vm/prims/jvmtiEnter.xsl b/hotspot/src/share/vm/prims/jvmtiEnter.xsl
index 2d012a8..bdb7915 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnter.xsl
+++ b/hotspot/src/share/vm/prims/jvmtiEnter.xsl
@@ -40,6 +40,7 @@
 # include "memory/resourceArea.hpp"
 # include "utilities/macros.hpp"
 #if INCLUDE_JVMTI
+# include "logging/log.hpp"
 # include "oops/oop.inline.hpp"
 # include "prims/jvmtiEnter.hpp"
 # include "prims/jvmtiRawMonitor.hpp"
@@ -415,7 +416,7 @@
     <xsl:value-of select="$space"/>
     <xsl:text>  if (trace_flags) {</xsl:text>
     <xsl:value-of select="$space"/>
-    <xsl:text>    tty->print_cr("JVMTI [non-attached thread] %s %s",  func_name,</xsl:text>
+    <xsl:text>    log_trace(jvmti)("[non-attached thread] %s %s",  func_name,</xsl:text>
     <xsl:value-of select="$space"/>
     <xsl:text>    JvmtiUtil::error_name(JVMTI_ERROR_UNATTACHED_THREAD));</xsl:text>
     <xsl:value-of select="$space"/>
@@ -452,7 +453,7 @@
 </xsl:text>
     <xsl:if test="$trace='Trace'">
       <xsl:text>    if (trace_flags) {
-          tty->print_cr("JVMTI [%s] %s %s",  curr_thread_name, func_name, 
+          log_trace(jvmti)("[%s] %s %s",  curr_thread_name, func_name, 
                     JvmtiUtil::error_name(JVMTI_ERROR_MUST_POSSESS_CAPABILITY));
     }
 </xsl:text>
@@ -486,7 +487,7 @@
 </xsl:text>
     <xsl:if test="$trace='Trace'">
       <xsl:text>    if (trace_flags) {
-          tty->print_cr("JVMTI [-] %s %s",  func_name, 
+          log_trace(jvmti)("[-] %s %s",  func_name, 
                     JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
     }
 </xsl:text>
@@ -509,7 +510,7 @@
 </xsl:text>
     <xsl:if test="$trace='Trace'">
       <xsl:text>    if (trace_flags) {
-          tty->print_cr("JVMTI [-] %s %s",  func_name, 
+          log_trace(jvmti)("[-] %s %s",  func_name, 
                     JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
     }
 </xsl:text>
@@ -522,7 +523,7 @@
 </xsl:text>
     <xsl:if test="$trace='Trace'">
       <xsl:text>    if (trace_flags) {
-          tty->print_cr("JVMTI [-] %s %s",  func_name, 
+          log_trace(jvmti)("[-] %s %s",  func_name, 
                     JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
     }
 </xsl:text>
@@ -541,7 +542,7 @@
 </xsl:text>
     <xsl:if test="$trace='Trace'">
       <xsl:text>    if (trace_flags) {
-          tty->print_cr("JVMTI [%s] %s %s  env=" PTR_FORMAT,  curr_thread_name, func_name, 
+          log_trace(jvmti)("[%s] %s %s  env=" PTR_FORMAT,  curr_thread_name, func_name, 
                     JvmtiUtil::error_name(JVMTI_ERROR_INVALID_ENVIRONMENT), p2i(env));
     }
 </xsl:text>
@@ -667,7 +668,7 @@
     <xsl:with-param name="endParam" select="."/>
   </xsl:apply-templates>
   <xsl:text>      }
-        tty->print_cr("JVMTI [%s] %s } %s - erroneous arg is </xsl:text>
+        log_error(jvmti)("[%s] %s } %s - erroneous arg is </xsl:text>
     <xsl:value-of select="@id"/>
     <xsl:value-of select="$comment"/>
     <xsl:text>",  curr_thread_name, func_name, 
@@ -692,10 +693,10 @@
 </xsl:text>
     <xsl:apply-templates select="." mode="traceIn"/>
     <xsl:text>    }
-    tty->print_cr("JVMTI [%s] %s } %s",  curr_thread_name, func_name, 
+    log_error(jvmti)("[%s] %s } %s",  curr_thread_name, func_name, 
                   JvmtiUtil::error_name(err));
   } else if ((trace_flags &amp; JvmtiTrace::SHOW_OUT) != 0) {
-    tty->print_cr("JVMTI [%s] %s }",  curr_thread_name, func_name);
+    log_trace(jvmti)("[%s] %s }",  curr_thread_name, func_name);
   }
 </xsl:text>
   </xsl:if>
@@ -703,7 +704,7 @@
 
 <xsl:template match="function" mode="traceIn">
   <xsl:param name="endParam"></xsl:param>
-  <xsl:text>          tty->print_cr("JVMTI [%s] %s { </xsl:text>
+  <xsl:text>          log_trace(jvmti)("[%s] %s { </xsl:text>
   <xsl:apply-templates select="parameters" mode="traceInFormat">
     <xsl:with-param name="endParam" select="$endParam"/>    
   </xsl:apply-templates>
diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp
index 6dffe98..d6f60a2 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp
@@ -489,7 +489,7 @@
     ObjectLocker ol(loader_lock, thread);
 
     // add the jar file to the bootclasspath
-    log_info(classload)("opened: %s", zip_entry->name());
+    log_info(class, load)("opened: %s", zip_entry->name());
     ClassLoaderExt::append_boot_classpath(zip_entry);
     return JVMTI_ERROR_NONE;
   } else {
@@ -640,11 +640,11 @@
     break;
   case JVMTI_VERBOSE_CLASS:
     if (value == 0) {
-      LogConfiguration::parse_log_arguments("stdout", "classunload=off", NULL, NULL, NULL);
-      LogConfiguration::parse_log_arguments("stdout", "classload=off", NULL, NULL, NULL);
+      LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL);
+      LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL);
     } else {
-      LogConfiguration::parse_log_arguments("stdout", "classload=info", NULL, NULL, NULL);
-      LogConfiguration::parse_log_arguments("stdout", "classunload=info", NULL, NULL, NULL);
+      LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL);
+      LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL);
     }
     break;
   case JVMTI_VERBOSE_GC:
@@ -1675,7 +1675,7 @@
   HandleMark hm(thread);
   KlassHandle kh (thread, k_oop);
 
-  TraceTime t("FollowReferences", TraceJVMTIObjectTagging);
+  TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data);
   return JVMTI_ERROR_NONE;
 } /* end FollowReferences */
@@ -1706,7 +1706,7 @@
   HandleMark hm(thread);
   KlassHandle kh (thread, k_oop);
 
-  TraceTime t("IterateThroughHeap", TraceJVMTIObjectTagging);
+  TraceTime t("IterateThroughHeap", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->iterate_through_heap(heap_filter, kh, callbacks, user_data);
   return JVMTI_ERROR_NONE;
 } /* end IterateThroughHeap */
@@ -1738,7 +1738,7 @@
 // tag_result_ptr - NULL is a valid value, must be checked
 jvmtiError
 JvmtiEnv::GetObjectsWithTags(jint tag_count, const jlong* tags, jint* count_ptr, jobject** object_result_ptr, jlong** tag_result_ptr) {
-  TraceTime t("GetObjectsWithTags", TraceJVMTIObjectTagging);
+  TraceTime t("GetObjectsWithTags", TRACETIME_LOG(Debug, jvmti, objecttagging));
   return JvmtiTagMap::tag_map_for(this)->get_objects_with_tags((jlong*)tags, tag_count, count_ptr, object_result_ptr, tag_result_ptr);
 } /* end GetObjectsWithTags */
 
@@ -1771,7 +1771,7 @@
 // user_data - NULL is a valid value, must be checked
 jvmtiError
 JvmtiEnv::IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, jvmtiStackReferenceCallback stack_ref_callback, jvmtiObjectReferenceCallback object_ref_callback, const void* user_data) {
-  TraceTime t("IterateOverReachableObjects", TraceJVMTIObjectTagging);
+  TraceTime t("IterateOverReachableObjects", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->iterate_over_reachable_objects(heap_root_callback, stack_ref_callback, object_ref_callback, user_data);
   return JVMTI_ERROR_NONE;
 } /* end IterateOverReachableObjects */
@@ -1781,7 +1781,7 @@
 // user_data - NULL is a valid value, must be checked
 jvmtiError
 JvmtiEnv::IterateOverHeap(jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
-  TraceTime t("IterateOverHeap", TraceJVMTIObjectTagging);
+  TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging));
   Thread *thread = Thread::current();
   HandleMark hm(thread);
   JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, KlassHandle(), heap_object_callback, user_data);
@@ -1805,7 +1805,7 @@
   Thread *thread = Thread::current();
   HandleMark hm(thread);
   KlassHandle klass (thread, k_oop);
-  TraceTime t("IterateOverInstancesOfClass", TraceJVMTIObjectTagging);
+  TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
   return JVMTI_ERROR_NONE;
 } /* end IterateOverInstancesOfClass */
diff --git a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
index 1c199bd..04e6869 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
@@ -162,6 +162,11 @@
 
   jvmtiCapabilities *get_prohibited_capabilities()  { return &_prohibited_capabilities; }
 
+  bool early_class_hook_env() {
+    return get_capabilities()->can_generate_early_class_hook_events != 0
+        && get_capabilities()->can_generate_all_class_hook_events != 0;
+  }
+
   bool early_vmstart_env() {
     return get_capabilities()->can_generate_early_vmstart != 0;
   }
diff --git a/hotspot/src/share/vm/prims/jvmtiEventController.cpp b/hotspot/src/share/vm/prims/jvmtiEventController.cpp
index 81ca1d7..006feea 100644
--- a/hotspot/src/share/vm/prims/jvmtiEventController.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiEventController.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "interpreter/interpreter.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "prims/jvmtiEventController.hpp"
 #include "prims/jvmtiEventController.inline.hpp"
@@ -42,7 +43,7 @@
 #define EC_TRACE(out) do { \
   if (JvmtiTrace::trace_event_controller()) { \
     SafeResourceMark rm; \
-    tty->print_cr out; \
+    log_trace(jvmti) out; \
   } \
 } while (0)
 #else
@@ -344,7 +345,7 @@
 
 
 void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state) {
-  EC_TRACE(("JVMTI [%s] # Entering interpreter only mode",
+  EC_TRACE(("[%s] # Entering interpreter only mode",
             JvmtiTrace::safe_get_thread_name(state->get_thread())));
 
   VM_EnterInterpOnlyMode op(state);
@@ -354,7 +355,7 @@
 
 void
 JvmtiEventControllerPrivate::leave_interp_only_mode(JvmtiThreadState *state) {
-  EC_TRACE(("JVMTI [%s] # Leaving interpreter only mode",
+  EC_TRACE(("[%s] # Leaving interpreter only mode",
             JvmtiTrace::safe_get_thread_name(state->get_thread())));
   state->leave_interp_only_mode();
 }
@@ -370,7 +371,7 @@
       jlong bit = JvmtiEventEnabled::bit_for((jvmtiEvent)ei);
       if (changed & bit) {
         // it changed, print it
-        tty->print_cr("JVMTI [%s] # %s event %s",
+         log_trace(jvmti)("[%s] # %s event %s",
                       JvmtiTrace::safe_get_thread_name(state->get_thread()),
                       (now_enabled & bit)? "Enabling" : "Disabling", JvmtiTrace::event_name((jvmtiEvent)ei));
       }
@@ -390,7 +391,7 @@
       jlong bit = JvmtiEventEnabled::bit_for((jvmtiEvent)ei);
       if (changed & bit) {
         // it changed, print it
-        tty->print_cr("JVMTI [-] # %s event %s",
+         log_trace(jvmti)("[-] # %s event %s",
                       (now_enabled & bit)? "Enabling" : "Disabling", JvmtiTrace::event_name((jvmtiEvent)ei));
       }
     }
@@ -563,7 +564,7 @@
   jlong was_any_env_thread_enabled = JvmtiEventController::_universal_global_event_enabled.get_bits();
   jlong any_env_thread_enabled = 0;
 
-  EC_TRACE(("JVMTI [-] # recompute enabled - before " UINT64_FORMAT_X, was_any_env_thread_enabled));
+  EC_TRACE(("[-] # recompute enabled - before " UINT64_FORMAT_X, was_any_env_thread_enabled));
 
   // compute non-thread-filters events.
   // This must be done separately from thread-filtered events, since some
@@ -643,7 +644,7 @@
 
   }
 
-  EC_TRACE(("JVMTI [-] # recompute enabled - after " UINT64_FORMAT_X, any_env_thread_enabled));
+  EC_TRACE(("[-] # recompute enabled - after " UINT64_FORMAT_X, any_env_thread_enabled));
 }
 
 
@@ -653,7 +654,7 @@
   assert(thread == Thread::current(), "must be current thread");
   assert(JvmtiEnvBase::environments_might_exist(), "to enter event controller, JVM TI environments must exist");
 
-  EC_TRACE(("JVMTI [%s] # thread started", JvmtiTrace::safe_get_thread_name(thread)));
+  EC_TRACE(("[%s] # thread started", JvmtiTrace::safe_get_thread_name(thread)));
 
   // if we have any thread filtered events globally enabled, create/update the thread state
   if ((JvmtiEventController::_universal_global_event_enabled.get_bits() & THREAD_FILTERED_EVENT_BITS) != 0) {
@@ -673,7 +674,7 @@
   // May be called after all environments have been disposed.
   assert(JvmtiThreadState_lock->is_locked(), "sanity check");
 
-  EC_TRACE(("JVMTI [%s] # thread ended", JvmtiTrace::safe_get_thread_name(thread)));
+  EC_TRACE(("[%s] # thread ended", JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiThreadState *state = thread->jvmti_thread_state();
   assert(state != NULL, "else why are we here?");
@@ -684,7 +685,7 @@
                                                       const jvmtiEventCallbacks* callbacks,
                                                       jint size_of_callbacks) {
   assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
-  EC_TRACE(("JVMTI [*] # set event callbacks"));
+  EC_TRACE(("[*] # set event callbacks"));
 
   env->set_event_callbacks(callbacks, size_of_callbacks);
   jlong enabled_bits = 0;
@@ -704,7 +705,7 @@
                                                           jvmtiExtensionEvent callback)
 {
   assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
-  EC_TRACE(("JVMTI [*] # set extension event callback"));
+  EC_TRACE(("[*] # set extension event callback"));
 
   // extension events are allocated below JVMTI_MIN_EVENT_TYPE_VAL
   assert(extension_event_index >= (jint)EXT_MIN_EVENT_TYPE_VAL &&
@@ -750,7 +751,7 @@
 void
 JvmtiEventControllerPrivate::env_initialize(JvmtiEnvBase *env) {
   assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
-  EC_TRACE(("JVMTI [*] # env initialize"));
+  EC_TRACE(("[*] # env initialize"));
 
   if (JvmtiEnvBase::is_vm_live()) {
     // if we didn't initialize event info already (this is a late
@@ -772,7 +773,7 @@
 void
 JvmtiEventControllerPrivate::env_dispose(JvmtiEnvBase *env) {
   assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
-  EC_TRACE(("JVMTI [*] # env dispose"));
+  EC_TRACE(("[*] # env dispose"));
 
   // Before the environment is marked disposed, disable all events on this
   // environment (by zapping the callbacks).  As a result, the disposed
@@ -794,7 +795,7 @@
                                           jvmtiEvent event_type, bool enabled) {
   assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
 
-  EC_TRACE(("JVMTI [%s] # user %s event %s",
+  EC_TRACE(("[%s] # user %s event %s",
             thread==NULL? "ALL": JvmtiTrace::safe_get_thread_name(thread),
             enabled? "enabled" : "disabled", JvmtiTrace::event_name(event_type)));
 
@@ -813,7 +814,7 @@
 
 void
 JvmtiEventControllerPrivate::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) {
-  EC_TRACE(("JVMTI [%s] # set frame pop - frame=%d",
+  EC_TRACE(("[%s] # set frame pop - frame=%d",
             JvmtiTrace::safe_get_thread_name(ets->get_thread()),
             fpop.frame_number() ));
 
@@ -824,7 +825,7 @@
 
 void
 JvmtiEventControllerPrivate::clear_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) {
-  EC_TRACE(("JVMTI [%s] # clear frame pop - frame=%d",
+  EC_TRACE(("[%s] # clear frame pop - frame=%d",
             JvmtiTrace::safe_get_thread_name(ets->get_thread()),
             fpop.frame_number() ));
 
@@ -837,7 +838,7 @@
 JvmtiEventControllerPrivate::clear_to_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) {
   int cleared_cnt = ets->get_frame_pops()->clear_to(fpop);
 
-  EC_TRACE(("JVMTI [%s] # clear to frame pop - frame=%d, count=%d",
+  EC_TRACE(("[%s] # clear to frame pop - frame=%d, count=%d",
             JvmtiTrace::safe_get_thread_name(ets->get_thread()),
             fpop.frame_number(),
             cleared_cnt ));
@@ -863,7 +864,7 @@
     return;
   }
 
-  EC_TRACE(("JVMTI [-] # change field watch - %s %s count=%d",
+  EC_TRACE(("[-] # change field watch - %s %s count=%d",
             event_type==JVMTI_EVENT_FIELD_MODIFICATION? "modification" : "access",
             added? "add" : "remove",
             *count_addr));
@@ -893,7 +894,7 @@
     return;
   }
 
-  EC_TRACE(("JVMTI [-] # VM live"));
+  EC_TRACE(("[-] # VM live"));
 
 #ifdef ASSERT
   // check that our idea and the spec's idea of threaded events match
diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp
index 984c5f9..a388f29 100644
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp
@@ -29,6 +29,8 @@
 #include "code/scopeDesc.hpp"
 #include "interpreter/interpreter.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "logging/log.hpp"
+#include "logging/logStream.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/objArrayKlass.hpp"
 #include "oops/objArrayOop.hpp"
@@ -60,8 +62,8 @@
 #endif // INCLUDE_ALL_GCS
 
 #ifdef JVMTI_TRACE
-#define EVT_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_SENT) != 0) { SafeResourceMark rm; tty->print_cr out; }
-#define EVT_TRIG_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_TRIGGER) != 0) { SafeResourceMark rm; tty->print_cr out; }
+#define EVT_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_SENT) != 0) { SafeResourceMark rm; log_trace(jvmti) out; }
+#define EVT_TRIG_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_TRIGGER) != 0) { SafeResourceMark rm; log_trace(jvmti) out; }
 #else
 #define EVT_TRIG_TRACE(evt,out)
 #define EVT_TRACE(evt,out)
@@ -423,7 +425,10 @@
                          THREAD);
 
   if (HAS_PENDING_EXCEPTION) {
-    java_lang_Throwable::print(PENDING_EXCEPTION, tty);
+    LogTarget(Trace, jvmti) log;
+    LogStreamCHeap log_stream(log);
+    java_lang_Throwable::print(PENDING_EXCEPTION, &log_stream);
+    log_stream.cr();
     CLEAR_PENDING_EXCEPTION;
     return;
   }
@@ -465,7 +470,7 @@
 //
 
 void JvmtiExport::post_early_vm_start() {
-  EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Trg Early VM start event triggered" ));
+  EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("Trg Early VM start event triggered" ));
 
   // can now enable some events
   JvmtiEventController::vm_start();
@@ -474,7 +479,7 @@
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     // Only early vmstart envs post early VMStart event
     if (env->early_vmstart_env() && env->is_enabled(JVMTI_EVENT_VM_START)) {
-      EVT_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Evt Early VM start event sent" ));
+      EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt Early VM start event sent" ));
       JavaThread *thread  = JavaThread::current();
       JvmtiThreadEventMark jem(thread);
       JvmtiJavaThreadEventTransition jet(thread);
@@ -487,7 +492,7 @@
 }
 
 void JvmtiExport::post_vm_start() {
-  EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Trg VM start event triggered" ));
+  EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("Trg VM start event triggered" ));
 
   // can now enable some events
   JvmtiEventController::vm_start();
@@ -496,7 +501,7 @@
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     // Early vmstart envs do not post normal VMStart event
     if (!env->early_vmstart_env() && env->is_enabled(JVMTI_EVENT_VM_START)) {
-      EVT_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Evt VM start event sent" ));
+      EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt VM start event sent" ));
 
       JavaThread *thread  = JavaThread::current();
       JvmtiThreadEventMark jem(thread);
@@ -511,7 +516,7 @@
 
 
 void JvmtiExport::post_vm_initialized() {
-  EVT_TRIG_TRACE(JVMTI_EVENT_VM_INIT, ("JVMTI Trg VM init event triggered" ));
+  EVT_TRIG_TRACE(JVMTI_EVENT_VM_INIT, ("Trg VM init event triggered" ));
 
   // can now enable events
   JvmtiEventController::vm_init();
@@ -519,7 +524,7 @@
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_VM_INIT)) {
-      EVT_TRACE(JVMTI_EVENT_VM_INIT, ("JVMTI Evt VM init event sent" ));
+      EVT_TRACE(JVMTI_EVENT_VM_INIT, ("Evt VM init event sent" ));
 
       JavaThread *thread  = JavaThread::current();
       JvmtiThreadEventMark jem(thread);
@@ -534,12 +539,12 @@
 
 
 void JvmtiExport::post_vm_death() {
-  EVT_TRIG_TRACE(JVMTI_EVENT_VM_DEATH, ("JVMTI Trg VM death event triggered" ));
+  EVT_TRIG_TRACE(JVMTI_EVENT_VM_DEATH, ("Trg VM death event triggered" ));
 
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_VM_DEATH)) {
-      EVT_TRACE(JVMTI_EVENT_VM_DEATH, ("JVMTI Evt VM death event sent" ));
+      EVT_TRACE(JVMTI_EVENT_VM_DEATH, ("Evt VM death event sent" ));
 
       JavaThread *thread  = JavaThread::current();
       JvmtiEventMark jem(thread);
@@ -632,9 +637,6 @@
   }
 
   void post() {
-//    EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
-//                   ("JVMTI [%s] class file load hook event triggered",
-//                    JvmtiTrace::safe_get_thread_name(_thread)));
     post_all_envs();
     copy_modified_data();
   }
@@ -665,16 +667,11 @@
   }
 
   void post_to_env(JvmtiEnv* env, bool caching_needed) {
-    if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
+    if (env->phase() == JVMTI_PHASE_PRIMORDIAL && !env->early_class_hook_env()) {
       return;
     }
     unsigned char *new_data = NULL;
     jint new_len = 0;
-//    EVT_TRACE(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
-//     ("JVMTI [%s] class file load hook event sent %s  data_ptr = %d, data_len = %d",
-//               JvmtiTrace::safe_get_thread_name(_thread),
-//               _h_name == NULL ? "NULL" : _h_name->as_utf8(),
-//               _curr_data, _curr_len ));
     JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader,
                                     _h_protection_domain,
                                     _h_class_being_redefined);
@@ -840,7 +837,7 @@
   }
   JavaThread* thread = JavaThread::current();
   EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_UNLOAD,
-                 ("JVMTI [%s] method compile unload event triggered",
+                 ("[%s] method compile unload event triggered",
                   JvmtiTrace::safe_get_thread_name(thread)));
 
   // post the event for each environment that has this event enabled.
@@ -851,7 +848,7 @@
         continue;
       }
       EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_UNLOAD,
-                ("JVMTI [%s] class compile method unload event sent jmethodID " PTR_FORMAT,
+                ("[%s] class compile method unload event sent jmethodID " PTR_FORMAT,
                  JvmtiTrace::safe_get_thread_name(thread), p2i(method)));
 
       ResourceMark rm(thread);
@@ -879,7 +876,7 @@
   if (state == NULL) {
     return;
   }
-  EVT_TRIG_TRACE(JVMTI_EVENT_BREAKPOINT, ("JVMTI [%s] Trg Breakpoint triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Trg Breakpoint triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiEnvThreadStateIterator it(state);
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
@@ -887,7 +884,7 @@
     if (!ets->breakpoint_posted() && ets->is_enabled(JVMTI_EVENT_BREAKPOINT)) {
       ThreadState old_os_state = thread->osthread()->get_state();
       thread->osthread()->set_state(BREAKPOINTED);
-      EVT_TRACE(JVMTI_EVENT_BREAKPOINT, ("JVMTI [%s] Evt Breakpoint sent %s.%s @ " INTX_FORMAT,
+      EVT_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Evt Breakpoint sent %s.%s @ " INTX_FORMAT,
                      JvmtiTrace::safe_get_thread_name(thread),
                      (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                      (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
@@ -965,7 +962,7 @@
   if (state == NULL) {
     return;
   }
-  EVT_TRIG_TRACE(JVMTI_EVENT_SINGLE_STEP, ("JVMTI [%s] Trg Single Step triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_SINGLE_STEP, ("[%s] Trg Single Step triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
   if (!state->hide_single_stepping()) {
     if (state->is_pending_step_for_popframe()) {
@@ -1004,7 +1001,7 @@
   HandleMark hm(thread);
   KlassHandle kh(thread, klass);
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("JVMTI [%s] Trg Class Load triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiThreadState* state = thread->jvmti_thread_state();
   if (state == NULL) {
@@ -1017,7 +1014,7 @@
       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
         continue;
       }
-      EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("JVMTI [%s] Evt Class Load sent %s",
+      EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Evt Class Load sent %s",
                                          JvmtiTrace::safe_get_thread_name(thread),
                                          kh()==NULL? "NULL" : kh()->external_name() ));
       JvmtiClassEventMark jem(thread, kh());
@@ -1038,7 +1035,7 @@
   HandleMark hm(thread);
   KlassHandle kh(thread, klass);
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("JVMTI [%s] Trg Class Prepare triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiThreadState* state = thread->jvmti_thread_state();
   if (state == NULL) {
@@ -1051,7 +1048,7 @@
       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
         continue;
       }
-      EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("JVMTI [%s] Evt Class Prepare sent %s",
+      EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s",
                                             JvmtiTrace::safe_get_thread_name(thread),
                                             kh()==NULL? "NULL" : kh()->external_name() ));
       JvmtiClassEventMark jem(thread, kh());
@@ -1072,7 +1069,7 @@
   HandleMark hm(thread);
   KlassHandle kh(thread, klass);
 
-  EVT_TRIG_TRACE(EXT_EVENT_CLASS_UNLOAD, ("JVMTI [?] Trg Class Unload triggered" ));
+  EVT_TRIG_TRACE(EXT_EVENT_CLASS_UNLOAD, ("[?] Trg Class Unload triggered" ));
   if (JvmtiEventController::is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) {
     assert(thread->is_VM_thread(), "wrong thread");
 
@@ -1086,7 +1083,7 @@
         continue;
       }
       if (env->is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) {
-        EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("JVMTI [?] Evt Class Unload sent %s",
+        EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("[?] Evt Class Unload sent %s",
                   kh()==NULL? "NULL" : kh()->external_name() ));
 
         // do everything manually, since this is a proxy - needs special care
@@ -1125,7 +1122,7 @@
   }
   assert(thread->thread_state() == _thread_in_vm, "must be in vm state");
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_START, ("JVMTI [%s] Trg Thread Start event triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_START, ("[%s] Trg Thread Start event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   // do JVMTI thread initialization (if needed)
@@ -1140,7 +1137,7 @@
         continue;
       }
       if (env->is_enabled(JVMTI_EVENT_THREAD_START)) {
-        EVT_TRACE(JVMTI_EVENT_THREAD_START, ("JVMTI [%s] Evt Thread Start event sent",
+        EVT_TRACE(JVMTI_EVENT_THREAD_START, ("[%s] Evt Thread Start event sent",
                      JvmtiTrace::safe_get_thread_name(thread) ));
 
         JvmtiThreadEventMark jem(thread);
@@ -1159,7 +1156,7 @@
   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
     return;
   }
-  EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_END, ("JVMTI [%s] Trg Thread End event triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_END, ("[%s] Trg Thread End event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiThreadState *state = thread->jvmti_thread_state();
@@ -1178,7 +1175,7 @@
         if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
           continue;
         }
-        EVT_TRACE(JVMTI_EVENT_THREAD_END, ("JVMTI [%s] Evt Thread End event sent",
+        EVT_TRACE(JVMTI_EVENT_THREAD_END, ("[%s] Evt Thread End event sent",
                      JvmtiTrace::safe_get_thread_name(thread) ));
 
         JvmtiThreadEventMark jem(thread);
@@ -1196,8 +1193,8 @@
   assert(SafepointSynchronize::is_at_safepoint(), "must be executed at safepoint");
   assert(env->is_enabled(JVMTI_EVENT_OBJECT_FREE), "checking");
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_OBJECT_FREE, ("JVMTI [?] Trg Object Free triggered" ));
-  EVT_TRACE(JVMTI_EVENT_OBJECT_FREE, ("JVMTI [?] Evt Object Free sent"));
+  EVT_TRIG_TRACE(JVMTI_EVENT_OBJECT_FREE, ("[?] Trg Object Free triggered" ));
+  EVT_TRACE(JVMTI_EVENT_OBJECT_FREE, ("[?] Evt Object Free sent"));
 
   jvmtiEventObjectFree callback = env->callbacks()->ObjectFree;
   if (callback != NULL) {
@@ -1206,12 +1203,12 @@
 }
 
 void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const char* description) {
-  EVT_TRIG_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("JVMTI Trg resource exhausted event triggered" ));
+  EVT_TRIG_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Trg resource exhausted event triggered" ));
 
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_RESOURCE_EXHAUSTED)) {
-      EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("JVMTI Evt resource exhausted event sent" ));
+      EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Evt resource exhausted event sent" ));
 
       JavaThread *thread  = JavaThread::current();
       JvmtiThreadEventMark jem(thread);
@@ -1229,7 +1226,7 @@
   HandleMark hm(thread);
   methodHandle mh(thread, method);
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("JVMTI [%s] Trg Method Entry triggered %s.%s",
+  EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Trg Method Entry triggered %s.%s",
                      JvmtiTrace::safe_get_thread_name(thread),
                      (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                      (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() ));
@@ -1246,7 +1243,7 @@
     JvmtiEnvThreadStateIterator it(state);
     for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
       if (ets->is_enabled(JVMTI_EVENT_METHOD_ENTRY)) {
-        EVT_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("JVMTI [%s] Evt Method Entry sent %s.%s",
+        EVT_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Evt Method Entry sent %s.%s",
                                              JvmtiTrace::safe_get_thread_name(thread),
                                              (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                                              (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() ));
@@ -1267,7 +1264,7 @@
   HandleMark hm(thread);
   methodHandle mh(thread, method);
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_EXIT, ("JVMTI [%s] Trg Method Exit triggered %s.%s",
+  EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Trg Method Exit triggered %s.%s",
                      JvmtiTrace::safe_get_thread_name(thread),
                      (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                      (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() ));
@@ -1303,7 +1300,7 @@
     JvmtiEnvThreadStateIterator it(state);
     for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
       if (ets->is_enabled(JVMTI_EVENT_METHOD_EXIT)) {
-        EVT_TRACE(JVMTI_EVENT_METHOD_EXIT, ("JVMTI [%s] Evt Method Exit sent %s.%s",
+        EVT_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Evt Method Exit sent %s.%s",
                                             JvmtiTrace::safe_get_thread_name(thread),
                                             (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                                             (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() ));
@@ -1332,7 +1329,7 @@
         // we have a NotifyFramePop entry for this frame.
         // now check that this env/thread wants this event
         if (ets->is_enabled(JVMTI_EVENT_FRAME_POP)) {
-          EVT_TRACE(JVMTI_EVENT_FRAME_POP, ("JVMTI [%s] Evt Frame Pop sent %s.%s",
+          EVT_TRACE(JVMTI_EVENT_FRAME_POP, ("[%s] Evt Frame Pop sent %s.%s",
                                             JvmtiTrace::safe_get_thread_name(thread),
                                             (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                                             (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() ));
@@ -1370,7 +1367,7 @@
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
     ets->compare_and_set_current_location(mh(), location, JVMTI_EVENT_SINGLE_STEP);
     if (!ets->single_stepping_posted() && ets->is_enabled(JVMTI_EVENT_SINGLE_STEP)) {
-      EVT_TRACE(JVMTI_EVENT_SINGLE_STEP, ("JVMTI [%s] Evt Single Step sent %s.%s @ " INTX_FORMAT,
+      EVT_TRACE(JVMTI_EVENT_SINGLE_STEP, ("[%s] Evt Single Step sent %s.%s @ " INTX_FORMAT,
                     JvmtiTrace::safe_get_thread_name(thread),
                     (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                     (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
@@ -1401,7 +1398,7 @@
     return;
   }
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION, ("JVMTI [%s] Trg Exception thrown triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION, ("[%s] Trg Exception thrown triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
   if (!state->is_exception_detected()) {
     state->set_exception_detected();
@@ -1410,7 +1407,7 @@
       if (ets->is_enabled(JVMTI_EVENT_EXCEPTION) && (exception != NULL)) {
 
         EVT_TRACE(JVMTI_EVENT_EXCEPTION,
-                     ("JVMTI [%s] Evt Exception thrown sent %s.%s @ " INTX_FORMAT,
+                     ("[%s] Evt Exception thrown sent %s.%s @ " INTX_FORMAT,
                       JvmtiTrace::safe_get_thread_name(thread),
                       (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                       (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
@@ -1486,7 +1483,7 @@
     return;
   }
   EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION_CATCH,
-                    ("JVMTI [%s] Trg unwind_due_to_exception triggered %s.%s @ %s" INTX_FORMAT " - %s",
+                    ("[%s] Trg unwind_due_to_exception triggered %s.%s @ %s" INTX_FORMAT " - %s",
                      JvmtiTrace::safe_get_thread_name(thread),
                      (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                      (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
@@ -1521,7 +1518,7 @@
       for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
         if (ets->is_enabled(JVMTI_EVENT_EXCEPTION_CATCH) && (exception_handle() != NULL)) {
           EVT_TRACE(JVMTI_EVENT_EXCEPTION_CATCH,
-                     ("JVMTI [%s] Evt ExceptionCatch sent %s.%s @ " INTX_FORMAT,
+                     ("[%s] Evt ExceptionCatch sent %s.%s @ " INTX_FORMAT,
                       JvmtiTrace::safe_get_thread_name(thread),
                       (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                       (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
@@ -1610,12 +1607,12 @@
   if (state == NULL) {
     return;
   }
-  EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("JVMTI [%s] Trg Field Access event triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Trg Field Access event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiEnvThreadStateIterator it(state);
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
     if (ets->is_enabled(JVMTI_EVENT_FIELD_ACCESS)) {
-      EVT_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("JVMTI [%s] Evt Field Access event sent %s.%s @ " INTX_FORMAT,
+      EVT_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Evt Field Access event sent %s.%s @ " INTX_FORMAT,
                      JvmtiTrace::safe_get_thread_name(thread),
                      (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                      (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
@@ -1772,14 +1769,14 @@
     return;
   }
   EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_MODIFICATION,
-                     ("JVMTI [%s] Trg Field Modification event triggered",
+                     ("[%s] Trg Field Modification event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiEnvThreadStateIterator it(state);
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
     if (ets->is_enabled(JVMTI_EVENT_FIELD_MODIFICATION)) {
       EVT_TRACE(JVMTI_EVENT_FIELD_MODIFICATION,
-                   ("JVMTI [%s] Evt Field Modification event sent %s.%s @ " INTX_FORMAT,
+                   ("[%s] Evt Field Modification event sent %s.%s @ " INTX_FORMAT,
                     JvmtiTrace::safe_get_thread_name(thread),
                     (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
                     (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
@@ -1807,14 +1804,14 @@
   HandleMark hm(thread);
   methodHandle mh(thread, method);
 
-  EVT_TRIG_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("JVMTI [%s] Trg Native Method Bind event triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("[%s] Trg Native Method Bind event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   if (JvmtiEventController::is_enabled(JVMTI_EVENT_NATIVE_METHOD_BIND)) {
     JvmtiEnvIterator it;
     for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
       if (env->is_enabled(JVMTI_EVENT_NATIVE_METHOD_BIND)) {
-        EVT_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("JVMTI [%s] Evt Native Method Bind event sent",
+        EVT_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("[%s] Evt Native Method Bind event sent",
                      JvmtiTrace::safe_get_thread_name(thread) ));
 
         JvmtiMethodEventMark jem(thread, mh);
@@ -1878,7 +1875,7 @@
   JavaThread* thread = JavaThread::current();
 
   EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD,
-                 ("JVMTI [%s] method compile load event triggered",
+                 ("[%s] method compile load event triggered",
                  JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiEnvIterator it;
@@ -1888,7 +1885,7 @@
         continue;
       }
       EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD,
-                ("JVMTI [%s] class compile method load event sent %s.%s  ",
+                ("[%s] class compile method load event sent %s.%s  ",
                 JvmtiTrace::safe_get_thread_name(thread),
                 (nm->method() == NULL) ? "NULL" : nm->method()->klass_name()->as_C_string(),
                 (nm->method() == NULL) ? "NULL" : nm->method()->name()->as_C_string()));
@@ -1921,12 +1918,12 @@
   }
   JavaThread* thread = JavaThread::current();
   EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD,
-                 ("JVMTI [%s] method compile load event triggered (by GenerateEvents)",
+                 ("[%s] method compile load event triggered (by GenerateEvents)",
                  JvmtiTrace::safe_get_thread_name(thread)));
   if (env->is_enabled(JVMTI_EVENT_COMPILED_METHOD_LOAD)) {
 
     EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD,
-              ("JVMTI [%s] class compile method load event sent (by GenerateEvents), jmethodID=" PTR_FORMAT,
+              ("[%s] class compile method load event sent (by GenerateEvents), jmethodID=" PTR_FORMAT,
                JvmtiTrace::safe_get_thread_name(thread), p2i(method)));
 
     JvmtiEventMark jem(thread);
@@ -1949,13 +1946,13 @@
   ThreadInVMfromUnknown __tiv;
 
   EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED,
-                 ("JVMTI [%s] method dynamic code generated event triggered",
+                 ("[%s] method dynamic code generated event triggered",
                  JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) {
       EVT_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED,
-                ("JVMTI [%s] dynamic code generated event sent for %s",
+                ("[%s] dynamic code generated event sent for %s",
                 JvmtiTrace::safe_get_thread_name(thread), name));
       JvmtiEventMark jem(thread);
       JvmtiJavaThreadEventTransition jet(thread);
@@ -1991,11 +1988,11 @@
 {
   JavaThread* thread = JavaThread::current();
   EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED,
-                 ("JVMTI [%s] dynamic code generated event triggered (by GenerateEvents)",
+                 ("[%s] dynamic code generated event triggered (by GenerateEvents)",
                   JvmtiTrace::safe_get_thread_name(thread)));
   if (env->is_enabled(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) {
     EVT_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED,
-              ("JVMTI [%s] dynamic code generated event sent for %s",
+              ("[%s] dynamic code generated event sent for %s",
                JvmtiTrace::safe_get_thread_name(thread), name));
     JvmtiEventMark jem(thread);
     JvmtiJavaThreadEventTransition jet(thread);
@@ -2048,13 +2045,13 @@
 void JvmtiExport::post_garbage_collection_finish() {
   Thread *thread = Thread::current(); // this event is posted from VM-Thread.
   EVT_TRIG_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH,
-                 ("JVMTI [%s] garbage collection finish event triggered",
+                 ("[%s] garbage collection finish event triggered",
                   JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH)) {
       EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH,
-                ("JVMTI [%s] garbage collection finish event sent ",
+                ("[%s] garbage collection finish event sent",
                  JvmtiTrace::safe_get_thread_name(thread)));
       JvmtiThreadEventTransition jet(thread);
       // JNIEnv is NULL here because this event is posted from VM Thread
@@ -2069,13 +2066,13 @@
 void JvmtiExport::post_garbage_collection_start() {
   Thread* thread = Thread::current(); // this event is posted from vm-thread.
   EVT_TRIG_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_START,
-                 ("JVMTI [%s] garbage collection start event triggered",
+                 ("[%s] garbage collection start event triggered",
                   JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_GARBAGE_COLLECTION_START)) {
       EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_START,
-                ("JVMTI [%s] garbage collection start event sent ",
+                ("[%s] garbage collection start event sent",
                  JvmtiTrace::safe_get_thread_name(thread)));
       JvmtiThreadEventTransition jet(thread);
       // JNIEnv is NULL here because this event is posted from VM Thread
@@ -2090,13 +2087,13 @@
 void JvmtiExport::post_data_dump() {
   Thread *thread = Thread::current();
   EVT_TRIG_TRACE(JVMTI_EVENT_DATA_DUMP_REQUEST,
-                 ("JVMTI [%s] data dump request event triggered",
+                 ("[%s] data dump request event triggered",
                   JvmtiTrace::safe_get_thread_name(thread)));
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_DATA_DUMP_REQUEST)) {
       EVT_TRACE(JVMTI_EVENT_DATA_DUMP_REQUEST,
-                ("JVMTI [%s] data dump request event sent ",
+                ("[%s] data dump request event sent",
                  JvmtiTrace::safe_get_thread_name(thread)));
      JvmtiThreadEventTransition jet(thread);
      // JNIEnv is NULL here because this event is posted from VM Thread
@@ -2123,14 +2120,14 @@
   Handle h(thread, object);
 
   EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTER,
-                     ("JVMTI [%s] montior contended enter event triggered",
+                     ("[%s] montior contended enter event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiEnvThreadStateIterator it(state);
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
     if (ets->is_enabled(JVMTI_EVENT_MONITOR_CONTENDED_ENTER)) {
       EVT_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTER,
-                   ("JVMTI [%s] monitor contended enter event sent",
+                   ("[%s] monitor contended enter event sent",
                     JvmtiTrace::safe_get_thread_name(thread)));
       JvmtiMonitorEventMark  jem(thread, h());
       JvmtiEnv *env = ets->get_env();
@@ -2158,14 +2155,14 @@
   Handle h(thread, object);
 
   EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED,
-                     ("JVMTI [%s] montior contended entered event triggered",
+                     ("[%s] montior contended entered event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiEnvThreadStateIterator it(state);
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
     if (ets->is_enabled(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED)) {
       EVT_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED,
-                   ("JVMTI [%s] monitor contended enter event sent",
+                   ("[%s] monitor contended enter event sent",
                     JvmtiTrace::safe_get_thread_name(thread)));
       JvmtiMonitorEventMark  jem(thread, h());
       JvmtiEnv *env = ets->get_env();
@@ -2189,14 +2186,14 @@
   Handle h(thread, object);
 
   EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAIT,
-                     ("JVMTI [%s] montior wait event triggered",
+                     ("[%s] montior wait event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiEnvThreadStateIterator it(state);
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
     if (ets->is_enabled(JVMTI_EVENT_MONITOR_WAIT)) {
       EVT_TRACE(JVMTI_EVENT_MONITOR_WAIT,
-                   ("JVMTI [%s] monitor wait event sent ",
+                   ("[%s] monitor wait event sent",
                     JvmtiTrace::safe_get_thread_name(thread)));
       JvmtiMonitorEventMark  jem(thread, h());
       JvmtiEnv *env = ets->get_env();
@@ -2225,14 +2222,14 @@
   Handle h(thread, object);
 
   EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAITED,
-                     ("JVMTI [%s] montior waited event triggered",
+                     ("[%s] montior waited event triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
 
   JvmtiEnvThreadStateIterator it(state);
   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
     if (ets->is_enabled(JVMTI_EVENT_MONITOR_WAITED)) {
       EVT_TRACE(JVMTI_EVENT_MONITOR_WAITED,
-                   ("JVMTI [%s] monitor waited event sent ",
+                   ("[%s] monitor waited event sent",
                     JvmtiTrace::safe_get_thread_name(thread)));
       JvmtiMonitorEventMark  jem(thread, h());
       JvmtiEnv *env = ets->get_env();
@@ -2248,7 +2245,7 @@
 
 
 void JvmtiExport::post_vm_object_alloc(JavaThread *thread,  oop object) {
-  EVT_TRIG_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("JVMTI [%s] Trg vm object alloc triggered",
+  EVT_TRIG_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Trg vm object alloc triggered",
                       JvmtiTrace::safe_get_thread_name(thread)));
   if (object == NULL) {
     return;
@@ -2258,7 +2255,7 @@
   JvmtiEnvIterator it;
   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
     if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) {
-      EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("JVMTI [%s] Evt vmobject alloc sent %s",
+      EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Evt vmobject alloc sent %s",
                                          JvmtiTrace::safe_get_thread_name(thread),
                                          object==NULL? "NULL" : object->klass()->external_name()));
 
diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp
index 986517d..398f572 100644
--- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp
@@ -27,6 +27,8 @@
 #include "interpreter/interpreter.hpp"
 #include "interpreter/oopMapCache.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "logging/log.hpp"
+#include "logging/logStream.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/instanceKlass.hpp"
 #include "oops/oop.inline.hpp"
@@ -276,7 +278,7 @@
          _bci >= 0;
 }
 
-address JvmtiBreakpoint::getBcp() {
+address JvmtiBreakpoint::getBcp() const {
   return _method->bcp_from(_bci);
 }
 
@@ -301,11 +303,10 @@
       if (method->is_running_emcp() &&
           method->name() == m_name &&
           method->signature() == m_signature) {
-        RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)",
-          meth_act == &Method::set_breakpoint ? "sett" : "clear",
-          method->name()->as_C_string(),
-          method->signature()->as_C_string()));
-
+        ResourceMark rm;
+        log_debug(redefine, class, breakpoint)
+          ("%sing breakpoint in %s(%s)", meth_act == &Method::set_breakpoint ? "sett" : "clear",
+           method->name()->as_C_string(), method->signature()->as_C_string());
         (method->*meth_act)(_bci);
         break;
       }
@@ -321,12 +322,12 @@
   each_method_version_do(&Method::clear_breakpoint);
 }
 
-void JvmtiBreakpoint::print() {
+void JvmtiBreakpoint::print_on(outputStream* out) const {
 #ifndef PRODUCT
+  ResourceMark rm;
   const char *class_name  = (_method == NULL) ? "NULL" : _method->klass_name()->as_C_string();
   const char *method_name = (_method == NULL) ? "NULL" : _method->name()->as_C_string();
-
-  tty->print("Breakpoint(%s,%s,%d,%p)",class_name, method_name, _bci, getBcp());
+  out->print("Breakpoint(%s,%s,%d,%p)", class_name, method_name, _bci, getBcp());
 #endif
 }
 
@@ -389,16 +390,17 @@
   _bps.gc_epilogue();
 }
 
-void  JvmtiBreakpoints::print() {
+void JvmtiBreakpoints::print() {
 #ifndef PRODUCT
-  ResourceMark rm;
+  LogTarget(Trace, jvmti) log;
+  LogStreamCHeap log_stream(log);
 
   int n = _bps.length();
   for (int i=0; i<n; i++) {
     JvmtiBreakpoint& bp = _bps.at(i);
-    tty->print("%d: ", i);
-    bp.print();
-    tty->cr();
+    log_stream.print("%d: ", i);
+    bp.print_on(&log_stream);
+    log_stream.cr();
   }
 #endif
 }
@@ -875,22 +877,21 @@
 void JvmtiSuspendControl::print() {
 #ifndef PRODUCT
   MutexLocker mu(Threads_lock);
-  ResourceMark rm;
-
-  tty->print("Suspended Threads: [");
+  LogStreamHandle(Trace, jvmti) log_stream;
+  log_stream.print("Suspended Threads: [");
   for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
 #ifdef JVMTI_TRACE
     const char *name   = JvmtiTrace::safe_get_thread_name(thread);
 #else
     const char *name   = "";
 #endif /*JVMTI_TRACE */
-    tty->print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_');
+    log_stream.print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_');
     if (!thread->has_last_Java_frame()) {
-      tty->print("no stack");
+      log_stream.print("no stack");
     }
-    tty->print(") ");
+    log_stream.print(") ");
   }
-  tty->print_cr("]");
+  log_stream.print_cr("]");
 #endif
 }
 
diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.hpp b/hotspot/src/share/vm/prims/jvmtiImpl.hpp
index c1e4b81..ebb2027 100644
--- a/hotspot/src/share/vm/prims/jvmtiImpl.hpp
+++ b/hotspot/src/share/vm/prims/jvmtiImpl.hpp
@@ -34,6 +34,7 @@
 #include "prims/jvmtiUtil.hpp"
 #include "runtime/stackValueCollection.hpp"
 #include "runtime/vm_operations.hpp"
+#include "utilities/ostream.hpp"
 
 //
 // Forward Declarations
@@ -182,11 +183,11 @@
   bool lessThan(JvmtiBreakpoint &bp);
   void copy(JvmtiBreakpoint& bp);
   bool is_valid();
-  address getBcp();
+  address getBcp() const;
   void each_method_version_do(method_action meth_act);
   void set();
   void clear();
-  void print();
+  void print_on(outputStream* out) const;
 
   Method* method() { return _method; }
 
diff --git a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp
index a9ce01c..e0c3cb5 100644
--- a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp
@@ -24,8 +24,10 @@
 
 #include "precompiled.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "logging/log.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "prims/jvmtiManageCapabilities.hpp"
+
 static const jint CAPA_SIZE = (JVMTI_INTERNAL_CAPABILITY_COUNT + 7) / 8;
 
   // capabilities which are always potentially available
@@ -134,6 +136,7 @@
   jc.can_get_owned_monitor_stack_depth_info = 1;
   jc.can_get_current_contended_monitor = 1;
   jc.can_generate_early_vmstart = 1;
+  jc.can_generate_early_class_hook_events = 1;
   return jc;
 }
 
@@ -373,87 +376,89 @@
 #ifndef PRODUCT
 
 void JvmtiManageCapabilities:: print(const jvmtiCapabilities* cap) {
-  tty->print_cr("----- capabilities -----");
+  log_trace(jvmti)("----- capabilities -----");
   if (cap->can_tag_objects)
-    tty->print_cr("can_tag_objects");
+    log_trace(jvmti)("can_tag_objects");
   if (cap->can_generate_field_modification_events)
-    tty->print_cr("can_generate_field_modification_events");
+    log_trace(jvmti)("can_generate_field_modification_events");
   if (cap->can_generate_field_access_events)
-    tty->print_cr("can_generate_field_access_events");
+    log_trace(jvmti)("can_generate_field_access_events");
   if (cap->can_get_bytecodes)
-    tty->print_cr("can_get_bytecodes");
+    log_trace(jvmti)("can_get_bytecodes");
   if (cap->can_get_synthetic_attribute)
-    tty->print_cr("can_get_synthetic_attribute");
+    log_trace(jvmti)("can_get_synthetic_attribute");
   if (cap->can_get_owned_monitor_info)
-    tty->print_cr("can_get_owned_monitor_info");
+    log_trace(jvmti)("can_get_owned_monitor_info");
   if (cap->can_get_current_contended_monitor)
-    tty->print_cr("can_get_current_contended_monitor");
+    log_trace(jvmti)("can_get_current_contended_monitor");
   if (cap->can_get_monitor_info)
-    tty->print_cr("can_get_monitor_info");
+    log_trace(jvmti)("can_get_monitor_info");
   if (cap->can_get_constant_pool)
-    tty->print_cr("can_get_constant_pool");
+    log_trace(jvmti)("can_get_constant_pool");
   if (cap->can_pop_frame)
-    tty->print_cr("can_pop_frame");
+    log_trace(jvmti)("can_pop_frame");
   if (cap->can_force_early_return)
-    tty->print_cr("can_force_early_return");
+    log_trace(jvmti)("can_force_early_return");
   if (cap->can_redefine_classes)
-    tty->print_cr("can_redefine_classes");
+    log_trace(jvmti)("can_redefine_classes");
   if (cap->can_retransform_classes)
-    tty->print_cr("can_retransform_classes");
+    log_trace(jvmti)("can_retransform_classes");
   if (cap->can_signal_thread)
-    tty->print_cr("can_signal_thread");
+    log_trace(jvmti)("can_signal_thread");
   if (cap->can_get_source_file_name)
-    tty->print_cr("can_get_source_file_name");
+    log_trace(jvmti)("can_get_source_file_name");
   if (cap->can_get_line_numbers)
-    tty->print_cr("can_get_line_numbers");
+    log_trace(jvmti)("can_get_line_numbers");
   if (cap->can_get_source_debug_extension)
-    tty->print_cr("can_get_source_debug_extension");
+    log_trace(jvmti)("can_get_source_debug_extension");
   if (cap->can_access_local_variables)
-    tty->print_cr("can_access_local_variables");
+    log_trace(jvmti)("can_access_local_variables");
   if (cap->can_maintain_original_method_order)
-    tty->print_cr("can_maintain_original_method_order");
+    log_trace(jvmti)("can_maintain_original_method_order");
   if (cap->can_generate_single_step_events)
-    tty->print_cr("can_generate_single_step_events");
+    log_trace(jvmti)("can_generate_single_step_events");
   if (cap->can_generate_exception_events)
-    tty->print_cr("can_generate_exception_events");
+    log_trace(jvmti)("can_generate_exception_events");
   if (cap->can_generate_frame_pop_events)
-    tty->print_cr("can_generate_frame_pop_events");
+    log_trace(jvmti)("can_generate_frame_pop_events");
   if (cap->can_generate_breakpoint_events)
-    tty->print_cr("can_generate_breakpoint_events");
+    log_trace(jvmti)("can_generate_breakpoint_events");
   if (cap->can_suspend)
-    tty->print_cr("can_suspend");
+    log_trace(jvmti)("can_suspend");
   if (cap->can_redefine_any_class )
-    tty->print_cr("can_redefine_any_class");
+    log_trace(jvmti)("can_redefine_any_class");
   if (cap->can_retransform_any_class )
-    tty->print_cr("can_retransform_any_class");
+    log_trace(jvmti)("can_retransform_any_class");
   if (cap->can_get_current_thread_cpu_time)
-    tty->print_cr("can_get_current_thread_cpu_time");
+    log_trace(jvmti)("can_get_current_thread_cpu_time");
   if (cap->can_get_thread_cpu_time)
-    tty->print_cr("can_get_thread_cpu_time");
+    log_trace(jvmti)("can_get_thread_cpu_time");
   if (cap->can_generate_method_entry_events)
-    tty->print_cr("can_generate_method_entry_events");
+    log_trace(jvmti)("can_generate_method_entry_events");
   if (cap->can_generate_method_exit_events)
-    tty->print_cr("can_generate_method_exit_events");
+    log_trace(jvmti)("can_generate_method_exit_events");
   if (cap->can_generate_all_class_hook_events)
-    tty->print_cr("can_generate_all_class_hook_events");
+    log_trace(jvmti)("can_generate_all_class_hook_events");
   if (cap->can_generate_compiled_method_load_events)
-    tty->print_cr("can_generate_compiled_method_load_events");
+    log_trace(jvmti)("can_generate_compiled_method_load_events");
   if (cap->can_generate_monitor_events)
-    tty->print_cr("can_generate_monitor_events");
+    log_trace(jvmti)("can_generate_monitor_events");
   if (cap->can_generate_vm_object_alloc_events)
-    tty->print_cr("can_generate_vm_object_alloc_events");
+    log_trace(jvmti)("can_generate_vm_object_alloc_events");
   if (cap->can_generate_native_method_bind_events)
-    tty->print_cr("can_generate_native_method_bind_events");
+    log_trace(jvmti)("can_generate_native_method_bind_events");
   if (cap->can_generate_garbage_collection_events)
-    tty->print_cr("can_generate_garbage_collection_events");
+    log_trace(jvmti)("can_generate_garbage_collection_events");
   if (cap->can_generate_object_free_events)
-    tty->print_cr("can_generate_object_free_events");
+    log_trace(jvmti)("can_generate_object_free_events");
   if (cap->can_generate_resource_exhaustion_heap_events)
-    tty->print_cr("can_generate_resource_exhaustion_heap_events");
+    log_trace(jvmti)("can_generate_resource_exhaustion_heap_events");
   if (cap->can_generate_resource_exhaustion_threads_events)
-    tty->print_cr("can_generate_resource_exhaustion_threads_events");
+    log_trace(jvmti)("can_generate_resource_exhaustion_threads_events");
   if (cap->can_generate_early_vmstart)
-    tty->print_cr("can_generate_early_vmstart");
+    log_trace(jvmti)("can_generate_early_vmstart");
+  if (cap->can_generate_early_class_hook_events)
+    log_trace(jvmti)("can_generate_early_class_hook_events");
 }
 
 #endif
diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
index c6737e7..f173e57 100644
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
@@ -32,6 +32,7 @@
 #include "gc/shared/gcLocker.hpp"
 #include "interpreter/oopMapCache.hpp"
 #include "interpreter/rewriter.hpp"
+#include "logging/logStream.hpp"
 #include "memory/metadataFactory.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "memory/resourceArea.hpp"
@@ -68,6 +69,43 @@
   _res = JVMTI_ERROR_NONE;
 }
 
+static inline InstanceKlass* get_ik(jclass def) {
+  oop mirror = JNIHandles::resolve_non_null(def);
+  return InstanceKlass::cast(java_lang_Class::as_Klass(mirror));
+}
+
+// If any of the classes are being redefined, wait
+// Parallel constant pool merging leads to indeterminate constant pools.
+void VM_RedefineClasses::lock_classes() {
+  MutexLocker ml(RedefineClasses_lock);
+  bool has_redefined;
+  do {
+    has_redefined = false;
+    // Go through classes each time until none are being redefined.
+    for (int i = 0; i < _class_count; i++) {
+      if (get_ik(_class_defs[i].klass)->is_being_redefined()) {
+        RedefineClasses_lock->wait();
+        has_redefined = true;
+        break;  // for loop
+      }
+    }
+  } while (has_redefined);
+  for (int i = 0; i < _class_count; i++) {
+    get_ik(_class_defs[i].klass)->set_is_being_redefined(true);
+  }
+  RedefineClasses_lock->notify_all();
+}
+
+void VM_RedefineClasses::unlock_classes() {
+  MutexLocker ml(RedefineClasses_lock);
+  for (int i = 0; i < _class_count; i++) {
+    assert(get_ik(_class_defs[i].klass)->is_being_redefined(),
+           "should be being redefined to get here");
+    get_ik(_class_defs[i].klass)->set_is_being_redefined(false);
+  }
+  RedefineClasses_lock->notify_all();
+}
+
 bool VM_RedefineClasses::doit_prologue() {
   if (_class_count == 0) {
     _res = JVMTI_ERROR_NONE;
@@ -90,12 +128,23 @@
       _res = JVMTI_ERROR_NULL_POINTER;
       return false;
     }
+
+    oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass);
+    // classes for primitives and arrays cannot be redefined
+    // check here so following code can assume these classes are InstanceKlass
+    if (!is_modifiable_class(mirror)) {
+      _res = JVMTI_ERROR_UNMODIFIABLE_CLASS;
+      return false;
+    }
   }
 
   // Start timer after all the sanity checks; not quite accurate, but
   // better than adding a bunch of stop() calls.
-  RC_TIMER_START(_timer_vm_op_prologue);
+  if (log_is_enabled(Info, redefine, class, timer)) {
+    _timer_vm_op_prologue.start();
+  }
 
+  lock_classes();
   // We first load new class versions in the prologue, because somewhere down the
   // call chain it is required that the current thread is a Java thread.
   _res = load_new_class_versions(Thread::current());
@@ -111,11 +160,12 @@
     }
     // Free os::malloc allocated memory in load_new_class_version.
     os::free(_scratch_classes);
-    RC_TIMER_STOP(_timer_vm_op_prologue);
+    _timer_vm_op_prologue.stop();
+    unlock_classes();
     return false;
   }
 
-  RC_TIMER_STOP(_timer_vm_op_prologue);
+  _timer_vm_op_prologue.stop();
   return true;
 }
 
@@ -128,8 +178,7 @@
     // a shared class. We do the remap during the doit() phase of
     // the safepoint to be safer.
     if (!MetaspaceShared::remap_shared_readonly_as_readwrite()) {
-      RC_TRACE_WITH_THREAD(0x00000001, thread,
-        ("failed to remap shared readonly space to readwrite, private"));
+      log_info(redefine, class, load)("failed to remap shared readonly space to readwrite, private");
       _res = JVMTI_ERROR_INTERNAL;
       return;
     }
@@ -161,9 +210,9 @@
   // check_class() is optionally called for product bits, but is
   // always called for non-product bits.
 #ifdef PRODUCT
-  if (RC_TRACE_ENABLED(0x00004000)) {
+  if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) {
 #endif
-    RC_TRACE_WITH_THREAD(0x00004000, thread, ("calling check_class"));
+    log_trace(redefine, class, obsolete, metadata)("calling check_class");
     CheckClass check_class(thread);
     ClassLoaderDataGraph::classes_do(&check_class);
 #ifdef PRODUCT
@@ -172,25 +221,27 @@
 }
 
 void VM_RedefineClasses::doit_epilogue() {
+  unlock_classes();
+
   // Free os::malloc allocated memory.
   os::free(_scratch_classes);
 
   // Reset the_class_oop to null for error printing.
   _the_class_oop = NULL;
 
-  if (RC_TRACE_ENABLED(0x00000004)) {
+  if (log_is_enabled(Info, redefine, class, timer)) {
     // Used to have separate timers for "doit" and "all", but the timer
     // overhead skewed the measurements.
     jlong doit_time = _timer_rsc_phase1.milliseconds() +
                       _timer_rsc_phase2.milliseconds();
     jlong all_time = _timer_vm_op_prologue.milliseconds() + doit_time;
 
-    RC_TRACE(0x00000004, ("vm_op: all=" UINT64_FORMAT
-      "  prologue=" UINT64_FORMAT "  doit=" UINT64_FORMAT, all_time,
-      _timer_vm_op_prologue.milliseconds(), doit_time));
-    RC_TRACE(0x00000004,
+    log_info(redefine, class, timer)
+      ("vm_op: all=" UINT64_FORMAT "  prologue=" UINT64_FORMAT "  doit=" UINT64_FORMAT,
+       all_time, _timer_vm_op_prologue.milliseconds(), doit_time);
+    log_info(redefine, class, timer)
       ("redefine_single_class: phase1=" UINT64_FORMAT "  phase2=" UINT64_FORMAT,
-       _timer_rsc_phase1.milliseconds(), _timer_rsc_phase2.milliseconds()));
+       _timer_rsc_phase1.milliseconds(), _timer_rsc_phase2.milliseconds());
   }
 }
 
@@ -305,14 +356,14 @@
       // both new_name_ref_i and new_signature_ref_i will both be 0.
       // In that case, all we are appending is the current entry.
       if (new_name_ref_i != name_ref_i) {
-        RC_TRACE(0x00080000,
+        log_trace(redefine, class, constantpool)
           ("NameAndType entry@%d name_ref_index change: %d to %d",
-          *merge_cp_length_p, name_ref_i, new_name_ref_i));
+           *merge_cp_length_p, name_ref_i, new_name_ref_i);
       }
       if (new_signature_ref_i != signature_ref_i) {
-        RC_TRACE(0x00080000,
+        log_trace(redefine, class, constantpool)
           ("NameAndType entry@%d signature_ref_index change: %d to %d",
-          *merge_cp_length_p, signature_ref_i, new_signature_ref_i));
+           *merge_cp_length_p, signature_ref_i, new_signature_ref_i);
       }
 
       (*merge_cp_p)->name_and_type_at_put(*merge_cp_length_p,
@@ -361,14 +412,13 @@
       }
 
       if (klass_ref_i != new_klass_ref_i) {
-        RC_TRACE(0x00080000, ("%s entry@%d class_index changed: %d to %d",
-          entry_name, *merge_cp_length_p, klass_ref_i, new_klass_ref_i));
+        log_trace(redefine, class, constantpool)
+          ("%s entry@%d class_index changed: %d to %d", entry_name, *merge_cp_length_p, klass_ref_i, new_klass_ref_i);
       }
       if (name_and_type_ref_i != new_name_and_type_ref_i) {
-        RC_TRACE(0x00080000,
+        log_trace(redefine, class, constantpool)
           ("%s entry@%d name_and_type_index changed: %d to %d",
-          entry_name, *merge_cp_length_p, name_and_type_ref_i,
-          new_name_and_type_ref_i));
+           entry_name, *merge_cp_length_p, name_and_type_ref_i, new_name_and_type_ref_i);
       }
 
       if (scratch_i != *merge_cp_length_p) {
@@ -386,9 +436,8 @@
       int new_ref_i = find_or_append_indirect_entry(scratch_cp, ref_i, merge_cp_p,
                                                     merge_cp_length_p, THREAD);
       if (new_ref_i != ref_i) {
-        RC_TRACE(0x00080000,
-                 ("MethodType entry@%d ref_index change: %d to %d",
-                  *merge_cp_length_p, ref_i, new_ref_i));
+        log_trace(redefine, class, constantpool)
+          ("MethodType entry@%d ref_index change: %d to %d", *merge_cp_length_p, ref_i, new_ref_i);
       }
       (*merge_cp_p)->method_type_index_at_put(*merge_cp_length_p, new_ref_i);
       if (scratch_i != *merge_cp_length_p) {
@@ -407,9 +456,8 @@
       int new_ref_i = find_or_append_indirect_entry(scratch_cp, ref_i, merge_cp_p,
                                                     merge_cp_length_p, THREAD);
       if (new_ref_i != ref_i) {
-        RC_TRACE(0x00080000,
-                 ("MethodHandle entry@%d ref_index change: %d to %d",
-                  *merge_cp_length_p, ref_i, new_ref_i));
+        log_trace(redefine, class, constantpool)
+          ("MethodHandle entry@%d ref_index change: %d to %d", *merge_cp_length_p, ref_i, new_ref_i);
       }
       (*merge_cp_p)->method_handle_index_at_put(*merge_cp_length_p, ref_kind, new_ref_i);
       if (scratch_i != *merge_cp_length_p) {
@@ -432,14 +480,13 @@
       int new_ref_i = find_or_append_indirect_entry(scratch_cp, old_ref_i, merge_cp_p,
                                                     merge_cp_length_p, THREAD);
       if (new_bs_i != old_bs_i) {
-        RC_TRACE(0x00080000,
-                 ("InvokeDynamic entry@%d bootstrap_method_attr_index change: %d to %d",
-                  *merge_cp_length_p, old_bs_i, new_bs_i));
+        log_trace(redefine, class, constantpool)
+          ("InvokeDynamic entry@%d bootstrap_method_attr_index change: %d to %d",
+           *merge_cp_length_p, old_bs_i, new_bs_i);
       }
       if (new_ref_i != old_ref_i) {
-        RC_TRACE(0x00080000,
-                 ("InvokeDynamic entry@%d name_and_type_index change: %d to %d",
-                  *merge_cp_length_p, old_ref_i, new_ref_i));
+        log_trace(redefine, class, constantpool)
+          ("InvokeDynamic entry@%d name_and_type_index change: %d to %d", *merge_cp_length_p, old_ref_i, new_ref_i);
       }
 
       (*merge_cp_p)->invoke_dynamic_at_put(*merge_cp_length_p, new_bs_i, new_ref_i);
@@ -516,9 +563,8 @@
   int new_ref_i = find_or_append_indirect_entry(scratch_cp, old_ref_i, merge_cp_p,
                                                 merge_cp_length_p, THREAD);
   if (new_ref_i != old_ref_i) {
-    RC_TRACE(0x00080000,
-             ("operands entry@%d bootstrap method ref_index change: %d to %d",
-              _operands_cur_length, old_ref_i, new_ref_i));
+    log_trace(redefine, class, constantpool)
+      ("operands entry@%d bootstrap method ref_index change: %d to %d", _operands_cur_length, old_ref_i, new_ref_i);
   }
 
   Array<u2>* merge_ops = (*merge_cp_p)->operands();
@@ -539,9 +585,9 @@
                                                       merge_cp_length_p, THREAD);
     merge_ops->at_put(new_base++, new_arg_ref_i);
     if (new_arg_ref_i != old_arg_ref_i) {
-      RC_TRACE(0x00080000,
-               ("operands entry@%d bootstrap method argument ref_index change: %d to %d",
-                _operands_cur_length, old_arg_ref_i, new_arg_ref_i));
+      log_trace(redefine, class, constantpool)
+        ("operands entry@%d bootstrap method argument ref_index change: %d to %d",
+         _operands_cur_length, old_arg_ref_i, new_arg_ref_i);
     }
   }
   if (old_bs_i != _operands_cur_length) {
@@ -586,14 +632,13 @@
   // Shrink the merge_cp operands
   merge_cp->shrink_operands(_operands_cur_length, CHECK);
 
-  if (RC_TRACE_ENABLED(0x00040000)) {
+  if (log_is_enabled(Trace, redefine, class, constantpool)) {
     // don't want to loop unless we are tracing
     int count = 0;
     for (int i = 1; i < _operands_index_map_p->length(); i++) {
       int value = _operands_index_map_p->at(i);
       if (value != -1) {
-        RC_TRACE_WITH_THREAD(0x00040000, THREAD,
-          ("operands_index_map[%d]: old=%d new=%d", count, i, value));
+        log_trace(redefine, class, constantpool)("operands_index_map[%d]: old=%d new=%d", count, i, value);
         count++;
       }
     }
@@ -795,9 +840,9 @@
           }
         }
       }
-      RC_TRACE(0x00008000, ("Method matched: new: %s [%d] == old: %s [%d]",
-                            k_new_method->name_and_sig_as_C_string(), ni,
-                            k_old_method->name_and_sig_as_C_string(), oi));
+      log_trace(redefine, class, normalize)
+        ("Method matched: new: %s [%d] == old: %s [%d]",
+         k_new_method->name_and_sig_as_C_string(), ni, k_old_method->name_and_sig_as_C_string(), oi);
       // advance to next pair of methods
       ++oi;
       ++ni;
@@ -832,8 +877,8 @@
           return JVMTI_ERROR_OUT_OF_MEMORY;
         }
       }
-      RC_TRACE(0x00008000, ("Method added: new: %s [%d]",
-                            k_new_method->name_and_sig_as_C_string(), ni));
+      log_trace(redefine, class, normalize)
+        ("Method added: new: %s [%d]", k_new_method->name_and_sig_as_C_string(), ni);
       ++ni; // advance to next new method
       break;
     case deleted:
@@ -846,8 +891,8 @@
         // deleted methods must be private
         return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED;
       }
-      RC_TRACE(0x00008000, ("Method deleted: old: %s [%d]",
-                            k_old_method->name_and_sig_as_C_string(), oi));
+      log_trace(redefine, class, normalize)
+        ("Method deleted: old: %s [%d]", k_old_method->name_and_sig_as_C_string(), oi);
       ++oi; // advance to next old method
       break;
     default:
@@ -963,21 +1008,12 @@
     // versions are deleted. Constant pools are deallocated while merging
     // constant pools
     HandleMark hm(THREAD);
-
-    oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass);
-    // classes for primitives cannot be redefined
-    if (!is_modifiable_class(mirror)) {
-      return JVMTI_ERROR_UNMODIFIABLE_CLASS;
-    }
-    Klass* the_class_oop = java_lang_Class::as_Klass(mirror);
-    instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop);
+    instanceKlassHandle the_class(THREAD, get_ik(_class_defs[i].klass));
     Symbol*  the_class_sym = the_class->name();
 
-    // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-    RC_TRACE_WITH_THREAD(0x00000001, THREAD,
+    log_debug(redefine, class, load)
       ("loading name=%s kind=%d (avail_mem=" UINT64_FORMAT "K)",
-      the_class->external_name(), _class_load_kind,
-      os::available_memory() >> 10));
+       the_class->external_name(), _class_load_kind, os::available_memory() >> 10);
 
     ClassFileStream st((u1*)_class_defs[i].class_bytes,
                        _class_defs[i].class_byte_count,
@@ -1011,9 +1047,7 @@
 
     if (HAS_PENDING_EXCEPTION) {
       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
-      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-      RC_TRACE_WITH_THREAD(0x00000002, THREAD, ("parse_stream exception: '%s'",
-        ex_name->as_C_string()));
+      log_info(redefine, class, load, exceptions)("parse_stream exception: '%s'", ex_name->as_C_string());
       CLEAR_PENDING_EXCEPTION;
 
       if (ex_name == vmSymbols::java_lang_UnsupportedClassVersionError()) {
@@ -1037,9 +1071,7 @@
       the_class->link_class(THREAD);
       if (HAS_PENDING_EXCEPTION) {
         Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
-        // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-        RC_TRACE_WITH_THREAD(0x00000002, THREAD, ("link_class exception: '%s'",
-          ex_name->as_C_string()));
+        log_info(redefine, class, load, exceptions)("link_class exception: '%s'", ex_name->as_C_string());
         CLEAR_PENDING_EXCEPTION;
         if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
           return JVMTI_ERROR_OUT_OF_MEMORY;
@@ -1075,9 +1107,7 @@
 
     if (HAS_PENDING_EXCEPTION) {
       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
-      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-      RC_TRACE_WITH_THREAD(0x00000002, THREAD,
-        ("verify_byte_codes exception: '%s'", ex_name->as_C_string()));
+      log_info(redefine, class, load, exceptions)("verify_byte_codes exception: '%s'", ex_name->as_C_string());
       CLEAR_PENDING_EXCEPTION;
       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
         return JVMTI_ERROR_OUT_OF_MEMORY;
@@ -1090,9 +1120,7 @@
     res = merge_cp_and_rewrite(the_class, scratch_class, THREAD);
     if (HAS_PENDING_EXCEPTION) {
       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
-      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-      RC_TRACE_WITH_THREAD(0x00000002, THREAD,
-        ("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string()));
+      log_info(redefine, class, load, exceptions)("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string());
       CLEAR_PENDING_EXCEPTION;
       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
         return JVMTI_ERROR_OUT_OF_MEMORY;
@@ -1110,10 +1138,8 @@
 
       if (HAS_PENDING_EXCEPTION) {
         Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
-        // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-        RC_TRACE_WITH_THREAD(0x00000002, THREAD,
-          ("verify_byte_codes post merge-CP exception: '%s'",
-          ex_name->as_C_string()));
+        log_info(redefine, class, load, exceptions)
+          ("verify_byte_codes post merge-CP exception: '%s'", ex_name->as_C_string());
         CLEAR_PENDING_EXCEPTION;
         if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
           return JVMTI_ERROR_OUT_OF_MEMORY;
@@ -1130,9 +1156,8 @@
     }
     if (HAS_PENDING_EXCEPTION) {
       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
-      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-      RC_TRACE_WITH_THREAD(0x00000002, THREAD,
-        ("Rewriter::rewrite or link_methods exception: '%s'", ex_name->as_C_string()));
+      log_info(redefine, class, load, exceptions)
+        ("Rewriter::rewrite or link_methods exception: '%s'", ex_name->as_C_string());
       CLEAR_PENDING_EXCEPTION;
       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
         return JVMTI_ERROR_OUT_OF_MEMORY;
@@ -1141,10 +1166,8 @@
       }
     }
 
-    // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-    RC_TRACE_WITH_THREAD(0x00000001, THREAD,
-      ("loaded name=%s (avail_mem=" UINT64_FORMAT "K)",
-      the_class->external_name(), os::available_memory() >> 10));
+    log_debug(redefine, class, load)
+      ("loaded name=%s (avail_mem=" UINT64_FORMAT "K)", the_class->external_name(), os::available_memory() >> 10);
   }
 
   return JVMTI_ERROR_NONE;
@@ -1152,7 +1175,7 @@
 
 
 // Map old_index to new_index as needed. scratch_cp is only needed
-// for RC_TRACE() calls.
+// for log calls.
 void VM_RedefineClasses::map_index(const constantPoolHandle& scratch_cp,
        int old_index, int new_index) {
   if (find_new_index(old_index) != 0) {
@@ -1168,8 +1191,8 @@
   _index_map_p->at_put(old_index, new_index);
   _index_map_count++;
 
-  RC_TRACE(0x00040000, ("mapped tag %d at index %d to %d",
-    scratch_cp->tag_at(old_index).value(), old_index, new_index));
+  log_trace(redefine, class, constantpool)
+    ("mapped tag %d at index %d to %d", scratch_cp->tag_at(old_index).value(), old_index, new_index);
 } // end map_index()
 
 
@@ -1188,7 +1211,7 @@
   _operands_index_map_p->at_put(old_index, new_index);
   _operands_index_map_count++;
 
-  RC_TRACE(0x00040000, ("mapped bootstrap specifier at index %d to %d", old_index, new_index));
+  log_trace(redefine, class, constantpool)("mapped bootstrap specifier at index %d to %d", old_index, new_index);
 } // end map_index()
 
 
@@ -1219,9 +1242,7 @@
     return false; // robustness
   }
 
-  RC_TRACE_WITH_THREAD(0x00010000, THREAD,
-    ("old_cp_len=%d, scratch_cp_len=%d", old_cp->length(),
-    scratch_cp->length()));
+  log_info(redefine, class, constantpool)("old_cp_len=%d, scratch_cp_len=%d", old_cp->length(), scratch_cp->length());
 
   {
     // Pass 0:
@@ -1273,8 +1294,7 @@
 
   // merge_cp_len should be the same as old_cp->length() at this point
   // so this trace message is really a "warm-and-breathing" message.
-  RC_TRACE_WITH_THREAD(0x00020000, THREAD,
-    ("after pass 0: merge_cp_len=%d", *merge_cp_length_p));
+  log_debug(redefine, class, constantpool)("after pass 0: merge_cp_len=%d", *merge_cp_length_p);
 
   int scratch_i;  // index into scratch_cp
   {
@@ -1339,9 +1359,9 @@
     }
   }
 
-  RC_TRACE_WITH_THREAD(0x00020000, THREAD,
+  log_debug(redefine, class, constantpool)
     ("after pass 1a: merge_cp_len=%d, scratch_i=%d, index_map_len=%d",
-    *merge_cp_length_p, scratch_i, _index_map_count));
+     *merge_cp_length_p, scratch_i, _index_map_count);
 
   if (scratch_i < scratch_cp->length()) {
     // Pass 1b:
@@ -1377,9 +1397,9 @@
         CHECK_0);
     }
 
-    RC_TRACE_WITH_THREAD(0x00020000, THREAD,
+    log_debug(redefine, class, constantpool)
       ("after pass 1b: merge_cp_len=%d, scratch_i=%d, index_map_len=%d",
-      *merge_cp_length_p, scratch_i, _index_map_count));
+       *merge_cp_length_p, scratch_i, _index_map_count);
   }
   finalize_operands_merge(*merge_cp_p, THREAD);
 
@@ -1449,12 +1469,12 @@
 
   ResourceMark rm(THREAD);
   _index_map_count = 0;
-  _index_map_p = new intArray(scratch_cp->length(), -1);
+  _index_map_p = new intArray(scratch_cp->length(), scratch_cp->length(), -1);
 
   _operands_cur_length = ConstantPool::operand_array_length(old_cp->operands());
   _operands_index_map_count = 0;
-  _operands_index_map_p = new intArray(
-    ConstantPool::operand_array_length(scratch_cp->operands()), -1);
+  int operands_index_map_len = ConstantPool::operand_array_length(scratch_cp->operands());
+  _operands_index_map_p = new intArray(operands_index_map_len, operands_index_map_len, -1);
 
   // reference to the cp holder is needed for copy_operands()
   merge_cp->set_pool_holder(scratch_class());
@@ -1468,8 +1488,7 @@
     return JVMTI_ERROR_INTERNAL;
   }
 
-  RC_TRACE_WITH_THREAD(0x00010000, THREAD,
-    ("merge_cp_len=%d, index_map_len=%d", merge_cp_length, _index_map_count));
+  log_info(redefine, class, constantpool)("merge_cp_len=%d, index_map_len=%d", merge_cp_length, _index_map_count);
 
   if (_index_map_count == 0) {
     // there is nothing to map between the new and merged constant pools
@@ -1508,15 +1527,14 @@
       cp_cleaner.add_scratch_cp(scratch_cp());
     }
   } else {
-    if (RC_TRACE_ENABLED(0x00040000)) {
+    if (log_is_enabled(Trace, redefine, class, constantpool)) {
       // don't want to loop unless we are tracing
       int count = 0;
       for (int i = 1; i < _index_map_p->length(); i++) {
         int value = _index_map_p->at(i);
 
         if (value != -1) {
-          RC_TRACE_WITH_THREAD(0x00040000, THREAD,
-            ("index_map[%d]: old=%d new=%d", count, i, value));
+          log_trace(redefine, class, constantpool)("index_map[%d]: old=%d new=%d", count, i, value);
           count++;
         }
       }
@@ -1653,9 +1671,7 @@
     }
     if (HAS_PENDING_EXCEPTION) {
       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
-      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
-      RC_TRACE_WITH_THREAD(0x00000002, THREAD,
-        ("rewrite_cp_refs_in_method exception: '%s'", ex_name->as_C_string()));
+      log_info(redefine, class, load, exceptions)("rewrite_cp_refs_in_method exception: '%s'", ex_name->as_C_string());
       // Need to clear pending exception here as the super caller sets
       // the JVMTI_ERROR_INTERNAL if the returned value is false.
       CLEAR_PENDING_EXCEPTION;
@@ -1715,14 +1731,12 @@
           if (!StressLdcRewrite && new_index <= max_jubyte) {
             // The new value can still use ldc instead of ldc_w
             // unless we are trying to stress ldc -> ldc_w rewriting
-            RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-              ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c),
-              p2i(bcp), cp_index, new_index));
+            log_trace(redefine, class, constantpool)
+              ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c), p2i(bcp), cp_index, new_index);
             *(bcp + 1) = new_index;
           } else {
-            RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-              ("%s->ldc_w@" INTPTR_FORMAT " old=%d, new=%d",
-              Bytecodes::name(c), p2i(bcp), cp_index, new_index));
+            log_trace(redefine, class, constantpool)
+              ("%s->ldc_w@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c), p2i(bcp), cp_index, new_index);
             // the new value needs ldc_w instead of ldc
             u_char inst_buffer[4]; // max instruction size is 4 bytes
             bcp = (address)inst_buffer;
@@ -1781,9 +1795,8 @@
         int new_index = find_new_index(cp_index);
         if (new_index != 0) {
           // the original index is mapped so update w/ new value
-          RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-            ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c),
-            p2i(bcp), cp_index, new_index));
+          log_trace(redefine, class, constantpool)
+            ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c),p2i(bcp), cp_index, new_index);
           // Rewriter::rewrite_method() uses put_native_u2() in this
           // situation because it is reusing the constant pool index
           // location for a native index into the ConstantPoolCache.
@@ -1823,8 +1836,7 @@
     return true;
   }
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("class_annotations length=%d", class_annotations->length()));
+  log_debug(redefine, class, annotation)("class_annotations length=%d", class_annotations->length());
 
   int byte_i = 0;  // byte index into class_annotations
   return rewrite_cp_refs_in_annotations_typeArray(class_annotations, byte_i,
@@ -1846,8 +1858,7 @@
 
   if ((byte_i_ref + 2) > annotations_typeArray->length()) {
     // not enough room for num_annotations field
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("length() is too small for num_annotations field"));
+    log_debug(redefine, class, annotation)("length() is too small for num_annotations field");
     return false;
   }
 
@@ -1855,15 +1866,13 @@
                          annotations_typeArray->adr_at(byte_i_ref));
   byte_i_ref += 2;
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("num_annotations=%d", num_annotations));
+  log_debug(redefine, class, annotation)("num_annotations=%d", num_annotations);
 
   int calc_num_annotations = 0;
   for (; calc_num_annotations < num_annotations; calc_num_annotations++) {
     if (!rewrite_cp_refs_in_annotation_struct(annotations_typeArray,
            byte_i_ref, THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad annotation_struct at %d", calc_num_annotations));
+      log_debug(redefine, class, annotation)("bad annotation_struct at %d", calc_num_annotations);
       // propagate failure back to caller
       return false;
     }
@@ -1891,8 +1900,7 @@
        AnnotationArray* annotations_typeArray, int &byte_i_ref, TRAPS) {
   if ((byte_i_ref + 2 + 2) > annotations_typeArray->length()) {
     // not enough room for smallest annotation_struct
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("length() is too small for annotation_struct"));
+    log_debug(redefine, class, annotation)("length() is too small for annotation_struct");
     return false;
   }
 
@@ -1903,9 +1911,8 @@
                                  annotations_typeArray->adr_at(byte_i_ref));
   byte_i_ref += 2;
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("type_index=%d  num_element_value_pairs=%d", type_index,
-    num_element_value_pairs));
+  log_debug(redefine, class, annotation)
+    ("type_index=%d  num_element_value_pairs=%d", type_index, num_element_value_pairs);
 
   int calc_num_element_value_pairs = 0;
   for (; calc_num_element_value_pairs < num_element_value_pairs;
@@ -1913,8 +1920,7 @@
     if ((byte_i_ref + 2) > annotations_typeArray->length()) {
       // not enough room for another element_name_index, let alone
       // the rest of another component
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("length() is too small for element_name_index"));
+      log_debug(redefine, class, annotation)("length() is too small for element_name_index");
       return false;
     }
 
@@ -1922,13 +1928,11 @@
                               annotations_typeArray, byte_i_ref,
                               "element_name_index", THREAD);
 
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("element_name_index=%d", element_name_index));
+    log_debug(redefine, class, annotation)("element_name_index=%d", element_name_index);
 
     if (!rewrite_cp_refs_in_element_value(annotations_typeArray,
            byte_i_ref, THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad element_value at %d", calc_num_element_value_pairs));
+      log_debug(redefine, class, annotation)("bad element_value at %d", calc_num_element_value_pairs);
       // propagate failure back to caller
       return false;
     }
@@ -1953,7 +1957,7 @@
   u2 old_cp_index = Bytes::get_Java_u2(cp_index_addr);
   u2 new_cp_index = find_new_index(old_cp_index);
   if (new_cp_index != 0) {
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("mapped old %s=%d", trace_mesg, old_cp_index));
+    log_debug(redefine, class, annotation)("mapped old %s=%d", trace_mesg, old_cp_index);
     Bytes::put_Java_u2(cp_index_addr, new_cp_index);
     old_cp_index = new_cp_index;
   }
@@ -1988,14 +1992,13 @@
 
   if ((byte_i_ref + 1) > annotations_typeArray->length()) {
     // not enough room for a tag let alone the rest of an element_value
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("length() is too small for a tag"));
+    log_debug(redefine, class, annotation)("length() is too small for a tag");
     return false;
   }
 
   u1 tag = annotations_typeArray->at(byte_i_ref);
   byte_i_ref++;
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("tag='%c'", tag));
+  log_debug(redefine, class, annotation)("tag='%c'", tag);
 
   switch (tag) {
     // These BaseType tag values are from Table 4.2 in VM spec:
@@ -2017,8 +2020,7 @@
 
       if ((byte_i_ref + 2) > annotations_typeArray->length()) {
         // not enough room for a const_value_index
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a const_value_index"));
+        log_debug(redefine, class, annotation)("length() is too small for a const_value_index");
         return false;
       }
 
@@ -2026,8 +2028,7 @@
                                annotations_typeArray, byte_i_ref,
                                "const_value_index", THREAD);
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("const_value_index=%d", const_value_index));
+      log_debug(redefine, class, annotation)("const_value_index=%d", const_value_index);
     } break;
 
     case 'e':
@@ -2036,8 +2037,7 @@
 
       if ((byte_i_ref + 4) > annotations_typeArray->length()) {
         // not enough room for a enum_const_value
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a enum_const_value"));
+        log_debug(redefine, class, annotation)("length() is too small for a enum_const_value");
         return false;
       }
 
@@ -2049,9 +2049,8 @@
                               annotations_typeArray, byte_i_ref,
                               "const_name_index", THREAD);
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("type_name_index=%d  const_name_index=%d", type_name_index,
-        const_name_index));
+      log_debug(redefine, class, annotation)
+        ("type_name_index=%d  const_name_index=%d", type_name_index, const_name_index);
     } break;
 
     case 'c':
@@ -2060,8 +2059,7 @@
 
       if ((byte_i_ref + 2) > annotations_typeArray->length()) {
         // not enough room for a class_info_index
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a class_info_index"));
+        log_debug(redefine, class, annotation)("length() is too small for a class_info_index");
         return false;
       }
 
@@ -2069,8 +2067,7 @@
                               annotations_typeArray, byte_i_ref,
                               "class_info_index", THREAD);
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("class_info_index=%d", class_info_index));
+      log_debug(redefine, class, annotation)("class_info_index=%d", class_info_index);
     } break;
 
     case '@':
@@ -2087,8 +2084,7 @@
     {
       if ((byte_i_ref + 2) > annotations_typeArray->length()) {
         // not enough room for a num_values field
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a num_values field"));
+        log_debug(redefine, class, annotation)("length() is too small for a num_values field");
         return false;
       }
 
@@ -2097,14 +2093,13 @@
       u2 num_values = Bytes::get_Java_u2((address)
                         annotations_typeArray->adr_at(byte_i_ref));
       byte_i_ref += 2;
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("num_values=%d", num_values));
+      log_debug(redefine, class, annotation)("num_values=%d", num_values);
 
       int calc_num_values = 0;
       for (; calc_num_values < num_values; calc_num_values++) {
         if (!rewrite_cp_refs_in_element_value(
                annotations_typeArray, byte_i_ref, THREAD)) {
-          RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-            ("bad nested element_value at %d", calc_num_values));
+          log_debug(redefine, class, annotation)("bad nested element_value at %d", calc_num_values);
           // propagate failure back to caller
           return false;
         }
@@ -2113,7 +2108,7 @@
     } break;
 
     default:
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("bad tag=0x%x", tag));
+      log_debug(redefine, class, annotation)("bad tag=0x%x", tag);
       return false;
   } // end decode tag field
 
@@ -2132,8 +2127,7 @@
     return true;
   }
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("fields_annotations length=%d", fields_annotations->length()));
+  log_debug(redefine, class, annotation)("fields_annotations length=%d", fields_annotations->length());
 
   for (int i = 0; i < fields_annotations->length(); i++) {
     AnnotationArray* field_annotations = fields_annotations->at(i);
@@ -2145,8 +2139,7 @@
     int byte_i = 0;  // byte index into field_annotations
     if (!rewrite_cp_refs_in_annotations_typeArray(field_annotations, byte_i,
            THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad field_annotations at %d", i));
+      log_debug(redefine, class, annotation)("bad field_annotations at %d", i);
       // propagate failure back to caller
       return false;
     }
@@ -2172,8 +2165,7 @@
     int byte_i = 0;  // byte index into method_annotations
     if (!rewrite_cp_refs_in_annotations_typeArray(method_annotations, byte_i,
            THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad method_annotations at %d", i));
+      log_debug(redefine, class, annotation)("bad method_annotations at %d", i);
       // propagate failure back to caller
       return false;
     }
@@ -2210,8 +2202,7 @@
 
     if (method_parameter_annotations->length() < 1) {
       // not enough room for a num_parameters field
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("length() is too small for a num_parameters field at %d", i));
+      log_debug(redefine, class, annotation)("length() is too small for a num_parameters field at %d", i);
       return false;
     }
 
@@ -2220,15 +2211,13 @@
     u1 num_parameters = method_parameter_annotations->at(byte_i);
     byte_i++;
 
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("num_parameters=%d", num_parameters));
+    log_debug(redefine, class, annotation)("num_parameters=%d", num_parameters);
 
     int calc_num_parameters = 0;
     for (; calc_num_parameters < num_parameters; calc_num_parameters++) {
       if (!rewrite_cp_refs_in_annotations_typeArray(
              method_parameter_annotations, byte_i, THREAD)) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("bad method_parameter_annotations at %d", calc_num_parameters));
+        log_debug(redefine, class, annotation)("bad method_parameter_annotations at %d", calc_num_parameters);
         // propagate failure back to caller
         return false;
       }
@@ -2264,8 +2253,7 @@
 
     if (!rewrite_cp_refs_in_element_value(
            method_default_annotations, byte_i, THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad default element_value at %d", i));
+      log_debug(redefine, class, annotation)("bad default element_value at %d", i);
       // propagate failure back to caller
       return false;
     }
@@ -2285,8 +2273,7 @@
     return true;
   }
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("class_type_annotations length=%d", class_type_annotations->length()));
+  log_debug(redefine, class, annotation)("class_type_annotations length=%d", class_type_annotations->length());
 
   int byte_i = 0;  // byte index into class_type_annotations
   return rewrite_cp_refs_in_type_annotations_typeArray(class_type_annotations,
@@ -2304,8 +2291,7 @@
     return true;
   }
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("fields_type_annotations length=%d", fields_type_annotations->length()));
+  log_debug(redefine, class, annotation)("fields_type_annotations length=%d", fields_type_annotations->length());
 
   for (int i = 0; i < fields_type_annotations->length(); i++) {
     AnnotationArray* field_type_annotations = fields_type_annotations->at(i);
@@ -2317,8 +2303,7 @@
     int byte_i = 0;  // byte index into field_type_annotations
     if (!rewrite_cp_refs_in_type_annotations_typeArray(field_type_annotations,
            byte_i, "field_info", THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad field_type_annotations at %d", i));
+      log_debug(redefine, class, annotation)("bad field_type_annotations at %d", i);
       // propagate failure back to caller
       return false;
     }
@@ -2341,14 +2326,12 @@
       continue;
     }
 
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("methods type_annotations length=%d", method_type_annotations->length()));
+    log_debug(redefine, class, annotation)("methods type_annotations length=%d", method_type_annotations->length());
 
     int byte_i = 0;  // byte index into method_type_annotations
     if (!rewrite_cp_refs_in_type_annotations_typeArray(method_type_annotations,
            byte_i, "method_info", THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad method_type_annotations at %d", i));
+      log_debug(redefine, class, annotation)("bad method_type_annotations at %d", i);
       // propagate failure back to caller
       return false;
     }
@@ -2374,8 +2357,7 @@
 
   if ((byte_i_ref + 2) > type_annotations_typeArray->length()) {
     // not enough room for num_annotations field
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("length() is too small for num_annotations field"));
+    log_debug(redefine, class, annotation)("length() is too small for num_annotations field");
     return false;
   }
 
@@ -2383,15 +2365,13 @@
                          type_annotations_typeArray->adr_at(byte_i_ref));
   byte_i_ref += 2;
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("num_type_annotations=%d", num_annotations));
+  log_debug(redefine, class, annotation)("num_type_annotations=%d", num_annotations);
 
   int calc_num_annotations = 0;
   for (; calc_num_annotations < num_annotations; calc_num_annotations++) {
     if (!rewrite_cp_refs_in_type_annotation_struct(type_annotations_typeArray,
            byte_i_ref, location_mesg, THREAD)) {
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("bad type_annotation_struct at %d", calc_num_annotations));
+      log_debug(redefine, class, annotation)("bad type_annotation_struct at %d", calc_num_annotations);
       // propagate failure back to caller
       return false;
     }
@@ -2399,10 +2379,9 @@
   assert(num_annotations == calc_num_annotations, "sanity check");
 
   if (byte_i_ref != type_annotations_typeArray->length()) {
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("read wrong amount of bytes at end of processing "
-       "type_annotations_typeArray (%d of %d bytes were read)",
-       byte_i_ref, type_annotations_typeArray->length()));
+    log_debug(redefine, class, annotation)
+      ("read wrong amount of bytes at end of processing type_annotations_typeArray (%d of %d bytes were read)",
+       byte_i_ref, type_annotations_typeArray->length());
     return false;
   }
 
@@ -2479,15 +2458,14 @@
 
   if ((byte_i_ref + 1) > type_annotations_typeArray->length()) {
     // not enough room for a target_type let alone the rest of a type_annotation
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("length() is too small for a target_type"));
+    log_debug(redefine, class, annotation)("length() is too small for a target_type");
     return false;
   }
 
   u1 target_type = type_annotations_typeArray->at(byte_i_ref);
   byte_i_ref += 1;
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("target_type=0x%.2x", target_type));
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("location=%s", location_mesg));
+  log_debug(redefine, class, annotation)("target_type=0x%.2x", target_type);
+  log_debug(redefine, class, annotation)("location=%s", location_mesg);
 
   // Skip over target_info
   switch (target_type) {
@@ -2505,17 +2483,14 @@
       // }
       //
       if ((byte_i_ref + 1) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a type_parameter_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a type_parameter_target");
         return false;
       }
 
       u1 type_parameter_index = type_annotations_typeArray->at(byte_i_ref);
       byte_i_ref += 1;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("type_parameter_target: type_parameter_index=%d",
-         type_parameter_index));
+      log_debug(redefine, class, annotation)("type_parameter_target: type_parameter_index=%d", type_parameter_index);
     } break;
 
     case 0x10:
@@ -2531,8 +2506,7 @@
       // }
       //
       if ((byte_i_ref + 2) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a supertype_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a supertype_target");
         return false;
       }
 
@@ -2540,8 +2514,7 @@
                              type_annotations_typeArray->adr_at(byte_i_ref));
       byte_i_ref += 2;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("supertype_target: supertype_index=%d", supertype_index));
+      log_debug(redefine, class, annotation)("supertype_target: supertype_index=%d", supertype_index);
     } break;
 
     case 0x11:
@@ -2559,8 +2532,7 @@
       // }
       //
       if ((byte_i_ref + 2) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a type_parameter_bound_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a type_parameter_bound_target");
         return false;
       }
 
@@ -2569,9 +2541,8 @@
       u1 bound_index = type_annotations_typeArray->at(byte_i_ref);
       byte_i_ref += 1;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("type_parameter_bound_target: type_parameter_index=%d, bound_index=%d",
-         type_parameter_index, bound_index));
+      log_debug(redefine, class, annotation)
+        ("type_parameter_bound_target: type_parameter_index=%d, bound_index=%d", type_parameter_index, bound_index);
     } break;
 
     case 0x13:
@@ -2589,8 +2560,7 @@
       // empty_target {
       // }
       //
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("empty_target"));
+      log_debug(redefine, class, annotation)("empty_target");
     } break;
 
     case 0x16:
@@ -2604,17 +2574,15 @@
       // }
       //
       if ((byte_i_ref + 1) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a formal_parameter_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a formal_parameter_target");
         return false;
       }
 
       u1 formal_parameter_index = type_annotations_typeArray->at(byte_i_ref);
       byte_i_ref += 1;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("formal_parameter_target: formal_parameter_index=%d",
-         formal_parameter_index));
+      log_debug(redefine, class, annotation)
+        ("formal_parameter_target: formal_parameter_index=%d", formal_parameter_index);
     } break;
 
     case 0x17:
@@ -2628,8 +2596,7 @@
       // }
       //
       if ((byte_i_ref + 2) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a throws_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a throws_target");
         return false;
       }
 
@@ -2637,8 +2604,7 @@
                                type_annotations_typeArray->adr_at(byte_i_ref));
       byte_i_ref += 2;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("throws_target: throws_type_index=%d", throws_type_index));
+      log_debug(redefine, class, annotation)("throws_target: throws_type_index=%d", throws_type_index);
     } break;
 
     case 0x40:
@@ -2661,8 +2627,7 @@
       //
       if ((byte_i_ref + 2) > type_annotations_typeArray->length()) {
         // not enough room for a table_length let alone the rest of a localvar_target
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a localvar_target table_length"));
+        log_debug(redefine, class, annotation)("length() is too small for a localvar_target table_length");
         return false;
       }
 
@@ -2670,16 +2635,14 @@
                           type_annotations_typeArray->adr_at(byte_i_ref));
       byte_i_ref += 2;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("localvar_target: table_length=%d", table_length));
+      log_debug(redefine, class, annotation)("localvar_target: table_length=%d", table_length);
 
       int table_struct_size = 2 + 2 + 2; // 3 u2 variables per table entry
       int table_size = table_length * table_struct_size;
 
       if ((byte_i_ref + table_size) > type_annotations_typeArray->length()) {
         // not enough room for a table
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a table array of length %d", table_length));
+        log_debug(redefine, class, annotation)("length() is too small for a table array of length %d", table_length);
         return false;
       }
 
@@ -2698,8 +2661,7 @@
       // }
       //
       if ((byte_i_ref + 2) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a catch_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a catch_target");
         return false;
       }
 
@@ -2707,8 +2669,7 @@
                                    type_annotations_typeArray->adr_at(byte_i_ref));
       byte_i_ref += 2;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("catch_target: exception_table_index=%d", exception_table_index));
+      log_debug(redefine, class, annotation)("catch_target: exception_table_index=%d", exception_table_index);
     } break;
 
     case 0x43:
@@ -2731,8 +2692,7 @@
       // }
       //
       if ((byte_i_ref + 2) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a offset_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a offset_target");
         return false;
       }
 
@@ -2740,8 +2700,7 @@
                     type_annotations_typeArray->adr_at(byte_i_ref));
       byte_i_ref += 2;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("offset_target: offset=%d", offset));
+      log_debug(redefine, class, annotation)("offset_target: offset=%d", offset);
     } break;
 
     case 0x47:
@@ -2769,8 +2728,7 @@
       // }
       //
       if ((byte_i_ref + 3) > type_annotations_typeArray->length()) {
-        RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-          ("length() is too small for a type_argument_target"));
+        log_debug(redefine, class, annotation)("length() is too small for a type_argument_target");
         return false;
       }
 
@@ -2780,14 +2738,12 @@
       u1 type_argument_index = type_annotations_typeArray->at(byte_i_ref);
       byte_i_ref += 1;
 
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("type_argument_target: offset=%d, type_argument_index=%d",
-         offset, type_argument_index));
+      log_debug(redefine, class, annotation)
+        ("type_argument_target: offset=%d, type_argument_index=%d", offset, type_argument_index);
     } break;
 
     default:
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("unknown target_type"));
+      log_debug(redefine, class, annotation)("unknown target_type");
 #ifdef ASSERT
       ShouldNotReachHere();
 #endif
@@ -2814,24 +2770,21 @@
 
   if ((byte_i_ref + 1) > type_annotations_typeArray->length()) {
     // not enough room for a path_length let alone the rest of the type_path
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-      ("length() is too small for a type_path"));
+    log_debug(redefine, class, annotation)("length() is too small for a type_path");
     return false;
   }
 
   u1 path_length = type_annotations_typeArray->at(byte_i_ref);
   byte_i_ref += 1;
 
-  RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-    ("type_path: path_length=%d", path_length));
+  log_debug(redefine, class, annotation)("type_path: path_length=%d", path_length);
 
   int calc_path_length = 0;
   for (; calc_path_length < path_length; calc_path_length++) {
     if ((byte_i_ref + 1 + 1) > type_annotations_typeArray->length()) {
       // not enough room for a path
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("length() is too small for path entry %d of %d",
-         calc_path_length, path_length));
+      log_debug(redefine, class, annotation)
+        ("length() is too small for path entry %d of %d", calc_path_length, path_length);
       return false;
     }
 
@@ -2840,14 +2793,13 @@
     u1 type_argument_index = type_annotations_typeArray->at(byte_i_ref);
     byte_i_ref += 1;
 
-    RC_TRACE_WITH_THREAD(0x02000000, THREAD,
+    log_debug(redefine, class, annotation)
       ("type_path: path[%d]: type_path_kind=%d, type_argument_index=%d",
-       calc_path_length, type_path_kind, type_argument_index));
+       calc_path_length, type_path_kind, type_argument_index);
 
     if (type_path_kind > 3 || (type_path_kind != 3 && type_argument_index != 0)) {
       // not enough room for a path
-      RC_TRACE_WITH_THREAD(0x02000000, THREAD,
-        ("inconsistent type_path values"));
+      log_debug(redefine, class, annotation)("inconsistent type_path values");
       return false;
     }
   }
@@ -2883,8 +2835,7 @@
   u2 number_of_entries = Bytes::get_Java_u2(stackmap_p);
   stackmap_p += 2;
 
-  RC_TRACE_WITH_THREAD(0x04000000, THREAD,
-    ("number_of_entries=%u", number_of_entries));
+  log_debug(redefine, class, stackmap)("number_of_entries=%u", number_of_entries);
 
   // walk through each stack_map_frame
   u2 calc_number_of_entries = 0;
@@ -3084,16 +3035,14 @@
     u2 cpool_index = Bytes::get_Java_u2(stackmap_p_ref);
     u2 new_cp_index = find_new_index(cpool_index);
     if (new_cp_index != 0) {
-      RC_TRACE_WITH_THREAD(0x04000000, THREAD,
-        ("mapped old cpool_index=%d", cpool_index));
+      log_debug(redefine, class, stackmap)("mapped old cpool_index=%d", cpool_index);
       Bytes::put_Java_u2(stackmap_p_ref, new_cp_index);
       cpool_index = new_cp_index;
     }
     stackmap_p_ref += 2;
 
-    RC_TRACE_WITH_THREAD(0x04000000, THREAD,
-      ("frame_i=%u, frame_type=%u, cpool_index=%d", frame_i,
-      frame_type, cpool_index));
+    log_debug(redefine, class, stackmap)
+      ("frame_i=%u, frame_type=%u, cpool_index=%d", frame_i, frame_type, cpool_index);
   } break;
 
   // Uninitialized_variable_info {
@@ -3106,8 +3055,7 @@
     break;
 
   default:
-    RC_TRACE_WITH_THREAD(0x04000000, THREAD,
-      ("frame_i=%u, frame_type=%u, bad tag=0x%x", frame_i, frame_type, tag));
+    log_debug(redefine, class, stackmap)("frame_i=%u, frame_type=%u, bad tag=0x%x", frame_i, frame_type, tag);
     ShouldNotReachHere();
     break;
   } // end switch (tag)
@@ -3157,29 +3105,25 @@
     jshort cur_index = fs.name_index();
     jshort new_index = find_new_index(cur_index);
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("field-name_index change: %d to %d", cur_index, new_index));
+      log_trace(redefine, class, constantpool)("field-name_index change: %d to %d", cur_index, new_index);
       fs.set_name_index(new_index);
     }
     cur_index = fs.signature_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("field-signature_index change: %d to %d", cur_index, new_index));
+      log_trace(redefine, class, constantpool)("field-signature_index change: %d to %d", cur_index, new_index);
       fs.set_signature_index(new_index);
     }
     cur_index = fs.initval_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("field-initval_index change: %d to %d", cur_index, new_index));
+      log_trace(redefine, class, constantpool)("field-initval_index change: %d to %d", cur_index, new_index);
       fs.set_initval_index(new_index);
     }
     cur_index = fs.generic_signature_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("field-generic_signature change: %d to %d", cur_index, new_index));
+      log_trace(redefine, class, constantpool)("field-generic_signature change: %d to %d", cur_index, new_index);
       fs.set_generic_signature_index(new_index);
     }
   } // end for each field
@@ -3196,22 +3140,19 @@
     }
     int new_index = find_new_index(cur_index);
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("inner_class_info change: %d to %d", cur_index, new_index));
+      log_trace(redefine, class, constantpool)("inner_class_info change: %d to %d", cur_index, new_index);
       iter.set_inner_class_info_index(new_index);
     }
     cur_index = iter.outer_class_info_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("outer_class_info change: %d to %d", cur_index, new_index));
+      log_trace(redefine, class, constantpool)("outer_class_info change: %d to %d", cur_index, new_index);
       iter.set_outer_class_info_index(new_index);
     }
     cur_index = iter.inner_name_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("inner_name change: %d to %d", cur_index, new_index));
+      log_trace(redefine, class, constantpool)("inner_name change: %d to %d", cur_index, new_index);
       iter.set_inner_name_index(new_index);
     }
   } // end for each inner class
@@ -3225,23 +3166,20 @@
 
     int new_index = find_new_index(method->name_index());
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("method-name_index change: %d to %d", method->name_index(),
-        new_index));
+      log_trace(redefine, class, constantpool)
+        ("method-name_index change: %d to %d", method->name_index(), new_index);
       method->set_name_index(new_index);
     }
     new_index = find_new_index(method->signature_index());
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("method-signature_index change: %d to %d",
-        method->signature_index(), new_index));
+      log_trace(redefine, class, constantpool)
+        ("method-signature_index change: %d to %d", method->signature_index(), new_index);
       method->set_signature_index(new_index);
     }
     new_index = find_new_index(method->generic_signature_index());
     if (new_index != 0) {
-      RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-        ("method-generic_signature_index change: %d to %d",
-        method->generic_signature_index(), new_index));
+      log_trace(redefine, class, constantpool)
+        ("method-generic_signature_index change: %d to %d", method->generic_signature_index(), new_index);
       method->set_generic_signature_index(new_index);
     }
 
@@ -3255,8 +3193,7 @@
         int cur_index = cext_table[j].class_cp_index;
         int new_index = find_new_index(cur_index);
         if (new_index != 0) {
-          RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-            ("cext-class_cp_index change: %d to %d", cur_index, new_index));
+          log_trace(redefine, class, constantpool)("cext-class_cp_index change: %d to %d", cur_index, new_index);
           cext_table[j].class_cp_index = (u2)new_index;
         }
       } // end for each checked exception table entry
@@ -3274,8 +3211,7 @@
       int cur_index = ex_table.catch_type_index(j);
       int new_index = find_new_index(cur_index);
       if (new_index != 0) {
-        RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-          ("ext-klass_index change: %d to %d", cur_index, new_index));
+        log_trace(redefine, class, constantpool)("ext-klass_index change: %d to %d", cur_index, new_index);
         ex_table.set_catch_type_index(j, new_index);
       }
     } // end for each exception table entry
@@ -3292,23 +3228,19 @@
         int cur_index = lv_table[j].name_cp_index;
         int new_index = find_new_index(cur_index);
         if (new_index != 0) {
-          RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-            ("lvt-name_cp_index change: %d to %d", cur_index, new_index));
+          log_trace(redefine, class, constantpool)("lvt-name_cp_index change: %d to %d", cur_index, new_index);
           lv_table[j].name_cp_index = (u2)new_index;
         }
         cur_index = lv_table[j].descriptor_cp_index;
         new_index = find_new_index(cur_index);
         if (new_index != 0) {
-          RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-            ("lvt-descriptor_cp_index change: %d to %d", cur_index,
-            new_index));
+          log_trace(redefine, class, constantpool)("lvt-descriptor_cp_index change: %d to %d", cur_index, new_index);
           lv_table[j].descriptor_cp_index = (u2)new_index;
         }
         cur_index = lv_table[j].signature_cp_index;
         new_index = find_new_index(cur_index);
         if (new_index != 0) {
-          RC_TRACE_WITH_THREAD(0x00080000, THREAD,
-            ("lvt-signature_cp_index change: %d to %d", cur_index, new_index));
+          log_trace(redefine, class, constantpool)("lvt-signature_cp_index change: %d to %d", cur_index, new_index);
           lv_table[j].signature_cp_index = (u2)new_index;
         }
       } // end for each local variable table entry
@@ -3332,13 +3264,6 @@
   bool trace_name_printed = false;
   InstanceKlass *the_class = InstanceKlass::cast(_the_class_oop);
 
-  // Very noisy: only enable this call if you are trying to determine
-  // that a specific class gets found by this routine.
-  // RC_TRACE macro has an embedded ResourceMark
-  // RC_TRACE_WITH_THREAD(0x00100000, THREAD,
-  //   ("adjust check: name=%s", k->external_name()));
-  // trace_name_printed = true;
-
   // If the class being redefined is java.lang.Object, we need to fix all
   // array class vtables also
   if (k->is_array_klass() && _the_class_oop == SystemDictionary::Object_klass()) {
@@ -3576,9 +3501,11 @@
       // With tracing we try not to "yack" too much. The position of
       // this trace assumes there are fewer obsolete methods than
       // EMCP methods.
-      RC_TRACE(0x00000100, ("mark %s(%s) as obsolete",
-        old_method->name()->as_C_string(),
-        old_method->signature()->as_C_string()));
+      if (log_is_enabled(Trace, redefine, class, obsolete, mark)) {
+        ResourceMark rm;
+        log_trace(redefine, class, obsolete, mark)
+          ("mark %s(%s) as obsolete", old_method->name()->as_C_string(), old_method->signature()->as_C_string());
+      }
     }
     old_method->set_is_old();
   }
@@ -3596,14 +3523,15 @@
     // With tracing we try not to "yack" too much. The position of
     // this trace assumes there are fewer obsolete methods than
     // EMCP methods.
-    RC_TRACE(0x00000100, ("mark deleted %s(%s) as obsolete",
-                          old_method->name()->as_C_string(),
-                          old_method->signature()->as_C_string()));
+    if (log_is_enabled(Trace, redefine, class, obsolete, mark)) {
+      ResourceMark rm;
+      log_trace(redefine, class, obsolete, mark)
+        ("mark deleted %s(%s) as obsolete", old_method->name()->as_C_string(), old_method->signature()->as_C_string());
+    }
   }
   assert((emcp_method_count + obsolete_count) == _old_methods->length(),
     "sanity check");
-  RC_TRACE(0x00000100, ("EMCP_cnt=%d, obsolete_cnt=%d", emcp_method_count,
-    obsolete_count));
+  log_trace(redefine, class, obsolete, mark)("EMCP_cnt=%d, obsolete_cnt=%d", emcp_method_count, obsolete_count);
   return emcp_method_count;
 }
 
@@ -3866,24 +3794,24 @@
        Klass* scratch_class_oop, TRAPS) {
 
   HandleMark hm(THREAD);   // make sure handles from this call are freed
-  RC_TIMER_START(_timer_rsc_phase1);
 
-  instanceKlassHandle scratch_class(scratch_class_oop);
+  if (log_is_enabled(Info, redefine, class, timer)) {
+    _timer_rsc_phase1.start();
+  }
 
-  oop the_class_mirror = JNIHandles::resolve_non_null(the_jclass);
-  Klass* the_class_oop = java_lang_Class::as_Klass(the_class_mirror);
-  instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop);
+  instanceKlassHandle scratch_class(THREAD, scratch_class_oop);
+  instanceKlassHandle the_class(THREAD, get_ik(the_jclass));
 
   // Remove all breakpoints in methods of this class
   JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints();
-  jvmti_breakpoints.clearall_in_class_at_safepoint(the_class_oop);
+  jvmti_breakpoints.clearall_in_class_at_safepoint(the_class());
 
   // Deoptimize all compiled code that depends on this class
   flush_dependent_code(the_class, THREAD);
 
   _old_methods = the_class->methods();
   _new_methods = scratch_class->methods();
-  _the_class_oop = the_class_oop;
+  _the_class_oop = the_class();
   compute_added_deleted_matching_methods();
   update_jmethod_ids();
 
@@ -4083,8 +4011,10 @@
   // keep track of previous versions of this class
   the_class->add_previous_version(scratch_class, emcp_method_count);
 
-  RC_TIMER_STOP(_timer_rsc_phase1);
-  RC_TIMER_START(_timer_rsc_phase2);
+  _timer_rsc_phase1.stop();
+  if (log_is_enabled(Info, redefine, class, timer)) {
+    _timer_rsc_phase2.start();
+  }
 
   // Adjust constantpool caches and vtables for all classes
   // that reference methods of the evolved class.
@@ -4104,25 +4034,20 @@
     the_class->oop_map_cache()->flush_obsolete_entries();
   }
 
-  // increment the classRedefinedCount field in the_class and in any
-  // direct and indirect subclasses of the_class
-  increment_class_counter((InstanceKlass *)the_class(), THREAD);
-
-  // RC_TRACE macro has an embedded ResourceMark
-  RC_TRACE_WITH_THREAD(0x00000001, THREAD,
-    ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)",
-    the_class->external_name(),
-    java_lang_Class::classRedefinedCount(the_class_mirror),
-    os::available_memory() >> 10));
-
   {
     ResourceMark rm(THREAD);
+    // increment the classRedefinedCount field in the_class and in any
+    // direct and indirect subclasses of the_class
+    increment_class_counter((InstanceKlass *)the_class(), THREAD);
+    log_info(redefine, class, load)
+      ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)",
+       the_class->external_name(), java_lang_Class::classRedefinedCount(the_class->java_mirror()), os::available_memory() >> 10);
     Events::log_redefinition(THREAD, "redefined class name=%s, count=%d",
                              the_class->external_name(),
-                             java_lang_Class::classRedefinedCount(the_class_mirror));
+                             java_lang_Class::classRedefinedCount(the_class->java_mirror()));
 
   }
-  RC_TIMER_STOP(_timer_rsc_phase2);
+  _timer_rsc_phase2.stop();
 } // end redefine_single_class()
 
 
@@ -4136,8 +4061,7 @@
 
   if (class_oop != _the_class_oop) {
     // _the_class_oop count is printed at end of redefine_single_class()
-    RC_TRACE_WITH_THREAD(0x00000008, THREAD,
-      ("updated count in subclass=%s to %d", ik->external_name(), new_count));
+    log_debug(redefine, class, subclass)("updated count in subclass=%s to %d", ik->external_name(), new_count);
   }
 
   for (Klass *subk = ik->subklass(); subk != NULL;
@@ -4159,11 +4083,10 @@
   ResourceMark rm(_thread);
   if (k->vtable_length() > 0 &&
       !k->vtable()->check_no_old_or_obsolete_entries()) {
-    if (RC_TRACE_ENABLED(0x00004000)) {
-      RC_TRACE_WITH_THREAD(0x00004000, _thread,
-        ("klassVtable::check_no_old_or_obsolete_entries failure"
-         " -- OLD or OBSOLETE method found -- class: %s",
-         k->signature_name()));
+    if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) {
+      log_trace(redefine, class, obsolete, metadata)
+        ("klassVtable::check_no_old_or_obsolete_entries failure -- OLD or OBSOLETE method found -- class: %s",
+         k->signature_name());
       k->vtable()->dump_vtable();
     }
     no_old_methods = false;
@@ -4176,11 +4099,10 @@
     // an itable should never contain old or obsolete methods
     if (ik->itable_length() > 0 &&
         !ik->itable()->check_no_old_or_obsolete_entries()) {
-      if (RC_TRACE_ENABLED(0x00004000)) {
-        RC_TRACE_WITH_THREAD(0x00004000, _thread,
-          ("klassItable::check_no_old_or_obsolete_entries failure"
-           " -- OLD or OBSOLETE method found -- class: %s",
-           ik->signature_name()));
+      if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) {
+        log_trace(redefine, class, obsolete, metadata)
+          ("klassItable::check_no_old_or_obsolete_entries failure -- OLD or OBSOLETE method found -- class: %s",
+           ik->signature_name());
         ik->itable()->dump_itable();
       }
       no_old_methods = false;
@@ -4190,11 +4112,10 @@
     if (ik->constants() != NULL &&
         ik->constants()->cache() != NULL &&
         !ik->constants()->cache()->check_no_old_or_obsolete_entries()) {
-      if (RC_TRACE_ENABLED(0x00004000)) {
-        RC_TRACE_WITH_THREAD(0x00004000, _thread,
-          ("cp-cache::check_no_old_or_obsolete_entries failure"
-           " -- OLD or OBSOLETE method found -- class: %s",
-           ik->signature_name()));
+      if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) {
+        log_trace(redefine, class, obsolete, metadata)
+          ("cp-cache::check_no_old_or_obsolete_entries failure -- OLD or OBSOLETE method found -- class: %s",
+           ik->signature_name());
         ik->constants()->cache()->dump_cache();
       }
       no_old_methods = false;
@@ -4203,10 +4124,10 @@
 
   // print and fail guarantee if old methods are found.
   if (!no_old_methods) {
-    if (RC_TRACE_ENABLED(0x00004000)) {
+    if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) {
       dump_methods();
     } else {
-      tty->print_cr("INFO: use the '-XX:TraceRedefineClasses=16384' option "
+      log_trace(redefine, class)("Use the '-Xlog:redefine+class*:' option "
         "to see more info about the following guarantee() failure.");
     }
     guarantee(false, "OLD and/or OBSOLETE method(s) found");
@@ -4216,54 +4137,60 @@
 
 void VM_RedefineClasses::dump_methods() {
   int j;
-  RC_TRACE(0x00004000, ("_old_methods --"));
+  log_trace(redefine, class, dump)("_old_methods --");
   for (j = 0; j < _old_methods->length(); ++j) {
+    LogStreamHandle(Trace, redefine, class, dump) log_stream;
     Method* m = _old_methods->at(j);
-    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
-    m->access_flags().print_on(tty);
-    tty->print(" --  ");
-    m->print_name(tty);
-    tty->cr();
+    log_stream.print("%4d  (%5d)  ", j, m->vtable_index());
+    m->access_flags().print_on(&log_stream);
+    log_stream.print(" --  ");
+    m->print_name(&log_stream);
+    log_stream.cr();
   }
-  RC_TRACE(0x00004000, ("_new_methods --"));
+  log_trace(redefine, class, dump)("_new_methods --");
   for (j = 0; j < _new_methods->length(); ++j) {
+    LogStreamHandle(Trace, redefine, class, dump) log_stream;
     Method* m = _new_methods->at(j);
-    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
-    m->access_flags().print_on(tty);
-    tty->print(" --  ");
-    m->print_name(tty);
-    tty->cr();
+    log_stream.print("%4d  (%5d)  ", j, m->vtable_index());
+    m->access_flags().print_on(&log_stream);
+    log_stream.print(" --  ");
+    m->print_name(&log_stream);
+    log_stream.cr();
   }
-  RC_TRACE(0x00004000, ("_matching_(old/new)_methods --"));
+  log_trace(redefine, class, dump)("_matching_methods --");
   for (j = 0; j < _matching_methods_length; ++j) {
+    LogStreamHandle(Trace, redefine, class, dump) log_stream;
     Method* m = _matching_old_methods[j];
-    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
-    m->access_flags().print_on(tty);
-    tty->print(" --  ");
-    m->print_name(tty);
-    tty->cr();
+    log_stream.print("%4d  (%5d)  ", j, m->vtable_index());
+    m->access_flags().print_on(&log_stream);
+    log_stream.print(" --  ");
+    m->print_name();
+    log_stream.cr();
+
     m = _matching_new_methods[j];
-    RC_TRACE_NO_CR(0x00004000, ("      (%5d)  ", m->vtable_index()));
-    m->access_flags().print_on(tty);
-    tty->cr();
+    log_stream.print("      (%5d)  ", m->vtable_index());
+    m->access_flags().print_on(&log_stream);
+    log_stream.cr();
   }
-  RC_TRACE(0x00004000, ("_deleted_methods --"));
+  log_trace(redefine, class, dump)("_deleted_methods --");
   for (j = 0; j < _deleted_methods_length; ++j) {
+    LogStreamHandle(Trace, redefine, class, dump) log_stream;
     Method* m = _deleted_methods[j];
-    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
-    m->access_flags().print_on(tty);
-    tty->print(" --  ");
-    m->print_name(tty);
-    tty->cr();
+    log_stream.print("%4d  (%5d)  ", j, m->vtable_index());
+    m->access_flags().print_on(&log_stream);
+    log_stream.print(" --  ");
+    m->print_name(&log_stream);
+    log_stream.cr();
   }
-  RC_TRACE(0x00004000, ("_added_methods --"));
+  log_trace(redefine, class, dump)("_added_methods --");
   for (j = 0; j < _added_methods_length; ++j) {
+    LogStreamHandle(Trace, redefine, class, dump) log_stream;
     Method* m = _added_methods[j];
-    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
-    m->access_flags().print_on(tty);
-    tty->print(" --  ");
-    m->print_name(tty);
-    tty->cr();
+    log_stream.print("%4d  (%5d)  ", j, m->vtable_index());
+    m->access_flags().print_on(&log_stream);
+    log_stream.print(" --  ");
+    m->print_name(&log_stream);
+    log_stream.cr();
   }
 }
 
diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp
index b4c0cc6..edba3dd 100644
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 #include "memory/resourceArea.hpp"
 #include "oops/objArrayKlass.hpp"
 #include "oops/objArrayOop.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/vm_operations.hpp"
 
 // Introduction:
@@ -490,6 +489,10 @@
 
   void flush_dependent_code(instanceKlassHandle k_h, TRAPS);
 
+  // lock classes to redefine since constant pool merging isn't thread safe.
+  void lock_classes();
+  void unlock_classes();
+
   static void dump_methods();
 
   // Check that there are no old or obsolete methods
diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp b/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp
deleted file mode 100644
index 43174e4..0000000
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP
-#define SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP
-
-// RedefineClasses tracing support via the TraceRedefineClasses
-// option. A bit is assigned to each group of trace messages.
-// Groups of messages are individually selectable. We have to use
-// decimal values on the command line since the command option
-// parsing logic doesn't like non-decimal numerics. The HEX values
-// are used in the actual RC_TRACE() calls for sanity. To achieve
-// the old cumulative behavior, pick the level after the one in
-// which you are interested and subtract one, e.g., 33554431 will
-// print every tracing message.
-//
-//    0x00000000 |          0 - default; no tracing messages
-//    0x00000001 |          1 - name each target class before loading, after
-//                              loading and after redefinition is completed
-//    0x00000002 |          2 - print info if parsing, linking or
-//                              verification throws an exception
-//    0x00000004 |          4 - print timer info for the VM operation
-//    0x00000008 |          8 - print subclass counter updates
-//    0x00000010 |         16 - unused
-//    0x00000020 |         32 - unused
-//    0x00000040 |         64 - unused
-//    0x00000080 |        128 - unused
-//    0x00000100 |        256 - previous class weak reference addition
-//    0x00000200 |        512 - previous class weak reference mgmt during
-//                              class unloading checks (GC)
-//    0x00000400 |       1024 - previous class weak reference mgmt during
-//                              add previous ops (GC)
-//    0x00000800 |       2048 - previous class breakpoint mgmt
-//    0x00001000 |       4096 - detect calls to obsolete methods
-//    0x00002000 |       8192 - fail a guarantee() in addition to detection
-//    0x00004000 |      16384 - detect old/obsolete methods in metadata
-//    0x00008000 |      32768 - old/new method matching/add/delete
-//    0x00010000 |      65536 - impl details: CP size info
-//    0x00020000 |     131072 - impl details: CP merge pass info
-//    0x00040000 |     262144 - impl details: CP index maps
-//    0x00080000 |     524288 - impl details: modified CP index values
-//    0x00100000 |    1048576 - impl details: vtable updates
-//    0x00200000 |    2097152 - impl details: itable updates
-//    0x00400000 |    4194304 - impl details: constant pool cache updates
-//    0x00800000 |    8388608 - impl details: methodComparator info
-//    0x01000000 |   16777216 - impl details: nmethod evolution info
-//    0x02000000 |   33554432 - impl details: annotation updates
-//    0x04000000 |   67108864 - impl details: StackMapTable updates
-//    0x08000000 |  134217728 - impl details: OopMapCache updates
-//    0x10000000 |  268435456 - unused
-//    0x20000000 |  536870912 - unused
-//    0x40000000 | 1073741824 - unused
-//    0x80000000 | 2147483648 - unused
-
-// Macro for checking if TraceRedefineClasses has a specific bit
-// enabled. Returns true if the bit specified by level is set.
-#define RC_TRACE_ENABLED(level) ((TraceRedefineClasses & level) != 0)
-
-// Macro for checking if TraceRedefineClasses has one or more bits
-// set in a range of bit values. Returns true if one or more bits
-// is set in the range from low..high inclusive. Assumes that low
-// and high are single bit values.
-//
-// ((high << 1) - 1)
-//     Yields a mask that removes bits greater than the high bit value.
-//     This algorithm doesn't work with highest bit.
-// ~(low - 1)
-//     Yields a mask that removes bits lower than the low bit value.
-#define RC_TRACE_IN_RANGE(low, high) \
-(((TraceRedefineClasses & ((high << 1) - 1)) & ~(low - 1)) != 0)
-
-// Note: The ResourceMark is to cleanup resource allocated args.
-// The "do {...} while (0)" is so we can use semi-colon at end of RC_TRACE().
-#define RC_TRACE(level, args) do { \
-  if (RC_TRACE_ENABLED(level)) { \
-    ResourceMark rm; \
-    tty->print("RedefineClasses-0x%x: ", level); \
-    tty->print_cr args; \
-  } \
-} while (0)
-
-#define RC_TRACE_NO_CR(level, args) do { \
-  if (RC_TRACE_ENABLED(level)) { \
-    ResourceMark rm; \
-    tty->print("RedefineClasses-0x%x: ", level); \
-    tty->print args; \
-  } \
-} while (0)
-
-#define RC_TRACE_WITH_THREAD(level, thread, args) do { \
-  if (RC_TRACE_ENABLED(level)) { \
-    ResourceMark rm(thread); \
-    tty->print("RedefineClasses-0x%x: ", level); \
-    tty->print_cr args; \
-  } \
-} while (0)
-
-#define RC_TRACE_MESG(args) do { \
-  ResourceMark rm; \
-  tty->print("RedefineClasses: "); \
-  tty->print_cr args; \
-} while (0)
-
-// Timer support macros. Only do timer operations if timer tracing is enabled.
-// The "do {...} while (0)" is so we can use semi-colon at end of the macro.
-#define RC_TIMER_START(t) do { \
-  if (RC_TRACE_ENABLED(0x00000004)) { \
-    t.start(); \
-  } \
-} while (0)
-#define RC_TIMER_STOP(t) do { \
-  if (RC_TRACE_ENABLED(0x00000004)) { \
-    t.stop(); \
-  } \
-} while (0)
-
-#endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP
diff --git a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
index b164c7a..fa9d513 100644
--- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
@@ -146,11 +146,7 @@
     _size_index = size_index;
     _size = initial_size;
     _entry_count = 0;
-    if (TraceJVMTIObjectTagging) {
-      _trace_threshold = initial_trace_threshold;
-    } else {
-      _trace_threshold = -1;
-    }
+    _trace_threshold = initial_trace_threshold;
     _load_factor = load_factor;
     _resize_threshold = (int)(_load_factor * _size);
     _resizing_enabled = true;
@@ -329,8 +325,7 @@
     }
 
     _entry_count++;
-    if (trace_threshold() > 0 && entry_count() >= trace_threshold()) {
-      assert(TraceJVMTIObjectTagging, "should only get here when tracing");
+    if (log_is_enabled(Debug, jvmti, objecttagging) && entry_count() >= trace_threshold()) {
       print_memory_usage();
       compute_next_trace_threshold();
     }
@@ -409,6 +404,7 @@
 
 // compute threshold for the next trace message
 void JvmtiTagHashmap::compute_next_trace_threshold() {
+  _trace_threshold = entry_count();
   if (trace_threshold() < medium_trace_threshold) {
     _trace_threshold += small_trace_threshold;
   } else {
@@ -3413,12 +3409,6 @@
     delayed_add = next;
   }
 
-  // stats
-  if (TraceJVMTIObjectTagging) {
-    int post_total = hashmap->_entry_count;
-    int pre_total = post_total + freed;
-
-    tty->print_cr("(%d->%d, %d freed, %d total moves)",
-        pre_total, post_total, freed, moved);
-  }
+  log_debug(jvmti, objecttagging)("(%d->%d, %d freed, %d total moves)",
+                                  hashmap->_entry_count + freed, hashmap->_entry_count, freed, moved);
 }
diff --git a/hotspot/src/share/vm/prims/jvmtiThreadState.cpp b/hotspot/src/share/vm/prims/jvmtiThreadState.cpp
index e98891e..1e3a6e8 100644
--- a/hotspot/src/share/vm/prims/jvmtiThreadState.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiThreadState.cpp
@@ -224,18 +224,11 @@
   RegisterMap reg_map(get_thread());
   javaVFrame *jvf = get_thread()->last_java_vframe(&reg_map);
   int n = 0;
-  // tty->print_cr("CSD: counting frames on %s ...",
-  //               JvmtiTrace::safe_get_thread_name(get_thread()));
   while (jvf != NULL) {
     Method* method = jvf->method();
-    // tty->print_cr("CSD: frame - method %s.%s - loc %d",
-    //               method->klass_name()->as_C_string(),
-    //               method->name()->as_C_string(),
-    //               jvf->bci() );
     jvf = jvf->java_sender();
     n++;
   }
-  // tty->print_cr("CSD: frame count: %d", n);
   return n;
 }
 
diff --git a/hotspot/src/share/vm/prims/jvmtiTrace.cpp b/hotspot/src/share/vm/prims/jvmtiTrace.cpp
index 01edd16..bb92c7b 100644
--- a/hotspot/src/share/vm/prims/jvmtiTrace.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiTrace.cpp
@@ -24,6 +24,8 @@
 
 #include "precompiled.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "logging/log.hpp"
+#include "logging/logConfiguration.hpp"
 #include "memory/resourceArea.hpp"
 #include "prims/jvmtiTrace.hpp"
 
@@ -80,6 +82,17 @@
   } else {
     curr = "";  // hack in fixed tracing here
   }
+
+  // Enable UL for JVMTI tracing
+  if (strlen(curr) > 0) {
+    if (!log_is_enabled(Trace, jvmti)) {
+      log_warning(arguments)("-XX:+TraceJVMTI specified, "
+         "but no log output configured for the 'jvmti' tag on Trace level. "
+         "Defaulting to -Xlog:jvmti=trace");
+      LogConfiguration::configure_stdout(LogLevel::Trace, true, LOG_TAGS(jvmti));
+    }
+  }
+
   very_end = curr + strlen(curr);
   while (curr < very_end) {
     const char *curr_end = strchr(curr, ',');
@@ -127,7 +140,7 @@
         bits |= SHOW_EVENT_SENT;
         break;
       default:
-        tty->print_cr("Invalid trace flag '%c'", *flags);
+        log_warning(jvmti)("Invalid trace flag '%c'", *flags);
         break;
       }
     }
@@ -152,7 +165,7 @@
       domain = ALL_EVENT | EVENT;
     } else if (len==2 && strncmp(curr, "ec", 2)==0) {
       _trace_event_controller = true;
-      tty->print_cr("JVMTI Tracing the event controller");
+      log_trace(jvmti)("Tracing the event controller");
     } else {
       domain = FUNC | EVENT;  // go searching
     }
@@ -161,9 +174,9 @@
     if (domain & FUNC) {
       if (domain & ALL_FUNC) {
         if (domain & EXCLUDE) {
-          tty->print("JVMTI Tracing all significant functions");
+          log_trace(jvmti)("Tracing all significant functions");
         } else {
-          tty->print_cr("JVMTI Tracing all functions");
+          log_trace(jvmti)("Tracing all functions");
         }
       }
       for (int i = 0; i <= _max_function_index; ++i) {
@@ -178,7 +191,7 @@
             if (fname != NULL) {
               size_t fnlen = strlen(fname);
               if (len==fnlen && strncmp(curr, fname, fnlen)==0) {
-                tty->print_cr("JVMTI Tracing the function: %s", fname);
+                log_trace(jvmti)("Tracing the function: %s", fname);
                 do_op = true;
               }
             }
@@ -196,7 +209,7 @@
     }
     if (domain & EVENT) {
       if (domain & ALL_EVENT) {
-        tty->print_cr("JVMTI Tracing all events");
+        log_trace(jvmti)("Tracing all events");
       }
       for (int i = 0; i <= _max_event_index; ++i) {
         bool do_op = false;
@@ -207,7 +220,7 @@
           if (ename != NULL) {
             size_t evtlen = strlen(ename);
             if (len==evtlen && strncmp(curr, ename, evtlen)==0) {
-              tty->print_cr("JVMTI Tracing the event: %s", ename);
+              log_trace(jvmti)("Tracing the event: %s", ename);
               do_op = true;
             }
           }
@@ -223,7 +236,7 @@
       }
     }
     if (!_on && (domain & (FUNC|EVENT))) {
-      tty->print_cr("JVMTI Trace domain not found");
+      log_warning(jvmti)("Trace domain not found");
     }
     curr = curr_end + 1;
   }
diff --git a/hotspot/src/share/vm/prims/methodComparator.cpp b/hotspot/src/share/vm/prims/methodComparator.cpp
index e143409..5a55757 100644
--- a/hotspot/src/share/vm/prims/methodComparator.cpp
+++ b/hotspot/src/share/vm/prims/methodComparator.cpp
@@ -25,7 +25,6 @@
 #include "precompiled.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/symbol.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/methodComparator.hpp"
 #include "runtime/handles.inline.hpp"
 #include "utilities/globalDefinitions.hpp"
@@ -39,10 +38,12 @@
   if (old_method->code_size() != new_method->code_size())
     return false;
   if (check_stack_and_locals_size(old_method, new_method) != 0) {
-    // RC_TRACE macro has an embedded ResourceMark
-    RC_TRACE(0x00800000, ("Methods %s non-comparable with diagnosis %d",
-      old_method->name()->as_C_string(),
-      check_stack_and_locals_size(old_method, new_method)));
+    if (log_is_enabled(Debug, redefine, class, methodcomparator)) {
+      ResourceMark rm;
+      log_debug(redefine, class, methodcomparator)
+        ("Methods %s non-comparable with diagnosis %d",
+         old_method->name()->as_C_string(), check_stack_and_locals_size(old_method, new_method));
+    }
     return false;
   }
 
diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp
index b4abd30..7b1782a 100644
--- a/hotspot/src/share/vm/prims/methodHandles.cpp
+++ b/hotspot/src/share/vm/prims/methodHandles.cpp
@@ -38,7 +38,6 @@
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "prims/methodHandles.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/compilationPolicy.hpp"
 #include "runtime/javaCalls.hpp"
 #include "runtime/timerTrace.hpp"
@@ -1084,17 +1083,15 @@
 
     java_lang_invoke_MemberName::set_vmtarget(mem_name, new_method);
 
-    if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
+    if (log_is_enabled(Info, redefine, class, update)) {
+      ResourceMark rm;
       if (!(*trace_name_printed)) {
-        // RC_TRACE_MESG macro has an embedded ResourceMark
-        RC_TRACE_MESG(("adjust: name=%s",
-                       old_method->method_holder()->external_name()));
+        log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
         *trace_name_printed = true;
       }
-      // RC_TRACE macro has an embedded ResourceMark
-      RC_TRACE(0x00400000, ("MemberName method update: %s(%s)",
-                            new_method->name()->as_C_string(),
-                            new_method->signature()->as_C_string()));
+      log_debug(redefine, class, update, constantpool)
+        ("MemberName method update: %s(%s)",
+         new_method->name()->as_C_string(), new_method->signature()->as_C_string());
     }
   }
 }
diff --git a/hotspot/src/share/vm/prims/stackwalk.cpp b/hotspot/src/share/vm/prims/stackwalk.cpp
index d772620..70f46f7 100644
--- a/hotspot/src/share/vm/prims/stackwalk.cpp
+++ b/hotspot/src/share/vm/prims/stackwalk.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,44 +37,44 @@
 #include "utilities/globalDefinitions.hpp"
 
 // setup and cleanup actions
-void StackWalkAnchor::setup_magic_on_entry(objArrayHandle frames_array) {
+void JavaFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
   frames_array->obj_at_put(magic_pos, _thread->threadObj());
   _anchor = address_value();
   assert(check_magic(frames_array), "invalid magic");
 }
 
-bool StackWalkAnchor::check_magic(objArrayHandle frames_array) {
+bool JavaFrameStream::check_magic(objArrayHandle frames_array) {
   oop   m1 = frames_array->obj_at(magic_pos);
   jlong m2 = _anchor;
   if (m1 == _thread->threadObj() && m2 == address_value())  return true;
   return false;
 }
 
-bool StackWalkAnchor::cleanup_magic_on_exit(objArrayHandle frames_array) {
+bool JavaFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
   bool ok = check_magic(frames_array);
   frames_array->obj_at_put(magic_pos, NULL);
   _anchor = 0L;
   return ok;
 }
 
-// Returns StackWalkAnchor for the current stack being traversed.
+// Returns JavaFrameStream for the current stack being traversed.
 //
 // Parameters:
 //  thread         Current Java thread.
 //  magic          Magic value used for each stack walking
 //  frames_array   User-supplied buffers.  The 0th element is reserved
-//                 to this StackWalkAnchor to use
+//                 to this JavaFrameStream to use
 //
-StackWalkAnchor* StackWalkAnchor::from_current(JavaThread* thread, jlong magic,
+JavaFrameStream* JavaFrameStream::from_current(JavaThread* thread, jlong magic,
                                                objArrayHandle frames_array)
 {
   assert(thread != NULL && thread->is_Java_thread(), "");
   oop m1 = frames_array->obj_at(magic_pos);
   if (m1 != thread->threadObj())      return NULL;
   if (magic == 0L)                    return NULL;
-  StackWalkAnchor* anchor = (StackWalkAnchor*) (intptr_t) magic;
-  if (!anchor->is_valid_in(thread, frames_array))   return NULL;
-  return anchor;
+  JavaFrameStream* stream = (JavaFrameStream*) (intptr_t) magic;
+  if (!stream->is_valid_in(thread, frames_array))   return NULL;
+  return stream;
 }
 
 // Unpacks one or more frames into user-supplied buffers.
@@ -84,19 +84,19 @@
 // In other words, do not leave any stale data in the vfst.
 //
 // Parameters:
-//   mode           Restrict which frames to be decoded.
-//   vfst           vFrameStream.
-//   max_nframes    Maximum number of frames to be filled.
-//   start_index    Start index to the user-supplied buffers.
-//   frames_array   Buffer to store Class or StackFrame in, starting at start_index.
-//                  frames array is a Class<?>[] array when only getting caller
-//                  reference, and a StackFrameInfo[] array (or derivative)
-//                  otherwise. It should never be null.
-//   end_index      End index to the user-supplied buffers with unpacked frames.
+//   mode             Restrict which frames to be decoded.
+//   JavaFrameStream  stream of javaVFrames
+//   max_nframes      Maximum number of frames to be filled.
+//   start_index      Start index to the user-supplied buffers.
+//   frames_array     Buffer to store Class or StackFrame in, starting at start_index.
+//                    frames array is a Class<?>[] array when only getting caller
+//                    reference, and a StackFrameInfo[] array (or derivative)
+//                    otherwise. It should never be null.
+//   end_index        End index to the user-supplied buffers with unpacked frames.
 //
 // Returns the number of frames whose information was transferred into the buffers.
 //
-int StackWalk::fill_in_frames(jlong mode, vframeStream& vfst,
+int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream,
                               int max_nframes, int start_index,
                               objArrayHandle  frames_array,
                               int& end_index, TRAPS) {
@@ -108,9 +108,9 @@
   assert(start_index + max_nframes <= frames_array->length(), "oob");
 
   int frames_decoded = 0;
-  for (; !vfst.at_end(); vfst.next()) {
-    Method* method = vfst.method();
-    int bci = vfst.bci();
+  for (; !stream.at_end(); stream.next()) {
+    Method* method = stream.method();
+    int bci = stream.bci();
 
     if (method == NULL) continue;
     if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) {
@@ -133,7 +133,7 @@
     if (live_frame_info(mode)) {
       assert (use_frames_array(mode), "Bad mode for get live frame");
       Handle stackFrame(frames_array->obj_at(index));
-      fill_live_stackframe(stackFrame, method, bci, vfst.java_frame(), CHECK_0);
+      fill_live_stackframe(stackFrame, method, bci, stream.java_frame(), CHECK_0);
     } else if (need_method_info(mode)) {
       assert (use_frames_array(mode), "Bad mode for get stack frame");
       Handle stackFrame(frames_array->obj_at(index));
@@ -294,6 +294,7 @@
                     int skip_frames, int frame_count, int start_index,
                     objArrayHandle frames_array,
                     TRAPS) {
+  ResourceMark rm(THREAD);
   JavaThread* jt = (JavaThread*)THREAD;
   if (TraceStackWalk) {
     tty->print_cr("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d",
@@ -309,41 +310,39 @@
 
   methodHandle m_doStackWalk(THREAD, Universe::do_stack_walk_method());
 
-  // Open up a traversable stream onto my stack.
-  // This stream will be made available by *reference* to the inner Java call.
-  StackWalkAnchor anchor(jt);
-  vframeStream& vfst = anchor.vframe_stream();
-
+  // Setup traversal onto my stack.
+  RegisterMap regMap(jt, true);
+  JavaFrameStream stream(jt, &regMap);
   {
-    while (!vfst.at_end()) {
-      InstanceKlass* ik = vfst.method()->method_holder();
+    while (!stream.at_end()) {
+      InstanceKlass* ik = stream.method()->method_holder();
       if (ik != stackWalker_klass &&
             ik != abstractStackWalker_klass && ik->super() != abstractStackWalker_klass)  {
         break;
       }
 
       if (TraceStackWalk) {
-        tty->print("  skip "); vfst.method()->print_short_name(); tty->print("\n");
+        tty->print("  skip "); stream.method()->print_short_name(); tty->print("\n");
       }
-      vfst.next();
+      stream.next();
     }
 
     // stack frame has been traversed individually and resume stack walk
     // from the stack frame at depth == skip_frames.
-    for (int n=0; n < skip_frames && !vfst.at_end(); vfst.next(), n++) {
+    for (int n=0; n < skip_frames && !stream.at_end(); stream.next(), n++) {
       if (TraceStackWalk) {
-        tty->print("  skip "); vfst.method()->print_short_name();
+        tty->print("  skip "); stream.method()->print_short_name();
         tty->print_cr(" frame id: " PTR_FORMAT " pc: " PTR_FORMAT,
-                      p2i(vfst.frame_id()), p2i(vfst.frame_pc()));
+                      p2i(stream.java_frame()->fr().id()),
+                      p2i(stream.java_frame()->fr().pc()));
       }
     }
   }
 
-  // The Method* pointer in the vfst has a very short shelf life.  Grab it now.
   int end_index = start_index;
   int numFrames = 0;
-  if (!vfst.at_end()) {
-    numFrames = fill_in_frames(mode, vfst, frame_count, start_index,
+  if (!stream.at_end()) {
+    numFrames = fill_in_frames(mode, stream, frame_count, start_index,
                                frames_array, end_index, CHECK_NULL);
     if (numFrames < 1) {
       THROW_MSG_(vmSymbols::java_lang_InternalError(), "stack walk: decode failed", NULL);
@@ -356,19 +355,19 @@
   // When JVM_CallStackWalk returns, it invalidates the stack stream.
   JavaValue result(T_OBJECT);
   JavaCallArguments args(stackStream);
-  args.push_long(anchor.address_value());
+  args.push_long(stream.address_value());
   args.push_int(skip_frames);
   args.push_int(frame_count);
   args.push_int(start_index);
   args.push_int(end_index);
 
   // Link the thread and vframe stream into the callee-visible object
-  anchor.setup_magic_on_entry(frames_array);
+  stream.setup_magic_on_entry(frames_array);
 
   JavaCalls::call(&result, m_doStackWalk, &args, THREAD);
 
   // Do this before anything else happens, to disable any lingering stream objects
-  bool ok = anchor.cleanup_magic_on_exit(frames_array);
+  bool ok = stream.cleanup_magic_on_exit(frames_array);
 
   // Throw pending exception if we must
   (void) (CHECK_NULL);
@@ -379,7 +378,6 @@
 
   // Return normally
   return (oop)result.get_jobject();
-
 }
 
 // Walk the next batch of stack frames
@@ -400,8 +398,8 @@
                            TRAPS)
 {
   JavaThread* jt = (JavaThread*)THREAD;
-  StackWalkAnchor* existing_anchor = StackWalkAnchor::from_current(jt, magic, frames_array);
-  if (existing_anchor == NULL) {
+  JavaFrameStream* existing_stream = JavaFrameStream::from_current(jt, magic, frames_array);
+  if (existing_stream == NULL) {
     THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L);
   }
 
@@ -410,8 +408,8 @@
   }
 
   if (TraceStackWalk) {
-    tty->print_cr("StackWalk::moreFrames frame_count %d existing_anchor " PTR_FORMAT " start %d frames %d",
-                  frame_count, p2i(existing_anchor), start_index, frames_array->length());
+    tty->print_cr("StackWalk::moreFrames frame_count %d existing_stream " PTR_FORMAT " start %d frames %d",
+                  frame_count, p2i(existing_stream), start_index, frames_array->length());
   }
   int end_index = start_index;
   if (frame_count <= 0) {
@@ -421,12 +419,11 @@
   int count = frame_count + start_index;
   assert (frames_array->length() >= count, "not enough space in buffers");
 
-  StackWalkAnchor& anchor = (*existing_anchor);
-  vframeStream& vfst = anchor.vframe_stream();
-  if (!vfst.at_end()) {
-    vfst.next();  // this was the last frame decoded in the previous batch
-    if (!vfst.at_end()) {
-      int n = fill_in_frames(mode, vfst, frame_count, start_index,
+  JavaFrameStream& stream = (*existing_stream);
+  if (!stream.at_end()) {
+    stream.next(); // advance past the last frame decoded in previous batch
+    if (!stream.at_end()) {
+      int n = fill_in_frames(mode, stream, frame_count, start_index,
                              frames_array, end_index, CHECK_0);
       if (n < 1) {
         THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: later decode failed", 0L);
diff --git a/hotspot/src/share/vm/prims/stackwalk.hpp b/hotspot/src/share/vm/prims/stackwalk.hpp
index 2eb41ae..e222e62 100644
--- a/hotspot/src/share/vm/prims/stackwalk.hpp
+++ b/hotspot/src/share/vm/prims/stackwalk.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,21 +29,31 @@
 #include "oops/oop.hpp"
 #include "runtime/vframe.hpp"
 
-class StackWalkAnchor : public StackObj {
+//
+// JavaFrameStream is used by StackWalker to iterate through Java stack frames
+// on the given JavaThread.
+//
+class JavaFrameStream : public StackObj {
 private:
   enum {
     magic_pos = 0
   };
 
   JavaThread*           _thread;
-  vframeStream          _vfst;
+  javaVFrame*           _jvf;
   jlong                 _anchor;
 public:
-  StackWalkAnchor(JavaThread* thread)
-    : _thread(thread), _vfst(thread), _anchor(0L) {}
+  JavaFrameStream(JavaThread* thread, RegisterMap* rm)
+    : _thread(thread), _anchor(0L) {
+    _jvf = _thread->last_java_vframe(rm);
+  }
 
-  vframeStream&   vframe_stream()         { return _vfst; }
-  JavaThread*     thread()                { return _thread; }
+  javaVFrame*     java_frame()        { return _jvf; }
+  void            next()              { _jvf = _jvf->java_sender(); }
+  bool            at_end()            { return _jvf == NULL; }
+
+  Method* method()                    { return _jvf->method(); }
+  int bci()                           { return _jvf->bci(); }
 
   void setup_magic_on_entry(objArrayHandle frames_array);
   bool check_magic(objArrayHandle frames_array);
@@ -57,12 +67,12 @@
     return (jlong) castable_address(this);
   }
 
-  static StackWalkAnchor* from_current(JavaThread* thread, jlong anchor, objArrayHandle frames_array);
+  static JavaFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array);
 };
 
 class StackWalk : public AllStatic {
 private:
-  static int fill_in_frames(jlong mode, vframeStream& vfst,
+  static int fill_in_frames(jlong mode, JavaFrameStream& stream,
                             int max_nframes, int start_index,
                             objArrayHandle frames_array,
                             int& end_index, TRAPS);
diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp
index 7222638..7111676 100644
--- a/hotspot/src/share/vm/prims/unsafe.cpp
+++ b/hotspot/src/share/vm/prims/unsafe.cpp
@@ -131,38 +131,137 @@
 }
 
 
-///// Data in the Java heap.
+///// Data read/writes on the Java heap and in native (off-heap) memory
 
-#define truncate_jboolean(x) ((x) & 1)
-#define truncate_jbyte(x) (x)
-#define truncate_jshort(x) (x)
-#define truncate_jchar(x) (x)
-#define truncate_jint(x) (x)
-#define truncate_jlong(x) (x)
-#define truncate_jfloat(x) (x)
-#define truncate_jdouble(x) (x)
+/**
+ * Helper class for accessing memory.
+ *
+ * Normalizes values and wraps accesses in
+ * JavaThread::doing_unsafe_access() if needed.
+ */
+class MemoryAccess : StackObj {
+  JavaThread* _thread;
+  jobject _obj;
+  jlong _offset;
 
-#define GET_FIELD(obj, offset, type_name, v) \
-  oop p = JNIHandles::resolve(obj); \
-  type_name v = *(type_name*)index_oop_from_field_offset_long(p, offset)
+  // Resolves and returns the address of the memory access
+  void* addr() {
+    return index_oop_from_field_offset_long(JNIHandles::resolve(_obj), _offset);
+  }
 
-#define SET_FIELD(obj, offset, type_name, x) \
-  oop p = JNIHandles::resolve(obj); \
-  *(type_name*)index_oop_from_field_offset_long(p, offset) = truncate_##type_name(x)
+  template <typename T>
+  T normalize(T x) {
+    return x;
+  }
 
-#define GET_FIELD_VOLATILE(obj, offset, type_name, v) \
-  oop p = JNIHandles::resolve(obj); \
-  if (support_IRIW_for_not_multiple_copy_atomic_cpu) { \
-    OrderAccess::fence(); \
-  } \
-  volatile type_name v = OrderAccess::load_acquire((volatile type_name*)index_oop_from_field_offset_long(p, offset));
+  jboolean normalize(jboolean x) {
+    return x & 1;
+  }
 
-#define SET_FIELD_VOLATILE(obj, offset, type_name, x) \
-  oop p = JNIHandles::resolve(obj); \
-  OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), truncate_##type_name(x));
+  /**
+   * Helper class to wrap memory accesses in JavaThread::doing_unsafe_access()
+   */
+  class GuardUnsafeAccess {
+    JavaThread* _thread;
+    bool _active;
+
+  public:
+    GuardUnsafeAccess(JavaThread* thread, jobject _obj) : _thread(thread) {
+      if (JNIHandles::resolve(_obj) == NULL) {
+        // native/off-heap access which may raise SIGBUS if accessing
+        // memory mapped file data in a region of the file which has
+        // been truncated and is now invalid
+        _thread->set_doing_unsafe_access(true);
+        _active = true;
+      } else {
+        _active = false;
+      }
+    }
+
+    ~GuardUnsafeAccess() {
+      if (_active) {
+        _thread->set_doing_unsafe_access(false);
+      }
+    }
+  };
+
+public:
+  MemoryAccess(JavaThread* thread, jobject obj, jlong offset)
+    : _thread(thread), _obj(obj), _offset(offset) {
+  }
+
+  template <typename T>
+  T get() {
+    GuardUnsafeAccess guard(_thread, _obj);
+
+    T* p = (T*)addr();
+
+    T x = *p;
+
+    return x;
+  }
+
+  template <typename T>
+  void put(T x) {
+    GuardUnsafeAccess guard(_thread, _obj);
+
+    T* p = (T*)addr();
+
+    *p = normalize(x);
+  }
 
 
-// Get/SetObject must be special-cased, since it works with handles.
+  template <typename T>
+  T get_volatile() {
+    GuardUnsafeAccess guard(_thread, _obj);
+
+    T* p = (T*)addr();
+
+    if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
+      OrderAccess::fence();
+    }
+
+    T x = OrderAccess::load_acquire((volatile T*)p);
+
+    return x;
+  }
+
+  template <typename T>
+  void put_volatile(T x) {
+    GuardUnsafeAccess guard(_thread, _obj);
+
+    T* p = (T*)addr();
+
+    OrderAccess::release_store_fence((volatile T*)p, normalize(x));
+  }
+
+
+#ifndef SUPPORTS_NATIVE_CX8
+  jlong get_jlong_locked() {
+    GuardUnsafeAccess guard(_thread, _obj);
+
+    MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
+
+    jlong* p = (jlong*)addr();
+
+    jlong x = Atomic::load(p);
+
+    return x;
+  }
+
+  void put_jlong_locked(jlong x) {
+    GuardUnsafeAccess guard(_thread, _obj);
+
+    MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
+
+    jlong* p = (jlong*)addr();
+
+    Atomic::store(normalize(x),  p);
+  }
+#endif
+};
+
+// Get/PutObject must be special-cased, since it works with handles.
 
 // These functions allow a null base pointer with an arbitrary address.
 // But if the base pointer is non-null, the offset should make some sense.
@@ -208,7 +307,7 @@
   return ret;
 } UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
+UNSAFE_ENTRY(void, Unsafe_PutObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop p = JNIHandles::resolve(obj);
 
@@ -236,7 +335,7 @@
   return JNIHandles::make_local(env, v);
 } UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
+UNSAFE_ENTRY(void, Unsafe_PutObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop p = JNIHandles::resolve(obj);
   void* addr = index_oop_from_field_offset_long(p, offset);
@@ -301,25 +400,17 @@
 
 UNSAFE_ENTRY(jlong, Unsafe_GetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
   if (VM_Version::supports_cx8()) {
-    GET_FIELD_VOLATILE(obj, offset, jlong, v);
-    return v;
+    return MemoryAccess(thread, obj, offset).get_volatile<jlong>();
   } else {
-    Handle p (THREAD, JNIHandles::resolve(obj));
-    jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
-    MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
-    jlong value = Atomic::load(addr);
-    return value;
+    return MemoryAccess(thread, obj, offset).get_jlong_locked();
   }
 } UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x)) {
+UNSAFE_ENTRY(void, Unsafe_PutLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x)) {
   if (VM_Version::supports_cx8()) {
-    SET_FIELD_VOLATILE(obj, offset, jlong, x);
+    MemoryAccess(thread, obj, offset).put_volatile<jlong>(x);
   } else {
-    Handle p (THREAD, JNIHandles::resolve(obj));
-    jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
-    MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
-    Atomic::store(x, addr);
+    MemoryAccess(thread, obj, offset).put_jlong_locked(x);
   }
 } UNSAFE_END
 
@@ -337,15 +428,14 @@
   return UseUnalignedAccesses;
 } UNSAFE_END
 
-#define DEFINE_GETSETOOP(java_type, Type)        \
+#define DEFINE_GETSETOOP(java_type, Type) \
  \
 UNSAFE_ENTRY(java_type, Unsafe_Get##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { \
-  GET_FIELD(obj, offset, java_type, v); \
-  return v; \
+  return MemoryAccess(thread, obj, offset).get<java_type>(); \
 } UNSAFE_END \
  \
-UNSAFE_ENTRY(void, Unsafe_Set##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \
-  SET_FIELD(obj, offset, java_type, x); \
+UNSAFE_ENTRY(void, Unsafe_Put##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \
+  MemoryAccess(thread, obj, offset).put<java_type>(x); \
 } UNSAFE_END \
  \
 // END DEFINE_GETSETOOP.
@@ -364,12 +454,11 @@
 #define DEFINE_GETSETOOP_VOLATILE(java_type, Type) \
  \
 UNSAFE_ENTRY(java_type, Unsafe_Get##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { \
-  GET_FIELD_VOLATILE(obj, offset, java_type, v); \
-  return v; \
+  return MemoryAccess(thread, obj, offset).get_volatile<java_type>(); \
 } UNSAFE_END \
  \
-UNSAFE_ENTRY(void, Unsafe_Set##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \
-  SET_FIELD_VOLATILE(obj, offset, java_type, x); \
+UNSAFE_ENTRY(void, Unsafe_Put##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \
+  MemoryAccess(thread, obj, offset).put_volatile<java_type>(x); \
 } UNSAFE_END \
  \
 // END DEFINE_GETSETOOP_VOLATILE.
@@ -400,98 +489,6 @@
   OrderAccess::fence();
 } UNSAFE_END
 
-////// Data in the C heap.
-
-// Note:  These do not throw NullPointerException for bad pointers.
-// They just crash.  Only a oop base pointer can generate a NullPointerException.
-//
-#define DEFINE_GETSETNATIVE(java_type, Type, native_type) \
- \
-UNSAFE_ENTRY(java_type, Unsafe_GetNative##Type(JNIEnv *env, jobject unsafe, jlong addr)) { \
-  void* p = addr_from_java(addr); \
-  JavaThread* t = JavaThread::current(); \
-  t->set_doing_unsafe_access(true); \
-  java_type x = *(volatile native_type*)p; \
-  t->set_doing_unsafe_access(false); \
-  return x; \
-} UNSAFE_END \
- \
-UNSAFE_ENTRY(void, Unsafe_SetNative##Type(JNIEnv *env, jobject unsafe, jlong addr, java_type x)) { \
-  JavaThread* t = JavaThread::current(); \
-  t->set_doing_unsafe_access(true); \
-  void* p = addr_from_java(addr); \
-  *(volatile native_type*)p = x; \
-  t->set_doing_unsafe_access(false); \
-} UNSAFE_END \
- \
-// END DEFINE_GETSETNATIVE.
-
-DEFINE_GETSETNATIVE(jbyte, Byte, signed char)
-DEFINE_GETSETNATIVE(jshort, Short, signed short);
-DEFINE_GETSETNATIVE(jchar, Char, unsigned short);
-DEFINE_GETSETNATIVE(jint, Int, jint);
-// no long -- handled specially
-DEFINE_GETSETNATIVE(jfloat, Float, float);
-DEFINE_GETSETNATIVE(jdouble, Double, double);
-
-#undef DEFINE_GETSETNATIVE
-
-UNSAFE_ENTRY(jlong, Unsafe_GetNativeLong(JNIEnv *env, jobject unsafe, jlong addr)) {
-  JavaThread* t = JavaThread::current();
-  // We do it this way to avoid problems with access to heap using 64
-  // bit loads, as jlong in heap could be not 64-bit aligned, and on
-  // some CPUs (SPARC) it leads to SIGBUS.
-  t->set_doing_unsafe_access(true);
-  void* p = addr_from_java(addr);
-  jlong x;
-
-  if (is_ptr_aligned(p, sizeof(jlong)) == 0) {
-    // jlong is aligned, do a volatile access
-    x = *(volatile jlong*)p;
-  } else {
-    jlong_accessor acc;
-    acc.words[0] = ((volatile jint*)p)[0];
-    acc.words[1] = ((volatile jint*)p)[1];
-    x = acc.long_value;
-  }
-
-  t->set_doing_unsafe_access(false);
-
-  return x;
-} UNSAFE_END
-
-UNSAFE_ENTRY(void, Unsafe_SetNativeLong(JNIEnv *env, jobject unsafe, jlong addr, jlong x)) {
-  JavaThread* t = JavaThread::current();
-  // see comment for Unsafe_GetNativeLong
-  t->set_doing_unsafe_access(true);
-  void* p = addr_from_java(addr);
-
-  if (is_ptr_aligned(p, sizeof(jlong))) {
-    // jlong is aligned, do a volatile access
-    *(volatile jlong*)p = x;
-  } else {
-    jlong_accessor acc;
-    acc.long_value = x;
-    ((volatile jint*)p)[0] = acc.words[0];
-    ((volatile jint*)p)[1] = acc.words[1];
-  }
-
-  t->set_doing_unsafe_access(false);
-} UNSAFE_END
-
-
-UNSAFE_LEAF(jlong, Unsafe_GetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr)) {
-  void* p = addr_from_java(addr);
-
-  return addr_to_java(*(void**)p);
-} UNSAFE_END
-
-UNSAFE_LEAF(void, Unsafe_SetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr, jlong x)) {
-  void* p = addr_from_java(addr);
-  *(void**)p = addr_from_java(x);
-} UNSAFE_END
-
-
 ////// Allocation requests
 
 UNSAFE_ENTRY(jobject, Unsafe_AllocateInstance(JNIEnv *env, jobject unsafe, jclass cls)) {
@@ -943,7 +940,7 @@
   // this point.   The mirror and any instances of this class have to keep
   // it alive afterwards.
   if (anon_klass() != NULL) {
-    anon_klass->class_loader_data()->set_keep_alive(false);
+    anon_klass->class_loader_data()->dec_keep_alive();
   }
 
   // let caller initialize it as needed...
@@ -980,8 +977,8 @@
 } UNSAFE_END
 
 UNSAFE_ENTRY(jlong, Unsafe_CompareAndExchangeLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) {
-  Handle p (THREAD, JNIHandles::resolve(obj));
-  jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
+  Handle p(THREAD, JNIHandles::resolve(obj));
+  jlong* addr = (jlong*)index_oop_from_field_offset_long(p(), offset);
 
 #ifdef SUPPORTS_NATIVE_CX8
   return (jlong)(Atomic::cmpxchg(x, addr, e));
@@ -1017,7 +1014,7 @@
 
 UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) {
   oop p = JNIHandles::resolve(obj);
-  jint* addr = (jint *) index_oop_from_field_offset_long(p, offset);
+  jint* addr = (jint *)index_oop_from_field_offset_long(p, offset);
 
   return (jint)(Atomic::cmpxchg(x, addr, e)) == e;
 } UNSAFE_END
@@ -1143,20 +1140,16 @@
 
 #define DECLARE_GETPUTOOP(Type, Desc) \
     {CC "get" #Type,      CC "(" OBJ "J)" #Desc,       FN_PTR(Unsafe_Get##Type)}, \
-    {CC "put" #Type,      CC "(" OBJ "J" #Desc ")V",   FN_PTR(Unsafe_Set##Type)}, \
+    {CC "put" #Type,      CC "(" OBJ "J" #Desc ")V",   FN_PTR(Unsafe_Put##Type)}, \
     {CC "get" #Type "Volatile",      CC "(" OBJ "J)" #Desc,       FN_PTR(Unsafe_Get##Type##Volatile)}, \
-    {CC "put" #Type "Volatile",      CC "(" OBJ "J" #Desc ")V",   FN_PTR(Unsafe_Set##Type##Volatile)}
+    {CC "put" #Type "Volatile",      CC "(" OBJ "J" #Desc ")V",   FN_PTR(Unsafe_Put##Type##Volatile)}
 
 
-#define DECLARE_GETPUTNATIVE(Byte, B) \
-    {CC "get" #Byte,         CC "(" ADR ")" #B,       FN_PTR(Unsafe_GetNative##Byte)}, \
-    {CC "put" #Byte,         CC "(" ADR#B ")V",       FN_PTR(Unsafe_SetNative##Byte)}
-
 static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = {
     {CC "getObject",        CC "(" OBJ "J)" OBJ "",   FN_PTR(Unsafe_GetObject)},
-    {CC "putObject",        CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_SetObject)},
+    {CC "putObject",        CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_PutObject)},
     {CC "getObjectVolatile",CC "(" OBJ "J)" OBJ "",   FN_PTR(Unsafe_GetObjectVolatile)},
-    {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_SetObjectVolatile)},
+    {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_PutObjectVolatile)},
 
     {CC "getUncompressedObject", CC "(" ADR ")" OBJ,  FN_PTR(Unsafe_GetUncompressedObject)},
     {CC "getJavaMirror",         CC "(" ADR ")" CLS,  FN_PTR(Unsafe_GetJavaMirror)},
@@ -1171,17 +1164,6 @@
     DECLARE_GETPUTOOP(Float, F),
     DECLARE_GETPUTOOP(Double, D),
 
-    DECLARE_GETPUTNATIVE(Byte, B),
-    DECLARE_GETPUTNATIVE(Short, S),
-    DECLARE_GETPUTNATIVE(Char, C),
-    DECLARE_GETPUTNATIVE(Int, I),
-    DECLARE_GETPUTNATIVE(Long, J),
-    DECLARE_GETPUTNATIVE(Float, F),
-    DECLARE_GETPUTNATIVE(Double, D),
-
-    {CC "getAddress",         CC "(" ADR ")" ADR,        FN_PTR(Unsafe_GetNativeAddress)},
-    {CC "putAddress",         CC "(" ADR "" ADR ")V",    FN_PTR(Unsafe_SetNativeAddress)},
-
     {CC "allocateMemory0",    CC "(J)" ADR,              FN_PTR(Unsafe_AllocateMemory0)},
     {CC "reallocateMemory0",  CC "(" ADR "J)" ADR,       FN_PTR(Unsafe_ReallocateMemory0)},
     {CC "freeMemory0",        CC "(" ADR ")V",           FN_PTR(Unsafe_FreeMemory0)},
@@ -1239,7 +1221,6 @@
 #undef DAC_Args
 
 #undef DECLARE_GETPUTOOP
-#undef DECLARE_GETPUTNATIVE
 
 
 // This function is exported, used by NativeLookup.
diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp
index 88a7323..dc354b4 100644
--- a/hotspot/src/share/vm/prims/whitebox.cpp
+++ b/hotspot/src/share/vm/prims/whitebox.cpp
@@ -38,6 +38,7 @@
 #include "memory/iterator.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.hpp"
+#include "memory/oopFactory.hpp"
 #include "oops/constantPool.hpp"
 #include "oops/oop.inline.hpp"
 #include "prims/wbtestmethods/parserTests.hpp"
@@ -374,6 +375,68 @@
   Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
   return JNIHandles::make_local(env, h());
 WB_END
+
+class OldRegionsLivenessClosure: public HeapRegionClosure {
+
+ private:
+  const int _liveness;
+  size_t _total_count;
+  size_t _total_memory;
+  size_t _total_memory_to_free;
+
+ public:
+  OldRegionsLivenessClosure(int liveness) :
+    _liveness(liveness),
+    _total_count(0),
+    _total_memory(0),
+    _total_memory_to_free(0) { }
+
+    size_t total_count() { return _total_count; }
+    size_t total_memory() { return _total_memory; }
+    size_t total_memory_to_free() { return _total_memory_to_free; }
+
+  bool doHeapRegion(HeapRegion* r) {
+    if (r->is_old()) {
+      size_t prev_live = r->marked_bytes();
+      size_t live = r->live_bytes();
+      size_t size = r->used();
+      size_t reg_size = HeapRegion::GrainBytes;
+      if (size > 0 && ((int)(live * 100 / size) < _liveness)) {
+        _total_memory += size;
+        ++_total_count;
+        if (size == reg_size) {
+        // we don't include non-full regions since they are unlikely included in mixed gc
+        // for testing purposes it's enough to have lowest estimation of total memory that is expected to be freed
+          _total_memory_to_free += size - prev_live;
+        }
+      }
+    }
+    return false;
+  }
+};
+
+
+WB_ENTRY(jlongArray, WB_G1GetMixedGCInfo(JNIEnv* env, jobject o, jint liveness))
+  if (!UseG1GC) {
+    THROW_MSG_NULL(vmSymbols::java_lang_RuntimeException(), "WB_G1GetMixedGCInfo: G1 is not enabled");
+  }
+  if (liveness < 0) {
+    THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "liveness value should be non-negative");
+  }
+
+  G1CollectedHeap* g1h = G1CollectedHeap::heap();
+  OldRegionsLivenessClosure rli(liveness);
+  g1h->heap_region_iterate(&rli);
+
+  typeArrayOop result = oopFactory::new_longArray(3, CHECK_NULL);
+  result->long_at_put(0, rli.total_count());
+  result->long_at_put(1, rli.total_memory());
+  result->long_at_put(2, rli.total_memory_to_free());
+  return (jlongArray) JNIHandles::make_local(env, result);
+WB_END
+
+
+
 #endif // INCLUDE_ALL_GCS
 
 #if INCLUDE_NMT
@@ -483,9 +546,9 @@
             RegisterMap* reg_map = fst.register_map();
             Deoptimization::deoptimize(t, *f, reg_map);
             if (_make_not_entrant) {
-                nmethod* nm = CodeCache::find_nmethod(f->pc());
-                assert(nm != NULL, "sanity check");
-                nm->make_not_entrant();
+                CompiledMethod* cm = CodeCache::find_compiled(f->pc());
+                assert(cm != NULL, "sanity check");
+                cm->make_not_entrant();
             }
             ++_result;
           }
@@ -533,7 +596,7 @@
   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
   MutexLockerEx mu(Compile_lock);
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
-  nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
+  CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
   if (code == NULL) {
     return JNI_FALSE;
   }
@@ -589,7 +652,7 @@
   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   CHECK_JNI_EXCEPTION_(env, CompLevel_none);
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
-  nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
+  CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
   return (code != NULL ? code->comp_level() : CompLevel_none);
 WB_END
 
@@ -608,7 +671,7 @@
   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   CHECK_JNI_EXCEPTION_(env, InvocationEntryBci);
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
-  nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false);
+  CompiledMethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false);
   return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci);
 WB_END
 
@@ -639,17 +702,27 @@
   return result;
 WB_END
 
-WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
-  // Screen for unavailable/bad comp level
-  if (CompileBroker::compiler(comp_level) == NULL) {
+bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* THREAD) {
+  // Screen for unavailable/bad comp level or null method
+  if (method == NULL || comp_level > TieredStopAtLevel ||
+      CompileBroker::compiler(comp_level) == NULL) {
     return false;
   }
-  jmethodID jmid = reflected_method_to_jmid(thread, env, method);
-  CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
-  methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
-  nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
+  methodHandle mh(THREAD, method);
+  nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), CompileTask::Reason_Whitebox, THREAD);
   MutexLockerEx mu(Compile_lock);
   return (mh->queued_for_compilation() || nm != NULL);
+}
+
+WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
+  jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+  CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
+  return WhiteBox::compile_method(Method::checked_resolve_jmethod_id(jmid), comp_level, bci, THREAD);
+WB_END
+
+WB_ENTRY(jboolean, WB_EnqueueInitializerForCompilation(JNIEnv* env, jobject o, jclass klass, jint comp_level))
+  instanceKlassHandle ikh(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
+  return WhiteBox::compile_method(ikh->class_initializer(), comp_level, InvocationEntryBci, THREAD);
 WB_END
 
 WB_ENTRY(jboolean, WB_ShouldPrintAssembly(JNIEnv* env, jobject o, jobject method, jint comp_level))
@@ -1083,7 +1156,7 @@
   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   CHECK_JNI_EXCEPTION_(env, NULL);
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
-  nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
+  CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
   jobjectArray result = NULL;
   if (code == NULL) {
     return result;
@@ -1482,7 +1555,7 @@
   if (res == NULL) {
     tty->print_cr("Invalid layout of %s at %s", ik->external_name(),
         name_symbol->as_C_string());
-    vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:classload=info to see the origin of the problem class");
+    vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class");
   }
 
   //fetch the field at the offset we've found
@@ -1601,6 +1674,7 @@
                                                       (void*)&WB_G1AuxiliaryMemoryUsage  },
   {CC"psVirtualSpaceAlignment",CC"()J",               (void*)&WB_PSVirtualSpaceAlignment},
   {CC"psHeapGenerationAlignment",CC"()J",             (void*)&WB_PSHeapGenerationAlignment},
+  {CC"g1GetMixedGCInfo",   CC"(I)[J",                 (void*)&WB_G1GetMixedGCInfo },
 #endif // INCLUDE_ALL_GCS
 #if INCLUDE_NMT
   {CC"NMTMalloc",           CC"(J)J",                 (void*)&WB_NMTMalloc          },
@@ -1640,6 +1714,8 @@
       CC"(Ljava/lang/reflect/Executable;Z)Z",         (void*)&WB_TestSetForceInlineMethod},
   {CC"enqueueMethodForCompilation0",
       CC"(Ljava/lang/reflect/Executable;II)Z",        (void*)&WB_EnqueueMethodForCompilation},
+  {CC"enqueueInitializerForCompilation0",
+      CC"(Ljava/lang/Class;I)Z",                      (void*)&WB_EnqueueInitializerForCompilation},
   {CC"clearMethodState0",
       CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_ClearMethodState},
   {CC"lockCompilation",    CC"()V",                   (void*)&WB_LockCompilation},
diff --git a/hotspot/src/share/vm/prims/whitebox.hpp b/hotspot/src/share/vm/prims/whitebox.hpp
index 3ebada8..6398b4c 100644
--- a/hotspot/src/share/vm/prims/whitebox.hpp
+++ b/hotspot/src/share/vm/prims/whitebox.hpp
@@ -77,6 +77,7 @@
   static void register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread,
     JNINativeMethod* method_array, int method_count);
   static void register_extended(JNIEnv* env, jclass wbclass, JavaThread* thread);
+  static bool compile_method(Method* method, int comp_level, int bci, Thread* THREAD);
 };
 
 
diff --git a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp
index ad739cf..f8f6a45 100644
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp
@@ -191,8 +191,8 @@
       max_method = method;
     } else {
       // If a method has been stale for some time, remove it from the queue.
-      // Blocking tasks don't become stale
-      if (!task->is_blocking() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
+      // Blocking tasks and tasks submitted from whitebox API don't become stale
+      if (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
         if (PrintTieredEvents) {
           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
         }
@@ -491,12 +491,12 @@
 void AdvancedThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) {
   int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
   update_rate(os::javaTimeMillis(), mh());
-  CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread);
+  CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread);
 }
 
 // Handle the invocation event.
 void AdvancedThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh,
-                                                      CompLevel level, nmethod* nm, JavaThread* thread) {
+                                                      CompLevel level, CompiledMethod* nm, JavaThread* thread) {
   if (should_create_mdo(mh(), level)) {
     create_mdo(mh, thread);
   }
@@ -511,7 +511,7 @@
 // Handle the back branch event. Notice that we can compile the method
 // with a regular entry from here.
 void AdvancedThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh,
-                                                       int bci, CompLevel level, nmethod* nm, JavaThread* thread) {
+                                                       int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) {
   if (should_create_mdo(mh(), level)) {
     create_mdo(mh, thread);
   }
diff --git a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp
index 2ae2ce9..0e8494f 100644
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -216,9 +216,9 @@
   virtual void submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread);
   // event() from SimpleThresholdPolicy would call these.
   virtual void method_invocation_event(const methodHandle& method, const methodHandle& inlinee,
-                                       CompLevel level, nmethod* nm, JavaThread* thread);
+                                       CompLevel level, CompiledMethod* nm, JavaThread* thread);
   virtual void method_back_branch_event(const methodHandle& method, const methodHandle& inlinee,
-                                        int bci, CompLevel level, nmethod* nm, JavaThread* thread);
+                                        int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread);
 public:
   AdvancedThresholdPolicy() : _start_time(0) { }
   // Select task is called by CompileBroker. We should return a task or NULL.
diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp
index 8fb0519b..9395a5c 100644
--- a/hotspot/src/share/vm/runtime/arguments.cpp
+++ b/hotspot/src/share/vm/runtime/arguments.cpp
@@ -42,6 +42,7 @@
 #include "runtime/arguments.hpp"
 #include "runtime/arguments_ext.hpp"
 #include "runtime/commandLineFlagConstraintList.hpp"
+#include "runtime/commandLineFlagWriteableList.hpp"
 #include "runtime/commandLineFlagRangeList.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
@@ -410,23 +411,25 @@
 static AliasedLoggingFlag const aliased_logging_flags[] = {
   { "PrintCompressedOopsMode",   LogLevel::Info,  true,  LOG_TAGS(gc, heap, coops) },
   { "TraceBiasedLocking",        LogLevel::Info,  true,  LOG_TAGS(biasedlocking) },
-  { "TraceClassLoading",         LogLevel::Info,  true,  LOG_TAGS(classload) },
-  { "TraceClassLoadingPreorder", LogLevel::Debug, true,  LOG_TAGS(classload, preorder) },
-  { "TraceClassPaths",           LogLevel::Info,  true,  LOG_TAGS(classpath) },
-  { "TraceClassResolution",      LogLevel::Debug, true,  LOG_TAGS(classresolve) },
-  { "TraceClassUnloading",       LogLevel::Info,  true,  LOG_TAGS(classunload) },
+  { "TraceClassLoading",         LogLevel::Info,  true,  LOG_TAGS(class, load) },
+  { "TraceClassLoadingPreorder", LogLevel::Debug, true,  LOG_TAGS(class, preorder) },
+  { "TraceClassPaths",           LogLevel::Info,  true,  LOG_TAGS(class, path) },
+  { "TraceClassResolution",      LogLevel::Debug, true,  LOG_TAGS(class, resolve) },
+  { "TraceClassUnloading",       LogLevel::Info,  true,  LOG_TAGS(class, unload) },
   { "TraceExceptions",           LogLevel::Info,  true,  LOG_TAGS(exceptions) },
-  { "TraceLoaderConstraints",    LogLevel::Info,  true,  LOG_TAGS(classload, constraints) },
+  { "TraceLoaderConstraints",    LogLevel::Info,  true,  LOG_TAGS(class, loader, constraints) },
   { "TraceMonitorInflation",     LogLevel::Debug, true,  LOG_TAGS(monitorinflation) },
-  { "TraceSafepointCleanupTime", LogLevel::Info,  true,  LOG_TAGS(safepointcleanup) },
+  { "TraceSafepointCleanupTime", LogLevel::Info,  true,  LOG_TAGS(safepoint, cleanup) },
+  { "TraceJVMTIObjectTagging",   LogLevel::Debug, true,  LOG_TAGS(jvmti, objecttagging) },
+  { "TraceRedefineClasses",      LogLevel::Info,  false, LOG_TAGS(redefine, class) },
   { NULL,                        LogLevel::Off,   false, LOG_TAGS(_NO_TAG) }
 };
 
 #ifndef PRODUCT
 // These options are removed in jdk9. Remove this code for jdk10.
 static AliasedFlag const removed_develop_logging_flags[] = {
-  { "TraceClassInitialization",   "-Xlog:classinit" },
-  { "TraceClassLoaderData",       "-Xlog:classloaderdata" },
+  { "TraceClassInitialization",   "-Xlog:class+init" },
+  { "TraceClassLoaderData",       "-Xlog:class+loader+data" },
   { "TraceDefaultMethods",        "-Xlog:defaultmethods=debug" },
   { "TraceItables",               "-Xlog:itables=debug" },
   { "TraceMonitorMismatch",       "-Xlog:monitormismatch=info" },
@@ -578,8 +581,8 @@
 }
 #endif
 
-// Parses a memory size specification string.
-static bool atomull(const char *s, julong* result) {
+// Parses a size specification string.
+bool Arguments::atojulong(const char *s, julong* result) {
   julong n = 0;
   int args_read = 0;
   bool is_hex = false;
@@ -685,7 +688,7 @@
     return false;
   }
 
-  // Check the sign first since atomull() parses only unsigned values.
+  // Check the sign first since atojulong() parses only unsigned values.
   if (*value == '-') {
     if (!result->is_intx() && !result->is_int()) {
       return false;
@@ -693,7 +696,7 @@
     value++;
     is_neg = true;
   }
-  if (!atomull(value, &v)) {
+  if (!Arguments::atojulong(value, &v)) {
     return false;
   }
   if (result->is_int()) {
@@ -799,11 +802,13 @@
   int max_tags = sizeof(tagSet)/sizeof(tagSet[0]);
   for (int i = 0; i < max_tags && tagSet[i] != LogTag::__NO_TAG; i++) {
     if (i > 0) {
-      strncat(tagset_buffer, ",", max_tagset_len - strlen(tagset_buffer));
+      strncat(tagset_buffer, "+", max_tagset_len - strlen(tagset_buffer));
     }
     strncat(tagset_buffer, LogTag::name(tagSet[i]), max_tagset_len - strlen(tagset_buffer));
   }
-
+  if (!alf.exactMatch) {
+      strncat(tagset_buffer, "*", max_tagset_len - strlen(tagset_buffer));
+  }
   log_warning(arguments)("-XX:%s%s is deprecated. Will use -Xlog:%s=%s instead.",
                          (on) ? "+" : "-",
                          name,
@@ -864,6 +869,11 @@
     Flag* flag;
 
     // this scanf pattern matches both strings (handled here) and numbers (handled later))
+    AliasedLoggingFlag alf = catch_logging_aliases(name, true);
+    if (alf.alias_name != NULL) {
+      LogConfiguration::configure_stdout(alf.level, alf.exactMatch, alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5);
+      return true;
+    }
     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
     if (real_name == NULL) {
       return false;
@@ -1916,6 +1926,28 @@
     FLAG_SET_DEFAULT(GCTimeRatio, 12);
   }
 
+  // Below, we might need to calculate the pause time interval based on
+  // the pause target. When we do so we are going to give G1 maximum
+  // flexibility and allow it to do pauses when it needs to. So, we'll
+  // arrange that the pause interval to be pause time target + 1 to
+  // ensure that a) the pause time target is maximized with respect to
+  // the pause interval and b) we maintain the invariant that pause
+  // time target < pause interval. If the user does not want this
+  // maximum flexibility, they will have to set the pause interval
+  // explicitly.
+
+  if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
+    // The default pause time target in G1 is 200ms
+    FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
+  }
+
+  // Then, if the interval parameter was not set, set it according to
+  // the pause time target (this will also deal with the case when the
+  // pause time target is the default value).
+  if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
+    FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
+  }
+
   log_trace(gc)("MarkStackSize: %uk  MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
   log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
 }
@@ -2420,6 +2452,20 @@
     }
     FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
   }
+  if (UseCompiler && is_interpreter_only()) {
+    if (!FLAG_IS_DEFAULT(UseCompiler)) {
+      warning("UseCompiler disabled due to -Xint.");
+    }
+    FLAG_SET_CMDLINE(bool, UseCompiler, false);
+  }
+#ifdef COMPILER2
+  if (PostLoopMultiversioning && !RangeCheckElimination) {
+    if (!FLAG_IS_DEFAULT(PostLoopMultiversioning)) {
+      warning("PostLoopMultiversioning disabled because RangeCheckElimination is disabled.");
+    }
+    FLAG_SET_CMDLINE(bool, PostLoopMultiversioning, false);
+  }
+#endif
   return status;
 }
 
@@ -2457,12 +2503,12 @@
                             uintx* uintx_arg,
                             uintx min_size) {
 
-  // Check the sign first since atomull() parses only unsigned values.
+  // Check the sign first since atojulong() parses only unsigned values.
   bool value_is_positive = !(*value == '-');
 
   if (value_is_positive) {
     julong n;
-    bool good_return = atomull(value, &n);
+    bool good_return = atojulong(value, &n);
     if (good_return) {
       bool above_minimum = n >= min_size;
       bool value_is_too_large = n > max_uintx;
@@ -2479,7 +2525,7 @@
 Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
                                                   julong* long_arg,
                                                   julong min_size) {
-  if (!atomull(s, long_arg)) return arg_unreadable;
+  if (!atojulong(s, long_arg)) return arg_unreadable;
   return check_memory_size(*long_arg, min_size);
 }
 
@@ -2602,8 +2648,8 @@
     // -verbose:[class/gc/jni]
     if (match_option(option, "-verbose", &tail)) {
       if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
-        LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classload));
-        LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classunload));
+        LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, load));
+        LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, unload));
       } else if (!strcmp(tail, ":gc")) {
         LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
       } else if (!strcmp(tail, ":jni")) {
@@ -3236,7 +3282,7 @@
 
   // PrintSharedArchiveAndExit will turn on
   //   -Xshare:on
-  //   -Xlog:classpath=info
+  //   -Xlog:class+path=info
   if (PrintSharedArchiveAndExit) {
     if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
       return JNI_EINVAL;
@@ -3244,7 +3290,7 @@
     if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) {
       return JNI_EINVAL;
     }
-    LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classpath));
+    LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
   }
 
   // Change the default value for flags  which have different default values
@@ -4036,9 +4082,10 @@
 jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
   assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent");
 
-  // Initialize ranges and constraints
+  // Initialize ranges, constraints and writeables
   CommandLineFlagRangeList::init();
   CommandLineFlagConstraintList::init();
+  CommandLineFlagWriteableList::init();
 
   // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
   const char* hotspotrc = ".hotspotrc";
@@ -4314,6 +4361,11 @@
     warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
   }
 
+  if (UseOnStackReplacement && !UseLoopCounter) {
+    warning("On-stack-replacement requires loop counters; enabling loop counters");
+    FLAG_SET_DEFAULT(UseLoopCounter, true);
+  }
+
 #ifndef PRODUCT
   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
     if (use_vm_log()) {
diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp
index 9fd8ae0..8c8399d 100644
--- a/hotspot/src/share/vm/runtime/arguments.hpp
+++ b/hotspot/src/share/vm/runtime/arguments.hpp
@@ -769,6 +769,8 @@
   static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);
 
   static void check_unsupported_dumping_properties() NOT_CDS_RETURN;
+
+  static bool atojulong(const char *s, julong* result);
 };
 
 // Disable options not supported in this release, with a warning if they
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp
index c79a48c..27d7a32 100644
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp
@@ -217,7 +217,7 @@
 #define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
 
 // Generate func argument to pass into emit_constraint_xxx functions
-#define EMIT_CONSTRAINT_CHECK(func, type)                               , func, CommandLineFlagConstraint::type
+#define EMIT_CONSTRAINT_CHECK(func, type)                         , func, CommandLineFlagConstraint::type
 
 // the "name" argument must be a string literal
 #define INITIAL_CONSTRAINTS_SIZE 72
@@ -239,7 +239,8 @@
                                         EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
                                         EMIT_CONSTRAINT_LP64_PRODUCT_FLAG,
                                         IGNORE_RANGE,
-                                        EMIT_CONSTRAINT_CHECK));
+                                        EMIT_CONSTRAINT_CHECK,
+                                        IGNORE_WRITEABLE));
 
   EMIT_CONSTRAINTS_FOR_GLOBALS_EXT
 
@@ -249,7 +250,8 @@
                                      EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
                                      EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
                                      IGNORE_RANGE,
-                                     EMIT_CONSTRAINT_CHECK));
+                                     EMIT_CONSTRAINT_CHECK,
+                                     IGNORE_WRITEABLE));
 
 
 #ifdef COMPILER1
@@ -260,7 +262,8 @@
                                    EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
                                    EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
                                    IGNORE_RANGE,
-                                   EMIT_CONSTRAINT_CHECK));
+                                   EMIT_CONSTRAINT_CHECK,
+                                   IGNORE_WRITEABLE));
 #endif // COMPILER1
 
 #ifdef COMPILER2
@@ -272,7 +275,8 @@
                                    EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
                                    EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
                                    IGNORE_RANGE,
-                                   EMIT_CONSTRAINT_CHECK));
+                                   EMIT_CONSTRAINT_CHECK,
+                                   IGNORE_WRITEABLE));
 #endif // COMPILER2
 
 #if INCLUDE_ALL_GCS
@@ -286,7 +290,8 @@
                                    EMIT_CONSTRAINT_MANAGEABLE_FLAG,
                                    EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
                                    IGNORE_RANGE,
-                                   EMIT_CONSTRAINT_CHECK));
+                                   EMIT_CONSTRAINT_CHECK,
+                                   IGNORE_WRITEABLE));
 #endif // INCLUDE_ALL_GCS
 }
 
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp
index bfadc31..f3ab445 100644
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp
@@ -90,16 +90,29 @@
 }
 
 Flag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) {
-  if (value < 0) {
+  if (value < 0 || value > 512) {
     CommandLineError::print(verbose,
-                            "Unable to determine system-specific value for AllocatePrefetchDistance. "
-                            "Please provide appropriate value, if unsure, use 0 to disable prefetching\n");
+                            "AllocatePrefetchDistance (" INTX_FORMAT ") must be "
+                            "between 0 and " INTX_FORMAT "\n",
+                            AllocatePrefetchDistance, 512);
     return Flag::VIOLATES_CONSTRAINT;
   }
 
   return Flag::SUCCESS;
 }
 
+Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) {
+  if (AllocatePrefetchStyle == 3) {
+    if (value % wordSize != 0) {
+      CommandLineError::print(verbose,
+                              "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n",
+                              value, wordSize);
+      return Flag::VIOLATES_CONSTRAINT;
+    }
+  }
+  return Flag::SUCCESS;
+}
+
 Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) {
   intx max_value = max_intx;
 #if defined(SPARC)
@@ -117,49 +130,6 @@
   return Flag::SUCCESS;
 }
 
-Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) {
-  intx max_value = 512;
-  if (value < 1 || value > max_value) {
-    CommandLineError::print(verbose,
-                            "AllocatePrefetchStepSize (" INTX_FORMAT ") "
-                            "must be between 1 and %d\n",
-                            AllocatePrefetchStepSize,
-                            max_value);
-    return Flag::VIOLATES_CONSTRAINT;
-  }
-
-  if (AllocatePrefetchDistance % AllocatePrefetchStepSize != 0) {
-    CommandLineError::print(verbose,
-                            "AllocatePrefetchDistance (" INTX_FORMAT ") "
-                            "%% AllocatePrefetchStepSize (" INTX_FORMAT ") "
-                            "= " INTX_FORMAT " "
-                            "must be 0\n",
-                            AllocatePrefetchDistance, AllocatePrefetchStepSize,
-                            AllocatePrefetchDistance % AllocatePrefetchStepSize);
-    return Flag::VIOLATES_CONSTRAINT;
-  }
-
-  /* The limit of 64 for the quotient of AllocatePrefetchDistance and AllocatePrefetchSize
-   * originates from the limit of 64 for AllocatePrefetchLines/AllocateInstancePrefetchLines.
-   * If AllocatePrefetchStyle == 2, the quotient from above is used in PhaseMacroExpand::prefetch_allocation()
-   * to determine the number of lines to prefetch. For other values of AllocatePrefetchStyle,
-   * AllocatePrefetchDistance and AllocatePrefetchSize is used. For consistency, all these
-   * quantities must have the same limit (64 in this case).
-   */
-  if (AllocatePrefetchDistance / AllocatePrefetchStepSize > 64) {
-    CommandLineError::print(verbose,
-                            "AllocatePrefetchDistance (" INTX_FORMAT ") too large or "
-                            "AllocatePrefetchStepSize (" INTX_FORMAT ") too small; "
-                            "try decreasing/increasing values so that "
-                            "AllocatePrefetchDistance / AllocatePrefetchStepSize <= 64\n",
-                            AllocatePrefetchDistance, AllocatePrefetchStepSize,
-                            AllocatePrefetchDistance % AllocatePrefetchStepSize);
-    return Flag::VIOLATES_CONSTRAINT;
-  }
-
-  return Flag::SUCCESS;
-}
-
 Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) {
   if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) {
     CommandLineError::print(verbose,
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
index 5dce241..5d14ef7 100644
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
@@ -312,20 +312,6 @@
   }
 }
 
-Flag::Error G1YoungSurvRateNumRegionsSummaryConstraintFunc(intx value, bool verbose) {
-  if (!UseG1GC) return Flag::SUCCESS;
-
-  if (value > (intx)HeapRegionBounds::target_number()) {
-    CommandLineError::print(verbose,
-                            "G1YoungSurvRateNumRegionsSummary (" INTX_FORMAT ") must be "
-                            "less than or equal to region count (" SIZE_FORMAT ")\n",
-                            value, HeapRegionBounds::target_number());
-    return Flag::VIOLATES_CONSTRAINT;
-  } else {
-    return Flag::SUCCESS;
-  }
-}
-
 Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) {
   if (!UseG1GC) return Flag::SUCCESS;
 
@@ -599,6 +585,14 @@
                                 value);
         return Flag::VIOLATES_CONSTRAINT;
       }
+
+      if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
+        CommandLineError::print(verbose,
+                                "GCPauseIntervalMillis cannot be set "
+                                "without setting MaxGCPauseMillis\n");
+        return Flag::VIOLATES_CONSTRAINT;
+      }
+
       if (value <= MaxGCPauseMillis) {
         CommandLineError::print(verbose,
                                 "GCPauseIntervalMillis (" UINTX_FORMAT ") must be "
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp
index 9470a1c..1582ad0 100644
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp
@@ -49,7 +49,6 @@
 #if INCLUDE_ALL_GCS
 Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose);
 Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose);
-Flag::Error G1YoungSurvRateNumRegionsSummaryConstraintFunc(intx value, bool verbose);
 Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose);
 Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose);
 Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose);
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp
index 89acace..ba9d8f1 100644
--- a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp
+++ b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp
@@ -305,7 +305,8 @@
                                    EMIT_RANGE_PRODUCT_RW_FLAG,
                                    EMIT_RANGE_LP64_PRODUCT_FLAG,
                                    EMIT_RANGE_CHECK,
-                                   IGNORE_CONSTRAINT) );
+                                   IGNORE_CONSTRAINT,
+                                   IGNORE_WRITEABLE));
 
   EMIT_RANGES_FOR_GLOBALS_EXT
 
@@ -315,7 +316,8 @@
                                 EMIT_RANGE_EXPERIMENTAL_FLAG,
                                 EMIT_RANGE_NOTPRODUCT_FLAG,
                                 EMIT_RANGE_CHECK,
-                                IGNORE_CONSTRAINT));
+                                IGNORE_CONSTRAINT,
+                                IGNORE_WRITEABLE));
 
 #if INCLUDE_JVMCI
   emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
@@ -326,7 +328,8 @@
                                  EMIT_RANGE_EXPERIMENTAL_FLAG,
                                  EMIT_RANGE_NOTPRODUCT_FLAG,
                                  EMIT_RANGE_CHECK,
-                                 IGNORE_CONSTRAINT));
+                                 IGNORE_CONSTRAINT,
+                                 IGNORE_WRITEABLE));
 #endif // INCLUDE_JVMCI
 
 #ifdef COMPILER1
@@ -337,7 +340,8 @@
                               EMIT_RANGE_DIAGNOSTIC_FLAG,
                               EMIT_RANGE_NOTPRODUCT_FLAG,
                               EMIT_RANGE_CHECK,
-                              IGNORE_CONSTRAINT));
+                              IGNORE_CONSTRAINT,
+                              IGNORE_WRITEABLE));
 #endif // COMPILER1
 
 #ifdef COMPILER2
@@ -349,7 +353,8 @@
                               EMIT_RANGE_EXPERIMENTAL_FLAG,
                               EMIT_RANGE_NOTPRODUCT_FLAG,
                               EMIT_RANGE_CHECK,
-                              IGNORE_CONSTRAINT));
+                              IGNORE_CONSTRAINT,
+                              IGNORE_WRITEABLE));
 #endif // COMPILER2
 
 #if INCLUDE_ALL_GCS
@@ -363,7 +368,8 @@
                               EMIT_RANGE_MANAGEABLE_FLAG,
                               EMIT_RANGE_PRODUCT_RW_FLAG,
                               EMIT_RANGE_CHECK,
-                              IGNORE_CONSTRAINT));
+                              IGNORE_CONSTRAINT,
+                              IGNORE_WRITEABLE));
 #endif // INCLUDE_ALL_GCS
 }
 
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp
index bc299d4..6531da6 100644
--- a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp
+++ b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp
@@ -66,7 +66,6 @@
   static GrowableArray<CommandLineFlagRange*>* _ranges;
 public:
   static void init();
-  static void add_globals_ext();
   static int length() { return (_ranges != NULL) ? _ranges->length() : 0; }
   static CommandLineFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; }
   static CommandLineFlagRange* find(const char* name);
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp
new file mode 100644
index 0000000..51b0117
--- /dev/null
+++ b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "runtime/commandLineFlagWriteableList.hpp"
+#include "runtime/os.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
+#include "gc/g1/g1_globals.hpp"
+#include "gc/g1/heapRegionBounds.inline.hpp"
+#include "gc/shared/plab.hpp"
+#endif // INCLUDE_ALL_GCS
+#ifdef COMPILER1
+#include "c1/c1_globals.hpp"
+#endif // COMPILER1
+#ifdef COMPILER2
+#include "opto/c2_globals.hpp"
+#endif // COMPILER2
+#if INCLUDE_JVMCI
+#include "jvmci/jvmci_globals.hpp"
+#endif
+
+bool CommandLineFlagWriteable::is_writeable(void) {
+  return _writeable;
+}
+
+void CommandLineFlagWriteable::mark_once(void) {
+  if (_type == Once) {
+    _writeable = false;
+  }
+}
+
+void CommandLineFlagWriteable::mark_startup(void) {
+  if (_type == CommandLineFlagWriteable::CommandLineOnly) {
+    _writeable = false;
+  }
+}
+
+// No control emitting
+void emit_writeable_no(...)                         { /* NOP */ }
+
+// No control emitting if type argument is NOT provided
+void emit_writeable_bool(const char* /*name*/)      { /* NOP */ }
+void emit_writeable_ccstr(const char* /*name*/)     { /* NOP */ }
+void emit_writeable_ccstrlist(const char* /*name*/) { /* NOP */ }
+void emit_writeable_int(const char* /*name*/)       { /* NOP */ }
+void emit_writeable_intx(const char* /*name*/)      { /* NOP */ }
+void emit_writeable_uint(const char* /*name*/)      { /* NOP */ }
+void emit_writeable_uintx(const char* /*name*/)     { /* NOP */ }
+void emit_writeable_uint64_t(const char* /*name*/)  { /* NOP */ }
+void emit_writeable_size_t(const char* /*name*/)    { /* NOP */ }
+void emit_writeable_double(const char* /*name*/)    { /* NOP */ }
+
+// CommandLineFlagWriteable emitting code functions if range arguments are provided
+void emit_writeable_bool(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+void emit_writeable_int(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+void emit_writeable_intx(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+void emit_writeable_uint(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+void emit_writeable_uintx(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+void emit_writeable_uint64_t(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+void emit_writeable_size_t(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+void emit_writeable_double(const char* name, CommandLineFlagWriteable::WriteableType type) {
+  CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type));
+}
+
+// Generate code to call emit_writeable_xxx function
+#define EMIT_WRITEABLE_PRODUCT_FLAG(type, name, value, doc)      ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_COMMERCIAL_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_DIAGNOSTIC_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_MANAGEABLE_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_PRODUCT_RW_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_PD_PRODUCT_FLAG(type, name, doc)          ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_DEVELOPER_FLAG(type, name, value, doc)    ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_PD_DEVELOPER_FLAG(type, name, doc)        ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_NOTPRODUCT_FLAG(type, name, value, doc)   ); emit_writeable_##type(#name
+#define EMIT_WRITEABLE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name
+
+// Generate type argument to pass into emit_writeable_xxx functions
+#define EMIT_WRITEABLE(a)                                      , CommandLineFlagWriteable::a
+
+#define INITIAL_WRITEABLES_SIZE 2
+GrowableArray<CommandLineFlagWriteable*>* CommandLineFlagWriteableList::_controls = NULL;
+
+void CommandLineFlagWriteableList::init(void) {
+
+  _controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagWriteable*>(INITIAL_WRITEABLES_SIZE, true);
+
+  emit_writeable_no(NULL RUNTIME_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
+                                   EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
+                                   EMIT_WRITEABLE_PRODUCT_FLAG,
+                                   EMIT_WRITEABLE_PD_PRODUCT_FLAG,
+                                   EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
+                                   EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
+                                   EMIT_WRITEABLE_NOTPRODUCT_FLAG,
+                                   EMIT_WRITEABLE_MANAGEABLE_FLAG,
+                                   EMIT_WRITEABLE_PRODUCT_RW_FLAG,
+                                   EMIT_WRITEABLE_LP64_PRODUCT_FLAG,
+                                   IGNORE_RANGE,
+                                   IGNORE_CONSTRAINT,
+                                   EMIT_WRITEABLE));
+
+  EMIT_WRITEABLES_FOR_GLOBALS_EXT
+
+  emit_writeable_no(NULL ARCH_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
+                                EMIT_WRITEABLE_PRODUCT_FLAG,
+                                EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
+                                EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
+                                EMIT_WRITEABLE_NOTPRODUCT_FLAG,
+                                IGNORE_RANGE,
+                                IGNORE_CONSTRAINT,
+                                EMIT_WRITEABLE));
+
+#if INCLUDE_JVMCI
+  emit_writeable_no(NULL JVMCI_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
+                                 EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
+                                 EMIT_WRITEABLE_PRODUCT_FLAG,
+                                 EMIT_WRITEABLE_PD_PRODUCT_FLAG,
+                                 EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
+                                 EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
+                                 EMIT_WRITEABLE_NOTPRODUCT_FLAG,
+                                 IGNORE_RANGE,
+                                 IGNORE_CONSTRAINT,
+                                 EMIT_WRITEABLE));
+#endif // INCLUDE_JVMCI
+
+#ifdef COMPILER1
+  emit_writeable_no(NULL C1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
+                              EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
+                              EMIT_WRITEABLE_PRODUCT_FLAG,
+                              EMIT_WRITEABLE_PD_PRODUCT_FLAG,
+                              EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
+                              EMIT_WRITEABLE_NOTPRODUCT_FLAG,
+                              IGNORE_RANGE,
+                              IGNORE_CONSTRAINT,
+                              EMIT_WRITEABLE));
+#endif // COMPILER1
+
+#ifdef COMPILER2
+  emit_writeable_no(NULL C2_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
+                              EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
+                              EMIT_WRITEABLE_PRODUCT_FLAG,
+                              EMIT_WRITEABLE_PD_PRODUCT_FLAG,
+                              EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
+                              EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
+                              EMIT_WRITEABLE_NOTPRODUCT_FLAG,
+                              IGNORE_RANGE,
+                              IGNORE_CONSTRAINT,
+                              EMIT_WRITEABLE));
+#endif // COMPILER2
+
+#if INCLUDE_ALL_GCS
+  emit_writeable_no(NULL G1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
+                              EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
+                              EMIT_WRITEABLE_PRODUCT_FLAG,
+                              EMIT_WRITEABLE_PD_PRODUCT_FLAG,
+                              EMIT_WRITEABLE_DIAGNOSTIC_FLAG,
+                              EMIT_WRITEABLE_EXPERIMENTAL_FLAG,
+                              EMIT_WRITEABLE_NOTPRODUCT_FLAG,
+                              EMIT_WRITEABLE_MANAGEABLE_FLAG,
+                              EMIT_WRITEABLE_PRODUCT_RW_FLAG,
+                              IGNORE_RANGE,
+                              IGNORE_CONSTRAINT,
+                              EMIT_WRITEABLE));
+#endif // INCLUDE_ALL_GCS
+}
+
+CommandLineFlagWriteable* CommandLineFlagWriteableList::find(const char* name) {
+  CommandLineFlagWriteable* found = NULL;
+  for (int i=0; i<length(); i++) {
+    CommandLineFlagWriteable* writeable = at(i);
+    if (strcmp(writeable->name(), name) == 0) {
+      found = writeable;
+      break;
+    }
+  }
+  return found;
+}
+
+void CommandLineFlagWriteableList::mark_startup(void) {
+  for (int i=0; i<length(); i++) {
+    CommandLineFlagWriteable* writeable = at(i);
+    writeable->mark_startup();
+  }
+}
diff --git a/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp
new file mode 100644
index 0000000..8422085
--- /dev/null
+++ b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP
+#define SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP
+
+#include "runtime/globals.hpp"
+#include "utilities/growableArray.hpp"
+
+class CommandLineFlagWriteable : public CHeapObj<mtArguments> {
+public:
+  enum WriteableType {
+    // can be set without any limits
+    Always           = 0,
+    // can only be set once, either via command lines or during runtime
+    Once             = 1,
+    // can only be set on command line (multiple times allowed)
+    CommandLineOnly  = 2
+  };
+private:
+  const char* _name;
+  WriteableType _type;
+  bool _writeable;
+  bool _startup_done;
+public:
+  // the "name" argument must be a string literal
+  CommandLineFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; }
+  ~CommandLineFlagWriteable() {}
+  const char* name() { return _name; }
+  const WriteableType type() { return _type; }
+  bool is_writeable(void);
+  void mark_once(void);
+  void mark_startup(void);
+};
+
+class CommandLineFlagWriteableList : public AllStatic {
+  static GrowableArray<CommandLineFlagWriteable*>* _controls;
+public:
+  static void init();
+  static int length() { return (_controls != NULL) ? _controls->length() : 0; }
+  static CommandLineFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; }
+  static CommandLineFlagWriteable* find(const char* name);
+  static void add(CommandLineFlagWriteable* range) { _controls->append(range); }
+  static void mark_startup(void);
+};
+
+#endif // SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP
diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.cpp b/hotspot/src/share/vm/runtime/compilationPolicy.cpp
index 3538f3d..7333d0d 100644
--- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp
@@ -107,6 +107,33 @@
          (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods
 }
 
+void CompilationPolicy::compile_if_required(methodHandle selected_method, TRAPS) {
+  if (must_be_compiled(selected_method)) {
+    // This path is unusual, mostly used by the '-Xcomp' stress test mode.
+
+    // Note: with several active threads, the must_be_compiled may be true
+    //       while can_be_compiled is false; remove assert
+    // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile");
+    if (!THREAD->can_call_java() || THREAD->is_Compiler_thread()) {
+      // don't force compilation, resolve was on behalf of compiler
+      return;
+    }
+    if (selected_method->method_holder()->is_not_initialized()) {
+      // 'is_not_initialized' means not only '!is_initialized', but also that
+      // initialization has not been started yet ('!being_initialized')
+      // Do not force compilation of methods in uninitialized classes.
+      // Note that doing this would throw an assert later,
+      // in CompileBroker::compile_method.
+      // We sometimes use the link resolver to do reflective lookups
+      // even before classes are initialized.
+      return;
+    }
+    CompileBroker::compile_method(selected_method, InvocationEntryBci,
+        CompilationPolicy::policy()->initial_compile_level(),
+        methodHandle(), 0, CompileTask::Reason_MustBeCompiled, CHECK);
+  }
+}
+
 // Returns true if m is allowed to be compiled
 bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) {
   // allow any levels for WhiteBox
@@ -379,7 +406,7 @@
 }
 
 nmethod* NonTieredCompPolicy::event(const methodHandle& method, const methodHandle& inlinee, int branch_bci,
-                                    int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
+                                    int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) {
   assert(comp_level == CompLevel_none, "This should be only called from the interpreter");
   NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci));
   if (JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) {
@@ -481,12 +508,11 @@
   const int comp_level = CompLevel_highest_tier;
   const int hot_count = m->invocation_count();
   reset_counter_for_invocation_event(m);
-  const char* comment = "count";
 
   if (is_compilation_enabled() && can_be_compiled(m, comp_level)) {
-    nmethod* nm = m->code();
+    CompiledMethod* nm = m->code();
     if (nm == NULL ) {
-      CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread);
+      CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, CompileTask::Reason_InvocationCount, thread);
     }
   }
 }
@@ -494,10 +520,9 @@
 void SimpleCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
   const int comp_level = CompLevel_highest_tier;
   const int hot_count = m->backedge_count();
-  const char* comment = "backedge_count";
 
   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
-    CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
+    CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread);
     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   }
 }
@@ -512,7 +537,6 @@
   const int comp_level = CompLevel_highest_tier;
   const int hot_count = m->invocation_count();
   reset_counter_for_invocation_event(m);
-  const char* comment = "count";
 
   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
     ResourceMark rm(thread);
@@ -542,7 +566,7 @@
       assert(top != NULL, "findTopInlinableFrame returned null");
       if (TraceCompilationPolicy) top->print();
       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
-                                    m, hot_count, comment, thread);
+                                    m, hot_count, CompileTask::Reason_InvocationCount, thread);
     }
   }
 }
@@ -550,10 +574,9 @@
 void StackWalkCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
   const int comp_level = CompLevel_highest_tier;
   const int hot_count = m->backedge_count();
-  const char* comment = "backedge_count";
 
   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
-    CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
+    CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread);
     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   }
 }
@@ -713,7 +736,7 @@
   // note: we allow ik->is_abstract()
   if (!m->method_holder()->is_initialized()) return (_msg = "method holder not initialized");
   if (m->is_native()) return (_msg = "native method");
-  nmethod* m_code = m->code();
+  CompiledMethod* m_code = m->code();
   if (m_code != NULL && m_code->code_size() > InlineSmallCode)
     return (_msg = "already compiled into a big method");
 
diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.hpp b/hotspot/src/share/vm/runtime/compilationPolicy.hpp
index ae2128ad..84d7825 100644
--- a/hotspot/src/share/vm/runtime/compilationPolicy.hpp
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,13 +43,19 @@
   static elapsedTimer       _accumulated_time;
 
   static bool               _in_vm_startup;
+
+  // m must be compiled before executing it
+  static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
+
 public:
   static  void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
   static  void completed_vm_startup();
   static  bool delay_compilation_during_startup()    { return _in_vm_startup; }
 
-  // m must be compiled before executing it
-  static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
+  // If m must_be_compiled then request a compilation from the CompileBroker.
+  // This supports the -Xcomp option.
+  static void compile_if_required(methodHandle m, TRAPS);
+
   // m is allowed to be compiled
   static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
   // m is allowed to be osr compiled
@@ -68,7 +74,7 @@
   virtual int compiler_count(CompLevel comp_level) = 0;
   // main notification entry, return a pointer to an nmethod if the OSR is required,
   // returns NULL otherwise.
-  virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0;
+  virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) = 0;
   // safepoint() is called at the end of the safepoint
   virtual void do_safepoint_work() = 0;
   // reprofile request
@@ -109,7 +115,7 @@
   virtual bool is_mature(Method* method);
   virtual void initialize();
   virtual CompileTask* select_task(CompileQueue* compile_queue);
-  virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
+  virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread);
   virtual void method_invocation_event(const methodHandle& m, JavaThread* thread) = 0;
   virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) = 0;
 };
diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp
index d380bf6..f926b88 100644
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp
@@ -168,9 +168,10 @@
   // Now get the deoptee with a valid map
   frame deoptee = stub_frame.sender(&map);
   // Set the deoptee nmethod
-  assert(thread->deopt_nmethod() == NULL, "Pending deopt!");
-  thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null());
-  bool skip_internal = thread->deopt_nmethod() != NULL && !thread->deopt_nmethod()->compiler()->is_jvmci();
+  assert(thread->deopt_compiled_method() == NULL, "Pending deopt!");
+  CompiledMethod* cm = deoptee.cb()->as_compiled_method_or_null();
+  thread->set_deopt_compiled_method(cm);
+  bool skip_internal = (cm != NULL) && !cm->is_compiled_by_jvmci();
 
   if (VerifyStack) {
     thread->validate_frame_layout();
@@ -548,7 +549,7 @@
 
   delete thread->deopt_mark();
   thread->set_deopt_mark(NULL);
-  thread->set_deopt_nmethod(NULL);
+  thread->set_deopt_compiled_method(NULL);
 
 
   if (JvmtiExport::can_pop_frame()) {
@@ -762,7 +763,7 @@
         guarantee(false, "wrong number of expression stack elements during deopt");
       }
       VerifyOopClosure verify;
-      iframe->oops_interpreted_do(&verify, NULL, &rm, false);
+      iframe->oops_interpreted_do(&verify, &rm, false);
       callee_size_of_parameters = mh->size_of_parameters();
       callee_max_locals = mh->max_locals();
       is_top_frame = false;
@@ -1316,14 +1317,14 @@
   gather_statistics(reason, Action_none, Bytecodes::_illegal);
 
   if (LogCompilation && xtty != NULL) {
-    nmethod* nm = fr.cb()->as_nmethod_or_null();
-    assert(nm != NULL, "only compiled methods can deopt");
+    CompiledMethod* cm = fr.cb()->as_compiled_method_or_null();
+    assert(cm != NULL, "only compiled methods can deopt");
 
     ttyLocker ttyl;
-    xtty->begin_head("deoptimized thread='" UINTX_FORMAT "'", (uintx)thread->osthread()->thread_id());
-    nm->log_identity(xtty);
+    xtty->begin_head("deoptimized thread='" UINTX_FORMAT "' reason='%s' pc='" INTPTR_FORMAT "'",(uintx)thread->osthread()->thread_id(), trap_reason_name(reason), p2i(fr.pc()));
+    cm->log_identity(xtty);
     xtty->end_head();
-    for (ScopeDesc* sd = nm->scope_desc_at(fr.pc()); ; sd = sd->sender()) {
+    for (ScopeDesc* sd = cm->scope_desc_at(fr.pc()); ; sd = sd->sender()) {
       xtty->begin_elem("jvms bci='%d'", sd->bci());
       xtty->method(sd->method());
       xtty->end_elem();
@@ -1504,7 +1505,7 @@
     vframe*  vf  = vframe::new_vframe(&fr, &reg_map, thread);
     compiledVFrame* cvf = compiledVFrame::cast(vf);
 
-    nmethod* nm = cvf->code();
+    CompiledMethod* nm = cvf->code();
 
     ScopeDesc*      trap_scope  = cvf->scope();
 
@@ -1523,7 +1524,7 @@
     oop speculation = thread->pending_failed_speculation();
     if (nm->is_compiled_by_jvmci()) {
       if (speculation != NULL) {
-        oop speculation_log = nm->speculation_log();
+        oop speculation_log = nm->as_nmethod()->speculation_log();
         if (speculation_log != NULL) {
           if (TraceDeoptimization || TraceUncollectedSpeculations) {
             if (HotSpotSpeculationLog::lastFailed(speculation_log) != NULL) {
@@ -1639,19 +1640,21 @@
         nm->method()->print_short_name(tty);
         tty->print(" compiler=%s compile_id=%d", nm->compiler() == NULL ? "" : nm->compiler()->name(), nm->compile_id());
 #if INCLUDE_JVMCI
-        oop installedCode = nm->jvmci_installed_code();
-        if (installedCode != NULL) {
-          oop installedCodeName = NULL;
-          if (installedCode->is_a(InstalledCode::klass())) {
-            installedCodeName = InstalledCode::name(installedCode);
+        if (nm->is_nmethod()) {
+          oop installedCode = nm->as_nmethod()->jvmci_installed_code();
+          if (installedCode != NULL) {
+            oop installedCodeName = NULL;
+            if (installedCode->is_a(InstalledCode::klass())) {
+              installedCodeName = InstalledCode::name(installedCode);
+            }
+            if (installedCodeName != NULL) {
+              tty->print(" (JVMCI: installedCodeName=%s) ", java_lang_String::as_utf8_string(installedCodeName));
+            } else {
+              tty->print(" (JVMCI: installed code has no name) ");
+            }
+          } else if (nm->is_compiled_by_jvmci()) {
+            tty->print(" (JVMCI: no installed code) ");
           }
-          if (installedCodeName != NULL) {
-            tty->print(" (JVMCI: installedCodeName=%s) ", java_lang_String::as_utf8_string(installedCodeName));
-          } else {
-            tty->print(" (JVMCI: installed code has no name) ");
-          }
-        } else if (nm->is_compiled_by_jvmci()) {
-          tty->print(" (JVMCI: no installed code) ");
         }
 #endif
         tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"),
@@ -1891,7 +1894,7 @@
       // Assume that in new recompiled code the statistic could be different,
       // for example, due to different inlining.
       if ((reason != Reason_rtm_state_change) && (trap_mdo != NULL) &&
-          UseRTMDeopt && (nm->rtm_state() != ProfileRTM)) {
+          UseRTMDeopt && (nm->as_nmethod()->rtm_state() != ProfileRTM)) {
         trap_mdo->atomic_set_rtm_state(ProfileRTM);
       }
 #endif
diff --git a/hotspot/src/share/vm/runtime/fprofiler.cpp b/hotspot/src/share/vm/runtime/fprofiler.cpp
index e5785c1..fe19244d 100644
--- a/hotspot/src/share/vm/runtime/fprofiler.cpp
+++ b/hotspot/src/share/vm/runtime/fprofiler.cpp
@@ -538,11 +538,12 @@
 
 class runtimeStubNode : public ProfilerNode {
  private:
-   const CodeBlob* _stub;
+  const RuntimeStub* _stub;
   const char* _symbol;     // The name of the nearest VM symbol when ProfileVM is on. Points to a unique string.
  public:
-   runtimeStubNode(const CodeBlob* stub, const char* name, TickPosition where) : ProfilerNode(), _stub(stub),  _symbol(name) {
+   runtimeStubNode(const CodeBlob* stub, const char* name, TickPosition where) : ProfilerNode(), _stub(NULL),  _symbol(name) {
      assert(stub->is_runtime_stub(), "wrong code blob");
+     _stub = (RuntimeStub*) stub;
      update(where);
    }
 
@@ -550,7 +551,7 @@
 
   bool runtimeStub_match(const CodeBlob* stub, const char* name) const {
     assert(stub->is_runtime_stub(), "wrong code blob");
-    return ((RuntimeStub*)_stub)->entry_point() == ((RuntimeStub*)stub)->entry_point() &&
+    return _stub->entry_point() == ((RuntimeStub*)stub)->entry_point() &&
             (_symbol == name);
   }
 
@@ -571,7 +572,7 @@
   }
 
   void print_method_on(outputStream* st) {
-    st->print("%s", ((RuntimeStub*)_stub)->name());
+    st->print("%s", _stub->name());
     print_symbol_on(st);
   }
 
@@ -588,18 +589,18 @@
  public:
    unknown_compiledNode(const CodeBlob* cb, TickPosition where) : ProfilerNode() {
      if ( cb->is_buffer_blob() )
-       _name = ((BufferBlob*)cb)->name();
+       _name = ((const BufferBlob*)cb)->name();
      else
-       _name = ((SingletonBlob*)cb)->name();
+       _name = ((const SingletonBlob*)cb)->name();
      update(where);
   }
   bool is_compiled()    const { return true; }
 
   bool unknown_compiled_match(const CodeBlob* cb) const {
      if ( cb->is_buffer_blob() )
-       return !strcmp(((BufferBlob*)cb)->name(), _name);
+       return !strcmp(((const BufferBlob*)cb)->name(), _name);
      else
-       return !strcmp(((SingletonBlob*)cb)->name(), _name);
+       return !strcmp(((const SingletonBlob*)cb)->name(), _name);
   }
 
   Method* method()         { return NULL; }
@@ -993,16 +994,15 @@
 
   CodeBlob* cb = fr.cb();
 
-// For runtime stubs, record as native rather than as compiled
-   if (cb->is_runtime_stub()) {
-        RegisterMap map(thread, false);
-        fr = fr.sender(&map);
-        cb = fr.cb();
-        localwhere = tp_native;
-  }
-  Method* method = (cb->is_nmethod()) ? ((nmethod *)cb)->method() :
-                                          (Method*)NULL;
+  // For runtime stubs, record as native rather than as compiled
+  if (cb->is_runtime_stub()) {
+    RegisterMap map(thread, false);
+    fr = fr.sender(&map);
+    cb = fr.cb();
+    localwhere = tp_native;
+ }
 
+  Method* method = cb->is_compiled() ? cb->as_compiled_method()->method() : (Method*) NULL;
   if (method == NULL) {
     if (cb->is_runtime_stub())
       runtime_stub_update(cb, name, localwhere);
diff --git a/hotspot/src/share/vm/runtime/frame.cpp b/hotspot/src/share/vm/runtime/frame.cpp
index b2a3216..82f5ead 100644
--- a/hotspot/src/share/vm/runtime/frame.cpp
+++ b/hotspot/src/share/vm/runtime/frame.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -132,11 +132,11 @@
 
 address frame::raw_pc() const {
   if (is_deoptimized_frame()) {
-    nmethod* nm = cb()->as_nmethod_or_null();
-    if (nm->is_method_handle_return(pc()))
-      return nm->deopt_mh_handler_begin() - pc_return_offset;
+    CompiledMethod* cm = cb()->as_compiled_method_or_null();
+    if (cm->is_method_handle_return(pc()))
+      return cm->deopt_mh_handler_begin() - pc_return_offset;
     else
-      return nm->deopt_handler_begin() - pc_return_offset;
+      return cm->deopt_handler_begin() - pc_return_offset;
   } else {
     return (pc() - pc_return_offset);
   }
@@ -183,8 +183,8 @@
 
 bool frame::is_compiled_frame() const {
   if (_cb != NULL &&
-      _cb->is_nmethod() &&
-      ((nmethod*)_cb)->is_java_method()) {
+      _cb->is_compiled() &&
+      ((CompiledMethod*)_cb)->is_java_method()) {
     return true;
   }
   return false;
@@ -228,8 +228,8 @@
 bool frame::should_be_deoptimized() const {
   if (_deopt_state == is_deoptimized ||
       !is_compiled_frame() ) return false;
-  assert(_cb != NULL && _cb->is_nmethod(), "must be an nmethod");
-  nmethod* nm = (nmethod *)_cb;
+  assert(_cb != NULL && _cb->is_compiled(), "must be an nmethod");
+  CompiledMethod* nm = (CompiledMethod *)_cb;
   if (TraceDependencies) {
     tty->print("checking (%s) ", nm->is_marked_for_deoptimization() ? "true" : "false");
     nm->print_value_on(tty);
@@ -246,7 +246,7 @@
 
 bool frame::can_be_deoptimized() const {
   if (!is_compiled_frame()) return false;
-  nmethod* nm = (nmethod*)_cb;
+  CompiledMethod* nm = (CompiledMethod*)_cb;
 
   if( !nm->can_be_deoptimized() )
     return false;
@@ -256,8 +256,7 @@
 
 void frame::deoptimize(JavaThread* thread) {
   // Schedule deoptimization of an nmethod activation with this frame.
-  assert(_cb != NULL && _cb->is_nmethod(), "must be");
-  nmethod* nm = (nmethod*)_cb;
+  assert(_cb != NULL && _cb->is_compiled(), "must be");
 
   // This is a fix for register window patching race
   if (NeedsDeoptSuspend && Thread::current() != thread) {
@@ -316,12 +315,13 @@
 
   // If the call site is a MethodHandle call site use the MH deopt
   // handler.
-  address deopt = nm->is_method_handle_return(pc()) ?
-    nm->deopt_mh_handler_begin() :
-    nm->deopt_handler_begin();
+  CompiledMethod* cm = (CompiledMethod*) _cb;
+  address deopt = cm->is_method_handle_return(pc()) ?
+                        cm->deopt_mh_handler_begin() :
+                        cm->deopt_handler_begin();
 
   // Save the original pc before we patch in the new one
-  nm->set_original_pc(this, pc());
+  cm->set_original_pc(this, pc());
   patch_pc(thread, deopt);
 
 #ifdef ASSERT
@@ -396,6 +396,11 @@
   *interpreter_frame_method_addr() = method;
 }
 
+void frame::interpreter_frame_set_mirror(oop mirror) {
+  assert(is_interpreted_frame(), "interpreted frame expected");
+  *interpreter_frame_mirror_addr() = mirror;
+}
+
 jint frame::interpreter_frame_bci() const {
   assert(is_interpreted_frame(), "interpreted frame expected");
   address bcp = interpreter_frame_bcp();
@@ -661,14 +666,19 @@
       }
     } else if (_cb->is_buffer_blob()) {
       st->print("v  ~BufferBlob::%s", ((BufferBlob *)_cb)->name());
-    } else if (_cb->is_nmethod()) {
-      nmethod* nm = (nmethod*)_cb;
-      Method* m = nm->method();
+    } else if (_cb->is_compiled()) {
+      CompiledMethod* cm = (CompiledMethod*)_cb;
+      Method* m = cm->method();
       if (m != NULL) {
+        if (cm->is_nmethod()) {
+          nmethod* nm = cm->as_nmethod();
+          st->print("J %d%s", nm->compile_id(), (nm->is_osr_method() ? "%" : ""));
+          if (nm->compiler() != NULL) {
+            st->print(" %s", nm->compiler()->name());
+          }
+        }
         m->name_and_sig_as_C_string(buf, buflen);
-        st->print("J %d%s %s ",
-                  nm->compile_id(), (nm->is_osr_method() ? "%" : ""),
-                  ((nm->compiler() != NULL) ? nm->compiler()->name() : ""));
+        st->print(" %s", buf);
         ModuleEntry* module = m->method_holder()->module();
         if (module->is_named()) {
           module->name()->as_C_string(buf, buflen);
@@ -676,12 +686,15 @@
           module->version()->as_C_string(buf, buflen);
           st->print("@%s", buf);
         }
-        st->print("%s (%d bytes) @ " PTR_FORMAT " [" PTR_FORMAT "+" INTPTR_FORMAT "]",
-                  buf, m->code_size(), p2i(_pc), p2i(_cb->code_begin()), _pc - _cb->code_begin());
+        st->print(" (%d bytes) @ " PTR_FORMAT " [" PTR_FORMAT "+" INTPTR_FORMAT "]",
+                  m->code_size(), p2i(_pc), p2i(_cb->code_begin()), _pc - _cb->code_begin());
 #if INCLUDE_JVMCI
-        char* jvmciName = nm->jvmci_installed_code_name(buf, buflen);
-        if (jvmciName != NULL) {
-          st->print(" (%s)", jvmciName);
+        if (cm->is_nmethod()) {
+          nmethod* nm = cm->as_nmethod();
+          char* jvmciName = nm->jvmci_installed_code_name(buf, buflen);
+          if (jvmciName != NULL) {
+            st->print(" (%s)", jvmciName);
+          }
         }
 #endif
       } else {
@@ -850,8 +863,7 @@
 }
 
 
-void frame::oops_interpreted_do(OopClosure* f, CLDClosure* cld_f,
-    const RegisterMap* map, bool query_oop_map_cache) {
+void frame::oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache) {
   assert(is_interpreted_frame(), "Not an interpreted frame");
   assert(map != NULL, "map must be set");
   Thread *thread = Thread::current();
@@ -877,21 +889,16 @@
     current->oops_do(f);
   }
 
-  // process fixed part
-  if (cld_f != NULL) {
-    // The method pointer in the frame might be the only path to the method's
-    // klass, and the klass needs to be kept alive while executing. The GCs
-    // don't trace through method pointers, so typically in similar situations
-    // the mirror or the class loader of the klass are installed as a GC root.
-    // To minimize the overhead of doing that here, we ask the GC to pass down a
-    // closure that knows how to keep klasses alive given a ClassLoaderData.
-    cld_f->do_cld(m->method_holder()->class_loader_data());
-  }
-
-  if (m->is_native() PPC32_ONLY(&& m->is_static())) {
+  if (m->is_native()) {
     f->do_oop(interpreter_frame_temp_oop_addr());
   }
 
+  // The method pointer in the frame might be the only path to the method's
+  // klass, and the klass needs to be kept alive while executing. The GCs
+  // don't trace through method pointers, so the mirror of the method's klass
+  // is installed as a GC root.
+  f->do_oop(interpreter_frame_mirror_addr());
+
   int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals();
 
   Symbol* signature = NULL;
@@ -1091,7 +1098,7 @@
 }
 
 
-void frame::oops_do_internal(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) {
+void frame::oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) {
 #ifndef PRODUCT
   // simulate GC crash here to dump java thread in error report
   if (CrashGCForDumpingJavaThread) {
@@ -1100,7 +1107,7 @@
   }
 #endif
   if (is_interpreted_frame()) {
-    oops_interpreted_do(f, cld_f, map, use_interpreter_oop_map_cache);
+    oops_interpreted_do(f, map, use_interpreter_oop_map_cache);
   } else if (is_entry_frame()) {
     oops_entry_do(f, map);
   } else if (CodeCache::contains(pc())) {
@@ -1145,7 +1152,7 @@
 #if defined(COMPILER2) || INCLUDE_JVMCI
   assert(DerivedPointerTable::is_empty(), "must be empty before verify");
 #endif
-  oops_do_internal(&VerifyOopClosure::verify_oop, NULL, NULL, (RegisterMap*)map, false);
+  oops_do_internal(&VerifyOopClosure::verify_oop, NULL, (RegisterMap*)map, false);
 }
 
 
@@ -1242,10 +1249,10 @@
     values.describe(-1, info_address, err_msg("#%d entry frame", frame_no), 2);
   } else if (is_compiled_frame()) {
     // For now just label the frame
-    nmethod* nm = cb()->as_nmethod_or_null();
+    CompiledMethod* cm = (CompiledMethod*)cb();
     values.describe(-1, info_address,
                     FormatBuffer<1024>("#%d nmethod " INTPTR_FORMAT " for method %s%s", frame_no,
-                                       p2i(nm), nm->method()->name_and_sig_as_C_string(),
+                                       p2i(cm), cm->method()->name_and_sig_as_C_string(),
                                        (_deopt_state == is_deoptimized) ?
                                        " (deoptimized)" :
                                        ((_deopt_state == unknown) ? " (state unknown)" : "")),
diff --git a/hotspot/src/share/vm/runtime/frame.hpp b/hotspot/src/share/vm/runtime/frame.hpp
index 0bb1d87..b71585a 100644
--- a/hotspot/src/share/vm/runtime/frame.hpp
+++ b/hotspot/src/share/vm/runtime/frame.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -320,6 +320,9 @@
   void interpreter_frame_set_method(Method* method);
   Method** interpreter_frame_method_addr() const;
   ConstantPoolCache** interpreter_frame_cache_addr() const;
+  oop* interpreter_frame_mirror_addr() const;
+
+  void interpreter_frame_set_mirror(oop mirror);
 
  public:
   // Entry frames
@@ -386,19 +389,19 @@
 
   // Oops-do's
   void oops_compiled_arguments_do(Symbol* signature, bool has_receiver, bool has_appendix, const RegisterMap* reg_map, OopClosure* f);
-  void oops_interpreted_do(OopClosure* f, CLDClosure* cld_f, const RegisterMap* map, bool query_oop_map_cache = true);
+  void oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache = true);
 
  private:
   void oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f);
 
   // Iteration of oops
-  void oops_do_internal(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache);
+  void oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache);
   void oops_entry_do(OopClosure* f, const RegisterMap* map);
   void oops_code_blob_do(OopClosure* f, CodeBlobClosure* cf, const RegisterMap* map);
   int adjust_offset(Method* method, int index); // helper for above fn
  public:
   // Memory management
-  void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map) { oops_do_internal(f, cld_f, cf, map, true); }
+  void oops_do(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map) { oops_do_internal(f, cf, map, true); }
   void nmethods_do(CodeBlobClosure* cf);
 
   // RedefineClasses support for finding live interpreted methods on the stack
diff --git a/hotspot/src/share/vm/runtime/globals.cpp b/hotspot/src/share/vm/runtime/globals.cpp
index ef98dd7..0674221 100644
--- a/hotspot/src/share/vm/runtime/globals.cpp
+++ b/hotspot/src/share/vm/runtime/globals.cpp
@@ -29,10 +29,12 @@
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
 #include "runtime/commandLineFlagConstraintList.hpp"
+#include "runtime/commandLineFlagWriteableList.hpp"
 #include "runtime/commandLineFlagRangeList.hpp"
 #include "runtime/os.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "trace/tracing.hpp"
+#include "utilities/defaultStream.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
 #if INCLUDE_ALL_GCS
@@ -62,7 +64,8 @@
               MATERIALIZE_PRODUCT_RW_FLAG, \
               MATERIALIZE_LP64_PRODUCT_FLAG, \
               IGNORE_RANGE, \
-              IGNORE_CONSTRAINT)
+              IGNORE_CONSTRAINT, \
+              IGNORE_WRITEABLE)
 
 RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \
                  MATERIALIZE_PD_DEVELOPER_FLAG, \
@@ -71,7 +74,8 @@
                  MATERIALIZE_DIAGNOSTIC_FLAG, \
                  MATERIALIZE_NOTPRODUCT_FLAG, \
                  IGNORE_RANGE, \
-                 IGNORE_CONSTRAINT)
+                 IGNORE_CONSTRAINT, \
+                 IGNORE_WRITEABLE)
 
 ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \
            MATERIALIZE_PRODUCT_FLAG, \
@@ -79,7 +83,8 @@
            MATERIALIZE_EXPERIMENTAL_FLAG, \
            MATERIALIZE_NOTPRODUCT_FLAG, \
            IGNORE_RANGE, \
-           IGNORE_CONSTRAINT)
+           IGNORE_CONSTRAINT, \
+           IGNORE_WRITEABLE)
 
 MATERIALIZE_FLAGS_EXT
 
@@ -141,10 +146,35 @@
 #endif
 }
 
-void Flag::check_writable() {
+Flag::Error Flag::check_writable(bool changed) {
   if (is_constant_in_binary()) {
     fatal("flag is constant: %s", _name);
   }
+
+  Flag::Error error = Flag::SUCCESS;
+  if (changed) {
+    CommandLineFlagWriteable* writeable = CommandLineFlagWriteableList::find(_name);
+    if (writeable) {
+      if (writeable->is_writeable() == false) {
+        switch (writeable->type())
+        {
+          case CommandLineFlagWriteable::Once:
+            error = Flag::SET_ONLY_ONCE;
+            jio_fprintf(defaultStream::error_stream(), "Error: %s may not be set more than once\n", _name);
+            break;
+          case CommandLineFlagWriteable::CommandLineOnly:
+            error = Flag::COMMAND_LINE_ONLY;
+            jio_fprintf(defaultStream::error_stream(), "Error: %s may be modified only from commad line\n", _name);
+            break;
+          default:
+            ShouldNotReachHere();
+            break;
+        }
+      }
+      writeable->mark_once();
+    }
+  }
+  return error;
 }
 
 bool Flag::is_bool() const {
@@ -155,9 +185,12 @@
   return *((bool*) _addr);
 }
 
-void Flag::set_bool(bool value) {
-  check_writable();
-  *((bool*) _addr) = value;
+Flag::Error Flag::set_bool(bool value) {
+  Flag::Error error = check_writable(value!=get_bool());
+  if (error == Flag::SUCCESS) {
+    *((bool*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_int() const {
@@ -168,9 +201,12 @@
   return *((int*) _addr);
 }
 
-void Flag::set_int(int value) {
-  check_writable();
-  *((int*) _addr) = value;
+Flag::Error Flag::set_int(int value) {
+  Flag::Error error = check_writable(value!=get_int());
+  if (error == Flag::SUCCESS) {
+    *((int*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_uint() const {
@@ -181,9 +217,12 @@
   return *((uint*) _addr);
 }
 
-void Flag::set_uint(uint value) {
-  check_writable();
-  *((uint*) _addr) = value;
+Flag::Error Flag::set_uint(uint value) {
+  Flag::Error error = check_writable(value!=get_uint());
+  if (error == Flag::SUCCESS) {
+    *((uint*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_intx() const {
@@ -194,9 +233,12 @@
   return *((intx*) _addr);
 }
 
-void Flag::set_intx(intx value) {
-  check_writable();
-  *((intx*) _addr) = value;
+Flag::Error Flag::set_intx(intx value) {
+  Flag::Error error = check_writable(value!=get_intx());
+  if (error == Flag::SUCCESS) {
+    *((intx*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_uintx() const {
@@ -207,9 +249,12 @@
   return *((uintx*) _addr);
 }
 
-void Flag::set_uintx(uintx value) {
-  check_writable();
-  *((uintx*) _addr) = value;
+Flag::Error Flag::set_uintx(uintx value) {
+  Flag::Error error = check_writable(value!=get_uintx());
+  if (error == Flag::SUCCESS) {
+    *((uintx*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_uint64_t() const {
@@ -220,9 +265,12 @@
   return *((uint64_t*) _addr);
 }
 
-void Flag::set_uint64_t(uint64_t value) {
-  check_writable();
-  *((uint64_t*) _addr) = value;
+Flag::Error Flag::set_uint64_t(uint64_t value) {
+  Flag::Error error = check_writable(value!=get_uint64_t());
+  if (error == Flag::SUCCESS) {
+    *((uint64_t*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_size_t() const {
@@ -233,9 +281,12 @@
   return *((size_t*) _addr);
 }
 
-void Flag::set_size_t(size_t value) {
-  check_writable();
-  *((size_t*) _addr) = value;
+Flag::Error Flag::set_size_t(size_t value) {
+  Flag::Error error = check_writable(value!=get_size_t());
+  if (error == Flag::SUCCESS) {
+    *((size_t*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_double() const {
@@ -246,9 +297,12 @@
   return *((double*) _addr);
 }
 
-void Flag::set_double(double value) {
-  check_writable();
-  *((double*) _addr) = value;
+Flag::Error Flag::set_double(double value) {
+  Flag::Error error = check_writable(value!=get_double());
+  if (error == Flag::SUCCESS) {
+    *((double*) _addr) = value;
+  }
+  return error;
 }
 
 bool Flag::is_ccstr() const {
@@ -263,9 +317,12 @@
   return *((ccstr*) _addr);
 }
 
-void Flag::set_ccstr(ccstr value) {
-  check_writable();
-  *((ccstr*) _addr) = value;
+Flag::Error Flag::set_ccstr(ccstr value) {
+  Flag::Error error = check_writable(value!=get_ccstr());
+  if (error == Flag::SUCCESS) {
+    *((ccstr*) _addr) = value;
+  }
+  return error;
 }
 
 
@@ -654,7 +711,8 @@
                RUNTIME_PRODUCT_RW_FLAG_STRUCT, \
                RUNTIME_LP64_PRODUCT_FLAG_STRUCT, \
                IGNORE_RANGE, \
-               IGNORE_CONSTRAINT)
+               IGNORE_CONSTRAINT, \
+               IGNORE_WRITEABLE)
  RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
                   RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
                   RUNTIME_PRODUCT_FLAG_STRUCT, \
@@ -662,7 +720,8 @@
                   RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \
                   RUNTIME_NOTPRODUCT_FLAG_STRUCT, \
                   IGNORE_RANGE, \
-                  IGNORE_CONSTRAINT)
+                  IGNORE_CONSTRAINT, \
+                  IGNORE_WRITEABLE)
 #if INCLUDE_ALL_GCS
  G1_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
           RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
@@ -674,7 +733,8 @@
           RUNTIME_MANAGEABLE_FLAG_STRUCT, \
           RUNTIME_PRODUCT_RW_FLAG_STRUCT, \
           IGNORE_RANGE, \
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT, \
+          IGNORE_WRITEABLE)
 #endif // INCLUDE_ALL_GCS
 #if INCLUDE_JVMCI
  JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_STRUCT, \
@@ -685,7 +745,8 @@
              JVMCI_EXPERIMENTAL_FLAG_STRUCT, \
              JVMCI_NOTPRODUCT_FLAG_STRUCT, \
              IGNORE_RANGE, \
-             IGNORE_CONSTRAINT)
+             IGNORE_CONSTRAINT, \
+             IGNORE_WRITEABLE)
 #endif // INCLUDE_JVMCI
 #ifdef COMPILER1
  C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, \
@@ -695,7 +756,8 @@
           C1_DIAGNOSTIC_FLAG_STRUCT, \
           C1_NOTPRODUCT_FLAG_STRUCT, \
           IGNORE_RANGE, \
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT, \
+          IGNORE_WRITEABLE)
 #endif // COMPILER1
 #ifdef COMPILER2
  C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, \
@@ -706,7 +768,8 @@
           C2_EXPERIMENTAL_FLAG_STRUCT, \
           C2_NOTPRODUCT_FLAG_STRUCT, \
           IGNORE_RANGE, \
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT, \
+          IGNORE_WRITEABLE)
 #endif // COMPILER2
 #ifdef SHARK
  SHARK_FLAGS(SHARK_DEVELOP_FLAG_STRUCT, \
@@ -714,7 +777,10 @@
              SHARK_PRODUCT_FLAG_STRUCT, \
              SHARK_PD_PRODUCT_FLAG_STRUCT, \
              SHARK_DIAGNOSTIC_FLAG_STRUCT, \
-             SHARK_NOTPRODUCT_FLAG_STRUCT)
+             SHARK_NOTPRODUCT_FLAG_STRUCT, \
+             IGNORE_RANGE, \
+             IGNORE_CONSTRAINT, \
+             IGNORE_WRITEABLE)
 #endif // SHARK
  ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, \
             ARCH_PRODUCT_FLAG_STRUCT, \
@@ -722,7 +788,8 @@
             ARCH_EXPERIMENTAL_FLAG_STRUCT, \
             ARCH_NOTPRODUCT_FLAG_STRUCT, \
             IGNORE_RANGE, \
-            IGNORE_CONSTRAINT)
+            IGNORE_CONSTRAINT, \
+            IGNORE_WRITEABLE)
  FLAGTABLE_EXT
  {0, NULL, NULL}
 };
@@ -873,10 +940,10 @@
   if (check != Flag::SUCCESS) return check;
   bool old_value = flag->get_bool();
   trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
-  flag->set_bool(*value);
+  check = flag->set_bool(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) {
@@ -922,10 +989,10 @@
   if (check != Flag::SUCCESS) return check;
   int old_value = flag->get_int();
   trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin);
-  flag->set_int(*value);
+  check = flag->set_int(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::intAtPut(const char* name, size_t len, int* value, Flag::Flags origin) {
@@ -971,10 +1038,10 @@
   if (check != Flag::SUCCESS) return check;
   uint old_value = flag->get_uint();
   trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin);
-  flag->set_uint(*value);
+  check = flag->set_uint(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin) {
@@ -1020,10 +1087,10 @@
   if (check != Flag::SUCCESS) return check;
   intx old_value = flag->get_intx();
   trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin);
-  flag->set_intx(*value);
+  check = flag->set_intx(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) {
@@ -1069,10 +1136,10 @@
   if (check != Flag::SUCCESS) return check;
   uintx old_value = flag->get_uintx();
   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
-  flag->set_uintx(*value);
+  check = flag->set_uintx(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) {
@@ -1118,10 +1185,10 @@
   if (check != Flag::SUCCESS) return check;
   uint64_t old_value = flag->get_uint64_t();
   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
-  flag->set_uint64_t(*value);
+  check = flag->set_uint64_t(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) {
@@ -1168,10 +1235,10 @@
   if (check != Flag::SUCCESS) return check;
   size_t old_value = flag->get_size_t();
   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
-  flag->set_size_t(*value);
+  check = flag->set_size_t(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin) {
@@ -1217,10 +1284,10 @@
   if (check != Flag::SUCCESS) return check;
   double old_value = flag->get_double();
   trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
-  flag->set_double(*value);
+  check = flag->set_double(*value);
   *value = old_value;
   flag->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {
@@ -1252,14 +1319,14 @@
   if (*value != NULL) {
     new_value = os::strdup_check_oom(*value);
   }
-  result->set_ccstr(new_value);
+  Flag::Error check = result->set_ccstr(new_value);
   if (result->is_default() && old_value != NULL) {
     // Prior value is NOT heap allocated, but was a literal constant.
     old_value = os::strdup_check_oom(old_value);
   }
   *value = old_value;
   result->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 Flag::Error CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
@@ -1268,13 +1335,13 @@
   ccstr old_value = faddr->get_ccstr();
   trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin);
   char* new_value = os::strdup_check_oom(value);
-  faddr->set_ccstr(new_value);
+  Flag::Error check = faddr->set_ccstr(new_value);
   if (!faddr->is_default() && old_value != NULL) {
     // Prior value is heap allocated so free it.
     FREE_C_HEAP_ARRAY(char, old_value);
   }
   faddr->set_origin(origin);
-  return Flag::SUCCESS;
+  return check;
 }
 
 extern "C" {
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index fe2d2e6..54cd9c0 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -280,6 +280,12 @@
     VIOLATES_CONSTRAINT,
     // there is no flag with the given name
     INVALID_FLAG,
+    // the flag can only be set only on command line during invocation of the VM
+    COMMAND_LINE_ONLY,
+    // the flag may only be set once
+    SET_ONLY_ONCE,
+    // the flag is not writable in this combination of product/debug build
+    CONSTANT,
     // other, unspecified error related to setting the flag
     ERR_OTHER
   };
@@ -316,44 +322,44 @@
   static const char* get_size_t_default_range_str();
   static const char* get_double_default_range_str();
 
-  void check_writable();
+  Flag::Error check_writable(bool changed);
 
   bool is_bool() const;
   bool get_bool() const;
-  void set_bool(bool value);
+  Flag::Error set_bool(bool value);
 
   bool is_int() const;
   int get_int() const;
-  void set_int(int value);
+  Flag::Error set_int(int value);
 
   bool is_uint() const;
   uint get_uint() const;
-  void set_uint(uint value);
+  Flag::Error set_uint(uint value);
 
   bool is_intx() const;
   intx get_intx() const;
-  void set_intx(intx value);
+  Flag::Error set_intx(intx value);
 
   bool is_uintx() const;
   uintx get_uintx() const;
-  void set_uintx(uintx value);
+  Flag::Error set_uintx(uintx value);
 
   bool is_uint64_t() const;
   uint64_t get_uint64_t() const;
-  void set_uint64_t(uint64_t value);
+  Flag::Error set_uint64_t(uint64_t value);
 
   bool is_size_t() const;
   size_t get_size_t() const;
-  void set_size_t(size_t value);
+  Flag::Error set_size_t(size_t value);
 
   bool is_double() const;
   double get_double() const;
-  void set_double(double value);
+  Flag::Error set_double(double value);
 
   bool is_ccstr() const;
   bool ccstr_accumulates() const;
   ccstr get_ccstr() const;
-  void set_ccstr(ccstr value);
+  Flag::Error set_ccstr(ccstr value);
 
   Flags get_origin();
   void set_origin(Flags origin);
@@ -621,8 +627,31 @@
 // constraint is a macro that will expand to custom function call
 //    for constraint checking if provided - see commandLineFlagConstraintList.hpp
 //
+// writeable is a macro that controls if and how the value can change during the runtime
+//
+// writeable(Always) is optional and allows the flag to have its value changed
+//    without any limitations at any time
+//
+// writeable(Once) flag value's can be only set once during the lifetime of VM
+//
+// writeable(CommandLineOnly) flag value's can be only set from command line
+//    (multiple times allowed)
+//
 
-#define RUNTIME_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw, lp64_product, range, constraint) \
+
+#define RUNTIME_FLAGS(develop, \
+                      develop_pd, \
+                      product, \
+                      product_pd, \
+                      diagnostic, \
+                      experimental, \
+                      notproduct, \
+                      manageable, \
+                      product_rw, \
+                      lp64_product, \
+                      range, \
+                      constraint, \
+                      writeable) \
                                                                             \
   lp64_product(bool, UseCompressedOops, false,                              \
           "Use 32-bit object references in 64-bit VM. "                     \
@@ -732,7 +761,7 @@
           "Control whether SHA instructions can be used "                   \
           "on SPARC, on ARM and on x86")                                    \
                                                                             \
-  product(bool, UseGHASHIntrinsics, false,                                  \
+  diagnostic(bool, UseGHASHIntrinsics, false,                               \
           "Use intrinsics for GHASH versions of crypto")                    \
                                                                             \
   product(size_t, LargePageSizeInBytes, 0,                                  \
@@ -802,27 +831,27 @@
   product(bool, UseInlineCaches, true,                                      \
           "Use Inline Caches for virtual calls ")                           \
                                                                             \
-  develop(bool, InlineArrayCopy, true,                                      \
+  diagnostic(bool, InlineArrayCopy, true,                                   \
           "Inline arraycopy native that is known to be part of "            \
           "base library DLL")                                               \
                                                                             \
-  develop(bool, InlineObjectHash, true,                                     \
+  diagnostic(bool, InlineObjectHash, true,                                  \
           "Inline Object::hashCode() native that is known to be part "      \
           "of base library DLL")                                            \
                                                                             \
-  develop(bool, InlineNatives, true,                                        \
+  diagnostic(bool, InlineNatives, true,                                     \
           "Inline natives that are known to be part of base library DLL")   \
                                                                             \
-  develop(bool, InlineMathNatives, true,                                    \
+  diagnostic(bool, InlineMathNatives, true,                                 \
           "Inline SinD, CosD, etc.")                                        \
                                                                             \
-  develop(bool, InlineClassNatives, true,                                   \
+  diagnostic(bool, InlineClassNatives, true,                                \
           "Inline Class.isInstance, etc")                                   \
                                                                             \
-  develop(bool, InlineThreadNatives, true,                                  \
+  diagnostic(bool, InlineThreadNatives, true,                               \
           "Inline Thread.currentThread, etc")                               \
                                                                             \
-  develop(bool, InlineUnsafeOps, true,                                      \
+  diagnostic(bool, InlineUnsafeOps, true,                                   \
           "Inline memory ops (native methods) from Unsafe")                 \
                                                                             \
   product(bool, CriticalJNINatives, true,                                   \
@@ -831,34 +860,34 @@
   notproduct(bool, StressCriticalJNINatives, false,                         \
           "Exercise register saving code in critical natives")              \
                                                                             \
-  product(bool, UseAESIntrinsics, false,                                    \
+  diagnostic(bool, UseAESIntrinsics, false,                                 \
           "Use intrinsics for AES versions of crypto")                      \
                                                                             \
-  product(bool, UseAESCTRIntrinsics, false,                                 \
+  diagnostic(bool, UseAESCTRIntrinsics, false,                              \
           "Use intrinsics for the paralleled version of AES/CTR crypto")    \
                                                                             \
-  product(bool, UseSHA1Intrinsics, false,                                   \
+  diagnostic(bool, UseSHA1Intrinsics, false,                                \
           "Use intrinsics for SHA-1 crypto hash function. "                 \
           "Requires that UseSHA is enabled.")                               \
                                                                             \
-  product(bool, UseSHA256Intrinsics, false,                                 \
+  diagnostic(bool, UseSHA256Intrinsics, false,                              \
           "Use intrinsics for SHA-224 and SHA-256 crypto hash functions. "  \
           "Requires that UseSHA is enabled.")                               \
                                                                             \
-  product(bool, UseSHA512Intrinsics, false,                                 \
+  diagnostic(bool, UseSHA512Intrinsics, false,                              \
           "Use intrinsics for SHA-384 and SHA-512 crypto hash functions. "  \
           "Requires that UseSHA is enabled.")                               \
                                                                             \
-  product(bool, UseCRC32Intrinsics, false,                                  \
+  diagnostic(bool, UseCRC32Intrinsics, false,                               \
           "use intrinsics for java.util.zip.CRC32")                         \
                                                                             \
-  product(bool, UseCRC32CIntrinsics, false,                                 \
+  diagnostic(bool, UseCRC32CIntrinsics, false,                              \
           "use intrinsics for java.util.zip.CRC32C")                        \
                                                                             \
-  product(bool, UseAdler32Intrinsics, false,                                \
+  diagnostic(bool, UseAdler32Intrinsics, false,                             \
           "use intrinsics for java.util.zip.Adler32")                       \
                                                                             \
-  product(bool, UseVectorizedMismatchIntrinsic, false,                      \
+  diagnostic(bool, UseVectorizedMismatchIntrinsic, false,                   \
           "Enables intrinsification of ArraysSupport.vectorizedMismatch()") \
                                                                             \
   diagnostic(ccstrlist, DisableIntrinsic, "",                               \
@@ -1253,7 +1282,7 @@
   product(intx, MonitorBound, 0, "Bound Monitor population")                \
           range(0, max_jint)                                                \
                                                                             \
-  product(bool, MonitorInUseLists, false, "Track Monitors for Deflation")   \
+  product(bool, MonitorInUseLists, true, "Track Monitors for Deflation")    \
                                                                             \
   experimental(intx, SyncFlags, 0, "(Unsafe, Unstable) "                    \
                "Experimental Sync flags")                                   \
@@ -1418,10 +1447,6 @@
   product(bool, StressLdcRewrite, false,                                    \
           "Force ldc -> ldc_w rewrite during RedefineClasses")              \
                                                                             \
-  product(uintx, TraceRedefineClasses, 0,                                   \
-          "Trace level for JVMTI RedefineClasses")                          \
-          range(0, 0xFFFFFFFF)                                              \
-                                                                            \
   /* change to false by default sometime after Mustang */                   \
   product(bool, VerifyMergedCPBytecodes, true,                              \
           "Verify bytecodes after RedefineClasses constant pool merging")   \
@@ -2070,6 +2095,9 @@
   notproduct(bool, VerboseInternalVMTests, false,                           \
           "Turn on logging for internal VM tests.")                         \
                                                                             \
+  product(bool, ExecutingUnitTests, false,                                  \
+          "Whether the JVM is running unit tests or not")                   \
+                                                                            \
   product_pd(bool, UseTLAB, "Use thread-local object allocation")           \
                                                                             \
   product_pd(bool, ResizeTLAB,                                              \
@@ -2221,11 +2249,11 @@
           "Adaptive size policy maximum GC pause time goal in millisecond, "\
           "or (G1 Only) the maximum GC time per MMU time slice")            \
           range(1, max_uintx - 1)                                           \
-          constraint(MaxGCPauseMillisConstraintFunc,AfterMemoryInit)        \
+          constraint(MaxGCPauseMillisConstraintFunc,AfterErgo)              \
                                                                             \
   product(uintx, GCPauseIntervalMillis, 0,                                  \
           "Time slice for MMU specification")                               \
-          constraint(GCPauseIntervalMillisConstraintFunc,AfterMemoryInit)   \
+          constraint(GCPauseIntervalMillisConstraintFunc,AfterErgo)         \
                                                                             \
   product(uintx, MaxGCMinorPauseMillis, max_uintx,                          \
           "Adaptive size policy maximum GC minor pause time goal "          \
@@ -2901,9 +2929,9 @@
                                                                             \
   product(intx,  AllocatePrefetchStyle, 1,                                  \
           "0 = no prefetch, "                                               \
-          "1 = prefetch instructions for each allocation, "                 \
+          "1 = generate prefetch instructions for each allocation, "        \
           "2 = use TLAB watermark to gate allocation prefetch, "            \
-          "3 = use BIS instruction on Sparc for allocation prefetch")       \
+          "3 = generate one prefetch instruction per cache line")           \
           range(0, 3)                                                       \
                                                                             \
   product(intx,  AllocatePrefetchDistance, -1,                              \
@@ -2926,8 +2954,8 @@
           constraint(AllocatePrefetchStepSizeConstraintFunc,AfterMemoryInit)\
                                                                             \
   product(intx,  AllocatePrefetchInstr, 0,                                  \
-          "Prefetch instruction to prefetch ahead of allocation pointer")   \
-          constraint(AllocatePrefetchInstrConstraintFunc, AfterErgo)        \
+          "Select instruction to prefetch ahead of allocation pointer")     \
+          constraint(AllocatePrefetchInstrConstraintFunc, AfterMemoryInit)  \
                                                                             \
   /* deoptimization */                                                      \
   develop(bool, TraceDeoptimization, false,                                 \
@@ -3847,9 +3875,9 @@
                                                                             \
   /* Properties for Java libraries  */                                      \
                                                                             \
-  product(size_t, MaxDirectMemorySize, 0,                                   \
+  product(uint64_t, MaxDirectMemorySize, 0,                                 \
           "Maximum total size of NIO direct-buffer allocations")            \
-          range(0, (size_t)SIZE_MAX)                                        \
+          range(0, max_jlong)                                               \
                                                                             \
   /* Flags used for temporary code during development  */                   \
                                                                             \
@@ -4186,6 +4214,8 @@
 // Only materialize src code for contraint checking when required, ignore otherwise
 #define IGNORE_CONSTRAINT(func,type)
 
+#define IGNORE_WRITEABLE(type)
+
 RUNTIME_FLAGS(DECLARE_DEVELOPER_FLAG, \
               DECLARE_PD_DEVELOPER_FLAG, \
               DECLARE_PRODUCT_FLAG, \
@@ -4197,7 +4227,8 @@
               DECLARE_PRODUCT_RW_FLAG, \
               DECLARE_LP64_PRODUCT_FLAG, \
               IGNORE_RANGE, \
-              IGNORE_CONSTRAINT)
+              IGNORE_CONSTRAINT, \
+              IGNORE_WRITEABLE)
 
 RUNTIME_OS_FLAGS(DECLARE_DEVELOPER_FLAG, \
                  DECLARE_PD_DEVELOPER_FLAG, \
@@ -4206,7 +4237,8 @@
                  DECLARE_DIAGNOSTIC_FLAG, \
                  DECLARE_NOTPRODUCT_FLAG, \
                  IGNORE_RANGE, \
-                 IGNORE_CONSTRAINT)
+                 IGNORE_CONSTRAINT, \
+                 IGNORE_WRITEABLE)
 
 ARCH_FLAGS(DECLARE_DEVELOPER_FLAG, \
            DECLARE_PRODUCT_FLAG, \
@@ -4214,7 +4246,8 @@
            DECLARE_EXPERIMENTAL_FLAG, \
            DECLARE_NOTPRODUCT_FLAG, \
            IGNORE_RANGE, \
-           IGNORE_CONSTRAINT)
+           IGNORE_CONSTRAINT, \
+           IGNORE_WRITEABLE)
 
 // Extensions
 
diff --git a/hotspot/src/share/vm/runtime/globals_extension.hpp b/hotspot/src/share/vm/runtime/globals_extension.hpp
index b550f23..810fcd7 100644
--- a/hotspot/src/share/vm/runtime/globals_extension.hpp
+++ b/hotspot/src/share/vm/runtime/globals_extension.hpp
@@ -103,7 +103,8 @@
                RUNTIME_PRODUCT_RW_FLAG_MEMBER, \
                RUNTIME_LP64_PRODUCT_FLAG_MEMBER, \
                IGNORE_RANGE, \
-               IGNORE_CONSTRAINT)
+               IGNORE_CONSTRAINT, \
+               IGNORE_WRITEABLE)
  RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER, \
                   RUNTIME_PD_DEVELOP_FLAG_MEMBER, \
                   RUNTIME_PRODUCT_FLAG_MEMBER, \
@@ -111,7 +112,8 @@
                   RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \
                   RUNTIME_NOTPRODUCT_FLAG_MEMBER, \
                   IGNORE_RANGE, \
-                  IGNORE_CONSTRAINT)
+                  IGNORE_CONSTRAINT, \
+                  IGNORE_WRITEABLE)
 #if INCLUDE_ALL_GCS
  G1_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER, \
           RUNTIME_PD_DEVELOP_FLAG_MEMBER, \
@@ -123,7 +125,8 @@
           RUNTIME_MANAGEABLE_FLAG_MEMBER, \
           RUNTIME_PRODUCT_RW_FLAG_MEMBER, \
           IGNORE_RANGE, \
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT, \
+          IGNORE_WRITEABLE)
 #endif // INCLUDE_ALL_GCS
 #if INCLUDE_JVMCI
  JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_MEMBER, \
@@ -134,7 +137,8 @@
              JVMCI_EXPERIMENTAL_FLAG_MEMBER, \
              JVMCI_NOTPRODUCT_FLAG_MEMBER, \
              IGNORE_RANGE, \
-             IGNORE_CONSTRAINT)
+             IGNORE_CONSTRAINT, \
+             IGNORE_WRITEABLE)
 #endif // INCLUDE_JVMCI
 #ifdef COMPILER1
  C1_FLAGS(C1_DEVELOP_FLAG_MEMBER, \
@@ -144,7 +148,8 @@
           C1_DIAGNOSTIC_FLAG_MEMBER, \
           C1_NOTPRODUCT_FLAG_MEMBER, \
           IGNORE_RANGE, \
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT, \
+          IGNORE_WRITEABLE)
 #endif
 #ifdef COMPILER2
  C2_FLAGS(C2_DEVELOP_FLAG_MEMBER, \
@@ -155,7 +160,8 @@
           C2_EXPERIMENTAL_FLAG_MEMBER, \
           C2_NOTPRODUCT_FLAG_MEMBER, \
           IGNORE_RANGE, \
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT, \
+          IGNORE_WRITEABLE)
 #endif
  ARCH_FLAGS(ARCH_DEVELOP_FLAG_MEMBER, \
             ARCH_PRODUCT_FLAG_MEMBER, \
@@ -163,7 +169,8 @@
             ARCH_EXPERIMENTAL_FLAG_MEMBER, \
             ARCH_NOTPRODUCT_FLAG_MEMBER, \
             IGNORE_RANGE, \
-            IGNORE_CONSTRAINT)
+            IGNORE_CONSTRAINT, \
+            IGNORE_WRITEABLE)
  COMMANDLINEFLAG_EXT
  NUM_CommandLineFlag
 } CommandLineFlag;
@@ -229,7 +236,8 @@
                RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE,
                RUNTIME_LP64_PRODUCT_FLAG_MEMBER_WITH_TYPE,
                IGNORE_RANGE,
-               IGNORE_CONSTRAINT)
+               IGNORE_CONSTRAINT,
+               IGNORE_WRITEABLE)
  RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE,
                   RUNTIME_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE,
                   RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE,
@@ -237,7 +245,8 @@
                   RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE,
                   RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE,
                   IGNORE_RANGE,
-                  IGNORE_CONSTRAINT)
+                  IGNORE_CONSTRAINT,
+                  IGNORE_WRITEABLE)
 #if INCLUDE_ALL_GCS
  G1_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE,
           RUNTIME_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE,
@@ -249,7 +258,8 @@
           RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE,
           RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE,
           IGNORE_RANGE,
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT,
+          IGNORE_WRITEABLE)
 #endif // INCLUDE_ALL_GCS
 #if INCLUDE_JVMCI
  JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_MEMBER_WITH_TYPE,
@@ -260,7 +270,8 @@
              JVMCI_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE,
              JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE,
              IGNORE_RANGE,
-             IGNORE_CONSTRAINT)
+             IGNORE_CONSTRAINT,
+             IGNORE_WRITEABLE)
 #endif // INCLUDE_JVMCI
 #ifdef COMPILER1
  C1_FLAGS(C1_DEVELOP_FLAG_MEMBER_WITH_TYPE,
@@ -270,7 +281,8 @@
           C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE,
           C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE,
           IGNORE_RANGE,
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT,
+          IGNORE_WRITEABLE)
 #endif
 #ifdef COMPILER2
  C2_FLAGS(C2_DEVELOP_FLAG_MEMBER_WITH_TYPE,
@@ -281,7 +293,8 @@
           C2_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE,
           C2_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE,
           IGNORE_RANGE,
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT,
+          IGNORE_WRITEABLE)
 #endif
  ARCH_FLAGS(ARCH_DEVELOP_FLAG_MEMBER_WITH_TYPE,
           ARCH_PRODUCT_FLAG_MEMBER_WITH_TYPE,
@@ -289,7 +302,8 @@
           ARCH_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE,
           ARCH_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE,
           IGNORE_RANGE,
-          IGNORE_CONSTRAINT)
+          IGNORE_CONSTRAINT,
+          IGNORE_WRITEABLE)
  COMMANDLINEFLAGWITHTYPE_EXT
  NUM_CommandLineFlagWithType
 } CommandLineFlagWithType;
diff --git a/hotspot/src/share/vm/runtime/javaCalls.cpp b/hotspot/src/share/vm/runtime/javaCalls.cpp
index bf8aa7c..686a2c56 100644
--- a/hotspot/src/share/vm/runtime/javaCalls.cpp
+++ b/hotspot/src/share/vm/runtime/javaCalls.cpp
@@ -343,13 +343,7 @@
   }
 #endif
 
-
-  assert(thread->can_call_java(), "cannot compile from the native compiler");
-  if (CompilationPolicy::must_be_compiled(method)) {
-    CompileBroker::compile_method(method, InvocationEntryBci,
-                                  CompilationPolicy::policy()->initial_compile_level(),
-                                  methodHandle(), 0, "must_be_compiled", CHECK);
-  }
+  CompilationPolicy::compile_if_required(method, CHECK);
 
   // Since the call stub sets up like the interpreter we call the from_interpreted_entry
   // so we can go compiled via a i2c. Otherwise initial entry method will always
diff --git a/hotspot/src/share/vm/runtime/mutex.cpp b/hotspot/src/share/vm/runtime/mutex.cpp
index ef6ac43..a065fb1 100644
--- a/hotspot/src/share/vm/runtime/mutex.cpp
+++ b/hotspot/src/share/vm/runtime/mutex.cpp
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "runtime/atomic.inline.hpp"
+#include "runtime/interfaceSupport.hpp"
 #include "runtime/mutex.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "runtime/osThread.hpp"
diff --git a/hotspot/src/share/vm/runtime/mutexLocker.cpp b/hotspot/src/share/vm/runtime/mutexLocker.cpp
index 1a3767c..219194a 100644
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp
@@ -120,6 +120,7 @@
 Mutex*   Management_lock              = NULL;
 Monitor* Service_lock                 = NULL;
 Monitor* PeriodicTask_lock            = NULL;
+Monitor* RedefineClasses_lock         = NULL;
 
 #ifdef INCLUDE_TRACE
 Mutex*   JfrStacktrace_lock           = NULL;
@@ -264,6 +265,7 @@
   def(Debug3_lock                  , Mutex  , nonleaf+4,   true,  Monitor::_safepoint_check_never);
   def(CompileThread_lock           , Monitor, nonleaf+5,   false, Monitor::_safepoint_check_always);
   def(PeriodicTask_lock            , Monitor, nonleaf+5,   true,  Monitor::_safepoint_check_sometimes);
+  def(RedefineClasses_lock         , Monitor, nonleaf+5,   true,  Monitor::_safepoint_check_always);
   if (WhiteBoxAPI) {
     def(Compilation_lock           , Monitor, leaf,        false, Monitor::_safepoint_check_never);
   }
diff --git a/hotspot/src/share/vm/runtime/mutexLocker.hpp b/hotspot/src/share/vm/runtime/mutexLocker.hpp
index 014ffb2..ae4c799 100644
--- a/hotspot/src/share/vm/runtime/mutexLocker.hpp
+++ b/hotspot/src/share/vm/runtime/mutexLocker.hpp
@@ -121,6 +121,7 @@
 extern Mutex*   Management_lock;                 // a lock used to serialize JVM management
 extern Monitor* Service_lock;                    // a lock used for service thread operation
 extern Monitor* PeriodicTask_lock;               // protects the periodic task structure
+extern Monitor* RedefineClasses_lock;            // locks classes from parallel redefinition
 
 #ifdef INCLUDE_TRACE
 extern Mutex*   JfrStacktrace_lock;              // used to guard access to the JFR stacktrace table
diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp
index d1ac2b4..4abbdbb 100644
--- a/hotspot/src/share/vm/runtime/os.hpp
+++ b/hotspot/src/share/vm/runtime/os.hpp
@@ -520,7 +520,9 @@
   static int ftruncate(int fd, jlong length);
   static int fsync(int fd);
   static int available(int fd, jlong *bytes);
-  static int fileno(FILE* fp);
+  static int get_fileno(FILE* fp);
+  static void flockfile(FILE* fp);
+  static void funlockfile(FILE* fp);
 
   static int compare_file_modified_times(const char* file1, const char* file2);
 
diff --git a/hotspot/src/share/vm/runtime/os_ext.hpp b/hotspot/src/share/vm/runtime/os_ext.hpp
index 80b87f2..3aa733a 100644
--- a/hotspot/src/share/vm/runtime/os_ext.hpp
+++ b/hotspot/src/share/vm/runtime/os_ext.hpp
@@ -27,6 +27,7 @@
 
 #define EMIT_RANGES_FOR_GLOBALS_EXT // NOP
 #define EMIT_CONSTRAINTS_FOR_GLOBALS_EXT // NOP
+#define EMIT_WRITEABLES_FOR_GLOBALS_EXT // NOP
 
 public:
   static void init_globals_ext() {} // Run from init_globals().
diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp
index 625d558..f81deb6 100644
--- a/hotspot/src/share/vm/runtime/reflection.cpp
+++ b/hotspot/src/share/vm/runtime/reflection.cpp
@@ -76,9 +76,9 @@
     const char * to = to_class->external_name();
     // print in a single call to reduce interleaving between threads
     if (source_file != NULL) {
-      log_debug(classresolve)("%s %s %s:%d (reflection)", from, to, source_file, line_number);
+      log_debug(class, resolve)("%s %s %s:%d (reflection)", from, to, source_file, line_number);
     } else {
-      log_debug(classresolve)("%s %s (reflection)", from, to);
+      log_debug(class, resolve)("%s %s (reflection)", from, to);
     }
   }
 }
@@ -502,17 +502,16 @@
     }
 
     // Find the module entry for current_class, the accessor
-    ModuleEntry* module_from = InstanceKlass::cast(current_class)->module();
+    ModuleEntry* module_from = current_class->module();
     // Find the module entry for new_class, the accessee
     if (new_class->is_objArray_klass()) {
       new_class = ObjArrayKlass::cast(new_class)->bottom_klass();
     }
-    if (!new_class->is_instance_klass()) {
-      // Everyone can read a typearray.
-      assert (new_class->is_typeArray_klass(), "Unexpected klass type");
+    if (new_class->is_typeArray_klass()) {
+      // A TypeArray's defining module is java.base, access to the TypeArray is allowed
       return ACCESS_OK;
     }
-    ModuleEntry* module_to = InstanceKlass::cast(new_class)->module();
+    ModuleEntry* module_to = new_class->module();
 
     // both in same (possibly unnamed) module
     if (module_from == module_to) {
@@ -532,7 +531,7 @@
       return MODULE_NOT_READABLE;
     }
 
-    PackageEntry* package_to = InstanceKlass::cast(new_class)->package();
+    PackageEntry* package_to = new_class->package();
     assert(package_to != NULL, "can not obtain new_class' package");
 
     // Once readability is established, if module_to exports T unqualifiedly,
@@ -570,20 +569,13 @@
   char * msg = NULL;
   if (result != OTHER_PROBLEM && new_class != NULL && current_class != NULL) {
     // Find the module entry for current_class, the accessor
-    ModuleEntry* module_from = InstanceKlass::cast(current_class)->module();
+    ModuleEntry* module_from = current_class->module();
     const char * module_from_name = module_from->is_named() ? module_from->name()->as_C_string() : UNNAMED_MODULE;
     const char * current_class_name = current_class->external_name();
 
     // Find the module entry for new_class, the accessee
     ModuleEntry* module_to = NULL;
-    if (new_class->is_objArray_klass()) {
-      new_class = ObjArrayKlass::cast(new_class)->bottom_klass();
-    }
-    if (new_class->is_instance_klass()) {
-      module_to = InstanceKlass::cast(new_class)->module();
-    } else {
-      module_to = ModuleEntryTable::javabase_module();
-    }
+    module_to = new_class->module();
     const char * module_to_name = module_to->is_named() ? module_to->name()->as_C_string() : UNNAMED_MODULE;
     const char * new_class_name = new_class->external_name();
 
@@ -611,10 +603,10 @@
       }
 
     } else if (result == TYPE_NOT_EXPORTED) {
-      assert(InstanceKlass::cast(new_class)->package() != NULL,
+      assert(new_class->package() != NULL,
              "Unnamed packages are always exported");
       const char * package_name =
-        InstanceKlass::cast(new_class)->package()->name()->as_klass_external_name();
+        new_class->package()->name()->as_klass_external_name();
       assert(module_to->is_named(), "Unnamed modules export all packages");
       if (module_from->is_named()) {
         size_t len = 118 + strlen(current_class_name) + 2*strlen(module_from_name) +
@@ -769,7 +761,7 @@
                                                        Handle(THREAD, protection_domain),
                                                        true,
                                                        CHECK_NULL);
-    if (log_is_enabled(Debug, classresolve)) {
+    if (log_is_enabled(Debug, class, resolve)) {
       trace_class_resolution(k);
     }
     return k->java_mirror();
@@ -824,7 +816,7 @@
                                       Handle(THREAD, k->protection_domain()),
                                       true, CHECK_(Handle()));
 
-  if (log_is_enabled(Debug, classresolve)) {
+  if (log_is_enabled(Debug, class, resolve)) {
     trace_class_resolution(result);
   }
 
diff --git a/hotspot/src/share/vm/runtime/rframe.cpp b/hotspot/src/share/vm/runtime/rframe.cpp
index dea7ef7..4028389 100644
--- a/hotspot/src/share/vm/runtime/rframe.cpp
+++ b/hotspot/src/share/vm/runtime/rframe.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,7 +127,7 @@
 }
 
 int CompiledRFrame::cost() const {
-  nmethod* nm = top_method()->code();
+  CompiledMethod* nm = top_method()->code();
   if (nm != NULL) {
     return nm->insts_size();
   } else {
@@ -139,7 +139,7 @@
   RegisterMap map(thread(), false);
   vframe* vf = vframe::new_vframe(&_fr, &map, thread());
   assert(vf->is_compiled_frame(), "must be compiled");
-  _nm = compiledVFrame::cast(vf)->code();
+  _nm = compiledVFrame::cast(vf)->code()->as_nmethod();
   vf = vf->top();
   _vf = javaVFrame::cast(vf);
   _method = CodeCache::find_nmethod(_fr.pc())->method();
diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp
index ceb934a..28f00fd 100644
--- a/hotspot/src/share/vm/runtime/safepoint.cpp
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp
@@ -545,7 +545,7 @@
   {
     const char* name = "deflating idle monitors";
     EventSafepointCleanupTask event;
-    TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup));
+    TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
     ObjectSynchronizer::deflate_idle_monitors();
     event_safepoint_cleanup_task_commit(event, name);
   }
@@ -553,14 +553,14 @@
   {
     const char* name = "updating inline caches";
     EventSafepointCleanupTask event;
-    TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup));
+    TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
     InlineCacheBuffer::update_inline_caches();
     event_safepoint_cleanup_task_commit(event, name);
   }
   {
     const char* name = "compilation policy safepoint handler";
     EventSafepointCleanupTask event;
-    TraceTime timer("compilation policy safepoint handler", TRACETIME_LOG(Info, safepointcleanup));
+    TraceTime timer("compilation policy safepoint handler", TRACETIME_LOG(Info, safepoint, cleanup));
     CompilationPolicy::policy()->do_safepoint_work();
     event_safepoint_cleanup_task_commit(event, name);
   }
@@ -568,7 +568,7 @@
   {
     const char* name = "mark nmethods";
     EventSafepointCleanupTask event;
-    TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup));
+    TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
     NMethodSweeper::mark_active_nmethods();
     event_safepoint_cleanup_task_commit(event, name);
   }
@@ -576,7 +576,7 @@
   if (SymbolTable::needs_rehashing()) {
     const char* name = "rehashing symbol table";
     EventSafepointCleanupTask event;
-    TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup));
+    TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
     SymbolTable::rehash_table();
     event_safepoint_cleanup_task_commit(event, name);
   }
@@ -584,7 +584,7 @@
   if (StringTable::needs_rehashing()) {
     const char* name = "rehashing string table";
     EventSafepointCleanupTask event;
-    TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup));
+    TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
     StringTable::rehash_table();
     event_safepoint_cleanup_task_commit(event, name);
   }
@@ -594,7 +594,7 @@
     // make sure concurrent sweep is done
     const char* name = "purging class loader data graph";
     EventSafepointCleanupTask event;
-    TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup));
+    TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
     ClassLoaderDataGraph::purge_if_needed();
     event_safepoint_cleanup_task_commit(event, name);
   }
@@ -1010,8 +1010,8 @@
   address real_return_addr = thread()->saved_exception_pc();
 
   CodeBlob *cb = CodeCache::find_blob(real_return_addr);
-  assert(cb != NULL && cb->is_nmethod(), "return address should be in nmethod");
-  nmethod* nm = (nmethod*)cb;
+  assert(cb != NULL && cb->is_compiled(), "return address should be in nmethod");
+  CompiledMethod* nm = (CompiledMethod*)cb;
 
   // Find frame of caller
   frame stub_fr = thread()->last_frame();
diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp
index d38d493..eba1d72 100644
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp
@@ -46,7 +46,6 @@
 #include "oops/oop.inline.hpp"
 #include "prims/forte.hpp"
 #include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "prims/methodHandles.hpp"
 #include "prims/nativeLookup.hpp"
 #include "runtime/arguments.hpp"
@@ -540,10 +539,10 @@
   CodeBlob *cb = CodeCache::find_blob(pc);
 
   // Should be an nmethod
-  assert(cb && cb->is_nmethod(), "safepoint polling: pc must refer to an nmethod");
+  assert(cb && cb->is_compiled(), "safepoint polling: pc must refer to an nmethod");
 
   // Look up the relocation information
-  assert(((nmethod*)cb)->is_at_poll_or_poll_return(pc),
+  assert(((CompiledMethod*)cb)->is_at_poll_or_poll_return(pc),
     "safepoint polling: type must be poll");
 
 #ifdef ASSERT
@@ -554,8 +553,8 @@
   }
 #endif
 
-  bool at_poll_return = ((nmethod*)cb)->is_at_poll_return(pc);
-  bool has_wide_vectors = ((nmethod*)cb)->has_wide_vectors();
+  bool at_poll_return = ((CompiledMethod*)cb)->is_at_poll_return(pc);
+  bool has_wide_vectors = ((CompiledMethod*)cb)->has_wide_vectors();
   if (at_poll_return) {
     assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
            "polling page return stub not created yet");
@@ -603,49 +602,40 @@
 }
 
 // The interpreter code to call this tracing function is only
-// called/generated when TraceRedefineClasses has the right bits
-// set. Since obsolete methods are never compiled, we don't have
+// called/generated when UL is on for redefine, class and has the right level
+// and tags. Since obsolete methods are never compiled, we don't have
 // to modify the compilers to generate calls to this function.
 //
 JRT_LEAF(int, SharedRuntime::rc_trace_method_entry(
     JavaThread* thread, Method* method))
-  assert(RC_TRACE_IN_RANGE(0x00001000, 0x00002000), "wrong call");
-
   if (method->is_obsolete()) {
     // We are calling an obsolete method, but this is not necessarily
     // an error. Our method could have been redefined just after we
     // fetched the Method* from the constant pool.
-
-    // RC_TRACE macro has an embedded ResourceMark
-    RC_TRACE_WITH_THREAD(0x00001000, thread,
-                         ("calling obsolete method '%s'",
-                          method->name_and_sig_as_C_string()));
-    if (RC_TRACE_ENABLED(0x00002000)) {
-      // this option is provided to debug calls to obsolete methods
-      guarantee(false, "faulting at call to an obsolete method.");
-    }
+    ResourceMark rm;
+    log_trace(redefine, class, obsolete)("calling obsolete method '%s'", method->name_and_sig_as_C_string());
   }
   return 0;
 JRT_END
 
 // ret_pc points into caller; we are returning caller's exception handler
 // for given exception
-address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
+address SharedRuntime::compute_compiled_exc_handler(CompiledMethod* cm, address ret_pc, Handle& exception,
                                                     bool force_unwind, bool top_frame_only) {
-  assert(nm != NULL, "must exist");
+  assert(cm != NULL, "must exist");
   ResourceMark rm;
 
 #if INCLUDE_JVMCI
-  if (nm->is_compiled_by_jvmci()) {
+  if (cm->is_compiled_by_jvmci()) {
     // lookup exception handler for this pc
-    int catch_pco = ret_pc - nm->code_begin();
-    ExceptionHandlerTable table(nm);
+    int catch_pco = ret_pc - cm->code_begin();
+    ExceptionHandlerTable table(cm);
     HandlerTableEntry *t = table.entry_for(catch_pco, -1, 0);
     if (t != NULL) {
-      return nm->code_begin() + t->pco();
+      return cm->code_begin() + t->pco();
     } else {
       // there is no exception handler for this pc => deoptimize
-      nm->make_not_entrant();
+      cm->make_not_entrant();
 
       // Use Deoptimization::deoptimize for all of its side-effects:
       // revoking biases of monitors, gathering traps statistics, logging...
@@ -662,6 +652,7 @@
   }
 #endif // INCLUDE_JVMCI
 
+  nmethod* nm = cm->as_nmethod();
   ScopeDesc* sd = nm->scope_desc_at(ret_pc);
   // determine handler bci, if any
   EXCEPTION_MARK;
@@ -797,7 +788,7 @@
 }
 
 #if INCLUDE_JVMCI
-address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, nmethod* nm, int deopt_reason) {
+address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason) {
   assert(deopt_reason > Deoptimization::Reason_none && deopt_reason < Deoptimization::Reason_LIMIT, "invalid deopt reason");
   thread->set_jvmci_implicit_exception_pc(pc);
   thread->set_pending_deoptimization(Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret));
@@ -871,7 +862,7 @@
           // 2. Inline-cache check in nmethod, or
           // 3. Implicit null exception in nmethod
 
-          if (!cb->is_nmethod()) {
+          if (!cb->is_compiled()) {
             bool is_in_blob = cb->is_adapter_blob() || cb->is_method_handles_adapter_blob();
             if (!is_in_blob) {
               // Allow normal crash reporting to handle this
@@ -882,9 +873,9 @@
             return StubRoutines::throw_NullPointerException_at_call_entry();
           }
 
-          // Otherwise, it's an nmethod.  Consult its exception handlers.
-          nmethod* nm = (nmethod*)cb;
-          if (nm->inlinecache_check_contains(pc)) {
+          // Otherwise, it's a compiled method.  Consult its exception handlers.
+          CompiledMethod* cm = (CompiledMethod*)cb;
+          if (cm->inlinecache_check_contains(pc)) {
             // exception happened inside inline-cache check code
             // => the nmethod is not yet active (i.e., the frame
             // is not set up yet) => use return address pushed by
@@ -893,7 +884,7 @@
             return StubRoutines::throw_NullPointerException_at_call_entry();
           }
 
-          if (nm->method()->is_method_handle_intrinsic()) {
+          if (cm->method()->is_method_handle_intrinsic()) {
             // exception happened inside MH dispatch code, similar to a vtable stub
             Events::log_exception(thread, "NullPointerException in MH adapter " INTPTR_FORMAT, p2i(pc));
             return StubRoutines::throw_NullPointerException_at_call_entry();
@@ -903,15 +894,15 @@
           _implicit_null_throws++;
 #endif
 #if INCLUDE_JVMCI
-          if (nm->is_compiled_by_jvmci() && nm->pc_desc_at(pc) != NULL) {
+          if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) {
             // If there's no PcDesc then we'll die way down inside of
             // deopt instead of just getting normal error reporting,
             // so only go there if it will succeed.
-            return deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_null_check);
+            return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_null_check);
           } else {
 #endif // INCLUDE_JVMCI
-          assert (nm->is_nmethod(), "Expect nmethod");
-          target_pc = nm->continuation_for_implicit_exception(pc);
+          assert (cm->is_nmethod(), "Expect nmethod");
+          target_pc = ((nmethod*)cm)->continuation_for_implicit_exception(pc);
 #if INCLUDE_JVMCI
           }
 #endif // INCLUDE_JVMCI
@@ -925,17 +916,17 @@
 
 
       case IMPLICIT_DIVIDE_BY_ZERO: {
-        nmethod* nm = CodeCache::find_nmethod(pc);
-        guarantee(nm != NULL, "must have containing compiled method for implicit division-by-zero exceptions");
+        CompiledMethod* cm = CodeCache::find_compiled(pc);
+        guarantee(cm != NULL, "must have containing compiled method for implicit division-by-zero exceptions");
 #ifndef PRODUCT
         _implicit_div0_throws++;
 #endif
 #if INCLUDE_JVMCI
-        if (nm->is_compiled_by_jvmci() && nm->pc_desc_at(pc) != NULL) {
-          return deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_div0_check);
+        if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) {
+          return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_div0_check);
         } else {
 #endif // INCLUDE_JVMCI
-        target_pc = nm->continuation_for_implicit_exception(pc);
+        target_pc = cm->continuation_for_implicit_exception(pc);
 #if INCLUDE_JVMCI
         }
 #endif // INCLUDE_JVMCI
@@ -1084,14 +1075,14 @@
 }
 
 methodHandle SharedRuntime::extract_attached_method(vframeStream& vfst) {
-  nmethod* caller_nm = vfst.nm();
+  CompiledMethod* caller = vfst.nm();
 
-  nmethodLocker caller_lock(caller_nm);
+  nmethodLocker caller_lock(caller);
 
   address pc = vfst.frame_pc();
   { // Get call instruction under lock because another thread may be busy patching it.
     MutexLockerEx ml_patch(Patching_lock, Mutex::_no_safepoint_check_flag);
-    return caller_nm->attached_method_before_pc(pc);
+    return caller->attached_method_before_pc(pc);
   }
   return NULL;
 }
@@ -1283,8 +1274,8 @@
   frame caller_frame = thread->last_frame().sender(&cbl_map);
 
   CodeBlob* caller_cb = caller_frame.cb();
-  guarantee(caller_cb != NULL && caller_cb->is_nmethod(), "must be called from nmethod");
-  nmethod* caller_nm = caller_cb->as_nmethod_or_null();
+  guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method");
+  CompiledMethod* caller_nm = caller_cb->as_compiled_method_or_null();
 
   // make sure caller is not getting deoptimized
   // and removed before we are done with it.
@@ -1347,14 +1338,19 @@
 
   // Make sure the callee nmethod does not get deoptimized and removed before
   // we are done patching the code.
-  nmethod* callee_nm = callee_method->code();
-  if (callee_nm != NULL && !callee_nm->is_in_use()) {
-    // Patch call site to C2I adapter if callee nmethod is deoptimized or unloaded.
-    callee_nm = NULL;
+  CompiledMethod* callee = callee_method->code();
+
+  if (callee != NULL) {
+    assert(callee->is_compiled(), "must be nmethod for patching");
   }
-  nmethodLocker nl_callee(callee_nm);
+
+  if (callee != NULL && !callee->is_in_use()) {
+    // Patch call site to C2I adapter if callee nmethod is deoptimized or unloaded.
+    callee = NULL;
+  }
+  nmethodLocker nl_callee(callee);
 #ifdef ASSERT
-  address dest_entry_point = callee_nm == NULL ? 0 : callee_nm->entry_point(); // used below
+  address dest_entry_point = callee == NULL ? 0 : callee->entry_point(); // used below
 #endif
 
   if (is_virtual) {
@@ -1382,12 +1378,12 @@
     // which may happen when multiply alive nmethod (tiered compilation)
     // will be supported.
     if (!callee_method->is_old() &&
-        (callee_nm == NULL || callee_nm->is_in_use() && (callee_method->code() == callee_nm))) {
+        (callee == NULL || callee->is_in_use() && (callee_method->code() == callee))) {
 #ifdef ASSERT
       // We must not try to patch to jump to an already unloaded method.
       if (dest_entry_point != 0) {
         CodeBlob* cb = CodeCache::find_blob(dest_entry_point);
-        assert((cb != NULL) && cb->is_nmethod() && (((nmethod*)cb) == callee_nm),
+        assert((cb != NULL) && cb->is_compiled() && (((CompiledMethod*)cb) == callee),
                "should not call unloaded nmethod");
       }
 #endif
@@ -1582,8 +1578,9 @@
     RegisterMap reg_map(thread, false);
     frame caller_frame = thread->last_frame().sender(&reg_map);
     CodeBlob* cb = caller_frame.cb();
-    if (cb->is_nmethod()) {
-      CompiledIC* inline_cache = CompiledIC_before(((nmethod*)cb), caller_frame.pc());
+    CompiledMethod* caller_nm = cb->as_compiled_method_or_null();
+    if (cb->is_compiled()) {
+      CompiledIC* inline_cache = CompiledIC_before(((CompiledMethod*)cb), caller_frame.pc());
       bool should_be_mono = false;
       if (inline_cache->is_optimized()) {
         if (TraceCallFixup) {
@@ -1667,7 +1664,7 @@
 
     // Check for static or virtual call
     bool is_static_call = false;
-    nmethod* caller_nm = CodeCache::find_nmethod(pc);
+    CompiledMethod* caller_nm = CodeCache::find_compiled(pc);
 
     // Default call_addr is the location of the "basic" call.
     // Determine the address of the call we a reresolving. With
@@ -1755,6 +1752,21 @@
   return callee_method;
 }
 
+address SharedRuntime::handle_unsafe_access(JavaThread* thread, address next_pc) {
+  // The faulting unsafe accesses should be changed to throw the error
+  // synchronously instead. Meanwhile the faulting instruction will be
+  // skipped over (effectively turning it into a no-op) and an
+  // asynchronous exception will be raised which the thread will
+  // handle at a later point. If the instruction is a load it will
+  // return garbage.
+
+  // Request an async exception.
+  thread->set_pending_unsafe_access_error();
+
+  // Return address of next instruction to execute.
+  return next_pc;
+}
+
 #ifdef ASSERT
 void SharedRuntime::check_member_name_argument_is_last_argument(const methodHandle& method,
                                                                 const BasicType* sig_bt,
@@ -1802,12 +1814,12 @@
   // ask me how I know this...
 
   CodeBlob* cb = CodeCache::find_blob(caller_pc);
-  if (!cb->is_nmethod() || entry_point == moop->get_c2i_entry()) {
+  if (!cb->is_compiled() || entry_point == moop->get_c2i_entry()) {
     return;
   }
 
   // The check above makes sure this is a nmethod.
-  nmethod* nm = cb->as_nmethod_or_null();
+  CompiledMethod* nm = cb->as_compiled_method_or_null();
   assert(nm, "must be");
 
   // Get the return PC for the passed caller PC.
diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp
index 68baebc..eb9797f 100644
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp
@@ -188,7 +188,7 @@
 #endif // INCLUDE_ALL_GCS
 
   // exception handling and implicit exceptions
-  static address compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
+  static address compute_compiled_exc_handler(CompiledMethod* nm, address ret_pc, Handle& exception,
                                               bool force_unwind, bool top_frame_only);
   enum ImplicitExceptionKind {
     IMPLICIT_NULL,
@@ -207,7 +207,7 @@
                                                      address faulting_pc,
                                                      ImplicitExceptionKind exception_kind);
 #if INCLUDE_JVMCI
-  static address deoptimize_for_implicit_exception(JavaThread* thread, address pc, nmethod* nm, int deopt_reason);
+  static address deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason);
 #endif
 
   static void enable_stack_reserved_zone(JavaThread* thread);
@@ -522,6 +522,8 @@
   static address handle_wrong_method_abstract(JavaThread* thread);
   static address handle_wrong_method_ic_miss(JavaThread* thread);
 
+  static address handle_unsafe_access(JavaThread* thread, address next_pc);
+
 #ifndef PRODUCT
 
   // Collect and print inline cache miss statistics
diff --git a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp
index 2a01388..40f4d1a 100644
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -192,7 +192,7 @@
 }
 
 nmethod* SimpleThresholdPolicy::event(const methodHandle& method, const methodHandle& inlinee,
-                                      int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
+                                      int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) {
   if (comp_level == CompLevel_none &&
       JvmtiExport::can_post_interpreter_events() &&
       thread->is_interp_only_mode()) {
@@ -265,7 +265,7 @@
 // Tell the broker to compile the method
 void SimpleThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) {
   int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
-  CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread);
+  CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread);
 }
 
 // Call and loop predicates determine whether a transition to a higher
@@ -392,7 +392,7 @@
 
 // Handle the invocation event.
 void SimpleThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh,
-                                              CompLevel level, nmethod* nm, JavaThread* thread) {
+                                              CompLevel level, CompiledMethod* nm, JavaThread* thread) {
   if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) {
     CompLevel next_level = call_event(mh(), level);
     if (next_level != level) {
@@ -404,7 +404,7 @@
 // Handle the back branch event. Notice that we can compile the method
 // with a regular entry from here.
 void SimpleThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh,
-                                                     int bci, CompLevel level, nmethod* nm, JavaThread* thread) {
+                                                     int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) {
   // If the method is already compiling, quickly bail out.
   if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) {
     // Use loop event as an opportunity to also check there's been
diff --git a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp
index 02a13ca..d2dd9cc 100644
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,16 +81,16 @@
 
   // Get a compilation level for a given method.
   static CompLevel comp_level(Method* method) {
-    nmethod *nm = method->code();
+    CompiledMethod *nm = method->code();
     if (nm != NULL && nm->is_in_use()) {
       return (CompLevel)nm->comp_level();
     }
     return CompLevel_none;
   }
   virtual void method_invocation_event(const methodHandle& method, const methodHandle& inlinee,
-                                       CompLevel level, nmethod* nm, JavaThread* thread);
+                                       CompLevel level, CompiledMethod* nm, JavaThread* thread);
   virtual void method_back_branch_event(const methodHandle& method, const methodHandle& inlinee,
-                                        int bci, CompLevel level, nmethod* nm, JavaThread* thread);
+                                        int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread);
 public:
   SimpleThresholdPolicy() : _c1_count(0), _c2_count(0) { }
   virtual int compiler_count(CompLevel comp_level) {
@@ -104,7 +104,7 @@
   virtual void disable_compilation(Method* method) { }
   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
   virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee,
-                         int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
+                         int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread);
   // Select task is called by CompileBroker. We should return a task or NULL.
   virtual CompileTask* select_task(CompileQueue* compile_queue);
   // Tell the runtime if we think a given method is adequately profiled.
diff --git a/hotspot/src/share/vm/runtime/stubRoutines.cpp b/hotspot/src/share/vm/runtime/stubRoutines.cpp
index ac98cd1..12e0e3a 100644
--- a/hotspot/src/share/vm/runtime/stubRoutines.cpp
+++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp
@@ -55,7 +55,6 @@
 address StubRoutines::_throw_NullPointerException_at_call_entry = NULL;
 address StubRoutines::_throw_StackOverflowError_entry           = NULL;
 address StubRoutines::_throw_delayed_StackOverflowError_entry   = NULL;
-address StubRoutines::_handler_for_unsafe_access_entry          = NULL;
 jint    StubRoutines::_verify_oop_count                         = 0;
 address StubRoutines::_verify_oop_subroutine_entry              = NULL;
 address StubRoutines::_atomic_xchg_entry                        = NULL;
@@ -154,11 +153,14 @@
 
 address StubRoutines::_dexp = NULL;
 address StubRoutines::_dlog = NULL;
+address StubRoutines::_dlog10 = NULL;
 address StubRoutines::_dpow = NULL;
 address StubRoutines::_dsin = NULL;
 address StubRoutines::_dcos = NULL;
 address StubRoutines::_dlibm_sin_cos_huge = NULL;
 address StubRoutines::_dlibm_reduce_pi04l = NULL;
+address StubRoutines::_dlibm_tan_cot_huge = NULL;
+address StubRoutines::_dtan = NULL;
 
 double (* StubRoutines::_intrinsic_log10 )(double) = NULL;
 double (* StubRoutines::_intrinsic_sin   )(double) = NULL;
diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp
index 55cd993..729886f 100644
--- a/hotspot/src/share/vm/runtime/stubRoutines.hpp
+++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -111,7 +111,6 @@
   static address _throw_NullPointerException_at_call_entry;
   static address _throw_StackOverflowError_entry;
   static address _throw_delayed_StackOverflowError_entry;
-  static address _handler_for_unsafe_access_entry;
 
   static address _atomic_xchg_entry;
   static address _atomic_xchg_ptr_entry;
@@ -212,11 +211,14 @@
 
   static address _dexp;
   static address _dlog;
+  static address _dlog10;
   static address _dpow;
   static address _dsin;
   static address _dcos;
   static address _dlibm_sin_cos_huge;
   static address _dlibm_reduce_pi04l;
+  static address _dlibm_tan_cot_huge;
+  static address _dtan;
 
   // These are versions of the java.lang.Math methods which perform
   // the same operations as the intrinsic version.  They are used for
@@ -251,8 +253,8 @@
       (_code2 != NULL && _code2->blob_contains(addr)) ;
   }
 
-  static CodeBlob* code1() { return _code1; }
-  static CodeBlob* code2() { return _code2; }
+  static RuntimeBlob* code1() { return _code1; }
+  static RuntimeBlob* code2() { return _code2; }
 
   // Debugging
   static jint    verify_oop_count()                        { return _verify_oop_count; }
@@ -285,10 +287,6 @@
   static address throw_StackOverflowError_entry()          { return _throw_StackOverflowError_entry; }
   static address throw_delayed_StackOverflowError_entry()  { return _throw_delayed_StackOverflowError_entry; }
 
-  // Exceptions during unsafe access - should throw Java exception rather
-  // than crash.
-  static address handler_for_unsafe_access()               { return _handler_for_unsafe_access_entry; }
-
   static address atomic_xchg_entry()                       { return _atomic_xchg_entry; }
   static address atomic_xchg_ptr_entry()                   { return _atomic_xchg_ptr_entry; }
   static address atomic_store_entry()                      { return _atomic_store_entry; }
@@ -390,11 +388,14 @@
 
   static address dexp()                { return _dexp; }
   static address dlog()                { return _dlog; }
+  static address dlog10()                { return _dlog10; }
   static address dpow()                { return _dpow; }
   static address dsin()                { return _dsin; }
   static address dcos()                { return _dcos; }
   static address dlibm_reduce_pi04l()  { return _dlibm_reduce_pi04l; }
   static address dlibm_sin_cos_huge()  { return _dlibm_sin_cos_huge; }
+  static address dlibm_tan_cot_huge()  { return _dlibm_tan_cot_huge; }
+  static address dtan()                { return _dtan; }
 
   static address select_fill_function(BasicType t, bool aligned, const char* &name);
 
diff --git a/hotspot/src/share/vm/runtime/sweeper.cpp b/hotspot/src/share/vm/runtime/sweeper.cpp
index 3bd5a0f..16cf5cd 100644
--- a/hotspot/src/share/vm/runtime/sweeper.cpp
+++ b/hotspot/src/share/vm/runtime/sweeper.cpp
@@ -109,13 +109,13 @@
   }
 }
 
-void NMethodSweeper::record_sweep(nmethod* nm, int line) {
+void NMethodSweeper::record_sweep(CompiledMethod* nm, int line) {
   if (_records != NULL) {
     _records[_sweep_index].traversal = _traversals;
-    _records[_sweep_index].traversal_mark = nm->_stack_traversal_mark;
+    _records[_sweep_index].traversal_mark = nm->is_nmethod() ? ((nmethod*)nm)->_stack_traversal_mark : 0;
     _records[_sweep_index].compile_id = nm->compile_id();
     _records[_sweep_index].kind = nm->compile_kind();
-    _records[_sweep_index].state = nm->_state;
+    _records[_sweep_index].state = nm->get_state();
     _records[_sweep_index].vep = nm->verified_entry_point();
     _records[_sweep_index].uep = nm->entry_point();
     _records[_sweep_index].line = line;
@@ -134,7 +134,7 @@
 #define SWEEP(nm)
 #endif
 
-NMethodIterator NMethodSweeper::_current;                      // Current nmethod
+CompiledMethodIterator NMethodSweeper::_current;               // Current compiled method
 long     NMethodSweeper::_traversals                   = 0;    // Stack scan count, also sweep ID.
 long     NMethodSweeper::_total_nof_code_cache_sweeps  = 0;    // Total number of full sweeps of the code cache
 long     NMethodSweeper::_time_counter                 = 0;    // Virtual time used to periodically invoke sweeper
@@ -210,10 +210,17 @@
   _time_counter++;
 
   // Check for restart
-  assert(CodeCache::find_blob_unsafe(_current.method()) == _current.method(), "Sweeper nmethod cached state invalid");
+  if (_current.method() != NULL) {
+    if (_current.method()->is_nmethod()) {
+      assert(CodeCache::find_blob_unsafe(_current.method()) == _current.method(), "Sweeper nmethod cached state invalid");
+    } else {
+      ShouldNotReachHere();
+    }
+  }
+
   if (wait_for_stack_scanning()) {
     _seen = 0;
-    _current = NMethodIterator();
+    _current = CompiledMethodIterator();
     // Initialize to first nmethod
     _current.next();
     _traversals += 1;
@@ -415,14 +422,15 @@
       // Since we will give up the CodeCache_lock, always skip ahead
       // to the next nmethod.  Other blobs can be deleted by other
       // threads but nmethods are only reclaimed by the sweeper.
-      nmethod* nm = _current.method();
+      CompiledMethod* nm = _current.method();
       _current.next();
 
       // Now ready to process nmethod and give up CodeCache_lock
       {
         MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
         // Save information before potentially flushing the nmethod
-        int size = nm->total_size();
+        // Only flushing nmethods so size only matters for them.
+        int size = nm->is_nmethod() ? ((nmethod*)nm)->total_size() : 0;
         bool is_c2_method = nm->is_compiled_by_c2();
         bool is_osr = nm->is_osr_method();
         int compile_id = nm->compile_id();
@@ -430,7 +438,7 @@
         const char* state_before = nm->state();
         const char* state_after = "";
 
-        MethodStateChange type = process_nmethod(nm);
+        MethodStateChange type = process_compiled_method(nm);
         switch (type) {
           case Flushed:
             state_after = "flushed";
@@ -532,28 +540,28 @@
   }
 }
 
-class NMethodMarker: public StackObj {
+class CompiledMethodMarker: public StackObj {
  private:
   CodeCacheSweeperThread* _thread;
  public:
-  NMethodMarker(nmethod* nm) {
+  CompiledMethodMarker(CompiledMethod* cm) {
     JavaThread* current = JavaThread::current();
     assert (current->is_Code_cache_sweeper_thread(), "Must be");
     _thread = (CodeCacheSweeperThread*)current;
-    if (!nm->is_zombie() && !nm->is_unloaded()) {
+    if (!cm->is_zombie() && !cm->is_unloaded()) {
       // Only expose live nmethods for scanning
-      _thread->set_scanned_nmethod(nm);
+      _thread->set_scanned_compiled_method(cm);
     }
   }
-  ~NMethodMarker() {
-    _thread->set_scanned_nmethod(NULL);
+  ~CompiledMethodMarker() {
+    _thread->set_scanned_compiled_method(NULL);
   }
 };
 
-void NMethodSweeper::release_nmethod(nmethod* nm) {
+void NMethodSweeper::release_compiled_method(CompiledMethod* nm) {
   // Make sure the released nmethod is no longer referenced by the sweeper thread
   CodeCacheSweeperThread* thread = (CodeCacheSweeperThread*)JavaThread::current();
-  thread->set_scanned_nmethod(NULL);
+  thread->set_scanned_compiled_method(NULL);
 
   // Clean up any CompiledICHolders
   {
@@ -571,98 +579,100 @@
   nm->flush();
 }
 
-NMethodSweeper::MethodStateChange NMethodSweeper::process_nmethod(nmethod* nm) {
-  assert(nm != NULL, "sanity");
+NMethodSweeper::MethodStateChange NMethodSweeper::process_compiled_method(CompiledMethod* cm) {
+  assert(cm != NULL, "sanity");
   assert(!CodeCache_lock->owned_by_self(), "just checking");
 
   MethodStateChange result = None;
   // Make sure this nmethod doesn't get unloaded during the scan,
   // since safepoints may happen during acquired below locks.
-  NMethodMarker nmm(nm);
-  SWEEP(nm);
+  CompiledMethodMarker nmm(cm);
+  SWEEP(cm);
 
   // Skip methods that are currently referenced by the VM
-  if (nm->is_locked_by_vm()) {
+  if (cm->is_locked_by_vm()) {
     // But still remember to clean-up inline caches for alive nmethods
-    if (nm->is_alive()) {
+    if (cm->is_alive()) {
       // Clean inline caches that point to zombie/non-entrant/unloaded nmethods
       MutexLocker cl(CompiledIC_lock);
-      nm->cleanup_inline_caches();
-      SWEEP(nm);
+      cm->cleanup_inline_caches();
+      SWEEP(cm);
     }
     return result;
   }
 
-  if (nm->is_zombie()) {
+  if (cm->is_zombie()) {
     // All inline caches that referred to this nmethod were cleaned in the
     // previous sweeper cycle. Now flush the nmethod from the code cache.
-    assert(!nm->is_locked_by_vm(), "must not flush locked nmethods");
-    release_nmethod(nm);
+    assert(!cm->is_locked_by_vm(), "must not flush locked Compiled Methods");
+    release_compiled_method(cm);
     assert(result == None, "sanity");
     result = Flushed;
-  } else if (nm->is_not_entrant()) {
+  } else if (cm->is_not_entrant()) {
     // If there are no current activations of this method on the
     // stack we can safely convert it to a zombie method
-    if (nm->can_convert_to_zombie()) {
+    if (cm->can_convert_to_zombie()) {
       // Clear ICStubs to prevent back patching stubs of zombie or flushed
       // nmethods during the next safepoint (see ICStub::finalize).
       {
         MutexLocker cl(CompiledIC_lock);
-        nm->clear_ic_stubs();
+        cm->clear_ic_stubs();
       }
       // Code cache state change is tracked in make_zombie()
-      nm->make_zombie();
-      SWEEP(nm);
+      cm->make_zombie();
+      SWEEP(cm);
       // The nmethod may have been locked by JVMTI after being made zombie (see
       // JvmtiDeferredEvent::compiled_method_unload_event()). If so, we cannot
       // flush the osr nmethod directly but have to wait for a later sweeper cycle.
-      if (nm->is_osr_method() && !nm->is_locked_by_vm()) {
+      if (cm->is_osr_method() && !cm->is_locked_by_vm()) {
         // No inline caches will ever point to osr methods, so we can just remove it.
         // Make sure that we unregistered the nmethod with the heap and flushed all
         // dependencies before removing the nmethod (done in make_zombie()).
-        assert(nm->is_zombie(), "nmethod must be unregistered");
-        release_nmethod(nm);
+        assert(cm->is_zombie(), "nmethod must be unregistered");
+        release_compiled_method(cm);
         assert(result == None, "sanity");
         result = Flushed;
       } else {
         assert(result == None, "sanity");
         result = MadeZombie;
-        assert(nm->is_zombie(), "nmethod must be zombie");
+        assert(cm->is_zombie(), "nmethod must be zombie");
       }
     } else {
       // Still alive, clean up its inline caches
       MutexLocker cl(CompiledIC_lock);
-      nm->cleanup_inline_caches();
-      SWEEP(nm);
+      cm->cleanup_inline_caches();
+      SWEEP(cm);
     }
-  } else if (nm->is_unloaded()) {
+  } else if (cm->is_unloaded()) {
     // Code is unloaded, so there are no activations on the stack.
     // Convert the nmethod to zombie or flush it directly in the OSR case.
     {
       // Clean ICs of unloaded nmethods as well because they may reference other
       // unloaded nmethods that may be flushed earlier in the sweeper cycle.
       MutexLocker cl(CompiledIC_lock);
-      nm->cleanup_inline_caches();
+      cm->cleanup_inline_caches();
     }
-    if (nm->is_osr_method()) {
-      SWEEP(nm);
+    if (cm->is_osr_method()) {
+      SWEEP(cm);
       // No inline caches will ever point to osr methods, so we can just remove it
-      release_nmethod(nm);
+      release_compiled_method(cm);
       assert(result == None, "sanity");
       result = Flushed;
     } else {
       // Code cache state change is tracked in make_zombie()
-      nm->make_zombie();
-      SWEEP(nm);
+      cm->make_zombie();
+      SWEEP(cm);
       assert(result == None, "sanity");
       result = MadeZombie;
     }
   } else {
-    possibly_flush(nm);
+    if (cm->is_nmethod()) {
+      possibly_flush((nmethod*)cm);
+    }
     // Clean inline caches that point to zombie/non-entrant/unloaded nmethods
     MutexLocker cl(CompiledIC_lock);
-    nm->cleanup_inline_caches();
-    SWEEP(nm);
+    cm->cleanup_inline_caches();
+    SWEEP(cm);
   }
   return result;
 }
diff --git a/hotspot/src/share/vm/runtime/sweeper.hpp b/hotspot/src/share/vm/runtime/sweeper.hpp
index eb29e7d..800e381 100644
--- a/hotspot/src/share/vm/runtime/sweeper.hpp
+++ b/hotspot/src/share/vm/runtime/sweeper.hpp
@@ -66,7 +66,7 @@
   static long      _total_nof_code_cache_sweeps;  // Total number of full sweeps of the code cache
   static long      _time_counter;                 // Virtual time used to periodically invoke sweeper
   static long      _last_sweep;                   // Value of _time_counter when the last sweep happened
-  static NMethodIterator _current;                // Current nmethod
+  static CompiledMethodIterator _current;         // Current compiled method
   static int       _seen;                         // Nof. nmethod we have currently processed in current pass of CodeCache
 
   static volatile int  _sweep_started;            // Flag to control conc sweeper
@@ -88,8 +88,8 @@
 
   static Monitor*  _stat_lock;
 
-  static MethodStateChange process_nmethod(nmethod *nm);
-  static void              release_nmethod(nmethod* nm);
+  static MethodStateChange process_compiled_method(CompiledMethod *nm);
+  static void              release_compiled_method(CompiledMethod* nm);
 
   static void init_sweeper_log() NOT_DEBUG_RETURN;
   static bool wait_for_stack_scanning();
@@ -107,9 +107,8 @@
 
 
 #ifdef ASSERT
-  static bool is_sweeping(nmethod* which) { return _current.method() == which; }
   // Keep track of sweeper activity in the ring buffer
-  static void record_sweep(nmethod* nm, int line);
+  static void record_sweep(CompiledMethod* nm, int line);
   static void report_events(int id, address entry);
   static void report_events();
 #endif
diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp
index 719eb74..6c6bb68 100644
--- a/hotspot/src/share/vm/runtime/thread.cpp
+++ b/hotspot/src/share/vm/runtime/thread.cpp
@@ -60,6 +60,7 @@
 #include "runtime/atomic.inline.hpp"
 #include "runtime/biasedLocking.hpp"
 #include "runtime/commandLineFlagConstraintList.hpp"
+#include "runtime/commandLineFlagWriteableList.hpp"
 #include "runtime/commandLineFlagRangeList.hpp"
 #include "runtime/deoptimization.hpp"
 #include "runtime/fprofiler.hpp"
@@ -785,7 +786,7 @@
   return false;
 }
 
-void Thread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
+void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
   active_handles()->oops_do(f);
   // Do oop for ThreadShadow
   f->do_oop((oop*)&_pending_exception);
@@ -1432,7 +1433,7 @@
   set_vframe_array_last(NULL);
   set_deferred_locals(NULL);
   set_deopt_mark(NULL);
-  set_deopt_nmethod(NULL);
+  set_deopt_compiled_method(NULL);
   clear_must_deopt_id();
   set_monitor_chunks(NULL);
   set_next(NULL);
@@ -2758,7 +2759,7 @@
   }
 };
 
-void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
+void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
   // Verify that the deferred card marks have been flushed.
   assert(deferred_card_mark().is_empty(), "Should be empty during GC");
 
@@ -2766,7 +2767,7 @@
   // since there may be more than one thread using each ThreadProfiler.
 
   // Traverse the GCHandles
-  Thread::oops_do(f, cld_f, cf);
+  Thread::oops_do(f, cf);
 
   JVMCI_ONLY(f->do_oop((oop*)&_pending_failed_speculation);)
 
@@ -2796,7 +2797,7 @@
 
     // Traverse the execution stack
     for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
-      fst.current()->oops_do(f, cld_f, cf, fst.register_map());
+      fst.current()->oops_do(f, cf, fst.register_map());
     }
   }
 
@@ -2946,7 +2947,7 @@
 
 void JavaThread::verify() {
   // Verify oops in the thread.
-  oops_do(&VerifyOopClosure::verify_oop, NULL, NULL);
+  oops_do(&VerifyOopClosure::verify_oop, NULL);
 
   // Verify the stack frames.
   frames_do(frame_verify);
@@ -3186,7 +3187,7 @@
 static void oops_print(frame* f, const RegisterMap *map) {
   PrintAndVerifyOopClosure print;
   f->print_value();
-  f->oops_do(&print, NULL, NULL, (RegisterMap*)map);
+  f->oops_do(&print, NULL, (RegisterMap*)map);
 }
 
 // Print our all the locations that contain oops and whether they are
@@ -3300,26 +3301,26 @@
 // Create sweeper thread
 CodeCacheSweeperThread::CodeCacheSweeperThread()
 : JavaThread(&sweeper_thread_entry) {
-  _scanned_nmethod = NULL;
+  _scanned_compiled_method = NULL;
 }
 
-void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
-  JavaThread::oops_do(f, cld_f, cf);
-  if (_scanned_nmethod != NULL && cf != NULL) {
+void CodeCacheSweeperThread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
+  JavaThread::oops_do(f, cf);
+  if (_scanned_compiled_method != NULL && cf != NULL) {
     // Safepoints can occur when the sweeper is scanning an nmethod so
     // process it here to make sure it isn't unloaded in the middle of
     // a scan.
-    cf->do_code_blob(_scanned_nmethod);
+    cf->do_code_blob(_scanned_compiled_method);
   }
 }
 
 void CodeCacheSweeperThread::nmethods_do(CodeBlobClosure* cf) {
   JavaThread::nmethods_do(cf);
-  if (_scanned_nmethod != NULL && cf != NULL) {
+  if (_scanned_compiled_method != NULL && cf != NULL) {
     // Safepoints can occur when the sweeper is scanning an nmethod so
     // process it here to make sure it isn't unloaded in the middle of
     // a scan.
-    cf->do_code_blob(_scanned_nmethod);
+    cf->do_code_blob(_scanned_compiled_method);
   }
 }
 
@@ -3544,6 +3545,8 @@
     return JNI_EINVAL;
   }
 
+  CommandLineFlagWriteableList::mark_startup();
+
   if (PauseAtStartup) {
     os::pause();
   }
@@ -4291,11 +4294,11 @@
 // uses the Threads_lock to guarantee this property. It also makes sure that
 // all threads gets blocked when exiting or starting).
 
-void Threads::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
+void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) {
   ALL_JAVA_THREADS(p) {
-    p->oops_do(f, cld_f, cf);
+    p->oops_do(f, cf);
   }
-  VMThread::vm_thread()->oops_do(f, cld_f, cf);
+  VMThread::vm_thread()->oops_do(f, cf);
 }
 
 void Threads::change_thread_claim_parity() {
@@ -4318,16 +4321,16 @@
 }
 #endif // ASSERT
 
-void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
+void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf) {
   int cp = Threads::thread_claim_parity();
   ALL_JAVA_THREADS(p) {
     if (p->claim_oops_do(is_par, cp)) {
-      p->oops_do(f, cld_f, cf);
+      p->oops_do(f, cf);
     }
   }
   VMThread* vmt = VMThread::vm_thread();
   if (vmt->claim_oops_do(is_par, cp)) {
-    vmt->oops_do(f, cld_f, cf);
+    vmt->oops_do(f, cf);
   }
 }
 
@@ -4353,7 +4356,7 @@
   ALL_JAVA_THREADS(p) {
     // This is used by the code cache sweeper to mark nmethods that are active
     // on the stack of a Java thread. Ignore the sweeper thread itself to avoid
-    // marking CodeCacheSweeperThread::_scanned_nmethod as active.
+    // marking CodeCacheSweeperThread::_scanned_compiled_method as active.
     if(!p->is_Code_cache_sweeper_thread()) {
       p->nmethods_do(cf);
     }
diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp
index f5d7ac5..2b81b31 100644
--- a/hotspot/src/share/vm/runtime/thread.hpp
+++ b/hotspot/src/share/vm/runtime/thread.hpp
@@ -96,6 +96,7 @@
 //       - GangWorker
 //       - GCTaskThread
 //   - JavaThread
+//     - various subclasses eg CompilerThread, ServiceThread
 //   - WatcherThread
 
 class Thread: public ThreadShadow {
@@ -314,8 +315,7 @@
 
   // Manage Thread::current()
   void initialize_thread_current();
-  private:
-  void clear_thread_current(); // needed for detaching JNI threads
+  void clear_thread_current(); // TLS cleanup needed before threads terminate
 
   public:
   // thread entry point
@@ -482,10 +482,9 @@
 
   // GC support
   // Apply "f->do_oop" to all root oops in "this".
-  // Apply "cld_f->do_cld" to CLDs that are otherwise not kept alive.
   //   Used by JavaThread::oops_do.
   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
-  virtual void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
+  virtual void oops_do(OopClosure* f, CodeBlobClosure* cf);
 
   // Handles the parallel case for the method below.
  private:
@@ -744,6 +743,11 @@
   // Constructor
   WatcherThread();
 
+  // No destruction allowed
+  ~WatcherThread() {
+    guarantee(false, "WatcherThread deletion must fix the race with VM termination");
+  }
+
   // Tester
   bool is_Watcher_thread() const                 { return true; }
 
@@ -820,7 +824,7 @@
 
   intptr_t*      _must_deopt_id;                 // id of frame that needs to be deopted once we
                                                  // transition out of native
-  nmethod*       _deopt_nmethod;                 // nmethod that is currently being deoptimized
+  CompiledMethod*       _deopt_nmethod;         // CompiledMethod that is currently being deoptimized
   vframeArray*  _vframe_array_head;              // Holds the heap of the active vframeArrays
   vframeArray*  _vframe_array_last;              // Holds last vFrameArray we popped
   // Because deoptimization is lazy we must save jvmti requests to set locals
@@ -1298,8 +1302,8 @@
   void     set_must_deopt_id(intptr_t* id)       { _must_deopt_id = id; }
   void     clear_must_deopt_id()                 { _must_deopt_id = NULL; }
 
-  void set_deopt_nmethod(nmethod* nm)            { _deopt_nmethod = nm;   }
-  nmethod* deopt_nmethod()                       { return _deopt_nmethod; }
+  void set_deopt_compiled_method(CompiledMethod* nm)  { _deopt_nmethod = nm; }
+  CompiledMethod* deopt_compiled_method()        { return _deopt_nmethod; }
 
   Method*    callee_target() const               { return _callee_target; }
   void set_callee_target  (Method* x)          { _callee_target   = x; }
@@ -1642,7 +1646,7 @@
   void frames_do(void f(frame*, const RegisterMap*));
 
   // Memory operations
-  void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
+  void oops_do(OopClosure* f, CodeBlobClosure* cf);
 
   // Sweeper operations
   virtual void nmethods_do(CodeBlobClosure* cf);
@@ -1980,13 +1984,13 @@
 
 // Dedicated thread to sweep the code cache
 class CodeCacheSweeperThread : public JavaThread {
-  nmethod*       _scanned_nmethod; // nmethod being scanned by the sweeper
+  CompiledMethod*       _scanned_compiled_method; // nmethod being scanned by the sweeper
  public:
   CodeCacheSweeperThread();
   // Track the nmethod currently being scanned by the sweeper
-  void set_scanned_nmethod(nmethod* nm) {
-    assert(_scanned_nmethod == NULL || nm == NULL, "should reset to NULL before writing a new value");
-    _scanned_nmethod = nm;
+  void set_scanned_compiled_method(CompiledMethod* cm) {
+    assert(_scanned_compiled_method == NULL || cm == NULL, "should reset to NULL before writing a new value");
+    _scanned_compiled_method = cm;
   }
 
   // Hide sweeper thread from external view.
@@ -1994,8 +1998,8 @@
 
   bool is_Code_cache_sweeper_thread() const { return true; }
 
-  // Prevent GC from unloading _scanned_nmethod
-  void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
+  // Prevent GC from unloading _scanned_compiled_method
+  void oops_do(OopClosure* f, CodeBlobClosure* cf);
   void nmethods_do(CodeBlobClosure* cf);
 };
 
@@ -2122,9 +2126,9 @@
 
   // Apply "f->do_oop" to all root oops in all threads.
   // This version may only be called by sequential code.
-  static void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
+  static void oops_do(OopClosure* f, CodeBlobClosure* cf);
   // This version may be called by sequential or parallel code.
-  static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
+  static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf);
   // This creates a list of GCTasks, one per thread.
   static void create_thread_roots_tasks(GCTaskQueue* q);
   // This creates a list of GCTasks, one per thread, for marking objects.
diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp
index 2716deb..7d9a7b3 100644
--- a/hotspot/src/share/vm/runtime/vframe.cpp
+++ b/hotspot/src/share/vm/runtime/vframe.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,8 +67,8 @@
   // Compiled frame
   CodeBlob* cb = f->cb();
   if (cb != NULL) {
-    if (cb->is_nmethod()) {
-      nmethod* nm = (nmethod*)cb;
+    if (cb->is_compiled()) {
+      CompiledMethod* nm = (CompiledMethod*)cb;
       return new compiledVFrame(f, reg_map, thread, nm);
     }
 
diff --git a/hotspot/src/share/vm/runtime/vframe.hpp b/hotspot/src/share/vm/runtime/vframe.hpp
index dde2f24..de7d510 100644
--- a/hotspot/src/share/vm/runtime/vframe.hpp
+++ b/hotspot/src/share/vm/runtime/vframe.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,9 +66,9 @@
   // Accessors
   frame              fr()           const { return _fr;       }
   CodeBlob*          cb()         const { return _fr.cb();  }
-  nmethod*           nm()         const {
-      assert( cb() != NULL && cb()->is_nmethod(), "usage");
-      return (nmethod*) cb();
+  CompiledMethod*   nm()         const {
+      assert( cb() != NULL && cb()->is_compiled(), "usage");
+      return (CompiledMethod*) cb();
   }
 
 // ???? Does this need to be a copy?
@@ -317,18 +317,10 @@
   intptr_t* frame_id() const { return _frame.id(); }
   address frame_pc() const { return _frame.pc(); }
 
-  javaVFrame* java_frame() {
-    vframe* vf = vframe::new_vframe(&_frame, &_reg_map, _thread);
-    if (vf->is_java_frame()) {
-      return (javaVFrame*)vf;
-    }
-    return NULL;
-  }
-
   CodeBlob*          cb()         const { return _frame.cb();  }
-  nmethod*           nm()         const {
-    assert( cb() != NULL && cb()->is_nmethod(), "usage");
-    return (nmethod*) cb();
+  CompiledMethod*   nm()         const {
+      assert( cb() != NULL && cb()->is_compiled(), "usage");
+      return (CompiledMethod*) cb();
   }
 
   // Frame type
@@ -449,7 +441,7 @@
 
   // Compiled frame
 
-  if (cb() != NULL && cb()->is_nmethod()) {
+  if (cb() != NULL && cb()->is_compiled()) {
     if (nm()->is_native_method()) {
       // Do not rely on scopeDesc since the pc might be unprecise due to the _last_native_pc trick.
       fill_from_compiled_native_frame();
diff --git a/hotspot/src/share/vm/runtime/vframeArray.cpp b/hotspot/src/share/vm/runtime/vframeArray.cpp
index 29be4e4..4834732 100644
--- a/hotspot/src/share/vm/runtime/vframeArray.cpp
+++ b/hotspot/src/share/vm/runtime/vframeArray.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -206,8 +206,8 @@
   // in which case bcp should point to the monitorenter since it is within the exception's range.
 
   assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame");
-  assert(thread->deopt_nmethod() != NULL, "nmethod should be known");
-  guarantee(!(thread->deopt_nmethod()->is_compiled_by_c2() &&
+  assert(thread->deopt_compiled_method() != NULL, "compiled method should be known");
+  guarantee(!(thread->deopt_compiled_method()->is_compiled_by_c2() &&
               *bcp == Bytecodes::_monitorenter             &&
               exec_mode == Deoptimization::Unpack_exception),
             "shouldn't get exception during monitorenter");
diff --git a/hotspot/src/share/vm/runtime/vframe_hp.cpp b/hotspot/src/share/vm/runtime/vframe_hp.cpp
index 45617d0..168deb0 100644
--- a/hotspot/src/share/vm/runtime/vframe_hp.cpp
+++ b/hotspot/src/share/vm/runtime/vframe_hp.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -196,7 +196,7 @@
 GrowableArray<MonitorInfo*>* compiledVFrame::monitors() const {
   // Natives has no scope
   if (scope() == NULL) {
-    nmethod* nm = code();
+    CompiledMethod* nm = code();
     Method* method = nm->method();
     assert(method->is_native(), "");
     if (!method->is_synchronized()) {
@@ -240,13 +240,13 @@
 }
 
 
-compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm)
+compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, CompiledMethod* nm)
 : javaVFrame(fr, reg_map, thread) {
   _scope  = NULL;
   // Compiled method (native stub or Java code)
   // native wrappers have no scope data, it is implied
-  if (!nm->is_native_method()) {
-    _scope  = nm->scope_desc_at(_fr.pc());
+  if (!nm->is_compiled() || !nm->as_compiled_method()->is_native_method()) {
+      _scope  = nm->scope_desc_at(_fr.pc());
   }
 }
 
@@ -264,15 +264,15 @@
 }
 
 
-nmethod* compiledVFrame::code() const {
-  return CodeCache::find_nmethod(_fr.pc());
+CompiledMethod* compiledVFrame::code() const {
+  return CodeCache::find_compiled(_fr.pc());
 }
 
 
 Method* compiledVFrame::method() const {
   if (scope() == NULL) {
     // native nmethods have no scope the method is implied
-    nmethod* nm = code();
+    nmethod* nm = code()->as_nmethod();
     assert(nm->is_native_method(), "must be native");
     return nm->method();
   }
@@ -289,7 +289,7 @@
 int compiledVFrame::raw_bci() const {
   if (scope() == NULL) {
     // native nmethods have no scope the method/bci is implied
-    nmethod* nm = code();
+    nmethod* nm = code()->as_nmethod();
     assert(nm->is_native_method(), "must be native");
     return 0;
   }
@@ -299,7 +299,7 @@
 bool compiledVFrame::should_reexecute() const {
   if (scope() == NULL) {
     // native nmethods have no scope the method/bci is implied
-    nmethod* nm = code();
+    nmethod* nm = code()->as_nmethod();
     assert(nm->is_native_method(), "must be native");
     return false;
   }
@@ -310,7 +310,7 @@
   const frame f = fr();
   if (scope() == NULL) {
     // native nmethods have no scope the method/bci is implied
-    nmethod* nm = code();
+    nmethod* nm = code()->as_nmethod();
     assert(nm->is_native_method(), "must be native");
     return vframe::sender();
   } else {
diff --git a/hotspot/src/share/vm/runtime/vframe_hp.hpp b/hotspot/src/share/vm/runtime/vframe_hp.hpp
index 21ec69e..c3be6c2 100644
--- a/hotspot/src/share/vm/runtime/vframe_hp.hpp
+++ b/hotspot/src/share/vm/runtime/vframe_hp.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,13 +52,13 @@
 
  public:
   // Constructors
-  compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm);
+  compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, CompiledMethod* nm);
 
   // Update a local in a compiled frame. Update happens when deopt occurs
   void update_local(BasicType type, int index, jvalue value);
 
   // Returns the active nmethod
-  nmethod*  code() const;
+  CompiledMethod*  code() const;
 
   // Returns the scopeDesc
   ScopeDesc* scope() const { return _scope; }
diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp
index 3cd5d16..dab3dbb 100644
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp
@@ -337,7 +337,7 @@
   volatile_nonstatic_field(InstanceKlass,      _oop_map_cache,                                OopMapCache*)                          \
   nonstatic_field(InstanceKlass,               _jni_ids,                                      JNIid*)                                \
   nonstatic_field(InstanceKlass,               _osr_nmethods_head,                            nmethod*)                              \
-  nonstatic_field(InstanceKlass,               _breakpoints,                                  BreakpointInfo*)                       \
+  JVMTI_ONLY(nonstatic_field(InstanceKlass,    _breakpoints,                                  BreakpointInfo*))                      \
   nonstatic_field(InstanceKlass,               _generic_signature_index,                      u2)                                    \
   nonstatic_field(InstanceKlass,               _methods_jmethod_ids,                          jmethodID*)                            \
   volatile_nonstatic_field(InstanceKlass,      _idnum_allocated_count,                        u2)                                    \
@@ -387,7 +387,7 @@
   nonstatic_field(MethodCounters,              _backedge_mask,                                int)                                   \
   COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_invocation_count,   int))                                  \
   COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_throwout_count,     u2))                                   \
-  nonstatic_field(MethodCounters,              _number_of_breakpoints,                        u2)                                    \
+  JVMTI_ONLY(nonstatic_field(MethodCounters,   _number_of_breakpoints,                        u2))                                   \
   nonstatic_field(MethodCounters,              _invocation_counter,                           InvocationCounter)                     \
   nonstatic_field(MethodCounters,              _backedge_counter,                             InvocationCounter)                     \
   nonstatic_field(Method,                      _constMethod,                                  ConstMethod*)                          \
@@ -398,7 +398,7 @@
   nonstatic_field(Method,                      _intrinsic_id,                                 u2)                                    \
   nonstatic_field(Method,                      _flags,                                        u2)                                    \
   nonproduct_nonstatic_field(Method,           _compiled_invocation_count,                    int)                                   \
-  volatile_nonstatic_field(Method,             _code,                                         nmethod*)                              \
+  volatile_nonstatic_field(Method,             _code,                                         CompiledMethod*)                       \
   nonstatic_field(Method,                      _i2i_entry,                                    address)                               \
   volatile_nonstatic_field(Method,             _from_compiled_entry,                          address)                               \
   volatile_nonstatic_field(Method,             _from_interpreted_entry,                       address)                               \
@@ -447,11 +447,11 @@
   nonstatic_field(ExceptionTableElement,       end_pc,                                        u2)                                    \
   nonstatic_field(ExceptionTableElement,       handler_pc,                                    u2)                                    \
   nonstatic_field(ExceptionTableElement,       catch_type_index,                              u2)                                    \
-  nonstatic_field(BreakpointInfo,              _orig_bytecode,                                Bytecodes::Code)                       \
-  nonstatic_field(BreakpointInfo,              _bci,                                          int)                                   \
-  nonstatic_field(BreakpointInfo,              _name_index,                                   u2)                                    \
-  nonstatic_field(BreakpointInfo,              _signature_index,                              u2)                                    \
-  nonstatic_field(BreakpointInfo,              _next,                                         BreakpointInfo*)                       \
+  JVMTI_ONLY(nonstatic_field(BreakpointInfo,   _orig_bytecode,                                Bytecodes::Code))                      \
+  JVMTI_ONLY(nonstatic_field(BreakpointInfo,   _bci,                                          int))                                  \
+  JVMTI_ONLY(nonstatic_field(BreakpointInfo,   _name_index,                                   u2))                                   \
+  JVMTI_ONLY(nonstatic_field(BreakpointInfo,   _signature_index,                              u2))                                   \
+  JVMTI_ONLY(nonstatic_field(BreakpointInfo,   _next,                                         BreakpointInfo*))                      \
   /***********/                                                                                                                      \
   /* JNI IDs */                                                                                                                      \
   /***********/                                                                                                                      \
@@ -600,6 +600,7 @@
   nonstatic_field(ThreadLocalAllocBuffer,      _pf_top,                                       HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _desired_size,                                 size_t)                                \
   nonstatic_field(ThreadLocalAllocBuffer,      _refill_waste_limit,                           size_t)                                \
+     static_field(ThreadLocalAllocBuffer,      _reserve_for_allocation_prefetch,              int)                                   \
      static_field(ThreadLocalAllocBuffer,      _target_refills,                               unsigned)                              \
   nonstatic_field(ThreadLocalAllocBuffer,      _number_of_refills,                            unsigned)                              \
   nonstatic_field(ThreadLocalAllocBuffer,      _fast_refill_waste,                            unsigned)                              \
@@ -662,11 +663,11 @@
   /* CompactHashTable */                                                                                                             \
   /********************/                                                                                                             \
                                                                                                                                      \
-  nonstatic_field(SymbolCompactHashTable,      _base_address,                                 uintx)                                 \
-  nonstatic_field(SymbolCompactHashTable,      _entry_count,                                  juint)                                 \
-  nonstatic_field(SymbolCompactHashTable,      _bucket_count,                                 juint)                                 \
-  nonstatic_field(SymbolCompactHashTable,      _table_end_offset,                             juint)                                 \
-  nonstatic_field(SymbolCompactHashTable,      _buckets,                                      juint*)                                \
+  nonstatic_field(SymbolCompactHashTable,      _base_address,                                 address)                               \
+  nonstatic_field(SymbolCompactHashTable,      _entry_count,                                  u4)                                    \
+  nonstatic_field(SymbolCompactHashTable,      _bucket_count,                                 u4)                                    \
+  nonstatic_field(SymbolCompactHashTable,      _buckets,                                      u4*)                                   \
+  nonstatic_field(SymbolCompactHashTable,      _entries,                                      u4*)                                   \
                                                                                                                                      \
   /********************/                                                                                                             \
   /* SystemDictionary */                                                                                                             \
@@ -859,9 +860,11 @@
      static_field(StubRoutines,                _mulAdd,                                       address)                               \
      static_field(StubRoutines,                _dexp,                                         address)                               \
      static_field(StubRoutines,                _dlog,                                         address)                               \
+     static_field(StubRoutines,                _dlog10,                                       address)                               \
      static_field(StubRoutines,                _dpow,                                         address)                               \
      static_field(StubRoutines,                _dsin,                                         address)                               \
      static_field(StubRoutines,                _dcos,                                         address)                               \
+     static_field(StubRoutines,                _dtan,                                         address)                               \
      static_field(StubRoutines,                _vectorizedMismatch,                           address)                               \
      static_field(StubRoutines,                _jbyte_arraycopy,                              address)                               \
      static_field(StubRoutines,                _jshort_arraycopy,                             address)                               \
@@ -913,40 +916,47 @@
   /* CodeBlobs (NOTE: incomplete, but only a little) */                                                                              \
   /***************************************************/                                                                              \
                                                                                                                                      \
-  nonstatic_field(CodeBlob,                    _name,                                   const char*)                                 \
-  nonstatic_field(CodeBlob,                    _size,                                   int)                                         \
-  nonstatic_field(CodeBlob,                    _header_size,                            int)                                         \
-  nonstatic_field(CodeBlob,                    _relocation_size,                        int)                                         \
-  nonstatic_field(CodeBlob,                    _content_offset,                         int)                                         \
-  nonstatic_field(CodeBlob,                    _code_offset,                            int)                                         \
-  nonstatic_field(CodeBlob,                    _frame_complete_offset,                  int)                                         \
-  nonstatic_field(CodeBlob,                    _data_offset,                            int)                                         \
-  nonstatic_field(CodeBlob,                    _frame_size,                             int)                                         \
-  nonstatic_field(CodeBlob,                    _oop_maps,                               ImmutableOopMapSet*)                         \
+  nonstatic_field(CodeBlob,                 _name,                                   const char*)                                    \
+  nonstatic_field(CodeBlob,                 _size,                                   int)                                            \
+  nonstatic_field(CodeBlob,                 _header_size,                            int)                                            \
+  nonstatic_field(CodeBlob,                 _frame_complete_offset,                  int)                                            \
+  nonstatic_field(CodeBlob,                 _data_offset,                            int)                                            \
+  nonstatic_field(CodeBlob,                 _frame_size,                             int)                                            \
+  nonstatic_field(CodeBlob,                 _oop_maps,                               ImmutableOopMapSet*)                            \
+  nonstatic_field(CodeBlob,                 _code_begin,                             address)                                        \
+  nonstatic_field(CodeBlob,                 _code_end,                               address)                                        \
+  nonstatic_field(CodeBlob,                 _content_begin,                          address)                                        \
+  nonstatic_field(CodeBlob,                 _data_end,                               address)                                        \
                                                                                                                                      \
   nonstatic_field(DeoptimizationBlob,          _unpack_offset,                                int)                                   \
                                                                                                                                      \
   nonstatic_field(RuntimeStub,                 _caller_must_gc_arguments,                     bool)                                  \
                                                                                                                                      \
+  /********************************************************/                                                                         \
+  /* CompiledMethod (NOTE: incomplete, but only a little) */                                                                         \
+  /********************************************************/                                                                         \
+                                                                                                                                     \
+  nonstatic_field(CompiledMethod,                     _method,                                       Method*)                        \
+  volatile_nonstatic_field(CompiledMethod,            _exception_cache,                              ExceptionCache*)                \
+  nonstatic_field(CompiledMethod,                     _scopes_data_begin,                            address)                        \
+  nonstatic_field(CompiledMethod,                     _deopt_handler_begin,                          address)                        \
+  nonstatic_field(CompiledMethod,                     _deopt_mh_handler_begin,                       address)                        \
+                                                                                                                                     \
   /**************************************************/                                                                               \
   /* NMethods (NOTE: incomplete, but only a little) */                                                                               \
   /**************************************************/                                                                               \
                                                                                                                                      \
-  nonstatic_field(nmethod,                     _method,                                       Method*)                               \
   nonstatic_field(nmethod,                     _entry_bci,                                    int)                                   \
   nonstatic_field(nmethod,                     _osr_link,                                     nmethod*)                              \
   nonstatic_field(nmethod,                     _scavenge_root_link,                           nmethod*)                              \
   nonstatic_field(nmethod,                     _scavenge_root_state,                          jbyte)                                 \
   nonstatic_field(nmethod,                     _state,                                        volatile unsigned char)                \
   nonstatic_field(nmethod,                     _exception_offset,                             int)                                   \
-  nonstatic_field(nmethod,                     _deoptimize_offset,                            int)                                   \
-  nonstatic_field(nmethod,                     _deoptimize_mh_offset,                         int)                                   \
   nonstatic_field(nmethod,                     _orig_pc_offset,                               int)                                   \
   nonstatic_field(nmethod,                     _stub_offset,                                  int)                                   \
   nonstatic_field(nmethod,                     _consts_offset,                                int)                                   \
   nonstatic_field(nmethod,                     _oops_offset,                                  int)                                   \
   nonstatic_field(nmethod,                     _metadata_offset,                              int)                                   \
-  nonstatic_field(nmethod,                     _scopes_data_offset,                           int)                                   \
   nonstatic_field(nmethod,                     _scopes_pcs_offset,                            int)                                   \
   nonstatic_field(nmethod,                     _dependencies_offset,                          int)                                   \
   nonstatic_field(nmethod,                     _handler_table_offset,                         int)                                   \
@@ -959,7 +969,6 @@
   nonstatic_field(nmethod,                     _stack_traversal_mark,                         long)                                  \
   nonstatic_field(nmethod,                     _compile_id,                                   int)                                   \
   nonstatic_field(nmethod,                     _comp_level,                                   int)                                   \
-  nonstatic_field(nmethod,                     _exception_cache,                              ExceptionCache*)                       \
                                                                                                                                      \
   unchecked_c2_static_field(Deoptimization,    _trap_reason_name,                             void*)                                 \
                                                                                                                                      \
@@ -1316,7 +1325,6 @@
      static_field(Abstract_VM_Version,         _vm_minor_version,                             int)                                   \
      static_field(Abstract_VM_Version,         _vm_security_version,                          int)                                   \
      static_field(Abstract_VM_Version,         _vm_build_number,                              int)                                   \
-     static_field(Abstract_VM_Version,         _reserve_for_allocation_prefetch,              int)                                   \
                                                                                                                                      \
      static_field(JDK_Version,                 _current,                                      JDK_Version)                           \
   nonstatic_field(JDK_Version,                 _major,                                        unsigned char)                         \
@@ -1357,6 +1365,12 @@
      static_field(java_lang_Class,             _oop_size_offset,                              int)                                   \
      static_field(java_lang_Class,             _static_oop_field_count_offset,                int)                                   \
                                                                                                                                      \
+  /******************/                                                                                                               \
+  /* VMError fields */                                                                                                               \
+  /******************/                                                                                                               \
+                                                                                                                                     \
+     static_field(VMError,                     _thread,                                       Thread*)                               \
+                                                                                                                                     \
   /************************/                                                                                                         \
   /* Miscellaneous fields */                                                                                                         \
   /************************/                                                                                                         \
@@ -1586,7 +1600,6 @@
            declare_type(TenuredGeneration,            CardGeneration)     \
   declare_toplevel_type(GenCollectorPolicy)                               \
   declare_toplevel_type(Space)                                            \
-  declare_toplevel_type(BitMap)                                           \
            declare_type(CompactibleSpace,             Space)              \
            declare_type(ContiguousSpace,              CompactibleSpace)   \
            declare_type(OffsetTableContigSpace,       ContiguousSpace)    \
@@ -1742,16 +1755,18 @@
   declare_toplevel_type(SharedRuntime)                                    \
                                                                           \
   declare_toplevel_type(CodeBlob)                                         \
-  declare_type(BufferBlob,               CodeBlob)                        \
+  declare_type(RuntimeBlob,             CodeBlob)                        \
+  declare_type(BufferBlob,               RuntimeBlob)                    \
   declare_type(AdapterBlob,              BufferBlob)                      \
   declare_type(MethodHandlesAdapterBlob, BufferBlob)                      \
-  declare_type(nmethod,                  CodeBlob)                        \
-  declare_type(RuntimeStub,              CodeBlob)                        \
-  declare_type(SingletonBlob,            CodeBlob)                        \
+  declare_type(CompiledMethod,           CodeBlob)                        \
+  declare_type(nmethod,                  CompiledMethod)                  \
+  declare_type(RuntimeStub,              RuntimeBlob)                    \
+  declare_type(SingletonBlob,            RuntimeBlob)                    \
   declare_type(SafepointBlob,            SingletonBlob)                   \
   declare_type(DeoptimizationBlob,       SingletonBlob)                   \
   declare_c2_type(ExceptionBlob,         SingletonBlob)                   \
-  declare_c2_type(UncommonTrapBlob,      CodeBlob)                        \
+  declare_c2_type(UncommonTrapBlob,      RuntimeBlob)                        \
                                                                           \
   /***************************************/                               \
   /* PcDesc and other compiled code info */                               \
@@ -1920,6 +1935,7 @@
   declare_c2_type(ConvL2INode, Node)                                      \
   declare_c2_type(CastX2PNode, Node)                                      \
   declare_c2_type(CastP2XNode, Node)                                      \
+  declare_c2_type(SetVectMaskINode, Node)                                 \
   declare_c2_type(MemBarNode, MultiNode)                                  \
   declare_c2_type(MemBarAcquireNode, MemBarNode)                          \
   declare_c2_type(MemBarReleaseNode, MemBarNode)                          \
@@ -1927,6 +1943,7 @@
   declare_c2_type(StoreFenceNode, MemBarNode)                             \
   declare_c2_type(MemBarVolatileNode, MemBarNode)                         \
   declare_c2_type(MemBarCPUOrderNode, MemBarNode)                         \
+  declare_c2_type(OnSpinWaitNode, MemBarNode)                             \
   declare_c2_type(InitializeNode, MemBarNode)                             \
   declare_c2_type(ThreadLocalNode, Node)                                  \
   declare_c2_type(Opaque1Node, Node)                                      \
@@ -2066,10 +2083,8 @@
   declare_c2_type(NegNode, Node)                                          \
   declare_c2_type(NegFNode, NegNode)                                      \
   declare_c2_type(NegDNode, NegNode)                                      \
-  declare_c2_type(TanDNode, Node)                                         \
   declare_c2_type(AtanDNode, Node)                                        \
   declare_c2_type(SqrtDNode, Node)                                        \
-  declare_c2_type(Log10DNode, Node)                                       \
   declare_c2_type(ReverseBytesINode, Node)                                \
   declare_c2_type(ReverseBytesLNode, Node)                                \
   declare_c2_type(ReductionNode, Node)                                    \
@@ -2206,6 +2221,12 @@
                                                                           \
   declare_toplevel_type(Arguments)                                        \
                                                                           \
+  /***********/                                                           \
+  /* VMError */                                                           \
+  /***********/                                                           \
+                                                                          \
+  declare_toplevel_type(VMError)                                          \
+                                                                          \
   /***************/                                                       \
   /* Other types */                                                       \
   /***************/                                                       \
@@ -2228,12 +2249,16 @@
             declare_type(Array<Klass*>, MetaspaceObj)                     \
             declare_type(Array<Method*>, MetaspaceObj)                    \
                                                                           \
+   declare_toplevel_type(BitMap)                                          \
+            declare_type(BitMapView, BitMap)                              \
+                                                                          \
    declare_integer_type(AccessFlags)  /* FIXME: wrong type (not integer) */\
   declare_toplevel_type(address)      /* FIXME: should this be an integer type? */\
    declare_integer_type(BasicType)   /* FIXME: wrong type (not integer) */\
   declare_toplevel_type(BreakpointInfo)                                   \
   declare_toplevel_type(BreakpointInfo*)                                  \
   declare_toplevel_type(CodeBlob*)                                        \
+  declare_toplevel_type(RuntimeBlob*)                                     \
   declare_toplevel_type(CompressedWriteStream*)                           \
   declare_toplevel_type(ConstantPoolCacheEntry)                           \
   declare_toplevel_type(elapsedTimer)                                     \
diff --git a/hotspot/src/share/vm/runtime/vmThread.cpp b/hotspot/src/share/vm/runtime/vmThread.cpp
index 138431a..d7c0137 100644
--- a/hotspot/src/share/vm/runtime/vmThread.cpp
+++ b/hotspot/src/share/vm/runtime/vmThread.cpp
@@ -226,16 +226,12 @@
   }
 }
 
-
 VMThread::VMThread() : NamedThread() {
   set_name("VM Thread");
 }
 
 void VMThread::destroy() {
-  if (_vm_thread != NULL) {
-    delete _vm_thread;
-    _vm_thread = NULL;      // VM thread is gone
-  }
+  _vm_thread = NULL;      // VM thread is gone
 }
 
 void VMThread::run() {
@@ -308,9 +304,9 @@
     _terminate_lock->notify();
   }
 
-  // Deletion must be done synchronously by the JNI DestroyJavaVM thread
-  // so that the VMThread deletion completes before the main thread frees
-  // up the CodeHeap.
+  // We are now racing with the VM termination being carried out in
+  // another thread, so we don't "delete this". Numerous threads don't
+  // get deleted when the VM terminates
 
 }
 
@@ -655,8 +651,8 @@
 }
 
 
-void VMThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
-  Thread::oops_do(f, cld_f, cf);
+void VMThread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
+  Thread::oops_do(f, cf);
   _vm_queue->oops_do(f);
 }
 
@@ -688,5 +684,5 @@
 #endif
 
 void VMThread::verify() {
-  oops_do(&VerifyOopClosure::verify_oop, NULL, NULL);
+  oops_do(&VerifyOopClosure::verify_oop, NULL);
 }
diff --git a/hotspot/src/share/vm/runtime/vmThread.hpp b/hotspot/src/share/vm/runtime/vmThread.hpp
index 692fbdd..85c52cb 100644
--- a/hotspot/src/share/vm/runtime/vmThread.hpp
+++ b/hotspot/src/share/vm/runtime/vmThread.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -104,6 +104,12 @@
   // Constructor
   VMThread();
 
+  // No destruction allowed
+  ~VMThread() {
+    guarantee(false, "VMThread deletion must fix the race with VM termination");
+  }
+
+
   // Tester
   bool is_VM_thread() const                      { return true; }
   bool is_GC_thread() const                      { return true; }
@@ -126,7 +132,7 @@
   static VMThread* vm_thread()                    { return _vm_thread; }
 
   // GC support
-  void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
+  void oops_do(OopClosure* f, CodeBlobClosure* cf);
 
   void verify();
 
diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp
index c36098a..98e90d5 100644
--- a/hotspot/src/share/vm/runtime/vm_version.cpp
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp
@@ -43,7 +43,6 @@
 bool Abstract_VM_Version::_supports_atomic_getadd8 = false;
 unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;
 unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
-int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
 
 #ifndef HOTSPOT_VERSION_STRING
   #error HOTSPOT_VERSION_STRING must be defined
@@ -289,6 +288,7 @@
                                                       unsigned int switch_pt) {
   if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
     assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
+    unsigned int threads;
     // For very large machines, there are diminishing returns
     // for large numbers of worker threads.  Instead of
     // hogging the whole system, use a fraction of the workers for every
@@ -296,9 +296,20 @@
     // and a chosen fraction of 5/8
     // use 8 + (72 - 8) * (5/8) == 48 worker threads.
     unsigned int ncpus = (unsigned int) os::active_processor_count();
-    return (ncpus <= switch_pt) ?
-           ncpus :
-          (switch_pt + ((ncpus - switch_pt) * num) / den);
+    threads = (ncpus <= switch_pt) ?
+             ncpus :
+             (switch_pt + ((ncpus - switch_pt) * num) / den);
+#ifndef _LP64
+    // On 32-bit binaries the virtual address space available to the JVM
+    // is usually limited to 2-3 GB (depends on the platform).
+    // Do not use up address space with too many threads (stacks and per-thread
+    // data). Note that x86 apps running on Win64 have 2 stacks per thread.
+    // GC may more generally scale down threads by max heap size (etc), but the
+    // consequences of over-provisioning threads are higher on 32-bit JVMS,
+    // so add hard limit here:
+    threads = MIN2(threads, (2*switch_pt));
+#endif
+    return threads;
   } else {
     return ParallelGCThreads;
   }
diff --git a/hotspot/src/share/vm/runtime/vm_version.hpp b/hotspot/src/share/vm/runtime/vm_version.hpp
index 5d07fc7..a9e5733 100644
--- a/hotspot/src/share/vm/runtime/vm_version.hpp
+++ b/hotspot/src/share/vm/runtime/vm_version.hpp
@@ -57,7 +57,6 @@
   static int          _vm_build_number;
   static unsigned int _parallel_worker_threads;
   static bool         _parallel_worker_threads_initialized;
-  static int          _reserve_for_allocation_prefetch;
 
   static unsigned int nof_parallel_worker_threads(unsigned int num,
                                                   unsigned int dem,
@@ -139,12 +138,6 @@
     return _L1_data_cache_line_size;
   }
 
-  // Need a space at the end of TLAB for prefetch instructions
-  // which may fault when accessing memory outside of heap.
-  static int reserve_for_allocation_prefetch() {
-    return _reserve_for_allocation_prefetch;
-  }
-
   // ARCH specific policy for the BiasedLocking
   static bool use_biased_locking()  { return true; }
 
@@ -162,6 +155,9 @@
   // Calculates and returns the number of parallel threads.  May
   // be VM version specific.
   static unsigned int calc_parallel_worker_threads();
+
+  // Does this CPU support spin wait instruction?
+  static bool supports_on_spin_wait() { return false; }
 };
 
 #ifdef TARGET_ARCH_x86
diff --git a/hotspot/src/share/vm/services/classLoadingService.cpp b/hotspot/src/share/vm/services/classLoadingService.cpp
index 67bdb22..6d1f0cd 100644
--- a/hotspot/src/share/vm/services/classLoadingService.cpp
+++ b/hotspot/src/share/vm/services/classLoadingService.cpp
@@ -138,9 +138,9 @@
     }
   }
 
-  if (log_is_enabled(Info, classunload)) {
+  if (log_is_enabled(Info, class, unload)) {
     ResourceMark rm;
-    log_info(classunload)("unloading class %s " INTPTR_FORMAT , k->external_name(), p2i(k));
+    log_info(class, unload)("unloading class %s " INTPTR_FORMAT , k->external_name(), p2i(k));
   }
 }
 
@@ -184,9 +184,9 @@
   MutexLocker m(Management_lock);
   // verbose will be set to the previous value
   if (verbose) {
-    LogConfiguration::parse_log_arguments("stdout", "classload=info", NULL, NULL, NULL);
+    LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL);
   } else {
-    LogConfiguration::parse_log_arguments("stdout", "classload=off", NULL, NULL, NULL);
+    LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL);
   }
   reset_trace_class_unloading();
   return verbose;
@@ -197,9 +197,9 @@
   assert(Management_lock->owned_by_self(), "Must own the Management_lock");
   bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose();
   if (value) {
-    LogConfiguration::parse_log_arguments("stdout", "classunload=info", NULL, NULL, NULL);
+    LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL);
   } else {
-    LogConfiguration::parse_log_arguments("stdout", "classunload=off", NULL, NULL, NULL);
+    LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL);
   }
 }
 
diff --git a/hotspot/src/share/vm/services/classLoadingService.hpp b/hotspot/src/share/vm/services/classLoadingService.hpp
index 16ff40f..763abcc 100644
--- a/hotspot/src/share/vm/services/classLoadingService.hpp
+++ b/hotspot/src/share/vm/services/classLoadingService.hpp
@@ -55,7 +55,7 @@
 public:
   static void init();
 
-  static bool get_verbose() { return log_is_enabled(Info, classload); }
+  static bool get_verbose() { return log_is_enabled(Info, class, load); }
   static bool set_verbose(bool verbose);
   static void reset_trace_class_unloading() NOT_MANAGEMENT_RETURN;
 
diff --git a/hotspot/src/share/vm/services/g1MemoryPool.cpp b/hotspot/src/share/vm/services/g1MemoryPool.cpp
index 4932890..92daa7b 100644
--- a/hotspot/src/share/vm/services/g1MemoryPool.cpp
+++ b/hotspot/src/share/vm/services/g1MemoryPool.cpp
@@ -24,8 +24,6 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.hpp"
-#include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "services/g1MemoryPool.hpp"
 
diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp
index 6de924a..ff4da35 100644
--- a/hotspot/src/share/vm/services/management.cpp
+++ b/hotspot/src/share/vm/services/management.cpp
@@ -1609,8 +1609,8 @@
   }
   char* name = java_lang_String::as_utf8_string(fn);
 
-  FormatBuffer<80> err_msg("%s", "");
-  int succeed = WriteableFlags::set_flag(name, new_value, Flag::MANAGEMENT, err_msg);
+  FormatBuffer<80> error_msg("%s", "");
+  int succeed = WriteableFlags::set_flag(name, new_value, Flag::MANAGEMENT, error_msg);
 
   if (succeed != Flag::SUCCESS) {
     if (succeed == Flag::MISSING_VALUE) {
@@ -1619,7 +1619,7 @@
     } else {
       // all the other errors are reported as IAE with the appropriate error message
       THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-                err_msg.buffer());
+                error_msg.buffer());
     }
   }
   assert(succeed == Flag::SUCCESS, "Setting flag should succeed");
diff --git a/hotspot/src/share/vm/trace/trace.dtd b/hotspot/src/share/vm/trace/trace.dtd
index 155bea6..3c40dc9 100644
--- a/hotspot/src/share/vm/trace/trace.dtd
+++ b/hotspot/src/share/vm/trace/trace.dtd
@@ -64,23 +64,28 @@
                         has_stacktrace CDATA "false"
                         is_instant     CDATA "false"
                         is_constant    CDATA "false"
-                        is_requestable CDATA "false">
+                        is_requestable CDATA "false"
+                        experimental   CDATA "false">
 <!ATTLIST struct        id             CDATA #REQUIRED>
 <!ATTLIST value         type           CDATA #REQUIRED
                         field          CDATA #REQUIRED
                         label          CDATA #REQUIRED
                         description    CDATA #IMPLIED
                         relation       CDATA "NOT_AVAILABLE"
-                        transition     CDATA "NONE">
+                        transition     CDATA "NONE"
+                        experimental   CDATA "false">
 <!ATTLIST array         type           CDATA #REQUIRED
                         field          CDATA #REQUIRED
                         label          CDATA #REQUIRED
-                        description    CDATA #IMPLIED>
+                        description    CDATA #IMPLIED
+                        experimental   CDATA "false">
 <!ATTLIST structarray   type           CDATA #REQUIRED
                         field          CDATA #REQUIRED
                         label          CDATA #REQUIRED
-                        description    CDATA #IMPLIED>
+                        description    CDATA #IMPLIED
+                        experimental   CDATA "false">
 <!ATTLIST structvalue   type           CDATA #REQUIRED
                         field          CDATA #REQUIRED
                         label          CDATA #REQUIRED
-                        description    CDATA #IMPLIED>
+                        description    CDATA #IMPLIED
+                        experimental   CDATA "false">
diff --git a/hotspot/src/share/vm/utilities/array.cpp b/hotspot/src/share/vm/utilities/array.cpp
deleted file mode 100644
index 746f2a5..0000000
--- a/hotspot/src/share/vm/utilities/array.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
- * 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 "memory/resourceArea.hpp"
-#include "runtime/thread.inline.hpp"
-#include "utilities/array.hpp"
-
-
-#ifdef ASSERT
-void ResourceArray::init_nesting() {
-  _nesting = Thread::current()->resource_area()->nesting();
-}
-#endif
-
-
-void ResourceArray::sort(size_t esize, ftype f) {
-  if (!is_empty()) qsort(_data, length(), esize, f);
-}
-template <MEMFLAGS F> void CHeapArray<F>::sort(size_t esize, ftype f) {
-  if (!is_empty()) qsort(_data, length(), esize, f);
-}
-
-
-void ResourceArray::expand(size_t esize, int i, int& size) {
-  // make sure we are expanding within the original resource mark
-  assert(
-    _nesting == Thread::current()->resource_area()->nesting(),
-    "allocating outside original resource mark"
-  );
-  // determine new size
-  if (size == 0) size = 4; // prevent endless loop
-  while (i >= size) size *= 2;
-  // allocate and initialize new data section
-  void* data = resource_allocate_bytes(esize * size);
-  memcpy(data, _data, esize * length());
-  _data = data;
-}
-
-
-template <MEMFLAGS F> void CHeapArray<F>::expand(size_t esize, int i, int& size) {
-  // determine new size
-  if (size == 0) size = 4; // prevent endless loop
-  while (i >= size) size *= 2;
-  // allocate and initialize new data section
-  void* data = NEW_C_HEAP_ARRAY(char*, esize * size, F);
-  memcpy(data, _data, esize * length());
-  FREE_C_HEAP_ARRAY(char*, _data);
-  _data = data;
-}
-
-
-void ResourceArray::remove_at(size_t esize, int i) {
-  assert(0 <= i && i < length(), "index out of bounds");
-  _length--;
-  void* dst = (char*)_data + i*esize;
-  void* src = (char*)dst + esize;
-  size_t cnt = (length() - i)*esize;
-  memmove(dst, src, cnt);
-}
-
-template <MEMFLAGS F> void CHeapArray<F>::remove_at(size_t esize, int i) {
-  assert(0 <= i && i < length(), "index out of bounds");
-  _length--;
-  void* dst = (char*)_data + i*esize;
-  void* src = (char*)dst + esize;
-  size_t cnt = (length() - i)*esize;
-  memmove(dst, src, cnt);
-}
diff --git a/hotspot/src/share/vm/utilities/array.hpp b/hotspot/src/share/vm/utilities/array.hpp
index f759fe1..d174bee 100644
--- a/hotspot/src/share/vm/utilities/array.hpp
+++ b/hotspot/src/share/vm/utilities/array.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,273 +30,11 @@
 #include "memory/metaspace.hpp"
 #include "runtime/orderAccess.hpp"
 
-// correct linkage required to compile w/o warnings
-// (must be on file level - cannot be local)
-extern "C" { typedef int (*ftype)(const void*, const void*); }
-
-
-class ResourceArray: public ResourceObj {
- protected:
-  int   _length;                                 // the number of array elements
-  void* _data;                                   // the array memory
-#ifdef ASSERT
-  int   _nesting;                                // the resource area nesting level
-#endif
-
-  // creation
-  ResourceArray() {
-    _length  = 0;
-    _data    = NULL;
-    DEBUG_ONLY(init_nesting();)
-    // client may call initialize, at most once
-  }
-
-
-  ResourceArray(size_t esize, int length) {
-    DEBUG_ONLY(_data = NULL);
-    initialize(esize, length);
-  }
-
-  void initialize(size_t esize, int length) {
-    assert(length >= 0, "illegal length");
-    assert(StressRewriter || _data == NULL, "must be new object");
-    _length  = length;
-    _data    = resource_allocate_bytes(esize * length);
-    DEBUG_ONLY(init_nesting();)
-  }
-
-#ifdef ASSERT
-  void init_nesting();
-#endif
-
-  // helper functions
-  void sort     (size_t esize, ftype f);         // sort the array
-  void expand   (size_t esize, int i, int& size);// expand the array to include slot i
-  void remove_at(size_t esize, int i);           // remove the element in slot i
-
- public:
-  // standard operations
-  int  length() const                            { return _length; }
-  bool is_empty() const                          { return length() == 0; }
-};
-
-
-template <MEMFLAGS F>class CHeapArray: public CHeapObj<F> {
- protected:
-  int   _length;                                 // the number of array elements
-  void* _data;                                   // the array memory
-
-  // creation
-  CHeapArray() {
-    _length  = 0;
-    _data    = NULL;
-  }
-
-
-  CHeapArray(size_t esize, int length) {
-    assert(length >= 0, "illegal length");
-    _length  = length;
-    _data    = (void*) NEW_C_HEAP_ARRAY(char *, esize * length, F);
-  }
-
-  void initialize(size_t esize, int length) {
-    // In debug set array to 0?
-  }
-
-#ifdef ASSERT
-  void init_nesting();
-#endif
-
-  // helper functions
-  void sort     (size_t esize, ftype f);         // sort the array
-  void expand   (size_t esize, int i, int& size);// expand the array to include slot i
-  void remove_at(size_t esize, int i);           // remove the element in slot i
-
- public:
-  // standard operations
-  int  length() const                            { return _length; }
-  bool is_empty() const                          { return length() == 0; }
-};
-
-#define define_generic_array(array_name,element_type, base_class)                        \
-  class array_name: public base_class {                                                  \
-   protected:                                                                            \
-    typedef element_type etype;                                                          \
-    enum { esize = sizeof(etype) };                                                      \
-                                                                                         \
-    void base_remove_at(size_t size, int i) { base_class::remove_at(size, i); }          \
-                                                                                         \
-   public:                                                                               \
-    /* creation */                                                                       \
-    array_name() : base_class()                       {}                                 \
-    explicit array_name(const int length) : base_class(esize, length) {}                          \
-    array_name(const int length, const etype fx)      { initialize(length, fx); }        \
-    void initialize(const int length)     { base_class::initialize(esize, length); }     \
-    void initialize(const int length, const etype fx) {                                  \
-      initialize(length);                                                                \
-      for (int i = 0; i < length; i++) ((etype*)_data)[i] = fx;                          \
-    }                                                                                    \
-                                                                                         \
-    /* standard operations */                                                            \
-    etype& operator [] (const int i) const {                                             \
-      assert(0 <= i && i < length(), "index out of bounds");                             \
-      return ((etype*)_data)[i];                                                         \
-    }                                                                                    \
-                                                                                         \
-    int index_of(const etype x) const {                                                  \
-      int i = length();                                                                  \
-      while (i-- > 0 && ((etype*)_data)[i] != x) ;                                       \
-      /* i < 0 || ((etype*)_data)_data[i] == x */                                        \
-      return i;                                                                          \
-    }                                                                                    \
-                                                                                         \
-    void sort(int f(etype*, etype*))             { base_class::sort(esize, (ftype)f); }  \
-    bool contains(const etype x) const           { return index_of(x) >= 0; }            \
-                                                                                         \
-    /* deprecated operations - for compatibility with GrowableArray only */              \
-    etype  at(const int i) const                 { return (*this)[i]; }                  \
-    void   at_put(const int i, const etype x)    { (*this)[i] = x; }                     \
-    etype* adr_at(const int i)                   { return &(*this)[i]; }                 \
-    int    find(const etype x)                   { return index_of(x); }                 \
-  };                                                                                     \
-
-
-#define define_array(array_name,element_type)                                            \
-  define_generic_array(array_name, element_type, ResourceArray)
-
-
-#define define_stack(stack_name,array_name)                                              \
-  class stack_name: public array_name {                                                  \
-   protected:                                                                            \
-    int _size;                                                                           \
-                                                                                         \
-    void grow(const int i, const etype fx) {                                             \
-      assert(i >= length(), "index too small");                                          \
-      if (i >= size()) expand(esize, i, _size);                                          \
-      for (int j = length(); j <= i; j++) ((etype*)_data)[j] = fx;                       \
-      _length = i+1;                                                                     \
-    }                                                                                    \
-                                                                                         \
-   public:                                                                               \
-    /* creation */                                                                       \
-    stack_name() : array_name()                     { _size = 0; }                       \
-    stack_name(const int size)                      { initialize(size); }                \
-    stack_name(const int size, const etype fx)      { initialize(size, fx); }            \
-    void initialize(const int size, const etype fx) {                                    \
-      _size = size;                                                                      \
-      array_name::initialize(size, fx);                                                  \
-      /* _length == size, allocation and size are the same */                            \
-    }                                                                                    \
-    void initialize(const int size) {                                                    \
-      _size = size;                                                                      \
-      array_name::initialize(size);                                                      \
-      _length = 0;          /* reset length to zero; _size records the allocation */     \
-    }                                                                                    \
-                                                                                         \
-    /* standard operations */                                                            \
-    int size() const                             { return _size; }                       \
-                                                                                         \
-    int push(const etype x) {                                                            \
-      int len = length();                                                                \
-      if (len >= size()) expand(esize, len, _size);                                      \
-      ((etype*)_data)[len] = x;                                                          \
-      _length = len+1;                                                                   \
-      return len;                                                                        \
-    }                                                                                    \
-                                                                                         \
-    etype pop() {                                                                        \
-      assert(!is_empty(), "stack is empty");                                             \
-      return ((etype*)_data)[--_length];                                                 \
-    }                                                                                    \
-                                                                                         \
-    etype top() const {                                                                  \
-      assert(!is_empty(), "stack is empty");                                             \
-      return ((etype*)_data)[length() - 1];                                              \
-    }                                                                                    \
-                                                                                         \
-    void push_all(const stack_name* stack) {                                             \
-      const int l = stack->length();                                                     \
-      for (int i = 0; i < l; i++) push(((etype*)(stack->_data))[i]);                     \
-    }                                                                                    \
-                                                                                         \
-    etype at_grow(const int i, const etype fx) {                                         \
-      if (i >= length()) grow(i, fx);                                                    \
-      return ((etype*)_data)[i];                                                         \
-    }                                                                                    \
-                                                                                         \
-    void at_put_grow(const int i, const etype x, const etype fx) {                       \
-      if (i >= length()) grow(i, fx);                                                    \
-      ((etype*)_data)[i] = x;                                                            \
-    }                                                                                    \
-                                                                                         \
-    void truncate(const int length) {                                                    \
-      assert(0 <= length && length <= this->length(), "illegal length");                 \
-      _length = length;                                                                  \
-    }                                                                                    \
-                                                                                         \
-    void remove_at(int i)                        { base_remove_at(esize, i); }           \
-    void remove(etype x)                         { remove_at(index_of(x)); }             \
-                                                                                         \
-    /* inserts the given element before the element at index i */                        \
-    void insert_before(const int i, const etype el)  {                                   \
-      int len = length();                                                                \
-      int new_length = len + 1;                                                          \
-      if (new_length >= size()) expand(esize, new_length, _size);                        \
-      for (int j = len - 1; j >= i; j--) {                                               \
-        ((etype*)_data)[j + 1] = ((etype*)_data)[j];                                     \
-      }                                                                                  \
-      _length = new_length;                                                              \
-      at_put(i, el);                                                                     \
-    }                                                                                    \
-                                                                                         \
-    /* inserts contents of the given stack before the element at index i */              \
-    void insert_before(const int i, const stack_name *st) {                              \
-      if (st->length() == 0) return;                                                     \
-      int len = length();                                                                \
-      int st_len = st->length();                                                         \
-      int new_length = len + st_len;                                                     \
-      if (new_length >= size()) expand(esize, new_length, _size);                        \
-      int j;                                                                             \
-      for (j = len - 1; j >= i; j--) {                                                   \
-        ((etype*)_data)[j + st_len] = ((etype*)_data)[j];                                \
-      }                                                                                  \
-      for (j = 0; j < st_len; j++) {                                                     \
-        ((etype*)_data)[i + j] = ((etype*)st->_data)[j];                                 \
-      }                                                                                  \
-      _length = new_length;                                                              \
-    }                                                                                    \
-                                                                                         \
-    /* deprecated operations - for compatibility with GrowableArray only */              \
-    int  capacity() const                        { return size(); }                      \
-    void clear()                                 { truncate(0); }                        \
-    void trunc_to(const int length)              { truncate(length); }                   \
-    int  append(const etype x)                   { return push(x); }                     \
-    void appendAll(const stack_name* stack)      { push_all(stack); }                    \
-    etype last() const                           { return top(); }                       \
-  };                                                                                     \
-
-
-#define define_resource_list(element_type)                                               \
-  define_generic_array(element_type##Array, element_type, ResourceArray)                 \
-  define_stack(element_type##List, element_type##Array)
-
-#define define_resource_pointer_list(element_type)                                       \
-  define_generic_array(element_type##Array, element_type *, ResourceArray)               \
-  define_stack(element_type##List, element_type##Array)
-
-#define define_c_heap_list(element_type)                                                 \
-  define_generic_array(element_type##Array, element_type, CHeapArray)                    \
-  define_stack(element_type##List, element_type##Array)
-
-#define define_c_heap_pointer_list(element_type)                                         \
-  define_generic_array(element_type##Array, element_type *, CHeapArray)                  \
-  define_stack(element_type##List, element_type##Array)
-
-
 // Arrays for basic types
-
-define_array(boolArray, bool)          define_stack(boolStack, boolArray)
-define_array(intArray , int )          define_stack(intStack , intArray )
+typedef GrowableArray<int> intArray;
+typedef GrowableArray<int> intStack;
+typedef GrowableArray<bool> boolArray;
+typedef GrowableArray<bool> boolStack;
 
 // Array for metadata allocation
 
diff --git a/hotspot/src/share/vm/utilities/bitMap.cpp b/hotspot/src/share/vm/utilities/bitMap.cpp
index bb7ae8e..12758ab 100644
--- a/hotspot/src/share/vm/utilities/bitMap.cpp
+++ b/hotspot/src/share/vm/utilities/bitMap.cpp
@@ -28,13 +28,144 @@
 #include "runtime/atomic.inline.hpp"
 #include "utilities/bitMap.inline.hpp"
 #include "utilities/copy.hpp"
+#include "utilities/debug.hpp"
 
 STATIC_ASSERT(sizeof(BitMap::bm_word_t) == BytesPerWord); // "Implementation assumption."
 
-BitMap::BitMap(idx_t size_in_bits, bool in_resource_area) :
-  _map(NULL), _size(0)
-{
-  resize(size_in_bits, in_resource_area);
+typedef BitMap::bm_word_t bm_word_t;
+typedef BitMap::idx_t     idx_t;
+
+class ResourceBitMapAllocator : StackObj {
+ public:
+  bm_word_t* allocate(idx_t size_in_words) const {
+    return NEW_RESOURCE_ARRAY(bm_word_t, size_in_words);
+  }
+  void free(bm_word_t* map, idx_t size_in_words) const {
+    // Don't free resource allocated arrays.
+  }
+};
+
+class CHeapBitMapAllocator : StackObj {
+ public:
+  bm_word_t* allocate(size_t size_in_words) const {
+    return ArrayAllocator<bm_word_t, mtInternal>::allocate(size_in_words);
+  }
+  void free(bm_word_t* map, idx_t size_in_words) const {
+    ArrayAllocator<bm_word_t, mtInternal>::free(map, size_in_words);
+  }
+};
+
+class ArenaBitMapAllocator : StackObj {
+  Arena* _arena;
+
+ public:
+  ArenaBitMapAllocator(Arena* arena) : _arena(arena) {}
+  bm_word_t* allocate(idx_t size_in_words) const {
+    return (bm_word_t*)_arena->Amalloc(size_in_words * BytesPerWord);
+  }
+  void free(bm_word_t* map, idx_t size_in_words) const {
+    // ArenaBitMaps currently don't free memory.
+  }
+};
+
+template <class Allocator>
+BitMap::bm_word_t* BitMap::reallocate(const Allocator& allocator, bm_word_t* old_map, idx_t old_size_in_bits, idx_t new_size_in_bits) {
+  size_t old_size_in_words = calc_size_in_words(old_size_in_bits);
+  size_t new_size_in_words = calc_size_in_words(new_size_in_bits);
+
+  bm_word_t* map = NULL;
+
+  if (new_size_in_words > 0) {
+    map = allocator.allocate(new_size_in_words);
+
+    Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) map,
+                         MIN2(old_size_in_words, new_size_in_words));
+
+    if (new_size_in_words > old_size_in_words) {
+      clear_range_of_words(map, old_size_in_words, new_size_in_words);
+    }
+  }
+
+  if (old_map != NULL) {
+    allocator.free(old_map, old_size_in_words);
+  }
+
+  return map;
+}
+
+template <class Allocator>
+bm_word_t* BitMap::allocate(const Allocator& allocator, idx_t size_in_bits) {
+  // Reuse reallocate to ensure that the new memory is cleared.
+  return reallocate(allocator, NULL, 0, size_in_bits);
+}
+
+template <class Allocator>
+void BitMap::free(const Allocator& allocator, bm_word_t* map, idx_t  size_in_bits) {
+  bm_word_t* ret = reallocate(allocator, map, size_in_bits, 0);
+  assert(ret == NULL, "Reallocate shouldn't have allocated");
+}
+
+template <class Allocator>
+void BitMap::resize(const Allocator& allocator, idx_t new_size_in_bits) {
+  bm_word_t* new_map = reallocate(allocator, map(), size(), new_size_in_bits);
+
+  update(new_map, new_size_in_bits);
+}
+
+template <class Allocator>
+void BitMap::initialize(const Allocator& allocator, idx_t size_in_bits) {
+  assert(map() == NULL, "precondition");
+  assert(size() == 0,   "precondition");
+
+  resize(allocator, size_in_bits);
+}
+
+template <class Allocator>
+void BitMap::reinitialize(const Allocator& allocator, idx_t new_size_in_bits) {
+  // Remove previous bits.
+  resize(allocator, 0);
+
+  initialize(allocator, new_size_in_bits);
+}
+
+ResourceBitMap::ResourceBitMap(idx_t size_in_bits)
+    : BitMap(allocate(ResourceBitMapAllocator(), size_in_bits), size_in_bits) {
+}
+
+void ResourceBitMap::resize(idx_t new_size_in_bits) {
+  BitMap::resize(ResourceBitMapAllocator(), new_size_in_bits);
+}
+
+void ResourceBitMap::initialize(idx_t size_in_bits) {
+  BitMap::initialize(ResourceBitMapAllocator(), size_in_bits);
+}
+
+void ResourceBitMap::reinitialize(idx_t size_in_bits) {
+  BitMap::reinitialize(ResourceBitMapAllocator(), size_in_bits);
+}
+
+ArenaBitMap::ArenaBitMap(Arena* arena, idx_t size_in_bits)
+    : BitMap(allocate(ArenaBitMapAllocator(arena), size_in_bits), size_in_bits) {
+}
+
+CHeapBitMap::CHeapBitMap(idx_t size_in_bits)
+    : BitMap(allocate(CHeapBitMapAllocator(), size_in_bits), size_in_bits) {
+}
+
+CHeapBitMap::~CHeapBitMap() {
+  free(CHeapBitMapAllocator(), map(), size());
+}
+
+void CHeapBitMap::resize(idx_t new_size_in_bits) {
+  BitMap::resize(CHeapBitMapAllocator(), new_size_in_bits);
+}
+
+void CHeapBitMap::initialize(idx_t size_in_bits) {
+  BitMap::initialize(CHeapBitMapAllocator(), size_in_bits);
+}
+
+void CHeapBitMap::reinitialize(idx_t size_in_bits) {
+  BitMap::reinitialize(CHeapBitMapAllocator(), size_in_bits);
 }
 
 #ifdef ASSERT
@@ -49,25 +180,6 @@
 }
 #endif // #ifdef ASSERT
 
-void BitMap::resize(idx_t size_in_bits, bool in_resource_area) {
-  idx_t old_size_in_words = size_in_words();
-  bm_word_t* old_map = map();
-
-  _size = size_in_bits;
-  idx_t new_size_in_words = size_in_words();
-  if (in_resource_area) {
-    _map = NEW_RESOURCE_ARRAY(bm_word_t, new_size_in_words);
-    Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) _map,
-                         MIN2(old_size_in_words, new_size_in_words));
-  } else {
-    _map = ArrayAllocator<bm_word_t, mtInternal>::reallocate(old_map, old_size_in_words, new_size_in_words);
-  }
-
-  if (new_size_in_words > old_size_in_words) {
-    clear_range_of_words(old_size_in_words, new_size_in_words);
-  }
-}
-
 void BitMap::pretouch() {
   os::pretouch_memory(word_addr(0), word_addr(size()));
 }
@@ -205,13 +317,6 @@
   return value ? par_set_bit(bit) : par_clear_bit(bit);
 }
 
-void BitMap::at_put_grow(idx_t offset, bool value) {
-  if (offset >= size()) {
-    resize(2 * MAX2(size(), offset));
-  }
-  at_put(offset, value);
-}
-
 void BitMap::at_put_range(idx_t start_offset, idx_t end_offset, bool value) {
   if (value) {
     set_range(start_offset, end_offset);
@@ -271,10 +376,10 @@
   par_put_range_within_word(bit_index(end_full_word), end, value);
 }
 
-bool BitMap::contains(const BitMap other) const {
+bool BitMap::contains(const BitMap& other) const {
   assert(size() == other.size(), "must have same size");
-  bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* dest_map = map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size_in_words(); index++) {
     bm_word_t word_union = dest_map[index] | other_map[index];
@@ -285,10 +390,10 @@
   return true;
 }
 
-bool BitMap::intersects(const BitMap other) const {
+bool BitMap::intersects(const BitMap& other) const {
   assert(size() == other.size(), "must have same size");
-  bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* dest_map = map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size_in_words(); index++) {
     if ((dest_map[index] & other_map[index]) != 0) return true;
@@ -297,10 +402,10 @@
   return false;
 }
 
-void BitMap::set_union(BitMap other) {
+void BitMap::set_union(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size_in_words(); index++) {
     dest_map[index] = dest_map[index] | other_map[index];
@@ -308,10 +413,10 @@
 }
 
 
-void BitMap::set_difference(BitMap other) {
+void BitMap::set_difference(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size_in_words(); index++) {
     dest_map[index] = dest_map[index] & ~(other_map[index]);
@@ -319,10 +424,10 @@
 }
 
 
-void BitMap::set_intersection(BitMap other) {
+void BitMap::set_intersection(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
     dest_map[index]  = dest_map[index] & other_map[index];
@@ -330,14 +435,14 @@
 }
 
 
-void BitMap::set_intersection_at_offset(BitMap other, idx_t offset) {
+void BitMap::set_intersection_at_offset(const BitMap& other, idx_t offset) {
   assert(other.size() >= offset, "offset not in range");
   assert(other.size() - offset >= size(), "other not large enough");
   // XXX Ideally, we would remove this restriction.
   guarantee((offset % (sizeof(bm_word_t) * BitsPerByte)) == 0,
             "Only handle aligned cases so far.");
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t offset_word_ind = word_index(offset);
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
@@ -345,11 +450,11 @@
   }
 }
 
-bool BitMap::set_union_with_result(BitMap other) {
+bool BitMap::set_union_with_result(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bool changed = false;
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
     idx_t temp = dest_map[index] | other_map[index];
@@ -360,11 +465,11 @@
 }
 
 
-bool BitMap::set_difference_with_result(BitMap other) {
+bool BitMap::set_difference_with_result(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bool changed = false;
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
     bm_word_t temp = dest_map[index] & ~(other_map[index]);
@@ -375,11 +480,11 @@
 }
 
 
-bool BitMap::set_intersection_with_result(BitMap other) {
+bool BitMap::set_intersection_with_result(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bool changed = false;
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
     bm_word_t orig = dest_map[index];
@@ -391,10 +496,10 @@
 }
 
 
-void BitMap::set_from(BitMap other) {
+void BitMap::set_from(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
     dest_map[index] = other_map[index];
@@ -402,10 +507,10 @@
 }
 
 
-bool BitMap::is_same(BitMap other) {
+bool BitMap::is_same(const BitMap& other) {
   assert(size() == other.size(), "must have same size");
   bm_word_t* dest_map = map();
-  bm_word_t* other_map = other.map();
+  const bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
     if (dest_map[index] != other_map[index]) return false;
@@ -414,7 +519,7 @@
 }
 
 bool BitMap::is_full() const {
-  bm_word_t* word = map();
+  const bm_word_t* word = map();
   idx_t rest = size();
   for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
     if (*word != ~(bm_word_t)0) return false;
@@ -425,7 +530,7 @@
 
 
 bool BitMap::is_empty() const {
-  bm_word_t* word = map();
+  const bm_word_t* word = map();
   idx_t rest = size();
   for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
     if (*word != 0) return false;
@@ -532,93 +637,116 @@
 
 class TestBitMap : public AllStatic {
   const static BitMap::idx_t BITMAP_SIZE = 1024;
-  static void fillBitMap(BitMap& map) {
+
+  template <class ResizableBitMapClass>
+  static void fillBitMap(ResizableBitMapClass& map) {
     map.set_bit(1);
     map.set_bit(3);
     map.set_bit(17);
     map.set_bit(512);
   }
 
-  static void testResize(bool in_resource_area) {
-    {
-      BitMap map(0, in_resource_area);
-      map.resize(BITMAP_SIZE, in_resource_area);
-      fillBitMap(map);
-
-      BitMap map2(BITMAP_SIZE, in_resource_area);
-      fillBitMap(map2);
-      assert(map.is_same(map2), "could be");
-    }
-
-    {
-      BitMap map(128, in_resource_area);
-      map.resize(BITMAP_SIZE, in_resource_area);
-      fillBitMap(map);
-
-      BitMap map2(BITMAP_SIZE, in_resource_area);
-      fillBitMap(map2);
-      assert(map.is_same(map2), "could be");
-    }
-
-    {
-      BitMap map(BITMAP_SIZE, in_resource_area);
-      map.resize(BITMAP_SIZE, in_resource_area);
-      fillBitMap(map);
-
-      BitMap map2(BITMAP_SIZE, in_resource_area);
-      fillBitMap(map2);
-      assert(map.is_same(map2), "could be");
-    }
-  }
-
-  static void testResizeResource() {
+  template <class ResizableBitMapClass>
+  static void testResize(BitMap::idx_t start_size) {
     ResourceMark rm;
-    testResize(true);
+
+    ResizableBitMapClass map(start_size);
+    map.resize(BITMAP_SIZE);
+    fillBitMap(map);
+
+    ResizableBitMapClass map2(BITMAP_SIZE);
+    fillBitMap(map2);
+    assert(map.is_same(map2), "could be");
   }
 
-  static void testResizeNonResource() {
-    const size_t bitmap_bytes = BITMAP_SIZE / BitsPerByte;
+  template <class ResizableBitMapClass>
+  static void testResizeGrow() {
+    testResize<ResizableBitMapClass>(0);
+    testResize<ResizableBitMapClass>(128);
+  }
 
-    // Test the default behavior
-    testResize(false);
+  template <class ResizableBitMapClass>
+  static void testResizeSame() {
+    testResize<ResizableBitMapClass>(BITMAP_SIZE);
+  }
 
-    {
-      // Make sure that AllocatorMallocLimit is larger than our allocation request
-      // forcing it to call standard malloc()
-      SizeTFlagSetting fs(ArrayAllocatorMallocLimit, bitmap_bytes * 4);
-      testResize(false);
-    }
-    {
-      // Make sure that AllocatorMallocLimit is smaller than our allocation request
-      // forcing it to call mmap() (or equivalent)
-      SizeTFlagSetting fs(ArrayAllocatorMallocLimit, bitmap_bytes / 4);
-      testResize(false);
-    }
+  template <class ResizableBitMapClass>
+  static void testResizeShrink() {
+    testResize<ResizableBitMapClass>(BITMAP_SIZE * 2);
+  }
+
+  static void testResizeGrow() {
+    testResizeGrow<ResourceBitMap>();
+    testResizeGrow<CHeapBitMap>();
+  }
+
+  static void testResizeSame() {
+    testResizeSame<ResourceBitMap>();
+    testResizeSame<CHeapBitMap>();
+  }
+
+  static void testResizeShrink() {
+    testResizeShrink<ResourceBitMap>();
+    testResizeShrink<CHeapBitMap>();
+  }
+
+  static void testResize() {
+    testResizeGrow();
+    testResizeSame();
+    testResizeShrink();
+  }
+
+  template <class InitializableBitMapClass>
+  static void testInitialize() {
+    ResourceMark rm;
+
+    InitializableBitMapClass map;
+    map.initialize(BITMAP_SIZE);
+    fillBitMap(map);
+
+    InitializableBitMapClass map2(BITMAP_SIZE);
+    fillBitMap(map2);
+    assert(map.is_same(map2), "could be");
+  }
+
+  static void testInitialize() {
+    testInitialize<ResourceBitMap>();
+    testInitialize<CHeapBitMap>();
+  }
+
+  template <class ReinitializableBitMapClass>
+  static void testReinitialize(BitMap::idx_t init_size) {
+    ResourceMark rm;
+
+    ReinitializableBitMapClass map(init_size);
+    map.reinitialize(BITMAP_SIZE);
+    fillBitMap(map);
+
+    ReinitializableBitMapClass map2(BITMAP_SIZE);
+    fillBitMap(map2);
+    assert(map.is_same(map2), "could be");
+  }
+
+  template <class ReinitializableBitMapClass>
+  static void testReinitialize() {
+    testReinitialize<ReinitializableBitMapClass>(0);
+    testReinitialize<ReinitializableBitMapClass>(128);
+    testReinitialize<ReinitializableBitMapClass>(BITMAP_SIZE);
+  }
+
+  static void testReinitialize() {
+    testReinitialize<ResourceBitMap>();
   }
 
  public:
   static void test() {
-    testResizeResource();
-    testResizeNonResource();
+    testResize();
+    testInitialize();
+    testReinitialize();
   }
-
 };
 
 void TestBitMap_test() {
   TestBitMap::test();
 }
 #endif
-
-
-BitMap2D::BitMap2D(bm_word_t* map, idx_t size_in_slots, idx_t bits_per_slot)
-  : _bits_per_slot(bits_per_slot)
-  , _map(map, size_in_slots * bits_per_slot)
-{
-}
-
-
-BitMap2D::BitMap2D(idx_t size_in_slots, idx_t bits_per_slot)
-  : _bits_per_slot(bits_per_slot)
-  , _map(size_in_slots * bits_per_slot)
-{
-}
diff --git a/hotspot/src/share/vm/utilities/bitMap.hpp b/hotspot/src/share/vm/utilities/bitMap.hpp
index b41cc12..bc5cb58 100644
--- a/hotspot/src/share/vm/utilities/bitMap.hpp
+++ b/hotspot/src/share/vm/utilities/bitMap.hpp
@@ -33,6 +33,16 @@
 // Operations for bitmaps represented as arrays of unsigned integers.
 // Bit offsets are numbered from 0 to size-1.
 
+// The "abstract" base BitMap class.
+//
+// The constructor and destructor are protected to prevent
+// creation of BitMap instances outside of the BitMap class.
+//
+// The BitMap class doesn't use virtual calls on purpose,
+// this ensures that we don't get a vtable unnecessarily.
+//
+// The allocation of the backing storage for the BitMap are handled by
+// the subclasses. BitMap doesn't allocate or delete backing storage.
 class BitMap VALUE_OBJ_CLASS_SPEC {
   friend class BitMap2D;
 
@@ -50,10 +60,6 @@
   bm_word_t* _map;     // First word in bitmap
   idx_t      _size;    // Size of bitmap (in bits)
 
-  // Puts the given value at the given offset, using resize() to size
-  // the bitmap appropriately if needed using factor-of-two expansion.
-  void at_put_grow(idx_t index, bool value);
-
  protected:
   // Return the position of bit within the word that contains it (e.g., if
   // bitmap words are 32 bits, return a number 0 <= n <= 31).
@@ -70,11 +76,13 @@
   static idx_t bit_index(idx_t word)  { return word << LogBitsPerWord; }
 
   // Return the array of bitmap words, or a specific word from it.
-  bm_word_t* map() const           { return _map; }
+  bm_word_t* map()                 { return _map; }
+  const bm_word_t* map() const     { return _map; }
   bm_word_t  map(idx_t word) const { return _map[word]; }
 
   // Return a pointer to the word containing the specified bit.
-  bm_word_t* word_addr(idx_t bit) const { return map() + word_index(bit); }
+  bm_word_t* word_addr(idx_t bit)             { return map() + word_index(bit); }
+  const bm_word_t* word_addr(idx_t bit) const { return map() + word_index(bit); }
 
   // Set a word to a specified value or to all ones; clear a word.
   void set_word  (idx_t word, bm_word_t val) { _map[word] = val; }
@@ -95,6 +103,8 @@
   void      set_large_range_of_words   (idx_t beg, idx_t end);
   void      clear_large_range_of_words (idx_t beg, idx_t end);
 
+  static void clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end);
+
   // The index of the first full word in a range.
   idx_t word_index_round_up(idx_t bit) const;
 
@@ -108,46 +118,69 @@
   static idx_t num_set_bits(bm_word_t w);
   static idx_t num_set_bits_from_table(unsigned char c);
 
- public:
+  // Allocation Helpers.
 
-  // Constructs a bitmap with no map, and size 0.
-  BitMap() : _map(NULL), _size(0) {}
+  // Allocates and clears the bitmap memory.
+  template <class Allocator>
+  static bm_word_t* allocate(const Allocator&, idx_t size_in_bits);
 
-  // Constructs a bitmap with the given map and size.
-  BitMap(bm_word_t* map, idx_t size_in_bits) :_map(map), _size(size_in_bits) {}
+  // Reallocates and clears the new bitmap memory.
+  template <class Allocator>
+  static bm_word_t* reallocate(const Allocator&, bm_word_t* map, idx_t old_size_in_bits, idx_t new_size_in_bits);
 
-  // Constructs an empty bitmap of the given size (that is, this clears the
-  // new bitmap).  Allocates the map array in resource area if
-  // "in_resource_area" is true, else in the C heap.
-  BitMap(idx_t size_in_bits, bool in_resource_area = true);
+  // Free the bitmap memory.
+  template <class Allocator>
+  static void free(const Allocator&, bm_word_t* map, idx_t size_in_bits);
+
+  // Protected functions, that are used by BitMap sub-classes that support them.
+
+  // Resize the backing bitmap memory.
+  //
+  // Old bits are transfered to the new memory
+  // and the extended memory is cleared.
+  template <class Allocator>
+  void resize(const Allocator& allocator, idx_t new_size_in_bits);
+
+  // Set up and clear the bitmap memory.
+  //
+  // Precondition: The bitmap was default constructed and has
+  // not yet had memory allocated via resize or (re)initialize.
+  template <class Allocator>
+  void initialize(const Allocator& allocator, idx_t size_in_bits);
+
+  // Set up and clear the bitmap memory.
+  //
+  // Can be called on previously initialized bitmaps.
+  template <class Allocator>
+  void reinitialize(const Allocator& allocator, idx_t new_size_in_bits);
 
   // Set the map and size.
-  void set_map(bm_word_t* map)      { _map = map; }
-  void set_size(idx_t size_in_bits) { _size = size_in_bits; }
+  void update(bm_word_t* map, idx_t size) {
+    _map = map;
+    _size = size;
+  }
 
-  // Allocates necessary data structure, either in the resource area
-  // or in the C heap, as indicated by "in_resource_area."
-  // Preserves state currently in bit map by copying data.
-  // Zeros any newly-addressable bits.
-  // If "in_resource_area" is false, frees the current map.
-  // (Note that this assumes that all calls to "resize" on the same BitMap
-  // use the same value for "in_resource_area".)
-  void resize(idx_t size_in_bits, bool in_resource_area = true);
+  // Protected constructor and destructor.
+  BitMap(bm_word_t* map, idx_t size_in_bits) : _map(map), _size(size_in_bits) {}
+  ~BitMap() {}
 
+ public:
   // Pretouch the entire range of memory this BitMap covers.
   void pretouch();
 
   // Accessing
-  idx_t size() const                    { return _size; }
-  idx_t size_in_bytes() const           { return size_in_words() * BytesPerWord; }
-  idx_t size_in_words() const           {
-    return calc_size_in_words(size());
-  }
-
   static idx_t calc_size_in_words(size_t size_in_bits) {
     return word_index(size_in_bits + BitsPerWord - 1);
   }
 
+  static idx_t calc_size_in_bytes(size_t size_in_bits) {
+    return calc_size_in_words(size_in_bits) * BytesPerWord;
+  }
+
+  idx_t size() const          { return _size; }
+  idx_t size_in_words() const { return calc_size_in_words(size()); }
+  idx_t size_in_bytes() const { return calc_size_in_bytes(size()); }
+
   bool at(idx_t index) const {
     verify_index(index);
     return (*word_addr(index) & bit_mask(index)) != 0;
@@ -237,19 +270,19 @@
   idx_t count_one_bits() const;
 
   // Set operations.
-  void set_union(BitMap bits);
-  void set_difference(BitMap bits);
-  void set_intersection(BitMap bits);
+  void set_union(const BitMap& bits);
+  void set_difference(const BitMap& bits);
+  void set_intersection(const BitMap& bits);
   // Returns true iff "this" is a superset of "bits".
-  bool contains(const BitMap bits) const;
+  bool contains(const BitMap& bits) const;
   // Returns true iff "this and "bits" have a non-empty intersection.
-  bool intersects(const BitMap bits) const;
+  bool intersects(const BitMap& bits) const;
 
   // Returns result of whether this map changed
   // during the operation
-  bool set_union_with_result(BitMap bits);
-  bool set_difference_with_result(BitMap bits);
-  bool set_intersection_with_result(BitMap bits);
+  bool set_union_with_result(const BitMap& bits);
+  bool set_difference_with_result(const BitMap& bits);
+  bool set_intersection_with_result(const BitMap& bits);
 
   // Requires the submap of "bits" starting at offset to be at least as
   // large as "this".  Modifies "this" to be the intersection of its
@@ -258,11 +291,11 @@
   // (For expedience, currently requires the offset to be aligned to the
   // bitsize of a uintptr_t.  This should go away in the future though it
   // will probably remain a good case to optimize.)
-  void set_intersection_at_offset(BitMap bits, idx_t offset);
+  void set_intersection_at_offset(const BitMap& bits, idx_t offset);
 
-  void set_from(BitMap bits);
+  void set_from(const BitMap& bits);
 
-  bool is_same(BitMap bits);
+  bool is_same(const BitMap& bits);
 
   // Test if all bits are set or cleared
   bool is_full() const;
@@ -277,6 +310,88 @@
 #endif
 };
 
+// A concrete implementation of the the "abstract" BitMap class.
+//
+// The BitMapView is used when the backing storage is managed externally.
+class BitMapView : public BitMap {
+ public:
+  BitMapView() : BitMap(NULL, 0) {}
+  BitMapView(bm_word_t* map, idx_t size_in_bits) : BitMap(map, size_in_bits) {}
+};
+
+// A BitMap with storage in a ResourceArea.
+class ResourceBitMap : public BitMap {
+  friend class TestBitMap;
+
+ public:
+  ResourceBitMap() : BitMap(NULL, 0) {}
+  // Clears the bitmap memory.
+  ResourceBitMap(idx_t size_in_bits);
+
+  // Resize the backing bitmap memory.
+  //
+  // Old bits are transfered to the new memory
+  // and the extended memory is cleared.
+  void resize(idx_t new_size_in_bits);
+
+  // Set up and clear the bitmap memory.
+  //
+  // Precondition: The bitmap was default constructed and has
+  // not yet had memory allocated via resize or initialize.
+  void initialize(idx_t size_in_bits);
+
+  // Set up and clear the bitmap memory.
+  //
+  // Can be called on previously initialized bitmaps.
+  void reinitialize(idx_t size_in_bits);
+};
+
+// A BitMap with storage in a specific Arena.
+class ArenaBitMap : public BitMap {
+ public:
+  // Clears the bitmap memory.
+  ArenaBitMap(Arena* arena, idx_t size_in_bits);
+
+ private:
+  // Don't allow copy or assignment.
+  ArenaBitMap(const ArenaBitMap&);
+  ArenaBitMap& operator=(const ArenaBitMap&);
+};
+
+// A BitMap with storage in the CHeap.
+class CHeapBitMap : public BitMap {
+  friend class TestBitMap;
+
+ private:
+  // Don't allow copy or assignment, to prevent the
+  // allocated memory from leaking out to other instances.
+  CHeapBitMap(const CHeapBitMap&);
+  CHeapBitMap& operator=(const CHeapBitMap&);
+
+ public:
+  CHeapBitMap() : BitMap(NULL, 0) {}
+  // Clears the bitmap memory.
+  CHeapBitMap(idx_t size_in_bits);
+  ~CHeapBitMap();
+
+  // Resize the backing bitmap memory.
+  //
+  // Old bits are transfered to the new memory
+  // and the extended memory is cleared.
+  void resize(idx_t new_size_in_bits);
+
+  // Set up and clear the bitmap memory.
+  //
+  // Precondition: The bitmap was default constructed and has
+  // not yet had memory allocated via resize or initialize.
+  void initialize(idx_t size_in_bits);
+
+  // Set up and clear the bitmap memory.
+  //
+  // Can be called on previously initialized bitmaps.
+  void reinitialize(idx_t size_in_bits);
+};
+
 // Convenience class wrapping BitMap which provides multiple bits per slot.
 class BitMap2D VALUE_OBJ_CLASS_SPEC {
  public:
@@ -284,8 +399,8 @@
   typedef BitMap::bm_word_t bm_word_t;  // Element type of array that
                                         // represents the bitmap.
  private:
-  BitMap _map;
-  idx_t  _bits_per_slot;
+  ResourceBitMap _map;
+  idx_t          _bits_per_slot;
 
   idx_t bit_index(idx_t slot_index, idx_t bit_within_slot_index) const {
     return slot_index * _bits_per_slot + bit_within_slot_index;
@@ -297,10 +412,12 @@
 
  public:
   // Construction. bits_per_slot must be greater than 0.
-  BitMap2D(bm_word_t* map, idx_t size_in_slots, idx_t bits_per_slot);
+  BitMap2D(idx_t bits_per_slot) :
+      _map(), _bits_per_slot(bits_per_slot) {}
 
   // Allocates necessary data structure in resource area. bits_per_slot must be greater than 0.
-  BitMap2D(idx_t size_in_slots, idx_t bits_per_slot);
+  BitMap2D(idx_t size_in_slots, idx_t bits_per_slot) :
+      _map(size_in_slots * bits_per_slot), _bits_per_slot(bits_per_slot) {}
 
   idx_t size_in_bits() {
     return _map.size();
diff --git a/hotspot/src/share/vm/utilities/bitMap.inline.hpp b/hotspot/src/share/vm/utilities/bitMap.inline.hpp
index 57cb847..49521d8 100644
--- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp
+++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp
@@ -121,18 +121,18 @@
   for (idx_t i = beg; i < end; ++i) map[i] = ~(bm_word_t)0;
 }
 
-
-inline void BitMap::clear_range_of_words(idx_t beg, idx_t end) {
-  bm_word_t* map = _map;
+inline void BitMap::clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end) {
   for (idx_t i = beg; i < end; ++i) map[i] = 0;
 }
 
+inline void BitMap::clear_range_of_words(idx_t beg, idx_t end) {
+  clear_range_of_words(_map, beg, end);
+}
 
 inline void BitMap::clear() {
   clear_range_of_words(0, size_in_words());
 }
 
-
 inline void BitMap::par_clear_range(idx_t beg, idx_t end, RangeSizeHint hint) {
   if (hint == small_range && end - beg == 1) {
     par_at_put(beg, false);
@@ -359,7 +359,12 @@
 
 inline void BitMap2D::at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
   verify_bit_within_slot_index(bit_within_slot_index);
-  _map.at_put_grow(bit_index(slot_index, bit_within_slot_index), value);
+
+  idx_t bit = bit_index(slot_index, bit_within_slot_index);
+  if (bit >= _map.size()) {
+    _map.resize(2 * MAX2(_map.size(), bit));
+  }
+  _map.at_put(bit, value);
 }
 
 inline void BitMap2D::clear() {
diff --git a/hotspot/src/share/vm/utilities/debug.cpp b/hotspot/src/share/vm/utilities/debug.cpp
index ad1e9e4..b284448 100644
--- a/hotspot/src/share/vm/utilities/debug.cpp
+++ b/hotspot/src/share/vm/utilities/debug.cpp
@@ -58,6 +58,8 @@
 #include "trace/tracing.hpp"
 #endif
 
+#include <stdio.h>
+
 #ifndef ASSERT
 #  ifdef _DEBUG
    // NOTE: don't turn the lines below into a comment -- if you're getting
@@ -187,7 +189,7 @@
     return true;
   }
 
-  if (!is_error_reported()) {
+  if (!is_error_reported() && !SuppressFatalErrorMessage) {
     // print a friendly hint:
     fdStream out(defaultStream::output_fd());
     out.print_raw_cr("# To suppress the following error report, specify this argument");
@@ -262,6 +264,21 @@
   report_vm_error(file, line, "Unimplemented()");
 }
 
+#ifdef ASSERT
+bool is_executing_unit_tests() {
+  return ExecutingUnitTests;
+}
+
+void report_assert_msg(const char* msg, ...) {
+  va_list ap;
+  va_start(ap, msg);
+
+  fprintf(stderr, "assert failed: %s\n", err_msg(FormatBufferDummy(), msg, ap).buffer());
+
+  va_end(ap);
+}
+#endif // ASSERT
+
 void report_untested(const char* file, int line, const char* message) {
 #ifndef PRODUCT
   warning("Untested: %s in %s: %d\n", message, file, line);
diff --git a/hotspot/src/share/vm/utilities/debug.hpp b/hotspot/src/share/vm/utilities/debug.hpp
index 398e38b..d5da6db 100644
--- a/hotspot/src/share/vm/utilities/debug.hpp
+++ b/hotspot/src/share/vm/utilities/debug.hpp
@@ -46,11 +46,15 @@
   FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3);
 };
 
+class FormatBufferDummy {};
+
 // Use stack for buffer
 template <size_t bufsz = FormatBufferBase::BufferSize>
 class FormatBuffer : public FormatBufferBase {
  public:
   inline FormatBuffer(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
+  // since va_list is unspecified type (can be char*), we use FormatBufferDummy to disambiguate these constructors
+  inline FormatBuffer(FormatBufferDummy dummy, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0);
   inline void append(const char* format, ...)  ATTRIBUTE_PRINTF(2, 3);
   inline void print(const char* format, ...)  ATTRIBUTE_PRINTF(2, 3);
   inline void printv(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
@@ -75,6 +79,11 @@
 }
 
 template <size_t bufsz>
+FormatBuffer<bufsz>::FormatBuffer(FormatBufferDummy dummy, const char * format, va_list ap) : FormatBufferBase(_buffer) {
+  jio_vsnprintf(_buf, bufsz, format, ap);
+}
+
+template <size_t bufsz>
 FormatBuffer<bufsz>::FormatBuffer() : FormatBufferBase(_buffer) {
   _buf[0] = '\0';
 }
@@ -119,11 +128,13 @@
 #define vmassert(p, ...)                                                       \
 do {                                                                           \
   if (!(p)) {                                                                  \
+    if (is_executing_unit_tests()) {                                           \
+      report_assert_msg(__VA_ARGS__);                                          \
+    }                                                                          \
     report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \
     BREAKPOINT;                                                                \
   }                                                                            \
 } while (0)
-
 #endif
 
 // For backward compatibility.
@@ -210,10 +221,16 @@
 // ATTRIBUTE_PRINTF works with gcc >= 4.8 and any other compiler.
 void report_vm_error(const char* file, int line, const char* error_msg,
                      const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5);
+#ifdef ASSERT
+void report_assert_msg(const char* msg, ...) ATTRIBUTE_PRINTF(1, 2);
+#endif // ASSERT
 #else
 // GCC < 4.8 warns because of empty format string.  Warning can not be switched off selectively.
 void report_vm_error(const char* file, int line, const char* error_msg,
                      const char* detail_fmt, ...);
+#ifdef ASSERT
+void report_assert_msg(const char* msg, ...);
+#endif // ASSERT
 #endif
 void report_vm_status_error(const char* file, int line, const char* error_msg,
                             int status, const char* detail);
@@ -225,6 +242,11 @@
 void report_unimplemented(const char* file, int line);
 void report_untested(const char* file, int line, const char* message);
 
+#ifdef ASSERT
+// unit test support
+bool is_executing_unit_tests();
+#endif // ASSERT
+
 void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
 
 // Compile-time asserts.  Cond must be a compile-time constant expression that
diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
index 36846d9..4c9e513 100644
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
@@ -1004,7 +1004,9 @@
 class VMOperationQueue;
 
 class CodeBlob;
-class  nmethod;
+class  CompiledMethod;
+class   nmethod;
+class RuntimeBlob;
 class  OSRAdapter;
 class  I2CAdapter;
 class  C2IAdapter;
diff --git a/hotspot/src/share/vm/utilities/growableArray.hpp b/hotspot/src/share/vm/utilities/growableArray.hpp
index fccbad3..abe5ace 100644
--- a/hotspot/src/share/vm/utilities/growableArray.hpp
+++ b/hotspot/src/share/vm/utilities/growableArray.hpp
@@ -249,6 +249,10 @@
     return _data[_len-1];
   }
 
+  E last() const {
+    return top();
+  }
+
   GrowableArrayIterator<E> begin() const {
     return GrowableArrayIterator<E>(this, 0);
   }
@@ -362,6 +366,24 @@
     _data[idx] = elem;
   }
 
+  void insert_before(const int idx, const GrowableArray<E>* array) {
+    assert(0 <= idx && idx <= _len, "illegal index");
+    check_nesting();
+    int array_len = array->length();
+    int new_len = _len + array_len;
+    if (new_len >= _max) grow(new_len);
+
+    for (int j = _len - 1; j >= idx; j--) {
+      _data[j + array_len] = _data[j];
+    }
+
+    for (int j = 0; j < array_len; j++) {
+      _data[idx + j] = array->_data[j];
+    }
+
+    _len += array_len;
+  }
+
   void appendAll(const GrowableArray<E>* l) {
     for (int i = 0; i < l->_len; i++) {
       raw_at_put_grow(_len, l->_data[i], E());
diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp
index 985885c..c6543b7 100644
--- a/hotspot/src/share/vm/utilities/internalVMTests.cpp
+++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp
@@ -78,9 +78,11 @@
   run_unit_test(Test_log_prefix);
   run_unit_test(Test_log_big);
   run_unit_test(Test_logtagset_duplicates);
+  run_unit_test(Test_logtagset_descriptions);
   run_unit_test(Test_log_file_startup_rotation);
   run_unit_test(Test_log_file_startup_truncation);
   run_unit_test(Test_invalid_log_file);
+  run_unit_test(Test_multiline_logging);
   run_unit_test(DirectivesParser_test);
   run_unit_test(Test_TempNewSymbol);
 #if INCLUDE_VM_STRUCTS
@@ -98,6 +100,7 @@
   run_unit_test(test_memset_with_concurrent_readers);
   run_unit_test(TestPredictions_test);
   run_unit_test(WorkerDataArray_test);
+  run_unit_test(ParallelCompact_test);
 #endif
   tty->print_cr("All internal VM tests passed");
 }
diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp
index 4ca94f3..095cc8b 100644
--- a/hotspot/src/share/vm/utilities/vmError.cpp
+++ b/hotspot/src/share/vm/utilities/vmError.cpp
@@ -28,6 +28,7 @@
 #include "compiler/compileBroker.hpp"
 #include "compiler/disassembler.hpp"
 #include "gc/shared/collectedHeap.hpp"
+#include "logging/logConfiguration.hpp"
 #include "prims/whitebox.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/atomic.inline.hpp"
@@ -289,8 +290,8 @@
 
 void VMError::report(outputStream* st, bool _verbose) {
 
-# define BEGIN if (_current_step == 0) { _current_step = 1;
-# define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s;
+# define BEGIN if (_current_step == 0) { _current_step = __LINE__;
+# define STEP(s) } if (_current_step < __LINE__) { _current_step = __LINE__; _current_step_info = s;
 # define END }
 
   // don't allocate large buffer on stack
@@ -298,7 +299,7 @@
 
   BEGIN
 
-  STEP(10, "(printing fatal error message)")
+  STEP("printing fatal error message")
 
     st->print_cr("#");
     if (should_report_bug(_id)) {
@@ -313,21 +314,21 @@
 
   // test secondary error handling. Test it twice, to test that resetting
   // error handler after a secondary crash works.
-  STEP(20, "(test secondary crash 1)")
+  STEP("test secondary crash 1")
     if (_verbose && TestCrashInErrorHandler != 0) {
       st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
         TestCrashInErrorHandler);
       controlled_crash(TestCrashInErrorHandler);
     }
 
-  STEP(30, "(test secondary crash 2)")
+  STEP("test secondary crash 2")
     if (_verbose && TestCrashInErrorHandler != 0) {
       st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
         TestCrashInErrorHandler);
       controlled_crash(TestCrashInErrorHandler);
     }
 
-  STEP(40, "(test safefetch in error handler)")
+  STEP("test safefetch in error handler")
     // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
     // to test that resetting the signal handler works correctly.
     if (_verbose && TestSafeFetchInErrorHandler) {
@@ -348,7 +349,7 @@
     }
 #endif // PRODUCT
 
-  STEP(50, "(printing type of error)")
+  STEP("printing type of error")
 
      switch(_id) {
        case OOM_MALLOC_ERROR:
@@ -383,7 +384,7 @@
          break;
      }
 
-  STEP(60, "(printing exception/signal name)")
+  STEP("printing exception/signal name")
 
      st->print_cr("#");
      st->print("#  ");
@@ -413,14 +414,14 @@
        }
      }
 
-  STEP(70, "(printing current thread and pid)")
+  STEP("printing current thread and pid")
 
      // process id, thread id
      st->print(", pid=%d", os::current_process_id());
      st->print(", tid=" UINTX_FORMAT, os::current_thread_id());
      st->cr();
 
-  STEP(80, "(printing error message)")
+  STEP("printing error message")
 
      if (should_report_bug(_id)) {  // already printed the message.
        // error message
@@ -431,11 +432,11 @@
        }
      }
 
-  STEP(90, "(printing Java version string)")
+  STEP("printing Java version string")
 
      report_vm_version(st, buf, sizeof(buf));
 
-  STEP(100, "(printing problematic frame)")
+  STEP("printing problematic frame")
 
      // Print current frame if we have a context (i.e. it's a crash)
      if (_context) {
@@ -447,7 +448,7 @@
        st->print_cr("#");
      }
 
-  STEP(110, "(printing core file information)")
+  STEP("printing core file information")
     st->print("# ");
     if (CreateCoredumpOnCrash) {
       if (coredump_status) {
@@ -461,13 +462,13 @@
     st->cr();
     st->print_cr("#");
 
-  STEP(120, "(printing bug submit message)")
+  STEP("printing bug submit message")
 
      if (should_report_bug(_id) && _verbose) {
        print_bug_submit_message(st, _thread);
      }
 
-  STEP(130, "(printing summary)" )
+  STEP("printing summary")
 
      if (_verbose) {
        st->cr();
@@ -475,7 +476,7 @@
        st->cr();
      }
 
-  STEP(140, "(printing VM option summary)" )
+  STEP("printing VM option summary")
 
      if (_verbose) {
        // VM options
@@ -483,20 +484,20 @@
        st->cr();
      }
 
-  STEP(150, "(printing summary machine and OS info)")
+  STEP("printing summary machine and OS info")
 
      if (_verbose) {
        os::print_summary_info(st, buf, sizeof(buf));
      }
 
 
-  STEP(160, "(printing date and time)" )
+  STEP("printing date and time")
 
      if (_verbose) {
        os::print_date_and_time(st, buf, sizeof(buf));
      }
 
-  STEP(170, "(printing thread)" )
+  STEP("printing thread")
 
      if (_verbose) {
        st->cr();
@@ -504,7 +505,7 @@
        st->cr();
      }
 
-  STEP(180, "(printing current thread)" )
+  STEP("printing current thread")
 
      // current thread
      if (_verbose) {
@@ -518,7 +519,7 @@
        st->cr();
      }
 
-  STEP(190, "(printing current compile task)" )
+  STEP("printing current compile task")
 
      if (_verbose && _thread && _thread->is_Compiler_thread()) {
         CompilerThread* t = (CompilerThread*)_thread;
@@ -531,7 +532,7 @@
      }
 
 
-  STEP(200, "(printing stack bounds)" )
+  STEP("printing stack bounds")
 
      if (_verbose) {
        st->print("Stack: ");
@@ -562,7 +563,7 @@
        st->cr();
      }
 
-  STEP(210, "(printing native stack)" )
+  STEP("printing native stack")
 
    if (_verbose) {
      if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) {
@@ -576,13 +577,13 @@
      }
    }
 
-  STEP(220, "(printing Java stack)" )
+  STEP("printing Java stack")
 
      if (_verbose && _thread && _thread->is_Java_thread()) {
        print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf));
      }
 
-  STEP(230, "(printing target Java thread stack)" )
+  STEP("printing target Java thread stack")
 
      // printing Java thread stack trace if it is involved in GC crash
      if (_verbose && _thread && (_thread->is_Named_thread())) {
@@ -593,7 +594,7 @@
        }
      }
 
-  STEP(240, "(printing siginfo)" )
+  STEP("printing siginfo")
 
      // signal no, signal code, address that caused the fault
      if (_verbose && _siginfo) {
@@ -602,7 +603,7 @@
        st->cr();
      }
 
-  STEP(245, "(CDS archive access warning)" )
+  STEP("CDS archive access warning")
 
      // Print an explicit hint if we crashed on access to the CDS archive.
      if (_verbose && _siginfo) {
@@ -610,7 +611,7 @@
        st->cr();
      }
 
-  STEP(250, "(printing register info)")
+  STEP("printing register info")
 
      // decode register contents if possible
      if (_verbose && _context && Universe::is_fully_initialized()) {
@@ -618,7 +619,7 @@
        st->cr();
      }
 
-  STEP(260, "(printing registers, top of stack, instructions near pc)")
+  STEP("printing registers, top of stack, instructions near pc")
 
      // registers, top of stack, instructions near pc
      if (_verbose && _context) {
@@ -626,7 +627,7 @@
        st->cr();
      }
 
-  STEP(265, "(printing code blob if possible)")
+  STEP("printing code blob if possible")
 
      if (_verbose && _context) {
        CodeBlob* cb = CodeCache::find_blob(_pc);
@@ -651,7 +652,7 @@
        }
      }
 
-  STEP(270, "(printing VM operation)" )
+  STEP("printing VM operation")
 
      if (_verbose && _thread && _thread->is_VM_thread()) {
         VMThread* t = (VMThread*)_thread;
@@ -663,7 +664,7 @@
         }
      }
 
-  STEP(280, "(printing process)" )
+  STEP("printing process")
 
      if (_verbose) {
        st->cr();
@@ -671,7 +672,7 @@
        st->cr();
      }
 
-  STEP(290, "(printing all threads)" )
+  STEP("printing all threads")
 
      // all threads
      if (_verbose && _thread) {
@@ -679,7 +680,7 @@
        st->cr();
      }
 
-  STEP(300, "(printing VM state)" )
+  STEP("printing VM state")
 
      if (_verbose) {
        // Safepoint state
@@ -701,7 +702,7 @@
        st->cr();
      }
 
-  STEP(310, "(printing owned locks on error)" )
+  STEP("printing owned locks on error")
 
      // mutexes/monitors that currently have an owner
      if (_verbose) {
@@ -709,7 +710,7 @@
        st->cr();
      }
 
-  STEP(320, "(printing number of OutOfMemoryError and StackOverflow exceptions)")
+  STEP("printing number of OutOfMemoryError and StackOverflow exceptions")
 
      if (_verbose && Exceptions::has_exception_counts()) {
        st->print_cr("OutOfMemory and StackOverflow Exception counts:");
@@ -717,7 +718,7 @@
        st->cr();
      }
 
-  STEP(330, "(printing compressed oops mode")
+  STEP("printing compressed oops mode")
 
      if (_verbose && UseCompressedOops) {
        Universe::print_compressed_oops_mode(st);
@@ -727,7 +728,7 @@
        st->cr();
      }
 
-  STEP(340, "(printing heap information)" )
+  STEP("printing heap information")
 
      if (_verbose && Universe::is_fully_initialized()) {
        Universe::heap()->print_on_error(st);
@@ -736,7 +737,7 @@
        st->cr();
      }
 
-  STEP(350, "(printing code cache information)" )
+  STEP("printing code cache information")
 
      if (_verbose && Universe::is_fully_initialized()) {
        // print code cache information before vm abort
@@ -744,14 +745,14 @@
        st->cr();
      }
 
-  STEP(360, "(printing ring buffers)" )
+  STEP("printing ring buffers")
 
      if (_verbose) {
        Events::print_all(st);
        st->cr();
      }
 
-  STEP(370, "(printing dynamic libraries)" )
+  STEP("printing dynamic libraries")
 
      if (_verbose) {
        // dynamic libraries, or memory map
@@ -759,7 +760,7 @@
        st->cr();
      }
 
-  STEP(380, "(printing VM options)" )
+  STEP("printing VM options")
 
      if (_verbose) {
        // VM options
@@ -767,33 +768,40 @@
        st->cr();
      }
 
-  STEP(390, "(printing warning if internal testing API used)" )
+  STEP("printing warning if internal testing API used")
 
      if (WhiteBox::used()) {
        st->print_cr("Unsupported internal testing APIs have been used.");
        st->cr();
      }
 
-  STEP(400, "(printing all environment variables)" )
+  STEP("printing log configuration")
+    if (_verbose){
+      st->print_cr("Logging:");
+      LogConfiguration::describe_current_configuration(st);
+      st->cr();
+    }
+
+  STEP("printing all environment variables")
 
      if (_verbose) {
        os::print_environment_variables(st, env_list);
        st->cr();
      }
 
-  STEP(410, "(printing signal handlers)" )
+  STEP("printing signal handlers")
 
      if (_verbose) {
        os::print_signal_handlers(st, buf, sizeof(buf));
        st->cr();
      }
 
-  STEP(420, "(Native Memory Tracking)" )
+  STEP("Native Memory Tracking")
      if (_verbose) {
        MemTracker::error_report(st);
      }
 
-  STEP(430, "(printing system)" )
+  STEP("printing system")
 
      if (_verbose) {
        st->cr();
@@ -801,27 +809,27 @@
        st->cr();
      }
 
-  STEP(440, "(printing OS information)" )
+  STEP("printing OS information")
 
      if (_verbose) {
        os::print_os_info(st);
        st->cr();
      }
 
-  STEP(450, "(printing CPU info)" )
+  STEP("printing CPU info")
      if (_verbose) {
        os::print_cpu_info(st, buf, sizeof(buf));
        st->cr();
      }
 
-  STEP(460, "(printing memory info)" )
+  STEP("printing memory info")
 
      if (_verbose) {
        os::print_memory_info(st);
        st->cr();
      }
 
-  STEP(470, "(printing internal vm info)" )
+  STEP("printing internal vm info")
 
      if (_verbose) {
        st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
@@ -829,7 +837,7 @@
      }
 
   // print a defined marker to show that error handling finished correctly.
-  STEP(480, "(printing end marker)" )
+  STEP("printing end marker")
 
      if (_verbose) {
        st->print_cr("END.");
@@ -850,35 +858,35 @@
   char buf[O_BUFLEN];
   report_vm_version(st, buf, sizeof(buf));
 
-  // STEP("(printing summary)")
+  // STEP("printing summary")
 
   st->cr();
   st->print_cr("---------------  S U M M A R Y ------------");
   st->cr();
 
-  // STEP("(printing VM option summary)")
+  // STEP("printing VM option summary")
 
   // VM options
   Arguments::print_summary_on(st);
   st->cr();
 
-  // STEP("(printing summary machine and OS info)")
+  // STEP("printing summary machine and OS info")
 
   os::print_summary_info(st, buf, sizeof(buf));
 
-  // STEP("(printing date and time)")
+  // STEP("printing date and time")
 
   os::print_date_and_time(st, buf, sizeof(buf));
 
-  // Skip: STEP("(printing thread)")
+  // Skip: STEP("printing thread")
 
-  // STEP("(printing process)")
+  // STEP("printing process")
 
   st->cr();
   st->print_cr("---------------  P R O C E S S  ---------------");
   st->cr();
 
-  // STEP("(printing number of OutOfMemoryError and StackOverflow exceptions)")
+  // STEP("printing number of OutOfMemoryError and StackOverflow exceptions")
 
   if (Exceptions::has_exception_counts()) {
     st->print_cr("OutOfMemory and StackOverflow Exception counts:");
@@ -886,7 +894,7 @@
     st->cr();
   }
 
-  // STEP("(printing compressed oops mode")
+  // STEP("printing compressed oops mode")
 
   if (UseCompressedOops) {
     Universe::print_compressed_oops_mode(st);
@@ -896,7 +904,7 @@
     st->cr();
   }
 
-  // STEP("(printing heap information)")
+  // STEP("printing heap information")
 
   if (Universe::is_fully_initialized()) {
     Universe::heap()->print_on_error(st);
@@ -905,7 +913,7 @@
     st->cr();
   }
 
-  // STEP("(printing code cache information)")
+  // STEP("printing code cache information")
 
   if (Universe::is_fully_initialized()) {
     // print code cache information before vm abort
@@ -913,72 +921,77 @@
     st->cr();
   }
 
-  // STEP("(printing ring buffers)")
+  // STEP("printing ring buffers")
 
   Events::print_all(st);
   st->cr();
 
-  // STEP("(printing dynamic libraries)")
+  // STEP("printing dynamic libraries")
 
   // dynamic libraries, or memory map
   os::print_dll_info(st);
   st->cr();
 
-  // STEP("(printing VM options)")
+  // STEP("printing VM options")
 
   // VM options
   Arguments::print_on(st);
   st->cr();
 
-  // STEP("(printing warning if internal testing API used)")
+  // STEP("printing warning if internal testing API used")
 
   if (WhiteBox::used()) {
     st->print_cr("Unsupported internal testing APIs have been used.");
     st->cr();
   }
 
-  // STEP("(printing all environment variables)")
+  // STEP("printing log configuration")
+  st->print_cr("Logging:");
+  LogConfiguration::describe(st);
+  st->cr();
+
+  // STEP("printing all environment variables")
 
   os::print_environment_variables(st, env_list);
   st->cr();
 
-  // STEP("(printing signal handlers)")
+  // STEP("printing signal handlers")
 
   os::print_signal_handlers(st, buf, sizeof(buf));
   st->cr();
 
-  // STEP("(Native Memory Tracking)")
+  // STEP("Native Memory Tracking")
 
   MemTracker::error_report(st);
 
-  // STEP("(printing system)")
+  // STEP("printing system")
 
   st->cr();
   st->print_cr("---------------  S Y S T E M  ---------------");
   st->cr();
 
-  // STEP("(printing OS information)")
+  // STEP("printing OS information")
 
   os::print_os_info(st);
   st->cr();
 
-  // STEP("(printing CPU info)")
+  // STEP("printing CPU info")
 
   os::print_cpu_info(st, buf, sizeof(buf));
   st->cr();
 
-  // STEP("(printing memory info)")
+  // STEP("printing memory info")
 
   os::print_memory_info(st);
   st->cr();
 
-  // STEP("(printing internal vm info)")
+  // STEP("printing internal vm info")
 
   st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
   st->cr();
 
   // print a defined marker to show that error handling finished correctly.
-  // STEP("(printing end marker)")
+  // STEP("printing end marker")
 
   st->print_cr("END.");
 }
@@ -1177,7 +1190,7 @@
       }
 
       jio_snprintf(buffer, sizeof(buffer),
-                   "[error occurred during error reporting %s, id 0x%x]",
+                   "[error occurred during error reporting (%s), id 0x%x]",
                    _current_step_info, _id);
       if (log.is_open()) {
         log.cr();
diff --git a/hotspot/src/share/vm/utilities/vmError.hpp b/hotspot/src/share/vm/utilities/vmError.hpp
index 62ce62e..23f973b 100644
--- a/hotspot/src/share/vm/utilities/vmError.hpp
+++ b/hotspot/src/share/vm/utilities/vmError.hpp
@@ -33,6 +33,7 @@
 class VMError : public AllStatic {
   friend class VM_ReportJavaOutOfMemory;
   friend class Decoder;
+  friend class VMStructs;
 
   static int         _id;               // Solaris/Linux signals: 0 - SIGRTMAX
                                         // Windows exceptions: 0xCxxxxxxx system errors
diff --git a/hotspot/test/Makefile b/hotspot/test/Makefile
index 1dfecd6..2f2f810 100644
--- a/hotspot/test/Makefile
+++ b/hotspot/test/Makefile
@@ -52,6 +52,11 @@
 WC        = wc
 ZIP       = zip
 
+define NEWLINE
+
+
+endef
+
 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
 UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
 ifeq ($(UNAME_S), SunOS)
@@ -301,7 +306,10 @@
 endif
 
 ifdef CONCURRENCY
-  EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
+  JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+endif
+ifdef EXTRA_JTREG_OPTIONS
+  JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 endif
 
 # Default JTREG to run
@@ -321,8 +329,6 @@
 # Multiply by 4 the timeout factor
 JTREG_TIMEOUT_OPTION =  -timeoutFactor:4
 JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
-# Add any extra options
-JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 # Set other vm and test options
 JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%)
 
@@ -436,6 +442,20 @@
 
 ################################################################
 
+# Run the native gtest tests from the test image
+
+hotspot_gtest:
+	$(foreach v, $(JVM_VARIANTS), \
+	  $(MAKE) hotspot_gtest$v $(NEWLINE) )
+
+hotspot_gtestserver hotspot_gtestclient hotspot_gtestminimal: hotspot_gtest%:
+	$(TESTNATIVE_DIR)/hotspot/gtest/$*/gtestLauncher \
+	    -jdk $(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")
+
+PHONY_LIST += hotspot_gtest hotspot_gtestserver hotspot_gtestclient \
+    hotspot_gtestminimal
+
+################################################################
 # Phony targets (e.g. these are not filenames)
 .PHONY: all clean prep $(PHONY_LIST)
 
diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups
index 18dc949..262232e 100644
--- a/hotspot/test/TEST.groups
+++ b/hotspot/test/TEST.groups
@@ -338,6 +338,7 @@
   sanity/ExecuteInternalVMTests.java \
   gc/ \
   -gc/g1/ \
+  -gc/logging/TestUnifiedLoggingSwitchStress.java \
   -gc/stress \
   -gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java \
   -gc/cms/TestMBeanCMS.java \
@@ -353,7 +354,7 @@
   runtime/ \
  -runtime/ErrorHandling/ErrorHandler.java \
  -runtime/RedefineObject/TestRedefineObject.java \
- -runtime/8003720/Test8003720.java \
+ -runtime/MirrorFrame/Test8003720.java \
  -runtime/Metaspace/FragmentMetaspace.java \
  -runtime/Metaspace/FragmentMetaspaceSimple.java \
  -runtime/Thread/TestThreadDumpMonitorContention.java \
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/hotspot/test/compiler/arguments/TestUseCompiler.java
similarity index 69%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to hotspot/test/compiler/arguments/TestUseCompiler.java
index 9e5a4a7..edf3540 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/hotspot/test/compiler/arguments/TestUseCompiler.java
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -22,16 +20,19 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
-
-import java.util.Properties;
 
 /**
- * Interface to plugin (container) context.
+ * @test TestUseCompiler
+ * @bug 8086068
+ * @summary Tests execution with inconsistent UseCompiler flag combination.
+ * @run main/othervm -Xint -XX:+UseCompiler TestUseCompiler
+ * @run main/othervm -XX:+UseCompiler -Xint TestUseCompiler
  */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+
+public class TestUseCompiler {
+
+    public static void main(String args[]) {
+        System.out.println("Passed");
+    }
 }
+
diff --git a/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java b/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java
index a2430dc..ccd2cfe 100644
--- a/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java
+++ b/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java
@@ -72,6 +72,7 @@
     }
 
     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+    private static final int TIERED_STOP_AT_LEVEL = WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue();
 
     static boolean deoptimize(Method method, Object src_obj) throws Exception {
         for (int i = 0; i < 10; i++) {
@@ -84,7 +85,9 @@
     }
 
     static public void main(String[] args) throws Exception {
-        if (Platform.isServer()) {
+        // Only execute if C2 is available
+        if (Platform.isServer() &&
+            TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
             int[] src = new int[10];
             Object src_obj = new Object();
             Method method_m1 = TestArrayCopyNoInitDeopt.class.getMethod("m1", Object.class);
diff --git a/hotspot/test/compiler/c2/5057225/Test5057225.java b/hotspot/test/compiler/c2/5057225/Test5057225.java
index 106d390..7cf64f9 100644
--- a/hotspot/test/compiler/c2/5057225/Test5057225.java
+++ b/hotspot/test/compiler/c2/5057225/Test5057225.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 5057225
  * @summary Remove useless I2L conversions
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -Xcomp -XX:CompileOnly=Test5057225.doload Test5057225
  */
diff --git a/hotspot/test/compiler/c2/6603011/Test.java b/hotspot/test/compiler/c2/6603011/Test.java
index bc45707..39c0419 100644
--- a/hotspot/test/compiler/c2/6603011/Test.java
+++ b/hotspot/test/compiler/c2/6603011/Test.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 6603011
  * @summary long/int division by constant
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -Xcomp -Xbatch -XX:-Inline Test
  */
diff --git a/hotspot/test/compiler/c2/6800154/Test6800154.java b/hotspot/test/compiler/c2/6800154/Test6800154.java
index 05ad662..b43c155 100644
--- a/hotspot/test/compiler/c2/6800154/Test6800154.java
+++ b/hotspot/test/compiler/c2/6800154/Test6800154.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 6800154
  * @summary Add comments to long_by_long_mulhi() for better understandability
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154
  */
diff --git a/hotspot/test/compiler/c2/6805724/Test6805724.java b/hotspot/test/compiler/c2/6805724/Test6805724.java
index 922b297d..afa20d2 100644
--- a/hotspot/test/compiler/c2/6805724/Test6805724.java
+++ b/hotspot/test/compiler/c2/6805724/Test6805724.java
@@ -26,6 +26,7 @@
  * @bug 6805724
  * @summary ModLNode::Ideal() generates functionally incorrect graph
  *          when divisor is any (2^k-1) constant.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
  */
diff --git a/hotspot/test/compiler/c2/6968348/Test6968348.java b/hotspot/test/compiler/c2/6968348/Test6968348.java
index b13b7e6..432f45f 100644
--- a/hotspot/test/compiler/c2/6968348/Test6968348.java
+++ b/hotspot/test/compiler/c2/6968348/Test6968348.java
@@ -31,7 +31,7 @@
  * @run main Test6968348
  */
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.lang.reflect.*;
 
 public class Test6968348 {
@@ -40,7 +40,7 @@
     static int array_long_base_offset;
 
     public static void main(String[] args) throws Exception {
-        Class c = Test6968348.class.getClassLoader().loadClass("sun.misc.Unsafe");
+        Class c = Test6968348.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
         Field f = c.getDeclaredField("theUnsafe");
         f.setAccessible(true);
         unsafe = (Unsafe)f.get(c);
diff --git a/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java b/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java
index 08d6848..de48a6e 100644
--- a/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java
+++ b/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java
@@ -32,7 +32,7 @@
 
 import java.lang.ref.*;
 import java.lang.reflect.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class Test7190310_unsafe {
 
@@ -48,7 +48,7 @@
   private TestObject obj;
 
   public static void main(String[] args) throws Exception {
-    Class c = Test7190310_unsafe.class.getClassLoader().loadClass("sun.misc.Unsafe");
+    Class c = Test7190310_unsafe.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
     Field f = c.getDeclaredField("theUnsafe");
     f.setAccessible(true);
     Unsafe unsafe = (Unsafe)f.get(c);
diff --git a/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java b/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java
index fc8ab3b..a405f56 100644
--- a/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java
+++ b/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java
@@ -32,7 +32,7 @@
  * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS
  */
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.lang.reflect.*;
 
 public class TestIntUnsafeCAS {
@@ -47,7 +47,7 @@
   private static final int BASE;
   static {
     try {
-      Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("sun.misc.Unsafe");
+      Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
       Field f = c.getDeclaredField("theUnsafe");
       f.setAccessible(true);
       unsafe = (Unsafe)f.get(c);
diff --git a/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java b/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java
index 3c8ddf3..6cbab7a 100644
--- a/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java
+++ b/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java
@@ -32,7 +32,7 @@
  * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeVolatile
  */
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.lang.reflect.*;
 
 public class TestIntUnsafeVolatile {
@@ -47,7 +47,7 @@
   private static final int BASE;
   static {
     try {
-      Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("sun.misc.Unsafe");
+      Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
       Field f = c.getDeclaredField("theUnsafe");
       f.setAccessible(true);
       unsafe = (Unsafe)f.get(c);
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java
index 12c14cb..3124d3d 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @library /test/lib /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @build compiler.calls.common.InvokeDynamic
  * @build compiler.calls.common.InvokeDynamicPatcher
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java
index 097cf9d..4916220 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @library /test/lib /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @build compiler.calls.common.InvokeDynamic
  * @build compiler.calls.common.InvokeDynamicPatcher
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java
index 98baacb..3721632 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @library /test/lib /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @build compiler.calls.common.InvokeDynamic
  * @build compiler.calls.common.InvokeDynamicPatcher
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java
index fec0fda..34f86cd 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeInterface
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java
index 2baf4e7..fb30210 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeInterface
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java
index ec394a1..a930528 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeInterface
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java
index 5d659f5..39648e7 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java
index 1a6c6c9..25cac6b 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java
index e1b6474..e30115a 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java
index f31ef6b..8cda5e0 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java
index 8a8b856..1d998e0 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java
index 955a727..a0c8009 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java
index 53fb39a..6ac0e2b 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java
index d875be7..9f03a2c 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java
index 0f69bb5..93643d6 100644
--- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java
index ffc4fa9..17d1512 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @library /test/lib /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @build compiler.calls.common.InvokeDynamic
  * @build compiler.calls.common.InvokeDynamicPatcher
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java
index 9579fc2..5988ac6 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @library /test/lib /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @build compiler.calls.common.InvokeDynamic
  * @build compiler.calls.common.InvokeDynamicPatcher
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java
index 78f2f55..7f0015a 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @library /test/lib /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @build compiler.calls.common.InvokeDynamic
  * @build compiler.calls.common.InvokeDynamicPatcher
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java
index 84b4e50..ea458db 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeInterface
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java
index a4f204f..ed150e4 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeInterface
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java
index ca00445..8adc7a6 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeInterface
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java
index d47585a..ad0b12f 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java
index 9c047fa..324ad86 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java
index 768d5eb..e34cca0 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java
index de4f6c2..96501a1 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java
index 0633909..8efd93d 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java
index 2a7deda..0bcbb37 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java
index fb7a645..eefe4e6 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java
index c4eecef..d44e140 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java
index 2ac9911..2011993 100644
--- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java
index 1a303bd..86a0784 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java
index 517422a..83520ce 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java
index 9b3d7ad..f9b3ce5 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeSpecial
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java
index 546ed82..7133571 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java
index 5e480d8..541b364 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java
index 9ace6ea..34ad481 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeStatic
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java
index 5605971..4f86421 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java
index 0977726..c0d3b77 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java
index d4ddd11..b83b9330 100644
--- a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java
+++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary /
  * @build compiler.calls.common.InvokeVirtual
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java
index 3745d73..65b3d58 100644
--- a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java
+++ b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java
@@ -22,7 +22,7 @@
  */
 
 import sun.hotspot.WhiteBox;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 import java.io.IOException;
 import java.lang.reflect.Method;
diff --git a/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java b/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java
index a824ec2..d141546 100644
--- a/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java
+++ b/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java
@@ -31,6 +31,7 @@
  * @test MethodUnloadingTest
  * @bug 8029443
  * @summary "Tests the unloading of methods to to class unloading"
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build TestMethodUnloading
  * @build WorkerClass
diff --git a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java
index 85537e8..31e8d2b 100644
--- a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java
+++ b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java
@@ -35,6 +35,7 @@
  * @test OverflowCodeCacheTest
  * @bug 8059550
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build OverflowCodeCacheTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java b/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java
index b8408ea..57fc8e0 100644
--- a/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java
+++ b/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java
@@ -48,6 +48,7 @@
  * @test SegmentedCodeCacheDtraceTest
  * @bug 8015774
  * @requires os.family=="solaris"
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary / /test/lib
  * @build SegmentedCodeCacheDtraceTestWorker
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java b/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java
index bea23c6..f7838e5 100644
--- a/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java
+++ b/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java
@@ -28,6 +28,7 @@
 /**
  * @test BeanTypeTest
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build BeanTypeTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java b/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java
index faef9a2..6f99c25 100644
--- a/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java
+++ b/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java
@@ -28,6 +28,7 @@
 /**
  * @test CodeHeapBeanPresenceTest
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build CodeHeapBeanPresenceTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java b/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java
index a67812f..f695234 100644
--- a/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java
+++ b/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,7 @@
             Asserts.assertEQ(initialUsage, 0L, "Unexpected initial usage");
         }
         ArrayList<Long> blobs = new ArrayList<>();
-        long minAllocationUnit = CodeCacheUtils.MIN_ALLOCATION - headerSize;
+        long minAllocationUnit = Math.max(0, CodeCacheUtils.MIN_ALLOCATION - headerSize);
         /* now filling code cache with large-sized allocation first, since
          lots of small allocations takes too much time, so, just a small
          optimization */
diff --git a/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java b/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java
index 4b3b597..45107f0 100644
--- a/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java
+++ b/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java
@@ -28,6 +28,7 @@
 /**
  * @test ManagerNamesTest
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build ManagerNamesTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java b/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java
index 22eecc8..a3a0308 100644
--- a/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java
+++ b/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java
@@ -33,6 +33,7 @@
 /**
  * @test MemoryPoolsPresenceTest
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build MemoryPoolsPresenceTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java b/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java
index 69f1021..97b2143 100644
--- a/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java
+++ b/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java
@@ -37,6 +37,7 @@
 
 /*
  * @test PoolsIndependenceTest
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build PoolsIndependenceTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java b/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java
index 765eede..8f2e6f1 100644
--- a/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java
+++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@
 
     protected void runTest() {
         long headerSize = CodeCacheUtils.getHeaderSize(btype);
-        long allocationUnit = CodeCacheUtils.MIN_ALLOCATION - headerSize;
+        long allocationUnit = Math.max(0, CodeCacheUtils.MIN_ALLOCATION - headerSize);
         MemoryPoolMXBean bean = btype.getMemoryPool();
         long initialCount = bean.getUsageThresholdCount();
         long initialSize = bean.getUsage().getUsed();
diff --git a/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java b/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java
index 29b5263..1838226 100644
--- a/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java
+++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,9 +58,12 @@
         MemoryPoolMXBean bean = btype.getMemoryPool();
         long initialThresholdCount = bean.getUsageThresholdCount();
         long initialUsage = bean.getUsage().getUsed();
+
         bean.setUsageThreshold(initialUsage + 1 + CodeCacheUtils.MIN_ALLOCATION);
-        CodeCacheUtils.WB.allocateCodeBlob(CodeCacheUtils.MIN_ALLOCATION
-                - CodeCacheUtils.getHeaderSize(btype), btype.id);
+        long size = CodeCacheUtils.getHeaderSize(btype);
+
+        CodeCacheUtils.WB.allocateCodeBlob(Math.max(0, CodeCacheUtils.MIN_ALLOCATION
+                - size), btype.id);
         // a gc cycle triggers usage threshold recalculation
         CodeCacheUtils.WB.fullGC();
         CodeCacheUtils.assertEQorGTE(btype, bean.getUsageThresholdCount(), initialThresholdCount,
diff --git a/hotspot/test/compiler/codegen/6823354/Test6823354.java b/hotspot/test/compiler/codegen/6823354/Test6823354.java
index 6f9bc02..1ba60e1 100644
--- a/hotspot/test/compiler/codegen/6823354/Test6823354.java
+++ b/hotspot/test/compiler/codegen/6823354/Test6823354.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 6823354
  * @summary These methods can be instrinsified by using bit scan, bit test, and population count instructions.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -Xcomp -XX:CompileOnly=Test6823354.lzcomp,Test6823354.tzcomp,.dolzcomp,.dotzcomp Test6823354
  */
diff --git a/hotspot/test/compiler/codegen/IntRotateWithImmediate.java b/hotspot/test/compiler/codegen/IntRotateWithImmediate.java
index e174de6..3da2aec 100644
--- a/hotspot/test/compiler/codegen/IntRotateWithImmediate.java
+++ b/hotspot/test/compiler/codegen/IntRotateWithImmediate.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +25,7 @@
 /*
  * @test
  * @bug 8080190
+ * @bug 8154537
  * @key regression
  * @summary Test that the rotate distance used in the rotate instruction is properly masked with 0x1f
  * @run main/othervm -Xbatch -XX:-UseOnStackReplacement IntRotateWithImmediate
@@ -33,7 +35,7 @@
 public class IntRotateWithImmediate {
 
   // This is currently the same as Integer.rotateRight()
-  static int rotateRight(int i, int distance) {
+  static int rotateRight1(int i, int distance) {
     // On some architectures (i.e. x86_64 and ppc64) the following computation is
     // matched in the .ad file into a single MachNode which emmits a single rotate
     // machine instruction. It is important that the shift amount is masked to match
@@ -43,17 +45,29 @@
     return ((i >>> distance) | (i << -distance));
   }
 
-  static int compute(int x) {
-    return rotateRight(x, 3);
+  static int rotateRight2(int i, int distance) {
+      return ((i >>> distance) | (i << (32-distance)));
+  }
+
+  static int compute1(int x) {
+    return rotateRight1(x, 3);
+  }
+
+  static int compute2(int x) {
+    return rotateRight2(x, 3);
   }
 
   public static void main(String args[]) {
     int val = 4096;
 
-    int firstResult = compute(val);
+    int firstResult = compute1(val);
 
     for (int i = 0; i < 100000; i++) {
-      int newResult = compute(val);
+      int newResult = compute1(val);
+      if (firstResult != newResult) {
+        throw new InternalError(firstResult + " != " + newResult);
+      }
+      newResult = compute2(val);
       if (firstResult != newResult) {
         throw new InternalError(firstResult + " != " + newResult);
       }
diff --git a/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java b/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java
index 3dc057c..afba82b 100644
--- a/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java
+++ b/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java
@@ -24,6 +24,7 @@
 /*
  * @test InlineMatcherTest
  * @bug 8074095
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java
index 2541d9d..925c1c7 100644
--- a/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java
+++ b/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=compileonly
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commandfile.CompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java b/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java
index 77c2a2e..98b3c71 100644
--- a/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java
+++ b/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=exclude
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commandfile.ExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java b/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java
index ce45d52..18dd2a7 100644
--- a/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java
+++ b/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=log
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commandfile.LogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java b/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java
index 5e90521..f47b9a4 100644
--- a/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java
+++ b/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java
@@ -25,8 +25,8 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=print
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
- * @ignore 8140354
  * @build compiler.compilercontrol.commandfile.PrintTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
diff --git a/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java
index 7a1b0c1..d4e57e9 100644
--- a/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java
+++ b/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=compileonly
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commands.CompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java b/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java
index b84befc..f8311e7 100644
--- a/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java
+++ b/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=exclude
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commands.ExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/commands/LogTest.java b/hotspot/test/compiler/compilercontrol/commands/LogTest.java
index 4ffebe4..7f9db79 100644
--- a/hotspot/test/compiler/compilercontrol/commands/LogTest.java
+++ b/hotspot/test/compiler/compilercontrol/commands/LogTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=log
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commands.LogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/commands/PrintTest.java b/hotspot/test/compiler/compilercontrol/commands/PrintTest.java
index d9ac685..bbe9efe 100644
--- a/hotspot/test/compiler/compilercontrol/commands/PrintTest.java
+++ b/hotspot/test/compiler/compilercontrol/commands/PrintTest.java
@@ -25,8 +25,8 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=print
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
- * @ignore 8140354
  * @build compiler.compilercontrol.commands.PrintTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
diff --git a/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java
index 439e5e9..e351c42 100644
--- a/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java
+++ b/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to compile only specified  methods
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.directives.CompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java b/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java
index 0569cdf..5799fe2 100644
--- a/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java
+++ b/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to exclude methods from compilation
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.directives.ExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/directives/LogTest.java b/hotspot/test/compiler/compilercontrol/directives/LogTest.java
index 1f84d4a..0d5f9cc 100644
--- a/hotspot/test/compiler/compilercontrol/directives/LogTest.java
+++ b/hotspot/test/compiler/compilercontrol/directives/LogTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to turn on LogCompilation
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.directives.LogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/directives/PrintTest.java b/hotspot/test/compiler/compilercontrol/directives/PrintTest.java
index bbd92c1..ac45d43 100644
--- a/hotspot/test/compiler/compilercontrol/directives/PrintTest.java
+++ b/hotspot/test/compiler/compilercontrol/directives/PrintTest.java
@@ -25,8 +25,8 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to turn on print_assembly
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
- * @ignore 8140354
  * @build compiler.compilercontrol.directives.PrintTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java
index 372b50a..ec296ce 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to add and remove directives
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddAndRemoveTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java
index 5b2a9e2..7096373 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to compile only specified methods
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddCompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java
index a06c326..38125fb 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to exclude only specified methods
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java
index 266cf3c..7c14e41 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to log only specified methods
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddLogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java
index 9697711..ea8bd58 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java
@@ -26,6 +26,7 @@
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to print assembly
  *          only for specified methods
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddPrintAssemblyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java
index da1fef4..4635a7f 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java
@@ -26,6 +26,7 @@
  * @bug 8137167
  * @ignore 8140405
  * @summary Tests jcmd to be able to clear directives added via options
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.ClearDirectivesFileStackTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java
index c9d9f8d..20d7a7a 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests clear JCMD command
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.ClearDirectivesStackTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java b/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java
index 7afd4d6..74bc4ee 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java
@@ -25,8 +25,8 @@
  * @test
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to compile only specified methods
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
- * @ignore 8140354
  * @build compiler.compilercontrol.jcmd.PrintDirectivesTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
diff --git a/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java b/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java
index 26c2253..4cf2945 100644
--- a/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java
+++ b/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java
@@ -26,6 +26,7 @@
  * @bug 8137167
  * @summary Tests jcmd to be able to add a lot of huge directive files with
  *          parallel executed jcmds until timeout has reached
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.StressAddMultiThreadedTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/logcompilation/LogTest.java b/hotspot/test/compiler/compilercontrol/logcompilation/LogTest.java
new file mode 100644
index 0000000..001251c
--- /dev/null
+++ b/hotspot/test/compiler/compilercontrol/logcompilation/LogTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8137167
+ * @summary Tests LogCompilation executed standalone without log commands or directives
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
+ * @build compiler.compilercontrol.logcompilation.LogTest
+ *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *  -XX:+UnlockDiagnosticVMOptions compiler.compilercontrol.logcompilation.LogTest
+ */
+
+package compiler.compilercontrol.logcompilation;
+
+import compiler.compilercontrol.share.processors.LogProcessor;
+import compiler.compilercontrol.share.scenario.Scenario;
+
+public class LogTest {
+    public static void main(String[] args) {
+        Scenario.Builder builder = Scenario.getBuilder();
+        builder.addFlag("-XX:+UnlockDiagnosticVMOptions");
+        builder.addFlag("-XX:+LogCompilation");
+        builder.addFlag("-XX:LogFile=" + LogProcessor.LOG_FILE);
+        Scenario scenario = builder.build();
+        scenario.execute();
+    }
+}
diff --git a/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java b/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java
index 87cd26a..9ec1ecc 100644
--- a/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java
+++ b/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java
@@ -40,6 +40,7 @@
  * @test
  * @bug 8135068
  * @summary Tests CompilerCommand's method matcher
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ../share /
  * @build compiler.compilercontrol.matcher.MethodMatcherTest
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java b/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java
index c954dba..11d3858 100644
--- a/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java
+++ b/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Randomly generates commands with random types
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.mixed.RandomCommandsTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java b/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java
index e8739e8..46c7952 100644
--- a/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java
+++ b/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java
@@ -25,8 +25,8 @@
  * @test
  * @bug 8137167
  * @summary Randomly generates valid commands with random types
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
- * @ignore 8140354
  * @build compiler.compilercontrol.mixed.RandomValidCommandsTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
diff --git a/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java b/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java
index f0fc0bf..e4fda4a 100644
--- a/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java
+++ b/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directive json parser
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib ../share /
  * @run driver compiler.compilercontrol.parser.DirectiveParserTest
  */
diff --git a/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java b/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java
index ef1a311..c99b531 100644
--- a/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java
+++ b/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Stress directive json parser
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib ../share /
  * @run driver compiler.compilercontrol.parser.DirectiveStressTest
  */
diff --git a/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java b/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java
index 15cb560..3a88286 100644
--- a/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java
+++ b/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java
@@ -77,7 +77,7 @@
                 throw new Error("TESTBUG: incorrect argument: "+ args[1]);
             }
         }
-        int pid;
+        long pid;
         try {
             pid = ProcessTools.getProcessId();
         } catch (Exception e) {
diff --git a/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java b/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java
index a1acd0d..d921d1d 100644
--- a/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java
+++ b/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java
@@ -28,7 +28,6 @@
 import compiler.compilercontrol.share.scenario.State;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.OutputAnalyzer;
-import jdk.test.lib.Pair;
 import pool.PoolHelper;
 
 import java.io.File;
@@ -55,18 +54,17 @@
             "method='([^']+)'");
     private final List<String> loggedMethods;
     private final List<String> testMethods;
-    private Scanner scanner = null;
 
     public LogProcessor(Map<Executable, State> states) {
         loggedMethods = states.keySet().stream()
                 .filter(x -> states.get(x).isLog())
-                .map(MethodGenerator::logDescriptor)
+                .map(MethodGenerator::commandDescriptor)
                 .map(MethodDescriptor::getString)
                 .collect(Collectors.toList());
         testMethods = new PoolHelper().getAllMethods()
                 .stream()
                 .map(pair -> pair.first)
-                .map(MethodGenerator::logDescriptor)
+                .map(MethodGenerator::commandDescriptor)
                 .map(MethodDescriptor::getString)
                 .collect(Collectors.toList());
     }
@@ -76,8 +74,7 @@
         if (loggedMethods.isEmpty()) {
             return;
         }
-        getScanner();
-        matchTasks();
+        matchTasks(getScanner());
     }
 
     /*
@@ -85,6 +82,7 @@
      */
     private Scanner getScanner() {
         File logFile = new File(LOG_FILE);
+        Scanner scanner;
         try {
             scanner = new Scanner(logFile);
         } catch (FileNotFoundException e) {
@@ -97,29 +95,35 @@
      * Parses for &lt;task method='java.lang.String indexOf (I)I' &gt;
      * and finds if there is a compilation log for this task
      */
-    private void matchTasks() {
+    private void matchTasks(Scanner scanner) {
         String task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
         while (task != null) {
             String element = scanner.findWithinHorizon(ANY_ELEMENT, 0);
             if (Pattern.matches(TASK_DONE_ELEMENT, element)
                     || Pattern.matches(TASK_END_ELEMENT, element)) {
                 /* If there is nothing between <task> and </task>
-                   except <task done /> then compilation log is empty */
-                Asserts.assertTrue(matchMethod(task), "Compilation log "
+                   except <task done /> then compilation log is empty.
+                   Check the method in this task should not be logged */
+                Asserts.assertFalse(matchMethod(task), "Compilation log "
                         + "expected. Met: " + element);
             }
             task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
         }
     }
 
-    // Matches given string to regular expression
+    // Check that input method should be logged
     private boolean matchMethod(String input) {
         Matcher matcher = METHOD_PATTERN.matcher(input);
         Asserts.assertTrue(matcher.find(), "Wrong matcher or input");
         // Get method and normalize it
         String method = normalize(matcher.group(1));
-        // Check that this method matches regexp
-        return loggedMethods.contains(method) || !testMethods.contains(method);
+        if (loggedMethods.contains(method)) {
+            return true;
+        }
+        if (!testMethods.contains(method)) {
+            return false;
+        }
+        return false;
     }
 
     // Normalize given signature to conform regular expression used in tests
diff --git a/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java b/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java
index 505f36e..a0fefab 100644
--- a/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java
+++ b/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java
@@ -198,6 +198,7 @@
                 = new HashMap<>();
         private final JcmdStateBuilder jcmdStateBuilder;
         private final List<JcmdCommand> jcmdCommands = new ArrayList<>();
+        private boolean logCommandMet = false;
 
         public Builder() {
             addFlag("-Xmixed");
@@ -215,6 +216,9 @@
         public void add(CompileCommand compileCommand) {
             String[] vmOptions = compileCommand.command.vmOpts;
             Collections.addAll(vmopts, vmOptions);
+            if (compileCommand.command == Command.LOG) {
+                logCommandMet = true;
+            }
             if (compileCommand.type == Type.JCMD) {
                 jcmdStateBuilder.add((JcmdCommand) compileCommand);
                 jcmdCommands.add((JcmdCommand) compileCommand);
@@ -294,6 +298,18 @@
                 isValid &= builder.isValid();
             }
             options.addAll(jcmdStateBuilder.getOptions());
+
+            /*
+             * Update final states if LogCompilation is enabled and
+             * there is no any log command, then all methods should be logged
+             */
+            boolean isLogComp = vmopts.stream()
+                    .anyMatch(opt -> opt.contains("-XX:+LogCompilation"));
+            if (isLogComp && !logCommandMet) {
+                finalStates.entrySet()
+                        .forEach(entry -> entry.getValue().setLog(true));
+            }
+
             return new Scenario(isValid, options, finalStates, ccList,
                     jcmdCommands, directives);
         }
diff --git a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java
index 8e8deda..7be9e43 100644
--- a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java
+++ b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java
@@ -40,10 +40,11 @@
     public static final String USE_AES_INTRINSICS = "UseAESIntrinsics";
     public static final String USE_SSE = "UseSSE";
     public static final String USE_VIS = "UseVIS";
+    public static final String[] USE_DIAGNOSTIC_CMD
+            = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintIntrinsics"};
     public static final String[] TEST_AES_CMD
             = {"-XX:+IgnoreUnrecognizedVMOptions", "-XX:+PrintFlagsFinal",
-            "-Xbatch","-XX:+UnlockDiagnosticVMOptions",
-            "-XX:+PrintIntrinsics", "-DcheckOutput=true", "-Dmode=CBC",
+            "-Xbatch", "-DcheckOutput=true", "-Dmode=CBC",
             "TestAESMain"};
 
     protected AESIntrinsicsBase(BooleanSupplier predicate) {
@@ -52,14 +53,18 @@
 
     /**
      * Prepares command for TestAESMain execution.
+     * Intrinsics flags are of diagnostic type
+     * and must be preceded by UnlockDiagnosticVMOptions.
      * @param args flags that must be added to command
      * @return command for TestAESMain execution
      */
     public static String[] prepareArguments(String... args) {
-        String[] command = Arrays.copyOf(args, TEST_AES_CMD.length
-                + args.length);
-        System.arraycopy(TEST_AES_CMD, 0, command, args.length,
-                TEST_AES_CMD.length);
+        String[] command = Arrays.copyOf(USE_DIAGNOSTIC_CMD, args.length
+                + USE_DIAGNOSTIC_CMD.length + TEST_AES_CMD.length);
+        System.arraycopy(args, 0, command, USE_DIAGNOSTIC_CMD.length,
+                args.length);
+        System.arraycopy(TEST_AES_CMD, 0, command, args.length
+                + USE_DIAGNOSTIC_CMD.length, TEST_AES_CMD.length);
         return command;
     }
 }
diff --git a/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java b/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java
index cdea3b3..440a4b6 100644
--- a/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java
+++ b/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java
@@ -25,6 +25,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
  *                   -XX:CompileOnly=::valueOf,::byteValue,::shortValue,::testUnsignedByte,::testUnsignedShort
diff --git a/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java b/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java
index 3f38678..73ca08f 100644
--- a/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java
+++ b/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java
@@ -31,7 +31,7 @@
  */
 
 import java.lang.reflect.Field;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class TestUnsafePutAddressNullObjMustNotEscape {
 
@@ -43,7 +43,7 @@
         System.out.println("EXECUTING test.");
 
         {
-            System.out.println("Acquiring sun.misc.Unsafe.theUnsafe using reflection.");
+            System.out.println("Acquiring jdk.internal.misc.Unsafe.theUnsafe using reflection.");
             getUnsafe();
             System.out.println("Allocating raw memory.");
             mem = (usafe.allocateMemory(1024) + 8L) & ~7L;
@@ -78,8 +78,8 @@
     }
 
     private static void getUnsafe() throws Exception {
-        Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
+        Field field = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe");
         field.setAccessible(true);
-        usafe = (sun.misc.Unsafe) field.get(null);
+        usafe = (jdk.internal.misc.Unsafe) field.get(null);
     }
 }
diff --git a/hotspot/test/compiler/floatingpoint/TestPow2.java b/hotspot/test/compiler/floatingpoint/TestPow2.java
index a443062..d3893e9 100644
--- a/hotspot/test/compiler/floatingpoint/TestPow2.java
+++ b/hotspot/test/compiler/floatingpoint/TestPow2.java
@@ -26,6 +26,7 @@
  * @bug 8063086
  * @summary X^2 special case for C2 yields different result than interpreter
  * @library /testlibrary /test/lib /compiler/whitebox /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build TestPow2
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/inlining/InlineAccessors.java b/hotspot/test/compiler/inlining/InlineAccessors.java
index 60f8986..387a513 100644
--- a/hotspot/test/compiler/inlining/InlineAccessors.java
+++ b/hotspot/test/compiler/inlining/InlineAccessors.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8140650
  * @summary Method::is_accessor should cover getters and setters for all types
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm InlineAccessors
  */
diff --git a/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java b/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java
index ff2c7e3..ab582f9 100644
--- a/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java
+++ b/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java
@@ -29,6 +29,7 @@
 /*
  * @test
  * @bug 8130832
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox /compiler/testlibrary /
  * @build IntrinsicAvailableTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java b/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java
index 1fdaf80..638301a 100644
--- a/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java
+++ b/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 8138651
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build IntrinsicDisabledTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java
index f70f405..15380e8 100644
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java
@@ -31,7 +31,7 @@
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/bootclasspath/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- *                         -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestI
+ *                                 -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestI
  */
 
 import java.lang.reflect.Method;
diff --git a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java
index 32b43af..e0b9ecd 100644
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java
@@ -31,7 +31,7 @@
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/bootclasspath/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- *                         -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestL
+ *                                 -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestL
  */
 
 import java.lang.reflect.Method;
diff --git a/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java b/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java
index 2dde3fc..1e40e84 100644
--- a/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java
+++ b/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java
@@ -26,6 +26,7 @@
  * @test
  * @bug 8033626
  * @summary assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -XX:-TieredCompilation -Xbatch -XX:CompileOnly=TestObjectClone::f TestObjectClone
  */
diff --git a/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java b/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java
index 5a6f91c..cd8445b 100644
--- a/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java
+++ b/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java
@@ -42,6 +42,7 @@
  * @test
  * @bug 8130150 8131779 8139907
  * @summary Verify that the Montgomery multiply and square intrinsic works and correctly checks their arguments.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @library /testlibrary
  * @build MontgomeryMultiplyTest
diff --git a/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java b/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java
index 4d7b274..4b310e9 100644
--- a/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java
+++ b/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java
@@ -28,7 +28,7 @@
  * @summary Add C2 x86 intrinsic for BigInteger::mulAdd() method
  *
  * @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch
- *      -XX:+IgnoreUnrecognizedVMOptions -XX:-UseSquareToLenIntrinsic -XX:-UseMultiplyToLenIntrinsic
+ *      -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-UseSquareToLenIntrinsic -XX:-UseMultiplyToLenIntrinsic
  *      -XX:CompileCommand=dontinline,TestMulAdd::main
  *      -XX:CompileCommand=option,TestMulAdd::base_multiply,ccstr,DisableIntrinsic,_mulAdd
  *      -XX:CompileCommand=option,java.math.BigInteger::multiply,ccstr,DisableIntrinsic,_mulAdd
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java b/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
index 5c801cb..febf666 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
@@ -42,6 +42,11 @@
     protected static final String USE_SHA512_INTRINSICS_OPTION
             = "UseSHA512Intrinsics";
 
+    // Intrinsics flags are of diagnostic type
+    // and must be preceded by UnlockDiagnosticVMOptions.
+    protected static final String UNLOCK_DIAGNOSTIC_VM_OPTIONS
+            = "-XX:+UnlockDiagnosticVMOptions";
+
     // Note that strings below will be passed to
     // CommandLineOptionTest.verifySameJVMStartup and thus are regular
     // expressions, not just a plain strings.
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java
index ca11075..09dc581 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java
@@ -50,11 +50,13 @@
         CommandLineOptionTest.verifySameJVMStartup(null,
                 new String[] { ".*" + optionName + ".*" }, shouldPassMessage,
                 shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         CommandLineOptionTest.verifySameJVMStartup(null,
                 new String[] { ".*" + optionName + ".*" }, shouldPassMessage,
                 shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 
@@ -63,13 +65,15 @@
         // Verify that option is disabled by default.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be disabled by default",
-                        optionName));
+                        optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
 
         // Verify that option is disabled even if it was explicitly enabled
         // using CLI options.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be off on unsupported "
                         + "CPU even if set to true directly", optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that option is disabled when it explicitly disabled
@@ -79,6 +83,7 @@
                         + " even if '%s' flag set to JVM", optionName,
                         CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 }
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java
index 69be434..553cfaf 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java
@@ -49,6 +49,7 @@
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
                 }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that option could be disabled even if +UseSHA was passed to
@@ -60,6 +61,7 @@
                         optionName, CommandLineOptionTest.prepareBooleanFlag(
                             SHAOptionsBase.USE_SHA_OPTION, true)),
                 ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
@@ -75,6 +77,7 @@
                                   optionName,
                                   CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false)),
                     ExitCode.OK,
+                    SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                     CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
                     CommandLineOptionTest.prepareBooleanFlag(optionName, true));
         }
@@ -86,18 +89,21 @@
 
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
                 String.format("Option '%s' should be enabled by default",
-                        optionName));
+                        optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
 
         // Verify that it is possible to explicitly enable the option.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
                 String.format("Option '%s' was set to have value 'true'",
                         optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that it is possible to explicitly disable the option.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' was set to have value 'false'",
                         optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
         // verify that option is disabled when -UseSHA was passed to JVM.
@@ -106,6 +112,7 @@
                         + " flag set to JVM", optionName,
                         CommandLineOptionTest.prepareBooleanFlag(
                             SHAOptionsBase.USE_SHA_OPTION, false)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, false));
@@ -117,6 +124,7 @@
                         + " even if %s flag set to JVM", optionName,
                         CommandLineOptionTest.prepareBooleanFlag(
                             SHAOptionsBase.USE_SHA_OPTION, true)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java
index 6730b9e..8fabc79 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java
@@ -47,6 +47,7 @@
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
                 }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
         shouldPassMessage = String.format("If JVM is started with '-XX:-"
@@ -62,6 +63,7 @@
                     shouldPassMessage,
                     shouldPassMessage,
                     ExitCode.OK,
+                    SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                     CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
                     CommandLineOptionTest.prepareBooleanFlag(optionName, true));
         }
@@ -72,13 +74,15 @@
         // Verify that option is disabled by default.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be disabled by default",
-                        optionName));
+                        optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
 
         // Verify that option is disabled even if it was explicitly enabled
         // using CLI options.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be off on unsupported "
                         + "AArch64CPU even if set to true directly", optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that option is disabled when +UseSHA was passed to JVM.
@@ -87,6 +91,7 @@
                         + "AArch64CPU even if %s flag set to JVM",
                         optionName, CommandLineOptionTest.prepareBooleanFlag(
                             SHAOptionsBase.USE_SHA_OPTION, true)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true));
     }
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java
index 58dde55..1254b8a 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java
@@ -47,6 +47,7 @@
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
                 }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
         // Verify that when the tested option is enabled, then
@@ -58,6 +59,7 @@
                     shouldPassMessage,
                     shouldPassMessage,
                     ExitCode.OK,
+                    SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                     CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
                     CommandLineOptionTest.prepareBooleanFlag(optionName, true));
         }
@@ -68,13 +70,15 @@
         // Verify that option is disabled by default.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be disabled by default",
-                        optionName));
+                        optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
 
         // Verify that option is disabled even if it was explicitly enabled
         // using CLI options.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be off on unsupported "
                         + "SparcCPU even if set to true directly", optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that option is disabled when +UseSHA was passed to JVM.
@@ -83,6 +87,7 @@
                         + "SparcCPU even if %s flag set to JVM",
                         optionName, CommandLineOptionTest.prepareBooleanFlag(
                             SHAOptionsBase.USE_SHA_OPTION, true)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true));
     }
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java
index 2014ab5..599be2c 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,9 @@
 import jdk.test.lib.ExitCode;
 import jdk.test.lib.Platform;
 import jdk.test.lib.cli.CommandLineOptionTest;
+import jdk.test.lib.cli.predicate.AndPredicate;
 import jdk.test.lib.cli.predicate.OrPredicate;
+import jdk.test.lib.cli.predicate.NotPredicate;
 
 /**
  * Generic test case for SHA-related options targeted to X86 CPUs that don't
@@ -33,28 +35,36 @@
 public class GenericTestCaseForUnsupportedX86CPU
         extends SHAOptionsBase.TestCase {
     public GenericTestCaseForUnsupportedX86CPU(String optionName) {
-        super(optionName, new OrPredicate(Platform::isX64, Platform::isX86));
+        super(optionName, new AndPredicate(new OrPredicate(Platform::isX64, Platform::isX86),
+                new NotPredicate(SHAOptionsBase.getPredicateForOption(
+                        optionName))));
     }
 
     @Override
     protected void verifyWarnings() throws Throwable {
-        String shouldPassMessage = String.format("JVM should start with '-XX:+"
-                + "%s' flag, but output should contain warning.", optionName);
-        // Verify that when the tested option is explicitly enabled, then
-        // a warning will occur in VM output.
-        CommandLineOptionTest.verifySameJVMStartup(new String[] {
-                        SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
-                CommandLineOptionTest.prepareBooleanFlag(optionName, true));
-
-        shouldPassMessage = String.format("JVM should start with '-XX:-%s' "
+        String shouldPassMessage = String.format("JVM should start with '-XX:-%s' "
                 + "flag without any warnings", optionName);
         // Verify that the tested option could be explicitly disabled without
         // a warning.
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
                 }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
+
+        // Verify that when the tested option is enabled, then
+        // a warning will occur in VM output if UseSHA is disabled.
+        if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
+            CommandLineOptionTest.verifySameJVMStartup(
+                    new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) },
+                    null,
+                    shouldPassMessage,
+                    shouldPassMessage,
+                    ExitCode.OK,
+                    SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
+                    CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
+                    CommandLineOptionTest.prepareBooleanFlag(optionName, true));
+        }
     }
 
     @Override
@@ -62,12 +72,14 @@
         // Verify that the tested option is disabled by default.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be disabled by default",
-                        optionName));
+                        optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
 
         // Verify that it is not possible to explicitly enable the option.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
                 String.format("Option '%s' should be off on unsupported "
                         + "X86CPU even if set to true directly", optionName),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that the tested option is disabled even if +UseSHA was passed
@@ -77,6 +89,7 @@
                         + "X86CPU even if %s flag set to JVM",
                         optionName, CommandLineOptionTest.prepareBooleanFlag(
                             SHAOptionsBase.USE_SHA_OPTION, true)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true));
     }
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java
index 6ba51bb..c75a667 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java
@@ -59,6 +59,7 @@
         CommandLineOptionTest.verifySameJVMStartup(new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
                 }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
     }
 }
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java
index 9349a33..3c1d208 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java
@@ -57,6 +57,7 @@
         CommandLineOptionTest.verifySameJVMStartup(
                 null, new String[] { ".*UseSHA.*" }, shouldPassMessage,
                 shouldPassMessage, ExitCode.OK,
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -75,6 +76,7 @@
                 SHAOptionsBase.USE_SHA_OPTION, "false", String.format(
                 "'%s' option should be disabled when all UseSHA*Intrinsics are"
                         + " disabled", SHAOptionsBase.USE_SHA_OPTION),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -91,6 +93,7 @@
                         + "to JVM", SHAOptionsBase.USE_SHA_OPTION,
                         CommandLineOptionTest.prepareBooleanFlag(
                              SHAOptionsBase.USE_SHA_OPTION, true)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -109,6 +112,7 @@
                         SHAOptionsBase.USE_SHA_OPTION,
                         CommandLineOptionTest.prepareBooleanFlag(
                             SHAOptionsBase.USE_SHA_OPTION, false)),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, false),
                 CommandLineOptionTest.prepareBooleanFlag(
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java
index d325dda..22f133d 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java
@@ -68,6 +68,7 @@
                     "%s option should be disabled on unsupported CPU"
                         + " even if all UseSHA*Intrinsics options were enabled.",
                     SHAOptionsBase.USE_SHA_OPTION),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -84,6 +85,7 @@
                         + " and %s was enabled as well",
                     SHAOptionsBase.USE_SHA_OPTION,
                     SHAOptionsBase.USE_SHA_OPTION),
+                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
diff --git a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java
index 86d7b30..f3cb516 100644
--- a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java
+++ b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java
@@ -27,6 +27,7 @@
  * @test
  * @bug 8144212
  * @summary Check for correct memory flow with the String compress/inflate intrinsics.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main TestStringIntrinsicMemoryFlow
  */
diff --git a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java
index 7bba530..ca8ca1c 100644
--- a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java
+++ b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java
@@ -26,6 +26,7 @@
  * @test
  * @bug 8145336
  * @summary PPC64: fix string intrinsics after CompactStrings change
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java b/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java
index c9c0fc7..7c46ab1d 100644
--- a/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java
+++ b/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java
@@ -36,6 +36,7 @@
 /**
  * @test
  * @bug 8026049
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-UseUnalignedAccesses -Djdk.test.lib.random.seed=0 HeapByteBufferTest
  * @run main/othervm -Djdk.test.lib.random.seed=0 HeapByteBufferTest
diff --git a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java
index 2c60a71..78ef24a 100644
--- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java
@@ -25,6 +25,7 @@
 /**
  * @test
  * @bug 8142386
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @summary Unsafe access to an array is wrongly marked as mismatched
  * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:-TieredCompilation TestUnsafeMismatchedArrayFieldAccess
@@ -33,7 +34,7 @@
 
 import java.lang.reflect.*;
 import jdk.test.lib.Utils;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class TestUnsafeMismatchedArrayFieldAccess {
 
diff --git a/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java b/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java
index 5ed225f..7599781 100644
--- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java
+++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java
@@ -30,21 +30,21 @@
  *
  */
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.lang.reflect.*;
 
 public class UnsafeGetAddressTest {
     private static Unsafe unsafe;
 
     public static void main(String[] args) throws Exception {
-        Class c = UnsafeGetAddressTest.class.getClassLoader().loadClass("sun.misc.Unsafe");
+        Class c = UnsafeGetAddressTest.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
         Field f = c.getDeclaredField("theUnsafe");
         f.setAccessible(true);
         unsafe = (Unsafe)f.get(c);
 
         long address = unsafe.allocateMemory(unsafe.addressSize());
         unsafe.putAddress(address, 0x0000000080000000L);
-        // from sun.misc.Unsafe.getAddress' documentation:
+        // from jdk.internal.misc.Unsafe.getAddress' documentation:
         // "If the native pointer is less than 64 bits wide, it is
         // extended as an unsigned number to a Java long."
         result = unsafe.getAddress(address);
diff --git a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java
index c19705f..152b28d 100644
--- a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java
+++ b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java
@@ -24,12 +24,13 @@
 /**
  * @test
  * @bug 8057967
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @library patches
  * @build java.base/java.lang.invoke.MethodHandleHelper
- * @run main/bootclasspath/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -Xlog:classunload
- *                         -XX:+PrintCompilation -XX:+TraceDependencies -XX:+TraceReferenceGC
- *                         -verbose:gc compiler.jsr292.CallSiteDepContextTest
+ * @run main/bootclasspath/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -Xlog:class+unload
+ *                                 -XX:+PrintCompilation -XX:+TraceDependencies -XX:+TraceReferenceGC
+ *                                 -verbose:gc compiler.jsr292.CallSiteDepContextTest
  */
 
 package compiler.jsr292;
@@ -46,7 +47,7 @@
 import java.lang.reflect.Field;
 
 import jdk.internal.org.objectweb.asm.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 import static jdk.internal.org.objectweb.asm.Opcodes.*;
 
diff --git a/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java b/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java
index a59f962..3b009e9 100644
--- a/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java
+++ b/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main ContinuousCallSiteTargetChange
  */
diff --git a/hotspot/test/compiler/jsr292/InvokerGC.java b/hotspot/test/compiler/jsr292/InvokerGC.java
index 35884f4..98c69b1 100644
--- a/hotspot/test/compiler/jsr292/InvokerGC.java
+++ b/hotspot/test/compiler/jsr292/InvokerGC.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 8067247
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /compiler/whitebox /
  * @run main/bootclasspath/othervm -Xcomp -Xbatch
  *      -XX:CompileCommand=compileonly,InvokerGC::test
diff --git a/hotspot/test/compiler/jsr292/MHInlineTest.java b/hotspot/test/compiler/jsr292/MHInlineTest.java
index 552b122..915c8f1 100644
--- a/hotspot/test/compiler/jsr292/MHInlineTest.java
+++ b/hotspot/test/compiler/jsr292/MHInlineTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8062280
  * @summary C2: inlining failure due to access checks being too strict
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm MHInlineTest
  */
diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java
index 8cf3c14..3a93fe7 100644
--- a/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java
+++ b/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java
@@ -25,14 +25,15 @@
  * @test
  * @bug 8072008
  * @library /testlibrary /test/lib ../patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build java.base/java.lang.invoke.MethodHandleHelper
  * @build sun.hotspot.WhiteBox
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- *                         -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
- *                         -XX:+FoldStableValues
- *                         compiler.jsr292.NonInlinedCall.GCTest
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *                                 -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.jsr292.NonInlinedCall.GCTest
  */
 
 package compiler.jsr292.NonInlinedCall;
diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java
index fbd57cd..d413d38 100644
--- a/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java
+++ b/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java
@@ -25,14 +25,15 @@
  * @test
  * @bug 8072008
  * @library /testlibrary /test/lib / ../patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build java.base/java.lang.invoke.MethodHandleHelper
  * @build sun.hotspot.WhiteBox
  * @build compiler.jsr292.NonInlinedCall.InvokeTest
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- *                         -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
- *                         compiler.jsr292.NonInlinedCall.InvokeTest
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *                                 -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
+ *                                 compiler.jsr292.NonInlinedCall.InvokeTest
  */
 
 package compiler.jsr292.NonInlinedCall;
diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java
index 27bc5c9..1a77363 100644
--- a/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java
+++ b/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java
@@ -36,10 +36,10 @@
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  *                              compiler.jsr292.NonInlinedCall.RedefineTest
  * @run main/bootclasspath/othervm -javaagent:agent.jar
- *                         -XX:+IgnoreUnrecognizedVMOptions
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- *                         -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
- *                         compiler.jsr292.NonInlinedCall.RedefineTest
+ *                                 -XX:+IgnoreUnrecognizedVMOptions
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *                                 -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
+ *                                 compiler.jsr292.NonInlinedCall.RedefineTest
  */
 
 package compiler.jsr292.NonInlinedCall;
diff --git a/hotspot/test/compiler/jsr292/PollutedTrapCounts.java b/hotspot/test/compiler/jsr292/PollutedTrapCounts.java
index 7aecdae..b368b2f 100644
--- a/hotspot/test/compiler/jsr292/PollutedTrapCounts.java
+++ b/hotspot/test/compiler/jsr292/PollutedTrapCounts.java
@@ -24,6 +24,7 @@
 /**
  * @test
  * @bug 8074551
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main PollutedTrapCounts
  */
diff --git a/hotspot/test/compiler/jsr292/VMAnonymousClasses.java b/hotspot/test/compiler/jsr292/VMAnonymousClasses.java
index 953deaf..abb9b5d 100644
--- a/hotspot/test/compiler/jsr292/VMAnonymousClasses.java
+++ b/hotspot/test/compiler/jsr292/VMAnonymousClasses.java
@@ -32,7 +32,7 @@
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.MethodVisitor;
 import jdk.internal.org.objectweb.asm.Opcodes;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 import java.lang.invoke.ConstantCallSite;
 import java.lang.invoke.MethodHandle;
diff --git a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java
index 0504798..1384945 100644
--- a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java
+++ b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java
@@ -27,6 +27,7 @@
  * @bug 8136421
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.runtime
  * @run main/othervm -XX:+UnlockExperimentalVMOptions
  *      -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true
diff --git a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java
index 993cbba..48c406a 100644
--- a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java
+++ b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @run main/othervm -XX:+UnlockExperimentalVMOptions
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java
index 3902acf..148402e 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java
index b24d25c..4500a83 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java b/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java
index 81b7bd4..dc905f3 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib/
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.CollectCountersTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
index fe25187..ffe0a89 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.DebugOutputTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java
index bd39a56e..d8eedaa 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java
index 747a9cf..db74162 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java
index fb89c4e..399ff0c 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java
@@ -25,6 +25,7 @@
  * @library /testlibrary /test/lib /
  * @library ../common/patches
  * @ignore 8139383
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java
index 0cca017..cc5ff3d 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java
index 472bc37..7bfd132 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java
index 1b0eacd..3f2c80f 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.GetClassInitializerTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java
index 3e14a68..28463d7 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  *          jdk.vm.ci/jdk.vm.ci.meta
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
@@ -51,7 +52,7 @@
 import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject;
 import jdk.test.lib.Utils;
 import sun.hotspot.WhiteBox;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Tests for jdk.vm.ci.hotspot.CompilerToVM::getConstantPool method
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java
index 63f4433..536972d 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java
index 1b03ef2..894791f 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib/
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.GetImplementorTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java
index 99fcd9f..c1bfbba 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java
@@ -29,6 +29,7 @@
  * @library /testlibrary /test/lib /
  * @library ../common/patches
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java
index 958b2e4..d6f6725 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java
index c180d41..93653fd 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib/
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.GetMaxCallTargetOffsetTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java
index 44fbb4c..afca9ec 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java
index 87afff2..d23aad9 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java
index 4735af3..6e0fea3 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  *        jdk.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject
@@ -48,7 +49,7 @@
 import jdk.test.lib.Asserts;
 import jdk.test.lib.Utils;
 import sun.hotspot.WhiteBox;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 import java.lang.reflect.Field;
 
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java
index 0ddc246..1dde085 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  *          jdk.vm.ci/jdk.vm.ci.meta
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
@@ -59,7 +60,7 @@
 import jdk.test.lib.Asserts;
 import jdk.test.lib.Utils;
 import sun.hotspot.WhiteBox;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class GetResolvedJavaTypeTest {
     private static enum TestCase {
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java
index a6feb93..970e8cb 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java
index 9e1f829..7e10c95 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java
index 49fd321..66a0bd9 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java
index e45940e..9cb947e 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java b/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java
index 066e784..d972a22 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.HasFinalizableSubclassTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java b/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java
index 3de8ec5..9087b52 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.InitializeConfigurationTest
@@ -46,7 +47,7 @@
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.Utils;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class InitializeConfigurationTest {
     private static final Unsafe UNSAFE = Utils.getUnsafe();
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java
index b7a0cfd..369be86 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java
index f6ebb83..fe2f025 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.IsMatureTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java
index ac42d62..56a4343 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java
@@ -27,6 +27,7 @@
  * @bug 8136421
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  *          jdk.vm.ci/jdk.vm.ci.runtime
  * @run main/othervm -XX:+UnlockExperimentalVMOptions
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java
index 269c5a7..712d5d8 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.LookupTypeTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java
index e281749..43a7631 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java
index 812c258..d78672a 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.reflect
  *          java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java
index 4ec17c2..14e5304 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java
@@ -24,9 +24,11 @@
 /*
  * @test
  * @bug 8136421
+ * @ignore 8155216
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib/
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.ReadUncompressedOopTest
@@ -52,7 +54,7 @@
 import jdk.test.lib.Asserts;
 import jdk.test.lib.Utils;
 import sun.hotspot.WhiteBox;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 import java.lang.reflect.Field;
 
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java
index 1e8cb12..371af37 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java
index 3c004ce..8151340 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java
@@ -60,7 +60,7 @@
 import jdk.vm.ci.meta.ConstantPool;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.Utils;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.resolveFieldInPool} method
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java
index ff08b7e..98b56f8 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
@@ -56,7 +57,7 @@
 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.Utils;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class ResolveMethodTest {
     private static final Unsafe UNSAFE = Utils.getUnsafe();
@@ -137,8 +138,14 @@
         HotSpotResolvedObjectType callerMetaspace = CompilerToVMHelper
                 .lookupType(Utils.toJVMTypeSignature(tcase.caller),
                         getClass(), /* resolve = */ true);
+        HotSpotResolvedObjectType receiverMetaspace = CompilerToVMHelper
+                .lookupType(Utils.toJVMTypeSignature(tcase.receiver),
+                        getClass(), /* resolve = */ true);
+
+        // Can only resolve methods on a linked class so force initialization
+        receiverMetaspace.initialize();
         HotSpotResolvedJavaMethod resolvedMetaspaceMethod
-                = CompilerToVMHelper.resolveMethod(holderMetaspace,
+                = CompilerToVMHelper.resolveMethod(receiverMetaspace,
                         metaspaceMethod, callerMetaspace);
         if (tcase.isPositive) {
             Asserts.assertNotNull(resolvedMetaspaceMethod,
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java
index 69ceeff..a6dd4cf 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib/
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.ShouldDebugNonSafepointsTest
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java
index 615b585..bef796a 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java
@@ -28,6 +28,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java b/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java
index c8bfbff..c869389 100644
--- a/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java
+++ b/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  *          jdk.vm.ci/jdk.vm.ci.code
  *          jdk.vm.ci/jdk.vm.ci.meta
diff --git a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java
index 1110b1e..e045775 100644
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java
@@ -27,6 +27,7 @@
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary
  * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.org.objectweb.asm.tree
  *          jdk.vm.ci/jdk.vm.ci.hotspot
diff --git a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java
index 7dbbf8e..2c24932 100644
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java
@@ -26,6 +26,7 @@
  * @bug 8136421
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  *          jdk.vm.ci/jdk.vm.ci.code
  *          jdk.vm.ci/jdk.vm.ci.meta
diff --git a/hotspot/test/compiler/jvmci/code/CodeInstallationTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java
similarity index 96%
rename from hotspot/test/compiler/jvmci/code/CodeInstallationTest.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java
index 550665c..67a6666 100644
--- a/hotspot/test/compiler/jvmci/code/CodeInstallationTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java
@@ -20,15 +20,19 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package compiler.jvmci.code;
+package jdk.vm.ci.code.test;
 
 import java.lang.reflect.Method;
 
+import org.junit.Assert;
+
 import jdk.vm.ci.amd64.AMD64;
 import jdk.vm.ci.code.Architecture;
 import jdk.vm.ci.code.CodeCacheProvider;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.code.TargetDescription;
+import jdk.vm.ci.code.test.amd64.AMD64TestAssembler;
+import jdk.vm.ci.code.test.sparc.SPARCTestAssembler;
 import jdk.vm.ci.hotspot.HotSpotCompiledCode;
 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
 import jdk.vm.ci.meta.ConstantReflectionProvider;
@@ -37,11 +41,6 @@
 import jdk.vm.ci.runtime.JVMCIBackend;
 import jdk.vm.ci.sparc.SPARC;
 
-import org.junit.Assert;
-
-import compiler.jvmci.code.amd64.AMD64TestAssembler;
-import compiler.jvmci.code.sparc.SPARCTestAssembler;
-
 /**
  * Base class for code installation tests.
  */
diff --git a/hotspot/test/compiler/jvmci/code/DataPatchTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java
similarity index 97%
rename from hotspot/test/compiler/jvmci/code/DataPatchTest.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java
index 294d21e..3b7c421 100644
--- a/hotspot/test/compiler/jvmci/code/DataPatchTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java
@@ -32,10 +32,11 @@
  *          jdk.vm.ci/jdk.vm.ci.runtime
  *          jdk.vm.ci/jdk.vm.ci.amd64
  *          jdk.vm.ci/jdk.vm.ci.sparc
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.DataPatchTest
+ * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.DataPatchTest
  */
 
-package compiler.jvmci.code;
+package jdk.vm.ci.code.test;
 
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.site.DataSectionReference;
@@ -158,7 +159,6 @@
         });
     }
 
-
     public static long getConstSymbol(HotSpotMetaAccessProvider meta) {
         HotSpotSymbol symbol = meta.lookupSymbol("java/lang/Object");
         return symbol.getMetaspacePointer();
diff --git a/hotspot/test/compiler/jvmci/code/DebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java
similarity index 95%
rename from hotspot/test/compiler/jvmci/code/DebugInfoTest.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java
index 3b3c33a..c1bdc03 100644
--- a/hotspot/test/compiler/jvmci/code/DebugInfoTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -20,7 +20,7 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package compiler.jvmci.code;
+package jdk.vm.ci.code.test;
 
 import java.lang.reflect.Method;
 
diff --git a/hotspot/test/compiler/jvmci/code/InterpreterFrameSizeTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java
similarity index 92%
rename from hotspot/test/compiler/jvmci/code/InterpreterFrameSizeTest.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java
index 59c3e22..098871d 100644
--- a/hotspot/test/compiler/jvmci/code/InterpreterFrameSizeTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java
@@ -33,23 +33,20 @@
  *          jdk.vm.ci/jdk.vm.ci.amd64
  *          jdk.vm.ci/jdk.vm.ci.sparc
  * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.InterpreterFrameSizeTest
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.InterpreterFrameSizeTest
  */
 
-package compiler.jvmci.code;
-
-import java.lang.reflect.Method;
-
-import jdk.vm.ci.code.BytecodeFrame;
-import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.JavaValue;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
-
-import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
+package jdk.vm.ci.code.test;
 
 import org.junit.Assert;
 import org.junit.Test;
 
+import jdk.vm.ci.code.BytecodeFrame;
+import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
+import jdk.vm.ci.meta.JavaKind;
+import jdk.vm.ci.meta.JavaValue;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+
 public class InterpreterFrameSizeTest extends CodeInstallationTest {
 
     HotSpotCodeCacheProvider hotspotCodeCache() {
@@ -61,7 +58,7 @@
         try {
             hotspotCodeCache().interpreterFrameSize(null);
         } catch (NullPointerException npe) {
-            System.out.println("threw NPE as expected");
+            // Threw NPE as expected.
             return;
         }
         Assert.fail("expected NullPointerException");
@@ -78,7 +75,6 @@
         JavaKind[] slotKinds = new JavaKind[numLocals];
         BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, bci, false, false, values, slotKinds, numLocals, numStack, 0);
         int size = hotspotCodeCache().interpreterFrameSize(frame);
-        System.out.println("Frame size is " + size + " bytes");
         if (size <= 0) {
             Assert.fail("expected non-zero result");
         }
diff --git a/hotspot/test/compiler/jvmci/code/SimpleCodeInstallationTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java
similarity index 86%
rename from hotspot/test/compiler/jvmci/code/SimpleCodeInstallationTest.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java
index 6c1377c..0b8ca5c 100644
--- a/hotspot/test/compiler/jvmci/code/SimpleCodeInstallationTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,15 +32,16 @@
  *          jdk.vm.ci/jdk.vm.ci.runtime
  *          jdk.vm.ci/jdk.vm.ci.amd64
  *          jdk.vm.ci/jdk.vm.ci.sparc
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.SimpleCodeInstallationTest
+ * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleCodeInstallationTest
  */
 
-package compiler.jvmci.code;
-
-import jdk.vm.ci.code.Register;
+package jdk.vm.ci.code.test;
 
 import org.junit.Test;
 
+import jdk.vm.ci.code.Register;
+
 /**
  * Test simple code installation.
  */
diff --git a/hotspot/test/compiler/jvmci/code/SimpleDebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java
similarity index 96%
rename from hotspot/test/compiler/jvmci/code/SimpleDebugInfoTest.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java
index b27802c..5b00cb7 100644
--- a/hotspot/test/compiler/jvmci/code/SimpleDebugInfoTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,10 +32,14 @@
  *          jdk.vm.ci/jdk.vm.ci.runtime
  *          jdk.vm.ci/jdk.vm.ci.amd64
  *          jdk.vm.ci/jdk.vm.ci.sparc
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.SimpleDebugInfoTest
+ * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleDebugInfoTest
  */
 
-package compiler.jvmci.code;
+package jdk.vm.ci.code.test;
+
+import org.junit.Assume;
+import org.junit.Test;
 
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.hotspot.HotSpotConstant;
@@ -45,9 +49,6 @@
 import jdk.vm.ci.meta.ResolvedJavaType;
 import jdk.vm.ci.meta.Value;
 
-import org.junit.Assume;
-import org.junit.Test;
-
 public class SimpleDebugInfoTest extends DebugInfoTest {
 
     public static int intOnStack() {
@@ -99,7 +100,6 @@
         testIntInLocal(compiler);
     }
 
-
     public static float floatOnStack() {
         return 42.0f;
     }
@@ -149,7 +149,6 @@
         testFloatInLocal(compiler);
     }
 
-
     public static long longOnStack() {
         return 42;
     }
@@ -202,7 +201,6 @@
         testLongInLocal(compiler);
     }
 
-
     public static Class<?> objectOnStack() {
         return SimpleDebugInfoTest.class;
     }
diff --git a/hotspot/test/compiler/jvmci/code/TestAssembler.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java
similarity index 99%
rename from hotspot/test/compiler/jvmci/code/TestAssembler.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java
index 5034027..9e10e46 100644
--- a/hotspot/test/compiler/jvmci/code/TestAssembler.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java
@@ -21,7 +21,7 @@
  * questions.
  */
 
-package compiler.jvmci.code;
+package jdk.vm.ci.code.test;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
diff --git a/hotspot/test/compiler/jvmci/code/VirtualObjectDebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java
similarity index 89%
rename from hotspot/test/compiler/jvmci/code/VirtualObjectDebugInfoTest.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java
index c06c507..04dd67c 100644
--- a/hotspot/test/compiler/jvmci/code/VirtualObjectDebugInfoTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,18 @@
  *          jdk.vm.ci/jdk.vm.ci.runtime
  *          jdk.vm.ci/jdk.vm.ci.amd64
  *          jdk.vm.ci/jdk.vm.ci.sparc
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.VirtualObjectDebugInfoTest
+ * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.VirtualObjectDebugInfoTest
  */
 
-package compiler.jvmci.code;
+package jdk.vm.ci.code.test;
 
 import java.util.ArrayList;
 import java.util.Objects;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.VirtualObject;
 import jdk.vm.ci.hotspot.HotSpotConstant;
@@ -49,9 +53,6 @@
 import jdk.vm.ci.meta.ResolvedJavaField;
 import jdk.vm.ci.meta.ResolvedJavaType;
 
-import org.junit.Assert;
-import org.junit.Test;
-
 public class VirtualObjectDebugInfoTest extends DebugInfoTest {
 
     private static class TestClass {
@@ -61,11 +62,11 @@
         private float floatField;
         private Object[] arrayField;
 
-        public TestClass() {
+        TestClass() {
             this.longField = 8472;
             this.intField = 42;
             this.floatField = 3.14f;
-            this.arrayField = new Object[] { Integer.valueOf(58), this, null, Integer.valueOf(17), "Hello, World!" };
+            this.arrayField = new Object[]{Integer.valueOf(58), this, null, Integer.valueOf(17), "Hello, World!"};
         }
 
         @Override
@@ -75,10 +76,7 @@
             }
 
             TestClass other = (TestClass) o;
-            if (this.longField != other.longField
-                || this.intField != other.intField
-                || this.floatField != other.floatField
-                || this.arrayField.length != other.arrayField.length) {
+            if (this.longField != other.longField || this.intField != other.intField || this.floatField != other.floatField || this.arrayField.length != other.arrayField.length) {
                 return false;
             }
 
@@ -95,6 +93,11 @@
 
             return true;
         }
+
+        @Override
+        public int hashCode() {
+            return super.hashCode();
+        }
     }
 
     public static TestClass buildObject() {
diff --git a/hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java
similarity index 96%
rename from hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java
index 4ed0625..7d249d6 100644
--- a/hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java
@@ -21,7 +21,7 @@
  * questions.
  */
 
-package compiler.jvmci.code.amd64;
+package jdk.vm.ci.code.test.amd64;
 
 import jdk.vm.ci.amd64.AMD64;
 import jdk.vm.ci.amd64.AMD64Kind;
@@ -31,6 +31,7 @@
 import jdk.vm.ci.code.StackSlot;
 import jdk.vm.ci.code.site.ConstantReference;
 import jdk.vm.ci.code.site.DataSectionReference;
+import jdk.vm.ci.code.test.TestAssembler;
 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
 import jdk.vm.ci.hotspot.HotSpotConstant;
 import jdk.vm.ci.hotspot.HotSpotForeignCallTarget;
@@ -39,8 +40,6 @@
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.VMConstant;
 
-import compiler.jvmci.code.TestAssembler;
-
 public class AMD64TestAssembler extends TestAssembler {
 
     public AMD64TestAssembler(CodeCacheProvider codeCache) {
@@ -161,7 +160,7 @@
             code.emitInt(0xDEADDEAD);
             return ret;
         } else {
-            return emitLoadLong(0xDEADDEADDEADDEADl);
+            return emitLoadLong(0xDEADDEADDEADDEADL);
         }
     }
 
@@ -195,14 +194,16 @@
     @Override
     public StackSlot emitIntToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(AMD64Kind.DWORD));
-        emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m32,r32
+        // MOV r/m32,r32
+        emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16);
         return ret;
     }
 
     @Override
     public StackSlot emitLongToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(AMD64Kind.QWORD));
-        emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m64,r64
+        // MOV r/m64,r64
+        emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16);
         return ret;
     }
 
@@ -221,14 +222,16 @@
     @Override
     public StackSlot emitPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(AMD64Kind.QWORD));
-        emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m64,r64
+        // MOV r/m64,r64
+        emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16);
         return ret;
     }
 
     @Override
     public StackSlot emitNarrowPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(AMD64Kind.DWORD));
-        emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m32,r32
+        // MOV r/m32,r32
+        emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16);
         return ret;
     }
 
diff --git a/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java
similarity index 95%
rename from hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java
rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java
index 5b2cd7f..7c7aa7b 100644
--- a/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java
@@ -21,7 +21,7 @@
  * questions.
  */
 
-package compiler.jvmci.code.sparc;
+package jdk.vm.ci.code.test.sparc;
 
 import jdk.vm.ci.code.CodeCacheProvider;
 import jdk.vm.ci.code.DebugInfo;
@@ -29,6 +29,7 @@
 import jdk.vm.ci.code.StackSlot;
 import jdk.vm.ci.code.site.ConstantReference;
 import jdk.vm.ci.code.site.DataSectionReference;
+import jdk.vm.ci.code.test.TestAssembler;
 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
 import jdk.vm.ci.hotspot.HotSpotCompiledCode;
 import jdk.vm.ci.hotspot.HotSpotConstant;
@@ -41,8 +42,6 @@
 import jdk.vm.ci.sparc.SPARC;
 import jdk.vm.ci.sparc.SPARCKind;
 
-import compiler.jvmci.code.TestAssembler;
-
 public class SPARCTestAssembler extends TestAssembler {
 
     private static final int MASK13 = (1 << 13) - 1;
@@ -69,7 +68,8 @@
 
     @Override
     public void emitPrologue() {
-        emitOp3(0b10, SPARC.sp, 0b111100, SPARC.sp, -SPARC.REGISTER_SAFE_AREA_SIZE); // SAVE sp, -128, sp
+        // SAVE sp, -128, sp
+        emitOp3(0b10, SPARC.sp, 0b111100, SPARC.sp, -SPARC.REGISTER_SAFE_AREA_SIZE);
         setDeoptRescueSlot(newStackSlot(LIRKind.value(SPARCKind.XWORD)));
     }
 
@@ -195,35 +195,40 @@
     @Override
     public StackSlot emitIntToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.WORD));
-        emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset]
+        // STW a, [fp+offset]
+        emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS);
         return ret;
     }
 
     @Override
     public StackSlot emitLongToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.XWORD));
-        emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset]
+        // STX a, [fp+offset]
+        emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS);
         return ret;
     }
 
     @Override
     public StackSlot emitFloatToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.SINGLE));
-        emitOp3(0b11, a, 0b100100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STF a, [fp+offset]
+        // STF a, [fp+offset]
+        emitOp3(0b11, a, 0b100100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS);
         return ret;
     }
 
     @Override
     public StackSlot emitPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.XWORD));
-        emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset]
+        // STX a, [fp+offset]
+        emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS);
         return ret;
     }
 
     @Override
     public StackSlot emitNarrowPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.WORD));
-        emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset]
+        // STW a, [fp+offset]
+        emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS);
         return ret;
     }
 
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java
index 761db0e..dfa217a 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.ConstantTest
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.ConstantTest
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java
index 038efdc..604d671 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.RedefineClassTest
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.RedefineClassTest
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java
index 6f1f175..b253a38 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java
@@ -105,7 +105,7 @@
         ResolvedJavaMethod di = getMethod(i, "d");
         ResolvedJavaMethod dc = getMethod(c, "d");
 
-        assertEquals(di, i.resolveConcreteMethod(di, c));
+        assertEquals(null, i.resolveConcreteMethod(di, c));
         assertEquals(di, b.resolveConcreteMethod(di, c));
         assertEquals(dc, c.resolveConcreteMethod(di, c));
     }
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java
index ba62291..0d8121b 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java
@@ -105,7 +105,7 @@
         ResolvedJavaMethod di = getMethod(i, "d");
         ResolvedJavaMethod dc = getMethod(c, "d");
 
-        assertEquals(di, i.resolveMethod(di, c));
+        assertEquals(null, i.resolveMethod(di, c));
         assertEquals(di, b.resolveMethod(di, c));
         assertEquals(dc, c.resolveMethod(di, c));
     }
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java
index fe31f59..824a153 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestConstantReflectionProvider
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestConstantReflectionProvider
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java
index 46f4e80..4537b38 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestJavaField
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestJavaField
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java
index 460abd9..faa96b8 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestJavaMethod
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestJavaMethod
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java
index 72506cf..23959e2 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestJavaType
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestJavaType
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java
index 10b2e70..904aada 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestMetaAccessProvider
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestMetaAccessProvider
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java
index 71e9f18..defa199 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestResolvedJavaField
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestResolvedJavaField
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java
index c60a7d4..d96560c 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java
@@ -27,6 +27,7 @@
  * @library ../../../../../
  * @modules jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestResolvedJavaMethod
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestResolvedJavaMethod
  */
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java
index 9c90450..48946aa 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java
@@ -29,6 +29,7 @@
  *          jdk.vm.ci/jdk.vm.ci.meta
  *          jdk.vm.ci/jdk.vm.ci.runtime
  *          jdk.vm.ci/jdk.vm.ci.common
+ *          java.base/jdk.internal.misc
  * @build jdk.vm.ci.runtime.test.TestResolvedJavaType
  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestResolvedJavaType
  */
@@ -584,29 +585,20 @@
         return declarations;
     }
 
-    private static void checkResolveMethod(ResolvedJavaType type, ResolvedJavaType context, ResolvedJavaMethod decl, ResolvedJavaMethod expected) {
-        ResolvedJavaMethod impl = type.resolveConcreteMethod(decl, context);
-        assertEquals(expected, impl);
-    }
-
     @Test
     public void resolveMethodTest() {
         ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class);
         for (Class<?> c : classes) {
-            if (c.isInterface() || c.isPrimitive()) {
-                ResolvedJavaType type = metaAccess.lookupJavaType(c);
+            ResolvedJavaType type = metaAccess.lookupJavaType(c);
+            if (c.isInterface()) {
                 for (Method m : c.getDeclaredMethods()) {
-                    if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) {
-                        ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m);
-                        ResolvedJavaMethod impl = type.resolveMethod(resolved, context);
-                        ResolvedJavaMethod expected = resolved.isDefault() || resolved.isAbstract() ? resolved : null;
-                        assertEquals(m.toString(), expected, impl);
-                    } else {
-                        // As of JDK 8, interfaces can have static and private methods
-                    }
+                    ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m);
+                    ResolvedJavaMethod impl = type.resolveMethod(resolved, context);
+                    assertEquals(m.toString(), null, impl);
                 }
+            } else if (c.isPrimitive()) {
+                assertEquals("No methods expected", c.getDeclaredMethods().length, 0);
             } else {
-                ResolvedJavaType type = metaAccess.lookupJavaType(c);
                 VTable vtable = getVTable(c);
                 for (Method impl : vtable.methods.values()) {
                     Set<Method> decls = findDeclarations(impl, c);
@@ -614,7 +606,7 @@
                         ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl);
                         if (m.isPublic()) {
                             ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl);
-                            checkResolveMethod(type, context, m, i);
+                            assertEquals(m.toString(), i, type.resolveMethod(m, context));
                         }
                     }
                 }
@@ -626,20 +618,16 @@
     public void resolveConcreteMethodTest() {
         ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class);
         for (Class<?> c : classes) {
-            if (c.isInterface() || c.isPrimitive()) {
-                ResolvedJavaType type = metaAccess.lookupJavaType(c);
+            ResolvedJavaType type = metaAccess.lookupJavaType(c);
+            if (c.isInterface()) {
                 for (Method m : c.getDeclaredMethods()) {
-                    if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) {
-                        ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m);
-                        ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context);
-                        ResolvedJavaMethod expected = resolved.isDefault() ? resolved : null;
-                        assertEquals(m.toString(), expected, impl);
-                    } else {
-                        // As of JDK 8, interfaces can have static and private methods
-                    }
+                    ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m);
+                    ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context);
+                    assertEquals(m.toString(), null, impl);
                 }
+            } else if (c.isPrimitive()) {
+                assertEquals("No methods expected", c.getDeclaredMethods().length, 0);
             } else {
-                ResolvedJavaType type = metaAccess.lookupJavaType(c);
                 VTable vtable = getVTable(c);
                 for (Method impl : vtable.methods.values()) {
                     Set<Method> decls = findDeclarations(impl, c);
@@ -647,7 +635,7 @@
                         ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl);
                         if (m.isPublic()) {
                             ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl);
-                            checkResolveMethod(type, context, m, i);
+                            assertEquals(i, type.resolveConcreteMethod(m, context));
                         }
                     }
                 }
@@ -880,6 +868,31 @@
         }
     }
 
+    static class TrivialCloneable implements Cloneable {
+        @Override
+        protected Object clone() {
+            return new TrivialCloneable();
+        }
+    }
+
+    @Test
+    public void isCloneableWithAllocationTest() {
+        ResolvedJavaType cloneable = metaAccess.lookupJavaType(Cloneable.class);
+        for (Class<?> c : classes) {
+            ResolvedJavaType type = metaAccess.lookupJavaType(c);
+            if (type.isCloneableWithAllocation()) {
+                // Only Cloneable types should be allocation cloneable
+                assertTrue(c.toString(), cloneable.isAssignableFrom(type));
+            }
+        }
+        /*
+         * We can't know for sure which types should be allocation cloneable on a particular
+         * platform but assume that at least totally trivial objects should be.
+         */
+        ResolvedJavaType trivialCloneable = metaAccess.lookupJavaType(TrivialCloneable.class);
+        assertTrue(trivialCloneable.toString(), trivialCloneable.isCloneableWithAllocation());
+    }
+
     @Test
     public void findMethodTest() {
         try {
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java
index c660689..59969f8 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java
@@ -57,7 +57,7 @@
 
 import org.junit.Test;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 //JaCoCo Exclude
 
diff --git a/hotspot/test/compiler/jvmci/meta/StableFieldTest.java b/hotspot/test/compiler/jvmci/meta/StableFieldTest.java
index 82a3b98..5c2bd0d 100644
--- a/hotspot/test/compiler/jvmci/meta/StableFieldTest.java
+++ b/hotspot/test/compiler/jvmci/meta/StableFieldTest.java
@@ -26,6 +26,7 @@
  * @bug 8151664
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  *          jdk.vm.ci/jdk.vm.ci.hotspot
  *          jdk.vm.ci/jdk.vm.ci.meta
diff --git a/hotspot/test/compiler/linkage/CallSites.jasm b/hotspot/test/compiler/linkage/CallSites.jasm
new file mode 100644
index 0000000..813a9df
--- /dev/null
+++ b/hotspot/test/compiler/linkage/CallSites.jasm
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+super class I
+version 52:0
+{
+
+}
+
+
+super class CallSites
+version 52:0
+{
+
+    // Non-existent methods.
+
+    // I.m1()V vs I.m1(I)V
+    public static Method testI1:"(LI;)V"
+        stack 1 locals 1
+    {
+        aload_0;
+        invokeinterface InterfaceMethod I."m1":"()V", 1; // throws NSME
+        return;
+    }
+
+    // X.m1()V vs X.m1(I)V
+    public static Method testX1:"(LX;)V"
+        stack 1 locals 1
+    {
+        aload_0;
+        invokevirtual Method X."m1":"()V"; // throws NSME
+        return;
+    }
+
+    // invokestatic of instance methods.
+
+    public static Method testI2:"()V"
+        stack 1 locals 0
+    {
+        iconst_0;
+        invokestatic InterfaceMethod I."m1":"(I)V"; // throws ICCE
+        return;
+    }
+
+    public static Method testX2:"()V"
+        stack 1 locals 0
+    {
+        iconst_0;
+        invokestatic Method X."m1":"(I)V"; // throws ICCE
+        return;
+    }
+
+    // Virtual invocation of static methods.
+
+    public static Method testI3:"(LI;)V"
+        stack 1 locals 1
+    {
+        aload_0;
+        invokeinterface InterfaceMethod I."s1":"()V", 1; // throws ICCE
+        return;
+    }
+
+    public static Method testX3:"(LX;)V"
+        stack 1 locals 1
+    {
+        aload_0;
+        invokevirtual Method X."s1":"()V";  // throws ICCE
+        return;
+    }
+
+} // end Class CallSites
diff --git a/hotspot/test/compiler/linkage/LinkageErrors.java b/hotspot/test/compiler/linkage/LinkageErrors.java
new file mode 100644
index 0000000..0a1b2a8
--- /dev/null
+++ b/hotspot/test/compiler/linkage/LinkageErrors.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+/*
+ * @test
+ * @bug 8132879
+ * @compile CallSites.jasm
+ * @run main/othervm -Xverify:all -Xbatch -XX:CompileCommand=dontinline,Test::test* LinkageErrors
+ */
+
+import java.lang.invoke.*;
+
+interface I {
+    void m1(int i);
+    static void s1() {}
+}
+
+class A implements I {
+    public void m1(int i) {}
+}
+
+class X {
+    public        void m1(int i) {}
+    public final  void f1(int i) {}
+    public static void s1(int i) {}
+}
+
+public class LinkageErrors {
+    final static MethodHandles.Lookup L = MethodHandles.lookup();
+
+    static void test(MethodHandle mh) {
+        try {
+            mh.invokeExact();
+            throw new AssertionError("No exception thrown");
+        } catch (LinkageError e) {
+            return; // expected
+        } catch (AssertionError e) {
+            throw e; // rethrow
+        } catch (Throwable e) {
+            throw new AssertionError("Unexpected exception", e);
+        }
+    }
+
+    public static void main(String args[]) throws Throwable {
+        Class<?> test = Class.forName("CallSites");
+
+        // Non-existent method lookups.
+        MethodHandle testI1 = L.findStatic(test, "testI1", MethodType.methodType(void.class, I.class));
+        MethodHandle testX1 = L.findStatic(test, "testX1", MethodType.methodType(void.class, X.class));
+
+        MethodHandle testI1_A    = testI1.bindTo(new A());
+        MethodHandle testI1_null = testI1.bindTo(null);
+        MethodHandle testX1_X    = testX1.bindTo(new X());
+        MethodHandle testX1_null = testX1.bindTo(null);
+
+        // invokestatic of instance methods.
+        MethodHandle testI2 = L.findStatic(test, "testI2", MethodType.methodType(void.class));
+        MethodHandle testX2 = L.findStatic(test, "testX2", MethodType.methodType(void.class));
+
+        MethodHandle testI3 = L.findStatic(test, "testI3", MethodType.methodType(void.class, I.class));
+        MethodHandle testX3 = L.findStatic(test, "testX3", MethodType.methodType(void.class, X.class));
+
+        // Virtual invocation of static methods.
+        MethodHandle testI3_A    = testI3.bindTo(new A());
+        MethodHandle testI3_null = testI3.bindTo(null);
+        MethodHandle testX3_X    = testX3.bindTo(new X());
+        MethodHandle testX3_null = testX3.bindTo(null);
+
+        for (int i = 0; i < 20_000; i++) {
+            test(testI1_A);
+            test(testI1_null);
+            test(testX1_X);
+            test(testX1_null);
+
+            test(testI2);
+            test(testX2);
+
+            test(testI3_A);
+            test(testI3_null);
+            test(testX3_X);
+            test(testX3_null);
+        }
+
+        System.out.println("TEST PASSED");
+    }
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java
similarity index 69%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java
index 9e5a4a7..63745f7 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -21,17 +19,19 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
+ *
  */
-package jdk.tools.jlink.plugin;
-
-import java.util.Properties;
 
 /**
- * Interface to plugin (container) context.
+ * @test TestSplitIfBlocksDisabled
+ * @bug 8086057
+ * @summary Verifies that loop optimizations work if SplitIfBlocks is disabled.
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:-SplitIfBlocks TestSplitIfBlocksDisabled
  */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+public class TestSplitIfBlocksDisabled {
+
+    public static void main(String[] args) {
+      System.out.println("Passed");
+    }
 }
+
diff --git a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java
index 689b7f4..67cd3c9 100644
--- a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java
+++ b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java
@@ -27,6 +27,7 @@
  * @bug 6869327
  * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.base
  * @ignore 8146096
  * @run main UseCountedLoopSafepoints
diff --git a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java
index 60c47e3..41e7769 100644
--- a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java
+++ b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java
@@ -23,12 +23,13 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * @test
  * @bug 8078497
  * @summary Tests correct alignment of vectors with loop invariant offset.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main TestVectorizationWithInvariant
  */
diff --git a/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java b/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java
new file mode 100644
index 0000000..6a3fa0d
--- /dev/null
+++ b/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2016 Azul Systems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestOnSpinWait
+ * @summary (x86 only) checks that java.lang.Thread.onSpinWait is intrinsified
+ * @bug 8147844
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ * @requires os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64"
+ * @run main TestOnSpinWait
+ */
+
+import java.lang.invoke.*;
+import jdk.test.lib.*;
+import static jdk.test.lib.Asserts.*;
+
+public class TestOnSpinWait {
+
+    public static void main(String[] args) throws Exception {
+
+        // Test C1 compiler
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+          "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
+          "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch",
+          "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions",
+          "-XX:+PrintInlining", "TestOnSpinWait$Launcher");
+
+        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
+
+        analyzer.shouldHaveExitValue(0);
+
+        // The test is applicable only to C1 (present in Server VM).
+        analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes)   intrinsic");
+
+        // Test C2 compiler
+        pb = ProcessTools.createJavaProcessBuilder(
+          "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
+          "-XX:-TieredCompilation", "-Xbatch",
+          "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions",
+          "-XX:+PrintInlining", "TestOnSpinWait$Launcher");
+
+        analyzer = new OutputAnalyzer(pb.start());
+
+        analyzer.shouldHaveExitValue(0);
+
+        // The test is applicable only to C2 (present in Server VM).
+        if (analyzer.getStderr().contains("Server VM")) {
+            analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes)   (intrinsic)");
+        }
+    }
+
+    static class Launcher {
+
+        public static void main(final String[] args) throws Exception {
+            int end = 20_000;
+
+            for (int i=0; i < end; i++) {
+                test();
+            }
+        }
+        static void test() {
+            java.lang.Thread.onSpinWait();
+        }
+    }
+}
diff --git a/hotspot/test/compiler/oracle/GetMethodOptionTest.java b/hotspot/test/compiler/oracle/GetMethodOptionTest.java
index a6b92b2..ed295f41 100644
--- a/hotspot/test/compiler/oracle/GetMethodOptionTest.java
+++ b/hotspot/test/compiler/oracle/GetMethodOptionTest.java
@@ -30,6 +30,7 @@
 /*
  * @test
  * @bug 8074980
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox jdk.test.lib.Asserts GetMethodOptionTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/oracle/MethodMatcherTest.java b/hotspot/test/compiler/oracle/MethodMatcherTest.java
index 386f244..1f15827 100644
--- a/hotspot/test/compiler/oracle/MethodMatcherTest.java
+++ b/hotspot/test/compiler/oracle/MethodMatcherTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test MethodMatcherTest
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/profiling/UnsafeAccess.java b/hotspot/test/compiler/profiling/UnsafeAccess.java
new file mode 100644
index 0000000..28abc34
--- /dev/null
+++ b/hotspot/test/compiler/profiling/UnsafeAccess.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8134918
+ * @modules java.base/jdk.internal.misc
+ * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -Xbatch
+ *                                 -XX:CompileCommand=dontinline,UnsafeAccess::test*
+ *                                 UnsafeAccess
+ */
+import jdk.internal.misc.Unsafe;
+
+public class UnsafeAccess {
+    private static final Unsafe U = Unsafe.getUnsafe();
+
+    static Class cls = Object.class;
+    static long off = U.ARRAY_OBJECT_BASE_OFFSET;
+
+    static Object testUnsafeAccess(Object o, boolean isObjArray) {
+        if (o != null && cls.isInstance(o)) { // speculates "o" type to int[]
+            return helperUnsafeAccess(o, isObjArray);
+        }
+        return null;
+    }
+
+    static Object helperUnsafeAccess(Object o, boolean isObjArray) {
+        if (isObjArray) {
+            U.putObject(o, off, new Object());
+        }
+        return o;
+    }
+
+    static Object testUnsafeLoadStore(Object o, boolean isObjArray) {
+        if (o != null && cls.isInstance(o)) { // speculates "o" type to int[]
+            return helperUnsafeLoadStore(o, isObjArray);
+        }
+        return null;
+    }
+
+    static Object helperUnsafeLoadStore(Object o, boolean isObjArray) {
+        if (isObjArray) {
+            Object o1 = U.getObject(o, off);
+            U.compareAndSwapObject(o, off, o1, new Object());
+        }
+        return o;
+    }
+
+    public static void main(String[] args) {
+        Object[] objArray = new Object[10];
+        int[]    intArray = new    int[10];
+
+        for (int i = 0; i < 20_000; i++) {
+            helperUnsafeAccess(objArray, true);
+        }
+        for (int i = 0; i < 20_000; i++) {
+            testUnsafeAccess(intArray, false);
+        }
+
+        for (int i = 0; i < 20_000; i++) {
+            helperUnsafeLoadStore(objArray, true);
+        }
+        for (int i = 0; i < 20_000; i++) {
+            testUnsafeLoadStore(intArray, false);
+        }
+
+        System.out.println("TEST PASSED");
+    }
+}
diff --git a/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java b/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java
index 0053ffa..c4c97f9 100644
--- a/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java
+++ b/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,9 @@
  * @test
  * @bug 8073480
  * @summary explicit range checks should be recognized by C2
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox /
- * @build  TestExplicitRangeChecks
+ * @build TestExplicitRangeChecks
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main ClassFileInstaller jdk.test.lib.Platform
  * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
@@ -40,12 +41,14 @@
 import sun.hotspot.WhiteBox;
 import sun.hotspot.code.NMethod;
 import jdk.test.lib.Platform;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import compiler.whitebox.CompilerWhiteBoxTest;
 
 public class TestExplicitRangeChecks {
-
-    static int[] array = new int[10];
+    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+    private static final int TIERED_STOP_AT_LEVEL = WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue();
+    private static int[] array = new int[10];
+    private static boolean success = true;
 
     @Retention(RetentionPolicy.RUNTIME)
     @interface Args {
@@ -366,10 +369,6 @@
         return true;
     }
 
-    static boolean success = true;
-
-    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
-
     final HashMap<String,Method> tests = new HashMap<>();
     {
         for (Method m : this.getClass().getDeclaredMethods()) {
@@ -439,7 +438,9 @@
                 System.out.println(name + " bad result for bad input " + bad[i]);
                 success = false;
             }
-            if (Platform.isServer()) {
+            // Only perform these additional checks if C2 is available
+            if (Platform.isServer() &&
+                TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
                 if (deoptimize && WHITE_BOX.isMethodCompiled(m)) {
                     System.out.println(name + " not deoptimized on invalid access");
                     success = false;
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java
similarity index 67%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java
index 9e5a4a7..288af4d 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -21,17 +19,19 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
+ *
  */
-package jdk.tools.jlink.plugin;
-
-import java.util.Properties;
 
 /**
- * Interface to plugin (container) context.
+ * @test TestRangeCheckEliminationDisabled
+ * @bug 8154763
+ * @summary Tests PostLoopMultiversioning with RangeCheckElimination disabled.
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+PostLoopMultiversioning -XX:-RangeCheckElimination TestRangeCheckEliminationDisabled
  */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+public class TestRangeCheckEliminationDisabled {
+
+    public static void main(String[] args) {
+      System.out.println("Passed");
+    }
 }
+
diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java
index 90a9f14..574b7cc 100644
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java
@@ -44,7 +44,7 @@
 import rtm.*;
 import rtm.predicate.SupportedCPU;
 import rtm.predicate.SupportedVM;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Test verifies that method will be deoptimized on high abort ratio
diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java
index 605f795..e4623c2 100644
--- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java
@@ -46,7 +46,7 @@
 import rtm.*;
 import rtm.predicate.SupportedCPU;
 import rtm.predicate.SupportedVM;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * To verify that with +UseRTMDeopt method's RTM state will be
diff --git a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java
index b531aac..de8e8a3 100644
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java
@@ -43,7 +43,7 @@
 import rtm.*;
 import rtm.predicate.SupportedCPU;
 import rtm.predicate.SupportedVM;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Test verifies that low abort ratio method will be deoptimized with
diff --git a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java
index 8b1ee98..7280fc2 100644
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java
@@ -44,7 +44,7 @@
 import rtm.*;
 import rtm.predicate.SupportedCPU;
 import rtm.predicate.SupportedVM;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Test verifies that RTMLockingThreshold option actually affects how soon
diff --git a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java
index 4056dc9..37920da 100644
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java
@@ -37,7 +37,7 @@
  *                   -XX:+WhiteBoxAPI TestRTMTotalCountIncrRate
  */
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.util.List;
 
 import jdk.test.lib.*;
diff --git a/hotspot/test/compiler/runtime/6859338/Test6859338.java b/hotspot/test/compiler/runtime/6859338/Test6859338.java
index 03d6812..7357684 100644
--- a/hotspot/test/compiler/runtime/6859338/Test6859338.java
+++ b/hotspot/test/compiler/runtime/6859338/Test6859338.java
@@ -27,7 +27,7 @@
  * @bug 6859338
  * @summary Assertion failure in sharedRuntime.cpp
  *
- * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions  -XX:-InlineObjectHash -Xbatch -XX:-ProfileInterpreter Test6859338
+ * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-InlineObjectHash -Xbatch -XX:-ProfileInterpreter Test6859338
  */
 
 public class Test6859338 {
diff --git a/hotspot/test/compiler/runtime/8010927/Test8010927.java b/hotspot/test/compiler/runtime/8010927/Test8010927.java
index 127e80b..9453878 100644
--- a/hotspot/test/compiler/runtime/8010927/Test8010927.java
+++ b/hotspot/test/compiler/runtime/8010927/Test8010927.java
@@ -35,7 +35,7 @@
 
 import sun.hotspot.WhiteBox;
 import java.lang.reflect.Field;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * The test creates uncommitted space between oldgen and young gen
diff --git a/hotspot/test/compiler/stable/TestStableBoolean.java b/hotspot/test/compiler/stable/TestStableBoolean.java
index 5dbcef7..0be8173 100644
--- a/hotspot/test/compiler/stable/TestStableBoolean.java
+++ b/hotspot/test/compiler/stable/TestStableBoolean.java
@@ -27,31 +27,32 @@
  * @test TestStableBoolean
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableBoolean
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableBoolean
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableBoolean
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:-FoldStableValues
- *                         compiler.stable.TestStableBoolean
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:-FoldStableValues
+ *                                 compiler.stable.TestStableBoolean
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:+TieredCompilation -XX:TieredStopAtLevel=1
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableBoolean
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableBoolean
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:+TieredCompilation -XX:TieredStopAtLevel=1
- *                         -XX:-FoldStableValues
- *                         compiler.stable.TestStableBoolean
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                                 -XX:-FoldStableValues
+ *                                 compiler.stable.TestStableBoolean
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableByte.java b/hotspot/test/compiler/stable/TestStableByte.java
index 0a5d46b..a983cfa 100644
--- a/hotspot/test/compiler/stable/TestStableByte.java
+++ b/hotspot/test/compiler/stable/TestStableByte.java
@@ -27,31 +27,32 @@
  * @test TestStableByte
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableByte
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableByte
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableByte
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableByte
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableByte
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableByte
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableByte
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableByte
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableByte
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableChar.java b/hotspot/test/compiler/stable/TestStableChar.java
index 7aeb172..6fcc407 100644
--- a/hotspot/test/compiler/stable/TestStableChar.java
+++ b/hotspot/test/compiler/stable/TestStableChar.java
@@ -27,31 +27,32 @@
  * @test TestStableChar
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableChar
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableChar
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableChar
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableChar
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableChar
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableChar
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableChar
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableChar
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableChar
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableDouble.java b/hotspot/test/compiler/stable/TestStableDouble.java
index 30617b9..09a388a 100644
--- a/hotspot/test/compiler/stable/TestStableDouble.java
+++ b/hotspot/test/compiler/stable/TestStableDouble.java
@@ -27,31 +27,32 @@
  * @test TestStableDouble
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableDouble
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableDouble
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableDouble
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableDouble
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableDouble
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableDouble
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableDouble
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableDouble
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableDouble
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableFloat.java b/hotspot/test/compiler/stable/TestStableFloat.java
index d17ee9b..7053e67 100644
--- a/hotspot/test/compiler/stable/TestStableFloat.java
+++ b/hotspot/test/compiler/stable/TestStableFloat.java
@@ -27,31 +27,32 @@
  * @test TestStableFloat
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableFloat
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableFloat
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableFloat
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableFloat
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableFloat
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableFloat
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableFloat
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableFloat
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableFloat
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableInt.java b/hotspot/test/compiler/stable/TestStableInt.java
index 24f6a56..1ebe529 100644
--- a/hotspot/test/compiler/stable/TestStableInt.java
+++ b/hotspot/test/compiler/stable/TestStableInt.java
@@ -27,31 +27,32 @@
  * @test TestStableInt
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableInt
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableInt
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableInt
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableInt
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableInt
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableInt
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableInt
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableInt
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableInt
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableLong.java b/hotspot/test/compiler/stable/TestStableLong.java
index 4f4f210..b70ea91 100644
--- a/hotspot/test/compiler/stable/TestStableLong.java
+++ b/hotspot/test/compiler/stable/TestStableLong.java
@@ -27,31 +27,32 @@
  * @test TestStableLong
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableLong
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableLong
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableLong
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableLong
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableLong
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableLong
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableLong
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableLong
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableLong
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableMemoryBarrier.java b/hotspot/test/compiler/stable/TestStableMemoryBarrier.java
index 313dac2..4a421c6 100644
--- a/hotspot/test/compiler/stable/TestStableMemoryBarrier.java
+++ b/hotspot/test/compiler/stable/TestStableMemoryBarrier.java
@@ -28,10 +28,11 @@
  * @bug 8139758
  * @summary tests memory barrier correctly inserted for stable fields
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  *
  * @run main/bootclasspath/othervm -Xcomp -XX:CompileOnly=::testCompile
- *                         compiler.stable.TestStableMemoryBarrier
+ *                                 compiler.stable.TestStableMemoryBarrier
  *
  * @author hui.shi@linaro.org
  */
diff --git a/hotspot/test/compiler/stable/TestStableObject.java b/hotspot/test/compiler/stable/TestStableObject.java
index c08afa8..cc0f89b 100644
--- a/hotspot/test/compiler/stable/TestStableObject.java
+++ b/hotspot/test/compiler/stable/TestStableObject.java
@@ -27,31 +27,32 @@
  * @test TestStableObject
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableObject
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableObject
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableObject
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableObject
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableObject
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableObject
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableObject
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableObject
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableObject
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableShort.java b/hotspot/test/compiler/stable/TestStableShort.java
index bab170a..15c71b4 100644
--- a/hotspot/test/compiler/stable/TestStableShort.java
+++ b/hotspot/test/compiler/stable/TestStableShort.java
@@ -27,31 +27,32 @@
  * @test TestStableShort
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableShort
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableShort
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableShort
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableShort
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableShort
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableShort
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableShort
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         compiler.stable.TestStableShort
+ *                                 -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 compiler.stable.TestStableShort
  */
 
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableUByte.java b/hotspot/test/compiler/stable/TestStableUByte.java
index b1c68da..788feca 100644
--- a/hotspot/test/compiler/stable/TestStableUByte.java
+++ b/hotspot/test/compiler/stable/TestStableUByte.java
@@ -27,35 +27,36 @@
  * @test TestStableUByte
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableUByte
  *
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUByte
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUByte
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:-TieredCompilation
- *                         -XX:-FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUByte
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:-FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUByte
  *
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:+TieredCompilation -XX:TieredStopAtLevel=1
- *                         -XX:+FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUByte
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                                 -XX:+FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUByte
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:+TieredCompilation -XX:TieredStopAtLevel=1
- *                         -XX:-FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUByte
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                                 -XX:-FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUByte
  *
  */
 package compiler.stable;
diff --git a/hotspot/test/compiler/stable/TestStableUShort.java b/hotspot/test/compiler/stable/TestStableUShort.java
index 2f9d44a..43ebf3c 100644
--- a/hotspot/test/compiler/stable/TestStableUShort.java
+++ b/hotspot/test/compiler/stable/TestStableUShort.java
@@ -27,35 +27,36 @@
  * @test TestStableUShort
  * @summary tests on stable fields and arrays
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build sun.hotspot.WhiteBox
  * @build compiler.stable.TestStableUShort
  *
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUShort
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUShort
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:-TieredCompilation
- *                         -XX:-FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUShort
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:-TieredCompilation
+ *                                 -XX:-FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUShort
  *
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:+TieredCompilation -XX:TieredStopAtLevel=1
- *                         -XX:+FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUShort
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                                 -XX:+FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUShort
  * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
- *                         -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
- *                         -XX:+TieredCompilation -XX:TieredStopAtLevel=1
- *                         -XX:-FoldStableValues
- *                         -XX:CompileOnly=::get,::get1
- *                         compiler.stable.TestStableUShort
+ *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                                 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                                 -XX:-FoldStableValues
+ *                                 -XX:CompileOnly=::get,::get1
+ *                                 compiler.stable.TestStableUShort
  *
  */
 package compiler.stable;
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/hotspot/test/compiler/startup/TieredStopAtLevel0SanityTest.java
similarity index 69%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to hotspot/test/compiler/startup/TieredStopAtLevel0SanityTest.java
index 9e5a4a7..a7dbf2b 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/hotspot/test/compiler/startup/TieredStopAtLevel0SanityTest.java
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -22,16 +20,16 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
 
-import java.util.Properties;
-
-/**
- * Interface to plugin (container) context.
+/*
+ * @test
+ * @bug 8154151
+ * @summary Sanity test flag combo that force compiles on level 0
+ * @run main/othervm -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:TieredStopAtLevel=0 TieredStopAtLevel0SanityTest
  */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+
+public class TieredStopAtLevel0SanityTest {
+    public static void main(String[] args) throws Exception {
+        System.out.println("Hello world!");
+    }
 }
diff --git a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java
index 19e3bf8..39916c5 100644
--- a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java
+++ b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java
@@ -25,7 +25,7 @@
 package rtm;
 
 import jdk.test.lib.Utils;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Current RTM locking implementation force transaction abort
diff --git a/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java b/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java
index 5f423d3..8d33ad6 100644
--- a/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java
+++ b/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java
@@ -59,14 +59,23 @@
     };
 
     public static final BooleanSupplier SHA1_INSTRUCTION_AVAILABLE
-            = new OrPredicate(
-                    new CPUSpecificPredicate("sparc.*", new String[] { "sha1" },null),
-                    new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" },null));
+            = new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" },null),
+              new OrPredicate(
+                      new CPUSpecificPredicate("sparc.*", new String[] { "sha1" },null),
+                      new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" },null)))));
 
     public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE
-            = new OrPredicate(
-                    new CPUSpecificPredicate("sparc.*", new String[] { "sha256" },null),
-                    new CPUSpecificPredicate("aarch64.*", new String[] { "sha256" },null));
+            = new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] {
+"sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null),
+              new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null),
+              new OrPredicate(
+                      new CPUSpecificPredicate("sparc.*", new String[] { "sha256" },null),
+                      new CPUSpecificPredicate("aarch64.*", new String[] { "sha256" },null)))))));
 
     public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE
             = new OrPredicate(
diff --git a/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java
index 4eb086a..d0cbbad 100644
--- a/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java
+++ b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java
@@ -31,9 +31,9 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build TransitionsTestExecutor ConstantGettersTransitionsTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
- *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
+ *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation -XX:-UseCounterDecay
  *                   -XX:CompileCommand=compileonly,ConstantGettersTestCase$TrivialMethods::*
  *                   TransitionsTestExecutor ConstantGettersTransitionsTest
  * @summary Test the correctness of compilation level transitions for constant getters methods
diff --git a/hotspot/test/compiler/tiered/LevelTransitionTest.java b/hotspot/test/compiler/tiered/LevelTransitionTest.java
index c011ba4..62f1fc6 100644
--- a/hotspot/test/compiler/tiered/LevelTransitionTest.java
+++ b/hotspot/test/compiler/tiered/LevelTransitionTest.java
@@ -38,7 +38,7 @@
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
- *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::*
+ *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::*
  *                   -XX:CompileCommand=compileonly,ExtendedTestCase$CompileMethodHolder::*
  *                   TransitionsTestExecutor LevelTransitionTest
  * @summary Test the correctness of compilation level transitions for different methods
@@ -80,7 +80,7 @@
     /**
      * Makes and verifies transitions between compilation levels
      */
-    protected void checkTransitions() {
+    protected void checkTransitions() throws Exception {
         checkNotCompiled();
         boolean finish = false;
         while (!finish) {
diff --git a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java
index 4a1a52e..98fad1e 100644
--- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java
+++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java
@@ -27,13 +27,14 @@
 /**
  * @test NonTieredLevelsTest
  * @library /testlibrary /test/lib /compiler/whitebox /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build NonTieredLevelsTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:-TieredCompilation
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::*
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay
+ *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::*
  *                   NonTieredLevelsTest
  * @summary Verify that only one level can be used
  * @author igor.ignatyev@oracle.com
diff --git a/hotspot/test/compiler/tiered/TieredLevelsTest.java b/hotspot/test/compiler/tiered/TieredLevelsTest.java
index 0790b19..bf18121 100644
--- a/hotspot/test/compiler/tiered/TieredLevelsTest.java
+++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java
@@ -26,13 +26,14 @@
 /**
  * @test TieredLevelsTest
  * @library /testlibrary /test/lib /compiler/whitebox /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build TieredLevelsTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::*
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay
+ *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::*
  *                   TieredLevelsTest
  * @summary Verify that all levels &lt; 'TieredStopAtLevel' can be used
  * @author igor.ignatyev@oracle.com
diff --git a/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java b/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java
index 50979d2..7295581 100644
--- a/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java
+++ b/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java
@@ -27,6 +27,7 @@
 /*
  * @test
  * @bug 8009761
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
  * @build Test8009761
diff --git a/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java b/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java
index c7dc5ca..a6707d5 100644
--- a/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java
+++ b/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java
@@ -31,7 +31,7 @@
 
 import java.lang.reflect.Field;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class GetUnsafeObjectG1PreBarrier {
     private static final Unsafe unsafe;
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
index 58fe929..96c1a82 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestBoolean {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -148,4 +149,3 @@
 
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
index 12ae3c3..2b5438e 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestByte {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -185,4 +186,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
index f912b7f..67f4258 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestChar {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -203,4 +204,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
index adbe249..5304bc2 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestDouble {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -185,4 +186,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
index 6e08a21..f7c542e 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestFloat {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -185,4 +186,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
index 47bfd7d..817e78d 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestInt {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -251,26 +252,47 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapInt(base, offset, 1, 2);
-            assertEquals(r, true, "weakCompareAndSwap int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapInt(base, offset, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSwap int");
             int x = UNSAFE.getInt(base, offset);
             assertEquals(x, 2, "weakCompareAndSwap int value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 2, 1);
-            assertEquals(r, true, "weakCompareAndSwapAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire int");
             int x = UNSAFE.getInt(base, offset);
             assertEquals(x, 1, "weakCompareAndSwapAcquire int");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 1, 2);
-            assertEquals(r, true, "weakCompareAndSwapRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease int");
             int x = UNSAFE.getInt(base, offset);
             assertEquals(x, 2, "weakCompareAndSwapRelease int");
         }
 
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile int");
+            int x = UNSAFE.getInt(base, offset);
+            assertEquals(x, 1, "weakCompareAndSwapVolatile int");
+        }
+
+        UNSAFE.putInt(base, offset, 2);
+
         // Compare set and get
         {
             int o = UNSAFE.getAndSetInt(base, offset, 1);
@@ -286,7 +308,7 @@
             int o = UNSAFE.getAndAddInt(base, offset, 2);
             assertEquals(o, 1, "getAndAdd int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1 + 2, "weakCompareAndSwapRelease int");
+            assertEquals(x, 1 + 2, "getAndAdd int");
         }
     }
 
@@ -300,4 +322,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
index 9ed8b87..d4b8837 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestLong {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -251,26 +252,47 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapLong(base, offset, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSwap long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapLong(base, offset, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSwap long");
             long x = UNSAFE.getLong(base, offset);
             assertEquals(x, 2L, "weakCompareAndSwap long value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSwapAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire long");
             long x = UNSAFE.getLong(base, offset);
             assertEquals(x, 1L, "weakCompareAndSwapAcquire long");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSwapRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease long");
             long x = UNSAFE.getLong(base, offset);
             assertEquals(x, 2L, "weakCompareAndSwapRelease long");
         }
 
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile long");
+            long x = UNSAFE.getLong(base, offset);
+            assertEquals(x, 1L, "weakCompareAndSwapVolatile long");
+        }
+
+        UNSAFE.putLong(base, offset, 2L);
+
         // Compare set and get
         {
             long o = UNSAFE.getAndSetLong(base, offset, 1L);
@@ -286,7 +308,7 @@
             long o = UNSAFE.getAndAddLong(base, offset, 2L);
             assertEquals(o, 1L, "getAndAdd long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L + 2L, "weakCompareAndSwapRelease long");
+            assertEquals(x, 1L + 2L, "getAndAdd long");
         }
     }
 
@@ -300,4 +322,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
index 2db2efa..7fc59cd 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestObject {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -204,26 +205,47 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSwap Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSwap Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "bar", "weakCompareAndSwap Object value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSwapAcquire Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "foo", "weakCompareAndSwapAcquire Object");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSwapRelease Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "bar", "weakCompareAndSwapRelease Object");
         }
 
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObjectVolatile(base, offset, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile Object");
+            Object x = UNSAFE.getObject(base, offset);
+            assertEquals(x, "foo", "weakCompareAndSwapVolatile Object");
+        }
+
+        UNSAFE.putObject(base, offset, "bar");
+
         // Compare set and get
         {
             Object o = UNSAFE.getAndSetObject(base, offset, "foo");
@@ -236,4 +258,3 @@
 
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
index 814e036..a9fab93 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestShort {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -203,4 +204,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
index 7288954..c5349ff 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestBoolean {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -131,9 +132,7 @@
 
 
 
-
     }
 
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
index 928f517..24ab3f8 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestByte {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
index 48aa82f..7000479 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestChar {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
index 0902911..9300fc0 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestDouble {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
index 41056dc..39a3f51 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestFloat {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
index ecf79ee..4310a6e 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestInt {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -165,7 +166,6 @@
 
 
 
-
         UNSAFE.putInt(base, offset, 1);
 
         // Compare
@@ -183,7 +183,7 @@
             assertEquals(x, 2, "failing compareAndSwap int value");
         }
 
-
+        UNSAFE.putInt(base, offset, 2);
 
         // Compare set and get
         {
@@ -200,7 +200,7 @@
             int o = UNSAFE.getAndAddInt(base, offset, 2);
             assertEquals(o, 1, "getAndAdd int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1 + 2, "weakCompareAndSwapRelease int");
+            assertEquals(x, 1 + 2, "getAndAdd int");
         }
     }
 
@@ -214,4 +214,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
index 4a9b480..6dd6434 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestLong {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -165,7 +166,6 @@
 
 
 
-
         UNSAFE.putLong(base, offset, 1L);
 
         // Compare
@@ -183,7 +183,7 @@
             assertEquals(x, 2L, "failing compareAndSwap long value");
         }
 
-
+        UNSAFE.putLong(base, offset, 2L);
 
         // Compare set and get
         {
@@ -200,7 +200,7 @@
             long o = UNSAFE.getAndAddLong(base, offset, 2L);
             assertEquals(o, 1L, "getAndAdd long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L + 2L, "weakCompareAndSwapRelease long");
+            assertEquals(x, 1L + 2L, "getAndAdd long");
         }
     }
 
@@ -214,4 +214,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
index efb1509..b56cc41 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestObject {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -136,7 +137,6 @@
 
 
 
-
         UNSAFE.putObject(base, offset, "foo");
 
         // Compare
@@ -154,7 +154,7 @@
             assertEquals(x, "bar", "failing compareAndSwap Object value");
         }
 
-
+        UNSAFE.putObject(base, offset, "bar");
 
         // Compare set and get
         {
@@ -168,4 +168,3 @@
 
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
index 4e4cda0..c8c7284 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestShort {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
diff --git a/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java b/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java
index edd5597..3fc0e82 100644
--- a/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java
+++ b/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java
@@ -25,12 +25,13 @@
  * @test
  * @bug 8077504
  * @summary Unsafe load can loose control dependency and cause crash
+ * @modules java.base/jdk.internal.misc
  * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestUnsafeLoadControl
  *
  */
 
 import java.lang.reflect.Field;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class TestUnsafeLoadControl {
 
diff --git a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java
index 2ffc5ec..7701443 100644
--- a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java
+++ b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java
@@ -33,24 +33,25 @@
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.vm.annotation
  *          java.base/jdk.internal.misc
- * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
- *                         -Xbatch -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress()
- *                         -XX:CompileCommand=dontinline,*.test*
- *                         -XX:+UseUnalignedAccesses
- *                         -XaddReads:java.base=ALL-UNNAMED
- *                         compiler.unsafe.UnsafeGetConstantField
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
- *                         -Xbatch -XX:-TieredCompilation
- *                         -XX:+FoldStableValues
- *                         -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress()
- *                         -XX:CompileCommand=dontinline,*.test*
- *                         -XX:CompileCommand=inline,*Unsafe.get*
- *                         -XX:-UseUnalignedAccesses
+ *                                 -Xbatch -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress()
+ *                                 -XX:CompileCommand=dontinline,*.test*
+ *                                 -XX:+UseUnalignedAccesses
  *                         -XaddReads:java.base=ALL-UNNAMED
- *                         compiler.unsafe.UnsafeGetConstantField
+ *                                 compiler.unsafe.UnsafeGetConstantField
+ *
+ * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
+ *                                 -Xbatch -XX:-TieredCompilation
+ *                                 -XX:+FoldStableValues
+ *                                 -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress()
+ *                                 -XX:CompileCommand=dontinline,*.test*
+ *                                 -XX:CompileCommand=inline,*Unsafe.get*
+ *                                 -XX:-UseUnalignedAccesses
+ *                         -XaddReads:java.base=ALL-UNNAMED
+ *                                 compiler.unsafe.UnsafeGetConstantField
  */
 package compiler.unsafe;
 
@@ -65,7 +66,6 @@
 import jdk.internal.misc.Unsafe;
 
 import java.io.IOException;
-import java.lang.reflect.Field;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -149,10 +149,7 @@
             if (!hasDefaultValue && (stable || g.isFinal())) {
                 Asserts.assertEQ(t.value, test.testDirect(),
                         "direct read doesn't return prev value");
-                // fails for getCharUnaligned due to JDK-8148518
-                if (!(t == JavaType.C && "Unaligned".equals(postfix))) {
-                    Asserts.assertEQ(test.testDirect(), test.testUnsafe());
-                }
+                Asserts.assertEQ(test.testDirect(), test.testUnsafe());
             } else {
                 Asserts.assertEQ(t.defaultValue, test.testDirect(),
                         "direct read doesn't return default value");
diff --git a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java
index 08bdb49..c4d5672 100644
--- a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java
+++ b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java
@@ -26,24 +26,28 @@
 /*
  * @test
  * @summary tests on constant folding of unsafe get operations from stable arrays
- * @library /testlibrary /test/lib
- * @ignore 8151137
+ * @library /testlibrary
  *
  * @requires vm.flavor != "client"
  *
- * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions
+ * @modules java.base/jdk.internal.vm.annotation
+ *          java.base/jdk.internal.misc
+
+ * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
  *                   -Xbatch -XX:-TieredCompilation
  *                   -XX:+FoldStableValues
  *                   -XX:CompileCommand=dontinline,*Test::test*
- *                   UnsafeGetStableArrayElement
+ *                   compiler.unsafe.UnsafeGetStableArrayElement
  */
+package compiler.unsafe;
+
 import jdk.internal.misc.Unsafe;
 import jdk.internal.vm.annotation.Stable;
 import java.util.concurrent.Callable;
+import jdk.test.lib.Platform;
 
 import static jdk.internal.misc.Unsafe.*;
 import static jdk.test.lib.Asserts.*;
-import static jdk.test.lib.Platform;
 
 public class UnsafeGetStableArrayElement {
     @Stable static final boolean[] STABLE_BOOLEAN_ARRAY = new boolean[16];
@@ -219,13 +223,7 @@
         Setter.reset();
     }
 
-    public static void main(String[] args) throws Exception {
-        if (Platform.isServer()) {
-            test();
-        }
-    }
-
-    static void test() throws Exception {
+    static void testUnsafeAccess() throws Exception {
         // boolean[], aligned accesses
         testMatched(   Test::testZ_Z, Test::changeZ);
         testMismatched(Test::testZ_B, Test::changeZ);
@@ -329,4 +327,11 @@
         run(Test::testL_I);
         run(Test::testL_F);
     }
+
+    public static void main(String[] args) throws Exception {
+        if (Platform.isServer()) {
+            testUnsafeAccess();
+        }
+        System.out.println("TEST PASSED");
+    }
 }
diff --git a/hotspot/test/compiler/unsafe/UnsafeRaw.java b/hotspot/test/compiler/unsafe/UnsafeRaw.java
index 80ffd83..bb2e9a1 100644
--- a/hotspot/test/compiler/unsafe/UnsafeRaw.java
+++ b/hotspot/test/compiler/unsafe/UnsafeRaw.java
@@ -33,51 +33,52 @@
 
 import jdk.test.lib.Utils;
 import java.util.Random;
+import jdk.internal.misc.Unsafe;
 
 public class UnsafeRaw {
   public static class Tests {
-    public static int int_index(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
+    public static int int_index(Unsafe unsafe, long base, int index) throws Exception {
       return unsafe.getInt(base + (index << 2));
     }
-    public static int long_index(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
+    public static int long_index(Unsafe unsafe, long base, long index) throws Exception {
       return unsafe.getInt(base + (index << 2));
     }
-    public static int int_index_back_ashift(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
+    public static int int_index_back_ashift(Unsafe unsafe, long base, int index) throws Exception {
       return unsafe.getInt(base + (index >> 2));
     }
-    public static int int_index_back_lshift(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
+    public static int int_index_back_lshift(Unsafe unsafe, long base, int index) throws Exception {
       return unsafe.getInt(base + (index >>> 2));
     }
-    public static int long_index_back_ashift(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
+    public static int long_index_back_ashift(Unsafe unsafe, long base, long index) throws Exception {
       return unsafe.getInt(base + (index >> 2));
     }
-    public static int long_index_back_lshift(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
+    public static int long_index_back_lshift(Unsafe unsafe, long base, long index) throws Exception {
       return unsafe.getInt(base + (index >>> 2));
     }
-    public static int int_const_12345678_index(sun.misc.Unsafe unsafe, long base) throws Exception {
+    public static int int_const_12345678_index(Unsafe unsafe, long base) throws Exception {
       int idx4 = 0x12345678;
       return unsafe.getInt(base + idx4);
     }
-    public static int long_const_1234567890abcdef_index(sun.misc.Unsafe unsafe, long base) throws Exception {
+    public static int long_const_1234567890abcdef_index(Unsafe unsafe, long base) throws Exception {
       long idx5 = 0x1234567890abcdefL;
       return unsafe.getInt(base + idx5);
     }
-    public static int int_index_mul(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
+    public static int int_index_mul(Unsafe unsafe, long base, int index) throws Exception {
       return unsafe.getInt(base + (index * 4));
     }
-    public static int long_index_mul(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
+    public static int long_index_mul(Unsafe unsafe, long base, long index) throws Exception {
       return unsafe.getInt(base + (index * 4));
     }
-    public static int int_index_mul_scale_16(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
+    public static int int_index_mul_scale_16(Unsafe unsafe, long base, int index) throws Exception {
       return unsafe.getInt(base + (index * 16));
     }
-    public static int long_index_mul_scale_16(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
+    public static int long_index_mul_scale_16(Unsafe unsafe, long base, long index) throws Exception {
       return unsafe.getInt(base + (index * 16));
     }
   }
 
   public static void main(String[] args) throws Exception {
-    sun.misc.Unsafe unsafe = Utils.getUnsafe();
+    Unsafe unsafe = Utils.getUnsafe();
     final int array_size = 128;
     final int element_size = 4;
     final int magic = 0x12345678;
diff --git a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template
index e1957e0..19c3bfa 100644
--- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template
+++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template
@@ -40,6 +40,7 @@
 
 public class $Qualifier$UnsafeAccessTest$Type$ {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final $package$.Unsafe UNSAFE;
 
@@ -273,26 +274,47 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSwap $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSwap $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
             assertEquals(x, $value2$, "weakCompareAndSwap $type$ value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSwapAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
             assertEquals(x, $value1$, "weakCompareAndSwapAcquire $type$");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSwapRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
             assertEquals(x, $value2$, "weakCompareAndSwapRelease $type$");
         }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwap$Type$Volatile(base, offset, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile $type$");
+            $type$ x = UNSAFE.get$Type$(base, offset);
+            assertEquals(x, $value1$, "weakCompareAndSwapVolatile $type$");
+        }
+
 #end[JdkInternalMisc]
+        UNSAFE.put$Type$(base, offset, $value2$);
 
         // Compare set and get
         {
@@ -311,7 +333,7 @@
             $type$ o = UNSAFE.getAndAdd$Type$(base, offset, $value2$);
             assertEquals(o, $value1$, "getAndAdd $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$ + $value2$, "weakCompareAndSwapRelease $type$");
+            assertEquals(x, $value1$ + $value2$, "getAndAdd $type$");
         }
 #end[AtomicAdd]
     }
diff --git a/hotspot/test/compiler/unsafe/generate-unsafe-tests.sh b/hotspot/test/compiler/unsafe/generate-unsafe-tests.sh
deleted file mode 100644
index a20c45a..0000000
--- a/hotspot/test/compiler/unsafe/generate-unsafe-tests.sh
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/bash
-
-javac -d . ../../../../jdk/make/src/classes/build/tools/spp/Spp.java
-
-SPP=build.tools.spp.Spp
-
-# Generates unsafe access tests for objects and all primitive types
-# $1 = package name to Unsafe, sun.misc | jdk.internal.misc
-# $2 = test class qualifier name, SunMisc | JdkInternalMisc
-function generate {
-    package=$1
-    Qualifier=$2
-
-    for type in boolean byte short char int long float double Object
-    do
-      Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}"
-      args="-K$type -Dtype=$type -DType=$Type"
-
-      case $type in
-        Object|int|long)
-          args="$args -KCAS -KOrdered"
-          ;;
-      esac
-
-      case $type in
-        int|long)
-          args="$args -KAtomicAdd"
-          ;;
-      esac
-
-      case $type in
-        short|char|int|long)
-          args="$args -KUnaligned"
-          ;;
-      esac
-
-      case $type in
-        boolean)
-          value1=true
-          value2=false
-          value3=false
-          ;;
-        byte)
-          value1=(byte)1
-          value2=(byte)2
-          value3=(byte)3
-          ;;
-        short)
-          value1=(short)1
-          value2=(short)2
-          value3=(short)3
-          ;;
-        char)
-          value1=\'a\'
-          value2=\'b\'
-          value3=\'c\'
-          ;;
-        int)
-          value1=1
-          value2=2
-          value3=3
-          ;;
-        long)
-          value1=1L
-          value2=2L
-          value3=3L
-          ;;
-        float)
-          value1=1.0f
-          value2=2.0f
-          value3=3.0f
-          ;;
-        double)
-          value1=1.0d
-          value2=2.0d
-          value3=3.0d
-          ;;
-        Object)
-          value1=\"foo\"
-          value2=\"bar\"
-          value3=\"baz\"
-          ;;
-      esac
-
-      args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3"
-
-      echo $args
-
-      java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier \
-          $args < X-UnsafeAccessTest.java.template > ${Qualifier}UnsafeAccessTest${Type}.java
-    done
-}
-
-generate sun.misc SunMisc
-generate jdk.internal.misc JdkInternalMisc
-
-rm -fr build
\ No newline at end of file
diff --git a/hotspot/test/compiler/vectorization/TestVectorUnalignedOffset.java b/hotspot/test/compiler/vectorization/TestVectorUnalignedOffset.java
new file mode 100644
index 0000000..081a6d9f
--- /dev/null
+++ b/hotspot/test/compiler/vectorization/TestVectorUnalignedOffset.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8155612
+ * @summary Aarch64: vector nodes need to support misaligned offset
+ * @run main/othervm -XX:-BackgroundCompilation TestVectorUnalignedOffset
+ *
+ */
+
+
+public class TestVectorUnalignedOffset {
+
+    static void test1(int[] src_array, int[] dst_array, int l) {
+        for (int i = 0; i < l; i++) {
+            dst_array[i + 250] = src_array[i + 250];
+        }
+    }
+
+    static void test2(byte[] src_array, byte[] dst_array, int l) {
+        for (int i = 0; i < l; i++) {
+            dst_array[i + 250] = src_array[i + 250];
+        }
+    }
+
+    static public void main(String[] args) {
+        int[] int_array = new int[1000];
+        byte[] byte_array = new byte[1000];
+        for (int i = 0; i < 20000; i++) {
+            test1(int_array, int_array, int_array.length - 250);
+            test2(byte_array, byte_array, byte_array.length - 250);
+        }
+    }
+}
diff --git a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java
index 8968d3f..db37118 100644
--- a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java
+++ b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java
@@ -35,6 +35,7 @@
  * @test AllocationCodeBlobTest
  * @bug 8059624 8064669
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build AllocationCodeBlobTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/whitebox/BlockingCompilation.java b/hotspot/test/compiler/whitebox/BlockingCompilation.java
index d960ff4..927cfea 100644
--- a/hotspot/test/compiler/whitebox/BlockingCompilation.java
+++ b/hotspot/test/compiler/whitebox/BlockingCompilation.java
@@ -23,14 +23,14 @@
 
 /*
  * @test
- * @bug 8150646
+ * @bug 8150646 8153013
  * @summary Add support for blocking compiles through whitebox API
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /
  * @build sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- *
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=60
  *        -Xbootclasspath/a:.
  *        -Xmixed
@@ -40,11 +40,10 @@
  *        BlockingCompilation
  */
 
+import compiler.testlibrary.CompilerUtils;
 import java.lang.reflect.Method;
 import java.util.Random;
-
 import sun.hotspot.WhiteBox;
-import compiler.testlibrary.CompilerUtils;
 
 public class BlockingCompilation {
     private static final WhiteBox WB = WhiteBox.getWhiteBox();
@@ -77,7 +76,13 @@
         // If the compiles are blocking, this call will block until the test time out,
         // Progress == success
         // (Don't run with -Xcomp since that can cause long timeouts due to many compiles)
-        WB.enqueueMethodForCompilation(m, highest_level);
+        if (!WB.enqueueMethodForCompilation(m, highest_level)) {
+            throw new Exception("Failed to enqueue method on level: " + highest_level);
+        }
+
+        if (!WB.isMethodQueuedForCompilation(m)) {
+            throw new Exception("Must be enqueued because of locked compilation");
+        }
 
         // restore state
         WB.unlockCompilation();
diff --git a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java
index dfc6301..38eb99a 100644
--- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java
+++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java
@@ -29,11 +29,12 @@
  * @test ClearMethodStateTest
  * @bug 8006683 8007288 8022832
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build ClearMethodStateTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ClearMethodStateTest
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+PrintCompilation -XX:-UseCounterDecay ClearMethodStateTest
  * @summary testing of WB::clearMethodState()
  * @author igor.ignatyev@oracle.com
  */
@@ -41,8 +42,8 @@
 
     public static void main(String[] args) throws Exception {
         String directive =
-                "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " +
-                " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]";
+                "[{ match:\"*SimpleTestCaseHelper.*\", BackgroundCompilation: false }, " +
+                " { match:\"*.*\", inline:\"-*SimpleTestCaseHelper.*\"}]";
         if (WHITE_BOX.addCompilerDirective(directive) != 2) {
             throw new RuntimeException("Could not add directive");
         }
diff --git a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java
index 5bec2ea..e83cd1e 100644
--- a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java
+++ b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java
@@ -24,6 +24,7 @@
 
 import sun.hotspot.WhiteBox;
 import sun.hotspot.code.NMethod;
+
 import java.lang.reflect.Executable;
 import java.util.Objects;
 import java.util.concurrent.Callable;
@@ -58,6 +59,8 @@
     /** Value of {@code -XX:BackgroundCompilation} */
     protected static final boolean BACKGROUND_COMPILATION
             = Boolean.valueOf(getVMOption("BackgroundCompilation", "true"));
+    protected static final boolean USE_COUNTER_DECAY
+            = Boolean.valueOf(getVMOption("UseCounterDecay", "true"));
     /** Value of {@code -XX:TieredCompilation} */
     protected static final boolean TIERED_COMPILATION
             = Boolean.valueOf(getVMOption("TieredCompilation", "false"));
@@ -370,7 +373,10 @@
      * @return accumulated result
      * @see #compile(int)
      */
-    protected final int compile() {
+    protected final int compile() throws Exception {
+        if (USE_COUNTER_DECAY) {
+            throw new Exception("Tests using compile method must turn off counter decay for reliability");
+        }
         if (testCase.isOsr()) {
             return compile(1);
         } else {
diff --git a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java
index b5ecf97..e479149 100644
--- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java
+++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java
@@ -27,11 +27,12 @@
  * @test DeoptimizeAllTest
  * @bug 8006683 8007288 8022832
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build DeoptimizeAllTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* DeoptimizeAllTest
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* DeoptimizeAllTest
  * @summary testing of WB::deoptimizeAll()
  * @author igor.ignatyev@oracle.com
  */
diff --git a/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java
index 75ac8cd..ce21094 100644
--- a/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java
+++ b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java
@@ -27,17 +27,18 @@
  * @test DeoptimizeFramesTest
  * @bug 8028595
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build DeoptimizeFramesTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
- *                   -XX:+WhiteBoxAPI -Xmixed
+ *                   -XX:+WhiteBoxAPI -Xmixed -XX:-UseCounterDecay
  *                   -XX:CompileCommand=compileonly,DeoptimizeFramesTest$TestCaseImpl::method
  *                   -XX:+IgnoreUnrecognizedVMOptions -XX:-DeoptimizeRandom -XX:-DeoptimizeALot
  *                   DeoptimizeFramesTest true
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
- *                   -XX:+WhiteBoxAPI -Xmixed
+ *                   -XX:+WhiteBoxAPI -Xmixed -XX:-UseCounterDecay
  *                   -XX:CompileCommand=compileonly,DeoptimizeFramesTest$TestCaseImpl::method
  *                   -XX:+IgnoreUnrecognizedVMOptions -XX:-DeoptimizeRandom -XX:-DeoptimizeALot
  *                   DeoptimizeFramesTest false
diff --git a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java
index 473f56c..71ef586 100644
--- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java
+++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java
@@ -27,11 +27,12 @@
  * @test DeoptimizeMethodTest
  * @bug 8006683 8007288 8022832
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build DeoptimizeMethodTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* DeoptimizeMethodTest
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* DeoptimizeMethodTest
  * @summary testing of WB::deoptimizeMethod()
  * @author igor.ignatyev@oracle.com
  */
diff --git a/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java b/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java
index dfd5dd2..82397fe 100644
--- a/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java
+++ b/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java
@@ -30,6 +30,7 @@
  * @test DeoptimizeMultipleOSRTest
  * @bug 8061817
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build DeoptimizeMultipleOSRTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java
index cde67e2..3bf0a1d 100644
--- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java
+++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java
@@ -27,11 +27,12 @@
  * @test EnqueueMethodForCompilationTest
  * @bug 8006683 8007288 8022832
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build EnqueueMethodForCompilationTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI EnqueueMethodForCompilationTest
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+PrintCompilation -XX:-UseCounterDecay EnqueueMethodForCompilationTest
  * @summary testing of WB::enqueueMethodForCompilation()
  * @author igor.ignatyev@oracle.com
  */
@@ -39,8 +40,8 @@
 
     public static void main(String[] args) throws Exception {
         String directive =
-                "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " +
-                " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]";
+                "[{ match:\"*SimpleTestCaseHelper.*\", BackgroundCompilation: false }, " +
+                " { match:\"*.*\", inline:\"-*SimpleTestCaseHelper.*\"}]";
         if (WHITE_BOX.addCompilerDirective(directive) != 2) {
             throw new RuntimeException("Could not add directive");
         }
@@ -86,7 +87,10 @@
         checkNotCompiled();
         WHITE_BOX.clearMethodState(method);
 
-        WHITE_BOX.enqueueMethodForCompilation(method, compLevel, bci);
+        if (!WHITE_BOX.enqueueMethodForCompilation(method, compLevel, bci)) {
+           throw new RuntimeException(method
+                    + " could not be enqueued for compilation");
+        }
         checkCompiled();
         deoptimize();
         checkNotCompiled();
diff --git a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java
index 8661b32..ea22e25 100644
--- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java
+++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java
@@ -34,16 +34,17 @@
 
 /*
  * @test
- * @bug 8059624 8064669
+ * @bug 8059624 8064669 8153265
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build ForceNMethodSweepTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:-TieredCompilation -XX:+WhiteBoxAPI
- *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::*
- *                   -XX:-BackgroundCompilation ForceNMethodSweepTest
+ *                   -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::*
+ *                   -XX:-BackgroundCompilation -XX:-UseCounterDecay ForceNMethodSweepTest
  * @summary testing of WB::forceNMethodSweep
  */
 public class ForceNMethodSweepTest extends CompilerWhiteBoxTest {
@@ -60,6 +61,12 @@
 
     @Override
     protected void test() throws Exception {
+        // prime the asserts: get their bytecodes loaded, any lazy computation
+        // resolved, and executed once
+        Asserts.assertGT(1, 0, "message");
+        Asserts.assertLTE(0, 0, "message");
+        Asserts.assertLT(-1, 0, "message");
+
         checkNotCompiled();
         guaranteedSweep();
         int usage = getTotalUsage();
diff --git a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java
index 9632585..8b2acf4 100644
--- a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java
+++ b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java
@@ -34,6 +34,7 @@
  * @test GetCodeHeapEntriesTest
  * @bug 8059624
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build GetCodeHeapEntriesTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/compiler/whitebox/GetNMethodTest.java b/hotspot/test/compiler/whitebox/GetNMethodTest.java
index 285a300..bb9f9fc 100644
--- a/hotspot/test/compiler/whitebox/GetNMethodTest.java
+++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java
@@ -31,11 +31,12 @@
  * @test GetNMethodTest
  * @bug 8038240
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build GetNMethodTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* GetNMethodTest
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* GetNMethodTest
  * @summary testing of WB::getNMethod()
  * @author igor.ignatyev@oracle.com
  */
diff --git a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java
index a733bc9..ff34c2a 100644
--- a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java
+++ b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java
@@ -27,12 +27,13 @@
  * @library /testlibrary /test/lib /
  * @modules java.base/jdk.internal.misc
  *          java.management
- * @build jdk.test.lib.* sun.hotspot.WhiteBox
+ * @build jdk.test.lib.*
+ *        sun.hotspot.WhiteBox
  * @build IsMethodCompilableTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main ClassFileInstaller jdk.test.lib.Platform
- * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -Xmixed -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* IsMethodCompilableTest
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ *                                jdk.test.lib.Platform
+ * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -Xmixed -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* IsMethodCompilableTest
  * @summary testing of WB::isMethodCompilable()
  * @author igor.ignatyev@oracle.com
  */
diff --git a/hotspot/test/compiler/whitebox/LockCompilationTest.java b/hotspot/test/compiler/whitebox/LockCompilationTest.java
index 4ba0396..eb04651 100644
--- a/hotspot/test/compiler/whitebox/LockCompilationTest.java
+++ b/hotspot/test/compiler/whitebox/LockCompilationTest.java
@@ -25,11 +25,12 @@
  * @test LockCompilationTest
  * @bug 8059624 8152169
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build LockCompilationTest
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI LockCompilationTest
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay LockCompilationTest
  * @summary testing of WB::lock/unlockCompilation()
  */
 
@@ -47,10 +48,10 @@
         // This case waits for 5 seconds and verifies that the method hasn't been
         // compiled during that time. Only do that for one of the test cases.
 
-        // Only compile SimpleTestCase$Helper.method and exclude all other to ensure no
+        // Only compile SimpleTestCaseHelper.method and exclude all other to ensure no
         // contention on the compile queue causes problems.
         String directive =
-                "[{ match:\"*SimpleTestCase$Helper.method\", Exclude:false}, " +
+                "[{ match:\"*SimpleTestCaseHelper.method\", Exclude:false}, " +
                 " { match:\"*.*\", Exclude:true}]";
         if (WHITE_BOX.addCompilerDirective(directive) != 2) {
             throw new RuntimeException("Could not add directive");
diff --git a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java
index 1e86bfb..ba06694 100644
--- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java
+++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java
@@ -27,11 +27,12 @@
  * @test MakeMethodNotCompilableTest
  * @bug 8012322 8006683 8007288 8022832
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build MakeMethodNotCompilableTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI  -Xmixed MakeMethodNotCompilableTest
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmixed -XX:-UseCounterDecay MakeMethodNotCompilableTest
  * @summary testing of WB::makeMethodNotCompilable()
  * @author igor.ignatyev@oracle.com
  */
@@ -39,8 +40,8 @@
     private int bci;
     public static void main(String[] args) throws Exception {
         String directive =
-                "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " +
-                " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]";
+                "[{ match:\"*SimpleTestCaseHelper.*\", BackgroundCompilation: false }, " +
+                " { match:\"*.*\", inline:\"-*SimpleTestCaseHelper.*\"}]";
         if (WHITE_BOX.addCompilerDirective(directive) != 2) {
             throw new RuntimeException("Could not add directive");
         }
@@ -227,7 +228,7 @@
         return false;
     }
 
-    private int getBci() {
+    private int getBci() throws Exception {
         compile();
         checkCompiled();
         int result = WHITE_BOX.getMethodEntryBci(method);
diff --git a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java
index 94846de..3ba7b77 100644
--- a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java
+++ b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java
@@ -27,11 +27,12 @@
  * @test SetDontInlineMethodTest
  * @bug 8006683 8007288 8022832
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build SetDontInlineMethodTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* SetDontInlineMethodTest
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* SetDontInlineMethodTest
  * @summary testing of WB::testSetDontInlineMethod()
  * @author igor.ignatyev@oracle.com
  */
diff --git a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java
index 497e894..c04f234 100644
--- a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java
+++ b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java
@@ -27,11 +27,12 @@
  * @test SetForceInlineMethodTest
  * @bug 8006683 8007288 8022832
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build SetForceInlineMethodTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* SetForceInlineMethodTest
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* SetForceInlineMethodTest
  * @summary testing of WB::testSetForceInlineMethod()
  * @author igor.ignatyev@oracle.com
  */
diff --git a/hotspot/test/compiler/whitebox/SimpleTestCase.java b/hotspot/test/compiler/whitebox/SimpleTestCase.java
index 76954ac..2de860e 100644
--- a/hotspot/test/compiler/whitebox/SimpleTestCase.java
+++ b/hotspot/test/compiler/whitebox/SimpleTestCase.java
@@ -31,18 +31,17 @@
 
 public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
     /** constructor test case */
-    CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE, false),
+    CONSTRUCTOR_TEST(SimpleTestCaseHelper.CONSTRUCTOR, SimpleTestCaseHelper.CONSTRUCTOR_CALLABLE, false),
     /** method test case */
-    METHOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false),
+    METHOD_TEST(SimpleTestCaseHelper.METHOD, SimpleTestCaseHelper.METHOD_CALLABLE, false),
     /** static method test case */
-    STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false),
+    STATIC_TEST(SimpleTestCaseHelper.STATIC, SimpleTestCaseHelper.STATIC_CALLABLE, false),
     /** OSR constructor test case */
-    OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR,
-            Helper.OSR_CONSTRUCTOR_CALLABLE, true),
+    OSR_CONSTRUCTOR_TEST(SimpleTestCaseHelper.OSR_CONSTRUCTOR, SimpleTestCaseHelper.OSR_CONSTRUCTOR_CALLABLE, true),
     /** OSR method test case */
-    OSR_METHOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true),
+    OSR_METHOD_TEST(SimpleTestCaseHelper.OSR_METHOD, SimpleTestCaseHelper.OSR_METHOD_CALLABLE, true),
     /** OSR static method test case */
-    OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true);
+    OSR_STATIC_TEST(SimpleTestCaseHelper.OSR_STATIC, SimpleTestCaseHelper.OSR_STATIC_CALLABLE, true);
 
     private final Executable executable;
     private final Callable<Integer> callable;
@@ -69,20 +68,21 @@
     public boolean isOsr() {
         return isOsr;
     }
+}
 
-    private static class Helper {
+    class SimpleTestCaseHelper {
 
-        private static final Callable<Integer> CONSTRUCTOR_CALLABLE
+        public static final Callable<Integer> CONSTRUCTOR_CALLABLE
                 = new Callable<Integer>() {
             @Override
             public Integer call() throws Exception {
-                return new Helper(1337).hashCode();
+                return new SimpleTestCaseHelper(1337).hashCode();
             }
         };
 
-        private static final Callable<Integer> METHOD_CALLABLE
+        public static final Callable<Integer> METHOD_CALLABLE
                 = new Callable<Integer>() {
-            private final Helper helper = new Helper();
+            private final SimpleTestCaseHelper helper = new SimpleTestCaseHelper();
 
             @Override
             public Integer call() throws Exception {
@@ -90,7 +90,7 @@
             }
         };
 
-        private static final Callable<Integer> STATIC_CALLABLE
+        public static final Callable<Integer> STATIC_CALLABLE
                 = new Callable<Integer>() {
             @Override
             public Integer call() throws Exception {
@@ -98,17 +98,17 @@
             }
         };
 
-        private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE
+        public static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE
                 = new Callable<Integer>() {
             @Override
             public Integer call() throws Exception {
-                return new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
+                return new SimpleTestCaseHelper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
             }
         };
 
-        private static final Callable<Integer> OSR_METHOD_CALLABLE
+        public static final Callable<Integer> OSR_METHOD_CALLABLE
                 = new Callable<Integer>() {
-            private final Helper helper = new Helper();
+            private final SimpleTestCaseHelper helper = new SimpleTestCaseHelper();
 
             @Override
             public Integer call() throws Exception {
@@ -116,7 +116,7 @@
             }
         };
 
-        private static final Callable<Integer> OSR_STATIC_CALLABLE
+        public static final Callable<Integer> OSR_STATIC_CALLABLE
                 = new Callable<Integer>() {
             @Override
             public Integer call() throws Exception {
@@ -124,22 +124,22 @@
             }
         };
 
-        private static final Constructor CONSTRUCTOR;
-        private static final Constructor OSR_CONSTRUCTOR;
-        private static final Method METHOD;
-        private static final Method STATIC;
-        private static final Method OSR_METHOD;
-        private static final Method OSR_STATIC;
+        public static final Constructor CONSTRUCTOR;
+        public static final Constructor OSR_CONSTRUCTOR;
+        public static final Method METHOD;
+        public static final Method STATIC;
+        public static final Method OSR_METHOD;
+        public static final Method OSR_STATIC;
 
         static {
             try {
-                CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class);
+                CONSTRUCTOR = SimpleTestCaseHelper.class.getDeclaredConstructor(int.class);
             } catch (NoSuchMethodException | SecurityException e) {
                 throw new RuntimeException(
                         "exception on getting method Helper.<init>(int)", e);
             }
             try {
-                OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor(
+                OSR_CONSTRUCTOR = SimpleTestCaseHelper.class.getDeclaredConstructor(
                         Object.class, long.class);
             } catch (NoSuchMethodException | SecurityException e) {
                 throw new RuntimeException(
@@ -153,7 +153,7 @@
 
         private static Method getMethod(String name, Class<?>... parameterTypes) {
             try {
-                return Helper.class.getDeclaredMethod(name, parameterTypes);
+                return SimpleTestCaseHelper.class.getDeclaredMethod(name, parameterTypes);
             } catch (NoSuchMethodException | SecurityException e) {
                 throw new RuntimeException(
                         "exception on getting method Helper." + name, e);
@@ -195,7 +195,7 @@
          */
         private static int warmup(Method m) throws Exception {
             waitAndDeoptimize(m);
-            Helper helper = new Helper();
+            SimpleTestCaseHelper helper = new SimpleTestCaseHelper();
             int result = 0;
             for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) {
                 result += (int)m.invoke(helper, 1);
@@ -254,12 +254,12 @@
         private final int x;
 
         // for method and OSR method test case
-        public Helper() {
+        public SimpleTestCaseHelper() {
             x = 0;
         }
 
         // for OSR constructor test case
-        private Helper(Object o, long limit) throws Exception {
+        private SimpleTestCaseHelper(Object o, long limit) throws Exception {
             int result = 0;
             if (limit != 1) {
                 result = warmup(OSR_CONSTRUCTOR);
@@ -272,7 +272,7 @@
         }
 
         // for constructor test case
-        private Helper(int x) {
+        private SimpleTestCaseHelper(int x) {
             this.x = x;
         }
 
@@ -281,4 +281,4 @@
             return x;
         }
     }
-}
+
diff --git a/hotspot/test/gc/CondCardMark/Basic.java b/hotspot/test/gc/CondCardMark/Basic.java
index f936ce8..a6cc3a0 100644
--- a/hotspot/test/gc/CondCardMark/Basic.java
+++ b/hotspot/test/gc/CondCardMark/Basic.java
@@ -26,6 +26,7 @@
  * @bug 8076987
  * @bug 8078438
  * @summary Verify UseCondCardMark works
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build Basic
  * @run main/othervm -Xint Basic
diff --git a/hotspot/test/gc/TestDisableExplicitGC.java b/hotspot/test/gc/TestDisableExplicitGC.java
index 10199fd..316f50c 100644
--- a/hotspot/test/gc/TestDisableExplicitGC.java
+++ b/hotspot/test/gc/TestDisableExplicitGC.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
  * @requires vm.opt.DisableExplicitGC == null
  * @summary Verify GC behavior with DisableExplicitGC flag.
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ * @modules jdk.management/com.sun.management.internal
  * @run main/othervm                             -Xlog:gc=debug TestDisableExplicitGC
  * @run main/othervm/fail -XX:+DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC
  * @run main/othervm      -XX:-DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC
diff --git a/hotspot/test/gc/TestSmallHeap.java b/hotspot/test/gc/TestSmallHeap.java
index ffafa07..9c0dba3 100644
--- a/hotspot/test/gc/TestSmallHeap.java
+++ b/hotspot/test/gc/TestSmallHeap.java
@@ -30,6 +30,7 @@
  * @requires vm.opt.UseCompressedOops != false
  * @summary Verify that starting the VM with a small heap works
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @ignore 8076621
  * @build TestSmallHeap
diff --git a/hotspot/test/gc/TestVerifySilently.java b/hotspot/test/gc/TestVerifySilently.java
index 864a1ef..a387ae4 100644
--- a/hotspot/test/gc/TestVerifySilently.java
+++ b/hotspot/test/gc/TestVerifySilently.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
 import jdk.test.lib.ProcessTools;
 import java.util.ArrayList;
 import java.util.Collections;
+import jdk.test.lib.Utils;
 
 class RunSystemGC {
   public static void main(String args[]) throws Exception {
@@ -43,19 +44,11 @@
 
 
 public class TestVerifySilently {
-  private static String[] getTestJavaOpts() {
-    String testVmOptsStr = System.getProperty("test.java.opts");
-    if (!testVmOptsStr.isEmpty()) {
-      return testVmOptsStr.split(" ");
-    } else {
-      return new String[] {};
-    }
-  }
 
   private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
     ArrayList<String> vmOpts = new ArrayList();
 
-    Collections.addAll(vmOpts, getTestJavaOpts());
+    Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*"));
     Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                              "-XX:+VerifyDuringStartup",
                                              "-XX:+VerifyBeforeGC",
diff --git a/hotspot/test/gc/TestVerifySubSet.java b/hotspot/test/gc/TestVerifySubSet.java
index 7126b96..9208d47 100644
--- a/hotspot/test/gc/TestVerifySubSet.java
+++ b/hotspot/test/gc/TestVerifySubSet.java
@@ -34,6 +34,7 @@
 import jdk.test.lib.ProcessTools;
 import java.util.ArrayList;
 import java.util.Collections;
+import jdk.test.lib.Utils;
 
 class RunSystemGC {
     public static void main(String args[]) throws Exception {
@@ -42,19 +43,11 @@
 }
 
 public class TestVerifySubSet {
-    private static String[] getTestJavaOpts() {
-        String testVmOptsStr = System.getProperty("test.java.opts");
-        if (!testVmOptsStr.isEmpty()) {
-            return testVmOptsStr.split(" ");
-        } else {
-            return new String[] {};
-        }
-    }
 
     private static OutputAnalyzer runTest(String subset) throws Exception {
         ArrayList<String> vmOpts = new ArrayList();
 
-        Collections.addAll(vmOpts, getTestJavaOpts());
+        Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*"));
         Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                                  "-XX:+VerifyBeforeGC",
                                                  "-XX:+VerifyAfterGC",
diff --git a/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java b/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java
index 4d0a295..9193581 100644
--- a/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java
+++ b/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java
@@ -31,6 +31,7 @@
  * @bug 8028391
  * @summary Verify that MaxHeapFreeRatio flag is manageable
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @run main TestDynMaxHeapFreeRatio
  * @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMaxHeapFreeRatio
diff --git a/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java b/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java
index 53a21a1..f8dca9b 100644
--- a/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java
+++ b/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java
@@ -26,6 +26,7 @@
  * @bug 8028391
  * @summary Verify that MinHeapFreeRatio flag is manageable
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @run main TestDynMinHeapFreeRatio
  * @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMinHeapFreeRatio
diff --git a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java
index d25b19c..1864a47 100644
--- a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java
+++ b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java
@@ -27,6 +27,7 @@
  * @bug 8021879
  * @requires vm.gc=="null" | vm.gc=="G1"
  * @summary Verify that the flag G1HeapRegionSize is updated properly
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @library /testlibrary
  * @run main TestG1HeapRegionSize
diff --git a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
index 19d03b2..85d0fcd 100644
--- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
+++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
@@ -39,7 +39,7 @@
 import jdk.test.lib.ProcessTools;
 import jdk.test.lib.Utils;
 import jdk.test.lib.HeapRegionUsageTool;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class TestMaxMinHeapFreeRatioFlags {
 
@@ -88,6 +88,7 @@
                 (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio),
                 "-Xmx" + MAX_HEAP_SIZE,
                 "-Xms" + HEAP_SIZE,
+                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:NewSize=" + NEW_SIZE,
                 "-XX:MaxNewSize=" + MAX_NEW_SIZE,
                 "-XX:" + (shrinkHeapInSteps ? '+' : '-') + "ShrinkHeapInSteps",
@@ -119,6 +120,7 @@
         Collections.addAll(vmOptions,
                 (useXminf ? "-Xminf" + minRatio / 100.0 : "-XX:MinHeapFreeRatio=" + minRatio),
                 (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio),
+                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-version"
         );
         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
diff --git a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java
index 2e386c2..2891eb1 100644
--- a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java
+++ b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java
@@ -74,6 +74,7 @@
 
         Collections.addAll(vmOptions,
                 "-Xbootclasspath/a:.",
+                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:+UnlockDiagnosticVMOptions",
                 "-XX:+WhiteBoxAPI",
                 "-XX:GCLockerEdenExpansionPercent=0",
diff --git a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java
index b1198e7..aadb620e 100644
--- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java
+++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java
@@ -42,7 +42,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import jdk.test.lib.HeapRegionUsageTool;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import jdk.test.lib.OutputAnalyzer;
 import jdk.test.lib.ProcessTools;
 import jdk.test.lib.Utils;
@@ -130,6 +130,7 @@
         LinkedList<String> vmOptions = new LinkedList<>(options);
         Collections.addAll(vmOptions,
                 "-Xbootclasspath/a:.",
+                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:+UnlockDiagnosticVMOptions",
                 "-XX:+WhiteBoxAPI",
                 "-XX:+UseAdaptiveSizePolicy",
diff --git a/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java b/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java
index 3706d95..d092c11 100644
--- a/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java
+++ b/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java
@@ -28,6 +28,7 @@
  * @summary Runs an simple application (GarbageProducer) with various
          combinations of -XX:{+|-}Verify{After|Before}GC flags and checks that
          output contain or doesn't contain expected patterns
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @library /testlibrary
  * @run driver TestVerifyBeforeAndAfterGCFlags
diff --git a/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java b/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java
index 1cd9e11..7b262fd 100644
--- a/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java
+++ b/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java
@@ -27,6 +27,7 @@
  * @summary Ensure that UseDynamicNumberOfGCThreads runs
  * @requires vm.gc=="null"
  * @key gc
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java b/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java
index 4c88649..f572ed0 100644
--- a/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java
+++ b/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @requires vm.gc == "G1" | vm.gc == "null"
  * @summary Test handling of marked but unscanned reclaimed humongous objects.
  * @key gc
+ * @modules jdk.management
  * @run main/othervm -XX:+UseG1GC -Xss32m -Xmx128m -XX:G1HeapRegionSize=1m
  *      -XX:+UnlockExperimentalVMOptions
  *          -XX:+G1EagerReclaimHumongousObjects
diff --git a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java
index 2173dbd..a7a3444 100644
--- a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java
+++ b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java
@@ -26,6 +26,7 @@
  * @bug 8143587
  * @summary G1: humongous object allocations should work even when there is
  *              not enough space in the heapRegion to fit a filler object.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run driver TestHumongousAllocNearlyFullRegion
  */
diff --git a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java
index a689fbc..da1c08a 100644
--- a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java
+++ b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java
@@ -28,6 +28,7 @@
  * @summary Verify that heap shrinks after GC in the presence of fragmentation
  * due to humongous objects
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @run main/othervm -XX:-ExplicitGCInvokesConcurrent -XX:MinHeapFreeRatio=10
  * -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc
diff --git a/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java b/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java
index 28f1b16..463fadc 100644
--- a/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java
+++ b/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java
@@ -26,6 +26,7 @@
  * @summary Test that auxiliary data structures are allocated using large pages if available.
  * @bug 8058354 8079208
  * @key gc
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @requires (vm.gc=="G1" | vm.gc=="null")
  * @build jdk.test.lib.* sun.hotspot.WhiteBox
diff --git a/hotspot/test/gc/g1/TestPLABOutput.java b/hotspot/test/gc/g1/TestPLABOutput.java
index 4b85b1c..f7d7ceb 100644
--- a/hotspot/test/gc/g1/TestPLABOutput.java
+++ b/hotspot/test/gc/g1/TestPLABOutput.java
@@ -27,6 +27,7 @@
  * @summary Check that G1 does not report empty PLAB statistics in the first evacuation.
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @key gc
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/gc/g1/TestRegionLivenessPrint.java b/hotspot/test/gc/g1/TestRegionLivenessPrint.java
index 17af16c..9abbe4c 100644
--- a/hotspot/test/gc/g1/TestRegionLivenessPrint.java
+++ b/hotspot/test/gc/g1/TestRegionLivenessPrint.java
@@ -32,7 +32,7 @@
  * @build TestRegionLivenessPrint
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx128M -XX:G1HeapRegionSize=1m -Xlog:gc+liveness=trace TestRegionLivenessPrint
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx128M -XX:G1HeapRegionSize=1m -Xlog:gc+liveness=trace TestRegionLivenessPrint
  */
 
 import sun.hotspot.WhiteBox;
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java
index 65247c6..1600989 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java
@@ -36,7 +36,7 @@
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
-import sun.misc.Unsafe; // for ADDRESS_SIZE
+import jdk.internal.misc.Unsafe; // for ADDRESS_SIZE
 import sun.hotspot.WhiteBox;
 
 public class TestShrinkAuxiliaryData {
@@ -52,6 +52,7 @@
         "-Xlog:gc=debug",
         "-XX:+UnlockDiagnosticVMOptions",
         "-XX:+WhiteBoxAPI",
+        "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
         "-Xbootclasspath/a:.",
     };
 
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java
index e4149b4..ae12f5c 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java
@@ -25,6 +25,7 @@
  * @test TestShrinkAuxiliaryData00
  * @bug 8038423 8061715
  * @summary Checks that decommitment occurs for JVM with different
+ * @ignore 8155957
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java
index db611f6..0e00ffe 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java
@@ -26,6 +26,7 @@
  * @bug 8038423 8061715 8078405
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @ignore 8155957
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java
index 8e645ed..afad2ca 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java
@@ -26,6 +26,7 @@
  * @bug 8038423 8061715 8078405
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @ignore 8155957
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java
index 2b4401f..598caaa 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java
@@ -26,6 +26,7 @@
  * @bug 8038423 8061715 8078405
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @ignore 8155957
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java
index b0854ea..13ad25d 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java
@@ -26,6 +26,7 @@
  * @bug 8038423 8061715 8078405
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @ignore 8155957
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java
index 60f6e50..8e8f84f 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java
@@ -26,6 +26,7 @@
  * @bug 8038423 8061715 8078405
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @ignore 8155957
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java
index 6b73629..249a721 100644
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java
@@ -26,6 +26,7 @@
  * @bug 8038423 8061715 8078405
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @ignore 8155957
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
diff --git a/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java b/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java
new file mode 100644
index 0000000..6767e4b
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+package gc.g1.humongousObjects;
+
+import gc.testlibrary.Helpers;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Generates non-humongous and humongous class loaders.
+ * Since the generation depends on current host architecture it cannot be done as part of pre-compilation step
+ */
+public class ClassLoaderGenerator {
+    public static void main(String[] args) throws IOException {
+
+        if (args.length != 1) {
+            throw new Error("Test Bug: Expected region size wasn't provided as command line argument");
+        }
+
+        long regionSize = Long.parseLong(args[0]) * 1024 * 1024;
+
+        Path wrkDir = Paths.get("");
+        generateClassLoader(regionSize, wrkDir);
+
+    }
+
+    public static void generateClassLoader(long regionSize, Path wrkDir) throws IOException {
+        // Generating simple classloader
+        String finalSimpleClassLoaderPrototype = TestHumongousClassLoader.GENERIC_PROTOTYPE
+                .replace("${Methods}",
+                        TestHumongousClassLoader.LOAD_CLASS_METHOD_PROTOTYPE
+                                .replace("${ClassLoadFilter}",
+                                        "fileName.equals(\"" + TestHumongousClassLoader.HUMONGOUS_CLASSLOADER_NAME
+                                                + "\")"))
+                .replace("${ClassHeader}", TestHumongousClassLoader.CLASS_HEADER)
+                .replace("${ConstructorClause}", TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE);
+
+        Helpers.generateByTemplateAndCompile(TestHumongousClassLoader.SIMPLE_CLASSLOADER_NAME, "ClassLoader",
+                finalSimpleClassLoaderPrototype, TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE, regionSize / 4,
+                wrkDir, TestHumongousClassLoader.SIMPLE_CLASSLOADER_NAME + "Base");
+
+
+        // Preparations for generating humongous classloader
+
+        // Generating condition for loadClass method of generated class loader
+        // We want the generated class loader to load only classes from G1SampleClass enum
+        // All other classes should be loaded by parent classloader
+        // As result we get full loadClass method
+        StringBuilder classesToLoadBuilder = new StringBuilder();
+        for (G1SampleClass g1SampleClass : G1SampleClass.values()) {
+            if (classesToLoadBuilder.length() != 0) {
+                classesToLoadBuilder.append(" || ");
+            }
+            classesToLoadBuilder.append("fileName.startsWith(\"" + Helpers.enumNameToClassName(g1SampleClass.name())
+                    + "\")");
+        }
+
+        // Generating final class loader prototype - with specified methods,header and constructor
+        String finalHumongousClassLoaderPrototype = TestHumongousClassLoader.GENERIC_PROTOTYPE
+                .replace("${Methods}",
+                        TestHumongousClassLoader.LOAD_CLASS_METHOD_PROTOTYPE
+                                .replace("${ClassLoadFilter}", classesToLoadBuilder))
+                .replace("${ClassHeader}", TestHumongousClassLoader.CLASS_HEADER)
+                .replace("${ConstructorClause}", TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE);
+
+
+        // Generating humongous classloader with specified name, base class, final class prototype and
+        // constructor prototype for filler classes
+        // Generated class instance should be humongous since we specify size of (regionSize * 3 / 4)
+        Helpers.generateByTemplateAndCompile(TestHumongousClassLoader.HUMONGOUS_CLASSLOADER_NAME, "ClassLoader",
+                finalHumongousClassLoaderPrototype, TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE,
+                regionSize * 3 / 4,
+                wrkDir, TestHumongousClassLoader.HUMONGOUS_CLASSLOADER_NAME + "Base");
+
+
+    }
+}
diff --git a/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java b/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java
index d843d35..7fe5262 100644
--- a/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java
+++ b/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java
@@ -39,6 +39,7 @@
  * @summary Checks that heap counters work as expected after humongous allocations/deallocations
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
  *        gc.testlibrary.Helpers
diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java
new file mode 100644
index 0000000..0395236
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.g1.humongousObjects;
+
+import gc.testlibrary.Helpers;
+import jdk.test.lib.Asserts;
+import sun.hotspot.WhiteBox;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * @test gc.g1.humongousObjects.TestHumongousClassLoader
+ * @summary Checks that unreachable classes and unreachable humongous class loader are unloaded after GC
+ * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.G1HeapRegionSize == "null" | vm.opt.G1HeapRegionSize == "1M"
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != true
+ * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
+ * @modules java.management
+ * @build sun.hotspot.WhiteBox
+ *        gc.testlibrary.Helpers
+ *        gc.g1.humongousObjects.G1SampleClass
+ *        gc.g1.humongousObjects.ClassLoaderGenerator
+ *        gc.g1.humongousObjects.TestHumongousClassLoader
+ *
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ *
+ * @run main/othervm/timeout=240  -Xms256M -Xmx256M -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ *                                gc.g1.humongousObjects.ClassLoaderGenerator 1
+ *
+ * @run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ *                   -Xlog:class+load,class+unload=debug:file=TestHumongousClassLoader_Full_GC.log
+ *                   -XX:G1HeapRegionSize=1M
+ *                   gc.g1.humongousObjects.TestHumongousClassLoader FULL_GC
+ *
+ * @run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ *                   -Xlog:class+load,class+unload=debug:file=TestHumongousClassLoader_Full_GC_Mem_Pressure.log
+ *                   -XX:G1HeapRegionSize=1M
+ *                   gc.g1.humongousObjects.TestHumongousClassLoader FULL_GC_MEMORY_PRESSURE
+ *
+ *@run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ *                   -Xlog:class+load,class+unload=debug:file=TestHumongousClassLoader_CMC.log
+ *                   -XX:G1HeapRegionSize=1M -XX:MaxTenuringThreshold=1
+ *                   gc.g1.humongousObjects.TestHumongousClassLoader CMC
+ *
+ */
+
+public class TestHumongousClassLoader {
+
+    private static final WhiteBox WB = WhiteBox.getWhiteBox();
+    private static final String SAMPLE_CLASS_NAME_PREFIX = "SampleClassFiller";
+    public static final String SIMPLE_CLASSLOADER_NAME = "SimpleClassLoader";
+    public static final String HUMONGOUS_CLASSLOADER_NAME = "HumongousClassLoader";
+
+
+    public static final String LOAD_CLASS_METHOD_PROTOTYPE =
+            "    @Override\n"
+                    + "    public Class loadClass(String fileName) throws ClassNotFoundException {\n"
+                    + "        if (${ClassLoadFilter}) {\n"
+                    + "            System.out.println(\"Loading class \" + fileName);\n"
+                    + "            byte[] b = null;\n"
+                    + "            try {\n"
+                    + "                b = Files.readAllBytes(new File(fileName + \".class\").toPath());\n"
+                    + "            } catch (IOException e) {\n"
+                    + "                e.printStackTrace();\n"
+                    + "            }\n"
+                    + "            Class c = defineClass(fileName, b, 0, b.length);\n"
+                    + "            resolveClass(c);\n"
+                    + "            return c;\n"
+                    + "        } else {\n"
+                    + "            return super.loadClass(fileName);\n"
+                    + "        }\n"
+                    + "\n"
+                    + "\n"
+                    + "    }\n";
+
+    public static final String CLASS_HEADER = "import java.io.File;\n"
+            + "import java.io.IOException;\n"
+            + "import java.nio.file.Files;\n"
+            + "import java.nio.file.Paths;\n";
+
+    public static final String GENERIC_PROTOTYPE = "${ClassHeader}\n"
+            + "public class ${ClassName} extends ${BaseClass}{\n"
+            + "    ${ConstructorClause}\n"
+            + "    ${Methods}\n"
+            + "    ${Fields}\n"
+            + "}\n";
+
+    public static final String CONSTUCTOR_PROTOTYPE = "public ${ClassName}(ClassLoader parent) { super(parent);}\n";
+
+    private enum GC {
+        FULL_GC {
+            @Override
+            public void provoke() {
+                System.gc();
+            }
+        },
+        CMC {
+            @Override
+            public void provoke() {
+                // We need 2 young gc to promote class loader to old gen
+                // Otherwise it will not be unloaded after CMC
+                WHITE_BOX.youngGC();
+                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
+                WHITE_BOX.youngGC();
+                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
+                WHITE_BOX.g1StartConcMarkCycle();
+                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
+            }
+        },
+        FULL_GC_MEMORY_PRESSURE {
+            @Override
+            public void provoke() {
+                WHITE_BOX.fullGC();
+            }
+        };
+        private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
+        public abstract void provoke();
+    }
+
+    public static void main(String[] args) throws ClassNotFoundException, InstantiationException,
+            IllegalAccessException, IOException, NoSuchMethodException, InvocationTargetException {
+
+        if (args.length != 1) {
+            throw new Error("Test Bug: Expected GC type wasn't provided as command line argument");
+        }
+        GC gc = GC.valueOf(args[0]);
+
+        Path wrkDir = Paths.get("");
+        URL[] url = {wrkDir.toUri().toURL()};
+        URLClassLoader urlLoader = new URLClassLoader(url);
+
+        Class<?> simpleClassLoaderClass = urlLoader.loadClass(SIMPLE_CLASSLOADER_NAME);
+
+        ClassLoader simpleClassLoader = (ClassLoader) simpleClassLoaderClass
+                .getConstructor(java.lang.ClassLoader.class)
+                .newInstance(TestHumongousClassLoader.class.getClassLoader());
+
+        // Sanity check
+        Asserts.assertEquals(WB.g1IsHumongous(simpleClassLoader), false,
+                "Test Bug: simpleClassLoader is expected to be non-humongous but it's humongous");
+
+
+        Class<?> humongousClassLoaderClass = simpleClassLoader.loadClass(HUMONGOUS_CLASSLOADER_NAME);
+
+        ClassLoader humongousClassLoader = (ClassLoader) humongousClassLoaderClass
+                .getConstructor(java.lang.ClassLoader.class)
+                .newInstance(simpleClassLoader);
+
+        // Sanity check
+        Asserts.assertEquals(WB.g1IsHumongous(humongousClassLoader), true,
+                "Test Bug: humongousClassLoader is expected to be humongous but it's non-humongous");
+
+        //Asserts.assertEquals(1,0);
+
+        Object[] loadedClasses = new Object[]{
+                G1SampleClass.LARGEST_NON_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX)
+                        .newInstance(),
+                G1SampleClass.SMALLEST_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX)
+                        .newInstance(),
+                G1SampleClass.ONE_REGION_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX)
+                        .newInstance(),
+                G1SampleClass.TWO_REGION_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX)
+                        .newInstance(),
+        };
+
+        // forgetting references to loaded classes
+        for (int i = 0; i < loadedClasses.length; ++i) {
+            loadedClasses[i] = null;
+        }
+
+        // forgetting referencies to classloaders
+        humongousClassLoader = null;
+        humongousClassLoaderClass = null;
+
+        simpleClassLoader = null;
+        simpleClassLoaderClass = null;
+
+        gc.provoke();
+
+        // Test checks
+        Asserts.assertEquals(WB.isClassAlive(HUMONGOUS_CLASSLOADER_NAME), false,
+                String.format("Classloader class %s is loaded after we forget all references to it",
+                        HUMONGOUS_CLASSLOADER_NAME));
+
+        for (G1SampleClass sampleClass : G1SampleClass.values()) {
+            String className = Helpers.enumNameToClassName(sampleClass.name()) + "Class";
+            Asserts.assertEquals(WB.isClassAlive(className), false,
+                    String.format("Class %s is loaded after we forget all references to it", className));
+        }
+    }
+
+}
diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java
index 66ca21b..a7d1cc8 100644
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java
@@ -41,6 +41,7 @@
  * @summary Checks that Humongous objects are not moved during GC
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
  *        gc.testlibrary.Helpers
diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java
index 118c311..e1ad30c 100644
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java
@@ -40,6 +40,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.G1HeapRegionSize == "null" | vm.opt.G1HeapRegionSize == "1M"
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
  *        gc.testlibrary.Helpers
diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java
index 3b66bc7..8ff4a56 100644
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java
@@ -33,6 +33,7 @@
  * @summary Checks that objects larger than half a region are allocated as humongous
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
  *        gc.testlibrary.Helpers
diff --git a/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java b/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java
index be17365..f5f5484 100644
--- a/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java
+++ b/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java
@@ -39,6 +39,7 @@
  * actual object behavior
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
  *        gc.testlibrary.Helpers
diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java
new file mode 100644
index 0000000..17aa974
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.g1.humongousObjects.objectGraphTest;
+
+import gc.testlibrary.Helpers;
+import jdk.test.lib.Asserts;
+import sun.hotspot.WhiteBox;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Consumer;
+
+/**
+ * Provides methods to initiate GC of requested type and
+ * checks for states of humongous and non-humongous soft/weak externally
+ * referenced objects after GCs
+ */
+public enum GC {
+
+    YOUNG_GC {
+        @Override
+        public Runnable get() {
+            return WHITE_BOX::youngGC;
+        }
+
+        public Consumer<ReferenceInfo<Object[]>> getChecker() {
+            return getCheckerImpl(false, false, true, false);
+        }
+
+        @Override
+        public List<String> shouldContain() {
+            return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC);
+        }
+
+        @Override
+        public List<String> shouldNotContain() {
+            return Arrays.asList(GCTokens.WB_INITIATED_MIXED_GC, GCTokens.FULL_GC, GCTokens.WB_INITIATED_CMC,
+                    GCTokens.CMC, GCTokens.YOUNG_GC);
+        }
+    },
+    FULL_GC {
+        @Override
+        public Runnable get() {
+            return System::gc;
+        }
+
+        public Consumer<ReferenceInfo<Object[]>> getChecker() {
+            return getCheckerImpl(true, false, true, false);
+        }
+
+        @Override
+        public List<String> shouldContain() {
+            return Arrays.asList(GCTokens.FULL_GC);
+        }
+
+        @Override
+        public List<String> shouldNotContain() {
+            return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC,
+                    GCTokens.WB_INITIATED_CMC, GCTokens.CMC, GCTokens.YOUNG_GC);
+        }
+    },
+
+    FULL_GC_MEMORY_PRESSURE {
+        @Override
+        public Runnable get() {
+            return WHITE_BOX::fullGC;
+        }
+
+        public Consumer<ReferenceInfo<Object[]>> getChecker() {
+            return getCheckerImpl(true, true, true, true);
+        }
+
+        @Override
+        public List<String> shouldContain() {
+            return Arrays.asList(GCTokens.FULL_GC_MEMORY_PRESSURE);
+        }
+
+        @Override
+        public List<String> shouldNotContain() {
+            return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC,
+                    GCTokens.WB_INITIATED_CMC, GCTokens.CMC, GCTokens.YOUNG_GC, GCTokens.FULL_GC);
+        }
+    };
+
+    protected String getErrorMessage(ReferenceInfo<Object[]> ref, boolean expectedNull, String gcType) {
+        return String.format("Externally effectively %s referenced %shumongous object was%s deleted after %s",
+                (ref.softlyReachable ? "soft" : "weak"), (ref.effectiveHumongous ? "" : "non-"),
+                (expectedNull ? " not" : ""), gcType);
+    }
+
+    protected Consumer<ReferenceInfo<Object[]>> getCaseCheck(boolean expectedNull) {
+        return expectedNull
+                ? r -> Asserts.assertNull(r.reference.get(), getErrorMessage(r, true, name()))
+                : r -> Asserts.assertNotNull(r.reference.get(), getErrorMessage(r, false, name()));
+    }
+
+    protected Consumer<ReferenceInfo<Object[]>> getCheckerImpl(boolean weakH, boolean softH,
+                                                               boolean weakS, boolean softS) {
+        return new Checker(getCaseCheck(weakH), getCaseCheck(softH), getCaseCheck(weakS), getCaseCheck(softS));
+    }
+
+    protected String getGcLogName(String prefix) {
+        return prefix + "_" + name() + ".gc.log";
+    }
+
+    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
+    /**
+     * @return method to initiate GC
+     */
+    public abstract Runnable get();
+
+    /**
+     * @return checker for objects' states after GC
+     */
+    public abstract Consumer<ReferenceInfo<Object[]>> getChecker();
+
+    /**
+     * @return list of tokens that should be contained in gc log after gc of specified type
+     */
+    public abstract List<String> shouldContain();
+
+    /**
+     * @return list of tokens that should not be contained in gc log after gc of specified type
+     */
+    public abstract List<String> shouldNotContain();
+
+
+    /**
+     * Checks object' state after gc
+     * Contains 4 Consumers which are called depending on humongous/non-humongous and
+     * external weak/soft referenced objects
+     */
+    private static class Checker implements Consumer<ReferenceInfo<Object[]>> {
+        // 4 consumers with checks for (humongous /simple objects)*(weak/soft referenced)
+        final Consumer<ReferenceInfo<Object[]>> weakHumongousCheck;
+        final Consumer<ReferenceInfo<Object[]>> softHumongousCheck;
+        final Consumer<ReferenceInfo<Object[]>> weakSimpleCheck;
+        final Consumer<ReferenceInfo<Object[]>> softSimpleCheck;
+
+        public Checker(Consumer<ReferenceInfo<Object[]>> weakHumongousCheck,
+                       Consumer<ReferenceInfo<Object[]>> softHumongousCheck,
+                       Consumer<ReferenceInfo<Object[]>> weakSimpleCheck,
+                       Consumer<ReferenceInfo<Object[]>> softSimpleCheck) {
+            this.weakHumongousCheck = weakHumongousCheck;
+            this.softHumongousCheck = softHumongousCheck;
+            this.weakSimpleCheck = weakSimpleCheck;
+            this.softSimpleCheck = softSimpleCheck;
+        }
+
+        public void accept(ReferenceInfo<Object[]> ref) {
+
+            System.out.println("reference.get() returned " + ref.reference.get());
+            if (ref.effectiveHumongous && ref.softlyReachable) {
+                System.out.println("soft and humongous");
+                softHumongousCheck.accept(ref);
+            }
+
+            if (ref.effectiveHumongous && !ref.softlyReachable) {
+                System.out.println("weak and humongous");
+                weakHumongousCheck.accept(ref);
+
+            }
+
+            if (!ref.effectiveHumongous && ref.softlyReachable) {
+                System.out.println("soft and non-humongous");
+                softSimpleCheck.accept(ref);
+            }
+
+            if (!ref.effectiveHumongous && !ref.softlyReachable) {
+                System.out.println("weak and non-humongous");
+                weakSimpleCheck.accept(ref);
+            }
+        }
+    }
+
+}
diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java
new file mode 100644
index 0000000..e8a5200
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.g1.humongousObjects.objectGraphTest;
+
+/**
+ * Contains tokens that could appear in gc log
+ */
+public final class GCTokens {
+    // Private c-tor to prevent instantiating
+    private GCTokens() {
+    }
+
+    public static final String WB_INITIATED_YOUNG_GC = "Young (WhiteBox Initiated Young GC)";
+    public static final String WB_INITIATED_MIXED_GC = "Pause Mixed (WhiteBox Initiated Young GC)";
+    public static final String WB_INITIATED_CMC = "WhiteBox Initiated Concurrent Mark";
+    public static final String FULL_GC = "Full (System.gc())";
+    public static final String FULL_GC_MEMORY_PRESSURE = "WhiteBox Initiated Full GC";
+    public static final String CMC = "Concurrent Mark)";
+    public static final String YOUNG_GC = "GC pause (young)";
+}
diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java
new file mode 100644
index 0000000..48ca3d3
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.g1.humongousObjects.objectGraphTest;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+
+public class ObjectGraph {
+
+    private ObjectGraph() {
+    }
+
+    public enum ReferenceType {
+        NONE,
+        WEAK,
+        SOFT,
+        STRONG;
+    }
+
+    /**
+     * Performs operation on all nodes that are reachable from initial ones
+     *
+     * @param nodes     initial nodes
+     * @param operation operation
+     */
+    public static void propagateTransitiveProperty(Set<Object[]> nodes, Consumer<Object[]> operation) {
+        Deque<Object[]> roots = new ArrayDeque<>();
+        nodes.stream().forEach(roots::push);
+        ObjectGraph.enumerateAndMark(roots, operation);
+    }
+
+    /**
+     * Connects graph's vertexes with single-directed (vertex -> neighbour) link
+     *
+     * @param vertex    who is connected
+     * @param neighbour connected to whom
+     */
+    private static void connectVertexes(Object[] vertex, Object[] neighbour) {
+
+        // check if vertex array is full
+        if (vertex[vertex.length - 1] != null) {
+            throw new Error("Array is full and no connections could be added");
+        }
+        int i = 0;
+        while (vertex[i] != null) {
+            ++i;
+        }
+        vertex[i] = neighbour;
+    }
+
+
+    /**
+     * Builds object graph using description from list of parsed nodes. Graph uses Object[] as nodes, first n elements
+     * of array are links to connected nodes, others are null. Then runs visitors on generated graph
+     *
+     * @param parsedNodes             list of nodes' description
+     * @param visitors                visitors that will visit each node of generated graph
+     * @param humongousAllocationSize size of humongous node
+     * @param simpleAllocationSize    size of simple (non-humongous) node
+     * @return root reference to generated graph
+     */
+    public static Object[] generateObjectNodes(List<TestcaseData.FinalParsedNode> parsedNodes,
+                                               Map<Predicate<TestcaseData.FinalParsedNode>,
+                                                       BiConsumer<TestcaseData.FinalParsedNode, Object[][]>> visitors,
+                                               int humongousAllocationSize, int simpleAllocationSize) {
+
+        Object[][] objectNodes = new Object[parsedNodes.size()][];
+
+        // Allocating nodes on Object[]
+        for (int i = 0; i < parsedNodes.size(); ++i) {
+            objectNodes[i] = new Object[(parsedNodes.get(i).isHumongous ?
+                    humongousAllocationSize : simpleAllocationSize)];
+        }
+
+        // Connecting nodes on allocated on Object[]
+        for (int i = 0; i < parsedNodes.size(); ++i) {
+            for (int j = 0; j < parsedNodes.get(i).getConnectedTo().size(); ++j) {
+                connectVertexes(objectNodes[i], objectNodes[parsedNodes.get(i).getConnectedTo().get(j)]);
+            }
+        }
+
+        // Calling visitors
+        visitors.entrySet()
+                .stream()
+                .forEach(
+                        entry -> parsedNodes.stream()
+                                .filter(parsedNode -> entry.getKey().test(parsedNode))
+                                .forEach(node -> entry.getValue().accept(node, objectNodes))
+                );
+
+        return objectNodes[0];
+    }
+
+    /**
+     * Enumerates graph starting with provided vertexes. All vertexes that are reachable from the provided ones are
+     * marked
+     *
+     * @param markedParents provided vertexes
+     * @param markVertex    lambda which marks vertexes
+     */
+    public static void enumerateAndMark(Deque<Object[]> markedParents,
+                                        Consumer<Object[]> markVertex) {
+        Map<Object[], Boolean> isVisited = new HashMap<>();
+        while (!markedParents.isEmpty()) {
+            Object[] vertex = markedParents.pop();
+            if (vertex == null || isVisited.containsKey(vertex)) {
+                continue;
+            }
+            isVisited.put(vertex, true);
+            markVertex.accept(vertex);
+
+            for (int i = 0; i < vertex.length; ++i) {
+                if (vertex[i] == null) {
+                    break;
+                }
+                markedParents.add((Object[]) vertex[i]);
+            }
+        }
+    }
+
+}
diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README
new file mode 100644
index 0000000..1c3522e
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+The test checks that after different type of GC unreachable objects behave as expected:
+
+1. Young GC - weakly referenced non-humongous objects are collected, other objects are not collected.
+
+2. Full GC - weakly referenced non-humongous and humongous objects are collected, softly referenced non-humongous and
+             humongous objects are not collected.
+
+3. Full GC with memory pressure - weakly and softly referenced non-humongous and humongous objects are collected.
+
+The test gets gc type as a command line argument.
+Then the test allocates object graph in heap (currently testing scenarios are pre-generated and stored in
+TestcaseData.getPregeneratedTestcases()) with TestObjectGraphAfterGC::allocateObjectGraph.
+
+Since we are testing humongous objects we need pretty unusual nodes - arrays of Object.
+We need this since only large enough array could be Humongous object (in fact class with huge amount of fields is
+humongous too but it's for other tests).
+ObjectGraph class generates object graph with Object[] nodes. It also provides a way to collect
+information about each node using "visitor" pattern.
+
+Using visitors we build Set of ReferenceInfo instances which contains the following information:
+reference - external weak/soft reference to graph's node
+graphId and nodeId - graph's and node's ids - we need this for error handling
+softlyReachable - is node effectively referenced by external soft reference. It could be when external
+soft reference or when this node is reachable from node that exteranally referenced by soft reference
+effectiveHumongous - if node behaves effectively humongous.  It could be when node is humongous
+or when this node is reachable from humongous node.
+
+When we leave TestObjectGraphAfterGC::allocateObjectGraph we make graph reachable only with references from Set of
+ReferenceInfo instances.
+
+We run specified gc and check that each instance of ReferenceInfo set behaves as expected.
+Then we check that gc log file contains expected tokens and doesn't contain tokens that it should not contain.
diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java
new file mode 100644
index 0000000..98e249a
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.g1.humongousObjects.objectGraphTest;
+
+import java.lang.ref.Reference;
+
+/**
+ * Immutable structure that holds the following information about graph's node
+ * reference - weak/soft reference to graph's node
+ * graphId and nodeId - graph's and node's ids - we need this for error handling
+ * softlyReachable - is node effectively referenced by external soft reference. It could be when external
+ * soft reference or when this node is reachable from node that externally referenced by soft reference
+ * effectiveHumongous - if node behaves effectively humongous.  It could be when node is humongous
+ * or when this node is reachable from humongous node.
+ *
+ * @param <T> - actual type of node
+ */
+public class ReferenceInfo<T> {
+    public final Reference<T> reference;
+    public final String graphId;
+    public final String nodeId;
+    public final boolean softlyReachable;
+    public final boolean effectiveHumongous;
+
+    public ReferenceInfo(Reference<T> reference, String graphId, String nodeId, boolean softlyReachable,
+                         boolean effectiveHumongous) {
+        this.reference = reference;
+        this.graphId = graphId;
+        this.nodeId = nodeId;
+        this.softlyReachable = softlyReachable;
+        this.effectiveHumongous = effectiveHumongous;
+    }
+
+    @Override
+    public String toString() {
+        return String.format("Node %s is effectively %shumongous and effectively %ssoft referenced\n"
+                        + "\tReference type is %s and it points to %s", nodeId,
+                (effectiveHumongous ? "" : "non-"), (softlyReachable ? "" : "non-"),
+                reference.getClass().getSimpleName(), reference.get());
+    }
+}
diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java
new file mode 100644
index 0000000..53c58b4
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.g1.humongousObjects.objectGraphTest;
+
+import jdk.test.lib.OutputAnalyzer;
+import sun.hotspot.WhiteBox;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.nio.file.Files;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+
+/**
+ * @test TestObjectGraphAfterGC
+ * @summary Checks that objects' graph behave as expected after gc
+ * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != true
+ * @library /testlibrary /test/lib /
+ * @modules java.management java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ *        gc.testlibrary.Helpers
+ *        gc.g1.humongousObjects.objectGraphTest.GCTokens
+ *        gc.g1.humongousObjects.objectGraphTest.ReferenceInfo
+ *        gc.g1.humongousObjects.objectGraphTest.GC
+ *        gc.g1.humongousObjects.objectGraphTest.ObjectGraph
+ *        gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC
+ *
+ * @ignore 8156755
+ *
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ *
+ * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ * -XX:G1HeapRegionSize=1M -Xlog:gc*=debug:file=TestObjectGraphAfterGC_YOUNG_GC.gc.log
+ * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC YOUNG_GC
+ *
+ * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_FULL_GC.gc.log
+ * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC FULL_GC
+ *
+ * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_FULL_GC_MEMORY_PRESSURE.gc.log
+ * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC FULL_GC_MEMORY_PRESSURE
+ *
+ */
+
+/**
+ * Checks that objects' graph behave as expected after gc
+ * See README file for detailed info on test's logic
+ */
+public class TestObjectGraphAfterGC {
+
+    private static final int simpleAllocationSize = 1024;
+
+    /**
+     * Entry point
+     *
+     * @param args - first argument - gc name
+     */
+    public static void main(String[] args) {
+
+        if (args.length < 1) {
+            throw new Error("Expected gc name wasn't provided as command line argument");
+        }
+
+        GC gcType = GC.valueOf(args[0].toUpperCase());
+
+        System.out.println("Testing " + gcType.name());
+
+        TestcaseData.getPregeneratedTestcases().stream().forEach(testcase -> {
+            System.out.println("Testcase: " + testcase);
+
+            try {
+                TestObjectGraphAfterGC.doTesting(testcase, gcType.get(), gcType.getChecker(),
+                        gcType.getGcLogName(TestObjectGraphAfterGC.class.getSimpleName()), gcType.shouldContain(),
+                        gcType.shouldNotContain());
+            } catch (IOException e) {
+                throw new Error("Problems trying to find or open " + TestObjectGraphAfterGC.class.getSimpleName()
+                        + ".gc.log", e);
+            }
+            System.out.println(" Passed");
+        });
+    }
+
+    /**
+     * Implements testing with 3 methods - allocateObjectGraph, checkResults and checkGCLog
+     *
+     * @param testcaseData     testcase in the following notation:
+     *                         H - humongous node
+     *                         S - non-humongous node
+     *                         s - external soft reference
+     *                         w - external weak reference
+     *                         Hs->Sw - 1st node is humongous, externally soft referenced and strong references to
+     *                         non-humongous node 2 which is externally weak referenced
+     *                         H->1 - humongous node connects to the first node of chain
+     * @param doGC             method that initiates gc
+     * @param checker          consumer that checks node's state after gc and throws Error if it's wrong
+     * @param gcLogName        name of gc log
+     * @param shouldContain    list of tokens that should be contained in gc log
+     * @param shouldNotContain list of tokens that should not be contained in gc log
+     * @throws IOException if there are some issues with gc log
+     */
+    private static void doTesting(String testcaseData, Runnable doGC, Consumer<ReferenceInfo<Object[]>> checker,
+                                  String gcLogName, List<String> shouldContain, List<String> shouldNotContain)
+            throws IOException {
+        Set<ReferenceInfo<Object[]>> nodeData = allocateObjectGraph(testcaseData);
+        doGC.run();
+        checkResults(nodeData, checker);
+        checkGCLog(gcLogName, shouldContain, shouldNotContain);
+    }
+
+    /**
+     * Allocates a number of objects of humongous and regular size and links then with strong references.
+     * How many objects to create, their size and links between them is encoded in the given parameters.
+     * As the result an object graph will be created.
+     * For the testing purpose for each created object (a graph node) an extra ReferenceInfo object will be created.
+     * The ReferenceInfo instances will contain either weak or soft reference to the graph node.
+     *
+     * @param testcaseData testcase in the
+     *                     <p>
+     *                     H - humongous node
+     *                     S - non-humongous node
+     *                     s - external soft reference
+     *                     w - external weak reference
+     *                     Hs->Sw - 1st node is humongous, externally soft referenced and strong references to
+     *                     non-humongous node 2 which is externally weak referenced
+     *                     H->1 - humongous node connects to the first node of chain
+     * @return set of ReferenceInfo objects containing weak/soft reference to the graph node and other data on how
+     * objects should behave after gc
+     */
+    private static Set<ReferenceInfo<Object[]>> allocateObjectGraph(String testcaseData) {
+        Map<Object[], String> nodeIds = new HashMap<>();
+        Set<Object[]> humongousNodes = new HashSet<>();
+        Set<Object[]> externalSoftReferenced = new HashSet<>();
+        Set<Object[]> externalWeakReferenced = new HashSet<>();
+
+        Map<Predicate<TestcaseData.FinalParsedNode>, BiConsumer<TestcaseData.FinalParsedNode, Object[][]>> visitors
+                = new HashMap<>();
+
+        visitors.put((parsedNode -> true),
+                (parsedNode, objects) -> nodeIds.put(objects[Integer.valueOf(parsedNode.id)], parsedNode.id)
+        );
+
+        visitors.put((parsedNode -> parsedNode.isHumongous),
+                (parsedNode, objects) -> humongousNodes.add(objects[Integer.valueOf(parsedNode.id)])
+        );
+
+        visitors.put(parsedNode -> parsedNode.getReferencesTypes().stream().
+                        anyMatch(referenceType -> referenceType == ObjectGraph.ReferenceType.SOFT),
+                (parsedNode, objects) -> externalSoftReferenced.add(objects[Integer.valueOf(parsedNode.id)])
+        );
+
+        visitors.put(parsedNode -> parsedNode.getReferencesTypes().stream().
+                        anyMatch(referenceType -> referenceType == ObjectGraph.ReferenceType.WEAK),
+                (parsedNode, objects) -> externalWeakReferenced.add(objects[Integer.valueOf(parsedNode.id)])
+        );
+
+        List<TestcaseData.FinalParsedNode> internalParsedNodes = TestcaseData.parse(testcaseData);
+
+        Object[] root = ObjectGraph.generateObjectNodes(internalParsedNodes, visitors,
+                WhiteBox.getWhiteBox().g1RegionSize(), simpleAllocationSize);
+
+        ObjectGraph.propagateTransitiveProperty(humongousNodes, humongousNodes::add);
+        Set<Object[]> effectiveSoftReferenced = new HashSet<>();
+        ObjectGraph.propagateTransitiveProperty(externalSoftReferenced, effectiveSoftReferenced::add);
+
+        // Create external references
+        ReferenceQueue<Object[]> referenceQueue = new ReferenceQueue<>();
+        Set<Reference<Object[]>> externalRefs = new HashSet<>();
+
+        externalWeakReferenced.stream()
+                .forEach(objects -> externalRefs.add(new WeakReference<>(objects, referenceQueue)));
+        externalSoftReferenced.stream()
+                .forEach(objects -> externalRefs.add(new SoftReference<>(objects, referenceQueue)));
+
+        return externalRefs.stream()
+                .map(ref -> new ReferenceInfo<>(ref, testcaseData, nodeIds.get(ref.get()),
+                        effectiveSoftReferenced.contains(ref.get()), humongousNodes.contains(ref.get())))
+                .collect(Collectors.toSet());
+
+    }
+
+    /**
+     * Checks that object' state after gc is as expected
+     *
+     * @param nodeData array with information about nodes
+     * @param checker  consumer that checks node's state after gc and throws Error if it's wrong
+     */
+    private static void checkResults(Set<ReferenceInfo<Object[]>> nodeData, Consumer<ReferenceInfo<Object[]>> checker) {
+        nodeData.stream().forEach(checker::accept);
+    }
+
+    /**
+     * Checks that gc log contains what we expected and does not contain what we didn't expect
+     *
+     * @param gcLogName        gc log name
+     * @param shouldContain    list of tokens that should be contained in gc log
+     * @param shouldNotContain list of tokens that should not be contained in gc log
+     * @throws IOException if there are some issues with gc log
+     */
+    private static void checkGCLog(String gcLogName, List<String> shouldContain, List<String> shouldNotContain)
+            throws IOException {
+
+        if (gcLogName == null) {
+            return;
+        }
+        String gcLog = new String(Files.readAllBytes(new File(gcLogName).toPath()));
+
+        OutputAnalyzer outputAnalyzer = new OutputAnalyzer(gcLog, "");
+
+        shouldContain.stream().forEach(outputAnalyzer::shouldContain);
+        shouldNotContain.stream().forEach(outputAnalyzer::shouldNotContain);
+    }
+
+}
diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java
new file mode 100644
index 0000000..0229346
--- /dev/null
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.g1.humongousObjects.objectGraphTest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public final class TestcaseData {
+    /**
+     * Temporary node description used during parsing
+     */
+    private static class InternalParsedNode {
+        public String id;
+        public final ArrayList<Integer> connectedTo = new ArrayList<>();
+        public final ArrayList<Integer> connectedFrom = new ArrayList<>();
+        public final List<ObjectGraph.ReferenceType> referencesTypes = new ArrayList<>();
+        public boolean isHumongous;
+    }
+
+    /**
+     * Immutable node description.
+     * Contains:
+     * Node id
+     * Humongous flag
+     * List of external references' types
+     * List of nodes connected to
+     */
+    public static class FinalParsedNode {
+        public final String id;
+        public final boolean isHumongous;
+        private final List<ObjectGraph.ReferenceType> referencesTypes;
+        private final ArrayList<Integer> connectedTo;
+
+
+        public FinalParsedNode(InternalParsedNode internalParsedNode) {
+            referencesTypes = internalParsedNode.referencesTypes;
+            connectedTo = internalParsedNode.connectedTo;
+            id = internalParsedNode.id;
+            isHumongous = internalParsedNode.isHumongous;
+        }
+
+        public List<ObjectGraph.ReferenceType> getReferencesTypes() {
+            return Collections.unmodifiableList(referencesTypes);
+        }
+
+        public List<Integer> getConnectedTo() {
+            return Collections.unmodifiableList(connectedTo);
+        }
+    }
+
+    /**
+     * @param testcaseDesc testcase in the following notation:
+     *                     H - humongous node
+     *                     S - non-humongous node
+     *                     s - external soft reference
+     *                     w - external weak reference
+     *                     Hs->Sw - 1st node is humongous, externally soft referenced and strong references to non-humongous node 2 which is
+     *                     externally weak referenced
+     *                     H->1 - humongous node connects to the first node of chain
+     * @return list of nodes description in FinalParsedNode structure
+     */
+    public static List<FinalParsedNode> parse(String testcaseDesc) {
+        String[] nodes = testcaseDesc.split("-");
+        List<InternalParsedNode> internalParsedNodeList = new ArrayList<>();
+
+        for (int i = 0; i < nodes.length; ++i) {
+            String node = nodes[i];
+            InternalParsedNode nd;
+            if (node.contains("1")) {
+                nd = internalParsedNodeList.get(0);
+
+            } else {
+                nd = new InternalParsedNode();
+                internalParsedNodeList.add(nd);
+                nd.id = String.valueOf(i);
+            }
+
+            if (node.startsWith(">")) {
+                nd.connectedFrom.add(i - 1);
+            }
+            if (node.endsWith("<")) {
+                nd.connectedFrom.add(i + 1);
+            }
+            if (node.contains("w")) {
+                nd.referencesTypes.add(ObjectGraph.ReferenceType.WEAK);
+            }
+
+            if (node.contains("s")) {
+                nd.referencesTypes.add(ObjectGraph.ReferenceType.SOFT);
+            }
+            if (node.contains("H")) {
+                nd.isHumongous = true;
+            }
+
+            if (node.contains("S")) {
+                nd.isHumongous = false;
+            }
+        }
+
+        // we have connectedFrom but we need to get connectedTo
+        for (int i = 0; i < internalParsedNodeList.size(); ++i) {
+            for (Integer reference : internalParsedNodeList.get(i).connectedFrom) {
+                internalParsedNodeList.get(reference).connectedTo.add(i);
+            }
+        }
+
+        List<FinalParsedNode> finalParsedNodes = internalParsedNodeList.stream().map(FinalParsedNode::new)
+                .collect(Collectors.toList());
+
+        return finalParsedNodes;
+    }
+
+    /**
+     * @return List of pregenerated testing cases
+     */
+    public static List<String> getPregeneratedTestcases() {
+        return Arrays.asList(
+                "Hw",
+                "Sw",
+                "Sw->Hw",
+                "Hw->Sw",
+                "Sw<->Hw",
+                "Sw<->Sw",
+                "Hw->Sw->Sw",
+                "Hw->Sw->Sw",
+                "Sw->Hw->Sw",
+                "Hw->Sw->Sw->1",
+                "Sw->Hw->Sw->1",
+                "Sw->Hw->Hw->1",
+                "Sw<->Hw<->Hw->1",
+                "Sw<->Hw<->Sw->1",
+                "Sw->Hw<->Sw",
+                "Hs",
+                "Ss",
+                "Ss->Hs",
+                "Hs->Ss",
+                "Ss<->Hs",
+                "Ss<->Ss",
+                "Hs->Ss->Ss",
+                "Hs->Ss->Ss",
+                "Ss->Hs->Ss",
+                "Hs->Ss->Ss->1",
+                "Ss->Hs->Ss->1",
+                "Ss->Hs->Hs->1",
+                "Ss<->Hs<->Hs->1",
+                "Ss<->Hs<->Ss->1",
+                "Ss->Hs<->Ss",
+                "Ss->Hw",
+                "Sw->Hs",
+                "Hs->Sw",
+                "Hw->Ss",
+                "Ss<->Hw",
+                "Sw<->Hs",
+                "Ss<->Sw",
+                "Sw<->Ss",
+                "Hs->Sw->Sw",
+                "Hw->Ss->Sw",
+                "Hw->Sw->Ss",
+                "Ss->Hw->Sw",
+                "Sw->Hs->Sw",
+                "Sw->Hw->Ss",
+                "Hs->Sw->Sw->1",
+                "Hw->Ss->Sw->1",
+                "Hw->Sw->Ss->1",
+                "Ss->Hw->Sw->1",
+                "Ss->Hs->Sw->1",
+                "Sw->Hw->Ss->1",
+                "Ss->Hw->Hw->1",
+                "Sw->Hs->Hw->1",
+                "Sw->Hw->Hs->1",
+                "Ss<->Hw<->Hw->1",
+                "Sw<->Hs<->Hw->1",
+                "Sw<->Hw<->Hs->1",
+                "Ss<->Hw<->Sw->1",
+                "Sw<->Hs<->Sw->1",
+                "Sw<->Hw<->Ss->1",
+                "Ss->Hw<->Sw",
+                "Sw->Hs<->Sw",
+                "Sw->Hw<->Ss"
+        );
+    }
+}
diff --git a/hotspot/test/gc/g1/ihop/TestIHOPErgo.java b/hotspot/test/gc/g1/ihop/TestIHOPErgo.java
index 1029929..95609b8 100644
--- a/hotspot/test/gc/g1/ihop/TestIHOPErgo.java
+++ b/hotspot/test/gc/g1/ihop/TestIHOPErgo.java
@@ -29,6 +29,7 @@
  * @requires vm.opt.FlightRecorder != true
  * @requires vm.opt.ExplicitGCInvokesConcurrent != true
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build gc.g1.ihop.TestIHOPErgo
  *        gc.g1.ihop.lib.IhopUtils
diff --git a/hotspot/test/gc/g1/ihop/TestIHOPStatic.java b/hotspot/test/gc/g1/ihop/TestIHOPStatic.java
index 4e91a95..efbe6d6 100644
--- a/hotspot/test/gc/g1/ihop/TestIHOPStatic.java
+++ b/hotspot/test/gc/g1/ihop/TestIHOPStatic.java
@@ -29,6 +29,7 @@
  * @requires vm.opt.FlightRecorder != true
  * @requires vm.opt.ExplicitGCInvokesConcurrent != true
  * @library /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build gc.g1.ihop.TestIHOPStatic
  *        gc.g1.ihop.lib.IhopUtils
diff --git a/hotspot/test/gc/g1/mixedgc/TestLogging.java b/hotspot/test/gc/g1/mixedgc/TestLogging.java
index 913097d..f99fdbd 100644
--- a/hotspot/test/gc/g1/mixedgc/TestLogging.java
+++ b/hotspot/test/gc/g1/mixedgc/TestLogging.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @summary Check that a mixed GC is reflected in the gc logs
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /test/lib
- * @ignore 8138607
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox gc.g1.mixedgc.TestLogging
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
@@ -57,8 +57,8 @@
             "-XX:SurvivorRatio=1", // Survivor-to-eden ratio is 1:1
             "-Xms10M", "-Xmx10M",
             "-XX:MaxTenuringThreshold=1", // promote objects after first gc
-            "-XX:InitiatingHeapOccupancyPercent=0", // marking cycle happens
-            // each time
+            "-XX:InitiatingHeapOccupancyPercent=100", // set initial CMC threshold and disable adaptive IHOP
+            "-XX:-G1UseAdaptiveIHOP",                 // to avoid additional concurrent cycles caused by ergonomics
             "-XX:G1MixedGCCountTarget=4",
             "-XX:MaxGCPauseMillis=30000", // to have enough time
             "-XX:G1HeapRegionSize=1m", "-XX:G1HeapWastePercent=0",
@@ -120,8 +120,8 @@
         // Allocates buffer and promotes it to the old gen. Mix live and dead old
         // objects
         for (int i = 0; i < TestLogging.ALLOCATION_COUNT; ++i) {
-            liveOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 10]);
-            deadOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 10]);
+            liveOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 5]);
+            deadOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 5]);
         }
 
         // need only 2 promotions to promote objects to the old gen
diff --git a/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java b/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java
index 5bcad7f..6aa5834 100644
--- a/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java
+++ b/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java
@@ -27,6 +27,7 @@
  * @summary Checks PLAB statistics on evacuation failure
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build gc.g1.plab.lib.LogParser
  *        gc.g1.plab.lib.AppPLABEvacuationFailure
diff --git a/hotspot/test/gc/g1/plab/TestPLABPromotion.java b/hotspot/test/gc/g1/plab/TestPLABPromotion.java
index 7af0969..3664897 100644
--- a/hotspot/test/gc/g1/plab/TestPLABPromotion.java
+++ b/hotspot/test/gc/g1/plab/TestPLABPromotion.java
@@ -28,6 +28,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.FlightRecorder != true
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build ClassFileInstaller
  *        sun.hotspot.WhiteBox
diff --git a/hotspot/test/gc/g1/plab/TestPLABResize.java b/hotspot/test/gc/g1/plab/TestPLABResize.java
index 71e00bb..f3ac2aa 100644
--- a/hotspot/test/gc/g1/plab/TestPLABResize.java
+++ b/hotspot/test/gc/g1/plab/TestPLABResize.java
@@ -28,6 +28,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.FlightRecorder != true
  * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build ClassFileInstaller
  *        sun.hotspot.WhiteBox
diff --git a/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java b/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java
new file mode 100644
index 0000000..647cd63
--- /dev/null
+++ b/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package gc.logging;
+
+import jdk.test.lib.Utils;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import java.lang.management.ManagementFactory;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+
+/**
+ * @test TestUnifiedLoggingSwitchStress
+ * @summary Switches gc log level on fly while stressing memory/gc
+ * @key gc
+ * @key stress
+ * @library /testlibrary /test/lib /
+ * @modules java.management java.base/jdk.internal.misc
+ *
+ * @run main/othervm -Xmx256M -Xms256M
+ *                   gc.logging.TestUnifiedLoggingSwitchStress 60
+ */
+
+class MemoryStresser implements Runnable {
+    public static volatile boolean shouldStop = false;
+
+    private final List<byte[]> liveObjects = new LinkedList<>();
+    private final List<byte[]> liveHObjects = new LinkedList<>();
+    private int maxSimpleAllocationMemory = 0;
+    private int usedMemory = 0;
+
+    /**
+     * Maximum amount of huge allocations
+     */
+    private static int H_ALLOCATION_MAX_COUNT = 4;
+    /**
+     * Maximum regions in one huge allocation
+     */
+    private static int H_ALLOCATION_REGION_SIZE = 2;
+    private static final int G1_REGION_SIZE = 1024 * 1024;
+    /**
+     * Maximum size of simple allocation
+     */
+    private static final int MAX_SIMPLE_ALLOCATION_SIZE = (int) (G1_REGION_SIZE / 2 * 0.9);
+
+    /**
+     * Maximum size of dead (i.e. one which is made unreachable right after allocation) object
+     */
+    private static final int DEAD_OBJECT_MAX_SIZE = G1_REGION_SIZE / 10;
+    private static final Random RND = Utils.getRandomInstance();
+
+    /**
+     * @param maxMemory maximum memory that could be allocated
+     */
+    public MemoryStresser(int maxMemory) {
+        maxSimpleAllocationMemory = maxMemory - G1_REGION_SIZE * H_ALLOCATION_MAX_COUNT * H_ALLOCATION_REGION_SIZE;
+    }
+
+    public final Runnable[] actions = new Runnable[]{
+            // Huge allocation
+            () -> {
+                if (liveHObjects.size() < H_ALLOCATION_MAX_COUNT) {
+                    int allocationSize = RND.nextInt((int) (G1_REGION_SIZE * (H_ALLOCATION_REGION_SIZE - 0.5)
+                            * 0.9));
+                    liveHObjects.add(new byte[allocationSize + G1_REGION_SIZE / 2]);
+                }
+            },
+
+            // Huge deallocation
+            () -> {
+                if (liveHObjects.size() > 0) {
+                    int elementNum = RND.nextInt(liveHObjects.size());
+                    liveHObjects.remove(elementNum);
+                }
+            },
+
+            // Simple allocation
+            () -> {
+                if (maxSimpleAllocationMemory - usedMemory != 0) {
+                    int arraySize = RND.nextInt(Math.min(maxSimpleAllocationMemory - usedMemory,
+                            MAX_SIMPLE_ALLOCATION_SIZE));
+                    if (arraySize != 0) {
+                        liveObjects.add(new byte[arraySize]);
+                        usedMemory += arraySize;
+                    }
+                }
+            },
+
+            // Simple deallocation
+            () -> {
+                if (liveObjects.size() != 0) {
+                    int elementNum = RND.nextInt(liveObjects.size());
+                    int shouldFree = liveObjects.get(elementNum).length;
+                    liveObjects.remove(elementNum);
+                    usedMemory -= shouldFree;
+                }
+            },
+
+            // Dead object allocation
+            () -> {
+                int size = RND.nextInt(DEAD_OBJECT_MAX_SIZE);
+                byte[] deadObject = new byte[size];
+            }
+    };
+
+    @Override
+    public void run() {
+        while (!shouldStop) {
+            actions[RND.nextInt(actions.length)].run();
+            Thread.yield();
+        }
+
+        System.out.println("Memory Stresser finished");
+    }
+}
+
+class LogLevelSwitcher implements Runnable {
+
+    public static volatile boolean shouldStop = false;
+    private final int logCount; // how many various log files will be used
+    private final String logFilePrefix; // name of log file will be logFilePrefix + index
+    private final Random RND = Utils.getRandomInstance();
+    private final MBeanServer MBS = ManagementFactory.getPlatformMBeanServer();
+
+    /**
+     * @param logFilePrefix prefix for log files
+     * @param logCount     amount of log files
+     */
+    public LogLevelSwitcher(String logFilePrefix, int logCount) {
+        this.logCount = logCount;
+        this.logFilePrefix = logFilePrefix;
+
+    }
+
+    private static final String[] LOG_LEVELS = {"error", "warning", "info", "debug", "trace"};
+
+    @Override
+    public void run() {
+
+        while (!shouldStop) {
+            int fileNum = RND.nextInt(logCount);
+            int logLevel = RND.nextInt(LOG_LEVELS.length);
+
+            String outputCommand = String.format("output=%s_%d.log", logFilePrefix, fileNum);
+            String logLevelCommand = "what='gc*=" + LOG_LEVELS[logLevel] + "'";
+
+            try {
+                Object out = MBS.invoke(new ObjectName("com.sun.management:type=DiagnosticCommand"),
+                                        "vmLog",
+                                        new Object[]{new String[]{outputCommand, logLevelCommand}},
+                                        new String[]{String[].class.getName()});
+
+                if (!out.toString().isEmpty()) {
+                    System.out.format("WARNING: Diagnostic command vmLog with arguments %s,%s returned not empty"
+                                    + " output %s\n",
+                            outputCommand, logLevelCommand, out);
+                }
+            } catch (InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException e) {
+                System.out.println("Got exception trying to change log level:" + e);
+                e.printStackTrace();
+                throw new Error(e);
+            }
+            Thread.yield();
+        }
+        System.out.println("Log Switcher finished");
+    }
+}
+
+
+public class TestUnifiedLoggingSwitchStress {
+    /**
+     * Count of memory stressing threads
+     */
+    private static final int MEMORY_STRESSERS_COUNT = 3;
+    /**
+     * Count of log switching threads
+     */
+    private static final int LOG_LEVEL_SWITCHERS_COUNT = 2;
+    /**
+     * Count of log files created by each log switching thread
+     */
+    private static final int LOG_FILES_COUNT = 2;
+    /**
+     * Maximum amount memory allocated by each stressing thread
+     */
+    private static final int MAX_MEMORY_PER_STRESSER = (int) (Runtime.getRuntime().freeMemory()
+            / MEMORY_STRESSERS_COUNT * 0.7);
+
+    public static void main(String[] args) throws InterruptedException {
+        if (args.length != 1) {
+            throw new Error("Test Bug: Expected duration (in seconds) wasn't provided as command line argument");
+        }
+        long duration = Integer.parseInt(args[0]) * 1000;
+
+        long startTime = System.currentTimeMillis();
+
+        List<Thread> threads = new LinkedList<>();
+
+        for (int i = 0; i < LOG_LEVEL_SWITCHERS_COUNT; i++) {
+            threads.add(new Thread(new LogLevelSwitcher("Output_" + i, LOG_FILES_COUNT)));
+        }
+
+        for (int i = 0; i < MEMORY_STRESSERS_COUNT; i++) {
+            threads.add(new Thread(new MemoryStresser(MAX_MEMORY_PER_STRESSER)));
+        }
+
+        threads.stream().forEach(Thread::start);
+
+        while (System.currentTimeMillis() - startTime < duration) {
+            Thread.yield();
+        }
+
+        MemoryStresser.shouldStop = true;
+        LogLevelSwitcher.shouldStop = true;
+    }
+}
diff --git a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java
index 57fb611..ebe90ee 100644
--- a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java
+++ b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java
@@ -49,10 +49,12 @@
             return;
         }
 
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
 
-        JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
-                                              .addToolArg("-heap")
+        JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb")
+                                              .addToolArg("jmap")
+                                              .addToolArg("--heap")
+                                              .addToolArg("--pid")
                                               .addToolArg(pid);
         ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
 
diff --git a/hotspot/test/gc/metaspace/PerfCounters.java b/hotspot/test/gc/metaspace/PerfCounters.java
index d6848f2..9dce3bd 100644
--- a/hotspot/test/gc/metaspace/PerfCounters.java
+++ b/hotspot/test/gc/metaspace/PerfCounters.java
@@ -40,7 +40,7 @@
 
     static {
         try {
-            String pid = Integer.toString(ProcessTools.getProcessId());
+            String pid = Long.toString(ProcessTools.getProcessId());
             VmIdentifier vmId = new VmIdentifier(pid);
             MonitoredHost host = MonitoredHost.getMonitoredHost(vmId);
             vm = host.getMonitoredVm(vmId);
diff --git a/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java b/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java
index c7bbcec..e38ef16 100644
--- a/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java
+++ b/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java
@@ -26,6 +26,7 @@
 /* @test TestMetaspaceInitialization
  * @bug 8042933
  * @summary Tests to initialize metaspace with a very low MetaspaceSize
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -XX:MetaspaceSize=2m TestMetaspaceInitialization
  */
diff --git a/hotspot/test/gc/parallel/TestDynShrinkHeap.java b/hotspot/test/gc/parallel/TestDynShrinkHeap.java
index a71f335..809706f 100644
--- a/hotspot/test/gc/parallel/TestDynShrinkHeap.java
+++ b/hotspot/test/gc/parallel/TestDynShrinkHeap.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
  * @bug 8016479
  * @requires vm.gc=="Parallel" | vm.gc=="null"
  * @summary Verify that the heap shrinks after full GC according to the current values of the Min/MaxHeapFreeRatio flags
+ * @modules java.base/jdk.internal.misc
+ * @modules jdk.management
  * @library /testlibrary
  * @run main/othervm -XX:+UseAdaptiveSizePolicyWithSystemGC -XX:+UseParallelGC -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Xmx1g -verbose:gc TestDynShrinkHeap
  */
diff --git a/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java b/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java
index 1a7501e..17fd5ec 100644
--- a/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java
+++ b/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java
@@ -27,6 +27,7 @@
  * @summary Tests that jvm with maximally verbose GC logging does not crash when ParOldGC has no memory
  * @key gc
  * @requires vm.gc=="Parallel" | vm.gc=="null"
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -Xmx50m -XX:+UseParallelGC -Xlog:gc*=trace TestPrintGCDetailsVerbose
  */
diff --git a/hotspot/test/gc/stress/TestMultiThreadStressRSet.java b/hotspot/test/gc/stress/TestMultiThreadStressRSet.java
index 8947cb7..5a69888 100644
--- a/hotspot/test/gc/stress/TestMultiThreadStressRSet.java
+++ b/hotspot/test/gc/stress/TestMultiThreadStressRSet.java
@@ -35,6 +35,7 @@
  * @requires os.maxMemory > 2G
  *
  * @summary Stress G1 Remembered Set using multiple threads
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib /testlibrary
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/gc/stress/TestStressG1Humongous.java b/hotspot/test/gc/stress/TestStressG1Humongous.java
new file mode 100644
index 0000000..91a5f06
--- /dev/null
+++ b/hotspot/test/gc/stress/TestStressG1Humongous.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+ * @test TestStressG1Humongous
+ * @key gc
+ * @key stress
+ * @summary Stress G1 by humongous allocations in situation near OOM
+ * @requires vm.gc=="G1" | vm.gc=="null"
+ * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=4m
+ *              -Dtimeout=120 -Dthreads=3 -Dhumongoussize=1.1 -Dregionsize=4 TestStressG1Humongous
+ * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=16m
+ *              -Dtimeout=120 -Dthreads=5 -Dhumongoussize=2.1 -Dregionsize=16 TestStressG1Humongous
+ * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=32m
+ *              -Dtimeout=120 -Dthreads=4 -Dhumongoussize=0.6 -Dregionsize=32 TestStressG1Humongous
+ * @run main/othervm/timeout=700 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=1m
+ *              -Dtimeout=600 -Dthreads=7 -Dhumongoussize=0.6 -Dregionsize=1 TestStressG1Humongous
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class TestStressG1Humongous {
+
+    // Timeout in seconds
+    private static final int TIMEOUT = Integer.getInteger("timeout", 60);
+    private static final int THREAD_COUNT = Integer.getInteger("threads", 2);
+    private static final int REGION_SIZE = Integer.getInteger("regionsize", 1) * 1024 * 1024;
+    private static final int HUMONGOUS_SIZE = (int) (REGION_SIZE * Double.parseDouble(System.getProperty("humongoussize", "1.5")));
+
+    private volatile boolean isRunning;
+    private final ExecutorService threadExecutor;
+    private final AtomicInteger alocatedObjectsCount;
+    private CountDownLatch countDownLatch;
+    public static final List<Object> GARBAGE = Collections.synchronizedList(new ArrayList<>());
+
+    public static void main(String[] args) throws InterruptedException {
+        new TestStressG1Humongous().run();
+    }
+
+    public TestStressG1Humongous() {
+        isRunning = true;
+        threadExecutor = Executors.newFixedThreadPool(THREAD_COUNT + 1);
+        alocatedObjectsCount = new AtomicInteger(0);
+    }
+
+    private void run() throws InterruptedException {
+        threadExecutor.submit(new Timer());
+        int checkedAmountOfHObjects = getExpectedAmountOfObjects();
+        while (isRunning()) {
+            countDownLatch = new CountDownLatch(THREAD_COUNT);
+            startAllocationThreads(checkedAmountOfHObjects);
+            countDownLatch.await();
+            GARBAGE.clear();
+            System.out.println("Allocated " + alocatedObjectsCount.get() + " objects.");
+            alocatedObjectsCount.set(0);
+        }
+        threadExecutor.shutdown();
+        System.out.println("Done!");
+    }
+
+    /**
+     * Tries to fill available memory with humongous objects to get expected amount.
+     * @return expected amount of humongous objects
+     */
+    private int getExpectedAmountOfObjects() {
+        long maxMem = Runtime.getRuntime().maxMemory();
+        int expectedHObjects = (int) (maxMem / HUMONGOUS_SIZE);
+        // Will allocate 1 region less to give some free space for VM.
+        int checkedAmountOfHObjects = checkHeapCapacity(expectedHObjects) - 1;
+        return checkedAmountOfHObjects;
+    }
+
+    /**
+     * Starts several threads to allocate the requested amount of humongous objects.
+     * @param totalObjects total amount of object that will be created
+     */
+    private void startAllocationThreads(int totalObjects) {
+        int objectsPerThread = totalObjects / THREAD_COUNT;
+        int objectsForLastThread = objectsPerThread + totalObjects % THREAD_COUNT;
+        for (int i = 0; i < THREAD_COUNT - 1; ++i) {
+            threadExecutor.submit(new AllocationThread(countDownLatch, objectsPerThread, alocatedObjectsCount));
+        }
+        threadExecutor.submit(new AllocationThread(countDownLatch, objectsForLastThread, alocatedObjectsCount));
+    }
+
+    /**
+     * Creates a humongous object of the predefined size.
+     */
+    private void createObject() {
+        GARBAGE.add(new byte[HUMONGOUS_SIZE]);
+    }
+
+    /**
+     * Tries to create the requested amount of humongous objects.
+     * In case of OOME, stops creating and cleans the created garbage.
+     * @param expectedObjects amount of objects based on heap size
+     * @return amount of created objects
+     */
+    private int checkHeapCapacity(int expectedObjects) {
+        int allocated = 0;
+        try {
+            while (isRunning() && allocated < expectedObjects) {
+                createObject();
+                ++allocated;
+            }
+        } catch (OutOfMemoryError oome) {
+            GARBAGE.clear();
+        }
+        return allocated;
+    }
+
+    private void setDone() {
+        isRunning = false;
+    }
+
+    private boolean isRunning() {
+        return isRunning;
+    }
+
+    /**
+     * Thread which allocates requested amount of humongous objects.
+     */
+    private class AllocationThread implements Runnable {
+
+        private final int totalObjects;
+        private final CountDownLatch cdl;
+        private final AtomicInteger allocationCounter;
+
+        /**
+         * Creates allocation thread
+         * @param cdl CountDownLatch
+         * @param objects amount of objects to allocate
+         * @param counter
+         */
+        public AllocationThread(CountDownLatch cdl, int objects, AtomicInteger counter) {
+            totalObjects = objects;
+            this.cdl = cdl;
+            allocationCounter = counter;
+        }
+
+        @Override
+        public void run() {
+            int allocatedObjects = 0;
+            try {
+                while (isRunning && allocatedObjects < totalObjects) {
+                    createObject();
+                    allocatedObjects++;
+                    allocationCounter.incrementAndGet();
+                }
+
+            } catch (OutOfMemoryError oome) {
+                GARBAGE.clear();
+                System.out.print("OOME was caught.");
+                System.out.println(" Allocated in thread: " + allocatedObjects + " . Totally allocated: " + allocationCounter.get() + ".");
+            } finally {
+                cdl.countDown();
+            }
+        }
+    }
+
+    /**
+     * Simple Runnable which waits TIMEOUT and sets isRunning to false.
+     */
+    class Timer implements Runnable {
+
+        @Override
+        public void run() {
+            try {
+                Thread.sleep(TIMEOUT * 1000);
+            } catch (InterruptedException ex) {
+            }
+            setDone();
+        }
+    }
+}
diff --git a/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java b/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java
index 5b7e167..8be8115 100644
--- a/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java
+++ b/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java
@@ -31,7 +31,7 @@
 import jdk.test.lib.Asserts;
 import com.sun.management.ThreadMXBean;
 import sun.hotspot.WhiteBox;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Main class for tests on {@code SurvivorAlignmentInBytes} option.
diff --git a/hotspot/test/gc/testlibrary/Helpers.java b/hotspot/test/gc/testlibrary/Helpers.java
index aa20031..b28d92d 100644
--- a/hotspot/test/gc/testlibrary/Helpers.java
+++ b/hotspot/test/gc/testlibrary/Helpers.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 
 public class Helpers {
 
@@ -45,14 +46,14 @@
 
     /**
      * According class file format theoretical amount of fields in class is u2 which is (256 * 256 - 1).
-     * Some service info takes place in constant pool and we really could make a class with only (256 * 256 - 29)
-     * fields.
+     * Some service info takes place in constant pool and we really could make a class with lesser amount of fields.
+     *
      * Since the exact value is not so important and I would like to avoid issues that may be caused by future changes/
-     * different archs etc I selected (256 * 256 - 32) for this constant.
+     * different archs etc I selected (256 * 256 - 1024) for this constant.
      * The test works with other values too but the smaller the number the more classes we need to generate and it takes
      * more time
      */
-    private static final int MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS = 256 * 256 - 32;
+    private static final int MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS = 256 * 256 - 1024;
 
     /**
      * Detects amount of extra bytes required to allocate a byte array.
@@ -140,6 +141,28 @@
     }
 
     /**
+     * Generates specified amount of long fields
+     * Result string will looks like this:
+     * <p>
+     * long f0;
+     * ...
+     * long fNNN;
+     *
+     * @param fieldCount count of long fields
+     * @return generated fields
+     */
+    private static String fieldsGenerator(long fieldCount) {
+        StringBuilder fieldsBuilder = new StringBuilder();
+
+        for (int i = 0; i < fieldCount; ++i) {
+            fieldsBuilder.append(String.format("long f%d;\n", i));
+        }
+
+        return fieldsBuilder.toString();
+    }
+
+
+    /**
      * Changes string from enum notation to class notation - i.e. "VERY_SMALL_CAT" to "VerySmallCat"
      *
      * @param enumName string in enum notation
@@ -216,22 +239,121 @@
             // for the last generated class we use specified class name
             String clsName = (i == generatedClassesCount - 1) ? className : prefix + i;
 
-            Helpers.compileClass(clsName, workDir,
-                    Helpers.generate(
-                            clsName,
-                            // for first generated class we don't have 'extends'
-                            (i == 0 ? null : prefix + (i - 1)),
-                            null,
-                            // for the last generated class we use different field count
-                            (i == generatedClassesCount - 1) ? fieldsInLastClassCount
-                                    : MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS));
+            // If we already have a file with the same name we do not create it again
+            if (Files.notExists(Paths.get(clsName + ".java"))) {
+                Helpers.compileClass(clsName, workDir,
+                        Helpers.generate(
+                                clsName,
+                                // for first generated class we don't have 'extends'
+                                (i == 0 ? null : prefix + (i - 1)),
+                                null,
+                                // for the last generated class we use different field count
+                                (i == generatedClassesCount - 1) ? fieldsInLastClassCount
+                                        : MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS));
+            } else {
+                System.out.println("Class " + clsName +
+                        ".java already exists, skipping class' generation and compilation");
+            }
+
         }
         return classLoader.loadClass(className);
     }
 
     /**
+     * Creates a class which instances will be approximately of the requested size.
+     * This method produces a java source from a class template by substituting values instead of parameters.
+     * Then the obtained source is compiled.
+     * Generated class will looks like this:
+     * classTemplate
+     * constructorTemplate
+     * long f0;
+     * ...
+     * long fNNN;
+     * <p>
+     * }
+     *
+     * @param className    generated class name
+     * @param baseClass    base class
+     * @param classTemplate class template - the first part of class. ${ClassName} and ${BaseClass} will be replaced
+     *                      with values from className and baseClass,one entry of ${Fields} will be replaced with
+     *                      generated long fields. Class template should look like this:
+     *                      imports;
+     *                      public class ${ClassName} extends ${BaseClass} {
+     *                         public ${ClassName}  { some code here;}
+     *                         some methods
+     *                         ${Fields}
+     *
+     *                      }
+     * @param constructorTemplate constructor template, ${ClassName} would be replaced on actual class name
+     * @param instanceSize size of generated class' instance. Size should be aligned by 8 bytes
+     * @param workDir      working dir where generated classes are put and compiled
+     * @param prefix       prefix for service classes (ones we use to create chain of inheritance).
+     *                     The names will be prefix_1, prefix_2,.., prefix_n
+     * @return Class object of generated and compiled class loaded in specified class loader
+     * @throws IOException if cannot write or read to workDir
+     */
+    public static void generateByTemplateAndCompile(String className, String baseClass, String classTemplate,
+                                                    String constructorTemplate, long instanceSize, Path workDir,
+                                                    String prefix) throws IOException {
+
+        if (instanceSize % SIZE_OF_LONG != 0L) {
+            throw new Error(String.format("Test bug: only sizes aligned by %d bytes are supported and %d was specified",
+                    SIZE_OF_LONG, instanceSize));
+        }
+
+        int instanceSizeWithoutObjectHeaderInWords =
+                (int) (instanceSize - WhiteBox.getWhiteBox().getObjectSize(new Object())) / SIZE_OF_LONG;
+
+        if (instanceSizeWithoutObjectHeaderInWords <= 0) {
+            throw new Error(String.format("Test bug: specified instance size is too small - %d."
+                    + " Cannot generate any classes", instanceSize));
+        }
+
+        int sizeOfLastFile = instanceSizeWithoutObjectHeaderInWords % MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS;
+        int generatedClassesCount = instanceSizeWithoutObjectHeaderInWords / MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS;
+
+        // Do all the classes have the maximum number of fields?
+        int fieldsInLastClassCount;
+
+        if (sizeOfLastFile == 0) {
+            fieldsInLastClassCount = MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS;
+        } else {
+            generatedClassesCount++;
+            fieldsInLastClassCount = sizeOfLastFile;
+        }
+
+        // first (generatedClassesCount - 1) classes are just fillers - just long fields and constructor
+        for (int i = 0; i < generatedClassesCount - 1; i++) {
+            String clsName = prefix + i;
+
+            Helpers.compileClass(clsName, workDir,
+                    Helpers.generate(
+                            clsName,
+                            // first generated class extends base class
+                            (i == 0 ? baseClass : prefix + (i - 1)),
+                            constructorTemplate.replace("${ClassName}", clsName),
+                            MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS));
+        }
+
+        // generating last class - the one with specified className
+        Helpers.compileClass(className, workDir,
+                classTemplate.replaceAll("\\$\\{ClassName\\}", className)
+                        // if no fillers were generated (generatedClassesCount == 1)
+                        // the last class should extends baseClass
+                        // otherwise it should extend last generated filler class which name is
+                        // prefix + (generatedClassesCount - 2)
+                        // generatedClassesCount is always not smaller than 1
+                        .replace("${BaseClass}",
+                                generatedClassesCount == 1 ? baseClass :
+                                        prefix + (generatedClassesCount - 2))
+                        .replace("${Fields}", fieldsGenerator(fieldsInLastClassCount))
+        );
+    }
+
+    /**
      * Waits until Concurent Mark Cycle finishes
-     * @param wb  Whitebox instance
+     *
+     * @param wb        Whitebox instance
      * @param sleepTime sleep time
      */
     public static void waitTillCMCFinished(WhiteBox wb, int sleepTime) {
diff --git a/hotspot/test/native/GTestWrapper.java b/hotspot/test/native/GTestWrapper.java
new file mode 100644
index 0000000..9ba9399
--- /dev/null
+++ b/hotspot/test/native/GTestWrapper.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/* @test
+ * @summary a jtreg wrapper for gtest tests
+ * @library /test/lib/share/classes
+ * @modules java.base/jdk.internal.misc
+ * @run main/native GTestWrapper
+ */
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Stream;
+import java.util.stream.Collectors;
+
+import java.nio.file.Paths;
+import java.nio.file.Path;
+
+import jdk.test.lib.Platform;
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class GTestWrapper {
+    public static void main(String[] args) throws Throwable {
+        // gtestLauncher is located in <test_image>/hotspot/gtest/<vm_variant>/
+        // nativePath points either to <test_image>/hotspot/jtreg/native or to <test_image>/hotspot/gtest
+        Path nativePath = Paths.get(System.getProperty("test.nativepath"));
+        String jvmVariantDir = getJVMVariantSubDir();
+        // let's assume it's <test_image>/hotspot/gtest
+        Path path = nativePath.resolve(jvmVariantDir);
+        if (!path.toFile().exists()) {
+            // maybe it is <test_image>/hotspot/jtreg/native
+            path = nativePath.getParent()
+                             .getParent()
+                             .resolve("gtest")
+                             .resolve(jvmVariantDir);
+        }
+        if (!path.toFile().exists()) {
+            throw new Error("TESTBUG: the library has not been found in " + nativePath);
+        }
+        path = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : ""));
+        Stream<String> launcherArgs = Stream.of(path.toString(), "-jdk",
+                System.getProperty("test.jdk"));
+        // JVM accepts only -X and -D flags
+        Stream<String> vmFLags = Arrays.stream(Utils.getTestJavaOpts())
+                                       .filter(s -> s.startsWith("-X") || s.startsWith("-D"));
+        String[] cmds = Stream.concat(launcherArgs, vmFLags)
+                              .toArray(String[]::new);
+        ProcessTools.executeCommand(cmds).shouldHaveExitValue(0);
+    }
+
+    private static String getJVMVariantSubDir() {
+        if (Platform.isServer()) {
+            return "server";
+        } else if (Platform.isClient()) {
+            return "client";
+        } else if (Platform.isMinimal()) {
+            return "minimal";
+        } else {
+            throw new Error("TESTBUG: unsuppported vm variant");
+        }
+    }
+}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/hotspot/test/native/gtestLauncher.cpp
similarity index 79%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to hotspot/test/native/gtestLauncher.cpp
index 135652e..d25a0f9 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/hotspot/test/native/gtestLauncher.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -19,14 +19,16 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
+ *
  */
 
-package sun.misc;
+#include "prims/jni.h"
 
-public class Unsafe {
-    private Unsafe() { }
+extern "C" {
+  JNIIMPORT void JNICALL runUnitTests(int argv, char** argc);
+}
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+int main(int argc, char** argv) {
+  runUnitTests(argc, argv);
+  return 0;
 }
diff --git a/hotspot/test/native/gtestMain.cpp b/hotspot/test/native/gtestMain.cpp
new file mode 100644
index 0000000..3c48e80
--- /dev/null
+++ b/hotspot/test/native/gtestMain.cpp
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#ifdef __APPLE__
+#  include <dlfcn.h>
+#endif
+
+#include "prims/jni.h"
+#include "unittest.hpp"
+
+extern "C" {
+
+static int init_jvm(int argc, char **argv, bool is_executing_death_test) {
+  // don't care about the program name
+  argc--;
+  argv++;
+
+  int extra_jvm_args = is_executing_death_test ? 4 : 2;
+  int num_jvm_options = argc + extra_jvm_args;
+
+  JavaVMOption* options = new JavaVMOption[num_jvm_options];
+  options[0].optionString = (char*) "-Dsun.java.launcher.is_altjvm=true";
+  options[1].optionString = (char*) "-XX:+ExecutingUnitTests";
+
+  if (is_executing_death_test) {
+    // don't create core files or hs_err files when executing death tests
+    options[2].optionString = (char*) "-XX:+SuppressFatalErrorMessage";
+    options[3].optionString = (char*) "-XX:-CreateCoredumpOnCrash";
+  }
+
+  for (int i = 0; i < argc; i++) {
+    options[extra_jvm_args + i].optionString = argv[i];
+  }
+
+  JavaVMInitArgs args;
+  args.version = JNI_VERSION_1_8;
+  args.nOptions = num_jvm_options;
+  args.options = options;
+
+  JavaVM* jvm;
+  JNIEnv* env;
+
+  return JNI_CreateJavaVM(&jvm, (void**)&env, &args);
+}
+
+class JVMInitializerListener : public ::testing::EmptyTestEventListener {
+ private:
+  int _argc;
+  char** _argv;
+  bool _is_initialized;
+
+  void initialize_jvm() {
+  }
+
+ public:
+  JVMInitializerListener(int argc, char** argv) :
+    _argc(argc), _argv(argv), _is_initialized(false) {
+  }
+
+  virtual void OnTestStart(const ::testing::TestInfo& test_info) {
+    const char* name = test_info.name();
+    if (strstr(name, "_test_vm") != NULL && !_is_initialized) {
+      ASSERT_EQ(init_jvm(_argc, _argv, false), 0) << "Could not initialize the JVM";
+      _is_initialized = true;
+    }
+  }
+};
+
+static bool is_prefix(const char* prefix, const char* str) {
+  return strncmp(str, prefix, strlen(prefix)) == 0;
+}
+
+static char* get_java_home_arg(int argc, char** argv) {
+  for (int i = 0; i < argc; i++) {
+    if (strncmp(argv[i], "-jdk", strlen(argv[i])) == 0) {
+      return argv[i+1];
+    }
+    if (is_prefix("--jdk=", argv[i])) {
+      return argv[i] + strlen("--jdk=");
+    }
+    if (is_prefix("-jdk:", argv[i])) {
+      return argv[i] + strlen("-jdk:");
+    }
+  }
+  return NULL;
+}
+
+static int num_args_to_skip(char* arg) {
+  if (strcmp(arg, "-jdk") == 0) {
+    return 2; // skip the argument after -jdk as well
+  }
+  if (is_prefix("--jdk=", arg)) {
+    return 1;
+  }
+  if (is_prefix("-jdk:", arg)) {
+    return 1;
+  }
+  return 0;
+}
+
+static char** remove_test_runner_arguments(int* argcp, char **argv) {
+  int argc = *argcp;
+  char** new_argv = (char**) malloc(sizeof(char*) * argc);
+  int new_argc = 0;
+
+  int i = 0;
+  while (i < argc) {
+    int args_to_skip = num_args_to_skip(argv[i]);
+    if (args_to_skip == 0) {
+      new_argv[new_argc] = argv[i];
+      i++;
+      new_argc++;
+    } else {
+      i += num_args_to_skip(argv[i]);
+    }
+  }
+
+  *argcp = new_argc;
+  return new_argv;
+}
+
+JNIEXPORT void JNICALL runUnitTests(int argc, char** argv) {
+  // Must look at googletest options before initializing googletest, since
+  // InitGoogleTest removes googletest options from argv.
+  bool is_executing_death_test = true;
+  for (int i = 0; i < argc; i++) {
+    const char* death_test_flag = "--gtest_internal_run_death_test";
+    if (is_prefix(death_test_flag, argv[i])) {
+      is_executing_death_test = true;
+    }
+  }
+
+  ::testing::InitGoogleTest(&argc, argv);
+  ::testing::GTEST_FLAG(death_test_style) = "threadsafe";
+//  ::testing::GTEST_FLAG(death_test_output_prefix) = "Other VM";
+
+  char* java_home = get_java_home_arg(argc, argv);
+  if (java_home == NULL) {
+    fprintf(stderr, "ERROR: You must specify a JDK to use for running the unit tests.\n");
+    exit(1);
+  }
+#ifndef _WIN32
+  int overwrite = 1; // overwrite an eventual existing value for JAVA_HOME
+  setenv("JAVA_HOME", java_home, overwrite);
+
+// workaround for JDK-7131356
+#ifdef __APPLE__
+  size_t len = strlen(java_home) + strlen("/lib/jli/libjli.dylib") + 1;
+  char* path = new char[len];
+  snprintf(path, len, "%s/lib/jli/libjli.dylib", java_home);
+  dlopen(path, RTLD_NOW | RTLD_GLOBAL);
+#endif // __APPLE__
+
+#else  // _WIN32
+  char* java_home_var = "_ALT_JAVA_HOME_DIR";
+  size_t len = strlen(java_home) + strlen(java_home_var) + 2;
+  char * envString = new char[len];
+  sprintf_s(envString, len, "%s=%s", java_home_var, java_home);
+  _putenv(envString);
+#endif // _WIN32
+  argv = remove_test_runner_arguments(&argc, argv);
+
+  if (is_executing_death_test) {
+    if (init_jvm(argc, argv, true) != 0) {
+      abort();
+    }
+  } else {
+    ::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners();
+    listeners.Append(new JVMInitializerListener(argc, argv));
+  }
+
+  int result = RUN_ALL_TESTS();
+  if (result != 0) {
+    fprintf(stderr, "ERROR: RUN_ALL_TESTS() failed. Error %d\n", result);
+    exit(2);
+  }
+}
+
+} // extern "C"
diff --git a/hotspot/test/native/runtime/test_os.cpp b/hotspot/test/native/runtime/test_os.cpp
new file mode 100644
index 0000000..7346685
--- /dev/null
+++ b/hotspot/test/native/runtime/test_os.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "runtime/os.hpp"
+#include "unittest.hpp"
+
+TEST_VM(os, page_size_for_region) {
+  size_t large_page_example = 4 * M;
+  size_t large_page = os::page_size_for_region_aligned(large_page_example, 1);
+
+  size_t small_page = os::vm_page_size();
+  if (large_page > small_page) {
+    size_t num_small_in_large = large_page / small_page;
+    size_t page = os::page_size_for_region_aligned(large_page, num_small_in_large);
+    ASSERT_EQ(page, small_page) << "Did not get a small page";
+  }
+}
+
+#ifdef ASSERT
+TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") {
+  size_t region_size = 16 * os::vm_page_size();
+  os::page_size_for_region_aligned(region_size, 0); // should assert
+}
+#endif
diff --git a/hotspot/test/native/unittest.hpp b/hotspot/test/native/unittest.hpp
new file mode 100644
index 0000000..5f3f28e
--- /dev/null
+++ b/hotspot/test/native/unittest.hpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define GTEST_DONT_DEFINE_TEST 1
+#include "gtest/gtest.h"
+#ifdef assert
+  #undef assert
+#endif
+
+#define CONCAT(a, b) a ## b
+
+#define TEST(category, name) GTEST_TEST(category, CONCAT(name, _test))
+
+#define TEST_VM(category, name) GTEST_TEST(category, CONCAT(name, _test_vm))
+
+#define TEST_VM_F(test_fixture, name)                               \
+  GTEST_TEST_(test_fixture, name ## _test_vm, test_fixture,         \
+              ::testing::internal::GetTypeId<test_fixture>())
+
+#define TEST_OTHER_VM(category, name)                               \
+  static void test_  ## category ## _ ## name ## _();               \
+                                                                    \
+  static void child_ ## category ## _ ## name ## _() {              \
+    ::testing::GTEST_FLAG(throw_on_failure) = true;                 \
+    test_ ## category ## _ ## name ## _();                          \
+    fprintf(stderr, "OKIDOKI");                                     \
+    exit(0);                                                        \
+  }                                                                 \
+                                                                    \
+  TEST(category, CONCAT(name, _other_vm)) {                         \
+    ASSERT_EXIT(child_ ## category ## _ ## name ## _(),             \
+                ::testing::ExitedWithCode(0),                       \
+                ".*OKIDOKI.*");                                     \
+  }                                                                 \
+                                                                    \
+  void test_ ## category ## _ ## name ## _()
+
+#ifdef ASSERT
+#define TEST_VM_ASSERT(category, name)                              \
+  static void test_  ## category ## _ ## name ## _();               \
+                                                                    \
+  static void child_ ## category ## _ ## name ## _() {              \
+    ::testing::GTEST_FLAG(throw_on_failure) = true;                 \
+    test_ ## category ## _ ## name ## _();                          \
+    exit(0);                                                        \
+  }                                                                 \
+                                                                    \
+  TEST(category, CONCAT(name, _vm_assert)) {                        \
+    ASSERT_EXIT(child_ ## category ## _ ## name ## _(),             \
+                ::testing::ExitedWithCode(1),                       \
+                "assert failed");                                   \
+  }                                                                 \
+                                                                    \
+  void test_ ## category ## _ ## name ## _()
+#else
+#define TEST_VM_ASSERT(...)                                         \
+    TEST_VM_ASSERT is only available in debug builds
+#endif
+
+#ifdef ASSERT
+#define TEST_VM_ASSERT_MSG(category, name, msg)                     \
+  static void test_  ## category ## _ ## name ## _();               \
+                                                                    \
+  static void child_ ## category ## _ ## name ## _() {              \
+    ::testing::GTEST_FLAG(throw_on_failure) = true;                 \
+    test_ ## category ## _ ## name ## _();                          \
+    exit(0);                                                        \
+  }                                                                 \
+                                                                    \
+  TEST(category, CONCAT(name, _vm_assert)) {                        \
+    ASSERT_EXIT(child_ ## category ## _ ## name ## _(),             \
+                ::testing::ExitedWithCode(1),                       \
+                "assert failed: " msg);                             \
+  }                                                                 \
+                                                                    \
+  void test_ ## category ## _ ## name ## _()
+#else
+#define TEST_VM_ASSERT_MSG(...)                                     \
+    TEST_VM_ASSERT_MSG is only available in debug builds
+#endif
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/hotspot/test/native/utilities/test_quicksort.cpp
similarity index 67%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to hotspot/test/native/utilities/test_quicksort.cpp
index 9e5a4a7..5a56c87 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/hotspot/test/native/utilities/test_quicksort.cpp
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -21,17 +19,29 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
+ *
  */
-package jdk.tools.jlink.plugin;
 
-import java.util.Properties;
+#include "prims/jvm.h"
+#include "utilities/quickSort.hpp"
+#include "unittest.hpp"
 
-/**
- * Interface to plugin (container) context.
- */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+static int int_comparator(int a, int b) {
+  if (a == b) {
+    return 0;
+  } else if (a < b) {
+    return -1;
+  }
+
+  // a > b
+  return 1;
+}
+
+TEST(utilities, quicksort) {
+  int test_array[] = {3,2,1};
+  QuickSort::sort(test_array, 3, int_comparator, false);
+
+  ASSERT_EQ(1, test_array[0]);
+  ASSERT_EQ(2, test_array[1]);
+  ASSERT_EQ(3, test_array[2]);
 }
diff --git a/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java b/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java
index c84bf5c..a9f69d6 100644
--- a/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java
+++ b/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java
@@ -35,7 +35,7 @@
  */
 import jdk.internal.org.objectweb.asm.*;
 import java.lang.reflect.Constructor;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class InvokeSpecialAnonTest implements Opcodes {
 
diff --git a/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java b/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java
index d911435..6ce8cb1 100644
--- a/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java
+++ b/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java
@@ -24,6 +24,7 @@
 /* @test
  * @bug 8149170
  * @summary Test native functions return booleans as 0/1 but differently than java functions
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile BoolConstructor.java
  * @run main/native NativeSmallIntCallsTest
diff --git a/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java b/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java
index db3b5f6..9694382 100644
--- a/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java
+++ b/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java
@@ -67,6 +67,7 @@
             // if sharing failed due to ASLR or similar reasons,
             // check whether sharing was attempted at all (UseSharedSpaces)
             output.shouldContain("UseSharedSpaces:");
+            output.shouldNotContain("Unable to map %s");
         }
         output.shouldHaveExitValue(0);
     }
diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveClass.java b/hotspot/test/runtime/ClassUnload/KeepAliveClass.java
index a108026..9c0b50c 100644
--- a/hotspot/test/runtime/ClassUnload/KeepAliveClass.java
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveClass.java
@@ -24,6 +24,7 @@
 /*
  * @test KeepAliveClass
  * @summary This test case uses a java.lang.Class instance to keep a class alive.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveClass test.Empty
diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java b/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java
index 21e92a1..ec8fa0d 100644
--- a/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java
@@ -24,6 +24,7 @@
 /*
  * @test KeepAliveClassLoader
  * @summary This test case uses a java.lang.ClassLoader instance to keep a class alive.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveClassLoader test.Empty
diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveObject.java b/hotspot/test/runtime/ClassUnload/KeepAliveObject.java
index 4a8ffb7..aca13b0 100644
--- a/hotspot/test/runtime/ClassUnload/KeepAliveObject.java
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveObject.java
@@ -24,6 +24,7 @@
 /*
  * @test KeepAliveObject
  * @summary This test case uses a class instance to keep the class alive.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveObject test.Empty
diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java b/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java
index 0aa3547..e6321a5 100644
--- a/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java
@@ -24,6 +24,7 @@
 /*
  * @test KeepAliveSoftReference
  * @summary This test case uses a java.lang.ref.SoftReference referencing a class instance to keep a class alive.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveSoftReference test.Empty
diff --git a/hotspot/test/runtime/ClassUnload/UnloadTest.java b/hotspot/test/runtime/ClassUnload/UnloadTest.java
index cb8f052..eada270 100644
--- a/hotspot/test/runtime/ClassUnload/UnloadTest.java
+++ b/hotspot/test/runtime/ClassUnload/UnloadTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test UnloadTest
+ * @modules java.base/jdk.internal.misc
  * @library /runtime/testlibrary /testlibrary /test/lib
  * @library classes
  * @build ClassUnloadCommon test.Empty
diff --git a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java
index b65df44..f2401c7 100644
--- a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java
+++ b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8060449 8073989
  * @summary Newly obsolete command line options should still give useful error messages when used improperly.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java
index e6ec4c5..7da0e14 100644
--- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java
+++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java
@@ -90,11 +90,12 @@
         excludeTestMaxRange("CICompilerCount");
 
         /*
-         * JDK-8153340
-         * Temporary exclude AllocatePrefetchDistance option from testing
+         * JDK-8156679
+         * Temporarily exclude from range testing as the range is not
+         * valid for all platforms
          */
-        excludeTestRange("AllocatePrefetchDistance");
-
+        excludeTestRange("AllocatePrefetchLines");
+        excludeTestRange("AllocateInstancePrefetchLines");
 
         /*
          * JDK-8136766
diff --git a/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java b/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java
index f0661cd..2fd472e 100644
--- a/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java
+++ b/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java
@@ -106,7 +106,7 @@
       output.shouldHaveExitValue(0);
 
       // Test jcmd PrintTouchedMethods VM.print_touched_methods
-      String pid = Integer.toString(ProcessTools.getProcessId());
+      String pid = Long.toString(ProcessTools.getProcessId());
       pb = new ProcessBuilder();
       pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.print_touched_methods"});
       output = new OutputAnalyzer(pb.start());
diff --git a/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java b/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java
index 321a435..3566e59 100644
--- a/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java
+++ b/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java
@@ -26,6 +26,7 @@
  * @bug 8129786
  * @summary Verify that JVM correctly processes very long unrecognized VM option
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @run main TestLongUnrecognizedVMOption
  */
diff --git a/hotspot/test/runtime/CommandLine/VMAliasOptions.java b/hotspot/test/runtime/CommandLine/VMAliasOptions.java
index fbb3506..ee516b9 100644
--- a/hotspot/test/runtime/CommandLine/VMAliasOptions.java
+++ b/hotspot/test/runtime/CommandLine/VMAliasOptions.java
@@ -28,6 +28,7 @@
  * @test
  * @bug 8061611
  * @summary Test that various alias options correctly set the target options. See aliased_jvm_flags in arguments.cpp.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 public class VMAliasOptions {
diff --git a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java
index 2b568c0..5ea7653 100644
--- a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java
+++ b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java
@@ -28,6 +28,7 @@
  * @test
  * @bug 8066821
  * @summary Test that various options are deprecated. See deprecated_jvm_flags in arguments.cpp.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 public class VMDeprecatedOptions {
diff --git a/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java b/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java
index de7ed44..0049548 100644
--- a/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java
+++ b/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java
@@ -26,6 +26,7 @@
  * @bug 8061999 8135195 8136552
  * @summary Test "-XX:VMOptionsFile" VM option
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.management
  * @run main TestVMOptionsFile
  */
diff --git a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java
index 299444f..a864f4d 100644
--- a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java
+++ b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java
@@ -33,7 +33,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class CreateCoredumpOnCrash {
     private static class Crasher {
@@ -56,7 +56,7 @@
     public static OutputAnalyzer runTest(String option) throws Exception {
         return new OutputAnalyzer(
             ProcessTools.createJavaProcessBuilder(
-            "-Xmx64m", "-XX:-TransmitErrorReport", option, Crasher.class.getName())
+            "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName())
             .start());
     }
 }
diff --git a/hotspot/test/runtime/ErrorHandling/ErrorHandler.java b/hotspot/test/runtime/ErrorHandling/ErrorHandler.java
index deabd01..ba5cdbc 100644
--- a/hotspot/test/runtime/ErrorHandling/ErrorHandler.java
+++ b/hotspot/test/runtime/ErrorHandling/ErrorHandler.java
@@ -27,6 +27,7 @@
  * @bug 8015884
  * @summary Exercise HotSpot error handling code by invoking java with
  *          -XX:ErrorHandlerTest option to cause an error report. Check the results.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run driver ErrorHandler
  */
diff --git a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java
index 85a0749..df6b9ce 100644
--- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java
+++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java
@@ -36,7 +36,7 @@
 
 import jdk.test.lib.*;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import jdk.test.lib.Utils;
 
 public class ProblematicFrameTest {
diff --git a/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java b/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java
index 27bcab5..c34e56a 100644
--- a/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java
+++ b/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java
@@ -35,6 +35,7 @@
  * @test
  * @bug 8074552
  * @summary SafeFetch32 and SafeFetchN do not work in error handling
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @author Thomas Stuefe (SAP)
  */
diff --git a/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java b/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java
index 0a6e82d..d658401 100644
--- a/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java
+++ b/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java
@@ -24,6 +24,7 @@
 /*
  * @test TestCrashOnOutOfMemoryError
  * @summary Test using -XX:+CrashOnOutOfMemoryError
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.*
  * @run driver TestCrashOnOutOfMemoryError
diff --git a/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java b/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java
index 2f266da..79d064f 100644
--- a/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java
+++ b/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java
@@ -24,6 +24,7 @@
 /*
  * @test TestExitOnOutOfMemoryError
  * @summary Test using -XX:ExitOnOutOfMemoryError
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.*
  * @run driver TestExitOnOutOfMemoryError
diff --git a/hotspot/test/runtime/ErrorHandling/TestOnError.java b/hotspot/test/runtime/ErrorHandling/TestOnError.java
index 4e8763f..4fa5c44 100644
--- a/hotspot/test/runtime/ErrorHandling/TestOnError.java
+++ b/hotspot/test/runtime/ErrorHandling/TestOnError.java
@@ -24,6 +24,7 @@
 /*
  * @test TestOnError
  * @summary Test using -XX:OnError=<cmd>
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build TestOnError
  * @run main TestOnError
diff --git a/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java b/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java
index 775e1bf..c81cab5 100644
--- a/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java
+++ b/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java
@@ -24,6 +24,7 @@
 /*
  * @test TestOnOutOfMemoryError
  * @summary Test using -XX:OnOutOfMemoryError=<cmd>
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build TestOnOutOfMemoryError
  * @run main TestOnOutOfMemoryError
diff --git a/hotspot/test/runtime/Metaspace/FragmentMetaspace.java b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java
index d4423a3..acd64cd 100644
--- a/hotspot/test/runtime/Metaspace/FragmentMetaspace.java
+++ b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /runtime/testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.compiler
  * @build GeneratedClassLoader
  * @run main/othervm/timeout=200 -Xmx300m FragmentMetaspace
diff --git a/hotspot/test/runtime/8003720/Asmator.java b/hotspot/test/runtime/MirrorFrame/Asmator.java
similarity index 100%
rename from hotspot/test/runtime/8003720/Asmator.java
rename to hotspot/test/runtime/MirrorFrame/Asmator.java
diff --git a/hotspot/test/runtime/8003720/Test8003720.java b/hotspot/test/runtime/MirrorFrame/Test8003720.java
similarity index 100%
rename from hotspot/test/runtime/8003720/Test8003720.java
rename to hotspot/test/runtime/MirrorFrame/Test8003720.java
diff --git a/hotspot/test/runtime/8003720/Victim.java b/hotspot/test/runtime/MirrorFrame/Victim.java
similarity index 100%
rename from hotspot/test/runtime/8003720/Victim.java
rename to hotspot/test/runtime/MirrorFrame/Victim.java
diff --git a/hotspot/test/runtime/8003720/VictimClassLoader.java b/hotspot/test/runtime/MirrorFrame/VictimClassLoader.java
similarity index 100%
rename from hotspot/test/runtime/8003720/VictimClassLoader.java
rename to hotspot/test/runtime/MirrorFrame/VictimClassLoader.java
diff --git a/hotspot/test/runtime/NMT/BaselineWithParameter.java b/hotspot/test/runtime/NMT/BaselineWithParameter.java
index 38d31ff..b498211 100644
--- a/hotspot/test/runtime/NMT/BaselineWithParameter.java
+++ b/hotspot/test/runtime/NMT/BaselineWithParameter.java
@@ -38,7 +38,7 @@
 
   public static void main(String args[]) throws Exception {
     // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
     OutputAnalyzer output;
 
     ProcessBuilder pb = new ProcessBuilder();
diff --git a/hotspot/test/runtime/NMT/ChangeTrackingLevel.java b/hotspot/test/runtime/NMT/ChangeTrackingLevel.java
index a5e8beb..e790548 100644
--- a/hotspot/test/runtime/NMT/ChangeTrackingLevel.java
+++ b/hotspot/test/runtime/NMT/ChangeTrackingLevel.java
@@ -26,6 +26,7 @@
  * @bug 8059100
  * @summary Test that you can decrease NMT tracking level but not increase it.
  * @key nmt
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build ChangeTrackingLevel
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/runtime/NMT/JcmdBaselineDetail.java b/hotspot/test/runtime/NMT/JcmdBaselineDetail.java
index ce99b20..1318dc3 100644
--- a/hotspot/test/runtime/NMT/JcmdBaselineDetail.java
+++ b/hotspot/test/runtime/NMT/JcmdBaselineDetail.java
@@ -37,7 +37,7 @@
 
     public static void main(String args[]) throws Exception {
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
         OutputAnalyzer output;
 
         ProcessBuilder pb = new ProcessBuilder();
diff --git a/hotspot/test/runtime/NMT/JcmdDetailDiff.java b/hotspot/test/runtime/NMT/JcmdDetailDiff.java
index 694d47e..962afd1 100644
--- a/hotspot/test/runtime/NMT/JcmdDetailDiff.java
+++ b/hotspot/test/runtime/NMT/JcmdDetailDiff.java
@@ -45,7 +45,7 @@
         ProcessBuilder pb = new ProcessBuilder();
         OutputAnalyzer output;
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
 
         long commitSize = 128 * 1024;
         long reserveSize = 256 * 1024;
diff --git a/hotspot/test/runtime/NMT/JcmdScale.java b/hotspot/test/runtime/NMT/JcmdScale.java
index 13cb50a..b8d8e56 100644
--- a/hotspot/test/runtime/NMT/JcmdScale.java
+++ b/hotspot/test/runtime/NMT/JcmdScale.java
@@ -39,7 +39,7 @@
     ProcessBuilder pb = new ProcessBuilder();
     OutputAnalyzer output;
     // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
 
     pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"});
     output = new OutputAnalyzer(pb.start());
diff --git a/hotspot/test/runtime/NMT/JcmdScaleDetail.java b/hotspot/test/runtime/NMT/JcmdScaleDetail.java
index 0379e234..27cb8c8 100644
--- a/hotspot/test/runtime/NMT/JcmdScaleDetail.java
+++ b/hotspot/test/runtime/NMT/JcmdScaleDetail.java
@@ -39,7 +39,7 @@
         ProcessBuilder pb = new ProcessBuilder();
         OutputAnalyzer output;
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
 
         pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"});
         output = new OutputAnalyzer(pb.start());
diff --git a/hotspot/test/runtime/NMT/JcmdSummaryDiff.java b/hotspot/test/runtime/NMT/JcmdSummaryDiff.java
index a53d75f..2c0b39c 100644
--- a/hotspot/test/runtime/NMT/JcmdSummaryDiff.java
+++ b/hotspot/test/runtime/NMT/JcmdSummaryDiff.java
@@ -45,7 +45,7 @@
         ProcessBuilder pb = new ProcessBuilder();
         OutputAnalyzer output;
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
 
         long commitSize = 128 * 1024;
         long reserveSize = 256 * 1024;
diff --git a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java
index b9c506b..4081865 100644
--- a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java
+++ b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java
@@ -60,7 +60,7 @@
     }
 
     // Grab my own PID
-    pid = Integer.toString(ProcessTools.getProcessId());
+    pid = Long.toString(ProcessTools.getProcessId());
 
     jcmdCommand("summary");
     jcmdCommand("detail");
diff --git a/hotspot/test/runtime/NMT/MallocRoundingReportTest.java b/hotspot/test/runtime/NMT/MallocRoundingReportTest.java
index b823679..b5ff6dd 100644
--- a/hotspot/test/runtime/NMT/MallocRoundingReportTest.java
+++ b/hotspot/test/runtime/NMT/MallocRoundingReportTest.java
@@ -46,7 +46,7 @@
         WhiteBox wb = WhiteBox.getWhiteBox();
 
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
         ProcessBuilder pb = new ProcessBuilder();
 
         long[] additionalBytes = {0, 1, 512, 650};
diff --git a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java
index 7e754f4..3bb39aa 100644
--- a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java
+++ b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java
@@ -26,6 +26,7 @@
  * @summary Test corner case that overflows malloc site hashtable bucket
  * @requires sun.arch.data.model == "32"
  * @key nmt jcmd stress
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build MallocSiteHashOverflow
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
@@ -48,7 +49,7 @@
         int MAX_HASH_SIZE = wb.NMTGetHashSize();
 
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
         ProcessBuilder pb = new ProcessBuilder();
 
         // Verify that current tracking level is "detail"
diff --git a/hotspot/test/runtime/NMT/MallocStressTest.java b/hotspot/test/runtime/NMT/MallocStressTest.java
index af7f97f..8d7061f 100644
--- a/hotspot/test/runtime/NMT/MallocStressTest.java
+++ b/hotspot/test/runtime/NMT/MallocStressTest.java
@@ -74,7 +74,7 @@
         whiteBox = WhiteBox.getWhiteBox();
 
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
         ProcessBuilder pb = new ProcessBuilder();
 
         AllocThread[]   alloc_threads = new AllocThread[256];
diff --git a/hotspot/test/runtime/NMT/MallocTestType.java b/hotspot/test/runtime/NMT/MallocTestType.java
index abd04a7..3ee5e48 100644
--- a/hotspot/test/runtime/NMT/MallocTestType.java
+++ b/hotspot/test/runtime/NMT/MallocTestType.java
@@ -44,7 +44,7 @@
     WhiteBox wb = WhiteBox.getWhiteBox();
 
     // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
     ProcessBuilder pb = new ProcessBuilder();
 
     // Use WB API to alloc and free with the mtTest type
diff --git a/hotspot/test/runtime/NMT/MallocTrackingVerify.java b/hotspot/test/runtime/NMT/MallocTrackingVerify.java
index cefbcd9..0a77bd2 100644
--- a/hotspot/test/runtime/NMT/MallocTrackingVerify.java
+++ b/hotspot/test/runtime/NMT/MallocTrackingVerify.java
@@ -53,7 +53,7 @@
         OutputAnalyzer output;
 
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
         ProcessBuilder pb = new ProcessBuilder();
 
         Random random = new Random();
diff --git a/hotspot/test/runtime/NMT/PrintNMTStatistics.java b/hotspot/test/runtime/NMT/PrintNMTStatistics.java
index 7966f23..413ade5 100644
--- a/hotspot/test/runtime/NMT/PrintNMTStatistics.java
+++ b/hotspot/test/runtime/NMT/PrintNMTStatistics.java
@@ -26,6 +26,7 @@
  * @key nmt regression
  * @bug 8005936 8058606
  * @summary Verify PrintNMTStatistics on normal JVM exit for detail and summary tracking level
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java b/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java
index 8453d88..c67b622 100644
--- a/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java
+++ b/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java
@@ -26,6 +26,7 @@
  * @bug 8013120
  * @summary Release committed memory and make sure NMT handles it correctly
  * @key nmt regression
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build ReleaseCommittedMemory
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/runtime/NMT/ReleaseNoCommit.java b/hotspot/test/runtime/NMT/ReleaseNoCommit.java
index 7499d60..0d35411 100644
--- a/hotspot/test/runtime/NMT/ReleaseNoCommit.java
+++ b/hotspot/test/runtime/NMT/ReleaseNoCommit.java
@@ -49,7 +49,7 @@
         ProcessBuilder pb = new ProcessBuilder();
         OutputAnalyzer output;
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
 
         addr = wb.NMTReserveMemory(reserveSize);
         // Check for reserved
diff --git a/hotspot/test/runtime/NMT/ShutdownTwice.java b/hotspot/test/runtime/NMT/ShutdownTwice.java
index 1d35416..d0a7c77 100644
--- a/hotspot/test/runtime/NMT/ShutdownTwice.java
+++ b/hotspot/test/runtime/NMT/ShutdownTwice.java
@@ -37,7 +37,7 @@
 
   public static void main(String args[]) throws Exception {
     // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
     OutputAnalyzer output;
 
     ProcessBuilder pb = new ProcessBuilder();
diff --git a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java
index 6692115..aec1a80 100644
--- a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java
+++ b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java
@@ -38,7 +38,7 @@
   public static void main(String args[]) throws Exception {
     OutputAnalyzer output;
     // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
     ProcessBuilder pb = new ProcessBuilder();
 
     // Run 'jcmd <pid> VM.native_memory shutdown'
diff --git a/hotspot/test/runtime/NMT/SummarySanityCheck.java b/hotspot/test/runtime/NMT/SummarySanityCheck.java
index d322fa6..511596b 100644
--- a/hotspot/test/runtime/NMT/SummarySanityCheck.java
+++ b/hotspot/test/runtime/NMT/SummarySanityCheck.java
@@ -45,7 +45,7 @@
   private static String jcmdout;
   public static void main(String args[]) throws Exception {
     // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
 
     ProcessBuilder pb = new ProcessBuilder();
 
diff --git a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java
index a0e29fc..2fee0c7 100644
--- a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java
+++ b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java
@@ -46,7 +46,7 @@
     final WhiteBox wb = WhiteBox.getWhiteBox();
 
     // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
     ProcessBuilder pb = new ProcessBuilder();
 
     Thread allocThread = new Thread() {
diff --git a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java
index 8ba7e7c..1611b6f 100644
--- a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java
+++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java
@@ -45,7 +45,7 @@
   public static void main(String args[]) throws Exception {
     OutputAnalyzer output;
 
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
     ProcessBuilder pb = new ProcessBuilder();
 
     Thread reserveThread = new Thread() {
diff --git a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java
index fbc5fe9..dabdcd4 100644
--- a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java
+++ b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java
@@ -48,7 +48,7 @@
         long reserveSize = 4 * 1024 * 1024; // 4096KB
         long addr;
 
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
         ProcessBuilder pb = new ProcessBuilder();
 
         // reserve
diff --git a/hotspot/test/runtime/NMT/VirtualAllocTestType.java b/hotspot/test/runtime/NMT/VirtualAllocTestType.java
index b8bd3be..da611ab 100644
--- a/hotspot/test/runtime/NMT/VirtualAllocTestType.java
+++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java
@@ -46,7 +46,7 @@
     long reserveSize = 256 * 1024;
     long addr;
 
-    String pid = Integer.toString(ProcessTools.getProcessId());
+    String pid = Long.toString(ProcessTools.getProcessId());
     ProcessBuilder pb = new ProcessBuilder();
 
     addr = wb.NMTReserveMemory(reserveSize);
diff --git a/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java b/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java
index 0593014..a759574 100644
--- a/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java
+++ b/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java
@@ -25,6 +25,7 @@
  * @test
  * @library /testlibrary
  * @summary Test that type annotations are retained after a retransform
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.instrument
  *          jdk.jartool/sun.tools.jar
diff --git a/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java b/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java
index 394e31c..de76aea 100644
--- a/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java
+++ b/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java
@@ -26,6 +26,7 @@
  * @bug 6904403
  * @summary Don't assert if we redefine finalize method
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.compiler
  *          java.instrument
  *          jdk.jartool/sun.tools.jar
diff --git a/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java b/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java
index 525d890..9921afb 100644
--- a/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java
+++ b/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java
@@ -26,6 +26,7 @@
  * @bug 8055008
  * @summary Redefine EMCP and non-EMCP methods that are running in an infinite loop
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.compiler
  *          java.instrument
  *          jdk.jartool/sun.tools.jar
diff --git a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java
index d90007f3..283d08d 100644
--- a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java
+++ b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java
@@ -26,6 +26,7 @@
  * @bug 8087315
  * @summary Get old method's stack trace elements after GC
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.compiler
  *          java.instrument
  *          jdk.jartool/sun.tools.jar
diff --git a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java
index 2924722..a56907a 100644
--- a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java
+++ b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java
@@ -26,6 +26,7 @@
  * @bug 8076110
  * @summary Redefine running methods that have cached resolution errors
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.instrument
  *          jdk.jartool/sun.tools.jar
diff --git a/hotspot/test/runtime/ReservedStack/ReservedStackTest.java b/hotspot/test/runtime/ReservedStack/ReservedStackTest.java
index 43177dd..3c60d47 100644
--- a/hotspot/test/runtime/ReservedStack/ReservedStackTest.java
+++ b/hotspot/test/runtime/ReservedStack/ReservedStackTest.java
@@ -24,6 +24,7 @@
 /*
  * @test ReservedStackTest
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @build jdk.test.lib.*
  * @run main/othervm -XX:-Inline -XX:CompileCommand=exclude,java/util/concurrent/locks/AbstractOwnableSynchronizer.setExclusiveOwnerThread ReservedStackTest
diff --git a/hotspot/test/runtime/SameObject/SameObject.java b/hotspot/test/runtime/SameObject/SameObject.java
index 14ca516..10bb41d 100644
--- a/hotspot/test/runtime/SameObject/SameObject.java
+++ b/hotspot/test/runtime/SameObject/SameObject.java
@@ -30,6 +30,7 @@
  * @summary -Xcheck:jni overly strict in JNI method IsSameObject
  *          Fixed in JDK1.3.1_10
  *          Fixed in JDK1.4.1_07
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm/native -Xcheck:jni SameObject
  */
diff --git a/hotspot/test/runtime/SharedArchiveFile/BasicJarBuilder.java b/hotspot/test/runtime/SharedArchiveFile/BasicJarBuilder.java
deleted file mode 100644
index ab8955c..0000000
--- a/hotspot/test/runtime/SharedArchiveFile/BasicJarBuilder.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @summary Simple jar builder
- *   Input: jarName className1 className2 ...
- *     do not specify extensions, just the names
- *     E.g. prot_domain ProtDomainA ProtDomainB
- *   Output: A jar containing compiled classes, placed in a test classes folder
- */
-
-import jdk.test.lib.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import sun.tools.jar.Main;
-
-// Using JarBuilder requires that all to-be-jarred classes should be placed
-// in the current working directory, aka "."
-public class BasicJarBuilder {
-    private static final String classDir = System.getProperty("test.classes");
-
-    public static void build(boolean classesInWorkDir, String jarName,
-        String ...classNames) throws Exception {
-
-        if (classesInWorkDir) {
-            createSimpleJar(".", classDir + File.separator + jarName + ".jar", classNames);
-        } else {
-            build(jarName, classNames);
-        }
-    }
-
-    public static void build(String jarName, String ...classNames) throws Exception {
-        createSimpleJar(classDir, classDir + File.separator + jarName + ".jar",
-            classNames);
-    }
-
-    private static void createSimpleJar(String jarclassDir, String jarName,
-        String[] classNames) throws Exception {
-        ArrayList<String> args = new ArrayList<String>();
-        args.add("cf");
-        args.add(jarName);
-        addClassArgs(args, jarclassDir, classNames);
-        createJar(args);
-    }
-
-    private static void addClassArgs(ArrayList<String> args, String jarclassDir,
-        String[] classNames) {
-
-        for (String name : classNames) {
-            args.add("-C");
-            args.add(jarclassDir);
-            args.add(name + ".class");
-        }
-    }
-
-    private static void createJar(ArrayList<String> args) {
-        Main jarTool = new Main(System.out, System.err, "jar");
-        if (!jarTool.run(args.toArray(new String[1]))) {
-            throw new RuntimeException("jar operation failed");
-        }
-    }
-
-    // Get full path to the test jar
-    public static String getTestJar(String jar) {
-        File dir = new File(System.getProperty("test.classes", "."));
-        File jarFile = new File(dir, jar);
-        if (!jarFile.exists()) {
-            throw new RuntimeException("Cannot find " + jarFile.getPath());
-        }
-        if (!jarFile.isFile()) {
-            throw new RuntimeException("Not a regular file: " + jarFile.getPath());
-        }
-        return jarFile.getPath();
-    }
-}
diff --git a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java
index efc95b9..502adcf 100644
--- a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java
+++ b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java
@@ -154,7 +154,7 @@
                 APP_CLASS,
                 BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
             OutputAnalyzer output = new OutputAnalyzer(pb.start());
-            output.shouldContain("[classload] org.omg.CORBA.Context source: jrt:/java.corba");
+            output.shouldContain("[class,load] org.omg.CORBA.Context source: jrt:/java.corba");
         }
     }
 
@@ -179,11 +179,11 @@
                 APP_CLASS,
                 BOOT_APPEND_MODULE_CLASS_NAME);
             OutputAnalyzer output = new OutputAnalyzer(pb.start());
-            output.shouldContain("[classload] javax.sound.sampled.MyClass");
+            output.shouldContain("[class,load] javax.sound.sampled.MyClass");
 
             // When CDS is enabled, the shared class should be loaded from the archive.
             if (mode.equals("on")) {
-                output.shouldContain("[classload] javax.sound.sampled.MyClass source: shared objects file");
+                output.shouldContain("[class,load] javax.sound.sampled.MyClass source: shared objects file");
             }
         }
     }
@@ -211,8 +211,8 @@
                 APP_CLASS,
                 BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
             OutputAnalyzer output = new OutputAnalyzer(pb.start());
-            output.shouldContain("[classload] org.omg.CORBA.Context");
-            output.shouldMatch(".*\\[classload\\] org.omg.CORBA.Context source:.*bootAppend.jar");
+            output.shouldContain("[class,load] org.omg.CORBA.Context");
+            output.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar");
         }
     }
 
@@ -235,13 +235,13 @@
                 APP_CLASS,
                 BOOT_APPEND_CLASS_NAME);
             OutputAnalyzer output = new OutputAnalyzer(pb.start());
-            output.shouldContain("[classload] nonjdk.myPackage.MyClass");
+            output.shouldContain("[class,load] nonjdk.myPackage.MyClass");
 
             // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded
             // from the shared archive.
             if (mode.equals("on")) {
                 output.shouldContain(
-                    "[classload] nonjdk.myPackage.MyClass source: shared objects file");
+                    "[class,load] nonjdk.myPackage.MyClass source: shared objects file");
             }
         }
     }
diff --git a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java
index 1d30fd6..4d24b54 100644
--- a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java
+++ b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java
@@ -36,7 +36,7 @@
 public class DumpSymbolAndStringTable {
     public static void main(String[] args) throws Exception {
         // Grab my own PID
-        String pid = Integer.toString(ProcessTools.getProcessId());
+        String pid = Long.toString(ProcessTools.getProcessId());
 
         ProcessBuilder pb = new ProcessBuilder();
         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.symboltable", "-verbose"});
diff --git a/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java b/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java
index 32dfb2a..47304b4 100644
--- a/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java
+++ b/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java
@@ -125,7 +125,7 @@
 
         // test with sizes which just meet the minimum required sizes
         // the following tests also attempt to use the shared archive
-        new SharedSizeTestData(Region.RO, Platform.is64bit() ? "9M":"8M", Result.VALID_ARCHIVE),
+        new SharedSizeTestData(Region.RO, Platform.is64bit() ? "10M":"9M", Result.VALID_ARCHIVE),
         new SharedSizeTestData(Region.RW, Platform.is64bit() ? "12M":"7M", Result.VALID_ARCHIVE),
         new SharedSizeTestData(Region.MD, Platform.is64bit() ? "4M":"2M", Result.VALID_ARCHIVE),
         new SharedSizeTestData(Region.MC, "120k", Result.VALID_ARCHIVE),
@@ -176,7 +176,7 @@
                                output.getOutput().contains("Unable to reserve shared space at required address")) &&
                                output.getExitValue() == 1) {
                                System.out.println("Unable to use shared archive: test not executed; assumed passed");
-                               return;
+                               continue;
                           }
                       }
                       output.shouldHaveExitValue(0);
diff --git a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java
new file mode 100644
index 0000000..2cd8453
--- /dev/null
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test SASymbolTableTest
+ * @summary Walk symbol table using SA, with and without CDS.
+ * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ *          jdk.hotspot.agent/sun.jvm.hotspot.oops
+ *          jdk.hotspot.agent/sun.jvm.hotspot.memory
+ *          jdk.hotspot.agent/sun.jvm.hotspot.runtime
+ *          jdk.hotspot.agent/sun.jvm.hotspot.tools
+ *          java.management
+ * @build SASymbolTableTestAgent SASymbolTableTestAttachee jdk.test.lib.*
+ * @run main SASymbolTableTest
+ */
+
+import jdk.test.lib.*;
+
+/*
+ * The purpose of this test is to validate that we can use SA to
+ * attach a process and walk its SymbolTable, regardless whether
+ * the attachee process runs in CDS mode or not.
+ *
+ * SASymbolTableTest Just sets up the agent and attachee processes.
+ * The SymbolTable walking is done in the SASymbolTableTestAgent class.
+ */
+public class SASymbolTableTest {
+    static String jsaName = "./SASymbolTableTest.jsa";
+
+    public static void main(String[] args) throws Exception {
+        if (!Platform.shouldSAAttach()) {
+            System.out.println("SA attach not expected to work - test skipped.");
+            return;
+        }
+        createArchive();
+        run(true);
+        run(false);
+    }
+
+    private static void createArchive()  throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+UnlockDiagnosticVMOptions",
+            "-XX:SharedArchiveFile=" + jsaName,
+            "-Xshare:dump");
+
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("Loading classes to share");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static void run(boolean useArchive) throws Exception {
+        String flag = useArchive ? "auto" : "off";
+
+        // (1) Launch the attachee process
+        ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder(
+            "-XX:+UnlockDiagnosticVMOptions",
+            "-XX:SharedArchiveFile=" + jsaName,
+            "-Xshare:" + flag,
+            "-showversion",                // so we can see "sharing" in the output
+            "SASymbolTableTestAttachee");
+
+        final Process p = attachee.start();
+
+        // (2) Launch the agent process
+        long pid = p.getPid();
+        System.out.println("Attaching agent " + pid);
+        ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
+            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
+            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
+            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
+            "SASymbolTableTestAgent",
+            Long.toString(pid));
+        OutputAnalyzer output = ProcessTools.executeProcess(tool);
+        System.out.println(output.getOutput());
+        output.shouldHaveExitValue(0);
+
+        Thread t = new Thread() {
+                public void run() {
+                    try {
+                        OutputAnalyzer output = new OutputAnalyzer(p);
+                        System.out.println("STDOUT[");
+                        System.out.print(output.getStdout());
+                        System.out.println("]");
+                        System.out.println("STDERR[");
+                        System.out.print(output.getStderr());
+                        System.out.println("]");
+                    } catch (Throwable t) {
+                        t.printStackTrace();
+                    }
+                }
+            };
+        t.start();
+
+        Thread.sleep(2 * 1000);
+        p.destroy();
+        t.join();
+    }
+}
diff --git a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java
new file mode 100644
index 0000000..4c5193f
--- /dev/null
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import sun.jvm.hotspot.memory.SymbolTable;
+import sun.jvm.hotspot.oops.Symbol;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.tools.Tool;
+
+/**
+ * This class is launched in a sub-process by the main test,
+ * SASymbolTableTest.java.
+ *
+ * It uses SA to connect to another JVM process, whose PID is specified in args[].
+ * The purpose of the test is to validate that we can walk the SymbolTable
+ * and CompactHashTable of the other process. Everything should work regardless
+ * of whether the other process runs in CDS mode or not.
+ *
+ * Note: CompactHashTable is used only when CDS is enabled.
+ */
+public class SASymbolTableTestAgent extends Tool {
+    public SASymbolTableTestAgent() {
+        super();
+    }
+    public static void main(String args[]) {
+        SASymbolTableTestAgent tool = new SASymbolTableTestAgent();
+        tool.execute(args);
+    }
+
+    static String[] commonNames = {
+        "java/lang/Object",
+        "java/lang/String",
+        "java/lang/Class",
+        "java/lang/Cloneable",
+        "java/lang/ClassLoader",
+        "java/io/Serializable",
+        "java/lang/System",
+        "java/lang/Throwable",
+        "java/lang/Error",
+        "java/lang/ThreadDeath",
+        "java/lang/Exception",
+        "java/lang/RuntimeException",
+        "java/lang/SecurityManager",
+        "java/security/ProtectionDomain",
+        "java/security/AccessControlContext",
+        "java/security/SecureClassLoader",
+        "java/lang/ClassNotFoundException",
+        "java/lang/NoClassDefFoundError",
+        "java/lang/LinkageError",
+        "java/lang/ClassCastException",
+        "java/lang/ArrayStoreException",
+        "java/lang/VirtualMachineError",
+        "java/lang/OutOfMemoryError",
+        "java/lang/StackOverflowError",
+        "java/lang/IllegalMonitorStateException",
+        "java/lang/ref/Reference",
+        "java/lang/ref/SoftReference",
+        "java/lang/ref/WeakReference",
+        "java/lang/ref/FinalReference",
+        "java/lang/ref/PhantomReference",
+        "java/lang/ref/Finalizer",
+        "java/lang/Thread",
+        "java/lang/ThreadGroup",
+        "java/util/Properties",
+        "java/lang/reflect/AccessibleObject",
+        "java/lang/reflect/Field",
+        "java/lang/reflect/Method",
+        "java/lang/reflect/Constructor",
+        "java/lang/invoke/MethodHandle",
+        "java/lang/invoke/MemberName",
+        "java/lang/invoke/MethodHandleNatives",
+        "java/lang/invoke/MethodType",
+        "java/lang/BootstrapMethodError",
+        "java/lang/invoke/CallSite",
+        "java/lang/invoke/ConstantCallSite",
+        "java/lang/invoke/MutableCallSite",
+        "java/lang/invoke/VolatileCallSite",
+        "java/lang/StringBuffer",
+        "java/lang/StringBuilder",
+        "java/io/ByteArrayInputStream",
+        "java/io/File",
+        "java/net/URLClassLoader",
+        "java/net/URL",
+        "java/util/jar/Manifest",
+        "java/security/CodeSource",
+    };
+
+    static String[] badNames = {
+        "java/lang/badbadbad",
+        "java/io/badbadbadbad",
+        "this*symbol*must*not*exist"
+    };
+
+    public void run() {
+        System.out.println("SASymbolTableTestAgent: starting");
+        VM vm = VM.getVM();
+        SymbolTable table = vm.getSymbolTable();
+
+        // (a) These are names that are likely to exist in the symbol table
+        //     of a JVM after start-up. They were taken from vmSymbols.hpp
+        //     during the middle of JDK9 development.
+        //
+        //     The purpose is not to check that each name must exist (a future
+        //     version of JDK may not preload some of the classes).
+        //
+        //     The purpose of this loops is to ensure that we check a lot of symbols,
+        //     so we will (most likely) hit on both VALUE_ONLY_BUCKET_TYPE and normal bucket type
+        //     in CompactHashTable.probe().
+        for (String n : commonNames) {
+            Symbol s = table.probe(n);
+            System.out.format("%-40s = %s\n", n, s);
+        }
+
+        System.out.println("======================================================================");
+
+        // (b) Also test a few strings that are known to not exist in the table. This will
+        //     both the compact table (if it exists) and the regular table to be walked.
+        for (String n : badNames) {
+            Symbol s = table.probe(n);
+            System.out.format("%-40s = %s\n", n, s);
+        }
+    }
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java
similarity index 60%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java
index 9e5a4a7..e08d1a5 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -22,16 +20,19 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
-
-import java.util.Properties;
 
 /**
- * Interface to plugin (container) context.
+ * This class is launched in a sub-process by the main test,
+ * SASymbolTableTest.java.
+ *
+ * This class does nothing in particular. It just sleeps for 120
+ * seconds so SASymbolTableTestAgent can have a chance to examine its
+ * SymbolTable. This process should be killed by the parent process
+ * after SASymbolTableTestAgent has completed testing.
  */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+public class SASymbolTableTestAttachee {
+    public static void main(String args[]) throws Throwable {
+        System.out.println("SASymbolTableTestAttachee: sleeping to wait for SA tool to attach ...");
+        Thread.sleep(120 * 1000);
+    }
 }
diff --git a/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java b/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java
index ed2b3e3..ec7bf3aa 100644
--- a/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java
+++ b/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java
@@ -40,37 +40,51 @@
 
 public class SharedStrings {
     public static void main(String[] args) throws Exception {
+        boolean test_runtime = true;
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-XX:+UnlockDiagnosticVMOptions",
             "-XX:SharedArchiveFile=./SharedStrings.jsa",
+            "-XX:+UseG1GC",
+            "-XX:+UseCompressedOops",
             "-XX:+PrintSharedSpaces",
             // Needed for bootclasspath match, for CDS to work with WhiteBox API
             "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"),
             "-Xshare:dump");
 
-        new OutputAnalyzer(pb.start())
-            .shouldContain("Loading classes to share")
-            .shouldContain("Shared string table stats")
-            .shouldHaveExitValue(0);
-
-        pb = ProcessTools.createJavaProcessBuilder(
-            "-XX:+UnlockDiagnosticVMOptions",
-            "-XX:SharedArchiveFile=./SharedStrings.jsa",
-            // these are required modes for shared strings
-            "-XX:+UseCompressedOops", "-XX:+UseG1GC",
-            // needed for access to white box test API
-            "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"),
-            "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
-            "-Xshare:on", "-showversion", "SharedStringsWb");
-
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
-
+        OutputAnalyzer dumpOutput = new OutputAnalyzer(pb.start());
         try {
-            output.shouldContain("sharing");
-            output.shouldHaveExitValue(0);
+            dumpOutput.shouldContain("Loading classes to share");
+            dumpOutput.shouldContain("Shared string table stats");
+            dumpOutput.shouldHaveExitValue(0);
         } catch (RuntimeException e) {
-            output.shouldContain("Unable to use shared archive");
-            output.shouldHaveExitValue(1);
+            if (dumpOutput.getOutput().indexOf("Shared strings are excluded") != -1 ||
+                dumpOutput.getOutput().indexOf("Cannot dump shared archive") != -1) {
+                test_runtime = false;
+            } else {
+                throw new RuntimeException("Unexpected failure");
+            }
+        }
+
+        if (test_runtime) {
+            pb = ProcessTools.createJavaProcessBuilder(
+                "-XX:+UnlockDiagnosticVMOptions",
+                "-XX:SharedArchiveFile=./SharedStrings.jsa",
+                // these are required modes for shared strings
+                "-XX:+UseCompressedOops", "-XX:+UseG1GC",
+                // needed for access to white box test API
+                "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"),
+                "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
+                "-Xshare:on", "-showversion", "SharedStringsWb");
+
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+
+            try {
+                output.shouldContain("sharing");
+                output.shouldHaveExitValue(0);
+            } catch (RuntimeException e) {
+                output.shouldContain("Unable to use shared archive");
+                output.shouldHaveExitValue(1);
+            }
         }
     }
 }
diff --git a/hotspot/test/runtime/Thread/Fibonacci.java b/hotspot/test/runtime/Thread/Fibonacci.java
index c8bbed1..65ae1c3 100644
--- a/hotspot/test/runtime/Thread/Fibonacci.java
+++ b/hotspot/test/runtime/Thread/Fibonacci.java
@@ -28,6 +28,7 @@
  *     This test is skipped on 32-bit Windows: limited virtual space on Win-32
  *     make this test inherently unstable on Windows with 32-bit VM data model.
  * @requires !(os.family == "windows" & sun.arch.data.model == "32")
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm Fibonacci 15
  */
diff --git a/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java b/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java
index 39af699..1670b02 100644
--- a/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java
+++ b/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java
@@ -36,6 +36,7 @@
  * @bug 4345157
  * @summary JDK 1.3.0 alters thread signal mask
  * @requires (os.simpleArch == "sparcv9")
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile Prog.java
  * @run main/native ThreadSignalMask
diff --git a/hotspot/test/runtime/Throwable/TestThrowable.java b/hotspot/test/runtime/Throwable/TestThrowable.java
index f3cb1ad..9cdef2d 100644
--- a/hotspot/test/runtime/Throwable/TestThrowable.java
+++ b/hotspot/test/runtime/Throwable/TestThrowable.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8150778
  * @summary Test exception depths, and code to get stack traces
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm -XX:MaxJavaStackTraceDepth=1024 TestThrowable
  */
diff --git a/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java b/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java
index fd4be6c..71f1dc2 100644
--- a/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java
+++ b/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8033735
  * @summary check backtrace field introspection
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main ThrowableIntrospectionSegfault
  */
diff --git a/hotspot/test/runtime/Unsafe/AllocateInstance.java b/hotspot/test/runtime/Unsafe/AllocateInstance.java
index e9748e5..6b283d3 100644
--- a/hotspot/test/runtime/Unsafe/AllocateInstance.java
+++ b/hotspot/test/runtime/Unsafe/AllocateInstance.java
@@ -31,7 +31,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class AllocateInstance {
diff --git a/hotspot/test/runtime/Unsafe/AllocateMemory.java b/hotspot/test/runtime/Unsafe/AllocateMemory.java
index 0af6fcb..d9f8a12 100644
--- a/hotspot/test/runtime/Unsafe/AllocateMemory.java
+++ b/hotspot/test/runtime/Unsafe/AllocateMemory.java
@@ -32,7 +32,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class AllocateMemory {
diff --git a/hotspot/test/runtime/Unsafe/CopyMemory.java b/hotspot/test/runtime/Unsafe/CopyMemory.java
index ef67517..e2328d3 100644
--- a/hotspot/test/runtime/Unsafe/CopyMemory.java
+++ b/hotspot/test/runtime/Unsafe/CopyMemory.java
@@ -31,7 +31,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class CopyMemory {
diff --git a/hotspot/test/runtime/Unsafe/DefineClass.java b/hotspot/test/runtime/Unsafe/DefineClass.java
index bf10a39..fa0d3b6 100644
--- a/hotspot/test/runtime/Unsafe/DefineClass.java
+++ b/hotspot/test/runtime/Unsafe/DefineClass.java
@@ -34,7 +34,7 @@
 import java.security.ProtectionDomain;
 import java.io.InputStream;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class DefineClass {
diff --git a/hotspot/test/runtime/Unsafe/FieldOffset.java b/hotspot/test/runtime/Unsafe/FieldOffset.java
index 6bbd785..abf62fc 100644
--- a/hotspot/test/runtime/Unsafe/FieldOffset.java
+++ b/hotspot/test/runtime/Unsafe/FieldOffset.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.lang.reflect.*;
 import static jdk.test.lib.Asserts.*;
 
diff --git a/hotspot/test/runtime/Unsafe/GetField.java b/hotspot/test/runtime/Unsafe/GetField.java
index 48e71b5..f01d5de 100644
--- a/hotspot/test/runtime/Unsafe/GetField.java
+++ b/hotspot/test/runtime/Unsafe/GetField.java
@@ -31,7 +31,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.lang.reflect.*;
 import static jdk.test.lib.Asserts.*;
 
diff --git a/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java b/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java
index f1fc7d5..7a53be5 100644
--- a/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java
+++ b/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java
@@ -32,7 +32,7 @@
 import static jdk.test.lib.Asserts.*;
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class GetKlassPointerGetJavaMirror {
 
diff --git a/hotspot/test/runtime/Unsafe/GetPutAddress.java b/hotspot/test/runtime/Unsafe/GetPutAddress.java
index 9650d04..1dd0a18 100644
--- a/hotspot/test/runtime/Unsafe/GetPutAddress.java
+++ b/hotspot/test/runtime/Unsafe/GetPutAddress.java
@@ -31,7 +31,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutAddress {
diff --git a/hotspot/test/runtime/Unsafe/GetPutBoolean.java b/hotspot/test/runtime/Unsafe/GetPutBoolean.java
index eddbc6c..51e59cf 100644
--- a/hotspot/test/runtime/Unsafe/GetPutBoolean.java
+++ b/hotspot/test/runtime/Unsafe/GetPutBoolean.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutBoolean {
diff --git a/hotspot/test/runtime/Unsafe/GetPutByte.java b/hotspot/test/runtime/Unsafe/GetPutByte.java
index ec08dd2..48f4700 100644
--- a/hotspot/test/runtime/Unsafe/GetPutByte.java
+++ b/hotspot/test/runtime/Unsafe/GetPutByte.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutByte {
diff --git a/hotspot/test/runtime/Unsafe/GetPutChar.java b/hotspot/test/runtime/Unsafe/GetPutChar.java
index 79e94f0..86b5c80 100644
--- a/hotspot/test/runtime/Unsafe/GetPutChar.java
+++ b/hotspot/test/runtime/Unsafe/GetPutChar.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutChar {
diff --git a/hotspot/test/runtime/Unsafe/GetPutDouble.java b/hotspot/test/runtime/Unsafe/GetPutDouble.java
index b1d7431..1073c8e 100644
--- a/hotspot/test/runtime/Unsafe/GetPutDouble.java
+++ b/hotspot/test/runtime/Unsafe/GetPutDouble.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutDouble {
diff --git a/hotspot/test/runtime/Unsafe/GetPutFloat.java b/hotspot/test/runtime/Unsafe/GetPutFloat.java
index 16de792..f49ac75 100644
--- a/hotspot/test/runtime/Unsafe/GetPutFloat.java
+++ b/hotspot/test/runtime/Unsafe/GetPutFloat.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutFloat {
diff --git a/hotspot/test/runtime/Unsafe/GetPutInt.java b/hotspot/test/runtime/Unsafe/GetPutInt.java
index 0a44036..49f82d5 100644
--- a/hotspot/test/runtime/Unsafe/GetPutInt.java
+++ b/hotspot/test/runtime/Unsafe/GetPutInt.java
@@ -31,7 +31,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutInt {
diff --git a/hotspot/test/runtime/Unsafe/GetPutLong.java b/hotspot/test/runtime/Unsafe/GetPutLong.java
index 2c524e2..8336c85 100644
--- a/hotspot/test/runtime/Unsafe/GetPutLong.java
+++ b/hotspot/test/runtime/Unsafe/GetPutLong.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutLong {
diff --git a/hotspot/test/runtime/Unsafe/GetPutObject.java b/hotspot/test/runtime/Unsafe/GetPutObject.java
index e4add8f..6607db3 100644
--- a/hotspot/test/runtime/Unsafe/GetPutObject.java
+++ b/hotspot/test/runtime/Unsafe/GetPutObject.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutObject {
diff --git a/hotspot/test/runtime/Unsafe/GetPutShort.java b/hotspot/test/runtime/Unsafe/GetPutShort.java
index f7b94fb..2ede76c 100644
--- a/hotspot/test/runtime/Unsafe/GetPutShort.java
+++ b/hotspot/test/runtime/Unsafe/GetPutShort.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetPutShort {
diff --git a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java
index 9673c75..dc72a5e 100644
--- a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java
+++ b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java
@@ -32,7 +32,7 @@
 import static jdk.test.lib.Asserts.*;
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class GetUncompressedObject {
 
diff --git a/hotspot/test/runtime/Unsafe/GetUnsafe.java b/hotspot/test/runtime/Unsafe/GetUnsafe.java
index 8cb95f5..64ad19d 100644
--- a/hotspot/test/runtime/Unsafe/GetUnsafe.java
+++ b/hotspot/test/runtime/Unsafe/GetUnsafe.java
@@ -29,7 +29,7 @@
  * @run main GetUnsafe
  */
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class GetUnsafe {
diff --git a/hotspot/test/runtime/Unsafe/PageSize.java b/hotspot/test/runtime/Unsafe/PageSize.java
index 6b29f6d..6ce5a1c 100644
--- a/hotspot/test/runtime/Unsafe/PageSize.java
+++ b/hotspot/test/runtime/Unsafe/PageSize.java
@@ -32,7 +32,7 @@
 
 import java.lang.reflect.Field;
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class PageSize {
diff --git a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java
index 5405d4b..f081efc 100644
--- a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java
+++ b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java
@@ -25,7 +25,7 @@
 import java.lang.reflect.Field;
 import static jdk.internal.org.objectweb.asm.Opcodes.*;
 import jdk.internal.org.objectweb.asm.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /*
  * @test PrimitiveHostClass
diff --git a/hotspot/test/runtime/Unsafe/RangeCheck.java b/hotspot/test/runtime/Unsafe/RangeCheck.java
index ecd413c..0e9b914 100644
--- a/hotspot/test/runtime/Unsafe/RangeCheck.java
+++ b/hotspot/test/runtime/Unsafe/RangeCheck.java
@@ -31,7 +31,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 public class RangeCheck {
 
@@ -44,6 +44,7 @@
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                 true,
                 "-Xmx32m",
+                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:-TransmitErrorReport",
                 "-XX:-CreateCoredumpOnCrash",
                 "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert
diff --git a/hotspot/test/runtime/Unsafe/Reallocate.java b/hotspot/test/runtime/Unsafe/Reallocate.java
index 10992fc..b2fe5d9 100644
--- a/hotspot/test/runtime/Unsafe/Reallocate.java
+++ b/hotspot/test/runtime/Unsafe/Reallocate.java
@@ -32,7 +32,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class Reallocate {
diff --git a/hotspot/test/runtime/Unsafe/SetMemory.java b/hotspot/test/runtime/Unsafe/SetMemory.java
index e199196..8ff36cc 100644
--- a/hotspot/test/runtime/Unsafe/SetMemory.java
+++ b/hotspot/test/runtime/Unsafe/SetMemory.java
@@ -31,7 +31,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class SetMemory {
diff --git a/hotspot/test/runtime/Unsafe/ThrowException.java b/hotspot/test/runtime/Unsafe/ThrowException.java
index 957be3c..c263aa1 100644
--- a/hotspot/test/runtime/Unsafe/ThrowException.java
+++ b/hotspot/test/runtime/Unsafe/ThrowException.java
@@ -31,7 +31,7 @@
  */
 
 import jdk.test.lib.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import static jdk.test.lib.Asserts.*;
 
 public class ThrowException {
diff --git a/hotspot/test/runtime/contended/Basic.java b/hotspot/test/runtime/contended/Basic.java
index bf64e94..5ffba1a 100644
--- a/hotspot/test/runtime/contended/Basic.java
+++ b/hotspot/test/runtime/contended/Basic.java
@@ -35,13 +35,14 @@
 import java.util.regex.Pattern;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import jdk.internal.vm.annotation.Contended;
 
 /*
  * @test
  * @bug     8003985
  * @summary Support Contended Annotation - JEP 142
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @run main/othervm -XX:-RestrictContended Basic
  */
diff --git a/hotspot/test/runtime/contended/DefaultValue.java b/hotspot/test/runtime/contended/DefaultValue.java
index 8ed4f06..b61ab3d 100644
--- a/hotspot/test/runtime/contended/DefaultValue.java
+++ b/hotspot/test/runtime/contended/DefaultValue.java
@@ -35,7 +35,7 @@
 import java.util.regex.Pattern;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import jdk.internal.vm.annotation.Contended;
 
 /*
@@ -43,6 +43,7 @@
  * @bug     8014509
  * @summary \@Contended: explicit default value behaves differently from the implicit value
  *
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @run main/othervm -XX:-RestrictContended DefaultValue
  */
diff --git a/hotspot/test/runtime/contended/HasNonStatic.java b/hotspot/test/runtime/contended/HasNonStatic.java
index 3e07c09..04f2fb8 100644
--- a/hotspot/test/runtime/contended/HasNonStatic.java
+++ b/hotspot/test/runtime/contended/HasNonStatic.java
@@ -35,7 +35,7 @@
 import java.util.regex.Pattern;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import jdk.internal.vm.annotation.Contended;
 
 /*
@@ -43,6 +43,7 @@
  * @bug     8015270
  * @summary \@Contended: fix multiple issues in the layout code
  *
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @run main/othervm -XX:-RestrictContended HasNonStatic
  */
diff --git a/hotspot/test/runtime/contended/Inheritance1.java b/hotspot/test/runtime/contended/Inheritance1.java
index f333361..57dec49 100644
--- a/hotspot/test/runtime/contended/Inheritance1.java
+++ b/hotspot/test/runtime/contended/Inheritance1.java
@@ -35,7 +35,7 @@
 import java.util.regex.Pattern;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import jdk.internal.vm.annotation.Contended;
 
 /*
@@ -43,6 +43,7 @@
  * @bug     8012939
  * @summary \@Contended doesn't work correctly with inheritance
  *
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.vm.annotation
  * @run main/othervm -XX:-RestrictContended Inheritance1
  */
diff --git a/hotspot/test/runtime/contended/OopMaps.java b/hotspot/test/runtime/contended/OopMaps.java
index 27d5ba8..a3b3e01 100644
--- a/hotspot/test/runtime/contended/OopMaps.java
+++ b/hotspot/test/runtime/contended/OopMaps.java
@@ -35,7 +35,6 @@
 import java.util.regex.Pattern;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import sun.misc.Unsafe;
 import jdk.internal.vm.annotation.Contended;
 
 /*
diff --git a/hotspot/test/runtime/contended/OopMapsSameGroup.java b/hotspot/test/runtime/contended/OopMapsSameGroup.java
index 6975fd3..5adb012 100644
--- a/hotspot/test/runtime/contended/OopMapsSameGroup.java
+++ b/hotspot/test/runtime/contended/OopMapsSameGroup.java
@@ -35,7 +35,6 @@
 import java.util.regex.Pattern;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import sun.misc.Unsafe;
 import jdk.internal.vm.annotation.Contended;
 
 /*
diff --git a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java
index 94b6368..04916a3 100644
--- a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java
+++ b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.loader
  *          java.desktop
  * @library /testlibrary
diff --git a/hotspot/test/runtime/interned/SanityTest.java b/hotspot/test/runtime/interned/SanityTest.java
index 6f07b0c..c0f2f72 100644
--- a/hotspot/test/runtime/interned/SanityTest.java
+++ b/hotspot/test/runtime/interned/SanityTest.java
@@ -24,6 +24,7 @@
 /*
  * @test SanityTest
  * @summary Sanity check of String.intern() & GC
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build SanityTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java b/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java
index e9a8406..49201a7 100644
--- a/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java
+++ b/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java
@@ -27,6 +27,7 @@
  * @bug 8141445
  * @summary make sure the Solaris Sparc M7 libadimalloc.so library generates SIGSEGV's on buffer overflow
  * @requires (os.family == "solaris" & os.arch == "sparcv9")
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.*
  * @compile SEGVOverflow.java
diff --git a/hotspot/test/runtime/logging/ClassInitializationTest.java b/hotspot/test/runtime/logging/ClassInitializationTest.java
index a95cc48..9ffd4d2 100644
--- a/hotspot/test/runtime/logging/ClassInitializationTest.java
+++ b/hotspot/test/runtime/logging/ClassInitializationTest.java
@@ -25,6 +25,7 @@
 /*
  * @test ClassInitializationTest
  * @bug 8142976
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile BadMap50.jasm
  * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools
@@ -40,7 +41,7 @@
     public static void main(String... args) throws Exception {
 
         // (1)
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info",
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=info",
                                                                   "-Xverify:all",
                                                                   "-Xmx64m",
                                                                   "BadMap50");
@@ -53,7 +54,7 @@
 
         // (2)
         if (Platform.isDebugBuild()) {
-            pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info",
+            pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=info",
                                                        "-Xverify:all",
                                                        "-XX:+EagerInitialization",
                                                        "-Xmx64m",
@@ -63,13 +64,13 @@
             out.shouldHaveExitValue(0);
         }
 
-        // (3) classinit should turn off.
-        pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=off",
+        // (3) class+init should turn off.
+        pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=off",
                                                    "-Xverify:all",
                                                    "-Xmx64m",
                                                    "BadMap50");
         out = new OutputAnalyzer(pb.start());
-        out.shouldNotContain("[classinit]");
+        out.shouldNotContain("[class,init]");
         out.shouldNotContain("Fail over class verification to old verifier for: BadMap50");
 
     }
diff --git a/hotspot/test/runtime/logging/ClassLoadUnloadTest.java b/hotspot/test/runtime/logging/ClassLoadUnloadTest.java
index 85cf5cb..e9c5d97 100644
--- a/hotspot/test/runtime/logging/ClassLoadUnloadTest.java
+++ b/hotspot/test/runtime/logging/ClassLoadUnloadTest.java
@@ -25,6 +25,7 @@
 /*
  * @test ClassLoadUnloadTest
  * @bug 8142506
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /runtime/testlibrary
  * @library classes
  * @build ClassUnloadCommon test.Empty jdk.test.lib.* jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
@@ -79,50 +80,50 @@
 
     public static void main(String... args) throws Exception {
 
-        //  -Xlog:classunload=info
-        pb = exec("-Xlog:classunload=info");
-        checkFor("[classunload]", "unloading class");
+        //  -Xlog:class+unload=info
+        pb = exec("-Xlog:class+unload=info");
+        checkFor("[class,unload]", "unloading class");
 
-        //  -Xlog:classunload=off
-        pb = exec("-Xlog:classunload=off");
-        checkAbsent("[classunload]");
+        //  -Xlog:class+unload=off
+        pb = exec("-Xlog:class+unload=off");
+        checkAbsent("[class,unload]");
 
         //  -XX:+TraceClassUnloading
         pb = exec("-XX:+TraceClassUnloading");
-        checkFor("[classunload]", "unloading class");
+        checkFor("[class,unload]", "unloading class");
 
         //  -XX:-TraceClassUnloading
         pb = exec("-XX:-TraceClassUnloading");
-        checkAbsent("[classunload]");
+        checkAbsent("[class,unload]");
 
-        //  -Xlog:classload=info
-        pb = exec("-Xlog:classload=info");
-        checkFor("[classload]", "java.lang.Object", "source:");
+        //  -Xlog:class+load=info
+        pb = exec("-Xlog:class+load=info");
+        checkFor("[class,load]", "java.lang.Object", "source:");
 
-        //  -Xlog:classload=debug
-        pb = exec("-Xlog:classload=debug");
-        checkFor("[classload]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:");
+        //  -Xlog:class+load=debug
+        pb = exec("-Xlog:class+load=debug");
+        checkFor("[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:");
 
-        //  -Xlog:classload=off
-        pb = exec("-Xlog:classload=off");
-        checkAbsent("[classload]");
+        //  -Xlog:class+load=off
+        pb = exec("-Xlog:class+load=off");
+        checkAbsent("[class,load]");
 
         //  -XX:+TraceClassLoading
         pb = exec("-XX:+TraceClassLoading");
-        checkFor("[classload]", "java.lang.Object", "source:");
+        checkFor("[class,load]", "java.lang.Object", "source:");
 
         //  -XX:-TraceClassLoading
         pb = exec("-XX:-TraceClassLoading");
-        checkAbsent("[classload]");
+        checkAbsent("[class,load]");
 
         //  -verbose:class
         pb = exec("-verbose:class");
-        checkFor("[classload]", "java.lang.Object", "source:");
-        checkFor("[classunload]", "unloading class");
+        checkFor("[class,load]", "java.lang.Object", "source:");
+        checkFor("[class,unload]", "unloading class");
 
-        //  -Xlog:classloaderdata=trace
-        pb = exec("-Xlog:classloaderdata=trace");
-        checkFor("[classloaderdata]", "create class loader data");
+        //  -Xlog:class+loader+data=trace
+        pb = exec("-Xlog:class+loader+data=trace");
+        checkFor("[class,loader,data]", "create class loader data");
 
     }
 }
diff --git a/hotspot/test/runtime/logging/ClassResolutionTest.java b/hotspot/test/runtime/logging/ClassResolutionTest.java
index 700fc77..ceebd4c 100644
--- a/hotspot/test/runtime/logging/ClassResolutionTest.java
+++ b/hotspot/test/runtime/logging/ClassResolutionTest.java
@@ -25,6 +25,7 @@
 /*
  * @test ClassResolutionTest
  * @bug 8144874
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
  * @run driver ClassResolutionTest
@@ -58,32 +59,32 @@
 
     public static void main(String... args) throws Exception {
 
-        // (1) classresolve should turn on.
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classresolve=debug",
+        // (1) class+resolve should turn on.
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug",
                                                                   ClassResolutionTestMain.class.getName());
         OutputAnalyzer o = new OutputAnalyzer(pb.start());
-        o.shouldContain("[classresolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1");
-        o.shouldContain("[classresolve] resolve JVM_CONSTANT_MethodHandle");
+        o.shouldContain("[class,resolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1");
+        o.shouldContain("[class,resolve] resolve JVM_CONSTANT_MethodHandle");
 
-        // (2) classresolve should turn off.
-        pb = ProcessTools.createJavaProcessBuilder("-Xlog:classresolve=debug",
-                                                   "-Xlog:classresolve=off",
+        // (2) class+resolve should turn off.
+        pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug",
+                                                   "-Xlog:class+resolve=off",
                                                    ClassResolutionTestMain.class.getName());
         o = new OutputAnalyzer(pb.start());
-        o.shouldNotContain("[classresolve]");
+        o.shouldNotContain("[class,resolve]");
 
         // (3) TraceClassResolution should turn on.
         pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceClassResolution",
                                                    ClassResolutionTestMain.class.getName());
         o = new OutputAnalyzer(pb.start());
-        o.shouldContain("[classresolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1");
+        o.shouldContain("[class,resolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1");
 
         // (4) TraceClassResolution should turn off.
-        pb = ProcessTools.createJavaProcessBuilder("-Xlog:classresolve=debug",
+        pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug",
                                                    "-XX:-TraceClassResolution",
                                                    ClassResolutionTestMain.class.getName());
         o = new OutputAnalyzer(pb.start());
-        o.shouldNotContain("[classresolve]");
+        o.shouldNotContain("[class,resolve]");
 
     };
 
diff --git a/hotspot/test/runtime/logging/LoaderConstraintsTest.java b/hotspot/test/runtime/logging/LoaderConstraintsTest.java
index 7d7fdff..ea6e13b 100644
--- a/hotspot/test/runtime/logging/LoaderConstraintsTest.java
+++ b/hotspot/test/runtime/logging/LoaderConstraintsTest.java
@@ -25,6 +25,7 @@
 /*
  * @test LoaderConstraintsTest
  * @bug 8149996
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /runtime/testlibrary
  * @library classes
  * @build ClassUnloadCommon test.Empty jdk.test.lib.* jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
@@ -67,22 +68,22 @@
         pb = exec("-XX:+TraceLoaderConstraints");
         out = new OutputAnalyzer(pb.start());
         out.getOutput();
-        out.shouldContain("[classload,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: <bootloader>");
+        out.shouldContain("[class,loader,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: <bootloader>");
 
-        // -Xlog:classload+constraints=info
-        pb = exec("-Xlog:classload+constraints=info");
+        // -Xlog:class+loader+constraints=info
+        pb = exec("-Xlog:class+loader+constraints=info");
         out = new OutputAnalyzer(pb.start());
-        out.shouldContain("[classload,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: <bootloader>");
+        out.shouldContain("[class,loader,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: <bootloader>");
 
         // -XX:-TraceLoaderConstraints
         pb = exec("-XX:-TraceLoaderConstraints");
         out = new OutputAnalyzer(pb.start());
-        out.shouldNotContain("[classload,constraints]");
+        out.shouldNotContain("[class,loaderconstraints]");
 
-        // -Xlog:classload+constraints=off
-        pb = exec("-Xlog:classload+constraints=off");
+        // -Xlog:class+loader+constraints=off
+        pb = exec("-Xlog:class+loader+constraints=off");
         out = new OutputAnalyzer(pb.start());
-        out.shouldNotContain("[classload,constraints]");
+        out.shouldNotContain("[class,loader,constraints]");
 
     }
 }
diff --git a/hotspot/test/runtime/logging/MonitorMismatchTest.java b/hotspot/test/runtime/logging/MonitorMismatchTest.java
index 6aacb53..82d464c 100644
--- a/hotspot/test/runtime/logging/MonitorMismatchTest.java
+++ b/hotspot/test/runtime/logging/MonitorMismatchTest.java
@@ -25,6 +25,7 @@
 /*
  * @test MonitorMismatchTest
  * @bug 8150084
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile MonitorMismatchHelper.jasm
  * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools jdk.test.lib.Platform
diff --git a/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java b/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java
index 57790ad..919d958 100644
--- a/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java
+++ b/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java
@@ -24,6 +24,7 @@
 /*
  * @test ProtectionDomainVerificationTest
  * @bug 8149064
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools
  * @run driver ProtectionDomainVerificationTest
diff --git a/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java b/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java
index a5d44d9..47d61d1 100644
--- a/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java
+++ b/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java
@@ -25,6 +25,7 @@
 /*
  * @test RemovedDevelopFlagsTest
  * @bug 8146632
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
  * @run driver RemovedDevelopFlagsTest
@@ -49,8 +50,8 @@
 
     public static void main(String... args) throws Exception {
         if (Platform.isDebugBuild()){
-            exec("TraceClassInitialization", "-Xlog:classinit");
-            exec("TraceClassLoaderData", "-Xlog:classloaderdata");
+            exec("TraceClassInitialization", "-Xlog:class+init");
+            exec("TraceClassLoaderData", "-Xlog:class+loader+data");
             exec("TraceDefaultMethods", "-Xlog:defaultmethods=debug");
             exec("TraceItables", "-Xlog:itables=debug");
             exec("TraceSafepoint", "-Xlog:safepoint=debug");
diff --git a/hotspot/test/runtime/logging/SafepointCleanupTest.java b/hotspot/test/runtime/logging/SafepointCleanupTest.java
index efe47cb..cbec3cb 100644
--- a/hotspot/test/runtime/logging/SafepointCleanupTest.java
+++ b/hotspot/test/runtime/logging/SafepointCleanupTest.java
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8149991
- * @summary safepointcleanup=info should have output from the code
+ * @summary safepoint+cleanup=info should have output from the code
  * @library /testlibrary
  * @modules java.base/jdk.internal.misc
  *          java.management
@@ -38,7 +38,7 @@
 public class SafepointCleanupTest {
     static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldContain("[safepointcleanup]");
+        output.shouldContain("[safepoint,cleanup]");
         output.shouldContain("deflating idle monitors");
         output.shouldContain("updating inline caches");
         output.shouldContain("compilation policy safepoint handler");
@@ -49,12 +49,12 @@
 
     static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldNotContain("[safepointcleanup]");
+        output.shouldNotContain("[safepoint,cleanup]");
         output.shouldHaveExitValue(0);
     }
 
     public static void main(String[] args) throws Exception {
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepointcleanup=info",
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=info",
                                                                   InnerClass.class.getName());
         analyzeOutputOn(pb);
 
@@ -62,7 +62,7 @@
                                                    InnerClass.class.getName());
         analyzeOutputOn(pb);
 
-        pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepointcleanup=off",
+        pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=off",
                                                    InnerClass.class.getName());
         analyzeOutputOff(pb);
 
diff --git a/hotspot/test/runtime/memory/ReadVMPageSize.java b/hotspot/test/runtime/memory/ReadVMPageSize.java
index bbd23c5..aa83ce0 100644
--- a/hotspot/test/runtime/memory/ReadVMPageSize.java
+++ b/hotspot/test/runtime/memory/ReadVMPageSize.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Using WhiteBox to get VM page size
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build ReadVMPageSize
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/runtime/memory/StressVirtualSpaceResize.java b/hotspot/test/runtime/memory/StressVirtualSpaceResize.java
index 417c8de..4fd0534 100644
--- a/hotspot/test/runtime/memory/StressVirtualSpaceResize.java
+++ b/hotspot/test/runtime/memory/StressVirtualSpaceResize.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Stress test that expands/shrinks VirtualSpace
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build StressVirtualSpaceResize
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/runtime/modules/AccessCheck/CheckRead.java b/hotspot/test/runtime/modules/AccessCheck/CheckRead.java
index ec88eef..71435b1 100644
--- a/hotspot/test/runtime/modules/AccessCheck/CheckRead.java
+++ b/hotspot/test/runtime/modules/AccessCheck/CheckRead.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if module m1 can not read module m2, then class p1.c1
  *          in module m1 can not access p2.c2 in module m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -102,7 +103,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java
index 7ccf918..3342d8f 100644
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if module m1 can not read module m2, then class p1.c1
  *          in module m1 can not access p2.c2 in module m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -102,7 +103,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java
index c815a85..3d2bb9e 100644
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java
@@ -28,6 +28,7 @@
  * @summary Test that if module m1 can read module m2, but package p2 in m2
  *          is exported specifically to module m3, then class p1.c1 in m1 can not
  *          access p2.c2 in m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -104,7 +105,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java
index c1c38fd..5854c45 100644
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java
@@ -27,6 +27,7 @@
  * @test
  * @summary class p1.c1 defined in m1 tries to access p2.c2 defined in m2.
  *          Access allowed since m1 can read m2 and package p2 is exported to m1.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -90,7 +91,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java
index a866833..5749076 100644
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if module m1 can read module m2, and package p2 in m2 is
  *          exported unqualifiedly, then class p1.c1 in m1 can read p2.c2 in m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -91,7 +92,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java
index d4f3d62..9b1bd96 100644
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if module m1 can read module m2, but package p2 in m2 is not
  *          exported, then class p1.c1 in m1 can not read p2.c2 in m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -90,7 +91,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java
index d40911f..09488b6 100644
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java
@@ -27,6 +27,7 @@
  * @test
  * @summary class p1.c1 defined in m1 tries to access p2.c2 defined in unnamed module.
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.module
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -91,7 +92,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MyDiffClassLoader.loader1 = new MyDiffClassLoader();
      MyDiffClassLoader.loader2 = new MyDiffClassLoader();
@@ -140,7 +141,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MyDiffClassLoader.loader1 = new MyDiffClassLoader();
      MyDiffClassLoader.loader2 = new MyDiffClassLoader();
@@ -189,7 +190,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MyDiffClassLoader.loader1 = new MyDiffClassLoader();
      MyDiffClassLoader.loader2 = new MyDiffClassLoader();
diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java
index 5cd133d..3ce9842 100644
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java
@@ -27,6 +27,7 @@
  * @test
  * @summary class p3.c3 defined in module m1 tries to access c4 defined in an unnamed package
  *          and an unnamed module.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile c4.java
@@ -86,7 +87,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MyDiffClassLoader.loader1 = new MyDiffClassLoader();
      MyDiffClassLoader.loader2 = new MyDiffClassLoader();
@@ -135,7 +136,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MyDiffClassLoader.loader1 = new MyDiffClassLoader();
      MyDiffClassLoader.loader2 = new MyDiffClassLoader();
diff --git a/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java
index 4645d09..5cf5132 100644
--- a/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java
+++ b/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java
@@ -28,6 +28,7 @@
  * @summary Test that if module m1 can read module m2, but package p2 in m2
  *          is exported specifically to module m3, then class p1.c1 in m1 can not
  *          access p2.c2 in m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -104,7 +105,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java b/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java
index fa0b094..4a7822f 100644
--- a/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java
+++ b/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if module m1 can read module m2, AND package p2 in m2 is
  *          exported qualifiedly to m1, then class p1.c1 in m1 can read p2.c2 in m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -80,7 +81,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to the same class loader for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java
index a7c74ba..67e69ea 100644
--- a/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java
+++ b/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if module m1 can read module m2, AND package p2 in module2 is
  *          exported unqualifiedly, then class p1.c1 in m1 can read p2.c2 in m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -80,7 +81,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to the same class loader for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java b/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java
index a75fda9..3762f13 100644
--- a/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java
+++ b/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java
@@ -28,6 +28,7 @@
  * @summary Test if package p2 in module m2 is exported to all unnamed,
  *          then class p1.c1 in an unnamed module can read p2.c2 in module m2.
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.module
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -92,7 +93,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java
index b8a5617..0b04497 100644
--- a/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java
+++ b/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if module m1 can read module m2, but package p2 in m2 is not
  *          exported, then class p1.c1 in m1 can not read p2.c2 in m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -90,7 +91,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to the same class loader for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod.java b/hotspot/test/runtime/modules/AccessCheck/Umod.java
index 7bea0a5..c61bcf4 100644
--- a/hotspot/test/runtime/modules/AccessCheck/Umod.java
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod.java
@@ -27,6 +27,7 @@
  * @test
  * @summary class p1.c1 defined in m1 tries to access p2.c2 defined in unnamed module.
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.module
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -91,7 +92,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      // map module m1 to class loader.
      // class c2 will be loaded in an unnamed module/loader.
@@ -137,7 +138,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MySameClassLoader loader = new MySameClassLoader();
      // map module m1 to class loader.
@@ -183,7 +184,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MySameClassLoader loader = new MySameClassLoader();
      // map module m1 to class loader.
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java
index 34ea50f..cde2644 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java
@@ -28,6 +28,7 @@
  * @summary class p1.c1 defined in an unnamed module tries to access p2.c2 defined in m2.
  *          Access is denied, since an unnamed module can read all modules but p2 in module
  *          m2 is exported specifically to module m1, not to all modules.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -91,7 +92,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java
index 52d253b..93b2f14 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java
@@ -28,6 +28,7 @@
  * @summary class p1.c1 defined in an unnamed module tries to access p2.c2 defined in m2.
  *          Access allowed, an unnamed module can read all modules and p2 in module m2
  *          which is exported unqualifiedly.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p2/c2.java
@@ -91,7 +92,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java
index ebe3e5d..aca576b 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java
@@ -28,6 +28,7 @@
  * @summary class p1.c1 defined in unnamed module tries to access p2.c2 defined in m2.
  *          Access is denied since even though unnamed module can read all modules, p2
  *          in module m2 is not exported at all.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p1/c1.java
@@ -90,7 +91,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java b/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java
index 97f781c..36035e9 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java
@@ -26,6 +26,7 @@
 /*
  * @test
  * @summary class p3.c3 defined in module m1 tries to access c4 defined in unnamed module.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile c4.java
@@ -86,7 +87,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      // map module m1 to class loader.
      // class c4 will be loaded in an unnamed module/loader.
@@ -132,7 +133,7 @@
      // Resolves "m1"
      Configuration cf = Layer.boot()
              .configuration()
-             .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+             .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
      MySameClassLoader loader = new MySameClassLoader();
      // map module m1 to class loader.
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java
index 299a41f..ed81b24 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java
@@ -28,6 +28,7 @@
  * @summary class c5 defined in an unnamed module tries to access p6.c6 defined in m2.
  *          Access is denied, since an unnamed module can read all modules but p6 in module
  *          m2 is exported specifically to module m1, not to all modules.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p6/c6.java
@@ -91,7 +92,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java
index 9210c29..11d42b7 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java
@@ -27,6 +27,7 @@
  * @test
  * @summary class c5 in an unnamed module can read module m2, but package p6 in module m2 is not exported.
  *          Access denied since even though unnamed module can read all modules, p6 in module m2 is not exported at all.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MyDiffClassLoader.java
  * @compile p6/c6.java
@@ -90,7 +91,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java
index 1084294..8ea1cdd 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if class c5 in an unnamed module can read package p6 in module m2, but package p6 in module m2 is
  *          exported qualifiedly to module m3, then class c5 in an unnamed module can not read p6.c6 in module m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p6/c6.java
@@ -100,7 +101,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java
index 8ee6e92..ebf9b5e 100644
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test if package p6 in module m2 is not exported, then class c5
  *          in an unnamed module can not access p6.c2 in module m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p6/c6.java
@@ -88,7 +89,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to the same class loader for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java
index fe2fb7b..3c58cdb 100644
--- a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test that if package p2 in module m2 is exported to module m3,
  *          then class p1.c1 in an unnamed module can not read p2.c2 in module m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -100,7 +101,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java
index 445713c..6f8f83f 100644
--- a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test if package p2 in module m2 is exported unqualifiedly,
  *          then class p1.c1 in an unnamed module can read p2.c2 in module m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -90,7 +91,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java
index 7a346cf..90c071c 100644
--- a/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test if package p2 in module m2 is not exported, then class p1.c1
  *          in an unnamed module can not access p2.c2 in module m2.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @compile myloaders/MySameClassLoader.java
  * @compile p2/c2.java
@@ -88,7 +89,7 @@
         // Resolves "m1"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of("m1"));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         // map each module to the same class loader for this test
         Map<String, ClassLoader> map = new HashMap<>();
diff --git a/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java b/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java
index a97f7cc..8846108 100644
--- a/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java
+++ b/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java
@@ -26,6 +26,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/AccessCheckExp.java b/hotspot/test/runtime/modules/AccessCheckExp.java
index 304af7f..0adbd72 100644
--- a/hotspot/test/runtime/modules/AccessCheckExp.java
+++ b/hotspot/test/runtime/modules/AccessCheckExp.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/AccessCheckJavaBase.java b/hotspot/test/runtime/modules/AccessCheckJavaBase.java
index 764f9fb..dc1b691 100644
--- a/hotspot/test/runtime/modules/AccessCheckJavaBase.java
+++ b/hotspot/test/runtime/modules/AccessCheckJavaBase.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @build sun.hotspot.WhiteBox
diff --git a/hotspot/test/runtime/modules/AccessCheckRead.java b/hotspot/test/runtime/modules/AccessCheckRead.java
index 8158582..320ba55 100644
--- a/hotspot/test/runtime/modules/AccessCheckRead.java
+++ b/hotspot/test/runtime/modules/AccessCheckRead.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/AccessCheckSuper.java b/hotspot/test/runtime/modules/AccessCheckSuper.java
index bd2065b..663679b 100644
--- a/hotspot/test/runtime/modules/AccessCheckSuper.java
+++ b/hotspot/test/runtime/modules/AccessCheckSuper.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p3/c3.java
diff --git a/hotspot/test/runtime/modules/AccessCheckUnnamed.java b/hotspot/test/runtime/modules/AccessCheckUnnamed.java
index 0451489..319ee74 100644
--- a/hotspot/test/runtime/modules/AccessCheckUnnamed.java
+++ b/hotspot/test/runtime/modules/AccessCheckUnnamed.java
@@ -26,6 +26,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/AccessCheckWorks.java b/hotspot/test/runtime/modules/AccessCheckWorks.java
index 3a13b04..63de8ca 100644
--- a/hotspot/test/runtime/modules/AccessCheckWorks.java
+++ b/hotspot/test/runtime/modules/AccessCheckWorks.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/ExportTwice.java b/hotspot/test/runtime/modules/ExportTwice.java
index b33b55e..93f4e68 100644
--- a/hotspot/test/runtime/modules/ExportTwice.java
+++ b/hotspot/test/runtime/modules/ExportTwice.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java b/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java
index b7b34b7..8ea4f6b 100644
--- a/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java
+++ b/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/JVMAddModuleExports.java b/hotspot/test/runtime/modules/JVMAddModuleExports.java
index 330dd92..1f0dcae 100644
--- a/hotspot/test/runtime/modules/JVMAddModuleExports.java
+++ b/hotspot/test/runtime/modules/JVMAddModuleExports.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/reflect/ModuleHelper.java
diff --git a/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java b/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java
index f41d401..9f6e69f 100644
--- a/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java
+++ b/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java
@@ -26,6 +26,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @compile p1/c1.java
diff --git a/hotspot/test/runtime/modules/JVMAddModulePackage.java b/hotspot/test/runtime/modules/JVMAddModulePackage.java
index 430c67c..359e3f2 100644
--- a/hotspot/test/runtime/modules/JVMAddModulePackage.java
+++ b/hotspot/test/runtime/modules/JVMAddModulePackage.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/reflect/ModuleHelper.java
diff --git a/hotspot/test/runtime/modules/JVMAddReadsModule.java b/hotspot/test/runtime/modules/JVMAddReadsModule.java
index 9d5e2ad..dda6282 100644
--- a/hotspot/test/runtime/modules/JVMAddReadsModule.java
+++ b/hotspot/test/runtime/modules/JVMAddReadsModule.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/reflect/ModuleHelper.java
diff --git a/hotspot/test/runtime/modules/JVMCanReadModule.java b/hotspot/test/runtime/modules/JVMCanReadModule.java
index ca131df..daabd21 100644
--- a/hotspot/test/runtime/modules/JVMCanReadModule.java
+++ b/hotspot/test/runtime/modules/JVMCanReadModule.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/reflect/ModuleHelper.java
diff --git a/hotspot/test/runtime/modules/JVMDefineModule.java b/hotspot/test/runtime/modules/JVMDefineModule.java
index 77d3c0f..602c5fd 100644
--- a/hotspot/test/runtime/modules/JVMDefineModule.java
+++ b/hotspot/test/runtime/modules/JVMDefineModule.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary  /test/lib /compiler/whitebox ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/reflect/ModuleHelper.java
diff --git a/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java b/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java
index 25065e2..88ff93a 100644
--- a/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java
+++ b/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @compile p2/c2.java
  * @build sun.hotspot.WhiteBox
diff --git a/hotspot/test/runtime/modules/JVMIsExportedToModule.java b/hotspot/test/runtime/modules/JVMIsExportedToModule.java
index 0e35b7d..2d46500 100644
--- a/hotspot/test/runtime/modules/JVMIsExportedToModule.java
+++ b/hotspot/test/runtime/modules/JVMIsExportedToModule.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/reflect/ModuleHelper.java
diff --git a/hotspot/test/runtime/modules/LoadUnloadModuleStress.java b/hotspot/test/runtime/modules/LoadUnloadModuleStress.java
index 53d45c9..ec30f58 100644
--- a/hotspot/test/runtime/modules/LoadUnloadModuleStress.java
+++ b/hotspot/test/runtime/modules/LoadUnloadModuleStress.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Ensure module information is cleaned when owning class loader unloads
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib /compiler/whitebox ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/reflect/ModuleHelper.java
diff --git a/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java b/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java
index b0dbfcf..d874d10 100644
--- a/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java
+++ b/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Make sure -Xpatch works with multiple directories.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile Xpatch2DirsMain.java
  * @run main Xpatch2Dirs
diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java b/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java
index 93935df..69448a6 100644
--- a/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java
+++ b/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary VM exit initialization results if java.base is specificed more than once to Xpatch.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java b/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java
index 2a44b97..9fcffa4 100644
--- a/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java
+++ b/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Module system initialization exception results if a module is specificed twice to Xpatch.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTest.java b/hotspot/test/runtime/modules/Xpatch/XpatchTest.java
index e72be0e..6c67a4f 100644
--- a/hotspot/test/runtime/modules/Xpatch/XpatchTest.java
+++ b/hotspot/test/runtime/modules/Xpatch/XpatchTest.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8130399
  * @summary Make sure -Xpatch works for modules besides java.base.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile XpatchMain.java
  * @run main XpatchTest
diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java b/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java
index 1a96167..c348497 100644
--- a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java
+++ b/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java
@@ -26,6 +26,7 @@
  * @bug 8069469
  * @summary Make sure -Xlog:classload=info works properly with "modules" jimage,
             -Xpatch, and with -Xbootclasspath/a
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile XpatchMain.java
  * @run main XpatchTraceCL
@@ -50,15 +51,15 @@
              "mods/java.naming");
 
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming",
-             "-Xlog:classload=info", "XpatchMain", "javax.naming.spi.NamingManager");
+             "-Xlog:class+load=info", "XpatchMain", "javax.naming.spi.NamingManager");
 
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         // "modules" jimage case.
-        output.shouldContain("[classload] java.lang.Thread source: jrt:/java.base");
+        output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base");
         // -Xpatch case.
-        output.shouldContain("[classload] javax.naming.spi.NamingManager source: mods/java.naming");
+        output.shouldContain("[class,load] javax.naming.spi.NamingManager source: mods/java.naming");
         // -cp case.
-        output.shouldContain("[classload] XpatchMain source: file");
+        output.shouldContain("[class,load] XpatchMain source: file");
 
         // Test -Xlog:classload=info output for -Xbootclasspath/a
         source = "package XpatchTraceCL_pkg; "                 +
@@ -73,10 +74,10 @@
              "xbcp");
 
         pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:xbcp",
-             "-Xlog:classload=info", "XpatchMain", "XpatchTraceCL_pkg.ItIsI");
+             "-Xlog:class+load=info", "XpatchMain", "XpatchTraceCL_pkg.ItIsI");
         output = new OutputAnalyzer(pb.start());
         // -Xbootclasspath/a case.
-        output.shouldContain("[classload] XpatchTraceCL_pkg.ItIsI source: xbcp");
+        output.shouldContain("[class,load] XpatchTraceCL_pkg.ItIsI source: xbcp");
         output.shouldHaveExitValue(0);
     }
 }
diff --git a/hotspot/test/runtime/modules/getModuleJNI/GetModule.java b/hotspot/test/runtime/modules/getModuleJNI/GetModule.java
index bc9883c..c9ef495 100644
--- a/hotspot/test/runtime/modules/getModuleJNI/GetModule.java
+++ b/hotspot/test/runtime/modules/getModuleJNI/GetModule.java
@@ -42,10 +42,22 @@
 
     public static void main(String[] args) {
         Module module;
+        Module javaBaseModule;
+
+        // Module for primitive type, should be "java.base"
+        java.lang.Integer primitive_int = 1;
+        try {
+            javaBaseModule = (Module)callGetModule(primitive_int.getClass());
+            if (!javaBaseModule.getName().equals("java.base")) {
+                throw new RuntimeException("Unexpected module name for primitive type: " +
+                                           javaBaseModule.getName());
+            }
+        } catch(Throwable e) {
+            throw new RuntimeException("Unexpected exception for Integer: " + e.toString());
+        }
 
         // Module for array of primitives, should be "java.base"
         int[] int_array = {1, 2, 3};
-        Module javaBaseModule;
         try {
             javaBaseModule = (Module)callGetModule(int_array.getClass());
             if (!javaBaseModule.getName().equals("java.base")) {
@@ -56,7 +68,19 @@
             throw new RuntimeException("Unexpected exception for [I: " + e.toString());
         }
 
-        // Module for java.lang.String
+        // Module for multi-dimensional array of primitives, should be "java.base"
+        int[][] multi_int_array = { {1, 2, 3}, {4, 5, 6} };
+        try {
+            javaBaseModule = (Module)callGetModule(multi_int_array.getClass());
+            if (!javaBaseModule.getName().equals("java.base")) {
+                throw new RuntimeException("Unexpected module name for multi-dimensional array of primitives: " +
+                                           javaBaseModule.getName());
+            }
+        } catch(Throwable e) {
+            throw new RuntimeException("Unexpected exception for multi-dimensional Integer array: " + e.toString());
+        }
+
+        // Module for java.lang.String, should be "java.base"
         java.lang.String str = "abc";
         try {
             module = (Module)callGetModule(str.getClass());
@@ -68,6 +92,30 @@
             throw new RuntimeException("Unexpected exception for String: " + e.toString());
         }
 
+        // Module for array of java.lang.Strings, should be "java.base"
+        java.lang.String[] str_array = {"a", "b", "c"};
+        try {
+            javaBaseModule = (Module)callGetModule(str_array.getClass());
+            if (!javaBaseModule.getName().equals("java.base")) {
+                throw new RuntimeException("Unexpected module name for array of Strings: " +
+                                           javaBaseModule.getName());
+            }
+        } catch(Throwable e) {
+            throw new RuntimeException("Unexpected exception for String array: " + e.toString());
+        }
+
+        // Module for multi-dimensional array of java.lang.Strings, should be "java.base"
+        java.lang.String[][] multi_str_array = { {"a", "b", "c"}, {"d", "e", "f"} };
+        try {
+            javaBaseModule = (Module)callGetModule(multi_str_array.getClass());
+            if (!javaBaseModule.getName().equals("java.base")) {
+                throw new RuntimeException("Unexpected module name for multi-dimensional array of Strings: " +
+                                           javaBaseModule.getName());
+            }
+        } catch(Throwable e) {
+            throw new RuntimeException("Unexpected exception for multidimensional String array: " + e.toString());
+        }
+
         // Module for java.lang.management.LockInfo
         try {
             LockInfo li = new LockInfo("java.lang.Class", 57);
diff --git a/hotspot/test/runtime/os/AvailableProcessors.java b/hotspot/test/runtime/os/AvailableProcessors.java
index 529f2a0..a607573 100644
--- a/hotspot/test/runtime/os/AvailableProcessors.java
+++ b/hotspot/test/runtime/os/AvailableProcessors.java
@@ -30,6 +30,7 @@
  * @bug 6515172 8148766
  * @summary Check that availableProcessors reports the correct value when running in a cpuset on linux
  * @requires os.family == "linux"
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.*
  * @run driver AvailableProcessors
diff --git a/hotspot/test/runtime/verifier/TraceClassRes.java b/hotspot/test/runtime/verifier/TraceClassRes.java
index ef18a5c..c8b5d5e 100644
--- a/hotspot/test/runtime/verifier/TraceClassRes.java
+++ b/hotspot/test/runtime/verifier/TraceClassRes.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8076318
  * @summary split verifier needs to add TraceClassResolution
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
@@ -38,7 +39,7 @@
         "-XX:+TraceClassResolution", "-verify", "-Xshare:off", "-version");
 
     OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("[classresolve] java.lang.ClassLoader java.lang.Throwable ClassLoader.java (verification)");
+    output.shouldContain("[class,resolve] java.lang.ClassLoader java.lang.Throwable ClassLoader.java (verification)");
     output.shouldHaveExitValue(0);
   }
 }
diff --git a/hotspot/test/runtime/whitebox/WBStackSize.java b/hotspot/test/runtime/whitebox/WBStackSize.java
index 0d3ccc3..9bc117b 100644
--- a/hotspot/test/runtime/whitebox/WBStackSize.java
+++ b/hotspot/test/runtime/whitebox/WBStackSize.java
@@ -24,6 +24,7 @@
 /*
  * @test WBStackSize
  * @summary verify that whitebox functions getThreadFullStackSize() and getThreadRemainingStackSize are working
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build WBStackSize
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java b/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java
index 87d56e4..a6f4424 100644
--- a/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java
+++ b/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java
@@ -26,6 +26,7 @@
  * @bug 8011675
  * @summary verify that whitebox can be used even if not all functions are declared in java-part
  * @author igor.ignatyev@oracle.com
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @compile WhiteBox.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/sanity/WBApi.java b/hotspot/test/sanity/WBApi.java
index 75ac5c3..e24e672 100644
--- a/hotspot/test/sanity/WBApi.java
+++ b/hotspot/test/sanity/WBApi.java
@@ -24,6 +24,7 @@
 /*
  * @test WBApi
  * @summary verify that whitebox functions can be linked and executed
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build WBApi
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/serviceability/ParserTest.java b/hotspot/test/serviceability/ParserTest.java
index a9d6c8d..58ef23b 100644
--- a/hotspot/test/serviceability/ParserTest.java
+++ b/hotspot/test/serviceability/ParserTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Test that the diagnostic command arguemnt parser works
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary /test/lib
  * @build ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.parser.*
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/serviceability/attach/AttachWithStalePidFile.java b/hotspot/test/serviceability/attach/AttachWithStalePidFile.java
index 8ed9b47..5cc42ca 100644
--- a/hotspot/test/serviceability/attach/AttachWithStalePidFile.java
+++ b/hotspot/test/serviceability/attach/AttachWithStalePidFile.java
@@ -26,6 +26,7 @@
  * @bug 7162400
  * @key regression
  * @summary Regression test for attach issue where stale pid files in /tmp lead to connection issues
+ * @modules java.base/jdk.internal.misc
  * @modules jdk.attach/sun.tools.attach
  * @library /testlibrary
  * @build jdk.test.lib.* AttachWithStalePidFileTarget
diff --git a/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java b/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java
index 6434bb0..996074a 100644
--- a/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java
+++ b/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,33 +57,34 @@
 
         /*
          * example output:
-         *   num     #instances         #bytes  class name
-         *  ----------------------------------------------
-         *     1:          1647        1133752  [B
-         *     2:          6198         383168  [C
-         *     3:          1464         165744  java.lang.Class
-         *     4:          6151         147624  java.lang.String
-         *     5:          2304          73728  java.util.concurrent.ConcurrentHashMap$Node
-         *     6:          1199          64280  [Ljava.lang.Object;
+         *  num     #instances         #bytes  class name (module)
+         * -------------------------------------------------------
+         *    1:          7991         757792  [B (java.base@9-internal)
+         *    2:          1811         217872  java.lang.Class (java.base@9-internal)
+         *    3:          6724         215168  java.util.HashMap$Node (java.base@9-internal)
+         *    4:          7852         188448  java.lang.String (java.base@9-internal)
+         *    5:          1378         105040  [Ljava.util.HashMap$Node; (java.base@9-internal)
+         *    6:          1863          95096  [Ljava.lang.Object; (java.base@9-internal)
+
          * ...
          */
 
         /* Require at least one java.lang.Class */
-        output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class\\s*$");
+        output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class \\(java.base@\\S*\\)\\s*$");
 
         /* Require at least one java.lang.String */
-        output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String\\s*$");
+        output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String \\(java.base@\\S*\\)\\s*$");
 
         /* Require at least one java.lang.Object */
-        output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object\\s*$");
+        output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object \\(java.base@\\S*\\)\\s*$");
 
         /* Require at exactly one TestClass[] */
         output.shouldMatch("^\\s+\\d+:\\s+1\\s+\\d+\\s+" +
-                Pattern.quote(TestClass[].class.getName()) + "\\s*$");
+            Pattern.quote(TestClass[].class.getName()) + "\\s*$");
 
         /* Require at exactly 1024 TestClass */
         output.shouldMatch("^\\s+\\d+:\\s+1024\\s+\\d+\\s+" +
-                Pattern.quote(TestClass.class.getName()) + "\\s*$");
+            Pattern.quote(TestClass.class.getName()) + "\\s*$");
     }
 
     @Test
diff --git a/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java b/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java
index 1e53a23..05b0627 100644
--- a/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java
+++ b/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,9 @@
  * @test
  * @summary
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ * @modules java.xml
+ *          java.management
  * @build jdk.test.lib.*
  * @build jdk.test.lib.dcmd.*
  * @run testng FinalizerInfoTest
diff --git a/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java b/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java
index daedf12..5193e6c 100644
--- a/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java
+++ b/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,9 @@
  * @test
  * @summary Test of diagnostic command GC.heap_info
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ * @modules java.xml
+ *          java.management
  * @build jdk.test.lib.*
  * @build jdk.test.lib.dcmd.*
  * @run testng HeapInfoTest
diff --git a/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java b/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java
index 1586db2..b25999a 100644
--- a/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java
+++ b/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java
@@ -31,6 +31,7 @@
  * @test
  * @bug 8054890
  * @summary Test of JVMTI.data_dump diagnostic command
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.*
  * @run testng DataDumpDcmdTest
diff --git a/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java b/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java
index b6e6744..9132aec 100644
--- a/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java
+++ b/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java
@@ -31,6 +31,7 @@
  * @test
  * @bug 8054890
  * @summary Test of VM.set_flag diagnostic command
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.*
  * @build jdk.test.lib.dcmd.*
diff --git a/hotspot/test/serviceability/logging/TestBasicLogOutput.java b/hotspot/test/serviceability/logging/TestBasicLogOutput.java
index c74a258..345e373 100644
--- a/hotspot/test/serviceability/logging/TestBasicLogOutput.java
+++ b/hotspot/test/serviceability/logging/TestBasicLogOutput.java
@@ -24,6 +24,7 @@
 /*
  * @test TestBasicLogOutput
  * @summary Ensure logging can be enabled and successfully prints to stdout.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/serviceability/logging/TestLogRotation.java b/hotspot/test/serviceability/logging/TestLogRotation.java
index ca59cf6..3e3696b 100644
--- a/hotspot/test/serviceability/logging/TestLogRotation.java
+++ b/hotspot/test/serviceability/logging/TestLogRotation.java
@@ -75,7 +75,7 @@
         ArrayList<String> args = new ArrayList();
         String[] logOpts = new String[]{
             "-cp", System.getProperty("java.class.path"),
-            "-Xlog:gc=debug:" + logFileName + "::filesize=" + logFileSizeK + ",filecount=" + numberOfFiles,
+            "-Xlog:gc=debug:" + logFileName + "::filesize=" + logFileSizeK + "k,filecount=" + numberOfFiles,
             "-XX:-DisableExplicitGC", // to ensure that System.gc() works
             "-Xmx128M"};
         // System.getProperty("test.java.opts") is '' if no options is set
diff --git a/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java b/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java
index 6914927..dfc62f7 100644
--- a/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java
+++ b/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java
@@ -24,6 +24,7 @@
 /*
  * @test TestMultipleXlogArgs
  * @summary Ensure multiple -Xlog arguments aggregate the logging options.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java b/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java
index 39789ea..77b4e00 100644
--- a/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java
+++ b/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java
@@ -24,6 +24,7 @@
 /*
  * @test TestQuotedLogOutputs
  * @summary Ensure proper parsing of quoted output names for -Xlog arguments.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 
diff --git a/hotspot/test/serviceability/sa/DeadlockDetectionTest.java b/hotspot/test/serviceability/sa/DeadlockDetectionTest.java
index 23ce96f..85e5529 100644
--- a/hotspot/test/serviceability/sa/DeadlockDetectionTest.java
+++ b/hotspot/test/serviceability/sa/DeadlockDetectionTest.java
@@ -40,6 +40,7 @@
  * @summary Test deadlock detection
  * @library /test/lib/share/classes
  * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build jdk.test.lib.*
  * @build jdk.test.lib.apps.*
diff --git a/hotspot/test/serviceability/sa/TestClassLoaderStats.java b/hotspot/test/serviceability/sa/TestClassLoaderStats.java
index 92f843e..df46c41 100644
--- a/hotspot/test/serviceability/sa/TestClassLoaderStats.java
+++ b/hotspot/test/serviceability/sa/TestClassLoaderStats.java
@@ -32,6 +32,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library /testlibrary
  * @build jdk.test.lib.*
diff --git a/hotspot/test/serviceability/sa/TestStackTrace.java b/hotspot/test/serviceability/sa/TestStackTrace.java
index 203735c..7044f10 100644
--- a/hotspot/test/serviceability/sa/TestStackTrace.java
+++ b/hotspot/test/serviceability/sa/TestStackTrace.java
@@ -32,6 +32,7 @@
 
 /*
  * @test
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library /testlibrary
  * @build jdk.test.lib.*
diff --git a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java
index ac0ef6d..0328e39 100644
--- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java
+++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java
@@ -44,7 +44,7 @@
 public class Test8028623 {
 
   public static int \u00CB = 1;
-  public static String dumpFile = "heap.out";
+  public static String dumpFile = "heap.bin";
 
   public static void main (String[] args) {
 
@@ -55,11 +55,12 @@
             System.out.println("SA attach not expected to work - test skipped.");
             return;
         }
-        int pid = ProcessTools.getProcessId();
-        JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
-                                              .addToolArg("-F")
-                                              .addToolArg("-dump:live,format=b,file=" + dumpFile)
-                                              .addToolArg(Integer.toString(pid));
+        long pid = ProcessTools.getProcessId();
+        JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb")
+                                              .addToolArg("jmap")
+                                              .addToolArg("--binaryheap")
+                                              .addToolArg("--pid")
+                                              .addToolArg(Long.toString(pid));
         ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
         OutputBuffer output = ProcessTools.getOutput(pb);
         Process p = pb.start();
diff --git a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java
index c1b6e95..077617b 100644
--- a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java
+++ b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java
@@ -53,33 +53,22 @@
  */
 
 public class JMapHProfLargeHeapTest {
-    private static final String HEAP_DUMP_FILE_NAME = "heap.hprof";
+    private static final String HEAP_DUMP_FILE_NAME = "heap.bin";
+    private static final String HPROF_HEADER_1_0_1 = "JAVA PROFILE 1.0.1";
     private static final String HPROF_HEADER_1_0_2 = "JAVA PROFILE 1.0.2";
     private static final long M = 1024L;
     private static final long G = 1024L * M;
 
     public static void main(String[] args) throws Exception {
-        // If we are on MacOSX, test if JMap tool is signed, otherwise return
-        // since test will fail with privilege error.
-        if (Platform.isOSX()) {
-            String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
-            ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
-                    "codesign", "-v", jmapToolPath);
-            Process codesignProcess = codesignProcessBuilder.start();
-            OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
-            try {
-                analyser.shouldNotContain("code object is not signed at all");
-                System.out.println("Signed jmap found at: " + jmapToolPath);
-            } catch (Exception e) {
-                // Abort since we can't know if the test will work
-                System.out
-                        .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
-                return;
-            }
+        if (!Platform.shouldSAAttach()) {
+            System.out.println("SA attach not expected to work - test skipped.");
+            return;
         }
 
         // All heap dumps should create 1.0.2 file format
-        testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_2);
+        // Hotspot internal heapdumper always use HPROF_HEADER_1_0_2 format,
+        // but SA heapdumper still use HPROF_HEADER_1_0_1 for small heaps
+        testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);
 
         /**
          * This test was deliberately commented out since the test system lacks
@@ -110,9 +99,10 @@
             System.out.println("Extracted pid: " + pid);
 
             JDKToolLauncher jMapLauncher = JDKToolLauncher
-                    .createUsingTestJDK("jmap");
-            jMapLauncher.addToolArg("-dump:format=b,file=" + pid + "-"
-                    + HEAP_DUMP_FILE_NAME);
+                    .createUsingTestJDK("jhsdb");
+            jMapLauncher.addToolArg("jmap");
+            jMapLauncher.addToolArg("--binaryheap");
+            jMapLauncher.addToolArg("--pid");
             jMapLauncher.addToolArg(String.valueOf(pid));
 
             ProcessBuilder jMapProcessBuilder = new ProcessBuilder(
@@ -123,12 +113,11 @@
             Process jMapProcess = jMapProcessBuilder.start();
             OutputAnalyzer analyzer = new OutputAnalyzer(jMapProcess);
             analyzer.shouldHaveExitValue(0);
-            analyzer.shouldContain(pid + "-" + HEAP_DUMP_FILE_NAME);
-            analyzer.shouldContain("Heap dump file created");
+            analyzer.shouldContain(HEAP_DUMP_FILE_NAME);
 
             largeHeapProc.getOutputStream().write('\n');
 
-            File dumpFile = new File(pid + "-" + HEAP_DUMP_FILE_NAME);
+            File dumpFile = new File(HEAP_DUMP_FILE_NAME);
             Asserts.assertTrue(dumpFile.exists(), "Heap dump file not found.");
 
             try (Reader reader = new BufferedReader(new FileReader(dumpFile))) {
diff --git a/hotspot/test/serviceability/threads/TestFalseDeadLock.java b/hotspot/test/serviceability/threads/TestFalseDeadLock.java
index 2954d5d..e4654f4 100644
--- a/hotspot/test/serviceability/threads/TestFalseDeadLock.java
+++ b/hotspot/test/serviceability/threads/TestFalseDeadLock.java
@@ -30,6 +30,7 @@
  * @test
  * @bug 8016304
  * @summary Make sure no deadlock is reported for this program which has no deadlocks.
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @run main/othervm TestFalseDeadLock
  */
diff --git a/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java b/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java
index 6b154ec..cebd2c7 100644
--- a/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java
+++ b/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java
@@ -25,6 +25,7 @@
  * @test
  * @summary Create daemon and non-deamon threads.
  *          Check the correctness of thread's status from jstack.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java b/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java
index 6ca8188..2d0eb05 100644
--- a/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java
+++ b/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java
@@ -32,6 +32,7 @@
  * @test JstackThreadTest
  * @bug 8151442
  * @summary jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  * @build jdk.test.lib.*
  * @run main JstackThreadTest
diff --git a/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java b/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java
index 92bd5e5..884c8d2 100644
--- a/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java
+++ b/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java
@@ -27,6 +27,7 @@
  *          synchronizing on one monitor inside of each method.
  *          After checking that lock info is correct invoke another method
  *          and get the lock again. Repeat this action.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java b/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java
index c5943d1..282bfda 100644
--- a/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java
+++ b/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Checks that jstack correctly prints the thread names
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java b/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java
index 9f47815..174bcdb 100644
--- a/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java
+++ b/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java
@@ -27,6 +27,7 @@
  *          synchronizing on one monitor inside of each method.
  *          After checking that lock info is correct free the lock and
  *          invoke another method. Repeat this action.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java b/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java
index 198124c..6f87c0a 100644
--- a/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java
+++ b/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java
@@ -27,6 +27,7 @@
  *           presented in the stack is correct. Call notifyAll method
  *           monitor info have to disappear from the stack.
  *           Repeats the same scenario calling interrupt() method
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java b/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java
index ec6d1bc..2ed5c05 100644
--- a/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java
+++ b/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java
@@ -27,6 +27,7 @@
  * @test
  * @summary Test checks the consistency of the output
  * displayed with jstat -gccapacity.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @requires vm.opt.ExplicitGCInvokesConcurrent != true
diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java
index 508b786..688670f 100644
--- a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java
+++ b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java
@@ -28,6 +28,7 @@
  *          test several times provokes garbage collection in the debuggee application and after each garbage
  *          collection runs jstat. jstat should show that after garbage collection number of GC events and garbage
  *          collection time increase.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @requires vm.opt.ExplicitGCInvokesConcurrent != true
diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java
index 95200d4..0efd59f 100644
--- a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java
+++ b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java
@@ -27,6 +27,7 @@
  *          Test scenario:
  *          tests forces debuggee application eat ~70% of heap and runs jstat.
  *          jstat should show that ~70% of heap (OC/OU ~= 70%).
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java
index 94514d4..a014c37 100644
--- a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java
+++ b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java
@@ -27,6 +27,7 @@
  *          Test scenario:
  *          test forces debuggee application call System.gc(), runs jstat and checks that
  *          cause of last garbage collection displayed by jstat (LGCC) is 'System.gc()'.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java b/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java
index bdb06c1..4e2fbdc 100644
--- a/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java
+++ b/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java
@@ -29,6 +29,7 @@
  *          test several times provokes garbage collection in the debuggee application and after each garbage
  *          collection runs jstat. jstat should show that after garbage collection number of GC events and garbage
  *          collection time increase.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
diff --git a/hotspot/test/serviceability/tmtools/jstat/GcTest01.java b/hotspot/test/serviceability/tmtools/jstat/GcTest01.java
index 2a6b0c5..5738da1 100644
--- a/hotspot/test/serviceability/tmtools/jstat/GcTest01.java
+++ b/hotspot/test/serviceability/tmtools/jstat/GcTest01.java
@@ -31,6 +31,7 @@
  *          jstat should show that after garbage collection
  *          number of GC events and garbage
  *          collection time increase.
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @requires vm.opt.ExplicitGCInvokesConcurrent != true
diff --git a/hotspot/test/serviceability/tmtools/jstat/GcTest02.java b/hotspot/test/serviceability/tmtools/jstat/GcTest02.java
index bcdc258..171b87b 100644
--- a/hotspot/test/serviceability/tmtools/jstat/GcTest02.java
+++ b/hotspot/test/serviceability/tmtools/jstat/GcTest02.java
@@ -28,10 +28,12 @@
  *          Test scenario:
  *          tests forces debuggee application eat ~70% of heap and runs jstat.
  *          jstat should show that ~70% of heap is utilized (OC/OU ~= 70%).
+ * @modules java.base/jdk.internal.misc
  * @library /test/lib/share/classes
  * @library ../share
  * @build common.*
  * @build utils.*
+ * @ignore 8155570
  * @run main/othervm -XX:+UsePerfData -Xmx128M -XX:MaxMetaspaceSize=128M GcTest02
  */
 
diff --git a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java
index f05a02a..96b627a 100644
--- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java
+++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 import sun.hotspot.WhiteBox;
 import jdk.internal.misc.SharedSecrets;
-import sun.reflect.ConstantPool;
+import jdk.internal.reflect.ConstantPool;
 
 import java.lang.reflect.Executable;
 
diff --git a/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java b/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java
index 70e990a..21ff415 100644
--- a/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java
+++ b/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java
@@ -90,27 +90,8 @@
    *
    * @return Process id
    */
-  public static int getProcessId() throws Exception {
-    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
-    int pid = Integer.parseInt(runtime.getName().split("@")[0]);
-
-    return pid;
-  }
-
-  /**
-   * Get the string containing input arguments passed to the VM
-   *
-   * @return arguments
-   */
-  public static String getVmInputArguments() {
-    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
-
-    List<String> args = runtime.getInputArguments();
-    StringBuilder result = new StringBuilder();
-    for (String arg : args)
-        result.append(arg).append(' ');
-
-    return result.toString();
+  public static long getProcessId() throws Exception {
+    return ProcessHandle.current().getPid();
   }
 
   /**
diff --git a/hotspot/test/testlibrary/jdk/test/lib/Utils.java b/hotspot/test/testlibrary/jdk/test/lib/Utils.java
index 9dcf063..8ad11fd 100644
--- a/hotspot/test/testlibrary/jdk/test/lib/Utils.java
+++ b/hotspot/test/testlibrary/jdk/test/lib/Utils.java
@@ -51,7 +51,7 @@
 import java.util.function.Consumer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Common library for various test helper functions.
diff --git a/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java b/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java
index 4830661..228c027 100644
--- a/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java
+++ b/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java
@@ -44,7 +44,7 @@
     @Override
     public boolean getAsBoolean() {
         if (!Platform.getOsArch().matches(cpuArchPattern)) {
-            System.out.println("CPU arch does not match " + cpuArchPattern);
+            System.out.println("CPU arch " + Platform.getOsArch() + " does not match " + cpuArchPattern);
             return false;
         }
 
diff --git a/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java b/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java
index 24836e6..17ffd91 100644
--- a/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java
+++ b/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java
@@ -55,7 +55,7 @@
         File cmdFile = createTempFile();
         writeCommandToTemporaryFile(cmd, cmdFile);
 
-        return Arrays.asList(jcmdBinary, Integer.toString(pid),
+        return Arrays.asList(jcmdBinary, Long.toString(pid),
                 "-f", cmdFile.getAbsolutePath());
     }
 
diff --git a/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java b/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java
index bce55d7..f1caddb 100644
--- a/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java
+++ b/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java
@@ -32,7 +32,7 @@
  * Executes Diagnostic Commands on the target VM (specified by pid) using the jcmd tool
  */
 public class PidJcmdExecutor extends JcmdExecutor {
-    protected final int pid;
+    protected final long pid;
 
     /**
      * Instantiates a new PidJcmdExecutor targeting the current VM
@@ -53,11 +53,11 @@
      */
     public PidJcmdExecutor(String target) {
         super();
-        pid = Integer.valueOf(target);
+        pid = Long.valueOf(target);
     }
 
     protected List<String> createCommandLine(String cmd) throws CommandExecutorException {
-        return Arrays.asList(jcmdBinary, Integer.toString(pid), cmd);
+        return Arrays.asList(jcmdBinary, Long.toString(pid), cmd);
     }
 
 }
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java
index d06ecb0..acc4493 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java
@@ -27,10 +27,10 @@
     static final long serialVersionUID = -2325617203741536725L;
 
     public ProductionFailedException(String msg) {
-        super(msg);
+        super(msg, null, false, false);
     }
 
     public ProductionFailedException() {
-        super();
+        super(null, null, false, false);
     }
 }
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java
index 9547bdb..1307838 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java
@@ -26,6 +26,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Stack;
 import jdk.test.lib.jittester.types.TypeKlass;
 
@@ -37,7 +38,7 @@
     private static int VARIABLE_NUMBER = 0;
     private static int FUNCTION_NUMBER = 0;
 
-    static private void initExternalSymbols() {
+    private static void initExternalSymbols() {
 
         String classList = ProductionParams.addExternalSymbols.value();
         if (classList.equals("all")) {
@@ -254,12 +255,12 @@
     public static void push() {
         // Do deep cloning..
         HashMap<Type, ArrayList<Symbol>> prev = SYMBOL_STACK.peek();
-        SYMBOL_STACK.push(new HashMap<>());
-        HashMap<Type, ArrayList<Symbol>> top = SYMBOL_STACK.peek();
-        for (Type type : prev.keySet()) {
-            ArrayList<Symbol> prevArray = prev.get(type);
-            top.put(type, new ArrayList<>(prevArray.size()));
-            ArrayList<Symbol> topArray = top.get(type);
+        HashMap<Type, ArrayList<Symbol>> top = new HashMap<>(prev.size());
+        SYMBOL_STACK.push(top);
+        for (Map.Entry<Type, ArrayList<Symbol>> entry : prev.entrySet()) {
+            ArrayList<Symbol> prevArray = entry.getValue();
+            ArrayList<Symbol> topArray = new ArrayList<>(prevArray.size());
+            top.put(entry.getKey(), topArray);
             for (Symbol symbol : prevArray) {
                 topArray.add(symbol.copy());
             }
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java
deleted file mode 100644
index 181d0a5..0000000
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.test.lib.jittester;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-
-public class TypeUtil {
-
-    public static Collection<Type> getImplicitlyCastable(Collection<Type> types, Type type) {
-        ArrayList<Type> result = new ArrayList<>(types);
-        Iterator<Type> iterator = result.iterator();
-        while (iterator.hasNext()) {
-            if (!iterator.next().canImplicitlyCastTo(type)) {
-                iterator.remove();
-            }
-        }
-        return result;
-    }
-
-    public static Collection<Type> getExplicitlyCastable(Collection<Type> types, Type type) {
-        ArrayList<Type> result = new ArrayList<>(types);
-        Iterator<Type> iterator = result.iterator();
-        while (iterator.hasNext()) {
-            if (!iterator.next().canExplicitlyCastTo(type)) {
-                iterator.remove();
-            }
-        }
-        return result;
-    }
-
-    public static List<Type> getMoreCapatiousThan(Collection<Type> types, BuiltInType type) {
-        ArrayList<Type> result = new ArrayList<>();
-        Iterator<Type> iterator = types.iterator();
-        while (iterator.hasNext()) {
-            try {
-                BuiltInType builtInType = (BuiltInType) iterator.next();
-                if (builtInType.isMoreCapaciousThan(type)) {
-                    result.add(builtInType);
-                }
-            } catch (Exception e) {
-            }
-        }
-        return result;
-    }
-
-    public static List<Type> getLessCapatiousOrEqualThan(Collection<Type> types, BuiltInType type) {
-        ArrayList<Type> result = new ArrayList<>();
-        Iterator<Type> iterator = types.iterator();
-        while (iterator.hasNext()) {
-            try {
-                BuiltInType builtInType = (BuiltInType) iterator.next();
-                if (!builtInType.isMoreCapaciousThan(type) || builtInType.equals(type)) {
-                    result.add(builtInType);
-                }
-            } catch (Exception e) {
-            }
-        }
-        return result;
-    }
-}
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java
index 2658be2..d5ce379 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java
@@ -31,7 +31,7 @@
 import jdk.test.lib.jittester.Rule;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.VariableBase;
 import jdk.test.lib.jittester.VariableInfo;
 import jdk.test.lib.jittester.types.TypeKlass;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java
index 96f9e18..b51cec7 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java
@@ -29,7 +29,7 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeInt;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.utils.PseudoRandom;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java
index 288eac1..6479644 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java
@@ -28,7 +28,7 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeBoolean;
 import jdk.test.lib.jittester.types.TypeInt;
 import jdk.test.lib.jittester.types.TypeKlass;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java
index 81ffbd9..d5c74e2 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java
@@ -28,11 +28,11 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
 import jdk.test.lib.jittester.types.TypeInt;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.types.TypeLong;
 import jdk.test.lib.jittester.utils.PseudoRandom;
+import jdk.test.lib.jittester.utils.TypeUtil;
 
 class BinaryShiftOperatorFactory extends BinaryOperatorFactory {
     BinaryShiftOperatorFactory(OperatorKind opKind, long complexityLimit, int operatorLimit,
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java
index 6ed509f..bad0bab 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java
@@ -28,7 +28,7 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.UnaryOperator;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.types.TypeInt;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java
index a47f4ae..37b6072 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java
@@ -33,7 +33,7 @@
 import jdk.test.lib.jittester.SymbolTable;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.loops.DoWhile;
 import jdk.test.lib.jittester.loops.For;
 import jdk.test.lib.jittester.loops.While;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java
index a8d934c..e170ff5 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java
@@ -30,7 +30,7 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeBoolean;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.utils.PseudoRandom;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java
index 1752b0c..b61d23f 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java
@@ -30,7 +30,7 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.utils.PseudoRandom;
 
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java
index 286b6d7..901bf43 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java
@@ -30,7 +30,7 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.types.TypeBoolean;
 import jdk.test.lib.jittester.utils.PseudoRandom;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java
index 8892901..9112bc1 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java
@@ -30,7 +30,7 @@
 import jdk.test.lib.jittester.SymbolTable;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.VariableInfo;
 import jdk.test.lib.jittester.loops.CounterInitializer;
 import jdk.test.lib.jittester.types.TypeKlass;
@@ -48,7 +48,7 @@
 
     @Override
     protected IRNode sproduce() throws ProductionFailedException {
-        List<Type> types = TypeUtil.getMoreCapatiousThan(TypeList.getBuiltIn(), new TypeInt());
+        List<Type> types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), new TypeInt());
         types.add(new TypeInt());
         final Type selectedType = PseudoRandom.randomElement(types);
         IRNode init = new LiteralInitializer(counterValue, selectedType);
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java
index 8ee2ecf..a1052ce 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java
@@ -34,7 +34,7 @@
 import jdk.test.lib.jittester.Rule;
 import jdk.test.lib.jittester.Switch;
 import jdk.test.lib.jittester.Type;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.types.TypeByte;
 import jdk.test.lib.jittester.types.TypeChar;
@@ -63,7 +63,7 @@
     @Override
     protected IRNode sproduce() throws ProductionFailedException {
         if (statementLimit > 0 && complexityLimit > 0) {
-            ArrayList<Type> switchTypes = new ArrayList<>();
+            List<Type> switchTypes = new ArrayList<>();
             switchTypes.add(new TypeChar());
             switchTypes.add(new TypeByte());
             switchTypes.add(new TypeShort());
@@ -78,8 +78,8 @@
                     .setCanHaveReturn(canHaveReturn);
             MAIN_LOOP:
             for (Type type : switchTypes) {
-                ArrayList<IRNode> caseConsts = new ArrayList<>();
-                ArrayList<IRNode> caseBlocks = new ArrayList<>();
+                List<IRNode> caseConsts = new ArrayList<>();
+                List<IRNode> caseBlocks = new ArrayList<>();
                 try {
                     int accumulatedStatements = 0;
                     int currentStatementsLimit = 0;
@@ -94,10 +94,10 @@
                             .getLimitedExpressionFactory()
                             .produce();
                     accumulatedComplexity += currentComplexityLimit;
-                    ArrayList<Type> caseTypes = new ArrayList<>();
+                    List<Type> caseTypes = new ArrayList<>();
                     caseTypes.add(new TypeByte());
                     caseTypes.add(new TypeChar());
-                    caseTypes = new ArrayList<>(TypeUtil.getLessCapatiousOrEqualThan(caseTypes,
+                    caseTypes = new ArrayList<>(TypeUtil.getLessCapaciousOrEqualThan(caseTypes,
                             (BuiltInType) type));
                     if (PseudoRandom.randomBoolean()) { // "default"
                         currentStatementsLimit = (int) (PseudoRandom.random()
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java
index 5060736..24e05e4 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java
@@ -30,7 +30,7 @@
 import jdk.test.lib.jittester.TernaryOperator;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.types.TypeBoolean;
 import jdk.test.lib.jittester.utils.PseudoRandom;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java
index dea0c93..523bfb5 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java
@@ -31,7 +31,7 @@
 import jdk.test.lib.jittester.TryCatchBlock;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.types.TypeKlass;
 import jdk.test.lib.jittester.utils.PseudoRandom;
 
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java
index 79b0e23..12e5e98 100644
--- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java
@@ -29,7 +29,7 @@
 import jdk.test.lib.jittester.ProductionFailedException;
 import jdk.test.lib.jittester.Type;
 import jdk.test.lib.jittester.TypeList;
-import jdk.test.lib.jittester.TypeUtil;
+import jdk.test.lib.jittester.utils.TypeUtil;
 import jdk.test.lib.jittester.UnaryOperator;
 import jdk.test.lib.jittester.types.TypeBoolean;
 import jdk.test.lib.jittester.types.TypeInt;
diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java
new file mode 100644
index 0000000..f9595de
--- /dev/null
+++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java
@@ -0,0 +1,88 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.jittester.utils;
+
+import jdk.test.lib.jittester.BuiltInType;
+import jdk.test.lib.jittester.Type;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Utility functions for type system
+ */
+public class TypeUtil {
+    /**
+     * Gets a list of implicitly castable types to a given one from the collection of types
+     *
+     * @param types a collection to get types from
+     * @param type  a target type which result type could be implicitly cast to
+     * @return      a result collection of types that match given conditions
+     */
+    public static Collection<Type> getImplicitlyCastable(Collection<Type> types, Type type) {
+        return types.stream()
+                .filter(t -> t.canImplicitlyCastTo(type))
+                .collect(Collectors.toList());
+    }
+
+    /**
+     * Gets a list of explicitly castable types to a given one from the collection of types
+     *
+     * @param types a collection to get types from
+     * @param type  a target type which result type could be explicitly cast to
+     * @return      a result collection of types that match given conditions
+     */
+    public static Collection<Type> getExplicitlyCastable(Collection<Type> types, Type type) {
+        return types.stream()
+                .filter(t -> t.canExplicitlyCastTo(type))
+                .collect(Collectors.toList());
+    }
+
+    /**
+     * Gets a list of more capacious types than a given one from the collection of types
+     *
+     * @param types a collection to get types from
+     * @param type  a type to filter given types by capacity
+     * @return      a result collection of types that match given conditions
+     */
+    public static List<Type> getMoreCapaciousThan(Collection<Type> types, BuiltInType type) {
+        return types.stream()
+                .filter(t -> ((BuiltInType) t).isMoreCapaciousThan(type))
+                .collect(Collectors.toList());
+    }
+
+    /**
+     * Gets a list of less or equal capacious types than a given one from the collection of types
+     *
+     * @param types a collection to get types from
+     * @param type  a type to filter given types by capacity
+     * @return      a result collection of types that match given conditions
+     */
+    public static List<Type> getLessCapaciousOrEqualThan(Collection<Type> types, BuiltInType type) {
+        return types.stream()
+                .filter(t -> !((BuiltInType) t).isMoreCapaciousThan(type) || t.equals(type))
+                .collect(Collectors.toList());
+    }
+}
diff --git a/hotspot/test/testlibrary/jvmti/libSimpleClassFileLoadHook.c b/hotspot/test/testlibrary/jvmti/libSimpleClassFileLoadHook.c
new file mode 100644
index 0000000..2424e87
--- /dev/null
+++ b/hotspot/test/testlibrary/jvmti/libSimpleClassFileLoadHook.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * A simple way to test JVMTI ClassFileLoadHook. See ../testlibrary_tests/SimpleClassFileLoadHookTest.java
+ * for an example.
+ */
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <jvmti.h>
+#include <jni.h>
+
+static char* CLASS_NAME = NULL;
+static char* FROM = NULL;
+static char* TO = NULL;
+static jvmtiEnv *jvmti = NULL;
+static jvmtiEventCallbacks callbacks;
+
+/**
+ * For all classes whose name equals to CLASS_NAME, we replace all occurrence of FROM to TO
+ * in the classfile data. CLASS_NAME must be a binary class name.
+ *
+ * FROM is usually chosen as part of a UTF8 string in the class file. For example, if the
+ * original class file has
+ *    String getXXX() { return "theXXX";}
+ * You can set FROM=XXX, TO=YYY to rewrite the class to be
+ *    String getYYY() { return "theYYY";}
+ *
+ * Please note that the replacement is NOT limited just the UTF8 strings, but rather applies
+ * to all the bytes in the classfile. So if you pick a very short FROM string like X,
+ * it may override any POP2 bytecodes, which have the value 88 (ascii 'X').
+ *
+ * A good FROM string to use is 'cellphone', where the first 4 bytes represent the bytecode
+ * sequence DADD/LSUB/IDIV/IDIV, which does not appear in valid bytecode streams.
+ */
+void JNICALL
+ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, jclass class_beeing_redefined,
+        jobject loader, const char* name, jobject protection_domain,
+        jint class_data_len, const unsigned char* class_data,
+        jint *new_class_data_len, unsigned char** new_class_data) {
+
+    if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) {
+      size_t n = strlen(FROM);
+      unsigned char* new_data;
+
+      if ((*jvmti)->Allocate(jvmti, class_data_len, &new_data) == JNI_OK) {
+        const unsigned char* s = class_data;
+        unsigned char* d = new_data;
+        unsigned char* end = d + class_data_len;
+        int count = 0;
+
+        fprintf(stderr, "found class to be hooked: %s - rewriting ...\n", name);
+
+        while (d + n < end) {
+          if (memcmp(s, FROM, n) == 0) {
+            memcpy(d, TO, n);
+            s += n;
+            d += n;
+            count++;
+          } else {
+            *d++ = *s++;
+          }
+        }
+        while (d < end) {
+          *d++ = *s++;
+        }
+
+        *new_class_data_len = class_data_len;
+        *new_class_data = new_data;
+
+        fprintf(stderr, "Rewriting done. Replaced %d occurrence(s)\n", count);
+      }
+    }
+}
+
+static jint init_options(char *options) {
+  char* class_name;
+  char* from;
+  char* to;
+
+  fprintf(stderr, "Agent library loaded with options = %s\n", options);
+  if ((class_name = options) != NULL &&
+      (from = strchr(class_name, ',')) != NULL && (from[1] != 0)) {
+    *from = 0;
+    from++;
+    if ((to = strchr(from, ',')) != NULL && (to[1] != 0)) {
+      *to = 0;
+      to++;
+      if (strchr(to, ',') == NULL &&
+          strlen(to) == strlen(from) &&
+          strlen(class_name) > 0 &&
+          strlen(to) > 0) {
+        CLASS_NAME = strdup(class_name);
+        FROM = strdup(from);
+        TO = strdup(to);
+        fprintf(stderr, "CLASS_NAME = %s, FROM = %s, TO = %s\n",
+                CLASS_NAME, FROM, TO);
+        return JNI_OK;
+      }
+    }
+  }
+  fprintf(stderr,
+          "Incorrect options. You need to start the JVM with -agentlib:ClassFileLoadHook=<classname>,<from>,<to>\n"
+          "where <classname> is the class you want to hook, <from> is the string in the classfile to be replaced\n"
+          "with <to>.  <from> and <to> must have the same length. Example:\n"
+          "    @run main/native -agentlib:ClassFileLoadHook=Foo,XXX,YYY ClassFileLoadHookTest\n");
+  return JNI_ERR;
+}
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+  int rc;
+
+  if ((rc = (*jvm)->GetEnv(jvm, (void **)&jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
+    fprintf(stderr, "Unable to create jvmtiEnv, GetEnv failed, error = %d\n", rc);
+    return JNI_ERR;
+  }
+  if ((rc = init_options(options)) != JNI_OK) {
+    return JNI_ERR;
+  }
+
+  (void) memset(&callbacks, 0, sizeof(callbacks));
+  callbacks.ClassFileLoadHook = &ClassFileLoadHook;
+  if ((rc = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks))) != JNI_OK) {
+    fprintf(stderr, "SetEventCallbacks failed, error = %d\n", rc);
+    return JNI_ERR;
+  }
+
+  if ((rc = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
+                                               JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)) != JNI_OK) {
+    fprintf(stderr, "SetEventNotificationMode failed, error = %d\n", rc);
+    return JNI_ERR;
+  }
+
+  return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+  return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+  return Agent_Initialize(jvm, options, reserved);
+}
diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
deleted file mode 100644
index 367e469..0000000
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.hotspot;
-
-import java.lang.reflect.Executable;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.Stream;
-import java.security.BasicPermission;
-
-import sun.hotspot.parser.DiagnosticCommand;
-
-public class WhiteBox {
-
-  @SuppressWarnings("serial")
-  public static class WhiteBoxPermission extends BasicPermission {
-    public WhiteBoxPermission(String s) {
-      super(s);
-    }
-  }
-
-  private WhiteBox() {}
-  private static final WhiteBox instance = new WhiteBox();
-  private static native void registerNatives();
-
-  /**
-   * Returns the singleton WhiteBox instance.
-   *
-   * The returned WhiteBox object should be carefully guarded
-   * by the caller, since it can be used to read and write data
-   * at arbitrary memory addresses. It must never be passed to
-   * untrusted code.
-   */
-  public synchronized static WhiteBox getWhiteBox() {
-    SecurityManager sm = System.getSecurityManager();
-    if (sm != null) {
-      sm.checkPermission(new WhiteBoxPermission("getInstance"));
-    }
-    return instance;
-  }
-
-  static {
-    registerNatives();
-  }
-
-  // Get the maximum heap size supporting COOPs
-  public native long getCompressedOopsMaxHeapSize();
-  // Arguments
-  public native void printHeapSizes();
-
-  // Memory
-  public native long getObjectAddress(Object o);
-  public native int  getHeapOopSize();
-  public native int  getVMPageSize();
-  public native boolean isObjectInOldGen(Object o);
-  public native long getObjectSize(Object o);
-
-  // Runtime
-  // Make sure class name is in the correct format
-  public boolean isClassAlive(String name) {
-    return isClassAlive0(name.replace('.', '/'));
-  }
-  private native boolean isClassAlive0(String name);
-
-  // JVMTI
-  public native void addToBootstrapClassLoaderSearch(String segment);
-  public native void addToSystemClassLoaderSearch(String segment);
-
-  // G1
-  public native boolean g1InConcurrentMark();
-  public native boolean g1IsHumongous(Object o);
-  public native long    g1NumFreeRegions();
-  public native int     g1RegionSize();
-  public native Object[]    parseCommandLine(String commandline, char delim, DiagnosticCommand[] args);
-
-  // NMT
-  public native long NMTMalloc(long size);
-  public native void NMTFree(long mem);
-  public native long NMTReserveMemory(long size);
-  public native void NMTCommitMemory(long addr, long size);
-  public native void NMTUncommitMemory(long addr, long size);
-  public native void NMTReleaseMemory(long addr, long size);
-  public native long NMTMallocWithPseudoStack(long size, int index);
-  public native boolean NMTIsDetailSupported();
-  public native boolean NMTChangeTrackingLevel();
-  public native int NMTGetHashSize();
-
-  // Compiler
-  public native void    deoptimizeAll();
-  public        boolean isMethodCompiled(Executable method) {
-    return isMethodCompiled(method, false /*not osr*/);
-  }
-  public native boolean isMethodCompiled(Executable method, boolean isOsr);
-  public        boolean isMethodCompilable(Executable method) {
-    return isMethodCompilable(method, -1 /*any*/);
-  }
-  public        boolean isMethodCompilable(Executable method, int compLevel) {
-    return isMethodCompilable(method, compLevel, false /*not osr*/);
-  }
-  public native boolean isMethodCompilable(Executable method, int compLevel, boolean isOsr);
-  public native boolean isMethodQueuedForCompilation(Executable method);
-  public        int     deoptimizeMethod(Executable method) {
-    return deoptimizeMethod(method, false /*not osr*/);
-  }
-  public native int     deoptimizeMethod(Executable method, boolean isOsr);
-  public        void    makeMethodNotCompilable(Executable method) {
-    makeMethodNotCompilable(method, -1 /*any*/);
-  }
-  public        void    makeMethodNotCompilable(Executable method, int compLevel) {
-    makeMethodNotCompilable(method, compLevel, false /*not osr*/);
-  }
-  public native void    makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr);
-  public        int     getMethodCompilationLevel(Executable method) {
-    return getMethodCompilationLevel(method, false /*not ost*/);
-  }
-  public native int     getMethodCompilationLevel(Executable method, boolean isOsr);
-  public native boolean testSetDontInlineMethod(Executable method, boolean value);
-  public        int     getCompileQueuesSize() {
-    return getCompileQueueSize(-1 /*any*/);
-  }
-  public native int     getCompileQueueSize(int compLevel);
-  public native boolean testSetForceInlineMethod(Executable method, boolean value);
-  public        boolean enqueueMethodForCompilation(Executable method, int compLevel) {
-    return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
-  }
-  public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci);
-  public native void    clearMethodState(Executable method);
-  public native void    lockCompilation();
-  public native void    unlockCompilation();
-  public native int     getMethodEntryBci(Executable method);
-  public native Object[] getNMethod(Executable method, boolean isOsr);
-  public native long    allocateCodeBlob(int size, int type);
-  public        long    allocateCodeBlob(long size, int type) {
-      int intSize = (int) size;
-      if ((long) intSize != size || size < 0) {
-          throw new IllegalArgumentException(
-                "size argument has illegal value " + size);
-      }
-      return allocateCodeBlob( intSize, type);
-  }
-  public native void    freeCodeBlob(long addr);
-  public        void    forceNMethodSweep() {
-    try {
-        forceNMethodSweep0().join();
-    } catch (InterruptedException e) {
-        Thread.currentThread().interrupt();
-    }
-  }
-  public native Thread  forceNMethodSweep0();
-  public native Object[] getCodeHeapEntries(int type);
-  public native int     getCompilationActivityMode();
-  public native Object[] getCodeBlob(long addr);
-
-  // Intered strings
-  public native boolean isInStringTable(String str);
-
-  // Memory
-  public native void readReservedMemory();
-  public native long allocateMetaspace(ClassLoader classLoader, long size);
-  public native void freeMetaspace(ClassLoader classLoader, long addr, long size);
-  public native long incMetaspaceCapacityUntilGC(long increment);
-  public native long metaspaceCapacityUntilGC();
-
-  // Force Young GC
-  public native void youngGC();
-
-  // Force Full GC
-  public native void fullGC();
-
-  // Method tries to start concurrent mark cycle.
-  // It returns false if CM Thread is always in concurrent cycle.
-  public native boolean g1StartConcMarkCycle();
-
-  // Tests on ReservedSpace/VirtualSpace classes
-  public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
-  public native void runMemoryUnitTests();
-  public native void readFromNoaccessArea();
-  public native long getThreadStackSize();
-  public native long getThreadRemainingStackSize();
-
-  // CPU features
-  public native String getCPUFeatures();
-
-  // Native extensions
-  public native long getHeapUsageForContext(int context);
-  public native long getHeapRegionCountForContext(int context);
-  public native int getContextForObject(Object obj);
-  public native void printRegionInfo(int context);
-
-  // VM flags
-  public native boolean isConstantVMFlag(String name);
-  public native boolean isLockedVMFlag(String name);
-  public native void    setBooleanVMFlag(String name, boolean value);
-  public native void    setIntxVMFlag(String name, long value);
-  public native void    setUintxVMFlag(String name, long value);
-  public native void    setUint64VMFlag(String name, long value);
-  public native void    setSizeTVMFlag(String name, long value);
-  public native void    setStringVMFlag(String name, String value);
-  public native void    setDoubleVMFlag(String name, double value);
-  public native Boolean getBooleanVMFlag(String name);
-  public native Long    getIntxVMFlag(String name);
-  public native Long    getUintxVMFlag(String name);
-  public native Long    getUint64VMFlag(String name);
-  public native Long    getSizeTVMFlag(String name);
-  public native String  getStringVMFlag(String name);
-  public native Double  getDoubleVMFlag(String name);
-  private final List<Function<String,Object>> flagsGetters = Arrays.asList(
-    this::getBooleanVMFlag, this::getIntxVMFlag, this::getUintxVMFlag,
-    this::getUint64VMFlag, this::getSizeTVMFlag, this::getStringVMFlag,
-    this::getDoubleVMFlag);
-
-  public Object getVMFlag(String name) {
-    return flagsGetters.stream()
-                       .map(f -> f.apply(name))
-                       .filter(x -> x != null)
-                       .findAny()
-                       .orElse(null);
-  }
-
-  // Jigsaw
-  public native Object DefineModule(String name, Object loader, Object[] packages);
-  public native void AddModuleExports(Object from_module, String pkg, Object to_module);
-  public native void AddReadsModule(Object from_module, Object to_module);
-  public native boolean CanReadModule(Object asking_module, Object target_module);
-  public native boolean IsExportedToModule(Object from_module, String pkg, Object to_module);
-  public native Object GetModule(Class clazz);
-  public native void AddModulePackage(Object module, String pkg);
-
-  // Image File
-  public native boolean readImageFile(String imagefile);
-
-  public native int getOffsetForName0(String name);
-  public int getOffsetForName(String name) throws Exception {
-    int offset = getOffsetForName0(name);
-    if (offset == -1) {
-      throw new RuntimeException(name + " not found");
-    }
-    return offset;
-  }
-
-}
diff --git a/hotspot/test/testlibrary_tests/AssertsTest.java b/hotspot/test/testlibrary_tests/AssertsTest.java
index baf10c9..449126c 100644
--- a/hotspot/test/testlibrary_tests/AssertsTest.java
+++ b/hotspot/test/testlibrary_tests/AssertsTest.java
@@ -25,6 +25,7 @@
 
 /* @test
  * @summary Tests the different assertions in the Assert class
+ * @modules java.base/jdk.internal.misc
  * @library /testlibrary
  */
 public class AssertsTest {
diff --git a/hotspot/test/testlibrary_tests/RedefineClassTest.java b/hotspot/test/testlibrary_tests/RedefineClassTest.java
index 48905f9..739352a 100644
--- a/hotspot/test/testlibrary_tests/RedefineClassTest.java
+++ b/hotspot/test/testlibrary_tests/RedefineClassTest.java
@@ -25,6 +25,7 @@
  * @test
  * @library /testlibrary
  * @summary Proof of concept test for RedefineClassHelper
+ * @modules java.base/jdk.internal.misc
  * @modules java.compiler
  *          java.instrument
  *          jdk.jartool/sun.tools.jar
diff --git a/hotspot/test/testlibrary_tests/SimpleClassFileLoadHookTest.java b/hotspot/test/testlibrary_tests/SimpleClassFileLoadHookTest.java
new file mode 100644
index 0000000..6f5ef8d
--- /dev/null
+++ b/hotspot/test/testlibrary_tests/SimpleClassFileLoadHookTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @library /testlibrary
+ *
+ * @run main/othervm/native -agentlib:SimpleClassFileLoadHook=Foo,XXX,YYY
+ *      SimpleClassFileLoadHookTest
+ */
+import jdk.test.lib.Asserts;
+
+class Foo {
+    static String getValue() {
+        return "XXX";
+    }
+    static String getOtherValue() {
+        return "xXXXxx";
+    }
+}
+public class SimpleClassFileLoadHookTest {
+    public static void main(String args[]) {
+        System.out.println(Foo.getValue());
+        System.out.println(Foo.getOtherValue());
+        Asserts.assertTrue("YYY".equals(Foo.getValue()) &&
+                           "xYYYxx".equals(Foo.getOtherValue()),
+                           "SimpleClassFileLoadHook should replace XXX with YYY");
+    }
+}
diff --git a/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java b/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java
index f507fb0..a114366 100644
--- a/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java
+++ b/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java
@@ -26,7 +26,7 @@
  * @bug 8012447
  * @library /testlibrary /test/lib /testlibrary/ctw/src
  * @modules java.base/jdk.internal.misc
- *          java.base/sun.reflect
+ *          java.base/jdk.internal.reflect
  *          java.management
  * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
diff --git a/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java b/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java
index 5a792a0..f9feeaa 100644
--- a/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java
+++ b/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java
@@ -26,7 +26,7 @@
  * @bug 8012447
  * @library /testlibrary /test/lib /testlibrary/ctw/src
  * @modules java.base/jdk.internal.misc
- *          java.base/sun.reflect
+ *          java.base/jdk.internal.reflect
  *          java.management
  * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
diff --git a/hotspot/test/testlibrary_tests/ctw/JarDirTest.java b/hotspot/test/testlibrary_tests/ctw/JarDirTest.java
index 1bfdc45..7bc97e6 100644
--- a/hotspot/test/testlibrary_tests/ctw/JarDirTest.java
+++ b/hotspot/test/testlibrary_tests/ctw/JarDirTest.java
@@ -26,7 +26,7 @@
  * @bug 8012447
  * @library /testlibrary /test/lib /testlibrary/ctw/src
  * @modules java.base/jdk.internal.misc
- *          java.base/sun.reflect
+ *          java.base/jdk.internal.reflect
  *          java.compiler
  *          java.management
  *          jdk.jvmstat/sun.jvmstat.monitor
diff --git a/hotspot/test/testlibrary_tests/ctw/JarsTest.java b/hotspot/test/testlibrary_tests/ctw/JarsTest.java
index 1050e51..e357912 100644
--- a/hotspot/test/testlibrary_tests/ctw/JarsTest.java
+++ b/hotspot/test/testlibrary_tests/ctw/JarsTest.java
@@ -26,7 +26,7 @@
  * @bug 8012447
  * @library /testlibrary /test/lib /testlibrary/ctw/src
  * @modules java.base/jdk.internal.misc
- *          java.base/sun.reflect
+ *          java.base/jdk.internal.reflect
  *          java.compiler
  *          java.management
  *          jdk.jvmstat/sun.jvmstat.monitor
diff --git a/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java b/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java
index 0ee48b5..3146339 100644
--- a/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java
+++ b/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java
@@ -25,6 +25,7 @@
  * @test BlobSanityTest
  * @bug 8132980
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build BlobSanityTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java
index 7a15c7d..2694ba7 100644
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java
@@ -25,6 +25,7 @@
  * @test DoubleTest
  * @bug 8028756
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build DoubleTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java
index b12f306..56ffc53 100644
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java
@@ -25,6 +25,7 @@
  * @test IntxTest
  * @bug 8038756
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build IntxTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java
index 531f59f..f8b98fa 100644
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java
@@ -25,6 +25,7 @@
  * @test StringTest
  * @bug 8028756
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build StringTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java
index c82e35e..015c02e 100644
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java
@@ -25,6 +25,7 @@
  * @test Uint64Test
  * @bug 8028756
  * @library /testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build Uint64Test
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index 3bef243..7de009b 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -361,3 +361,4 @@
 9d71d20e614777cd23c1a43b38b5c08a9094d27a jdk-9+116
 46b57560cd06ebcdd21489250628ff5f9d9d8916 jdk-9+117
 a8aa25fc6c5fda0ed7a93b8ffee62da326a752fc jdk-9+118
+f92e8518bb34a9628b11e662bf7308561a55eb3b jdk-9+119
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java
index 5563a90..0750429 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java
@@ -427,7 +427,7 @@
         Layer bootLayer = Layer.boot();
 
         Configuration cf = bootLayer.configuration()
-                .resolveRequires(finder, ModuleFinder.empty(), Set.of(mn));
+                .resolveRequires(finder, ModuleFinder.of(), Set.of(mn));
 
         PrivilegedAction<Layer> pa = () -> bootLayer.defineModules(cf, name -> loader);
         Layer layer = AccessController.doPrivileged(pa);
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java
index 131d87e..08e7f41 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
         publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId)));
 
         //check whether systemId is an urn
-        if (systemId != null && systemId.startsWith("urn:publicid:")) {
+        if (systemId != null && systemId.startsWith(Util.URN)) {
             systemId = Normalizer.decodeURN(systemId);
             if (publicId != null && !publicId.equals(systemId)) {
                 systemId = null;
@@ -67,7 +67,7 @@
         }
 
         CatalogImpl c = (CatalogImpl)catalog;
-        String resolvedSystemId = resolve(c, publicId, systemId);
+        String resolvedSystemId = Util.resolve(c, publicId, systemId);
 
         if (resolvedSystemId != null) {
             return new InputSource(resolvedSystemId);
@@ -86,55 +86,4 @@
         return null;
     }
 
-    /**
-     * Resolves the publicId or systemId using public or system entries in the catalog.
-     *
-     * The resolution follows the following rules determined by the prefer setting:
-     *
-     * prefer "system": attempts to resolve with a system entry;
-     *                  attempts to resolve with a public entry when only
-     *                  publicId is specified.
-     *
-     * prefer "public": attempts to resolve with a system entry;
-     *                  attempts to resolve with a public entry if no matching
-     *                  system entry is found.
-     * @param catalog the catalog
-     * @param publicId the publicId
-     * @param systemId the systemId
-     * @return the resolved systemId if a match is found, null otherwise
-     */
-    String resolve(CatalogImpl catalog, String publicId, String systemId) {
-        String resolvedSystemId = null;
-
-        //search the current catalog
-        catalog.reset();
-        if (systemId != null) {
-            /*
-               If a system identifier is specified, it is used no matter how
-            prefer is set.
-            */
-            resolvedSystemId = catalog.matchSystem(systemId);
-        }
-
-        if (resolvedSystemId == null && publicId != null) {
-            resolvedSystemId = catalog.matchPublic(publicId);
-        }
-
-        //mark the catalog as having been searched before trying alternatives
-        catalog.markAsSearched();
-
-        //search alternative catalogs
-        if (resolvedSystemId == null) {
-            Iterator<Catalog> iter = catalog.catalogs().iterator();
-            while (iter.hasNext()) {
-                resolvedSystemId = resolve((CatalogImpl)iter.next(), publicId, systemId);
-                if (resolvedSystemId != null) {
-                    break;
-                }
-
-            }
-        }
-
-        return resolvedSystemId;
-    }
 }
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java
index e7cb9bc..497aacf 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,18 +65,30 @@
 
         if (href == null) return null;
 
+        String result = null;
         CatalogImpl c = (CatalogImpl)catalog;
         String uri = Normalizer.normalizeURI(href);
-        String result;
-
-        //remove fragment if any.
-        int hashPos = uri.indexOf("#");
-        if (hashPos >= 0) {
-            uri = uri.substring(0, hashPos);
+        //check whether uri is an urn
+        if (uri != null && uri.startsWith(Util.URN)) {
+            String publicId = Normalizer.decodeURN(uri);
+            if (publicId != null) {
+                result = Util.resolve(c, publicId, null);
+            }
         }
 
-        //search the current catalog
-        result = resolve(c, uri);
+        //if no match with a public id, continue search for an URI
+        if (result == null) {
+            //remove fragment if any.
+            int hashPos = uri.indexOf("#");
+            if (hashPos >= 0) {
+                uri = uri.substring(0, hashPos);
+            }
+
+            //search the current catalog
+            result = resolve(c, uri);
+        }
+
+        //Report error or return the URI as is when no match is found
         if (result == null) {
             GroupEntry.ResolveType resolveType = c.getResolve();
             switch (resolveType) {
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java
index 0ebf25e..2c1a59c 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -298,6 +298,9 @@
                 case PUBLIC:
                     match = ((PublicEntry) entry).match(publicId);
                     break;
+                case URI:
+                    match = ((UriEntry) entry).match(publicId);
+                    break;
                 case GROUP:
                     match = ((GroupEntry) entry).matchPublic(publicId);
                     break;
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java
index 6beb4a8..d5b1993 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java
@@ -100,7 +100,7 @@
         } catch (UnsupportedEncodingException ex) {
             CatalogMessages.reportRunTimeError(CatalogMessages.ERR_OTHER, ex);
         }
-        return "urn:publicid:" + urn;
+        return Util.URN + urn;
     }
 
     /**
@@ -114,7 +114,7 @@
     static String decodeURN(String urn) {
         String publicId;
 
-        if (urn != null && urn.startsWith("urn:publicid:")) {
+        if (urn != null && urn.startsWith(Util.URN)) {
             publicId = urn.substring(13);
         } else {
             return urn;
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java
index 498b7ae..0c1aa29 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,11 @@
      */
     public void setName(String name) {
         CatalogMessages.reportNPEOnNull("name", name);
-        this.name = Normalizer.normalizeURI(name);
+        if (name.startsWith(Util.PUBLICID_PREFIX) || name.startsWith(Util.PUBLICID_PREFIX_ALT)) {
+            this.name = Normalizer.normalizePublicId(name);
+        } else {
+            this.name = Normalizer.normalizeURI(name);
+        }
     }
 
     /**
@@ -72,6 +76,7 @@
     public String getName() {
         return name;
     }
+
     /**
      * Get the uri attribute.
      * @return The uri attribute value.
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java
index f0fd1fd..b164f67 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java
@@ -31,6 +31,7 @@
 import java.net.URL;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Iterator;
 import jdk.xml.internal.SecuritySupport;
 
 /**
@@ -38,6 +39,61 @@
  * @since 9
  */
 class Util {
+    final static String URN = "urn:publicid:";
+    final static String PUBLICID_PREFIX = "-//";
+    final static String PUBLICID_PREFIX_ALT = "+//";
+
+    /**
+     * Finds an entry in the catalog that matches with the publicId or systemId.
+     *
+     * The resolution follows the following rules determined by the prefer setting:
+     *
+     * prefer "system": attempts to resolve with a system entry;
+     *                  attempts to resolve with a public entry when only
+     *                  publicId is specified.
+     *
+     * prefer "public": attempts to resolve with a system entry;
+     *                  attempts to resolve with a public entry if no matching
+     *                  system entry is found.
+     * @param catalog the catalog
+     * @param publicId the publicId
+     * @param systemId the systemId
+     * @return the resolved systemId if a match is found, null otherwise
+     */
+    static String resolve(CatalogImpl catalog, String publicId, String systemId) {
+        String resolvedSystemId = null;
+
+        //search the current catalog
+        catalog.reset();
+        if (systemId != null) {
+            /*
+               If a system identifier is specified, it is used no matter how
+            prefer is set.
+            */
+            resolvedSystemId = catalog.matchSystem(systemId);
+        }
+
+        if (resolvedSystemId == null && publicId != null) {
+            resolvedSystemId = catalog.matchPublic(publicId);
+        }
+
+        //mark the catalog as having been searched before trying alternatives
+        catalog.markAsSearched();
+
+        //search alternative catalogs
+        if (resolvedSystemId == null) {
+            Iterator<Catalog> iter = catalog.catalogs().iterator();
+            while (iter.hasNext()) {
+                resolvedSystemId = resolve((CatalogImpl)iter.next(), publicId, systemId);
+                if (resolvedSystemId != null) {
+                    break;
+                }
+
+            }
+        }
+
+        return resolvedSystemId;
+    }
 
     /**
      * Resolves the specified file path to an absolute systemId. If it is
diff --git a/jaxp/src/java.xml/share/classes/org/w3c/dom/package.html b/jaxp/src/java.xml/share/classes/org/w3c/dom/package.html
index a95de6c..673366b 100644
--- a/jaxp/src/java.xml/share/classes/org/w3c/dom/package.html
+++ b/jaxp/src/java.xml/share/classes/org/w3c/dom/package.html
@@ -4,9 +4,9 @@
 </head>
 <body bgcolor="white">
 Provides the interfaces for the Document Object Model (DOM). Supports the
-<a href="http://www.w3.org/TR/DOM-Level-2-Core/">Document Object Model Level 2 Core APIi</a>, 
-<a href="http://www.w3.org/TR/DOM-Level-3-Core">Document Object Model (DOM) Level 3 Core</a>, 
-and <a href="http://www.w3.org/TR/DOM-Level-3-LS">Document Object Model (DOM) Level 3 Load and Save</a>.
+<a href="http://www.w3.org/TR/DOM-Level-2-Core/">Document Object Model (DOM) Level 2 Core Specification</a>, 
+<a href="http://www.w3.org/TR/DOM-Level-3-Core">Document Object Model (DOM) Level 3 Core Specification</a>, 
+and <a href="http://www.w3.org/TR/DOM-Level-3-LS">Document Object Model (DOM) Level 3 Load and Save Specification</a>.
 
 @since 1.4
 </body>
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSS2Properties.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSS2Properties.java
index d22de1d..56c63fa 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSS2Properties.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSS2Properties.java
@@ -92,7 +92,7 @@
  * property with a value of "menu", querying for the values of the component
  * longhand properties should return the empty string.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSS2Properties {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSCharsetRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSCharsetRule.java
index 10a64ab..1241cac 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSCharsetRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSCharsetRule.java
@@ -59,7 +59,7 @@
  * header, has priority (see CSS document representation) but this is not
  * reflected in the <code>CSSCharsetRule</code>.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSCharsetRule extends CSSRule {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSFontFaceRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSFontFaceRule.java
index b4f6892..1a7e1a1 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSFontFaceRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSFontFaceRule.java
@@ -46,7 +46,7 @@
  * a CSS style sheet. The <code>@font-face</code> rule is used to hold a set
  * of font descriptions.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSFontFaceRule extends CSSRule {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSImportRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSImportRule.java
index a9d321a..e81d9a0 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSImportRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSImportRule.java
@@ -48,7 +48,7 @@
  * a CSS style sheet. The <code>@import</code> rule is used to import style
  * rules from other style sheets.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSImportRule extends CSSRule {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSMediaRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSMediaRule.java
index bf153d9..b102a8a 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSMediaRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSMediaRule.java
@@ -49,7 +49,7 @@
  * style sheet. A <code>@media</code> rule can be used to delimit style
  * rules for specific media types.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSMediaRule extends CSSRule {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPageRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPageRule.java
index 773b746..fc73252 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPageRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPageRule.java
@@ -48,7 +48,7 @@
  * CSS style sheet. The <code>@page</code> rule is used to specify the
  * dimensions, orientation, margins, etc. of a page box for paged media.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSPageRule extends CSSRule {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPrimitiveValue.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPrimitiveValue.java
index 3078d72..2646a03 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPrimitiveValue.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSPrimitiveValue.java
@@ -61,7 +61,7 @@
  * the range 0-255, a color percentage value can be converted to a number;
  * (see also the <code>RGBColor</code> interface).
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSPrimitiveValue extends CSSValue {
     // UnitTypes
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRule.java
index f81d0d5..338f490 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRule.java
@@ -50,7 +50,7 @@
  * sheet, even if the rule is not recognized by the parser. Unrecognized
  * rules are represented using the <code>CSSUnknownRule</code> interface.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSRule {
     // RuleType
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRuleList.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRuleList.java
index 33840ef..dd6f033 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRuleList.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSRuleList.java
@@ -47,7 +47,7 @@
  * <p> The items in the <code>CSSRuleList</code> are accessible via an
  * integral index, starting from 0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSRuleList {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleDeclaration.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleDeclaration.java
index de63268..c6bd17f 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleDeclaration.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleDeclaration.java
@@ -60,7 +60,7 @@
  * interface.  The CSS Object Model doesn't provide an access to the
  * specified or actual values of the CSS cascade.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSStyleDeclaration {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleRule.java
index e165cd1..5e0e92d 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleRule.java
@@ -47,7 +47,7 @@
  *  The <code>CSSStyleRule</code> interface represents a single rule set in a
  * CSS style sheet.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSStyleRule extends CSSRule {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleSheet.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleSheet.java
index d3cf723..2c021dc 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleSheet.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSStyleSheet.java
@@ -49,7 +49,7 @@
  * represent a CSS style sheet i.e., a style sheet whose content type is
  * "text/css".
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSStyleSheet extends StyleSheet {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSUnknownRule.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSUnknownRule.java
index 0b1d87b..8b7b3f6 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSUnknownRule.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSUnknownRule.java
@@ -45,7 +45,7 @@
  *  The <code>CSSUnknownRule</code> interface represents an at-rule not
  * supported by this user agent.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSUnknownRule extends CSSRule {
 }
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValue.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValue.java
index ae4effa..54aa703 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValue.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValue.java
@@ -48,7 +48,7 @@
  * value. A <code>CSSValue</code> object only occurs in a context of a CSS
  * property.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSValue {
     // UnitTypes
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValueList.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValueList.java
index 1567399..db62e1c 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValueList.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/CSSValueList.java
@@ -50,7 +50,7 @@
  * <p> The items in the <code>CSSValueList</code> are accessible via an
  * integral index, starting from 0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface CSSValueList extends CSSValue {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Counter.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Counter.java
index 44a2993..9da6a19 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Counter.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Counter.java
@@ -46,7 +46,7 @@
  * counters function value. This interface reflects the values in the
  * underlying style property.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface Counter {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DOMImplementationCSS.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DOMImplementationCSS.java
index 2aeb37e..b047fcb 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DOMImplementationCSS.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DOMImplementationCSS.java
@@ -49,7 +49,7 @@
  * outside the context of a document. There is no way to associate the new
  * <code>CSSStyleSheet</code> with a document in DOM Level 2.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM   Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface DOMImplementationCSS extends DOMImplementation {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DocumentCSS.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DocumentCSS.java
index 47399a7..f68b9e2 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DocumentCSS.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/DocumentCSS.java
@@ -62,7 +62,7 @@
  * interface can be obtained by using binding-specific casting methods on an
  * instance of the <code>Document</code> interface.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface DocumentCSS extends DocumentStyle {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ElementCSSInlineStyle.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ElementCSSInlineStyle.java
index c7e7053..2822d91 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ElementCSSInlineStyle.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ElementCSSInlineStyle.java
@@ -50,7 +50,7 @@
  * binding-specific casting methods on an instance of the Element interface
  * when the element supports inline CSS style informations.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface ElementCSSInlineStyle {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/RGBColor.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/RGBColor.java
index 7d37458..00bb451 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/RGBColor.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/RGBColor.java
@@ -55,7 +55,7 @@
  * <p> A color percentage value can always be converted to a number and vice
  * versa.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface RGBColor {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Rect.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Rect.java
index b9e6956..e8e0a73 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Rect.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/Rect.java
@@ -47,7 +47,7 @@
  * modifications made to the <code>CSSPrimitiveValue</code> objects modify
  * the style property.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface Rect {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ViewCSS.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ViewCSS.java
index 38b22b3..caf705c 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ViewCSS.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/css/ViewCSS.java
@@ -55,7 +55,7 @@
  * <code>CSSStyleDeclaration</code> and <code>CSSValue</code> related to
  * this declaration are no longer valid.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface ViewCSS extends AbstractView {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAnchorElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAnchorElement.java
index 8e4f6e7..9eb9f85 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAnchorElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAnchorElement.java
@@ -44,6 +44,8 @@
 /**
  *  The anchor element. See the  A element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLAnchorElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAppletElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAppletElement.java
index d159319..21ab47b 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAppletElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAppletElement.java
@@ -45,6 +45,8 @@
  *  An embedded Java applet. See the  APPLET element definition in HTML 4.0.
  * This element is deprecated in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLAppletElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAreaElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAreaElement.java
index f51cc31..743d399 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAreaElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLAreaElement.java
@@ -45,6 +45,8 @@
  *  Client-side image map area definition. See the  AREA element definition in
  * HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLAreaElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBRElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBRElement.java
index f35212f..3745d48 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBRElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBRElement.java
@@ -44,6 +44,8 @@
 /**
  *  Force a line break. See the  BR element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLBRElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseElement.java
index 69f518b..473b492 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseElement.java
@@ -44,6 +44,8 @@
 /**
  *  Document base URI. See the  BASE element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLBaseElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseFontElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseFontElement.java
index 68ed611..327ef9d 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseFontElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBaseFontElement.java
@@ -45,6 +45,8 @@
  *  Base font. See the  BASEFONT element definition in HTML 4.0. This element
  * is deprecated in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLBaseFontElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBodyElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBodyElement.java
index d0f2e45..ad14b86 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBodyElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLBodyElement.java
@@ -46,6 +46,8 @@
  * even if the tags are not present in the source document. See the  BODY
  * element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLBodyElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLButtonElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLButtonElement.java
index 8d45dbf..578b686 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLButtonElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLButtonElement.java
@@ -44,6 +44,8 @@
 /**
  *  Push button. See the  BUTTON element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLButtonElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLCollection.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLCollection.java
index 1c87fd9..f59ae97 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLCollection.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLCollection.java
@@ -50,6 +50,8 @@
  * to be  live meaning that they are automatically updated when the
  * underlying document is changed.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLCollection {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDListElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDListElement.java
index 8e0dad9..3b74758 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDListElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDListElement.java
@@ -44,6 +44,8 @@
 /**
  *  Definition list. See the  DL element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLDListElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDOMImplementation.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDOMImplementation.java
index 4d15541..698f097 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDOMImplementation.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDOMImplementation.java
@@ -47,7 +47,8 @@
  *  The <code>HTMLDOMImplementation</code> interface extends the
  * <code>DOMImplementation</code> interface with a method for creating an
  * HTML document instance.
- * @since DOM Level 2
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLDOMImplementation extends DOMImplementation {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDirectoryElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDirectoryElement.java
index 0fb3390..19fbc96 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDirectoryElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDirectoryElement.java
@@ -45,6 +45,8 @@
  *  Directory list. See the  DIR element definition in HTML 4.0. This element
  * is deprecated in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLDirectoryElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDivElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDivElement.java
index ee1b727..f204f28 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDivElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDivElement.java
@@ -44,6 +44,8 @@
 /**
  *  Generic block container. See the  DIV element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLDivElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDocument.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDocument.java
index 5116fc5..06e6eb7 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDocument.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLDocument.java
@@ -55,6 +55,8 @@
  * <code>getElementById</code> is inherited from the <code>Document</code>
  * interface where it was moved.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLDocument extends Document {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLElement.java
index b5b178a..cc0727e 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLElement.java
@@ -53,6 +53,8 @@
  * of an HTML element is accessible through the
  * <code>ElementCSSInlineStyle</code> interface which is defined in the  .
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLElement extends Element {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFieldSetElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFieldSetElement.java
index cb2c0bd..0c650d1 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFieldSetElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFieldSetElement.java
@@ -45,6 +45,8 @@
  *  Organizes form controls into logical groups. See the   FIELDSET  element
  * definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLFieldSetElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFontElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFontElement.java
index c8fc157..b9a0c7b 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFontElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFontElement.java
@@ -45,6 +45,8 @@
  *  Local change to font. See the  FONT element definition in HTML 4.0. This
  * element is deprecated in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLFontElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFormElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFormElement.java
index 42e2edd..0c00bd2 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFormElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFormElement.java
@@ -47,6 +47,8 @@
  * as well as the attributes of the form element. See the  FORM element
  * definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLFormElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameElement.java
index 5ffa425..92891a9 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameElement.java
@@ -46,6 +46,8 @@
 /**
  *  Create a frame. See the  FRAME element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLFrameElement extends HTMLElement {
     /**
@@ -107,7 +109,7 @@
     /**
      *  The document this frame contains, if there is any and it is available,
      * or <code>null</code> otherwise.
-     * @since DOM Level 2
+     * @since 1.4, DOM Level 2
      */
     public Document getContentDocument();
 
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameSetElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameSetElement.java
index fb6f7e9..60112d7 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameSetElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLFrameSetElement.java
@@ -44,6 +44,8 @@
 /**
  *  Create a grid of frames. See the  FRAMESET element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLFrameSetElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHRElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHRElement.java
index 334c04d..c0fbfda 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHRElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHRElement.java
@@ -44,6 +44,8 @@
 /**
  *  Create a horizontal rule. See the  HR element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLHRElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadElement.java
index 8894d32..319e6a5 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadElement.java
@@ -44,6 +44,8 @@
 /**
  *  Document head information. See the  HEAD element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLHeadElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadingElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadingElement.java
index 0cd4efe..f46bf5b 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadingElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHeadingElement.java
@@ -45,6 +45,8 @@
  *  For the <code>H1</code> to <code>H6</code> elements. See the  H1 element
  * definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLHeadingElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHtmlElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHtmlElement.java
index a2fa379..75a6cfa 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHtmlElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLHtmlElement.java
@@ -44,6 +44,8 @@
 /**
  *  Root of an HTML document. See the  HTML element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLHtmlElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIFrameElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIFrameElement.java
index 08c1988..7a7ffd6 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIFrameElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIFrameElement.java
@@ -46,6 +46,8 @@
 /**
  *  Inline subwindows. See the  IFRAME element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLIFrameElement extends HTMLElement {
     /**
@@ -120,7 +122,7 @@
     /**
      *  The document this frame contains, if there is any and it is available,
      * or <code>null</code> otherwise.
-     * @since DOM Level 2
+     * @since 1.4, DOM Level 2
      */
     public Document getContentDocument();
 
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLImageElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLImageElement.java
index 7fced61..238464d 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLImageElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLImageElement.java
@@ -44,6 +44,8 @@
 /**
  *  Embedded image. See the  IMG element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLImageElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLInputElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLInputElement.java
index b58d8b8..15d6d03 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLInputElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLInputElement.java
@@ -48,6 +48,8 @@
  * be masked to prevent unauthorized use. See the  INPUT element definition
  * in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLInputElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIsIndexElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIsIndexElement.java
index 111edde..2766c9e 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIsIndexElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLIsIndexElement.java
@@ -45,6 +45,8 @@
  *  This element is used for single-line text input. See the  ISINDEX element
  * definition in HTML 4.0. This element is deprecated in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLIsIndexElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLIElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLIElement.java
index f4113f1..e368c51 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLIElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLIElement.java
@@ -44,6 +44,8 @@
 /**
  *  List item. See the  LI element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLLIElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLabelElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLabelElement.java
index d3fd6be..d9bc78a 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLabelElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLabelElement.java
@@ -44,6 +44,8 @@
 /**
  *  Form field label text. See the  LABEL element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLLabelElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLegendElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLegendElement.java
index ffe0816..f9b5490 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLegendElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLegendElement.java
@@ -45,6 +45,8 @@
  *  Provides a caption for a <code>FIELDSET</code> grouping.  See the  LEGEND
  * element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLLegendElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLinkElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLinkElement.java
index cc03164..0824d0c 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLinkElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLLinkElement.java
@@ -47,6 +47,8 @@
  *  See the  LINK element definition in HTML 4.0  (see also the
  * <code>LinkStyle</code> interface in the  module).
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLLinkElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMapElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMapElement.java
index f2b4222..cb834e6 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMapElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMapElement.java
@@ -44,6 +44,8 @@
 /**
  *  Client-side image map. See the  MAP element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLMapElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMenuElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMenuElement.java
index b579879..cd7ea2b 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMenuElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMenuElement.java
@@ -45,6 +45,8 @@
  *  Menu list. See the  MENU element definition in HTML 4.0. This element is
  * deprecated in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLMenuElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMetaElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMetaElement.java
index 38920e4..4b6e253 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMetaElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLMetaElement.java
@@ -45,6 +45,8 @@
  *  This contains generic meta-information about the document. See the  META
  * element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLMetaElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLModElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLModElement.java
index cfd96a10..17e36db 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLModElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLModElement.java
@@ -45,6 +45,8 @@
  *  Notice of modification to part of a document. See the   INS  and  DEL
  * element definitions in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLModElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOListElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOListElement.java
index 728e760f..9599c48 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOListElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOListElement.java
@@ -44,6 +44,8 @@
 /**
  *  Ordered list. See the  OL element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLOListElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLObjectElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLObjectElement.java
index 972091b..2e1e631 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLObjectElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLObjectElement.java
@@ -49,6 +49,8 @@
  * read-only once the underlying object is instantiated. See the  OBJECT
  * element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLObjectElement extends HTMLElement {
     /**
@@ -181,7 +183,7 @@
     /**
      *  The document this object contains, if there is any and it is
      * available, or <code>null</code> otherwise.
-     * @since DOM Level 2
+     * @since 1.4, DOM Level 2
      */
     public Document getContentDocument();
 
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptGroupElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptGroupElement.java
index edddf36..de00e8c 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptGroupElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptGroupElement.java
@@ -45,6 +45,8 @@
  *  Group options together in logical subdivisions. See the  OPTGROUP element
  * definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLOptGroupElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptionElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptionElement.java
index 2736588..22e348b 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptionElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLOptionElement.java
@@ -44,6 +44,8 @@
 /**
  *  A selectable choice. See the  OPTION element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLOptionElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParagraphElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParagraphElement.java
index a7dc5d6..c5e43b4 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParagraphElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParagraphElement.java
@@ -44,6 +44,8 @@
 /**
  *  Paragraphs. See the  P element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLParagraphElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParamElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParamElement.java
index 6b18476..b7b8664 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParamElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLParamElement.java
@@ -45,6 +45,8 @@
  *  Parameters fed to the <code>OBJECT</code> element. See the  PARAM element
  * definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLParamElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLPreElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLPreElement.java
index 40b199f..a8bce79 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLPreElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLPreElement.java
@@ -44,6 +44,8 @@
 /**
  *  Preformatted text. See the  PRE element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLPreElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLQuoteElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLQuoteElement.java
index 61abf1f..db0b10d 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLQuoteElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLQuoteElement.java
@@ -45,6 +45,8 @@
  *  For the <code>Q</code> and <code>BLOCKQUOTE</code> elements. See the  Q
  * element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLQuoteElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLScriptElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLScriptElement.java
index 5004a41..9931a02 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLScriptElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLScriptElement.java
@@ -44,6 +44,8 @@
 /**
  *  Script statements. See the  SCRIPT element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLScriptElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLSelectElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLSelectElement.java
index 9611cca..85d6c21 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLSelectElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLSelectElement.java
@@ -48,6 +48,8 @@
  * options can be directly accessed through the select element as a
  * collection. See the  SELECT element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLSelectElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLStyleElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLStyleElement.java
index d811e85..5e7b99f 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLStyleElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLStyleElement.java
@@ -45,6 +45,8 @@
  *  Style information. See the  STYLE element definition in HTML 4.0, the
  * module and the <code>LinkStyle</code> interface in the  module.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLStyleElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCaptionElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCaptionElement.java
index b800137..f2126d3 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCaptionElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCaptionElement.java
@@ -44,6 +44,8 @@
 /**
  *  Table caption See the  CAPTION element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTableCaptionElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCellElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCellElement.java
index b7debbf..53b4102 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCellElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableCellElement.java
@@ -45,6 +45,8 @@
  *  The object used to represent the <code>TH</code> and <code>TD</code>
  * elements. See the  TD element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTableCellElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableColElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableColElement.java
index d7ece0f..fcf413f 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableColElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableColElement.java
@@ -45,6 +45,8 @@
  *  Regroups the <code>COL</code> and <code>COLGROUP</code> elements. See the
  * COL element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTableColElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableElement.java
index f57d51c..d73421a 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableElement.java
@@ -52,6 +52,8 @@
  * existing THead or TFoot element. See the  TABLE element definition in HTML
  * 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTableElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableRowElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableRowElement.java
index a24ff42..fed6b20 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableRowElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableRowElement.java
@@ -46,6 +46,8 @@
 /**
  *  A row in a table. See the  TR element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTableRowElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableSectionElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableSectionElement.java
index f6c3cfa..e68156d 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableSectionElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTableSectionElement.java
@@ -47,6 +47,8 @@
  *  The <code>THEAD</code> , <code>TFOOT</code> , and <code>TBODY</code>
  * elements.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTableSectionElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTextAreaElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTextAreaElement.java
index 1546a7d..85afeba 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTextAreaElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTextAreaElement.java
@@ -44,6 +44,8 @@
 /**
  *  Multi-line text field. See the  TEXTAREA element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTextAreaElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTitleElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTitleElement.java
index 9b3c1cb..166f783 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTitleElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLTitleElement.java
@@ -44,6 +44,8 @@
 /**
  *  The document title. See the  TITLE element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLTitleElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLUListElement.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLUListElement.java
index cd4386a..b58342e 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLUListElement.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/html/HTMLUListElement.java
@@ -44,6 +44,8 @@
 /**
  *  Unordered list. See the  UL element definition in HTML 4.0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
+ *
+ * @since 1.4, DOM Level 2
  */
 public interface HTMLUListElement extends HTMLElement {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/DocumentStyle.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/DocumentStyle.java
index 2be39e7..2c8ce70 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/DocumentStyle.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/DocumentStyle.java
@@ -48,7 +48,7 @@
  * obtained by using binding-specific casting methods on an instance of the
  * <code>Document</code> interface.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface DocumentStyle {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/LinkStyle.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/LinkStyle.java
index 9bd7b68..496bc64 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/LinkStyle.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/LinkStyle.java
@@ -49,7 +49,7 @@
  * linking node (<code>HTMLLinkElement</code>, <code>HTMLStyleElement</code>
  * or <code>ProcessingInstruction</code> in DOM Level 2).
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface LinkStyle {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/MediaList.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/MediaList.java
index 1a82767..ba57166 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/MediaList.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/MediaList.java
@@ -51,7 +51,7 @@
  * <p> The items in the <code>MediaList</code> are accessible via an integral
  * index, starting from 0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface MediaList {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheet.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheet.java
index 617c68e..40df308 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheet.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheet.java
@@ -51,7 +51,7 @@
  * an inline  STYLE element. In XML, this interface represents an external
  * style sheet, included via a style sheet processing instruction.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface StyleSheet {
     /**
diff --git a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheetList.java b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheetList.java
index 6cd5254..468f0c1 100644
--- a/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheetList.java
+++ b/jaxp/src/jdk.xml.dom/share/classes/org/w3c/dom/stylesheets/StyleSheetList.java
@@ -47,7 +47,7 @@
  * <p> The items in the <code>StyleSheetList</code> are accessible via an
  * integral index, starting from 0.
  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
- * @since DOM Level 2
+ * @since 1.4, DOM Level 2
  */
 public interface StyleSheetList {
     /**
diff --git a/jaxp/test/Makefile b/jaxp/test/Makefile
index bf94d25..63f1904 100644
--- a/jaxp/test/Makefile
+++ b/jaxp/test/Makefile
@@ -265,7 +265,10 @@
 # ------------------------------------------------------------------
 
 ifdef CONCURRENCY
-  EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
+  JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+endif
+ifdef EXTRA_JTREG_OPTIONS
+  JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 endif
 
 # Default JTREG to run
@@ -290,8 +293,6 @@
 # Set the max memory for jtreg control vm
 JTREG_MEMORY_OPTION = -J-Xmx512m
 JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION)
-# Add any extra options
-JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 # Set other vm and test options
 JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%)
 # Set the GC options for test vms
diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java
index 3e15767..74f051a 100644
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import static java.lang.module.ModuleFinder.empty;
 import static org.testng.Assert.assertSame;
 import static org.testng.Assert.assertTrue;
 
@@ -97,7 +96,7 @@
     public void testOneLayer() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1);
         Configuration cf1 = Layer.boot().configuration()
-                .resolveRequiresAndUses(finder1, empty(), Set.of("test"));
+                .resolveRequiresAndUses(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
         ClassLoader cl1 = layer1.findLoader("test");
@@ -127,12 +126,12 @@
     public void testTwoLayer() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1);
         Configuration cf1 = Layer.boot().configuration()
-                .resolveRequiresAndUses(finder1, empty(), Set.of("test"));
+                .resolveRequiresAndUses(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
 
         ModuleFinder finder2 = ModuleFinder.of(MOD_DIR2);
-        Configuration cf2 = cf1.resolveRequiresAndUses(finder2, empty(), Set.of("test"));
+        Configuration cf2 = cf1.resolveRequiresAndUses(finder2, ModuleFinder.of(), Set.of("test"));
         Layer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
         ClassLoader cl2 = layer2.findLoader("test");
 
@@ -161,12 +160,12 @@
     public void testTwoLayerWithDuplicate() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1, MOD_DIR2);
         Configuration cf1 = Layer.boot().configuration()
-                .resolveRequiresAndUses(finder1, empty(), Set.of("test"));
+                .resolveRequiresAndUses(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
 
         ModuleFinder finder2 = ModuleFinder.of(MOD_DIR2);
-        Configuration cf2 = cf1.resolveRequiresAndUses(finder2, empty(), Set.of("test"));
+        Configuration cf2 = cf1.resolveRequiresAndUses(finder2, ModuleFinder.of(), Set.of("test"));
         Layer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
         ClassLoader cl2 = layer2.findLoader("test");
 
diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java
index 01bf4f6..dc5e881 100644
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java
@@ -34,6 +34,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Source;
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
@@ -68,6 +69,24 @@
     }
 
     /*
+     * @bug 8156845
+     * Verifies that an URI reference with a urn:publicid is correctly resolved
+     * with an uri entry with a publicId.
+     *
+     * @param expectedFile is not used in this test, it's kept since we're
+     * copying the JCK test and its dataProvider. This test may be reused for
+     * other cases in that test.
+     */
+    @Test(dataProvider = "resolveUri")
+    public void testMatch1(String cFile, String href, String expectedFile, String expectedUri, String msg) {
+        String catalogFile = getClass().getResource(cFile).getFile();
+        CatalogUriResolver cur = CatalogManager.catalogUriResolver(CatalogFeatures.defaults(), catalogFile);
+        Source source = cur.resolve(href, null);
+        Assert.assertNotNull(source, "Source returned is null");
+        Assert.assertEquals(expectedUri, source.getSystemId(), msg);
+    }
+
+    /*
      * @bug 8154220
      * Verifies that the file input is validated properly. Valid input includes
      * multiple file paths separated by semicolon.
@@ -329,6 +348,21 @@
         }
     }
 
+
+    /*
+        DataProvider: used to verify CatalogUriResolver's resolve function.
+        Data columns:
+        catalog, uri or publicId, expectedFile, expectedUri, msg
+
+        This DataProvider is copied from JCK ResolveTests' dataMatch1
+     */
+    @DataProvider(name = "resolveUri")
+    Object[][] getDataForUriResolver() {
+        return new Object[][]{
+            {"uri.xml", "urn:publicid:-:Acme,+Inc.:DTD+Book+Version+1.0", null, "http://local/base/dtd/book.dtd", "Uri in publicId namespace is incorrectly unwrapped"},
+        };
+    }
+
     /*
         DataProvider: used to verify hierarchical catalogs. Refer to JCK test
     hierarchyOfCatFiles2.
diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/uri.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/uri.xml
new file mode 100644
index 0000000..f092ae8
--- /dev/null
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/uri.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base="http://local/base/dtd/">
+    <uri name="-//Acme, Inc.//DTD Book Version 1.0" uri="book.dtd"/> 
+</catalog> 
\ No newline at end of file
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 4d92200..0fe31aa 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -364,3 +364,4 @@
 529f0bf896e58525614d863e283ad155531941cb jdk-9+116
 58265b39fc74b932bda4d4f4649c530a89f55c4e jdk-9+117
 6ba73d04589ccc0705a5d8ae5111b63632b6ad20 jdk-9+118
+331a825f849afd2e5126c93c88e55bd9ef0c6b8f jdk-9+119
diff --git a/jdk/.hgtags b/jdk/.hgtags
index 2b6d80d..b7e36c3 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -361,3 +361,4 @@
 baeb5edb38939cdb78ae0ac6f4fd368465cbf188 jdk-9+116
 4da0f73ce03aaf245b92cc040cc0ab0e3fa54dc2 jdk-9+117
 e1eba5cfa5cc8c66d524396a05323dc93568730a jdk-9+118
+bad3f8a33db271a6143ba6eac0c8bd5bbd942417 jdk-9+119
diff --git a/jdk/make/Import.gmk b/jdk/make/Import.gmk
index d479b09..29e4ce0 100644
--- a/jdk/make/Import.gmk
+++ b/jdk/make/Import.gmk
@@ -112,7 +112,7 @@
 	$(LN) -s ../$(@F) $@
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
-  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.dSYM : $(BASE_INSTALL_LIBRARIES_HERE)/%.dSYM
+  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.dSYM:
 	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(LN) -s ../$(@F) $@
diff --git a/jdk/make/data/currency/CurrencyData.properties b/jdk/make/data/currency/CurrencyData.properties
index 808d01d..0288b04 100644
--- a/jdk/make/data/currency/CurrencyData.properties
+++ b/jdk/make/data/currency/CurrencyData.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
 # Version of the currency data format.
 #   1: initial
 #   2: Change in minor unit (allowing 4-9 digits)
-formatVersion=2
+#   3: Change in the order of special case and other currency entries
+formatVersion=3
 
 # Version of the currency code information in this class.
 # It is a serial number that accompanies with each amendment.
diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk
index 73b452f..b4c6f5e 100644
--- a/jdk/make/lib/Awt2dLibraries.gmk
+++ b/jdk/make/lib/Awt2dLibraries.gmk
@@ -96,10 +96,7 @@
       mlib_c_ImageAffine_BL.c \
       mlib_c_ImageAffine_BL_S16.c \
       mlib_c_ImageAffine_BL_U16.c \
-      mlib_c_ImageAffineIndex_BC.c \
-      mlib_c_ImageAffineIndex_BL.c \
       mlib_c_ImageAffine_NN.c \
-      mlib_c_ImageBlendTable.c \
       mlib_c_ImageConvClearEdge.c \
       mlib_c_ImageConvCopyEdge.c \
       mlib_c_ImageConv_f.c \
@@ -107,14 +104,6 @@
       mlib_c_ImageCopy.c \
       mlib_c_ImageLookUp.c \
       mlib_c_ImageLookUp_f.c \
-      mlib_v_ImageChannelExtract.c \
-      mlib_v_ImageChannelExtract_f.c \
-      mlib_v_ImageChannelInsert_34.c \
-      mlib_v_ImageChannelInsert.c \
-      mlib_v_ImageConvIndex3_8_16nw.c \
-      mlib_v_ImageConvIndex3_8_8nw.c \
-      mlib_v_ImageCopy.c \
-      mlib_v_ImageCopy_blk.s \
       #
 
   LIBMLIB_IMAGE_V_CFLAGS += $(filter-out -DMLIB_NO_LIBSUNMATH, $(BUILD_LIBMLIB_CFLAGS))
diff --git a/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java b/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java
index f158342..b72ac92 100644
--- a/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java
+++ b/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -584,7 +584,9 @@
                 String[] data = (String[])e[1];
 
                 if (map.get(TIMEZONE_ID_PREFIX + tzid) == null &&
-                    handlerMetaZones.get(tzid) == null) {
+                    handlerMetaZones.get(tzid) == null ||
+                    handlerMetaZones.get(tzid) != null &&
+                    map.get(METAZONE_ID_PREFIX + handlerMetaZones.get(tzid)) == null) {
                     // First, check the CLDR meta key
                     Optional<Map.Entry<String, String>> cldrMeta =
                         handlerMetaZones.getData().entrySet().stream()
diff --git a/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java b/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
index cc12563..ae861c5 100644
--- a/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
+++ b/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -121,7 +121,7 @@
 
     private static final int maxOtherCurrencies = 128;
     private static int otherCurrenciesCount = 0;
-    private static StringBuffer otherCurrencies = new StringBuffer();
+    private static String[] otherCurrencies = new String[maxOtherCurrencies];
     private static int[] otherCurrenciesDefaultFractionDigits = new int[maxOtherCurrencies];
     private static int[] otherCurrenciesNumericCode= new int[maxOtherCurrencies];
 
@@ -318,10 +318,7 @@
                 if (otherCurrenciesCount == maxOtherCurrencies) {
                     throw new RuntimeException("too many other currencies");
                 }
-                if (otherCurrencies.length() > 0) {
-                    otherCurrencies.append('-');
-                }
-                otherCurrencies.append(currencyCode);
+                otherCurrencies[otherCurrenciesCount] = currencyCode;
                 otherCurrenciesDefaultFractionDigits[otherCurrenciesCount] = getDefaultFractionDigits(currencyCode);
                 otherCurrenciesNumericCode[otherCurrenciesCount] = getNumericCode(currencyCode);
                 otherCurrenciesCount++;
@@ -350,35 +347,41 @@
         out.writeInt(Integer.parseInt(dataVersion));
         writeIntArray(mainTable, mainTable.length);
         out.writeInt(specialCaseCount);
-        writeLongArray(specialCaseCutOverTimes, specialCaseCount);
-        writeStringArray(specialCaseOldCurrencies, specialCaseCount);
-        writeStringArray(specialCaseNewCurrencies, specialCaseCount);
-        writeIntArray(specialCaseOldCurrenciesDefaultFractionDigits, specialCaseCount);
-        writeIntArray(specialCaseNewCurrenciesDefaultFractionDigits, specialCaseCount);
-        writeIntArray(specialCaseOldCurrenciesNumericCode, specialCaseCount);
-        writeIntArray(specialCaseNewCurrenciesNumericCode, specialCaseCount);
+        writeSpecialCaseEntries();
         out.writeInt(otherCurrenciesCount);
-        out.writeUTF(otherCurrencies.toString());
-        writeIntArray(otherCurrenciesDefaultFractionDigits, otherCurrenciesCount);
-        writeIntArray(otherCurrenciesNumericCode, otherCurrenciesCount);
+        writeOtherCurrencies();
     }
 
     private static void writeIntArray(int[] ia, int count) throws IOException {
-        for (int i = 0; i < count; i ++) {
+        for (int i = 0; i < count; i++) {
             out.writeInt(ia[i]);
         }
     }
 
-    private static void writeLongArray(long[] la, int count) throws IOException  {
-        for (int i = 0; i < count; i ++) {
-            out.writeLong(la[i]);
+    private static void writeSpecialCaseEntries() throws IOException {
+        for (int index = 0; index < specialCaseCount; index++) {
+            out.writeLong(specialCaseCutOverTimes[index]);
+            String str = (specialCaseOldCurrencies[index] != null)
+                    ? specialCaseOldCurrencies[index] : "";
+            out.writeUTF(str);
+            str = (specialCaseNewCurrencies[index] != null)
+                    ? specialCaseNewCurrencies[index] : "";
+            out.writeUTF(str);
+            out.writeInt(specialCaseOldCurrenciesDefaultFractionDigits[index]);
+            out.writeInt(specialCaseNewCurrenciesDefaultFractionDigits[index]);
+            out.writeInt(specialCaseOldCurrenciesNumericCode[index]);
+            out.writeInt(specialCaseNewCurrenciesNumericCode[index]);
         }
     }
 
-    private static void writeStringArray(String[] sa, int count) throws IOException  {
-        for (int i = 0; i < count; i ++) {
-            String str = (sa[i] != null) ? sa[i] : "";
+    private static void writeOtherCurrencies() throws IOException {
+        for (int index = 0; index < otherCurrenciesCount; index++) {
+            String str = (otherCurrencies[index] != null)
+                    ? otherCurrencies[index] : "";
             out.writeUTF(str);
+            out.writeInt(otherCurrenciesDefaultFractionDigits[index]);
+            out.writeInt(otherCurrenciesNumericCode[index]);
         }
     }
+
 }
diff --git a/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java b/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java
index da77475..04badbd 100644
--- a/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java
+++ b/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java
@@ -82,14 +82,14 @@
             mods.add(name);
             Configuration cf = Configuration.empty()
                     .resolveRequires(finder,
-                                     ModuleFinder.empty(),
+                                     ModuleFinder.of(),
                                      Set.of(name));
             genGraphs.genDotFile(dir, name, cf);
         }
 
         Configuration cf = Configuration.empty()
                 .resolveRequires(finder,
-                                 ModuleFinder.empty(),
+                                 ModuleFinder.of(),
                                  mods);
         genGraphs.genDotFile(dir, "jdk", cf);
 
diff --git a/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java b/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java
index c1b15d3..f274afd 100644
--- a/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java
+++ b/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java
@@ -292,7 +292,7 @@
     static Configuration resolve(Set<String> roots) {
         return Configuration.empty()
             .resolveRequires(ModuleFinder.ofSystem(),
-                             ModuleFinder.empty(),
+                             ModuleFinder.of(),
                              roots);
     }
 
diff --git a/jdk/src/demo/share/jvmti/index.html b/jdk/src/demo/share/jvmti/index.html
index 25440a1..5791b8b 100644
--- a/jdk/src/demo/share/jvmti/index.html
+++ b/jdk/src/demo/share/jvmti/index.html
@@ -415,7 +415,7 @@
 Various technical articles are also available through this website.
 And don't forget the 
 Java Tutorials at 
-<A HREF="http://java.sun.com/docs/books/tutorial">http://java.sun.com/docs/books/tutorial</A>
+<A HREF="http://docs.oracle.com/javase/tutorial">http://docs.oracle.com/javase/tutorial</A>
 for getting a quick start on all the various interfaces.
 
 <h2>Comments and Feedback</h2>
diff --git a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java
index fee0b80..50dc802 100644
--- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java
+++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,9 +43,10 @@
         1.0 to 1.3.X 45,3
         1.4 to 1.4.X 46,0
         1.5 to 1.5.X 49,0
-        1.6 to 1.5.x 50,0
-        1.7 to 1.6.x 51,0
-        1.8 to 1.7.x 52,0
+        1.6 to 1.6.X 50,0
+        1.7 to 1.7.X 51,0
+        1.8 to 1.8.X 52,0
+        1.9 to 1.9.X 53,0
     */
 
     public static final Package.Version JAVA_MIN_CLASS_VERSION =
@@ -63,6 +64,9 @@
     public static final Package.Version JAVA8_MAX_CLASS_VERSION =
             Package.Version.of(52, 00);
 
+    public static final Package.Version JAVA9_MAX_CLASS_VERSION =
+            Package.Version.of(53, 00);
+
     public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
 
     public static final Package.Version JAVA5_PACKAGE_VERSION =
@@ -79,7 +83,7 @@
 
     // upper limit, should point to the latest class version
     public static final Package.Version JAVA_MAX_CLASS_VERSION =
-            JAVA8_MAX_CLASS_VERSION;
+            JAVA9_MAX_CLASS_VERSION;
 
     // upper limit should point to the latest package version, for version info!.
     public static final Package.Version MAX_PACKAGE_VERSION =
diff --git a/jdk/src/java.base/share/classes/java/io/BufferedWriter.java b/jdk/src/java.base/share/classes/java/io/BufferedWriter.java
index 28e170f..3d8e1ee 100644
--- a/jdk/src/java.base/share/classes/java/io/BufferedWriter.java
+++ b/jdk/src/java.base/share/classes/java/io/BufferedWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -153,13 +153,18 @@
      * needed.  If the requested length is at least as large as the buffer,
      * however, then this method will flush the buffer and write the characters
      * directly to the underlying stream.  Thus redundant
-     * <code>BufferedWriter</code>s will not copy data unnecessarily.
+     * {@code BufferedWriter}s will not copy data unnecessarily.
      *
      * @param  cbuf  A character array
      * @param  off   Offset from which to start reading characters
      * @param  len   Number of characters to write
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(char cbuf[], int off, int len) throws IOException {
         synchronized (lock) {
@@ -195,17 +200,24 @@
     /**
      * Writes a portion of a String.
      *
-     * <p> If the value of the {@code len} parameter is negative then no
-     * characters are written.  This is contrary to the specification of this
-     * method in the {@linkplain java.io.Writer#write(java.lang.String,int,int)
-     * superclass}, which requires that an {@link IndexOutOfBoundsException} be
-     * thrown.
+     * @implSpec
+     * While the specification of this method in the
+     * {@linkplain java.io.Writer#write(java.lang.String,int,int) superclass}
+     * recommends that an {@link IndexOutOfBoundsException} be thrown
+     * if {@code len} is negative or {@code off + len} is negative,
+     * the implementation in this class does not throw such an exception in
+     * these cases but instead simply writes no characters.
      *
      * @param  s     String to be written
      * @param  off   Offset from which to start reading characters
      * @param  len   Number of characters to be written
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative,
+     *          or {@code off + len} is greater than the length
+     *          of the given string
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(String s, int off, int len) throws IOException {
         synchronized (lock) {
diff --git a/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java b/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java
index ed27bba..773b596 100644
--- a/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java
+++ b/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,6 +91,11 @@
      * @param c the data to be written
      * @param off       the start offset in the data
      * @param len       the number of chars that are written
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
      */
     public void write(char c[], int off, int len) {
         if ((off < 0) || (off > c.length) || (len < 0) ||
@@ -114,6 +119,11 @@
      * @param  str  String to be written from
      * @param  off  Offset from which to start reading characters
      * @param  len  Number of characters to be written
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given string
      */
     public void write(String str, int off, int len) {
         synchronized (lock) {
diff --git a/jdk/src/java.base/share/classes/java/io/FilterWriter.java b/jdk/src/java.base/share/classes/java/io/FilterWriter.java
index 303c674..8272b3c 100644
--- a/jdk/src/java.base/share/classes/java/io/FilterWriter.java
+++ b/jdk/src/java.base/share/classes/java/io/FilterWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,7 +72,12 @@
      * @param  off   Offset from which to start reading characters
      * @param  len   Number of characters to be written
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(char cbuf[], int off, int len) throws IOException {
         out.write(cbuf, off, len);
@@ -85,7 +90,12 @@
      * @param  off  Offset from which to start reading characters
      * @param  len  Number of characters to be written
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(String str, int off, int len) throws IOException {
         out.write(str, off, len);
diff --git a/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java b/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java
index 0d597e6..4fdb148 100644
--- a/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java
+++ b/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -202,7 +202,12 @@
      * @param  off   Offset from which to start writing characters
      * @param  len   Number of characters to write
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(char cbuf[], int off, int len) throws IOException {
         se.write(cbuf, off, len);
@@ -215,7 +220,12 @@
      * @param  off  Offset from which to start writing characters
      * @param  len  Number of characters to write
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given string
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(String str, int off, int len) throws IOException {
         se.write(str, off, len);
diff --git a/jdk/src/java.base/share/classes/java/io/PipedWriter.java b/jdk/src/java.base/share/classes/java/io/PipedWriter.java
index 02201fb..a4534b8 100644
--- a/jdk/src/java.base/share/classes/java/io/PipedWriter.java
+++ b/jdk/src/java.base/share/classes/java/io/PipedWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,19 +125,25 @@
     }
 
     /**
-     * Writes <code>len</code> characters from the specified character array
-     * starting at offset <code>off</code> to this piped output stream.
+     * Writes {@code len} characters from the specified character array
+     * starting at offset {@code off} to this piped output stream.
      * This method blocks until all the characters are written to the output
      * stream.
      * If a thread was reading data characters from the connected piped input
      * stream, but the thread is no longer alive, then an
-     * <code>IOException</code> is thrown.
+     * {@code IOException} is thrown.
      *
      * @param      cbuf  the data.
      * @param      off   the start offset in the data.
      * @param      len   the number of characters to write.
-     * @exception  IOException  if the pipe is
-     *          <a href=PipedOutputStream.html#BROKEN> <code>broken</code></a>,
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
+     * @throws  IOException  if the pipe is
+     *          <a href=PipedOutputStream.html#BROKEN><code>broken</code></a>,
      *          {@link #connect(java.io.PipedReader) unconnected}, closed
      *          or an I/O error occurs.
      */
diff --git a/jdk/src/java.base/share/classes/java/io/PrintWriter.java b/jdk/src/java.base/share/classes/java/io/PrintWriter.java
index 662f930..d516b8e 100644
--- a/jdk/src/java.base/share/classes/java/io/PrintWriter.java
+++ b/jdk/src/java.base/share/classes/java/io/PrintWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -410,6 +410,11 @@
      * @param buf Array of characters
      * @param off Offset from which to start writing characters
      * @param len Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
      */
     public void write(char buf[], int off, int len) {
         try {
@@ -440,6 +445,11 @@
      * @param s A String
      * @param off Offset from which to start writing characters
      * @param len Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
      */
     public void write(String s, int off, int len) {
         try {
diff --git a/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java b/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java
index 1a8344d..3806675 100644
--- a/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java
+++ b/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java
@@ -27,6 +27,8 @@
 
 import java.nio.channels.FileChannel;
 import java.util.concurrent.atomic.AtomicBoolean;
+import jdk.internal.misc.JavaIORandomAccessFileAccess;
+import jdk.internal.misc.SharedSecrets;
 import sun.nio.ch.FileChannelImpl;
 
 
@@ -75,6 +77,7 @@
     private static final int O_RDWR =   2;
     private static final int O_SYNC =   4;
     private static final int O_DSYNC =  8;
+    private static final int O_TEMPORARY =  16;
 
     /**
      * Creates a random access file stream to read from, and optionally
@@ -203,6 +206,12 @@
     public RandomAccessFile(File file, String mode)
         throws FileNotFoundException
     {
+        this(file, mode, false);
+    }
+
+    private RandomAccessFile(File file, String mode, boolean openAndDelete)
+        throws FileNotFoundException
+    {
         String name = (file != null ? file.getPath() : null);
         int imode = -1;
         if (mode.equals("r"))
@@ -219,6 +228,8 @@
                     imode = -1;
             }
         }
+        if (openAndDelete)
+            imode |= O_TEMPORARY;
         if (imode < 0)
             throw new IllegalArgumentException("Illegal mode \"" + mode
                                                + "\" must be one of "
@@ -1165,5 +1176,15 @@
 
     static {
         initIDs();
+        SharedSecrets.setJavaIORandomAccessFileAccess(new JavaIORandomAccessFileAccess()
+        {
+            // This is for j.u.z.ZipFile.OPEN_DELETE. The O_TEMPORARY flag
+            // is only implemented/supported on windows.
+            public RandomAccessFile openAndDelete(File file, String mode)
+                throws IOException
+            {
+                return new RandomAccessFile(file, mode, true);
+            }
+        });
     }
 }
diff --git a/jdk/src/java.base/share/classes/java/io/StringWriter.java b/jdk/src/java.base/share/classes/java/io/StringWriter.java
index 5d1babc..15022b3 100644
--- a/jdk/src/java.base/share/classes/java/io/StringWriter.java
+++ b/jdk/src/java.base/share/classes/java/io/StringWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,6 +83,11 @@
      * @param  cbuf  Array of characters
      * @param  off   Offset from which to start writing characters
      * @param  len   Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
      */
     public void write(char cbuf[], int off, int len) {
         if ((off < 0) || (off > cbuf.length) || (len < 0) ||
@@ -107,6 +112,11 @@
      * @param  str  String to be written
      * @param  off  Offset from which to start writing characters
      * @param  len  Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given string
      */
     public void write(String str, int off, int len)  {
         buf.append(str, off, off + len);
diff --git a/jdk/src/java.base/share/classes/java/io/Writer.java b/jdk/src/java.base/share/classes/java/io/Writer.java
index 5ad5e55..17e8de3 100644
--- a/jdk/src/java.base/share/classes/java/io/Writer.java
+++ b/jdk/src/java.base/share/classes/java/io/Writer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,12 +32,11 @@
  * Most subclasses, however, will override some of the methods defined here in
  * order to provide higher efficiency, additional functionality, or both.
  *
- * @see Writer
  * @see   BufferedWriter
  * @see   CharArrayWriter
  * @see   FilterWriter
  * @see   OutputStreamWriter
- * @see     FileWriter
+ * @see   FileWriter
  * @see   PipedWriter
  * @see   PrintWriter
  * @see   StringWriter
@@ -139,6 +138,12 @@
      * @param  len
      *         Number of characters to write
      *
+     * @throws  IndexOutOfBoundsException
+     *          Implementations should throw this exception
+     *          if {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
      * @throws  IOException
      *          If an I/O error occurs
      */
@@ -160,6 +165,11 @@
     /**
      * Writes a portion of a string.
      *
+     * @implSpec
+     * The implementation in this class throws an
+     * {@code IndexOutOfBoundsException} for the indicated conditions;
+     * overriding methods may choose to do otherwise.
+     *
      * @param  str
      *         A String
      *
@@ -170,8 +180,9 @@
      *         Number of characters to write
      *
      * @throws  IndexOutOfBoundsException
-     *          If {@code off} is negative, or {@code len} is negative,
-     *          or {@code off+len} is negative or greater than the length
+     *          Implementations should throw this exception
+     *          if {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
      *          of the given string
      *
      * @throws  IOException
diff --git a/jdk/src/java.base/share/classes/java/lang/Math.java b/jdk/src/java.base/share/classes/java/lang/Math.java
index 4244d40..aa678b8 100644
--- a/jdk/src/java.base/share/classes/java/lang/Math.java
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java
@@ -95,7 +95,7 @@
  * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
  * throw an {@code ArithmeticException} when the results overflow.
  * For other arithmetic operations such as divide, absolute value,
- * increment, decrement, and negation overflow occurs only with
+ * increment by one, decrement by one, and negation, overflow occurs only with
  * a specific minimum or maximum value and should be checked against
  * the minimum or maximum as appropriate.
  *
@@ -861,7 +861,7 @@
     public static int subtractExact(int x, int y) {
         int r = x - y;
         // HD 2-12 Overflow iff the arguments have different signs and
-        // the sign of the result is different than the sign of x
+        // the sign of the result is different from the sign of x
         if (((x ^ y) & (x ^ r)) < 0) {
             throw new ArithmeticException("integer overflow");
         }
@@ -882,7 +882,7 @@
     public static long subtractExact(long x, long y) {
         long r = x - y;
         // HD 2-12 Overflow iff the arguments have different signs and
-        // the sign of the result is different than the sign of x
+        // the sign of the result is different from the sign of x
         if (((x ^ y) & (x ^ r)) < 0) {
             throw new ArithmeticException("long overflow");
         }
@@ -909,6 +909,20 @@
     }
 
     /**
+     * Returns the product of the arguments, throwing an exception if the result
+     * overflows a {@code long}.
+     *
+     * @param x the first value
+     * @param y the second value
+     * @return the result
+     * @throws ArithmeticException if the result overflows a long
+     * @since 9
+     */
+    public static long multiplyExact(long x, int y) {
+        return multiplyExact(x, (long)y);
+    }
+
+    /**
      * Returns the product of the arguments,
      * throwing an exception if the result overflows a {@code long}.
      *
@@ -1060,17 +1074,64 @@
     }
 
     /**
+     * Returns the exact mathematical product of the arguments.
+     *
+     * @param x the first value
+     * @param y the second value
+     * @return the result
+     */
+    public static long multiplyFull(int x, int y) {
+        return (long)x * (long)y;
+    }
+
+    /**
+     * Returns as a {@code long} the most significant 64 bits of the 128-bit
+     * product of two 64-bit factors.
+     *
+     * @param x the first value
+     * @param y the second value
+     * @return the result
+     */
+    public static long multiplyHigh(long x, long y) {
+        if (x < 0 || y < 0) {
+            // Use technique from section 8-2 of Henry S. Warren, Jr.,
+            // Hacker's Delight (2nd ed.) (Addison Wesley, 2013), 173-174.
+            long x1 = x >> 32;
+            long x2 = x & 0xFFFFFFFFL;
+            long y1 = y >> 32;
+            long y2 = y & 0xFFFFFFFFL;
+            long z2 = x2 * y2;
+            long t = x1 * y2 + (z2 >>> 32);
+            long z1 = t & 0xFFFFFFFFL;
+            long z0 = t >> 32;
+            z1 += x2 * y1;
+            return x1 * y1 + z0 + (z1 >> 32);
+        } else {
+            // Use Karatsuba technique with two base 2^32 digits.
+            long x1 = x >>> 32;
+            long y1 = y >>> 32;
+            long x2 = x & 0xFFFFFFFFL;
+            long y2 = y & 0xFFFFFFFFL;
+            long A = x1 * y1;
+            long B = x2 * y2;
+            long C = (x1 + x2) * (y1 + y2);
+            long K = C - A - B;
+            return (((B >>> 32) + K) >>> 32) + A;
+        }
+    }
+
+    /**
      * Returns the largest (closest to positive infinity)
      * {@code int} value that is less than or equal to the algebraic quotient.
      * There is one special case, if the dividend is the
      * {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
      * then integer overflow occurs and
-     * the result is equal to the {@code Integer.MIN_VALUE}.
+     * the result is equal to {@code Integer.MIN_VALUE}.
      * <p>
      * Normal integer division operates under the round to zero rounding mode
      * (truncation).  This operation instead acts under the round toward
      * negative infinity (floor) rounding mode.
-     * The floor rounding mode gives different results than truncation
+     * The floor rounding mode gives different results from truncation
      * when the exact result is negative.
      * <ul>
      *   <li>If the signs of the arguments are the same, the results of
@@ -1108,12 +1169,41 @@
      * There is one special case, if the dividend is the
      * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
      * then integer overflow occurs and
-     * the result is equal to the {@code Long.MIN_VALUE}.
+     * the result is equal to {@code Long.MIN_VALUE}.
      * <p>
      * Normal integer division operates under the round to zero rounding mode
      * (truncation).  This operation instead acts under the round toward
      * negative infinity (floor) rounding mode.
-     * The floor rounding mode gives different results than truncation
+     * The floor rounding mode gives different results from truncation
+     * when the exact result is negative.
+     * <p>
+     * For examples, see {@link #floorDiv(int, int)}.
+     *
+     * @param x the dividend
+     * @param y the divisor
+     * @return the largest (closest to positive infinity)
+     * {@code int} value that is less than or equal to the algebraic quotient.
+     * @throws ArithmeticException if the divisor {@code y} is zero
+     * @see #floorMod(long, int)
+     * @see #floor(double)
+     * @since 9
+     */
+    public static long floorDiv(long x, int y) {
+        return floorDiv(x, (long)y);
+    }
+
+    /**
+     * Returns the largest (closest to positive infinity)
+     * {@code long} value that is less than or equal to the algebraic quotient.
+     * There is one special case, if the dividend is the
+     * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
+     * then integer overflow occurs and
+     * the result is equal to {@code Long.MIN_VALUE}.
+     * <p>
+     * Normal integer division operates under the round to zero rounding mode
+     * (truncation).  This operation instead acts under the round toward
+     * negative infinity (floor) rounding mode.
+     * The floor rounding mode gives different results from truncation
      * when the exact result is negative.
      * <p>
      * For examples, see {@link #floorDiv(int, int)}.
@@ -1181,8 +1271,34 @@
      * @since 1.8
      */
     public static int floorMod(int x, int y) {
-        int r = x - floorDiv(x, y) * y;
-        return r;
+        return x - floorDiv(x, y) * y;
+    }
+
+    /**
+     * Returns the floor modulus of the {@code long} and {@int} arguments.
+     * <p>
+     * The floor modulus is {@code x - (floorDiv(x, y) * y)},
+     * has the same sign as the divisor {@code y}, and
+     * is in the range of {@code -abs(y) < r < +abs(y)}.
+     *
+     * <p>
+     * The relationship between {@code floorDiv} and {@code floorMod} is such that:
+     * <ul>
+     *   <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
+     * </ul>
+     * <p>
+     * For examples, see {@link #floorMod(int, int)}.
+     *
+     * @param x the dividend
+     * @param y the divisor
+     * @return the floor modulus {@code x - (floorDiv(x, y) * y)}
+     * @throws ArithmeticException if the divisor {@code y} is zero
+     * @see #floorDiv(long, int)
+     * @since 9
+     */
+    public static int floorMod(long x, int y) {
+        // Result cannot overflow the range of int.
+        return (int)(x - floorDiv(x, y) * y);
     }
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/lang/Runtime.java b/jdk/src/java.base/share/classes/java/lang/Runtime.java
index 3c73d5b..1533130 100644
--- a/jdk/src/java.base/share/classes/java/lang/Runtime.java
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,9 +26,21 @@
 package java.lang;
 
 import java.io.*;
+import java.math.BigInteger;
+import java.util.AbstractList;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.RandomAccess;
 import java.util.StringTokenizer;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.Reflection;
+import sun.security.action.GetPropertyAction;
 
 /**
  * Every Java application has a single instance of class
@@ -46,6 +58,8 @@
 public class Runtime {
     private static final Runtime currentRuntime = new Runtime();
 
+    private static Version version;
+
     /**
      * Returns the runtime object associated with the current Java application.
      * Most of the methods of class {@code Runtime} are instance
@@ -917,4 +931,591 @@
         return out;
     }
 
+    /**
+     * Returns the version of the Java Runtime Environment as a {@link
+     * Runtime.Version}.
+     *
+     * @return  the {@link Runtime.Version} of the Java Runtime Environment
+     *
+     * @since  9
+     */
+    public static Version version() {
+        if (version == null) {
+            version = Version.parse(
+                GetPropertyAction.privilegedGetProperty("java.runtime.version"));
+        }
+        return version;
+    }
+
+    /**
+     * A representation of a version string for an implemenation of the
+     * Java&nbsp;SE Platform.  A version string contains a version number
+     * optionally followed by pre-release and build information.
+     *
+     * <h2><a name="verNum">Version numbers</a></h2>
+     *
+     * <p> A <em>version number</em>, {@code $VNUM}, is a non-empty sequence
+     * of elements separated by period characters (U+002E).  An element is
+     * either zero, or a unsigned integer numeral without leading zeros.  The
+     * final element in a version number must not be zero.  The format is:
+     * </p>
+     *
+     * <blockquote><pre>
+     *     ^[1-9][0-9]*(((\.0)*\.[1-9][0-9]*)*)*$
+     * </pre></blockquote>
+     *
+     * <p> The sequence may be of arbitrary length but the first three
+     * elements are assigned specific meanings, as follows:</p>
+     *
+     * <blockquote><pre>
+     *     $MAJOR.$MINOR.$SECURITY
+     * </pre></blockquote>
+     *
+     * <ul>
+     *
+     * <li><p> <a name="major">{@code $MAJOR}</a> --- The major version
+     * number, incremented for a major release that contains significant new
+     * features as specified in a new edition of the Java&#160;SE Platform
+     * Specification, <em>e.g.</em>, <a
+     * href="https://jcp.org/en/jsr/detail?id=337">JSR 337</a> for
+     * Java&#160;SE&#160;8.  Features may be removed in a major release, given
+     * advance notice at least one major release ahead of time, and
+     * incompatible changes may be made when justified. The {@code $MAJOR}
+     * version number of JDK&#160;8 is {@code 8}; the {@code $MAJOR} version
+     * number of JDK&#160;9 is {@code 9}.  When {@code $MAJOR} is incremented,
+     * all subsequent elements are removed. </p></li>
+     *
+     * <li><p> <a name="minor">{@code $MINOR}</a> --- The minor version
+     * number, incremented for a minor update release that may contain
+     * compatible bug fixes, revisions to standard APIs mandated by a
+     * <a href="https://jcp.org/en/procedures/jcp2#5.3">Maintenance Release</a>
+     * of the relevant Platform Specification, and implementation features
+     * outside the scope of that Specification such as new JDK-specific APIs,
+     * additional service providers, new garbage collectors, and ports to new
+     * hardware architectures. </p></li>
+     *
+     * <li><p> <a name="security">{@code $SECURITY}</a> --- The security
+     * level, incremented for a security update release that contains critical
+     * fixes including those necessary to improve security.  {@code $SECURITY}
+     * is <strong>not</strong> reset when {@code $MINOR} is incremented.  A
+     * higher value of {@code $SECURITY} for a given {@code $MAJOR} value,
+     * therefore, always indicates a more secure release, regardless of the
+     * value of {@code $MINOR}. </p></li>
+     *
+     * </ul>
+     *
+     * <p> The fourth and later elements of a version number are free for use
+     * by downstream consumers of this code base.  Such a consumer may,
+     * <em>e.g.</em>, use the fourth element to identify patch releases which
+     * contain a small number of critical non-security fixes in addition to
+     * the security fixes in the corresponding security release. </p>
+     *
+     * <p> The version number does not include trailing zero elements;
+     * <em>i.e.</em>, {@code $SECURITY} is omitted if it has the value zero,
+     * and {@code $MINOR} is omitted if both {@code $MINOR} and {@code
+     * $SECURITY} have the value zero. </p>
+     *
+     * <p> The sequence of numerals in a version number is compared to another
+     * such sequence in numerical, pointwise fashion; <em>e.g.</em>, {@code
+     * 9.9.1} is less than {@code 9.10.3}. If one sequence is shorter than
+     * another then the missing elements of the shorter sequence are
+     * considered to be less than the corresponding elements of the longer
+     * sequence; <em>e.g.</em>, {@code 9.1.2} is less than {@code 9.1.2.1}.
+     * </p>
+     *
+     * <h2><a name="verStr">Version strings</a></h2>
+     *
+     * <p> A <em>version string</em>, {@code $VSTR}, consists of a version
+     * number {@code $VNUM}, as described above, optionally followed by
+     * pre-release and build information, in the format </p>
+     *
+     * <blockquote><pre>
+     *     $VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
+     * </pre></blockquote>
+     *
+     * <p> where: </p>
+     *
+     * <ul>
+     *
+     * <li><p> <a name="pre">{@code $PRE}</a>, matching {@code ([a-zA-Z0-9]+)}
+     * --- A pre-release identifier.  Typically {@code ea}, for a
+     * potentially unstable early-access release under active development,
+     * or {@code internal}, for an internal developer build.
+     *
+     * <li><p> <a name="build">{@code $BUILD}</a>, matching {@code
+     * (0|[1-9][0-9]*)} --- The build number, incremented for each promoted
+     * build.  {@code $BUILD} is reset to {@code 1} when any portion of {@code
+     * $VNUM} is incremented. </p>
+     *
+     * <li><p> <a name="opt">{@code $OPT}</a>, matching {@code
+     * ([-a-zA-Z0-9\.]+)} --- Additional build information, if desired.  In
+     * the case of an {@code internal} build this will often contain the date
+     * and time of the build. </p>
+     *
+     * </ul>
+     *
+     * <p> A version number {@code 10-ea} matches {@code $VNUM = "10"} and
+     * {@code $PRE = "ea"}.  The version number {@code 10+-ea} matches
+     * {@code $VNUM = "10"} and {@code $OPT = "ea"}. </p>
+     *
+     * <p> When comparing two version strings, the value of {@code $OPT}, if
+     * present, may or may not be significant depending on the chosen
+     * comparison method.  The comparison methods {@link #compareTo(Version)
+     * compareTo()} and {@link #compareToIgnoreOpt(Version)
+     * compareToIgnoreOpt()} should be used consistently with the
+     * corresponding methods {@link #equals(Object) equals()} and {@link
+     * #equalsIgnoreOpt(Object) equalsIgnoreOpt()}.  </p>
+     *
+     * <p> A <em>short version string</em>, {@code $SVSTR}, often useful in
+     * less formal contexts, is a version number optionally followed by a
+     * pre-release identifier:
+     *
+     * <blockquote><pre>
+     *     $VNUM(-$PRE)?
+     * </pre></blockquote>
+     *
+     * @since  9
+     */
+    public static class Version
+        implements Comparable<Version>
+    {
+        private final List<Integer>     version;
+        private final Optional<String>  pre;
+        private final Optional<Integer> build;
+        private final Optional<String>  optional;
+
+
+        // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)?
+        // RE limits the format of version strings
+        // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))?
+
+        private static final String VNUM
+            = "(?<VNUM>[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)";
+        private static final String VNUM_GROUP  = "VNUM";
+
+        private static final String PRE      = "(?:-(?<PRE>[a-zA-Z0-9]+))?";
+        private static final String PRE_GROUP   = "PRE";
+
+        private static final String BUILD
+            = "(?:(?<PLUS>\\+)(?<BUILD>0|[1-9][0-9]*)?)?";
+        private static final String PLUS_GROUP  = "PLUS";
+        private static final String BUILD_GROUP = "BUILD";
+
+        private static final String OPT      = "(?:-(?<OPT>[-a-zA-Z0-9.]+))?";
+        private static final String OPT_GROUP   = "OPT";
+
+        private static final String VSTR_FORMAT
+            = "^" + VNUM + PRE + BUILD + OPT + "$";
+        private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
+
+        /**
+         * Constructs a valid <a href="verStr">version string</a> containing
+         * a <a href="#verNum">version number</a> followed by pre-release and
+         * build information.
+         *
+         * @param  s
+         *         A string to be interpreted as a version
+         *
+         * @throws  IllegalArgumentException
+         *          If the given string cannot be interpreted as a valid
+         *          version
+         *
+         * @throws  NullPointerException
+         *          If {@code s} is {@code null}
+         *
+         * @throws  NumberFormatException
+         *          If an element of the version number or the build number
+         *          cannot be represented as an {@link Integer}
+         */
+        private Version(String s) {
+            if (s == null)
+                throw new NullPointerException();
+
+            Matcher m = VSTR_PATTERN.matcher(s);
+            if (!m.matches())
+                throw new IllegalArgumentException("Invalid version string: '"
+                                                   + s + "'");
+
+            // $VNUM is a dot-separated list of integers of arbitrary length
+            List<Integer> list = new ArrayList<>();
+            for (String i : m.group(VNUM_GROUP).split("\\."))
+                list.add(Integer.parseInt(i));
+            version = Collections.unmodifiableList(list);
+
+            pre = Optional.ofNullable(m.group(PRE_GROUP));
+
+            String b = m.group(BUILD_GROUP);
+            // $BUILD is an integer
+            build = (b == null)
+                ? Optional.<Integer>empty()
+                : Optional.ofNullable(Integer.parseInt(b));
+
+            optional = Optional.ofNullable(m.group(OPT_GROUP));
+
+            // empty '+'
+            if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
+                if (optional.isPresent()) {
+                    if (pre.isPresent())
+                        throw new IllegalArgumentException("'+' found with"
+                            + " pre-release and optional components:'" + s
+                            + "'");
+                } else {
+                    throw new IllegalArgumentException("'+' found with neither"
+                        + " build or optional components: '" + s + "'");
+                }
+            }
+        }
+
+        /**
+         * Parses the given string as a valid
+         * <a href="#verStr">version string</a> containing a
+         * <a href="#verNum">version number</a> followed by pre-release and
+         * build information.
+         *
+         * @param  s
+         *         A string to interpret as a version
+         *
+         * @throws  IllegalArgumentException
+         *          If the given string cannot be interpreted as a valid
+         *          version
+         *
+         * @throws  NullPointerException
+         *          If the given string is {@code null}
+         *
+         * @throws  NumberFormatException
+         *          If an element of the version number or the build number
+         *          cannot be represented as an {@link Integer}
+         *
+         * @return  The Version of the given string
+         */
+        public static Version parse(String s) {
+            return new Version(s);
+        }
+
+        /**
+         * Returns the <a href="#major">major</a> version number.
+         *
+         * @return  The major version number
+         */
+        public int major() {
+            return version.get(0);
+        }
+
+        /**
+         * Returns the <a href="#minor">minor</a> version number or zero if it
+         * was not set.
+         *
+         * @return  The minor version number or zero if it was not set
+         */
+        public int minor() {
+            return (version.size() > 1 ? version.get(1) : 0);
+        }
+
+        /**
+         * Returns the <a href="#security">security</a> version number or zero
+         * if it was not set.
+         *
+         * @return  The security version number or zero if it was not set
+         */
+        public int security() {
+            return (version.size() > 2 ? version.get(2) : 0);
+        }
+
+        /**
+         * Returns an unmodifiable {@link java.util.List List} of the
+         * integer numerals contained in the <a href="#verNum">version
+         * number</a>.  The {@code List} always contains at least one
+         * element corresponding to the <a href="#major">major version
+         * number</a>.
+         *
+         * @return  An unmodifiable list of the integer numerals
+         *          contained in the version number
+         */
+        public List<Integer> version() {
+            return version;
+        }
+
+        /**
+         * Returns the optional <a href="#pre">pre-release</a> information.
+         *
+         * @return  The optional pre-release information as a String
+         */
+        public Optional<String> pre() {
+            return pre;
+        }
+
+        /**
+         * Returns the <a href="#build">build number</a>.
+         *
+         * @return  The optional build number.
+         */
+        public Optional<Integer> build() {
+            return build;
+        }
+
+        /**
+         * Returns <a href="#opt">optional</a> additional identifying build
+         * information.
+         *
+         * @return  Additional build information as a String
+         */
+        public Optional<String> optional() {
+            return optional;
+        }
+
+        /**
+         * Compares this version to another.
+         *
+         * <p> Each of the components in the <a href="#verStr">version</a> is
+         * compared in the follow order of precedence: version numbers,
+         * pre-release identifiers, build numbers, optional build information.
+         * </p>
+         *
+         * <p> Comparison begins by examining the sequence of version numbers.
+         * If one sequence is shorter than another, then the missing elements
+         * of the shorter sequence are considered to be less than the
+         * corresponding elements of the longer sequence. </p>
+         *
+         * <p> A version with a pre-release identifier is always considered to
+         * be less than a version without one.  Pre-release identifiers are
+         * compared numerically when they consist only of digits, and
+         * lexicographically otherwise.  Numeric identifiers are considered to
+         * be less than non-numeric identifiers.  </p>
+         *
+         * <p> A version without a build number is always less than one with a
+         * build number; otherwise build numbers are compared numerically. </p>
+         *
+         * <p> The optional build information is compared lexicographically.
+         * During this comparison, a version with optional build information is
+         * considered to be greater than a version without one. </p>
+         *
+         * <p> A version is not comparable to any other type of object.
+         *
+         * @param  ob
+         *         The object to be compared
+         *
+         * @return  A negative integer, zero, or a positive integer if this
+         *          {@code Version} is less than, equal to, or greater than the
+         *          given {@code Version}
+         *
+         * @throws  NullPointerException
+         *          If the given object is {@code null}
+         */
+        @Override
+        public int compareTo(Version ob) {
+            return compare(ob, false);
+        }
+
+        /**
+         * Compares this version to another disregarding optional build
+         * information.
+         *
+         * <p> Two versions are compared by examining the version string as
+         * described in {@link #compareTo(Version)} with the exception that the
+         * optional build information is always ignored. </p>
+         *
+         * <p> A version is not comparable to any other type of object.
+         *
+         * @param  ob
+         *         The object to be compared
+         *
+         * @return  A negative integer, zero, or a positive integer if this
+         *          {@code Version} is less than, equal to, or greater than the
+         *          given {@code Version}
+         *
+         * @throws  NullPointerException
+         *          If the given object is {@code null}
+         */
+        public int compareToIgnoreOpt(Version ob) {
+            return compare(ob, true);
+        }
+
+        private int compare(Version ob, boolean ignoreOpt) {
+            if (ob == null)
+                throw new NullPointerException("Invalid argument");
+
+            int ret = compareVersion(ob);
+            if (ret != 0)
+                return ret;
+
+            ret = comparePre(ob);
+            if (ret != 0)
+                return ret;
+
+            ret = compareBuild(ob);
+            if (ret != 0)
+                return ret;
+
+            if (!ignoreOpt)
+                return compareOpt(ob);
+
+            return 0;
+        }
+
+        private int compareVersion(Version ob) {
+            int size = version.size();
+            int oSize = ob.version().size();
+            int min = Math.min(size, oSize);
+            for (int i = 0; i < min; i++) {
+                Integer val = version.get(i);
+                Integer oVal = ob.version().get(i);
+                if (val != oVal)
+                    return val - oVal;
+            }
+            if (size != oSize)
+                return size - oSize;
+            return 0;
+        }
+
+        private int comparePre(Version ob) {
+            Optional<String> oPre = ob.pre();
+            if (!pre.isPresent()) {
+                if (oPre.isPresent())
+                    return 1;
+            } else {
+                if (!oPre.isPresent())
+                    return -1;
+                String val = pre.get();
+                String oVal = oPre.get();
+                if (val.matches("\\d+")) {
+                    return (oVal.matches("\\d+")
+                        ? (new BigInteger(val)).compareTo(new BigInteger(oVal))
+                        : -1);
+                } else {
+                    return (oVal.matches("\\d+")
+                        ? 1
+                        : val.compareTo(oVal));
+                }
+            }
+            return 0;
+        }
+
+        private int compareBuild(Version ob) {
+            Optional<Integer> oBuild = ob.build();
+            if (oBuild.isPresent()) {
+                return (build.isPresent()
+                        ? build.get().compareTo(oBuild.get())
+                        : 1);
+            } else if (build.isPresent()) {
+                return -1;
+            }
+            return 0;
+        }
+
+        private int compareOpt(Version ob) {
+            Optional<String> oOpt = ob.optional();
+            if (!optional.isPresent()) {
+                if (oOpt.isPresent())
+                    return -1;
+            } else {
+                if (!oOpt.isPresent())
+                    return 1;
+                return optional.get().compareTo(oOpt.get());
+            }
+            return 0;
+        }
+
+        /**
+         * Returns a string representation of this version.
+         *
+         * @return  The version string
+         */
+        @Override
+        public String toString() {
+            StringBuilder sb
+                = new StringBuilder(version.stream()
+                    .map(Object::toString)
+                    .collect(Collectors.joining(".")));
+
+            pre.ifPresent(v -> sb.append("-").append(v));
+
+            if (build.isPresent()) {
+                sb.append("+").append(build.get());
+                if (optional.isPresent())
+                    sb.append("-").append(optional.get());
+            } else {
+                if (optional.isPresent()) {
+                    sb.append(pre.isPresent() ? "-" : "+-");
+                    sb.append(optional.get());
+                }
+            }
+
+            return sb.toString();
+        }
+
+        /**
+         * Determines whether this {@code Version} is equal to another object.
+         *
+         * <p> Two {@code Version}s are equal if and only if they represent the
+         * same version string.
+         *
+         * <p> This method satisfies the general contract of the {@link
+         * Object#equals(Object) Object.equals} method. </p>
+         *
+         * @param  ob
+         *         The object to which this {@code Version} is to be compared
+         *
+         * @return  {@code true} if, and only if, the given object is a {@code
+         *          Version} that is identical to this {@code Version}
+         *
+         */
+        @Override
+        public boolean equals(Object ob) {
+            boolean ret = equalsIgnoreOpt(ob);
+            if (!ret)
+                return false;
+
+            Version that = (Version)ob;
+            return (this.optional().equals(that.optional()));
+        }
+
+        /**
+         * Determines whether this {@code Version} is equal to another
+         * disregarding optional build information.
+         *
+         * <p> Two {@code Version}s are equal if and only if they represent the
+         * same version string disregarding the optional build information.
+         *
+         * @param  ob
+         *         The object to which this {@code Version} is to be compared
+         *
+         * @return  {@code true} if, and only if, the given object is a {@code
+         *          Version} that is identical to this {@code Version}
+         *          ignoring the optinal build information
+         *
+         */
+        public boolean equalsIgnoreOpt(Object ob) {
+            if (this == ob)
+                return true;
+            if (!(ob instanceof Version))
+                return false;
+
+            Version that = (Version)ob;
+            return (this.version().equals(that.version())
+                && this.pre().equals(that.pre())
+                && this.build().equals(that.build()));
+        }
+
+        /**
+         * Returns the hash code of this version.
+         *
+         * <p> This method satisfies the general contract of the {@link
+         * Object#hashCode Object.hashCode} method.
+         *
+         * @return  The hashcode of this version
+         */
+        @Override
+        public int hashCode() {
+            int h = 1;
+            int p = 17;
+
+            h = p * h + version.hashCode();
+            h = p * h + pre.hashCode();
+            h = p * h + build.hashCode();
+            h = p * h + optional.hashCode();
+
+            return h;
+        }
+    }
+
 }
diff --git a/jdk/src/java.base/share/classes/java/lang/StrictMath.java b/jdk/src/java.base/share/classes/java/lang/StrictMath.java
index a92f566..998fc1e 100644
--- a/jdk/src/java.base/share/classes/java/lang/StrictMath.java
+++ b/jdk/src/java.base/share/classes/java/lang/StrictMath.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@
  * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
  * throw an {@code ArithmeticException} when the results overflow.
  * For other arithmetic operations such as divide, absolute value,
- * increment, decrement, and negation overflow occurs only with
+ * increment by one, decrement by one, and negation overflow occurs only with
  * a specific minimum or maximum value and should be checked against
  * the minimum or maximum as appropriate.
  *
@@ -803,6 +803,21 @@
     }
 
     /**
+     * Returns the product of the arguments, throwing an exception if the result
+     * overflows a {@code long}.
+     *
+     * @param x the first value
+     * @param y the second value
+     * @return the result
+     * @throws ArithmeticException if the result overflows a long
+     * @see Math#multiplyExact(long,int)
+     * @since 9
+     */
+    public static long multiplyExact(long x, int y) {
+        return Math.multiplyExact(x, y);
+    }
+
+    /**
      * Returns the product of the arguments,
      * throwing an exception if the result overflows a {@code long}.
      *
@@ -832,6 +847,33 @@
     }
 
     /**
+     * Returns the exact mathematical product of the arguments.
+     *
+     * @param x the first value
+     * @param y the second value
+     * @return the result
+     * @see Math#multiplyFull(int,int)
+     * @since 9
+     */
+    public static long multiplyFull(int x, int y) {
+        return Math.multiplyFull(x, y);
+    }
+
+    /**
+     * Returns as a {@code long} the most significant 64 bits of the 128-bit
+     * product of two 64-bit factors.
+     *
+     * @param x the first value
+     * @param y the second value
+     * @return the result
+     * @see Math#multiplyHigh(long,long)
+     * @since 9
+     */
+    public static long multiplyHigh(long x, long y) {
+        return Math.multiplyHigh(x, y);
+    }
+
+    /**
      * Returns the largest (closest to positive infinity)
      * {@code int} value that is less than or equal to the algebraic quotient.
      * There is one special case, if the dividend is the
@@ -861,6 +903,30 @@
      * There is one special case, if the dividend is the
      * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
      * then integer overflow occurs and
+     * the result is equal to {@code Long.MIN_VALUE}.
+     * <p>
+     * See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
+     * a comparison to the integer division {@code /} operator.
+     *
+     * @param x the dividend
+     * @param y the divisor
+     * @return the largest (closest to positive infinity)
+     * {@code int} value that is less than or equal to the algebraic quotient.
+     * @throws ArithmeticException if the divisor {@code y} is zero
+     * @see Math#floorDiv(long, int)
+     * @see Math#floor(double)
+     * @since 9
+     */
+    public static long floorDiv(long x, int y) {
+        return Math.floorDiv(x, y);
+    }
+
+    /**
+     * Returns the largest (closest to positive infinity)
+     * {@code long} value that is less than or equal to the algebraic quotient.
+     * There is one special case, if the dividend is the
+     * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
+     * then integer overflow occurs and
      * the result is equal to the {@code Long.MIN_VALUE}.
      * <p>
      * See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
@@ -905,6 +971,35 @@
     public static int floorMod(int x, int y) {
         return Math.floorMod(x , y);
     }
+
+    /**
+     * Returns the floor modulus of the {@code long} and {@int} arguments.
+     * <p>
+     * The floor modulus is {@code x - (floorDiv(x, y) * y)},
+     * has the same sign as the divisor {@code y}, and
+     * is in the range of {@code -abs(y) < r < +abs(y)}.
+     *
+     * <p>
+     * The relationship between {@code floorDiv} and {@code floorMod} is such that:
+     * <ul>
+     *   <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
+     * </ul>
+     * <p>
+     * See {@link Math#floorMod(int, int) Math.floorMod} for examples and
+     * a comparison to the {@code %} operator.
+     *
+     * @param x the dividend
+     * @param y the divisor
+     * @return the floor modulus {@code x - (floorDiv(x, y) * y)}
+     * @throws ArithmeticException if the divisor {@code y} is zero
+     * @see Math#floorMod(long, int)
+     * @see StrictMath#floorDiv(long, int)
+     * @since 9
+     */
+    public static int floorMod(long x, int y) {
+        return Math.floorMod(x , y);
+    }
+
     /**
      * Returns the floor modulus of the {@code long} arguments.
      * <p>
diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java
index ab7bb02..7ac564d 100644
--- a/jdk/src/java.base/share/classes/java/lang/System.java
+++ b/jdk/src/java.base/share/classes/java/lang/System.java
@@ -576,7 +576,8 @@
      * <tr><th>Key</th>
      *     <th>Description of Associated Value</th></tr>
      * <tr><td><code>java.version</code></td>
-     *     <td>Java Runtime Environment version</td></tr>
+     *     <td>Java Runtime Environment version which may be interpreted
+     *     as a {@link Runtime.Version}</td></tr>
      * <tr><td><code>java.vendor</code></td>
      *     <td>Java Runtime Environment vendor</td></tr>
      * <tr><td><code>java.vendor.url</code></td>
@@ -584,19 +585,22 @@
      * <tr><td><code>java.home</code></td>
      *     <td>Java installation directory</td></tr>
      * <tr><td><code>java.vm.specification.version</code></td>
-     *     <td>Java Virtual Machine specification version</td></tr>
+     *     <td>Java Virtual Machine specification version which may be
+     *     interpreted as a {@link Runtime.Version}</td></tr>
      * <tr><td><code>java.vm.specification.vendor</code></td>
      *     <td>Java Virtual Machine specification vendor</td></tr>
      * <tr><td><code>java.vm.specification.name</code></td>
      *     <td>Java Virtual Machine specification name</td></tr>
      * <tr><td><code>java.vm.version</code></td>
-     *     <td>Java Virtual Machine implementation version</td></tr>
+     *     <td>Java Virtual Machine implementation version which may be
+     *     interpreted as a {@link Runtime.Version}</td></tr>
      * <tr><td><code>java.vm.vendor</code></td>
      *     <td>Java Virtual Machine implementation vendor</td></tr>
      * <tr><td><code>java.vm.name</code></td>
      *     <td>Java Virtual Machine implementation name</td></tr>
      * <tr><td><code>java.specification.version</code></td>
-     *     <td>Java Runtime Environment specification  version</td></tr>
+     *     <td>Java Runtime Environment specification version which may be
+     *     interpreted as a {@link Runtime.Version}</td></tr>
      * <tr><td><code>java.specification.vendor</code></td>
      *     <td>Java Runtime Environment specification  vendor</td></tr>
      * <tr><td><code>java.specification.name</code></td>
diff --git a/jdk/src/java.base/share/classes/java/lang/Thread.java b/jdk/src/java.base/share/classes/java/lang/Thread.java
index 54fc27f..310ada1 100644
--- a/jdk/src/java.base/share/classes/java/lang/Thread.java
+++ b/jdk/src/java.base/share/classes/java/lang/Thread.java
@@ -341,6 +341,45 @@
     }
 
     /**
+     * Indicates that the caller is momentarily unable to progress, until the
+     * occurrence of one or more actions on the part of other activities. By
+     * invoking this method within each iteration of a spin-wait loop construct,
+     * the calling thread indicates to the runtime that it is busy-waiting.
+     * The runtime may take action to improve the performance of invoking
+     * spin-wait loop constructions.
+     * <p>
+     * @apiNote
+     * As an example consider a method in a class that spins in a loop until
+     * some flag is set outside of that method. A call to the {@code onSpinWait}
+     * method should be placed inside the spin loop.
+     * <pre>{@code
+     *     class EventHandler {
+     *         volatile boolean eventNotificationNotReceived;
+     *         void waitForEventAndHandleIt() {
+     *             while ( eventNotificationNotReceived ) {
+     *                 java.lang.Thread.onSpinWait();
+     *             }
+     *             readAndProcessEvent();
+     *         }
+     *
+     *         void readAndProcessEvent() {
+     *             // Read event from some source and process it
+     *              . . .
+     *         }
+     *     }
+     * }</pre>
+     * <p>
+     * The code above would remain correct even if the {@code onSpinWait}
+     * method was not called at all. However on some architectures the Java
+     * Virtual Machine may issue the processor instructions to address such
+     * code patterns in a more beneficial way.
+     * <p>
+     * @since 9
+     */
+    @HotSpotIntrinsicCandidate
+    public static void onSpinWait() {}
+
+    /**
      * Initializes a Thread with the current AccessControlContext.
      * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean)
      */
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
index 08e3898..da1700f 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
@@ -706,6 +706,9 @@
                 case ARRAY_STORE:
                     emitArrayStore(name);
                     continue;
+                case ARRAY_LENGTH:
+                    emitArrayLength(name);
+                    continue;
                 case IDENTITY:
                     assert(name.arguments.length == 1);
                     emitPushArguments(name);
@@ -740,15 +743,16 @@
         return classFile;
     }
 
-    void emitArrayLoad(Name name)  { emitArrayOp(name, Opcodes.AALOAD);  }
-    void emitArrayStore(Name name) { emitArrayOp(name, Opcodes.AASTORE); }
+    void emitArrayLoad(Name name)   { emitArrayOp(name, Opcodes.AALOAD);      }
+    void emitArrayStore(Name name)  { emitArrayOp(name, Opcodes.AASTORE);     }
+    void emitArrayLength(Name name) { emitArrayOp(name, Opcodes.ARRAYLENGTH); }
 
     void emitArrayOp(Name name, int arrayOpcode) {
-        assert arrayOpcode == Opcodes.AALOAD || arrayOpcode == Opcodes.AASTORE;
+        assert arrayOpcode == Opcodes.AALOAD || arrayOpcode == Opcodes.AASTORE || arrayOpcode == Opcodes.ARRAYLENGTH;
         Class<?> elementType = name.function.methodType().parameterType(0).getComponentType();
         assert elementType != null;
         emitPushArguments(name);
-        if (elementType.isPrimitive()) {
+        if (arrayOpcode != Opcodes.ARRAYLENGTH && elementType.isPrimitive()) {
             Wrapper w = Wrapper.forPrimitiveType(elementType);
             arrayOpcode = arrayInsnOpcode(arrayTypeCode(w), arrayOpcode);
         }
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
index 29cc430..1aca862 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
@@ -95,12 +95,12 @@
 
     /*non-public*/ MethodHandle varHandleMethodInvoker(VarHandle.AccessMode ak) {
         // TODO cache invoker
-        return makeVarHandleMethodInvoker(ak);
+        return makeVarHandleMethodInvoker(ak, false);
     }
 
     /*non-public*/ MethodHandle varHandleMethodExactInvoker(VarHandle.AccessMode ak) {
         // TODO cache invoker
-        return makeVarHandleMethodExactInvoker(ak);
+        return makeVarHandleMethodInvoker(ak, true);
     }
 
     private MethodHandle cachedInvoker(int idx) {
@@ -127,26 +127,11 @@
         return invoker;
     }
 
-    private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak) {
+    private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak, boolean isExact) {
         MethodType mtype = targetType;
         MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
 
-        LambdaForm lform = varHandleMethodGenericInvokerHandleForm(ak.methodName(), mtype);
-        VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
-        MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
-
-        invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.methodName(), mtype), false);
-        assert(checkVarHandleInvoker(invoker));
-
-        maybeCompileToBytecode(invoker);
-        return invoker;
-    }
-
-    private MethodHandle makeVarHandleMethodExactInvoker(VarHandle.AccessMode ak) {
-        MethodType mtype = targetType;
-        MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
-
-        LambdaForm lform = varHandleMethodExactInvokerHandleForm(ak.methodName(), mtype);
+        LambdaForm lform = varHandleMethodInvokerHandleForm(ak.methodName(), mtype, isExact);
         VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
         MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
 
@@ -400,59 +385,7 @@
         return lform;
     }
 
-    private static LambdaForm varHandleMethodExactInvokerHandleForm(String name, MethodType mtype) {
-        // TODO Cache form?
-
-        final int THIS_MH      = 0;
-        final int CALL_VH      = THIS_MH + 1;
-        final int ARG_BASE     = CALL_VH + 1;
-        final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
-        int nameCursor = ARG_LIMIT;
-        final int VAD_ARG      = nameCursor++;
-        final int CHECK_TYPE   = nameCursor++;
-        final int GET_MEMBER   = nameCursor++;
-        final int LINKER_CALL  = nameCursor++;
-
-        MethodType invokerFormType = mtype.insertParameterTypes(0, VarHandle.class)
-                .basicType()
-                .appendParameterTypes(MemberName.class);
-
-        MemberName linker = new MemberName(MethodHandle.class, "linkToStatic", invokerFormType, REF_invokeStatic);
-        try {
-            linker = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linker, null, NoSuchMethodException.class);
-        } catch (ReflectiveOperationException ex) {
-            throw newInternalError(ex);
-        }
-
-        Name[] names = new Name[LINKER_CALL + 1];
-        names[THIS_MH] = argument(THIS_MH, BasicType.basicType(Object.class));
-        names[CALL_VH] = argument(CALL_VH, BasicType.basicType(Object.class));
-        for (int i = 0; i < mtype.parameterCount(); i++) {
-            names[ARG_BASE + i] = argument(ARG_BASE + i, BasicType.basicType(mtype.parameterType(i)));
-        }
-
-        BoundMethodHandle.SpeciesData speciesData = BoundMethodHandle.speciesData_L();
-        names[THIS_MH] = names[THIS_MH].withConstraint(speciesData);
-
-        NamedFunction getter = speciesData.getterFunction(0);
-        names[VAD_ARG] = new Name(getter, names[THIS_MH]);
-
-        Object[] outArgs = Arrays.copyOfRange(names, CALL_VH, ARG_LIMIT + 1, Object[].class);
-
-        names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
-
-        names[GET_MEMBER] = new Name(NF_getVarHandleMemberName, names[CALL_VH], names[VAD_ARG]);
-        outArgs[outArgs.length - 1] = names[GET_MEMBER];
-
-        names[LINKER_CALL] = new Name(linker, outArgs);
-        LambdaForm lform = new LambdaForm(name + ":VarHandle_exactInvoker" + shortenSignature(basicTypeSignature(mtype)),
-                                          ARG_LIMIT, names);
-
-        lform.compileToBytecode();
-        return lform;
-    }
-
-    private static LambdaForm varHandleMethodGenericInvokerHandleForm(String name, MethodType mtype) {
+    private static LambdaForm varHandleMethodInvokerHandleForm(String name, MethodType mtype, boolean isExact) {
         // TODO Cache form?
 
         final int THIS_MH      = 0;
@@ -477,8 +410,11 @@
         NamedFunction getter = speciesData.getterFunction(0);
         names[VAD_ARG] = new Name(getter, names[THIS_MH]);
 
-        names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
-
+        if (isExact) {
+            names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
+        } else {
+            names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
+        }
         Object[] outArgs = new Object[ARG_LIMIT];
         outArgs[0] = names[CHECK_TYPE];
         for (int i = 1; i < ARG_LIMIT; i++) {
@@ -488,7 +424,8 @@
         MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class)
                 .basicType();
         names[LINKER_CALL] = new Name(outCallType, outArgs);
-        LambdaForm lform = new LambdaForm(name + ":VarHandle_invoker" + shortenSignature(basicTypeSignature(mtype)),
+        String debugName = isExact ? ":VarHandle_exactInvoker" : ":VarHandle_invoker";
+        LambdaForm lform = new LambdaForm(name + debugName + shortenSignature(basicTypeSignature(mtype)),
                                           ARG_LIMIT, names);
 
         lform.prepare();
@@ -511,21 +448,13 @@
 
     /*non-public*/ static
     @ForceInline
-    void checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) {
-        MethodType erasedTarget = handle.vform.methodType_table[ad.type];
-        MethodType erasedSymbolic = ad.symbolicMethodTypeErased;
-        if (erasedTarget != erasedSymbolic)
-            throw newWrongMethodTypeException(erasedTarget, erasedSymbolic);
-    }
-
-    /*non-public*/ static
-    @ForceInline
-    MemberName getVarHandleMemberName(VarHandle handle, VarHandle.AccessDescriptor ad) {
-        MemberName mn = handle.vform.memberName_table[ad.mode];
-        if (mn == null) {
-            throw handle.unsupported();
+    MethodHandle checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) {
+        MethodHandle mh = handle.getMethodHandle(ad.mode);
+        MethodType mt = mh.type();
+        if (mt != ad.symbolicMethodTypeInvoker) {
+            throw newWrongMethodTypeException(mt, ad.symbolicMethodTypeInvoker);
         }
-        return mn;
+        return mh;
     }
 
     /*non-public*/ static
@@ -649,8 +578,7 @@
         NF_getCallSiteTarget,
         NF_checkCustomized,
         NF_checkVarHandleGenericType,
-        NF_checkVarHandleExactType,
-        NF_getVarHandleMemberName;
+        NF_checkVarHandleExactType;
     static {
         try {
             NamedFunction nfs[] = {
@@ -666,8 +594,6 @@
                         .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)),
                 NF_checkVarHandleExactType = new NamedFunction(Invokers.class
                         .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)),
-                NF_getVarHandleMemberName = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("getVarHandleMemberName", VarHandle.class, VarHandle.AccessDescriptor.class))
             };
             // Each nf must be statically invocable or we get tied up in our bootstraps.
             assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
index 782eff6..ac0b584 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -41,9 +41,15 @@
 import sun.invoke.util.ValueConversions;
 import sun.invoke.util.VerifyType;
 import sun.invoke.util.Wrapper;
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+
 import static java.lang.invoke.LambdaForm.*;
 import static java.lang.invoke.MethodHandleStatics.*;
 import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
+import static jdk.internal.org.objectweb.asm.Opcodes.*;
 
 /**
  * Trusted implementation code for MethodHandle.
@@ -66,25 +72,28 @@
 
     /// Factory methods to create method handles:
 
-    static MethodHandle makeArrayElementAccessor(Class<?> arrayClass, boolean isSetter) {
-        if (arrayClass == Object[].class)
-            return (isSetter ? ArrayAccessor.OBJECT_ARRAY_SETTER : ArrayAccessor.OBJECT_ARRAY_GETTER);
+    static MethodHandle makeArrayElementAccessor(Class<?> arrayClass, ArrayAccess access) {
+        if (arrayClass == Object[].class) {
+            return ArrayAccess.objectAccessor(access);
+        }
         if (!arrayClass.isArray())
             throw newIllegalArgumentException("not an array: "+arrayClass);
         MethodHandle[] cache = ArrayAccessor.TYPED_ACCESSORS.get(arrayClass);
-        int cacheIndex = (isSetter ? ArrayAccessor.SETTER_INDEX : ArrayAccessor.GETTER_INDEX);
+        int cacheIndex = ArrayAccess.cacheIndex(access);
         MethodHandle mh = cache[cacheIndex];
         if (mh != null)  return mh;
-        mh = ArrayAccessor.getAccessor(arrayClass, isSetter);
-        MethodType correctType = ArrayAccessor.correctType(arrayClass, isSetter);
+        mh = ArrayAccessor.getAccessor(arrayClass, access);
+        MethodType correctType = ArrayAccessor.correctType(arrayClass, access);
         if (mh.type() != correctType) {
             assert(mh.type().parameterType(0) == Object[].class);
-            assert((isSetter ? mh.type().parameterType(2) : mh.type().returnType()) == Object.class);
-            assert(isSetter || correctType.parameterType(0).getComponentType() == correctType.returnType());
+            /* if access == SET */ assert(access != ArrayAccess.SET || mh.type().parameterType(2) == Object.class);
+            /* if access == GET */ assert(access != ArrayAccess.GET ||
+                    (mh.type().returnType() == Object.class &&
+                     correctType.parameterType(0).getComponentType() == correctType.returnType()));
             // safe to view non-strictly, because element type follows from array type
             mh = mh.viewAsType(correctType, false);
         }
-        mh = makeIntrinsic(mh, (isSetter ? Intrinsic.ARRAY_STORE : Intrinsic.ARRAY_LOAD));
+        mh = makeIntrinsic(mh, ArrayAccess.intrinsic(access));
         // Atomically update accessor cache.
         synchronized(cache) {
             if (cache[cacheIndex] == null) {
@@ -97,9 +106,56 @@
         return mh;
     }
 
+    enum ArrayAccess {
+        GET, SET, LENGTH;
+
+        // As ArrayAccess and ArrayAccessor have a circular dependency, the ArrayAccess properties cannot be stored in
+        // final fields.
+
+        static String opName(ArrayAccess a) {
+            switch (a) {
+                case GET: return "getElement";
+                case SET: return "setElement";
+                case LENGTH: return "length";
+            }
+            throw unmatchedArrayAccess(a);
+        }
+
+        static MethodHandle objectAccessor(ArrayAccess a) {
+            switch (a) {
+                case GET: return ArrayAccessor.OBJECT_ARRAY_GETTER;
+                case SET: return ArrayAccessor.OBJECT_ARRAY_SETTER;
+                case LENGTH: return ArrayAccessor.OBJECT_ARRAY_LENGTH;
+            }
+            throw unmatchedArrayAccess(a);
+        }
+
+        static int cacheIndex(ArrayAccess a) {
+            switch (a) {
+                case GET: return ArrayAccessor.GETTER_INDEX;
+                case SET: return ArrayAccessor.SETTER_INDEX;
+                case LENGTH: return ArrayAccessor.LENGTH_INDEX;
+            }
+            throw unmatchedArrayAccess(a);
+        }
+
+        static Intrinsic intrinsic(ArrayAccess a) {
+            switch (a) {
+                case GET: return Intrinsic.ARRAY_LOAD;
+                case SET: return Intrinsic.ARRAY_STORE;
+                case LENGTH: return Intrinsic.ARRAY_LENGTH;
+            }
+            throw unmatchedArrayAccess(a);
+        }
+    }
+
+    static InternalError unmatchedArrayAccess(ArrayAccess a) {
+        return newInternalError("should not reach here (unmatched ArrayAccess: " + a + ")");
+    }
+
     static final class ArrayAccessor {
-        /// Support for array element access
-        static final int GETTER_INDEX = 0, SETTER_INDEX = 1, INDEX_LIMIT = 2;
+        /// Support for array element and length access
+        static final int GETTER_INDEX = 0, SETTER_INDEX = 1, LENGTH_INDEX = 2, INDEX_LIMIT = 3;
         static final ClassValue<MethodHandle[]> TYPED_ACCESSORS
                 = new ClassValue<MethodHandle[]>() {
                     @Override
@@ -107,14 +163,16 @@
                         return new MethodHandle[INDEX_LIMIT];
                     }
                 };
-        static final MethodHandle OBJECT_ARRAY_GETTER, OBJECT_ARRAY_SETTER;
+        static final MethodHandle OBJECT_ARRAY_GETTER, OBJECT_ARRAY_SETTER, OBJECT_ARRAY_LENGTH;
         static {
             MethodHandle[] cache = TYPED_ACCESSORS.get(Object[].class);
-            cache[GETTER_INDEX] = OBJECT_ARRAY_GETTER = makeIntrinsic(getAccessor(Object[].class, false), Intrinsic.ARRAY_LOAD);
-            cache[SETTER_INDEX] = OBJECT_ARRAY_SETTER = makeIntrinsic(getAccessor(Object[].class, true),  Intrinsic.ARRAY_STORE);
+            cache[GETTER_INDEX] = OBJECT_ARRAY_GETTER = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.GET),    Intrinsic.ARRAY_LOAD);
+            cache[SETTER_INDEX] = OBJECT_ARRAY_SETTER = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.SET),    Intrinsic.ARRAY_STORE);
+            cache[LENGTH_INDEX] = OBJECT_ARRAY_LENGTH = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.LENGTH), Intrinsic.ARRAY_LENGTH);
 
             assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_GETTER.internalMemberName()));
             assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_SETTER.internalMemberName()));
+            assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_LENGTH.internalMemberName()));
         }
 
         static int     getElementI(int[]     a, int i)            { return              a[i]; }
@@ -137,31 +195,47 @@
         static void    setElementC(char[]    a, int i, char    x) {              a[i] = x; }
         static void    setElementL(Object[]  a, int i, Object  x) {              a[i] = x; }
 
-        static String name(Class<?> arrayClass, boolean isSetter) {
+        static int     lengthI(int[]     a)                       { return a.length; }
+        static int     lengthJ(long[]    a)                       { return a.length; }
+        static int     lengthF(float[]   a)                       { return a.length; }
+        static int     lengthD(double[]  a)                       { return a.length; }
+        static int     lengthZ(boolean[] a)                       { return a.length; }
+        static int     lengthB(byte[]    a)                       { return a.length; }
+        static int     lengthS(short[]   a)                       { return a.length; }
+        static int     lengthC(char[]    a)                       { return a.length; }
+        static int     lengthL(Object[]  a)                       { return a.length; }
+
+        static String name(Class<?> arrayClass, ArrayAccess access) {
             Class<?> elemClass = arrayClass.getComponentType();
             if (elemClass == null)  throw newIllegalArgumentException("not an array", arrayClass);
-            return (!isSetter ? "getElement" : "setElement") + Wrapper.basicTypeChar(elemClass);
+            return ArrayAccess.opName(access) + Wrapper.basicTypeChar(elemClass);
         }
-        static MethodType type(Class<?> arrayClass, boolean isSetter) {
+        static MethodType type(Class<?> arrayClass, ArrayAccess access) {
             Class<?> elemClass = arrayClass.getComponentType();
             Class<?> arrayArgClass = arrayClass;
             if (!elemClass.isPrimitive()) {
                 arrayArgClass = Object[].class;
                 elemClass = Object.class;
             }
-            return !isSetter ?
-                    MethodType.methodType(elemClass,  arrayArgClass, int.class) :
-                    MethodType.methodType(void.class, arrayArgClass, int.class, elemClass);
+            switch (access) {
+                case GET:    return MethodType.methodType(elemClass,  arrayArgClass, int.class);
+                case SET:    return MethodType.methodType(void.class, arrayArgClass, int.class, elemClass);
+                case LENGTH: return MethodType.methodType(int.class,  arrayArgClass);
+            }
+            throw unmatchedArrayAccess(access);
         }
-        static MethodType correctType(Class<?> arrayClass, boolean isSetter) {
+        static MethodType correctType(Class<?> arrayClass, ArrayAccess access) {
             Class<?> elemClass = arrayClass.getComponentType();
-            return !isSetter ?
-                    MethodType.methodType(elemClass,  arrayClass, int.class) :
-                    MethodType.methodType(void.class, arrayClass, int.class, elemClass);
+            switch (access) {
+                case GET:    return MethodType.methodType(elemClass,  arrayClass, int.class);
+                case SET:    return MethodType.methodType(void.class, arrayClass, int.class, elemClass);
+                case LENGTH: return MethodType.methodType(int.class,  arrayClass);
+            }
+            throw unmatchedArrayAccess(access);
         }
-        static MethodHandle getAccessor(Class<?> arrayClass, boolean isSetter) {
-            String     name = name(arrayClass, isSetter);
-            MethodType type = type(arrayClass, isSetter);
+        static MethodHandle getAccessor(Class<?> arrayClass, ArrayAccess access) {
+            String     name = name(arrayClass, access);
+            MethodType type = type(arrayClass, access);
             try {
                 return IMPL_LOOKUP.findStatic(ArrayAccessor.class, name, type);
             } catch (ReflectiveOperationException ex) {
@@ -1091,6 +1165,8 @@
     // Put the whole mess into its own nested class.
     // That way we can lazily load the code and set up the constants.
     private static class BindCaller {
+        private static MethodType INVOKER_MT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class);
+
         static
         MethodHandle bindCaller(MethodHandle mh, Class<?> hostClass) {
             // Do not use this function to inject calls into system classes.
@@ -1109,38 +1185,15 @@
         }
 
         private static MethodHandle makeInjectedInvoker(Class<?> hostClass) {
-            Class<?> bcc = UNSAFE.defineAnonymousClass(hostClass, T_BYTES, null);
-            if (hostClass.getClassLoader() != bcc.getClassLoader())
-                throw new InternalError(hostClass.getName()+" (CL)");
             try {
-                if (hostClass.getProtectionDomain() != bcc.getProtectionDomain())
-                    throw new InternalError(hostClass.getName()+" (PD)");
-            } catch (SecurityException ex) {
-                // Self-check was blocked by security manager.  This is OK.
-                // In fact the whole try body could be turned into an assertion.
-            }
-            try {
-                MethodHandle init = IMPL_LOOKUP.findStatic(bcc, "init", MethodType.methodType(void.class));
-                init.invokeExact();  // force initialization of the class
-            } catch (Throwable ex) {
-                throw uncaughtException(ex);
-            }
-            MethodHandle bccInvoker;
-            try {
-                MethodType invokerMT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class);
-                bccInvoker = IMPL_LOOKUP.findStatic(bcc, "invoke_V", invokerMT);
+                Class<?> invokerClass = UNSAFE.defineAnonymousClass(hostClass, INJECTED_INVOKER_TEMPLATE, null);
+                assert checkInjectedInvoker(hostClass, invokerClass);
+                return IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT);
             } catch (ReflectiveOperationException ex) {
                 throw uncaughtException(ex);
             }
-            // Test the invoker, to ensure that it really injects into the right place.
-            try {
-                MethodHandle vamh = prepareForInvoker(MH_checkCallerClass);
-                Object ok = bccInvoker.invokeExact(vamh, new Object[]{hostClass, bcc});
-            } catch (Throwable ex) {
-                throw new InternalError(ex);
-            }
-            return bccInvoker;
         }
+
         private static ClassValue<MethodHandle> CV_makeInjectedInvoker = new ClassValue<MethodHandle>() {
             @Override protected MethodHandle computeValue(Class<?> hostClass) {
                 return makeInjectedInvoker(hostClass);
@@ -1171,62 +1224,82 @@
             return mh;
         }
 
+        private static boolean checkInjectedInvoker(Class<?> hostClass, Class<?> invokerClass) {
+            assert (hostClass.getClassLoader() == invokerClass.getClassLoader()) : hostClass.getName()+" (CL)";
+            try {
+                assert (hostClass.getProtectionDomain() == invokerClass.getProtectionDomain()) : hostClass.getName()+" (PD)";
+            } catch (SecurityException ex) {
+                // Self-check was blocked by security manager. This is OK.
+            }
+            try {
+                // Test the invoker to ensure that it really injects into the right place.
+                MethodHandle invoker = IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT);
+                MethodHandle vamh = prepareForInvoker(MH_checkCallerClass);
+                return (boolean)invoker.invoke(vamh, new Object[]{ invokerClass });
+            } catch (Throwable ex) {
+                throw new InternalError(ex);
+            }
+        }
+
         private static final MethodHandle MH_checkCallerClass;
         static {
             final Class<?> THIS_CLASS = BindCaller.class;
-            assert(checkCallerClass(THIS_CLASS, THIS_CLASS));
+            assert(checkCallerClass(THIS_CLASS));
             try {
                 MH_checkCallerClass = IMPL_LOOKUP
                     .findStatic(THIS_CLASS, "checkCallerClass",
-                                MethodType.methodType(boolean.class, Class.class, Class.class));
-                assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS, THIS_CLASS));
+                                MethodType.methodType(boolean.class, Class.class));
+                assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS));
             } catch (Throwable ex) {
                 throw new InternalError(ex);
             }
         }
 
         @CallerSensitive
-        private static boolean checkCallerClass(Class<?> expected, Class<?> expected2) {
-            // This method is called via MH_checkCallerClass and so it's
-            // correct to ask for the immediate caller here.
+        private static boolean checkCallerClass(Class<?> expected) {
+            // This method is called via MH_checkCallerClass and so it's correct to ask for the immediate caller here.
             Class<?> actual = Reflection.getCallerClass();
-            if (actual != expected && actual != expected2)
-                throw new InternalError("found "+actual.getName()+", expected "+expected.getName()
-                                        +(expected == expected2 ? "" : ", or else "+expected2.getName()));
+            if (actual != expected)
+                throw new InternalError("found " + actual.getName() + ", expected " + expected.getName());
             return true;
         }
 
-        private static final byte[] T_BYTES;
-        static {
-            final Object[] values = {null};
-            AccessController.doPrivileged(new PrivilegedAction<>() {
-                    public Void run() {
-                        try {
-                            Class<T> tClass = T.class;
-                            String tName = tClass.getName();
-                            String tResource = tName.substring(tName.lastIndexOf('.')+1)+".class";
-                            try (java.io.InputStream in = tClass.getResourceAsStream(tResource)) {
-                                values[0] = in.readAllBytes();
-                            }
-                        } catch (java.io.IOException ex) {
-                            throw new InternalError(ex);
-                        }
-                        return null;
-                    }
-                });
-            T_BYTES = (byte[]) values[0];
-        }
+        private static final byte[] INJECTED_INVOKER_TEMPLATE = generateInvokerTemplate();
 
-        // The following class is used as a template for Unsafe.defineAnonymousClass:
-        private static class T {
-            static void init() { }  // side effect: initializes this class
-            static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable {
-                return vamh.invokeExact(args);
-            }
+        /** Produces byte code for a class that is used as an injected invoker. */
+        private static byte[] generateInvokerTemplate() {
+            ClassWriter cw = new ClassWriter(0);
+
+            // private static class InjectedInvoker {
+            //     @Hidden
+            //     static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable {
+            //        return vamh.invokeExact(args);
+            //     }
+            // }
+            cw.visit(52, ACC_PRIVATE | ACC_SUPER, "InjectedInvoker", null, "java/lang/Object", null);
+
+            MethodVisitor mv = cw.visitMethod(ACC_STATIC, "invoke_V",
+                          "(Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object;",
+                          null, null);
+
+            // Suppress invoker method in stack traces.
+            AnnotationVisitor av0 = mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
+            av0.visitEnd();
+
+            mv.visitCode();
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitVarInsn(ALOAD, 1);
+            mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact",
+                               "([Ljava/lang/Object;)Ljava/lang/Object;", false);
+            mv.visitInsn(ARETURN);
+            mv.visitMaxs(2, 2);
+            mv.visitEnd();
+
+            cw.visitEnd();
+            return cw.toByteArray();
         }
     }
 
-
     /** This subclass allows a wrapped method handle to be re-associated with an arbitrary member name. */
     private static final class WrappedMember extends DelegatingMethodHandle {
         private final MethodHandle target;
@@ -1282,6 +1355,7 @@
         NEW_ARRAY,
         ARRAY_LOAD,
         ARRAY_STORE,
+        ARRAY_LENGTH,
         IDENTITY,
         ZERO,
         NONE // no intrinsic associated
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
index c3a97a1..716d62f 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
@@ -2245,6 +2245,21 @@
     }
 
     /**
+     * Produces a method handle returning the length of an array.
+     * The type of the method handle will have {@code int} as return type,
+     * and its sole argument will be the array type.
+     * @param arrayClass an array type
+     * @return a method handle which can retrieve the length of an array of the given array type
+     * @throws NullPointerException if the argument is {@code null}
+     * @throws IllegalArgumentException if arrayClass is not an array type
+     * @since 9
+     */
+    public static
+    MethodHandle arrayLength(Class<?> arrayClass) throws IllegalArgumentException {
+        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.LENGTH);
+    }
+
+    /**
      * Produces a method handle giving read access to elements of an array.
      * The type of the method handle will have a return type of the array's
      * element type.  Its first argument will be the array type,
@@ -2256,7 +2271,7 @@
      */
     public static
     MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
-        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, false);
+        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.GET);
     }
 
     /**
@@ -2271,7 +2286,7 @@
      */
     public static
     MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
-        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, true);
+        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.SET);
     }
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
index 0d965ed..7da4550 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
@@ -128,7 +128,7 @@
     /**
      * Default strategy to use for concatenation.
      */
-    private static final Strategy DEFAULT_STRATEGY = Strategy.BC_SB;
+    private static final Strategy DEFAULT_STRATEGY = Strategy.MH_INLINE_SIZED_EXACT;
 
     private enum Strategy {
         /**
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
index 78a75bf..ee7be40 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
@@ -26,6 +26,7 @@
 package java.lang.invoke;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.util.Preconditions;
 import jdk.internal.vm.annotation.ForceInline;
 import jdk.internal.vm.annotation.Stable;
 
@@ -33,7 +34,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 
@@ -1475,11 +1475,11 @@
         TypesAndInvokers tis = getTypesAndInvokers();
         MethodHandle mh = tis.methodHandle_table[mode];
         if (mh == null) {
-            mh = tis.methodHandle_table[mode] = getMethodHandleUncached(tis, mode);
+            mh = tis.methodHandle_table[mode] = getMethodHandleUncached(mode);
         }
         return mh;
     }
-    private final MethodHandle getMethodHandleUncached(TypesAndInvokers tis, int mode) {
+    private final MethodHandle getMethodHandleUncached(int mode) {
         MethodType mt = accessModeType(AccessMode.values()[mode]).
                 insertParameterTypes(0, VarHandle.class);
         MemberName mn = vform.getMemberName(mode);
@@ -1501,7 +1501,7 @@
     }
 
     static final BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException>
-            AIOOBE_SUPPLIER = Objects.outOfBoundsExceptionFormatter(
+            AIOOBE_SUPPLIER = Preconditions.outOfBoundsExceptionFormatter(
             new Function<String, ArrayIndexOutOfBoundsException>() {
                 @Override
                 public ArrayIndexOutOfBoundsException apply(String s) {
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
index 7a058af..ebb6dd3 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
@@ -24,9 +24,11 @@
  */
 package java.lang.invoke;
 
-import java.util.Objects;
+import jdk.internal.util.Preconditions;
 import jdk.internal.vm.annotation.ForceInline;
 
+import java.util.Objects;
+
 import static java.lang.invoke.MethodHandleStatics.UNSAFE;
 
 #warn
@@ -163,8 +165,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -345,8 +346,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$Type$(handle.base,
+            return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -447,7 +447,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.get$Type$Volatile(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
         }
 
         @ForceInline
@@ -458,7 +458,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             UNSAFE.put$Type$Volatile(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 
@@ -470,7 +470,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.get$Type$Opaque(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
         }
 
         @ForceInline
@@ -481,7 +481,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             UNSAFE.put$Type$Opaque(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 
@@ -493,7 +493,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.get$Type$Acquire(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
         }
 
         @ForceInline
@@ -504,7 +504,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             UNSAFE.put$Type$Release(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 #if[CAS]
@@ -517,7 +517,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndSwap$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -530,7 +530,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndExchange$Type$Volatile(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -543,7 +543,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndExchange$Type$Acquire(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -556,7 +556,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndExchange$Type$Release(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -569,7 +569,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.weakCompareAndSwap$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -581,9 +581,8 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+            return UNSAFE.weakCompareAndSwap$Type$Volatile(array,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -596,7 +595,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -609,7 +608,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.weakCompareAndSwap$Type$Release(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -622,7 +621,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.getAndSet$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 #end[CAS]
@@ -636,7 +635,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.getAndAdd$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     value);
         }
 
@@ -648,7 +647,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.getAndAdd$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     value) + value;
         }
 #end[AtomicAdd]
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
index 8639e0d..66bf267 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
@@ -25,6 +25,7 @@
 package java.lang.invoke;
 
 import jdk.internal.misc.Unsafe;
+import jdk.internal.util.Preconditions;
 import jdk.internal.vm.annotation.ForceInline;
 
 import java.nio.ByteBuffer;
@@ -81,7 +82,7 @@
 
         @ForceInline
         static int index(byte[] ba, int index) {
-            return Objects.checkIndex(index, ba.length - ALIGN, null);
+            return Preconditions.checkIndex(index, ba.length - ALIGN, null);
         }
 
         @ForceInline
@@ -233,8 +234,7 @@
         @ForceInline
         static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -271,22 +271,33 @@
 #if[AtomicAdd]
 
         @ForceInline
-        static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ value) {
+        static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ delta) {
             byte[] ba = (byte[]) oba;
-            return convEndian(handle.be,
-                              UNSAFE.getAndAdd$RawType$(
-                                      ba,
-                                      address(ba, index(ba, index)),
-                                      convEndian(handle.be, value)));
+            if (handle.be == BE) {
+                return UNSAFE.getAndAdd$RawType$(
+                        ba,
+                        address(ba, index(ba, index)),
+                        delta);
+            } else {
+                return getAndAddConvEndianWithCAS(ba, index, delta);
+            }
         }
 
         @ForceInline
-        static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ value) {
-            byte[] ba = (byte[]) oba;
-            return convEndian(handle.be, UNSAFE.getAndAdd$RawType$(
-                    ba,
-                    address(ba, index(ba, index)),
-                    convEndian(handle.be, value))) + value;
+        static $type$ getAndAddConvEndianWithCAS(byte[] ba, int index, $type$ delta) {
+            $type$ nativeExpectedValue, expectedValue;
+            long offset = address(ba, index(ba, index));
+            do {
+                nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
+                expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
+            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+                    nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
+            return expectedValue;
+        }
+
+        @ForceInline
+        static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ delta) {
+            return getAndAdd(handle, oba, index, delta) + delta;
         }
 #end[AtomicAdd]
 
@@ -307,14 +318,14 @@
 
         @ForceInline
         static int index(ByteBuffer bb, int index) {
-            return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
+            return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
         }
 
         @ForceInline
         static int indexRO(ByteBuffer bb, int index) {
             if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY))
                 throw new ReadOnlyBufferException();
-            return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
+            return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
         }
 
         @ForceInline
@@ -466,8 +477,7 @@
         @ForceInline
         static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -504,23 +514,34 @@
 #if[AtomicAdd]
 
         @ForceInline
-        static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ value) {
+        static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return convEndian(handle.be,
-                              UNSAFE.getAndAdd$RawType$(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
-                                      address(bb, indexRO(bb, index)),
-                                      convEndian(handle.be, value)));
+            if (handle.be == BE) {
+                return UNSAFE.getAndAdd$RawType$(
+                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        address(bb, indexRO(bb, index)),
+                        delta);
+            } else {
+                return getAndAddConvEndianWithCAS(bb, index, delta);
+            }
         }
 
         @ForceInline
-        static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
-            ByteBuffer bb = (ByteBuffer) obb;
-            return convEndian(handle.be,
-                              UNSAFE.getAndAdd$RawType$(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
-                                      address(bb, indexRO(bb, index)),
-                                      convEndian(handle.be, value))) + value;
+        static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) {
+            $type$ nativeExpectedValue, expectedValue;
+            Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
+            long offset = address(bb, indexRO(bb, index));
+            do {
+                nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
+                expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
+            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+                    nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
+            return expectedValue;
+        }
+
+        @ForceInline
+        static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
+            return getAndAdd(handle, obb, index, delta) + delta;
         }
 #end[AtomicAdd]
 
diff --git a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
index 4b6ab93..d1efde87 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
@@ -152,7 +152,7 @@
  *    Configuration parent = Layer.boot().configuration();
  *
  *    Configuration cf = parent.resolveRequires(finder,
- *                                              ModuleFinder.empty(),
+ *                                              ModuleFinder.of(),
  *                                              Set.of("myapp"));
  *    cf.modules().forEach(m -> {
  *        System.out.format("%s -> %s%n",
@@ -366,7 +366,7 @@
         Configuration parent = empty();
 
         Resolver resolver
-            = new Resolver(finder, parent, ModuleFinder.empty(), traceOutput);
+            = new Resolver(finder, parent, ModuleFinder.of(), traceOutput);
         resolver.resolveRequires(roots).resolveUses();
 
         return new Configuration(parent, resolver, check);
diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java
index 1cdd128..a692448 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java
@@ -33,12 +33,15 @@
 import java.security.AccessController;
 import java.security.Permission;
 import java.security.PrivilegedAction;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 import sun.security.action.GetPropertyAction;
 
 /**
@@ -60,15 +63,15 @@
  *     ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
  *
  *     Optional<ModuleReference> omref = finder.find("jdk.foo");
- *     if (omref.isPresent()) { ... }
+ *     omref.ifPresent(mref -> ... );
  *
  * }</pre>
  *
  * <p> The {@link #find(String) find} and {@link #findAll() findAll} methods
- * defined here can fail for several reasons. These include include I/O errors,
- * errors detected parsing a module descriptor ({@code module-info.class}), or
- * in the case of {@code ModuleFinder} returned by {@link #of ModuleFinder.of},
- * that two or more modules with the same name are found in a directory.
+ * defined here can fail for several reasons. These include I/O errors, errors
+ * detected parsing a module descriptor ({@code module-info.class}), or in the
+ * case of {@code ModuleFinder} returned by {@link #of ModuleFinder.of}, that
+ * two or more modules with the same name are found in a directory.
  * When an error is detected then these methods throw {@link FindException
  * FindException} with an appropriate {@link Throwable#getCause cause}.
  * The behavior of a {@code ModuleFinder} after a {@code FindException} is
@@ -205,11 +208,13 @@
      *
      * <p> The module finder returned by this method supports modules that are
      * packaged as JAR files. A JAR file with a {@code module-info.class} in
-     * the top-level directory of the JAR file is a modular JAR and is an
-     * <em>explicit module</em>. A JAR file that does not have a {@code
-     * module-info.class} in the top-level directory is an {@link
-     * ModuleDescriptor#isAutomatic automatic} module. The {@link
-     * ModuleDescriptor} for an automatic module is created as follows:
+     * the top-level directory of the JAR file (or overridden by a versioned
+     * entry in a {@link java.util.jar.JarFile#isMultiRelease() multi-release}
+     * JAR file) is a modular JAR and is an <em>explicit module</em>.
+     * A JAR file that does not have a {@code module-info.class} in the
+     * top-level directory is an {@link ModuleDescriptor#isAutomatic automatic}
+     * module. The {@link ModuleDescriptor} for an automatic module is created as
+     * follows:
      *
      * <ul>
      *
@@ -263,18 +268,22 @@
      * </ul>
      *
      * <p> In addition to JAR files, an implementation may also support modules
-     * that are packaged in other implementation specific module formats. As
-     * with automatic modules, the contents of a packaged or exploded module
-     * may need to be <em>scanned</em> in order to determine the packages in
-     * the module. If a {@code .class} file that corresponds to a class in an
+     * that are packaged in other implementation specific module formats. When
+     * a file is encountered that is not recognized as a packaged module then
+     * {@code FindException} is thrown. An implementation may choose to ignore
+     * some files, {@link java.nio.file.Files#isHidden hidden} files for
+     * example. Paths to files that do not exist are always ignored. </p>
+     *
+     * <p> As with automatic modules, the contents of a packaged or exploded
+     * module may need to be <em>scanned</em> in order to determine the packages
+     * in the module. If a {@code .class} file that corresponds to a class in an
      * unnamed package is encountered then {@code FindException} is thrown. </p>
      *
      * <p> Finders created by this method are lazy and do not eagerly check
      * that the given file paths are directories or packaged modules.
      * Consequently, the {@code find} or {@code findAll} methods will only
      * fail if invoking these methods results in searching a directory or
-     * packaged module and an error is encountered. Paths to files that do not
-     * exist are ignored. </p>
+     * packaged module and an error is encountered. </p>
      *
      * @param entries
      *        A possibly-empty array of paths to directories of modules
@@ -283,81 +292,87 @@
      * @return A {@code ModuleFinder} that locates modules on the file system
      */
     static ModuleFinder of(Path... entries) {
+        // special case zero entries
+        if (entries.length == 0) {
+            return new ModuleFinder() {
+                @Override
+                public Optional<ModuleReference> find(String name) {
+                    Objects.requireNonNull(name);
+                    return Optional.empty();
+                }
+
+                @Override
+                public Set<ModuleReference> findAll() {
+                    return Collections.emptySet();
+                }
+            };
+        }
+
         return new ModulePath(entries);
     }
 
     /**
-     * Returns a module finder that is the equivalent to composing two
-     * module finders. The resulting finder will locate modules references
-     * using {@code first}; if not found then it will attempt to locate module
-     * references using {@code second}.
+     * Returns a module finder that is composed from a sequence of zero or more
+     * module finders. The {@link #find(String) find} method of the resulting
+     * module finder will locate a module by invoking the {@code find} method
+     * of each module finder, in array index order, until either the module is
+     * found or all module finders have been searched. The {@link #findAll()
+     * findAll} method of the resulting module finder will return a set of
+     * modules that includes all modules located by the first module finder.
+     * The set of modules will include all modules located by the second or
+     * subsequent module finder that are not located by previous module finders
+     * in the sequence.
      *
-     * <p> The {@link #findAll() findAll} method of the resulting module finder
-     * will locate all modules located by the first module finder. It will
-     * also locate all modules located by the second module finder that are not
-     * located by the first module finder. </p>
+     * <p> When locating modules then any exceptions or errors thrown by the
+     * {@code find} or {@code findAll} methods of the underlying module finders
+     * will be propogated to the caller of the resulting module finder's
+     * {@code find} or {@code findAll} methods. </p>
      *
-     * @apiNote This method will eventually be changed to take a sequence of
-     *          module finders.
+     * @param finders
+     *        The array of module finders
      *
-     * @param first
-     *        The first module finder
-     * @param second
-     *        The second module finder
-     *
-     * @return A {@code ModuleFinder} that composes two module finders
+     * @return A {@code ModuleFinder} that composes a sequence of module finders
      */
-    static ModuleFinder compose(ModuleFinder first, ModuleFinder second) {
-        Objects.requireNonNull(first);
-        Objects.requireNonNull(second);
+    static ModuleFinder compose(ModuleFinder... finders) {
+        final List<ModuleFinder> finderList = Arrays.asList(finders);
+        finderList.forEach(Objects::requireNonNull);
 
         return new ModuleFinder() {
-            Set<ModuleReference> allModules;
+            private final Map<String, ModuleReference> nameToModule = new HashMap<>();
+            private Set<ModuleReference> allModules;
 
             @Override
             public Optional<ModuleReference> find(String name) {
-                Optional<ModuleReference> om = first.find(name);
-                if (!om.isPresent())
-                    om = second.find(name);
-                return om;
+                // cached?
+                ModuleReference mref = nameToModule.get(name);
+                if (mref != null)
+                    return Optional.of(mref);
+                Optional<ModuleReference> omref = finderList.stream()
+                        .map(f -> f.find(name))
+                        .flatMap(Optional::stream)
+                        .findFirst();
+                omref.ifPresent(m -> nameToModule.put(name, m));
+                return omref;
             }
+
             @Override
             public Set<ModuleReference> findAll() {
-                if (allModules == null) {
-                    allModules = Stream.concat(first.findAll().stream(),
-                                               second.findAll().stream())
-                                       .map(a -> a.descriptor().name())
-                                       .distinct()
-                                       .map(this::find)
-                                       .map(Optional::get)
-                                       .collect(Collectors.toSet());
-                }
+                if (allModules != null)
+                    return allModules;
+                // seed with modules already found
+                Set<ModuleReference> result = new HashSet<>(nameToModule.values());
+                finderList.stream()
+                          .flatMap(f -> f.findAll().stream())
+                          .forEach(mref -> {
+                              String name = mref.descriptor().name();
+                              if (nameToModule.putIfAbsent(name, mref) == null) {
+                                  result.add(mref);
+                              }
+                          });
+                allModules = Collections.unmodifiableSet(result);
                 return allModules;
             }
         };
     }
 
-    /**
-     * Returns an empty module finder.  The empty finder does not find any
-     * modules.
-     *
-     * @apiNote This is useful when using methods such as {@link
-     * Configuration#resolveRequires resolveRequires} where two finders are
-     * specified. An alternative is {@code ModuleFinder.of()}.
-     *
-     * @return A {@code ModuleFinder} that does not find any modules
-     */
-    static ModuleFinder empty() {
-        // an alternative implementation of ModuleFinder.of()
-        return new ModuleFinder() {
-            @Override public Optional<ModuleReference> find(String name) {
-                Objects.requireNonNull(name);
-                return Optional.empty();
-            }
-            @Override public Set<ModuleReference> findAll() {
-                return Collections.emptySet();
-            }
-        };
-    }
-
 }
diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java
index efc8c37..7bf9342 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java
@@ -154,7 +154,7 @@
         int minor_version = in.readUnsignedShort();
         int major_version = in.readUnsignedShort();
         if (major_version < 53) {
-            // throw invalidModuleDescriptor"Must be >= 53.0");
+            throw invalidModuleDescriptor("Must be >= 53.0");
         }
 
         ConstantPool cpool = new ConstantPool(in);
diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java
index 6b0b5d4..eccd0d4 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java
@@ -220,10 +220,10 @@
         Optional<URI> implFind(String name) throws IOException {
             JarEntry je = getEntry(name);
             if (je != null) {
+                if (jf.isMultiRelease())
+                    name = SharedSecrets.javaUtilJarAccess().getRealName(jf, je);
                 String encodedPath = ParseUtil.encodePath(name, false);
                 String uris = "jar:" + uri + "!/" + encodedPath;
-                if (jf.isMultiRelease())
-                    uris += "#runtime";
                 return Optional.of(URI.create(uris));
             } else {
                 return Optional.empty();
diff --git a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java
index d14ee8d..77d5392 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java
@@ -45,6 +45,7 @@
 import jdk.internal.jimage.ImageReader;
 import jdk.internal.jimage.ImageReaderFactory;
 import jdk.internal.module.ModuleHashes;
+import jdk.internal.module.ModuleHashes.HashSupplier;
 import jdk.internal.module.SystemModules;
 import jdk.internal.module.ModulePatcher;
 import jdk.internal.perf.PerfCounter;
@@ -84,57 +85,23 @@
         long t0 = System.nanoTime();
         imageReader = ImageReaderFactory.getImageReader();
 
-        String[] moduleNames = SystemModules.MODULE_NAMES;
-        ModuleDescriptor[] descriptors = null;
+        String[] names = moduleNames();
+        ModuleDescriptor[] descriptors = descriptors(names);
 
-        boolean fastLoad = System.getProperty("jdk.installed.modules.disable") == null;
-        if (fastLoad) {
-            // fast loading of ModuleDescriptor of installed modules
-            descriptors = SystemModules.modules();
-        }
-
-        int n = moduleNames.length;
+        int n = names.length;
         moduleCount.add(n);
 
         Set<ModuleReference> mods = new HashSet<>(n);
         Map<String, ModuleReference> map = new HashMap<>(n);
 
         for (int i = 0; i < n; i++) {
-            String mn = moduleNames[i];
-            ModuleDescriptor md;
-            String hash;
-            if (fastLoad) {
-                md = descriptors[i];
-                hash = SystemModules.MODULES_TO_HASH[i];
-            } else {
-                // fallback to read module-info.class
-                // if fast loading of ModuleDescriptors is disabled
-                ImageLocation location = imageReader.findLocation(mn, "module-info.class");
-                md = ModuleDescriptor.read(imageReader.getResourceBuffer(location));
-                hash = null;
-            }
-            if (!md.name().equals(mn))
-                throw new InternalError();
+            ModuleDescriptor md = descriptors[i];
 
             // create the ModuleReference
-
-            URI uri = URI.create("jrt:/" + mn);
-
-            Supplier<ModuleReader> readerSupplier = new Supplier<>() {
-                @Override
-                public ModuleReader get() {
-                    return new ImageModuleReader(mn, uri);
-                }
-            };
-
-            ModuleReference mref =
-                new ModuleReference(md, uri, readerSupplier, hashSupplier(hash));
-
-            // may need a reference to a patched module if -Xpatch specified
-            mref = ModulePatcher.interposeIfNeeded(mref);
+            ModuleReference mref = toModuleReference(md, hashSupplier(i, names[i]));
 
             mods.add(mref);
-            map.put(mn, mref);
+            map.put(names[i], mref);
 
             // counters
             packageCount.add(md.packages().size());
@@ -147,16 +114,114 @@
         initTime.addElapsedTimeFrom(t0);
     }
 
-    private static ModuleHashes.HashSupplier hashSupplier(String hash) {
-        if (hash == null)
-            return null;
+    /*
+     * Returns an array of ModuleDescriptor of the given module names.
+     *
+     * This obtains ModuleDescriptors from SystemModules class that is generated
+     * from the jlink system-modules plugin.  ModuleDescriptors have already
+     * been validated at link time.
+     *
+     * If java.base is patched, or fastpath is disabled for troubleshooting
+     * purpose, it will fall back to find system modules via jrt file system.
+     */
+    private static ModuleDescriptor[] descriptors(String[] names) {
+        // fastpath is enabled by default.
+        // It can be disabled for troubleshooting purpose.
+        boolean disabled =
+            System.getProperty("jdk.system.module.finder.disabledFastPath") != null;
 
-        return new ModuleHashes.HashSupplier() {
+        // fast loading of ModuleDescriptor of system modules
+        if (isFastPathSupported() && !disabled)
+            return SystemModules.modules();
+
+        // if fast loading of ModuleDescriptors is disabled
+        // fallback to read module-info.class
+        ModuleDescriptor[] descriptors = new ModuleDescriptor[names.length];
+        for (int i = 0; i < names.length; i++) {
+            String mn = names[i];
+            ImageLocation loc = imageReader.findLocation(mn, "module-info.class");
+            descriptors[i] = ModuleDescriptor.read(imageReader.getResourceBuffer(loc));
+
+            // add the recorded hashes of tied modules
+            Hashes.add(descriptors[i]);
+        }
+        return descriptors;
+    }
+
+    private static boolean isFastPathSupported() {
+       return SystemModules.MODULE_NAMES.length > 0;
+    }
+
+    private static String[] moduleNames() {
+        if (isFastPathSupported())
+            // module names recorded at link time
+            return SystemModules.MODULE_NAMES;
+
+        // this happens when java.base is patched with java.base
+        // from an exploded image
+        return imageReader.getModuleNames();
+    }
+
+    private static ModuleReference toModuleReference(ModuleDescriptor md,
+                                                     HashSupplier hash)
+    {
+        String mn = md.name();
+        URI uri = URI.create("jrt:/" + mn);
+
+        Supplier<ModuleReader> readerSupplier = new Supplier<>() {
             @Override
-            public String generate(String algorithm) {
-                return hash;
+            public ModuleReader get() {
+                return new ImageModuleReader(mn, uri);
             }
         };
+
+        ModuleReference mref =
+            new ModuleReference(md, uri, readerSupplier, hash);
+
+        // may need a reference to a patched module if -Xpatch specified
+        mref = ModulePatcher.interposeIfNeeded(mref);
+
+        return mref;
+    }
+
+    private static HashSupplier hashSupplier(int index, String name) {
+        if (isFastPathSupported()) {
+            return new HashSupplier() {
+                @Override
+                public String generate(String algorithm) {
+                    return SystemModules.MODULES_TO_HASH[index];
+                }
+            };
+        } else {
+            return Hashes.hashFor(name);
+        }
+    }
+
+    /*
+     * This helper class is only used when SystemModules is patched.
+     * It will get the recorded hashes from module-info.class.
+     */
+    private static class Hashes {
+        static Map<String, String> hashes = new HashMap<>();
+
+        static void add(ModuleDescriptor descriptor) {
+            Optional<ModuleHashes> ohashes = descriptor.hashes();
+            if (ohashes.isPresent()) {
+                hashes.putAll(ohashes.get().hashes());
+            }
+        }
+
+        static HashSupplier hashFor(String name) {
+            if (!hashes.containsKey(name))
+                return null;
+
+            return new HashSupplier() {
+                @Override
+                public String generate(String algorithm) {
+                    return hashes.get(name);
+                }
+            };
+        }
     }
 
     SystemModuleFinder() { }
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java b/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java
index 0ca75a8..34dae52 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java
@@ -77,7 +77,7 @@
  * #boot() boot} layer, that is created when the Java virtual machine is
  * started. The <em>system modules</em>, including {@code java.base}, are in
  * the boot layer. The modules in the boot layer are mapped to the bootstrap
- * class loader and other class loaders that are built-in into the ava virtual
+ * class loader and other class loaders that are built-in into the Java virtual
  * machine. The boot layer will often be the {@link #parent() parent} when
  * creating additional layers. </p>
  *
@@ -105,7 +105,7 @@
  *     Layer parent = Layer.boot();
  *
  *     Configuration cf = parent.configuration()
- *         .resolveRequires(finder, ModuleFinder.empty(), Set.of("myapp"));
+ *         .resolveRequires(finder, ModuleFinder.of(), Set.of("myapp"));
  *
  *     ClassLoader scl = ClassLoader.getSystemClassLoader();
  *
diff --git a/jdk/src/java.base/share/classes/java/math/BigDecimal.java b/jdk/src/java.base/share/classes/java/math/BigDecimal.java
index 557c5cc..dce4300 100644
--- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java
+++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java
@@ -128,6 +128,7 @@
  * <tr><td>Subtract</td><td>max(minuend.scale(), subtrahend.scale())</td>
  * <tr><td>Multiply</td><td>multiplier.scale() + multiplicand.scale()</td>
  * <tr><td>Divide</td><td>dividend.scale() - divisor.scale()</td>
+ * <tr><td>Square root</td><td>radicand.scale()/2</td>
  * </table>
  *
  * These scales are the ones used by the methods which return exact
@@ -346,6 +347,16 @@
     public static final BigDecimal TEN =
         ZERO_THROUGH_TEN[10];
 
+    /**
+     * The value 0.1, with a scale of 1.
+     */
+    private static final BigDecimal ONE_TENTH = valueOf(1L, 1);
+
+    /**
+     * The value 0.5, with a scale of 1.
+     */
+    private static final BigDecimal ONE_HALF = valueOf(5L, 1);
+
     // Constructors
 
     /**
@@ -1996,6 +2007,295 @@
     }
 
     /**
+     * Returns an approximation to the square root of {@code this}
+     * with rounding according to the context settings.
+     *
+     * <p>The preferred scale of the returned result is equal to
+     * {@code this.scale()/2}. The value of the returned result is
+     * always within one ulp of the exact decimal value for the
+     * precision in question.  If the rounding mode is {@link
+     * RoundingMode#HALF_UP HALF_UP}, {@link RoundingMode#HALF_DOWN
+     * HALF_DOWN}, or {@link RoundingMode#HALF_EVEN HALF_EVEN}, the
+     * result is within one half an ulp of the exact decimal value.
+     *
+     * <p>Special case:
+     * <ul>
+     * <li> The square root of a number numerically equal to {@code
+     * ZERO} is numerically equal to {@code ZERO} with a preferred
+     * scale according to the general rule above. In particular, for
+     * {@code ZERO}}, {@code ZERO.sqrt(mc).equals(ZERO)} is true with
+     * any {@code MathContext} as an argument.
+     * </ul>
+     *
+     * @param mc the context to use.
+     * @return the square root of {@code this}.
+     * @throws ArithmeticException if {@code this} is less than zero.
+     * @throws ArithmeticException if an exact result is requested
+     * ({@code mc.getPrecision()==0}) and there is no finite decimal
+     * expansion of the exact result
+     * @throws ArithmeticException if
+     * {@code (mc.getRoundingMode()==RoundingMode.UNNECESSARY}) and
+     * the exact result cannot fit in {@code mc.getPrecision()}
+     * digits.
+     * @since  9
+     */
+    public BigDecimal sqrt(MathContext mc) {
+        int signum = signum();
+        if (signum == 1) {
+            /*
+             * The following code draws on the algorithm presented in
+             * "Properly Rounded Variable Precision Square Root," Hull and
+             * Abrham, ACM Transactions on Mathematical Software, Vol 11,
+             * No. 3, September 1985, Pages 229-237.
+             *
+             * The BigDecimal computational model differs from the one
+             * presented in the paper in several ways: first BigDecimal
+             * numbers aren't necessarily normalized, second many more
+             * rounding modes are supported, including UNNECESSARY, and
+             * exact results can be requested.
+             *
+             * The main steps of the algorithm below are as follows,
+             * first argument reduce the value to the numerical range
+             * [1, 10) using the following relations:
+             *
+             * x = y * 10 ^ exp
+             * sqrt(x) = sqrt(y) * 10^(exp / 2) if exp is even
+             * sqrt(x) = sqrt(y/10) * 10 ^((exp+1)/2) is exp is odd
+             *
+             * Then use Newton's iteration on the reduced value to compute
+             * the numerical digits of the desired result.
+             *
+             * Finally, scale back to the desired exponent range and
+             * perform any adjustment to get the preferred scale in the
+             * representation.
+             */
+
+            // The code below favors relative simplicity over checking
+            // for special cases that could run faster.
+
+            int preferredScale = this.scale()/2;
+            BigDecimal zeroWithFinalPreferredScale = valueOf(0L, preferredScale);
+
+            // First phase of numerical normalization, strip trailing
+            // zeros and check for even powers of 10.
+            BigDecimal stripped = this.stripTrailingZeros();
+            int strippedScale = stripped.scale();
+
+            // Numerically sqrt(10^2N) = 10^N
+            if (stripped.isPowerOfTen() &&
+                strippedScale % 2 == 0) {
+                BigDecimal result = valueOf(1L, strippedScale/2);
+                if (result.scale() != preferredScale) {
+                    // Adjust to requested precision and preferred
+                    // scale as appropriate.
+                    result = result.add(zeroWithFinalPreferredScale, mc);
+                }
+                return result;
+            }
+
+            // After stripTrailingZeros, the representation is normalized as
+            //
+            // unscaledValue * 10^(-scale)
+            //
+            // where unscaledValue is an integer with the mimimum
+            // precision for the cohort of the numerical value. To
+            // allow binary floating-point hardware to be used to get
+            // approximately a 15 digit approximation to the square
+            // root, it is helpful to instead normalize this so that
+            // the significand portion is to right of the decimal
+            // point by roughly (scale() - precision() +1).
+
+            // Now the precision / scale adjustment
+            int scaleAdjust = 0;
+            int scale = stripped.scale() - stripped.precision() + 1;
+            if (scale % 2 == 0) {
+                scaleAdjust = scale;
+            } else {
+                scaleAdjust = scale - 1;
+            }
+
+            BigDecimal working = stripped.scaleByPowerOfTen(scaleAdjust);
+
+            assert  // Verify 0.1 <= working < 10
+                ONE_TENTH.compareTo(working) <= 0 && working.compareTo(TEN) < 0;
+
+            // Use good ole' Math.sqrt to get the initial guess for
+            // the Newton iteration, good to at least 15 decimal
+            // digits. This approach does incur the cost of a
+            //
+            // BigDecimal -> double -> BigDecimal
+            //
+            // conversion cycle, but it avoids the need for several
+            // Newton iterations in BigDecimal arithmetic to get the
+            // working answer to 15 digits of precision. If many fewer
+            // than 15 digits were needed, it might be faster to do
+            // the loop entirely in BigDecimal arithmetic.
+            //
+            // (A double value might have as much many as 17 decimal
+            // digits of precision; it depends on the relative density
+            // of binary and decimal numbers at different regions of
+            // the number line.)
+            //
+            // (It would be possible to check for certain special
+            // cases to avoid doing any Newton iterations. For
+            // example, if the BigDecimal -> double conversion was
+            // known to be exact and the rounding mode had a
+            // low-enough precision, the post-Newton rounding logic
+            // could be applied directly.)
+
+            BigDecimal guess = new BigDecimal(Math.sqrt(working.doubleValue()));
+            int guessPrecision = 15;
+            int originalPrecision = mc.getPrecision();
+            int targetPrecision;
+
+            // If an exact value is requested, it must only need about
+            // half of the input digits to represent since multiplying
+            // an N digit number by itself yield a 2N-1 digit or 2N
+            // digit result.
+            if (originalPrecision == 0) {
+                targetPrecision = stripped.precision()/2 + 1;
+            } else {
+                targetPrecision = originalPrecision;
+            }
+
+            // When setting the precision to use inside the Newton
+            // iteration loop, take care to avoid the case where the
+            // precision of the input exceeds the requested precision
+            // and rounding the input value too soon.
+            BigDecimal approx = guess;
+            int workingPrecision = working.precision();
+            do {
+                int tmpPrecision = Math.max(Math.max(guessPrecision, targetPrecision + 2),
+                                           workingPrecision);
+                MathContext mcTmp = new MathContext(tmpPrecision, RoundingMode.HALF_EVEN);
+                // approx = 0.5 * (approx + fraction / approx)
+                approx = ONE_HALF.multiply(approx.add(working.divide(approx, mcTmp), mcTmp));
+                guessPrecision *= 2;
+            } while (guessPrecision < targetPrecision + 2);
+
+            BigDecimal result;
+            RoundingMode targetRm = mc.getRoundingMode();
+            if (targetRm == RoundingMode.UNNECESSARY || originalPrecision == 0) {
+                RoundingMode tmpRm =
+                    (targetRm == RoundingMode.UNNECESSARY) ? RoundingMode.DOWN : targetRm;
+                MathContext mcTmp = new MathContext(targetPrecision, tmpRm);
+                result = approx.scaleByPowerOfTen(-scaleAdjust/2).round(mcTmp);
+
+                // If result*result != this numerically, the square
+                // root isn't exact
+                if (this.subtract(result.multiply(result)).compareTo(ZERO) != 0) {
+                    throw new ArithmeticException("Computed square root not exact.");
+                }
+            } else {
+                result = approx.scaleByPowerOfTen(-scaleAdjust/2).round(mc);
+            }
+
+            if (result.scale() != preferredScale) {
+                // The preferred scale of an add is
+                // max(addend.scale(), augend.scale()). Therefore, if
+                // the scale of the result is first minimized using
+                // stripTrailingZeros(), adding a zero of the
+                // preferred scale rounding the correct precision will
+                // perform the proper scale vs precision tradeoffs.
+                result = result.stripTrailingZeros().
+                    add(zeroWithFinalPreferredScale,
+                        new MathContext(originalPrecision, RoundingMode.UNNECESSARY));
+            }
+            assert squareRootResultAssertions(result, mc);
+            return result;
+        } else {
+            switch (signum) {
+            case -1:
+                throw new ArithmeticException("Attempted square root " +
+                                              "of negative BigDecimal");
+            case 0:
+                return valueOf(0L, scale()/2);
+
+            default:
+                throw new AssertionError("Bad value from signum");
+            }
+        }
+    }
+
+    private boolean isPowerOfTen() {
+        return BigInteger.ONE.equals(this.unscaledValue());
+    }
+
+    /**
+     * For nonzero values, check numerical correctness properties of
+     * the computed result for the chosen rounding mode.
+     *
+     * For the directed roundings, for DOWN and FLOOR, result^2 must
+     * be {@code <=} the input and (result+ulp)^2 must be {@code >} the
+     * input. Conversely, for UP and CEIL, result^2 must be {@code >=} the
+     * input and (result-ulp)^2 must be {@code <} the input.
+     */
+    private boolean squareRootResultAssertions(BigDecimal result, MathContext mc) {
+        if (result.signum() == 0) {
+            return squareRootZeroResultAssertions(result, mc);
+        } else {
+            RoundingMode rm = mc.getRoundingMode();
+            BigDecimal ulp = result.ulp();
+            BigDecimal neighborUp   = result.add(ulp);
+            // Make neighbor down accurate even for powers of ten
+            if (this.isPowerOfTen()) {
+                ulp = ulp.divide(TEN);
+            }
+            BigDecimal neighborDown = result.subtract(ulp);
+
+            // Both the starting value and result should be nonzero and positive.
+            if (result.signum() != 1 ||
+                this.signum() != 1) {
+                return false;
+            }
+
+            switch (rm) {
+            case DOWN:
+            case FLOOR:
+                return
+                    result.multiply(result).compareTo(this)         <= 0 &&
+                    neighborUp.multiply(neighborUp).compareTo(this) > 0;
+
+            case UP:
+            case CEILING:
+                return
+                    result.multiply(result).compareTo(this)             >= 0 &&
+                    neighborDown.multiply(neighborDown).compareTo(this) < 0;
+
+            case HALF_DOWN:
+            case HALF_EVEN:
+            case HALF_UP:
+                BigDecimal err = result.multiply(result).subtract(this).abs();
+                BigDecimal errUp = neighborUp.multiply(neighborUp).subtract(this);
+                BigDecimal errDown =  this.subtract(neighborDown.multiply(neighborDown));
+                // All error values should be positive so don't need to
+                // compare absolute values.
+
+                int err_comp_errUp = err.compareTo(errUp);
+                int err_comp_errDown = err.compareTo(errDown);
+
+                return
+                    errUp.signum()   == 1 &&
+                    errDown.signum() == 1 &&
+
+                    err_comp_errUp   <= 0 &&
+                    err_comp_errDown <= 0 &&
+
+                    ((err_comp_errUp   == 0 ) ? err_comp_errDown < 0 : true) &&
+                    ((err_comp_errDown == 0 ) ? err_comp_errUp   < 0 : true);
+                // && could check for digit conditions for ties too
+
+            default: // Definition of UNNECESSARY already verified.
+                return true;
+            }
+        }
+    }
+
+    private boolean squareRootZeroResultAssertions(BigDecimal result, MathContext mc) {
+        return this.compareTo(ZERO) == 0;
+    }
+
+    /**
      * Returns a {@code BigDecimal} whose value is
      * <code>(this<sup>n</sup>)</code>, The power is computed exactly, to
      * unlimited precision.
diff --git a/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java b/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
index a295d86..4945713 100644
--- a/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
+++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
@@ -87,27 +87,22 @@
         return isReusePortAvailable;
     }
 
-    private static volatile Set<SocketOption<?>> socketOptions;
-
     /**
-     * Returns a set of SocketOptions supported by this impl
-     * and by this impl's socket (Socket or ServerSocket)
+     * Returns a set of SocketOptions supported by this impl and by this impl's
+     * socket (Socket or ServerSocket)
      *
      * @return a Set of SocketOptions
      */
     @Override
     protected Set<SocketOption<?>> supportedOptions() {
-        Set<SocketOption<?>> options = socketOptions;
-        if (options == null) {
-            if (isReusePortAvailable()) {
-                options = new HashSet<>();
-                options.addAll(super.supportedOptions());
-                options.add(StandardSocketOptions.SO_REUSEPORT);
-                options = Collections.unmodifiableSet(options);
-            } else {
-                options = super.supportedOptions();
-            }
-            socketOptions = options;
+        Set<SocketOption<?>> options;
+        if (isReusePortAvailable()) {
+            options = new HashSet<>();
+            options.addAll(super.supportedOptions());
+            options.add(StandardSocketOptions.SO_REUSEPORT);
+            options = Collections.unmodifiableSet(options);
+        } else {
+            options = super.supportedOptions();
         }
         return options;
     }
diff --git a/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java b/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java
index c9afa26..465ec01 100644
--- a/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java
+++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java
@@ -104,27 +104,22 @@
         return isReusePortAvailable;
     }
 
-    private static volatile Set<SocketOption<?>> socketOptions;
-
-   /**
-    * Returns a set of SocketOptions supported by this impl
-    * and by this impl's socket (Socket or ServerSocket)
-    *
-    * @return a Set of SocketOptions
-    */
+    /**
+     * Returns a set of SocketOptions supported by this impl and by this impl's
+     * socket (Socket or ServerSocket)
+     *
+     * @return a Set of SocketOptions
+     */
     @Override
     protected Set<SocketOption<?>> supportedOptions() {
-        Set<SocketOption<?>> options = socketOptions;
-        if (options == null) {
-            if (isReusePortAvailable()) {
-                options = new HashSet<>();
-                options.addAll(super.supportedOptions());
-                options.add(StandardSocketOptions.SO_REUSEPORT);
-                options = Collections.unmodifiableSet(options);
-            } else {
-                options = super.supportedOptions();
-            }
-            socketOptions = options;
+        Set<SocketOption<?>> options;
+        if (isReusePortAvailable()) {
+            options = new HashSet<>();
+            options.addAll(super.supportedOptions());
+            options.add(StandardSocketOptions.SO_REUSEPORT);
+            options = Collections.unmodifiableSet(options);
+        } else {
+            options = super.supportedOptions();
         }
         return options;
     }
diff --git a/jdk/src/java.base/share/classes/java/net/MulticastSocket.java b/jdk/src/java.base/share/classes/java/net/MulticastSocket.java
index 365092b..9c9e4b8 100644
--- a/jdk/src/java.base/share/classes/java/net/MulticastSocket.java
+++ b/jdk/src/java.base/share/classes/java/net/MulticastSocket.java
@@ -26,7 +26,9 @@
 package java.net;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.Set;
 
 /**
  * The multicast datagram socket class is useful for sending
@@ -716,4 +718,24 @@
                 } // synch p
             }  //synch ttl
     } //method
+
+    private static Set<SocketOption<?>> options;
+    private static boolean optionsSet = false;
+
+    @Override
+    public Set<SocketOption<?>> supportedOptions() {
+        synchronized (MulticastSocket.class) {
+            if (optionsSet) {
+                return options;
+            }
+            try {
+                DatagramSocketImpl impl = getImpl();
+                options = Collections.unmodifiableSet(impl.supportedOptions());
+            } catch (SocketException ex) {
+                options = Collections.emptySet();
+            }
+            optionsSet = true;
+            return options;
+        }
+    }
 }
diff --git a/jdk/src/java.base/share/classes/java/nio/Buffer.java b/jdk/src/java.base/share/classes/java/nio/Buffer.java
index d534fb3..1f6bef1 100644
--- a/jdk/src/java.base/share/classes/java/nio/Buffer.java
+++ b/jdk/src/java.base/share/classes/java/nio/Buffer.java
@@ -111,7 +111,7 @@
  * to zero.
  *
  *
- * <h2> Clearing, flipping, and rewinding </h2>
+ * <h2> Additional operations </h2>
  *
  * <p> In addition to methods for accessing the position, limit, and capacity
  * values and for marking and resetting, this class also defines the following
@@ -131,6 +131,12 @@
  *   it already contains: It leaves the limit unchanged and sets the position
  *   to zero.  </p></li>
  *
+ *   <li><p> {@link #slice} creates a subsequence of a buffer: It leaves the
+ *   limit and the position unchanged. </p></li>
+ *
+ *   <li><p> {@link #duplicate} creates a shallow copy of a buffer: It leaves
+ *   the limit and the position unchanged. </p></li>
+ *
  * </ul>
  *
  *
@@ -567,6 +573,46 @@
      */
     public abstract boolean isDirect();
 
+    /**
+     * Creates a new buffer whose content is a shared subsequence of
+     * this buffer's content.
+     *
+     * <p> The content of the new buffer will start at this buffer's current
+     * position.  Changes to this buffer's content will be visible in the new
+     * buffer, and vice versa; the two buffers' position, limit, and mark
+     * values will be independent.
+     *
+     * <p> The new buffer's position will be zero, its capacity and its limit
+     * will be the number of elements remaining in this buffer, its mark will be
+     * undefined. The new buffer will be direct if, and only if, this buffer is
+     * direct, and it will be read-only if, and only if, this buffer is
+     * read-only.  </p>
+     *
+     * @return  The new buffer
+     *
+     * @since 9
+     */
+    public abstract Buffer slice();
+
+    /**
+     * Creates a new buffer that shares this buffer's content.
+     *
+     * <p> The content of the new buffer will be that of this buffer.  Changes
+     * to this buffer's content will be visible in the new buffer, and vice
+     * versa; the two buffers' position, limit, and mark values will be
+     * independent.
+     *
+     * <p> The new buffer's capacity, limit, position and mark values will be
+     * identical to those of this buffer. The new buffer will be direct if, and
+     * only if, this buffer is direct, and it will be read-only if, and only if,
+     * this buffer is read-only.  </p>
+     *
+     * @return  The new buffer
+     *
+     * @since 9
+     */
+    public abstract Buffer duplicate();
+
 
     // -- Package-private methods for bounds checking, etc. --
 
diff --git a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template
index 104f504..1292ca4 100644
--- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template
+++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template
@@ -70,8 +70,7 @@
  *
 #end[byte]
  *
- *   <li><p> Methods for {@link #compact compacting}, {@link
- *   #duplicate duplicating}, and {@link #slice slicing}
+ *   <li><p> A method for {@link #compact compacting}
  *   $a$ $type$ buffer.  </p></li>
  *
  * </ul>
@@ -535,6 +534,7 @@
      * @see #alignedSlice(int)
 #end[byte]
      */
+    @Override
     public abstract $Type$Buffer slice();
 
     /**
@@ -557,6 +557,7 @@
      *
      * @return  The new $type$ buffer
      */
+    @Override
     public abstract $Type$Buffer duplicate();
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/security/DrbgParameters.java b/jdk/src/java.base/share/classes/java/security/DrbgParameters.java
index 50fa82e..ed62514 100644
--- a/jdk/src/java.base/share/classes/java/security/DrbgParameters.java
+++ b/jdk/src/java.base/share/classes/java/security/DrbgParameters.java
@@ -216,10 +216,9 @@
  * <p>
  * If a DRBG is not instantiated with a {@link DrbgParameters.Instantiation}
  * object explicitly, this implementation instantiates it with a default
- * requested strength of 128 bits (112 bits for CTR_DRBG with 3KeyTDEA),
- * no prediction resistance request, and no personalization string.
- * These default instantiation parameters can also be customized with
- * the {@code securerandom.drbg.config} security property.
+ * requested strength of 128 bits, no prediction resistance request, and
+ * no personalization string. These default instantiation parameters can also
+ * be customized with the {@code securerandom.drbg.config} security property.
  * <p>
  * This implementation reads fresh entropy from the system default entropy
  * source determined by the security property {@code securerandom.source}.
diff --git a/jdk/src/java.base/share/classes/java/security/Provider.java b/jdk/src/java.base/share/classes/java/security/Provider.java
index 9ecc8ff..de09dc4 100644
--- a/jdk/src/java.base/share/classes/java/security/Provider.java
+++ b/jdk/src/java.base/share/classes/java/security/Provider.java
@@ -569,7 +569,8 @@
      * @since 1.8
      */
     @Override
-    public synchronized void replaceAll(BiFunction<? super Object, ? super Object, ? extends Object> function) {
+    public synchronized void replaceAll(BiFunction<? super Object,
+            ? super Object, ? extends Object> function) {
         check("putProviderProperty." + name);
 
         if (debug != null) {
@@ -597,8 +598,8 @@
      * @since 1.8
      */
     @Override
-    public synchronized Object compute(Object key,
-        BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction) {
+    public synchronized Object compute(Object key, BiFunction<? super Object,
+            ? super Object, ? extends Object> remappingFunction) {
         check("putProviderProperty." + name);
         check("removeProviderProperty" + name);
 
@@ -628,7 +629,8 @@
      * @since 1.8
      */
     @Override
-    public synchronized Object computeIfAbsent(Object key, Function<? super Object, ? extends Object> mappingFunction) {
+    public synchronized Object computeIfAbsent(Object key, Function<? super Object,
+            ? extends Object> mappingFunction) {
         check("putProviderProperty." + name);
         check("removeProviderProperty" + name);
 
@@ -657,7 +659,8 @@
      * @since 1.8
      */
     @Override
-    public synchronized Object computeIfPresent(Object key, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction) {
+    public synchronized Object computeIfPresent(Object key, BiFunction<? super Object,
+            ? super Object, ? extends Object> remappingFunction) {
         check("putProviderProperty." + name);
         check("removeProviderProperty" + name);
 
@@ -689,7 +692,8 @@
      * @since 1.8
      */
     @Override
-    public synchronized Object merge(Object key, Object value,  BiFunction<? super Object, ? super Object, ? extends Object>  remappingFunction) {
+    public synchronized Object merge(Object key, Object value,  BiFunction<? super Object,
+            ? super Object, ? extends Object>  remappingFunction) {
         check("putProviderProperty." + name);
         check("removeProviderProperty" + name);
 
@@ -868,18 +872,21 @@
     }
 
     @SuppressWarnings("unchecked") // Function must actually operate over strings
-    private void implReplaceAll(BiFunction<? super Object, ? super Object, ? extends Object> function) {
+    private void implReplaceAll(BiFunction<? super Object, ? super Object,
+            ? extends Object> function) {
         legacyChanged = true;
         if (legacyStrings == null) {
             legacyStrings = new LinkedHashMap<>();
         } else {
-            legacyStrings.replaceAll((BiFunction<? super String, ? super String, ? extends String>) function);
+            legacyStrings.replaceAll((BiFunction<? super String, ? super String,
+                    ? extends String>) function);
         }
         super.replaceAll(function);
     }
 
     @SuppressWarnings("unchecked") // Function must actually operate over strings
-    private Object implMerge(Object key, Object value, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction) {
+    private Object implMerge(Object key, Object value, BiFunction<? super Object,
+            ? super Object, ? extends Object> remappingFunction) {
         if ((key instanceof String) && (value instanceof String)) {
             if (!checkLegacy(key)) {
                 return null;
@@ -891,7 +898,8 @@
     }
 
     @SuppressWarnings("unchecked") // Function must actually operate over strings
-    private Object implCompute(Object key, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction) {
+    private Object implCompute(Object key, BiFunction<? super Object,
+            ? super Object, ? extends Object> remappingFunction) {
         if (key instanceof String) {
             if (!checkLegacy(key)) {
                 return null;
@@ -903,7 +911,8 @@
     }
 
     @SuppressWarnings("unchecked") // Function must actually operate over strings
-    private Object implComputeIfAbsent(Object key, Function<? super Object, ? extends Object> mappingFunction) {
+    private Object implComputeIfAbsent(Object key, Function<? super Object,
+            ? extends Object> mappingFunction) {
         if (key instanceof String) {
             if (!checkLegacy(key)) {
                 return null;
@@ -915,7 +924,8 @@
     }
 
     @SuppressWarnings("unchecked") // Function must actually operate over strings
-    private Object implComputeIfPresent(Object key, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction) {
+    private Object implComputeIfPresent(Object key, BiFunction<? super Object,
+            ? super Object, ? extends Object> remappingFunction) {
         if (key instanceof String) {
             if (!checkLegacy(key)) {
                 return null;
diff --git a/jdk/src/java.base/share/classes/java/time/Instant.java b/jdk/src/java.base/share/classes/java/time/Instant.java
index 84056b7..7f526e6 100644
--- a/jdk/src/java.base/share/classes/java/time/Instant.java
+++ b/jdk/src/java.base/share/classes/java/time/Instant.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -342,7 +342,7 @@
      */
     public static Instant ofEpochMilli(long epochMilli) {
         long secs = Math.floorDiv(epochMilli, 1000);
-        int mos = (int)Math.floorMod(epochMilli, 1000);
+        int mos = Math.floorMod(epochMilli, 1000);
         return create(secs, mos * 1000_000);
     }
 
diff --git a/jdk/src/java.base/share/classes/java/time/LocalDate.java b/jdk/src/java.base/share/classes/java/time/LocalDate.java
index 940f21f..62db987 100644
--- a/jdk/src/java.base/share/classes/java/time/LocalDate.java
+++ b/jdk/src/java.base/share/classes/java/time/LocalDate.java
@@ -826,7 +826,7 @@
      * @return the day-of-week, not null
      */
     public DayOfWeek getDayOfWeek() {
-        int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7);
+        int dow0 = Math.floorMod(toEpochDay() + 3, 7);
         return DayOfWeek.of(dow0 + 1);
     }
 
@@ -1329,7 +1329,7 @@
         long monthCount = year * 12L + (month - 1);
         long calcMonths = monthCount + monthsToAdd;  // safe overflow
         int newYear = YEAR.checkValidIntValue(Math.floorDiv(calcMonths, 12));
-        int newMonth = (int)Math.floorMod(calcMonths, 12) + 1;
+        int newMonth = Math.floorMod(calcMonths, 12) + 1;
         return resolvePreviousValid(newYear, newMonth, day);
     }
 
diff --git a/jdk/src/java.base/share/classes/java/time/LocalDateTime.java b/jdk/src/java.base/share/classes/java/time/LocalDateTime.java
index 2195cae..0366333 100644
--- a/jdk/src/java.base/share/classes/java/time/LocalDateTime.java
+++ b/jdk/src/java.base/share/classes/java/time/LocalDateTime.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -418,7 +418,7 @@
         NANO_OF_SECOND.checkValidValue(nanoOfSecond);
         long localSecond = epochSecond + offset.getTotalSeconds();  // overflow caught later
         long localEpochDay = Math.floorDiv(localSecond, SECONDS_PER_DAY);
-        int secsOfDay = (int)Math.floorMod(localSecond, SECONDS_PER_DAY);
+        int secsOfDay = Math.floorMod(localSecond, SECONDS_PER_DAY);
         LocalDate date = LocalDate.ofEpochDay(localEpochDay);
         LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + nanoOfSecond);
         return new LocalDateTime(date, time);
diff --git a/jdk/src/java.base/share/classes/java/time/LocalTime.java b/jdk/src/java.base/share/classes/java/time/LocalTime.java
index b951c87..4b0456a 100644
--- a/jdk/src/java.base/share/classes/java/time/LocalTime.java
+++ b/jdk/src/java.base/share/classes/java/time/LocalTime.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -361,7 +361,7 @@
          Objects.requireNonNull(zone, "zone");
          ZoneOffset offset = zone.getRules().getOffset(instant);
          long localSecond = instant.getEpochSecond() + offset.getTotalSeconds();
-         int secsOfDay = (int) Math.floorMod(localSecond, SECONDS_PER_DAY);
+         int secsOfDay = Math.floorMod(localSecond, SECONDS_PER_DAY);
          return ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + instant.getNano());
      }
 
diff --git a/jdk/src/java.base/share/classes/java/time/OffsetTime.java b/jdk/src/java.base/share/classes/java/time/OffsetTime.java
index cbfeb19..65cf560 100644
--- a/jdk/src/java.base/share/classes/java/time/OffsetTime.java
+++ b/jdk/src/java.base/share/classes/java/time/OffsetTime.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -258,7 +258,7 @@
         ZoneRules rules = zone.getRules();
         ZoneOffset offset = rules.getOffset(instant);
         long localSecond = instant.getEpochSecond() + offset.getTotalSeconds();  // overflow caught later
-        int secsOfDay = (int) Math.floorMod(localSecond, SECONDS_PER_DAY);
+        int secsOfDay = Math.floorMod(localSecond, SECONDS_PER_DAY);
         LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + instant.getNano());
         return new OffsetTime(time, offset);
     }
diff --git a/jdk/src/java.base/share/classes/java/time/YearMonth.java b/jdk/src/java.base/share/classes/java/time/YearMonth.java
index 2fbd95b..31c6a5a 100644
--- a/jdk/src/java.base/share/classes/java/time/YearMonth.java
+++ b/jdk/src/java.base/share/classes/java/time/YearMonth.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -850,7 +850,7 @@
         long monthCount = year * 12L + (month - 1);
         long calcMonths = monthCount + monthsToAdd;  // safe overflow
         int newYear = YEAR.checkValidIntValue(Math.floorDiv(calcMonths, 12));
-        int newMonth = (int)Math.floorMod(calcMonths, 12) + 1;
+        int newMonth = Math.floorMod(calcMonths, 12) + 1;
         return with(newYear, newMonth);
     }
 
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java b/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java
index 9d5059e..60d0529 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -497,7 +497,7 @@
      * @return the day-of-week; computed from the epochday
      */
     private int getDayOfWeek() {
-        int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7);
+        int dow0 = Math.floorMod(toEpochDay() + 3, 7);
         return dow0 + 1;
     }
 
diff --git a/jdk/src/java.base/share/classes/java/util/Currency.java b/jdk/src/java.base/share/classes/java/util/Currency.java
index cea4cdc..6c9bbb6 100644
--- a/jdk/src/java.base/share/classes/java/util/Currency.java
+++ b/jdk/src/java.base/share/classes/java/util/Currency.java
@@ -153,33 +153,13 @@
     //   - bits 0-4: final char for currency code for simple country, or ID of special case
     // - special case IDs:
     //   - 0: country has no currency
-    //   - other: index into sc* arrays + 1
-    // - scCutOverTimes: cut-over time in millis as returned by
-    //   System.currentTimeMillis for special case countries that are changing
-    //   currencies; Long.MAX_VALUE for countries that are not changing currencies
-    // - scOldCurrencies: old currencies for special case countries
-    // - scNewCurrencies: new currencies for special case countries that are
-    //   changing currencies; null for others
-    // - scOldCurrenciesDFD: default fraction digits for old currencies
-    // - scNewCurrenciesDFD: default fraction digits for new currencies, 0 for
-    //   countries that are not changing currencies
-    // - otherCurrencies: concatenation of all currency codes that are not the
-    //   main currency of a simple country, separated by "-"
-    // - otherCurrenciesDFD: decimal format digits for currencies in otherCurrencies, same order
+    //   - other: index into specialCasesList
 
     static int formatVersion;
     static int dataVersion;
     static int[] mainTable;
-    static long[] scCutOverTimes;
-    static String[] scOldCurrencies;
-    static String[] scNewCurrencies;
-    static int[] scOldCurrenciesDFD;
-    static int[] scNewCurrenciesDFD;
-    static int[] scOldCurrenciesNumericCode;
-    static int[] scNewCurrenciesNumericCode;
-    static String otherCurrencies;
-    static int[] otherCurrenciesDFD;
-    static int[] otherCurrenciesNumericCode;
+    static List<SpecialCaseEntry> specialCasesList;
+    static List<OtherCurrencyEntry> otherCurrenciesList;
 
     // handy constants - must match definitions in GenerateCurrencyData
     // magic number
@@ -214,7 +194,7 @@
     private static final int NUMERIC_CODE_SHIFT = 10;
 
     // Currency data format version
-    private static final int VALID_FORMAT_VERSION = 2;
+    private static final int VALID_FORMAT_VERSION = 3;
 
     static {
         AccessController.doPrivileged(new PrivilegedAction<>() {
@@ -236,17 +216,9 @@
                         dataVersion = dis.readInt();
                         mainTable = readIntArray(dis, A_TO_Z * A_TO_Z);
                         int scCount = dis.readInt();
-                        scCutOverTimes = readLongArray(dis, scCount);
-                        scOldCurrencies = readStringArray(dis, scCount);
-                        scNewCurrencies = readStringArray(dis, scCount);
-                        scOldCurrenciesDFD = readIntArray(dis, scCount);
-                        scNewCurrenciesDFD = readIntArray(dis, scCount);
-                        scOldCurrenciesNumericCode = readIntArray(dis, scCount);
-                        scNewCurrenciesNumericCode = readIntArray(dis, scCount);
+                        specialCasesList = readSpecialCases(dis, scCount);
                         int ocCount = dis.readInt();
-                        otherCurrencies = dis.readUTF();
-                        otherCurrenciesDFD = readIntArray(dis, ocCount);
-                        otherCurrenciesNumericCode = readIntArray(dis, ocCount);
+                        otherCurrenciesList = readOtherCurrencies(dis, ocCount);
                     }
                 } catch (IOException e) {
                     throw new InternalError(e);
@@ -329,6 +301,7 @@
             // Currency code not internally generated, need to verify first
             // A currency code must have 3 characters and exist in the main table
             // or in the list of other currencies.
+            boolean found = false;
             if (currencyCode.length() != 3) {
                 throw new IllegalArgumentException();
             }
@@ -340,17 +313,23 @@
                     && currencyCode.charAt(2) - 'A' == (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK)) {
                 defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT;
                 numericCode = (tableEntry & NUMERIC_CODE_MASK) >> NUMERIC_CODE_SHIFT;
-            } else {
-                // Check for '-' separately so we don't get false hits in the table.
-                if (currencyCode.charAt(2) == '-') {
+                found = true;
+            } else { //special case
+                int[] fractionAndNumericCode = SpecialCaseEntry.findEntry(currencyCode);
+                if (fractionAndNumericCode != null) {
+                    defaultFractionDigits = fractionAndNumericCode[0];
+                    numericCode = fractionAndNumericCode[1];
+                    found = true;
+                }
+            }
+
+            if (!found) {
+                OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(currencyCode);
+                if (ocEntry == null) {
                     throw new IllegalArgumentException();
                 }
-                int index = otherCurrencies.indexOf(currencyCode);
-                if (index == -1) {
-                    throw new IllegalArgumentException();
-                }
-                defaultFractionDigits = otherCurrenciesDFD[index / 4];
-                numericCode = otherCurrenciesNumericCode[index / 4];
+                defaultFractionDigits = ocEntry.fraction;
+                numericCode = ocEntry.numericCode;
             }
         }
 
@@ -410,13 +389,17 @@
             if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) {
                 return null;
             } else {
-                int index = (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA;
-                if (scCutOverTimes[index] == Long.MAX_VALUE || System.currentTimeMillis() < scCutOverTimes[index]) {
-                    return getInstance(scOldCurrencies[index], scOldCurrenciesDFD[index],
-                        scOldCurrenciesNumericCode[index]);
+                int index = SpecialCaseEntry.toIndex(tableEntry);
+                SpecialCaseEntry scEntry = specialCasesList.get(index);
+                if (scEntry.cutOverTime == Long.MAX_VALUE
+                        || System.currentTimeMillis() < scEntry.cutOverTime) {
+                    return getInstance(scEntry.oldCurrency,
+                            scEntry.oldCurrencyFraction,
+                            scEntry.oldCurrencyNumericCode);
                 } else {
-                    return getInstance(scNewCurrencies[index], scNewCurrenciesDFD[index],
-                        scNewCurrenciesNumericCode[index]);
+                    return getInstance(scEntry.newCurrency,
+                            scEntry.newCurrencyFraction,
+                            scEntry.newCurrencyNumericCode);
                 }
             }
         }
@@ -451,14 +434,29 @@
                             sb.append(c2);
                             sb.append(finalChar);
                             available.add(getInstance(sb.toString(), defaultFractionDigits, numericCode));
+                        } else if ((tableEntry & COUNTRY_TYPE_MASK) == SPECIAL_CASE_COUNTRY_MASK
+                                && tableEntry != INVALID_COUNTRY_ENTRY
+                                && tableEntry != COUNTRY_WITHOUT_CURRENCY_ENTRY) {
+                            int index = SpecialCaseEntry.toIndex(tableEntry);
+                            SpecialCaseEntry scEntry = specialCasesList.get(index);
+
+                            if (scEntry.cutOverTime == Long.MAX_VALUE
+                                    || System.currentTimeMillis() < scEntry.cutOverTime) {
+                                available.add(getInstance(scEntry.oldCurrency,
+                                        scEntry.oldCurrencyFraction,
+                                        scEntry.oldCurrencyNumericCode));
+                            } else {
+                                available.add(getInstance(scEntry.newCurrency,
+                                        scEntry.newCurrencyFraction,
+                                        scEntry.newCurrencyNumericCode));
+                            }
                         }
                     }
                 }
 
                 // Now add other currencies
-                StringTokenizer st = new StringTokenizer(otherCurrencies, "-");
-                while (st.hasMoreElements()) {
-                    available.add(getInstance((String)st.nextElement()));
+                for (OtherCurrencyEntry entry : otherCurrenciesList) {
+                    available.add(getInstance(entry.currencyCode));
                 }
             }
         }
@@ -521,15 +519,15 @@
     }
 
     /**
-    * Gets the default number of fraction digits used with this currency.
-    * Note that the number of fraction digits is the same as ISO 4217's
-    * minor unit for the currency.
-    * For example, the default number of fraction digits for the Euro is 2,
-    * while for the Japanese Yen it's 0.
-    * In the case of pseudo-currencies, such as IMF Special Drawing Rights,
-    * -1 is returned.
-    *
-    * @return the default number of fraction digits used with this currency
+     * Gets the default number of fraction digits used with this currency.
+     * Note that the number of fraction digits is the same as ISO 4217's
+     * minor unit for the currency.
+     * For example, the default number of fraction digits for the Euro is 2,
+     * while for the Japanese Yen it's 0.
+     * In the case of pseudo-currencies, such as IMF Special Drawing Rights,
+     * -1 is returned.
+     *
+     * @return the default number of fraction digits used with this currency
     */
     public int getDefaultFractionDigits() {
         return defaultFractionDigits;
@@ -693,22 +691,55 @@
         return ret;
     }
 
-    private static long[] readLongArray(DataInputStream dis, int count) throws IOException {
-        long[] ret = new long[count];
-        for (int i = 0; i < count; i++) {
-            ret[i] = dis.readLong();
-        }
+    private static List<SpecialCaseEntry> readSpecialCases(DataInputStream dis,
+            int count)
+            throws IOException {
 
-        return ret;
+        List<SpecialCaseEntry> list = new ArrayList<>(count);
+        long cutOverTime;
+        String oldCurrency;
+        String newCurrency;
+        int oldCurrencyFraction;
+        int newCurrencyFraction;
+        int oldCurrencyNumericCode;
+        int newCurrencyNumericCode;
+
+        for (int i = 0; i < count; i++) {
+            cutOverTime = dis.readLong();
+            oldCurrency = dis.readUTF();
+            newCurrency = dis.readUTF();
+            oldCurrencyFraction = dis.readInt();
+            newCurrencyFraction = dis.readInt();
+            oldCurrencyNumericCode = dis.readInt();
+            newCurrencyNumericCode = dis.readInt();
+            SpecialCaseEntry sc = new SpecialCaseEntry(cutOverTime,
+                    oldCurrency, newCurrency,
+                    oldCurrencyFraction, newCurrencyFraction,
+                    oldCurrencyNumericCode, newCurrencyNumericCode);
+            list.add(sc);
+        }
+        return list;
     }
 
-    private static String[] readStringArray(DataInputStream dis, int count) throws IOException {
-        String[] ret = new String[count];
-        for (int i = 0; i < count; i++) {
-            ret[i] = dis.readUTF();
-        }
+    private static List<OtherCurrencyEntry> readOtherCurrencies(DataInputStream dis,
+            int count)
+            throws IOException {
 
-        return ret;
+        List<OtherCurrencyEntry> list = new ArrayList<>(count);
+        String currencyCode;
+        int fraction;
+        int numericCode;
+
+        for (int i = 0; i < count; i++) {
+            currencyCode = dis.readUTF();
+            fraction = dis.readInt();
+            numericCode = dis.readInt();
+            OtherCurrencyEntry oc = new OtherCurrencyEntry(currencyCode,
+                    fraction,
+                    numericCode);
+            list.add(oc);
+        }
+        return list;
     }
 
     /**
@@ -766,21 +797,27 @@
             return;
         }
 
-        int index;
-        for (index = 0; index < scOldCurrencies.length; index++) {
-            if (scOldCurrencies[index].equals(code)) {
-                break;
-            }
+        int index = SpecialCaseEntry.indexOf(code, fraction, numeric);
+
+        /* if a country switches from simple case to special case or
+         * one special case to other special case which is not present
+         * in the sc arrays then insert the new entry in special case arrays
+         */
+        if (index == -1 && (ctry.charAt(0) != code.charAt(0)
+                || ctry.charAt(1) != code.charAt(1))) {
+
+            specialCasesList.add(new SpecialCaseEntry(code, fraction, numeric));
+            index = specialCasesList.size() - 1;
         }
 
-        if (index == scOldCurrencies.length) {
+        if (index == -1) {
             // simple case
-            entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT) |
-                     (code.charAt(2) - 'A');
+            entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT)
+                    | (code.charAt(2) - 'A');
         } else {
             // special case
-            entry |= SPECIAL_CASE_COUNTRY_MASK |
-                     (index + SPECIAL_CASE_COUNTRY_INDEX_DELTA);
+            entry = SPECIAL_CASE_COUNTRY_MASK
+                    | (index + SPECIAL_CASE_COUNTRY_INDEX_DELTA);
         }
         setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry);
     }
@@ -814,5 +851,128 @@
             }
         }
     }
+
+    /* Used to represent a special case currency entry
+     * - cutOverTime: cut-over time in millis as returned by
+     *   System.currentTimeMillis for special case countries that are changing
+     *   currencies; Long.MAX_VALUE for countries that are not changing currencies
+     * - oldCurrency: old currencies for special case countries
+     * - newCurrency: new currencies for special case countries that are
+     *   changing currencies; null for others
+     * - oldCurrencyFraction: default fraction digits for old currencies
+     * - newCurrencyFraction: default fraction digits for new currencies, 0 for
+     *   countries that are not changing currencies
+     * - oldCurrencyNumericCode: numeric code for old currencies
+     * - newCurrencyNumericCode: numeric code for new currencies, 0 for countries
+     *   that are not changing currencies
+    */
+    private static class SpecialCaseEntry {
+
+        final private long cutOverTime;
+        final private String oldCurrency;
+        final private String newCurrency;
+        final private int oldCurrencyFraction;
+        final private int newCurrencyFraction;
+        final private int oldCurrencyNumericCode;
+        final private int newCurrencyNumericCode;
+
+        private SpecialCaseEntry(long cutOverTime, String oldCurrency, String newCurrency,
+                int oldCurrencyFraction, int newCurrencyFraction,
+                int oldCurrencyNumericCode, int newCurrencyNumericCode) {
+            this.cutOverTime = cutOverTime;
+            this.oldCurrency = oldCurrency;
+            this.newCurrency = newCurrency;
+            this.oldCurrencyFraction = oldCurrencyFraction;
+            this.newCurrencyFraction = newCurrencyFraction;
+            this.oldCurrencyNumericCode = oldCurrencyNumericCode;
+            this.newCurrencyNumericCode = newCurrencyNumericCode;
+        }
+
+        private SpecialCaseEntry(String currencyCode, int fraction,
+                int numericCode) {
+            this(Long.MAX_VALUE, currencyCode, "", fraction, 0, numericCode, 0);
+        }
+
+        //get the index of the special case entry
+        private static int indexOf(String code, int fraction, int numeric) {
+            int size = specialCasesList.size();
+            for (int index = 0; index < size; index++) {
+                SpecialCaseEntry scEntry = specialCasesList.get(index);
+                if (scEntry.oldCurrency.equals(code)
+                        && scEntry.oldCurrencyFraction == fraction
+                        && scEntry.oldCurrencyNumericCode == numeric
+                        && scEntry.cutOverTime == Long.MAX_VALUE) {
+                    return index;
+                }
+            }
+            return -1;
+        }
+
+        // get the fraction and numericCode of the sc currencycode
+        private static int[] findEntry(String code) {
+            int[] fractionAndNumericCode = null;
+            int size = specialCasesList.size();
+            for (int index = 0; index < size; index++) {
+                SpecialCaseEntry scEntry = specialCasesList.get(index);
+                if (scEntry.oldCurrency.equals(code) && (scEntry.cutOverTime == Long.MAX_VALUE
+                        || System.currentTimeMillis() < scEntry.cutOverTime)) {
+                    //consider only when there is no new currency or cutover time is not passed
+                    fractionAndNumericCode = new int[2];
+                    fractionAndNumericCode[0] = scEntry.oldCurrencyFraction;
+                    fractionAndNumericCode[1] = scEntry.oldCurrencyNumericCode;
+                    break;
+                } else if (scEntry.newCurrency.equals(code)
+                        && System.currentTimeMillis() >= scEntry.cutOverTime) {
+                    //consider only if the cutover time is passed
+                    fractionAndNumericCode = new int[2];
+                    fractionAndNumericCode[0] = scEntry.newCurrencyFraction;
+                    fractionAndNumericCode[1] = scEntry.newCurrencyNumericCode;
+                    break;
+                }
+            }
+            return fractionAndNumericCode;
+        }
+
+        // convert the special case entry to sc arrays index
+        private static int toIndex(int tableEntry) {
+            return (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA;
+        }
+
+    }
+
+    /* Used to represent Other currencies
+     * - currencyCode: currency codes that are not the main currency
+     *   of a simple country
+     * - otherCurrenciesDFD: decimal format digits for other currencies
+     * - otherCurrenciesNumericCode: numeric code for other currencies
+     */
+    private static class OtherCurrencyEntry {
+
+        final private String currencyCode;
+        final private int fraction;
+        final private int numericCode;
+
+        private OtherCurrencyEntry(String currencyCode, int fraction,
+                int numericCode) {
+            this.currencyCode = currencyCode;
+            this.fraction = fraction;
+            this.numericCode = numericCode;
+        }
+
+        //get the instance of the other currency code
+        private static OtherCurrencyEntry findEntry(String code) {
+            int size = otherCurrenciesList.size();
+            for (int index = 0; index < size; index++) {
+                OtherCurrencyEntry ocEntry = otherCurrenciesList.get(index);
+                if (ocEntry.currencyCode.equalsIgnoreCase(code)) {
+                    return ocEntry;
+                }
+            }
+            return null;
+        }
+
+    }
+
 }
 
+
diff --git a/jdk/src/java.base/share/classes/java/util/Hashtable.java b/jdk/src/java.base/share/classes/java/util/Hashtable.java
index 6ad2f3a..b541ca1 100644
--- a/jdk/src/java.base/share/classes/java/util/Hashtable.java
+++ b/jdk/src/java.base/share/classes/java/util/Hashtable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -230,6 +230,14 @@
     }
 
     /**
+     * A constructor chained from {@link Properties} keeps Hashtable fields
+     * uninitialized since they are not used.
+     *
+     * @param dummy a dummy parameter
+     */
+    Hashtable(Void dummy) {}
+
+    /**
      * Returns the number of keys in this hashtable.
      *
      * @return  the number of keys in this hashtable.
@@ -549,18 +557,23 @@
      * @return  a clone of the hashtable
      */
     public synchronized Object clone() {
+        Hashtable<?,?> t = cloneHashtable();
+        t.table = new Entry<?,?>[table.length];
+        for (int i = table.length ; i-- > 0 ; ) {
+            t.table[i] = (table[i] != null)
+                ? (Entry<?,?>) table[i].clone() : null;
+        }
+        t.keySet = null;
+        t.entrySet = null;
+        t.values = null;
+        t.modCount = 0;
+        return t;
+    }
+
+    /** Calls super.clone() */
+    final Hashtable<?,?> cloneHashtable() {
         try {
-            Hashtable<?,?> t = (Hashtable<?,?>)super.clone();
-            t.table = new Entry<?,?>[table.length];
-            for (int i = table.length ; i-- > 0 ; ) {
-                t.table[i] = (table[i] != null)
-                    ? (Entry<?,?>) table[i].clone() : null;
-            }
-            t.keySet = null;
-            t.entrySet = null;
-            t.values = null;
-            t.modCount = 0;
-            return t;
+            return (Hashtable<?,?>)super.clone();
         } catch (CloneNotSupportedException e) {
             // this shouldn't happen, since we are Cloneable
             throw new InternalError(e);
@@ -1189,6 +1202,15 @@
      */
     private void writeObject(java.io.ObjectOutputStream s)
             throws IOException {
+        writeHashtable(s);
+    }
+
+    /**
+     * Perform serialization of the Hashtable to an ObjectOutputStream.
+     * The Properties class overrides this method.
+     */
+    void writeHashtable(java.io.ObjectOutputStream s)
+            throws IOException {
         Entry<Object, Object> entryStack = null;
 
         synchronized (this) {
@@ -1219,11 +1241,29 @@
     }
 
     /**
+     * Called by Properties to write out a simulated threshold and loadfactor.
+     */
+    final void defaultWriteHashtable(java.io.ObjectOutputStream s, int length,
+            float loadFactor) throws IOException {
+        this.threshold = (int)Math.min(length * loadFactor, MAX_ARRAY_SIZE + 1);
+        this.loadFactor = loadFactor;
+        s.defaultWriteObject();
+    }
+
+    /**
      * Reconstitute the Hashtable from a stream (i.e., deserialize it).
      */
     private void readObject(java.io.ObjectInputStream s)
-         throws IOException, ClassNotFoundException
-    {
+            throws IOException, ClassNotFoundException {
+        readHashtable(s);
+    }
+
+    /**
+     * Perform deserialization of the Hashtable from an ObjectInputStream.
+     * The Properties class overrides this method.
+     */
+    void readHashtable(java.io.ObjectInputStream s)
+            throws IOException, ClassNotFoundException {
         // Read in the threshold and loadFactor
         s.defaultReadObject();
 
diff --git a/jdk/src/java.base/share/classes/java/util/Objects.java b/jdk/src/java.base/share/classes/java/util/Objects.java
index 28b39d0..dad583b 100644
--- a/jdk/src/java.base/share/classes/java/util/Objects.java
+++ b/jdk/src/java.base/share/classes/java/util/Objects.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,9 @@
 
 package java.util;
 
-import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.util.Preconditions;
+import jdk.internal.vm.annotation.ForceInline;
 
-import java.util.function.BiFunction;
-import java.util.function.Function;
 import java.util.function.Supplier;
 
 /**
@@ -349,172 +348,6 @@
     }
 
     /**
-     * Maps out-of-bounds values to a runtime exception.
-     *
-     * @param checkKind the kind of bounds check, whose name may correspond
-     *        to the name of one of the range check methods, checkIndex,
-     *        checkFromToIndex, checkFromIndexSize
-     * @param args the out-of-bounds arguments that failed the range check.
-     *        If the checkKind corresponds a the name of a range check method
-     *        then the bounds arguments are those that can be passed in order
-     *        to the method.
-     * @param oobef the exception formatter that when applied with a checkKind
-     *        and a list out-of-bounds arguments returns a runtime exception.
-     *        If {@code null} then, it is as if an exception formatter was
-     *        supplied that returns {@link IndexOutOfBoundsException} for any
-     *        given arguments.
-     * @return the runtime exception
-     */
-    private static RuntimeException outOfBounds(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobef,
-            String checkKind,
-            Integer... args) {
-        List<Integer> largs = List.of(args);
-        RuntimeException e = oobef == null
-                             ? null : oobef.apply(checkKind, largs);
-        return e == null
-               ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e;
-    }
-
-    // Specific out-of-bounds exception producing methods that avoid
-    // the varargs-based code in the critical methods there by reducing their
-    // the byte code size, and therefore less likely to peturb inlining
-
-    private static RuntimeException outOfBoundsCheckIndex(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
-            int index, int length) {
-        return outOfBounds(oobe, "checkIndex", index, length);
-    }
-
-    private static RuntimeException outOfBoundsCheckFromToIndex(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
-            int fromIndex, int toIndex, int length) {
-        return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length);
-    }
-
-    private static RuntimeException outOfBoundsCheckFromIndexSize(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
-            int fromIndex, int size, int length) {
-        return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length);
-    }
-
-    /**
-     * Returns an out-of-bounds exception formatter from an given exception
-     * factory.  The exception formatter is a function that formats an
-     * out-of-bounds message from its arguments and applies that message to the
-     * given exception factory to produce and relay an exception.
-     *
-     * <p>The exception formatter accepts two arguments: a {@code String}
-     * describing the out-of-bounds range check that failed, referred to as the
-     * <em>check kind</em>; and a {@code List<Integer>} containing the
-     * out-of-bound integer values that failed the check.  The list of
-     * out-of-bound values is not modified.
-     *
-     * <p>Three check kinds are supported {@code checkIndex},
-     * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding
-     * respectively to the specified application of an exception formatter as an
-     * argument to the out-of-bounds range check methods
-     * {@link #checkIndex(int, int, BiFunction) checkIndex},
-     * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and
-     * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}.
-     * Thus a supported check kind corresponds to a method name and the
-     * out-of-bound integer values correspond to method argument values, in
-     * order, preceding the exception formatter argument (similar in many
-     * respects to the form of arguments required for a reflective invocation of
-     * such a range check method).
-     *
-     * <p>Formatter arguments conforming to such supported check kinds will
-     * produce specific exception messages describing failed out-of-bounds
-     * checks.  Otherwise, more generic exception messages will be produced in
-     * any of the following cases: the check kind is supported but fewer
-     * or more out-of-bounds values are supplied, the check kind is not
-     * supported, the check kind is {@code null}, or the list of out-of-bound
-     * values is {@code null}.
-     *
-     * @apiNote
-     * This method produces an out-of-bounds exception formatter that can be
-     * passed as an argument to any of the supported out-of-bounds range check
-     * methods declared by {@code Objects}.  For example, a formatter producing
-     * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a
-     * {@code static final} field as follows:
-     * <pre>{@code
-     * static final
-     * BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException> AIOOBEF =
-     *     outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
-     * }</pre>
-     * The formatter instance {@code AIOOBEF} may be passed as an argument to an
-     * out-of-bounds range check method, such as checking if an {@code index}
-     * is within the bounds of a {@code limit}:
-     * <pre>{@code
-     * checkIndex(index, limit, AIOOBEF);
-     * }</pre>
-     * If the bounds check fails then the range check method will throw an
-     * {@code ArrayIndexOutOfBoundsException} with an appropriate exception
-     * message that is a produced from {@code AIOOBEF} as follows:
-     * <pre>{@code
-     * AIOOBEF.apply("checkIndex", List.of(index, limit));
-     * }</pre>
-     *
-     * @param f the exception factory, that produces an exception from a message
-     *        where the message is produced and formatted by the returned
-     *        exception formatter.  If this factory is stateless and side-effect
-     *        free then so is the returned formatter.
-     *        Exceptions thrown by the factory are relayed to the caller
-     *        of the returned formatter.
-     * @param <X> the type of runtime exception to be returned by the given
-     *        exception factory and relayed by the exception formatter
-     * @return the out-of-bounds exception formatter
-     */
-    public static <X extends RuntimeException>
-    BiFunction<String, List<Integer>, X> outOfBoundsExceptionFormatter(Function<String, X> f) {
-        // Use anonymous class to avoid bootstrap issues if this method is
-        // used early in startup
-        return new BiFunction<String, List<Integer>, X>() {
-            @Override
-            public X apply(String checkKind, List<Integer> args) {
-                return f.apply(outOfBoundsMessage(checkKind, args));
-            }
-        };
-    }
-
-    private static String outOfBoundsMessage(String checkKind, List<Integer> args) {
-        if (checkKind == null && args == null) {
-            return String.format("Range check failed");
-        } else if (checkKind == null) {
-            return String.format("Range check failed: %s", args);
-        } else if (args == null) {
-            return String.format("Range check failed: %s", checkKind);
-        }
-
-        int argSize = 0;
-        switch (checkKind) {
-            case "checkIndex":
-                argSize = 2;
-                break;
-            case "checkFromToIndex":
-            case "checkFromIndexSize":
-                argSize = 3;
-                break;
-            default:
-        }
-
-        // Switch to default if fewer or more arguments than required are supplied
-        switch ((args.size() != argSize) ? "" : checkKind) {
-            case "checkIndex":
-                return String.format("Index %d out-of-bounds for length %d",
-                                     args.get(0), args.get(1));
-            case "checkFromToIndex":
-                return String.format("Range [%d, %d) out-of-bounds for length %d",
-                                     args.get(0), args.get(1), args.get(2));
-            case "checkFromIndexSize":
-                return String.format("Range [%d, %<d + %d) out-of-bounds for length %d",
-                                     args.get(0), args.get(1), args.get(2));
-            default:
-                return String.format("Range check failed: %s %s", checkKind, args);
-        }
-    }
-
-    /**
      * Checks if the {@code index} is within the bounds of the range from
      * {@code 0} (inclusive) to {@code length} (exclusive).
      *
@@ -526,72 +359,16 @@
      *  <li>{@code length < 0}, which is implied from the former inequalities</li>
      * </ul>
      *
-     * <p>This method behaves as if {@link #checkIndex(int, int, BiFunction)}
-     * was called with same out-of-bounds arguments and an exception formatter
-     * argument produced from an invocation of
-     * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
-     * be more efficient).
-     *
      * @param index the index
      * @param length the upper-bound (exclusive) of the range
      * @return {@code index} if it is within bounds of the range
      * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
      * @since 9
      */
+    @ForceInline
     public static
     int checkIndex(int index, int length) {
-        return checkIndex(index, length, null);
-    }
-
-    /**
-     * Checks if the {@code index} is within the bounds of the range from
-     * {@code 0} (inclusive) to {@code length} (exclusive).
-     *
-     * <p>The {@code index} is defined to be out-of-bounds if any of the
-     * following inequalities is true:
-     * <ul>
-     *  <li>{@code index < 0}</li>
-     *  <li>{@code index >= length}</li>
-     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
-     * </ul>
-     *
-     * <p>If the {@code index} is out-of-bounds, then a runtime exception is
-     * thrown that is the result of applying the following arguments to the
-     * exception formatter: the name of this method, {@code checkIndex};
-     * and an unmodifiable list integers whose values are, in order, the
-     * out-of-bounds arguments {@code index} and {@code length}.
-     *
-     * @param <X> the type of runtime exception to throw if the arguments are
-     *        out-of-bounds
-     * @param index the index
-     * @param length the upper-bound (exclusive) of the range
-     * @param oobef the exception formatter that when applied with this
-     *        method name and out-of-bounds arguments returns a runtime
-     *        exception.  If {@code null} or returns {@code null} then, it is as
-     *        if an exception formatter produced from an invocation of
-     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
-     *        instead (though it may be more efficient).
-     *        Exceptions thrown by the formatter are relayed to the caller.
-     * @return {@code index} if it is within bounds of the range
-     * @throws X if the {@code index} is out-of-bounds and the exception
-     *         formatter is non-{@code null}
-     * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
-     *         and the exception formatter is {@code null}
-     * @since 9
-     *
-     * @implNote
-     * This method is made intrinsic in optimizing compilers to guide them to
-     * perform unsigned comparisons of the index and length when it is known the
-     * length is a non-negative value (such as that of an array length or from
-     * the upper bound of a loop)
-    */
-    @HotSpotIntrinsicCandidate
-    public static <X extends RuntimeException>
-    int checkIndex(int index, int length,
-                   BiFunction<String, List<Integer>, X> oobef) {
-        if (index < 0 || index >= length)
-            throw outOfBoundsCheckIndex(oobef, index, length);
-        return index;
+        return Preconditions.checkIndex(index, length, null);
     }
 
     /**
@@ -608,12 +385,6 @@
      *  <li>{@code length < 0}, which is implied from the former inequalities</li>
      * </ul>
      *
-     * <p>This method behaves as if {@link #checkFromToIndex(int, int, int, BiFunction)}
-     * was called with same out-of-bounds arguments and an exception formatter
-     * argument produced from an invocation of
-     * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
-     * be more efficient).
-     *
      * @param fromIndex the lower-bound (inclusive) of the sub-range
      * @param toIndex the upper-bound (exclusive) of the sub-range
      * @param length the upper-bound (exclusive) the range
@@ -623,54 +394,7 @@
      */
     public static
     int checkFromToIndex(int fromIndex, int toIndex, int length) {
-        return checkFromToIndex(fromIndex, toIndex, length, null);
-    }
-
-    /**
-     * Checks if the sub-range from {@code fromIndex} (inclusive) to
-     * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
-     * (inclusive) to {@code length} (exclusive).
-     *
-     * <p>The sub-range is defined to be out-of-bounds if any of the following
-     * inequalities is true:
-     * <ul>
-     *  <li>{@code fromIndex < 0}</li>
-     *  <li>{@code fromIndex > toIndex}</li>
-     *  <li>{@code toIndex > length}</li>
-     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
-     * </ul>
-     *
-     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
-     * thrown that is the result of applying the following arguments to the
-     * exception formatter: the name of this method, {@code checkFromToIndex};
-     * and an unmodifiable list integers whose values are, in order, the
-     * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}.
-     *
-     * @param <X> the type of runtime exception to throw if the arguments are
-     *        out-of-bounds
-     * @param fromIndex the lower-bound (inclusive) of the sub-range
-     * @param toIndex the upper-bound (exclusive) of the sub-range
-     * @param length the upper-bound (exclusive) the range
-     * @param oobef the exception formatter that when applied with this
-     *        method name and out-of-bounds arguments returns a runtime
-     *        exception.  If {@code null} or returns {@code null} then, it is as
-     *        if an exception formatter produced from an invocation of
-     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
-     *        instead (though it may be more efficient).
-     *        Exceptions thrown by the formatter are relayed to the caller.
-     * @return {@code fromIndex} if the sub-range within bounds of the range
-     * @throws X if the sub-range is out-of-bounds and the exception factory
-     *         function is non-{@code null}
-     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
-     *         the exception factory function is {@code null}
-     * @since 9
-     */
-    public static <X extends RuntimeException>
-    int checkFromToIndex(int fromIndex, int toIndex, int length,
-                         BiFunction<String, List<Integer>, X> oobef) {
-        if (fromIndex < 0 || fromIndex > toIndex || toIndex > length)
-            throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length);
-        return fromIndex;
+        return Preconditions.checkFromToIndex(fromIndex, toIndex, length, null);
     }
 
     /**
@@ -687,12 +411,6 @@
      *  <li>{@code length < 0}, which is implied from the former inequalities</li>
      * </ul>
      *
-     * <p>This method behaves as if {@link #checkFromIndexSize(int, int, int, BiFunction)}
-     * was called with same out-of-bounds arguments and an exception formatter
-     * argument produced from an invocation of
-     * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
-     * be more efficient).
-     *
      * @param fromIndex the lower-bound (inclusive) of the sub-interval
      * @param size the size of the sub-range
      * @param length the upper-bound (exclusive) of the range
@@ -702,54 +420,7 @@
      */
     public static
     int checkFromIndexSize(int fromIndex, int size, int length) {
-        return checkFromIndexSize(fromIndex, size, length, null);
+        return Preconditions.checkFromIndexSize(fromIndex, size, length, null);
     }
 
-    /**
-     * Checks if the sub-range from {@code fromIndex} (inclusive) to
-     * {@code fromIndex + size} (exclusive) is within the bounds of range from
-     * {@code 0} (inclusive) to {@code length} (exclusive).
-     *
-     * <p>The sub-range is defined to be out-of-bounds if any of the following
-     * inequalities is true:
-     * <ul>
-     *  <li>{@code fromIndex < 0}</li>
-     *  <li>{@code size < 0}</li>
-     *  <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
-     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
-     * </ul>
-     *
-     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
-     * thrown that is the result of applying the following arguments to the
-     * exception formatter: the name of this method, {@code checkFromIndexSize};
-     * and an unmodifiable list integers whose values are, in order, the
-     * out-of-bounds arguments {@code fromIndex}, {@code size}, and
-     * {@code length}.
-     *
-     * @param <X> the type of runtime exception to throw if the arguments are
-     *        out-of-bounds
-     * @param fromIndex the lower-bound (inclusive) of the sub-interval
-     * @param size the size of the sub-range
-     * @param length the upper-bound (exclusive) of the range
-     * @param oobef the exception formatter that when applied with this
-     *        method name and out-of-bounds arguments returns a runtime
-     *        exception.  If {@code null} or returns {@code null} then, it is as
-     *        if an exception formatter produced from an invocation of
-     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
-     *        instead (though it may be more efficient).
-     *        Exceptions thrown by the formatter are relayed to the caller.
-     * @return {@code fromIndex} if the sub-range within bounds of the range
-     * @throws X if the sub-range is out-of-bounds and the exception factory
-     *         function is non-{@code null}
-     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
-     *         the exception factory function is {@code null}
-     * @since 9
-     */
-    public static <X extends RuntimeException>
-    int checkFromIndexSize(int fromIndex, int size, int length,
-                           BiFunction<String, List<Integer>, X> oobef) {
-        if ((length | fromIndex | size) < 0 || size > length - fromIndex)
-            throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length);
-        return fromIndex;
-    }
 }
diff --git a/jdk/src/java.base/share/classes/java/util/Properties.java b/jdk/src/java.base/share/classes/java/util/Properties.java
index 1eddbab..c2b93d2 100644
--- a/jdk/src/java.base/share/classes/java/util/Properties.java
+++ b/jdk/src/java.base/share/classes/java/util/Properties.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,13 @@
 import java.io.Writer;
 import java.io.OutputStreamWriter;
 import java.io.BufferedWriter;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StreamCorruptedException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
 
 import jdk.internal.util.xml.PropertiesDefaultHandler;
 
@@ -60,6 +67,13 @@
  * object that contains a non-{@code String} key.
  *
  * <p>
+ * The iterators returned by the {@code iterator} method of this class's
+ * "collection views" (that is, {@code entrySet()}, {@code keySet()}, and
+ * {@code values()}) may not fail-fast (unlike the Hashtable implementation).
+ * These iterators are guaranteed to traverse elements as they existed upon
+ * construction exactly once, and may (but are not guaranteed to) reflect any
+ * modifications subsequent to construction.
+ * <p>
  * The {@link #load(java.io.Reader) load(Reader)} {@code /}
  * {@link #store(java.io.Writer, java.lang.String) store(Writer, String)}
  * methods load and store properties from and to a character based stream
@@ -128,6 +142,15 @@
     protected Properties defaults;
 
     /**
+     * Properties does not store values in its inherited Hashtable, but instead
+     * in an internal ConcurrentHashMap.  Synchronization is omitted from
+     * simple read operations.  Writes and bulk operations remain synchronized,
+     * as in Hashtable.
+     */
+    private transient ConcurrentHashMap<Object, Object> map =
+            new ConcurrentHashMap<>(8);
+
+    /**
      * Creates an empty property list with no default values.
      */
     public Properties() {
@@ -140,6 +163,9 @@
      * @param   defaults   the defaults.
      */
     public Properties(Properties defaults) {
+        // use package-private constructor to
+        // initialize unused fields with dummy values
+        super((Void) null);
         this.defaults = defaults;
     }
 
@@ -826,9 +852,9 @@
         bw.write("#" + new Date().toString());
         bw.newLine();
         synchronized (this) {
-            for (Enumeration<?> e = keys(); e.hasMoreElements();) {
-                String key = (String)e.nextElement();
-                String val = (String)get(key);
+            for (Map.Entry<Object, Object> e : entrySet()) {
+                String key = (String)e.getKey();
+                String val = (String)e.getValue();
                 key = saveConvert(key, true, escUnicode);
                 /* No need to escape embedded and trailing spaces for value, hence
                  * pass false to flag.
@@ -967,7 +993,7 @@
      * @see     #defaults
      */
     public String getProperty(String key) {
-        Object oval = super.get(key);
+        Object oval = map.get(key);
         String sval = (oval instanceof String) ? (String)oval : null;
         return ((sval == null) && (defaults != null)) ? defaults.getProperty(key) : sval;
     }
@@ -1029,7 +1055,7 @@
      * @since   1.6
      */
     public Set<String> stringPropertyNames() {
-        Hashtable<String, String> h = new Hashtable<>();
+        Map<String, String> h = new HashMap<>();
         enumerateStringProperties(h);
         return h.keySet();
     }
@@ -1044,11 +1070,11 @@
      */
     public void list(PrintStream out) {
         out.println("-- listing properties --");
-        Hashtable<String,Object> h = new Hashtable<>();
+        Map<String, Object> h = new HashMap<>();
         enumerate(h);
-        for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
-            String key = e.nextElement();
-            String val = (String)h.get(key);
+        for (Map.Entry<String, Object> e : h.entrySet()) {
+            String key = e.getKey();
+            String val = (String)e.getValue();
             if (val.length() > 40) {
                 val = val.substring(0, 37) + "...";
             }
@@ -1072,11 +1098,11 @@
      */
     public void list(PrintWriter out) {
         out.println("-- listing properties --");
-        Hashtable<String,Object> h = new Hashtable<>();
+        Map<String, Object> h = new HashMap<>();
         enumerate(h);
-        for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
-            String key = e.nextElement();
-            String val = (String)h.get(key);
+        for (Map.Entry<String, Object> e : h.entrySet()) {
+            String key = e.getKey();
+            String val = (String)e.getValue();
             if (val.length() > 40) {
                 val = val.substring(0, 37) + "...";
             }
@@ -1085,33 +1111,33 @@
     }
 
     /**
-     * Enumerates all key/value pairs in the specified hashtable.
-     * @param h the hashtable
+     * Enumerates all key/value pairs into the specified Map.
+     * @param h the Map
      * @throws ClassCastException if any of the property keys
      *         is not of String type.
      */
-    private synchronized void enumerate(Hashtable<String,Object> h) {
+    private void enumerate(Map<String, Object> h) {
         if (defaults != null) {
             defaults.enumerate(h);
         }
-        for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
-            String key = (String)e.nextElement();
-            h.put(key, get(key));
+        for (Map.Entry<Object, Object> e : entrySet()) {
+            String key = (String)e.getKey();
+            h.put(key, e.getValue());
         }
     }
 
     /**
-     * Enumerates all key/value pairs in the specified hashtable
+     * Enumerates all key/value pairs into the specified Map
      * and omits the property if the key or value is not a string.
-     * @param h the hashtable
+     * @param h the Map
      */
-    private synchronized void enumerateStringProperties(Hashtable<String, String> h) {
+    private void enumerateStringProperties(Map<String, String> h) {
         if (defaults != null) {
             defaults.enumerateStringProperties(h);
         }
-        for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
-            Object k = e.nextElement();
-            Object v = get(k);
+        for (Map.Entry<Object, Object> e : entrySet()) {
+            Object k = e.getKey();
+            Object v = e.getValue();
             if (k instanceof String && v instanceof String) {
                 h.put((String) k, (String) v);
             }
@@ -1130,4 +1156,283 @@
     private static final char[] hexDigit = {
         '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
     };
+
+    //
+    // Hashtable methods overridden and delegated to a ConcurrentHashMap instance
+
+    @Override
+    public int size() {
+        return map.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return map.isEmpty();
+    }
+
+    @Override
+    public Enumeration<Object> keys() {
+        // CHM.keys() returns Iterator w/ remove() - instead wrap keySet()
+        return Collections.enumeration(map.keySet());
+    }
+
+    @Override
+    public Enumeration<Object> elements() {
+        // CHM.elements() returns Iterator w/ remove() - instead wrap values()
+        return Collections.enumeration(map.values());
+    }
+
+    @Override
+    public boolean contains(Object value) {
+        return map.contains(value);
+    }
+
+    @Override
+    public boolean containsValue(Object value) {
+        return map.containsValue(value);
+    }
+
+    @Override
+    public boolean containsKey(Object key) {
+        return map.containsKey(key);
+    }
+
+    @Override
+    public Object get(Object key) {
+        return map.get(key);
+    }
+
+    @Override
+    public synchronized Object put(Object key, Object value) {
+        return map.put(key, value);
+    }
+
+    @Override
+    public synchronized Object remove(Object key) {
+        return map.remove(key);
+    }
+
+    @Override
+    public synchronized void putAll(Map<?, ?> t) {
+        map.putAll(t);
+    }
+
+    @Override
+    public synchronized void clear() {
+        map.clear();
+    }
+
+    @Override
+    public synchronized String toString() {
+        return map.toString();
+    }
+
+    @Override
+    public Set<Object> keySet() {
+        return Collections.synchronizedSet(map.keySet(), this);
+    }
+
+    @Override
+    public Collection<Object> values() {
+        return Collections.synchronizedCollection(map.values(), this);
+    }
+
+    @Override
+    public Set<Map.Entry<Object, Object>> entrySet() {
+        return Collections.synchronizedSet(new EntrySet(map.entrySet()), this);
+    }
+
+    /*
+     * Properties.entrySet() should not support add/addAll, however
+     * ConcurrentHashMap.entrySet() provides add/addAll.  This class wraps the
+     * Set returned from CHM, changing add/addAll to throw UOE.
+     */
+    private static class EntrySet implements Set<Map.Entry<Object, Object>> {
+        private Set<Map.Entry<Object,Object>> entrySet;
+
+        private EntrySet(Set<Map.Entry<Object, Object>> entrySet) {
+            this.entrySet = entrySet;
+        }
+
+        @Override public int size() { return entrySet.size(); }
+        @Override public boolean isEmpty() { return entrySet.isEmpty(); }
+        @Override public boolean contains(Object o) { return entrySet.contains(o); }
+        @Override public Object[] toArray() { return entrySet.toArray(); }
+        @Override public <T> T[] toArray(T[] a) { return entrySet.toArray(a); }
+        @Override public void clear() { entrySet.clear(); }
+        @Override public boolean remove(Object o) { return entrySet.remove(o); }
+
+        @Override
+        public boolean add(Map.Entry<Object, Object> e) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean addAll(Collection<? extends Map.Entry<Object, Object>> c) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean containsAll(Collection<?> c) {
+            return entrySet.containsAll(c);
+        }
+
+        @Override
+        public boolean removeAll(Collection<?> c) {
+            return entrySet.removeAll(c);
+        }
+
+        @Override
+        public boolean retainAll(Collection<?> c) {
+            return entrySet.retainAll(c);
+        }
+
+        @Override
+        public Iterator<Map.Entry<Object, Object>> iterator() {
+            return entrySet.iterator();
+        }
+    }
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        return map.equals(o);
+    }
+
+    @Override
+    public synchronized int hashCode() {
+        return map.hashCode();
+    }
+
+    @Override
+    public Object getOrDefault(Object key, Object defaultValue) {
+        return map.getOrDefault(key, defaultValue);
+    }
+
+    @Override
+    public synchronized void forEach(BiConsumer<? super Object, ? super Object> action) {
+        map.forEach(action);
+    }
+
+    @Override
+    public synchronized void replaceAll(BiFunction<? super Object, ? super Object, ?> function) {
+        map.replaceAll(function);
+    }
+
+    @Override
+    public synchronized Object putIfAbsent(Object key, Object value) {
+        return map.putIfAbsent(key, value);
+    }
+
+    @Override
+    public synchronized boolean remove(Object key, Object value) {
+        return map.remove(key, value);
+    }
+
+    /** @hidden */
+    @Override
+    public synchronized boolean replace(Object key, Object oldValue, Object newValue) {
+        return map.replace(key, oldValue, newValue);
+    }
+
+    @Override
+    public synchronized Object replace(Object key, Object value) {
+        return map.replace(key, value);
+    }
+
+    @Override
+    public synchronized Object computeIfAbsent(Object key,
+            Function<? super Object, ?> mappingFunction) {
+        return map.computeIfAbsent(key, mappingFunction);
+    }
+
+    @Override
+    public synchronized Object computeIfPresent(Object key,
+            BiFunction<? super Object, ? super Object, ?> remappingFunction) {
+        return map.computeIfPresent(key, remappingFunction);
+    }
+
+    @Override
+    public synchronized Object compute(Object key,
+            BiFunction<? super Object, ? super Object, ?> remappingFunction) {
+        return map.compute(key, remappingFunction);
+    }
+
+    @Override
+    public synchronized Object merge(Object key, Object value,
+            BiFunction<? super Object, ? super Object, ?> remappingFunction) {
+        return map.merge(key, value, remappingFunction);
+    }
+
+    //
+    // Special Hashtable methods
+
+    @Override
+    protected void rehash() { /* no-op */ }
+
+    @Override
+    public synchronized Object clone() {
+        Properties clone = (Properties) cloneHashtable();
+        clone.map = new ConcurrentHashMap<>(map);
+        return clone;
+    }
+
+    //
+    // Hashtable serialization overrides
+    // (these should emit and consume Hashtable-compatible stream)
+
+    @Override
+    void writeHashtable(ObjectOutputStream s) throws IOException {
+        List<Object> entryStack = new ArrayList<>(map.size() * 2); // an estimate
+
+        for (Map.Entry<Object, Object> entry : map.entrySet()) {
+            entryStack.add(entry.getValue());
+            entryStack.add(entry.getKey());
+        }
+
+        // Write out the simulated threshold, loadfactor
+        float loadFactor = 0.75f;
+        int count = entryStack.size() / 2;
+        int length = (int)(count / loadFactor) + (count / 20) + 3;
+        if (length > count && (length & 1) == 0) {
+            length--;
+        }
+        synchronized (map) { // in case of multiple concurrent serializations
+            defaultWriteHashtable(s, length, loadFactor);
+        }
+
+        // Write out simulated length and real count of elements
+        s.writeInt(length);
+        s.writeInt(count);
+
+        // Write out the key/value objects from the stacked entries
+        for (int i = entryStack.size() - 1; i >= 0; i--) {
+            s.writeObject(entryStack.get(i));
+        }
+    }
+
+    @Override
+    void readHashtable(ObjectInputStream s) throws IOException,
+            ClassNotFoundException {
+        // Read in the threshold and loadfactor
+        s.defaultReadObject();
+
+        // Read the original length of the array and number of elements
+        int origlength = s.readInt();
+        int elements = s.readInt();
+
+        // Validate # of elements
+        if (elements < 0) {
+            throw new StreamCorruptedException("Illegal # of Elements: " + elements);
+        }
+
+        // create CHM of appropriate capacity
+        map = new ConcurrentHashMap<>(elements);
+
+        // Read all the key/value objects
+        for (; elements > 0; elements--) {
+            Object key = s.readObject();
+            Object value = s.readObject();
+            map.put(key, value);
+        }
+    }
 }
diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
index 5f08db7..aab2474 100644
--- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -153,7 +153,7 @@
         SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl());
 
         BASE_VERSION = 8;  // one less than lowest version for versioned entries
-        int runtimeVersion = jdk.Version.current().major();
+        int runtimeVersion = Runtime.version().major();
         String jarVersion =
                 GetPropertyAction.privilegedGetProperty("jdk.util.jar.version");
         if (jarVersion != null) {
@@ -357,7 +357,7 @@
     }
 
     private boolean runtimeVersionExists() {
-        int version = jdk.Version.current().major();
+        int version = Runtime.version().major();
         try {
             Release.valueOf(version);
             return true;
diff --git a/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java b/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java
index 0a873c7..238fc6e 100644
--- a/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java
+++ b/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java
@@ -302,7 +302,8 @@
         defCategory("C", ((1<<Character.CONTROL)     |
                           (1<<Character.FORMAT)      |
                           (1<<Character.PRIVATE_USE) |
-                          (1<<Character.SURROGATE))); // Other
+                          (1<<Character.SURROGATE)   |
+                          (1<<Character.UNASSIGNED))); // Other
         defCategory("P", ((1<<Character.DASH_PUNCTUATION)      |
                           (1<<Character.START_PUNCTUATION)     |
                           (1<<Character.END_PUNCTUATION)       |
diff --git a/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java b/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java
index 33de7d5..f6bd8f5 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java
@@ -106,7 +106,7 @@
     protected Spliterator<P_IN> spliterator;
 
     /** Target leaf size, common to all tasks in a computation */
-    protected long targetSize; // may be laziliy initialized
+    protected long targetSize; // may be lazily initialized
 
     /**
      * The left child.
diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java
index 9d25d90..ad25075 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java
@@ -211,6 +211,11 @@
      *         .sum();
      * }</pre>
      *
+     * <p>In cases where the stream implementation is able to optimize away the
+     * production of some or all the elements (such as with short-circuiting
+     * operations like {@code findFirst}, or in the example described in
+     * {@link #count}), the action will not be invoked for those elements.
+     *
      * @param action a <a href="package-summary.html#NonInterference">
      *               non-interfering</a> action to perform on the elements as
      *               they are consumed from the stream
diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java
index 115a782..9c72977 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java
@@ -209,6 +209,11 @@
      *         .sum();
      * }</pre>
      *
+     * <p>In cases where the stream implementation is able to optimize away the
+     * production of some or all the elements (such as with short-circuiting
+     * operations like {@code findFirst}, or in the example described in
+     * {@link #count}), the action will not be invoked for those elements.
+     *
      * @param action a <a href="package-summary.html#NonInterference">
      *               non-interfering</a> action to perform on the elements as
      *               they are consumed from the stream
diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java
index f987820..7965bfd 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java
@@ -209,6 +209,11 @@
      *         .sum();
      * }</pre>
      *
+     * <p>In cases where the stream implementation is able to optimize away the
+     * production of some or all the elements (such as with short-circuiting
+     * operations like {@code findFirst}, or in the example described in
+     * {@link #count}), the action will not be invoked for those elements.
+     *
      * @param action a <a href="package-summary.html#NonInterference">
      *               non-interfering</a> action to perform on the elements as
      *               they are consumed from the stream
diff --git a/jdk/src/java.base/share/classes/java/util/stream/Stream.java b/jdk/src/java.base/share/classes/java/util/stream/Stream.java
index 1dd1d43..7ab71a5 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java
@@ -82,6 +82,19 @@
  * terminal operation is initiated, and source elements are consumed only
  * as needed.
  *
+ * <p>A stream implementation is permitted significant latitude in optimizing
+ * the computation of the result.  For example, a stream implementation is free
+ * to elide operations (or entire stages) from a stream pipeline -- and
+ * therefore elide invocation of behavioral parameters -- if it can prove that
+ * it would not affect the result of the computation.  This means that
+ * side-effects of behavioral parameters may not always be executed and should
+ * not be relied upon, unless otherwise specified (such as by the terminal
+ * operations {@code forEach} and {@code forEachOrdered}). (For a specific
+ * example of such an optimization, see the API note documented on the
+ * {@link #count} operation.  For more detail, see the
+ * <a href="package-summary.html#SideEffects">side-effects</a> section of the
+ * stream package documentation.)
+ *
  * <p>Collections and streams, while bearing some superficial similarities,
  * have different goals.  Collections are primarily concerned with the efficient
  * management of, and access to, their elements.  By contrast, streams do not
@@ -415,6 +428,11 @@
      *         .collect(Collectors.toList());
      * }</pre>
      *
+     * <p>In cases where the stream implementation is able to optimize away the
+     * production of some or all the elements (such as with short-circuiting
+     * operations like {@code findFirst}, or in the example described in
+     * {@link #count}), the action will not be invoked for those elements.
+     *
      * @param action a <a href="package-summary.html#NonInterference">
      *                 non-interfering</a> action to perform on the elements as
      *                 they are consumed from the stream
diff --git a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
index cb92b2e..8236255 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
@@ -28,7 +28,6 @@
 import java.util.Objects;
 import java.util.Spliterator;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.BooleanSupplier;
 import java.util.function.Consumer;
@@ -104,7 +103,7 @@
         T_BUFFER buffer;
 
         /**
-         * True if full traversal has occurred (with possible cancelation).
+         * True if full traversal has occurred (with possible cancellation).
          * If doing a partial traversal, there may be still elements in buffer.
          */
         boolean finished;
diff --git a/jdk/src/java.base/share/classes/java/util/stream/package-info.java b/jdk/src/java.base/share/classes/java/util/stream/package-info.java
index 2850e21..f580d8f 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/package-info.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/package-info.java
@@ -287,18 +287,35 @@
  * statelessness requirement, as well as other thread-safety hazards.
  *
  * <p>If the behavioral parameters do have side-effects, unless explicitly
- * stated, there are no guarantees as to the
- * <a href="../concurrent/package-summary.html#MemoryVisibility"><i>visibility</i></a>
- * of those side-effects to other threads, nor are there any guarantees that
- * different operations on the "same" element within the same stream pipeline
- * are executed in the same thread.  Further, the ordering of those effects
- * may be surprising.  Even when a pipeline is constrained to produce a
- * <em>result</em> that is consistent with the encounter order of the stream
- * source (for example, {@code IntStream.range(0,5).parallel().map(x -> x*2).toArray()}
+ * stated, there are no guarantees as to:
+ * <ul>
+ *    <li>the <a href="../concurrent/package-summary.html#MemoryVisibility">
+ *    <i>visibility</i></a> of those side-effects to other threads;</li>
+ *    <li>that different operations on the "same" element within the same stream
+ *    pipeline are executed in the same thread; and</li>
+ *    <li>that behavioral parameters are always invoked, since a stream
+ *    implementation is free to elide operations (or entire stages) from a
+ *    stream pipeline if it can prove that it would not affect the result of the
+ *    computation.
+ *    </li>
+ * </ul>
+ * <p>The ordering of side-effects may be surprising.  Even when a pipeline is
+ * constrained to produce a <em>result</em> that is consistent with the
+ * encounter order of the stream source (for example,
+ * {@code IntStream.range(0,5).parallel().map(x -> x*2).toArray()}
  * must produce {@code [0, 2, 4, 6, 8]}), no guarantees are made as to the order
  * in which the mapper function is applied to individual elements, or in what
  * thread any behavioral parameter is executed for a given element.
  *
+ * <p>The eliding of side-effects may also be surprising.  With the exception of
+ * terminal operations {@link java.util.stream.Stream#forEach forEach} and
+ * {@link java.util.stream.Stream#forEachOrdered forEachOrdered}, side-effects
+ * of behavioral parameters may not always be executed when the stream
+ * implementation can optimize away the execution of behavioral parameters
+ * without affecting the result of the computation.  (For a specific example
+ * see the API note documented on the {@link java.util.stream.Stream#count count}
+ * operation.)
+ *
  * <p>Many computations where one might be tempted to use side effects can be more
  * safely and efficiently expressed without side-effects, such as using
  * <a href="package-summary.html#Reduction">reduction</a> instead of mutable
diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
index 1cba038..cc91536 100644
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
@@ -54,6 +54,8 @@
 import java.util.stream.StreamSupport;
 import jdk.internal.misc.JavaUtilZipFileAccess;
 import jdk.internal.misc.SharedSecrets;
+import jdk.internal.misc.JavaIORandomAccessFileAccess;
+import jdk.internal.misc.VM;
 import jdk.internal.perf.PerfCounter;
 
 import static java.util.zip.ZipConstants.*;
@@ -462,9 +464,13 @@
 
     private class ZipEntryIterator implements Enumeration<ZipEntry>, Iterator<ZipEntry> {
         private int i = 0;
+        private final int entryCount;
 
         public ZipEntryIterator() {
-            ensureOpen();
+            synchronized (ZipFile.this) {
+                ensureOpen();
+                this.entryCount = zsrc.total;
+            }
         }
 
         public boolean hasMoreElements() {
@@ -472,10 +478,7 @@
         }
 
         public boolean hasNext() {
-            synchronized (ZipFile.this) {
-                ensureOpen();
-                return i < zsrc.total;
-            }
+            return i < entryCount;
         }
 
         public ZipEntry nextElement() {
@@ -485,7 +488,7 @@
         public ZipEntry next() {
             synchronized (ZipFile.this) {
                 ensureOpen();
-                if (i >= zsrc.total) {
+                if (!hasNext()) {
                     throw new NoSuchElementException();
                 }
                 // each "entry" has 3 ints in table entries
@@ -526,34 +529,34 @@
     /* Checks ensureOpen() before invoke this method */
     private ZipEntry getZipEntry(String name, int pos) {
         byte[] cen = zsrc.cen;
-        ZipEntry e = new ZipEntry();
         int nlen = CENNAM(cen, pos);
         int elen = CENEXT(cen, pos);
         int clen = CENCOM(cen, pos);
-        e.flag = CENFLG(cen, pos);  // get the flag first
-        if (name != null) {
-            e.name = name;
-        } else {
-            if (!zc.isUTF8() && (e.flag & EFS) != 0) {
-                e.name = zc.toStringUTF8(cen, pos + CENHDR, nlen);
+        int flag = CENFLG(cen, pos);
+        if (name == null) {
+            if (!zc.isUTF8() && (flag & EFS) != 0) {
+                name = zc.toStringUTF8(cen, pos + CENHDR, nlen);
             } else {
-                e.name = zc.toString(cen, pos + CENHDR, nlen);
+                name = zc.toString(cen, pos + CENHDR, nlen);
             }
         }
+        ZipEntry e = new ZipEntry(name);
+        e.flag = flag;
         e.xdostime = CENTIM(cen, pos);
         e.crc = CENCRC(cen, pos);
         e.size = CENLEN(cen, pos);
         e.csize = CENSIZ(cen, pos);
         e.method = CENHOW(cen, pos);
         if (elen != 0) {
-            e.setExtra0(Arrays.copyOfRange(cen, pos + CENHDR + nlen,
-                                           pos + CENHDR + nlen + elen), true);
+            int start = pos + CENHDR + nlen;
+            e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true);
         }
         if (clen != 0) {
-            if (!zc.isUTF8() && (e.flag & EFS) != 0) {
-                e.comment = zc.toStringUTF8(cen, pos + CENHDR + nlen + elen, clen);
+            int start = pos + CENHDR + nlen + elen;
+            if (!zc.isUTF8() && (flag & EFS) != 0) {
+                e.comment = zc.toStringUTF8(cen, start, clen);
             } else {
-                e.comment = zc.toString(cen, pos + CENHDR + nlen + elen, clen);
+                e.comment = zc.toString(cen, start, clen);
             }
         }
         return e;
@@ -804,6 +807,30 @@
         }
     }
 
+    /**
+     * Returns the names of all non-directory entries that begin with
+     * "META-INF/" (case ignored). This method is used in JarFile, via
+     * SharedSecrets, as an optimization when looking up manifest and
+     * signature file entries. Returns null if no entries were found.
+     */
+    private String[] getMetaInfEntryNames() {
+        synchronized (this) {
+            ensureOpen();
+            if (zsrc.metanames == null) {
+                return null;
+            }
+            String[] names = new String[zsrc.metanames.length];
+            byte[] cen = zsrc.cen;
+            for (int i = 0; i < names.length; i++) {
+                int pos = zsrc.metanames[i];
+                names[i] = new String(cen, pos + CENHDR, CENNAM(cen, pos),
+                                      StandardCharsets.UTF_8);
+            }
+            return names;
+        }
+    }
+
+    private static boolean isWindows;
     static {
         SharedSecrets.setJavaUtilZipFileAccess(
             new JavaUtilZipFileAccess() {
@@ -815,30 +842,7 @@
                 }
              }
         );
-    }
-
-    /*
-     * Returns an array of strings representing the names of all entries
-     * that begin with "META-INF/" (case ignored). This method is used
-     * in JarFile, via SharedSecrets, as an optimization when looking up
-     * manifest and signature file entries. Returns null if no entries
-     * were found.
-     */
-    private String[] getMetaInfEntryNames() {
-        synchronized (this) {
-            ensureOpen();
-            if (zsrc.metanames.size() == 0) {
-                return null;
-            }
-            String[] names = new String[zsrc.metanames.size()];
-            byte[] cen = zsrc.cen;
-            for (int i = 0; i < names.length; i++) {
-                int pos = zsrc.metanames.get(i);
-                names[i] = new String(cen, pos + CENHDR,  CENNAM(cen, pos),
-                                      StandardCharsets.UTF_8);
-            }
-            return names;
-        }
+        isWindows = VM.getSavedProperty("os.name").contains("Windows");
     }
 
     private static class Source {
@@ -850,7 +854,7 @@
         private long locpos;                 // position of first LOC header (usually 0)
         private byte[] comment;              // zip file comment
                                              // list of meta entries in META-INF dir
-        private ArrayList<Integer> metanames = new ArrayList<>();
+        private int[] metanames;
         private final boolean startsWithLoc; // true, if zip file starts with LOCSIG (usually true)
 
         // A Hashmap for all entries.
@@ -955,9 +959,16 @@
 
         private Source(Key key, boolean toDelete) throws IOException {
             this.key = key;
-            this.zfile = new RandomAccessFile(key.file, "r");
             if (toDelete) {
-                key.file.delete();
+                if (isWindows) {
+                    this.zfile = SharedSecrets.getJavaIORandomAccessFileAccess()
+                                              .openAndDelete(key.file, "r");
+                } else {
+                    this.zfile = new RandomAccessFile(key.file, "r");
+                    key.file.delete();
+                }
+            } else {
+                this.zfile = new RandomAccessFile(key.file, "r");
             }
             try {
                 initCEN(-1);
@@ -1159,7 +1170,7 @@
             int next = -1;
 
             // list for all meta entries
-            metanames = new ArrayList<>();
+            ArrayList<Integer> metanamesList = null;
 
             // Iterate through the entries in the central directory
             int i = 0;
@@ -1194,13 +1205,21 @@
                 idx = addEntry(idx, hash, next, pos);
                 // Adds name to metanames.
                 if (isMetaName(cen, pos + CENHDR, nlen)) {
-                    metanames.add(pos);
+                    if (metanamesList == null)
+                        metanamesList = new ArrayList<>(4);
+                    metanamesList.add(pos);
                 }
                 // skip ext and comment
                 pos += (CENHDR + nlen + elen + clen);
                 i++;
             }
             total = i;
+            if (metanamesList != null) {
+                metanames = new int[metanamesList.size()];
+                for (int j = 0, len = metanames.length; j < len; j++) {
+                    metanames[j] = metanamesList.get(j);
+                }
+            }
             if (pos + ENDHDR != cen.length) {
                 zerror("invalid CEN header (bad header size)");
             }
@@ -1265,44 +1284,38 @@
             }
         }
 
-        private static byte[] metainf = new byte[] {
-            'M', 'E', 'T', 'A', '-', 'I' , 'N', 'F', '/',
-        };
-
-        /*
-         * Returns true if the specified entry's name begins with the string
-         * "META-INF/" irrespective of case.
+        /**
+         * Returns true if the bytes represent a non-directory name
+         * beginning with "META-INF/", disregarding ASCII case.
          */
-        private static boolean isMetaName(byte[] name,  int off, int len) {
-            if (len < 9 || (name[off] != 'M' && name[off] != 'm')) {  //  sizeof("META-INF/") - 1
-                return false;
-            }
-            off++;
-            for (int i = 1; i < metainf.length; i++) {
-                byte c = name[off++];
-                // Avoid toupper; it's locale-dependent
-                if (c >= 'a' && c <= 'z') {
-                    c += 'A' - 'a';
-                }
-                if (metainf[i] != c) {
-                    return false;
-                }
-            }
-            return true;
+        private static boolean isMetaName(byte[] name, int off, int len) {
+            // Use the "oldest ASCII trick in the book"
+            return len > 9                     // "META-INF/".length()
+                && name[off + len - 1] != '/'  // non-directory
+                && (name[off++] | 0x20) == 'm'
+                && (name[off++] | 0x20) == 'e'
+                && (name[off++] | 0x20) == 't'
+                && (name[off++] | 0x20) == 'a'
+                && (name[off++]       ) == '-'
+                && (name[off++] | 0x20) == 'i'
+                && (name[off++] | 0x20) == 'n'
+                && (name[off++] | 0x20) == 'f'
+                && (name[off]         ) == '/';
         }
 
-        /*
-         * Counts the number of CEN headers in a central directory extending
-         * from BEG to END.  Might return a bogus answer if the zip file is
-         * corrupt, but will not crash.
+        /**
+         * Returns the number of CEN headers in a central directory.
+         * Will not throw, even if the zip file is corrupt.
+         *
+         * @param cen copy of the bytes in a zip file's central directory
+         * @param size number of bytes in central directory
          */
-        static int countCENHeaders(byte[] cen, int end) {
+        private static int countCENHeaders(byte[] cen, int size) {
             int count = 0;
-            int pos = 0;
-            while (pos + CENHDR <= end) {
+            for (int p = 0;
+                 p + CENHDR <= size;
+                 p += CENHDR + CENNAM(cen, p) + CENEXT(cen, p) + CENCOM(cen, p))
                 count++;
-                pos += (CENHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENCOM(cen, pos));
-            }
             return count;
         }
     }
diff --git a/jdk/src/java.base/share/classes/jdk/Version.java b/jdk/src/java.base/share/classes/jdk/Version.java
deleted file mode 100644
index 8afccfb..0000000
--- a/jdk/src/java.base/share/classes/jdk/Version.java
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import sun.security.action.GetPropertyAction;
-
-/**
- * A representation of the JDK version-string which contains a version
- * number optionally followed by pre-release and build information.
- *
- * <h2><a name="verNum">Version numbers</a></h2>
- *
- * A <em>version number</em>, {@code $VNUM}, is a non-empty sequence of
- * non-negative integer numerals, without leading or trailing zeroes,
- * separated by period characters (U+002E); i.e., it matches the regular
- * expression {@code ^[1-9][0-9]*(((\.0)*\.[1-9][0-9]*)*)*$}. The sequence may
- * be of arbitrary length but the first three elements are assigned specific
- * meanings, as follows:
- *
- * <blockquote><pre>
- *     $MAJOR.$MINOR.$SECURITY
- * </pre></blockquote>
- *
- * <ul>
- *
- * <li><p> <a name="major">{@code $MAJOR}</a> --- The major version number,
- * incremented for a major release that contains significant new features as
- * specified in a new edition of the Java&#160;SE Platform Specification,
- * <em>e.g.</em>, <a href="https://jcp.org/en/jsr/detail?id=337">JSR 337</a>
- * for Java&#160;SE&#160;8. Features may be removed in a major release, given
- * advance notice at least one major release ahead of time, and incompatible
- * changes may be made when justified. The {@code $MAJOR} version number of
- * JDK&#160;8 was {@code 8}; the {@code $MAJOR} version number of JDK&#160;9
- * is {@code 9}. </p></li>
- *
- * <li><p> <a name="minor">{@code $MINOR}</a> --- The minor version number,
- * incremented for a minor update release that may contain compatible bug
- * fixes, revisions to standard APIs mandated by a <a
- * href="https://jcp.org/en/procedures/jcp2#5.3">Maintenance Release</a> of
- * the relevant Platform Specification, and implementation features outside
- * the scope of that Specification such as new JDK-specific APIs, additional
- * service providers, new garbage collectors, and ports to new hardware
- * architectures. {@code $MINOR} is reset to zero when {@code $MAJOR} is
- * incremented. </p></li>
- *
- * <li><p> <a name="security">{@code $SECURITY}</a> --- The security level,
- * incremented for a security-update release that contains critical fixes
- * including those necessary to improve security. {@code $SECURITY} is reset
- * to zero <strong>only</strong> when {@code $MAJOR} is incremented. A higher
- * value of {@code $SECURITY} for a given {@code $MAJOR} value, therefore,
- * always indicates a more secure release, regardless of the value of {@code
- * $MINOR}. </p></li>
- *
- * </ul>
- *
- * <p> The fourth and later elements of a version number are free for use by
- * downstream consumers of the JDK code base.  Such a consumer may,
- * <em>e.g.</em>, use the fourth element to identify patch releases which
- * contain a small number of critical non-security fixes in addition to the
- * security fixes in the corresponding security release. </p>
- *
- * <p> The version number does not include trailing zero elements;
- * <em>i.e.</em>, {@code $SECURITY} is omitted if it has the value zero, and
- * {@code $MINOR} is omitted if both {@code $MINOR} and {@code $SECURITY} have
- * the value zero. </p>
- *
- * <p> The sequence of numerals in a version number is compared to another
- * such sequence in numerical, pointwise fashion; <em>e.g.</em>, {@code 9.9.1}
- * is less than {@code 9.10.0}. If one sequence is shorter than another then
- * the missing elements of the shorter sequence are considered to be zero;
- * <em>e.g.</em>, {@code 9.1.2} is equal to {@code 9.1.2.0} but less than
- * {@code 9.1.2.1}. </p>
- *
- * <h2><a name="verStr">Version strings</a></h2>
- *
- * <p> A <em>version string</em> {@code $VSTR} consists of a version number
- * {@code $VNUM}, as described above, optionally followed by pre-release and
- * build information, in the format </p>
- *
- * <blockquote><pre>
- *     $VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
- * </pre></blockquote>
- *
- * <p> where: </p>
- *
- * <ul>
- *
- * <li><p> <a name="pre">{@code $PRE}</a>, matching {@code ([a-zA-Z0-9]+)} ---
- * A pre-release identifier.  Typically {@code ea}, for an early-access
- * release that's under active development and potentially unstable, or {@code
- * internal}, for an internal developer build.
- *
- * <li><p> <a name="build">{@code $BUILD}</a>, matching {@code
- * (0|[1-9][0-9]*)} --- The build number, incremented for each promoted build.
- * {@code $BUILD} is reset to {@code 1} when any portion of {@code $VNUM} is
- * incremented. </p>
- *
- * <li><p> <a name="opt">{@code $OPT}</a>, matching {@code ([-a-zA-Z0-9\.]+)}
- * --- Additional build information, if desired.  In the case of an {@code
- * internal} build this will often contain the date and time of the
- * build. </p>
- *
- * </ul>
- *
- * <p> When comparing two version strings the value of {@code $OPT}, if
- * present, may or may not be significant depending on the chosen comparison
- * method.  The comparison methods {@link #compareTo(Version) compareTo()} and
- * {@link #compareToIgnoreOpt(Version) compareToIgnoreOpt{}} should be used
- * consistently with the corresponding methods {@link #equals(Object) equals()}
- * and {@link #equalsIgnoreOpt(Object) equalsIgnoreOpt()}.  </p>
- *
- * <p> A <em>short version string</em> ({@code $SVSTR}), often useful in less
- * formal contexts, is simply {@code $VNUM} optionally ended with {@code
- * -$PRE}. </p>
- *
- * @since  9
- */
-public final class Version
-    implements Comparable<Version>
-{
-    private final List<Integer>     version;
-    private final Optional<String>  pre;
-    private final Optional<Integer> build;
-    private final Optional<String>  optional;
-
-    private static Version current;
-
-    // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)?
-    // RE limits the format of version strings
-    // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))?
-
-    private static final String VNUM
-        = "(?<VNUM>[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)";
-    private static final String VNUM_GROUP  = "VNUM";
-
-    private static final String PRE      = "(?:-(?<PRE>[a-zA-Z0-9]+))?";
-    private static final String PRE_GROUP   = "PRE";
-
-    private static final String BUILD
-        = "(?:(?<PLUS>\\+)(?<BUILD>0|[1-9][0-9]*)?)?";
-    private static final String PLUS_GROUP  = "PLUS";
-    private static final String BUILD_GROUP = "BUILD";
-
-    private static final String OPT      = "(?:-(?<OPT>[-a-zA-Z0-9.]+))?";
-    private static final String OPT_GROUP   = "OPT";
-
-    private static final String VSTR_FORMAT
-        = "^" + VNUM + PRE + BUILD + OPT + "$";
-    private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
-
-    /**
-     * Constructs a valid JDK <a href="verStr">version string</a> containing a
-     * <a href="#verNum">version number</a> followed by pre-release and build
-     * information.
-     *
-     * @param  s
-     *         A string to be interpreted as a version
-     *
-     * @throws  IllegalArgumentException
-     *          If the given string cannot be interpreted a valid version
-     *
-     * @throws  NullPointerException
-     *          If {@code s} is {@code null}
-     *
-     * @throws  NumberFormatException
-     *          If an element of the version number or the build number cannot
-     *          be represented as an {@link Integer}
-     */
-    private Version(String s) {
-        if (s == null)
-            throw new NullPointerException();
-
-        Matcher m = VSTR_PATTERN.matcher(s);
-        if (!m.matches())
-            throw new IllegalArgumentException("Invalid version string: '"
-                                               + s + "'");
-
-        // $VNUM is a dot-separated list of integers of arbitrary length
-        List<Integer> list = new ArrayList<>();
-        for (String i : m.group(VNUM_GROUP).split("\\."))
-            list.add(Integer.parseInt(i));
-        version = Collections.unmodifiableList(list);
-
-        pre = Optional.ofNullable(m.group(PRE_GROUP));
-
-        String b = m.group(BUILD_GROUP);
-        // $BUILD is an integer
-        build = (b == null)
-             ? Optional.<Integer>empty()
-             : Optional.ofNullable(Integer.parseInt(b));
-
-        optional = Optional.ofNullable(m.group(OPT_GROUP));
-
-        // empty '+'
-        if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
-            if (optional.isPresent()) {
-                if (pre.isPresent())
-                    throw new IllegalArgumentException("'+' found with"
-                        + " pre-release and optional components:'" + s + "'");
-            } else {
-                throw new IllegalArgumentException("'+' found with neither"
-                    + " build or optional components: '" + s + "'");
-            }
-        }
-    }
-
-    /**
-     * Parses the given string as a valid JDK <a
-     * href="#verStr">version string</a> containing a <a
-     * href="#verNum">version number</a> followed by pre-release and
-     * build information.
-     *
-     * @param  s
-     *         A string to interpret as a version
-     *
-     * @throws  IllegalArgumentException
-     *          If the given string cannot be interpreted a valid version
-     *
-     * @throws  NullPointerException
-     *          If the given string is {@code null}
-     *
-     * @throws  NumberFormatException
-     *          If an element of the version number or the build number cannot
-     *          be represented as an {@link Integer}
-     *
-     * @return  This version
-     */
-    public static Version parse(String s) {
-        return new Version(s);
-    }
-
-    /**
-     * Returns {@code System.getProperty("java.version")} as a Version.
-     *
-     * @throws  SecurityException
-     *          If a security manager exists and its {@link
-     *          SecurityManager#checkPropertyAccess(String)
-     *          checkPropertyAccess} method does not allow access to the
-     *          system property "java.version"
-     *
-     * @return  {@code System.getProperty("java.version")} as a Version
-     */
-    public static Version current() {
-        if (current == null) {
-            current = parse(
-                    GetPropertyAction.privilegedGetProperty("java.version"));
-        }
-        return current;
-    }
-
-    /**
-     * Returns the <a href="#major">major</a> version number.
-     *
-     * @return  The major version number
-     */
-    public int major() {
-        return version.get(0);
-    }
-
-    /**
-     * Returns the <a href="#minor">minor</a> version number or zero if it was
-     * not set.
-     *
-     * @return  The minor version number or zero if it was not set
-     */
-    public int minor() {
-        return (version.size() > 1 ? version.get(1) : 0);
-    }
-
-    /**
-     * Returns the <a href="#security">security</a> version number or zero if
-     * it was not set.
-     *
-     * @return  The security version number or zero if it was not set
-     */
-    public int security() {
-        return (version.size() > 2 ? version.get(2) : 0);
-    }
-
-    /**
-     * Returns an unmodifiable {@link java.util.List List} of the
-     * integer numerals contained in the <a href="#verNum">version
-     * number</a>.  The {@code List} always contains at least one
-     * element corresponding to the <a href="#major">major version
-     * number</a>.
-     *
-     * @return  An unmodifiable list of the integer numerals
-     *          contained in the version number
-     */
-    public List<Integer> version() {
-        return version;
-    }
-
-    /**
-     * Returns the optional <a href="#pre">pre-release</a> information.
-     *
-     * @return  The optional pre-release information as a String
-     */
-    public Optional<String> pre() {
-        return pre;
-    }
-
-    /**
-     * Returns the <a href="#build">build number</a>.
-     *
-     * @return The optional build number.
-     */
-    public Optional<Integer> build() {
-        return build;
-    }
-
-    /**
-     * Returns <a href="#opt">optional</a> additional identifying build
-     * information.
-     *
-     * @return  Additional build information as a String
-     */
-    public Optional<String> optional() {
-        return optional;
-    }
-
-    /**
-     * Compares this version to another.
-     *
-     * <p> Each of the components in the <a href="#verStr">version</a> is
-     * compared in the follow order of precedence: version numbers,
-     * pre-release identifiers, build numbers, optional build information. </p>
-     *
-     * <p> Comparison begins by examining the sequence of version numbers.  If
-     * one sequence is shorter than another, then the missing elements of the
-     * shorter sequence are considered to be zero. </p>
-     *
-     * <p> A version with a pre-release identifier is always considered to be
-     * less than a version without one.  Pre-release identifiers are compared
-     * numerically when they consist only of digits, and lexicographically
-     * otherwise.  Numeric identifiers are considered to be less than
-     * non-numeric identifiers.  </p>
-     *
-     * <p> A version without a build number is always less than one with a
-     * build number; otherwise build numbers are compared numerically. </p>
-     *
-     * <p> The optional build information is compared lexicographically.
-     * During this comparison, a version with optional build information is
-     * considered to be greater than a version without one. </p>
-     *
-     * <p> A version is not comparable to any other type of object.
-     *
-     * @param  ob
-     *         The object to be compared
-     *
-     * @return  A negative integer, zero, or a positive integer if this
-     *          {@code Version} is less than, equal to, or greater than the
-     *          given {@code Version}
-     *
-     * @throws  NullPointerException
-     *          If the given object is {@code null}
-     */
-    @Override
-    public int compareTo(Version ob) {
-        return compare(ob, false);
-    }
-
-    /**
-     * Compares this version to another disregarding optional build
-     * information.
-     *
-     * <p> Two versions are compared by examining the version string as
-     * described in {@link #compareTo(Version)} with the exception that the
-     * optional build information is always ignored. </p>
-     *
-     * <p> A version is not comparable to any other type of object.
-     *
-     * @param  ob
-     *         The object to be compared
-     *
-     * @return  A negative integer, zero, or a positive integer if this
-     *          {@code Version} is less than, equal to, or greater than the
-     *          given {@code Version}
-     *
-     * @throws  NullPointerException
-     *          If the given object is {@code null}
-     */
-    public int compareToIgnoreOpt(Version ob) {
-        return compare(ob, true);
-    }
-
-    private int compare(Version ob, boolean ignoreOpt) {
-        if (ob == null)
-            throw new NullPointerException("Invalid argument");
-
-        int ret = compareVersion(ob);
-        if (ret != 0)
-            return ret;
-
-        ret = comparePre(ob);
-        if (ret != 0)
-            return ret;
-
-        ret = compareBuild(ob);
-        if (ret != 0)
-            return ret;
-
-        if (!ignoreOpt)
-            return compareOpt(ob);
-
-        return 0;
-    }
-
-    private int compareVersion(Version ob) {
-        int size = version.size();
-        int oSize = ob.version().size();
-        int min = Math.min(size, oSize);
-        for (int i = 0; i < min; i++) {
-            Integer val = version.get(i);
-            Integer oVal = ob.version().get(i);
-            if (val != oVal)
-                return val - oVal;
-        }
-        if (size != oSize)
-            return size - oSize;
-        return 0;
-    }
-
-    private int comparePre(Version ob) {
-        Optional<String> oPre = ob.pre();
-        if (!pre.isPresent()) {
-            if (oPre.isPresent())
-                return 1;
-        } else {
-            if (!oPre.isPresent())
-                return -1;
-            String val = pre.get();
-            String oVal = oPre.get();
-            if (val.matches("\\d+")) {
-                return (oVal.matches("\\d+")
-                        ? (new BigInteger(val)).compareTo(new BigInteger(oVal))
-                        : -1);
-            } else {
-                return (oVal.matches("\\d+")
-                        ? 1
-                        : val.compareTo(oVal));
-            }
-        }
-        return 0;
-    }
-
-    private int compareBuild(Version ob) {
-        Optional<Integer> oBuild = ob.build();
-        if (oBuild.isPresent()) {
-            return (build.isPresent()
-                   ? build.get().compareTo(oBuild.get())
-                   : 1);
-        } else if (build.isPresent()) {
-            return -1;
-        }
-        return 0;
-    }
-
-    private int compareOpt(Version ob) {
-        Optional<String> oOpt = ob.optional();
-        if (!optional.isPresent()) {
-            if (oOpt.isPresent())
-                return -1;
-        } else {
-            if (!oOpt.isPresent())
-                return 1;
-            return optional.get().compareTo(oOpt.get());
-        }
-        return 0;
-    }
-
-    /**
-     * Returns a string representation of this version.
-     *
-     * @return  The version string
-     */
-    @Override
-    public String toString() {
-        StringBuilder sb
-            = new StringBuilder(version.stream()
-                                .map(Object::toString)
-                                .collect(Collectors.joining(".")));
-        pre.ifPresent(v -> sb.append("-").append(v));
-
-        if (build.isPresent()) {
-            sb.append("+").append(build.get());
-            if (optional.isPresent())
-                sb.append("-").append(optional.get());
-        } else {
-            if (optional.isPresent()) {
-                sb.append(pre.isPresent() ? "-" : "+-");
-                sb.append(optional.get());
-            }
-        }
-
-        return sb.toString();
-    }
-
-    /**
-     * Determines whether this {@code Version} is equal to another object.
-     *
-     * <p> Two {@code Version}s are equal if and only if they represent the
-     * same version string.
-     *
-     * <p> This method satisfies the general contract of the {@link
-     * Object#equals(Object) Object.equals} method. </p>
-     *
-     * @param  ob
-     *         The object to which this {@code Version} is to be compared
-     *
-     * @return  {@code true} if, and only if, the given object is a {@code
-     *          Version} that is identical to this {@code Version}
-     *
-     */
-    @Override
-    public boolean equals(Object ob) {
-        boolean ret = equalsIgnoreOpt(ob);
-        if (!ret)
-            return false;
-
-        Version that = (Version)ob;
-        return (this.optional().equals(that.optional()));
-    }
-
-    /**
-     * Determines whether this {@code Version} is equal to another
-     * disregarding optional build information.
-     *
-     * <p> Two {@code Version}s are equal if and only if they represent the
-     * same version string disregarding the optional build information.
-     *
-     * @param  ob
-     *         The object to which this {@code Version} is to be compared
-     *
-     * @return  {@code true} if, and only if, the given object is a {@code
-     *          Version} that is identical to this {@code Version}
-     *          ignoring the optinal build information
-     *
-     */
-    public boolean equalsIgnoreOpt(Object ob) {
-        if (this == ob)
-            return true;
-        if (!(ob instanceof Version))
-            return false;
-
-        Version that = (Version)ob;
-        return (this.version().equals(that.version())
-                && this.pre().equals(that.pre())
-                && this.build().equals(that.build()));
-    }
-
-    /**
-     * Returns the hash code of this version.
-     *
-     * <p> This method satisfies the general contract of the {@link
-     * Object#hashCode Object.hashCode} method.
-     *
-     * @return  The hashcode of this version
-     */
-    @Override
-    public int hashCode() {
-        int h = 1;
-        int p = 17;
-
-        h = p * h + version.hashCode();
-        h = p * h + pre.hashCode();
-        h = p * h + build.hashCode();
-        h = p * h + optional.hashCode();
-
-        return h;
-    }
-}
diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
index 9b21fb6..68b0767 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
@@ -27,6 +27,8 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.IntBuffer;
@@ -98,8 +100,34 @@
         }
 
         // Open the file only if no memory map yet or is 32 bit jvm
-        channel = map != null && MAP_ALL ? null :
-                  FileChannel.open(imagePath, StandardOpenOption.READ);
+        if (map != null && MAP_ALL) {
+            channel = null;
+        } else {
+            channel = FileChannel.open(imagePath, StandardOpenOption.READ);
+            // No lambdas during bootstrap
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                @Override
+                public Void run() {
+                    if (BasicImageReader.class.getClassLoader() == null) {
+                        try {
+                            Class<?> fileChannelImpl =
+                                Class.forName("sun.nio.ch.FileChannelImpl");
+                            Method setUninterruptible =
+                                    fileChannelImpl.getMethod("setUninterruptible");
+                            setUninterruptible.invoke(channel);
+                        } catch (ClassNotFoundException |
+                                 NoSuchMethodException |
+                                 IllegalAccessException |
+                                 InvocationTargetException ex) {
+                            // fall thru - will only happen on JDK-8 systems where this code
+                            // is only used by tools using jrt-fs (non-critical.)
+                        }
+                    }
+
+                    return null;
+                }
+            });
+        }
 
         // If no memory map yet and 64 bit jvm then memory map entire file
         if (MAP_ALL && map == null) {
diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java
index 2c78ea9..a747ea8 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java
@@ -149,6 +149,17 @@
         return reader.getEntryNames();
     }
 
+    public String[] getModuleNames() {
+        Objects.requireNonNull(reader, "image file closed");
+        int off = "/modules/".length();
+        return reader.findNode("/modules")
+                     .getChildren()
+                     .stream()
+                     .map(Node::getNameString)
+                     .map(s -> s.substring(off, s.length()))
+                     .toArray(String[]::new);
+    }
+
     public long[] getAttributes(int offset) {
         Objects.requireNonNull(reader, "image file closed");
         return reader.getAttributes(offset);
diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
index 7a94609..bc2396f 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
@@ -68,13 +68,14 @@
         if (s != null && s.length() > 0)
             bcp = toURLClassPath(s);
 
-        // we have a class path if -cp is specified or -m is not specified
+        // we have a class path if -cp is specified or -m is not specified.
+        // If neither is specified then default to -cp <working directory>.
         URLClassPath ucp = null;
         String mainMid = System.getProperty("jdk.module.main");
         String cp = System.getProperty("java.class.path");
-        if (mainMid == null && (cp == null || cp.length() == 0))
-            cp = ".";
-        if (cp != null && cp.length() > 0)
+        if (mainMid == null && cp == null)
+            cp = "";
+        if (cp != null)
             ucp = toURLClassPath(cp);
 
 
@@ -197,7 +198,7 @@
          * @see java.lang.instrument.Instrumentation#appendToSystemClassLoaderSearch
          */
         void appendToClassPathForInstrumentation(String path) {
-            appendToUCP(path, ucp);
+            addClassPathToUCP(path, ucp);
         }
 
         /**
@@ -224,7 +225,7 @@
      */
     private static URLClassPath toURLClassPath(String cp) {
         URLClassPath ucp = new URLClassPath(new URL[0]);
-        appendToUCP(cp, ucp);
+        addClassPathToUCP(cp, ucp);
         return ucp;
     }
 
@@ -232,20 +233,28 @@
      * Converts the elements in the given class path to file URLs and adds
      * them to the given URLClassPath.
      */
-    private static void appendToUCP(String cp, URLClassPath ucp) {
-        String[] elements = cp.split(File.pathSeparator);
-        if (elements.length == 0) {
-            // contains path separator(s) only, default to current directory
-            // to be compatible with long standing behavior
-            elements = new String[] { "" };
+    private static void addClassPathToUCP(String cp, URLClassPath ucp) {
+        int off = 0;
+        int next;
+        while ((next = cp.indexOf(File.pathSeparator, off)) != -1) {
+            addURLToUCP(cp.substring(off, next), ucp);
+            off = next + 1;
         }
-        for (String s: elements) {
-            try {
-                URL url = Paths.get(s).toRealPath().toUri().toURL();
-                ucp.addURL(url);
-            } catch (InvalidPathException | IOException ignore) {
-                // malformed path string or class path element does not exist
-            }
+
+        // remaining
+        addURLToUCP(cp.substring(off), ucp);
+    }
+
+    /**
+     * Attempts to convert to the given string to a file URL and adds it
+     * to the given URLClassPath.
+     */
+    private static void addURLToUCP(String s, URLClassPath ucp) {
+        try {
+            URL url = Paths.get(s).toRealPath().toUri().toURL();
+            ucp.addURL(url);
+        } catch (InvalidPathException | IOException ignore) {
+            // malformed path string or class path element does not exist
         }
     }
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaIORandomAccessFileAccess.java
similarity index 82%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to jdk/src/java.base/share/classes/jdk/internal/misc/JavaIORandomAccessFileAccess.java
index 9e5a4a7..db15bac 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaIORandomAccessFileAccess.java
@@ -22,16 +22,14 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
 
-import java.util.Properties;
+package jdk.internal.misc;
 
-/**
- * Interface to plugin (container) context.
- */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+public interface JavaIORandomAccessFileAccess {
+    public RandomAccessFile openAndDelete(File file, String mode)
+        throws IOException;
 }
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
index 24dc4ce..5e3fb12 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
@@ -30,6 +30,7 @@
 import java.io.Console;
 import java.io.FileDescriptor;
 import java.io.ObjectInputStream;
+import java.io.RandomAccessFile;
 import java.security.ProtectionDomain;
 import java.security.AccessController;
 
@@ -64,6 +65,7 @@
     private static JavaAWTFontAccess javaAWTFontAccess;
     private static JavaBeansAccess javaBeansAccess;
     private static JavaObjectInputStreamAccess javaObjectInputStreamAccess;
+    private static JavaIORandomAccessFileAccess javaIORandomAccessFileAccess;
 
     public static JavaUtilJarAccess javaUtilJarAccess() {
         if (javaUtilJarAccess == null) {
@@ -274,4 +276,15 @@
     public static void setJavaObjectInputStreamAccess(JavaObjectInputStreamAccess access) {
         javaObjectInputStreamAccess = access;
     }
+
+    public static void setJavaIORandomAccessFileAccess(JavaIORandomAccessFileAccess jirafa) {
+        javaIORandomAccessFileAccess = jirafa;
+    }
+
+    public static JavaIORandomAccessFileAccess getJavaIORandomAccessFileAccess() {
+        if (javaIORandomAccessFileAccess == null) {
+            unsafe.ensureClassInitialized(RandomAccessFile.class);
+        }
+        return javaIORandomAccessFileAccess;
+    }
 }
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
index 735d1b8..bc7aaa5 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
@@ -33,6 +33,7 @@
 import jdk.internal.misc.VM;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.vm.annotation.ForceInline;
 
 
 /**
@@ -209,46 +210,103 @@
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native boolean getBoolean(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putBoolean(Object o, long offset, boolean x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native byte    getByte(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putByte(Object o, long offset, byte x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native short   getShort(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putShort(Object o, long offset, short x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native char    getChar(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putChar(Object o, long offset, char x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native long    getLong(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putLong(Object o, long offset, long x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native float   getFloat(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putFloat(Object o, long offset, float x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native double  getDouble(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putDouble(Object o, long offset, double x);
 
+    /**
+     * Fetches a native pointer from a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p>If the native pointer is less than 64 bits wide, it is extended as
+     * an unsigned number to a Java long.  The pointer may be indexed by any
+     * given byte offset, simply by adding that offset (as a simple integer) to
+     * the long representing the pointer.  The number of bytes actually read
+     * from the target address may be determined by consulting {@link
+     * #addressSize}.
+     *
+     * @see #allocateMemory
+     * @see #getInt(Object, long)
+     */
+    @ForceInline
+    public long getAddress(Object o, long offset) {
+        if (ADDRESS_SIZE == 4) {
+            return Integer.toUnsignedLong(getInt(o, offset));
+        } else {
+            return getLong(o, offset);
+        }
+    }
+
+    /**
+     * Stores a native pointer into a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p>The number of bytes actually written at the target address may be
+     * determined by consulting {@link #addressSize}.
+     *
+     * @see #allocateMemory
+     * @see #putInt(Object, long, int)
+     */
+    @ForceInline
+    public void putAddress(Object o, long offset, long x) {
+        if (ADDRESS_SIZE == 4) {
+            putInt(o, offset, (int)x);
+        } else {
+            putLong(o, offset, x);
+        }
+    }
+
     // These read VM internal data.
 
     /**
@@ -287,8 +345,10 @@
      *
      * @see #allocateMemory
      */
-    @HotSpotIntrinsicCandidate
-    public native byte    getByte(long address);
+    @ForceInline
+    public byte getByte(long address) {
+        return getByte(null, address);
+    }
 
     /**
      * Stores a value into a given memory address.  If the address is zero, or
@@ -297,75 +357,94 @@
      *
      * @see #getByte(long)
      */
-    @HotSpotIntrinsicCandidate
-    public native void    putByte(long address, byte x);
+    @ForceInline
+    public void putByte(long address, byte x) {
+        putByte(null, address, x);
+    }
 
     /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native short   getShort(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putShort(long address, short x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native char    getChar(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putChar(long address, char x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native int     getInt(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putInt(long address, int x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native long    getLong(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putLong(long address, long x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native float   getFloat(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putFloat(long address, float x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native double  getDouble(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putDouble(long address, double x);
+    @ForceInline
+    public short getShort(long address) {
+        return getShort(null, address);
+    }
 
-    /**
-     * Fetches a native pointer from a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p>If the native pointer is less than 64 bits wide, it is extended as
-     * an unsigned number to a Java long.  The pointer may be indexed by any
-     * given byte offset, simply by adding that offset (as a simple integer) to
-     * the long representing the pointer.  The number of bytes actually read
-     * from the target address may be determined by consulting {@link
-     * #addressSize}.
-     *
-     * @see #allocateMemory
-     */
-    @HotSpotIntrinsicCandidate
-    public native long getAddress(long address);
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putShort(long address, short x) {
+        putShort(null, address, x);
+    }
 
-    /**
-     * Stores a native pointer into a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p>The number of bytes actually written at the target address may be
-     * determined by consulting {@link #addressSize}.
-     *
-     * @see #getAddress(long)
-     */
-    @HotSpotIntrinsicCandidate
-    public native void putAddress(long address, long x);
+    /** @see #getByte(long) */
+    @ForceInline
+    public char getChar(long address) {
+        return getChar(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putChar(long address, char x) {
+        putChar(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public int getInt(long address) {
+        return getInt(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putInt(long address, int x) {
+        putInt(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public long getLong(long address) {
+        return getLong(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putLong(long address, long x) {
+        putLong(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public float getFloat(long address) {
+        return getFloat(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putFloat(long address, float x) {
+        putFloat(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public double getDouble(long address) {
+        return getDouble(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putDouble(long address, double x) {
+        putDouble(null, address, x);
+    }
+
+    /** @see #getAddress(Object, long) */
+    @ForceInline
+    public long getAddress(long address) {
+        return getAddress(null, address);
+    }
+
+    /** @see #putAddress(Object, long, long) */
+    @ForceInline
+    public void putAddress(long address, long x) {
+        putAddress(null, address, x);
+    }
 
 
 
@@ -1271,6 +1350,13 @@
         return compareAndSwapObject(o, offset, expected, x);
     }
 
+    @HotSpotIntrinsicCandidate
+    public final boolean weakCompareAndSwapObjectVolatile(Object o, long offset,
+                                                                Object expected,
+                                                                Object x) {
+        return compareAndSwapObject(o, offset, expected, x);
+    }
+
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
@@ -1325,6 +1411,13 @@
         return compareAndSwapInt(o, offset, expected, x);
     }
 
+    @HotSpotIntrinsicCandidate
+    public final boolean weakCompareAndSwapIntVolatile(Object o, long offset,
+                                                             int expected,
+                                                             int x) {
+        return compareAndSwapInt(o, offset, expected, x);
+    }
+
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
@@ -1379,6 +1472,13 @@
         return compareAndSwapLong(o, offset, expected, x);
     }
 
+    @HotSpotIntrinsicCandidate
+    public final boolean weakCompareAndSwapLongVolatile(Object o, long offset,
+                                                              long expected,
+                                                              long x) {
+        return compareAndSwapLong(o, offset, expected, x);
+    }
+
     /**
      * Fetches a reference value from a given Java variable, with volatile
      * load semantics. Otherwise identical to {@link #getObject(Object, long)}
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
index f2f7e02..52d9512 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
@@ -341,7 +341,7 @@
         // resolve all root modules
         Configuration cf = Configuration.empty()
                 .resolveRequires(finder,
-                                 ModuleFinder.empty(),
+                                 ModuleFinder.of(),
                                  roots);
 
         // module name -> reference
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java
index 1fb433b..c86416e 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java
@@ -54,7 +54,7 @@
         ClassWriter cw = new ClassWriter(0);
 
         String name = md.name().replace('.', '/') + "/module-info";
-        cw.visit(Opcodes.V1_8, ACC_MODULE, name, null, null, null);
+        cw.visit(Opcodes.V1_9, ACC_MODULE, name, null, null, null);
 
         cw.visitAttribute(new ModuleAttribute(md));
         cw.visitAttribute(new ConcealedPackagesAttribute(md.conceals()));
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java
index 43de2cd..78619f0 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java
@@ -46,12 +46,12 @@
      * and read module-info.class from the run-time image instead of
      * the fastpath.
      */
-    public static final String[] MODULE_NAMES = new String[1];
+    public static final String[] MODULE_NAMES = new String[0];
 
     /**
      * Hash of system modules.
      */
-    public static String[] MODULES_TO_HASH = new String[1];
+    public static String[] MODULES_TO_HASH = new String[0];
 
     /**
      * Number of packages in the boot layer from the installed modules.
@@ -67,7 +67,7 @@
      * When running an exploded image it returns an empty array.
      */
     public static ModuleDescriptor[] modules() {
-        return new ModuleDescriptor[0];
+        throw new InternalError("should not reach here");
     }
 
 }
diff --git a/jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java b/jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java
new file mode 100644
index 0000000..cb1b748
--- /dev/null
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.internal.util;
+
+import jdk.internal.HotSpotIntrinsicCandidate;
+
+import java.util.List;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+/**
+ * Utility methods to check if state or arguments are correct.
+ *
+ */
+public class Preconditions {
+
+    /**
+     * Maps out-of-bounds values to a runtime exception.
+     *
+     * @param checkKind the kind of bounds check, whose name may correspond
+     *        to the name of one of the range check methods, checkIndex,
+     *        checkFromToIndex, checkFromIndexSize
+     * @param args the out-of-bounds arguments that failed the range check.
+     *        If the checkKind corresponds a the name of a range check method
+     *        then the bounds arguments are those that can be passed in order
+     *        to the method.
+     * @param oobef the exception formatter that when applied with a checkKind
+     *        and a list out-of-bounds arguments returns a runtime exception.
+     *        If {@code null} then, it is as if an exception formatter was
+     *        supplied that returns {@link IndexOutOfBoundsException} for any
+     *        given arguments.
+     * @return the runtime exception
+     */
+    private static RuntimeException outOfBounds(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobef,
+            String checkKind,
+            Integer... args) {
+        List<Integer> largs = List.of(args);
+        RuntimeException e = oobef == null
+                             ? null : oobef.apply(checkKind, largs);
+        return e == null
+               ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e;
+    }
+
+    private static RuntimeException outOfBoundsCheckIndex(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+            int index, int length) {
+        return outOfBounds(oobe, "checkIndex", index, length);
+    }
+
+    private static RuntimeException outOfBoundsCheckFromToIndex(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+            int fromIndex, int toIndex, int length) {
+        return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length);
+    }
+
+    private static RuntimeException outOfBoundsCheckFromIndexSize(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+            int fromIndex, int size, int length) {
+        return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length);
+    }
+
+    /**
+     * Returns an out-of-bounds exception formatter from an given exception
+     * factory.  The exception formatter is a function that formats an
+     * out-of-bounds message from its arguments and applies that message to the
+     * given exception factory to produce and relay an exception.
+     *
+     * <p>The exception formatter accepts two arguments: a {@code String}
+     * describing the out-of-bounds range check that failed, referred to as the
+     * <em>check kind</em>; and a {@code List<Integer>} containing the
+     * out-of-bound integer values that failed the check.  The list of
+     * out-of-bound values is not modified.
+     *
+     * <p>Three check kinds are supported {@code checkIndex},
+     * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding
+     * respectively to the specified application of an exception formatter as an
+     * argument to the out-of-bounds range check methods
+     * {@link #checkIndex(int, int, BiFunction) checkIndex},
+     * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and
+     * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}.
+     * Thus a supported check kind corresponds to a method name and the
+     * out-of-bound integer values correspond to method argument values, in
+     * order, preceding the exception formatter argument (similar in many
+     * respects to the form of arguments required for a reflective invocation of
+     * such a range check method).
+     *
+     * <p>Formatter arguments conforming to such supported check kinds will
+     * produce specific exception messages describing failed out-of-bounds
+     * checks.  Otherwise, more generic exception messages will be produced in
+     * any of the following cases: the check kind is supported but fewer
+     * or more out-of-bounds values are supplied, the check kind is not
+     * supported, the check kind is {@code null}, or the list of out-of-bound
+     * values is {@code null}.
+     *
+     * @apiNote
+     * This method produces an out-of-bounds exception formatter that can be
+     * passed as an argument to any of the supported out-of-bounds range check
+     * methods declared by {@code Objects}.  For example, a formatter producing
+     * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a
+     * {@code static final} field as follows:
+     * <pre>{@code
+     * static final
+     * BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException> AIOOBEF =
+     *     outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
+     * }</pre>
+     * The formatter instance {@code AIOOBEF} may be passed as an argument to an
+     * out-of-bounds range check method, such as checking if an {@code index}
+     * is within the bounds of a {@code limit}:
+     * <pre>{@code
+     * checkIndex(index, limit, AIOOBEF);
+     * }</pre>
+     * If the bounds check fails then the range check method will throw an
+     * {@code ArrayIndexOutOfBoundsException} with an appropriate exception
+     * message that is a produced from {@code AIOOBEF} as follows:
+     * <pre>{@code
+     * AIOOBEF.apply("checkIndex", List.of(index, limit));
+     * }</pre>
+     *
+     * @param f the exception factory, that produces an exception from a message
+     *        where the message is produced and formatted by the returned
+     *        exception formatter.  If this factory is stateless and side-effect
+     *        free then so is the returned formatter.
+     *        Exceptions thrown by the factory are relayed to the caller
+     *        of the returned formatter.
+     * @param <X> the type of runtime exception to be returned by the given
+     *        exception factory and relayed by the exception formatter
+     * @return the out-of-bounds exception formatter
+     */
+    public static <X extends RuntimeException>
+    BiFunction<String, List<Integer>, X> outOfBoundsExceptionFormatter(Function<String, X> f) {
+        // Use anonymous class to avoid bootstrap issues if this method is
+        // used early in startup
+        return new BiFunction<String, List<Integer>, X>() {
+            @Override
+            public X apply(String checkKind, List<Integer> args) {
+                return f.apply(outOfBoundsMessage(checkKind, args));
+            }
+        };
+    }
+
+    private static String outOfBoundsMessage(String checkKind, List<Integer> args) {
+        if (checkKind == null && args == null) {
+            return String.format("Range check failed");
+        } else if (checkKind == null) {
+            return String.format("Range check failed: %s", args);
+        } else if (args == null) {
+            return String.format("Range check failed: %s", checkKind);
+        }
+
+        int argSize = 0;
+        switch (checkKind) {
+            case "checkIndex":
+                argSize = 2;
+                break;
+            case "checkFromToIndex":
+            case "checkFromIndexSize":
+                argSize = 3;
+                break;
+            default:
+        }
+
+        // Switch to default if fewer or more arguments than required are supplied
+        switch ((args.size() != argSize) ? "" : checkKind) {
+            case "checkIndex":
+                return String.format("Index %d out-of-bounds for length %d",
+                                     args.get(0), args.get(1));
+            case "checkFromToIndex":
+                return String.format("Range [%d, %d) out-of-bounds for length %d",
+                                     args.get(0), args.get(1), args.get(2));
+            case "checkFromIndexSize":
+                return String.format("Range [%d, %<d + %d) out-of-bounds for length %d",
+                                     args.get(0), args.get(1), args.get(2));
+            default:
+                return String.format("Range check failed: %s %s", checkKind, args);
+        }
+    }
+
+    /**
+     * Checks if the {@code index} is within the bounds of the range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The {@code index} is defined to be out-of-bounds if any of the
+     * following inequalities is true:
+     * <ul>
+     *  <li>{@code index < 0}</li>
+     *  <li>{@code index >= length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the {@code index} is out-of-bounds, then a runtime exception is
+     * thrown that is the result of applying the following arguments to the
+     * exception formatter: the name of this method, {@code checkIndex};
+     * and an unmodifiable list integers whose values are, in order, the
+     * out-of-bounds arguments {@code index} and {@code length}.
+     *
+     * @param <X> the type of runtime exception to throw if the arguments are
+     *        out-of-bounds
+     * @param index the index
+     * @param length the upper-bound (exclusive) of the range
+     * @param oobef the exception formatter that when applied with this
+     *        method name and out-of-bounds arguments returns a runtime
+     *        exception.  If {@code null} or returns {@code null} then, it is as
+     *        if an exception formatter produced from an invocation of
+     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+     *        instead (though it may be more efficient).
+     *        Exceptions thrown by the formatter are relayed to the caller.
+     * @return {@code index} if it is within bounds of the range
+     * @throws X if the {@code index} is out-of-bounds and the exception
+     *         formatter is non-{@code null}
+     * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
+     *         and the exception formatter is {@code null}
+     * @since 9
+     *
+     * @implNote
+     * This method is made intrinsic in optimizing compilers to guide them to
+     * perform unsigned comparisons of the index and length when it is known the
+     * length is a non-negative value (such as that of an array length or from
+     * the upper bound of a loop)
+    */
+    @HotSpotIntrinsicCandidate
+    public static <X extends RuntimeException>
+    int checkIndex(int index, int length,
+                   BiFunction<String, List<Integer>, X> oobef) {
+        if (index < 0 || index >= length)
+            throw outOfBoundsCheckIndex(oobef, index, length);
+        return index;
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
+     * (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out-of-bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code fromIndex > toIndex}</li>
+     *  <li>{@code toIndex > length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
+     * thrown that is the result of applying the following arguments to the
+     * exception formatter: the name of this method, {@code checkFromToIndex};
+     * and an unmodifiable list integers whose values are, in order, the
+     * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}.
+     *
+     * @param <X> the type of runtime exception to throw if the arguments are
+     *        out-of-bounds
+     * @param fromIndex the lower-bound (inclusive) of the sub-range
+     * @param toIndex the upper-bound (exclusive) of the sub-range
+     * @param length the upper-bound (exclusive) the range
+     * @param oobef the exception formatter that when applied with this
+     *        method name and out-of-bounds arguments returns a runtime
+     *        exception.  If {@code null} or returns {@code null} then, it is as
+     *        if an exception formatter produced from an invocation of
+     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+     *        instead (though it may be more efficient).
+     *        Exceptions thrown by the formatter are relayed to the caller.
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws X if the sub-range is out-of-bounds and the exception factory
+     *         function is non-{@code null}
+     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+     *         the exception factory function is {@code null}
+     * @since 9
+     */
+    public static <X extends RuntimeException>
+    int checkFromToIndex(int fromIndex, int toIndex, int length,
+                         BiFunction<String, List<Integer>, X> oobef) {
+        if (fromIndex < 0 || fromIndex > toIndex || toIndex > length)
+            throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length);
+        return fromIndex;
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code fromIndex + size} (exclusive) is within the bounds of range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out-of-bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code size < 0}</li>
+     *  <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
+     * thrown that is the result of applying the following arguments to the
+     * exception formatter: the name of this method, {@code checkFromIndexSize};
+     * and an unmodifiable list integers whose values are, in order, the
+     * out-of-bounds arguments {@code fromIndex}, {@code size}, and
+     * {@code length}.
+     *
+     * @param <X> the type of runtime exception to throw if the arguments are
+     *        out-of-bounds
+     * @param fromIndex the lower-bound (inclusive) of the sub-interval
+     * @param size the size of the sub-range
+     * @param length the upper-bound (exclusive) of the range
+     * @param oobef the exception formatter that when applied with this
+     *        method name and out-of-bounds arguments returns a runtime
+     *        exception.  If {@code null} or returns {@code null} then, it is as
+     *        if an exception formatter produced from an invocation of
+     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+     *        instead (though it may be more efficient).
+     *        Exceptions thrown by the formatter are relayed to the caller.
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws X if the sub-range is out-of-bounds and the exception factory
+     *         function is non-{@code null}
+     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+     *         the exception factory function is {@code null}
+     * @since 9
+     */
+    public static <X extends RuntimeException>
+    int checkFromIndexSize(int fromIndex, int size, int length,
+                           BiFunction<String, List<Integer>, X> oobef) {
+        if ((length | fromIndex | size) < 0 || size > length - fromIndex)
+            throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length);
+        return fromIndex;
+    }
+}
diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java
index 9d9fe8e..a1b1333 100644
--- a/jdk/src/java.base/share/classes/module-info.java
+++ b/jdk/src/java.base/share/classes/module-info.java
@@ -81,9 +81,6 @@
     exports javax.security.auth.x500;
     exports javax.security.cert;
 
-    // see JDK-8144062
-    exports jdk;
-
 
     // the service types defined by the APIs in this module
 
diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
index 6390b97..32aa8ec 100644
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
@@ -100,7 +100,6 @@
 \    -Xdiag            show additional diagnostic messages\n\
 \    -Xdiag:resolver   show resolver diagnostic messages\n\
 \    -Xnoclassgc       disable class garbage collection\n\
-\    -Xincgc           enable incremental garbage collection\n\
 \    -Xloggc:<file>    log GC status to a file with time stamps\n\
 \    -Xbatch           disable background compilation\n\
 \    -Xms<size>        set initial Java heap size\n\
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
index deefc85..df9364a1 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
@@ -40,7 +40,6 @@
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.WritableByteChannel;
-import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -83,6 +82,9 @@
     // Lock for operations involving position and size
     private final Object positionLock = new Object();
 
+    // Positional-read is not interruptible
+    private volatile boolean uninterruptible;
+
     private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
                             boolean writable, Object parent)
     {
@@ -108,6 +110,10 @@
             throw new ClosedChannelException();
     }
 
+    public void setUninterruptible() {
+        uninterruptible = true;
+    }
+
     // -- Standard channel operations --
 
     protected void implCloseChannel() throws IOException {
@@ -733,8 +739,10 @@
         assert !nd.needsPositionLock() || Thread.holdsLock(positionLock);
         int n = 0;
         int ti = -1;
+
+        boolean interruptible = !uninterruptible;
         try {
-            begin();
+            if (interruptible) begin();
             ti = threads.add();
             if (!isOpen())
                 return -1;
@@ -744,7 +752,7 @@
             return IOStatus.normalize(n);
         } finally {
             threads.remove(ti);
-            end(n > 0);
+            if (interruptible) end(n > 0);
             assert IOStatus.check(n);
         }
     }
diff --git a/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java b/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java
index 9082670..971c493 100644
--- a/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java
+++ b/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java
@@ -650,12 +650,29 @@
         }
     }
 
+    /* Defined Groups for jdk.security.provider.preferred */
+    private static final String SHA2Group[] = { "SHA-224", "SHA-256",
+            "SHA-384", "SHA-512", "SHA-512/224", "SHA-512/256" };
+    private static final String HmacSHA2Group[] = { "HmacSHA224",
+            "HmacSHA256", "HmacSHA384", "HmacSHA512"};
+    private static final String SHA2RSAGroup[] = { "SHA224withRSA",
+            "SHA256withRSA", "SHA384withRSA", "SHA512withRSA"};
+    private static final String SHA2DSAGroup[] = { "SHA224withDSA",
+            "SHA256withDSA", "SHA384withDSA", "SHA512withDSA"};
+    private static final String SHA2ECDSAGroup[] = { "SHA224withECDSA",
+            "SHA256withECDSA", "SHA384withECDSA", "SHA512withECDSA"};
+    private static final String SHA3Group[] = { "SHA3-224", "SHA3-256",
+            "SHA3-384", "SHA3-512" };
+    private static final String HmacSHA3Group[] = { "HmacSHA3-224",
+            "HmacSHA3-256", "HmacSHA3-384", "HmacSHA3-512"};
+
     // Individual preferred property entry from jdk.security.provider.preferred
-    private class PreferredEntry {
-        String type = null;
-        String algorithm;
-        String provider;
-        String alternateName = null;
+    private static class PreferredEntry {
+        private String type = null;
+        private String algorithm;
+        private String provider;
+        private String alternateNames[] = null;
+        private boolean group = false;
 
         PreferredEntry(String t, String p) {
             int i = t.indexOf('.');
@@ -667,47 +684,83 @@
             }
 
             provider = p;
-            if (algorithm.compareToIgnoreCase("SHA1") == 0) {
-                alternateName = "SHA-1";
+            // Group definitions
+            if (type != null && type.compareToIgnoreCase("Group") == 0) {
+                // Currently intrinsic algorithm groups
+                if (algorithm.compareToIgnoreCase("SHA2") == 0) {
+                    alternateNames = SHA2Group;
+                } else if (algorithm.compareToIgnoreCase("HmacSHA2") == 0) {
+                    alternateNames = HmacSHA2Group;
+                } else if (algorithm.compareToIgnoreCase("SHA2RSA") == 0) {
+                    alternateNames = SHA2RSAGroup;
+                } else if (algorithm.compareToIgnoreCase("SHA2DSA") == 0) {
+                    alternateNames = SHA2DSAGroup;
+                } else if (algorithm.compareToIgnoreCase("SHA2ECDSA") == 0) {
+                    alternateNames = SHA2ECDSAGroup;
+                } else if (algorithm.compareToIgnoreCase("SHA3") == 0) {
+                    alternateNames = SHA3Group;
+                } else if (algorithm.compareToIgnoreCase("HmacSHA3") == 0) {
+                    alternateNames = HmacSHA3Group;
+                }
+                if (alternateNames != null) {
+                    group = true;
+                }
+
+            // If the algorithm name given is SHA1
+            } else if (algorithm.compareToIgnoreCase("SHA1") == 0) {
+                alternateNames = new String[] { "SHA-1" };
             } else if (algorithm.compareToIgnoreCase("SHA-1") == 0) {
-                alternateName = "SHA1";
+                alternateNames = new String[] { "SHA1" };
             }
         }
 
         boolean match(String t, String a) {
             if (debug != null) {
-                debug.println("Config match:  " + toString() + " == [" + t +
-                        ", " + a + "]");
+                debug.println("Config check:  " + toString() + " == " +
+                        print(t, a, null));
             }
 
             // Compare service type if configured
-            if (type != null && type.compareToIgnoreCase(t) != 0) {
+            if (type != null && !group && type.compareToIgnoreCase(t) != 0) {
                 return false;
             }
 
             // Compare the algorithm string.
-            if (a.compareToIgnoreCase(algorithm) == 0) {
+            if (!group && a.compareToIgnoreCase(algorithm) == 0) {
                 if (debug != null) {
-                    debug.println("Config entry found:  " + toString());
+                    debug.println("Config entry matched:  " + toString());
                 }
                 return true;
             }
 
-            if (alternateName != null &&
-                    a.compareToIgnoreCase(alternateName) == 0) {
-                if (debug != null) {
-                    debug.println("Config entry found (alternateName):  " +
-                            toString());
+            if (alternateNames != null) {
+                for (String alt : alternateNames) {
+                    if (debug != null) {
+                        debug.println("AltName check:  " + print(type, alt,
+                                provider));
+                    }
+                    if (a.compareToIgnoreCase(alt) == 0) {
+                        if (debug != null) {
+                            debug.println("AltName entry matched:  " +
+                                    provider);
+                        }
+                        return true;
+                    }
                 }
-                return true;
             }
 
             // No match
             return false;
         }
 
+        // Print debugging output of PreferredEntry
+        private String print(String t, String a, String p) {
+            return "[" + ((t != null) ? t : "" ) + ", " + a +
+                    ((p != null) ? " : " + p : "" ) + "] ";
+        }
+
         public String toString() {
-            return "[" + type + ", " + algorithm + " : " + provider + "] ";
+            return print(type, algorithm, provider);
         }
     }
 
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/CtrDrbg.java b/jdk/src/java.base/share/classes/sun/security/provider/CtrDrbg.java
index 4182383..1d23417 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/CtrDrbg.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/CtrDrbg.java
@@ -471,7 +471,7 @@
 
     @Override
     public String toString() {
-        return super.toString() + "/"
+        return super.toString() + ","
                 + (usedf ? "use_df" : "no_df");
     }
 }
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java
index 5861b6c..861fa69 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -259,14 +259,10 @@
 
     private static final Debug debug = Debug.getInstance("policy");
 
-    private static final String NONE = "NONE";
-    private static final String P11KEYSTORE = "PKCS11";
-
     private static final String SELF = "${{self}}";
     private static final String X500PRINCIPAL =
                         "javax.security.auth.x500.X500Principal";
     private static final String POLICY = "java.security.policy";
-    private static final String SECURITY_MANAGER = "java.security.manager";
     private static final String POLICY_URL = "policy.url.";
     private static final String AUTH_POLICY = "java.security.auth.policy";
     private static final String AUTH_POLICY_URL = "auth.policy.url.";
@@ -288,6 +284,17 @@
     private static final Class<?>[] PARAMS2 = { String.class, String.class };
 
     /**
+     * When a policy file has a syntax error, the exception code may generate
+     * another permission check and this can cause the policy file to be parsed
+     * repeatedly, leading to a StackOverflowError or ClassCircularityError.
+     * To avoid this, this set is populated with policy files that have been
+     * previously parsed and have syntax errors, so that they can be
+     * subsequently ignored.
+     */
+    private static AtomicReference<Set<URL>> badPolicyURLs =
+        new AtomicReference<>(new HashSet<>());
+
+    /**
      * Initializes the Policy object and reads the default policy
      * configuration file(s) into the Policy object.
      */
@@ -580,6 +587,16 @@
      * @param policyFile the policy Reader object.
      */
     private boolean init(URL policy, PolicyInfo newInfo) {
+
+        // skip parsing policy file if it has been previously parsed and
+        // has syntax errors
+        if (badPolicyURLs.get().contains(policy)) {
+            if (debug != null) {
+                debug.println("skipping bad policy file: " + policy);
+            }
+            return false;
+        }
+
         boolean success = false;
         PolicyParser pp = new PolicyParser(expandProperties);
         InputStreamReader isr = null;
@@ -622,13 +639,18 @@
                 addGrantEntry(ge, keyStore, newInfo);
             }
         } catch (PolicyParser.ParsingException pe) {
+            // record bad policy file to avoid later reparsing it
+            badPolicyURLs.updateAndGet(k -> {
+                k.add(policy);
+                return k;
+            });
             MessageFormat form = new MessageFormat(ResourcesMgr.getString
                 (POLICY + ".error.parsing.policy.message"));
             Object[] source = {policy, pe.getLocalizedMessage()};
             System.err.println(form.format(source));
-            if (debug != null)
+            if (debug != null) {
                 pe.printStackTrace();
-
+            }
         } catch (Exception e) {
             if (debug != null) {
                 debug.println("error parsing "+policy);
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java
index ba8ed75..f8aa620 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -213,7 +213,9 @@
                             new MessageFormat(ResourcesMgr.getString(
                                 "duplicate.keystore.domain.name"));
                         Object[] source = {domainName};
-                        throw new ParsingException(form.format(source));
+                        String msg = "duplicate keystore domain name: " +
+                                     domainName;
+                        throw new ParsingException(msg, form, source);
                     }
                 }
             } else {
@@ -743,7 +745,8 @@
                     ResourcesMgr.getString
                             ("expected.expect.read.end.of.file."));
             Object[] source = {expect};
-            throw new ParsingException(form.format(source));
+            String msg = "expected [" + expect + "], read [end of file]";
+            throw new ParsingException(msg, form, source);
         case StreamTokenizer.TT_WORD:
             if (expect.equalsIgnoreCase(st.sval)) {
                 lookahead = st.nextToken();
@@ -1244,7 +1247,8 @@
                 MessageFormat form = new MessageFormat(ResourcesMgr.getString(
                     "duplicate.keystore.name"));
                 Object[] source = {keystoreName};
-                throw new ParsingException(form.format(source));
+                String msg = "duplicate keystore name: " + keystoreName;
+                throw new ParsingException(msg, form, source);
             }
         }
 
@@ -1316,6 +1320,8 @@
         private static final long serialVersionUID = -4330692689482574072L;
 
         private String i18nMessage;
+        private MessageFormat form;
+        private Object[] source;
 
         /**
          * Constructs a ParsingException with the specified
@@ -1330,26 +1336,34 @@
             i18nMessage = msg;
         }
 
+        public ParsingException(String msg, MessageFormat form,
+                                Object[] source) {
+            super(msg);
+            this.form = form;
+            this.source = source;
+        }
+
         public ParsingException(int line, String msg) {
             super("line " + line + ": " + msg);
-            MessageFormat form = new MessageFormat
-                (ResourcesMgr.getString("line.number.msg"));
-            Object[] source = {line, msg};
-            i18nMessage = form.format(source);
+            // don't call form.format unless getLocalizedMessage is called
+            // to avoid unnecessary permission checks
+            form = new MessageFormat(ResourcesMgr.getString("line.number.msg"));
+            source = new Object[] {line, msg};
         }
 
         public ParsingException(int line, String expect, String actual) {
             super("line " + line + ": expected [" + expect +
                 "], found [" + actual + "]");
-            MessageFormat form = new MessageFormat(ResourcesMgr.getString
+            // don't call form.format unless getLocalizedMessage is called
+            // to avoid unnecessary permission checks
+            form = new MessageFormat(ResourcesMgr.getString
                 ("line.number.expected.expect.found.actual."));
-            Object[] source = {line, expect, actual};
-            i18nMessage = form.format(source);
+            source = new Object[] {line, expect, actual};
         }
 
         @Override
         public String getLocalizedMessage() {
-            return i18nMessage;
+            return i18nMessage != null ? i18nMessage : form.format(source);
         }
     }
 
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java b/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java
index 5ba6b47..a8df0ea 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,21 +41,8 @@
     byte[] random_bytes;  // exactly 32 bytes
 
     RandomCookie(SecureRandom generator) {
-        long temp = System.currentTimeMillis() / 1000;
-        int gmt_unix_time;
-        if (temp < Integer.MAX_VALUE) {
-            gmt_unix_time = (int) temp;
-        } else {
-            gmt_unix_time = Integer.MAX_VALUE;          // Whoops!
-        }
-
         random_bytes = new byte[32];
         generator.nextBytes(random_bytes);
-
-        random_bytes[0] = (byte)(gmt_unix_time >> 24);
-        random_bytes[1] = (byte)(gmt_unix_time >> 16);
-        random_bytes[2] = (byte)(gmt_unix_time >>  8);
-        random_bytes[3] = (byte)gmt_unix_time;
     }
 
     RandomCookie(HandshakeInStream m) throws IOException {
@@ -68,22 +55,15 @@
     }
 
     void print(PrintStream s) {
-        int i, gmt_unix_time;
-
-        gmt_unix_time = ((random_bytes[0] & 0xFF) << 24) |
-                        ((random_bytes[1] & 0xFF) << 16) |
-                        ((random_bytes[2] & 0xFF) << 8) |
-                         (random_bytes[3] & 0xFF);
-
-        s.print("GMT: " + gmt_unix_time + " ");
-        s.print("bytes = { ");
-
-        for (i = 4; i < 32; i++) {
-            if (i != 4) {
-                s.print(", ");
+        s.print("random_bytes = {");
+        for (int i = 0; i < 32; i++) {
+            int k = random_bytes[i] & 0xFF;
+            if (i != 0) {
+                s.print(' ');
             }
-            s.print(random_bytes[i] & 0x0ff);
+            s.print(Utilities.hexDigits[k >>> 4]);
+            s.print(Utilities.hexDigits[k & 0xf]);
         }
-        s.println(" }");
+        s.println("}");
     }
 }
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/Utilities.java b/jdk/src/java.base/share/classes/sun/security/ssl/Utilities.java
index aefb02c..9b267f6 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/Utilities.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/Utilities.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,11 @@
  */
 final class Utilities {
     /**
+     * hex digits
+     */
+    static final char[] hexDigits = "0123456789ABCDEF".toCharArray();
+
+    /**
      * Puts {@code hostname} into the {@code serverNames} list.
      * <P>
      * If the {@code serverNames} does not look like a legal FQDN, it will
diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java
index e2b4cfb..8503762 100644
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java
@@ -67,7 +67,9 @@
      *
      * @param keyType type of key, e.g. "RSA", "DSA"
      * @param sigAlg name of the signature algorithm, e.g. "MD5WithRSA",
-     *          "MD2WithRSA", "SHAwithDSA".
+     *          "MD2WithRSA", "SHAwithDSA". If set to null, a default
+     *          algorithm matching the private key will be chosen after
+     *          the first keypair is generated.
      * @exception NoSuchAlgorithmException on unrecognized algorithms.
      */
     public CertAndKeyGen (String keyType, String sigAlg)
@@ -83,7 +85,9 @@
      *
      * @param keyType type of key, e.g. "RSA", "DSA"
      * @param sigAlg name of the signature algorithm, e.g. "MD5WithRSA",
-     *          "MD2WithRSA", "SHAwithDSA".
+     *          "MD2WithRSA", "SHAwithDSA". If set to null, a default
+     *          algorithm matching the private key will be chosen after
+     *          the first keypair is generated.
      * @param providerName name of the provider
      * @exception NoSuchAlgorithmException on unrecognized algorithms.
      * @exception NoSuchProviderException on unrecognized providers.
@@ -161,8 +165,16 @@
             throw new IllegalArgumentException("Public key format is "
                 + publicKey.getFormat() + ", must be X.509");
         }
-    }
 
+        if (sigAlg == null) {
+            sigAlg = AlgorithmId.getDefaultSigAlgForKey(privateKey);
+            if (sigAlg == null) {
+                throw new IllegalArgumentException(
+                        "Cannot derive signature algorithm from "
+                                + privateKey.getAlgorithm());
+            }
+        }
+    }
 
     /**
      * Returns the public key of the generated key pair if it is of type
diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
index 94969b8..3a3d5cf 100644
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
@@ -54,7 +54,6 @@
 import java.util.*;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
-import java.lang.reflect.Constructor;
 import java.math.BigInteger;
 import java.net.URI;
 import java.net.URL;
@@ -1238,7 +1237,7 @@
         PrivateKey privateKey =
                 (PrivateKey)recoverKey(alias, storePass, keyPass).fst;
         if (sigAlgName == null) {
-            sigAlgName = getCompatibleSigAlgName(privateKey.getAlgorithm());
+            sigAlgName = getCompatibleSigAlgName(privateKey);
         }
         Signature signature = Signature.getInstance(sigAlgName);
         signature.initSign(privateKey);
@@ -1328,7 +1327,7 @@
         PrivateKey privateKey =
                 (PrivateKey)recoverKey(alias, storePass, keyPass).fst;
         if (sigAlgName == null) {
-            sigAlgName = getCompatibleSigAlgName(privateKey.getAlgorithm());
+            sigAlgName = getCompatibleSigAlgName(privateKey);
         }
 
         X509CRLEntry[] badCerts = new X509CRLEntry[ids.size()];
@@ -1387,7 +1386,7 @@
 
         // Construct a Signature object, so that we can sign the request
         if (sigAlgName == null) {
-            sigAlgName = getCompatibleSigAlgName(privKey.getAlgorithm());
+            sigAlgName = getCompatibleSigAlgName(privKey);
         }
 
         Signature signature = Signature.getInstance(sigAlgName);
@@ -1619,19 +1618,17 @@
      * If no signature algorithm was specified at the command line,
      * we choose one that is compatible with the selected private key
      */
-    private static String getCompatibleSigAlgName(String keyAlgName)
+    private static String getCompatibleSigAlgName(PrivateKey key)
             throws Exception {
-        if ("DSA".equalsIgnoreCase(keyAlgName)) {
-            return "SHA256WithDSA";
-        } else if ("RSA".equalsIgnoreCase(keyAlgName)) {
-            return "SHA256WithRSA";
-        } else if ("EC".equalsIgnoreCase(keyAlgName)) {
-            return "SHA256withECDSA";
+        String result = AlgorithmId.getDefaultSigAlgForKey(key);
+        if (result != null) {
+            return result;
         } else {
             throw new Exception(rb.getString
                     ("Cannot.derive.signature.algorithm"));
         }
     }
+
     /**
      * Creates a new key pair and self-signed certificate.
      */
@@ -1658,9 +1655,6 @@
             throw new Exception(form.format(source));
         }
 
-        if (sigAlgName == null) {
-            sigAlgName = getCompatibleSigAlgName(keyAlgName);
-        }
         CertAndKeyGen keypair =
                 new CertAndKeyGen(keyAlgName, sigAlgName, providerName);
 
@@ -2526,7 +2520,7 @@
 
         // Determine the signature algorithm
         if (sigAlgName == null) {
-            sigAlgName = getCompatibleSigAlgName(privKey.getAlgorithm());
+            sigAlgName = getCompatibleSigAlgName(privKey);
         }
 
         // Get the old certificate
diff --git a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
index 20e66d5..0bf5fcb 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
@@ -145,11 +145,10 @@
      */
     public static boolean isBlockOrSF(String s) {
         // we currently only support DSA and RSA PKCS7 blocks
-        if (s.endsWith(".SF") || s.endsWith(".DSA") ||
-                s.endsWith(".RSA") || s.endsWith(".EC")) {
-            return true;
-        }
-        return false;
+        return s.endsWith(".SF")
+            || s.endsWith(".DSA")
+            || s.endsWith(".RSA")
+            || s.endsWith(".EC");
     }
 
     /**
diff --git a/jdk/src/java.base/share/conf/security/java.policy b/jdk/src/java.base/share/conf/security/java.policy
index 0400ebf..32d3147 100644
--- a/jdk/src/java.base/share/conf/security/java.policy
+++ b/jdk/src/java.base/share/conf/security/java.policy
@@ -80,6 +80,10 @@
         permission java.security.AllPermission;
 };
 
+grant codeBase "jrt:/java.scripting" {
+        permission java.security.AllPermission;
+};
+
 grant codeBase "jrt:/jdk.scripting.nashorn" {
         permission java.security.AllPermission;
 };
diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security
index 6fa0d30..caf9444 100644
--- a/jdk/src/java.base/share/conf/security/java.security
+++ b/jdk/src/java.base/share/conf/security/java.security
@@ -105,15 +105,30 @@
 # The provider is the name of the provider. Any provider that does not
 # also appear in the registered list will be ignored.
 #
+# There is a special serviceType for this property only to group a set of
+# algorithms together. The type is "Group" and is followed by an algorithm
+# keyword. Groups are to simplify and lessen the entries on the property
+# line. Current groups are:
+#   Group.SHA2 = SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256
+#   Group.HmacSHA2 = HmacSHA224, HmacSHA256, HmacSHA384, HmacSHA512
+#   Group.SHA2RSA = SHA224withRSA, SHA256withRSA, SHA384withRSA, SHA512withRSA
+#   Group.SHA2DSA = SHA224withDSA, SHA256withDSA, SHA384withDSA, SHA512withDSA
+#   Group.SHA2ECDSA = SHA224withECDSA, SHA256withECDSA, SHA384withECDSA, \
+#                     SHA512withECDSA
+#   Group.SHA3 = SHA3-224, SHA3-256, SHA3-384, SHA3-512
+#   Group.HmacSHA3 = HmacSHA3-224, HmacSHA3-256, HmacSHA3-384, HmacSHA3-512
+#
 # Example:
 #   jdk.security.provider.preferred=AES/GCM/NoPadding:SunJCE, \
-#         MessageDigest.SHA-256:SUN
+#         MessageDigest.SHA-256:SUN, Group.HmacSHA2:SunJCE
 #ifdef solaris-sparc
-jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, SHA-224:SUN, \
-      SHA-256:SUN, SHA-384:SUN, SHA-512:SUN
+jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, \
+      HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE
 #endif
 #ifdef solaris-x86
-jdk.security.provider.preferred=AES:SunJCE, RSA:SunRsaSign
+jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, \
+      HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE, RSA:SunRsaSign, \
+      SHA1withRSA:SunRsaSign, Group.SHA2RSA:SunRsaSign
 #endif
 
 
@@ -613,14 +628,14 @@
 # "CertConstraint" specifies additional constraints for
 # certificates that contain algorithms that are restricted:
 #
-#   "jdkCA" prohibits the specified algorithm only if the algorithm is used
-#     in a certificate chain that terminates at a marked trust anchor in the
-#     lib/security/cacerts keystore.  All other chains are not affected.
-#     If the jdkCA constraint is not set, then all chains using the
-#     specified algorithm are restricted.  jdkCA may only be used once in
+#   "jdkCA" prohibits the specified algorithm only if the algorithm is used
+#     in a certificate chain that terminates at a marked trust anchor in the
+#     lib/security/cacerts keystore.  All other chains are not affected.
+#     If the jdkCA constraint is not set, then all chains using the
+#     specified algorithm are restricted.  jdkCA may only be used once in
 #     a DisabledAlgorithm expression.
-#     Example:  To apply this constraint to SHA-1 certificates, include
-#     the following:  "SHA1 jdkCA"
+#     Example:  To apply this constraint to SHA-1 certificates, include
+#     the following:  "SHA1 jdkCA"
 #
 # When an algorithm must satisfy more than one constraint, it must be
 # delimited by an ampersand '&'.  For example, to restrict certificates in a
@@ -713,6 +728,12 @@
 # See SSL/TLS specifications and "Java Cryptography Architecture Standard
 # Algorithm Name Documentation" for information about the algorithm names.
 #
+# Note: If a legacy algorithm is also restricted through the
+# jdk.tls.disabledAlgorithms property or the
+# java.security.AlgorithmConstraints API (See
+# javax.net.ssl.SSLParameters.setAlgorithmConstraints()),
+# then the algorithm is completely disabled and will not be negotiated.
+#
 # Note: This property is currently used by Oracle's JSSE implementation.
 # It is not guaranteed to be examined and used by other implementations.
 # There is no guarantee the property will continue to exist or be of the
diff --git a/jdk/src/java.base/share/native/include/jvmti.h b/jdk/src/java.base/share/native/include/jvmti.h
index 684fd2d..5f8835c 100644
--- a/jdk/src/java.base/share/native/include/jvmti.h
+++ b/jdk/src/java.base/share/native/include/jvmti.h
@@ -704,7 +704,8 @@
     unsigned int can_generate_resource_exhaustion_heap_events : 1;
     unsigned int can_generate_resource_exhaustion_threads_events : 1;
     unsigned int can_generate_early_vmstart : 1;
-    unsigned int : 6;
+    unsigned int can_generate_early_class_hook_events : 1;
+    unsigned int : 5;
     unsigned int : 16;
     unsigned int : 16;
     unsigned int : 16;
diff --git a/jdk/src/java.base/share/native/libjava/RandomAccessFile.c b/jdk/src/java.base/share/native/libjava/RandomAccessFile.c
index 4c02741..d20dfe8 100644
--- a/jdk/src/java.base/share/native/libjava/RandomAccessFile.c
+++ b/jdk/src/java.base/share/native/libjava/RandomAccessFile.c
@@ -60,6 +60,10 @@
         else if (mode & java_io_RandomAccessFile_O_DSYNC)
             flags |= O_DSYNC;
     }
+#ifdef WIN32
+    if (mode & java_io_RandomAccessFile_O_TEMPORARY)
+        flags |= O_TEMPORARY;
+#endif
     fileOpen(env, this, path, raf_fd, flags);
 }
 
diff --git a/jdk/src/java.base/unix/native/launcher/jexec.c b/jdk/src/java.base/unix/native/launcher/jexec.c
index 179ae4f..d288823 100644
--- a/jdk/src/java.base/unix/native/launcher/jexec.c
+++ b/jdk/src/java.base/unix/native/launcher/jexec.c
@@ -331,6 +331,7 @@
                 off_t end   = start  + xlen;
 
                 if (end <= count) {
+                    end -= 4; // make sure there are 4 bytes to read at start
                     while (start < end) {
                         off_t xhid  = SH(buf, start);
                         off_t xdlen = SH(buf, start + 2);
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.c b/jdk/src/java.base/unix/native/libnet/net_util_md.c
index abad413..6d623c8 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c
@@ -353,6 +353,7 @@
     if (getsockname(0, (struct sockaddr *)&sa, &sa_len) == 0) {
         struct sockaddr *saP = (struct sockaddr *)&sa;
         if (saP->sa_family != AF_INET6) {
+            close(fd);
             return JNI_FALSE;
         }
     }
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
index 91e1e4e..eaade12 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
@@ -112,7 +112,7 @@
     private AncestorListener ancestorListener = null;
     private DropTarget dragAndDropTarget = null;
 
-    private final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter();
+    private static final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter();
 
     private AquaFileSystemModel model;
 
@@ -997,7 +997,7 @@
     // *****************************************
     // ***** default AcceptAll file filter *****
     // *****************************************
-    protected class AcceptAllFileFilter extends FileFilter {
+    private static class AcceptAllFileFilter extends FileFilter {
         public AcceptAllFileFilter() {
         }
 
@@ -1305,6 +1305,8 @@
     protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
             PropertyChangeListener {
         protected FileFilter[] filters;
+        Object oldFileFilter = getFileChooser().getFileFilter();
+
         protected FilterComboBoxModel() {
             super();
             filters = getFileChooser().getChoosableFileFilters();
@@ -1321,12 +1323,17 @@
         }
 
         public void setSelectedItem(Object filter) {
-            if (filter != null && !containsFileFilter(filter)) {
+            if (filter != null && !isSelectedFileFilterInModel(filter)) {
+                oldFileFilter = filter;
                 getFileChooser().setFileFilter((FileFilter) filter);
                 fireContentsChanged(this, -1, -1);
             }
         }
 
+        private boolean isSelectedFileFilterInModel(Object filter) {
+            return Objects.equals(filter, oldFileFilter);
+        }
+
         public Object getSelectedItem() {
             // Ensure that the current filter is in the list.
             // NOTE: we shouldnt' have to do this, since JFileChooser adds
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
index 9b8e370..e57074e 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -282,12 +282,20 @@
         //kCGSFlagsMaskAppleLeftAlternateKey,
         //kCGSFlagsMaskAppleRightAlternateKey,
         58,
-        61,
+        0,
         java_awt_event_InputEvent_ALT_DOWN_MASK,
         java_awt_event_InputEvent_ALT_MASK,
         java_awt_event_KeyEvent_VK_ALT
     },
     {
+        NSAlternateKeyMask,
+        0,
+        61,
+        java_awt_event_InputEvent_ALT_DOWN_MASK | java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK,
+        java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK,
+        java_awt_event_KeyEvent_VK_ALT
+    },
+    {
         NSCommandKeyMask,
         //kCGSFlagsMaskAppleLeftCommandKey,
         //kCGSFlagsMaskAppleRightCommandKey,
@@ -310,6 +318,8 @@
     {0, 0, 0, 0, 0, 0}
 };
 
+static BOOL leftAltKeyPressed;
+
 /*
  * Almost all unicode characters just go from NS to Java with no translation.
  *  For the few exceptions, we handle it here with this small table.
@@ -523,13 +533,17 @@
             //    *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
             //}
             if (eventKeyCode == cur->leftKeyCode) {
+                leftAltKeyPressed = YES;
                 *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
             } else if (eventKeyCode == cur->rightKeyCode) {
                 *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
+            } else if (cur->nsMask == NSAlternateKeyMask) {
+                leftAltKeyPressed = NO;
+                continue;
             }
             *javaKeyType = (cur->nsMask & nsFlags) ?
-                java_awt_event_KeyEvent_KEY_PRESSED :
-                java_awt_event_KeyEvent_KEY_RELEASED;
+            java_awt_event_KeyEvent_KEY_PRESSED :
+            java_awt_event_KeyEvent_KEY_RELEASED;
             break;
         }
     }
@@ -545,7 +559,11 @@
 
     for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
         if ((cur->nsMask & nsFlags) != 0) {
-            javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
+            javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
+            if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) {
+                continue;
+            }
+            break;
         }
     }
 
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m
index 28e4f38..e6b7e21 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m
@@ -25,7 +25,6 @@
 
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
 #include <Carbon/Carbon.h>
-
 #import "CMenuItem.h"
 #import "CMenu.h"
 #import "AWTEvent.h"
@@ -64,42 +63,6 @@
 - (BOOL) worksWhenModal {
     return YES;
 }
-// This is a method written using Carbon framework methods to remove
-// All modifiers including "Shift" modifier.
-// Example 1: Shortcut set is "Command Shift m" returns "m"
-// Example 2: Shortcut set is "Command m" returns "m"
-// Example 3: Shortcut set is "Alt Shift ," returns ","
-
-CFStringRef createStringForKey(CGKeyCode keyCode)
-{
-    TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
-//  currentKeyboard now contains the current input source
-    CFDataRef layoutData =
-    TISGetInputSourceProperty(currentKeyboard,
-                              kTISPropertyUnicodeKeyLayoutData);
-//  the UNICODE keyLayout is fetched from currentKeyboard in layoutData
-    const UCKeyboardLayout *keyboardLayout =
-    (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
-//  A read-only data pointer is fetched from layoutData
-    UInt32 keysDown = 0;
-    UniChar chars[4];
-    UniCharCount realLength;
-    
-    UCKeyTranslate(keyboardLayout,
-                   keyCode,
-                   kUCKeyActionDisplay,
-                   0,
-                   LMGetKbdType(),
-                   kUCKeyTranslateNoDeadKeysBit,
-                   &keysDown,
-                   sizeof(chars) / sizeof(chars[0]),
-                   &realLength,
-                   chars);
-    CFRelease(currentKeyboard);
-//  Converts keyCode, modifier and dead-key state into UNICODE characters
-    return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1);
-}
-
 // Events
 - (void)handleAction:(NSMenuItem *)sender {
     AWT_ASSERT_APPKIT_THREAD;
@@ -116,35 +79,6 @@
     // from this "frameless" menu, because there are no active windows. This
     // means we have to handle it here.
     NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
-    if ([currEvent type] == NSKeyDown) {
-        NSString *menuKey = [sender keyEquivalent];
-//      If shortcut is "Command Shift ," the menuKey gets the value ","
-//      But [currEvent charactersIgnoringModifiers]; returns "<" and not ","
-//      because the charactersIgnoreingModifiers does not ignore "Shift"
-//      So a shortcut like "Command Shift m" will return "M" where as the
-//      MenuKey will have the value "m". To remove this issue the below
-//      createStringForKey is used.
-        NSString *eventKey = createStringForKey([currEvent keyCode]);
-        
-//      Apple uses characters from private Unicode range for some of the
-//      keys, so we need to do the same translation here that we do
-//      for the regular key down events
-                if ([eventKey length] == 1) {
-                    unichar origChar = [eventKey characterAtIndex:0];
-                    unichar newChar =  NsCharToJavaChar(origChar, 0);
-                    if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
-                        newChar = origChar;
-                    }
-        
-                    eventKey = [NSString stringWithCharacters: &newChar length: 1];
-                }
-        
-        NSWindow *keyWindow = [NSApp keyWindow];
-        if ([menuKey isEqualToString:eventKey] && keyWindow != nil) {
-            return;
-        }
-    }
-    
     if (fIsCheckbox) {
         static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
         static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
@@ -154,16 +88,47 @@
         NSInteger state = [sender state];
         jboolean newState = (state == NSOnState ? JNI_FALSE : JNI_TRUE);
         JNFCallVoidMethod(env, fPeer, jm_ckHandleAction, newState);
-    } else {
-        static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
-        static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
-        
-        NSUInteger modifiers = [currEvent modifierFlags];
-        jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
-        
-        JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
+    }
+    else {
+        if ([currEvent type] == NSKeyDown) {
+            
+            // Event available through sender variable hence NSApplication
+            // not needed for checking the keyboard input sans the modifier keys
+            // Also, the method used to fetch eventKey earlier would be locale dependent
+            // With earlier implementation, if MenuKey: e EventKey: ा ; if input method
+            // is not U.S. (Devanagari in this case)
+            // With current implementation, EventKey = MenuKey = e irrespective of
+            // input method
+            
+            NSString *eventKey = [sender keyEquivalent];
+            // Apple uses characters from private Unicode range for some of the
+            // keys, so we need to do the same translation here that we do
+            // for the regular key down events
+            if ([eventKey length] == 1) {
+                unichar origChar = [eventKey characterAtIndex:0];
+                unichar newChar =  NsCharToJavaChar(origChar, 0);
+                if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
+                    newChar = origChar;
+                }
+                eventKey = [NSString stringWithCharacters: &newChar length: 1];
+            }
+            NSWindow *keyWindow = [NSApp keyWindow];
+            if (keyWindow != nil) {
+                return;
+            }
+            else {
+                static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
+                static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
+                
+                NSUInteger modifiers = [currEvent modifierFlags];
+                jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
+                
+                JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
+            }
+        }
     }
     JNF_COCOA_EXIT(env);
+    
 }
 
 - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
index b740d05..0ad123b 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
@@ -25,7 +25,7 @@
 
 // External Java Accessibility links:
 //
-// <http://java.sun.com/j2se/1.4.2/docs/guide/access/index.html>
+// <https://docs.oracle.com/javase/8/docs/technotes/guides/access/index.html>
 // <http://www-106.ibm.com/developerworks/library/j-access/?n-j-10172>
 // <http://archives.java.sun.com/archives/java-access.html> (Sun's mailing list for Java accessibility)
 
@@ -1030,7 +1030,7 @@
 // Element's value (id)
 // note that the appKit meaning of "accessibilityValue" is different from the java
 // meaning of "accessibleValue", which is specific to numerical values
-// (http://java.sun.com/j2se/1.3/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue(java.lang.Number))
+// (https://docs.oracle.com/javase/8/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue-java.lang.Number-)
 - (id)accessibilityValueAttribute
 {
     static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;");
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java
index a1097b3..db96e67 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java
@@ -31,7 +31,7 @@
  * color space.
  */
 public final class SimpleCMYKColorSpace extends ColorSpace {
-    private static final long serialVersionUID = 666L; // XXX Revise UID value
+    private static final long serialVersionUID = 5387117338644522424L;
 
     private static ColorSpace theInstance = null;
     private ColorSpace csRGB;
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java
index 8d5e7f0..010bd3d 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,14 @@
 
 package com.sun.media.sound;
 
-import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioFormat;
 
-
 /**
  * AIFF file format.
  *
  * @author Jan Borgersen
  */
-
-final class AiffFileFormat extends AudioFileFormat {
+final class AiffFileFormat extends StandardFileFormat {
 
     static final int AIFF_MAGIC         = 1179603533;
 
@@ -70,11 +67,8 @@
     /** FVER chunk size in bytes, inclusive magic and length field */
     private final int fverChunkSize=0;
 
-    AiffFileFormat( AudioFileFormat aff ) {
-        this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
-    }
-
-    AiffFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) {
+    AiffFileFormat(final Type type, final long byteLength,
+                   final AudioFormat format, final long frameLength) {
         super(type, byteLength, format, frameLength);
     }
 
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java
index c0ac8bf..20dc684 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java
@@ -45,7 +45,7 @@
 public final class AiffFileReader extends SunFileReader {
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         DataInputStream dis = new DataInputStream(stream);
 
@@ -60,11 +60,11 @@
             throw new UnsupportedAudioFileException("not an AIFF file");
         }
 
-        int frameLength = 0;
+        long /* unsigned 32bit */ frameLength = 0;
         int length = dis.readInt();
         int iffType = dis.readInt();
 
-        int totallength;
+        final long totallength;
         if(length <= 0 ) {
             length = AudioSystem.NOT_SPECIFIED;
             totallength = AudioSystem.NOT_SPECIFIED;
@@ -106,12 +106,7 @@
                 if (channels <= 0) {
                     throw new UnsupportedAudioFileException("Invalid number of channels");
                 }
-                frameLength = dis.readInt(); // numSampleFrames
-                if (frameLength < 0) {
-                    // AiffFileFormat uses int, unlike AIS which uses long
-                    //TODO this (negative) value should be passed as long to AIS
-                    frameLength = AudioSystem.NOT_SPECIFIED;
-                }
+                frameLength = dis.readInt() & 0xffffffffL; // numSampleFrames
 
                 int sampleSizeInBits = dis.readUnsignedShort();
                 if (sampleSizeInBits < 1 || sampleSizeInBits > 32) {
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java
index 7a91bfc..dc425e4 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java
@@ -33,7 +33,7 @@
  *
  * @author Jan Borgersen
  */
-final class AuFileFormat extends AudioFileFormat {
+final class AuFileFormat extends StandardFileFormat {
 
     // magic numbers
     static final int AU_SUN_MAGIC = 0x2e736e64; // ".snd"
@@ -55,11 +55,18 @@
 
     static final int AU_HEADERSIZE       = 24;
 
+    /**
+     * According the specification of AU file format this is the value for
+     * length field if length is not known. This is a maximum possible value for
+     * the unsigned int.
+     */
+    static final long /*unsigned int */ UNKNOWN_SIZE = 0xffffffffL;
+
     private int auType;
 
-    AuFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {
-
-        super(type,lengthInBytes,format,lengthInFrames);
+    AuFileFormat(final AudioFileFormat.Type type, final long byteLength,
+                 final AudioFormat format, final long frameLength) {
+        super(type, byteLength, format, frameLength);
 
         AudioFormat.Encoding encoding = format.getEncoding();
 
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java
index 876c3b7..097b64b 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java
@@ -29,7 +29,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioFileFormat.Type;
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioSystem;
@@ -45,7 +44,7 @@
 public final class AuFileReader extends SunFileReader {
 
     @Override
-    public AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    public StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         final DataInputStream dis = new DataInputStream(stream);
         final int magic = dis.readInt();
@@ -56,7 +55,7 @@
         }
 
         final int headerSize = dis.readInt();
-        final int dataSize = dis.readInt();
+        final long /* unsigned int */ dataSize = dis.readInt() & 0xffffffffL;
         final int auType = dis.readInt();
         final int sampleRate = dis.readInt();
         final int channels = dis.readInt();
@@ -120,21 +119,21 @@
                 // unsupported filetype, throw exception
                 throw new UnsupportedAudioFileException("not a valid AU file");
         }
+        // now seek past the header
+        dis.skipBytes(headerSize - AuFileFormat.AU_HEADERSIZE);
 
         final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels);
         //$$fb 2002-11-02: fix for 4629669: AU file reader: problems with empty files
-        final int length;
-        if (dataSize < 0) {
-            length = AudioSystem.NOT_SPECIFIED;
-        } else {
-            //$$fb 2003-10-20: fix for 4940459: AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED
-            length = dataSize / frameSize;
+        //$$fb 2003-10-20: fix for 4940459: AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED
+        long frameLength = AudioSystem.NOT_SPECIFIED;
+        long byteLength = AudioSystem.NOT_SPECIFIED;
+        if (dataSize != AuFileFormat.UNKNOWN_SIZE) {
+            frameLength = dataSize / frameSize;
+            byteLength = dataSize + headerSize;
         }
-        // now seek past the header
-        dis.skipBytes(headerSize - AuFileFormat.AU_HEADERSIZE);
         final AudioFormat format = new AudioFormat(encoding, sampleRate,
                                                    sampleSizeInBits, channels,
                                                    frameSize, sampleRate, true);
-        return new AuFileFormat(Type.AU, dataSize + headerSize, format, length);
+        return new AuFileFormat(Type.AU, byteLength, format, frameLength);
     }
 }
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
index 715cfcf..b573b16 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,6 @@
 import javax.sound.midi.Receiver;
 import javax.sound.midi.Sequence;
 import javax.sound.midi.Track;
-import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioFileFormat.Type;
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioInputStream;
@@ -56,10 +55,10 @@
     private static final AudioFormat format = new AudioFormat(44100, 16, 2,
                                                               true, false);
 
-    private static AudioFileFormat getAudioFileFormat(final Sequence seq) {
+    private static StandardFileFormat getAudioFileFormat(final Sequence seq) {
         long totallen = seq.getMicrosecondLength() / 1000000;
         long len = (long) (format.getFrameRate() * (totallen + 4));
-        return new AudioFileFormat(MIDI, format, (int) len);
+        return new StandardFileFormat(MIDI, format, len);
     }
 
     private AudioInputStream getAudioInputStream(final Sequence seq)
@@ -140,7 +139,7 @@
     }
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         try {
             return getAudioFileFormat(MidiSystem.getSequence(stream));
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java
new file mode 100644
index 0000000..5be7149
--- /dev/null
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.media.sound;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+
+/**
+ * An instance of the {@code StandardFileFormat} describes the file's length in
+ * bytes and the length in sample frames as longs. This will provide an
+ * additional precision unlike the {@code AudioFileFormat}.
+ */
+class StandardFileFormat extends AudioFileFormat {
+
+    /**
+     * File length in bytes stored as long.
+     */
+    private final long byteLength;
+
+    /**
+     * Audio data length in sample frames stored as long.
+     */
+    private final long frameLength;
+
+    /**
+     * Constructs {@code StandardFileFormat} object.
+     *
+     * @param  type the type of the audio file
+     * @param  format the format of the audio data contained in the file
+     * @param  frameLength the audio data length in sample frames, or
+     *         {@code AudioSystem.NOT_SPECIFIED}
+     */
+    StandardFileFormat(final Type type, final AudioFormat format,
+                       final long frameLength) {
+        this(type, AudioSystem.NOT_SPECIFIED, format, frameLength);
+    }
+
+    /**
+     * Constructs {@code StandardFileFormat} object.
+     *
+     * @param  type the type of the audio file
+     * @param  byteLength the length of the file in bytes, or
+     *         {@code AudioSystem.NOT_SPECIFIED}
+     * @param  format the format of the audio data contained in the file
+     * @param  frameLength the audio data length in sample frames, or
+     *         {@code AudioSystem.NOT_SPECIFIED}
+     */
+    StandardFileFormat(final Type type, final long byteLength,
+                       final AudioFormat format, final long frameLength) {
+        super(type, clip(byteLength), format, clip(frameLength));
+        this.byteLength = byteLength;
+        this.frameLength = frameLength;
+    }
+
+    /**
+     * Replaces the passed value to {@code AudioSystem.NOT_SPECIFIED} if the
+     * value is greater than {@code Integer.MAX_VALUE}.
+     *
+     * @param  value which should be clipped
+     * @return the clipped value
+     */
+    private static int clip(final long value) {
+        if (value > Integer.MAX_VALUE) {
+            return AudioSystem.NOT_SPECIFIED;
+        }
+        return (int) value;
+    }
+
+    /**
+     * Obtains the length of the audio data contained in the file, expressed in
+     * sample frames. The long precision is used.
+     *
+     * @return the number of sample frames of audio data in the file
+     * @see AudioSystem#NOT_SPECIFIED
+     */
+    public final long getLongFrameLength() {
+        return frameLength;
+    }
+
+    /**
+     * Obtains the size in bytes of the entire audio file (not just its audio
+     * data). The long precision is used.
+     *
+     * @return the audio file length in bytes
+     * @see AudioSystem#NOT_SPECIFIED
+     */
+    public final long getLongByteLength() {
+        return byteLength;
+    }
+}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java
index a9e40ff..01307d5 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
 abstract class SunFileReader extends AudioFileReader {
 
     @Override
-    public final AudioFileFormat getAudioFileFormat(final InputStream stream)
+    public final StandardFileFormat getAudioFileFormat(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         stream.mark(200); // The biggest value which was historically used
         try {
@@ -87,11 +87,11 @@
             throws UnsupportedAudioFileException, IOException {
         stream.mark(200); // The biggest value which was historically used
         try {
-            final AudioFileFormat fileFormat = getAudioFileFormatImpl(stream);
+            final StandardFileFormat format = getAudioFileFormatImpl(stream);
             // we've got everything, the stream is supported and it is at the
             // beginning of the audio data, so return an AudioInputStream
-            return new AudioInputStream(stream, fileFormat.getFormat(),
-                                        fileFormat.getFrameLength());
+            return new AudioInputStream(stream, format.getFormat(),
+                                        format.getLongFrameLength());
         } catch (UnsupportedAudioFileException | EOFException ignored) {
             // stream is unsupported or the header is less than was expected
             stream.reset();
@@ -140,7 +140,7 @@
      *         UnsupportedAudioFileException if the header is less than was
      *         expected
      */
-    abstract AudioFileFormat getAudioFileFormatImpl(InputStream stream)
+    abstract StandardFileFormat getAudioFileFormatImpl(InputStream stream)
             throws UnsupportedAudioFileException, IOException;
 
     // HELPER METHODS
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
index 7d6ec18..5066ba2 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
@@ -34,7 +34,6 @@
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioFormat.Encoding;
 import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.UnsupportedAudioFileException;
 
 /**
@@ -167,7 +166,7 @@
     }
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
         RIFFReader riffiterator = new RIFFReader(stream);
@@ -249,19 +248,17 @@
         } else {
             throw new UnsupportedAudioFileException();
         }
-        long frameLength = dataSize / audioformat.getFrameSize();
-        if (frameLength > Integer.MAX_VALUE) {
-            frameLength = AudioSystem.NOT_SPECIFIED;
-        }
-        return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat,
-                                   (int) frameLength);
+        return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat,
+                                      dataSize / audioformat.getFrameSize());
     }
 
     @Override
     public AudioInputStream getAudioInputStream(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
-        final AudioFileFormat format = getAudioFileFormat(stream);
+        final StandardFileFormat format = getAudioFileFormat(stream);
+        final AudioFormat af = format.getFormat();
+        final long length = format.getLongFrameLength();
         // we've got everything, the stream is supported and it is at the
         // beginning of the header, so find the data chunk again and return an
         // AudioInputStream
@@ -269,8 +266,6 @@
         while (riffiterator.hasNextChunk()) {
             RIFFReader chunk = riffiterator.nextChunk();
             if (chunk.getFormat().equals("data")) {
-                final AudioFormat af = format.getFormat();
-                final long length = chunk.getSize() / af.getFrameSize();
                 return new AudioInputStream(chunk, af, length);
             }
         }
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java
index 9bf8c92..bf3abbf 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java
@@ -33,7 +33,7 @@
  *
  * @author Jan Borgersen
  */
-final class WaveFileFormat extends AudioFileFormat {
+final class WaveFileFormat extends StandardFileFormat {
 
     /**
      * Wave format type.
@@ -73,9 +73,9 @@
     static final int WAVE_FORMAT_SX7383    = 0x1C07;
     static final int WAVE_FORMAT_EXTENSIBLE= 0xFFFE;
 
-    WaveFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {
-
-        super(type,lengthInBytes,format,lengthInFrames);
+    WaveFileFormat(final AudioFileFormat.Type type, final long byteLength,
+                   final AudioFormat format, final long frameLength) {
+        super(type, byteLength, format, frameLength);
 
         AudioFormat.Encoding encoding = format.getEncoding();
 
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java
index 96a4bd7..7295b18 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 public final class WaveFileReader extends SunFileReader {
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
         // assumes sream is rewound
@@ -64,9 +64,9 @@
         DataInputStream dis = new DataInputStream( stream );
 
         int magic = dis.readInt();
-        int fileLength = rllong(dis);
+        long /* unsigned int */ fileLength = rllong(dis) & 0xffffffffL;
         int waveMagic = dis.readInt();
-        int totallength;
+        long totallength;
         if (fileLength <= 0) {
             fileLength = AudioSystem.NOT_SPECIFIED;
             totallength = AudioSystem.NOT_SPECIFIED;
@@ -186,19 +186,18 @@
             }
         }
         // this is the length of the data chunk
-        int dataLength = rllong(dis); nread += 4;
+        long /* unsigned int */ dataLength = rllong(dis) & 0xffffffffL; nread += 4;
 
         // now build the new AudioFileFormat and return
-
+        final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels);
         AudioFormat format = new AudioFormat(encoding,
                                              (float)sampleRate,
                                              sampleSizeInBits, channels,
-                                             calculatePCMFrameSize(sampleSizeInBits, channels),
+                                             frameSize,
                                              (float)sampleRate, false);
 
-        return new WaveFileFormat(AudioFileFormat.Type.WAVE,
-                                  totallength,
-                                  format,
-                                  dataLength / format.getFrameSize());
+        long frameLength = dataLength / format.getFrameSize();
+        return new WaveFileFormat(AudioFileFormat.Type.WAVE, totallength,
+                                  format, frameLength);
     }
 }
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java
index 284877d..2c3be15 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java
@@ -32,7 +32,6 @@
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioFormat.Encoding;
 import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.UnsupportedAudioFileException;
 
 /**
@@ -43,7 +42,7 @@
 public final class WaveFloatFileReader extends SunFileReader {
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
         RIFFReader riffiterator = new RIFFReader(stream);
@@ -88,20 +87,17 @@
         AudioFormat audioformat = new AudioFormat(
                 Encoding.PCM_FLOAT, samplerate, bits, channels,
                 framesize, samplerate, false);
-        long frameLength = dataSize / audioformat.getFrameSize();
-        if (frameLength > Integer.MAX_VALUE) {
-            frameLength = AudioSystem.NOT_SPECIFIED;
-        }
-
-        return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat,
-                                   (int) frameLength);
+        return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat,
+                                      dataSize / audioformat.getFrameSize());
     }
 
     @Override
     public AudioInputStream getAudioInputStream(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
-        final AudioFileFormat format = getAudioFileFormat(stream);
+        final StandardFileFormat format = getAudioFileFormat(stream);
+        final AudioFormat af = format.getFormat();
+        final long length = format.getLongFrameLength();
         // we've got everything, the stream is supported and it is at the
         // beginning of the header, so find the data chunk again and return an
         // AudioInputStream
@@ -109,8 +105,6 @@
         while (riffiterator.hasNextChunk()) {
             RIFFReader chunk = riffiterator.nextChunk();
             if (chunk.getFormat().equals("data")) {
-                final AudioFormat af = format.getFormat();
-                final long length = chunk.getSize() / af.getFrameSize();
                 return new AudioInputStream(chunk, af, length);
             }
         }
diff --git a/jdk/src/java.desktop/share/classes/java/applet/Applet.java b/jdk/src/java.desktop/share/classes/java/applet/Applet.java
index 0e02c9c..a8430a7 100644
--- a/jdk/src/java.desktop/share/classes/java/applet/Applet.java
+++ b/jdk/src/java.desktop/share/classes/java/applet/Applet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,13 @@
  * @author      Arthur van Hoff
  * @author      Chris Warth
  * @since       1.0
+ *
+ * @deprecated  The Applet API is deprecated. See the
+ * <a href="package-summary.html"> java.applet package documentation</a>
+ * for further information.
  */
+
+@Deprecated(since = "9")
 public class Applet extends Panel {
 
     /**
diff --git a/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java b/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java
index 7caae99..3863aed 100644
--- a/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java
+++ b/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,13 @@
  *
  * @author      Arthur van Hoff
  * @since       1.0
+ *
+ * @deprecated  The Applet API is deprecated. See the
+ * <a href="package-summary.html"> java.applet package documentation</a>
+ * for further information.
  */
+
+@Deprecated(since = "9")
 public interface AppletContext {
     /**
      * Creates an audio clip.
diff --git a/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java b/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java
index 7a7e614..1f4e39b 100644
--- a/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java
+++ b/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,13 @@
  * @author      Arthur van Hoff
  * @see         java.applet.Applet#setStub(java.applet.AppletStub)
  * @since       1.0
+ *
+ * @deprecated  The Applet API is deprecated. See the
+ * <a href="package-summary.html"> java.applet package documentation</a>
+ * for further information.
  */
+
+@Deprecated(since = "9")
 public interface AppletStub {
     /**
      * Determines if the applet is active. An applet is active just
diff --git a/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java b/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java
index f935fa4..6436ccb 100644
--- a/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java
+++ b/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,13 @@
  *
  * @author      Arthur van Hoff
  * @since       1.0
+ *
+ * @deprecated  The Applet API is deprecated. See the
+ * <a href="package-summary.html">java.applet package documentation</a>
+ * for further information.
  */
+
+@Deprecated(since = "9")
 public interface AudioClip {
     /**
      * Starts playing this audio clip. Each time this method is called,
diff --git a/jdk/src/java.desktop/share/classes/java/applet/package.html b/jdk/src/java.desktop/share/classes/java/applet/package.html
index 3315f29..a95395b 100644
--- a/jdk/src/java.desktop/share/classes/java/applet/package.html
+++ b/jdk/src/java.desktop/share/classes/java/applet/package.html
@@ -39,6 +39,11 @@
 applets. For example, the applet context could be a Web browser or an applet
 development environment.
 <p>
+The APIs in this package are all deprecated. Alternative technologies such as Java Web Start
+or installable applications should be used instead. See <a href="http://openjdk.java.net/jeps/289">JEP 289</a>
+and the Oracle White Paper <a href="http://www.oracle.com/technetwork/java/javase/migratingfromapplets-2872444.pdf">
+"Migrating from Java Applets to plugin-free Java technologies"</a> for more information.
+<p>
 <!--
 <h2>Package Specification</h2>
 
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java
index b2b51e0..c2a021f 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java
@@ -9739,19 +9739,24 @@
      */
     int getAccessibleIndexInParent() {
         synchronized (getTreeLock()) {
-            int index = -1;
-            Container parent = this.getParent();
-            if (parent != null && parent instanceof Accessible) {
-                Component ca[] = parent.getComponents();
-                for (int i = 0; i < ca.length; i++) {
-                    if (ca[i] instanceof Accessible) {
-                        index++;
-                    }
-                    if (this.equals(ca[i])) {
-                        return index;
-                    }
+
+            AccessibleContext accContext = getAccessibleContext();
+            if (accContext == null) {
+                return -1;
+            }
+
+            Accessible parent = accContext.getAccessibleParent();
+            if (parent == null) {
+                return -1;
+            }
+
+            accContext = parent.getAccessibleContext();
+            for (int i = 0; i < accContext.getAccessibleChildrenCount(); i++) {
+                if (this.equals(accContext.getAccessibleChild(i))) {
+                    return i;
                 }
             }
+
             return -1;
         }
     }
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
index 9e7646f..b45dd39 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,7 +89,7 @@
  * <br>For more information, see
  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html#transferTiming">Timing
  * Focus Transfers</a>, a section in
- * <a href="http://java.sun.com/docs/books/tutorial/uiswing/">The Swing
+ * <a href="http://docs.oracle.com/javase/tutorial/uiswing/">The Swing
  * Tutorial</a>.
  *
  * <li>Making a top-level container visible.
@@ -207,30 +207,34 @@
     }
 
     /**
-     * Returns whether dynamic layout of Containers on resize is
-     * currently active (both set in program
-     *( {@code isDynamicLayoutSet()} )
-     *, and supported
-     * by the underlying operating system and/or window manager).
-     * If dynamic layout is currently inactive then Containers
-     * re-layout their components when resizing is completed. As a result
-     * the {@code Component.validate()} method will be invoked only
-     * once per resize.
-     * If dynamic layout is currently active then Containers
-     * re-layout their components on every native resize event and
-     * the {@code validate()} method will be invoked each time.
-     * The OS/WM support can be queried using
-     * the getDesktopProperty("awt.dynamicLayoutSupported") method.
+     * Returns whether dynamic layout of Containers on resize is currently
+     * enabled on the underlying operating system and/or window manager). If the
+     * platform supports it, {@code setDynamicLayout(boolean)} may be used to
+     * programmatically enable or disable platform dynamic layout. Regardless of
+     * whether that toggling is supported, or whether {@code true} or {@code
+     * false} is specified as an argument, or has never been called at all, this
+     * method will return the active current platform behavior and which will be
+     * followed by the JDK in determining layout policy during resizing.
+     * <p>
+     * If dynamic layout is currently inactive then Containers re-layout their
+     * components when resizing is completed. As a result the
+     * {@code Component.validate()} method will be invoked only once per resize.
+     * If dynamic layout is currently active then Containers re-layout their
+     * components on every native resize event and the {@code validate()} method
+     * will be invoked each time. The OS/WM support can be queried using the
+     * getDesktopProperty("awt.dynamicLayoutSupported") method. This property
+     * will reflect the platform capability but is not sufficient to tell if it
+     * is presently enabled.
      *
-     * @return    true if dynamic layout of Containers on resize is
-     *            currently active, false otherwise.
-     * @exception HeadlessException if the GraphicsEnvironment.isHeadless()
-     *            method returns true
-     * @see       #setDynamicLayout(boolean dynamic)
-     * @see       #isDynamicLayoutSet()
-     * @see       #getDesktopProperty(String propertyName)
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @since     1.4
+     * @return true if dynamic layout of Containers on resize is currently
+     *         active, false otherwise.
+     * @throws HeadlessException if the GraphicsEnvironment.isHeadless() method
+     *         returns true
+     * @see #setDynamicLayout(boolean dynamic)
+     * @see #isDynamicLayoutSet()
+     * @see #getDesktopProperty(String propertyName)
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @since 1.4
      */
     public boolean isDynamicLayoutActive()
         throws HeadlessException {
diff --git a/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java b/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java
index d86ecfa..daae045 100644
--- a/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java
+++ b/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java
@@ -53,8 +53,8 @@
  *
  *<p>
  * For more information you might also want to check out
- * <a
- href="http://java.sun.com/products/jfc/tsc/articles/persistence3">Long Term Persistence of JavaBeans Components: XML Schema</a>,
+ * <a href="http://www.oracle.com/technetwork/java/persistence3-139471.html">
+ * Long Term Persistence of JavaBeans Components: XML Schema</a>,
  * an article in <em>The Swing Connection.</em>
  * @see XMLEncoder
  * @see java.io.ObjectInputStream
@@ -284,7 +284,8 @@
      * The {@code null} value may cause illegal parsing in such case.
      * The same problem may occur, if the {@code owner} class
      * does not contain expected method to call. See details <a
-     * href="http://java.sun.com/products/jfc/tsc/articles/persistence3/">here</a>.
+     * href="http://www.oracle.com/technetwork/java/persistence3-139471.html">
+     * here</a>.
      *
      * @param owner  the owner of the default handler
      *               that can be used as a value of &lt;java&gt; element
diff --git a/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java b/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java
index ac4ab41..7deaea3 100644
--- a/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java
+++ b/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java
@@ -193,8 +193,8 @@
  *
  *<p>
  * For more information you might also want to check out
- * <a
- href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>,
+ * <a href="http://www.oracle.com/technetwork/java/persistence4-140124.html">
+ * Using XMLEncoder</a>,
  * an article in <em>The Swing Connection.</em>
  * @see XMLDecoder
  * @see java.io.ObjectOutputStream
@@ -438,7 +438,8 @@
      * <P>
      * For more information about using resource bundles with the
      * XMLEncoder, see
-     * http://java.sun.com/products/jfc/tsc/articles/persistence4/#i18n
+     * <a href="http://www.oracle.com/technetwork/java/persistence4-140124.html#i18n">
+     * Creating Internationalized Applications</a>,
      *
      * @param oldExp The expression that will be written
      *               to the stream.
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java
index 28ee56a..58adc76 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java
@@ -87,9 +87,9 @@
         }
     }
 
-    static class ModelTiePoint extends TIFFTag {
-        public ModelTiePoint() {
-            super("ModelTiePointTag",
+    static class ModelTiepoint extends TIFFTag {
+        public ModelTiepoint() {
+            super("ModelTiepointTag",
                   TAG_MODEL_TIE_POINT,
                   1 << TIFFTag.TIFF_DOUBLE);
         }
@@ -126,7 +126,7 @@
 
         tags.add(new GeoTIFFTagSet.ModelPixelScale());
         tags.add(new GeoTIFFTagSet.ModelTransformation());
-        tags.add(new GeoTIFFTagSet.ModelTiePoint());
+        tags.add(new GeoTIFFTagSet.ModelTiepoint());
         tags.add(new GeoTIFFTagSet.GeoKeyDirectory());
         tags.add(new GeoTIFFTagSet.GeoDoubleParams());
         tags.add(new GeoTIFFTagSet.GeoAsciiParams());
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
index 336f815..a6ba385 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
@@ -412,7 +412,7 @@
 
     /**
      * Creates a {@code TIFFField} from a TIFF native image
-     * metadata node. If the value of the <tt>"tagNumber"</tt> attribute
+     * metadata node. If the value of the <tt>"number"</tt> attribute
      * of the node is not found in {@code tagSet} then a new
      * {@code TIFFTag} with name {@code TIFFTag.UNKNOWN_TAG_NAME}
      * will be created and assigned to the field.
@@ -424,6 +424,10 @@
      * {@code null}.
      * @throws IllegalArgumentException if the name of the node is not
      * {@code "TIFFField"}.
+     * @throws NullPointerException if the node does not contain any data.
+     * @throws IllegalArgumentException if the combination of node attributes
+     * and data is not legal per the {@link #TIFFField(TIFFTag,int,int,Object)}
+     * constructor specification.
      * @return A new {@code TIFFField}.
      */
     public static TIFFField createFromMetadataNode(TIFFTagSet tagSet,
@@ -1089,6 +1093,15 @@
      * {@code TIFF_SBYTE} data will be returned in the range
      * [-128, 127].
      *
+     * <p> Data in {@code TIFF_FLOAT} and {@code TIFF_DOUBLE} are
+     * simply cast to {@code long} and may suffer from truncation.
+     *
+     * <p> Data in {@code TIFF_SRATIONAL} or
+     * {@code TIFF_RATIONAL} format are evaluated by dividing the
+     * numerator into the denominator using double-precision
+     * arithmetic and then casting to {@code long}.  Loss of
+     * precision and truncation may occur.
+     *
      * <p> Data in {@code TIFF_ASCII} format will be parsed as by
      * the {@code Double.parseDouble} method, with the result
      * cast to {@code long}.
@@ -1112,6 +1125,10 @@
         case TIFFTag.TIFF_LONG:
         case TIFFTag.TIFF_IFD_POINTER:
             return ((long[])data)[index];
+        case TIFFTag.TIFF_FLOAT:
+            return (long)((float[])data)[index];
+        case TIFFTag.TIFF_DOUBLE:
+            return (long)((double[])data)[index];
         case TIFFTag.TIFF_SRATIONAL:
             int[] ivalue = getAsSRational(index);
             return (long)((double)ivalue[0]/ivalue[1]);
@@ -1286,7 +1303,11 @@
      * version of the data item.  Data of type
      * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} are
      * represented as a pair of integers separated by a
-     * {@code '/'} character.
+     * {@code '/'} character.  If the numerator of a
+     * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} is an integral
+     * multiple of the denominator, then the value is represented as
+     * {@code "q/1"} where {@code q} is the quotient of the numerator and
+     * denominator.
      *
      * @param index The index of the data.
      * @return The data at the given index as a {@code String}.
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java b/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java
index 2d9ce39..c6f4a71 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,7 +92,13 @@
  *
  * @author Arnaud Weber
  * @since 1.2
+ *
+ * @deprecated  The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package documentation</a>
+ * for further information.
  */
+
+@Deprecated(since = "9")
 @JavaBean(defaultProperty = "JMenuBar", description = "Swing's Applet subclass.")
 @SwingContainer(delegate = "getContentPane")
 @SuppressWarnings("serial") // Same-version serialization only
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java
index 4061f2e..80dfb29 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java
@@ -194,7 +194,7 @@
  * @see JComponent
  * @see BoxLayout
  *
- * @see <a href="http://java.sun.com/products/jfc/tsc/articles/mixing/">
+ * @see <a href="http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html">
  * Mixing Heavy and Light Components</a>
  *
  * @author David Kloba
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html
index cb80302..43ff5ee 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html
@@ -37,10 +37,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -49,7 +49,7 @@
 This document forms the complete API specification.  For overviews, tutorials, 
 examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/colorchooser.html" target="_top">How to Use Color Choosers</a>, 
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/colorchooser.html" target="_top">How to Use Color Choosers</a>,
       a section in <em>The Java Tutorial</em>
 
   <li><a href="../../../../technotes/guides/intl/index.html"
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/event/package.html b/jdk/src/java.desktop/share/classes/javax/swing/event/package.html
index 054a005..070ae42 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/event/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/event/package.html
@@ -39,17 +39,17 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Related Documentation</h2>
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/events/"
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/events/index.html"
       target="_top">Writing Event Listeners</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html
index d850fc5..fa06236 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html
@@ -37,10 +37,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -49,7 +49,7 @@
 This document forms the complete API specification.  For overviews, tutorials,
 examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html" target="_top">How to Use File Choosers</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html" target="_top">How to Use File Choosers</a>,
       a section in <em>The Java Tutorial</em>
   <li><a href="../../../../technotes/guides/intl/index.html"
       target="_top">Internationalization Documentation</a>
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/package.html b/jdk/src/java.desktop/share/classes/javax/swing/package.html
index 8050000..934bb90 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/package.html
@@ -38,7 +38,7 @@
 (all-Java language) components that,
 to the maximum degree possible, work the same on all platforms.
 For a programmer's guide to using these components, see
-<a href="http://java.sun.com/docs/books/tutorial/uiswing/index.html" 
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/index.html"
 target="_top">Creating
 a GUI with JFC/Swing</a>, a trail in <em>The Java Tutorial</em>.
 For other resources, see 
@@ -123,9 +123,9 @@
 processing when working with Swing.
 <p>
 More information on this topic can be found in the
-<a href="http://download.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
 in particular the section on
-<a href="http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
 
 
 <H2>
@@ -134,13 +134,13 @@
 <P>For overviews, tutorials, examples, guides, and other documentation, please see:
 
 <UL>
-   <LI><A HREF="http://java.sun.com/products/jfc/tsc/" 
+   <LI><A HREF="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html"
    target="_top">The Swing Connection</A>
-   <LI><A HREF="http://java.sun.com/docs/books/tutorial/" 
+   <LI><A HREF="http://docs.oracle.com/javase/tutorial/"
    target="_top">The Java Tutorial</A>
-   <LI><A HREF="http://java.sun.com/developer/onlineTraining/" 
+   <LI><A HREF="http://www.oracle.com/technetwork/java/javase/training/index.html"
    target="_top">Online Training</A> at the Java Developer Connection<font size=-2><sup>SM</sup></font>
-   <LI><A HREF="http://java.sun.com/products/jfc/" 
+   <LI><A HREF="http://www.oracle.com/technetwork/java/javase/tech/index-jsp-142216.html"
    target="_top">Java Foundation Classes (JFC)</A> home page
 </UL>
 
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java
index f6d211f..5ee8bed 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java
@@ -210,6 +210,16 @@
         LookAndFeel.installBorder(spinner, "Spinner.border");
         LookAndFeel.installColorsAndFont(spinner, "Spinner.background", "Spinner.foreground", "Spinner.font");
         LookAndFeel.installProperty(spinner, "opaque", Boolean.TRUE);
+
+        JComponent editor = spinner.getEditor();
+        if (editor instanceof JSpinner.DefaultEditor) {
+            JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
+            if (tf != null) {
+                if (tf.getFont() instanceof UIResource) {
+                    tf.setFont(new FontUIResource(spinner.getFont()));
+                }
+            }
+        }
     }
 
 
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html
index d02593c..347fc7c 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html
@@ -55,10 +55,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html
index 1c41e7f..db16ddd 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html
@@ -51,10 +51,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html
index 512b1a5..343db54 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html
@@ -18,7 +18,7 @@
 <i>
 This document is based on an article
 originally published in
-<a href="http://java.sun.com/products/jfc/tsc/" target="_top"><em>The Swing
+<a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html" target="_top"><em>The Swing
 Connection</em></a>.
 </i>
 </p>
@@ -65,12 +65,12 @@
 Before reading further, you should be familiar 
 with the concept of pluggable look and feels.
 For basic information, see
-<a href="http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html">How to Set the Look and Feel</a>,
+<a href="https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html">How to Set the Look and Feel</a>,
 a section in 
 <em>The Java Tutorial</em>.
 For architectural details, you can read
 <a
-href="http://java.sun.com/products/jfc/tsc/articles/architecture/#pluggable">Pluggable look-and-feel architecture</a>, a section within
+href="http://www.oracle.com/technetwork/java/architecture-142923.html#pluggable">Pluggable look-and-feel architecture</a>, a section within
 a <em>Swing Connection</em> article.
 </p>
 
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html
index 65d1aea..32b0d6b 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html
@@ -53,10 +53,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html
index 14cac30..f91d737 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html
@@ -88,10 +88,10 @@
 <p><strong>Note:</strong>
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
-<a href="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html"
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
    target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
        target="_top">The Java Tutorial</a></em>.
 
 @since 1.7
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html
index c207c89..0fc8c53 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html
@@ -44,10 +44,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
index 2022830..0936b29 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
@@ -950,7 +950,7 @@
       Beans persistance can be used to embed any Object. This is
       typically used for embedding your own Painters, but can be used
       for other arbritrary objects as well. Refer to <a
-							href="http://java.sun.com/products/jfc/tsc/articles/persistence3/">http://java.sun.com/products/jfc/tsc/articles/persistence3/</a> for details on beans persistance.
+							href="http://www.oracle.com/technetwork/java/persistence3-139471.html">http://www.oracle.com/technetwork/java/persistence3-139471.html</a> for details on beans persistance.
 
 
     <h3>Backing Style</h3>
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/table/package.html b/jdk/src/java.desktop/share/classes/javax/swing/table/package.html
index f3fd20c..cf94482 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/package.html
@@ -43,10 +43,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -54,7 +54,7 @@
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html" target="_top">How to Use Tables</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html" target="_top">How to Use Tables</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java b/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java
index 12c9a09..4cab9c4 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java
@@ -166,7 +166,7 @@
  * </ul>
  *
  * <p>For more information on the <code>Document</code> class, see
- * <a href="http://java.sun.com/products/jfc/tsc">The Swing Connection</a>
+ * <a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html">The Swing Connection</a>
  * and most particularly the article,
  * <a href="http://java.sun.com/products/jfc/tsc/articles/text/element_interface">
  * The Element Interface</a>.
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html
index e0ab035..c9c41b8 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html
@@ -37,10 +37,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Package Specification</h2>
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html
index d503bc7..05c5398 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html
@@ -40,10 +40,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @see javax.swing.text.html.HTMLEditorKit.ParserCallback
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/package.html
index 4aa7804..1c38c25 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/package.html
@@ -41,17 +41,17 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Related Documentation</h2>
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/text.html" target="_top">Using Text Components</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/text.html" target="_top">Using Text Components</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html
index aa83e9f..9b62f22 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html
@@ -38,10 +38,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html b/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html
index b6b58bb..e820b3c 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html
@@ -39,10 +39,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -50,7 +50,7 @@
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html" target="_top">How to Use Trees</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html" target="_top">How to Use Trees</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html b/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html
index f4ae62d..bf6d809 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html
@@ -37,17 +37,17 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Related Documentation</h2>
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#undo" target="_top">Implementing Undo and Redo</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html#undo" target="_top">Implementing Undo and Redo</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
diff --git a/jdk/src/java.desktop/share/classes/module-info.java b/jdk/src/java.desktop/share/classes/module-info.java
index 5cf785d..77150e1 100644
--- a/jdk/src/java.desktop/share/classes/module-info.java
+++ b/jdk/src/java.desktop/share/classes/module-info.java
@@ -27,8 +27,6 @@
     requires public java.datatransfer;
     requires public java.xml;
     requires java.prefs;
-    // 8147544
-    requires jdk.unsupported;
 
     exports java.applet;
     exports java.awt;
diff --git a/jdk/src/java.desktop/share/classes/sun/applet/Main.java b/jdk/src/java.desktop/share/classes/sun/applet/Main.java
index 086b111..6c28c8f 100644
--- a/jdk/src/java.desktop/share/classes/sun/applet/Main.java
+++ b/jdk/src/java.desktop/share/classes/sun/applet/Main.java
@@ -104,7 +104,8 @@
     private int run(String [] args) {
         // DECODE ARGS
         try {
-            System.out.println(lookup("deprecated"));
+            System.err.println(lookup("deprecated"));
+            System.err.flush();
             if (args.length == 0) {
                 usage();
                 return 0;
diff --git a/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java b/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java
index 2b2bf2d..d9ba025 100644
--- a/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java
+++ b/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java
@@ -73,7 +73,7 @@
             {"appletviewer.parse.warning.embed.requiresheight", "Warning: <embed> tag requires height attribute."},
             {"appletviewer.parse.warning.embed.requireswidth", "Warning: <embed> tag requires width attribute."},
             {"appletviewer.parse.warning.appnotLongersupported", "Warning: <app> tag no longer supported, use <applet> instead:"},
-            {"appletviewer.deprecated", "AppletViewer is deprecated."},
+            {"appletviewer.deprecated", "Warning: Applet API and AppletViewer are deprecated."},
             {"appletviewer.usage", "Usage: appletviewer <options> url(s)\n\nwhere <options> include:\n  -encoding <encoding>    Specify character encoding used by HTML files\n  -J<runtime flag>        Pass argument to the java interpreter\n\nThe -J option is non-standard and subject to change without notice."},
             {"appletviewer.main.err.unsupportedopt", "Unsupported option: {0}"},
             {"appletviewer.main.err.unrecognizedarg", "Unrecognized argument: {0}"},
diff --git a/jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java b/jdk/src/java.desktop/share/classes/sun/awt/SoftCache.java
similarity index 99%
rename from jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java
rename to jdk/src/java.desktop/share/classes/sun/awt/SoftCache.java
index 30bc2ec..7b7ea26 100644
--- a/jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SoftCache.java
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.misc;
+package sun.awt;
 
 import java.lang.ref.SoftReference;
 import java.lang.ref.ReferenceQueue;
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java
index fdaeb1e..8461974 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java
@@ -65,7 +65,6 @@
 import sun.awt.image.ToolkitImage;
 import sun.awt.image.URLImageSource;
 import sun.font.FontDesignMetrics;
-import sun.misc.SoftCache;
 import sun.net.util.URLUtil;
 import sun.security.action.GetBooleanAction;
 import sun.security.action.GetPropertyAction;
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
index a8e67f7..26a8691 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
@@ -29,7 +29,7 @@
 import java.awt.image.MultiResolutionImage;
 import java.util.Arrays;
 import java.util.List;
-import sun.misc.SoftCache;
+import sun.awt.SoftCache;
 
 public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage {
 
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c
index 42d42ed..84d8a14 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c
@@ -73,7 +73,6 @@
  */
 
 #include "mlib_ImageCheck.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageAffine.h"
 
 
@@ -125,18 +124,6 @@
 };
 
 /***************************************************************/
-const type_affine_i_fun mlib_AffineFunArr_bc_i[] = {
-  mlib_ImageAffineIndex_U8_U8_3CH_BC,
-  mlib_ImageAffineIndex_U8_U8_4CH_BC,
-  mlib_ImageAffineIndex_S16_U8_3CH_BC,
-  mlib_ImageAffineIndex_S16_U8_4CH_BC,
-  mlib_ImageAffineIndex_U8_S16_3CH_BC,
-  mlib_ImageAffineIndex_U8_S16_4CH_BC,
-  mlib_ImageAffineIndex_S16_S16_3CH_BC,
-  mlib_ImageAffineIndex_S16_S16_4CH_BC
-};
-
-/***************************************************************/
 #ifdef i386 /* do not perform the coping by mlib_d64 data type for x86 */
 #define MAX_T_IND  2
 #else
@@ -148,8 +135,7 @@
                                       const mlib_image *src,
                                       const mlib_d64   *mtx,
                                       mlib_filter      filter,
-                                      mlib_edge        edge,
-                                      const void       *colormap)
+                                      mlib_edge        edge)
 {
   mlib_affine_param param[1];
   mlib_status res;
@@ -213,18 +199,6 @@
   else
     return MLIB_FAILURE; /* unknown image type */
 
-  if (colormap != NULL && filter != MLIB_NEAREST) {
-    if (t_ind != 0 && t_ind != 1)
-      return MLIB_FAILURE;
-
-    if (mlib_ImageGetLutType(colormap) == MLIB_SHORT)
-      t_ind += 2;
-    t_ind = 2 * t_ind;
-
-    if (mlib_ImageGetLutChannels(colormap) == 4)
-      t_ind++;
-  }
-
   if (type == MLIB_BIT) {
     mlib_s32 s_bitoff = mlib_ImageGetBitOffset(src);
     mlib_s32 d_bitoff = mlib_ImageGetBitOffset(dst);
@@ -253,25 +227,13 @@
 
       case MLIB_BILINEAR:
 
-        if (colormap != NULL) {
-          res = mlib_AffineFunArr_bl_i[t_ind] (param, colormap);
-        }
-        else {
-          res = mlib_AffineFunArr_bl[4 * t_ind + (nchan - 1)] (param);
-        }
-
+        res = mlib_AffineFunArr_bl[4 * t_ind + (nchan - 1)] (param);
         break;
 
       case MLIB_BICUBIC:
       case MLIB_BICUBIC2:
 
-        if (colormap != NULL) {
-          res = mlib_AffineFunArr_bc_i[t_ind] (param, colormap);
-        }
-        else {
-          res = mlib_AffineFunArr_bc[4 * t_ind + (nchan - 1)] (param);
-        }
-
+        res = mlib_AffineFunArr_bc[4 * t_ind + (nchan - 1)] (param);
         break;
     }
 
@@ -303,7 +265,7 @@
 
     switch (edge) {
       case MLIB_EDGE_DST_FILL_ZERO:
-        mlib_ImageAffineEdgeZero(param, param_e, colormap);
+        mlib_ImageAffineEdgeZero(param, param_e);
         break;
 
       case MLIB_EDGE_OP_NEAREST:
@@ -313,10 +275,10 @@
       case MLIB_EDGE_SRC_EXTEND:
 
         if (filter == MLIB_BILINEAR) {
-          res = mlib_ImageAffineEdgeExtend_BL(param, param_e, colormap);
+          res = mlib_ImageAffineEdgeExtend_BL(param, param_e);
         }
         else {
-          res = mlib_ImageAffineEdgeExtend_BC(param, param_e, colormap);
+          res = mlib_ImageAffineEdgeExtend_BC(param, param_e);
         }
 
         break;
@@ -355,7 +317,7 @@
     return MLIB_FAILURE;
   }
 
-  return mlib_ImageAffine_alltypes(dst, src, mtx, filter, edge, NULL);
+  return mlib_ImageAffine_alltypes(dst, src, mtx, filter, edge);
 }
 
 /***************************************************************/
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h
index b9f8fe8..be21823 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h
@@ -162,99 +162,25 @@
 
 /***************************************************************/
 void mlib_ImageAffineEdgeZero(mlib_affine_param *param,
-                              mlib_affine_param *param_e,
-                              const void        *colormap);
+                              mlib_affine_param *param_e);
 
 void mlib_ImageAffineEdgeNearest(mlib_affine_param *param,
                                  mlib_affine_param *param_e);
 
 mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap);
+                                          mlib_affine_param *param_e);
 
 mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap);
-
-mlib_status mlib_ImageAffineEdgeExtend_BC2(mlib_affine_param *param,
-                                           mlib_affine_param *param_e,
-                                           const void        *colormap);
-
-/***************************************************************/
-typedef mlib_status (*type_affine_i_fun)(mlib_affine_param *param, const void *colormap);
-
-mlib_status mlib_ImageAffine_u8_u8_i_bl(mlib_affine_param *param,
-                                        const void        *colormap);
-mlib_status mlib_ImageAffine_u8_s16_i_bl(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_u8_i_bl(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_s16_i_bl(mlib_affine_param *param,
-                                          const void        *colormap);
-
-mlib_status mlib_ImageAffine_u8_u8_i_bc(mlib_affine_param *param,
-                                        const void        *colormap);
-mlib_status mlib_ImageAffine_u8_s16_i_bc(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_u8_i_bc(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_s16_i_bc(mlib_affine_param *param,
-                                          const void        *colormap);
-
-void mlib_ImageAffineEdgeZeroIndex(mlib_affine_param *param,
-                                   mlib_affine_param *param_e,
-                                   const void        *colormap);
-
-void mlib_ImageAffineEdgeExtendIndex_BL(mlib_affine_param *param,
-                                        mlib_affine_param *param_e,
-                                        const void        *colormap);
-
-void mlib_ImageAffineEdgeExtendIndex_BC(mlib_affine_param *param,
-                                        mlib_affine_param *param_e,
-                                        const void        *colormap);
-
-void mlib_ImageAffineEdgeExtendIndex_BC2(mlib_affine_param *param,
-                                         mlib_affine_param *param_e,
-                                         const void        *colormap);
-
-/***************************************************************/
-#define PROT_AFFINEINDEX_BC(ITYPE, LTYPE, NCHAN)                                                 \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BC(mlib_affine_param *param, \
-                                                                       const void        *colormap)
-
-PROT_AFFINEINDEX_BC(U8, U8, 3);
-PROT_AFFINEINDEX_BC(U8, S16, 3);
-PROT_AFFINEINDEX_BC(U8, U8, 4);
-PROT_AFFINEINDEX_BC(U8, S16, 4);
-PROT_AFFINEINDEX_BC(S16, U8, 3);
-PROT_AFFINEINDEX_BC(S16, S16, 3);
-PROT_AFFINEINDEX_BC(S16, U8, 4);
-PROT_AFFINEINDEX_BC(S16, S16, 4);
-
-/***************************************************************/
-#define PROT_AFFINEINDEX_BL(ITYPE, LTYPE, NCHAN)                                                 \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BL(mlib_affine_param *param, \
-                                                                       const void        *colormap)
-
-PROT_AFFINEINDEX_BL(U8, U8, 3);
-PROT_AFFINEINDEX_BL(U8, S16, 3);
-PROT_AFFINEINDEX_BL(U8, U8, 4);
-PROT_AFFINEINDEX_BL(U8, S16, 4);
-PROT_AFFINEINDEX_BL(S16, U8, 3);
-PROT_AFFINEINDEX_BL(S16, S16, 3);
-PROT_AFFINEINDEX_BL(S16, U8, 4);
-PROT_AFFINEINDEX_BL(S16, S16, 4);
+                                          mlib_affine_param *param_e);
 
 /***************************************************************/
 mlib_status mlib_ImageAffine_alltypes(mlib_image       *dst,
                                       const mlib_image *src,
                                       const mlib_d64   *mtx,
                                       mlib_filter      filter,
-                                      mlib_edge        edge,
-                                      const void       *colormap);
+                                      mlib_edge        edge);
 
 /***************************************************************/
-extern const type_affine_i_fun mlib_AffineFunArr_bl_i[];
 extern const type_affine_fun mlib_AffineFunArr_nn[];
 extern const type_affine_fun mlib_AffineFunArr_bl[];
 extern const type_affine_fun mlib_AffineFunArr_bc[];
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c
index e095a0e..2cb39d0 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c
@@ -73,7 +73,6 @@
  */
 
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageAffine.h"
 
 /***************************************************************/
@@ -218,97 +217,6 @@
   }
 
 /***************************************************************/
-#define LUT(k, ind) plut[channels*sp[ind] + k]
-
-/***************************************************************/
-#define MLIB_EDGE_INDEX(ITYPE, DTYPE, size)                             \
-  for (j = 0; j < size; j++) {                                          \
-    ySrc = ((Y - 32768) >> MLIB_SHIFT);                                 \
-    xSrc = ((X - 32768) >> MLIB_SHIFT);                                 \
-                                                                        \
-    t = ((X - 32768) & MLIB_MASK) * scale;                              \
-    u = ((Y - 32768) & MLIB_MASK) * scale;                              \
-                                                                        \
-    xDelta = (((xSrc + 1 - srcWidth )) >> MLIB_SIGN_SHIFT) & 1;         \
-    yDelta = (((ySrc + 1 - srcHeight)) >> MLIB_SIGN_SHIFT) & srcStride; \
-                                                                        \
-    xFlag = (xSrc >> (MLIB_SIGN_SHIFT - MLIB_SHIFT));                   \
-    xSrc = xSrc + (1 & xFlag);                                          \
-    xDelta = xDelta &~ xFlag;                                           \
-                                                                        \
-    yFlag = (ySrc >> (MLIB_SIGN_SHIFT - MLIB_SHIFT));                   \
-    ySrc = ySrc + (1 & yFlag);                                          \
-    yDelta = yDelta &~ yFlag;                                           \
-                                                                        \
-    sp = (ITYPE*)lineAddr[ySrc] + xSrc;                                 \
-                                                                        \
-    for (k = 0; k < channels; k++) {                                    \
-      a00  = LUT(k, 0);                                                 \
-      a01  = LUT(k, xDelta);                                            \
-      a10  = LUT(k, yDelta);                                            \
-      a11  = LUT(k, yDelta + xDelta);                                   \
-      pix0 = (a00 * (1 - t) + a01 * t) * (1 - u) +                      \
-             (a10 * (1 - t) + a11 * t) * u;                             \
-                                                                        \
-      pbuff[k] = (mlib_s32)pix0;                                        \
-    }                                                                   \
-    pbuff += channels;                                                  \
-                                                                        \
-    X += dX;                                                            \
-    Y += dY;                                                            \
-  }
-
-/***************************************************************/
-#define MLIB_EDGE_INDEX_u8i(ITYPE, Left, Right) {                              \
-  mlib_u8  *pbuff = buff;                                                      \
-                                                                               \
-  size = Right - Left;                                                         \
-                                                                               \
-  MLIB_EDGE_INDEX(ITYPE, mlib_u8, size);                                       \
-                                                                               \
-  dp = (ITYPE*)data + Left;                                                    \
-                                                                               \
-  if (channels == 3) {                                                         \
-    if (sizeof(ITYPE) == 1) {                                                  \
-      mlib_ImageColorTrue2IndexLine_U8_U8_3 (buff, (void*)dp, size, colormap); \
-    } else {                                                                   \
-      mlib_ImageColorTrue2IndexLine_U8_S16_3(buff, (void*)dp, size, colormap); \
-    }                                                                          \
-  } else {                                                                     \
-    if (sizeof(ITYPE) == 1) {                                                  \
-      mlib_ImageColorTrue2IndexLine_U8_U8_4 (buff, (void*)dp, size, colormap); \
-    } else {                                                                   \
-      mlib_ImageColorTrue2IndexLine_U8_S16_4(buff, (void*)dp, size, colormap); \
-    }                                                                          \
-  }                                                                            \
-}
-
-/***************************************************************/
-#define MLIB_EDGE_INDEX_s16i(ITYPE, Left, Right) {                              \
-  mlib_s16 *pbuff = buff;                                                       \
-                                                                                \
-  size = Right - Left;                                                          \
-                                                                                \
-  MLIB_EDGE_INDEX(ITYPE, mlib_s16, size);                                       \
-                                                                                \
-  dp = (ITYPE*)data + Left;                                                     \
-                                                                                \
-  if (channels == 3) {                                                          \
-    if (sizeof(ITYPE) == 1) {                                                   \
-      mlib_ImageColorTrue2IndexLine_S16_U8_3 (buff, (void*)dp, size, colormap); \
-    } else {                                                                    \
-      mlib_ImageColorTrue2IndexLine_S16_S16_3(buff, (void*)dp, size, colormap); \
-    }                                                                           \
-  } else {                                                                      \
-    if (sizeof(ITYPE) == 1) {                                                   \
-      mlib_ImageColorTrue2IndexLine_S16_U8_4 (buff, (void*)dp, size, colormap); \
-    } else {                                                                    \
-      mlib_ImageColorTrue2IndexLine_S16_S16_4(buff, (void*)dp, size, colormap); \
-    }                                                                           \
-  }                                                                             \
-}
-
-/***************************************************************/
 #define GET_FLT_TBL(X, xf0, xf1, xf2, xf3)                      \
   filterpos = ((X - 32768) >> flt_shift) & flt_mask;            \
   fptr = (mlib_f32 *) ((mlib_u8 *)flt_tbl + filterpos);         \
@@ -424,47 +332,6 @@
   MLIB_EDGE_BC_LINE(TYPE, Left, Right, GET_FLT_BC2)
 
 /***************************************************************/
-#define MLIB_EDGE_INDEX_BC(ITYPE, DTYPE, size)                  \
-  for (j = 0; j < size; j++) {                                  \
-    GET_FLT_TBL(X, xf0, xf1, xf2, xf3);                         \
-    GET_FLT_TBL(Y, yf0, yf1, yf2, yf3);                         \
-                                                                \
-    CALC_SRC_POS(X, Y, 1, srcStride);                           \
-                                                                \
-    sp = (ITYPE*)lineAddr[ySrc] + xSrc;                         \
-                                                                \
-    for (k = 0; k < channels; k++) {                            \
-      c0 = LUT(k, yDelta0 + xDelta0) * xf0 +                    \
-           LUT(k, yDelta0          ) * xf1 +                    \
-           LUT(k, yDelta0 + xDelta1) * xf2 +                    \
-           LUT(k, yDelta0 + xDelta2) * xf3;                     \
-                                                                \
-      c1 = LUT(k, xDelta0) * xf0 +                              \
-           LUT(k, 0      ) * xf1 +                              \
-           LUT(k, xDelta1) * xf2 +                              \
-           LUT(k, xDelta2) * xf3;                               \
-                                                                \
-      c2 = LUT(k, yDelta1 + xDelta0) * xf0 +                    \
-           LUT(k, yDelta1          ) * xf1 +                    \
-           LUT(k, yDelta1 + xDelta1) * xf2 +                    \
-           LUT(k, yDelta1 + xDelta2) * xf3;                     \
-                                                                \
-      c3 = LUT(k, yDelta2 + xDelta0) * xf0 +                    \
-           LUT(k, yDelta2          ) * xf1 +                    \
-           LUT(k, yDelta2 + xDelta1) * xf2 +                    \
-           LUT(k, yDelta2 + xDelta2) * xf3;                     \
-                                                                \
-      val0 = c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3;                 \
-                                                                \
-      SAT##DTYPE(pbuff[k], val0);                               \
-    }                                                           \
-    pbuff += channels;                                          \
-                                                                \
-    X += dX;                                                    \
-    Y += dY;                                                    \
-  }
-
-/***************************************************************/
 #define MLIB_PROCESS_EDGES_ZERO(TYPE) {                         \
   TYPE *dp, *dstLineEnd;                                        \
                                                                 \
@@ -586,16 +453,11 @@
 
 /***************************************************************/
 void mlib_ImageAffineEdgeZero(mlib_affine_param *param,
-                              mlib_affine_param *param_e,
-                              const void        *colormap)
+                              mlib_affine_param *param_e)
 {
   GET_EDGE_PARAMS_ZERO();
   mlib_s32 zero = 0;
 
-  if (colormap != NULL) {
-    zero = mlib_ImageGetLutOffset(colormap);
-  }
-
   switch (type) {
     case MLIB_BYTE:
       MLIB_PROCESS_EDGES_ZERO(mlib_u8);
@@ -654,8 +516,7 @@
 
 /***************************************************************/
 mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap)
+                                          mlib_affine_param *param_e)
 {
   GET_EDGE_PARAMS();
   mlib_d64 scale = 1.0 / (mlib_d64) MLIB_PREC;
@@ -663,79 +524,6 @@
   mlib_d64 t, u, pix0;
   mlib_d64 a00, a01, a10, a11;
 
-  if (colormap != NULL) {
-    mlib_s32 max_xsize = param_e->max_xsize;
-    mlib_type ltype = mlib_ImageGetLutType(colormap);
-    mlib_d64 *plut = (mlib_d64 *) mlib_ImageGetLutDoubleData(colormap);
-    void *buff;
-
-    channels = mlib_ImageGetLutChannels(colormap);
-    plut -= channels * mlib_ImageGetLutOffset(colormap);
-
-    if (max_xsize == 0) {
-      return MLIB_SUCCESS;
-    }
-
-    if (ltype == MLIB_BYTE) {
-      buff = mlib_malloc(channels * max_xsize);
-    }
-    else if (ltype == MLIB_SHORT) {
-      buff = mlib_malloc(channels * max_xsize * sizeof(mlib_s16));
-    } else {
-      /* Unsupported type of lookup table. Report a failure */
-      return MLIB_FAILURE;
-    }
-
-    if (buff == NULL)
-      return MLIB_FAILURE;
-
-    switch (ltype) {
-      case MLIB_BYTE:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_s16);
-            break;
-        default:
-          /* Incompatible image type. Ignore it for now. */
-          break;
-        }
-
-        break;
-
-      case MLIB_SHORT:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_s16);
-            break;
-        default:
-          /* Incompatible image type. Ignore it for now. */
-          break;
-        }
-
-        break;
-    default:
-      /* Unsupported type of lookup table.
-       * Can not be here due to check on line 685,
-       * so just ignore it.
-       */
-      break;
-    }
-
-    mlib_free(buff);
-
-    return MLIB_SUCCESS;
-  }
-
   switch (type) {
     case MLIB_BYTE:
       MLIB_PROCESS_EDGES(MLIB_EDGE_BL, mlib_u8);
@@ -775,12 +563,8 @@
 }
 
 /***************************************************************/
-#undef  MLIB_EDGE_INDEX
-#define MLIB_EDGE_INDEX MLIB_EDGE_INDEX_BC
-
 mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap)
+                                          mlib_affine_param *param_e)
 {
   GET_EDGE_PARAMS();
   mlib_d64 scale = 1.0 / (mlib_d64) MLIB_PREC;
@@ -789,7 +573,6 @@
   mlib_d64 xf0, xf1, xf2, xf3;
   mlib_d64 yf0, yf1, yf2, yf3;
   mlib_d64 c0, c1, c2, c3, val0;
-  mlib_type ltype;
   mlib_filter filter = param->filter;
   mlib_f32 *fptr;
   mlib_f32 const *flt_tbl;
@@ -798,9 +581,7 @@
   mlib_s32 yDelta0, yDelta1, yDelta2;
   mlib_d64 sat;
 
-  ltype = (colormap != NULL) ? mlib_ImageGetLutType(colormap) : type;
-
-  if (ltype == MLIB_BYTE) {
+  if (type == MLIB_BYTE) {
     flt_shift = FLT_SHIFT_U8;
     flt_mask = FLT_MASK_U8;
     flt_tbl = (filter == MLIB_BICUBIC) ? mlib_filters_u8f_bc : mlib_filters_u8f_bc2;
@@ -813,78 +594,6 @@
     sat = (mlib_d64) 0x7FFF8000;                           /* saturation for U16 */
   }
 
-  if (colormap != NULL) {
-    mlib_s32 max_xsize = param_e->max_xsize;
-    mlib_d64 *plut = (mlib_d64 *) mlib_ImageGetLutDoubleData(colormap);
-    void *buff;
-
-    channels = mlib_ImageGetLutChannels(colormap);
-    plut -= channels * mlib_ImageGetLutOffset(colormap);
-
-    if (max_xsize == 0) {
-      return MLIB_SUCCESS;
-    }
-
-    if (ltype == MLIB_BYTE) {
-      buff = mlib_malloc(channels * max_xsize);
-    }
-    else if (ltype == MLIB_SHORT) {
-      buff = mlib_malloc(channels * max_xsize * sizeof(mlib_s16));
-    } else {
-      /* Unsupported type of lookup table. */
-      return MLIB_FAILURE;
-    }
-
-    if (buff == NULL)
-      return MLIB_FAILURE;
-
-    switch (ltype) {
-      case MLIB_BYTE:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_s16);
-            break;
-        default:
-          /* Ignore incomatible image type. */
-          break;
-        }
-
-        break;
-
-      case MLIB_SHORT:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_s16);
-            break;
-        default:
-          /* Ignore incomatible image type. */
-          break;
-        }
-
-        break;
-
-    default:
-      /* Unsupported type of lookup table.
-       * Can not be here due to check on line 836,
-       * so just ignore it.
-       */
-      break;
-    }
-
-    mlib_free(buff);
-
-    return MLIB_SUCCESS;
-  }
 
   switch (type) {
     case MLIB_BYTE:
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h
index 3cfaea8..8c6a5b1 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h
@@ -82,12 +82,6 @@
     return MLIB_FAILURE;                                        \
   }
 
-#define MLIB_IMAGE_AND_COLORMAP_ARE_COMPAT(image,colormap)                 \
-  if ((mlib_ImageGetChannels(image) != mlib_ImageGetLutChannels(colormap)) \
-    || (mlib_ImageGetLutType(colormap) != mlib_ImageGetType(image))) {     \
-    return MLIB_FAILURE;                                                   \
-  }
-
 #define MLIB_IMAGE_GET_ALL_PARAMS(image, type, nchan, width, height, stride, pdata) \
   type   = mlib_ImageGetType(image);                                                \
   nchan  = mlib_ImageGetChannels(image);                                            \
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c
deleted file mode 100644
index 0028fd2..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c
+++ /dev/null
@@ -1,4256 +0,0 @@
-/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * FUNCTION
- *      mlib_ImageColorTrue2Index - convert a true color image to an indexed
- *                                  color image
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageColorTrue2Index(mlib_image       *dst,
- *                                            const mlib_image *src,
- *                                            const void       *colormap)
- *
- * ARGUMENTS
- *      colormap  Internal data structure for inverse color mapping.
- *      dst       Pointer to destination image.
- *      src       Pointer to source image.
- *
- * DESCRIPTION
- *      Convert a true color image to a pseudo color image with the method
- *      of finding the nearest matched lut entry for each pixel.
- *
- *      The src can be an MLIB_BYTE or MLIB_SHORT image with 3 or 4 channels.
- *      The dst must be a 1-channel MLIB_BYTE or MLIB_SHORT image.
- *
- *      The lut might have either 3 or 4 channels. The type of the lut can be
- *      one of the following:
- *              MLIB_BYTE in, MLIB_BYTE out (i.e., BYTE-to-BYTE)
- *              MLIB_BYTE in, MLIB_SHORT out (i.e., BYTE-to-SHORT)
- *              MLIB_SHORT in, MLIB_SHORT out (i.e., SHORT-to-SHORT)
- *              MLIB_SHORT in, MLIB_BYTE out (i.e., SHORT-to-BYTE)
- *
- *      The src image and the lut must have same number of channels.
- */
-
-#include "mlib_image.h"
-#include "mlib_ImageColormap.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-
-/*#define USE_VIS_CODE*/
-
-#ifdef USE_VIS_CODE
-#include "vis_proto.h"
-#define VIS_ALIGNADDR(X, Y)  vis_alignaddr((void *)(X), (Y))
-#endif
-
-/***************************************************************/
-
-#define LUT_BYTE_COLORS_3CHANNELS  1000
-#define LUT_BYTE_COLORS_4CHANNELS  3000
-#define LUT_SHORT_COLORS_3CHANNELS 1000
-#define LUT_SHORT_COLORS_4CHANNELS 1000
-
-/***************************************************************/
-
-#define MAIN_COLORTRUE2INDEX_LOOP( FROM_TYPE, TO_TYPE, NCHANNELS )       \
-  for( y = 0; y < height; y++ )                                          \
-  {                                                                      \
-    mlib_ImageColorTrue2IndexLine_##FROM_TYPE##_##TO_TYPE##_##NCHANNELS( \
-      sdata, ddata, width, colormap );                                   \
-                                                                         \
-    sdata += sstride;                                                    \
-    ddata += dstride;                                                    \
-  }
-
-/***************************************************************/
-
-#define COLOR_CUBE_U8_3_SEARCH( TABLE_POINTER_TYPE, SHIFT, STEP ) \
-{                                                                 \
-  const mlib_u8 *c0, *c1, *c2;                                    \
-  TABLE_POINTER_TYPE *table = s->table;                           \
-  mlib_s32 bits = s->bits;                                        \
-  mlib_s32 nbits = 8 - bits;                                      \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                        \
-  mlib_s32 j;                                                     \
-                                                                  \
-  c0 = src + SHIFT;                                               \
-  c1 = src + 1 + SHIFT;                                           \
-  c2 = src + 2 + SHIFT;                                           \
-                                                                  \
-  switch( bits )                                                  \
-  {                                                               \
-    case 1:                                                       \
-    case 2:                                                       \
-    {                                                             \
-      mlib_s32 bits0 = 8 - bits;                                  \
-      mlib_s32 bits1 = bits0 - bits;                              \
-      mlib_s32 bits2 = bits1 - bits;                              \
-                                                                  \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) >> bits2 ) |           \
-          ( ( *c1 & mask ) >> bits1 ) |                           \
-          ( ( *c2 & mask ) >> bits0 ) ];                          \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 3:                                                       \
-    {                                                             \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 1 ) |               \
-          ( ( *c1 & mask ) >> 2 ) |                               \
-          ( ( *c2 & mask ) >> 5 ) ];                              \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 4:                                                       \
-    {                                                             \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 4 ) |               \
-          ( *c1 & mask ) |                                        \
-          ( ( *c2 & mask ) >> 4 ) ];                              \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 5:                                                       \
-    case 6:                                                       \
-    case 7:                                                       \
-    {                                                             \
-      mlib_s32 bits0 = 8 - bits;                                  \
-      mlib_s32 bits1 = bits * 2 - 8;                              \
-      mlib_s32 bits2 = bits1 + bits;                              \
-                                                                  \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << bits2 ) |           \
-          ( ( *c1 & mask ) << bits1 ) |                           \
-          ( ( *c2 & mask ) >> bits0 ) ];                          \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 8:                                                       \
-    {                                                             \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 16 ) |              \
-          ( ( *c1 & mask ) << 8 ) |                               \
-          ( *c2 & mask ) ];                                       \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-  }                                                               \
-}
-
-/***************************************************************/
-#define COLOR_CUBE_U8_4_SEARCH( TABLE_TYPE )                    \
-{                                                               \
-  const mlib_u8 *c0, *c1, *c2, *c3;                             \
-  TABLE_TYPE *table = s->table;                                 \
-  mlib_s32 bits = s->bits;                                      \
-  mlib_s32 nbits = 8 - bits;                                    \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                      \
-  mlib_s32 j;                                                   \
-                                                                \
-  c0 = src;                                                     \
-  c1 = src + 1;                                                 \
-  c2 = src + 2;                                                 \
-  c3 = src + 3;                                                 \
-                                                                \
-  switch( bits )                                                \
-  {                                                             \
-    case 1:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) >> 4 ) |             \
-          ( ( *c1 & mask ) >> 5 ) |                             \
-          ( ( *c2 & mask ) >> 6 ) |                             \
-          ( ( *c3 & mask ) >> 7 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 2:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( *c0 & mask ) |                      \
-          ( ( *c1 & mask ) >> 2 ) |                             \
-          ( ( *c2 & mask ) >> 4 ) |                             \
-          ( ( *c3 & mask ) >> 6 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-          }                                                     \
-      break;                                                    \
-    }                                                           \
-    case 3:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 4 ) |             \
-          ( ( *c1 & mask ) << 1 ) |                             \
-          ( ( *c2 & mask ) >> 2 ) |                             \
-          ( ( *c3 & mask ) >> 5 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 4:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 8 ) |             \
-          ( ( *c1 & mask ) << 4 ) |                             \
-          ( *c2 & mask ) |                                      \
-          ( ( *c3 & mask ) >> 4 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 5:                                                     \
-    case 6:                                                     \
-    {                                                           \
-      mlib_s32 bits3 = bits * 4 - 8;                            \
-      mlib_s32 bits2 = bits3 - bits;                            \
-      mlib_s32 bits1 = bits2 - bits;                            \
-      mlib_s32 bits0 = 8 - bits;                                \
-                                                                \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << bits3 ) |         \
-          ( ( *c1 & mask ) << bits2 ) |                         \
-          ( ( *c2 & mask ) << bits1 ) |                         \
-          ( ( *c3 & mask ) >> bits0 ) ];                        \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 7:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 20 ) |            \
-          ( ( *c1 & mask ) << 13 ) |                            \
-          ( ( *c2 & mask ) << 6 ) |                             \
-          ( ( *c3 & mask ) >> 1 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 8: /* will never be called */                          \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 24 ) |            \
-          ( ( *c1 & mask ) << 16 ) |                            \
-          ( ( *c2 & mask ) << 8 ) |                             \
-          ( *c3 & mask ) ];                                     \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-  }                                                             \
-}
-
-/***************************************************************/
-#define COLOR_CUBE_S16_3_SEARCH( TABLE_TYPE, SHIFT, STEP )                 \
-{                                                                          \
-  const mlib_s16 *c0, *c1, *c2;                                            \
-  mlib_s32 bits = s->bits;                                                 \
-  mlib_s32 nbits = 16 - bits;                                              \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                                 \
-  TABLE_TYPE *table = s->table;                                            \
-  mlib_s32 j;                                                              \
-                                                                           \
-  c0 = src + SHIFT;                                                        \
-  c1 = src + 1 + SHIFT;                                                    \
-  c2 = src + 2 + SHIFT;                                                    \
-                                                                           \
-  switch( bits )                                                           \
-  {                                                                        \
-    case 1:                                                                \
-    case 2:                                                                \
-    case 3:                                                                \
-    case 4:                                                                \
-    case 5:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits2 = bits1 - bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) >> bits2 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 6:                                                                \
-    case 7:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits2 = bits * 3 - 16;                                      \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits2 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 8:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 8 ) |     \
-          ( ( *c1 - MLIB_S16_MIN ) & mask ) |                              \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 8 ) ];                    \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 9:                                                                \
-    case 10:                                                               \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = 2 * bits - 16;                                      \
-      mlib_s32 bits2 = bits1 + bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits2 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << bits1 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    /* Other cases may not be considered as the table size will be more    \
-       than 2^32 */                                                        \
-  }                                                                        \
-}
-
-/***************************************************************/
-#define COLOR_CUBE_S16_4_SEARCH( TABLE_TYPE )                              \
-{                                                                          \
-  const mlib_s16 *c0, *c1, *c2, *c3;                                       \
-  TABLE_TYPE *table = s->table;                                            \
-  mlib_s32 bits = s->bits;                                                 \
-  mlib_s32 nbits = 16 - bits;                                              \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                                 \
-  mlib_s32 j;                                                              \
-                                                                           \
-  c0 = src;                                                                \
-  c1 = src + 1;                                                            \
-  c2 = src + 2;                                                            \
-  c3 = src + 3;                                                            \
-                                                                           \
-  switch( bits )                                                           \
-  {                                                                        \
-    case 1:                                                                \
-    case 2:                                                                \
-    case 3:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits2 = bits1 - bits;                                       \
-      mlib_s32 bits3 = bits2 - bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) >> bits3 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits2 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 4:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( *c0 - MLIB_S16_MIN ) & mask ) |              \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> 4 ) |                     \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 8 ) |                     \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 12 ) ];                   \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 5:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 4 ) |     \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> 1 ) |                     \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 6 ) |                     \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 11 ) ];                   \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 6:                                                                \
-    case 7:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits3 = bits * 4 - 16;                                      \
-      mlib_s32 bits2 = bits3 - bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits3 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << bits2 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 8:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 16 ) |    \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << 8 ) |                     \
-          ( ( *c2 - MLIB_S16_MIN ) & mask ) |                              \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 8 ) ];                    \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    /* Other cases may not be considered as the table size will be more    \
-       than 2^32 */                                                        \
-  }                                                                        \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_RIGHT( POSITION, COLOR_MAX, SHIFT )  \
-{                                                               \
-  if( ( distance >= ( ( ( position[ POSITION ] + current_size - \
-    c[ POSITION ] ) * ( position[ POSITION ] + current_size -   \
-    c[ POSITION ] ) ) >> SHIFT ) ) &&                           \
-    ( position[ POSITION ] + current_size != COLOR_MAX ) )      \
-    continue_up = 1;                                            \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_RIGHT_3( POSITION, COLOR_MAX, IMAGE_TYPE,    \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, SUBSTRACTION, SHIFT )                   \
-{                                                                        \
-  if( distance >= ( ( ( position[ POSITION ] + current_size -            \
-    c[ POSITION ] ) * ( position[ POSITION ] +                           \
-      current_size - c[ POSITION ] ) ) >> SHIFT ) )                      \
-  {                                                                      \
-    if( distance < ( ( ( COLOR_MAX - c[ POSITION ] ) *                   \
-      ( COLOR_MAX - c[ POSITION ] ) ) >> SHIFT ) )                       \
-    {                                                                    \
-      if( distance < ( ( ( position[ POSITION ] +                        \
-        current_size * 2 - c[ POSITION ] ) *                             \
-        ( position[ POSITION ] + current_size * 2 -                      \
-          c[ POSITION ] ) ) >> SHIFT ) )                                 \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_3(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-    else /* Cell is on the edge of the space */                          \
-    {                                                                    \
-      if( position[ POSITION ] + current_size * 2 ==                     \
-        COLOR_MAX )                                                      \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_3(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size,                       \
-              pass - 1, POSITION );                                      \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_RIGHT_4( POSITION, COLOR_MAX, IMAGE_TYPE,    \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, THIRD_NEIBOUR, SUBSTRACTION, SHIFT )    \
-{                                                                        \
-  if( distance >= ( ( ( position[ POSITION ] + current_size -            \
-    c[ POSITION ] ) * ( position[ POSITION ] +                           \
-      current_size - c[ POSITION ] ) ) >> SHIFT ) )                      \
-  {                                                                      \
-    if( distance < ( ( ( COLOR_MAX - c[ POSITION ] ) *                   \
-      ( COLOR_MAX - c[ POSITION ] ) ) >> SHIFT ) )                       \
-    {                                                                    \
-      if( distance < ( ( ( position[ POSITION ] +                        \
-        current_size * 2 - c[ POSITION ] ) *                             \
-        ( position[ POSITION ] + current_size * 2 -                      \
-          c[ POSITION ] ) ) >> SHIFT ) )                                 \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_4(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-    else /* Cell is on the edge of the space */                          \
-    {                                                                    \
-      if( position[ POSITION ] + current_size * 2 ==                     \
-        COLOR_MAX )                                                      \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_4(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size,                       \
-              pass - 1, POSITION );                                      \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_LEFT( POSITION, SHIFT )                \
-{                                                                 \
-  if( ( distance > ( ( ( position[ POSITION ] - c[ POSITION ] ) * \
-    ( position[ POSITION ] - c[ POSITION ] ) ) >> SHIFT ) )  &&   \
-    position[ POSITION ] )                                        \
-    continue_up = 1;                                              \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_LEFT_3( POSITION, IMAGE_TYPE,                \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, SUBSTRACTION, SHIFT )                   \
-{                                                                        \
-  if( distance >                                                         \
-    ( ( ( c[ POSITION ] - position[ POSITION ] ) *                       \
-    ( c[ POSITION ] - position[ POSITION ] ) ) >> SHIFT ) )              \
-  {                                                                      \
-    if( distance <= ( ( c[ POSITION ] * c[ POSITION ] ) >> SHIFT ) )     \
-    {                                                                    \
-      if( distance <= ( ( ( c[ POSITION ] + current_size -               \
-        position[ POSITION ] ) *                                         \
-        ( c[ POSITION ] + current_size -                                 \
-          position[ POSITION ] ) ) >> SHIFT ) )                          \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_3(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-    else                                                                 \
-    {                                                                    \
-      if( !( position[ POSITION ] - current_size ) )                     \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_3(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else                                                               \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_LEFT_4( POSITION, IMAGE_TYPE,                \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, THIRD_NEIBOUR, SUBSTRACTION, SHIFT )    \
-{                                                                        \
-  if( distance >                                                         \
-    ( ( ( c[ POSITION ] - position[ POSITION ] ) *                       \
-    ( c[ POSITION ] - position[ POSITION ] ) ) >> SHIFT ) )              \
-  {                                                                      \
-    if( distance <= ( ( c[ POSITION ] * c[ POSITION ] ) >> SHIFT ) )     \
-    {                                                                    \
-      if( distance <= ( ( ( c[ POSITION ] + current_size -               \
-        position[ POSITION ] ) *                                         \
-        ( c[ POSITION ] + current_size -                                 \
-          position[ POSITION ] ) ) >> SHIFT ) )                          \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_4(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-    else                                                                 \
-    {                                                                    \
-      if( !( position[ POSITION ] - current_size ) )                     \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_4(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else                                                               \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_U8_3( qq )                               \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],             \
-      p[ 0 ][ new_found_color ], c[ 1 ],                        \
-      p[ 1 ][ new_found_color ], c[ 2 ],                        \
-      p[ 2 ][ new_found_color ], 0 );                           \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_U8_3(                       \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], p );                              \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_S16_3( qq )                              \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 palc0, palc1, palc2, newdistance;                  \
-                                                                \
-    palc0 = p[ 0 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc1 = p[ 1 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc2 = p[ 2 ][ new_found_color ] - MLIB_S16_MIN;           \
-                                                                \
-    newdistance = FIND_DISTANCE_3( c[ 0 ], palc0,               \
-      c[ 1 ], palc1,                                            \
-      c[ 2 ], palc2, 2 );                                       \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_S16_3(                      \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], p );                              \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_3( SOURCE_IMAGE, POINTER_TYPE, BITS,              \
-  COLOR_MAX, SUBTRACTION, POINTER_SHIFT, STEP, SHIFT )                       \
-{                                                                            \
-  const POINTER_TYPE *channels[ 3 ], *p[ 3 ];                                \
-  mlib_u32 c[ 3 ];                                                           \
-  mlib_s32 j;                                                                \
-                                                                             \
-  p[ 0 ] = s->lut[ 0 ];                                                      \
-  p[ 1 ] = s->lut[ 1 ];                                                      \
-  p[ 2 ] = s->lut[ 2 ];                                                      \
-  channels[ 0 ] = src + POINTER_SHIFT;                                       \
-  channels[ 1 ] = src + 1 + POINTER_SHIFT;                                   \
-  channels[ 2 ] = src + 2 + POINTER_SHIFT;                                   \
-                                                                             \
-  for( j = 0; j < length; j++ )                                              \
-  {                                                                          \
-    mlib_s32 pass = BITS - 1;                                                \
-    mlib_u32 position[ 3 ] = { 0, 0, 0 };                                    \
-    mlib_s32 we_found_it = 0;                                                \
-    struct lut_node_3 *node = s->table;                                      \
-    /* Stack pointer pointers to the first free element of stack. */         \
-    /* The node we are in is in the `node' */                                \
-    struct                                                                   \
-    {                                                                        \
-      struct lut_node_3 *node;                                               \
-      mlib_s32 q;                                                            \
-    } stack[ BITS ];                                                         \
-    mlib_s32 stack_pointer = 0;                                              \
-                                                                             \
-    c[ 0 ] = *channels[ 0 ] - SUBTRACTION;                                   \
-    c[ 1 ] = *channels[ 1 ] - SUBTRACTION;                                   \
-    c[ 2 ] = *channels[ 2 ] - SUBTRACTION;                                   \
-                                                                             \
-    do                                                                       \
-    {                                                                        \
-      mlib_s32 q;                                                            \
-      mlib_u32 current_size = 1 << pass;                                     \
-                                                                             \
-      q = ( ( c[ 0 ] >> pass ) & 1 ) |                                       \
-        ( ( ( c[ 1 ] << 1 ) >> pass ) & 2 ) |                                \
-        ( ( ( c[ 2 ] << 2 ) >> pass ) & 4 );                                 \
-                                                                             \
-      position[ 0 ] |= c[ 0 ] & current_size;                                \
-      position[ 1 ] |= c[ 1 ] & current_size;                                \
-      position[ 2 ] |= c[ 2 ] & current_size;                                \
-                                                                             \
-      if( node->tag & ( 1 << q ) )                                           \
-      {                                                                      \
-        /*                                                                   \
-          Here is a cell with one color. We need to be sure it's             \
-          the one that is the closest to our color                           \
-        */                                                                   \
-        mlib_s32 palindex = node->contents.index[ q ];                       \
-        mlib_u32 palc[ 3 ];                                                  \
-        mlib_s32 identical;                                                  \
-                                                                             \
-        palc[ 0 ] = p[ 0 ][ palindex ] - SUBTRACTION;                        \
-        palc[ 1 ] = p[ 1 ][ palindex ] - SUBTRACTION;                        \
-        palc[ 2 ] = p[ 2 ][ palindex ] - SUBTRACTION;                        \
-                                                                             \
-        identical = ( palc[ 0 ] - c[ 0 ] ) | ( palc[ 1 ] - c[ 1 ] ) |        \
-          ( palc[ 2 ] - c[ 2 ] );                                            \
-                                                                             \
-        if( !identical || BITS - pass == bits )                              \
-        {                                                                    \
-          /* Oh, here it is :) */                                            \
-          dst[ j ] = palindex + s->offset;                                   \
-          we_found_it = 1;                                                   \
-        }                                                                    \
-        else                                                                 \
-        {                                                                    \
-          mlib_u32 distance;                                                 \
-          /* First index is the channel, second is the number of the         \
-             side */                                                         \
-          mlib_s32 found_color;                                              \
-          mlib_s32 continue_up;                                              \
-                                                                             \
-          distance = FIND_DISTANCE_3( c[ 0 ], palc[ 0 ],                     \
-            c[ 1 ], palc[ 1 ], c[ 2 ], palc[ 2 ], SHIFT );                   \
-          found_color = palindex;                                            \
-                                                                             \
-          do                                                                 \
-          {                                                                  \
-            mlib_s32 check_corner;                                           \
-                                                                             \
-            /*                                                               \
-              Neibours are enumerated in a cicle:                            \
-              0 - between quadrants 0 and 1,                                 \
-              1 - between quadrants 1 and 2 and                              \
-              2 - between quadrants 2 and 0                                  \
-            */                                                               \
-            mlib_s32 check_neibours[ 3 ];                                    \
-                                                                             \
-            /*                                                               \
-              Others are three two neibour quadrants                         \
-                                                                             \
-              Side number is [ <number of the coordinate >][ <the bit        \
-              in the quadrant number of the corner, corresponding to         \
-              this coordinate> ], e.g. 2 is 0..010b, so the sides it has     \
-              near are:                                                      \
-              [ 0 (coordinate number) ][ 0 (bit 0 in the number) ]           \
-              [ 1 (coordinate number) ][ 1 (bit 1 in the number) ]           \
-                                                                             \
-              Now we can look in the three nearest quadrants. Do             \
-              we really need it ? Check it.                                  \
-            */                                                               \
-                                                                             \
-            check_corner = check_neibours[ 0 ] = check_neibours[ 1 ] =       \
-              check_neibours[ 2 ] = 0;                                       \
-            continue_up = 0;                                                 \
-                                                                             \
-            if( q & 1 )                                                      \
-            {                                                                \
-              BINARY_TREE_EXPLORE_LEFT_3( 0, SOURCE_IMAGE, 2, 0,             \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_EXPLORE_RIGHT_3( 0, COLOR_MAX, SOURCE_IMAGE, 2, 0, \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-                                                                             \
-            if( q & 2 )                                                      \
-            {                                                                \
-              BINARY_TREE_EXPLORE_LEFT_3( 1, SOURCE_IMAGE, 0, 1,             \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_EXPLORE_RIGHT_3( 1, COLOR_MAX, SOURCE_IMAGE, 0, 1, \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-                                                                             \
-            if( q & 4 )                                                      \
-            {                                                                \
-              BINARY_TREE_EXPLORE_LEFT_3( 2, SOURCE_IMAGE, 1, 2,             \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_EXPLORE_RIGHT_3( 2, COLOR_MAX, SOURCE_IMAGE, 1, 2, \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-                                                                             \
-            if( check_neibours[ 0 ] >= 2 )                                   \
-            {                                                                \
-              mlib_s32 qq = q ^ 3;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( check_neibours[ 1 ] >= 2 )                                   \
-            {                                                                \
-              mlib_s32 qq = q ^ 6;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( check_neibours[ 2 ] >= 2 )                                   \
-            {                                                                \
-              mlib_s32 qq = q ^ 5;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( check_corner >= 3 )                                          \
-            {                                                                \
-              mlib_s32 qq = q ^ 7;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( q & 1 )                                                      \
-            {                                                                \
-              BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );               \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                           \
-            }                                                                \
-                                                                             \
-            if( q & 2 )                                                      \
-            {                                                                \
-              BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );               \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                           \
-            }                                                                \
-                                                                             \
-            if( q & 4 )                                                      \
-            {                                                                \
-              BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );               \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                           \
-            }                                                                \
-                                                                             \
-            position[ 0 ] &= ~( c[ 0 ] & current_size );                     \
-            position[ 1 ] &= ~( c[ 1 ] & current_size );                     \
-            position[ 2 ] &= ~( c[ 2 ] & current_size );                     \
-                                                                             \
-            current_size <<= 1;                                              \
-                                                                             \
-            pass++;                                                          \
-                                                                             \
-            stack_pointer--;                                                 \
-            q = stack[ stack_pointer ].q;                                    \
-            node = stack[ stack_pointer ].node;                              \
-          } while( continue_up );                                            \
-                                                                             \
-          dst[ j ] = found_color + s->offset;                                \
-                                                                             \
-          we_found_it = 1;                                                   \
-        }                                                                    \
-      }                                                                      \
-      else if( node->contents.quadrants[ q ] )                               \
-      {                                                                      \
-        /* Descend one level */                                              \
-        stack[ stack_pointer ].node = node;                                  \
-        stack[ stack_pointer++ ].q = q;                                      \
-        node = node->contents.quadrants[ q ];                                \
-      }                                                                      \
-      else                                                                   \
-      {                                                                      \
-        /* Found the empty quadrant. Look around */                          \
-        mlib_u32 distance = MLIB_U32_MAX;                                    \
-        mlib_s32 found_color;                                                \
-        mlib_s32 continue_up;                                                \
-                                                                             \
-        /*                                                                   \
-          As we had come to this level, it is warranted that there           \
-          are other points on this level near the empty quadrant             \
-        */                                                                   \
-        do                                                                   \
-        {                                                                    \
-          mlib_s32 check_corner;                                             \
-          mlib_s32 check_neibours[ 3 ];                                      \
-                                                                             \
-          check_corner = check_neibours[ 0 ] = check_neibours[ 1 ] =         \
-            check_neibours[ 2 ] = 0;                                         \
-          continue_up = 0;                                                   \
-                                                                             \
-          if( q & 1 )                                                        \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_LEFT_3( 0, SOURCE_IMAGE, 2, 0,               \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_RIGHT_3( 0, COLOR_MAX, SOURCE_IMAGE, 2, 0,   \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-                                                                             \
-          if( q & 2 )                                                        \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_LEFT_3( 1, SOURCE_IMAGE, 0, 1,               \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_RIGHT_3( 1, COLOR_MAX, SOURCE_IMAGE, 0, 1,   \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-                                                                             \
-          if( q & 4 )                                                        \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_LEFT_3( 2, SOURCE_IMAGE, 1, 2,               \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_RIGHT_3( 2, COLOR_MAX, SOURCE_IMAGE, 1, 2,   \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-                                                                             \
-          if( check_neibours[ 0 ] >= 2 )                                     \
-          {                                                                  \
-            mlib_s32 qq = q ^ 3;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( check_neibours[ 1 ] >= 2 )                                     \
-          {                                                                  \
-            mlib_s32 qq = q ^ 6;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( check_neibours[ 2 ] >= 2 )                                     \
-          {                                                                  \
-            mlib_s32 qq = q ^ 5;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( check_corner >= 3 )                                            \
-          {                                                                  \
-            mlib_s32 qq = q ^ 7;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( q & 1 )                                                        \
-          {                                                                  \
-            BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );                 \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                             \
-          }                                                                  \
-                                                                             \
-          if( q & 2 )                                                        \
-          {                                                                  \
-            BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );                 \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                             \
-          }                                                                  \
-                                                                             \
-          if( q & 4 )                                                        \
-          {                                                                  \
-            BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );                 \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                             \
-          }                                                                  \
-                                                                             \
-          position[ 0 ] &= ~( c[ 0 ] & current_size );                       \
-          position[ 1 ] &= ~( c[ 1 ] & current_size );                       \
-          position[ 2 ] &= ~( c[ 2 ] & current_size );                       \
-                                                                             \
-          current_size <<= 1;                                                \
-                                                                             \
-          pass++;                                                            \
-                                                                             \
-          stack_pointer--;                                                   \
-          q = stack[ stack_pointer ].q;                                      \
-          node = stack[ stack_pointer ].node;                                \
-        } while( continue_up );                                              \
-                                                                             \
-        dst[ j ] = found_color + s->offset;                                  \
-        we_found_it = 1;                                                     \
-      }                                                                      \
-                                                                             \
-      pass--;                                                                \
-                                                                             \
-    } while( !we_found_it );                                                 \
-                                                                             \
-    channels[ 0 ] += STEP;                                                   \
-    channels[ 1 ] += STEP;                                                   \
-    channels[ 2 ] += STEP;                                                   \
-  }                                                                          \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_U8_4( qq )                               \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],             \
-      p[ 0 ][ new_found_color ], c[ 1 ],                        \
-      p[ 1 ][ new_found_color ], c[ 2 ],                        \
-      p[ 2 ][ new_found_color ], c[ 3 ],                        \
-      p[ 3 ][ new_found_color ], 0 );                           \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_U8_4(                       \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p );                      \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_S16_4( qq )                              \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 palc0, palc1, palc2, palc3, newdistance;           \
-                                                                \
-    palc0 = p[ 0 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc1 = p[ 1 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc2 = p[ 2 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc3 = p[ 3 ][ new_found_color ] - MLIB_S16_MIN;           \
-                                                                \
-    newdistance = FIND_DISTANCE_4( c[ 0 ], palc0,               \
-      c[ 1 ], palc1,                                            \
-      c[ 2 ], palc2,                                            \
-      c[ 3 ], palc3, 2 );                                       \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_S16_4(                      \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p );                      \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_4( SOURCE_IMAGE, POINTER_TYPE, BITS,               \
-  COLOR_MAX, SUBTRACTION, SHIFT )                                             \
-{                                                                             \
-  const POINTER_TYPE *channels[ 4 ], *p[ 4 ];                                 \
-  mlib_u32 c[ 4 ];                                                            \
-  mlib_s32 j;                                                                 \
-                                                                              \
-  p[ 0 ] = s->lut[ 0 ];                                                       \
-  p[ 1 ] = s->lut[ 1 ];                                                       \
-  p[ 2 ] = s->lut[ 2 ];                                                       \
-  p[ 3 ] = s->lut[ 3 ];                                                       \
-  channels[ 0 ] = src;                                                        \
-  channels[ 1 ] = src + 1;                                                    \
-  channels[ 2 ] = src + 2;                                                    \
-  channels[ 3 ] = src + 3;                                                    \
-                                                                              \
-  for( j = 0; j < length; j++ )                                               \
-  {                                                                           \
-    mlib_s32 pass = BITS - 1;                                                 \
-    mlib_u32 position[ 4 ] = { 0, 0, 0, 0 };                                  \
-    mlib_s32 we_found_it = 0;                                                 \
-    struct lut_node_4 *node = s->table;                                       \
-    /* Stack pointer pointers to the first free element of stack. */          \
-    /* The node we are in is in the `node' */                                 \
-    struct                                                                    \
-    {                                                                         \
-      struct lut_node_4 *node;                                                \
-      mlib_s32 q;                                                             \
-    } stack[ BITS ];                                                          \
-    mlib_s32 stack_pointer = 0;                                               \
-                                                                              \
-    c[ 0 ] = *channels[ 0 ] - SUBTRACTION;                                    \
-    c[ 1 ] = *channels[ 1 ] - SUBTRACTION;                                    \
-    c[ 2 ] = *channels[ 2 ] - SUBTRACTION;                                    \
-    c[ 3 ] = *channels[ 3 ] - SUBTRACTION;                                    \
-                                                                              \
-    do                                                                        \
-    {                                                                         \
-      mlib_s32 q;                                                             \
-      mlib_u32 current_size = 1 << pass;                                      \
-                                                                              \
-      q = ( ( c[ 0 ] >> pass ) & 1 ) |                                        \
-        ( ( ( c[ 1 ] << 1 ) >> pass ) & 2 ) |                                 \
-        ( ( ( c[ 2 ] << 2 ) >> pass ) & 4 ) |                                 \
-        ( ( ( c[ 3 ] << 3 ) >> pass ) & 8 );                                  \
-                                                                              \
-      position[ 0 ] |= c[ 0 ] & current_size;                                 \
-      position[ 1 ] |= c[ 1 ] & current_size;                                 \
-      position[ 2 ] |= c[ 2 ] & current_size;                                 \
-      position[ 3 ] |= c[ 3 ] & current_size;                                 \
-                                                                              \
-      if( node->tag & ( 1 << q ) )                                            \
-      {                                                                       \
-        /*                                                                    \
-          Here is a cell with one color. We need to be sure it's              \
-          the one that is the closest to our color                            \
-        */                                                                    \
-        mlib_s32 palindex = node->contents.index[ q ];                        \
-        mlib_u32 palc[ 4 ];                                                   \
-        mlib_s32 identical;                                                   \
-                                                                              \
-        palc[ 0 ] = p[ 0 ][ palindex ] - SUBTRACTION;                         \
-        palc[ 1 ] = p[ 1 ][ palindex ] - SUBTRACTION;                         \
-        palc[ 2 ] = p[ 2 ][ palindex ] - SUBTRACTION;                         \
-        palc[ 3 ] = p[ 3 ][ palindex ] - SUBTRACTION;                         \
-                                                                              \
-        identical = ( palc[ 0 ] - c[ 0 ] ) | ( palc[ 1 ] - c[ 1 ] ) |         \
-          ( palc[ 2 ] - c[ 2 ] ) | ( palc[ 3 ] - c[ 3 ] );                    \
-                                                                              \
-        if( !identical || BITS - pass == bits )                               \
-        {                                                                     \
-          /* Oh, here it is :) */                                             \
-          dst[ j ] = palindex + s->offset;                                    \
-          we_found_it = 1;                                                    \
-        }                                                                     \
-        else                                                                  \
-        {                                                                     \
-          mlib_u32 distance;                                                  \
-          /* First index is the channel, second is the number of the          \
-             side */                                                          \
-          mlib_s32 found_color;                                               \
-          mlib_s32 continue_up;                                               \
-                                                                              \
-          distance = FIND_DISTANCE_4( c[ 0 ], palc[ 0 ],                      \
-            c[ 1 ], palc[ 1 ], c[ 2 ], palc[ 2 ], c[ 3 ], palc[ 3 ], SHIFT ); \
-          found_color = palindex;                                             \
-                                                                              \
-          do                                                                  \
-          {                                                                   \
-            mlib_s32 check_corner;                                            \
-            mlib_s32 check_neibours[ 6 ];                                     \
-            mlib_s32 check_far_neibours[ 4 ];                                 \
-                                                                              \
-            /*                                                                \
-              Check neibours: quadrants that are different by 2 bits          \
-              from the quadrant, that we are in:                              \
-              3 -  0                                                          \
-              5 -  1                                                          \
-              6 -  2                                                          \
-              9 -  3                                                          \
-              10 - 4                                                          \
-              12 - 5                                                          \
-              Far quadrants: different by 3 bits:                             \
-              7  - 0                                                          \
-              11 - 1                                                          \
-              13 - 2                                                          \
-              14 - 3                                                          \
-            */                                                                \
-                                                                              \
-            check_neibours[ 0 ] = check_neibours[ 1 ] =                       \
-              check_neibours[ 2 ] = check_neibours[ 3 ] =                     \
-              check_neibours[ 4 ] = check_neibours[ 5 ] = 0;                  \
-            continue_up = 0;                                                  \
-                                                                              \
-            if( q & 1 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 0, SOURCE_IMAGE, 0, 1, 3,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 0, COLOR_MAX, SOURCE_IMAGE,        \
-                0, 1, 3, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            if( q & 2 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 1, SOURCE_IMAGE, 0, 2, 4,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 1, COLOR_MAX, SOURCE_IMAGE,        \
-                0, 2, 4, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            if( q & 4 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 2, SOURCE_IMAGE, 1, 2, 5,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 2, COLOR_MAX, SOURCE_IMAGE,        \
-                1, 2, 5, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            if( q & 8 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 3, SOURCE_IMAGE, 3, 4, 5,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 3, COLOR_MAX, SOURCE_IMAGE,        \
-                3, 4, 5, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            check_far_neibours[ 0 ] = check_neibours[ 0 ] +                   \
-              check_neibours[ 1 ] + check_neibours[ 2 ];                      \
-            check_far_neibours[ 1 ] = check_neibours[ 0 ] +                   \
-              check_neibours[ 3 ] + check_neibours[ 4 ];                      \
-            check_far_neibours[ 2 ] = check_neibours[ 1 ] +                   \
-              check_neibours[ 3 ] + check_neibours[ 5 ];                      \
-            check_far_neibours[ 3 ] = check_neibours[ 2 ] +                   \
-              check_neibours[ 4 ] + check_neibours[ 5 ];                      \
-                                                                              \
-            check_corner = check_far_neibours[ 0 ] +                          \
-              check_far_neibours[ 1 ] +                                       \
-              check_far_neibours[ 2 ] +                                       \
-              check_far_neibours[ 3 ];                                        \
-                                                                              \
-            if( check_neibours[ 0 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 3;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 1 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 5;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 2 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 6;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 3 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 9;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 4 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 10;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 5 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 12;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 0 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 7;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 1 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 11;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 2 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 13;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 3 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 14;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_corner >= 4 )                                           \
-            {                                                                 \
-              mlib_s32 qq = q ^ 15;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( q & 1 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            if( q & 2 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            if( q & 4 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            if( q & 8 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 3, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 3, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            position[ 0 ] &= ~( c[ 0 ] & current_size );                      \
-            position[ 1 ] &= ~( c[ 1 ] & current_size );                      \
-            position[ 2 ] &= ~( c[ 2 ] & current_size );                      \
-            position[ 3 ] &= ~( c[ 3 ] & current_size );                      \
-                                                                              \
-            current_size <<= 1;                                               \
-                                                                              \
-            pass++;                                                           \
-                                                                              \
-            stack_pointer--;                                                  \
-            q = stack[ stack_pointer ].q;                                     \
-            node = stack[ stack_pointer ].node;                               \
-          } while( continue_up );                                             \
-                                                                              \
-          dst[ j ] = found_color + s->offset;                                 \
-          we_found_it = 1;                                                    \
-        }                                                                     \
-      }                                                                       \
-      else if( node->contents.quadrants[ q ] )                                \
-      {                                                                       \
-        /* Descend one level */                                               \
-        stack[ stack_pointer ].node = node;                                   \
-        stack[ stack_pointer++ ].q = q;                                       \
-        node = node->contents.quadrants[ q ];                                 \
-      }                                                                       \
-      else                                                                    \
-      {                                                                       \
-        /* Found the empty quadrant. Look around */                           \
-        mlib_u32 distance = MLIB_U32_MAX;                                     \
-        mlib_s32 found_color;                                                 \
-        mlib_s32 continue_up;                                                 \
-                                                                              \
-        /*                                                                    \
-          As we had come to this level, it is warranted that there            \
-          are other points on this level near the empty quadrant              \
-        */                                                                    \
-        do                                                                    \
-        {                                                                     \
-          mlib_s32 check_corner;                                              \
-          mlib_s32 check_neibours[ 6 ];                                       \
-          mlib_s32 check_far_neibours[ 4 ];                                   \
-                                                                              \
-          /*                                                                  \
-            Check neibours: quadrants that are different by 2 bits            \
-            from the quadrant, that we are in:                                \
-            3 -  0                                                            \
-            5 -  1                                                            \
-            6 -  2                                                            \
-            9 -  3                                                            \
-            10 - 4                                                            \
-            12 - 5                                                            \
-            Far quadrants: different by 3 bits:                               \
-            7  - 0                                                            \
-            11 - 1                                                            \
-            13 - 2                                                            \
-            14 - 3                                                            \
-          */                                                                  \
-                                                                              \
-          check_neibours[ 0 ] = check_neibours[ 1 ] =                         \
-            check_neibours[ 2 ] = check_neibours[ 3 ] =                       \
-            check_neibours[ 4 ] = check_neibours[ 5 ] = 0;                    \
-          continue_up = 0;                                                    \
-                                                                              \
-          if( q & 1 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 0, SOURCE_IMAGE, 0, 1, 3,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 0, COLOR_MAX, SOURCE_IMAGE,          \
-              0, 1, 3, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          if( q & 2 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 1, SOURCE_IMAGE, 0, 2, 4,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 1, COLOR_MAX, SOURCE_IMAGE,          \
-              0, 2, 4, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          if( q & 4 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 2, SOURCE_IMAGE, 1, 2, 5,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 2, COLOR_MAX, SOURCE_IMAGE,          \
-              1, 2, 5, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          if( q & 8 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 3, SOURCE_IMAGE, 3, 4, 5,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 3, COLOR_MAX, SOURCE_IMAGE,          \
-              3, 4, 5, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          check_far_neibours[ 0 ] = check_neibours[ 0 ] +                     \
-            check_neibours[ 1 ] + check_neibours[ 2 ];                        \
-          check_far_neibours[ 1 ] = check_neibours[ 0 ] +                     \
-            check_neibours[ 3 ] + check_neibours[ 4 ];                        \
-          check_far_neibours[ 2 ] = check_neibours[ 1 ] +                     \
-            check_neibours[ 3 ] + check_neibours[ 5 ];                        \
-          check_far_neibours[ 3 ] = check_neibours[ 2 ] +                     \
-            check_neibours[ 4 ] + check_neibours[ 5 ];                        \
-                                                                              \
-          check_corner = check_far_neibours[ 0 ] +                            \
-            check_far_neibours[ 1 ] +                                         \
-            check_far_neibours[ 2 ] +                                         \
-            check_far_neibours[ 3 ];                                          \
-                                                                              \
-          if( check_neibours[ 0 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 3;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 1 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 5;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 2 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 6;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 3 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 9;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 4 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 10;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 5 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 12;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 0 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 7;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 1 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 11;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 2 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 13;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 3 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 14;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_corner >= 4 )                                             \
-          {                                                                   \
-            mlib_s32 qq = q ^ 15;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( q & 1 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          if( q & 2 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          if( q & 4 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          if( q & 8 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 3, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 3, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          position[ 0 ] &= ~( c[ 0 ] & current_size );                        \
-          position[ 1 ] &= ~( c[ 1 ] & current_size );                        \
-          position[ 2 ] &= ~( c[ 2 ] & current_size );                        \
-          position[ 3 ] &= ~( c[ 3 ] & current_size );                        \
-                                                                              \
-          current_size <<= 1;                                                 \
-                                                                              \
-          pass++;                                                             \
-                                                                              \
-          stack_pointer--;                                                    \
-          q = stack[ stack_pointer ].q;                                       \
-          node = stack[ stack_pointer ].node;                                 \
-        } while( continue_up );                                               \
-                                                                              \
-        dst[ j ] = found_color + s->offset;                                   \
-        we_found_it = 1;                                                      \
-      }                                                                       \
-                                                                              \
-      pass--;                                                                 \
-                                                                              \
-    } while( !we_found_it );                                                  \
-                                                                              \
-    channels[ 0 ] += 4;                                                       \
-    channels[ 1 ] += 4;                                                       \
-    channels[ 2 ] += 4;                                                       \
-    channels[ 3 ] += 4;                                                       \
-  }                                                                           \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_U8_3_C( SHIFT, STEP )                      \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s -> lutlength;                            \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2;                                    \
-  mlib_d64 dist, len0, len1, len2;                              \
-                                                                \
-  for ( i = 0; i < length; i++ ) {                              \
-    col0 = src[ STEP * i + SHIFT ];                             \
-    col1 = src[ STEP * i + 1 + SHIFT ];                         \
-    col2 = src[ STEP * i + 2 + SHIFT ];                         \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-                                                                \
-    for ( k = 1; k <= entries; k++ ) {                          \
-      dist = len0 * len0;                                       \
-      len0 = double_lut[ 3 * k ] - col0;                        \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 3 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 = double_lut[ 3 * k + 2 ] - col2;                    \
-      diff = ( mlib_s32 )dist - min_dist;                       \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-                                                                \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-#define FIND_NEAREST_U8_4_C                                     \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s -> lutlength;                            \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2, col3;                              \
-  mlib_d64 dist, len0, len1, len2, len3;                        \
-                                                                \
-  for ( i = 0; i < length; i++ ) {                              \
-    col0 = src[ 4 * i ];                                        \
-    col1 = src[ 4 * i + 1 ];                                    \
-    col2 = src[ 4 * i + 2 ];                                    \
-    col3 = src[ 4 * i + 3 ];                                    \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-    len3 = double_lut[ 3 ] - col3;                              \
-                                                                \
-    for ( k = 1; k <= entries; k++ ) {                          \
-      dist = len0 * len0;                                       \
-      len0 =  double_lut[ 4 * k ] - col0;                       \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 4 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 =  double_lut[ 4 * k + 2 ] - col2;                   \
-      dist += len3 * len3;                                      \
-      len3 =  double_lut[ 4 * k + 3 ] - col3;                   \
-      diff = ( mlib_s32 )dist - min_dist;                       \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-                                                                \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-#define FSQR_S16_HI(dsrc)                                                   \
-  vis_fpadd32( vis_fmuld8ulx16( vis_read_hi( dsrc ), vis_read_hi( dsrc ) ), \
-    vis_fmuld8sux16( vis_read_hi( dsrc ), vis_read_hi( dsrc ) ) )
-
-/***************************************************************/
-#define FSQR_S16_LO(dsrc)                                                  \
-  vis_fpadd32( vis_fmuld8ulx16( vis_read_lo( dsrc ), vis_read_lo( dsrc) ), \
-    vis_fmuld8sux16( vis_read_lo( dsrc ), vis_read_lo( dsrc ) ) )
-
-/***************************************************************/
-#define FIND_NEAREST_U8_3                                             \
-{                                                                     \
-  mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3;        \
-  mlib_d64 dcolor, dind, dres, dres1, dpind[1], dpmin[1];             \
-  mlib_d64 done = vis_to_double_dup( 1 ),                             \
-           dmax = vis_to_double_dup( MLIB_S32_MAX );                  \
-  mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s );     \
-  mlib_f32 fone = vis_to_float( 0x100 );                              \
-  mlib_s32 i, k, mask;                                                \
-  mlib_s32 gsr[1];                                                    \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;                  \
-  mlib_s32 entries = s->lutlength;                                    \
-                                                                      \
-  gsr[0] = vis_read_gsr();                                            \
-  for( i = 0; i <= ( length-2 ); i += 2 )                             \
-  {                                                                   \
-    dpsrc = VIS_ALIGNADDR( src, -1 );                                 \
-    src += 6;                                                         \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    VIS_ALIGNADDR( dpsrc, 3 );                                        \
-    dsrc1 = vis_faligndata( dsrc1, dsrc1 );                           \
-    dsrc1 = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );             \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    dcolor = vis_fmul8x16al( lut[ 0 ], fone );                        \
-    for( k = 1; k <= entries; k++ )                                   \
-    {                                                                 \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      ddist3 = vis_fpsub16( dcolor, dsrc1 );                          \
-      ddist2 = FSQR_S16_HI( ddist3 );                                 \
-      ddist3 = FSQR_S16_LO( ddist3 );                                 \
-      dres1 = vis_fpadd32( ddist2, ddist3 );                          \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      dres = vis_freg_pair(                                           \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ),     \
-        vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset;                 \
-    dst[ i + 1 ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;              \
-  }                                                                   \
-  if( i < length )                                                    \
-  {                                                                   \
-    dpsrc = VIS_ALIGNADDR( src, -1 );                                 \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    for( k = 0; k < entries; k++ )                                    \
-    {                                                                 \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      dres = vis_write_lo( dres,                                      \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) );   \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;                  \
-  }                                                                   \
-  vis_write_gsr(gsr[0]);                                              \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_U8_3_IN4                                         \
-{                                                                     \
-  mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3;        \
-  mlib_d64 dcolor, dind, dres, dres1, dpind[1], dpmin[1];             \
-  mlib_d64 done = vis_to_double_dup( 1 ),                             \
-           dmax = vis_to_double_dup( MLIB_S32_MAX );                  \
-  mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s );     \
-  mlib_f32 fone = vis_to_float( 0x100 );                              \
-  mlib_s32 i, k, mask, gsr[1];                                        \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;                  \
-  mlib_s32 entries = s->lutlength;                                    \
-                                                                      \
-  gsr[0] = vis_read_gsr();                                            \
-  dpsrc = VIS_ALIGNADDR( src, 0 );                                    \
-  for( i = 0; i <= ( length-2 ); i += 2 )                             \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dpsrc++;                                                          \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dsrc1 = vis_fmul8x16al( vis_read_lo( dsrc1 ), fone );             \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    dcolor = vis_fmul8x16al( lut[ 0 ], fone );                        \
-    for( k = 1; k <= entries; k++ )                                   \
-    {                                                                 \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      ddist3 = vis_fpsub16( dcolor, dsrc1 );                          \
-      ddist2 = FSQR_S16_HI( ddist3 );                                 \
-      ddist3 = FSQR_S16_LO( ddist3 );                                 \
-      dres1 = vis_fpadd32( ddist2, ddist3 );                          \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      dres = vis_freg_pair(                                           \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ),     \
-        vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset;                 \
-    dst[ i + 1 ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;              \
-  }                                                                   \
-  if( i < length )                                                    \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    for( k = 0; k < entries; k++ )                                    \
-    {                                                                 \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      dres = vis_write_lo( dres,                                      \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) );   \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;                  \
-  }                                                                   \
-  vis_write_gsr(gsr[0]);                                              \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_U8_4                                             \
-{                                                                     \
-  mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3;        \
-  mlib_d64 dcolor, dind, dres, dres1, dpind[ 1 ], dpmin[ 1 ];         \
-  mlib_d64 done = vis_to_double_dup( 1 ),                             \
-           dmax = vis_to_double_dup( MLIB_S32_MAX );                  \
-  mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s );     \
-  mlib_f32 fone = vis_to_float( 0x100 );                              \
-  mlib_s32 i, k, mask, gsr[1];                                        \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;                  \
-  mlib_s32 entries = s->lutlength;                                    \
-                                                                      \
-  gsr[0] = vis_read_gsr();                                            \
-  dpsrc = VIS_ALIGNADDR( src, 0 );                                    \
-  for( i = 0; i <= ( length-2 ); i += 2 )                             \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dpsrc++;                                                          \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dsrc1 = vis_fmul8x16al( vis_read_lo( dsrc1 ), fone );             \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    dcolor = vis_fmul8x16al(lut[0], fone);                            \
-    for( k = 1; k <= entries; k++ )                                   \
-    {                                                                 \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      ddist3 = vis_fpsub16( dcolor, dsrc1 );                          \
-      ddist2 = FSQR_S16_HI( ddist3 );                                 \
-      ddist3 = FSQR_S16_LO( ddist3 );                                 \
-      dres1 = vis_fpadd32( ddist2, ddist3 );                          \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      dres = vis_freg_pair(                                           \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ),     \
-        vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset;                 \
-    dst[ i + 1 ] = ( ( mlib_s32 * )dpind )[ 1 ] + offset;             \
-  }                                                                   \
-  if( i < length )                                                    \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    for( k = 0; k < entries; k++ )                                    \
-    {                                                                 \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      dres = vis_write_lo( dres,                                      \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) );   \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 1 ] + offset;                 \
-  }                                                                   \
-  vis_write_gsr(gsr[0]);                                              \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_S16_3( SHIFT, STEP )                       \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s->lutlength;                              \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2;                                    \
-  mlib_d64 dist, len0, len1, len2;                              \
-                                                                \
-  for( i = 0; i < length; i++ )                                 \
-  {                                                             \
-    col0 = src[ STEP * i + SHIFT ];                             \
-    col1 = src[ STEP * i + 1 + SHIFT ];                         \
-    col2 = src[ STEP * i + 2 + SHIFT ];                         \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-    for( k = 1; k <= entries; k++ )                             \
-    {                                                           \
-      dist = len0 * len0;                                       \
-      len0 = double_lut[ 3 * k ] - col0;                        \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 3 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 = double_lut[ 3 * k + 2 ] - col2;                    \
-      diff = ( mlib_s32 )( dist * 0.125 ) - min_dist;           \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-#define FIND_NEAREST_S16_4                                      \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s->lutlength;                              \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2, col3;                              \
-  mlib_d64 dist, len0, len1, len2, len3;                        \
-                                                                \
-  for( i = 0; i < length; i++ )                                 \
-  {                                                             \
-    col0 = src[ 4 * i ];                                        \
-    col1 = src[ 4 * i + 1 ];                                    \
-    col2 = src[ 4 * i + 2 ];                                    \
-    col3 = src[ 4 * i + 3 ];                                    \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-    len3 = double_lut[ 3 ] - col3;                              \
-    for( k = 1; k <= entries; k++ )                             \
-    {                                                           \
-      dist = len0 * len0;                                       \
-      len0 =  double_lut[ 4 * k ] - col0;                       \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 4 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 =  double_lut[ 4 * k + 2 ] - col2;                   \
-      dist += len3 * len3;                                      \
-      len3 =  double_lut[ 4 * k + 3 ] - col3;                   \
-      diff = ( mlib_s32 )( dist * 0.125 ) - min_dist;           \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-mlib_status mlib_ImageColorTrue2Index(mlib_image       *dst,
-                                      const mlib_image *src,
-                                      const void       *colormap)
-{
-  mlib_s32 y, width, height, sstride, dstride, schann;
-  mlib_colormap *s = (mlib_colormap *)colormap;
-  mlib_s32 channels;
-  mlib_type stype, dtype;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_SIZE_EQUAL(src, dst);
-  MLIB_IMAGE_HAVE_CHAN(dst, 1);
-
-  if (!colormap)
-    return MLIB_NULLPOINTER;
-
-  channels = s->channels;
-  stype = mlib_ImageGetType(src);
-  dtype = mlib_ImageGetType(dst);
-  width = mlib_ImageGetWidth(src);
-  height = mlib_ImageGetHeight(src);
-  sstride = mlib_ImageGetStride(src);
-  dstride = mlib_ImageGetStride(dst);
-  schann = mlib_ImageGetChannels(src);
-
-  if (stype != s->intype || dtype != s->outtype)
-    return MLIB_FAILURE;
-
-  if (channels != schann)
-    return MLIB_FAILURE;
-
-  switch (stype) {
-    case MLIB_BYTE:
-      {
-        mlib_u8 *sdata = mlib_ImageGetData(src);
-
-        switch (dtype) {
-          case MLIB_BYTE:
-            {
-              mlib_u8 *ddata = mlib_ImageGetData(dst);
-
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, U8, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, U8, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-
-          case MLIB_SHORT:
-            {
-              mlib_s16 *ddata = mlib_ImageGetData(dst);
-
-              dstride /= 2;
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, S16, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, S16, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-        default:
-          /* Unsupported type of destination image */
-          return MLIB_FAILURE;
-        }
-      }
-
-    case MLIB_SHORT:
-      {
-        mlib_s16 *sdata = mlib_ImageGetData(src);
-
-        sstride /= 2;
-        switch (dtype) {
-          case MLIB_BYTE:
-            {
-              mlib_u8 *ddata = mlib_ImageGetData(dst);
-
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, U8, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, U8, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-
-          case MLIB_SHORT:
-            {
-              mlib_s16 *ddata = mlib_ImageGetData(dst);
-
-              dstride /= 2;
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, S16, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, S16, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-        default:
-          /* Unsupported type of destination image */
-          return MLIB_FAILURE;
-        }
-      }
-
-    default:
-      return MLIB_FAILURE;
-  }
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_U8_3(struct lut_node_3 *node,
-                                   mlib_u32          distance,
-                                    mlib_s32    *found_color,
-                                   mlib_u32          c0,
-                                   mlib_u32          c1,
-                                   mlib_u32          c2,
-                                   const mlib_u8     **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 8; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex];
-      newpalc1 = base[1][newindex];
-      newpalc2 = base[2][newindex];
-      newdistance = FIND_DISTANCE_3(c0, newpalc0, c1, newpalc1, c2, newpalc2, 0);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance,
-                                  found_color, c0, c1, c2, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_U8_3(struct lut_node_3 *node,
-                                                mlib_u32          distance,
-                                                 mlib_s32    *found_color,
-                                                const mlib_u32    *c,
-                                                const mlib_u8     **base,
-                                                mlib_u32          position,
-                                                mlib_s32          pass,
-                                                mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {0, 2, 4, 6},
-    {0, 1, 4, 5},
-    {0, 1, 2, 3}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_U8_3(node->contents.quadrants[qq],
-                                                 distance, found_color, c, base,
-                                                 position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_U8_3(node->contents.quadrants[i],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_U8_3(struct lut_node_3 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_u8     **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {1, 3, 5, 7},
-    {2, 3, 6, 7},
-    {4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_U8_3(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position + current_size,
-                                                  pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_U8_3(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base, position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_S16_3(struct lut_node_3 *node,
-                                    mlib_u32          distance,
-                                     mlib_s32    *found_color,
-                                    mlib_u32          c0,
-                                    mlib_u32          c1,
-                                    mlib_u32          c2,
-                                    const mlib_s16    **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 8; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-      newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-      newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-      newdistance = FIND_DISTANCE_3(c0, newpalc0, c1, newpalc1, c2, newpalc2, 2);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance,
-                                   found_color, c0, c1, c2, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_S16_3(struct lut_node_3 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_s16    **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {0, 2, 4, 6},
-    {0, 1, 4, 5},
-    {0, 1, 2, 3}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_S16_3(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_S16_3(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base,
-                                                    position + current_size,
-                                                    pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_S16_3(struct lut_node_3 *node,
-                                                  mlib_u32          distance,
-                                                   mlib_s32    *found_color,
-                                                  const mlib_u32    *c,
-                                                  const mlib_s16    **base,
-                                                  mlib_u32          position,
-                                                  mlib_s32          pass,
-                                                  mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {1, 3, 5, 7},
-    {2, 3, 6, 7},
-    {4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_S16_3(node->contents.quadrants[qq],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_S16_3(node->contents.
-                                                     quadrants[i], distance,
-                                                     found_color, c, base,
-                                                     position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_U8_4(struct lut_node_4 *node,
-                                   mlib_u32          distance,
-                                    mlib_s32    *found_color,
-                                   mlib_u32          c0,
-                                   mlib_u32          c1,
-                                   mlib_u32          c2,
-                                   mlib_u32          c3,
-                                   const mlib_u8     **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 16; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex];
-      newpalc1 = base[1][newindex];
-      newpalc2 = base[2][newindex];
-      newpalc3 = base[3][newindex];
-      newdistance = FIND_DISTANCE_4(c0, newpalc0,
-                                    c1, newpalc1, c2, newpalc2, c3, newpalc3, 0);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance,
-                                  found_color, c0, c1, c2, c3, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_U8_4(struct lut_node_4 *node,
-                                                mlib_u32          distance,
-                                                 mlib_s32    *found_color,
-                                                const mlib_u32    *c,
-                                                const mlib_u8     **base,
-                                                mlib_u32          position,
-                                                mlib_s32          pass,
-                                                mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {0, 2, 4, 6, 8, 10, 12, 14},
-    {0, 1, 4, 5, 8, 9, 12, 13},
-    {0, 1, 2, 3, 8, 9, 10, 11},
-    {0, 1, 2, 3, 4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_U8_4(node->contents.quadrants[qq],
-                                                 distance, found_color, c, base,
-                                                 position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_U8_4(node->contents.quadrants[i],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], c[3], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_U8_4(struct lut_node_4 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_u8     **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {1, 3, 5, 7, 9, 11, 13, 15},
-    {2, 3, 6, 7, 10, 11, 14, 15},
-    {4, 5, 6, 7, 12, 13, 14, 15},
-    {8, 9, 10, 11, 12, 13, 14, 15}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_U8_4(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position + current_size,
-                                                  pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], c[3], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_U8_4(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base, position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_S16_4(struct lut_node_4 *node,
-                                    mlib_u32          distance,
-                                     mlib_s32    *found_color,
-                                    mlib_u32          c0,
-                                    mlib_u32          c1,
-                                    mlib_u32          c2,
-                                    mlib_u32          c3,
-                                    const mlib_s16    **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 16; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-      newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-      newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-      newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-      newdistance = FIND_DISTANCE_4(c0, newpalc0,
-                                    c1, newpalc1, c2, newpalc2, c3, newpalc3, 2);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance,
-                                   found_color, c0, c1, c2, c3, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_S16_4(struct lut_node_4 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_s16    **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {0, 2, 4, 6, 8, 10, 12, 14},
-    {0, 1, 4, 5, 8, 9, 12, 13},
-    {0, 1, 2, 3, 8, 9, 10, 11},
-    {0, 1, 2, 3, 4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_S16_4(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_S16_4(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base,
-                                                    position + current_size,
-                                                    pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], c[3], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_S16_4(struct lut_node_4 *node,
-                                                  mlib_u32          distance,
-                                                   mlib_s32    *found_color,
-                                                  const mlib_u32    *c,
-                                                  const mlib_s16    **base,
-                                                  mlib_u32          position,
-                                                  mlib_s32          pass,
-                                                  mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {1, 3, 5, 7, 9, 11, 13, 15},
-    {2, 3, 6, 7, 10, 11, 14, 15},
-    {4, 5, 6, 7, 12, 13, 14, 15},
-    {8, 9, 10, 11, 12, 13, 14, 15}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_S16_4(node->contents.quadrants[qq],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], c[3], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_S16_4(node->contents.
-                                                     quadrants[i], distance,
-                                                     found_color, c, base,
-                                                     position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-
-#define TAB_SIZE_mlib_u8   256
-#define TAB_SIZE_mlib_s16 1024
-
-#define SRC_mlib_u8(i)    src[i]
-#define SRC_mlib_s16(i)   (((mlib_u16*)src)[i] >> 6)
-
-/***************************************************************/
-
-#define DIMENSIONS_SEARCH_3(STYPE, DTYPE, STEP)                 \
-{                                                               \
-  DTYPE  *tab0 = ((mlib_colormap *)state)->table;               \
-  DTYPE  *tab1 = tab0 + TAB_SIZE_##STYPE;                       \
-  DTYPE  *tab2 = tab1 + TAB_SIZE_##STYPE;                       \
-  mlib_s32 i;                                                   \
-                                                                \
-  for (i = 0; i < length; i++) {                                \
-    dst[i] = tab0[SRC_##STYPE(0)] + tab1[SRC_##STYPE(1)] +      \
-             tab2[SRC_##STYPE(2)];                              \
-    src += STEP;                                                \
-  }                                                             \
-}
-
-/***************************************************************/
-
-#define DIMENSIONS_SEARCH_4(STYPE, DTYPE)                       \
-{                                                               \
-  DTYPE  *tab0 = ((mlib_colormap *)state)->table;               \
-  DTYPE  *tab1 = tab0 + TAB_SIZE_##STYPE;                       \
-  DTYPE  *tab2 = tab1 + TAB_SIZE_##STYPE;                       \
-  DTYPE  *tab3 = tab2 + TAB_SIZE_##STYPE;                       \
-  mlib_s32 i;                                                   \
-                                                                \
-  for (i = 0; i < length; i++) {                                \
-    dst[i] = tab0[SRC_##STYPE(0)] + tab1[SRC_##STYPE(1)] +      \
-             tab2[SRC_##STYPE(2)] + tab3[SRC_##STYPE(3)];       \
-    src += 4;                                                   \
-  }                                                             \
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_U8_3(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_BYTE_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0, 3, 0);
-      }
-      break;
-
-#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_U8_3_SEARCH(mlib_u8, 0, 3);
-      }
-      break;
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3;
-#else
-        FIND_NEAREST_U8_3_C(0, 3);
-#endif
-      }
-      break;
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_u8, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4(const mlib_u8 *src,
-                                                mlib_u8       *dst,
-                                                mlib_s32      length,
-                                                const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_BYTE_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 1, 4, 0);
-        break;
-      }
-
-#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_U8_3_SEARCH(mlib_u8, 1, 4);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3_IN4;
-#else
-        FIND_NEAREST_U8_3_C(1, 4);
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_u8, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_U8_4(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_BYTE_COLORS_4CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_4(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0);
-        break;
-      }
-
-#endif /* LUT_BYTE_COLORS_4CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_U8_4_SEARCH(mlib_u8);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_4;
-#else
-        FIND_NEAREST_U8_4_C;
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_u8, mlib_u8)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_S16_3(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0, 3, 0);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_u8, 0, 3);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_s16, 0, 3);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3;
-#else
-        FIND_NEAREST_U8_3_C(0, 3);
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_s16, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4(const mlib_u8 *src,
-                                                 mlib_s16      *dst,
-                                                 mlib_s32      length,
-                                                 const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 1, 4, 0);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_u8, 1, 4);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_s16, 1, 4);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3_IN4;
-#else
-        FIND_NEAREST_U8_3_C(1, 4);
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_s16, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_S16_4(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_4(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_U8_4_SEARCH(mlib_u8);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_U8_4_SEARCH(mlib_s16);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_4;
-#else
-        FIND_NEAREST_U8_4_C;
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_u8, mlib_s16)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_S16_3(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 0, 3, 2);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_u8, 0, 3);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_s16, 0, 3);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(0, 3);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_s16, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4(const mlib_s16 *src,
-                                                  mlib_s16       *dst,
-                                                  mlib_s32       length,
-                                                  const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 1, 4, 2);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_u8, 1, 4);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_s16, 1, 4);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(1, 4);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_s16, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_S16_4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_4(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 2);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_S16_4_SEARCH(mlib_u8);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_S16_4_SEARCH(mlib_s16);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_4;
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_s16, mlib_s16)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_U8_3(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_SHORT_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 0, 3, 2);
-        break;
-      }
-
-#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_S16_3_SEARCH(mlib_u8, 0, 3);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(0, 3);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_u8, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4(const mlib_s16 *src,
-                                                 mlib_u8        *dst,
-                                                 mlib_s32       length,
-                                                 const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_SHORT_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 1, 4, 2);
-        break;
-      }
-
-#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_S16_3_SEARCH(mlib_u8, 1, 4);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(1, 4);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_u8, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_U8_4(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_SHORT_COLORS_4CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_4(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 2);
-        break;
-      }
-
-#endif /* LUT_SHORT_COLORS_4CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_S16_4_SEARCH(mlib_u8);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_4;
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_s16, mlib_u8)
-      break;
-  }
-}
-
-/***************************************************************/
-
-#ifndef VIS
-
-void mlib_c_ImageThresh1_U81_1B(void     *psrc,
-                                void     *pdst,
-                                mlib_s32 src_stride,
-                                mlib_s32 dst_stride,
-                                mlib_s32 width,
-                                mlib_s32 height,
-                                void     *thresh,
-                                void     *ghigh,
-                                void     *glow,
-                                mlib_s32 dbit_off);
-
-/***************************************************************/
-
-void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      bit_offset,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_u8  *lut = ((mlib_colormap *)state)->table;
-  mlib_s32 thresh[1];
-  mlib_s32 ghigh[1];
-  mlib_s32 glow[1];
-
-  thresh[0] = lut[2];
-
-  glow[0]  = lut[0] - lut[1];
-  ghigh[0] = lut[1] - lut[0];
-
-  mlib_c_ImageThresh1_U81_1B((void*)src, dst, 0, 0, length, 1,
-                             thresh, ghigh, glow, bit_offset);
-}
-
-#else
-
-/***************************************************************/
-
-void mlib_v_ImageThresh1B_U8_1(const mlib_u8  *src,
-                               mlib_s32       slb,
-                               mlib_u8        *dst,
-                               mlib_s32       dlb,
-                               mlib_s32       xsize,
-                               mlib_s32       ysize,
-                               mlib_s32       dbit_off,
-                               const mlib_s32 *th,
-                               mlib_s32       hc,
-                               mlib_s32       lc);
-
-/***************************************************************/
-
-void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      bit_offset,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_u8  *lut = ((mlib_colormap *)state)->table;
-  mlib_s32 thresh[4];
-  mlib_s32 ghigh[1];
-  mlib_s32 glow[1];
-
-  thresh[0] = thresh[1] = thresh[2] = thresh[3] = lut[2];
-
-  glow[0]  = (lut[1] < lut[0]) ? 0xFF : 0;
-  ghigh[0] = (lut[1] < lut[0]) ? 0 : 0xFF;
-
-  mlib_v_ImageThresh1B_U8_1((void*)src, 0, dst, 0, length, 1,
-                            bit_offset, thresh, ghigh[0], glow[0]);
-}
-
-/***************************************************************/
-
-#endif
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h
deleted file mode 100644
index 331851b..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-#ifndef __MLIB_IMAGECOLORMAP_H
-#define __MLIB_IMAGECOLORMAP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-typedef struct {
-  void **lut;
-  mlib_s32 channels;
-  mlib_type intype;
-  mlib_s32 offset;
-  void *table;
-  mlib_s32 bits;
-  mlib_s32 method;
-  mlib_s32 lutlength;
-  mlib_s32 indexsize;
-  mlib_type outtype;
-  void *normal_table;
-  mlib_d64 *double_lut;
-} mlib_colormap;
-
-/***************************************************************/
-#define LUT_COLOR_CUBE_SEARCH  0
-#define LUT_BINARY_TREE_SEARCH 1
-#define LUT_STUPID_SEARCH      2
-#define LUT_COLOR_DIMENSIONS   3
-
-/***************************************************************/
-
-/* Bit set in the tag denotes that the corresponding quadrant is a
-   palette index, not node. If the bit is clear, this means that that
-   is a pointer to the down level node. If the bit is clear and the
-   corresponding quadrant is NULL, then there is no way down there and
-   this quadrant is clear. */
-
-struct lut_node_3 {
-  mlib_u8 tag;
-  union {
-    struct lut_node_3 *quadrants[8];
-    long index[8];
-  } contents;
-};
-
-struct lut_node_4 {
-  mlib_u16 tag;
-  union {
-    struct lut_node_4 *quadrants[16];
-    long index[16];
-  } contents;
-};
-
-/***************************************************************/
-
-#define mlib_ImageGetLutData(colormap)                          \
-  ((void **)((( mlib_colormap *)( colormap))->lut))
-
-/***************************************************************/
-#define mlib_ImageGetLutNormalTable(colormap)                   \
-  ((void *)((( mlib_colormap *)( colormap))->normal_table))
-
-/***************************************************************/
-#define mlib_ImageGetLutInversTable(colormap)                   \
-  ((void *)((( mlib_colormap *)( colormap))->table))
-
-/***************************************************************/
-#define mlib_ImageGetLutChannels(colormap)                      \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->channels))
-
-/***************************************************************/
-#define mlib_ImageGetLutType(colormap)                          \
-  ((mlib_type)((( mlib_colormap *)( colormap))->intype))
-
-/***************************************************************/
-#define mlib_ImageGetIndexSize(colormap)                        \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->indexsize))
-
-/***************************************************************/
-#define mlib_ImageGetOutType(colormap)                          \
-  ((mlib_type)((( mlib_colormap *)( colormap))->outtype))
-
-/***************************************************************/
-#define mlib_ImageGetLutOffset(colormap)                        \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->offset))
-
-/***************************************************************/
-#define mlib_ImageGetBits(colormap)                             \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->bits))
-
-/***************************************************************/
-#define mlib_ImageGetMethod(colormap)                           \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->method))
-
-/***************************************************************/
-#define mlib_ImageGetLutDoubleData(colormap)                    \
-  ((mlib_d64 *)((( mlib_colormap *)( colormap))->double_lut))
-
-/***************************************************************/
-#define FIND_DISTANCE_3( x1, x2, y1, y2, z1, z2, SHIFT )        \
- (( ( ( ( x1 ) - ( x2 ) ) * ( ( x1 ) - ( x2 ) ) ) >> SHIFT ) +  \
-  ( ( ( ( y1 ) - ( y2 ) ) * ( ( y1 ) - ( y2 ) ) ) >> SHIFT ) +  \
-  ( ( ( ( z1 ) - ( z2 ) ) * ( ( z1 ) - ( z2 ) ) ) >> SHIFT ) )
-
-/***************************************************************/
-#define FIND_DISTANCE_4( x1, x2, y1, y2, z1, z2, w1, w2, SHIFT ) \
-  (( ( ( ( x1 ) - ( x2 ) ) * ( ( x1 ) - ( x2 ) ) ) >> SHIFT ) +  \
-   ( ( ( ( y1 ) - ( y2 ) ) * ( ( y1 ) - ( y2 ) ) ) >> SHIFT ) +  \
-   ( ( ( ( z1 ) - ( z2 ) ) * ( ( z1 ) - ( z2 ) ) ) >> SHIFT ) +  \
-   ( ( ( ( w1 ) - ( w2 ) ) * ( ( w1 ) - ( w2 ) ) ) >> SHIFT ) )
-
-/***************************************************************/
-
-void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      bit_offset,
-                                            mlib_s32      length,
-                                            const void    *state);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_U8_3(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4(const mlib_u8 *src,
-                                                mlib_u8       *dst,
-                                                mlib_s32      length,
-                                                const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_U8_4(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_S16_3(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4(const mlib_u8 *src,
-                                                 mlib_s16      *dst,
-                                                 mlib_s32      length,
-                                                 const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_S16_4(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_S16_3(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4(const mlib_s16 *src,
-                                                  mlib_s16       *dst,
-                                                  mlib_s32       length,
-                                                  const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_S16_4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_U8_3(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4(const mlib_s16 *src,
-                                                 mlib_u8        *dst,
-                                                 mlib_s32       length,
-                                                 const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_U8_4(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *colormap);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __MLIB_IMAGECOLORMAP_H */
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h
index a4f37d9..dc4b6bd 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h
@@ -41,466 +41,6 @@
 }
 #endif /* FREE_AND_RETURN_STATUS */
 
-void mlib_ImageXor80_aa(mlib_u8  *dl,
-                        mlib_s32 wid,
-                        mlib_s32 hgt,
-                        mlib_s32 str);
-
-void mlib_ImageXor80(mlib_u8  *dl,
-                     mlib_s32 wid,
-                     mlib_s32 hgt,
-                     mlib_s32 str,
-                     mlib_s32 nchan,
-                     mlib_s32 cmask);
-
-mlib_status mlib_conv2x2ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_bit(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_bit(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
 mlib_status mlib_convMxNext_s32(mlib_image       *dst,
                                 const mlib_image *src,
                                 const mlib_s32   *kernel,
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c
deleted file mode 100644
index f10cbe6..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c
+++ /dev/null
@@ -1,1118 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * FUNCTION
- *      Internal functions for mlib_ImageConv2x2 on U8/S16/U16 types
- *      and MLIB_EDGE_DST_NO_WRITE mask.
- */
-
-#include "mlib_image.h"
-#include "mlib_ImageConv.h"
-#include "mlib_c_ImageConv.h"
-
-/***************************************************************/
-#ifdef i386 /* do not copy by mlib_d64 data type for x86 */
-
-typedef struct {
-  mlib_s32 int0, int1;
-} two_int;
-
-#define TYPE_64BIT two_int
-
-#else /* i386 */
-
-#define TYPE_64BIT mlib_d64
-
-#endif /* i386 ( do not copy by mlib_d64 data type for x86 ) */
-
-/***************************************************************/
-#define LOAD_KERNEL_INTO_DOUBLE()                                        \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3]
-
-/***************************************************************/
-#define GET_SRC_DST_PARAMETERS(type)                            \
-  hgt = mlib_ImageGetHeight(src);                               \
-  wid = mlib_ImageGetWidth(src);                                \
-  nchannel = mlib_ImageGetChannels(src);                        \
-  sll = mlib_ImageGetStride(src) / sizeof(type);                \
-  dll = mlib_ImageGetStride(dst) / sizeof(type);                \
-  adr_src = (type *)mlib_ImageGetData(src);                     \
-  adr_dst = (type *)mlib_ImageGetData(dst)
-
-/***************************************************************/
-#ifndef MLIB_USE_FTOI_CLAMPING
-
-#define CLAMP_S32(x)                                            \
-  (((x) <= MLIB_S32_MIN) ? MLIB_S32_MIN :                       \
-  (((x) >= MLIB_S32_MAX) ? MLIB_S32_MAX : (mlib_s32)(x)))
-
-#else
-
-#define CLAMP_S32(x) ((mlib_s32)(x))
-
-#endif /* MLIB_USE_FTOI_CLAMPING */
-
-/***************************************************************/
-#if defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG)
-
-/* NB: Explicit cast to DTYPE is necessary to avoid warning from Microsoft VC compiler.
-      And we need to explicitly define cast behavior if source exceeds destination range.
-      (it is undefined according to C99 spec). We use mask here because this macro is typically
-      used to extract bit regions. */
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = (DTYPE) ((res1) & DTYPE_MASK);                      \
-  dp[chan1] = (DTYPE) ((res0) & DTYPE_MASK)
-
-#else
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = (DTYPE) ((res0) & DTYPE_MASK);                      \
-  dp[chan1] = (DTYPE) ((res1) & DTYPE_MASK)
-
-#endif /* defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG) */
-
-/***************************************************************/
-#ifdef _NO_LONGLONG
-
-#define LOAD_BUFF(buff)                                         \
-  buff[i    ] = sp[0];                                          \
-  buff[i + 1] = sp[chan1]
-
-#else /* _NO_LONGLONG */
-
-#ifdef _LITTLE_ENDIAN
-
-#define LOAD_BUFF(buff)                                         \
-  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | ((mlib_s64)sp[0] & 0xffffffff)
-
-#else /* _LITTLE_ENDIAN */
-
-#define LOAD_BUFF(buff)                                         \
-  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | ((mlib_s64)sp[chan1] & 0xffffffff)
-
-#endif /* _LITTLE_ENDIAN */
-
-#endif /* _NO_LONGLONG */
-
-/***************************************************************/
-typedef union {
-  TYPE_64BIT d64;
-  struct {
-    mlib_s32 i0, i1;
-  } i32s;
-} d64_2x32;
-
-/***************************************************************/
-#define D_KER     1
-
-#define BUFF_LINE 256
-
-/***************************************************************/
-#define XOR_80(x) x ^= 0x80
-
-void mlib_ImageXor80_aa(mlib_u8  *dl,
-                        mlib_s32 wid,
-                        mlib_s32 hgt,
-                        mlib_s32 str)
-{
-  mlib_u8  *dp, *dend;
-#ifdef _NO_LONGLONG
-  mlib_u32 cadd = 0x80808080;
-#else /* _NO_LONGLONG */
-  mlib_u64 cadd = MLIB_U64_CONST(0x8080808080808080);
-#endif /* _NO_LONGLONG */
-  mlib_s32 j;
-
-  if (wid == str) {
-    wid *= hgt;
-    hgt = 1;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    dend = dl + wid;
-
-    for (dp = dl; ((mlib_addr)dp & 7) && (dp < dend); dp++) XOR_80(dp[0]);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; dp <= (dend - 8); dp += 8) {
-#ifdef _NO_LONGLONG
-      *((mlib_s32*)dp) ^= cadd;
-      *((mlib_s32*)dp+1) ^= cadd;
-#else /* _NO_LONGLONG */
-      *((mlib_u64*)dp) ^= cadd;
-#endif /* _NO_LONGLONG */
-    }
-
-    for (; (dp < dend); dp++) XOR_80(dp[0]);
-
-    dl += str;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageXor80(mlib_u8  *dl,
-                     mlib_s32 wid,
-                     mlib_s32 hgt,
-                     mlib_s32 str,
-                     mlib_s32 nchan,
-                     mlib_s32 cmask)
-{
-  mlib_s32 i, j, c;
-
-  for (j = 0; j < hgt; j++) {
-    for (c = 0; c < nchan; c++) {
-      if (cmask & (1 << (nchan - 1 - c))) {
-        mlib_u8 *dp = dl + c;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-        for (i = 0; i < wid; i++) XOR_80(dp[i*nchan]);
-      }
-    }
-
-    dl += str;
-  }
-}
-
-/***************************************************************/
-#define DTYPE mlib_s16
-#define DTYPE_MASK 0xffff
-
-mlib_status mlib_c_conv2x2nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scalef_expon,
-                                 mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  wid1 = (wid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= D_KER;
-  hgt -= D_KER;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + D_KER; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    sl += (D_KER + 1)*sll;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dp[0] = buffo[i] >> 16;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-mlib_status mlib_c_conv2x2ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scalef_expon,
-                                  mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c, swid;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + D_KER;
-
-  wid1 = (swid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  swid -= dx_r;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((hgt - dy_b) > 0) sl1 = sl + sll;
-    else sl1 = sl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    if (dx_r != 0) {
-      buff0[swid - 1] = buff0[swid - 2];
-      buff1[swid - 1] = buff1[swid - 2];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl1 + sll;
-    else sl = sl1;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dp[0] = buffo[i] >> 16;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_u16
-
-mlib_status mlib_c_conv2x2nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scalef_expon,
-                                 mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_d64 doff = 0x7FFF8000;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  wid1 = (wid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= D_KER;
-  hgt -= D_KER;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + D_KER; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    sl += (D_KER + 1)*sll;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - doff);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        o64_1 = o64_1 ^ 0x80000000U;
-        o64_2 = o64_2 ^ 0x80000000U;
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        o64 = o64 ^ MLIB_U64_CONST(0x8000000080000000);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dp[0] = (buffo[i] >> 16) ^ 0x8000;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-mlib_status mlib_c_conv2x2ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scalef_expon,
-                                  mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c, swid;
-  mlib_d64 doff = 0x7FFF8000;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + D_KER;
-
-  wid1 = (swid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  swid -= dx_r;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((hgt - dy_b) > 0) sl1 = sl + sll;
-    else sl1 = sl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    if (dx_r != 0) {
-      buff0[swid - 1] = buff0[swid - 2];
-      buff1[swid - 1] = buff1[swid - 2];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl1 + sll;
-    else sl = sl1;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - doff);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        o64_1 = o64_1 ^ 0x80000000U;
-        o64_2 = o64_2 ^ 0x80000000U;
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        o64 = o64 ^ MLIB_U64_CONST(0x8000000080000000);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dp[0] = (buffo[i] >> 16) ^ 0x8000;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_u8
-
-mlib_status mlib_c_conv2x2nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scalef_expon,
-                                mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = (1 << 24);
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  wid1 = (wid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= D_KER;
-  hgt -= D_KER;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + D_KER; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    sl += (D_KER + 1)*sll;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - (1u << 31));
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 56, o64 >> 24);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dp[0] = (buffo[i] >> 24);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-mlib_status mlib_c_conv2x2ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scalef_expon,
-                                 mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[4*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = (1 << 24);
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c, swid;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + D_KER;
-
-  wid1 = (swid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  swid -= dx_r;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((hgt - dy_b) > 0) sl1 = sl + sll;
-    else sl1 = sl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    if (dx_r != 0) {
-      buff0[swid - 1] = buff0[swid - 2];
-      buff1[swid - 1] = buff1[swid - 2];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl1 + sll;
-    else sl = sl1;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - (1u << 31));
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 56, o64 >> 24);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dp[0] = (buffo[i] >> 24);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c
index 11a68ad..7226fd7 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c
@@ -80,9 +80,6 @@
 #endif /* IMG_TYPE == 1 */
 
 /***************************************************************/
-#define KSIZE1 (KSIZE - 1)
-
-/***************************************************************/
 #define PARAM                                                   \
   mlib_image       *dst,                                        \
   const mlib_image *src,                                        \
@@ -163,9 +160,6 @@
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
-#define MLIB_D2_24 16777216.0f
-
-/***************************************************************/
 typedef union {
   mlib_d64 d64;
   struct {
@@ -175,52 +169,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
-#define DEF_VARS(type)                                          \
-  type     *adr_src, *sl, *sp, *sl1;                            \
-  type     *adr_dst, *dl, *dp;                                  \
-  FTYPE    *pbuff = buff;                                       \
-  mlib_s32 *buffi, *buffo;                                      \
-  mlib_s32 wid, hgt, sll, dll;                                  \
-  mlib_s32 nchannel, chan1, chan2;                              \
-  mlib_s32 i, j, c, swid
-
-/***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -278,1334 +226,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buffo = (mlib_s32*)(buff3 + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((hgt - dy_b) > 0) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl2 + sll;
-    else sl = sl2;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l];
-      for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, delta_chan;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  delta_chan = 0;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[delta_chan];
-      p13 = sp1[delta_chan];
-      p23 = sp2[delta_chan];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += (chan1 + delta_chan);
-      sp1 += (chan1 + delta_chan);
-      sp2 += (chan1 + delta_chan);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      p02 = p03; p12 = p13; p22 = p23;
-
-      for (; i < wid - dx_r; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        sp0 += chan1;
-        sp1 += chan1;
-        sp2 += chan1;
-        dp += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-      sp2 -= chan1;
-
-      for (; i < wid; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        dp += chan1;
-      }
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buffd = buff4 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((hgt - dy_b) > 0) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl3 + sll;
-    else sl = sl3;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff4[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l];
-      for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buff5 = buff4 + swid;
-  buffd = buff5 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((hgt - dy_b) > 0) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-      buff4[i] = (FTYPE)sl4[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-      buff4[i + dx_l] = (FTYPE)sl4[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-      buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl4 + sll;
-    else sl = sl4;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff5[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l];
-      for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4;
-  DTYPE    *sp_1, *sp_2, *sp_3, *sp_4;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan4;
-  mlib_s32 delta_chan1, delta_chan2, delta_chan3;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1;
-  else delta_chan1 = 0;
-
-  if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1;
-  else delta_chan2 = delta_chan1;
-
-  if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1;
-  else delta_chan3 = delta_chan2;
-
-  chan4 = chan1 + delta_chan3;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_3 = sl;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_4 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sp_3;
-      sp_3 = sp_4;
-      sp_4 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-      sp3 = sp_3;
-      sp4 = sp_4;
-
-      /*
-       *  First loop
-       */
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];           p12 = sp1[0];
-      p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1];
-      p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2];
-      p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp0 += chan1;
-        sp1 += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp2[0];           p12 = sp3[0];
-      p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1];
-      p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2];
-      p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3];
-
-      sp2 += chan4;
-      sp3 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp2[0];     p14 = sp3[0];
-        p05 = sp2[chan1]; p15 = sp3[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp2 += chan2;
-        sp3 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp2 += chan1;
-        sp3 += chan1;
-      }
-
-      sp2 -= chan1;
-      sp3 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp4[0];
-      p03 = sp4[delta_chan1];
-      p04 = sp4[delta_chan2];
-      p05 = sp4[delta_chan3];
-
-      sp4 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp4[0]; p05 = sp4[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp4 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-        sp4 += chan1;
-      }
-
-      sp4 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-      }
-
-      /* next line */
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll;
-    else sl5 = sl4;
-
-    if ((hgt - dy_b) > 0) sl6 = sl5 + sll;
-    else sl6 = sl5;
-
-    for (i = 0; i < dx_l; i++) {
-      buffs[0][i] = (FTYPE)sl[0];
-      buffs[1][i] = (FTYPE)sl1[0];
-      buffs[2][i] = (FTYPE)sl2[0];
-      buffs[3][i] = (FTYPE)sl3[0];
-      buffs[4][i] = (FTYPE)sl4[0];
-      buffs[5][i] = (FTYPE)sl5[0];
-      buffs[6][i] = (FTYPE)sl6[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buffs[0][i + dx_l] = (FTYPE)sl[i*chan1];
-      buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1];
-      buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1];
-      buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1];
-      buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1];
-      buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1];
-      buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1];
-      buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1];
-      buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1];
-      buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1];
-      buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1];
-      buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1];
-      buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    if ((hgt - dy_b) > 1) sl = sl6 + sll;
-    else sl = sl6;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i + dx_l] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffn[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
-      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 #define BUFF_SIZE   1600
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c
index 0be65cd..4d0ba0c 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c
@@ -144,9 +144,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp = NULL;                           \
   type     *adr_dst, *dl, *dp = NULL;                           \
@@ -156,39 +153,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -246,1162 +210,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buffo = (mlib_s32*)(buff3 + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buffi[wid] = (mlib_s32)sp[0];
-      buff3[wid] = (FTYPE)buffi[wid];
-      buffi[wid + 1] = (mlib_s32)sp[chan1];
-      buff3[wid + 1] = (FTYPE)buffi[wid + 1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buffd = buff4 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (FTYPE)sp[0];
-      buff4[wid + 1] = (FTYPE)sp[chan1];
-      buff4[wid + 2] = (FTYPE)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buffd = buff5 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-      buff4[i] = (FTYPE)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-      p14 = buff3[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (FTYPE)sp[0];
-      buff5[wid + 1] = (FTYPE)sp[chan1];
-      buff5[wid + 2] = (FTYPE)sp[chan2];
-      buff5[wid + 3] = (FTYPE)sp[chan2 + chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan3, chan4;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  chan3 = chan2 + chan1;
-  chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (FTYPE)sl[i*chan1];
-      buffs[1][i] = (FTYPE)sl1[i*chan1];
-      buffs[2][i] = (FTYPE)sl2[i*chan1];
-      buffs[3][i] = (FTYPE)sl3[i*chan1];
-      buffs[4][i] = (FTYPE)sl4[i*chan1];
-      buffs[5][i] = (FTYPE)sl5[i*chan1];
-      buffs[6][i] = (FTYPE)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c
index b0697c8..1b5b120 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c
@@ -35,8 +35,6 @@
 #include "mlib_ImageConv.h"
 
 /***************************************************************/
-#define BUFF_LINE  256
-
 #define CACHE_SIZE (64*1024)
 
 /***************************************************************/
@@ -83,837 +81,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define CALC_SCALE()                                            \
-  scalef = 1.0;                                                 \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon)
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 2
-
-mlib_status CONV_FUNC(2x2)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 1)*BUFF_LINE];
-  mlib_d64 k0, k1, k2, k3;
-  mlib_d64 p00, p01, p02, p03,
-           p10, p11, p12, p13;
-  mlib_d64 d2;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 1)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  /* keep kernel in regs */
-  CALC_SCALE();
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];
-  k2 = scalef * kern[2];  k3 = scalef * kern[3];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      p03 = buff0[0];
-      p13 = buff1[0];
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 3); i += 3) {
-
-        p00 = p03; p10 = p13;
-
-        p01 = buff0[i + 1]; p11 = buff1[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-
-        buff2[i    ] = (mlib_d64)sp[0];
-        buff2[i + 1] = (mlib_d64)sp[chan1];
-        buff2[i + 2] = (mlib_d64)sp[chan2];
-
-        d0 = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        d1 = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-        d2 = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-        CLAMP_S32(dp[chan2], d2);
-
-        sp += chan3;
-        dp += chan3;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1];
-
-        buff2[i] = (mlib_d64)sp[0];
-
-        d0 = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff2[wid] = (mlib_d64)sp[0];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 1)*BUFF_LINE], *buff3;
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_d64 p00, p01, p02, p03,
-           p10, p11, p12, p13,
-           p20, p21, p22, p23;
-  mlib_s32 *sl2;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 1)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2];
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5];
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-      buff2[i] = (mlib_d64)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_d64 s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      sp = sl;
-      dp = dl;
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        buff3[i    ] = (mlib_d64)sp[0];
-        buff3[i + 1] = (mlib_d64)sp[chan1];
-
-        d0 = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-        d1 = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8;
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buff3[i] = (mlib_d64)sp[0];
-
-        d0 = (p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-              p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff3[wid    ] = (mlib_d64)sp[0];
-      buff3[wid + 1] = (mlib_d64)sp[chan1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buff3, *buff4, *buff5;
-  mlib_d64 k[KSIZE*KSIZE];
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7;
-  mlib_d64 p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  mlib_s32 *sl2, *sl3;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  for (j = 0; j < 16; j++) k[j] = scalef * kern[j];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-      buff2[i] = (mlib_d64)sl2[i*chan1];
-      buff3[i] = (mlib_d64)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        buff4[i] = (mlib_d64)sp[0];
-        buff4[i + 1] = (mlib_d64)sp[chan1];
-
-        buff5[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buff5[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-              p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buff5[i]);
-        d1 = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-              p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buff5[i + 1]);
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (mlib_d64)sp[0];
-
-        d0 = (p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-              p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-              p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-              p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (mlib_d64)sp[0];
-      buff4[wid + 1] = (mlib_d64)sp[chan1];
-      buff4[wid + 2] = (mlib_d64)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buff3, *buff4, *buff5, *buff6;
-  mlib_d64 k[KSIZE*KSIZE];
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_d64 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  mlib_s32 *sl2, *sl3, *sl4;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buff6 = buff5 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  for (j = 0; j < 25; j++) k[j] = scalef * kern[j];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-      buff2[i] = (mlib_d64)sl2[i*chan1];
-      buff3[i] = (mlib_d64)sl3[i*chan1];
-      buff4[i] = (mlib_d64)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buff6[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buff6[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        buff6[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buff6[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        buff5[i    ] = (mlib_d64)sp[0];
-        buff5[i + 1] = (mlib_d64)sp[chan1];
-
-        d0 = p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buff6[i];
-        d1 = p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buff6[i + 1];
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];        p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (mlib_d64)sp[0];
-
-        d0 = (p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-              p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-              p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-              p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-              p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (mlib_d64)sp[0];
-      buff5[wid + 1] = (mlib_d64)sp[chan1];
-      buff5[wid + 2] = (mlib_d64)sp[chan2];
-      buff5[wid + 3] = (mlib_d64)sp[chan3];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  mlib_d64 k[KSIZE*KSIZE];
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6;
-  mlib_d64 p0, p1, p2, p3, p4, p5, p6, p7;
-  mlib_d64 d0, d1;
-  mlib_s32 l, m, buff_ind, *sl2, *sl3, *sl4, *sl5, *sl6;
-  mlib_d64 scalef;
-  DEF_VARS_MxN(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 *sl1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  for (j = 0; j < 49; j++) k[j] = scalef * kern[j];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (mlib_d64)sl[i*chan1];
-      buffs[1][i] = (mlib_d64)sl1[i*chan1];
-      buffs[2][i] = (mlib_d64)sl2[i*chan1];
-      buffs[3][i] = (mlib_d64)sl3[i*chan1];
-      buffs[4][i] = (mlib_d64)sl4[i*chan1];
-      buffs[5][i] = (mlib_d64)sl5[i*chan1];
-      buffs[6][i] = (mlib_d64)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_d64 **buffc = buffs + buff_ind;
-      mlib_d64 *buffn = buffc[KSIZE];
-      mlib_d64 *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        mlib_d64 *buff = buffc[l];
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffn[i    ] = (mlib_d64)sp[0];
-            buffn[i + 1] = (mlib_d64)sp[chan1];
-
-            d0 = p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ];
-            d1 = p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1];
-
-            CLAMP_S32(dp[0    ], d0);
-            CLAMP_S32(dp[chan1], d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        mlib_d64 *pk = k, s = 0;
-
-        for (l = 0; l < KSIZE; l++) {
-          mlib_d64 *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        CLAMP_S32(dp[0], s);
-
-        buffn[i] = (mlib_d64)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
 #define FTYPE  mlib_d64
 #define DTYPE  mlib_s32
 
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c
index c7420a9..15799a4 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c
@@ -80,9 +80,6 @@
 #endif /* IMG_TYPE == 1 */
 
 /***************************************************************/
-#define KSIZE1 (KSIZE - 1)
-
-/***************************************************************/
 #define PARAM                                                   \
   mlib_image       *dst,                                        \
   const mlib_image *src,                                        \
@@ -126,21 +123,6 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = res1;                                             \
-  dp[chan1] = res0
-
-#else
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = res0;                                             \
-  dp[chan1] = res1
-
-#endif /* _LITTLE_ENDIAN */
-
-/***************************************************************/
 #ifdef _NO_LONGLONG
 
 #define LOAD_BUFF(buff)                                         \
@@ -163,9 +145,6 @@
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
-#define MLIB_D2_24 16777216.0f
-
-/***************************************************************/
 typedef union {
   mlib_d64 d64;
   struct {
@@ -175,52 +154,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
-#define DEF_VARS(type)                                          \
-  type     *adr_src, *sl, *sp, *sl1;                            \
-  type     *adr_dst, *dl, *dp;                                  \
-  FTYPE    *pbuff = buff;                                       \
-  mlib_s32 *buffi, *buffo;                                      \
-  mlib_s32 wid, hgt, sll, dll;                                  \
-  mlib_s32 nchannel, chan1, chan2;                              \
-  mlib_s32 i, j, c, swid
-
-/***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -278,1334 +211,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buffo = (mlib_s32*)(buff3 + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((hgt - dy_b) > 0) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl2 + sll;
-    else sl = sl2;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l];
-      for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, delta_chan;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  delta_chan = 0;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[delta_chan];
-      p13 = sp1[delta_chan];
-      p23 = sp2[delta_chan];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += (chan1 + delta_chan);
-      sp1 += (chan1 + delta_chan);
-      sp2 += (chan1 + delta_chan);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      p02 = p03; p12 = p13; p22 = p23;
-
-      for (; i < wid - dx_r; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0)
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        sp0 += chan1;
-        sp1 += chan1;
-        sp2 += chan1;
-        dp += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-      sp2 -= chan1;
-
-      for (; i < wid; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0)
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        dp += chan1;
-      }
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buffd = buff4 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((hgt - dy_b) > 0) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl3 + sll;
-    else sl = sl3;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff4[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l];
-      for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buff5 = buff4 + swid;
-  buffd = buff5 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((hgt - dy_b) > 0) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-      buff4[i] = (FTYPE)sl4[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-      buff4[i + dx_l] = (FTYPE)sl4[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-      buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl4 + sll;
-    else sl = sl4;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff5[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l];
-      for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4;
-  DTYPE    *sp_1, *sp_2, *sp_3, *sp_4;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan4;
-  mlib_s32 delta_chan1, delta_chan2, delta_chan3;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1;
-  else delta_chan1 = 0;
-
-  if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1;
-  else delta_chan2 = delta_chan1;
-
-  if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1;
-  else delta_chan3 = delta_chan2;
-
-  chan4 = chan1 + delta_chan3;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_3 = sl;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_4 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sp_3;
-      sp_3 = sp_4;
-      sp_4 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-      sp3 = sp_3;
-      sp4 = sp_4;
-
-      /*
-       *  First loop
-       */
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];           p12 = sp1[0];
-      p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1];
-      p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2];
-      p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp0 += chan1;
-        sp1 += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp2[0];           p12 = sp3[0];
-      p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1];
-      p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2];
-      p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3];
-
-      sp2 += chan4;
-      sp3 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp2[0];     p14 = sp3[0];
-        p05 = sp2[chan1]; p15 = sp3[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp2 += chan2;
-        sp3 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp2 += chan1;
-        sp3 += chan1;
-      }
-
-      sp2 -= chan1;
-      sp3 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp4[0];
-      p03 = sp4[delta_chan1];
-      p04 = sp4[delta_chan2];
-      p05 = sp4[delta_chan3];
-
-      sp4 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp4[0]; p05 = sp4[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        dp  += chan2;
-        sp4 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0)
-
-        dp  += chan1;
-        sp4 += chan1;
-      }
-
-      sp4 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0)
-
-        dp  += chan1;
-      }
-
-      /* next line */
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll;
-    else sl5 = sl4;
-
-    if ((hgt - dy_b) > 0) sl6 = sl5 + sll;
-    else sl6 = sl5;
-
-    for (i = 0; i < dx_l; i++) {
-      buffs[0][i] = (FTYPE)sl[0];
-      buffs[1][i] = (FTYPE)sl1[0];
-      buffs[2][i] = (FTYPE)sl2[0];
-      buffs[3][i] = (FTYPE)sl3[0];
-      buffs[4][i] = (FTYPE)sl4[0];
-      buffs[5][i] = (FTYPE)sl5[0];
-      buffs[6][i] = (FTYPE)sl6[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buffs[0][i + dx_l] = (FTYPE)sl[i*chan1];
-      buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1];
-      buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1];
-      buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1];
-      buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1];
-      buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1];
-      buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1];
-      buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1];
-      buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1];
-      buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1];
-      buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1];
-      buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1];
-      buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    if ((hgt - dy_b) > 1) sl = sl6 + sll;
-    else sl = sl6;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i + dx_l] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffn[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
-      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 #define BUFF_SIZE   1600
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c
index c81dbd0..4cdba6d 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c
@@ -145,9 +145,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp = NULL;                           \
   type     *adr_dst, *dl, *dp = NULL;                           \
@@ -157,39 +154,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -247,1162 +211,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buffo = (mlib_s32*)(buff3 + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buffi[wid] = (mlib_s32)sp[0];
-      buff3[wid] = (FTYPE)buffi[wid];
-      buffi[wid + 1] = (mlib_s32)sp[chan1];
-      buff3[wid + 1] = (FTYPE)buffi[wid + 1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0)
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buffd = buff4 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (FTYPE)sp[0];
-      buff4[wid + 1] = (FTYPE)sp[chan1];
-      buff4[wid + 2] = (FTYPE)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buffd = buff5 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-      buff4[i] = (FTYPE)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-      p14 = buff3[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (FTYPE)sp[0];
-      buff5[wid + 1] = (FTYPE)sp[chan1];
-      buff5[wid + 2] = (FTYPE)sp[chan2];
-      buff5[wid + 3] = (FTYPE)sp[chan2 + chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan3, chan4;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  chan3 = chan2 + chan1;
-  chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0)
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (FTYPE)sl[i*chan1];
-      buffs[1][i] = (FTYPE)sl1[i*chan1];
-      buffs[2][i] = (FTYPE)sl2[i*chan1];
-      buffs[3][i] = (FTYPE)sl3[i*chan1];
-      buffs[4][i] = (FTYPE)sl4[i*chan1];
-      buffs[5][i] = (FTYPE)sl5[i*chan1];
-      buffs[6][i] = (FTYPE)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c
index 551ea19..ef111ba 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c
@@ -75,495 +75,6 @@
   mlib_s32 i = 0, j, c
 
 /***************************************************************/
-#undef  KSIZE
-#define KSIZE 2
-
-mlib_status CONV_FUNC(2x2)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-  DTYPE k0, k1, k2, k3;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];
-  k2 = (DTYPE)kern[2];  k3 = (DTYPE)kern[3];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    dl = adr_dst + c;
-    sl = adr_src + c;
-
-    for (j = 0; j < hgt; j++) {
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-
-      p04 = sp0[0];
-      p14 = sp1[0];
-
-      sp0 += chan1;
-      sp1 += chan1;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 4); i += 4) {
-        p00 = p04; p10 = p14;
-
-        p01 = sp0[0];     p11 = sp1[0];
-        p02 = sp0[chan1]; p12 = sp1[chan1];
-        p03 = sp0[chan2]; p13 = sp1[chan2];
-        p04 = sp0[chan3]; p14 = sp1[chan3];
-
-        dp[0    ] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-        dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-        dp[chan3] = p03 * k0 + p04 * k1 + p13 * k2 + p14 * k3;
-
-        dp  += chan4;
-        sp0 += chan4;
-        sp1 += chan4;
-      }
-
-      if (i < wid) {
-        p00 = p04;    p10 = p14;
-        p01 = sp0[0]; p11 = sp1[0];
-        dp[0] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-
-        if ((i + 1) < wid) {
-          p02 = sp0[chan1]; p12 = sp1[chan1];
-          dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-
-          if ((i + 2) < wid) {
-            p03 = sp0[chan2]; p13 = sp1[chan2];
-            dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-          }
-        }
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  mlib_s32 chan2 = chan1 + chan1;
-  DTYPE    *sp0, *sp1;
-  DTYPE *sp2;
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  DTYPE p02, p03, p12, p13, p22, p23;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];  k2 = (DTYPE)kern[2];
-  k3 = (DTYPE)kern[3];  k4 = (DTYPE)kern[4];  k5 = (DTYPE)kern[5];
-  k6 = (DTYPE)kern[6];  k7 = (DTYPE)kern[7];  k8 = (DTYPE)kern[8];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      DTYPE s0, s1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        dp[0    ] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-        dp[chan1] = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        dp[0] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop on two first lines of kernel
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3];
-      k4 = (DTYPE)k[4]; k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                     p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                     p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[ 8]; k1 = (DTYPE)k[ 9]; k2 = (DTYPE)k[10]; k3 = (DTYPE)k[11];
-      k4 = (DTYPE)k[12]; k5 = (DTYPE)k[13]; k6 = (DTYPE)k[14]; k7 = (DTYPE)k[15];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                      p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                      p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                  p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  DTYPE p00, p01, p02, p03, p04, p05,
-        p10, p11, p12, p13, p14, p15;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; k4 = (DTYPE)k[4];
-      k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; k8 = (DTYPE)k[8]; k9 = (DTYPE)k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                     p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                 p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[10]; k1 = (DTYPE)k[11]; k2 = (DTYPE)k[12]; k3 = (DTYPE)k[13]; k4 = (DTYPE)k[14];
-      k5 = (DTYPE)k[15]; k6 = (DTYPE)k[16]; k7 = (DTYPE)k[17]; k8 = (DTYPE)k[18]; k9 = (DTYPE)k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                      p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                      p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                  p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = (DTYPE)k[20]; k1 = (DTYPE)k[21]; k2 = (DTYPE)k[22]; k3 = (DTYPE)k[23]; k4 = (DTYPE)k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        dp[0    ] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-        dp[chan1] += p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4;
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        dp[0] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
 #define BUFF_SIZE  1600
 
 #define CACHE_SIZE (64*1024)
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c
index 7e279d7..c825c97 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c
@@ -75,495 +75,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#undef  KSIZE
-#define KSIZE 2
-
-mlib_status CONV_FUNC(2x2)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-  DTYPE k0, k1, k2, k3;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];
-  k2 = (DTYPE)kern[2];  k3 = (DTYPE)kern[3];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    dl = adr_dst + c;
-    sl = adr_src + c;
-
-    for (j = 0; j < hgt; j++) {
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-
-      p04 = sp0[0];
-      p14 = sp1[0];
-
-      sp0 += chan1;
-      sp1 += chan1;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 4); i += 4) {
-        p00 = p04; p10 = p14;
-
-        p01 = sp0[0];     p11 = sp1[0];
-        p02 = sp0[chan1]; p12 = sp1[chan1];
-        p03 = sp0[chan2]; p13 = sp1[chan2];
-        p04 = sp0[chan3]; p14 = sp1[chan3];
-
-        dp[0    ] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-        dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-        dp[chan3] = p03 * k0 + p04 * k1 + p13 * k2 + p14 * k3;
-
-        dp  += chan4;
-        sp0 += chan4;
-        sp1 += chan4;
-      }
-
-      if (i < wid) {
-        p00 = p04;    p10 = p14;
-        p01 = sp0[0]; p11 = sp1[0];
-        dp[0] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-
-        if ((i + 1) < wid) {
-          p02 = sp0[chan1]; p12 = sp1[chan1];
-          dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-
-          if ((i + 2) < wid) {
-            p03 = sp0[chan2]; p13 = sp1[chan2];
-            dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-          }
-        }
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  mlib_s32 chan2 = chan1 + chan1;
-  DTYPE    *sp0, *sp1;
-  DTYPE *sp2;
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  DTYPE p02, p03, p12, p13, p22, p23;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];  k2 = (DTYPE)kern[2];
-  k3 = (DTYPE)kern[3];  k4 = (DTYPE)kern[4];  k5 = (DTYPE)kern[5];
-  k6 = (DTYPE)kern[6];  k7 = (DTYPE)kern[7];  k8 = (DTYPE)kern[8];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      DTYPE s0, s1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        dp[0    ] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-        dp[chan1] = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        dp[0] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop on two first lines of kernel
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3];
-      k4 = (DTYPE)k[4]; k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                     p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                     p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[ 8]; k1 = (DTYPE)k[ 9]; k2 = (DTYPE)k[10]; k3 = (DTYPE)k[11];
-      k4 = (DTYPE)k[12]; k5 = (DTYPE)k[13]; k6 = (DTYPE)k[14]; k7 = (DTYPE)k[15];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                      p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                      p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                  p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  DTYPE p00, p01, p02, p03, p04, p05,
-        p10, p11, p12, p13, p14, p15;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; k4 = (DTYPE)k[4];
-      k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; k8 = (DTYPE)k[8]; k9 = (DTYPE)k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                     p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                 p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[10]; k1 = (DTYPE)k[11]; k2 = (DTYPE)k[12]; k3 = (DTYPE)k[13]; k4 = (DTYPE)k[14];
-      k5 = (DTYPE)k[15]; k6 = (DTYPE)k[16]; k7 = (DTYPE)k[17]; k8 = (DTYPE)k[18]; k9 = (DTYPE)k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                      p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                      p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                  p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = (DTYPE)k[20]; k1 = (DTYPE)k[21]; k2 = (DTYPE)k[22]; k3 = (DTYPE)k[23]; k4 = (DTYPE)k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        dp[0    ] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-        dp[chan1] += p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4;
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        dp[0] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
 #define BUFF_SIZE  1600
 
 #define CACHE_SIZE (64*1024)
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c
index 926459d..b6a6410 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c
@@ -80,9 +80,6 @@
 #endif /* IMG_TYPE == 1 */
 
 /***************************************************************/
-#define KSIZE1 (KSIZE - 1)
-
-/***************************************************************/
 #define PARAM                                                   \
   mlib_image       *dst,                                        \
   const mlib_image *src,                                        \
@@ -163,9 +160,6 @@
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
-#define MLIB_D2_24 16777216.0f
-
-/***************************************************************/
 typedef union {
   mlib_d64 d64;
   struct {
@@ -175,9 +169,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp, *sl1;                            \
   type     *adr_dst, *dl, *dp;                                  \
@@ -188,39 +179,6 @@
   mlib_s32 i, j, c, swid
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -278,1334 +236,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buffo = (mlib_s32*)(buff3 + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((hgt - dy_b) > 0) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl2 + sll;
-    else sl = sl2;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l];
-      for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, delta_chan;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  delta_chan = 0;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[delta_chan];
-      p13 = sp1[delta_chan];
-      p23 = sp2[delta_chan];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += (chan1 + delta_chan);
-      sp1 += (chan1 + delta_chan);
-      sp2 += (chan1 + delta_chan);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      p02 = p03; p12 = p13; p22 = p23;
-
-      for (; i < wid - dx_r; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        sp0 += chan1;
-        sp1 += chan1;
-        sp2 += chan1;
-        dp += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-      sp2 -= chan1;
-
-      for (; i < wid; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        dp += chan1;
-      }
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buffd = buff4 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((hgt - dy_b) > 0) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl3 + sll;
-    else sl = sl3;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff4[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l];
-      for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buff5 = buff4 + swid;
-  buffd = buff5 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((hgt - dy_b) > 0) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-      buff4[i] = (FTYPE)sl4[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-      buff4[i + dx_l] = (FTYPE)sl4[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-      buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl4 + sll;
-    else sl = sl4;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff5[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l];
-      for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4;
-  DTYPE    *sp_1, *sp_2, *sp_3, *sp_4;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan4;
-  mlib_s32 delta_chan1, delta_chan2, delta_chan3;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1;
-  else delta_chan1 = 0;
-
-  if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1;
-  else delta_chan2 = delta_chan1;
-
-  if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1;
-  else delta_chan3 = delta_chan2;
-
-  chan4 = chan1 + delta_chan3;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_3 = sl;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_4 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sp_3;
-      sp_3 = sp_4;
-      sp_4 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-      sp3 = sp_3;
-      sp4 = sp_4;
-
-      /*
-       *  First loop
-       */
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];           p12 = sp1[0];
-      p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1];
-      p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2];
-      p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp0 += chan1;
-        sp1 += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp2[0];           p12 = sp3[0];
-      p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1];
-      p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2];
-      p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3];
-
-      sp2 += chan4;
-      sp3 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp2[0];     p14 = sp3[0];
-        p05 = sp2[chan1]; p15 = sp3[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp2 += chan2;
-        sp3 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp2 += chan1;
-        sp3 += chan1;
-      }
-
-      sp2 -= chan1;
-      sp3 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp4[0];
-      p03 = sp4[delta_chan1];
-      p04 = sp4[delta_chan2];
-      p05 = sp4[delta_chan3];
-
-      sp4 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp4[0]; p05 = sp4[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp4 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-        sp4 += chan1;
-      }
-
-      sp4 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-      }
-
-      /* next line */
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll;
-    else sl5 = sl4;
-
-    if ((hgt - dy_b) > 0) sl6 = sl5 + sll;
-    else sl6 = sl5;
-
-    for (i = 0; i < dx_l; i++) {
-      buffs[0][i] = (FTYPE)sl[0];
-      buffs[1][i] = (FTYPE)sl1[0];
-      buffs[2][i] = (FTYPE)sl2[0];
-      buffs[3][i] = (FTYPE)sl3[0];
-      buffs[4][i] = (FTYPE)sl4[0];
-      buffs[5][i] = (FTYPE)sl5[0];
-      buffs[6][i] = (FTYPE)sl6[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buffs[0][i + dx_l] = (FTYPE)sl[i*chan1];
-      buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1];
-      buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1];
-      buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1];
-      buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1];
-      buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1];
-      buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1];
-      buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1];
-      buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1];
-      buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1];
-      buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1];
-      buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1];
-      buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    if ((hgt - dy_b) > 1) sl = sl6 + sll;
-    else sl = sl6;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i + dx_l] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffn[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
-      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 #define BUFF_SIZE   1600
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c
index 2aebcb8..9bfbe93 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c
@@ -144,9 +144,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp = NULL;                           \
   type     *adr_dst, *dl, *dp = NULL;                           \
@@ -156,39 +153,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -246,1162 +210,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buffo = (mlib_s32*)(buff3 + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buffi[wid] = (mlib_s32)sp[0];
-      buff3[wid] = (FTYPE)buffi[wid];
-      buffi[wid + 1] = (mlib_s32)sp[chan1];
-      buff3[wid + 1] = (FTYPE)buffi[wid + 1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buffd = buff4 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (FTYPE)sp[0];
-      buff4[wid + 1] = (FTYPE)sp[chan1];
-      buff4[wid + 2] = (FTYPE)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buffd = buff5 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-      buff4[i] = (FTYPE)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-      p14 = buff3[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (FTYPE)sp[0];
-      buff5[wid + 1] = (FTYPE)sp[chan1];
-      buff5[wid + 2] = (FTYPE)sp[chan2];
-      buff5[wid + 3] = (FTYPE)sp[chan2 + chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan3, chan4;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  chan3 = chan2 + chan1;
-  chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (FTYPE)sl[i*chan1];
-      buffs[1][i] = (FTYPE)sl1[i*chan1];
-      buffs[2][i] = (FTYPE)sl2[i*chan1];
-      buffs[3][i] = (FTYPE)sl3[i*chan1];
-      buffs[4][i] = (FTYPE)sl4[i*chan1];
-      buffs[5][i] = (FTYPE)sl5[i*chan1];
-      buffs[6][i] = (FTYPE)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c
deleted file mode 100644
index cd763f5..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-#include "mlib_image.h"
-#include "mlib_ImageAffine.h"
-#include "mlib_ImageColormap.h"
-
-/***************************************************************/
-#define MLIB_LIMIT  512
-#define MLIB_SHIFT   16
-#define MLIB_PREC    (1 << MLIB_SHIFT)
-#define MLIB_MASK    (MLIB_PREC - 1)
-
-/***************************************************************/
-#define DTYPE  MLIB_TYPE
-
-/***************************************************************/
-#define DECLAREVAR_IND()                                        \
-  DECLAREVAR0();                                                \
-  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
-  mlib_s32  xSrc, ySrc;                                         \
-  mlib_s32  srcYStride = param -> srcYStride;                   \
-  mlib_s32  max_xsize  = param -> max_xsize;                    \
-  mlib_filter filter = param -> filter;                         \
-  MLIB_TYPE *sp, *dl;                                           \
-  mlib_d64  xf0, xf1, xf2, xf3;                                 \
-  mlib_d64  yf0, yf1, yf2, yf3;                                 \
-  mlib_d64  c0, c1, c2, c3, val0;                               \
-  mlib_s32  filterpos;                                          \
-  mlib_f32  *fptr;                                              \
-  mlib_d64  s0, s1, s2, s3;                                     \
-  mlib_s32  i, size
-
-/***************************************************************/
-#define GET_FILTERS_KOEF()                                         \
-  filterpos = (X >> FILTER_SHIFT) & FILTER_MASK;                   \
-  fptr = (mlib_f32 *) ((mlib_u8 *)mlib_filters_table + filterpos); \
-                                                                   \
-  xf0 = fptr[0];                                                   \
-  xf1 = fptr[1];                                                   \
-  xf2 = fptr[2];                                                   \
-  xf3 = fptr[3];                                                   \
-                                                                   \
-  filterpos = (Y >> FILTER_SHIFT) & FILTER_MASK;                   \
-  fptr = (mlib_f32 *) ((mlib_u8 *)mlib_filters_table + filterpos); \
-                                                                   \
-  yf0 = fptr[0];                                                   \
-  yf1 = fptr[1];                                                   \
-  yf2 = fptr[2];                                                   \
-  yf3 = fptr[3]
-
-/***************************************************************/
-#define GET_POINTER()                                           \
-  xSrc = (X >> MLIB_SHIFT)-1;                                   \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                   \
-  sp = ((MLIB_TYPE **)lineAddr)[ySrc] + xSrc
-
-/***************************************************************/
-#define LOAD_FIRST_ROW(nchan, chan)                             \
-  s0 = *(lut + sp[0]*nchan + chan);                             \
-  s1 = *(lut + sp[1]*nchan + chan);                             \
-  s2 = *(lut + sp[2]*nchan + chan);                             \
-  s3 = *(lut + sp[3]*nchan + chan)
-
-/***************************************************************/
-#define COUNT_NEXT_ROW(dst, nchan, chan)                        \
-  sp = (MLIB_TYPE*)((mlib_addr)sp + srcYStride);                \
-  dst = ((*(lut + sp[0]*nchan + chan))*xf0 +                    \
-         (*(lut + sp[1]*nchan + chan))*xf1 +                    \
-         (*(lut + sp[2]*nchan + chan))*xf2 +                    \
-         (*(lut + sp[3]*nchan + chan))*xf3)
-
-/***************************************************************/
-#ifdef MLIB_USE_FTOI_CLAMPING
-
-/***********/
-#define STORE_SAT_VALUE_U8(ind)                                 \
-  dp[ind] = ((mlib_s32)(val0 - (mlib_d64)0x7F800000) >> 24) ^ 0x80
-
-/***********/
-#define STORE_SAT_VALUE_S16(ind)                                \
-  dp[ind] = ((mlib_s32)(val0)) >> 16
-
-#else
-
-/***********/
-#define STORE_SAT_VALUE_U8(ind)                                 \
-  val0 -= (mlib_d64)0x7F800000;                                 \
-  if (val0 >= MLIB_S32_MAX)                                     \
-    dp[ind] = MLIB_U8_MAX;                                      \
-  else if (val0 <= MLIB_S32_MIN)                                \
-    dp[ind] = MLIB_U8_MIN;                                      \
-  else                                                          \
-    dp[ind] = ((mlib_s32)val0 >> 24) ^ 0x80
-
-/***********/
-#define STORE_SAT_VALUE_S16(ind)                                \
-  if (val0 >= MLIB_S32_MAX)                                     \
-    dp[ind] = MLIB_S16_MAX;                                     \
-  else if (val0 <= MLIB_S32_MIN)                                \
-    dp[ind] = MLIB_S16_MIN;                                     \
-  else                                                          \
-    dp[ind] = (mlib_s32)val0 >> 16
-
-#endif /* MLIB_USE_FTOI_CLAMPING */
-
-/***************************************************************/
-#define MAKE_BC_3CH(lut_format)                                 \
-  X += dX;                                                      \
-  Y += dY;                                                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 0);                                     \
-  COUNT_NEXT_ROW(c2, 3, 0);                                     \
-  COUNT_NEXT_ROW(c3, 3, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 1);                                     \
-  COUNT_NEXT_ROW(c2, 3, 1);                                     \
-  COUNT_NEXT_ROW(c3, 3, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 2);                                     \
-  COUNT_NEXT_ROW(c2, 3, 2);                                     \
-  COUNT_NEXT_ROW(c3, 3, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  GET_FILTERS_KOEF();                                           \
-  GET_POINTER();                                                \
-  LOAD_FIRST_ROW(3, 0);                                         \
-  STORE_SAT_VALUE_##lut_format(2);
-
-/***************************************************************/
-#define MAKE_LAST_PIXEL_BC_3CH(lut_format)                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 0);                                     \
-  COUNT_NEXT_ROW(c2, 3, 0);                                     \
-  COUNT_NEXT_ROW(c3, 3, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 1);                                     \
-  COUNT_NEXT_ROW(c2, 3, 1);                                     \
-  COUNT_NEXT_ROW(c3, 3, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 2);                                     \
-  COUNT_NEXT_ROW(c2, 3, 2);                                     \
-  COUNT_NEXT_ROW(c3, 3, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  STORE_SAT_VALUE_##lut_format(2);
-
-/***************************************************************/
-#define MAKE_BC_4CH(lut_format)                                 \
-  X += dX;                                                      \
-  Y += dY;                                                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 0);                                     \
-  COUNT_NEXT_ROW(c2, 4, 0);                                     \
-  COUNT_NEXT_ROW(c3, 4, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 1);                                     \
-  COUNT_NEXT_ROW(c2, 4, 1);                                     \
-  COUNT_NEXT_ROW(c3, 4, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 2);                                     \
-  COUNT_NEXT_ROW(c2, 4, 2);                                     \
-  COUNT_NEXT_ROW(c3, 4, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 3);                                         \
-  STORE_SAT_VALUE_##lut_format(2);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 3);                                     \
-  COUNT_NEXT_ROW(c2, 4, 3);                                     \
-  COUNT_NEXT_ROW(c3, 4, 3);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  GET_FILTERS_KOEF();                                           \
-  GET_POINTER();                                                \
-  LOAD_FIRST_ROW(4, 0);                                         \
-  STORE_SAT_VALUE_##lut_format(3);
-
-/***************************************************************/
-#define MAKE_LAST_PIXEL_BC_4CH(lut_format)                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 0);                                     \
-  COUNT_NEXT_ROW(c2, 4, 0);                                     \
-  COUNT_NEXT_ROW(c3, 4, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 1);                                     \
-  COUNT_NEXT_ROW(c2, 4, 1);                                     \
-  COUNT_NEXT_ROW(c3, 4, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 2);                                     \
-  COUNT_NEXT_ROW(c2, 4, 2);                                     \
-  COUNT_NEXT_ROW(c3, 4, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 3);                                         \
-  STORE_SAT_VALUE_##lut_format(2);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 3);                                     \
-  COUNT_NEXT_ROW(c2, 4, 3);                                     \
-  COUNT_NEXT_ROW(c3, 4, 3);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  STORE_SAT_VALUE_##lut_format(3);
-
-/***************************************************************/
-#define FILTER_U8  ((filter == MLIB_BICUBIC) ? mlib_filters_u8f_bc  : mlib_filters_u8f_bc2)
-#define FILTER_S16 ((filter == MLIB_BICUBIC) ? mlib_filters_s16f_bc : mlib_filters_s16f_bc2)
-
-/***************************************************************/
-#define mlib_U8  mlib_u8
-#define mlib_S16 mlib_s16
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BC_0(ITYPE, LTYPE, NCHAN)                                                  \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BC(mlib_affine_param *param,    \
-                                                                       const void        *colormap) \
-  {                                                                                                 \
-    DECLAREVAR_IND();                                                                               \
-    mlib_##LTYPE buff_lcl[NCHAN * MLIB_LIMIT], *pbuff = buff_lcl, *dp;                              \
-    mlib_d64  *lut = ((mlib_d64*)mlib_ImageGetLutDoubleData(colormap) -                             \
-                      NCHAN * mlib_ImageGetLutOffset(colormap));                                    \
-    const mlib_f32 *mlib_filters_table = FILTER_##LTYPE;                                            \
-                                                                                                    \
-    if (max_xsize > MLIB_LIMIT) {                                                                   \
-      pbuff = mlib_malloc(NCHAN * sizeof(mlib_##LTYPE) * max_xsize);                                \
-      if (pbuff == NULL) return MLIB_FAILURE;                                                       \
-    }                                                                                               \
-                                                                                                    \
-    for (j = yStart; j <= yFinish; j++) {                                                           \
-                                                                                                    \
-      NEW_LINE(1);                                                                                  \
-      dp = pbuff;                                                                                   \
-                                                                                                    \
-      GET_FILTERS_KOEF();                                                                           \
-      GET_POINTER();                                                                                \
-      LOAD_FIRST_ROW(NCHAN, 0);
-
-    /* pragma pipeloop(0) must be here */
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BC_1(ITYPE, LTYPE, NCHAN)                         \
-                                                                           \
-      for (i = 0; i < (xRight - xLeft); i++, dp += NCHAN) {                \
-        MAKE_BC_##NCHAN##CH(LTYPE);                                        \
-      }                                                                    \
-                                                                           \
-      MAKE_LAST_PIXEL_BC_##NCHAN##CH(LTYPE);                               \
-                                                                           \
-      mlib_ImageColorTrue2IndexLine_##LTYPE##_##ITYPE##_##NCHAN            \
-                                (pbuff, dl, xRight - xLeft + 1, colormap); \
-    }                                                                      \
-                                                                           \
-    if (pbuff != buff_lcl) mlib_free(pbuff);                               \
-                                                                           \
-    return MLIB_SUCCESS;                                                   \
-  }
-
-/***************************************************************/
-#undef MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, U8, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, S16, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, U8, 4)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, S16, 4)
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_s16
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, U8, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, S16, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, U8, 4)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, S16, 4)
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c
deleted file mode 100644
index 83ef3e5..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-#include "mlib_image.h"
-#include "mlib_ImageAffine.h"
-#include "mlib_ImageColormap.h"
-
-/***************************************************************/
-#define MLIB_LIMIT  512
-
-/***************************************************************/
-#define DTYPE  MLIB_TYPE
-
-/***************************************************************/
-#define DECLAREVAR_IND()                                        \
-  DECLAREVAR0();                                                \
-  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
-  mlib_s32  xSrc, ySrc;                                         \
-  mlib_s32  srcYStride = param -> srcYStride;                   \
-  mlib_s32  max_xsize  = param -> max_xsize;                    \
-  MLIB_TYPE *sp0, *sp1;                                         \
-  MLIB_TYPE *dl;                                                \
-  mlib_d64  scale = 1.0 / 65536.0;                              \
-  mlib_s32  i, size
-
-/***************************************************************/
-#define DECLARE_INTERNAL_VAR_3CH()                              \
-  mlib_d64  fdx, fdy;                                           \
-  mlib_d64  a00_0, a01_0, a10_0, a11_0;                         \
-  mlib_d64  a00_1, a01_1, a10_1, a11_1;                         \
-  mlib_d64  a00_2, a01_2, a10_2, a11_2;                         \
-  mlib_d64  pix0_0, pix1_0, res0;                               \
-  mlib_d64  pix0_1, pix1_1, res1;                               \
-  mlib_d64  pix0_2, pix1_2, res2
-
-/***************************************************************/
-#define DECLARE_INTERNAL_VAR_4CH()                              \
-  mlib_d64  fdx, fdy;                                           \
-  mlib_d64  a00_0, a01_0, a10_0, a11_0;                         \
-  mlib_d64  a00_1, a01_1, a10_1, a11_1;                         \
-  mlib_d64  a00_2, a01_2, a10_2, a11_2;                         \
-  mlib_d64  a00_3, a01_3, a10_3, a11_3;                         \
-  mlib_d64  pix0_0, pix1_0, res0;                               \
-  mlib_d64  pix0_1, pix1_1, res1;                               \
-  mlib_d64  pix0_2, pix1_2, res2;                               \
-  mlib_d64  pix0_3, pix1_3, res3
-
-/***************************************************************/
-#define GET_PIXELS_POINTERS()                                   \
-  fdx = (X & MLIB_MASK) * scale;                                \
-  fdy = (Y & MLIB_MASK) * scale;                                \
-  ySrc = MLIB_POINTER_SHIFT(Y);  Y += dY;                       \
-  xSrc = X >> MLIB_SHIFT;  X += dX;                             \
-  sp0 = MLIB_POINTER_GET(lineAddr, ySrc) + xSrc;                \
-  sp1 = (MLIB_TYPE *)((mlib_u8 *)sp0 + srcYStride)
-
-/***************************************************************/
-#define GET_COLOR_POINTERS(ind)                                 \
-  pcolor00 = (lut + sp0[0]*ind);                                \
-  pcolor10 = (lut + sp1[0]*ind);                                \
-  pcolor01 = (lut + sp0[1]*ind);                                \
-  pcolor11 = (lut + sp1[1]*ind)
-
-/***************************************************************/
-#define COUNT_BL_U8(ind)                                        \
-  pix0_##ind = a00_##ind + fdy * (a10_##ind - a00_##ind);       \
-  pix1_##ind = a01_##ind + fdy * (a11_##ind - a01_##ind);       \
-  res##ind = pix0_##ind + fdx * (pix1_##ind - pix0_##ind) + 0.5
-
-/***************************************************************/
-#define COUNT_BL_U8_3CH()                                       \
-  COUNT_BL_U8(0);                                               \
-  COUNT_BL_U8(1);                                               \
-  COUNT_BL_U8(2);
-
-/***************************************************************/
-#define COUNT_BL_U8_4CH()                                       \
-  COUNT_BL_U8_3CH();                                            \
-  COUNT_BL_U8(3);
-
-/***************************************************************/
-#define COUNT_BL_S16(ind)                                       \
-  pix0_##ind = a00_##ind + fdy * (a10_##ind - a00_##ind);       \
-  pix1_##ind = a01_##ind + fdy * (a11_##ind - a01_##ind);       \
-  res##ind = pix0_##ind + fdx * (pix1_##ind - pix0_##ind)
-
-/***************************************************************/
-#define COUNT_BL_S16_3CH()                                      \
-  COUNT_BL_S16(0);                                              \
-  COUNT_BL_S16(1);                                              \
-  COUNT_BL_S16(2);
-
-/***************************************************************/
-#define COUNT_BL_S16_4CH()                                      \
-  COUNT_BL_S16_3CH();                                           \
-  COUNT_BL_S16(3);
-
-/***************************************************************/
-#define LOAD(ind)                                               \
-  a00_##ind = pcolor00[ind];                                    \
-  a01_##ind = pcolor01[ind];                                    \
-  a10_##ind = pcolor10[ind];                                    \
-  a11_##ind = pcolor11[ind]
-
-/***************************************************************/
-#define LOAD_3CH()                                              \
-  LOAD(0);                                                      \
-  LOAD(1);                                                      \
-  LOAD(2);
-
-/***************************************************************/
-#define LOAD_4CH()                                              \
-  LOAD_3CH();                                                   \
-  LOAD(3);
-
-/***************************************************************/
-#define STORE_INTO_INTERM_BUF_3CH(LTYPE)                        \
-  dp[0] = (mlib_##LTYPE)res0;                                   \
-  dp[1] = (mlib_##LTYPE)res1;                                   \
-  dp[2] = (mlib_##LTYPE)res2
-
-/***************************************************************/
-#define STORE_INTO_INTERM_BUF_4CH(LTYPE)                        \
-  dp[0] = (mlib_##LTYPE)res0;                                   \
-  dp[1] = (mlib_##LTYPE)res1;                                   \
-  dp[2] = (mlib_##LTYPE)res2;                                   \
-  dp[3] = (mlib_##LTYPE)res3
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-/***************************************************************/
-#define mlib_U8  mlib_u8
-#define mlib_S16 mlib_s16
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BL_0(ITYPE, LTYPE, NCHAN)                                               \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BL(mlib_affine_param *param, \
-                                                                       const void        *colormap) \
-  {                                                                                              \
-    DECLAREVAR_IND();                                                                            \
-    mlib_##LTYPE  *dp, buff_lcl[NCHAN*MLIB_LIMIT], *pbuff = buff_lcl;                            \
-    mlib_d64 *pcolor00, *pcolor10, *pcolor01, *pcolor11;                                         \
-    mlib_d64 *lut = mlib_ImageGetLutDoubleData(colormap);                                        \
-                                                                                                 \
-    lut -= NCHAN*mlib_ImageGetLutOffset(colormap);                                               \
-                                                                                                 \
-    if (max_xsize > MLIB_LIMIT) {                                                                \
-      pbuff = mlib_malloc(NCHAN * sizeof(mlib_##LTYPE) * max_xsize);                             \
-      if (pbuff == NULL) return MLIB_FAILURE;                                                    \
-    }                                                                                            \
-                                                                                                 \
-    for (j = yStart; j <= yFinish; j++) {                                                        \
-      DECLARE_INTERNAL_VAR_##NCHAN##CH();                                                        \
-                                                                                                 \
-      NEW_LINE(1);                                                                               \
-      dp = pbuff;                                                                                \
-                                                                                                 \
-      GET_PIXELS_POINTERS();                                                                     \
-      GET_COLOR_POINTERS(NCHAN);                                                                 \
-      LOAD_##NCHAN##CH();
-
-    /* pragma pipeloop(0) must be here */
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BL_1(ITYPE, LTYPE, NCHAN)                   \
-      for (i = 0; i < (xRight - xLeft); i++, dp += NCHAN) {          \
-        COUNT_BL_##LTYPE##_##NCHAN##CH();                            \
-                                                                     \
-        GET_PIXELS_POINTERS();                                       \
-        GET_COLOR_POINTERS(NCHAN);                                   \
-        LOAD_##NCHAN##CH();                                          \
-                                                                     \
-        STORE_INTO_INTERM_BUF_##NCHAN##CH(LTYPE);                    \
-      }                                                              \
-                                                                     \
-      COUNT_BL_##LTYPE##_##NCHAN##CH();                              \
-      STORE_INTO_INTERM_BUF_##NCHAN##CH(LTYPE);                      \
-                                                                     \
-      mlib_ImageColorTrue2IndexLine_##LTYPE##_##ITYPE##_##NCHAN      \
-                          (pbuff, dl, xRight - xLeft + 1, colormap); \
-    }                                                                \
-                                                                     \
-    if (pbuff != buff_lcl) mlib_free(pbuff);                         \
-                                                                     \
-    return MLIB_SUCCESS;                                             \
-  }
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-FUNC_AFFINEINDEX_BL_0(U8, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, U8, 3)
-
-FUNC_AFFINEINDEX_BL_0(U8, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, S16, 3)
-
-FUNC_AFFINEINDEX_BL_0(U8, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, U8, 4)
-
-FUNC_AFFINEINDEX_BL_0(U8, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, S16, 4)
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_s16
-
-FUNC_AFFINEINDEX_BL_0(S16, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, U8, 3)
-
-FUNC_AFFINEINDEX_BL_0(S16, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, S16, 3)
-
-FUNC_AFFINEINDEX_BL_0(S16, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, U8, 4)
-
-FUNC_AFFINEINDEX_BL_0(S16, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, S16, 4)
-
-/***************************************************************/
-const type_affine_i_fun mlib_AffineFunArr_bl_i[] = {
-  mlib_ImageAffineIndex_U8_U8_3CH_BL,
-  mlib_ImageAffineIndex_U8_U8_4CH_BL,
-  mlib_ImageAffineIndex_S16_U8_3CH_BL,
-  mlib_ImageAffineIndex_S16_U8_4CH_BL,
-  mlib_ImageAffineIndex_U8_S16_3CH_BL,
-  mlib_ImageAffineIndex_U8_S16_4CH_BL,
-  mlib_ImageAffineIndex_S16_S16_3CH_BL,
-  mlib_ImageAffineIndex_S16_S16_4CH_BL
-};
-/***************************************************************/
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c
deleted file mode 100644
index 2447f76..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <mlib_image.h>
-#include "mlib_c_ImageBlendTable.h"
-
-const mlib_f32 mlib_c_blend_u8[] = {
-    0.0f,   1.0f,   2.0f,   3.0f,   4.0f,   5.0f,   6.0f,   7.0f,
-    8.0f,   9.0f,  10.0f,  11.0f,  12.0f,  13.0f,  14.0f,  15.0f,
-   16.0f,  17.0f,  18.0f,  19.0f,  20.0f,  21.0f,  22.0f,  23.0f,
-   24.0f,  25.0f,  26.0f,  27.0f,  28.0f,  29.0f,  30.0f,  31.0f,
-   32.0f,  33.0f,  34.0f,  35.0f,  36.0f,  37.0f,  38.0f,  39.0f,
-   40.0f,  41.0f,  42.0f,  43.0f,  44.0f,  45.0f,  46.0f,  47.0f,
-   48.0f,  49.0f,  50.0f,  51.0f,  52.0f,  53.0f,  54.0f,  55.0f,
-   56.0f,  57.0f,  58.0f,  59.0f,  60.0f,  61.0f,  62.0f,  63.0f,
-   64.0f,  65.0f,  66.0f,  67.0f,  68.0f,  69.0f,  70.0f,  71.0f,
-   72.0f,  73.0f,  74.0f,  75.0f,  76.0f,  77.0f,  78.0f,  79.0f,
-   80.0f,  81.0f,  82.0f,  83.0f,  84.0f,  85.0f,  86.0f,  87.0f,
-   88.0f,  89.0f,  90.0f,  91.0f,  92.0f,  93.0f,  94.0f,  95.0f,
-   96.0f,  97.0f,  98.0f,  99.0f, 100.0f, 101.0f, 102.0f, 103.0f,
-  104.0f, 105.0f, 106.0f, 107.0f, 108.0f, 109.0f, 110.0f, 111.0f,
-  112.0f, 113.0f, 114.0f, 115.0f, 116.0f, 117.0f, 118.0f, 119.0f,
-  120.0f, 121.0f, 122.0f, 123.0f, 124.0f, 125.0f, 126.0f, 127.0f,
-  128.0f, 129.0f, 130.0f, 131.0f, 132.0f, 133.0f, 134.0f, 135.0f,
-  136.0f, 137.0f, 138.0f, 139.0f, 140.0f, 141.0f, 142.0f, 143.0f,
-  144.0f, 145.0f, 146.0f, 147.0f, 148.0f, 149.0f, 150.0f, 151.0f,
-  152.0f, 153.0f, 154.0f, 155.0f, 156.0f, 157.0f, 158.0f, 159.0f,
-  160.0f, 161.0f, 162.0f, 163.0f, 164.0f, 165.0f, 166.0f, 167.0f,
-  168.0f, 169.0f, 170.0f, 171.0f, 172.0f, 173.0f, 174.0f, 175.0f,
-  176.0f, 177.0f, 178.0f, 179.0f, 180.0f, 181.0f, 182.0f, 183.0f,
-  184.0f, 185.0f, 186.0f, 187.0f, 188.0f, 189.0f, 190.0f, 191.0f,
-  192.0f, 193.0f, 194.0f, 195.0f, 196.0f, 197.0f, 198.0f, 199.0f,
-  200.0f, 201.0f, 202.0f, 203.0f, 204.0f, 205.0f, 206.0f, 207.0f,
-  208.0f, 209.0f, 210.0f, 211.0f, 212.0f, 213.0f, 214.0f, 215.0f,
-  216.0f, 217.0f, 218.0f, 219.0f, 220.0f, 221.0f, 222.0f, 223.0f,
-  224.0f, 225.0f, 226.0f, 227.0f, 228.0f, 229.0f, 230.0f, 231.0f,
-  232.0f, 233.0f, 234.0f, 235.0f, 236.0f, 237.0f, 238.0f, 239.0f,
-  240.0f, 241.0f, 242.0f, 243.0f, 244.0f, 245.0f, 246.0f, 247.0f,
-  248.0f, 249.0f, 250.0f, 251.0f, 252.0f, 253.0f, 254.0f, 255.0f,
-  256.0f
-};
-
-const mlib_f32 mlib_c_blend_Q8[] = {
-  0.00000000f, 0.00390625f, 0.00781250f, 0.01171875f,
-  0.01562500f, 0.01953125f, 0.02343750f, 0.02734375f,
-  0.03125000f, 0.03515625f, 0.03906250f, 0.04296875f,
-  0.04687500f, 0.05078125f, 0.05468750f, 0.05859375f,
-  0.06250000f, 0.06640625f, 0.07031250f, 0.07421875f,
-  0.07812500f, 0.08203125f, 0.08593750f, 0.08984375f,
-  0.09375000f, 0.09765625f, 0.10156250f, 0.10546875f,
-  0.10937500f, 0.11328125f, 0.11718750f, 0.12109375f,
-  0.12500000f, 0.12890625f, 0.13281250f, 0.13671875f,
-  0.14062500f, 0.14453125f, 0.14843750f, 0.15234375f,
-  0.15625000f, 0.16015625f, 0.16406250f, 0.16796875f,
-  0.17187500f, 0.17578125f, 0.17968750f, 0.18359375f,
-  0.18750000f, 0.19140625f, 0.19531250f, 0.19921875f,
-  0.20312500f, 0.20703125f, 0.21093750f, 0.21484375f,
-  0.21875000f, 0.22265625f, 0.22656250f, 0.23046875f,
-  0.23437500f, 0.23828125f, 0.24218750f, 0.24609375f,
-  0.25000000f, 0.25390625f, 0.25781250f, 0.26171875f,
-  0.26562500f, 0.26953125f, 0.27343750f, 0.27734375f,
-  0.28125000f, 0.28515625f, 0.28906250f, 0.29296875f,
-  0.29687500f, 0.30078125f, 0.30468750f, 0.30859375f,
-  0.31250000f, 0.31640625f, 0.32031250f, 0.32421875f,
-  0.32812500f, 0.33203125f, 0.33593750f, 0.33984375f,
-  0.34375000f, 0.34765625f, 0.35156250f, 0.35546875f,
-  0.35937500f, 0.36328125f, 0.36718750f, 0.37109375f,
-  0.37500000f, 0.37890625f, 0.38281250f, 0.38671875f,
-  0.39062500f, 0.39453125f, 0.39843750f, 0.40234375f,
-  0.40625000f, 0.41015625f, 0.41406250f, 0.41796875f,
-  0.42187500f, 0.42578125f, 0.42968750f, 0.43359375f,
-  0.43750000f, 0.44140625f, 0.44531250f, 0.44921875f,
-  0.45312500f, 0.45703125f, 0.46093750f, 0.46484375f,
-  0.46875000f, 0.47265625f, 0.47656250f, 0.48046875f,
-  0.48437500f, 0.48828125f, 0.49218750f, 0.49609375f,
-  0.50000000f, 0.50390625f, 0.50781250f, 0.51171875f,
-  0.51562500f, 0.51953125f, 0.52343750f, 0.52734375f,
-  0.53125000f, 0.53515625f, 0.53906250f, 0.54296875f,
-  0.54687500f, 0.55078125f, 0.55468750f, 0.55859375f,
-  0.56250000f, 0.56640625f, 0.57031250f, 0.57421875f,
-  0.57812500f, 0.58203125f, 0.58593750f, 0.58984375f,
-  0.59375000f, 0.59765625f, 0.60156250f, 0.60546875f,
-  0.60937500f, 0.61328125f, 0.61718750f, 0.62109375f,
-  0.62500000f, 0.62890625f, 0.63281250f, 0.63671875f,
-  0.64062500f, 0.64453125f, 0.64843750f, 0.65234375f,
-  0.65625000f, 0.66015625f, 0.66406250f, 0.66796875f,
-  0.67187500f, 0.67578125f, 0.67968750f, 0.68359375f,
-  0.68750000f, 0.69140625f, 0.69531250f, 0.69921875f,
-  0.70312500f, 0.70703125f, 0.71093750f, 0.71484375f,
-  0.71875000f, 0.72265625f, 0.72656250f, 0.73046875f,
-  0.73437500f, 0.73828125f, 0.74218750f, 0.74609375f,
-  0.75000000f, 0.75390625f, 0.75781250f, 0.76171875f,
-  0.76562500f, 0.76953125f, 0.77343750f, 0.77734375f,
-  0.78125000f, 0.78515625f, 0.78906250f, 0.79296875f,
-  0.79687500f, 0.80078125f, 0.80468750f, 0.80859375f,
-  0.81250000f, 0.81640625f, 0.82031250f, 0.82421875f,
-  0.82812500f, 0.83203125f, 0.83593750f, 0.83984375f,
-  0.84375000f, 0.84765625f, 0.85156250f, 0.85546875f,
-  0.85937500f, 0.86328125f, 0.86718750f, 0.87109375f,
-  0.87500000f, 0.87890625f, 0.88281250f, 0.88671875f,
-  0.89062500f, 0.89453125f, 0.89843750f, 0.90234375f,
-  0.90625000f, 0.91015625f, 0.91406250f, 0.91796875f,
-  0.92187500f, 0.92578125f, 0.92968750f, 0.93359375f,
-  0.93750000f, 0.94140625f, 0.94531250f, 0.94921875f,
-  0.95312500f, 0.95703125f, 0.96093750f, 0.96484375f,
-  0.96875000f, 0.97265625f, 0.97656250f, 0.98046875f,
-  0.98437500f, 0.98828125f, 0.99218750f, 0.99609375f,
-  1.00000000f, 1.00390625f, 1.00781250f, 1.01171875f,
-  1.01562500f, 1.01953125f, 1.02343750f, 1.02734375f,
-  1.03125000f, 1.03515625f, 1.03906250f, 1.04296875f,
-  1.04687500f, 1.05078125f, 1.05468750f, 1.05859375f,
-  1.06250000f, 1.06640625f, 1.07031250f, 1.07421875f,
-  1.07812500f, 1.08203125f, 1.08593750f, 1.08984375f,
-  1.09375000f, 1.09765625f, 1.10156250f, 1.10546875f,
-  1.10937500f, 1.11328125f, 1.11718750f, 1.12109375f,
-  1.12500000f, 1.12890625f, 1.13281250f, 1.13671875f,
-  1.14062500f, 1.14453125f, 1.14843750f, 1.15234375f,
-  1.15625000f, 1.16015625f, 1.16406250f, 1.16796875f,
-  1.17187500f, 1.17578125f, 1.17968750f, 1.18359375f,
-  1.18750000f, 1.19140625f, 1.19531250f, 1.19921875f,
-  1.20312500f, 1.20703125f, 1.21093750f, 1.21484375f,
-  1.21875000f, 1.22265625f, 1.22656250f, 1.23046875f,
-  1.23437500f, 1.23828125f, 1.24218750f, 1.24609375f,
-  1.25000000f, 1.25390625f, 1.25781250f, 1.26171875f,
-  1.26562500f, 1.26953125f, 1.27343750f, 1.27734375f,
-  1.28125000f, 1.28515625f, 1.28906250f, 1.29296875f,
-  1.29687500f, 1.30078125f, 1.30468750f, 1.30859375f,
-  1.31250000f, 1.31640625f, 1.32031250f, 1.32421875f,
-  1.32812500f, 1.33203125f, 1.33593750f, 1.33984375f,
-  1.34375000f, 1.34765625f, 1.35156250f, 1.35546875f,
-  1.35937500f, 1.36328125f, 1.36718750f, 1.37109375f,
-  1.37500000f, 1.37890625f, 1.38281250f, 1.38671875f,
-  1.39062500f, 1.39453125f, 1.39843750f, 1.40234375f,
-  1.40625000f, 1.41015625f, 1.41406250f, 1.41796875f,
-  1.42187500f, 1.42578125f, 1.42968750f, 1.43359375f,
-  1.43750000f, 1.44140625f, 1.44531250f, 1.44921875f,
-  1.45312500f, 1.45703125f, 1.46093750f, 1.46484375f,
-  1.46875000f, 1.47265625f, 1.47656250f, 1.48046875f,
-  1.48437500f, 1.48828125f, 1.49218750f, 1.49609375f,
-  1.50000000f, 1.50390625f, 1.50781250f, 1.51171875f,
-  1.51562500f, 1.51953125f, 1.52343750f, 1.52734375f,
-  1.53125000f, 1.53515625f, 1.53906250f, 1.54296875f,
-  1.54687500f, 1.55078125f, 1.55468750f, 1.55859375f,
-  1.56250000f, 1.56640625f, 1.57031250f, 1.57421875f,
-  1.57812500f, 1.58203125f, 1.58593750f, 1.58984375f,
-  1.59375000f, 1.59765625f, 1.60156250f, 1.60546875f,
-  1.60937500f, 1.61328125f, 1.61718750f, 1.62109375f,
-  1.62500000f, 1.62890625f, 1.63281250f, 1.63671875f,
-  1.64062500f, 1.64453125f, 1.64843750f, 1.65234375f,
-  1.65625000f, 1.66015625f, 1.66406250f, 1.66796875f,
-  1.67187500f, 1.67578125f, 1.67968750f, 1.68359375f,
-  1.68750000f, 1.69140625f, 1.69531250f, 1.69921875f,
-  1.70312500f, 1.70703125f, 1.71093750f, 1.71484375f,
-  1.71875000f, 1.72265625f, 1.72656250f, 1.73046875f,
-  1.73437500f, 1.73828125f, 1.74218750f, 1.74609375f,
-  1.75000000f, 1.75390625f, 1.75781250f, 1.76171875f,
-  1.76562500f, 1.76953125f, 1.77343750f, 1.77734375f,
-  1.78125000f, 1.78515625f, 1.78906250f, 1.79296875f,
-  1.79687500f, 1.80078125f, 1.80468750f, 1.80859375f,
-  1.81250000f, 1.81640625f, 1.82031250f, 1.82421875f,
-  1.82812500f, 1.83203125f, 1.83593750f, 1.83984375f,
-  1.84375000f, 1.84765625f, 1.85156250f, 1.85546875f,
-  1.85937500f, 1.86328125f, 1.86718750f, 1.87109375f,
-  1.87500000f, 1.87890625f, 1.88281250f, 1.88671875f,
-  1.89062500f, 1.89453125f, 1.89843750f, 1.90234375f,
-  1.90625000f, 1.91015625f, 1.91406250f, 1.91796875f,
-  1.92187500f, 1.92578125f, 1.92968750f, 1.93359375f,
-  1.93750000f, 1.94140625f, 1.94531250f, 1.94921875f,
-  1.95312500f, 1.95703125f, 1.96093750f, 1.96484375f,
-  1.96875000f, 1.97265625f, 1.97656250f, 1.98046875f,
-  1.98437500f, 1.98828125f, 1.99218750f, 1.99609375f,
-  2.00000000f
-};
-
-const mlib_f32 mlib_c_blend_u8_sat[] = {
-           0.0f,    8388608.0f,   16777216.0f,   25165824.0f,
-    33554432.0f,   41943040.0f,   50331648.0f,   58720256.0f,
-    67108864.0f,   75497472.0f,   83886080.0f,   92274688.0f,
-   100663296.0f,  109051904.0f,  117440512.0f,  125829120.0f,
-   134217728.0f,  142606336.0f,  150994944.0f,  159383552.0f,
-   167772160.0f,  176160768.0f,  184549376.0f,  192937984.0f,
-   201326592.0f,  209715200.0f,  218103808.0f,  226492416.0f,
-   234881024.0f,  243269632.0f,  251658240.0f,  260046848.0f,
-   268435456.0f,  276824064.0f,  285212672.0f,  293601280.0f,
-   301989888.0f,  310378496.0f,  318767104.0f,  327155712.0f,
-   335544320.0f,  343932928.0f,  352321536.0f,  360710144.0f,
-   369098752.0f,  377487360.0f,  385875968.0f,  394264576.0f,
-   402653184.0f,  411041792.0f,  419430400.0f,  427819008.0f,
-   436207616.0f,  444596224.0f,  452984832.0f,  461373440.0f,
-   469762048.0f,  478150656.0f,  486539264.0f,  494927872.0f,
-   503316480.0f,  511705088.0f,  520093696.0f,  528482304.0f,
-   536870912.0f,  545259520.0f,  553648128.0f,  562036736.0f,
-   570425344.0f,  578813952.0f,  587202560.0f,  595591168.0f,
-   603979776.0f,  612368384.0f,  620756992.0f,  629145600.0f,
-   637534208.0f,  645922816.0f,  654311424.0f,  662700032.0f,
-   671088640.0f,  679477248.0f,  687865856.0f,  696254464.0f,
-   704643072.0f,  713031680.0f,  721420288.0f,  729808896.0f,
-   738197504.0f,  746586112.0f,  754974720.0f,  763363328.0f,
-   771751936.0f,  780140544.0f,  788529152.0f,  796917760.0f,
-   805306368.0f,  813694976.0f,  822083584.0f,  830472192.0f,
-   838860800.0f,  847249408.0f,  855638016.0f,  864026624.0f,
-   872415232.0f,  880803840.0f,  889192448.0f,  897581056.0f,
-   905969664.0f,  914358272.0f,  922746880.0f,  931135488.0f,
-   939524096.0f,  947912704.0f,  956301312.0f,  964689920.0f,
-   973078528.0f,  981467136.0f,  989855744.0f,  998244352.0f,
-  1006632960.0f, 1015021568.0f, 1023410176.0f, 1031798784.0f,
-  1040187392.0f, 1048576000.0f, 1056964608.0f, 1065353216.0f,
-  1073741824.0f, 1082130432.0f, 1090519040.0f, 1098907648.0f,
-  1107296256.0f, 1115684864.0f, 1124073472.0f, 1132462080.0f,
-  1140850688.0f, 1149239296.0f, 1157627904.0f, 1166016512.0f,
-  1174405120.0f, 1182793728.0f, 1191182336.0f, 1199570944.0f,
-  1207959552.0f, 1216348160.0f, 1224736768.0f, 1233125376.0f,
-  1241513984.0f, 1249902592.0f, 1258291200.0f, 1266679808.0f,
-  1275068416.0f, 1283457024.0f, 1291845632.0f, 1300234240.0f,
-  1308622848.0f, 1317011456.0f, 1325400064.0f, 1333788672.0f,
-  1342177280.0f, 1350565888.0f, 1358954496.0f, 1367343104.0f,
-  1375731712.0f, 1384120320.0f, 1392508928.0f, 1400897536.0f,
-  1409286144.0f, 1417674752.0f, 1426063360.0f, 1434451968.0f,
-  1442840576.0f, 1451229184.0f, 1459617792.0f, 1468006400.0f,
-  1476395008.0f, 1484783616.0f, 1493172224.0f, 1501560832.0f,
-  1509949440.0f, 1518338048.0f, 1526726656.0f, 1535115264.0f,
-  1543503872.0f, 1551892480.0f, 1560281088.0f, 1568669696.0f,
-  1577058304.0f, 1585446912.0f, 1593835520.0f, 1602224128.0f,
-  1610612736.0f, 1619001344.0f, 1627389952.0f, 1635778560.0f,
-  1644167168.0f, 1652555776.0f, 1660944384.0f, 1669332992.0f,
-  1677721600.0f, 1686110208.0f, 1694498816.0f, 1702887424.0f,
-  1711276032.0f, 1719664640.0f, 1728053248.0f, 1736441856.0f,
-  1744830464.0f, 1753219072.0f, 1761607680.0f, 1769996288.0f,
-  1778384896.0f, 1786773504.0f, 1795162112.0f, 1803550720.0f,
-  1811939328.0f, 1820327936.0f, 1828716544.0f, 1837105152.0f,
-  1845493760.0f, 1853882368.0f, 1862270976.0f, 1870659584.0f,
-  1879048192.0f, 1887436800.0f, 1895825408.0f, 1904214016.0f,
-  1912602624.0f, 1920991232.0f, 1929379840.0f, 1937768448.0f,
-  1946157056.0f, 1954545664.0f, 1962934272.0f, 1971322880.0f,
-  1979711488.0f, 1988100096.0f, 1996488704.0f, 2004877312.0f,
-  2013265920.0f, 2021654528.0f, 2030043136.0f, 2038431744.0f,
-  2046820352.0f, 2055208960.0f, 2063597568.0f, 2071986176.0f,
-  2080374784.0f, 2088763392.0f, 2097152000.0f, 2105540608.0f,
-  2113929216.0f, 2122317824.0f, 2130706432.0f, 2139095040.0f,
-  2147483648.0f
-};
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h
deleted file mode 100644
index 2e95d50..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- *    These tables are used by C versions of the
- *    mlib_ImageBlend_... functions.
- */
-
-#ifndef MLIB_C_IMAGE_BLEND_TABLE_H
-#define MLIB_C_IMAGE_BLEND_TABLE_H
-
-#include "mlib_image.h"
-
-extern const mlib_f32 mlib_c_blend_u8[];
-extern const mlib_f32 mlib_U82F32[];
-extern const mlib_f32 mlib_c_blend_Q8[];
-extern const mlib_f32 mlib_c_blend_u8_sat[];
-
-#endif /* MLIB_C_IMAGEF_BLEND_TABLE_H */
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h
index 41fb980..8097c7d 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h
@@ -41,118 +41,6 @@
 }
 #endif /* FREE_AND_RETURN_STATUS */
 
-mlib_status mlib_c_conv2x2ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv3x3ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv3x3nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv4x4ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv4x4nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv5x5ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv5x5nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv7x7ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv7x7nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
 mlib_status mlib_c_convMxNnw_u8(mlib_image       *dst,
                                 const mlib_image *src,
                                 const mlib_s32   *kernel,
@@ -177,102 +65,6 @@
 
 #if ! defined ( __sparc ) /* for x86, using integer multiplies is faster */
 
-mlib_status mlib_i_conv3x3ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
 mlib_status mlib_i_convMxNnw_s16(mlib_image       *dst,
                                  const mlib_image *src,
                                  const mlib_s32   *kernel,
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c
index de4276b..825f973 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c
@@ -29,34 +29,6 @@
 #include "mlib_c_ImageConv.h"
 
 /***************************************************************/
-#define MLIB_PARAMS_CONV_NW                                     \
-  mlib_image       *dst,                                        \
-  const mlib_image *src,                                        \
-  const mlib_s32   *kern,                                       \
-  mlib_s32         scale,                                       \
-  mlib_s32         cmask
-
-/***************************************************************/
-#define MLIB_CALL_PARAMS_CONV_NW                                \
-  dst, src, kern, scale, cmask
-
-/***************************************************************/
-#define MLIB_PARAMS_CONV_EXT                                    \
-  mlib_image       *dst,                                        \
-  const mlib_image *src,                                        \
-  mlib_s32         dx_l,                                        \
-  mlib_s32         dx_r,                                        \
-  mlib_s32         dy_t,                                        \
-  mlib_s32         dy_b,                                        \
-  const mlib_s32   *kern,                                       \
-  mlib_s32         scale,                                       \
-  mlib_s32         cmask
-
-/***************************************************************/
-#define MLIB_CALL_PARAMS_CONV_EXT                               \
-  dst, src, dx_l, dx_r, dy_t, dy_b, kern, scale, cmask
-
-/***************************************************************/
 #define MLIB_PARAMS_CONV_MN_NW                                  \
   mlib_image *dst,                                              \
   const mlib_image *src,                                        \
@@ -92,52 +64,6 @@
 
 
 /***************************************************************/
-mlib_status mlib_conv2x2nw_u8(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv2x2nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv3x3nw_u8(MLIB_PARAMS_CONV_NW)
-{
-#ifdef __sparc
-  return mlib_c_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#else
-
-  if (mlib_ImageConvVersion(3, 3, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-  else
-    return mlib_i_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv4x4nw_u8(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv4x4nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv5x5nw_u8(MLIB_PARAMS_CONV_NW)
-{
-#ifdef __sparc
-  return mlib_c_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#else
-
-  if (mlib_ImageConvVersion(5, 5, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-  else
-    return mlib_i_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv7x7nw_u8(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv7x7nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
 mlib_status mlib_convMxNnw_u8(MLIB_PARAMS_CONV_MN_NW)
 {
 #ifdef __sparc
@@ -152,52 +78,6 @@
 }
 
 /***************************************************************/
-mlib_status mlib_conv2x2ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv2x2ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
-mlib_status mlib_conv3x3ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-#ifdef __sparc
-  return mlib_c_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#else
-
-  if (mlib_ImageConvVersion(3, 3, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-  else
-    return mlib_i_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv4x4ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv4x4ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
-mlib_status mlib_conv5x5ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-#ifdef __sparc
-  return mlib_c_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#else
-
-  if (mlib_ImageConvVersion(5, 5, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-  else
-    return mlib_i_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv7x7ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv7x7ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
 mlib_status mlib_convMxNext_u8(MLIB_PARAMS_CONV_MN_EXT)
 {
 #ifdef __sparc
@@ -212,27 +92,3 @@
 }
 
 /***************************************************************/
-mlib_status mlib_conv2x2nw_s16(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv2x2nw_s16(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv2x2nw_u16(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv2x2nw_u16(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv2x2ext_s16(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv2x2ext_s16(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
-mlib_status mlib_conv2x2ext_u16(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv2x2ext_u16(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h
deleted file mode 100644
index 54449b4..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-#ifndef __MLIB_C_IMAGETHRESH1_H
-#define __MLIB_C_IMAGETHRESH1_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/***************************************************************/
-#define PARAMS                                                  \
-  void     *psrc,                                               \
-  void     *pdst,                                               \
-  mlib_s32 src_stride,                                          \
-  mlib_s32 dst_stride,                                          \
-  mlib_s32 width,                                               \
-  mlib_s32 height,                                              \
-  void     *__thresh,                                           \
-  void     *__ghigh,                                            \
-  void     *__glow
-
-void mlib_c_ImageThresh1_D641(PARAMS);
-void mlib_c_ImageThresh1_D642(PARAMS);
-void mlib_c_ImageThresh1_D643(PARAMS);
-void mlib_c_ImageThresh1_D644(PARAMS);
-void mlib_c_ImageThresh1_D641_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_D642_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_D643_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_D644_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_F321(PARAMS);
-void mlib_c_ImageThresh1_F322(PARAMS);
-void mlib_c_ImageThresh1_F323(PARAMS);
-void mlib_c_ImageThresh1_F324(PARAMS);
-void mlib_c_ImageThresh1_F321_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_F322_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_F323_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_F324_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_S321(PARAMS);
-void mlib_c_ImageThresh1_S322(PARAMS);
-void mlib_c_ImageThresh1_S323(PARAMS);
-void mlib_c_ImageThresh1_S324(PARAMS);
-void mlib_c_ImageThresh1_S321_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S322_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S323_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S324_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_S161(PARAMS);
-void mlib_c_ImageThresh1_S162(PARAMS);
-void mlib_c_ImageThresh1_S163(PARAMS);
-void mlib_c_ImageThresh1_S164(PARAMS);
-void mlib_c_ImageThresh1_S161_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S162_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S163_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S164_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_U161(PARAMS);
-void mlib_c_ImageThresh1_U162(PARAMS);
-void mlib_c_ImageThresh1_U163(PARAMS);
-void mlib_c_ImageThresh1_U164(PARAMS);
-void mlib_c_ImageThresh1_U161_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U162_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U163_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U164_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_U81(PARAMS);
-void mlib_c_ImageThresh1_U82(PARAMS);
-void mlib_c_ImageThresh1_U83(PARAMS);
-void mlib_c_ImageThresh1_U84(PARAMS);
-void mlib_c_ImageThresh1_U81_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U82_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U83_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U84_1B(PARAMS, mlib_s32 dbit_off);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __MLIB_C_IMAGETHRESH1_H */
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c
deleted file mode 100644
index d16b069..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c
+++ /dev/null
@@ -1,848 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * FUNCTION
- *      mlib_ImageThresh1 - thresholding
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageThresh1(mlib_image       *dst,
- *                                    const mlib_image *src,
- *                                    const mlib_s32   *thresh,
- *                                    const mlib_s32   *ghigh,
- *                                    const mlib_s32   *glow);
- *
- * ARGUMENT
- *      dst     pointer to output image
- *      src     pointer to input image
- *      thresh  array of thresholds
- *      ghigh   array of values above thresholds
- *      glow    array of values below thresholds
- *
- * RESTRICTION
- *      The images must have the same size, and the same number
- *      of channels.
- *      The images can have 1, 2, 3, or 4 channels.
- *      The images can be in MLIB_BYTE, MLIB_SHORT or MLIB_INT data type.
- *      The type of the output image can be MLIB_BIT, or the same as the
- *      type of the input image.
- *
- * DESCRIPTION
- *      If the pixel band value is above the threshold for that channel,
- *      set the destination to the ghigh value for that channel.
- *      Otherwise, set the destination to the glow value for that channel.
- *
- *                      +- glow[c]   src[x][y][c] <= thresh[c]
- *      dst[x][y][c]  = |
- *                      +- ghigh[c]  src[x][y][c] >  thresh[c]
- */
-
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-#include "mlib_c_ImageThresh1.h"
-
-/***************************************************************/
-#define STYPE           mlib_u8
-#define TTYPE           mlib_s32
-#define T_SHIFT         31
-
-/***************************************************************/
-#define DO_THRESH(s0, th, gl, gh)                               \
-  (((gh) & (((th) - (TTYPE)(s0)) >> T_SHIFT)) |                 \
-   ((gl) &~ (((th) - (TTYPE)(s0)) >> T_SHIFT)))
-
-/***************************************************************/
-#define THRESH1_CMP_SHIFT(s0, th, sh)                           \
-  ((((th) - (s0)) >> T_SHIFT) & (1 << (sh)))
-
-/***************************************************************/
-#define STRIP(pd, ps, w, h, ch, th, gh, gl) {                   \
-    STYPE s0;                                                   \
-    for ( i = 0; i < h; i++ ) {                                 \
-      for (j = 0; j < w; j ++)  {                               \
-        for (k = 0; k < ch; k++) {                              \
-          s0 = ((STYPE*)ps)[i*src_stride + j*ch + k];           \
-          ((STYPE*)pd)[i*dst_stride + j*ch + k] =               \
-                (s0 <= th[k]) ? gl[k]: gh[k];                   \
-        }                                                       \
-      }                                                         \
-    }                                                           \
-  }
-
-/***************************************************************/
-#define INIT_THRESH0(n)                                         \
-  thresh0 = thresh[n];                                          \
-  ghigh0  = ghigh[n];                                           \
-  glow0   = glow[n]
-
-/***************************************************************/
-#define INIT_THRESH1(n)                                         \
-  thresh1 = thresh[n];                                          \
-  ghigh1  = ghigh[n];                                           \
-  glow1   = glow[n]
-
-/***************************************************************/
-#define INIT_THRESH2(n)                                         \
-  thresh2 = thresh[n];                                          \
-  ghigh2  = ghigh[n];                                           \
-  glow2   = glow[n]
-
-/***************************************************************/
-#define INIT_THRESH3(n)                                         \
-  thresh3 = thresh[n];                                          \
-  ghigh3  = ghigh[n];                                           \
-  glow3   = glow[n]
-
-/***************************************************************/
-#define THRESH0(s0) DO_THRESH(s0, thresh0, glow0, ghigh0)
-#define THRESH1(s0) DO_THRESH(s0, thresh1, glow1, ghigh1)
-#define THRESH2(s0) DO_THRESH(s0, thresh2, glow2, ghigh2)
-#define THRESH3(s0) DO_THRESH(s0, thresh3, glow3, ghigh3)
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U81(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0;
-  TTYPE ghigh0;
-  TTYPE glow0;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 1, thresh, ghigh, glow);
-    return;
-  }
-
-  INIT_THRESH0(0);
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 8); j += 8) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH0(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH0(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH0(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH0(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH0(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH0(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH0(psrc_row[j + 7]);
-    }
-
-    for (; j < width; j++) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U82(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0, thresh1;
-  TTYPE ghigh0, ghigh1;
-  TTYPE glow0, glow1;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 2, thresh, ghigh, glow);
-    return;
-  }
-
-  INIT_THRESH0(0);
-  INIT_THRESH1(1);
-  width <<= 1;
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 8); j += 8) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH0(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH1(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH0(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH1(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH0(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH1(psrc_row[j + 7]);
-    }
-
-    for (; j < width; j += 2) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U83(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2;
-  TTYPE ghigh0, ghigh1, ghigh2;
-  TTYPE glow0, glow1, glow2;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 3, thresh, ghigh, glow);
-    return;
-  }
-
-  width = 3 * width;
-  INIT_THRESH0(0);
-  INIT_THRESH1(1);
-  INIT_THRESH2(2);
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 12); j += 12) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH0(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH1(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH2(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH0(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH1(psrc_row[j + 7]);
-      pdst_row[j + 8] = THRESH2(psrc_row[j + 8]);
-      pdst_row[j + 9] = THRESH0(psrc_row[j + 9]);
-      pdst_row[j + 10] = THRESH1(psrc_row[j + 10]);
-      pdst_row[j + 11] = THRESH2(psrc_row[j + 11]);
-    }
-
-    for (; j < width; j += 3) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U84(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2, thresh3;
-  TTYPE ghigh0, ghigh1, ghigh2, ghigh3;
-  TTYPE glow0, glow1, glow2, glow3;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 4, thresh, ghigh, glow);
-    return;
-  }
-
-  INIT_THRESH0(0);
-  INIT_THRESH1(1);
-  INIT_THRESH2(2);
-  INIT_THRESH3(3);
-
-  width *= 4;
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 8); j += 8) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH3(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH0(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH1(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH2(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH3(psrc_row[j + 7]);
-    }
-
-    if (j < width) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH3(psrc_row[j + 3]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U81_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0 = thresh[0];
-  mlib_s32 mhigh, mlow, emask, dst0;
-  mlib_s32 i, j, jbit, l;
-
-  mhigh = (ghigh[0] > 0) ? 0xff : 0;
-  mlow = (glow[0] > 0) ? 0xff : 0;
-
-  for (i = 0; i < height; i++) {
-    j = 0;
-    jbit = 0;
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j < nume; j++) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-      }
-
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 16); j += 16) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh0, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh0, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh0, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh0, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh0, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh0, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh0, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-    }
-
-    if (width - j >= 8) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh0, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh0, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh0, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      j += 8;
-    }
-
-    if (j < width) {
-      dst0 = 0;
-      l = 7;
-      for (; j < width; j++) {
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l);
-        l--;
-      }
-
-      emask = (0xFF << (l + 1));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U82_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0 = thresh[0], thresh1 = thresh[1];
-  mlib_s32 mhigh0, mlow0, mhigh, mlow, emask, dst0;
-  mlib_s32 i, j, jbit, l;
-
-  mhigh0 = (ghigh[0] > 0) ? 0xaaa : 0;
-  mhigh0 |= (ghigh[1] > 0) ? 0x555 : 0;
-  mlow0 = (glow[0] > 0) ? 0xaaa : 0;
-  mlow0 |= (glow[1] > 0) ? 0x555 : 0;
-
-  width *= 2;
-
-  for (i = 0; i < height; i++) {
-    thresh0 = thresh[0];
-    thresh1 = thresh[1];
-
-    j = 0;
-    jbit = 0;
-    mhigh = mhigh0 >> (dbit_off & 1);
-    mlow = mlow0 >> (dbit_off & 1);
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j <= (nume - 2); j += 2) {
-        emask |= (3 << (6 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j));
-      }
-
-      if (j < nume) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        /* swap threshes */
-        thresh0 = thresh[1];
-        thresh1 = thresh[0];
-        j++;
-      }
-
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 16); j += 16) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh1, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh1, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh1, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh1, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-    }
-
-    if (width - j >= 8) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh1, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      j += 8;
-    }
-
-    if (j < width) {
-      dst0 = 0;
-      l = 7;
-      for (; j <= (width - 2); j += 2) {
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l);
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, l - 1);
-        l -= 2;
-      }
-
-      if (j < width) {
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l);
-        l--;
-      }
-
-      emask = (0xFF << (l + 1));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U83_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2, threshT;
-  mlib_s32 mhigh = 0, mlow = 0;
-  mlib_s32 mhigh0, mlow0, mhigh1, mlow1, mhigh2, mlow2, emask, dst0, dst1;
-  mlib_s32 i, j, jbit, k, l;
-
-  if (ghigh[0] > 0)
-    mhigh = 0x492492;
-
-  if (ghigh[1] > 0)
-    mhigh |= 0x249249;
-
-  if (ghigh[2] > 0)
-    mhigh |= 0x924924;
-
-  if (glow[0] > 0)
-    mlow = 0x492492;
-
-  if (glow[1] > 0)
-    mlow |= 0x249249;
-
-  if (glow[2] > 0)
-    mlow |= 0x924924;
-
-  width = 3 * width;
-
-  for (i = 0; i < height; i++) {
-    thresh0 = thresh[0];
-    thresh1 = thresh[1];
-    thresh2 = thresh[2];
-
-    j = 0;
-    jbit = 0;
-    mhigh0 = mhigh >> (dbit_off & 7);
-    mlow0 = mlow >> (dbit_off & 7);
-    mhigh1 = mhigh0 >> 1;
-    mlow1 = mlow0 >> 1;
-    mhigh2 = mhigh0 >> 2;
-    mlow2 = mlow0 >> 2;
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j <= (nume - 3); j += 3) {
-        emask |= (7 << (5 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5 - (dbit_off + j));
-      }
-
-      for (; j < nume; j++) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        /* swap threshes */
-        threshT = thresh0;
-        thresh0 = thresh1;
-        thresh1 = thresh2;
-        thresh2 = threshT;
-      }
-
-      dst0 = (mhigh0 & dst0) | (mlow0 & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-
-      mhigh0 = mhigh >> (9 - nume);
-      mlow0 = mlow >> (9 - nume);
-      mhigh1 = mhigh0 >> 1;
-      mlow1 = mlow0 >> 1;
-      mhigh2 = mhigh0 >> 2;
-      mlow2 = mlow0 >> 2;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 24); j += 24) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh1, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh2, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0));
-      dst0 = (mhigh0 & dst0) | (mlow0 & ~dst0);
-      *(pdst_row + jbit) = dst0;
-      jbit++;
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh2, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh0, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh1, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh2, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh0, 0));
-      dst0 = (mhigh1 & dst0) | (mlow1 & ~dst0);
-      *(pdst_row + jbit) = dst0;
-      jbit++;
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 16], thresh1, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 17], thresh2, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 18], thresh0, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 19], thresh1, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 20], thresh2, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 21], thresh0, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 22], thresh1, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 23], thresh2, 0));
-      dst0 = (mhigh2 & dst0) | (mlow2 & ~dst0);
-      *(pdst_row + jbit) = dst0;
-      jbit++;
-    }
-
-    if (j < width) {
-      k = width - j;
-      dst0 = 0;
-      l = 31;
-      for (; j < width; j += 3) {
-        dst0 |= (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l) |
-                 THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, l - 1) |
-                 THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, l - 2));
-        l -= 3;
-      }
-
-      l = (k + 7) >> 3;
-      k = (l << 3) - k;
-      emask = (0xFF << k);
-
-      if (l == 3) {
-        dst1 = dst0 >> 24;
-        dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1);
-        pdst_row[jbit] = dst1;
-        dst1 = (dst0 >> 16);
-        dst1 = (mhigh1 & dst1) | (mlow1 & ~dst1);
-        pdst_row[jbit + 1] = dst1;
-        dst1 = (dst0 >> 8);
-        dst1 = (mhigh2 & dst1) | (mlow2 & ~dst1);
-        pdst_row[jbit + 2] = (dst1 & emask) | (pdst_row[jbit + 2] & ~emask);
-      }
-      else if (l == 2) {
-        dst1 = dst0 >> 24;
-        dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1);
-        pdst_row[jbit] = dst1;
-        dst1 = (dst0 >> 16);
-        dst1 = (mhigh1 & dst1) | (mlow1 & ~dst1);
-        pdst_row[jbit + 1] = (dst1 & emask) | (pdst_row[jbit + 1] & ~emask);
-      }
-      else {
-        dst1 = dst0 >> 24;
-        dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1);
-        pdst_row[jbit] = (dst1 & emask) | (pdst_row[jbit] & ~emask);
-      }
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U84_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2, thresh3, threshT;
-  mlib_s32 mhigh0, mlow0, mhigh, mlow, emask, dst0;
-  mlib_s32 i, j, jbit;
-
-  mhigh0 = (ghigh[0] > 0) ? 0x8888 : 0;
-  mhigh0 |= (ghigh[1] > 0) ? 0x4444 : 0;
-  mhigh0 |= (ghigh[2] > 0) ? 0x2222 : 0;
-  mhigh0 |= (ghigh[3] > 0) ? 0x1111 : 0;
-
-  mlow0 = (glow[0] > 0) ? 0x8888 : 0;
-  mlow0 |= (glow[1] > 0) ? 0x4444 : 0;
-  mlow0 |= (glow[2] > 0) ? 0x2222 : 0;
-  mlow0 |= (glow[3] > 0) ? 0x1111 : 0;
-
-  width *= 4;
-
-  for (i = 0; i < height; i++) {
-    thresh0 = thresh[0];
-    thresh1 = thresh[1];
-    thresh2 = thresh[2];
-    thresh3 = thresh[3];
-
-    j = 0;
-    jbit = 0;
-    mhigh = mhigh0 >> dbit_off;
-    mlow = mlow0 >> dbit_off;
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j <= (nume - 4); j += 4) {
-        emask |= (0xf << (4 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4 - (dbit_off + j));
-      }
-
-      for (; j < nume; j++) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        /* swap threshes */
-        threshT = thresh0;
-        thresh0 = thresh1;
-        thresh1 = thresh2;
-        thresh2 = thresh3;
-        thresh3 = threshT;
-      }
-
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 16); j += 16) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh3, 0));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = dst0;
-      jbit++;
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh3, 0));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = dst0;
-      jbit++;
-    }
-
-    if (j <= width - 8) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh3, 0));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = dst0;
-      jbit++;
-      j += 8;
-    }
-
-    if (j < width) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1));
-
-      emask = (0xFF << (8 - (width - j)));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h
index 60d776a..ae1d224 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h
@@ -35,7 +35,6 @@
 #include <mlib_sys.h>
 #include <mlib_image_types.h>
 #include <mlib_image_proto.h>
-#include <mlib_image_blend_proto.h>
 #include <mlib_image_get.h>
 
 #endif  /* MLIB_IMAGE_H */
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h
deleted file mode 100644
index 5a7b001..0000000
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h
+++ /dev/null
@@ -1,1448 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-#ifndef __ORIG_MLIB_IMAGE_BLEND_PROTO_H
-#define __ORIG_MLIB_IMAGE_BLEND_PROTO_H
-
-#include <mlib_types.h>
-#include <mlib_status.h>
-#include <mlib_image_types.h>
-#if defined ( __MEDIALIB_OLD_NAMES_ADDED )
-#include <../include/mlib_image_blend_proto.h>
-#endif /* defined ( __MEDIALIB_OLD_NAMES_ADDED ) */
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#if defined ( _MSC_VER )
-#if ! defined ( __MEDIALIB_OLD_NAMES )
-#define __MEDIALIB_OLD_NAMES
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-#endif /* defined ( _MSC_VER ) */
-
-/***********************************************************************
-
-    NOTE: f = min(ALPHAsrc2, 1 - ALPHAsrc1)
-          f = min(ALPHAscr2, 1 - ALPHAsrc1dst) for In-place function
-          ALPHA = (ALPHA, ALPHA, ALPHA, ALPHA)
-
-************************************************************************/
-
-/* dst = 0 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ZERO mlib_ImageBlend_ZERO_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = 0 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ZERO_Inp mlib_ImageBlend_ZERO_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ONE mlib_ImageBlend_ZERO_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ONE_Inp mlib_ImageBlend_ZERO_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src2 * src1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DC mlib_ImageBlend_ZERO_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * src1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DC_Inp mlib_ImageBlend_ZERO_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (1 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDC mlib_ImageBlend_ZERO_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDC_Inp mlib_ImageBlend_ZERO_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SA mlib_ImageBlend_ZERO_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SA_Inp mlib_ImageBlend_ZERO_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMSA mlib_ImageBlend_ZERO_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMSA_Inp mlib_ImageBlend_ZERO_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DA mlib_ImageBlend_ZERO_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DA_Inp mlib_ImageBlend_ZERO_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDA mlib_ImageBlend_ZERO_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDA_Inp mlib_ImageBlend_ZERO_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SAS mlib_ImageBlend_ZERO_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SAS_Inp mlib_ImageBlend_ZERO_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ZERO mlib_ImageBlend_ONE_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ZERO(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ZERO_Inp mlib_ImageBlend_ONE_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ZERO_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ONE mlib_ImageBlend_ONE_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ONE(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ONE_Inp mlib_ImageBlend_ONE_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ONE_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DC mlib_ImageBlend_ONE_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DC(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DC_Inp mlib_ImageBlend_ONE_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DC_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src2 + src1 * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDC mlib_ImageBlend_ONE_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDC(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src2 + src1dst * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDC_Inp mlib_ImageBlend_ONE_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDC_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SA mlib_ImageBlend_ONE_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SA(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SA_Inp mlib_ImageBlend_ONE_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SA_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMSA mlib_ImageBlend_ONE_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMSA(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMSA_Inp mlib_ImageBlend_ONE_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMSA_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DA mlib_ImageBlend_ONE_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DA(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DA_Inp mlib_ImageBlend_ONE_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DA_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 + src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDA mlib_ImageBlend_ONE_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDA(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDA_Inp mlib_ImageBlend_ONE_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDA_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SAS mlib_ImageBlend_ONE_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SAS(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SAS_Inp mlib_ImageBlend_ONE_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SAS_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ZERO mlib_ImageBlend_SC_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ZERO(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ZERO_Inp mlib_ImageBlend_SC_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ZERO_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + 1) * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ONE mlib_ImageBlend_SC_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ONE(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = (src1dst + 1) * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ONE_Inp mlib_ImageBlend_SC_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ONE_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = 2 * src1 * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DC mlib_ImageBlend_SC_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DC(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = 2 * src1dst * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DC_Inp mlib_ImageBlend_SC_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DC_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDC mlib_ImageBlend_SC_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDC_Inp mlib_ImageBlend_SC_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (src1 + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SA mlib_ImageBlend_SC_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src2 * (src1dst + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SA_Inp mlib_ImageBlend_SC_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc2 + src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMSA mlib_ImageBlend_SC_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMSA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc2 + src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMSA_Inp mlib_ImageBlend_SC_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMSA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (src1 + ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DA mlib_ImageBlend_SC_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src2 * (src1dst + ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DA_Inp mlib_ImageBlend_SC_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc1 + src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDA mlib_ImageBlend_SC_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc1dst + src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDA_Inp mlib_ImageBlend_SC_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * ((f, f, f, 1) + src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SAS mlib_ImageBlend_SC_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SAS(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src2 * ((f, f, f, 1) + src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SAS_Inp mlib_ImageBlend_SC_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SAS_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ZERO mlib_ImageBlend_OMSC_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ZERO_Inp mlib_ImageBlend_OMSC_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + src2 * (1 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ONE mlib_ImageBlend_OMSC_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (1 - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ONE_Inp mlib_ImageBlend_OMSC_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DC mlib_ImageBlend_OMSC_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DC_Inp mlib_ImageBlend_OMSC_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 + src2 - 2 * src1 * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDC mlib_ImageBlend_OMSC_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 - 2 * src1dst * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDC_Inp mlib_ImageBlend_OMSC_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + src2 * (ALPHAsrc2 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SA mlib_ImageBlend_OMSC_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (ALPHAsrc2 - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SA_Inp mlib_ImageBlend_OMSC_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 + src2 - src2 * (src1 + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMSA mlib_ImageBlend_OMSC_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 - src2 * (src1dst + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMSA_Inp mlib_ImageBlend_OMSC_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + src2 * (ALPHAsrc1 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DA mlib_ImageBlend_OMSC_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (ALPHAsrc1dst - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DA_Inp mlib_ImageBlend_OMSC_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 + src2 - src2 * (src1 + ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDA mlib_ImageBlend_OMSC_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 - src2 * (src1dst + ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDA_Inp mlib_ImageBlend_OMSC_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 +  src2 * ((f, f, f, 1) - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SAS mlib_ImageBlend_OMSC_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst +  src2 * ((f, f, f, 1) - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SAS_Inp mlib_ImageBlend_OMSC_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ZERO mlib_ImageBlend_SA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ZERO(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ZERO_Inp mlib_ImageBlend_SA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ZERO_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ONE mlib_ImageBlend_SA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ONE(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ONE_Inp mlib_ImageBlend_SA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ONE_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DC mlib_ImageBlend_SA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DC(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DC_Inp mlib_ImageBlend_SA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DC_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDC mlib_ImageBlend_SA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDC_Inp mlib_ImageBlend_SA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SA mlib_ImageBlend_SA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SA_Inp mlib_ImageBlend_SA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = (src1 - src2) * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMSA mlib_ImageBlend_SA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMSA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = (src1dst - src2) * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMSA_Inp mlib_ImageBlend_SA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMSA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DA mlib_ImageBlend_SA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DA_Inp mlib_ImageBlend_SA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDA mlib_ImageBlend_SA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDA_Inp mlib_ImageBlend_SA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SAS mlib_ImageBlend_SA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SAS(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SAS_Inp mlib_ImageBlend_SA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SAS_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ZERO mlib_ImageBlend_OMSA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ZERO_Inp mlib_ImageBlend_OMSA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ONE mlib_ImageBlend_OMSA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ONE_Inp mlib_ImageBlend_OMSA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DC mlib_ImageBlend_OMSA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DC_Inp mlib_ImageBlend_OMSA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDC mlib_ImageBlend_OMSA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDC_Inp mlib_ImageBlend_OMSA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + (src2 - src1) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SA mlib_ImageBlend_OMSA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + (src2 - src1dst) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SA_Inp mlib_ImageBlend_OMSA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMSA mlib_ImageBlend_OMSA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMSA_Inp mlib_ImageBlend_OMSA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DA mlib_ImageBlend_OMSA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DA_Inp mlib_ImageBlend_OMSA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDA mlib_ImageBlend_OMSA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDA_Inp mlib_ImageBlend_OMSA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SAS mlib_ImageBlend_OMSA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SAS_Inp mlib_ImageBlend_OMSA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ZERO mlib_ImageBlend_DA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ZERO(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ZERO_Inp mlib_ImageBlend_DA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ZERO_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ONE mlib_ImageBlend_DA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ONE(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ONE_Inp mlib_ImageBlend_DA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ONE_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DC mlib_ImageBlend_DA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DC(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc1dst + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DC_Inp mlib_ImageBlend_DA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DC_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc1 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDC mlib_ImageBlend_DA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc1dst - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDC_Inp mlib_ImageBlend_DA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SA mlib_ImageBlend_DA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SA_Inp mlib_ImageBlend_DA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMSA mlib_ImageBlend_DA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMSA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMSA_Inp mlib_ImageBlend_DA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMSA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DA mlib_ImageBlend_DA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DA_Inp mlib_ImageBlend_DA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = (src1 - src2) * ALPHAsrc1 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDA mlib_ImageBlend_DA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = (src1dst - src2) * ALPHAsrc1dst + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDA_Inp mlib_ImageBlend_DA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SAS mlib_ImageBlend_DA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SAS(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SAS_Inp mlib_ImageBlend_DA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SAS_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ZERO mlib_ImageBlend_OMDA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ZERO_Inp mlib_ImageBlend_OMDA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ONE mlib_ImageBlend_OMDA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ONE_Inp mlib_ImageBlend_OMDA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DC mlib_ImageBlend_OMDA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DC_Inp mlib_ImageBlend_OMDA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDC mlib_ImageBlend_OMDA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDC_Inp mlib_ImageBlend_OMDA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SA mlib_ImageBlend_OMDA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SA_Inp mlib_ImageBlend_OMDA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMSA mlib_ImageBlend_OMDA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMSA_Inp mlib_ImageBlend_OMDA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + (src2 - src1) * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DA mlib_ImageBlend_OMDA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + (src2 - src1dst) * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DA_Inp mlib_ImageBlend_OMDA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDA mlib_ImageBlend_OMDA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDA_Inp mlib_ImageBlend_OMDA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SAS mlib_ImageBlend_OMDA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SAS_Inp mlib_ImageBlend_OMDA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageComposite mlib_ImageComposite
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageComposite(mlib_image *dst,
-                                   const mlib_image *src1,
-                                   const mlib_image *src2,
-                                   mlib_blend bsrc1,
-                                   mlib_blend bsrc2,
-                                   mlib_s32 cmask);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageComposite_Inp mlib_ImageComposite_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageComposite_Inp(mlib_image *src1dst,
-                                       const mlib_image *src2,
-                                       mlib_blend bsrc1,
-                                       mlib_blend bsrc2,
-                                       mlib_s32 cmask);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __ORIG_MLIB_IMAGE_BLEND_PROTO_H */
diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h
index 3a03e16..eabe268 100644
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h
@@ -1430,17 +1430,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageAffineIndex mlib_ImageAffineIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageAffineIndex(mlib_image *dst,
-                                     const mlib_image *src,
-                                     const mlib_d64 *mtx,
-                                     mlib_filter filter,
-                                     mlib_edge edge,
-                                     const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageAffineTable mlib_ImageAffineTable
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageAffineTable(mlib_image *dst,
@@ -1471,17 +1460,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageAffineTransformIndex mlib_ImageAffineTransformIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageAffineTransformIndex(mlib_image *dst,
-                                              const mlib_image *src,
-                                              const mlib_d64 *mtx,
-                                              mlib_filter filter,
-                                              mlib_edge edge,
-                                              const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageAffineTransform_Fp mlib_ImageAffineTransform_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageAffineTransform_Fp(mlib_image *dst,
@@ -1825,19 +1803,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageRotateIndex mlib_ImageRotateIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageRotateIndex(mlib_image *dst,
-                                     const mlib_image *src,
-                                     mlib_d64 angle,
-                                     mlib_d64 xcenter,
-                                     mlib_d64 ycenter,
-                                     mlib_filter filter,
-                                     mlib_edge edge,
-                                     const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageRotate_Fp mlib_ImageRotate_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageRotate_Fp(mlib_image *dst,
@@ -1887,16 +1852,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageZoomIn2XIndex mlib_ImageZoomIn2XIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageZoomIn2XIndex(mlib_image *dst,
-                                       const mlib_image *src,
-                                       mlib_filter filter,
-                                       mlib_edge edge,
-                                       const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageZoomIn2X_Fp mlib_ImageZoomIn2X_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageZoomIn2X_Fp(mlib_image *dst,
@@ -1915,16 +1870,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageZoomOut2XIndex mlib_ImageZoomOut2XIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageZoomOut2XIndex(mlib_image *dst,
-                                        const mlib_image *src,
-                                        mlib_filter filter,
-                                        mlib_edge edge,
-                                        const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageZoomOut2X_Fp mlib_ImageZoomOut2X_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageZoomOut2X_Fp(mlib_image *dst,
@@ -2012,18 +1957,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageZoomIndex mlib_ImageZoomIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageZoomIndex(mlib_image *dst,
-                                   const mlib_image *src,
-                                   mlib_d64 zoomx,
-                                   mlib_d64 zoomy,
-                                   mlib_filter filter,
-                                   mlib_edge edge,
-                                   const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageZoom_Fp mlib_ImageZoom_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageZoom_Fp(mlib_image *dst,
@@ -2312,98 +2245,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorTrue2IndexInit mlib_ImageColorTrue2IndexInit
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorTrue2IndexInit(void **colormap,
-                                             mlib_s32 bits,
-                                             mlib_type intype,
-                                             mlib_type outtype,
-                                             mlib_s32 channels,
-                                             mlib_s32 entries,
-                                             mlib_s32 offset,
-                                             const void **table);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorTrue2Index mlib_ImageColorTrue2Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorTrue2Index(mlib_image *dst,
-                                         const mlib_image *src,
-                                         const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorTrue2IndexFree mlib_ImageColorTrue2IndexFree
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-void  __mlib_ImageColorTrue2IndexFree(void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorDitherInit mlib_ImageColorDitherInit
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorDitherInit(void **colormap,
-                                         const mlib_s32 *dimensions,
-                                         mlib_type intype,
-                                         mlib_type outtype,
-                                         mlib_s32 channels,
-                                         mlib_s32 entries,
-                                         mlib_s32 offset,
-                                         void **lut);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorDitherFree mlib_ImageColorDitherFree
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-void  __mlib_ImageColorDitherFree(void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorErrorDiffusion3x3 mlib_ImageColorErrorDiffusion3x3
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorErrorDiffusion3x3(mlib_image *dst,
-                                                const mlib_image *src,
-                                                const mlib_s32 *kernel,
-                                                mlib_s32 scale,
-                                                const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorErrorDiffusionMxN mlib_ImageColorErrorDiffusionMxN
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorErrorDiffusionMxN(mlib_image *dst,
-                                                const mlib_image *src,
-                                                const mlib_s32 *kernel,
-                                                mlib_s32 m,
-                                                mlib_s32 n,
-                                                mlib_s32 dm,
-                                                mlib_s32 dn,
-                                                mlib_s32 scale,
-                                                const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorOrderedDither8x8 mlib_ImageColorOrderedDither8x8
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorOrderedDither8x8(mlib_image *dst,
-                                               const mlib_image *src,
-                                               const mlib_s32 *dmask,
-                                               mlib_s32 scale,
-                                               const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorOrderedDitherMxN mlib_ImageColorOrderedDitherMxN
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorOrderedDitherMxN(mlib_image *dst,
-                                               const mlib_image *src,
-                                               const mlib_s32 **dmask,
-                                               mlib_s32 m,
-                                               mlib_s32 n,
-                                               mlib_s32 scale,
-                                               const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageColorReplace mlib_ImageColorReplace
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageColorReplace(mlib_image *dst,
@@ -2694,17 +2535,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv2x2Index mlib_ImageConv2x2Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv2x2Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv2x2_Fp mlib_ImageConv2x2_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv2x2_Fp(mlib_image *dst,
@@ -2726,17 +2556,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv3x3Index mlib_ImageConv3x3Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv3x3Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv3x3_Fp mlib_ImageConv3x3_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv3x3_Fp(mlib_image *dst,
@@ -2758,17 +2577,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv4x4Index mlib_ImageConv4x4Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv4x4Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv4x4_Fp mlib_ImageConv4x4_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv4x4_Fp(mlib_image *dst,
@@ -2790,17 +2598,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv5x5Index mlib_ImageConv5x5Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv5x5Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv5x5_Fp mlib_ImageConv5x5_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv5x5_Fp(mlib_image *dst,
@@ -2822,17 +2619,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv7x7Index mlib_ImageConv7x7Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv7x7Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv7x7_Fp mlib_ImageConv7x7_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv7x7_Fp(mlib_image *dst,
@@ -2871,21 +2657,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConvMxNIndex mlib_ImageConvMxNIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConvMxNIndex(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 m,
-                                      mlib_s32 n,
-                                      mlib_s32 dm,
-                                      mlib_s32 dn,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConvMxN_Fp mlib_ImageConvMxN_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConvMxN_Fp(mlib_image *dst,
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java
index 20b7a9d..fa1ba5d 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java
@@ -464,7 +464,7 @@
             XToolkit.postEvent(XToolkit.targetToAppContext(e.getSource()), e);
         }
         public void mouseClicked(MouseEvent e) {
-            if ((e.getClickCount() > 1 || xtiPeer.balloon.isVisible()) &&
+            if ((e.getClickCount() == 1 || xtiPeer.balloon.isVisible()) &&
                 e.getButton() == MouseEvent.BUTTON1)
             {
                 ActionEvent aev = new ActionEvent(xtiPeer.target, ActionEvent.ACTION_PERFORMED,
diff --git a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c b/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c
deleted file mode 100644
index ad2bdf46..0000000
--- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-/*
- * FUNCTION
- *      mlib_ImageCopy   - Direct copy from one image to another.
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageCopy(mlib_image *dst,
- *                                 mlib_image *src);
- *
- * ARGUMENT
- *      dst     pointer to output or destination image
- *      src     pointer to input or source image
- *
- * RESTRICTION
- *      src and dst must have the same size, type and number of channels.
- *      They can have 1, 2, 3 or 4 channels of MLIB_BIT, MLIB_BYTE,
- *      MLIB_SHORT, MLIB_INT, MLIB_FLOAT or MLIB_DOUBLE data type.
- *
- * DESCRIPTION
- *      Direct copy from one image to another.
- */
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-
-extern void mlib_v_ImageCopy_blk(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size);
-extern void mlib_v_ImageCopy_a1(mlib_d64 *sp, mlib_d64 *dp, mlib_s32 size);
-extern void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size);
-extern void mlib_ImageCopy_bit_al(mlib_u8 *sa, mlib_u8 *da,
-                                  mlib_s32 size, mlib_s32 offset);
-extern void mlib_ImageCopy_bit_na(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size,
-                                  mlib_s32 s_offset, mlib_s32 d_offset);
-
-/***************************************************************/
-
-#ifdef MLIB_TEST
-
-mlib_status mlib_v_ImageCopy(mlib_image *dst, mlib_image *src)
-
-#else
-
-mlib_status mlib_ImageCopy(mlib_image *dst, const mlib_image *src)
-
-#endif
-{
-  mlib_u8  *sa;         /* start point in source */
-  mlib_u8  *da;         /* start points in destination */
-  mlib_s32 width;       /* width in bytes of src and dst */
-  mlib_s32 height;      /* height in lines of src and dst */
-  mlib_s32 s_offset;    /* bit offset of src */
-  mlib_s32 d_offset;    /* bit offset of dst */
-  mlib_s32 stride;      /* stride in bytes in src*/
-  mlib_s32 dstride;     /* stride in bytes in dst */
-  mlib_s32 j;           /* indices for x, y */
-  mlib_s32 size;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_TYPE_EQUAL(src, dst);
-  MLIB_IMAGE_CHAN_EQUAL(src, dst);
-  MLIB_IMAGE_SIZE_EQUAL(src, dst);
-
-  width  = mlib_ImageGetWidth(dst) * mlib_ImageGetChannels(dst);
-  height = mlib_ImageGetHeight(dst);
-  sa = (mlib_u8 *)mlib_ImageGetData(src);
-  da = (mlib_u8 *)mlib_ImageGetData(dst);
-
-  switch (mlib_ImageGetType(dst)) {
-    case MLIB_BIT:
-
-      if (!mlib_ImageIsNotOneDvector(src) &&
-          !mlib_ImageIsNotOneDvector(dst)) {
-          size = height * (width  >> 3);
-          if ((size & 0x3f) == 0 &&
-              !mlib_ImageIsNotAligned64(src) &&
-              !mlib_ImageIsNotAligned64(dst)) {
-
-              mlib_v_ImageCopy_blk(sa, da, size);
-              return MLIB_SUCCESS;
-          }
-          if (((size & 7) == 0) && !mlib_ImageIsNotAligned8(src) &&
-              !mlib_ImageIsNotAligned8(dst)) {
-
-              size >>= 3;                                /* in octlet */
-              mlib_v_ImageCopy_a1((mlib_d64 *)sa, (mlib_d64 *)da, size);
-          }
-          else {
-
-            mlib_ImageCopy_na(sa, da, size);
-          }
-        }
-      else {
-        stride = mlib_ImageGetStride(src);                /* in byte */
-        dstride = mlib_ImageGetStride(dst);               /* in byte */
-        s_offset = mlib_ImageGetBitOffset(src);           /* in bits */
-        d_offset = mlib_ImageGetBitOffset(dst);           /* in bits */
-
-        if (s_offset == d_offset) {
-          for (j = 0; j < height; j++) {
-            mlib_ImageCopy_bit_al(sa, da, width, s_offset);
-            sa += stride;
-            da += dstride;
-          }
-        } else {
-          for (j = 0; j < height; j++) {
-            mlib_ImageCopy_bit_na(sa, da, width, s_offset, d_offset);
-            sa += stride;
-            da += dstride;
-          }
-        }
-      }
-      return MLIB_SUCCESS;
-    case MLIB_BYTE:
-      break;
-    case MLIB_SHORT:
-      width *= 2;
-      break;
-    case MLIB_INT:
-    case MLIB_FLOAT:
-      width *= 4;
-      break;
-    case MLIB_DOUBLE:
-      width *= 8;
-      break;
-    default:
-      return MLIB_FAILURE;
-  }
-
-  if (!mlib_ImageIsNotOneDvector(src) &&
-      !mlib_ImageIsNotOneDvector(dst)) {
-      size = height * width;
-      if ((size & 0x3f) == 0 &&
-          !mlib_ImageIsNotAligned64(src) &&
-          !mlib_ImageIsNotAligned64(dst)) {
-
-          mlib_v_ImageCopy_blk(sa, da, size);
-          return MLIB_SUCCESS;
-      }
-      if (((size & 7) == 0) && !mlib_ImageIsNotAligned8(src) &&
-          !mlib_ImageIsNotAligned8(dst)) {
-
-          size >>= 3;                                /* in octlet */
-          mlib_v_ImageCopy_a1((mlib_d64 *)sa, (mlib_d64 *)da, size);
-      }
-      else {
-
-        mlib_ImageCopy_na(sa, da, size);
-      }
-    }
-  else {
-    stride = mlib_ImageGetStride(src);                /* in byte */
-    dstride = mlib_ImageGetStride(dst);                /* in byte */
-
-    /* row loop */
-    for (j = 0; j < height; j++) {
-      mlib_ImageCopy_na(sa, da, width);
-      sa += stride;
-      da += dstride;
-    }
-  }
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s b/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s
deleted file mode 100644
index 8261781..0000000
--- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s
+++ /dev/null
@@ -1,262 +0,0 @@
-!
-!
-! 
-! Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
-! DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-!
-! This code is free software; you can redistribute it and/or modify it
-! under the terms of the GNU General Public License version 2 only, as
-! published by the Free Software Foundation.  Oracle designates this
-! particular file as subject to the "Classpath" exception as provided
-! by Oracle in the LICENSE file that accompanied this code.
-!
-! This code is distributed in the hope that it will be useful, but WITHOUT
-! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-! FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-! version 2 for more details (a copy is included in the LICENSE file that
-! accompanied this code).
-!
-! You should have received a copy of the GNU General Public License version
-! 2 along with this work; if not, write to the Free Software Foundation,
-! Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-!
-! Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-! or visit www.oracle.com if you need additional information or have any
-! questions.
-!
-
-
-! FUNCTION
-!      mlib_v_ImageCopy_blk   - Copy an image into another 
-!				(with Block Load/Store)
-!
-! SYNOPSIS
-!      void mlib_v_ImageCopy_blk(void *src,
-!                                void *dst, 
-!                                int size);
-!
-! ARGUMENT
-!      src     source image data
-!      dst     destination image data
-!      size    image size in bytes
-!
-! NOTES
-!      src and dst must point to 64-byte aligned addresses
-!      size must be multiple of 64
-!
-! DESCRIPTION
-!      dst = src
-!
-
-#include "vis_asi.h"
-
-! Minimum size of stack frame according to SPARC ABI
-#define MINFRAME        96
-
-! ENTRY provides the standard procedure entry code
-#define ENTRY(x) \
-	.align  4; \
-	.global x; \
-x:
-
-! SET_SIZE trails a function and sets the size for the ELF symbol table
-#define SET_SIZE(x) \
-	.size   x, (.-x)
-
-! SPARC have four integer register groups. i-registers %i0 to %i7
-! hold input data. o-registers %o0 to %o7 hold output data. l-registers
-! %l0 to %l7 hold local data. g-registers %g0 to %g7 hold global data.
-! Note that %g0 is alway zero, write to it has no program-visible effect.
-
-! When calling an assembly function, the first 6 arguments are stored
-! in i-registers from %i0 to %i5. The rest arguments are stored in stack.
-! Note that %i6 is reserved for stack pointer and %i7 for return address.
-
-! Only the first 32 f-registers can be used as 32-bit registers.
-! The last 32 f-registers can only be used as 16 64-bit registers.
-
-#define src     %i0
-#define dst     %i1
-#define sz      %i2
-
-!frame pointer  %i6
-!return addr    %i7
-
-!stack pointer  %o6
-!call link      %o7
-
-#define sa      %l0
-#define da      %l1
-#define se      %l2
-#define ns      %l3
-
-#define O0      %f16
-#define O1      %f18
-#define O2      %f20
-#define O3      %f22
-#define O4      %f24
-#define O5      %f26
-#define O6      %f28
-#define O7      %f30
-
-#define A0      %f32
-#define A1      %f34
-#define A2      %f36
-#define A3      %f38
-#define A4      %f40
-#define A5      %f42
-#define A6      %f44
-#define A7      %f46
-
-#define B0      %f48
-#define B1      %f50
-#define B2      %f52
-#define B3      %f54
-#define B4      %f56
-#define B5      %f58
-#define B6      %f60
-#define B7      %f62
-
-#define USE_BLD
-#define USE_BST
-
-#define MEMBAR_BEFORE_BLD        membar  #StoreLoad
-#define MEMBAR_AFTER_BLD         membar  #StoreLoad
-
-#ifdef USE_BLD
-#define BLD_A0                                  \
-        ldda    [sa]ASI_BLK_P,A0;               \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#else
-#define BLD_A0                                  \
-        ldd     [sa +  0],A0;                   \
-        ldd     [sa +  8],A1;                   \
-        ldd     [sa + 16],A2;                   \
-        ldd     [sa + 24],A3;                   \
-        ldd     [sa + 32],A4;                   \
-        ldd     [sa + 40],A5;                   \
-        ldd     [sa + 48],A6;                   \
-        ldd     [sa + 56],A7;                   \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#endif
-
-#ifdef USE_BLD
-#define BLD_B0                                  \
-        ldda    [sa]ASI_BLK_P,B0;               \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#else
-#define BLD_B0                                  \
-        ldd     [sa +  0],B0;                   \
-        ldd     [sa +  8],B1;                   \
-        ldd     [sa + 16],B2;                   \
-        ldd     [sa + 24],B3;                   \
-        ldd     [sa + 32],B4;                   \
-        ldd     [sa + 40],B5;                   \
-        ldd     [sa + 48],B6;                   \
-        ldd     [sa + 56],B7;                   \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#endif
-
-#ifdef USE_BST
-#define BST                                     \
-        stda    O0,[da]ASI_BLK_P;               \
-        inc     64,da;                          \
-        deccc   ns;                             \
-        ble,pn  %icc,mlib_v_ImageCopy_end;	\
-        nop
-#else
-#define BST                                     \
-        std     O0,[da +  0];                   \
-        std     O1,[da +  8];                   \
-        std     O2,[da + 16];                   \
-        std     O3,[da + 24];                   \
-        std     O4,[da + 32];                   \
-        std     O5,[da + 40];                   \
-        std     O6,[da + 48];                   \
-        std     O7,[da + 56];                   \
-        inc     64,da;                          \
-        deccc   ns;                             \
-        ble,pn  %icc,mlib_v_ImageCopy_end;	\
-        nop
-#endif
-
-#define COPY_A0					\
-        fmovd A0, O0;                           \
-        fmovd A1, O1;                           \
-        fmovd A2, O2;                           \
-        fmovd A3, O3;                           \
-        fmovd A4, O4;                           \
-        fmovd A5, O5;                           \
-        fmovd A6, O6;                           \
-        fmovd A7, O7;
-
-#define COPY_B0					\
-        fmovd B0, O0;                           \
-        fmovd B1, O1;                           \
-        fmovd B2, O2;                           \
-        fmovd B3, O3;                           \
-        fmovd B4, O4;                           \
-        fmovd B5, O5;                           \
-        fmovd B6, O6;                           \
-        fmovd B7, O7;
-
-        .section        ".text",#alloc,#execinstr
-
-        ENTRY(mlib_v_ImageCopy_blk)	! function name
-
-        save    %sp,-MINFRAME,%sp	! reserve space for stack
-                                        ! and adjust register window
-! do some error checking
-        tst     sz                      ! size > 0
-        ble,pn  %icc,mlib_v_ImageCopy_ret
-
-! calculate loop count
-        sra     sz,6,ns                 ! 64 bytes per loop
-
-        add     src,sz,se               ! end address of source
-        mov     src,sa
-        mov     dst,da
-                                        ! issue memory barrier instruction
-        MEMBAR_BEFORE_BLD               ! to ensure all previous memory load
-                                        ! and store has completed
-
-        BLD_A0
-        BLD_B0                          ! issue the 2nd block load instruction
-                                        ! to synchronize with returning data
-mlib_v_ImageCopy_bgn:
-
-        COPY_A0				! process data returned by BLD_A0
-        BLD_A0                          ! block load and sync data from BLD_B0
-        BST                             ! block store data from BLD_A0
-
-        COPY_B0				! process data returned by BLD_B0
-        BLD_B0                          ! block load and sync data from BLD_A0
-        BST                             ! block store data from BLD_B0
-
-        bg,pt   %icc,mlib_v_ImageCopy_bgn
-
-mlib_v_ImageCopy_end:
-                                        ! issue memory barrier instruction
-        MEMBAR_AFTER_BLD                ! to ensure all previous memory load
-                                        ! and store has completed.
-mlib_v_ImageCopy_ret:
-        ret                             ! return
-        restore                         ! restore register window
-
-        SET_SIZE(mlib_v_ImageCopy_blk)
diff --git a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h b/jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h
deleted file mode 100644
index d0a75d3..0000000
--- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-#ifndef VIS_ASI_H
-#define VIS_ASI_H
-
-/* evolved from asm_asi.h in VSDK 1.0 */
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
-/* ASI definitions for VIS */
-
-#define         ASI_N                                   0x04
-#define         ASI_NL                                  0x0C
-#define         ASI_AIUP                                0x10
-#define         ASI_AIUS                                0x11
-#define         ASI_AIUPL                               0x18
-#define         ASI_AIUSL                               0x19
-#define         ASI_PHYS_USE_EC_L                       0x1C
-#define         ASI_PHYS_BYPASS_EC_WITH_EBIT_L          0x1D
-#define         ASI_DC_DATA                             0x46
-#define         ASI_DC_TAG                              0x47
-#define         ASI_UPA_CONTROL                         0x4A
-#define         ASI_MONDO_SEND_CTRL                     0x48
-#define         ASI_MONDO_RECEIVE_CTRL                  0x49
-#define         ASI_AFSR                                0x4C
-#define         ASI_AFAR                                0x4D
-#define         ASI_EC_TAG_DATA                         0x4E
-#define         ASI_ICACHE_DATA                         0x66
-#define         ASI_IC_INSTR                            0x66
-#define         ASI_IC_TAG                              0x67
-#define         ASI_IC_PRE_DECODE                       0x6E
-#define         ASI_IC_NEXT_FIELD                       0x6F
-#define         ASI_BLK_AIUP                            0x70
-#define         ASI_BLK_AIUS                            0x71
-#define         ASI_EC                                  0x76
-#define         ASI_BLK_AIUPL                           0x78
-#define         ASI_BLK_AIUSL                           0x79
-#define         ASI_P                                   0x80
-#define         ASI_S                                   0x81
-#define         ASI_PNF                                 0x82
-#define         ASI_SNF                                 0x83
-#define         ASI_PL                                  0x88
-#define         ASI_SL                                  0x89
-#define         ASI_PNFL                                0x8A
-#define         ASI_SNFL                                0x8B
-#define         ASI_PST8_P                              0xC0
-#define         ASI_PST8_S                              0xC1
-#define         ASI_PST16_P                             0xC2
-#define         ASI_PST16_S                             0xC3
-#define         ASI_PST32_P                             0xC4
-#define         ASI_PST32_S                             0xC5
-#define         ASI_PST8_PL                             0xC8
-#define         ASI_PST8_SL                             0xC9
-#define         ASI_PST16_PL                            0xCA
-#define         ASI_PST16_SL                            0xCB
-#define         ASI_PST32_PL                            0xCC
-#define         ASI_PST32_SL                            0xCD
-#define         ASI_FL8_P                               0xD0
-#define         ASI_FL8_S                               0xD1
-#define         ASI_FL16_P                              0xD2
-#define         ASI_FL16_S                              0xD3
-#define         ASI_FL8_PL                              0xD8
-#define         ASI_FL8_SL                              0xD9
-#define         ASI_FL16_PL                             0xDA
-#define         ASI_FL16_SL                             0xDB
-#define         ASI_COMMIT_P                            0xE0
-#define         ASI_COMMIT_S                            0xE1
-#define         ASI_BLK_P                               0xF0
-#define         ASI_BLK_S                               0xF1
-#define         ASI_BLK_PL                              0xF8
-#define         ASI_BLK_SL                              0xF9
-
-#define         ASI_NUCLEUS                             0x04
-#define         ASI_NUCLEUS_LITTLE                      0x0C
-#define         ASI_AS_IF_USER_PRIMARY                  0x10
-#define         ASI_AS_IF_USER_SECONDARY                0x11
-#define         ASI_PHYS_USE_EC                         0x14
-#define         ASI_PHYS_BYPASS_EC_WITH_EBIT            0x15
-#define         ASI_AS_IF_USER_PRIMARY_LITTLE           0x18
-#define         ASI_AS_IF_USER_SECONDARY_LITTLE         0x19
-#define         ASI_PHYS_USE_EC_LITTLE                  0x1C
-#define         ASI_PHYS_BYPASS_EC_WITH_EBIT_LITTLE     0x1D
-#define         ASI_LSU_CONTROL_REG                     0x45
-#define         ASI_DCACHE_DATA                         0x46
-#define         ASI_DCACHE_TAG                          0x47
-#define         ASI_INTR_DISPATCH_STATUS                0x48
-#define         ASI_INTR_RECEIVE                        0x49
-#define         ASI_UPA_CONFIG_REG                      0x4A
-#define         ASI_ESTATE_ERROR_EN_REG                 0x4B
-#define         ASI_ASYNC_FAULT_STATUS                  0x4C
-#define         ASI_ASYNC_FAULT_ADDR                    0x4D
-#define         ASI_ECACHE_TAG_DATA                     0x4E
-#define         ASI_OBSERVABILITY_REG                   0x4F
-#define         ASI_IMMU                                0x50
-#define         ASI_IMU_TSB_BASE                        0x50
-#define         ASI_IMU_TAG_ACCESS                      0x50
-#define         ASI_IMU_SFSR                            0x50
-#define         ASI_IMU_TAG_TARGET                      0x50
-#define         ASI_IMU_TSB_POINTER_8K                  0x51
-#define         ASI_IMU_TSB_POINTER_64K                 0x52
-#define         ASI_IMU_DATAIN                          0x54
-#define         ASI_IMMU_DATA_IN                        0x54
-#define         ASI_IMU_DATA_ACCESS                     0x55
-#define         ASI_IMU_TAG_READ                        0x56
-#define         ASI_IMU_DEMAP                           0x57
-#define         ASI_DMMU                                0x58
-#define         ASI_PRIMARY_CONTEXT                     0x58
-#define         ASI_SECONDARY_CONTEXT                   0x58
-#define         ASI_DMU_TSB_BASE                        0x58
-#define         ASI_DMU_TAG_ACCESS                      0x58
-#define         ASI_DMU_TAG_TARGET                      0x58
-#define         ASI_DMU_SFSR                            0x58
-#define         ASI_DMU_SFAR                            0x58
-#define         ASI_DMU_VA_WATCHPOINT                   0x58
-#define         ASI_DMU_PA_WATCHPOINT                   0x58
-#define         ASI_DMU_TSB_POINTER_8K                  0x59
-#define         ASI_DMU_TSB_POINTER_64K                 0x5A
-#define         ASI_DMU_TSB_POINTER_DIRECT              0x5B
-#define         ASI_DMU_DATAIN                          0x5C
-#define         ASI_DMMU_DATA_IN                        0x5C
-#define         ASI_DMU_DATA_ACCESS                     0x5D
-#define         ASI_DMU_TAG_READ                        0x5E
-#define         ASI_DMU_DEMAP                           0x5F
-#define         ASI_ICACHE_INSTR                        0x66
-#define         ASI_ICACHE_TAG                          0x67
-#define         ASI_ICACHE_PRE_DECODE                   0x6E
-#define         ASI_ICACHE_NEXT_FIELD                   0x6F
-#define         ASI_BLOCK_AS_IF_USER_PRIMARY            0x70
-#define         ASI_BLOCK_AS_IF_USER_SECONDARY          0x71
-#define         ASI_EXT                                 0x76
-#define         ASI_ECACHE                              0x76
-#define         ASI_ECACHE_DATA                         0x76
-#define         ASI_ECACHE_TAG                          0x76
-#define         ASI_SDB_INTR                            0x77
-#define         ASI_SDBH_ERR_REG                        0x77
-#define         ASI_SDBL_ERR_REG                        0x77
-#define         ASI_SDBH_CONTROL_REG                    0x77
-#define         ASI_SDBL_CONTROL_REG                    0x77
-#define         ASI_INTR_DISPATCH                       0x77
-#define         ASI_INTR_DATA0                          0x77
-#define         ASI_INTR_DATA1                          0x77
-#define         ASI_INTR_DATA2                          0x77
-#define         ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE     0x78
-#define         ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE   0x79
-#define         ASI_PRIMARY                             0x80
-#define         ASI_SECONDARY                           0x81
-#define         ASI_PRIMARY_NO_FAULT                    0x82
-#define         ASI_SECONDARY_NO_FAULT                  0x83
-#define         ASI_PRIMARY_LITTLE                      0x88
-#define         ASI_SECONDARY_LITTLE                    0x89
-#define         ASI_PRIMARY_NO_FAULT_LITTLE             0x8A
-#define         ASI_SECONDARY_NO_FAULT_LITTLE           0x8B
-#define         ASI_PST8_PRIMARY                        0xC0
-#define         ASI_PST8_SECONDARY                      0xC1
-#define         ASI_PST16_PRIMARY                       0xC2
-#define         ASI_PST16_SECONDARY                     0xC3
-#define         ASI_PST32_PRIMARY                       0xC4
-#define         ASI_PST32_SECONDARY                     0xC5
-#define         ASI_PST8_PRIMARY_LITTLE                 0xC8
-#define         ASI_PST8_SECONDARY_LITTLE               0xC9
-#define         ASI_PST16_PRIMARY_LITTLE                0xCA
-#define         ASI_PST16_SECONDARY_LITTLE              0xCB
-#define         ASI_PST32_PRIMARY_LITTLE                0xCC
-#define         ASI_PST32_SECONDARY_LITTLE              0xCD
-#define         ASI_FL8_PRIMARY                         0xD0
-#define         ASI_FL8_SECONDARY                       0xD1
-#define         ASI_FL16_PRIMARY                        0xD2
-#define         ASI_FL16_SECONDARY                      0xD3
-#define         ASI_FL8_PRIMARY_LITTLE                  0xD8
-#define         ASI_FL8_SECONDARY_LITTLE                0xD9
-#define         ASI_FL16_PRIMARY_LITTLE                 0xDA
-#define         ASI_FL16_SECONDARY_LITTLE               0xDB
-#define         ASI_COMMIT_PRIMARY                      0xE0
-#define         ASI_COMMIT_SECONDARY                    0xE1
-#define         ASI_BLOCK_PRIMARY                       0xF0
-#define         ASI_BLOCK_SECONDARY                     0xF1
-#define         ASI_BLOCK_PRIMARY_LITTLE                0xF8
-#define         ASI_BLOCK_SECONDARY_LITTLE              0xF9
-
-#ifdef  __cplusplus
-}
-#endif
-
-#endif  /* VIS_ASI_H */
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c
index ef8caa9..7ce7fae 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c
@@ -817,52 +817,22 @@
     io_handler = XSetIOErrorHandler(NULL);
 
     if (fp_gtk_check_version(2, 2, 0) == NULL) {
-        jclass clazz = (*env)->FindClass(env, "sun/misc/GThreadHelper");
-        jmethodID mid_getAndSetInitializationNeededFlag =
-                (*env)->GetStaticMethodID(env, clazz, "getAndSetInitializationNeededFlag", "()Z");
-        jmethodID mid_lock = (*env)->GetStaticMethodID(env, clazz, "lock", "()V");
-        jmethodID mid_unlock = (*env)->GetStaticMethodID(env, clazz, "unlock", "()V");
-
-        // Init the thread system to use GLib in a thread-safe mode
-        (*env)->CallStaticVoidMethod(env, clazz, mid_lock);
-        if ((*env)->ExceptionCheck(env)) {
-            AWT_UNLOCK();
-            return FALSE;
-        }
 
         // Calling g_thread_init() multiple times leads to crash on GLib < 2.24
         // We can use g_thread_get_initialized () but it is available only for
-        // GLib >= 2.20. We rely on GThreadHelper for GLib < 2.20.
+        // GLib >= 2.20.
         gboolean is_g_thread_get_initialized = FALSE;
         if (GLIB_CHECK_VERSION(2, 20, 0)) {
             is_g_thread_get_initialized = fp_g_thread_get_initialized();
         }
 
-        if (!(*env)->CallStaticBooleanMethod(env, clazz, mid_getAndSetInitializationNeededFlag)) {
-            if (!is_g_thread_get_initialized) {
-                fp_g_thread_init(NULL);
-            }
+        if (!is_g_thread_get_initialized) {
+            fp_g_thread_init(NULL);
+        }
 
-            //According the GTK documentation, gdk_threads_init() should be
-            //called before gtk_init() or gtk_init_check()
-            fp_gdk_threads_init();
-        }
-        jthrowable pendExcpn = NULL;
-        // Exception raised during mid_getAndSetInitializationNeededFlag
-        // call is saved and error handling is done
-        // after unlock method is called
-        if ((pendExcpn = (*env)->ExceptionOccurred(env)) != NULL) {
-            (*env)->ExceptionClear(env);
-        }
-        (*env)->CallStaticVoidMethod(env, clazz, mid_unlock);
-        if (pendExcpn != NULL) {
-            (*env)->Throw(env, pendExcpn);
-        }
-        // check if any exception occured during mid_unlock call
-        if ((*env)->ExceptionCheck(env)) {
-            AWT_UNLOCK();
-            return FALSE;
-        }
+        //According the GTK documentation, gdk_threads_init() should be
+        //called before gtk_init() or gtk_init_check()
+        fp_gdk_threads_init();
     }
     result = (*fp_gtk_init_check)(NULL, NULL);
 
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c
deleted file mode 100644
index d87fa01..0000000
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c
+++ /dev/null
@@ -1,1443 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-#include "vis_proto.h"
-#include "mlib_image.h"
-#include "mlib_ImageColormap.h"
-#include "mlib_ImageAffine.h"
-#include "mlib_v_ImageFilters.h"
-
-/***************************************************************/
-#define MLIB_LIMIT   512
-#define MLIB_SHIFT    16
-
-/***************************************************************/
-#undef  DECLAREVAR
-#define DECLAREVAR()                                            \
-  DECLAREVAR0();                                                \
-  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
-  mlib_s32  xSrc, ySrc;                                         \
-  mlib_s32  srcYStride = param -> srcYStride;                   \
-  mlib_s32  filter     = param -> filter;                       \
-  mlib_s32  max_xsize  = param -> max_xsize;                    \
-  MLIB_TYPE *srcIndexPtr;                                       \
-  MLIB_TYPE *dstIndexPtr;                                       \
-  mlib_d64  *dstPixelPtr;                                       \
-  mlib_s32  i
-
-/***************************************************************/
-#define DECLAREVAR_U8()                                         \
-  mlib_s32  filterposx, filterposy;                             \
-  mlib_d64  sum0, sum1, sum2, sum3;                             \
-  mlib_f32  hi_row00, hi_row10, hi_row20, hi_row30;             \
-  mlib_f32  hi_row01, hi_row11, hi_row21, hi_row31;             \
-  mlib_f32  lo_row00, lo_row10, lo_row20, lo_row30;             \
-  mlib_f32  lo_row01, lo_row11, lo_row21, lo_row31;             \
-  mlib_d64  xFilter0, xFilter1, xFilter2, xFilter3, yFilter;    \
-  mlib_d64  v00, v10, v20, v30;                                 \
-  mlib_d64  v01, v11, v21, v31;                                 \
-  mlib_d64  v02, v12, v22, v32;                                 \
-  mlib_d64  v03, v13, v23, v33;                                 \
-  mlib_d64  d0, d1, d2, d3;                                     \
-  mlib_d64  d00, d10, d20, d30;                                 \
-  mlib_d64  d01, d11, d21, d31;                                 \
-  mlib_s32  cols;                                               \
-  mlib_d64  res, *xPtr
-
-/***************************************************************/
-#define DECLAREVAR_S16()                                        \
-  mlib_s32  filterposx, filterposy;                             \
-  mlib_d64  sum0, sum1, sum2, sum3;                             \
-  mlib_d64  row00, row10, row20, row30;                         \
-  mlib_d64  row01, row11, row21, row31;                         \
-  mlib_d64  row02, row12, row22, row32;                         \
-  mlib_d64  row03, row13, row23, row33;                         \
-  mlib_d64  xFilter0, xFilter1, xFilter2, xFilter3;             \
-  mlib_d64  yFilter0, yFilter1, yFilter2, yFilter3;             \
-  mlib_d64  v00, v01, v02, v03, v10, v11, v12, v13;             \
-  mlib_d64  v20, v21, v22, v23, v30, v31, v32, v33;             \
-  mlib_d64  u00, u01, u10, u11, u20, u21, u30, u31;             \
-  mlib_d64  d0, d1, d2, d3;                                     \
-  mlib_d64  *yPtr, *xPtr;                                       \
-  mlib_s32  cols;                                               \
-  mlib_d64  res;                                                \
-  mlib_f32  f_x01000100 = vis_to_float(0x01000100)
-
-/***************************************************************/
-#undef  CLIP
-#define CLIP()                                                  \
-  dstData += dstYStride;                                        \
-  xLeft = leftEdges[j];                                         \
-  xRight = rightEdges[j];                                       \
-  X = xStarts[j];                                               \
-  Y = yStarts[j];                                               \
-  PREPARE_DELTAS                                                \
-  if (xLeft > xRight)                                           \
-    continue;                                                   \
-  dstIndexPtr = (MLIB_TYPE *)dstData + xLeft;                   \
-  dstPixelPtr = dstRowPtr
-
-/***************************************************************/
-#define FADD_4BC_U8()                                           \
-  d0 = vis_fpadd16(d00, d10);                                   \
-  d1 = vis_fpadd16(d20, d30);                                   \
-  d0 = vis_fpadd16(d0, d1);                                     \
-  d2 = vis_fpadd16(d01, d11);                                   \
-  d3 = vis_fpadd16(d21, d31);                                   \
-  d2 = vis_fpadd16(d2, d3);                                     \
-  res = vis_fpack16_pair(d0, d2)
-
-/***************************************************************/
-#define LOAD_BC_U8_4CH_1PIXEL(mlib_filters_u8, mlib_filters_u8_4)      \
-  filterposy = (Y >> FILTER_SHIFT) & FILTER_MASK;                      \
-  yFilter = *((mlib_d64 *) ((mlib_u8 *)mlib_filters_u8 + filterposy)); \
-  filterposx = (X >> FILTER_SHIFT) & FILTER_MASK;                      \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_u8_4+4*filterposx));    \
-  xFilter0 = xPtr[0];                                                  \
-  xFilter1 = xPtr[1];                                                  \
-  xFilter2 = xPtr[2];                                                  \
-  xFilter3 = xPtr[3];                                                  \
-  X += dX;                                                             \
-  Y += dY;                                                             \
-  hi_row00 = flut[srcIndexPtr[0]];                                     \
-  lo_row00 = flut[srcIndexPtr[1]];                                     \
-  hi_row01 = flut[srcIndexPtr[2]];                                     \
-  lo_row01 = flut[srcIndexPtr[3]];                                     \
-  srcIndexPtr += srcYStride;                                           \
-  hi_row10 = flut[srcIndexPtr[0]];                                     \
-  lo_row10 = flut[srcIndexPtr[1]];                                     \
-  hi_row11 = flut[srcIndexPtr[2]];                                     \
-  lo_row11 = flut[srcIndexPtr[3]];                                     \
-  srcIndexPtr += srcYStride;                                           \
-  hi_row20 = flut[srcIndexPtr[0]];                                     \
-  lo_row20 = flut[srcIndexPtr[1]];                                     \
-  hi_row21 = flut[srcIndexPtr[2]];                                     \
-  lo_row21 = flut[srcIndexPtr[3]];                                     \
-  srcIndexPtr += srcYStride;                                           \
-  hi_row30 = flut[srcIndexPtr[0]];                                     \
-  lo_row30 = flut[srcIndexPtr[1]];                                     \
-  hi_row31 = flut[srcIndexPtr[2]];                                     \
-  lo_row31 = flut[srcIndexPtr[3]]
-
-/***************************************************************/
-#define NEXT_PIXEL_4BC()                                        \
-  xSrc = (X >> MLIB_SHIFT)-1;                                   \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                   \
-  srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc
-
-/***************************************************************/
-#define RESULT_4BC_U8_1PIXEL(ind)                               \
-  v00 = vis_fmul8x16au(hi_row00, vis_read_hi(yFilter));         \
-  v01 = vis_fmul8x16au(lo_row00, vis_read_hi(yFilter));         \
-  v02 = vis_fmul8x16au(hi_row01, vis_read_hi(yFilter));         \
-  v03 = vis_fmul8x16au(lo_row01, vis_read_hi(yFilter));         \
-  v10 = vis_fmul8x16al(hi_row10, vis_read_hi(yFilter));         \
-  v11 = vis_fmul8x16al(lo_row10, vis_read_hi(yFilter));         \
-  sum0 = vis_fpadd16(v00, v10);                                 \
-  v12 = vis_fmul8x16al(hi_row11, vis_read_hi(yFilter));         \
-  sum1 = vis_fpadd16(v01, v11);                                 \
-  v13 = vis_fmul8x16al(lo_row11, vis_read_hi(yFilter));         \
-  sum2 = vis_fpadd16(v02, v12);                                 \
-  v20 = vis_fmul8x16au(hi_row20, vis_read_lo(yFilter));         \
-  sum3 = vis_fpadd16(v03, v13);                                 \
-  v21 = vis_fmul8x16au(lo_row20, vis_read_lo(yFilter));         \
-  sum0 = vis_fpadd16(sum0, v20);                                \
-  v22 = vis_fmul8x16au(hi_row21, vis_read_lo(yFilter));         \
-  sum1 = vis_fpadd16(sum1, v21);                                \
-  v23 = vis_fmul8x16au(lo_row21, vis_read_lo(yFilter));         \
-  sum2 = vis_fpadd16(sum2, v22);                                \
-  v30 = vis_fmul8x16al(hi_row30, vis_read_lo(yFilter));         \
-  sum3 = vis_fpadd16(sum3, v23);                                \
-  v31 = vis_fmul8x16al(lo_row30, vis_read_lo(yFilter));         \
-  sum0 = vis_fpadd16(sum0, v30);                                \
-  v32 = vis_fmul8x16al(hi_row31, vis_read_lo(yFilter));         \
-  sum1 = vis_fpadd16(sum1, v31);                                \
-  v33 = vis_fmul8x16al(lo_row31, vis_read_lo(yFilter));         \
-  sum2 = vis_fpadd16(sum2, v32);                                \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                         \
-  sum3 = vis_fpadd16(sum3, v33);                                \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                         \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                         \
-  d0##ind = vis_fpadd16(v00, v01);                              \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                         \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                         \
-  d1##ind = vis_fpadd16(v10, v11);                              \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                         \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                         \
-  d2##ind = vis_fpadd16(v20, v21);                              \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                         \
-  d3##ind = vis_fpadd16(v30, v31)
-
-/***************************************************************/
-#define BC_U8_4CH(ind, mlib_filters_u8, mlib_filters_u8_4)            \
-  v00 = vis_fmul8x16au(hi_row00, vis_read_hi(yFilter));               \
-  v01 = vis_fmul8x16au(lo_row00, vis_read_hi(yFilter));               \
-  v02 = vis_fmul8x16au(hi_row01, vis_read_hi(yFilter));               \
-  v03 = vis_fmul8x16au(lo_row01, vis_read_hi(yFilter));               \
-  hi_row00 = flut[srcIndexPtr[0]];                                    \
-  filterposy = (Y >> FILTER_SHIFT);                                   \
-  v10 = vis_fmul8x16al(hi_row10, vis_read_hi(yFilter));               \
-  lo_row00 = flut[srcIndexPtr[1]];                                    \
-  v11 = vis_fmul8x16al(lo_row10, vis_read_hi(yFilter));               \
-  sum0 = vis_fpadd16(v00, v10);                                       \
-  hi_row01 = flut[srcIndexPtr[2]];                                    \
-  v12 = vis_fmul8x16al(hi_row11, vis_read_hi(yFilter));               \
-  lo_row01 = flut[srcIndexPtr[3]];                                    \
-  filterposx = (X >> FILTER_SHIFT);                                   \
-  v13 = vis_fmul8x16al(lo_row11, vis_read_hi(yFilter));               \
-  srcIndexPtr += srcYStride;                                          \
-  hi_row10 = flut[srcIndexPtr[0]];                                    \
-  v20 = vis_fmul8x16au(hi_row20, vis_read_lo(yFilter));               \
-  sum1 = vis_fpadd16(v01, v11);                                       \
-  lo_row10 = flut[srcIndexPtr[1]];                                    \
-  X += dX;                                                            \
-  hi_row11 = flut[srcIndexPtr[2]];                                    \
-  v21 = vis_fmul8x16au(lo_row20, vis_read_lo(yFilter));               \
-  sum2 = vis_fpadd16(v02, v12);                                       \
-  lo_row11 = flut[srcIndexPtr[3]];                                    \
-  v22 = vis_fmul8x16au(hi_row21, vis_read_lo(yFilter));               \
-  srcIndexPtr += srcYStride;                                          \
-  hi_row20 = flut[srcIndexPtr[0]];                                    \
-  v23 = vis_fmul8x16au(lo_row21, vis_read_lo(yFilter));               \
-  sum3 = vis_fpadd16(v03, v13);                                       \
-  Y += dY;                                                            \
-  xSrc = (X >> MLIB_SHIFT)-1;                                         \
-  v30 = vis_fmul8x16al(hi_row30, vis_read_lo(yFilter));               \
-  sum0 = vis_fpadd16(sum0, v20);                                      \
-  lo_row20 = flut[srcIndexPtr[1]];                                    \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                         \
-  hi_row21 = flut[srcIndexPtr[2]];                                    \
-  v31 = vis_fmul8x16al(lo_row30, vis_read_lo(yFilter));               \
-  sum1 = vis_fpadd16(sum1, v21);                                      \
-  filterposy &= FILTER_MASK;                                          \
-  lo_row21 = flut[srcIndexPtr[3]];                                    \
-  v32 = vis_fmul8x16al(hi_row31, vis_read_lo(yFilter));               \
-  srcIndexPtr += srcYStride;                                          \
-  filterposx &= FILTER_MASK;                                          \
-  v33 = vis_fmul8x16al(lo_row31, vis_read_lo(yFilter));               \
-  sum2 = vis_fpadd16(sum2, v22);                                      \
-  hi_row30 = flut[srcIndexPtr[0]];                                    \
-  sum3 = vis_fpadd16(sum3, v23);                                      \
-  sum0 = vis_fpadd16(sum0, v30);                                      \
-  lo_row30 = flut[srcIndexPtr[1]];                                    \
-  sum1 = vis_fpadd16(sum1, v31);                                      \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                               \
-  hi_row31 = flut[srcIndexPtr[2]];                                    \
-  sum2 = vis_fpadd16(sum2, v32);                                      \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                               \
-  sum3 = vis_fpadd16(sum3, v33);                                      \
-  lo_row31 = flut[srcIndexPtr[3]];                                    \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                               \
-  d0##ind = vis_fpadd16(v00, v01);                                    \
-  yFilter = *((mlib_d64 *)((mlib_u8 *)mlib_filters_u8 + filterposy)); \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                               \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_u8_4+4*filterposx));   \
-  xFilter0 = xPtr[0];                                                 \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                               \
-  d1##ind = vis_fpadd16(v10, v11);                                    \
-  xFilter1 = xPtr[1];                                                 \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                               \
-  xFilter2 = xPtr[2];                                                 \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                               \
-  d2##ind = vis_fpadd16(v20, v21);                                    \
-  xFilter3 = xPtr[3];                                                 \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                               \
-  srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc;                   \
-  d3##ind = vis_fpadd16(v30, v31)
-
-/***************************************************************/
-#define LOAD_BC_S16_4CH_1PIXEL(mlib_filters_s16_4)                      \
-  row00 = flut[srcIndexPtr[0]];                                         \
-  row01 = flut[srcIndexPtr[1]];                                         \
-  row02 = flut[srcIndexPtr[2]];                                         \
-  row03 = flut[srcIndexPtr[3]];                                         \
-  srcIndexPtr += srcYStride;                                            \
-  row10 = flut[srcIndexPtr[0]];                                         \
-  row11 = flut[srcIndexPtr[1]];                                         \
-  row12 = flut[srcIndexPtr[2]];                                         \
-  row13 = flut[srcIndexPtr[3]];                                         \
-  srcIndexPtr += srcYStride;                                            \
-  row20 = flut[srcIndexPtr[0]];                                         \
-  row21 = flut[srcIndexPtr[1]];                                         \
-  row22 = flut[srcIndexPtr[2]];                                         \
-  row23 = flut[srcIndexPtr[3]];                                         \
-  srcIndexPtr += srcYStride;                                            \
-  row30 = flut[srcIndexPtr[0]];                                         \
-  row31 = flut[srcIndexPtr[1]];                                         \
-  row32 = flut[srcIndexPtr[2]];                                         \
-  row33 = flut[srcIndexPtr[3]];                                         \
-  filterposy = (Y >> FILTER_SHIFT) & FILTER_MASK;                       \
-  yPtr = ((mlib_d64 *) ((mlib_u8 *)mlib_filters_s16_4 + filterposy*4)); \
-  yFilter0 = yPtr[0];                                                   \
-  yFilter1 = yPtr[1];                                                   \
-  yFilter2 = yPtr[2];                                                   \
-  yFilter3 = yPtr[3];                                                   \
-  filterposx = (X >> FILTER_SHIFT) & FILTER_MASK;                       \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_s16_4 + filterposx*4));  \
-  xFilter0 = xPtr[0];                                                   \
-  xFilter1 = xPtr[1];                                                   \
-  xFilter2 = xPtr[2];                                                   \
-  xFilter3 = xPtr[3];                                                   \
-  X += dX;                                                              \
-  Y += dY
-
-/***************************************************************/
-#define RESULT_4BC_S16_1PIXEL()                                 \
-  u00 = vis_fmul8sux16(row00, yFilter0);                        \
-  u01 = vis_fmul8ulx16(row00, yFilter0);                        \
-  u10 = vis_fmul8sux16(row01, yFilter0);                        \
-  u11 = vis_fmul8ulx16(row01, yFilter0);                        \
-  v00 = vis_fpadd16(u00, u01);                                  \
-  u20 = vis_fmul8sux16(row02, yFilter0);                        \
-  v01 = vis_fpadd16(u10, u11);                                  \
-  u21 = vis_fmul8ulx16(row02, yFilter0);                        \
-  u30 = vis_fmul8sux16(row03, yFilter0);                        \
-  u31 = vis_fmul8ulx16(row03, yFilter0);                        \
-  v02 = vis_fpadd16(u20, u21);                                  \
-  u00 = vis_fmul8sux16(row10, yFilter1);                        \
-  u01 = vis_fmul8ulx16(row10, yFilter1);                        \
-  v03 = vis_fpadd16(u30, u31);                                  \
-  u10 = vis_fmul8sux16(row11, yFilter1);                        \
-  u11 = vis_fmul8ulx16(row11, yFilter1);                        \
-  v10 = vis_fpadd16(u00, u01);                                  \
-  u20 = vis_fmul8sux16(row12, yFilter1);                        \
-  v11 = vis_fpadd16(u10, u11);                                  \
-  u21 = vis_fmul8ulx16(row12, yFilter1);                        \
-  u30 = vis_fmul8sux16(row13, yFilter1);                        \
-  u31 = vis_fmul8ulx16(row13, yFilter1);                        \
-  u00 = vis_fmul8sux16(row20, yFilter2);                        \
-  v12 = vis_fpadd16(u20, u21);                                  \
-  u01 = vis_fmul8ulx16(row20, yFilter2);                        \
-  v13 = vis_fpadd16(u30, u31);                                  \
-  u10 = vis_fmul8sux16(row21, yFilter2);                        \
-  u11 = vis_fmul8ulx16(row21, yFilter2);                        \
-  v20 = vis_fpadd16(u00, u01);                                  \
-  u20 = vis_fmul8sux16(row22, yFilter2);                        \
-  sum0 = vis_fpadd16(v00, v10);                                 \
-  u21 = vis_fmul8ulx16(row22, yFilter2);                        \
-  u30 = vis_fmul8sux16(row23, yFilter2);                        \
-  u31 = vis_fmul8ulx16(row23, yFilter2);                        \
-  u00 = vis_fmul8sux16(row30, yFilter3);                        \
-  u01 = vis_fmul8ulx16(row30, yFilter3);                        \
-  v21 = vis_fpadd16(u10, u11);                                  \
-  sum1 = vis_fpadd16(v01, v11);                                 \
-  u10 = vis_fmul8sux16(row31, yFilter3);                        \
-  sum2 = vis_fpadd16(v02, v12);                                 \
-  sum3 = vis_fpadd16(v03, v13);                                 \
-  v22 = vis_fpadd16(u20, u21);                                  \
-  u11 = vis_fmul8ulx16(row31, yFilter3);                        \
-  sum0 = vis_fpadd16(sum0, v20);                                \
-  u20 = vis_fmul8sux16(row32, yFilter3);                        \
-  u21 = vis_fmul8ulx16(row32, yFilter3);                        \
-  v23 = vis_fpadd16(u30, u31);                                  \
-  v30 = vis_fpadd16(u00, u01);                                  \
-  sum1 = vis_fpadd16(sum1, v21);                                \
-  u30 = vis_fmul8sux16(row33, yFilter3);                        \
-  u31 = vis_fmul8ulx16(row33, yFilter3);                        \
-  v31 = vis_fpadd16(u10, u11);                                  \
-  sum2 = vis_fpadd16(sum2, v22);                                \
-  sum3 = vis_fpadd16(sum3, v23);                                \
-  v32 = vis_fpadd16(u20, u21);                                  \
-  sum0 = vis_fpadd16(sum0, v30);                                \
-  v33 = vis_fpadd16(u30, u31);                                  \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                         \
-  sum1 = vis_fpadd16(sum1, v31);                                \
-  sum2 = vis_fpadd16(sum2, v32);                                \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                         \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                         \
-  sum3 = vis_fpadd16(sum3, v33);                                \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                         \
-  d0 = vis_fpadd16(v00, v01);                                   \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                         \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                         \
-  d1 = vis_fpadd16(v10, v11);                                   \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                         \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                         \
-  d2 = vis_fpadd16(v20, v21);                                   \
-  d3 = vis_fpadd16(v30, v31);                                   \
-  d0 = vis_fpadd16(d0, d1);                                     \
-  d2 = vis_fpadd16(d2, d3);                                     \
-  d0 = vis_fpadd16(d0, d2);                                     \
-  d2 = vis_fmuld8sux16(f_x01000100, vis_read_hi(d0));           \
-  d3 = vis_fmuld8sux16(f_x01000100, vis_read_lo(d0));           \
-  res = vis_fpackfix_pair(d2, d3)
-
-/***************************************************************/
-#define BC_S16_4CH(mlib_filters_s16_4)                                  \
-  u00 = vis_fmul8sux16(row00, yFilter0);                                \
-  u01 = vis_fmul8ulx16(row00, yFilter0);                                \
-  u10 = vis_fmul8sux16(row01, yFilter0);                                \
-  u11 = vis_fmul8ulx16(row01, yFilter0);                                \
-  v00 = vis_fpadd16(u00, u01);                                          \
-  u20 = vis_fmul8sux16(row02, yFilter0);                                \
-  v01 = vis_fpadd16(u10, u11);                                          \
-  u21 = vis_fmul8ulx16(row02, yFilter0);                                \
-  u30 = vis_fmul8sux16(row03, yFilter0);                                \
-  u31 = vis_fmul8ulx16(row03, yFilter0);                                \
-  v02 = vis_fpadd16(u20, u21);                                          \
-  row00 = flut[srcIndexPtr[0]];                                         \
-  u00 = vis_fmul8sux16(row10, yFilter1);                                \
-  u01 = vis_fmul8ulx16(row10, yFilter1);                                \
-  filterposy = (Y >> FILTER_SHIFT);                                     \
-  v03 = vis_fpadd16(u30, u31);                                          \
-  row01 = flut[srcIndexPtr[1]];                                         \
-  u10 = vis_fmul8sux16(row11, yFilter1);                                \
-  u11 = vis_fmul8ulx16(row11, yFilter1);                                \
-  v10 = vis_fpadd16(u00, u01);                                          \
-  row02 = flut[srcIndexPtr[2]];                                         \
-  u20 = vis_fmul8sux16(row12, yFilter1);                                \
-  v11 = vis_fpadd16(u10, u11);                                          \
-  u21 = vis_fmul8ulx16(row12, yFilter1);                                \
-  u30 = vis_fmul8sux16(row13, yFilter1);                                \
-  row03 = flut[srcIndexPtr[3]];                                         \
-  u31 = vis_fmul8ulx16(row13, yFilter1);                                \
-  u00 = vis_fmul8sux16(row20, yFilter2);                                \
-  filterposx = (X >> FILTER_SHIFT);                                     \
-  srcIndexPtr += srcYStride;                                            \
-  v12 = vis_fpadd16(u20, u21);                                          \
-  u01 = vis_fmul8ulx16(row20, yFilter2);                                \
-  v13 = vis_fpadd16(u30, u31);                                          \
-  row10 = flut[srcIndexPtr[0]];                                         \
-  u10 = vis_fmul8sux16(row21, yFilter2);                                \
-  X += dX;                                                              \
-  u11 = vis_fmul8ulx16(row21, yFilter2);                                \
-  v20 = vis_fpadd16(u00, u01);                                          \
-  row11 = flut[srcIndexPtr[1]];                                         \
-  u20 = vis_fmul8sux16(row22, yFilter2);                                \
-  sum0 = vis_fpadd16(v00, v10);                                         \
-  u21 = vis_fmul8ulx16(row22, yFilter2);                                \
-  row12 = flut[srcIndexPtr[2]];                                         \
-  u30 = vis_fmul8sux16(row23, yFilter2);                                \
-  u31 = vis_fmul8ulx16(row23, yFilter2);                                \
-  row13 = flut[srcIndexPtr[3]];                                         \
-  u00 = vis_fmul8sux16(row30, yFilter3);                                \
-  srcIndexPtr += srcYStride;                                            \
-  u01 = vis_fmul8ulx16(row30, yFilter3);                                \
-  v21 = vis_fpadd16(u10, u11);                                          \
-  Y += dY;                                                              \
-  xSrc = (X >> MLIB_SHIFT)-1;                                           \
-  sum1 = vis_fpadd16(v01, v11);                                         \
-  row20 = flut[srcIndexPtr[0]];                                         \
-  u10 = vis_fmul8sux16(row31, yFilter3);                                \
-  sum2 = vis_fpadd16(v02, v12);                                         \
-  sum3 = vis_fpadd16(v03, v13);                                         \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                           \
-  row21 = flut[srcIndexPtr[1]];                                         \
-  v22 = vis_fpadd16(u20, u21);                                          \
-  u11 = vis_fmul8ulx16(row31, yFilter3);                                \
-  sum0 = vis_fpadd16(sum0, v20);                                        \
-  u20 = vis_fmul8sux16(row32, yFilter3);                                \
-  row22 = flut[srcIndexPtr[2]];                                         \
-  u21 = vis_fmul8ulx16(row32, yFilter3);                                \
-  v23 = vis_fpadd16(u30, u31);                                          \
-  v30 = vis_fpadd16(u00, u01);                                          \
-  filterposy &= FILTER_MASK;                                            \
-  sum1 = vis_fpadd16(sum1, v21);                                        \
-  u30 = vis_fmul8sux16(row33, yFilter3);                                \
-  row23 = flut[srcIndexPtr[3]];                                         \
-  u31 = vis_fmul8ulx16(row33, yFilter3);                                \
-  srcIndexPtr += srcYStride;                                            \
-  filterposx &= FILTER_MASK;                                            \
-  v31 = vis_fpadd16(u10, u11);                                          \
-  row30 = flut[srcIndexPtr[0]];                                         \
-  sum2 = vis_fpadd16(sum2, v22);                                        \
-  sum3 = vis_fpadd16(sum3, v23);                                        \
-  row31 = flut[srcIndexPtr[1]];                                         \
-  v32 = vis_fpadd16(u20, u21);                                          \
-  sum0 = vis_fpadd16(sum0, v30);                                        \
-  row32 = flut[srcIndexPtr[2]];                                         \
-  v33 = vis_fpadd16(u30, u31);                                          \
-  row33 = flut[srcIndexPtr[3]];                                         \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                                 \
-  yPtr = ((mlib_d64 *) ((mlib_u8 *)mlib_filters_s16_4 + filterposy*4)); \
-  sum1 = vis_fpadd16(sum1, v31);                                        \
-  yFilter0 = yPtr[0];                                                   \
-  sum2 = vis_fpadd16(sum2, v32);                                        \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                                 \
-  yFilter1 = yPtr[1];                                                   \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                                 \
-  sum3 = vis_fpadd16(sum3, v33);                                        \
-  yFilter2 = yPtr[2];                                                   \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                                 \
-  d0 = vis_fpadd16(v00, v01);                                           \
-  yFilter3 = yPtr[3];                                                   \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_s16_4 + filterposx*4));  \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                                 \
-  xFilter0 = xPtr[0];                                                   \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                                 \
-  d1 = vis_fpadd16(v10, v11);                                           \
-  xFilter1 = xPtr[1];                                                   \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                                 \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                                 \
-  d2 = vis_fpadd16(v20, v21);                                           \
-  xFilter2 = xPtr[2];                                                   \
-  d3 = vis_fpadd16(v30, v31);                                           \
-  xFilter3 = xPtr[3];                                                   \
-  srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc
-
-/***************************************************************/
-#define FADD_4BC_S16()                                          \
-  d0 = vis_fpadd16(d0, d1);                                     \
-  d2 = vis_fpadd16(d2, d3);                                     \
-  d0 = vis_fpadd16(d0, d2);                                     \
-  d2 = vis_fmuld8sux16(f_x01000100, vis_read_hi(d0));           \
-  d3 = vis_fmuld8sux16(f_x01000100, vis_read_lo(d0));           \
-  res = vis_fpackfix_pair(d2, d3)
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_U8_3CH_BC(mlib_affine_param *param,
-                                               const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4((mlib_u8 *)dstRowPtr,
-                                               dstIndexPtr,
-                                               xRight - xLeft + 1,
-                                               colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_S16_3CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((mlib_s16 *)dstRowPtr,
-                                                dstIndexPtr,
-                                                xRight - xLeft + 1,
-                                                colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_U8_4CH_BC(mlib_affine_param *param,
-                                               const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_4((mlib_u8 *)dstRowPtr,
-                                          dstIndexPtr,
-                                          xRight - xLeft + 1,
-                                          colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_S16_4CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_U8_4((mlib_s16 *)dstRowPtr,
-                                           dstIndexPtr,
-                                           xRight - xLeft + 1,
-                                           colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_s16
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_U8_3CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4((mlib_u8 *)dstRowPtr,
-                                                dstIndexPtr,
-                                                xRight - xLeft + 1,
-                                                colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_S16_3CH_BC(mlib_affine_param *param,
-                                                 const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((mlib_s16 *)dstRowPtr,
-                                                 dstIndexPtr,
-                                                 xRight - xLeft + 1,
-                                                 colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_U8_4CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_4((mlib_u8 *)dstRowPtr,
-                                           dstIndexPtr,
-                                           xRight - xLeft + 1,
-                                           colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_S16_4CH_BC(mlib_affine_param *param,
-                                                 const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_S16_4((mlib_s16 *)dstRowPtr,
-                                            dstIndexPtr,
-                                            xRight - xLeft + 1,
-                                            colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c
index 6d73ae0..f0abee6 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c
@@ -33,7 +33,6 @@
 
 #include "vis_proto.h"
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageAffine.h"
 #include "mlib_v_ImageFilters.h"
@@ -719,134 +718,3 @@
 }
 
 /***************************************************************/
-#define LUT(x)  plut[x]
-
-mlib_status FUN_NAME(u8_i)(mlib_affine_param *param,
-                           const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_f32 buff[BUF_SIZE], *pbuff = buff;
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-    mlib_f32 s0, s1, s2, s3;
-    DTYPE    *sp;
-
-    NEW_LINE(1);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      GET_FILTER_XY();
-
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      PROCESS_4CH(s0, s1, s2, s3);
-
-      pbuff[i] = vis_fpack16(dd);
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_U8_U8_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_s16
-
-mlib_status FUN_NAME(s16_i)(mlib_affine_param *param,
-                            const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_f32 buff[BUF_SIZE], *pbuff = buff;
-
-  srcYStride /= sizeof(DTYPE);
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-    mlib_f32 s0, s1, s2, s3;
-    DTYPE    *sp;
-
-    NEW_LINE(1);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      GET_FILTER_XY();
-
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      PROCESS_4CH(s0, s1, s2, s3);
-
-      pbuff[i] = vis_fpack16(dd);
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_U8_S16_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-const type_affine_i_fun mlib_AffineFunArr_bl_i[] = {
-  mlib_ImageAffine_u8_u8_i_bl,
-  mlib_ImageAffine_u8_u8_i_bl,
-  mlib_ImageAffine_u8_s16_i_bl,
-  mlib_ImageAffine_u8_s16_i_bl,
-  mlib_ImageAffine_s16_u8_i_bl,
-  mlib_ImageAffine_s16_u8_i_bl,
-  mlib_ImageAffine_s16_s16_i_bl,
-  mlib_ImageAffine_s16_s16_i_bl
-};
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c
index 05e9c6f..c51c351 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c
@@ -33,7 +33,6 @@
 
 #include "vis_proto.h"
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageAffine.h"
 #include "mlib_v_ImageFilters.h"
@@ -716,128 +715,3 @@
 }
 
 /***************************************************************/
-#define LUT(x)  plut[x]
-
-mlib_status FUN_NAME(s16_i)(mlib_affine_param *param,
-                            const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
-
-  srcYStride /= sizeof(DTYPE);
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
-  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
-  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
-  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
-
-  for (j = yStart; j <= yFinish; j++) {
-    DTYPE *sp;
-
-    NEW_LINE(1);
-
-    deltax = DOUBLE_4U16(X, X, X, X);
-    deltay = DOUBLE_4U16(Y, Y, Y, Y);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      BL_SUM();
-
-      pbuff[i] = dd;
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_S16_S16_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_u8
-
-mlib_status FUN_NAME(u8_i)(mlib_affine_param *param,
-                           const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
-  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
-  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
-  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
-
-  for (j = yStart; j <= yFinish; j++) {
-    DTYPE *sp;
-
-    NEW_LINE(1);
-
-    deltax = DOUBLE_4U16(X, X, X, X);
-    deltay = DOUBLE_4U16(Y, Y, Y, Y);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      BL_SUM();
-
-      pbuff[i] = dd;
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_S16_U8_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c
index b9de874..bc2b7e9 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c
@@ -33,7 +33,6 @@
 
 #include "vis_proto.h"
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageAffine.h"
 #include "mlib_v_ImageFilters.h"
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c
deleted file mode 100644
index 6d3d92b..0000000
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c
+++ /dev/null
@@ -1,825 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * FUNCTIONS
- *      mlib_ImageChannelExtract  - Copy the selected channels of the source
- *                                  image into the destination image
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageChannelExtract(mlib_image *dst,
- *                                           mlib_image *src,
- *                                           mlib_s32   cmask);
- * ARGUMENT
- *    dst     Pointer to destination image.
- *    src     Pointer to source image.
- *    cmask   Source channel selection mask.
- *    The least significant bit (LSB) is corresponding to the
- *    last channel in the source image data.
- *    The bits with value 1 stand for the channels selected.
- *    If more than N channels are selected, the leftmost N
- *    channels are extracted, where N is the number of channels
- *    in the destination image.
- *
- * RESTRICTION
- *    The src and dst must have the same width, height and data type.
- *    The src and dst can have 1, 2, 3 or 4 channels.
- *    The src and dst can be either MLIB_BYTE, MLIB_SHORT,  MLIB_INT,
- *    MLIB_FLOAT or  MLIB_DOUBLE.
- *
- * DESCRIPTION
- *    Copy the selected channels of the source image into the
- *    destination image
- */
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-/* functions defined in mlib_ImageChannelExtract_1.c */
-
-void
-mlib_v_ImageChannelExtract_U8(mlib_u8  *src,   mlib_s32 slb,
-                              mlib_u8  *dst,   mlib_s32 dlb,
-                              mlib_s32 channels, mlib_s32 channeld,
-                              mlib_s32 width,   mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16(mlib_u16 *src,    mlib_s32 slb,
-                               mlib_u16 *dst,    mlib_s32 dlb,
-                               mlib_s32 channels, mlib_s32 channeld,
-                               mlib_s32 width,    mlib_s32 height,
-                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S32(mlib_s32 *src,    mlib_s32 slb,
-                               mlib_s32 *dst,    mlib_s32 dlb,
-                               mlib_s32 channels, mlib_s32 channeld,
-                               mlib_s32 width,    mlib_s32 height,
-                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_D64(mlib_d64 *src,    mlib_s32 slb,
-                               mlib_d64 *dst,    mlib_s32 dlb,
-                               mlib_s32 channels, mlib_s32 channeld,
-                               mlib_s32 width,    mlib_s32 height,
-                               mlib_s32 cmask);
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_2_1(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8 *dl,  mlib_s32 dlb,
-                                       mlib_s32 width,   mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_U8_3_2(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8 *dl,  mlib_s32 dlb,
-                                       mlib_s32 width,   mlib_s32 height,
-                                       mlib_s32 count1);
-
-void mlib_v_ImageChannelExtract_U8_4_2(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8  *dl,  mlib_s32 dlb,
-                                       mlib_s32 width,   mlib_s32 height,
-                                       mlib_s32 count1);
-
-void mlib_v_ImageChannelExtract_32_2_1(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_32_3_1(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_32_3_2(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 deltac1);
-
-void mlib_v_ImageChannelExtract_32_4_1(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_32_4_2(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 deltac1);
-
-void mlib_v_ImageChannelExtract_32_4_3(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32  mask_off);
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelExtract_U8_21_A8D1X8(mlib_u8  *src,
-                                        mlib_u8  *dst,
-                                        mlib_s32 dsize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_21_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                        mlib_s32 xsize, mlib_s32 ysize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_21_D1(mlib_u8  *src,
-                                    mlib_u8  *dst,
-                                    mlib_s32 dsize,
-                                    mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_21(mlib_u8  *src,  mlib_s32 slb,
-                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                 mlib_s32 xsize, mlib_s32 ysize,
-                                 mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31_A8D1X8(mlib_u8  *src,
-                                        mlib_u8  *dst,
-                                        mlib_s32 dsize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                        mlib_s32 xsize, mlib_s32 ysize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31_D1(mlib_u8  *src,
-                                    mlib_u8  *dst,
-                                    mlib_s32 dsize,
-                                    mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31(mlib_u8  *src,  mlib_s32 slb,
-                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                 mlib_s32 xsize, mlib_s32 ysize,
-                                 mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41_A8D1X8(mlib_u8  *src,
-                                        mlib_u8  *dst,
-                                        mlib_s32 dsize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                        mlib_s32 xsize, mlib_s32 ysize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41_D1(mlib_u8  *src,
-                                    mlib_u8  *dst,
-                                    mlib_s32 dsize,
-                                    mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41(mlib_u8  *src,  mlib_s32 slb,
-                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                 mlib_s32 xsize, mlib_s32 ysize,
-                                 mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_11_A8D1X4(mlib_s16 *src, mlib_s16 *dst,
-                                         mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_21_A8D1X4(mlib_s16 *src,
-                                         mlib_s16 *dst,
-                                         mlib_s32 dsize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_21_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_21_D1(mlib_s16 *src,
-                                     mlib_s16 *dst,
-                                     mlib_s32 dsize,
-                                     mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_21(mlib_s16 *src,  mlib_s32 slb,
-                                  mlib_s16 *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize,
-                                  mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31_A8D1X4(mlib_s16 *src,
-                                         mlib_s16 *dst,
-                                         mlib_s32 dsize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31_D1(mlib_s16 *src,
-                                     mlib_s16 *dst,
-                                     mlib_s32 dsize,
-                                     mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31(mlib_s16 *src,  mlib_s32 slb,
-                                  mlib_s16 *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize,
-                                  mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41_A8D1X4(mlib_s16 *src,
-                                         mlib_s16 *dst,
-                                         mlib_s32 dsize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41_D1(mlib_s16 *src,
-                                     mlib_s16 *dst,
-                                     mlib_s32 dsize,
-                                     mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41(mlib_s16 *src,  mlib_s32 slb,
-                                  mlib_s16 *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize,
-                                  mlib_s32 cmask);
-
-/***************************************************************/
-/* functions defined in mlib_ImageChannelExtract_43.c */
-
-void
-mlib_v_ImageChannelExtract_U8_43R_A8D1X8(mlib_u8  *src,
-                                         mlib_u8  *dst,
-                                         mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43R_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_U8_43R_D1(mlib_u8  *src,
-                                     mlib_u8  *dst,
-                                     mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43R(mlib_u8  *src,  mlib_s32 slb,
-                                  mlib_u8  *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43R_A8D1X4(mlib_s16 *src,
-                                          mlib_s16 *dst,
-                                          mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43R_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                          mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43R_D1(mlib_s16 *src,
-                                      mlib_s16 *dst,
-                                      mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43R(mlib_s16 *src,  mlib_s32 slb,
-                                   mlib_s16 *dst,  mlib_s32 dlb,
-                                   mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_U8_43L_A8D1X8(mlib_u8  *src,
-                                         mlib_u8  *dst,
-                                         mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43L_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_U8_43L_D1(mlib_u8  *src,
-                                     mlib_u8  *dst,
-                                     mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43L(mlib_u8  *src,  mlib_s32 slb,
-                                  mlib_u8  *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43L_A8D1X4(mlib_s16 *src,
-                                          mlib_s16 *dst,
-                                          mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43L_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                          mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43L_D1(mlib_s16 *src,
-                                      mlib_s16 *dst,
-                                      mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43L(mlib_s16 *src,  mlib_s32 slb,
-                                   mlib_s16 *dst,  mlib_s32 dlb,
-                                   mlib_s32 xsize, mlib_s32 ysize);
-
-/***************************************************************/
-
-#ifdef MLIB_TEST
-mlib_status
-mlib_v_ImageChannelExtract(mlib_image *dst,
-                           mlib_image *src,
-                           mlib_s32   cmask)
-#else
-mlib_status
-mlib_ImageChannelExtract(mlib_image *dst,
-                         mlib_image *src,
-                         mlib_s32   cmask)
-#endif
-{
-  const mlib_s32  X8 = 0x7;
-  const mlib_s32  X4 = 0x3;
-  const mlib_s32  X2 = 0x1;
-  const mlib_s32  A8D1   = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_ONEDVECTOR;
-  const mlib_s32  A8D2X8 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH8X;
-  const mlib_s32  A8D2X4 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH4X;
-  const mlib_s32  A8D2X2 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH2X;
-  void      *sp;            /* pointer for pixel in src */
-  void      *dp;            /* pointer for pixel in dst */
-  mlib_s32  ncmask = 0;     /* normalized channel mask */
-  mlib_s32  channels;       /* number of channels for src */
-  mlib_s32  channeld;       /* number of channels for dst */
-  mlib_s32  width, height;  /* for src and dst */
-  mlib_s32  strides;        /* strides in bytes for src */
-  mlib_s32  strided;        /* strides in bytes for dst */
-  mlib_s32  flags;
-  mlib_s32  flagd;
-  mlib_s32  dsize;
-  int       delta0 = 0;     /* offset of first selected channel */
-  int       count1 = 0;     /* number of channels in first group */
-  int       i, bit1count = 0;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_TYPE_EQUAL(src, dst);
-  MLIB_IMAGE_SIZE_EQUAL(src, dst);
-
-  channels = mlib_ImageGetChannels(src);
-  channeld = mlib_ImageGetChannels(dst);
-  width    = mlib_ImageGetWidth(src);
-  height   = mlib_ImageGetHeight(src);
-  strides  = mlib_ImageGetStride(src);
-  strided  = mlib_ImageGetStride(dst);
-  sp       = mlib_ImageGetData(src);
-  dp       = mlib_ImageGetData(dst);
-  flags    = mlib_ImageGetFlags(src);
-  flagd    = mlib_ImageGetFlags(dst);
-  dsize    = width * height;
-
-  /* normalize the cmask, and count the number of bit with value 1 */
-  for (i = (channels - 1); i >= 0; i--) {
-    if (((cmask & (1 << i)) != 0) && (bit1count < channeld)) {
-      ncmask += (1 << i);
-      bit1count++;
-    }
-  }
-
-  /* do not support the cases in which the number of selected channels is
-   * less than the nubmber of channels in the destination image */
-  if (bit1count < channeld) {
-    return MLIB_FAILURE;
-  }
-
-  if (channels == channeld) {
-#ifdef MLIB_TEST
-    mlib_v_ImageCopy(dst, src);
-#else
-    mlib_ImageCopy(dst, src);
-#endif
-    return MLIB_SUCCESS;
-  }
-
-  switch (mlib_ImageGetType(src)) {
-    case MLIB_BYTE:
-      if (channeld == 1) {
-        switch (channels) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-              mlib_v_ImageChannelExtract_U8_21_A8D1X8((mlib_u8 *)sp,
-                                                      (mlib_u8 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-                     ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelExtract_U8_21_A8D2X8((mlib_u8 *)sp, strides,
-                                                      (mlib_u8 *)dp, strided,
-                                                      width, height,
-                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_U8_21_D1((mlib_u8 *)sp,
-                                                  (mlib_u8 *)dp,
-                                                  dsize,
-                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_U8_21((mlib_u8 *)sp, strides,
-                                               (mlib_u8 *)dp, strided,
-                                               width, height,
-                                               ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-              mlib_v_ImageChannelExtract_U8_31_A8D1X8((mlib_u8 *)sp,
-                                                      (mlib_u8 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-                     ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelExtract_U8_31_A8D2X8((mlib_u8 *)sp, strides,
-                                                      (mlib_u8 *)dp, strided,
-                                                      width, height,
-                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_U8_31_D1((mlib_u8 *)sp,
-                                                  (mlib_u8 *)dp,
-                                                  dsize,
-                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_U8_31((mlib_u8 *)sp, strides,
-                                               (mlib_u8 *)dp, strided,
-                                               width, height,
-                                               ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-              mlib_v_ImageChannelExtract_U8_41_A8D1X8((mlib_u8 *)sp,
-                                                      (mlib_u8 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-                     ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelExtract_U8_41_A8D2X8((mlib_u8 *)sp, strides,
-                                                      (mlib_u8 *)dp, strided,
-                                                      width, height,
-                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_U8_41_D1((mlib_u8 *)sp,
-                                                  (mlib_u8 *)dp,
-                                                  dsize,
-                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_U8_41((mlib_u8 *)sp, strides,
-                                               (mlib_u8 *)dp, strided,
-                                               width, height,
-                                               ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 7)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-          mlib_v_ImageChannelExtract_U8_43R_A8D1X8((mlib_u8 *)sp,
-                                                   (mlib_u8 *)dp,
-                                                   dsize);
-        }
-        else if (((flags & A8D2X8) == 0) &&
-                 ((flagd & A8D2X8) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43R_A8D2X8((mlib_u8 *)sp, strides,
-                                                   (mlib_u8 *)dp, strided,
-                                                   width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43R_D1((mlib_u8 *)sp,
-                                               (mlib_u8 *)dp,
-                                               dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_U8_43R((mlib_u8 *)sp, strides,
-                                            (mlib_u8 *)dp, strided,
-                                            width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-          mlib_v_ImageChannelExtract_U8_43L_A8D1X8((mlib_u8 *)sp,
-                                                   (mlib_u8 *)dp,
-                                                   dsize);
-        }
-        else if (((flags & A8D2X8) == 0) &&
-                 ((flagd & A8D2X8) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43L_A8D2X8((mlib_u8 *)sp, strides,
-                                                   (mlib_u8 *)dp, strided,
-                                                   width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43L_D1((mlib_u8 *)sp,
-                                               (mlib_u8 *)dp,
-                                               dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_U8_43L((mlib_u8 *)sp, strides,
-                                            (mlib_u8 *)dp, strided,
-                                            width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      break;
-
-    case MLIB_SHORT:
-      if (channeld == 1) {
-        switch (channels) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelExtract_S16_21_A8D1X4((mlib_s16 *)sp,
-                                                       (mlib_s16 *)dp,
-                                                       dsize,
-                                                       ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-                     ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelExtract_S16_21_A8D2X4((mlib_s16 *)sp, strides,
-                                                       (mlib_s16 *)dp, strided,
-                                                       width, height,
-                                                       ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_S16_21_D1((mlib_s16 *)sp,
-                                                   (mlib_s16 *)dp,
-                                                   dsize,
-                                                   ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_S16_21((mlib_s16 *)sp, strides,
-                                                (mlib_s16 *)dp, strided,
-                                                width, height,
-                                                ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelExtract_S16_31_A8D1X4((mlib_s16 *)sp,
-                                                       (mlib_s16 *)dp,
-                                                       dsize,
-                                                       ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-                     ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelExtract_S16_31_A8D2X4((mlib_s16 *)sp, strides,
-                                                       (mlib_s16 *)dp, strided,
-                                                       width, height,
-                                                       ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_S16_31_D1((mlib_s16 *)sp,
-                                                   (mlib_s16 *)dp,
-                                                   dsize,
-                                                   ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_S16_31((mlib_s16 *)sp, strides,
-                                                (mlib_s16 *)dp, strided,
-                                                width, height,
-                                                ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelExtract_S16_41_A8D1X4((mlib_s16 *)sp,
-                                                       (mlib_s16 *)dp,
-                                                       dsize,
-                                                       ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-                     ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelExtract_S16_41_A8D2X4((mlib_s16 *)sp, strides,
-                                                       (mlib_s16 *)dp, strided,
-                                                       width, height,
-                                                       ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_S16_41_D1((mlib_s16 *)sp,
-                                                   (mlib_s16 *)dp,
-                                                   dsize,
-                                                   ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_S16_41((mlib_s16 *)sp, strides,
-                                                (mlib_s16 *)dp, strided,
-                                                width, height,
-                                                ncmask);
-            }
-            return MLIB_SUCCESS;
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 7)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelExtract_S16_43R_A8D1X4((mlib_s16 *)sp,
-                                                    (mlib_s16 *)dp,
-                                                    dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-                 ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43R_A8D2X4((mlib_s16 *)sp, strides,
-                                                    (mlib_s16 *)dp, strided,
-                                                    width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43R_D1((mlib_s16 *)sp,
-                                                (mlib_s16 *)dp,
-                                                dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_S16_43R((mlib_s16 *)sp, strides,
-                                             (mlib_s16 *)dp, strided,
-                                             width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelExtract_S16_43L_A8D1X4((mlib_s16 *)sp,
-                                                    (mlib_s16 *)dp,
-                                                    dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-                 ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43L_A8D2X4((mlib_s16 *)sp, strides,
-                                                    (mlib_s16 *)dp, strided,
-                                                    width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43L_D1((mlib_s16 *)sp,
-                                                (mlib_s16 *)dp,
-                                                dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_S16_43L((mlib_s16 *)sp, strides,
-                                             (mlib_s16 *)dp, strided,
-                                             width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      break;
-
-  }
-
-/***************************************************************/
-  /* From C version */
-
-  for (i = (channels - 1); i >= 0; i--) {
-    if (!(ncmask & (1 << i))) delta0++;
-    else break;
-  }
-  for (; i >= 0; i--) {
-    if (ncmask & (1 << i)) count1++;
-    else break;
-  }
-
-  switch (mlib_ImageGetType(src)) {
-    case MLIB_BYTE:
-      {
-        mlib_u8 *sl = (mlib_u8 *)sp + delta0;
-        mlib_u8 *dl = (mlib_u8 *)dp;
-
-        switch (channels*10 + channeld) {
-          case 32:
-            mlib_v_ImageChannelExtract_U8_3_2(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          case 42:
-            if (ncmask == 0xA || ncmask == 0x5) { /* mask 1010 or 0101 */
-              mlib_v_ImageChannelExtract_U8_2_1(sl, strides, dl, strided, 2*width, height);
-              return MLIB_SUCCESS;
-            }
-            mlib_v_ImageChannelExtract_U8_4_2(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          case 43:
-            mlib_v_ImageChannelExtract_U8((mlib_u8 *)sp, strides,
-                                          (mlib_u8 *)dp, strided,
-                                          channels, channeld,
-                                          width, height,
-                                          ncmask);
-            return MLIB_SUCCESS;
-
-          default: return MLIB_FAILURE;
-        }
-      }
-
-    case MLIB_SHORT:
-      mlib_v_ImageChannelExtract_S16((mlib_u16 *)sp, strides,
-                                     (mlib_u16 *)dp, strided,
-                                     channels,  channeld,
-                                     width, height,
-                                     ncmask);
-      break;
-
-    case MLIB_INT:
-    case MLIB_FLOAT:
-      {
-        mlib_f32 *sl = (mlib_f32 *)sp + delta0;
-        mlib_f32 *dl = (mlib_f32 *)dp;
-        strides /= 4;
-        strided /= 4;
-
-        switch (channels*10 + channeld) {
-          case 21:
-            mlib_v_ImageChannelExtract_32_2_1(sl, strides, dl, strided, width, height);
-            return MLIB_SUCCESS;
-
-          case 31:
-            mlib_v_ImageChannelExtract_32_3_1(sl, strides, dl, strided, width, height);
-            return MLIB_SUCCESS;
-
-          case 32:
-            mlib_v_ImageChannelExtract_32_3_2(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          case 41:
-            mlib_v_ImageChannelExtract_32_4_1(sl, strides, dl, strided, width, height);
-            return MLIB_SUCCESS;
-
-          case 42:
-            if (ncmask == 0xA || ncmask == 0x5) { /* mask 1010 or 0101 */
-              mlib_v_ImageChannelExtract_32_2_1(sl, strides, dl, strided, 2*width, height);
-            } else {
-              mlib_v_ImageChannelExtract_32_4_2(sl, strides, dl, strided, width, height, count1);
-            }
-            return MLIB_SUCCESS;
-
-          case 43:
-            mlib_v_ImageChannelExtract_32_4_3(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-    case MLIB_DOUBLE:
-      mlib_v_ImageChannelExtract_D64((mlib_d64 *)sp, strides,
-                                     (mlib_d64 *)dp, strided,
-                                     channels,  channeld,
-                                     width, height,
-                                     ncmask);
-      break;
-
-    case MLIB_BIT:
-    default:
-      return MLIB_FAILURE;  /* MLIB_BIT is not supported here */
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h
index 6193ec1..7c59464 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h
@@ -32,348 +32,29 @@
 extern "C" {
 #endif /* __cplusplus */
 
-void mlib_v_ImageChannelExtract_U8_21_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_21_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask);
-
 void mlib_v_ImageChannelExtract_U8_21_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
                                          mlib_s32      cmask);
 
-void mlib_v_ImageChannelExtract_U8_21(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_31_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_31_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask);
-
 void mlib_v_ImageChannelExtract_U8_31_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
                                          mlib_s32      cmask);
 
-void mlib_v_ImageChannelExtract_U8_31(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_41_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_41_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask);
-
 void mlib_v_ImageChannelExtract_U8_41_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
                                          mlib_s32      cmask);
 
-void mlib_v_ImageChannelExtract_U8_41(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_S16_21_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_21_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_21_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_21(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize);
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize);
-
-void mlib_v_ImageChannelExtract_U8_43R_D1(const mlib_u8 *src,
-                                          mlib_u8       *dst,
-                                          mlib_s32      dsize);
-
-void mlib_v_ImageChannelExtract_U8_43R(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize);
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize);
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize);
-
-void mlib_v_ImageChannelExtract_S16_43R_D1(const mlib_s16 *src,
-                                           mlib_s16       *dst,
-                                           mlib_s32       dsize);
-
-void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize);
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize);
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize);
-
 void mlib_v_ImageChannelExtract_U8_43L_D1(const mlib_u8 *src,
                                           mlib_u8       *dst,
                                           mlib_s32      dsize);
 
-void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize);
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize);
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize);
-
 void mlib_v_ImageChannelExtract_S16_43L_D1(const mlib_s16 *src,
                                            mlib_s16       *dst,
                                            mlib_s32       dsize);
 
-void mlib_v_ImageChannelExtract_S16_43L(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize);
-
-void mlib_v_ImageChannelExtract_U8_2_1(const mlib_u8 *sl,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dl,
-                                       mlib_s32      dlb,
-                                       mlib_s32      width,
-                                       mlib_s32      height);
-
-void mlib_v_ImageChannelExtract_U8_3_2(const mlib_u8 *sl,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dl,
-                                       mlib_s32      dlb,
-                                       mlib_s32      width,
-                                       mlib_s32      height,
-                                       mlib_s32      count1);
-
-void mlib_v_ImageChannelExtract_U8_4_2(const mlib_u8 *sl,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dl,
-                                       mlib_s32      dlb,
-                                       mlib_s32      width,
-                                       mlib_s32      height,
-                                       mlib_s32      count1);
-
-void mlib_v_ImageChannelExtract_32_2_1(const mlib_f32 *sp,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dp,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height);
-
-void mlib_v_ImageChannelExtract_32_3_1(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height);
-
-void mlib_v_ImageChannelExtract_32_3_2(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height,
-                                       mlib_s32       count1);
-
-void mlib_v_ImageChannelExtract_32_4_1(const mlib_f32 *sp,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dp,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height);
-
-void mlib_v_ImageChannelExtract_32_4_2(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height,
-                                       mlib_s32       count1);
-
-void mlib_v_ImageChannelExtract_32_4_3(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height,
-                                       mlib_s32       count1);
-
-void mlib_v_ImageChannelExtract_U8(const mlib_u8 *src,
-                                   mlib_s32      slb,
-                                   mlib_u8       *dst,
-                                   mlib_s32      dlb,
-                                   mlib_s32      channels,
-                                   mlib_s32      channeld,
-                                   mlib_s32      width,
-                                   mlib_s32      height,
-                                   mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_S16(const mlib_u16 *src,
-                                    mlib_s32       slb,
-                                    mlib_u16       *dst,
-                                    mlib_s32       dlb,
-                                    mlib_s32       channels,
-                                    mlib_s32       channeld,
-                                    mlib_s32       width,
-                                    mlib_s32       height,
-                                    mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_D64(const mlib_d64 *src,
-                                    mlib_s32       slb,
-                                    mlib_d64       *dst,
-                                    mlib_s32       dlb,
-                                    mlib_s32       channels,
-                                    mlib_s32       channeld,
-                                    mlib_s32       width,
-                                    mlib_s32       height,
-                                    mlib_s32       cmask);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c
index 69ae723..54f26d5 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c
@@ -29,30 +29,9 @@
  * FILENAME: mlib_ImageChannelExtract_1.c
  *
  * FUNCTIONS
- *      mlib_v_ImageChannelExtract_U8_21_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_21_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_21_D1
- *      mlib_v_ImageChannelExtract_U8_21
- *      mlib_v_ImageChannelExtract_U8_31_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_31_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_31_D1
- *      mlib_v_ImageChannelExtract_U8_31
- *      mlib_v_ImageChannelExtract_U8_41_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_41_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_41_D1
- *      mlib_v_ImageChannelExtract_U8_41
- *      mlib_v_ImageChannelExtract_S16_21_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_21_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_21_D1
- *      mlib_v_ImageChannelExtract_S16_21
- *      mlib_v_ImageChannelExtract_S16_31_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_31_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_31_D1
- *      mlib_v_ImageChannelExtract_S16_31
- *      mlib_v_ImageChannelExtract_S16_41_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_41_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_41_D1
- *      mlib_v_ImageChannelExtract_S16_41
  *
  * ARGUMENT
  *      src    pointer to source image data
@@ -95,100 +74,6 @@
 
 /***************************************************************/
 /* extract one channel from a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_21_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc, sdd;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_U8_21L(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_U8_21R(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-/* extract one channel from a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_21_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc, sdd;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_U8_21L(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_U8_21R(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-/* extract one channel from a 2-channel image.
  */
 
 void mlib_v_ImageChannelExtract_U8_21_D1(const mlib_u8 *src,
@@ -415,32 +300,6 @@
 }
 
 /***************************************************************/
-/* extract one channel from a 2-channel image.
- */
-
-void mlib_v_ImageChannelExtract_U8_21(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_21_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd)                \
   sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));        \
   sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));        \
@@ -468,119 +327,6 @@
   dd  = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde))
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_31_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc, sdd, sde;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_U8_31M(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_U8_31R(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_U8_31_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc, sdd, sde;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_U8_31M(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_U8_31R(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelExtract_U8_31_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
@@ -932,29 +678,6 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_31(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_31_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd)           \
   sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2));        \
   sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2));        \
@@ -995,152 +718,6 @@
   dd  = vis_fpmerge(vis_read_lo(sde), vis_read_lo(sdf))
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_41_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc, sdd, sde, sdf;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41ML(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41MR(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41R(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_U8_41_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc, sdd, sde, sdf;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41ML(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41MR(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41R(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelExtract_U8_41_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
@@ -1632,1560 +1209,3 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_41(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_41_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_21L(sd0, sd1, dd)                    \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd1));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd1));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_21R(sd0, sd1, dd)                    \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd1));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd1));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-/* extract one channel from a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * dsize is multiple of 4.
- */
-
-void mlib_v_ImageChannelExtract_S16_21_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_S16_21L(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_S16_21R(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_21_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21L(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21R(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_21_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd0, dd1;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 off;                                       /* offset of dst over src */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  doff = ((mlib_addr) da & 7);
-  dend = da + dsize - 1;
-  dend2 = dend - 3;
-
-  /* calculate the src's offset over dst */
-  if (cmask == 2) {
-    off = (soff / 4) * 2 - doff;
-  }
-  else {
-    off = ((soff + 3) / 4) * 2 - doff;
-  }
-
-  if (((cmask == 2) && (soff % 4 == 0)) || ((cmask == 1) && (soff % 4 != 0))) { /* extract even words */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 16 bytes */
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 32 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-        CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else {                                    /* extract odd words */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes, don't care the garbage at the start point */
-      sd0 = *sp++;
-      sd1 = *sp++;
-
-      /* extract and store 8 bytes */
-      CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 16 bytes */
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 32 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-        CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_21(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_21_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd)               \
-  /* extract the left channel */                                \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd)               \
-  /* extract the middle channel */                              \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd)               \
-  /* extract the right channel */                               \
-  sda = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 sd0, sd1, sd2;                             /* 8-byte source data */
-  mlib_d64 sd3, sd4, sd5;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd0, dd1;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 off;                                       /* offset of src over dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  doff = ((mlib_addr) da & 7);
-  dend = da + dsize - 1;
-  dend2 = dend - 3;
-
-  /* calculate the src's offset over dst */
-  if (cmask == 4) {
-    off = (soff / 6) * 2 - doff;
-  }
-  else if (cmask == 2) {
-    off = ((soff + 2) / 6) * 2 - doff;
-  }
-  else {
-    off = ((soff + 4) / 6) * 2 - doff;
-  }
-
-  if (((cmask == 4) && (soff % 6 == 0)) ||
-      ((cmask == 2) && (soff % 6 == 4)) ||
-      ((cmask == 1) && (soff % 6 == 2))) { /* extract left channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-        CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd3 = *sp++;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else if (((cmask == 4) && (soff % 6 == 2)) ||
-           ((cmask == 2) && (soff % 6 == 0)) ||
-           ((cmask == 1) && (soff % 6 == 4))) {
-    /* extract middle channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-        CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd3 = *sp++;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else {                                    /* extract right channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-        CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd3 = *sp++;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_31_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41L(sd0, sd1,  sd2, sd3, dd)         \
-  /* extract the left channel */                                \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_hi(sd3));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd)         \
-  /* extract the middle left channel */                         \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_hi(sd3));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd)         \
-  /* extract the middle right channel */                        \
-  sda = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2));        \
-  sdb = vis_fpmerge(vis_read_lo(sd1), vis_read_lo(sd3));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd)          \
-  /* extract the right channel */                               \
-  sda = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2));        \
-  sdb = vis_fpmerge(vis_read_lo(sd1), vis_read_lo(sd3));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 sd4, sd5, sd6, sd7;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd0, dd1;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 off;                                       /* offset of src over dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  doff = ((mlib_addr) da & 7);
-  dend = da + dsize - 1;
-  dend2 = dend - 3;
-
-  /* calculate the src's offset over dst */
-  if (cmask == 8) {
-    off = (soff / 8) * 2 - doff;
-  }
-  else if (cmask == 4) {
-    off = ((soff + 2) / 8) * 2 - doff;
-  }
-  else if (cmask == 2) {
-    off = ((soff + 4) / 8) * 2 - doff;
-  }
-  else {
-    off = ((soff + 6) / 8) * 2 - doff;
-  }
-
-  if (((cmask == 8) && (soff == 0)) ||
-      ((cmask == 4) && (soff == 6)) ||
-      ((cmask == 2) && (soff == 4)) ||
-      ((cmask == 1) && (soff == 2))) { /* extract left channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-        CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else if (((cmask == 8) && (soff == 2)) ||
-           ((cmask == 4) && (soff == 0)) ||
-           ((cmask == 2) && (soff == 6)) ||
-           ((cmask == 1) && (soff == 4))) { /* extract middle left channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-        CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else if (((cmask == 8) && (soff == 4)) ||
-           ((cmask == 4) && (soff == 2)) ||
-           ((cmask == 2) && (soff == 0)) ||
-           ((cmask == 1) && (soff == 6))) { /* extract middle right channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-        CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else {                                    /* extract right channel */
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_41_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c
index cf6ec42..9924a29 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c
@@ -29,22 +29,8 @@
  * FILENAME: mlib_v_ImageChannelExtract_43.c
  *
  * FUNCTIONS
- *      mlib_v_ImageChannelExtract_U8_43R_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_43R_A8D2X8
- *      mlib_v_ImageChannelExtract_U8_43R_D1
- *      mlib_v_ImageChannelExtract_U8_43R
- *      mlib_v_ImageChannelExtract_S16_43R_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_43R_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_43R_D1
- *      mlib_v_ImageChannelExtract_S16_43R
- *      mlib_v_ImageChannelExtract_U8_43L_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_43L_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_43L_D1
- *      mlib_v_ImageChannelExtract_U8_43L
- *      mlib_v_ImageChannelExtract_S16_43L_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_43L_A8D2X4
  *      mlib_v_ImageChannelExtract_S16_43L_D1
- *      mlib_v_ImageChannelExtract_S16_43L
  *
  * SYNOPSIS
  *
@@ -74,705 +60,6 @@
 #include "mlib_v_ImageChannelExtract.h"
 
 /***************************************************************/
-#define EXTRACT_U8_43R_old          /* shift right */           \
-  dd2 = vis_faligndata(sd3, dd2);    /* r7-------------- */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* g7r7------------ */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* b7g7r7---------- */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* r6b7g7r7-------- */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* g6r6b7g7r7------ */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* b6g6r6b7g7r7---- */     \
-                                                                \
-  dd2 = vis_faligndata(sd2, dd2);    /* r5b6g6r6b7g7r7-- */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd2 = vis_faligndata(sd2, dd2);    /* g5r5b6g6r6b7g7r7 */     \
-                                                                \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* b5-------------- */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* r4b5------------ */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* g4r4b5---------- */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* b4g4r4b5-------- */     \
-                                                                \
-  dd1 = vis_faligndata(sd1, dd1);    /* r3b4g4r4b5------ */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* g3r3b4g4r4b5---- */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* b3g3r3b4g4r4b5-- */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* r2b3g3r3b4g4r4b5 */     \
-                                                                \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(sd1, dd0);    /* g2-------------- */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(sd1, dd0);    /* b2g2------------ */     \
-                                                                \
-  dd0 = vis_faligndata(sd0, dd0);    /* r1b2g2---------- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* g1r1b2g2-------- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* b1g1r1b2g2------ */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* r0b1g1r1b2g2---- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* g0r0b1g1r1b2g2-- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);           /* b0g0r0b1g1r1b2g2 */
-
-/***************************************************************/
-#define EXTRACT_U8_43R              /* shift right */           \
-  vis_alignaddr((void *)0, 5);                                  \
-  dd2 = vis_faligndata(sd3, dd2);    /* b7g7r7---------- */     \
-  sda = vis_freg_pair(vis_read_hi(sd3), vis_read_hi(sd3));      \
-  dd2 = vis_faligndata(sda, dd2);    /* b6g6r6b7g7r7---- */     \
-                                                                \
-  vis_alignaddr((void *)0, 6);                                  \
-  dd2 = vis_faligndata(sd2, dd2);    /* g5r5b6g6r6b7g7r7 */     \
-                                                                \
-  vis_alignaddr((void *)0, 5);                                  \
-  dd1 = vis_faligndata(sd2, dd1);    /* b5g5r5---------- */     \
-  sda = vis_freg_pair(vis_read_hi(sd2), vis_read_hi(sd2));      \
-  dd1 = vis_faligndata(sda, dd1);    /* b4g4r4b5g5r5---- */     \
-  dd1 = vis_faligndata(sd1, dd1);    /* b3g3r3b4g4r4b5g5 */     \
-  sda = vis_freg_pair(vis_read_hi(sd1), vis_read_hi(sd1));      \
-  vis_alignaddr((void *)0, 7);                                  \
-  dd1 = vis_faligndata(sda, dd1);    /* r2b3g3r3b4g4r4b5 */     \
-                                                                \
-  vis_alignaddr((void *)0, 5);                                  \
-  dd0 = vis_faligndata(sda, dd0);    /* b2g2r2---------- */     \
-  dd0 = vis_faligndata(sd0, dd0);    /* b1g1r1b2g2r2---- */     \
-  sda = vis_freg_pair(vis_read_hi(sd0), vis_read_hi(sd0));      \
-  dd0 = vis_faligndata(sda, dd0);           /* b0g0r0b1g1r1b2g2 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_U8_43R_STORE                               \
-  sd0 = *sp++;          /* --b0g0r0--b1g1r1 */                  \
-  sd1 = *sp++;          /* --b2g2r2--b3g3r3 */                  \
-  sd2 = *sp++;          /* --b4g4r4--b5g5r5 */                  \
-  sd3 = *sp++;          /* --b6g6r6--b7g7r7 */                  \
-  EXTRACT_U8_43R;                                               \
-  *dp++ = dd0;          /* b0g0r0b1g1r1b2g2 */                  \
-  *dp++ = dd1;          /* r2b3g3r3b4g4r4b5 */                  \
-  *dp++ = dd2;                              /* g5r5b6g6r6b7g7r7 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_U8_43R                                     \
-  vis_alignaddr((void *)soff, 0);                               \
-  s0 = s4;                                                      \
-  s1 = sp[1];                                                   \
-  s2 = sp[2];                                                   \
-  s3 = sp[3];                                                   \
-  s4 = sp[4];                                                   \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                 \
-  sd2 = vis_faligndata(s2, s3);                                 \
-  sd3 = vis_faligndata(s3, s4);                                 \
-  sp += 4;                                                      \
-  dd2old = dd2;                                                 \
-  EXTRACT_U8_43R
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 7); *//* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_EXTRACT_U8_43R_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 7); *//* only for _old */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_EXTRACT_U8_43R_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination data are not 8-byte aligned.
- * And dsize is in pixels.
- */
-
-void mlib_v_ImageChannelExtract_U8_43R_D1(const mlib_u8 *src,
-                                          mlib_u8       *dst,
-                                          mlib_s32      dsize)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *dend, *dend2;                              /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 s0, s1, s2, s3, s4;                        /* 8-byte source row data */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 dd2old;                                    /* the last datum of the last step */
-  mlib_d64 sda;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  dend = da + dsize * 3 - 1;
-  dend2 = dend - 23;
-  doff = 8 - ((mlib_addr) da & 7);
-
-  /* generate edge mask for the start point */
-  emask = vis_edge8(da, dend);
-
-  /* load 32 byte, convert, store 24 bytes */
-  s4 = sp[0];                               /* initial value */
-  LOAD_EXTRACT_U8_43R;
-
-  if (dsize >= 8) {
-    if (doff == 8) {
-      vis_pst_8(dd0, dp++, emask);
-      *dp++ = dd1;
-      *dp++ = dd2;
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask);
-      *dp++ = vis_faligndata(dd0, dd1);
-      *dp++ = vis_faligndata(dd1, dd2);
-    }
-  }
-  else {                                    /* for very small size */
-    if (doff == 8) {
-      vis_pst_8(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask);
-          if ((mlib_addr) dp <= (mlib_addr) dend) {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd2), dp++, emask);
-          }
-        }
-      }
-    }
-  }
-
-  /* no edge handling is needed in the loop */
-  if (doff == 8) {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_U8_43R;
-        *dp++ = dd0;
-        *dp++ = dd1;
-        *dp++ = dd2;
-      }
-    }
-  }
-  else {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_U8_43R;
-        vis_alignaddr((void *)doff, 0);
-        *dp++ = vis_faligndata(dd2old, dd0);
-        *dp++ = vis_faligndata(dd0, dd1);
-        *dp++ = vis_faligndata(dd1, dd2);
-      }
-    }
-  }
-
-  if ((mlib_addr) dp <= (mlib_addr) dend) {
-    LOAD_EXTRACT_U8_43R;
-    emask = vis_edge8(dp, dend);
-    if (doff == 8) {
-      vis_pst_8(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_8(vis_faligndata(dd2old, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask);
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_U8_43R(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_43R_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define EXTRACT_S16_43R_old      /* shift right */              \
-                                                                \
-  dd2 = vis_faligndata(sd3, dd2);    /* r3------ */             \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* g3r3---- */             \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* b3g3r3-- */             \
-                                                                \
-  dd2 = vis_faligndata(sd2, dd2);    /* r2b3g3r3 */             \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* g2------ */             \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* b2g2---- */             \
-                                                                \
-  dd1 = vis_faligndata(sd1, dd1);    /* r1b2g2-- */             \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* g1r1b2g2 */             \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(sd1, dd0);    /* b1------ */             \
-                                                                \
-  dd0 = vis_faligndata(sd0, dd0);    /* r0b1---- */             \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* g0r0b1-- */             \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);           /* b0g0r0b1 */
-
-/***************************************************************/
-#define EXTRACT_S16_43R        /* shift right */                \
-                                                                \
-  vis_alignaddr((void *)0, 2);                                  \
-  dd2 = vis_faligndata(sd3, dd2);    /* b3g3r3-- */             \
-                                                                \
-  vis_alignaddr((void *)0, 6);                                  \
-  dd2 = vis_faligndata(sd2, dd2);    /* r2b3g3r3 */             \
-  vis_alignaddr((void *)0, 2);                                  \
-  dd1 = vis_faligndata(sd2, dd1);    /* b2g2r2-- */             \
-                                                                \
-  vis_alignaddr((void *)0, 4);                                  \
-  dd1 = vis_faligndata(sd1, dd1);    /* g1r1b2g2 */             \
-  vis_alignaddr((void *)0, 2);                                  \
-  dd0 = vis_faligndata(sd1, dd0);    /* b1g1r1-- */             \
-  dd0 = vis_faligndata(sd0, dd0);           /* b0g0r0b1 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_S16_43R_STORE                              \
-                                                                \
-  sd0 = *sp++;          /* --b0g0r0 */                          \
-  sd1 = *sp++;          /* --b1g1r1 */                          \
-  sd2 = *sp++;          /* --b2g2r2 */                          \
-  sd3 = *sp++;          /* --b3g3r3 */                          \
-                                                                \
-  EXTRACT_S16_43R;                                              \
-                                                                \
-  *dp++ = dd0;          /* b0g0r0b1 */                          \
-  *dp++ = dd1;          /* g1r1b2g2 */                          \
-  *dp++ = dd2;                              /* r2b3g3r3 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_S16_43R                                    \
-                                                                \
-  vis_alignaddr((void *)soff, 0);                               \
-  s0 = s4;                                                      \
-  s1 = sp[1];                                                   \
-  s2 = sp[2];                                                   \
-  s3 = sp[3];                                                   \
-  s4 = sp[4];                                                   \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                 \
-  sd2 = vis_faligndata(s2, s3);                                 \
-  sd3 = vis_faligndata(s3, s4);                                 \
-  sp += 4;                                                      \
-  dd2old = dd2;                                                 \
-  EXTRACT_S16_43R
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And size is in 4-pixels.
- */
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 6); *//* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_EXTRACT_S16_43R_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. The xsize is multiple of 8.
- * slb and dlb are multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 6); *//* only for _old */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_EXTRACT_S16_43R_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination data are not 8-byte aligned.
- * And dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_S16_43R_D1(const mlib_s16 *src,
-                                           mlib_s16       *dst,
-                                           mlib_s32       dsize)
-{
-  mlib_s16 *sa, *da;                                  /* pointer for pixel */
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 s0, s1, s2, s3, s4;                        /* 8-byte source row data */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 dd2old;                                    /* the last datum of the last step */
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  dend = da + dsize * 3 - 1;
-  dend2 = dend - 11;
-  doff = 8 - ((mlib_addr) da & 7);
-
-  /* generate edge mask for the start point */
-  emask = vis_edge16(da, dend);
-
-  /* load 32 byte, convert, store 24 bytes */
-  s4 = sp[0];                               /* initial value */
-  LOAD_EXTRACT_S16_43R;
-
-  if (dsize >= 4) {
-    if (doff == 8) {
-      vis_pst_16(dd0, dp++, emask);
-      *dp++ = dd1;
-      *dp++ = dd2;
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask);
-      *dp++ = vis_faligndata(dd0, dd1);
-      *dp++ = vis_faligndata(dd1, dd2);
-    }
-  }
-  else {                                    /* for very small size */
-    if (doff == 8) {
-      vis_pst_16(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask);
-        }
-      }
-    }
-  }
-
-  /* no edge handling is needed in the loop */
-  if (doff == 8) {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_S16_43R;
-        *dp++ = dd0;
-        *dp++ = dd1;
-        *dp++ = dd2;
-      }
-    }
-  }
-  else {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_S16_43R;
-        vis_alignaddr((void *)doff, 0);
-        *dp++ = vis_faligndata(dd2old, dd0);
-        *dp++ = vis_faligndata(dd0, dd1);
-        *dp++ = vis_faligndata(dd1, dd2);
-      }
-    }
-  }
-
-  if ((mlib_addr) dp <= (mlib_addr) dend) {
-    LOAD_EXTRACT_S16_43R;
-    emask = vis_edge16(dp, dend);
-    if (doff == 8) {
-      vis_pst_16(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_16(vis_faligndata(dd2old, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask);
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_43R_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define EXTRACT_U8_43L_old      /* shift left */                \
-                                                                \
-  dd0 = vis_faligndata(dd0, sd0);    /* --------------r0 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ------------r0g0 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ----------r0g0b0 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* --------r0g0b0r1 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ------r0g0b0r1g1 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ----r0g0b0r1g1b1 */     \
-                                                                \
-  dd0 = vis_faligndata(dd0, sd1);    /* --r0g0b0r1g1b1r2 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(dd0, sd1);    /* r0g0b0r1g1b1r2g2 */     \
-                                                                \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* --------------b2 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* ------------b2r3 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* ----------b2r3g3 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* --------b2r3g3b3 */     \
-                                                                \
-  dd1 = vis_faligndata(dd1, sd2);    /* ------b2r3g3b3r4 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(dd1, sd2);    /* ----b2r3g3b3r4g4 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(dd1, sd2);    /* --b2r3g3b3r4g4b4 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(dd1, sd2);    /* b2r3g3b3r4g4b4r5 */     \
-                                                                \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd2 = vis_faligndata(dd2, sd2);    /* --------------g5 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd2 = vis_faligndata(dd2, sd2);    /* ------------g5b5 */     \
-                                                                \
-  dd2 = vis_faligndata(dd2, sd3);    /* ----------g5b5r6 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* --------g5b5r6g6 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* ------g5b5r6g6b6 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* ----g5b5r6g6b6r7 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* --g5b5r6g6b6r7g7 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);           /* g5b5r6g6b6r7g7b7 */
-
-/***************************************************************/
 #define EXTRACT_U8_43L        /* shift left */                  \
                                                                 \
   vis_alignaddr((void *)0, 3);                                  \
@@ -801,20 +88,6 @@
   dd2 = vis_faligndata(dd2, sda);           /* g5b5r6g6b6r7g7b7 */
 
 /***************************************************************/
-#define LOAD_EXTRACT_U8_43L_STORE                               \
-                                                                \
-  sd0 = *sp++;          /* r0g0b0--r1g1b1-- */                  \
-  sd1 = *sp++;          /* r2g2b2--r3g3b3-- */                  \
-  sd2 = *sp++;          /* r4g4b4--r5g5b5-- */                  \
-  sd3 = *sp++;          /* r6g6b6--r7g7b7-- */                  \
-                                                                \
-  EXTRACT_U8_43L;                                               \
-                                                                \
-  *dp++ = dd0;          /* r0g0b0r1g1b1r2g2 */                  \
-  *dp++ = dd1;          /* b2r3g3b3r4g4b4r5 */                  \
-  *dp++ = dd2;                              /* g5b5r6g6b6r7g7b7 */
-
-/***************************************************************/
 #define LOAD_EXTRACT_U8_43L                                             \
                                                                         \
   vis_alignaddr((void *)soff, 0);                                       \
@@ -835,74 +108,6 @@
 
 /***************************************************************/
 /*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 1); *//* for _old only */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_EXTRACT_U8_43L_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 1); *//* for _old only */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_EXTRACT_U8_43L_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
  * Either source or destination data are not 8-byte aligned.
  * And ssize is multiple of 8.
  */
@@ -1045,28 +250,6 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_43L_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define EXTRACT_S16_43L              /* shift left */           \
   vis_alignaddr((void *)0, 6);                                  \
   dd0 = vis_faligndata(dd0, sd0);    /* --r0g0b0 */             \
@@ -1083,20 +266,6 @@
   dd2 = vis_faligndata(dd2, sd3);           /* b2r3g3b3 */
 
 /***************************************************************/
-#define LOAD_EXTRACT_S16_43L_STORE                              \
-                                                                \
-  sd0 = *sp++;          /* r0g0b0-- */                          \
-  sd1 = *sp++;          /* r1g1b1-- */                          \
-  sd2 = *sp++;          /* r2g2b2-- */                          \
-  sd3 = *sp++;          /* r3g3b3-- */                          \
-                                                                \
-  EXTRACT_S16_43L;                                              \
-                                                                \
-  *dp++ = dd0;          /* r0g0b0r1 */                          \
-  *dp++ = dd1;          /* g1b1r2g2 */                          \
-  *dp++ = dd2;                              /* b2r3g3b3 */
-
-/***************************************************************/
 #define LOAD_EXTRACT_S16_43L                                    \
                                                                 \
   vis_alignaddr((void *)soff, 0);                               \
@@ -1115,72 +284,6 @@
 
 /***************************************************************/
 /*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 4.
- */
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 2); *//* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_EXTRACT_S16_43L_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. The xsize is multiple of 4.
- * And slb and dlb are multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 2); *//* only for _old */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_EXTRACT_S16_43L_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
  * Either source or destination data are not 8-byte aligned.
  * And size is in pixels.
  */
@@ -1318,25 +421,3 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_S16_43L(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_43L_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c
deleted file mode 100644
index da12eba..0000000
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c
+++ /dev/null
@@ -1,784 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-typedef union {
-  double d64;
-  struct {
-    float f0;
-    float f1;
-  } f32s;
-} d64_2_f32;
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_2_1(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8  *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_u8   *sp = sl;
-  mlib_u8   *dp = dl;
-  int       i, j;
-
-  for (j = 0; j < height; j++) {
-    mlib_u8  *dend = dl + width;
-    mlib_u32 *sp2;
-    while (((mlib_addr)sp & 7) > 1) {
-      *dp++ = *sp;
-      sp += 2;
-      if (dp >= dend) break;
-    }
-    if ((mlib_addr)sp & 7) {
-      sp2 = (mlib_u32 *)(sp - 1);
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        mlib_u32 s0;
-        s0 = *sp2++;
-        dp[0] = s0 >> 16;
-        dp[1] = s0;
-      }
-      if (dp < dend) {
-        dp[0] = sp2[0] >> 16;
-      }
-    } else {
-      sp2 = (mlib_u32 *)sp;
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        mlib_u32 s0;
-        s0 = *sp2++;
-        dp[0] = s0 >> 24;
-        dp[1] = s0 >> 8;
-      }
-      if (dp < dend) {
-        dp[0] = sp2[0] >> 24;
-      }
-    }
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_3_2(mlib_u8  *sl, mlib_s32 slb,
-                                       mlib_u8 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_u8   *sp = sl;
-  mlib_u8   *dp = dl;
-  mlib_u32  *sp2;
-  mlib_u16  *dp2;
-  mlib_u16  *d2end;
-  mlib_u32  s0, s1, s2, s3;
-  int       i, j, off, count_off;
-
-  for (j = 0; j < height; j++) {
-    mlib_u8  *dend  = dl + 2*width;
-
-    if (count1 == 1) {
-      if (dp < dend) *dp++ = sp[0];
-      sp += 2;
-    }
-
-    if ((mlib_addr)dp & 1) {
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        dp[0] = sp[0];
-        dp[1] = sp[1];
-        sp += 3;
-      }
-      if (dp < dend) {
-        dp[0] = sp[0];
-      }
-      sp = sl += slb;
-      dp = dl += dlb;
-      continue;
-    }
-
-    dp2 = (mlib_u16*)dp;
-    d2end = (mlib_u16*)((mlib_addr)dend &~ 1);
-    off = (mlib_addr)sp & 3;
-    sp2 = (mlib_u32 *)(sp - off);
-
-    switch (off) {
-
-      case 0:
-#pragma pipeloop(0)
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = sp2[0];
-          s1 = sp2[1];
-          s2 = sp2[2];
-          dp2[0] = s0 >> 16;
-          dp2[1] = (s0 << 8) | (s1 >> 24);
-          dp2[2] = s1;
-          dp2[3] = s2 >>  8;
-          sp2 += 3;
-        }
-        break;
-
-      case 1:
-#pragma pipeloop(0)
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = sp2[0];
-          s1 = sp2[1];
-          s2 = sp2[2];
-          dp2[0] = s0 >> 8;
-          dp2[1] = s1 >> 16;
-          dp2[2] = (s1 << 8) | (s2 >> 24);
-          dp2[3] = s2;
-          sp2 += 3;
-        }
-        break;
-
-      case 2:
-#pragma pipeloop(0)
-        s3 = sp2[0];
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = s3;
-          s1 = sp2[1];
-          s2 = sp2[2];
-          s3 = sp2[3];
-          dp2[0] = s0;
-          dp2[1] = s1 >> 8;
-          dp2[2] = s2 >> 16;
-          dp2[3] = (s2 << 8) | (s3 >> 24);
-          sp2 += 3;
-        }
-        break;
-
-      case 3:
-#pragma pipeloop(0)
-        s3 = sp2[0];
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = s3;
-          s1 = sp2[1];
-          s2 = sp2[2];
-          s3 = sp2[3];
-          dp2[0] = (s0 << 8) | (s1 >> 24);
-          dp2[1] = s1;
-          dp2[2] = s2 >>  8;
-          dp2[3] = s3 >> 16;
-          sp2 += 3;
-        }
-    }
-
-    sp = (mlib_u8 *)sp2 + off;
-    dp = (mlib_u8 *)dp2;
-    while (dp < dend) {
-      *dp++ = sp[0];
-      if (dp < dend) *dp++ = sp[1];
-      sp += 3;
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_4_2(mlib_u8  *sl, mlib_s32 slb,
-                                       mlib_u8 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_u8   *sp = sl;
-  mlib_u8   *dp = dl;
-  mlib_u32  *sp2;
-  mlib_u16  *dp2;
-  mlib_u16  *d2end;
-  mlib_u32  s0, s1, s2, s3;
-  int       i, j, off, count_off;
-
-  for (j = 0; j < height; j++) {
-    mlib_u8  *dend  = dl + 2*width;
-
-    if (count1 == 1) {
-      if (dp < dend) *dp++ = sp[0];
-      sp += 3;
-    }
-
-    off = (mlib_addr)sp & 3;
-
-    if (((mlib_addr)dp & 1) || (off == 3)) {
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        dp[0] = sp[0];
-        dp[1] = sp[1];
-        sp += 4;
-      }
-      if (dp < dend) {
-        dp[0] = sp[0];
-      }
-      sp = sl += slb;
-      dp = dl += dlb;
-      continue;
-    }
-
-    dp2 = (mlib_u16*)dp;
-    d2end = (mlib_u16*)((mlib_addr)dend &~ 1);
-    sp2 = (mlib_u32 *)(sp - off);
-
-    switch (off) {
-
-      case 0:
-#pragma pipeloop(0)
-        for (; dp2 < d2end; dp2++) {
-          s0 = sp2[0];
-          dp2[0] = s0 >> 16;
-          sp2++;
-        }
-        break;
-
-      case 1:
-#pragma pipeloop(0)
-        for (; dp2 < d2end; dp2++) {
-          s0 = sp2[0];
-          dp2[0] = s0 >> 8;
-          sp2++;
-        }
-        break;
-
-      case 2:
-#pragma pipeloop(0)
-        for (; dp2 < d2end; dp2++) {
-          s0 = sp2[0];
-          dp2[0] = s0;
-          sp2++;
-        }
-        break;
-    }
-
-    sp = (mlib_u8 *)sp2 + off;
-    dp = (mlib_u8 *)dp2;
-    if (dp < dend) {
-      *dp++ = sp[0];
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_2_1(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_d64  *sp2;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[i];
-        dp[i] = d.f32s.f0;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[i];
-        dp[i] = d.f32s.f1;
-      }
-    }
-
-    sp += slb;
-    dp += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_3_1(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  d64_2_f32 d0;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + width;
-
-    if ((mlib_addr)sp & 7) {
-      dp[0] = sp[0];
-      sp += 3;
-      dp ++;
-    }
-
-    sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-    for (; dp <= (dend-2); dp += 2) {
-      d64_2_f32 d0, d1;
-      d0.d64 = sp2[0];
-      d1.d64 = sp2[1];
-      dp[0] = d0.f32s.f0;
-      dp[1] = d1.f32s.f1;
-      sp2 += 3;
-    }
-
-    if (dp < dend) {
-      d0.d64 = sp2[0];
-      dp[0] = d0.f32s.f0;
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_3_2(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  d64_2_f32 d0;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + 2*width;
-
-    if (count1 == 1) {
-      if (dp < dend) *dp++ = sp[0];
-      sp += 2;
-    }
-
-    if ((mlib_addr)sp & 7) {
-      if (dp < dend) *dp++ = sp[0];
-      if (dp < dend) *dp++ = sp[1];
-      sp += 3;
-    }
-
-    sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-    for (; dp <= (dend-4); dp += 4) {
-      d64_2_f32 d0, d1, d2;
-      d0.d64 = sp2[0];
-      d1.d64 = sp2[1];
-      d2.d64 = sp2[2];
-      dp[0] = d0.f32s.f0;
-      dp[1] = d0.f32s.f1;
-      dp[2] = d1.f32s.f1;
-      dp[3] = d2.f32s.f0;
-      sp2 += 3;
-    }
-
-    if (dp < dend) {
-      sp = (mlib_f32 *)sp2;
-      *dp++ = sp[0];
-      if (dp < dend) *dp++ = sp[1];
-      if (dp < dend) *dp++ = sp[3];
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_4_1(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_d64  *sp2;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[2*i];
-        dp[i] = d.f32s.f0;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[2*i];
-        dp[i] = d.f32s.f1;
-      }
-    }
-
-    sp += slb;
-    dp += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_4_2(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  int       i, j, off;
-  d64_2_f32 d0, d1;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + 2*width;
-
-    if (count1 == 1) {
-      dp[0] = sp[0];
-      sp += 3;
-      dp ++;
-    }
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        d64_2_f32 d;
-        d.d64 = sp2[0];
-        dp[0] = d.f32s.f0;
-        dp[1] = d.f32s.f1;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        dp[0] = d0.f32s.f0;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        d64_2_f32 d0, d1;
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        dp[0] = d0.f32s.f1;
-        dp[1] = d1.f32s.f0;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        dp[0] = d0.f32s.f1;
-      }
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_4_3(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  int       i, j, k;
-  d64_2_f32 d0, d1;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + 3*width;
-
-    for (k = 0; k < count1; k++) {
-      if (dp < dend) *dp++ = *sp++;
-    }
-    sp++;
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (; dp <= (dend-3); dp += 3) {
-        d64_2_f32 d0, d1;
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        dp[0] = d0.f32s.f0;
-        dp[1] = d0.f32s.f1;
-        dp[2] = d1.f32s.f0;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        *dp++ = d0.f32s.f0;
-        if (dp < dend) *dp++ = d0.f32s.f1;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (; dp <= (dend-3); dp += 3) {
-        d64_2_f32 d0, d1;
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        dp[0] = d0.f32s.f1;
-        dp[1] = d1.f32s.f0;
-        dp[2] = d1.f32s.f1;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        *dp++ = d0.f32s.f1;
-        if (dp < dend) *dp++ = d1.f32s.f0;
-      }
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-/* general channel extraction: slower due to the inner loop */
-
-void mlib_v_ImageChannelExtract_U8(mlib_u8  *src, mlib_s32 slb,
-                              mlib_u8  *dst, mlib_s32 dlb,
-                              mlib_s32 channels, mlib_s32 channeld,
-                              mlib_s32 width, mlib_s32 height,
-                              mlib_s32 cmask)
-{
-  mlib_u8   *sp;              /* pointer for pixel in src */
-  mlib_u8   *sl;              /* pointer for line in src  */
-  mlib_u8   *dp;              /* pointer for pixel in dst */
-  mlib_u8   *dl;              /* pointer for line in dst  */
-  int       i, j, k;          /* indices for x, y, channel */
-  int       deltac[5] = { 0, 1, 1, 1, 1 };
-  int       inc0, inc1, inc2, inc3;
-  mlib_u8   s0, s1, s2, s3;
-
-  deltac[channeld] = 1;
-  for (i = (channels - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channeld] = channels;
-  for (i = 1; i < channeld; i++) {
-    deltac[channeld] -= deltac[i];
-  }
-
-  sp = sl = src + deltac[0];
-  dp = dl = dst;
-
-/* Only THREE CHANNEL CASE could be executed here!!! */
-
-  inc0 = deltac[1];
-  inc1 = deltac[2] + inc0;
-  inc2 = deltac[3] + inc1;
-  for (j = 0; j < height; j++) {
-    for (i = 0; i < width; i++) {
-#pragma pipeloop(0)
-      s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
-      dp[0] = s0;
-      dp[1] = s1;
-      dp[2] = s2;
-      sp   += inc2;
-      dp   += 3;
-    }
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-/* general channel extraction: slower due to the inner loop */
-
-void mlib_v_ImageChannelExtract_S16(mlib_u16 *src,    mlib_s32 slb,
-                                    mlib_u16 *dst,    mlib_s32 dlb,
-                                    mlib_s32 channels, mlib_s32 channeld,
-                                    mlib_s32 width,    mlib_s32 height,
-                                    mlib_s32 cmask)
-{
-  mlib_u16   *sp;              /* pointer for pixel in src */
-  mlib_u16   *sl;              /* pointer for line in src  */
-  mlib_u16   *dp;              /* pointer for pixel in dst */
-  mlib_u16   *dl;              /* pointer for line in dst  */
-  int       i, j, k;          /* indices for x, y, channel */
-  int       deltac[5] = { 0, 1, 1, 1, 1 };
-  int       inc0, inc1, inc2, inc3;
-  mlib_u16   s0, s1, s2, s3;
-
-  slb >>= 1;
-  dlb >>= 1;
-
-  deltac[channeld] = 1;
-  for (i = (channels - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channeld] = channels;
-  for (i = 1; i < channeld; i++) {
-    deltac[channeld] -= deltac[i];
-  }
-
-  sp = sl = src + deltac[0];
-  dp = dl = dst;
-
-  if (channeld == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0]; s1 = sp[inc0];
-        dp[0] = s0;
-        dp[1] = s1;
-        sp   += inc1;
-        dp   += 2;
-      }
-      sp = sl = sl + slb;
-      dp = dl = dl + dlb;
-    }
-  } else
-
-  if (channeld == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-      for (i = 0; i < width; i++) {
-#pragma pipeloop(0)
-        s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
-        dp[0] = s0;
-        dp[1] = s1;
-        dp[2] = s2;
-        sp   += inc2;
-        dp   += 3;
-      }
-      sp = sl = sl + slb;
-      dp = dl = dl + dlb;
-    }
-  }}
-
-/***************************************************************/
-/* general channel extraction: slower due to the inner loop */
-
-void mlib_v_ImageChannelExtract_D64(mlib_d64 *src,    mlib_s32 slb,
-                                    mlib_d64 *dst,    mlib_s32 dlb,
-                                    mlib_s32 channels, mlib_s32 channeld,
-                                    mlib_s32 width,    mlib_s32 height,
-                                    mlib_s32 cmask)
-{
-  mlib_d64   *sp;              /* pointer for pixel in src */
-  mlib_d64   *sl;              /* pointer for line in src  */
-  mlib_d64   *dp;              /* pointer for pixel in dst */
-  mlib_d64   *dl;              /* pointer for line in dst  */
-  int        i, j, k;          /* indices for x, y, channel */
-  int        deltac[5] = { 0, 1, 1, 1, 1 };
-  int        inc0, inc1, inc2, inc3;
-  mlib_d64   s0, s1, s2, s3;
-
-  deltac[channeld] = 1;
-  for (i = (channels - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channeld] = channels;
-  for (i = 1; i < channeld; i++) {
-    deltac[channeld] -= deltac[i];
-  }
-
-  sp = sl = src + deltac[0];
-  dp = dl = dst;
-
-  if (channeld == 1) {
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        dp[i] = s0;
-        sp   += channels;
-      }
-      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-    }
-  } else
-
-  if (channeld == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0]; s1 = sp[inc0];
-        dp[0] = s0;
-        dp[1] = s1;
-        sp   += inc1;
-        dp   += 2;
-      }
-      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-    }
-  } else
-
-  if (channeld == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-      for (i = 0; i < width; i++) {
-#pragma pipeloop(0)
-        s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
-        dp[0] = s0;
-        dp[1] = s1;
-        dp[2] = s2;
-        sp   += inc2;
-        dp   += 3;
-      }
-      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-    }
-  }
-}
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c
deleted file mode 100644
index f9fbf93..0000000
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c
+++ /dev/null
@@ -1,715 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-
-/*
- * FUNCTIONS
- *      mlib_ImageChannelInsert   - Copy the source image into the selected
- *                                                        channels of the destination image
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageChannelInsert(mlib_image *dst,
- *                                                                        mlib_image *src,
- *                                                                      mlib_s32   cmask);
- *
- * ARGUMENT
- *  dst     Pointer to destination image.
- *  src     Pointer to source image.
- *  cmask   Destination channel selection mask.
- *              The least significant bit (LSB) is corresponding to the
- *              last channel in the destination image data.
- *              The bits with value 1 stand for the channels selected.
- *              If more than N channels are selected, the leftmost N
- *              channels are inserted, where N is the number of channels
- *              in the source image.
- *
- * RESTRICTION
- *              The src and dst must have the same width, height and data type.
- *              The src and dst can have 1, 2, 3 or 4 channels.
- *              The src and dst can be either MLIB_BYTE, MLIB_SHORT, MLIB_INT,
- *          MLIB_FLOAT or MLIB_DOUBLE.
- *
- * DESCRIPTION
- *          Copy the source image into the selected channels of the destination
- *              image
- */
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-/* functions defined in mlib_v_ImageChannelInsert_1.c */
-
-void
-mlib_v_ImageChannelInsert_U8(mlib_u8  *src,  mlib_s32 slb,
-                             mlib_u8  *dst,  mlib_s32 dlb,
-                             mlib_s32 channels,
-                             mlib_s32 channeld,
-                             mlib_s32 width,  mlib_s32 height,
-                             mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_D64(mlib_d64  *src,  mlib_s32 slb,
-                              mlib_d64  *dst,  mlib_s32 dlb,
-                              mlib_s32 channels,
-                              mlib_s32 channeld,
-                              mlib_s32 width,  mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16(mlib_s16 *src,  mlib_s32 slb,
-                              mlib_s16 *dst,  mlib_s32 dlb,
-                              mlib_s32 channels,
-                              mlib_s32 channeld,
-                              mlib_s32 width,  mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S32(mlib_s32 *src,  mlib_s32 slb,
-                              mlib_s32 *dst,  mlib_s32 dlb,
-                              mlib_s32 channels,
-                              mlib_s32 channeld,
-                              mlib_s32 width,  mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12_A8D1X8(mlib_u8  *src,
-                                                               mlib_u8  *dst,
-                                                         mlib_s32 dsize,
-                                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                               mlib_u8  *dst,  mlib_s32 dlb,
-                                                       mlib_s32 xsize, mlib_s32 ysize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12_D1(mlib_u8  *src,
-                                                           mlib_u8  *dst,
-                                                   mlib_s32 dsize,
-                                                           mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12(mlib_u8  *src,  mlib_s32 slb,
-                                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                                mlib_s32 xsize, mlib_s32 ysize,
-                                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13_A8D1X8(mlib_u8  *src,
-                                                               mlib_u8  *dst,
-                                                       mlib_s32 dsize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                               mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13_D1(mlib_u8  *src,
-                                                           mlib_u8  *dst,
-                                                     mlib_s32 dsize,
-                                                           mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13(mlib_u8  *src,  mlib_s32 slb,
-                                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                                  mlib_s32 xsize, mlib_s32 ysize,
-                                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14_A8D1X8(mlib_u8  *src,
-                                                               mlib_u8  *dst,
-                                                       mlib_s32 dsize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                               mlib_u8  *dst,  mlib_s32 dlb,
-                                                       mlib_s32 xsize, mlib_s32 ysize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14_D1(mlib_u8  *src,
-                                                           mlib_u8  *dst,
-                                                   mlib_s32 dsize,
-                                                           mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14(mlib_u8  *src,  mlib_s32 slb,
-                                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                                mlib_s32 xsize, mlib_s32 ysize,
-                                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12_A8D1X4(mlib_s16 *src,
-                                                                      mlib_s16 *dst,
-                                                        mlib_s32 dsize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                      mlib_s16 *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12_D1(mlib_s16 *src,
-                                                            mlib_s16 *dst,
-                                                    mlib_s32 dsize,
-                                                            mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12(mlib_s16 *src,  mlib_s32 slb,
-                                                        mlib_s16 *dst,  mlib_s32 dlb,
-                                                  mlib_s32 xsize, mlib_s32 ysize,
-                                                  mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13_A8D1X4(mlib_s16 *src,
-                                                                      mlib_s16 *dst,
-                                                        mlib_s32 dsize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                      mlib_s16 *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13_D1(mlib_s16 *src,
-                                                            mlib_s16 *dst,
-                                                    mlib_s32 dsize,
-                                                            mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13(mlib_s16 *src,  mlib_s32 slb,
-                                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                                 mlib_s32 xsize, mlib_s32 ysize,
-                                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14_A8D1X4(mlib_s16 *src,
-                                                                      mlib_s16 *dst,
-                                                          mlib_s32 dsize,
-                                                                      mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                      mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize,
-                                                                      mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14_D1(mlib_s16 *src,
-                                                            mlib_s16 *dst,
-                                                    mlib_s32 dsize,
-                                                            mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14(mlib_s16 *src,  mlib_s32 slb,
-                                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                                 mlib_s32 xsize, mlib_s32 ysize,
-                                                         mlib_s32 cmask);
-
-/***************************************************************/
-/* functions defined in mlib_v_ImageChannelInsert_34.c */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                                mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34R(mlib_u8  *src,  mlib_s32 slb,
-                                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34L(mlib_u8  *src,  mlib_s32 slb,
-                                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize);
-
-
-/***************************************************************/
-
-#ifdef MLIB_TEST
-mlib_status
-mlib_v_ImageChannelInsert(mlib_image *dst,
-                                            mlib_image *src,
-                                          mlib_s32   cmask)
-#else
-mlib_status
-mlib_ImageChannelInsert(mlib_image *dst,
-                                        mlib_image *src,
-                                        mlib_s32   cmask)
-#endif
-{
-  const mlib_s32  X8 = 0x7;
-  const mlib_s32  X4 = 0x3;
-  const mlib_s32  X2 = 0x1;
-  const mlib_s32  A8D1   = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_ONEDVECTOR;
-  const mlib_s32  A8D2X8 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH8X;
-  const mlib_s32  A8D2X4 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH4X;
-  const mlib_s32  A8D2X2 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH2X;
-
-  void      *sp;                      /* pointer for pixel in src */
-  void      *dp;                      /* pointer for pixel in dst */
-  mlib_s32  ncmask = 0;         /* normalized channel mask */
-  mlib_s32  channels;             /* number of channels for src */
-  mlib_s32  channeld;             /* number of channels for dst */
-  mlib_s32  width, height;/* for src and dst */
-  mlib_s32  strides;              /* strides in bytes for src */
-  mlib_s32  strided;            /* strides in bytes for dst */
-  mlib_s32  flags;
-  mlib_s32  flagd;
-  mlib_s32  dsize;
-  int         i, bit1count = 0;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_TYPE_EQUAL(src,dst);
-  MLIB_IMAGE_SIZE_EQUAL(src,dst);
-
-  channels = mlib_ImageGetChannels(src);
-  channeld = mlib_ImageGetChannels(dst);
-  width    = mlib_ImageGetWidth(src);
-  height   = mlib_ImageGetHeight(src);
-  strides  = mlib_ImageGetStride(src);
-  strided  = mlib_ImageGetStride(dst);
-  sp       = mlib_ImageGetData(src);
-  dp       = mlib_ImageGetData(dst);
-  flags    = mlib_ImageGetFlags(src);
-  flagd    = mlib_ImageGetFlags(dst);
-  dsize    = width * height;
-
-  /* normalize the cmask, and count the number of bit with value 1 */
-  for (i = (channeld - 1); i >= 0; i--) {
-    if (((cmask & (1 << i)) != 0) && (bit1count < channels)) {
-      ncmask += (1 << i);
-      bit1count++;
-    }
-  }
-
-  /* do not support the cases in which the number of selected channels is
-   * less than the nubmber of channels in the source image */
-  if (bit1count < channels) {
-    return MLIB_FAILURE;
-  }
-
-  if (((channels == 1) && (channeld == 1)) ||
-      ((channels == 2) && (channeld == 2)) ||
-      ((channels == 3) && (channeld == 3)) ||
-      ((channels == 4) && (channeld == 4))) {
-      return mlib_ImageCopy(dst, src);
-  }
-
-  switch (mlib_ImageGetType(src)) {
-    case MLIB_BYTE:
-      if (channels == 1) {
-        switch (channeld) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-                mlib_v_ImageChannelInsert_U8_12_A8D1X8((mlib_u8 *)sp,
-                                                                             (mlib_u8 *)dp,
-                                                                             dsize,
-                                                                                     ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-              ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelInsert_U8_12_A8D2X8((mlib_u8 *)sp, strides,
-                                                                             (mlib_u8 *)dp, strided,
-                                                                             width, height,
-                                                                                     ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_U8_12_D1((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                 ncmask);
-            }
-            else {
-                mlib_v_ImageChannelInsert_U8_12((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height,
-                                                                              ncmask);
-            }
-            break;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-                mlib_v_ImageChannelInsert_U8_13_A8D1X8((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                               dsize,
-                                                                                           ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-              ((flagd & A8D2X8) == 0)) {
-                mlib_v_ImageChannelInsert_U8_13_A8D2X8((mlib_u8 *)sp, strides,
-                                                                                     (mlib_u8 *)dp, strided,
-                                                                             width, height,
-                                                                                     ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_U8_13_D1((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                 ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_U8_13((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height,
-                                                                      ncmask);
-            }
-            break;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-                  mlib_v_ImageChannelInsert_U8_14_A8D1X8((mlib_u8 *)sp,
-                                                                                   (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                             ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-               ((flagd & A8D2X8) == 0)) {
-               mlib_v_ImageChannelInsert_U8_14_A8D2X8((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                              width, height,
-                                                                                          ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-              ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_U8_14_D1((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                 ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_U8_14((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height,
-                                                                      ncmask);
-            }
-            break;
-
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else {
-        if ((channels == 3) && (channeld == 4) && (ncmask == 7)) {
-          if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-            mlib_v_ImageChannelInsert_U8_34R_A8D1X8((mlib_u8 *)sp,
-                                                                          (mlib_u8 *)dp,
-                                                                          dsize);
-          }
-        else if (((flags & A8D2X8) == 0) &&
-               ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelInsert_U8_34R_A8D2X8((mlib_u8 *)sp, strides,
-                                                                                    (mlib_u8 *)dp, strided,
-                                                                              width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelInsert_U8_34R_D1((mlib_u8 *)sp,
-                                                                          (mlib_u8 *)dp,
-                                                                          dsize);
-        }
-        else {
-              mlib_v_ImageChannelInsert_U8_34R((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height);
-        }
-      }
-      else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-            mlib_v_ImageChannelInsert_U8_34L_A8D1X8((mlib_u8 *)sp,
-                                                                            (mlib_u8 *)dp,
-                                                                          dsize);
-              }
-        else if (((flags & A8D2X8) == 0) &&
-                 ((flagd & A8D2X8) == 0)) {
-                 mlib_v_ImageChannelInsert_U8_34L_A8D2X8((mlib_u8 *)sp, strides,
-                                                                                  (mlib_u8 *)dp, strided,
-                                                                          width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                 mlib_v_ImageChannelInsert_U8_34L_D1((mlib_u8 *)sp,
-                                                                      (mlib_u8 *)dp,
-                                                                      dsize);
-        }
-        else mlib_v_ImageChannelInsert_U8_34L((mlib_u8 *)sp, strides,
-                                                                   (mlib_u8 *)dp, strided,
-                                                                   width, height);
-        }
-      else {
-
-      mlib_v_ImageChannelInsert_U8((mlib_u8 *)sp, strides,
-                                                     (mlib_u8 *)dp, strided,
-                                                     channels, channeld,
-                                                     width, height,
-                                                     ncmask);
-      }
-  }
-  break;
-
-    case MLIB_SHORT:
-      if (channels == 1) {
-        switch (channeld) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelInsert_S16_12_A8D1X4((mlib_s16 *)sp,
-                                                                                    (mlib_s16 *)dp,
-                                                                                      dsize,
-                                                                                      ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-               ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelInsert_S16_12_A8D2X4((mlib_s16 *)sp, strides,
-                                                                              (mlib_s16 *)dp, strided,
-                                                                              width, height,
-                                                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-             mlib_v_ImageChannelInsert_S16_12_D1((mlib_s16 *)sp,
-                                                                           (mlib_s16 *)dp,
-                                                                          dsize,
-                                                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_S16_12((mlib_s16 *)sp, strides,
-                                                                       (mlib_s16 *)dp, strided,
-                                                                       width, height,
-                                                                       ncmask);
-            }
-            break;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelInsert_S16_13_A8D1X4((mlib_s16 *)sp,
-                                                                              (mlib_s16 *)dp,
-                                                                                      dsize,
-                                                                                      ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-               ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelInsert_S16_13_A8D2X4((mlib_s16 *)sp, strides,
-                                                                              (mlib_s16 *)dp, strided,
-                                                                              width, height,
-                                                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_S16_13_D1((mlib_s16 *)sp,
-                                                                                  (mlib_s16 *)dp,
-                                                                                  dsize,
-                                                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_S16_13((mlib_s16 *)sp, strides,
-                                                                       (mlib_s16 *)dp, strided,
-                                                                       width, height,
-                                                                       ncmask);
-            }
-            break;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelInsert_S16_14_A8D1X4((mlib_s16 *)sp,
-                                                                                    (mlib_s16 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-               ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelInsert_S16_14_A8D2X4((mlib_s16 *)sp, strides,
-                                                                              (mlib_s16 *)dp, strided,
-                                                                              width, height,
-                                                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelInsert_S16_14_D1((mlib_s16 *)sp,
-                                                                          (mlib_s16 *)dp,
-                                                                          dsize,
-                                                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_S16_14((mlib_s16 *)sp, strides,
-                                                                       (mlib_s16 *)dp, strided,
-                                                                       width, height,
-                                                                       ncmask);
-            }
-            break;
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else if ((channels == 3) && (channeld == 4) && (ncmask == 7)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelInsert_S16_34R_A8D1X4((mlib_s16 *)sp,
-                                                                           (mlib_s16 *)dp,
-                                                                           dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-           ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34R_A8D2X4((mlib_s16 *)sp, strides,
-                                                                           (mlib_s16 *)dp, strided,
-                                                                           width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-           ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34R_D1((mlib_s16 *)sp,
-                                                                       (mlib_s16 *)dp,
-                                                                       dsize);
-        }
-        else {
-          mlib_v_ImageChannelInsert_S16_34R((mlib_s16 *)sp, strides,
-                                                                    (mlib_s16 *)dp, strided,
-                                                                     width, height);
-        }
-      }
-      else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelInsert_S16_34L_A8D1X4((mlib_s16 *)sp,
-                                                                           (mlib_s16 *)dp,
-                                                                           dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-           ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34L_A8D2X4((mlib_s16 *)sp, strides,
-                                                                           (mlib_s16 *)dp, strided,
-                                                                           width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-           ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34L_D1((mlib_s16 *)sp,
-                                                                       (mlib_s16 *)dp,
-                                                                       dsize);
-        }
-        else {
-          mlib_v_ImageChannelInsert_S16_34L((mlib_s16 *)sp, strides,
-                                                                    (mlib_s16 *)dp, strided,
-                                                                    width, height);
-        }
-      }
-      else {
-        mlib_v_ImageChannelInsert_S16((mlib_s16 *)sp, strides,
-                                                              (mlib_s16 *)dp, strided,
-                                                              channels,  channeld,
-                                                              width, height,
-                                                              ncmask);
-      }
-      break;
-
-    case MLIB_INT:
-        mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides,
-                                      (mlib_s32 *)dp, strided,
-                                      channels, channeld,
-                                      width, height,
-                                      ncmask);
-        break;
-
-    case MLIB_FLOAT:
-        mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides,
-                                      (mlib_s32 *)dp, strided,
-                                      channels, channeld,
-                                      width, height,
-                                      ncmask);
-        break;
-
-
-    case MLIB_DOUBLE:
-        mlib_v_ImageChannelInsert_D64((mlib_d64 *)sp, strides,
-                                      (mlib_d64 *)dp, strided,
-                                      channels, channeld,
-                                      width, height,
-                                      ncmask);
-        break;
-
-
-    case MLIB_BIT:
-    default:
-        return MLIB_FAILURE;    /* MLIB_BIT is not supported here */
-  }
-
-  return MLIB_SUCCESS;
-}
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h
index ff3c228..e684015 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h
@@ -32,290 +32,21 @@
 extern "C" {
 #endif /* __cplusplus */
 
-void mlib_v_ImageChannelInsert_U8(const mlib_u8 *src,
-                                  mlib_s32      slb,
-                                  mlib_u8       *dst,
-                                  mlib_s32      dlb,
-                                  mlib_s32      channels,
-                                  mlib_s32      channeld,
-                                  mlib_s32      width,
-                                  mlib_s32      height,
-                                  mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_D64(const mlib_d64 *src,
-                                   mlib_s32       slb,
-                                   mlib_d64       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16(const mlib_s16 *src,
-                                   mlib_s32       slb,
-                                   mlib_s16       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S32(const mlib_s32 *src,
-                                   mlib_s32       slb,
-                                   mlib_s32       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_U8_12_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_12_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask);
-
 void mlib_v_ImageChannelInsert_U8_12_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
                                         mlib_s32      cmask);
 
-void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_13_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_13_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask);
-
 void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
                                         mlib_s32      cmask);
 
-void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_14_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_14_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask);
-
 void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
                                         mlib_s32      cmask);
 
-void mlib_v_ImageChannelInsert_U8_14(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_S16_12_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_12_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_12_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_12(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_U8_34R_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34R_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_U8_34R_D1(const mlib_u8 *src,
-                                         mlib_u8       *dst,
-                                         mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34R(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_S16_34R_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34R_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize);
-
-void mlib_v_ImageChannelInsert_S16_34R_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34R(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize);
-
-void mlib_v_ImageChannelInsert_U8_34L_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34L_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_U8_34L_D1(const mlib_u8 *src,
-                                         mlib_u8       *dst,
-                                         mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34L(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_S16_34L_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34L_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize);
-
-void mlib_v_ImageChannelInsert_S16_34L_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34L(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c
index ae0abf0..b5dcf5e 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c
@@ -27,34 +27,9 @@
 
 /*
  * FUNCTIONS
- *      mlib_v_ImageChannelInsert_U8
- *      mlib_v_ImageChannelInsert_U8_12_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_12_A8D2X8
  *      mlib_v_ImageChannelInsert_U8_12_D1
- *      mlib_v_ImageChannelInsert_U8_12
- *      mlib_v_ImageChannelInsert_U8_13_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_13_A8D2X8
  *      mlib_v_ImageChannelInsert_U8_13_D1
- *      mlib_v_ImageChannelInsert_U8_13
- *      mlib_v_ImageChannelInsert_U8_14_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_14_A8D2X8
  *      mlib_v_ImageChannelInsert_U8_14_D1
- *      mlib_v_ImageChannelInsert_U8_14
- *      mlib_v_ImageChannelInsert_S16
- *      mlib_v_ImageChannelInsert_S16_12_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_12_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_12_D1
- *      mlib_v_ImageChannelInsert_S16_12
- *      mlib_v_ImageChannelInsert_S16_13_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_13_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_13_D1
- *      mlib_v_ImageChannelInsert_S16_13
- *      mlib_v_ImageChannelInsert_S16_14_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_14_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_14_D1
- *      mlib_v_ImageChannelInsert_S16_14
- *      mlib_v_ImageChannelInsert_S32
- *      mlib_v_ImageChannelInsert_D64
  *
  * ARGUMENT
  *      src     pointer to source image data
@@ -80,424 +55,12 @@
 #include "mlib_v_ImageChannelInsert.h"
 
 /***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-void mlib_v_ImageChannelInsert_U8(const mlib_u8 *src,
-                                  mlib_s32      slb,
-                                  mlib_u8       *dst,
-                                  mlib_s32      dlb,
-                                  mlib_s32      channels,
-                                  mlib_s32      channeld,
-                                  mlib_s32      width,
-                                  mlib_s32      height,
-                                  mlib_s32      cmask)
-{
-  mlib_u8 *sp;                                        /* pointer for pixel in src */
-  mlib_u8 *sl;                                        /* pointer for line in src */
-  mlib_u8 *dp;                                        /* pointer for pixel in dst */
-  mlib_u8 *dl;                                        /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_u8 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl += slb;
-      dp = dl += dlb;
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl += slb;
-      dp = dl += dlb;
-    }
-  }
-}
-
-/***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-void mlib_v_ImageChannelInsert_D64(const mlib_d64 *src,
-                                   mlib_s32       slb,
-                                   mlib_d64       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask)
-{
-  mlib_d64 *sp;                                       /* pointer for pixel in src */
-  mlib_d64 *sl;                                       /* pointer for line in src */
-  mlib_d64 *dp;                                       /* pointer for pixel in dst */
-  mlib_d64 *dl;                                       /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_d64 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 1) {
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        dp[0] = s0;
-        dp += channeld;
-        sp++;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-void mlib_v_ImageChannelInsert_S16(const mlib_s16 *src,
-                                   mlib_s32       slb,
-                                   mlib_s16       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask)
-{
-  mlib_s16 *sp;                                       /* pointer for pixel in src */
-  mlib_s16 *sl;                                       /* pointer for line in src */
-  mlib_s16 *dp;                                       /* pointer for pixel in dst */
-  mlib_s16 *dl;                                       /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_s16 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-
-void mlib_v_ImageChannelInsert_S32(const mlib_s32 *src,
-                                   mlib_s32       slb,
-                                   mlib_s32       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask)
-{
-  mlib_s32 *sp;                                       /* pointer for pixel in src */
-  mlib_s32 *sl;                                       /* pointer for line in src */
-  mlib_s32 *dp;                                       /* pointer for pixel in dst */
-  mlib_s32 *dl;                                       /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_s32 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 1) {
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        dp[0] = s0;
-        dp += channeld;
-        sp++;
-      }
-
-      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
 #define INSERT_U8_12(sd0, dd0, dd1)     /* channel duplicate */ \
   dd0 = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
   dd1 = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0))
 
 /***************************************************************/
 /* insert one channel to a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelInsert_U8_12_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0;
-  mlib_d64 dd0, dd1;
-  mlib_s32 bmask;
-  mlib_s32 i;
-
-  bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6);
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    sd0 = *sp++;
-    INSERT_U8_12(sd0, dd0, dd1);
-    vis_pst_8(dd0, dp++, bmask);
-    vis_pst_8(dd1, dp++, bmask);
-  }
-}
-
-/***************************************************************/
-/* insert one channel to a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelInsert_U8_12_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0;
-  mlib_d64 dd0, dd1;
-  mlib_s32 bmask;
-  mlib_s32 i, j;
-
-  bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6);
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      sd0 = *sp++;
-      INSERT_U8_12(sd0, dd0, dd1);
-      vis_pst_8(dd0, dp++, bmask);
-      vis_pst_8(dd1, dp++, bmask);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/* insert one channel to a 2-channel image.
  */
 
 void mlib_v_ImageChannelInsert_U8_12_D1(const mlib_u8 *src,
@@ -724,56 +287,6 @@
 }
 
 /***************************************************************/
-/* insert one channel to a 2-channel image.
- */
-
-void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_12_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define INSERT_U8_13(sd0, dd0, dd1, dd2)                        \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd0));        \
-  sdb = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sda));        \
-  sdc = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb));        \
-  sdd = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb));        \
-  dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_hi(sdd));        \
-  sde = vis_fpmerge(vis_read_lo(sdc), vis_read_lo(sdd));        \
-  dd1 = vis_freg_pair(vis_read_lo(dd0), vis_read_hi(sde));      \
-  dd2 = vis_freg_pair(vis_read_lo(sde), vis_read_lo(sde))
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_U8_A8(channeld)                       \
-  sd = *sp++;                                                   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld
-
-/***************************************************************/
 #define LOAD_INSERT_STORE_U8(channeld)                          \
   vis_alignaddr((void *)0, off);                                \
   sd0 = sd1;                                                    \
@@ -790,58 +303,6 @@
   vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld
 
 /***************************************************************/
-void mlib_v_ImageChannelInsert_U8_13_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask)
-{
-  mlib_u8 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  vis_alignaddr((void *)0, 1);              /* for 1-byte left shift */
-
-  sp = (mlib_d64 *) src;
-  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_INSERT_STORE_U8_A8(3);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_U8_13_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask)
-{
-  mlib_u8 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  vis_alignaddr((void *)0, 1);
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (2 / cmask);              /* 4,2,1 -> 0,1,2 */
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_INSERT_STORE_U8_A8(3);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_u8 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
@@ -908,30 +369,6 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_13_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define INSERT_U8_14(sd0, dd0, dd1, dd2, dd3)                   \
   sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
   sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0));        \
@@ -941,73 +378,6 @@
   dd3 = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb))
 
 /***************************************************************/
-void mlib_v_ImageChannelInsert_U8_14_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0;
-  mlib_d64 sda, sdb;
-  mlib_d64 dd0, dd1, dd2, dd3;
-  mlib_s32 bmask;
-  mlib_s32 i;
-
-  bmask = cmask | (cmask << 4);
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    sd0 = *sp++;
-    INSERT_U8_14(sd0, dd0, dd1, dd2, dd3);
-    vis_pst_8(dd0, dp++, bmask);
-    vis_pst_8(dd1, dp++, bmask);
-    vis_pst_8(dd2, dp++, bmask);
-    vis_pst_8(dd3, dp++, bmask);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_U8_14_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0;
-  mlib_d64 sda, sdb;
-  mlib_d64 dd0, dd1, dd2, dd3;
-  mlib_s32 bmask;
-  mlib_s32 i, j;
-
-  bmask = cmask | (cmask << 4);
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      sd0 = *sp++;
-      INSERT_U8_14(sd0, dd0, dd1, dd2, dd3);
-      vis_pst_8(dd0, dp++, bmask);
-      vis_pst_8(dd1, dp++, bmask);
-      vis_pst_8(dd2, dp++, bmask);
-      vis_pst_8(dd3, dp++, bmask);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
@@ -1188,445 +558,5 @@
   }
 }
 
-/***************************************************************/
-void mlib_v_ImageChannelInsert_U8_14(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_14_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_1X_A8(channeld)                   \
-  sd  = *sp++;                                                  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_1X(channeld)                      \
-  vis_alignaddr((void *)0, off);                                \
-  sd0 = sd1;                                                    \
-  sd1 = *sp++;                                                  \
-  sd  = vis_faligndata(sd0, sd1);                               \
-  vis_alignaddr((void *)0, 2);                                  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  da = dst + (2 - cmask);                   /* 2,1 -> 0,1 */
-
-  vis_alignaddr((void *)0, 2);
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X_A8(2);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (2 - cmask);              /* 2,1 -> 0,1 */
-
-  vis_alignaddr((void *)0, 2);
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_1X_A8(2);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend;                                     /* end point in destination */
-  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
-  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
-  mlib_s32 off;                                       /* offset of address alignment in src */
-  mlib_s32 i;
-
-  sa = (void *)src;
-  da = dst + (2 - cmask);                   /* 2,1 -> 0,1 */
-
-  /* prepare the src address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  off = (mlib_addr) sa & 7;
-
-  dend = da + dsize * 2 - 1;
-
-  sd1 = *sp++;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X(2);
-  }
-
-  /* right end handling */
-  if ((mlib_addr) da <= (mlib_addr) dend) {
-
-    vis_alignaddr((void *)0, off);
-    sd0 = sd1;
-    sd1 = *sp++;
-    sd = vis_faligndata(sd0, sd1);
-
-    vis_alignaddr((void *)0, 2);
-    vis_st_u16(sd = vis_faligndata(sd, sd), da);
-    da += 2;
-    if ((mlib_addr) da <= (mlib_addr) dend) {
-      vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      da += 2;
-      if ((mlib_addr) da <= (mlib_addr) dend) {
-        vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_12_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
-
-  vis_alignaddr((void *)0, 2);
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X_A8(3);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (2 / cmask);              /* 4,2,1 -> 0,1,2 */
-
-  vis_alignaddr((void *)0, 2);
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_1X_A8(3);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend;                                     /* end point in destination */
-  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
-  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
-  mlib_s32 off;                                       /* offset of address alignment in src */
-  mlib_s32 i;
-
-  sa = (void *)src;
-  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
-
-  /* prepare the src address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  off = (mlib_addr) sa & 7;
-
-  dend = da + dsize * 3 - 1;
-
-  sd1 = *sp++;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X(3);
-  }
-
-  /* right end handling */
-  if ((mlib_addr) da <= (mlib_addr) dend) {
-
-    vis_alignaddr((void *)0, off);
-    sd0 = sd1;
-    sd1 = *sp++;
-    sd = vis_faligndata(sd0, sd1);
-
-    vis_alignaddr((void *)0, 2);
-    vis_st_u16(sd = vis_faligndata(sd, sd), da);
-    da += 3;
-    if ((mlib_addr) da <= (mlib_addr) dend) {
-      vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      da += 3;
-      if ((mlib_addr) da <= (mlib_addr) dend) {
-        vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_13_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define INSERT_S16_14(sp, dp, bmask)    /* channel duplicate */ \
-  /* obsolete: it is slower than the vis_st_u16() version*/     \
-  sd0 = *sp++;                                                  \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sda));        \
-  sdd = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sda));        \
-  sde = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb));        \
-  sdf = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb));        \
-  dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc));        \
-  dd1 = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sdd));        \
-  dd2 = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sde));        \
-  dd3 = vis_fpmerge(vis_read_hi(sdf), vis_read_lo(sdf));        \
-  vis_pst_16(dd0, dp++, bmask);                                 \
-  vis_pst_16(dd1, dp++, bmask);                                 \
-  vis_pst_16(dd2, dp++, bmask);                                 \
-  vis_pst_16(dd3, dp++, bmask)
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  da = dst + (6 / cmask + 1) / 2;           /* 8,4,2,1 -> 0,1,2,3 */
-
-  vis_alignaddr((void *)0, 2);
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X_A8(4);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (6 / cmask + 1) / 2;      /* 8,4,2,1 -> 0,1,2,3 */
-
-  vis_alignaddr((void *)0, 2);
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_1X_A8(4);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend;                                     /* end point in destination */
-  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
-  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
-  mlib_s32 off;                                       /* offset of address alignment in src */
-  mlib_s32 i;
-
-  sa = (void *)src;
-  da = dst + (6 / cmask + 1) / 2;           /* 8,4,2,1 -> 0,1,2,3 */
-
-  /* prepare the src address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  off = (mlib_addr) sa & 7;
-
-  dend = da + dsize * 4 - 1;
-
-  sd1 = *sp++;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X(4);
-  }
-
-  /* right end handling */
-  if ((mlib_addr) da <= (mlib_addr) dend) {
-
-    vis_alignaddr((void *)0, off);
-    sd0 = sd1;
-    sd1 = *sp++;
-    sd = vis_faligndata(sd0, sd1);
-
-    vis_alignaddr((void *)0, 2);
-    vis_st_u16(sd = vis_faligndata(sd, sd), da);
-    da += 4;
-    if ((mlib_addr) da <= (mlib_addr) dend) {
-      vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      da += 4;
-      if ((mlib_addr) da <= (mlib_addr) dend) {
-        vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_14_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
 
 /***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c
deleted file mode 100644
index 105409a..0000000
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-/*
- * FILENAME: mlib_v_ImageChannelInsert_34.c
- *
- * FUNCTIONS
- *      mlib_v_ImageChannelInsert_U8_34R_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_34R_A8D2X8
- *      mlib_v_ImageChannelInsert_U8_34R_D1
- *      mlib_v_ImageChannelInsert_U8_34R
- *      mlib_v_ImageChannelInsert_S16_34R_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_34R_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_34R_D1
- *      mlib_v_ImageChannelInsert_S16_34R
- *      mlib_v_ImageChannelInsert_U8_34L_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_34L_A8D2X8
- *      mlib_v_ImageChannelInsert_U8_34L_D1
- *      mlib_v_ImageChannelInsert_U8_34L
- *      mlib_v_ImageChannelInsert_S16_34L_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_34L_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_34L_D1
- *      mlib_v_ImageChannelInsert_S16_34L
- *
- * SYNOPSIS
- *
- * ARGUMENT
- *      src       pointer to source image data
- *      dst       pointer to destination image data
- *          slb   source image line stride in bytes
- *          dlb   destination image line stride in bytes
- *          dsize       image data size in pixels
- *          xsize       image width in pixels
- *          ysize       image height in lines
- *          cmask channel mask
- *
- * DESCRIPTION
- *          Insert a 3-channel image into the right or left 3 channels of
- *          a 4-channel image low level functions.
- *
- *                BGR => ABGR   (34R), or       RGB => RGBA     (34L)
- *
- * NOTE
- *          These functions are separated from mlib_v_ImageChannelInsert.c
- *          for loop unrolling and structure clarity.
- */
-
-#include <stdlib.h>
-#include "vis_proto.h"
-#include "mlib_image.h"
-
-/***************************************************************/
-#define INSERT_U8_34R                                                                         \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));                    \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));                    \
-  sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));                    \
-  sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));                    \
-  sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc));                    \
-  sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc));                    \
-  sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde));                    \
-  sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf));                    \
-  sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf));                    \
-  sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi));                    \
-  sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi));                    \
-  sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh));                    \
-  sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh));                    \
-  dd0 = vis_fpmerge(vis_read_hi(sdl), vis_read_hi(sdj));                    \
-  dd1 = vis_fpmerge(vis_read_lo(sdl), vis_read_lo(sdj));                    \
-  dd2 = vis_fpmerge(vis_read_hi(sdm), vis_read_hi(sdk));                    \
-  dd3 = vis_fpmerge(vis_read_lo(sdm), vis_read_lo(sdk));
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_U8_34R_A8                                                         \
-  sd0 = *sp++;                                  /* b0g0r0b1g1r1b2g2 */                  \
-  sd1 = *sp++;                                  /* r2b3g3r3b4g4r4b5 */                  \
-  sd2 = *sp++;                                  /* g5r5b6g6r6b7g7r7 */                  \
-  INSERT_U8_34R                                                                                           \
-  vis_pst_8(dd0, dp++, bmask);                                                                \
-  vis_pst_8(dd1, dp++, bmask);                                                                \
-  vis_pst_8(dd2, dp++, bmask);                                                                \
-  vis_pst_8(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_U8_34R                                                                      \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                                  \
-  INSERT_U8_34R
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;
-  mlib_d64  sd0, sd1, sd2;          /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int       bmask = 0x77;
-  int       i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_INSERT_STORE_U8_34R_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                                mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;             /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;             /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int         bmask = 0x77;
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_INSERT_STORE_U8_34R_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                  /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                  /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                  /* the last datum of the last step */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int       soff;                 /* offset of address in src */
-  int       doff;                 /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int         bmask;            /* channel mask */
-  int         i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 31;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set band mask for vis_pst_8 to store the bytes needed */
-  bmask = 0xff & (0x7777 >> doff) ;
-
-  /* generate edge mask for the start point */
-  emask = vis_edge8(da, dend);
-
-  /* load 24 bytes, convert to 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_U8_34R;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 8 ) {
-      vis_pst_8(dd0, dp++, emask & bmask);
-      vis_pst_8(dd1, dp++, bmask);
-      vis_pst_8(dd2, dp++, bmask);
-      vis_pst_8(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34R;
-        vis_pst_8(dd0, dp++, bmask);
-        vis_pst_8(dd1, dp++, bmask);
-        vis_pst_8(dd2, dp++, bmask);
-        vis_pst_8(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34R;
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 8 ) {
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-            if ((mlib_addr) dp <= (mlib_addr) dend)  {
-              emask = vis_edge8(dp, dend);
-              vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask);
-            }
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34R;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34R;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelInsert_U8_34R(mlib_u8  *src,  mlib_s32 slb,
-                                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *sl, *dl;
-  int         j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_34R_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define INSERT_S16_34R                                                                              \
-  vis_alignaddr((void *)0, 6);                                                                \
-  dd0 = vis_faligndata(sd0, sd0);                 /* b1b0g0r0 */                \
-  vis_alignaddr((void *)0, 4);                                                                \
-  dd1 = vis_faligndata(sd0, sd1);                 /* r0b1gbr1 */                \
-  vis_alignaddr((void *)0, 2);                                                                \
-  dd2 = vis_faligndata(sd1, sd2);                       /* r1b2g2r2 */          \
-  dd3 = sd2;                                                          /* r2b3g3r3 */
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_34R_A8                                                      \
-  sd0 = *sp++;                                          /* b0g0r0b1 */                      \
-  sd1 = *sp++;                                          /* g1r1b2g2 */                      \
-  sd2 = *sp++;                                          /* r2b3g3r3 */                      \
-  INSERT_S16_34R                                                                                          \
-  vis_pst_16(dd0, dp++, bmask);                                                               \
-  vis_pst_16(dd1, dp++, bmask);                                                               \
-  vis_pst_16(dd2, dp++, bmask);                                                               \
-  vis_pst_16(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_S16_34R                                                                       \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                                               \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                                                                \
-  INSERT_S16_34R
-
-/***************************************************************/
-/*
- * both source and destination image data are 1-d vectors and
- * 8-byte aligned.  dsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x07;       /* channel mask */
-  int       i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-  /* vis_alignaddr((void *)0, 2); */            /* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_34R_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned.  xsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x07;       /* channel mask */
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_34R_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize)
-{
-  mlib_s16  *sa, *da;           /* pointer for pixel */
-  mlib_s16  *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                /* the last datum of the last step */
-  int soff;             /* offset of address in src */
-  int doff;             /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int       bmask;              /* channel mask */
-  int       i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 15;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set channel mask for vis_pst_16 to store the words needed */
-  bmask = 0xff & (0x77 >> (doff / 2));
-
-  /* generate edge mask for the start point */
-  emask = vis_edge16(da, dend);
-
-  /* load 24 byte, convert, store 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_S16_34R;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 4 ) {
-      vis_pst_16(dd0, dp++, emask & bmask);
-      vis_pst_16(dd1, dp++, bmask);
-      vis_pst_16(dd2, dp++, bmask);
-      vis_pst_16(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34R;
-        vis_pst_16(dd0, dp++, bmask);
-        vis_pst_16(dd1, dp++, bmask);
-        vis_pst_16(dd2, dp++, bmask);
-        vis_pst_16(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34R;
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 4 ) {
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34R;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34R;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_s16  *sa, *da;
-  mlib_s16  *sl, *dl;
-  int       j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_34R_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb);
-    da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define INSERT_U8_34L                                                                                 \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));                    \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));                    \
-  sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));                    \
-  sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));                    \
-  sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc));                    \
-  sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc));                    \
-  sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde));                    \
-  sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf));                    \
-  sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf));                    \
-  sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi));                    \
-  sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi));                    \
-  sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh));                    \
-  sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh));                    \
-  dd0 = vis_fpmerge(vis_read_hi(sdj), vis_read_hi(sdl));                    \
-  dd1 = vis_fpmerge(vis_read_lo(sdj), vis_read_lo(sdl));                    \
-  dd2 = vis_fpmerge(vis_read_hi(sdk), vis_read_hi(sdm));                    \
-  dd3 = vis_fpmerge(vis_read_lo(sdk), vis_read_lo(sdm));
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_U8_34L_A8                                                         \
-  sd0 = *sp++;                                  /* b0g0r0b1g1r1b2g2 */                  \
-  sd1 = *sp++;                                  /* r2b3g3r3b4g4r4b5 */                  \
-  sd2 = *sp++;                                  /* g5r5b6g6r6b7g7r7 */                  \
-  INSERT_U8_34L                                                                                                       \
-  vis_pst_8(dd0, dp++, bmask);                                                                \
-  vis_pst_8(dd1, dp++, bmask);                                                                \
-  vis_pst_8(dd2, dp++, bmask);                                                                \
-  vis_pst_8(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_U8_34L                                                                        \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                    \
-  INSERT_U8_34L
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;
-  mlib_d64  sd0, sd1, sd2;          /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int         bmask = 0xee;
-  int         i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_INSERT_STORE_U8_34L_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int         bmask = 0xee;
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_INSERT_STORE_U8_34L_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-void
-mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                /* the last datum of the last step */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int       soff;               /* offset of address in src */
-  int       doff;               /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int         bmask;            /* channel mask */
-  int         i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 31;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set band mask for vis_pst_8 to store the bytes needed */
-  bmask = 0xff & (0xeeee >> doff) ;
-
-  /* generate edge mask for the start point */
-  emask = vis_edge8(da, dend);
-
-  /* load 24 bytes, convert to 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_U8_34L;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 8 ) {
-      vis_pst_8(dd0, dp++, emask & bmask);
-      vis_pst_8(dd1, dp++, bmask);
-      vis_pst_8(dd2, dp++, bmask);
-      vis_pst_8(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34L;
-        vis_pst_8(dd0, dp++, bmask);
-        vis_pst_8(dd1, dp++, bmask);
-        vis_pst_8(dd2, dp++, bmask);
-        vis_pst_8(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34L;
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 8 ) {
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-            if ((mlib_addr) dp <= (mlib_addr) dend)  {
-              emask = vis_edge8(dp, dend);
-              vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask);
-            }
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34L;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34L;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void
-mlib_v_ImageChannelInsert_U8_34L(mlib_u8  *src,  mlib_s32 slb,
-                                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *sl, *dl;
-  int         j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_34L_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define INSERT_S16_34L                                                                              \
-  dd0 = sd0;                                                            /* b0g0r0b1 */        \
-  vis_alignaddr((void *)0, 6);                                                                \
-  dd1 = vis_faligndata(sd0, sd1);                       /* b1gbr1b2 */        \
-  vis_alignaddr((void *)0, 4);                                                                \
-  dd2 = vis_faligndata(sd1, sd2);                         /* b2g2r2b3 */              \
-  vis_alignaddr((void *)0, 2);                                                                \
-  dd3 = vis_faligndata(sd2, sd2);                         /* b3g3r3r2 */
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_34L_A8                                                      \
-  sd0 = *sp++;                                          /* b0g0r0b1 */                          \
-  sd1 = *sp++;                                          /* g1r1b2g2 */                      \
-  sd2 = *sp++;                                          /* r2b3g3r3 */                      \
-  INSERT_S16_34L                                                                                          \
-  vis_pst_16(dd0, dp++, bmask);                                                               \
-  vis_pst_16(dd1, dp++, bmask);                                                               \
-  vis_pst_16(dd2, dp++, bmask);                                                               \
-  vis_pst_16(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_S16_34L                                                                       \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                                               \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                                                                \
-  INSERT_S16_34L
-
-/***************************************************************/
-/*
- * both source and destination image data are 1-d vectors and
- * 8-byte aligned.  dsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x0e;       /* channel mask */
-  int       i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_34L_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned.  xsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x0e;       /* channel mask */
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_34L_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize)
-{
-  mlib_s16  *sa, *da;           /* pointer for pixel */
-  mlib_s16  *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                /* the last datum of the last step */
-  int soff;             /* offset of address in src */
-  int doff;             /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int       bmask;              /* channel mask */
-  int       i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 15;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set channel mask for vis_pst_16 to store the words needed */
-  bmask = 0xff & (0xee >> (doff / 2));
-
-  /* generate edge mask for the start point */
-  emask = vis_edge16(da, dend);
-
-  /* load 24 byte, convert, store 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_S16_34L;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 4 ) {
-      vis_pst_16(dd0, dp++, emask & bmask);
-      vis_pst_16(dd1, dp++, bmask);
-      vis_pst_16(dd2, dp++, bmask);
-      vis_pst_16(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34L;
-        vis_pst_16(dd0, dp++, bmask);
-        vis_pst_16(dd1, dp++, bmask);
-        vis_pst_16(dd2, dp++, bmask);
-        vis_pst_16(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34L;
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 4 ) {
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34L;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34L;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_s16  *sa, *da;
-  mlib_s16  *sl, *dl;
-  int       j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_34L_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb);
-    da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h
index ea66f67..92a5890 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h
@@ -34,18 +34,6 @@
 
 #if defined ( VIS ) && VIS == 0x200
 
-mlib_status mlib_conv2x2_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
 mlib_status mlib_convMxN_8nw_f(mlib_image       *dst,
                                const mlib_image *src,
                                mlib_s32         m,
@@ -58,16 +46,6 @@
 
 #else
 
-mlib_status mlib_conv2x2_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale);
-
-mlib_status mlib_conv3x3_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale);
-
 mlib_status mlib_convMxN_8nw_f(mlib_image       *dst,
                                const mlib_image *src,
                                mlib_s32         m,
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c
deleted file mode 100644
index 4127185..0000000
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c
+++ /dev/null
@@ -1,1673 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-/*
- * FUNCTION
- *      Internal functions for mlib_ImageConv* on U8 type
- *      and MLIB_EDGE_DST_NO_WRITE mask
- *
- */
-
-/***************************************************************/
-
-#include <vis_proto.h>
-#include <mlib_image.h>
-#include <mlib_ImageCheck.h>
-#include <mlib_ImageColormap.h>
-
-/*
-  This defines switches between functions in
-  files: mlib_v_ImageConv_8nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c
-*/
-
-#define CONV_INDEX
-
-#define DTYPE mlib_s16
-#define LTYPE mlib_u8
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define CONV_FUNC(KERN)                                         \
-  mlib_conv##KERN##_Index3_8_16nw(mlib_image *dst,              \
-                                  mlib_image *src,              \
-                                  mlib_s32   *kern,             \
-                                  mlib_s32   scale,             \
-                                  void       *colormap)
-
-#else
-
-#define CONV_FUNC(KERN)                         \
-  mlib_conv##KERN##_8nw_f(mlib_image *dst,      \
-                          mlib_image *src,      \
-                          mlib_s32   *kern,     \
-                          mlib_s32   scale)
-
-#endif
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define NCHAN  3
-
-#else
-
-#define NCHAN  nchan
-
-#endif
-
-/***************************************************************/
-
-#define DEF_VARS                                                \
-  DTYPE    *sl, *sp, *dl;                                       \
-  mlib_s32 hgt = mlib_ImageGetHeight(src);                      \
-  mlib_s32 wid = mlib_ImageGetWidth(src);                       \
-  mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(DTYPE);      \
-  mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(DTYPE);      \
-  DTYPE    *adr_src = (DTYPE *)mlib_ImageGetData(src);          \
-  DTYPE    *adr_dst = (DTYPE *)mlib_ImageGetData(dst);          \
-  mlib_s32 ssize, xsize, dsize, esize, emask, buff_ind = 0;     \
-  mlib_d64 *pbuff, *dp;                                         \
-  mlib_f32 *karr = (mlib_f32 *)kern;                            \
-  mlib_s32 gsr_scale = (31 - scale) << 3;                       \
-  mlib_d64 drnd = vis_to_double_dup(mlib_round_8[31 - scale]);  \
-  mlib_s32 i, j, l
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define DEF_EXTRA_VARS                                                  \
-  int    offset = mlib_ImageGetLutOffset(colormap);                     \
-  LTYPE  **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap);         \
-  LTYPE  *ltbl0 = lut_table[0] - offset;                                \
-  LTYPE  *ltbl1 = lut_table[1] - offset;                                \
-  LTYPE  *ltbl2 = lut_table[2] - offset;                                \
-  LTYPE  *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2
-
-#else
-
-#define DEF_EXTRA_VARS                          \
-  mlib_s32 nchan = mlib_ImageGetChannels(dst)
-
-#endif
-
-/***************************************************************/
-
-#if NCHAN == 3
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 8;                                                    \
-  }
-
-#else
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 6;                                                    \
-  }
-
-#endif
-
-/***************************************************************/
-
-static mlib_s32 mlib_round_8[16] = { 0x00400040, 0x00200020, 0x00100010, 0x00080008,
-                                    0x00040004, 0x00020002, 0x00010001, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000 };
-
-/***************************************************************/
-
-void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, int size);
-
-/***************************************************************/
-
-#define KSIZE  2
-
-mlib_status CONV_FUNC(2x2)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s0, s1;
-  mlib_d64 d0, d1, d00, d01, d10, d11;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-  dl = adr_dst;
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1;
-    sp = sl + KSIZE*sll;
-
-    buff0 = buffc[0];
-    buff1 = buffc[1];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl      )) & 7) == 0) buff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl + sll)) & 7) == 0) buff1 = (mlib_d64*)(sl + sll);
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-    k0 = pk[1];
-    k1 = pk[3];
-    vis_write_gsr(gsr_scale + NCHAN);
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-#pragma pipeloop(0)
-    for (i = 0; i < (xsize + 7)/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d01, d11);
-      buffd[2*i] = d0;
-      buffd[2*i + 1] = d1;
-    }
-
-    k0 = pk[0];
-    k1 = pk[2];
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      dp[i] = vis_fpack16_pair(d0, d1);
-    }
-
-    if (emask) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-
-      d0 = vis_fpack16_pair(d0, d1);
-      vis_pst_8(d0, dp + i, emask);
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      d02 = vis_fpadd16(d02, d12);
-      d2  = vis_fpadd16(d2, drnd);
-      d2  = vis_fpadd16(d2, d02);
-      d03 = vis_fpadd16(d03, d13);
-      d3  = vis_fpadd16(d3, drnd);
-      d3  = vis_fpadd16(d3, d03);
-      d04 = vis_fpadd16(d04, d14);
-      d4  = vis_fpadd16(d4, drnd);
-      d4  = vis_fpadd16(d4, d04);
-      d05 = vis_fpadd16(d05, d15);
-      d5  = vis_fpadd16(d5, drnd);
-      d5  = vis_fpadd16(d5, d05);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2;
-  mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21;
-  mlib_s32 ik, ik_last, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + 1);
-#else
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + NCHAN);
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2;
-    mlib_f32 *pk = karr, k0, k1, k2;
-    sp = sl + KSIZE*sll;
-
-    pbuff0 = buffc[0];
-    pbuff1 = buffc[1];
-    pbuff2 = buffc[2];
-    buffn  = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl        )) & 7) == 0) pbuff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl +   sll)) & 7) == 0) pbuff1 = (mlib_d64*)(sl + sll);
-    if ((((mlib_addr)(sl + 2*sll)) & 7) == 0) pbuff2 = (mlib_d64*)(sl + 2*sll);
-
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (KSIZE - 1);
-#endif
-
-    for (ik = 0; ik < KSIZE; ik++) {
-      k0 = pk[ik];
-      k1 = pk[ik + KSIZE];
-      k2 = pk[ik + 2*KSIZE];
-
-      off  = ik*NCHAN;
-      doff = off/8;
-      off &= 7;
-      buff0 = pbuff0 + doff;
-      buff1 = pbuff1 + doff;
-      buff2 = pbuff2 + doff;
-      vis_write_gsr(gsr_scale + off);
-
-      if (ik == ik_last) continue;
-      /*if (!ik_last) {
-        if ((off & 3) || (ik == (KSIZE - 1))) {
-          ik_last = ik;
-          continue;
-        }
-      }*/
-
-      if (off == 0) {
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s0 = buff0[i];
-          s1 = buff1[i];
-          s2 = buff2[i];
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else if (off == 4) {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-
-          d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-          d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-          d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-          d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-          d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-          d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-          s0  = vis_faligndata(s00, s01);
-          s1  = vis_faligndata(s10, s11);
-          s2  = vis_faligndata(s20, s21);
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-      }
-    }
-
-    k0 = pk[ik_last];
-    k1 = pk[ik_last + KSIZE];
-    k2 = pk[ik_last + 2*KSIZE];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = pbuff0 + doff;
-    buff1 = pbuff1 + doff;
-    buff2 = pbuff2 + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-    s21 = buff2[0];
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      dp[i] = dd;
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if (emask) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      vis_pst_8(dd, dp + i, emask);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d20, d21, d22, d23, d24, d25;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-      mlib_d64 s20 = buff2[i];
-      mlib_d64 s21 = buff2[i + 1];
-      mlib_d64 s22 = buff2[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-      d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-      d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-      d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-      d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-      d2 = vis_fpadd16(d2, d02);
-      d2 = vis_fpadd16(d2, d12);
-      d2 = vis_fpadd16(d2, d22);
-      d3 = vis_fpadd16(d3, d03);
-      d3 = vis_fpadd16(d3, d13);
-      d3 = vis_fpadd16(d3, d23);
-      d4 = vis_fpadd16(d4, d04);
-      d4 = vis_fpadd16(d4, d14);
-      d4 = vis_fpadd16(d4, d24);
-      d5 = vis_fpadd16(d5, d05);
-      d5 = vis_fpadd16(d5, d15);
-      d5 = vis_fpadd16(d5, d25);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-      buffd[2*i + 2] = drnd;
-      buffd[2*i + 3] = drnd;
-      buffd[2*i + 4] = drnd;
-      buffd[2*i + 5] = drnd;
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define MAX_N   11
-
-#ifdef CONV_INDEX
-
-mlib_status mlib_convMxN_Index3_8_16nw(mlib_image *dst,
-                                       mlib_image *src,
-                                       mlib_s32   m,
-                                       mlib_s32   n,
-                                       mlib_s32   dm,
-                                       mlib_s32   dn,
-                                       mlib_s32   *kern,
-                                       mlib_s32   scale,
-                                       void       *colormap)
-
-#else
-
-mlib_status mlib_convMxN_8nw_f(mlib_image *dst,
-                               mlib_image *src,
-                               mlib_s32   m,
-                               mlib_s32   n,
-                               mlib_s32   dm,
-                               mlib_s32   dn,
-                               mlib_s32   *kern,
-                               mlib_s32   scale)
-
-#endif
-{
-  mlib_d64 *buffs_local[3*(MAX_N + 1)], **buffs = buffs_local, **buff;
-  mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s30, s31, s0, s1, s2, s3;
-  mlib_d64 d00, d01, d10, d11, d20, d21, d30, d31;
-  mlib_d64 dd, d0, d1;
-  mlib_s32 ik, jk, ik_last, jk_size, coff, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  if (n > MAX_N) {
-    buffs = mlib_malloc(3*(n + 1)*sizeof(mlib_d64*));
-    if (buffs == NULL) return MLIB_FAILURE;
-  }
-
-  buff = buffs + 2*(n + 1);
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + dn*dll + dm;
-#else
-  dl = adr_dst + dn*dll + dm*NCHAN;
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((n + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) {
-    if (buffs != buffs_local) mlib_free(buffs);
-    return MLIB_FAILURE;
-  }
-
-  for (i = 0; i < (n + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (n + 1); i++) buffs[(n + 1) + i] = buffs[i];
-  buffd = buffs[n] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (m - 1);
-  hgt -= (n - 1);
-  xsize = ssize - NCHAN*(m - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < n; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1, k2, k3;
-    sp = sl + n*sll;
-
-    for (l = 0; l < n; l++) {
-      buff[l] = buffc[l];
-    }
-    buffn  = buffc[n];
-
-#ifndef CONV_INDEX
-    for (l = 0; l < n; l++) {
-      if ((((mlib_addr)(sl + l*sll)) & 7) == 0) buff[l] = (mlib_d64*)(sl + l*sll);
-    }
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (m - 1);
-#endif
-
-    for (jk = 0; jk < n; jk += jk_size) {
-      jk_size = n - jk;
-#ifdef CONV_INDEX
-      if (jk_size >= 5) jk_size = 3;
-      if (jk_size == 4) jk_size = 2;
-#else
-      if (jk_size >= 6) jk_size = 4;
-      if (jk_size == 5) jk_size = 3;
-#endif
-      coff = 0;
-
-      if (jk_size == 2) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          s01 = buff0[0];
-          s11 = buff1[0];
-#pragma pipeloop(0)
-          for (i = 0; i < (xsize + 7)/8; i++) {
-            s00 = s01;
-            s10 = s11;
-            s01 = buff0[i + 1];
-            s11 = buff1[i + 1];
-            s0  = vis_faligndata(s00, s01);
-            s1  = vis_faligndata(s10, s11);
-
-            d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-            d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-            d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-            d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-            d0 = buffd[2*i];
-            d1 = buffd[2*i + 1];
-            d0 = vis_fpadd16(d00, d0);
-            d0 = vis_fpadd16(d10, d0);
-            d1 = vis_fpadd16(d01, d1);
-            d1 = vis_fpadd16(d11, d1);
-            buffd[2*i] = d0;
-            buffd[2*i + 1] = d1;
-          }
-
-        }
-
-        pk += 2*m;
-
-      } else if (jk_size == 3) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 3*m;
-
-      } else { /* jk_size == 4 */
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-          k3 = pk[ik + 3*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-          buff3 = buff[jk + 3] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-              s3 = buff3[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-              d30 = vis_fmul8x16au(vis_read_lo(s30), k3);
-              d31 = vis_fmul8x16au(vis_read_hi(s31), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-              s3  = vis_faligndata(s30, s31);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 4*m;
-      }
-    }
-
-    /*****************************************
-     *****************************************
-     **          Final iteration            **
-     *****************************************
-     *****************************************/
-
-    jk_size = n;
-#ifdef CONV_INDEX
-    if (jk_size >= 5) jk_size = 3;
-    if (jk_size == 4) jk_size = 2;
-#else
-    if (jk_size >= 6) jk_size = 4;
-    if (jk_size == 5) jk_size = 3;
-#endif
-
-    k0 = karr[ik_last];
-    k1 = karr[ik_last + m];
-    k2 = karr[ik_last + 2*m];
-    k3 = karr[ik_last + 3*m];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = buff[0] + doff;
-    buff1 = buff[1] + doff;
-    buff2 = buff[2] + doff;
-    buff3 = buff[3] + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    if (jk_size == 2) {
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else if (jk_size == 3) {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else /* if (jk_size == 4) */ {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-      s31 = buff3[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-    }
-
-#else /* CONV_INDEX */
-
-    if (jk_size == 2) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-
-    } else /* if (jk_size == 3) */ {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d20, d21, d22, d23, d24, d25;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-        mlib_d64 s20 = buff2[i];
-        mlib_d64 s21 = buff2[i + 1];
-        mlib_d64 s22 = buff2[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-        d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-        d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-        d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-        d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d2 = vis_fpadd16(d2, d22);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d3 = vis_fpadd16(d3, d23);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d4 = vis_fpadd16(d4, d24);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-        d5 = vis_fpadd16(d5, d25);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (n + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-  if (buffs != buffs_local) mlib_free(buffs);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c
deleted file mode 100644
index ada07fe..0000000
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c
+++ /dev/null
@@ -1,1673 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-/*
- * FUNCTION
- *      Internal functions for mlib_ImageConv* on U8 type
- *      and MLIB_EDGE_DST_NO_WRITE mask
- *
- */
-
-/***************************************************************/
-
-#include <vis_proto.h>
-#include <mlib_image.h>
-#include <mlib_ImageCheck.h>
-#include <mlib_ImageColormap.h>
-
-/*
-  This defines switches between functions in
-  files: mlib_v_ImageConv_8nw.c,
-         mlib_v_ImageConvIndex3_8_8nw.c,
-         mlib_v_ImageConvIndex4_8_8nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c
-*/
-
-#define CONV_INDEX
-
-#define DTYPE mlib_u8
-#define LTYPE mlib_u8
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define CONV_FUNC(KERN)                                 \
-  mlib_conv##KERN##_Index3_8_8nw(mlib_image *dst,       \
-                                 mlib_image *src,       \
-                                 mlib_s32   *kern,      \
-                                 mlib_s32   scale,      \
-                                 void       *colormap)
-
-#else
-
-#define CONV_FUNC(KERN)                         \
-  mlib_conv##KERN##_8nw_f(mlib_image *dst,      \
-                          mlib_image *src,      \
-                          mlib_s32   *kern,     \
-                          mlib_s32   scale)
-
-#endif
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define NCHAN  3
-
-#else
-
-#define NCHAN  nchan
-
-#endif
-
-/***************************************************************/
-
-#define DEF_VARS                                                \
-  DTYPE    *sl, *sp, *dl;                                       \
-  mlib_s32 hgt = mlib_ImageGetHeight(src);                      \
-  mlib_s32 wid = mlib_ImageGetWidth(src);                       \
-  mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(DTYPE);      \
-  mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(DTYPE);      \
-  DTYPE    *adr_src = (DTYPE *)mlib_ImageGetData(src);          \
-  DTYPE    *adr_dst = (DTYPE *)mlib_ImageGetData(dst);          \
-  mlib_s32 ssize, xsize, dsize, esize, emask, buff_ind = 0;     \
-  mlib_d64 *pbuff, *dp;                                         \
-  mlib_f32 *karr = (mlib_f32 *)kern;                            \
-  mlib_s32 gsr_scale = (31 - scale) << 3;                       \
-  mlib_d64 drnd = vis_to_double_dup(mlib_round_8[31 - scale]);  \
-  mlib_s32 i, j, l
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define DEF_EXTRA_VARS                                                  \
-  int    offset = mlib_ImageGetLutOffset(colormap);                     \
-  LTYPE  **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap);         \
-  LTYPE  *ltbl0 = lut_table[0] - offset;                                \
-  LTYPE  *ltbl1 = lut_table[1] - offset;                                \
-  LTYPE  *ltbl2 = lut_table[2] - offset;                                \
-  LTYPE  *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2
-
-#else
-
-#define DEF_EXTRA_VARS                          \
-  mlib_s32 nchan = mlib_ImageGetChannels(dst)
-
-#endif
-
-/***************************************************************/
-
-#if NCHAN == 3
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 8;                                                    \
-  }
-
-#else
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 6;                                                    \
-  }
-
-#endif
-
-/***************************************************************/
-
-static mlib_s32 mlib_round_8[16] = { 0x00400040, 0x00200020, 0x00100010, 0x00080008,
-                                    0x00040004, 0x00020002, 0x00010001, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000 };
-
-/***************************************************************/
-
-void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, int size);
-
-/***************************************************************/
-
-#define KSIZE  2
-
-mlib_status CONV_FUNC(2x2)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s0, s1;
-  mlib_d64 d0, d1, d00, d01, d10, d11;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-  dl = adr_dst;
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1;
-    sp = sl + KSIZE*sll;
-
-    buff0 = buffc[0];
-    buff1 = buffc[1];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl      )) & 7) == 0) buff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl + sll)) & 7) == 0) buff1 = (mlib_d64*)(sl + sll);
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-    k0 = pk[1];
-    k1 = pk[3];
-    vis_write_gsr(gsr_scale + NCHAN);
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-#pragma pipeloop(0)
-    for (i = 0; i < (xsize + 7)/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d01, d11);
-      buffd[2*i] = d0;
-      buffd[2*i + 1] = d1;
-    }
-
-    k0 = pk[0];
-    k1 = pk[2];
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      dp[i] = vis_fpack16_pair(d0, d1);
-    }
-
-    if (emask) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-
-      d0 = vis_fpack16_pair(d0, d1);
-      vis_pst_8(d0, dp + i, emask);
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      d02 = vis_fpadd16(d02, d12);
-      d2  = vis_fpadd16(d2, drnd);
-      d2  = vis_fpadd16(d2, d02);
-      d03 = vis_fpadd16(d03, d13);
-      d3  = vis_fpadd16(d3, drnd);
-      d3  = vis_fpadd16(d3, d03);
-      d04 = vis_fpadd16(d04, d14);
-      d4  = vis_fpadd16(d4, drnd);
-      d4  = vis_fpadd16(d4, d04);
-      d05 = vis_fpadd16(d05, d15);
-      d5  = vis_fpadd16(d5, drnd);
-      d5  = vis_fpadd16(d5, d05);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2;
-  mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21;
-  mlib_s32 ik, ik_last, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + 1);
-#else
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + NCHAN);
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2;
-    mlib_f32 *pk = karr, k0, k1, k2;
-    sp = sl + KSIZE*sll;
-
-    pbuff0 = buffc[0];
-    pbuff1 = buffc[1];
-    pbuff2 = buffc[2];
-    buffn  = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl        )) & 7) == 0) pbuff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl +   sll)) & 7) == 0) pbuff1 = (mlib_d64*)(sl + sll);
-    if ((((mlib_addr)(sl + 2*sll)) & 7) == 0) pbuff2 = (mlib_d64*)(sl + 2*sll);
-
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (KSIZE - 1);
-#endif
-
-    for (ik = 0; ik < KSIZE; ik++) {
-      k0 = pk[ik];
-      k1 = pk[ik + KSIZE];
-      k2 = pk[ik + 2*KSIZE];
-
-      off  = ik*NCHAN;
-      doff = off/8;
-      off &= 7;
-      buff0 = pbuff0 + doff;
-      buff1 = pbuff1 + doff;
-      buff2 = pbuff2 + doff;
-      vis_write_gsr(gsr_scale + off);
-
-      if (ik == ik_last) continue;
-      /*if (!ik_last) {
-        if ((off & 3) || (ik == (KSIZE - 1))) {
-          ik_last = ik;
-          continue;
-        }
-      }*/
-
-      if (off == 0) {
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s0 = buff0[i];
-          s1 = buff1[i];
-          s2 = buff2[i];
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else if (off == 4) {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-
-          d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-          d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-          d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-          d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-          d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-          d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-          s0  = vis_faligndata(s00, s01);
-          s1  = vis_faligndata(s10, s11);
-          s2  = vis_faligndata(s20, s21);
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-      }
-    }
-
-    k0 = pk[ik_last];
-    k1 = pk[ik_last + KSIZE];
-    k2 = pk[ik_last + 2*KSIZE];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = pbuff0 + doff;
-    buff1 = pbuff1 + doff;
-    buff2 = pbuff2 + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-    s21 = buff2[0];
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      dp[i] = dd;
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if (emask) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      vis_pst_8(dd, dp + i, emask);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d20, d21, d22, d23, d24, d25;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-      mlib_d64 s20 = buff2[i];
-      mlib_d64 s21 = buff2[i + 1];
-      mlib_d64 s22 = buff2[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-      d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-      d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-      d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-      d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-      d2 = vis_fpadd16(d2, d02);
-      d2 = vis_fpadd16(d2, d12);
-      d2 = vis_fpadd16(d2, d22);
-      d3 = vis_fpadd16(d3, d03);
-      d3 = vis_fpadd16(d3, d13);
-      d3 = vis_fpadd16(d3, d23);
-      d4 = vis_fpadd16(d4, d04);
-      d4 = vis_fpadd16(d4, d14);
-      d4 = vis_fpadd16(d4, d24);
-      d5 = vis_fpadd16(d5, d05);
-      d5 = vis_fpadd16(d5, d15);
-      d5 = vis_fpadd16(d5, d25);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-      buffd[2*i + 2] = drnd;
-      buffd[2*i + 3] = drnd;
-      buffd[2*i + 4] = drnd;
-      buffd[2*i + 5] = drnd;
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define MAX_N   11
-
-#ifdef CONV_INDEX
-
-mlib_status mlib_convMxN_Index3_8_8nw(mlib_image *dst,
-                                      mlib_image *src,
-                                      mlib_s32   m,
-                                      mlib_s32   n,
-                                      mlib_s32   dm,
-                                      mlib_s32   dn,
-                                      mlib_s32   *kern,
-                                      mlib_s32   scale,
-                                      void       *colormap)
-
-#else
-
-mlib_status mlib_convMxN_8nw_f(mlib_image *dst,
-                               mlib_image *src,
-                               mlib_s32   m,
-                               mlib_s32   n,
-                               mlib_s32   dm,
-                               mlib_s32   dn,
-                               mlib_s32   *kern,
-                               mlib_s32   scale)
-
-#endif
-{
-  mlib_d64 *buffs_local[3*(MAX_N + 1)], **buffs = buffs_local, **buff;
-  mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s30, s31, s0, s1, s2, s3;
-  mlib_d64 d00, d01, d10, d11, d20, d21, d30, d31;
-  mlib_d64 dd, d0, d1;
-  mlib_s32 ik, jk, ik_last, jk_size, coff, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  if (n > MAX_N) {
-    buffs = mlib_malloc(3*(n + 1)*sizeof(mlib_d64*));
-    if (buffs == NULL) return MLIB_FAILURE;
-  }
-
-  buff = buffs + 2*(n + 1);
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + dn*dll + dm;
-#else
-  dl = adr_dst + dn*dll + dm*NCHAN;
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((n + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) {
-    if (buffs != buffs_local) mlib_free(buffs);
-    return MLIB_FAILURE;
-  }
-
-  for (i = 0; i < (n + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (n + 1); i++) buffs[(n + 1) + i] = buffs[i];
-  buffd = buffs[n] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (m - 1);
-  hgt -= (n - 1);
-  xsize = ssize - NCHAN*(m - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < n; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1, k2, k3;
-    sp = sl + n*sll;
-
-    for (l = 0; l < n; l++) {
-      buff[l] = buffc[l];
-    }
-    buffn  = buffc[n];
-
-#ifndef CONV_INDEX
-    for (l = 0; l < n; l++) {
-      if ((((mlib_addr)(sl + l*sll)) & 7) == 0) buff[l] = (mlib_d64*)(sl + l*sll);
-    }
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (m - 1);
-#endif
-
-    for (jk = 0; jk < n; jk += jk_size) {
-      jk_size = n - jk;
-#ifdef CONV_INDEX
-      if (jk_size >= 5) jk_size = 3;
-      if (jk_size == 4) jk_size = 2;
-#else
-      if (jk_size >= 6) jk_size = 4;
-      if (jk_size == 5) jk_size = 3;
-#endif
-      coff = 0;
-
-      if (jk_size == 2) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          s01 = buff0[0];
-          s11 = buff1[0];
-#pragma pipeloop(0)
-          for (i = 0; i < (xsize + 7)/8; i++) {
-            s00 = s01;
-            s10 = s11;
-            s01 = buff0[i + 1];
-            s11 = buff1[i + 1];
-            s0  = vis_faligndata(s00, s01);
-            s1  = vis_faligndata(s10, s11);
-
-            d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-            d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-            d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-            d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-            d0 = buffd[2*i];
-            d1 = buffd[2*i + 1];
-            d0 = vis_fpadd16(d00, d0);
-            d0 = vis_fpadd16(d10, d0);
-            d1 = vis_fpadd16(d01, d1);
-            d1 = vis_fpadd16(d11, d1);
-            buffd[2*i] = d0;
-            buffd[2*i + 1] = d1;
-          }
-
-        }
-
-        pk += 2*m;
-
-      } else if (jk_size == 3) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 3*m;
-
-      } else { /* jk_size == 4 */
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-          k3 = pk[ik + 3*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-          buff3 = buff[jk + 3] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-              s3 = buff3[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-              d30 = vis_fmul8x16au(vis_read_lo(s30), k3);
-              d31 = vis_fmul8x16au(vis_read_hi(s31), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-              s3  = vis_faligndata(s30, s31);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 4*m;
-      }
-    }
-
-    /*****************************************
-     *****************************************
-     **          Final iteration            **
-     *****************************************
-     *****************************************/
-
-    jk_size = n;
-#ifdef CONV_INDEX
-    if (jk_size >= 5) jk_size = 3;
-    if (jk_size == 4) jk_size = 2;
-#else
-    if (jk_size >= 6) jk_size = 4;
-    if (jk_size == 5) jk_size = 3;
-#endif
-
-    k0 = karr[ik_last];
-    k1 = karr[ik_last + m];
-    k2 = karr[ik_last + 2*m];
-    k3 = karr[ik_last + 3*m];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = buff[0] + doff;
-    buff1 = buff[1] + doff;
-    buff2 = buff[2] + doff;
-    buff3 = buff[3] + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    if (jk_size == 2) {
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else if (jk_size == 3) {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else /* if (jk_size == 4) */ {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-      s31 = buff3[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-    }
-
-#else /* CONV_INDEX */
-
-    if (jk_size == 2) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-
-    } else /* if (jk_size == 3) */ {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d20, d21, d22, d23, d24, d25;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-        mlib_d64 s20 = buff2[i];
-        mlib_d64 s21 = buff2[i + 1];
-        mlib_d64 s22 = buff2[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-        d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-        d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-        d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-        d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d2 = vis_fpadd16(d2, d22);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d3 = vis_fpadd16(d3, d23);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d4 = vis_fpadd16(d4, d24);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-        d5 = vis_fpadd16(d5, d25);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (n + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-  if (buffs != buffs_local) mlib_free(buffs);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c
index ac2e5f0..0605fa4 100644
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c
@@ -34,58 +34,16 @@
 #include "vis_proto.h"
 #include "mlib_image.h"
 #include "mlib_ImageCheck.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageConv.h"
 #include "mlib_v_ImageConv.h"
 
-/*
-  This defines switches between functions in
-  files: mlib_v_ImageConvIndex3_8_8nw.c,
-         mlib_v_ImageConvIndex4_8_8nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c
-*/
-
-/*#define CONV_INDEX*/
-
 /***************************************************************/
 #define DTYPE mlib_u8
-#define LTYPE mlib_u8
 
 /***************************************************************/
-#ifdef CONV_INDEX
-
-#define CONV_FUNC(KERN)                                         \
-  mlib_conv##KERN##_Index3_8_8nw(mlib_image       *dst,         \
-                                 const mlib_image *src,         \
-                                 const mlib_s32   *kern,        \
-                                 mlib_s32         scale,        \
-                                 const void       *colormap)
-
-#else
-
-#define CONV_FUNC(KERN)                                         \
-  mlib_conv##KERN##_8nw_f(mlib_image       *dst,                \
-                          const mlib_image *src,                \
-                          const mlib_s32   *kern,               \
-                          mlib_s32         scale)
-
-#endif /* CONV_INDEX */
-
-#define ColorTrue2IndexLine mlib_ImageColorTrue2IndexLine_U8_U8_3
-
-/***************************************************************/
-#ifdef CONV_INDEX
-
-#define NCHAN  3
-
-#else
-
 #define NCHAN  nchan
 
-#endif /* CONV_INDEX */
-
 /***************************************************************/
 #define DEF_VARS                                                \
   DTYPE    *sl, *sp, *dl;                                       \
@@ -103,104 +61,9 @@
   mlib_s32 i, j, l
 
 /***************************************************************/
-#ifdef CONV_INDEX
-
-#define DEF_EXTRA_VARS                                          \
-  mlib_s32 offset = mlib_ImageGetLutOffset(colormap);           \
-  LTYPE  **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap); \
-  LTYPE  *ltbl0 = lut_table[0] - offset;                        \
-  LTYPE  *ltbl1 = lut_table[1] - offset;                        \
-  LTYPE  *ltbl2 = lut_table[2] - offset;                        \
-  LTYPE  *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2
-
-#else
-
 #define DEF_EXTRA_VARS                                          \
   mlib_s32 nchan = mlib_ImageGetChannels(dst)
 
-#endif /* CONV_INDEX */
-
-/***************************************************************/
-#if NCHAN == 3
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 8;                                                    \
-  }
-
-#else
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 6;                                                    \
-  }
-
-#endif /* NCHAN == 3 */
-
 /***************************************************************/
 static const mlib_s32 mlib_round_8[16] = {
   0x00400040, 0x00200020, 0x00100010, 0x00080008,
@@ -210,651 +73,8 @@
 };
 
 /***************************************************************/
-#define KSIZE  2
-
-mlib_status CONV_FUNC(2x2)
-{
-  mlib_d64 *buffs[2 * (KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s0, s1;
-  mlib_d64 d0, d1, d00, d01, d10, d11;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-  dl = adr_dst;
-
-  ssize = NCHAN * wid;
-  dsize = (ssize + 7) / 8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4) * esize * sizeof(mlib_d64));
-
-  if (pbuff == NULL)
-    return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[i] = pbuff + i * esize;
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2 * esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN * (KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l * sll;
-
-#ifndef CONV_INDEX
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-
-#endif /* CONV_INDEX */
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1;
-    sp = sl + KSIZE * sll;
-
-    buff0 = buffc[0];
-    buff1 = buffc[1];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-
-    if ((((mlib_addr) (sl)) & 7) == 0)
-      buff0 = (mlib_d64 *) sl;
-
-    if ((((mlib_addr) (sl + sll)) & 7) == 0)
-      buff1 = (mlib_d64 *) (sl + sll);
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#endif /* CONV_INDEX */
-
-    k0 = pk[1];
-    k1 = pk[3];
-    vis_write_gsr(gsr_scale + NCHAN);
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-#pragma pipeloop(0)
-    for (i = 0; i < (xsize + 7) / 8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s0 = vis_faligndata(s00, s01);
-      s1 = vis_faligndata(s10, s11);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d01, d11);
-      buffd[2 * i] = d0;
-      buffd[2 * i + 1] = d1;
-    }
-
-    k0 = pk[0];
-    k1 = pk[2];
-#ifndef CONV_INDEX
-    dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl;
-
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0 = vis_fpadd16(d0, drnd);
-      d0 = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1 = vis_fpadd16(d1, drnd);
-      d1 = vis_fpadd16(d1, d01);
-      dp[i] = vis_fpack16_pair(d0, d1);
-    }
-
-    if (emask) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0 = vis_fpadd16(d0, drnd);
-      d0 = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1 = vis_fpadd16(d1, drnd);
-      d1 = vis_fpadd16(d1, d01);
-
-      d0 = vis_fpack16_pair(d0, d1);
-      vis_pst_8(d0, dp + i, emask);
-    }
-
-    if ((mlib_u8 *) dp != dl)
-      mlib_ImageCopy_na((void *)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d2 = buffd[2 * i + 2];
-      d3 = buffd[2 * i + 3];
-      d4 = buffd[2 * i + 4];
-      d5 = buffd[2 * i + 5];
-      d00 = vis_fpadd16(d00, d10);
-      d0 = vis_fpadd16(d0, drnd);
-      d0 = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1 = vis_fpadd16(d1, drnd);
-      d1 = vis_fpadd16(d1, d01);
-      d02 = vis_fpadd16(d02, d12);
-      d2 = vis_fpadd16(d2, drnd);
-      d2 = vis_fpadd16(d2, d02);
-      d03 = vis_fpadd16(d03, d13);
-      d3 = vis_fpadd16(d3, drnd);
-      d3 = vis_fpadd16(d3, d03);
-      d04 = vis_fpadd16(d04, d14);
-      d4 = vis_fpadd16(d4, drnd);
-      d4 = vis_fpadd16(d4, d04);
-      d05 = vis_fpadd16(d05, d15);
-      d5 = vis_fpadd16(d5, drnd);
-      d5 = vis_fpadd16(d5, d05);
-
-      buffe[i] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      LOAD_SRC();
-    }
-
-    ColorTrue2IndexLine((void *)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-
-    if (buff_ind >= (KSIZE + 1))
-      buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  mlib_d64 *buffs[2 * (KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2;
-  mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21;
-  mlib_s32 ik, ik_last, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + ((KSIZE - 1) / 2) * (dll + 1);
-#else
-  dl = adr_dst + ((KSIZE - 1) / 2) * (dll + NCHAN);
-#endif /* CONV_INDEX */
-
-  ssize = NCHAN * wid;
-  dsize = (ssize + 7) / 8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4) * esize * sizeof(mlib_d64));
-
-  if (pbuff == NULL)
-    return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[i] = pbuff + i * esize;
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2 * esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN * (KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l * sll;
-
-#ifndef CONV_INDEX
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7) / 8; i++) {
-    buffd[2 * i] = drnd;
-    buffd[2 * i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2;
-    mlib_f32 *pk = karr, k0, k1, k2;
-    sp = sl + KSIZE * sll;
-
-    pbuff0 = buffc[0];
-    pbuff1 = buffc[1];
-    pbuff2 = buffc[2];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-
-    if ((((mlib_addr) (sl)) & 7) == 0)
-      pbuff0 = (mlib_d64 *) sl;
-
-    if ((((mlib_addr) (sl + sll)) & 7) == 0)
-      pbuff1 = (mlib_d64 *) (sl + sll);
-
-    if ((((mlib_addr) (sl + 2 * sll)) & 7) == 0)
-      pbuff2 = (mlib_d64 *) (sl + 2 * sll);
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (KSIZE - 1);
-#endif /* CONV_INDEX */
-
-    for (ik = 0; ik < KSIZE; ik++) {
-      k0 = pk[ik];
-      k1 = pk[ik + KSIZE];
-      k2 = pk[ik + 2 * KSIZE];
-
-      off = ik * NCHAN;
-      doff = off / 8;
-      off &= 7;
-      buff0 = pbuff0 + doff;
-      buff1 = pbuff1 + doff;
-      buff2 = pbuff2 + doff;
-      vis_write_gsr(gsr_scale + off);
-
-      if (ik == ik_last)
-        continue;
-      /*if (!ik_last) {
-       * if ((off & 3) || (ik == (KSIZE - 1))) {
-       * ik_last = ik;
-       * continue;
-       * }
-       * } */
-
-      if (off == 0) {
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7) / 8; i++) {
-          s0 = buff0[i];
-          s1 = buff1[i];
-          s2 = buff2[i];
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2 * i];
-          d1 = buffd[2 * i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2 * i] = d0;
-          buffd[2 * i + 1] = d1;
-        }
-      }
-      else if (off == 4) {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7) / 8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-
-          d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-          d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-          d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-          d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-          d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-          d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-          d0 = buffd[2 * i];
-          d1 = buffd[2 * i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2 * i] = d0;
-          buffd[2 * i + 1] = d1;
-        }
-      }
-      else {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7) / 8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-          s0 = vis_faligndata(s00, s01);
-          s1 = vis_faligndata(s10, s11);
-          s2 = vis_faligndata(s20, s21);
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2 * i];
-          d1 = buffd[2 * i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2 * i] = d0;
-          buffd[2 * i + 1] = d1;
-        }
-      }
-    }
-
-    k0 = pk[ik_last];
-    k1 = pk[ik_last + KSIZE];
-    k2 = pk[ik_last + 2 * KSIZE];
-
-    off = ik_last * NCHAN;
-    doff = off / 8;
-    off &= 7;
-    buff0 = pbuff0 + doff;
-    buff1 = pbuff1 + doff;
-    buff2 = pbuff2 + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl;
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-    s21 = buff2[0];
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0 = vis_faligndata(s00, s01);
-      s1 = vis_faligndata(s10, s11);
-      s2 = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      dp[i] = dd;
-
-      buffd[2 * i] = drnd;
-      buffd[2 * i + 1] = drnd;
-    }
-
-    if (emask) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0 = vis_faligndata(s00, s01);
-      s1 = vis_faligndata(s10, s11);
-      s2 = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      vis_pst_8(dd, dp + i, emask);
-
-      buffd[2 * i] = drnd;
-      buffd[2 * i + 1] = drnd;
-    }
-
-    if ((mlib_u8 *) dp != dl)
-      mlib_ImageCopy_na((void *)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d20, d21, d22, d23, d24, d25;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-      mlib_d64 s20 = buff2[i];
-      mlib_d64 s21 = buff2[i + 1];
-      mlib_d64 s22 = buff2[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-      d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-      d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-      d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-      d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d2 = buffd[2 * i + 2];
-      d3 = buffd[2 * i + 3];
-      d4 = buffd[2 * i + 4];
-      d5 = buffd[2 * i + 5];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-      d2 = vis_fpadd16(d2, d02);
-      d2 = vis_fpadd16(d2, d12);
-      d2 = vis_fpadd16(d2, d22);
-      d3 = vis_fpadd16(d3, d03);
-      d3 = vis_fpadd16(d3, d13);
-      d3 = vis_fpadd16(d3, d23);
-      d4 = vis_fpadd16(d4, d04);
-      d4 = vis_fpadd16(d4, d14);
-      d4 = vis_fpadd16(d4, d24);
-      d5 = vis_fpadd16(d5, d05);
-      d5 = vis_fpadd16(d5, d15);
-      d5 = vis_fpadd16(d5, d25);
-
-      buffe[i] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      buffd[2 * i] = drnd;
-      buffd[2 * i + 1] = drnd;
-      buffd[2 * i + 2] = drnd;
-      buffd[2 * i + 3] = drnd;
-      buffd[2 * i + 4] = drnd;
-      buffd[2 * i + 5] = drnd;
-
-      LOAD_SRC();
-    }
-
-    ColorTrue2IndexLine((void *)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-
-    if (buff_ind >= (KSIZE + 1))
-      buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
 #define MAX_N   11
 
-#ifdef CONV_INDEX
-
-mlib_status mlib_convMxN_Index3_8_8nw(mlib_image       *dst,
-                                      const mlib_image *src,
-                                      mlib_s32         m,
-                                      mlib_s32         n,
-                                      mlib_s32         dm,
-                                      mlib_s32         dn,
-                                      const mlib_s32   *kern,
-                                      mlib_s32         scale,
-                                      const void       *colormap)
-#else
-
 mlib_status mlib_convMxN_8nw_f(mlib_image       *dst,
                                const mlib_image *src,
                                mlib_s32         m,
@@ -863,7 +83,6 @@
                                mlib_s32         dn,
                                const mlib_s32   *kern,
                                mlib_s32         scale)
-#endif /* CONV_INDEX */
 {
   mlib_d64 *buffs_local[3 * (MAX_N + 1)], **buffs = buffs_local, **buff;
   mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe;
@@ -884,11 +103,7 @@
   buff = buffs + 2 * (n + 1);
 
   sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + dn * dll + dm;
-#else
   dl = adr_dst + dn * dll + dm * NCHAN;
-#endif /* CONV_INDEX */
 
   ssize = NCHAN * wid;
   dsize = (ssize + 7) / 8;
@@ -919,17 +134,8 @@
     mlib_d64 *buffn = buffs[l];
     sp = sl + l * sll;
 
-#ifndef CONV_INDEX
-
     if ((mlib_addr) sp & 7)
       mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-
-#endif /* CONV_INDEX */
   }
 
   /* init buffer */
@@ -950,7 +156,6 @@
 
     buffn = buffc[n];
 
-#ifndef CONV_INDEX
     for (l = 0; l < n; l++) {
       if ((((mlib_addr) (sl + l * sll)) & 7) == 0)
         buff[l] = (mlib_d64 *) (sl + l * sll);
@@ -958,31 +163,18 @@
 
     if ((mlib_addr) sp & 7)
       mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#endif /* CONV_INDEX */
 
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
     ik_last = (m - 1);
-#endif /* CONV_INDEX */
 
     for (jk = 0; jk < n; jk += jk_size) {
       jk_size = n - jk;
-#ifdef CONV_INDEX
-
-      if (jk_size >= 5)
-        jk_size = 3;
-
-      if (jk_size == 4)
-        jk_size = 2;
-#else
 
       if (jk_size >= 6)
         jk_size = 4;
 
       if (jk_size == 5)
         jk_size = 3;
-#endif /* CONV_INDEX */
+
       coff = 0;
 
       if (jk_size == 1) {
@@ -1335,21 +527,12 @@
      *****************************************/
 
     jk_size = n;
-#ifdef CONV_INDEX
-
-    if (jk_size >= 5)
-      jk_size = 3;
-
-    if (jk_size == 4)
-      jk_size = 2;
-#else
 
     if (jk_size >= 6)
       jk_size = 4;
 
     if (jk_size == 5)
       jk_size = 3;
-#endif /* CONV_INDEX */
 
     k0 = karr[ik_last];
     k1 = karr[ik_last + m];
@@ -1365,8 +548,6 @@
     buff3 = buff[3] + doff;
     vis_write_gsr(gsr_scale + off);
 
-#ifndef CONV_INDEX
-
     if (jk_size == 1) {
       dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl;
 
@@ -1652,200 +833,6 @@
         mlib_ImageCopy_na((void *)buffe, dl, xsize);
     }
 
-#else /* CONV_INDEX */
-
-    if (jk_size == 1) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-
-        d0 = buffd[2 * i];
-        d1 = buffd[2 * i + 1];
-        d2 = buffd[2 * i + 2];
-        d3 = buffd[2 * i + 3];
-        d4 = buffd[2 * i + 4];
-        d5 = buffd[2 * i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d1 = vis_fpadd16(d1, d01);
-        d2 = vis_fpadd16(d2, d02);
-        d3 = vis_fpadd16(d3, d03);
-        d4 = vis_fpadd16(d4, d04);
-        d5 = vis_fpadd16(d5, d05);
-
-        buffe[i] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2 * i] = drnd;
-        buffd[2 * i + 1] = drnd;
-        buffd[2 * i + 2] = drnd;
-        buffd[2 * i + 3] = drnd;
-        buffd[2 * i + 4] = drnd;
-        buffd[2 * i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-    else if (jk_size == 2) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-        d0 = buffd[2 * i];
-        d1 = buffd[2 * i + 1];
-        d2 = buffd[2 * i + 2];
-        d3 = buffd[2 * i + 3];
-        d4 = buffd[2 * i + 4];
-        d5 = buffd[2 * i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-
-        buffe[i] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2 * i] = drnd;
-        buffd[2 * i + 1] = drnd;
-        buffd[2 * i + 2] = drnd;
-        buffd[2 * i + 3] = drnd;
-        buffd[2 * i + 4] = drnd;
-        buffd[2 * i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-    else {                                  /* if (jk_size == 3) */
-
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d20, d21, d22, d23, d24, d25;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-        mlib_d64 s20 = buff2[i];
-        mlib_d64 s21 = buff2[i + 1];
-        mlib_d64 s22 = buff2[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-        d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-        d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-        d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-        d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-        d0 = buffd[2 * i];
-        d1 = buffd[2 * i + 1];
-        d2 = buffd[2 * i + 2];
-        d3 = buffd[2 * i + 3];
-        d4 = buffd[2 * i + 4];
-        d5 = buffd[2 * i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d2 = vis_fpadd16(d2, d22);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d3 = vis_fpadd16(d3, d23);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d4 = vis_fpadd16(d4, d24);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-        d5 = vis_fpadd16(d5, d25);
-
-        buffe[i] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2 * i] = drnd;
-        buffd[2 * i + 1] = drnd;
-        buffd[2 * i + 2] = drnd;
-        buffd[2 * i + 3] = drnd;
-        buffd[2 * i + 4] = drnd;
-        buffd[2 * i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    ColorTrue2IndexLine((void *)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
     sl += sll;
     dl += dll;
 
diff --git a/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java b/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java
index 4973ac3..8fc1a82 100644
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java
@@ -55,8 +55,6 @@
      *               This flag can force us to use d3d
      *               anyway in these situations.  Or, this flag can force us to
      *               not use d3d in a situation where we would use it otherwise.
-     *      translAccelEnabled: usage: "-Dsun.java2d.translaccel=true"
-     *               equivalent to sun.java2d.d3d=true
      *      offscreenSharingEnabled: usage: "-Dsun.java2d.offscreenSharing=true"
      *               Turns on the ability to share a hardware-accelerated
      *               offscreen surface through the JAWT interface.  See
@@ -67,23 +65,6 @@
      *               without being very sure that we will be willing to support
      *               that API in the future regardless of other native
      *               rendering pipeline changes.
-     *      accelReset: usage: "-Dsun.java2d.accelReset"
-     *               This flag tells us to reset any persistent information
-     *               the display device acceleration characteristics so that
-     *               we are forced to retest these characteristics.  This flag
-     *               is primarily used for debugging purposes (to allow testing
-     *               of the persistent storage mechanisms) but may also be
-     *               needed by some users if, for example, a driver upgrade
-     *               may change the runtime characteristics and they want the
-     *               tests to be re-run.
-     *      checkRegistry: usage: "-Dsun.java2d.checkRegistry"
-     *               This flag tells us to output the current registry settings
-     *               (after our initialization) to the console.
-     *      disableRegistry: usage: "-Dsun.java2d.disableRegistry"
-     *               This flag tells us to disable all registry-related
-     *               activities.  It is mainly here for debugging purposes,
-     *               to allow us to see whether any runtime bugs are caused
-     *               by or related to registry problems.
      *      magPresent: usage: "-Djavax.accessibility.screen_magnifier_present"
      *               This flag is set either on the command line or in the
      *               properties file.  It tells Swing whether the user is
@@ -121,9 +102,6 @@
     private static boolean oglEnabled;
     private static boolean oglVerbose;
     private static boolean offscreenSharingEnabled;
-    private static boolean accelReset;
-    private static boolean checkRegistry;
-    private static boolean disableRegistry;
     private static boolean magPresent;
     private static boolean setHighDPIAware;
     // TODO: other flags, including nopixfmt
@@ -234,11 +212,6 @@
                 }
                 offscreenSharingEnabled =
                     getBooleanProp("sun.java2d.offscreenSharing", false);
-                accelReset = getBooleanProp("sun.java2d.accelReset", false);
-                checkRegistry =
-                    getBooleanProp("sun.java2d.checkRegistry", false);
-                disableRegistry =
-                    getBooleanProp("sun.java2d.disableRegistry", false);
                 String dpiOverride = System.getProperty("sun.java2d.dpiaware");
                 if (dpiOverride != null) {
                     setHighDPIAware = dpiOverride.equalsIgnoreCase("true");
@@ -265,22 +238,12 @@
         System.out.println("WindowsFlags (Java):");
         System.out.println("  ddEnabled: " + ddEnabled + "\n" +
                            "  ddOffscreenEnabled: " + ddOffscreenEnabled + "\n" +
-                           "  ddVramForced: " + ddVramForced + "\n" +
-                           "  ddLockEnabled: " + ddLockEnabled + "\n" +
-                           "  ddLockSet: " + ddLockSet + "\n" +
-                           "  ddBlitEnabled: " + ddBlitEnabled + "\n" +
-                           "  ddScaleEnabled: " + ddScaleEnabled + "\n" +
                            "  d3dEnabled: " + d3dEnabled + "\n" +
                            "  d3dSet: " + d3dSet + "\n" +
                            "  oglEnabled: " + oglEnabled + "\n" +
                            "  oglVerbose: " + oglVerbose + "\n" +
                            "  gdiBlitEnabled: " + gdiBlitEnabled + "\n" +
-                           "  translAccelEnabled: " + translAccelEnabled + "\n" +
-                           "  offscreenSharingEnabled: " + offscreenSharingEnabled + "\n" +
-                           "  accelReset: " + accelReset + "\n" +
-                           "  checkRegistry: " + checkRegistry + "\n" +
-                           "  disableRegistry: " + disableRegistry + "\n" +
-                           "  d3dTexBPP: " + d3dTexBpp);
+                           "  offscreenSharingEnabled: " + offscreenSharingEnabled);
         */
     }
 
@@ -304,10 +267,6 @@
         return gdiBlitEnabled;
     }
 
-    public static boolean isTranslucentAccelerationEnabled() {
-        return d3dEnabled;
-    }
-
     public static boolean isOffscreenSharingEnabled() {
         return offscreenSharingEnabled;
     }
diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h
index 91ee7b3..115626c 100644
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,131 +51,8 @@
 
 static const ADAPTER_INFO badHardware[] = {
 
-    // Intel HD
-    // Clarkdale (Desktop) GMA HD Lines
-    { 0x8086, 0x0042, NO_VERSION, OS_ALL },
-    // Arrandale (Mobile) GMA HD Lines
-    { 0x8086, 0x0046, NO_VERSION, OS_ALL },
-
-    // Sandy Bridge HD Graphics 3000/2000
-    { 0x8086, 0x0102, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0106, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0112, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0116, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0122, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0126, NO_VERSION, OS_ALL },
-    { 0x8086, 0x010A, NO_VERSION, OS_ALL },
-
-    // Ivy Bridge
-    { 0x8086, 0x0162, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0162, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0166, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0166, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x016A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x016A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0152, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0152, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0156, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0156, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x015A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x015A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
-    // Haswell
-    { 0x8086, 0x0402, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0402, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0406, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0406, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0412, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0412, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0416, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0416, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x041E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x041E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x040A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x040A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x041A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x041A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A06, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A06, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A16, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A16, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A2E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A2E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A1E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A1E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A0E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A0E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0D26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0D26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0D22, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0D22, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
-    // Reason: workaround for 6620073, 6612195
-    // Intel 740
-    { 0x8086, 0x7800, NO_VERSION, OS_ALL },
-    { 0x8086, 0x1240, NO_VERSION, OS_ALL },
-    { 0x8086, 0x7121, NO_VERSION, OS_ALL },
-    { 0x8086, 0x7123, NO_VERSION, OS_ALL },
-    { 0x8086, 0x7125, NO_VERSION, OS_ALL },
-    { 0x8086, 0x1132, NO_VERSION, OS_ALL },
-    // IEG
-    { 0x8086, 0x2562, NO_VERSION, OS_ALL },
-    { 0x8086, 0x3577, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2572, NO_VERSION, OS_ALL },
-    { 0x8086, 0x3582, NO_VERSION, OS_ALL },
-    { 0x8086, 0x358E, NO_VERSION, OS_ALL },
-    // GMA
-    { 0x8086, 0x2582, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2782, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2592, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2792, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2772, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2776, NO_VERSION, OS_ALL },
-    { 0x8086, 0x27A2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x27A6, NO_VERSION, OS_ALL },
-    { 0x8086, 0x27AE, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29D2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29D3, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29B2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29B3, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29C2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29C3, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA001, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA002, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA011, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA012, NO_VERSION, OS_ALL },
-    // GMA
-    { 0x8086, 0x2972, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2973, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2992, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2993, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29A2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29A3, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2982, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2983, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A02, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A03, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A12, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A13, NO_VERSION, OS_ALL },
-
-    // Eaglelake (Desktop) GMA 4500 Lines
-    { 0x8086, 0x2E42, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E43, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E92, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E93, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E12, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E13, NO_VERSION, OS_ALL },
-    // Eaglelake (Desktop) GMA X4500 Lines
-    { 0x8086, 0x2E32, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E33, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E22, NO_VERSION, OS_ALL },
-    // Eaglelake (Desktop) GMA X4500HD Lines
-    { 0x8086, 0x2E23, NO_VERSION, OS_ALL },
-    // Cantiga (Mobile) GMA 4500MHD Lines
-    { 0x8086, 0x2A42, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A43, NO_VERSION, OS_ALL },
+    // All Intel Chips.
+    { 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL },
 
     // ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350
     // Reason: workaround for 6613066, 6687166
diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp
index 1de213f..528e95e 100644
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp
@@ -27,13 +27,10 @@
 #include "Trace.h"
 #include "WindowsFlags.h"
 
-BOOL      accelReset;         // reset registry 2d acceleration settings
 BOOL      useD3D = TRUE;      // d3d enabled flag
                               // initially is TRUE to allow D3D preloading
 BOOL      forceD3DUsage;      // force d3d on or off
 jboolean  g_offscreenSharing; // JAWT accelerated surface sharing
-BOOL      checkRegistry;      // Diagnostic tool: outputs 2d registry settings
-BOOL      disableRegistry;    // Diagnostic tool: disables registry interaction
 BOOL      setHighDPIAware;    // Whether to set the high-DPI awareness flag
 
 extern WCHAR *j2dAccelKey;       // Name of java2d root key
@@ -95,12 +92,6 @@
     g_offscreenSharing = GetStaticBoolean(env, wFlagsClass,
                                           "offscreenSharingEnabled");
     JNU_CHECK_EXCEPTION(env);
-    accelReset = GetStaticBoolean(env, wFlagsClass, "accelReset");
-    JNU_CHECK_EXCEPTION(env);
-    checkRegistry = GetStaticBoolean(env, wFlagsClass, "checkRegistry");
-    JNU_CHECK_EXCEPTION(env);
-    disableRegistry = GetStaticBoolean(env, wFlagsClass, "disableRegistry");
-    JNU_CHECK_EXCEPTION(env);
 
     setHighDPIAware =
         (IS_WINVISTA && GetStaticBoolean(env, wFlagsClass, "setHighDPIAware"));
@@ -113,12 +104,6 @@
                 (forceD3DUsage ? "true" : "false"));
     J2dTraceLn1(J2D_TRACE_INFO, "  offscreenSharing = %s",
                 (g_offscreenSharing ? "true" : "false"));
-    J2dTraceLn1(J2D_TRACE_INFO, "  accelReset = %s",
-                (accelReset ? "true" : "false"));
-    J2dTraceLn1(J2D_TRACE_INFO, "  checkRegistry = %s",
-                (checkRegistry ? "true" : "false"));
-    J2dTraceLn1(J2D_TRACE_INFO, "  disableRegistry = %s",
-                (disableRegistry ? "true" : "false"));
     J2dTraceLn1(J2D_TRACE_INFO, "  setHighDPIAware = %s",
                 (setHighDPIAware ? "true" : "false"));
 }
diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h
index 68a51e4..1a3f041 100644
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h
@@ -27,12 +27,9 @@
 #ifndef WINDOWSFLAGS_H
 #define WINDOWSFLAGS_H
 
-extern BOOL      accelReset;         // reset registry 2d acceleration settings
 extern BOOL      useD3D;             // d3d enabled flag
 extern BOOL      forceD3DUsage;      // force d3d on or off
 extern jboolean  g_offscreenSharing; // JAWT accelerated surface sharing
-extern BOOL      checkRegistry;      // Diag tool: outputs 2d registry settings
-extern BOOL      disableRegistry;    // Diag tool: disables registry interaction
 extern BOOL      setHighDPIAware;    // whether to set High DPI Aware flag on Vista
 
 void SetD3DEnabledFlag(JNIEnv *env, BOOL d3dEnabled, BOOL d3dSet);
diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
index 746b111..781d4c5 100644
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
@@ -2720,6 +2720,7 @@
     {java_awt_event_KeyEvent_VK_SHIFT,            VK_SHIFT},
     {java_awt_event_KeyEvent_VK_CONTROL,          VK_CONTROL},
     {java_awt_event_KeyEvent_VK_ALT,              VK_MENU},
+    {java_awt_event_KeyEvent_VK_ALT_GRAPH,        VK_RMENU},
     {java_awt_event_KeyEvent_VK_NUM_LOCK,         VK_NUMLOCK},
 
     // Miscellaneous Windows keys
diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp
index 0528148..3baf7f7 100644
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp
@@ -335,6 +335,9 @@
     } else {
         // get the scancode from the virtual key
         scancode = ::MapVirtualKey(vkey, 0);
+        if (vkey == VK_RMENU) {
+            dwFlags |= KEYEVENTF_EXTENDEDKEY;
+        }
         keybd_event(vkey, scancode, dwFlags, 0);
     }
 }
diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp
index 56280a5..b7ec441 100644
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp
@@ -93,6 +93,12 @@
 
 void AwtTrayIcon::Dispose() {
     SendTrayMessage(NIM_DELETE);
+
+    // Destroy the icon to avoid leak of GDI objects
+    if (m_nid.hIcon != NULL) {
+        ::DestroyIcon(m_nid.hIcon);
+    }
+
     UnlinkObjects();
 
     if (--sm_instCount == 0) {
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java
index b3ff5c3..f11b8ed 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java
@@ -26,7 +26,6 @@
 import java.io.Closeable;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.concurrent.ExecutorService;
 import java.util.function.Consumer;
@@ -218,8 +217,8 @@
             }
             returnBuffers(buffers);
         } catch (Throwable t) {
-            t.printStackTrace();
             close();
+            errorHandler.accept(t);
         }
     }
 
@@ -231,8 +230,8 @@
                 doHandshakeImpl(r);
                 channelInputQ.registerPutCallback(this::upperRead);
             } catch (Throwable t) {
-                t.printStackTrace();
                 close();
+                errorHandler.accept(t);
             }
         });
     }
@@ -511,7 +510,7 @@
                     }
                 }
             } catch (Throwable t) {
-                Utils.close(lowerOutput);
+                close();
                 errorHandler.accept(t);
             }
         }
@@ -557,25 +556,37 @@
     }
 
     static void logParams(SSLParameters p) {
-        if (!Log.ssl())
+        if (!Log.ssl()) {
             return;
+        }
+
         Log.logSSL("SSLParameters:");
         if (p == null) {
             Log.logSSL("Null params");
             return;
         }
-        for (String cipher : p.getCipherSuites()) {
-            Log.logSSL("cipher: {0}\n", cipher);
+
+        if (p.getCipherSuites() != null) {
+            for (String cipher : p.getCipherSuites()) {
+                Log.logSSL("cipher: {0}\n", cipher);
+            }
         }
+
+        // SSLParameters.getApplicationProtocols() can't return null
         for (String approto : p.getApplicationProtocols()) {
             Log.logSSL("application protocol: {0}\n", approto);
         }
-        for (String protocol : p.getProtocols()) {
-            Log.logSSL("protocol: {0}\n", protocol);
+
+        if (p.getProtocols() != null) {
+            for (String protocol : p.getProtocols()) {
+                Log.logSSL("protocol: {0}\n", protocol);
+            }
         }
-        if (p.getServerNames() != null)
+
+        if (p.getServerNames() != null) {
             for (SNIServerName sname : p.getServerNames()) {
                 Log.logSSL("server name: {0}\n", sname.toString());
+            }
         }
     }
 
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Http1Request.java b/jdk/src/java.httpclient/share/classes/java/net/http/Http1Request.java
index a4fe194..7523833 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Http1Request.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Http1Request.java
@@ -101,16 +101,13 @@
 
         for (Map.Entry<String,List<String>> entry : entries) {
             String key = entry.getKey();
-            sb.append(key).append(": ");
             List<String> values = entry.getValue();
-            int num = values.size();
             for (String value : values) {
-                sb.append(value);
-                if (--num > 0) {
-                    sb.append(',');
-                }
+                sb.append(key)
+                  .append(": ")
+                  .append(value)
+                  .append("\r\n");
             }
-            sb.append("\r\n");
         }
     }
 
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java b/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java
index 75eab0f..94ddc9b 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java
@@ -364,8 +364,7 @@
     }
 
     void shutdown(Throwable t) {
-        System.err.println("Shutdown: " + t);
-        t.printStackTrace();
+        Log.logError(t);
         closed = true;
         client2.deleteConnection(this);
         Collection<Stream> c = streams.values();
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java b/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java
index 446987d..226cee9 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java
@@ -35,6 +35,7 @@
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -155,6 +156,15 @@
         selmgr.register(exchange);
     }
 
+    /**
+     * Only used from RawChannel to disconnect the channel from
+     * the selector
+     */
+    void cancelRegistration(SocketChannel s) {
+        selmgr.cancel(s);
+    }
+
+
     Http2ClientImpl client2() {
         return client2;
     }
@@ -220,6 +230,13 @@
             selector.wakeup();
         }
 
+        synchronized void cancel(SocketChannel e) {
+            SelectionKey key = e.keyFor(selector);
+            if (key != null)
+                key.cancel();
+            selector.wakeup();
+        }
+
         void wakeupSelector() {
             selector.wakeup();
         }
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java b/jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java
deleted file mode 100644
index c9ff689..0000000
--- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- */
-
-package java.net.http;
-
-public interface HttpHeaders1 extends HttpHeaders {
-    public void makeUnmodifiable();
-}
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java b/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java
index 10758d6..dcbfbdb 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java
@@ -176,7 +176,7 @@
      *
      * @return
      */
-    RawChannel rawChannel() {
+    RawChannel rawChannel() throws IOException {
         if (rawchan == null) {
             rawchan = new RawChannel(request.client(), connection);
         }
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Log.java b/jdk/src/java.httpclient/share/classes/java/net/http/Log.java
index 991edfe..51e5ce9 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Log.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Log.java
@@ -88,7 +88,7 @@
                         logging |= TRACE;
                         break;
                     case "all":
-                        logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE;
+                        logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE|SSL;
                         break;
                 }
                 if (val.startsWith("frames")) {
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Queue.java b/jdk/src/java.httpclient/share/classes/java/net/http/Queue.java
index d3f3360..1016ada 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Queue.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Queue.java
@@ -105,6 +105,8 @@
             while (q.size() == 0) {
                 waiters++;
                 wait();
+                if (closed)
+                    throw new IOException("Queue closed");
                 waiters--;
             }
             return q.removeFirst();
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java
index e4dc3b0..5f6fb4d 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java
@@ -29,6 +29,7 @@
 import java.nio.channels.GatheringByteChannel;
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
 
 //
 // Used to implement WebSocket. Each RawChannel corresponds to a TCP connection
@@ -56,9 +57,21 @@
     interface NonBlockingEvent extends RawEvent {
     }
 
-    RawChannel(HttpClientImpl client, HttpConnection connection) {
+    RawChannel(HttpClientImpl client, HttpConnection connection)
+                                                throws IOException {
         this.client = client;
         this.connection = connection;
+        SocketChannel chan = connection.channel();
+        client.cancelRegistration(chan);
+        chan.configureBlocking(false);
+    }
+
+    SocketChannel socketChannel() {
+        return connection.channel();
+    }
+
+    ByteBuffer getRemaining() {
+        return connection.getRemaining();
     }
 
     private class RawAsyncEvent extends AsyncEvent {
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/ResponseHeaders.java b/jdk/src/java.httpclient/share/classes/java/net/http/ResponseHeaders.java
index ad15bd7..6c25e23 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/ResponseHeaders.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/ResponseHeaders.java
@@ -190,10 +190,11 @@
     List<String> populateMapEntry(String name) {
         List<String> l = getOrCreate(name);
         int[] search = findHeaderValue(name);
-        if (search[0] != -1) {
+        while (search[0] != -1) {
             addEntry(l, name, search[0]);
             // clear the offset
             headerOffsets[search[1]] = -1;
+            search = findHeaderValue(name);
         }
         return l;
     }
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java b/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java
index 91252c9..51d7109 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java
@@ -32,6 +32,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -420,7 +421,7 @@
             }
         } catch (TimeoutException e) {
             throw new HttpTimeoutException("Response timed out");
-        } catch (InterruptedException | ExecutionException e) {
+        } catch (InterruptedException | ExecutionException | CompletionException e) {
             Throwable t = e.getCause();
             if (t instanceof IOException) {
                 throw (IOException)t;
@@ -636,6 +637,7 @@
     void cancelImpl(Throwable e) {
         Log.logTrace("cancelling stream: {0}\n", e.toString());
         inputQ.close();
+        completeResponseExceptionally(e);
         try {
             connection.resetStream(streamid, ResetFrame.CANCEL);
         } catch (IOException | InterruptedException ex) {
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Utils.java b/jdk/src/java.httpclient/share/classes/java/net/http/Utils.java
index 302b39d..9731399 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Utils.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Utils.java
@@ -317,7 +317,6 @@
 
     static void close(Closeable... chans) {
         for (Closeable chan : chans) {
-            System.err.println("Closing " + chan);
             try {
                 chan.close();
             } catch (IOException e) {
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java
index 6a7ddaa..d3cc7da 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java
@@ -24,6 +24,8 @@
  */
 package java.net.http;
 
+import java.io.UncheckedIOException;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
@@ -126,6 +128,8 @@
                         return CompletableFuture.completedFuture(result);
                     } catch (WebSocketHandshakeException e) {
                         return CompletableFuture.failedFuture(e);
+                    } catch (UncheckedIOException ee) {
+                        return CompletableFuture.failedFuture(ee.getCause());
                     }
                 });
     }
@@ -149,7 +153,12 @@
         checkAccept(response, h);
         checkExtensions(response, h);
         String subprotocol = checkAndReturnSubprotocol(response, h);
-        RawChannel channel = ((HttpResponseImpl) response).rawChannel();
+        RawChannel channel = null;
+        try {
+            channel = ((HttpResponseImpl) response).rawChannel();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
         return new Result(subprotocol, channel);
     }
 
diff --git a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c
index 0c57f8b..a74b2b7 100644
--- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c
+++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c
@@ -518,18 +518,22 @@
 splitPathList(const char* str, int* pathCount, char*** paths) {
     int count = 0;
     char** segments = NULL;
+    char** new_segments;
     char* c = (char*) str;
     while (*c != '\0') {
         while (*c == ' ') c++;          /* skip leading spaces */
         if (*c == '\0') {
             break;
         }
-        if (segments == NULL) {
-            segments = (char**)malloc( sizeof(char**) );
-        } else {
-            segments = (char**)realloc( segments, (count+1)*sizeof(char**) );
+        new_segments = (char**)realloc(segments, (count+1)*sizeof(char*));
+        if (new_segments == NULL) {
+            jplis_assert(0);
+            free(segments);
+            count = 0;
+            segments = NULL;
+            break;
         }
-        jplis_assert(segments != (char**)NULL);
+        segments = new_segments;
         segments[count++] = c;
         c = strchr(c, ' ');
         if (c == NULL) {
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
index bc06286..f429452 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
@@ -2506,15 +2506,12 @@
         }
     }
 
-    // Management Support
-    private static LoggingMXBean loggingMXBean = null;
     /**
      * String representation of the
      * {@link javax.management.ObjectName} for the management interface
      * for the logging facility.
      *
      * @see java.lang.management.PlatformLoggingMXBean
-     * @see java.util.logging.LoggingMXBean
      *
      * @since 1.5
      */
@@ -2523,24 +2520,21 @@
 
     /**
      * Returns {@code LoggingMXBean} for managing loggers.
-     * An alternative way to manage loggers is through the
-     * {@link java.lang.management.PlatformLoggingMXBean} interface
-     * that can be obtained by calling:
-     * <pre>
-     *     PlatformLoggingMXBean logging = {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
-     *         ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class);
-     * </pre>
      *
      * @return a {@link LoggingMXBean} object.
      *
+     * @deprecated {@code java.util.logging.LoggingMXBean} is deprecated and
+     *      replaced with {@code java.lang.management.PlatformLoggingMXBean}. Use
+     *      {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
+     *      ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class)
+     *      instead.
+     *
      * @see java.lang.management.PlatformLoggingMXBean
      * @since 1.5
      */
+    @Deprecated(since="9")
     public static synchronized LoggingMXBean getLoggingMXBean() {
-        if (loggingMXBean == null) {
-            loggingMXBean =  new Logging();
-        }
-        return loggingMXBean;
+        return Logging.getInstance();
     }
 
     /**
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/Logging.java b/jdk/src/java.logging/share/classes/java/util/logging/Logging.java
index 70c5950..716e8bc 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/Logging.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Logging.java
@@ -44,16 +44,18 @@
  * @see Logger
  * @see LogManager
  */
-class Logging implements LoggingMXBean {
+@SuppressWarnings("deprecation") // implements LoggingMXBean
+final class Logging implements LoggingMXBean {
 
     private static LogManager logManager = LogManager.getLogManager();
 
     /** Constructor of Logging which is the implementation class
      *  of LoggingMXBean.
      */
-    Logging() {
+    private Logging() {
     }
 
+    @Override
     public List<String> getLoggerNames() {
         Enumeration<String> loggers = logManager.getLoggerNames();
         ArrayList<String> array = new ArrayList<>();
@@ -65,6 +67,7 @@
     }
 
     private static String EMPTY_STRING = "";
+    @Override
     public String getLoggerLevel(String loggerName) {
         Logger l = logManager.getLogger(loggerName);
         if (l == null) {
@@ -79,6 +82,7 @@
         }
     }
 
+    @Override
     public void setLoggerLevel(String loggerName, String levelName) {
         if (loggerName == null) {
             throw new NullPointerException("loggerName is null");
@@ -102,6 +106,7 @@
         logger.setLevel(level);
     }
 
+    @Override
     public String getParentLoggerName( String loggerName ) {
         Logger l = logManager.getLogger( loggerName );
         if (l == null) {
@@ -116,4 +121,11 @@
             return p.getName();
         }
     }
+
+    static Logging getInstance() {
+        return INSTANCE;
+    }
+
+    private static final Logging INSTANCE = new Logging();
+
 }
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java b/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java
index 9d545d8..812eb36 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java
@@ -27,30 +27,23 @@
 
 
 /**
- * The management interface for the logging facility. It is recommended
- * to use the {@link java.lang.management.PlatformLoggingMXBean} management
- * interface that implements all attributes defined in this
- * {@code LoggingMXBean}.  The
- * {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
- * ManagementFactory.getPlatformMXBean} method can be used to obtain
- * the {@code PlatformLoggingMXBean} object representing the management
- * interface for logging.
+ * The management interface for the logging facility.
  *
- * <p>There is a single global instance of the {@code LoggingMXBean}.
- * This instance is an {@link javax.management.MXBean MXBean} that
- * can be obtained by calling the {@link LogManager#getLoggingMXBean}
- * method or from the
- * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
+ * {@link java.lang.management.PlatformLoggingMXBean
+ * java.lang.management.PlatformLoggingMXBean} is the management interface
+ * for logging facility registered in the {@link
+ * java.lang.management.ManagementFactory#getPlatformMBeanServer()
  * platform MBeanServer}.
- * <p>
- * The {@link javax.management.ObjectName ObjectName} that uniquely identifies
- * the management interface for logging within the {@code MBeanServer} is:
- * <pre>
- *    {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
- * </pre>
- * <p>
- * The instance registered in the platform {@code MBeanServer}
- * is also a {@link java.lang.management.PlatformLoggingMXBean}.
+ * It is recommended to use the {@code PlatformLoggingMXBean} obtained via
+ * the {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
+ * ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class)} method.
+ *
+ * @deprecated {@code LoggingMXBean} is no longer a {@link
+ * java.lang.management.PlatformManagedObject platform MXBean} and is replaced
+ * with {@link java.lang.management.PlatformLoggingMXBean}.
+ * It will not register in the platform {@code MBeanServer}.
+ * Use {@code ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class)}
+ * instead.
  *
  * @author  Ron Mann
  * @author  Mandy Chung
@@ -58,6 +51,7 @@
  *
  * @see java.lang.management.PlatformLoggingMXBean
  */
+@Deprecated(since="9")
 public interface LoggingMXBean {
 
     /**
diff --git a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java
index 8d0083f..9a6252a 100644
--- a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java
+++ b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java
@@ -598,9 +598,8 @@
 
         try {
             final ObjectName objName = new ObjectName(mxbeanName);
-            // skip the isInstanceOf check for LoggingMXBean
             String intfName = mxbeanInterface.getName();
-            if (!connection.isInstanceOf(objName, intfName)) {
+            if (!isInstanceOf(connection, objName, intfName)) {
                 throw new IllegalArgumentException(mxbeanName +
                     " is not an instance of " + mxbeanInterface);
             }
@@ -616,6 +615,33 @@
         }
     }
 
+    // This makes it possible to obtain an instance of LoggingMXBean
+    // using newPlatformMXBeanProxy(mbs, on, LoggingMXBean.class)
+    // even though the underlying MXBean no longer implements
+    // java.util.logging.LoggingMXBean.
+    // Altough java.util.logging.LoggingMXBean is deprecated, an application
+    // that uses newPlatformMXBeanProxy(mbs, on, LoggingMXBean.class) will
+    // continue to work.
+    //
+    private static boolean isInstanceOf(MBeanServerConnection connection,
+            ObjectName objName, String intfName)
+            throws InstanceNotFoundException, IOException
+    {
+        // special case for java.util.logging.LoggingMXBean.
+        // java.util.logging.LoggingMXBean is deprecated and
+        // replaced with java.lang.management.PlatformLoggingMXBean,
+        // so we will consider that any MBean implementing
+        // java.lang.management.PlatformLoggingMXBean also implements
+        // java.util.logging.LoggingMXBean.
+        if ("java.util.logging.LoggingMXBean".equals(intfName)) {
+            if (connection.isInstanceOf(objName,
+                    PlatformLoggingMXBean.class.getName())) {
+                return true;
+            }
+        }
+        return connection.isInstanceOf(objName, intfName);
+    }
+
     /**
      * Returns the platform MXBean implementing
      * the given {@code mxbeanInterface} which is specified
diff --git a/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java b/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java
index d18d0b3..80595dd 100644
--- a/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java
+++ b/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java
@@ -44,10 +44,6 @@
  *      {@link java.util.logging.LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
  * </pre>
  *
- * <p>The instance registered in the platform {@code MBeanServer} with
- * this {@code ObjectName} implements all attributes defined by
- * {@link java.util.logging.LoggingMXBean}.
- *
  * @since   1.7
  */
 public interface PlatformLoggingMXBean extends PlatformManagedObject {
diff --git a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java
index 44682b2..4eb5742 100644
--- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java
+++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java
@@ -26,6 +26,8 @@
 package sun.management;
 
 import java.lang.management.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
@@ -43,9 +45,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Module;
+import java.lang.reflect.UndeclaredThrowableException;
 import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
 
 /**
  * ManagementFactoryHelper provides static factory methods to create
@@ -66,6 +72,7 @@
         return jvm;
     }
 
+    static final String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
     private static ClassLoadingImpl    classMBean = null;
     private static MemoryImpl          memoryMBean = null;
     private static ThreadImpl          threadMBean = null;
@@ -145,74 +152,138 @@
     }
 
     public static PlatformLoggingMXBean getPlatformLoggingMXBean() {
-        if (LoggingMXBeanSupport.isAvailable()) {
-            return PlatformLoggingImpl.instance;
+        if (LoggingMXBeanAccess.isAvailable()) {
+            return PlatformLoggingImpl.MBEAN;
         } else {
             return null;
         }
     }
 
     public static boolean isPlatformLoggingMXBeanAvailable() {
-        return LoggingMXBeanSupport.isAvailable();
+        return LoggingMXBeanAccess.isAvailable();
     }
 
-    /**
-     * The logging MXBean object is an instance of
-     * PlatformLoggingMXBean and java.util.logging.LoggingMXBean
-     * but it can't directly implement two MXBean interfaces
-     * as a compliant MXBean implements exactly one MXBean interface,
-     * or if it implements one interface that is a subinterface of
-     * all the others; otherwise, it is a non-compliant MXBean
-     * and MBeanServer will throw NotCompliantMBeanException.
-     * See the Definition of an MXBean section in javax.management.MXBean spec.
-     *
-     * To create a compliant logging MXBean, define a LoggingMXBean interface
-     * that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean
-    */
-    public interface LoggingMXBean
-        extends PlatformLoggingMXBean, java.util.logging.LoggingMXBean {
-    }
-
-    // This is a trick: if java.util.logging is not present then
-    // attempting to access something that implements
-    // java.util.logging.LoggingMXBean will trigger a CNFE.
-    // So we cannot directly call any static method or access any static field
-    // on PlatformLoggingImpl, as we would risk raising a CNFE.
-    // Instead we use this intermediate LoggingMXBeanSupport class to determine
+    // The LoggingMXBeanAccess class uses reflection to determine
     // whether java.util.logging is present, and load the actual LoggingMXBean
     // implementation.
     //
-    static final class LoggingMXBeanSupport {
-        final static Object loggingImpl =
-                AccessController.doPrivileged(new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                try {
-                    // create a LoggingProxyImpl instance when
-                    // java.util.logging classes exist
-                    Class<?> c = Class.forName("java.util.logging.Logging", true, null);
-                    Constructor<?> cons = c.getDeclaredConstructor();
-                    cons.setAccessible(true);
-                    return cons.newInstance();
-                } catch (ClassNotFoundException cnf) {
-                    return null;
-                } catch (NoSuchMethodException | InstantiationException
-                        | IllegalAccessException | InvocationTargetException e) {
-                    throw new AssertionError(e);
-                }
-            }});
+    static final class LoggingMXBeanAccess {
+
+        final static String LOG_MANAGER_CLASS_NAME = "java.util.logging.LogManager";
+        final static String LOGGING_MXBEAN_CLASS_NAME = "java.util.logging.LoggingMXBean";
+        final static Class<?> LOG_MANAGER_CLASS = loadLoggingClass(LOG_MANAGER_CLASS_NAME);
 
         static boolean isAvailable() {
-            return loggingImpl != null;
+            return LOG_MANAGER_CLASS != null;
         }
+
+        private static Class<?> loadLoggingClass(String className) {
+            return AccessController.doPrivileged(new PrivilegedAction<>() {
+                @Override
+                public Class<?> run() {
+                    Optional<Module> logging = java.lang.reflect.Layer.boot()
+                        .findModule("java.logging");
+                    if (logging.isPresent()) {
+                        return Class.forName(logging.get(), className);
+                    }
+                    return null;
+                }
+            });
+        }
+
+        private Map<String, Method> initMethodMap(Object impl) {
+            if (impl == null) {
+                return Collections.emptyMap();
+            }
+            Class<?> intfClass = loadLoggingClass(LOGGING_MXBEAN_CLASS_NAME);
+            final Map<String, Method> methodsMap = new HashMap<>();
+            for (Method m : intfClass.getMethods()) {
+                try {
+                    // Sanity checking: all public methods present in
+                    // java.util.logging.LoggingMXBean should
+                    // also be in PlatformLoggingMXBean
+                    Method specMethod = PlatformLoggingMXBean.class
+                             .getMethod(m.getName(), m.getParameterTypes());
+                    if (specMethod.getReturnType().isAssignableFrom(m.getReturnType())) {
+                        if (methodsMap.putIfAbsent(m.getName(), m) != null) {
+                            throw new RuntimeException("unexpected polymorphic method: "
+                                     + m.getName());
+                        }
+                    }
+                } catch (NoSuchMethodException x) {
+                    // All methods in java.util.logging.LoggingMXBean should
+                    // also be in PlatformLoggingMXBean
+                    throw new InternalError(x);
+                }
+            }
+            return Collections.unmodifiableMap(methodsMap);
+        }
+
+        private static Object getMXBeanImplementation() {
+            if (!isAvailable()) {
+                // should not happen
+                throw new NoClassDefFoundError(LOG_MANAGER_CLASS_NAME);
+            }
+            try {
+                final Method m = LOG_MANAGER_CLASS.getMethod("getLoggingMXBean");
+                return m.invoke(null);
+            } catch (NoSuchMethodException
+                    | IllegalAccessException
+                    | InvocationTargetException x) {
+                throw new ExceptionInInitializerError(x);
+            }
+         }
+
+        // The implementation object, which will be invoked through
+        // reflection. The implementation does not need to implement
+        // PlatformLoggingMXBean, but must declare the same methods
+        // with same signatures, and they must be public, with one
+        // exception:
+        // getObjectName will not be called on the implementation object,
+        // so the implementation object does not need to declare such
+        // a method.
+        final Object impl = getMXBeanImplementation();
+        final Map<String, Method> methods = initMethodMap(impl);
+
+        LoggingMXBeanAccess() {
+        }
+
+        <T> T invoke(String methodName, Object... args) {
+            Method m = methods.get(methodName);
+            if (m == null) {
+                throw new UnsupportedOperationException(methodName);
+            }
+            try {
+                @SuppressWarnings("unchecked")
+                T result = (T) m.invoke(impl, args);
+                return result;
+            } catch (IllegalAccessException ex) {
+                throw new UnsupportedOperationException(ex);
+            } catch (InvocationTargetException ex) {
+                throw unwrap(ex);
+            }
+        }
+
+        private static RuntimeException unwrap(InvocationTargetException x) {
+            Throwable t = x.getCause();
+            if (t instanceof RuntimeException) {
+                return (RuntimeException)t;
+            }
+            if (t instanceof Error) {
+                throw (Error)t;
+            }
+            return new UndeclaredThrowableException(t == null ? x : t);
+        }
+
+
     }
 
-    static class PlatformLoggingImpl implements LoggingMXBean
-    {
-        final static java.util.logging.LoggingMXBean impl =
-                (java.util.logging.LoggingMXBean) LoggingMXBeanSupport.loggingImpl;
-        final static PlatformLoggingMXBean instance = new PlatformLoggingImpl();
-        final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
+    static final class PlatformLoggingImpl implements PlatformLoggingMXBean {
+
+        private final LoggingMXBeanAccess loggingAccess;
+        private PlatformLoggingImpl(LoggingMXBeanAccess loggingAccess) {
+            this.loggingAccess = loggingAccess;
+        }
 
         private volatile ObjectName objname;  // created lazily
         @Override
@@ -232,23 +303,29 @@
 
         @Override
         public java.util.List<String> getLoggerNames() {
-            return impl.getLoggerNames();
+            return loggingAccess.invoke("getLoggerNames");
         }
 
         @Override
         public String getLoggerLevel(String loggerName) {
-            return impl.getLoggerLevel(loggerName);
+            return loggingAccess.invoke("getLoggerLevel", loggerName);
         }
 
         @Override
         public void setLoggerLevel(String loggerName, String levelName) {
-            impl.setLoggerLevel(loggerName, levelName);
+            loggingAccess.invoke("setLoggerLevel", loggerName, levelName);
         }
 
         @Override
         public String getParentLoggerName(String loggerName) {
-            return impl.getParentLoggerName(loggerName);
+            return loggingAccess.invoke("getParentLoggerName", loggerName);
         }
+
+        private static PlatformLoggingImpl getInstance() {
+            return new PlatformLoggingImpl(new LoggingMXBeanAccess());
+         }
+
+        static final PlatformLoggingMXBean MBEAN = getInstance();
     }
 
     private static List<BufferPoolMXBean> bufferPools = null;
diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java
index e60507f..b3a0e8b 100644
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java
@@ -424,6 +424,9 @@
                 } catch (UnknownHostException | SecurityException e) {
                     // not canonicalized or no permission to do so, use old
                 }
+                if (hostName.endsWith(".")) {
+                    hostName = hostName.substring(0, hostName.length() - 1);
+                }
                 nameParts[1] = hostName.toLowerCase(Locale.ENGLISH);
             }
             nameStrings = nameParts;
diff --git a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
index 4a9562b..a5e965e 100644
--- a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
+++ b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
@@ -258,7 +258,7 @@
     /*
      * Convenience method for simple commands
      */
-    private InputStream executeCommand(String cmd, Object ... args) throws IOException {
+    public InputStream executeCommand(String cmd, Object ... args) throws IOException {
         try {
             return execute(cmd, args);
         } catch (AgentLoadException x) {
diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java
index 2c9337d..9b7edac 100644
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java
@@ -2498,6 +2498,12 @@
                     //ignore
                 }
 
+                if (o instanceof Runnable) {
+                    ((Runnable) o).run();
+                    sb.setLength(0);
+                    continue;
+                }
+
                 // Search mode.
                 //
                 // Note that we have to do this first, because if there is a command
diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
new file mode 100644
index 0000000..7e4bbbf
--- /dev/null
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
@@ -0,0 +1,418 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.jline.extra;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.function.Supplier;
+
+import jdk.internal.jline.console.ConsoleReader;
+import jdk.internal.jline.console.KeyMap;
+import jdk.internal.jline.console.history.History;
+import jdk.internal.jline.console.history.History.Entry;
+import jdk.internal.jline.console.history.MemoryHistory;
+
+/*Public for tests (HistoryTest).
+ */
+public abstract class EditingHistory implements History {
+
+    private final History fullHistory;
+    private History currentDelegate;
+
+    protected EditingHistory(ConsoleReader in, Iterable<? extends String> originalHistory) {
+        this.fullHistory = new MemoryHistory();
+        this.currentDelegate = fullHistory;
+        bind(in, CTRL_UP,
+             (Runnable) () -> moveHistoryToSnippet(in, ((EditingHistory) in.getHistory())::previousSnippet));
+        bind(in, CTRL_DOWN,
+             (Runnable) () -> moveHistoryToSnippet(in, ((EditingHistory) in.getHistory())::nextSnippet));
+        load(originalHistory);
+    }
+
+    private void moveHistoryToSnippet(ConsoleReader in, Supplier<Boolean> action) {
+        if (!action.get()) {
+            try {
+                in.beep();
+            } catch (IOException ex) {
+                throw new IllegalStateException(ex);
+            }
+        } else {
+            try {
+                //could use:
+                //in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1);
+                //but that would mean more re-writing on the screen, (and prints an additional
+                //empty line), so using setBuffer directly:
+                Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class);
+
+                setBuffer.setAccessible(true);
+                setBuffer.invoke(in, in.getHistory().current().toString());
+                in.flush();
+            } catch (ReflectiveOperationException | IOException ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+    }
+
+    private void bind(ConsoleReader in, String shortcut, Object action) {
+        KeyMap km = in.getKeys();
+        for (int i = 0; i < shortcut.length(); i++) {
+            Object value = km.getBound(Character.toString(shortcut.charAt(i)));
+            if (value instanceof KeyMap) {
+                km = (KeyMap) value;
+            } else {
+                km.bind(shortcut.substring(i), action);
+            }
+        }
+    }
+
+    private static final String CTRL_UP = "\033\133\061\073\065\101"; //Ctrl-UP
+    private static final String CTRL_DOWN = "\033\133\061\073\065\102"; //Ctrl-DOWN
+
+    @Override
+    public int size() {
+        return currentDelegate.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return currentDelegate.isEmpty();
+    }
+
+    @Override
+    public int index() {
+        return currentDelegate.index();
+    }
+
+    @Override
+    public void clear() {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        currentDelegate.clear();
+    }
+
+    @Override
+    public CharSequence get(int index) {
+        return currentDelegate.get(index);
+    }
+
+    @Override
+    public void add(CharSequence line) {
+        NarrowingHistoryLine currentLine = null;
+        int origIndex = fullHistory.index();
+        int fullSize;
+        try {
+            fullHistory.moveToEnd();
+            fullSize = fullHistory.index();
+            if (currentDelegate == fullHistory) {
+                if (origIndex < fullHistory.index()) {
+                    for (Entry entry : fullHistory) {
+                        if (!(entry.value() instanceof NarrowingHistoryLine))
+                            continue;
+                        int[] cluster = ((NarrowingHistoryLine) entry.value()).span;
+                        if (cluster[0] == origIndex && cluster[1] > cluster[0]) {
+                            currentDelegate = new MemoryHistory();
+                            for (int i = cluster[0]; i <= cluster[1]; i++) {
+                                currentDelegate.add(fullHistory.get(i));
+                            }
+                        }
+                    }
+                }
+            }
+            fullHistory.moveToEnd();
+            while (fullHistory.previous()) {
+                CharSequence c = fullHistory.current();
+                if (c instanceof NarrowingHistoryLine) {
+                    currentLine = (NarrowingHistoryLine) c;
+                    break;
+                }
+            }
+        } finally {
+            fullHistory.moveTo(origIndex);
+        }
+        if (currentLine == null || currentLine.span[1] != (-1)) {
+            line = currentLine = new NarrowingHistoryLine(line, fullSize);
+        }
+        StringBuilder complete = new StringBuilder();
+        for (int i = currentLine.span[0]; i < fullSize; i++) {
+            complete.append(fullHistory.get(i));
+        }
+        complete.append(line);
+        if (isComplete(complete)) {
+            currentLine.span[1] = fullSize; //TODO: +1?
+            currentDelegate = fullHistory;
+        }
+        fullHistory.add(line);
+    }
+
+    protected abstract boolean isComplete(CharSequence input);
+
+    @Override
+    public void set(int index, CharSequence item) {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        currentDelegate.set(index, item);
+    }
+
+    @Override
+    public CharSequence remove(int i) {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        return currentDelegate.remove(i);
+    }
+
+    @Override
+    public CharSequence removeFirst() {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        return currentDelegate.removeFirst();
+    }
+
+    @Override
+    public CharSequence removeLast() {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        return currentDelegate.removeLast();
+    }
+
+    @Override
+    public void replace(CharSequence item) {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        currentDelegate.replace(item);
+    }
+
+    @Override
+    public ListIterator<Entry> entries(int index) {
+        return currentDelegate.entries(index);
+    }
+
+    @Override
+    public ListIterator<Entry> entries() {
+        return currentDelegate.entries();
+    }
+
+    @Override
+    public Iterator<Entry> iterator() {
+        return currentDelegate.iterator();
+    }
+
+    @Override
+    public CharSequence current() {
+        return currentDelegate.current();
+    }
+
+    @Override
+    public boolean previous() {
+        return currentDelegate.previous();
+    }
+
+    @Override
+    public boolean next() {
+        return currentDelegate.next();
+    }
+
+    @Override
+    public boolean moveToFirst() {
+        return currentDelegate.moveToFirst();
+    }
+
+    @Override
+    public boolean moveToLast() {
+        return currentDelegate.moveToLast();
+    }
+
+    @Override
+    public boolean moveTo(int index) {
+        return currentDelegate.moveTo(index);
+    }
+
+    @Override
+    public void moveToEnd() {
+        currentDelegate.moveToEnd();
+    }
+
+    public boolean previousSnippet() {
+        for (int i = index() - 1; i >= 0; i--) {
+            if (get(i) instanceof NarrowingHistoryLine) {
+                moveTo(i);
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean nextSnippet() {
+        for (int i = index() + 1; i < size(); i++) {
+            if (get(i) instanceof NarrowingHistoryLine) {
+                moveTo(i);
+                return true;
+            }
+        }
+
+        if (index() < size()) {
+            moveToEnd();
+            return true;
+        }
+
+        return false;
+    }
+
+    public final void load(Iterable<? extends String> originalHistory) {
+        NarrowingHistoryLine currentHistoryLine = null;
+        boolean start = true;
+        int currentLine = 0;
+        for (String historyItem : originalHistory) {
+            StringBuilder line = new StringBuilder(historyItem);
+            int trailingBackSlashes = countTrailintBackslashes(line);
+            boolean continuation = trailingBackSlashes % 2 != 0;
+            line.delete(line.length() - trailingBackSlashes / 2 - (continuation ? 1 : 0), line.length());
+            if (start) {
+                class PersistentNarrowingHistoryLine extends NarrowingHistoryLine implements PersistentEntryMarker {
+                    public PersistentNarrowingHistoryLine(CharSequence delegate, int start) {
+                        super(delegate, start);
+                    }
+                }
+                fullHistory.add(currentHistoryLine = new PersistentNarrowingHistoryLine(line, currentLine));
+            } else {
+                class PersistentLine implements CharSequence, PersistentEntryMarker {
+                    private final CharSequence delegate;
+                    public PersistentLine(CharSequence delegate) {
+                        this.delegate = delegate;
+                    }
+                    @Override public int length() {
+                        return delegate.length();
+                    }
+                    @Override public char charAt(int index) {
+                        return delegate.charAt(index);
+                    }
+                    @Override public CharSequence subSequence(int start, int end) {
+                        return delegate.subSequence(start, end);
+                    }
+                    @Override public String toString() {
+                        return delegate.toString();
+                    }
+                }
+                fullHistory.add(new PersistentLine(line));
+            }
+            start = !continuation;
+            currentHistoryLine.span[1] = currentLine;
+            currentLine++;
+        }
+    }
+
+    public Collection<? extends String> save() {
+        Collection<String> result = new ArrayList<>();
+        Iterator<Entry> entries = fullHistory.iterator();
+
+        if (entries.hasNext()) {
+            Entry entry = entries.next();
+            while (entry != null) {
+                StringBuilder historyLine = new StringBuilder(entry.value());
+                int trailingBackSlashes = countTrailintBackslashes(historyLine);
+                for (int i = 0; i < trailingBackSlashes; i++) {
+                    historyLine.append("\\");
+                }
+                entry = entries.hasNext() ? entries.next() : null;
+                if (entry != null && !(entry.value() instanceof NarrowingHistoryLine)) {
+                    historyLine.append("\\");
+                }
+                result.add(historyLine.toString());
+            }
+        }
+
+        return result;
+    }
+
+    private int countTrailintBackslashes(CharSequence text) {
+        int count = 0;
+
+        for (int i = text.length() - 1; i >= 0; i--) {
+            if (text.charAt(i) == '\\') {
+                count++;
+            } else {
+                break;
+            }
+        }
+
+        return count;
+    }
+
+    public List<String> currentSessionEntries() {
+        List<String> result = new ArrayList<>();
+
+        for (Entry e : fullHistory) {
+            if (!(e.value() instanceof PersistentEntryMarker)) {
+                result.add(e.value().toString());
+            }
+        }
+
+        return result;
+    }
+
+    public void fullHistoryReplace(String source) {
+        fullHistory.replace(source);
+    }
+
+    private class NarrowingHistoryLine implements CharSequence {
+        private final CharSequence delegate;
+        private final int[] span;
+
+        public NarrowingHistoryLine(CharSequence delegate, int start) {
+            this.delegate = delegate;
+            this.span = new int[] {start, -1};
+        }
+
+        @Override
+        public int length() {
+            return delegate.length();
+        }
+
+        @Override
+        public char charAt(int index) {
+            return delegate.charAt(index);
+        }
+
+        @Override
+        public CharSequence subSequence(int start, int end) {
+            return delegate.subSequence(start, end);
+        }
+
+        @Override
+        public String toString() {
+            return delegate.toString();
+        }
+
+    }
+
+    private interface PersistentEntryMarker {}
+}
+
diff --git a/jdk/src/jdk.internal.le/share/classes/module-info.java b/jdk/src/jdk.internal.le/share/classes/module-info.java
index b4ae508..d52b3b5 100644
--- a/jdk/src/jdk.internal.le/share/classes/module-info.java
+++ b/jdk/src/jdk.internal.le/share/classes/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,9 @@
     exports jdk.internal.jline.console.history to
         jdk.scripting.nashorn.shell,
         jdk.jshell;
+    exports jdk.internal.jline.extra to
+        jdk.scripting.nashorn.shell,
+        jdk.jshell;
     exports jdk.internal.jline.internal to
         jdk.scripting.nashorn.shell,
         jdk.jshell;
diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
index 0559fff..85381b7 100644
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
@@ -38,6 +38,7 @@
 import java.lang.module.ResolutionException;
 import java.lang.module.ResolvedModule;
 import java.net.URI;
+import java.nio.ByteBuffer;
 import java.nio.file.Path;
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -62,6 +63,7 @@
 import static jdk.internal.util.jar.JarIndex.INDEX_NAME;
 import static java.util.jar.JarFile.MANIFEST_NAME;
 import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toSet;
 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
 
 /**
@@ -125,14 +127,12 @@
     boolean printModuleDescriptor;
     Version moduleVersion;
     Pattern modulesToHash;
-    ModuleFinder moduleFinder = ModuleFinder.empty();
+    ModuleFinder moduleFinder = ModuleFinder.of();
 
     private static final String MODULE_INFO = "module-info.class";
 
-    Path moduleInfo;
-    private boolean isModularJar() { return moduleInfo != null; }
-
     static final String MANIFEST_DIR = "META-INF/";
+    static final String VERSIONS_DIR = MANIFEST_DIR + "versions/";
     static final String VERSION = "1.0";
 
     private static ResourceBundle rsrc;
@@ -242,12 +242,27 @@
                         addMainClass(manifest, ename);
                     }
                 }
-                expand(null, files, false);
+                Map<String,Path> moduleInfoPaths = new HashMap<>();
+                expand(null, files, false, moduleInfoPaths);
 
-                byte[] moduleInfoBytes = null;
-                if (isModularJar()) {
-                    moduleInfoBytes = addExtendedModuleAttributes(
-                            readModuleInfo(moduleInfo));
+                Map<String,byte[]> moduleInfos = new LinkedHashMap<>();
+                if (!moduleInfoPaths.isEmpty()) {
+                    if (!checkModuleInfos(moduleInfoPaths))
+                        return false;
+
+                    // root module-info first
+                    byte[] b = readModuleInfo(moduleInfoPaths.get(MODULE_INFO));
+                    moduleInfos.put(MODULE_INFO, b);
+                    for (Map.Entry<String,Path> e : moduleInfoPaths.entrySet())
+                        moduleInfos.putIfAbsent(e.getKey(), readModuleInfo(e.getValue()));
+
+                    if (!addExtendedModuleAttributes(moduleInfos))
+                        return false;
+
+                    // Basic consistency checks for modular jars.
+                    if (!checkServices(moduleInfos.get(MODULE_INFO)))
+                        return false;
+
                 } else if (moduleVersion != null || modulesToHash != null) {
                     error(getMsg("error.module.options.without.info"));
                     return false;
@@ -274,13 +289,7 @@
                     tmpfile = createTemporaryFile(tmpbase, ".jar");
                     out = new FileOutputStream(tmpfile);
                 }
-                create(new BufferedOutputStream(out, 4096), manifest, moduleInfoBytes);
-
-                // Consistency checks for modular jars.
-                if (isModularJar()) {
-                    if (!checkServices(moduleInfoBytes))
-                        return false;
-                }
+                create(new BufferedOutputStream(out, 4096), manifest, moduleInfos);
 
                 if (in != null) {
                     in.close();
@@ -337,19 +346,20 @@
                 }
                 InputStream manifest = (!Mflag && (mname != null)) ?
                     (new FileInputStream(mname)) : null;
-                expand(null, files, true);
 
-                byte[] moduleInfoBytes = null;
-                if (isModularJar()) {
-                    moduleInfoBytes = readModuleInfo(moduleInfo);
-                }
+                Map<String,Path> moduleInfoPaths = new HashMap<>();
+                expand(null, files, true, moduleInfoPaths);
+
+                Map<String,byte[]> moduleInfos = new HashMap<>();
+                for (Map.Entry<String,Path> e : moduleInfoPaths.entrySet())
+                    moduleInfos.put(e.getKey(), readModuleInfo(e.getValue()));
 
                 boolean updateOk = update(in, new BufferedOutputStream(out),
-                                          manifest, moduleInfoBytes, null);
+                                          manifest, moduleInfos, null);
 
                 // Consistency checks for modular jars.
-                if (isModularJar()) {
-                    if(!checkServices(moduleInfoBytes))
+                if (!moduleInfos.isEmpty()) {
+                    if(!checkServices(moduleInfos.get(MODULE_INFO)))
                         return false;
                 }
 
@@ -638,7 +648,12 @@
      * Expands list of files to process into full list of all files that
      * can be found by recursively descending directories.
      */
-    void expand(File dir, String[] files, boolean isUpdate) throws IOException {
+    void expand(File dir,
+                String[] files,
+                boolean isUpdate,
+                Map<String,Path> moduleInfoPaths)
+        throws IOException
+    {
         if (files == null)
             return;
 
@@ -651,18 +666,17 @@
 
             if (f.isFile()) {
                 String path = f.getPath();
-                if (entryName(path).equals(MODULE_INFO)) {
-                    if (moduleInfo != null && vflag)
-                        output(formatMsg("error.unexpected.module-info", path));
-                    moduleInfo = f.toPath();
+                String entryName = entryName(path);
+                if (entryName.endsWith(MODULE_INFO)) {
+                    moduleInfoPaths.put(entryName, f.toPath());
                     if (isUpdate)
-                        entryMap.put(entryName(path), f);
+                        entryMap.put(entryName, f);
                 } else if (entries.add(f)) {
-                    jarEntries.add(entryName(path));
-                    if (path.endsWith(".class"))
-                        packages.add(toPackageName(entryName(path)));
+                    jarEntries.add(entryName);
+                    if (path.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR))
+                        packages.add(toPackageName(entryName));
                     if (isUpdate)
-                        entryMap.put(entryName(f.getPath()), f);
+                        entryMap.put(entryName, f);
                 }
             } else if (f.isDirectory()) {
                 if (entries.add(f)) {
@@ -672,7 +686,7 @@
                             (dirPath + File.separator);
                         entryMap.put(entryName(dirPath), f);
                     }
-                    expand(f, f.list(), isUpdate);
+                    expand(f, f.list(), isUpdate, moduleInfoPaths);
                 }
             } else {
                 error(formatMsg("error.nosuch.fileordir", String.valueOf(f)));
@@ -684,7 +698,7 @@
     /**
      * Creates a new JAR file.
      */
-    void create(OutputStream out, Manifest manifest, byte[] moduleInfoBytes)
+    void create(OutputStream out, Manifest manifest, Map<String,byte[]> moduleInfos)
         throws IOException
     {
         ZipOutputStream zos = new JarOutputStream(out);
@@ -710,17 +724,19 @@
             manifest.write(zos);
             zos.closeEntry();
         }
-        if (moduleInfoBytes != null) {
+        for (Map.Entry<String,byte[]> mi : moduleInfos.entrySet()) {
+            String entryName = mi.getKey();
+            byte[] miBytes = mi.getValue();
             if (vflag) {
-                output(getMsg("out.added.module-info"));
+                output(formatMsg("out.added.module-info", entryName));
             }
-            ZipEntry e = new ZipEntry(MODULE_INFO);
+            ZipEntry e = new ZipEntry(mi.getKey());
             e.setTime(System.currentTimeMillis());
             if (flag0) {
-                crc32ModuleInfo(e, moduleInfoBytes);
+                crc32ModuleInfo(e, miBytes);
             }
             zos.putNextEntry(e);
-            ByteArrayInputStream in = new ByteArrayInputStream(moduleInfoBytes);
+            ByteArrayInputStream in = new ByteArrayInputStream(miBytes);
             in.transferTo(zos);
             zos.closeEntry();
         }
@@ -755,18 +771,41 @@
     }
 
     /**
+     * Returns true of the given module-info's are located in acceptable
+     * locations.  Otherwise, outputs an appropriate message and returns false.
+     */
+    private boolean checkModuleInfos(Map<String,?> moduleInfos) {
+        // there must always be, at least, a root module-info
+        if (!moduleInfos.containsKey(MODULE_INFO)) {
+            error(getMsg("error.versioned.info.without.root"));
+            return false;
+        }
+
+        // module-info can only appear in the root, or a versioned section
+        Optional<String> other = moduleInfos.keySet().stream()
+                .filter(x -> !x.equals(MODULE_INFO))
+                .filter(x -> !x.startsWith(VERSIONS_DIR))
+                .findFirst();
+
+        if (other.isPresent()) {
+            error(formatMsg("error.unexpected.module-info", other.get()));
+            return false;
+        }
+        return true;
+    }
+
+    /**
      * Updates an existing jar file.
      */
     boolean update(InputStream in, OutputStream out,
                    InputStream newManifest,
-                   byte[] newModuleInfoBytes,
+                   Map<String,byte[]> moduleInfos,
                    JarIndex jarIndex) throws IOException
     {
         ZipInputStream zis = new ZipInputStream(in);
         ZipOutputStream zos = new JarOutputStream(out);
         ZipEntry e = null;
         boolean foundManifest = false;
-        boolean foundModuleInfo = false;
         boolean updateOk = true;
 
         if (jarIndex != null) {
@@ -778,7 +817,7 @@
             String name = e.getName();
 
             boolean isManifestEntry = equalsIgnoreCase(name, MANIFEST_NAME);
-            boolean isModuleInfoEntry = name.equals(MODULE_INFO);
+            boolean isModuleInfoEntry = name.endsWith(MODULE_INFO);
 
             if ((jarIndex != null && equalsIgnoreCase(name, INDEX_NAME))
                 || (Mflag && isManifestEntry)) {
@@ -806,13 +845,8 @@
                 if (!updateManifest(old, zos)) {
                     return false;
                 }
-            } else if (isModuleInfoEntry
-                       && ((newModuleInfoBytes != null) || (ename != null)
-                           || moduleVersion != null || modulesToHash != null)) {
-                if (newModuleInfoBytes == null) {
-                    // Update existing module-info.class
-                    newModuleInfoBytes = readModuleInfo(zis);
-                }
+            } else if (moduleInfos != null && isModuleInfoEntry) {
+                moduleInfos.putIfAbsent(name, readModuleInfo(zis));
             } else {
                 if (!entryMap.containsKey(name)) { // copy the old stuff
                     // do our own compression
@@ -860,13 +894,22 @@
             }
         }
 
-        // write the module-info.class
-        if (newModuleInfoBytes != null) {
-            newModuleInfoBytes = addExtendedModuleAttributes(newModuleInfoBytes);
+        if (moduleInfos != null && !moduleInfos.isEmpty()) {
+            if (!checkModuleInfos(moduleInfos))
+                updateOk = false;
+
+            if (updateOk) {
+                if (!addExtendedModuleAttributes(moduleInfos))
+                    updateOk = false;
+            }
 
             // TODO: check manifest main classes, etc
-            if (!updateModuleInfo(newModuleInfoBytes, zos)) {
-                updateOk = false;
+
+            if (updateOk) {
+                for (Map.Entry<String,byte[]> mi : moduleInfos.entrySet()) {
+                    if (!updateModuleInfo(mi.getValue(), zos, mi.getKey()))
+                        updateOk = false;
+                }
             }
         } else if (moduleVersion != null || modulesToHash != null) {
             error(getMsg("error.module.options.without.info"));
@@ -894,10 +937,10 @@
         zos.closeEntry();
     }
 
-    private boolean updateModuleInfo(byte[] moduleInfoBytes, ZipOutputStream zos)
+    private boolean updateModuleInfo(byte[] moduleInfoBytes, ZipOutputStream zos, String entryName)
         throws IOException
     {
-        ZipEntry e = new ZipEntry(MODULE_INFO);
+        ZipEntry e = new ZipEntry(entryName);
         e.setTime(System.currentTimeMillis());
         if (flag0) {
             crc32ModuleInfo(e, moduleInfoBytes);
@@ -905,7 +948,7 @@
         zos.putNextEntry(e);
         zos.write(moduleInfoBytes);
         if (vflag) {
-            output(getMsg("out.update.module-info"));
+            output(formatMsg("out.update.module-info", entryName));
         }
         return true;
     }
@@ -1710,13 +1753,11 @@
         return (classname.replace('.', '/')) + ".class";
     }
 
+    /* A module must have the implementation class of the services it 'provides'. */
     private boolean checkServices(byte[] moduleInfoBytes)
         throws IOException
     {
-        ModuleDescriptor md;
-        try (InputStream in = new ByteArrayInputStream(moduleInfoBytes)) {
-            md = ModuleDescriptor.read(in);
-        }
+        ModuleDescriptor md = ModuleDescriptor.read(ByteBuffer.wrap(moduleInfoBytes));
         Set<String> missing = md.provides()
                                 .values()
                                 .stream()
@@ -1732,63 +1773,140 @@
     }
 
     /**
-     * Returns a byte array containing the module-info.class.
+     * Adds extended modules attributes to the given module-info's.  The given
+     * Map values are updated in-place. Returns false if an error occurs.
+     */
+    private boolean addExtendedModuleAttributes(Map<String,byte[]> moduleInfos)
+        throws IOException
+    {
+        assert !moduleInfos.isEmpty() && moduleInfos.get(MODULE_INFO) != null;
+
+        ByteBuffer bb = ByteBuffer.wrap(moduleInfos.get(MODULE_INFO));
+        ModuleDescriptor rd = ModuleDescriptor.read(bb);
+
+        Set<String> exports = rd.exports()
+                                .stream()
+                                .map(Exports::source)
+                                .collect(toSet());
+
+        Set<String> conceals = packages.stream()
+                                       .filter(p -> !exports.contains(p))
+                                       .collect(toSet());
+
+        for (Map.Entry<String,byte[]> e: moduleInfos.entrySet()) {
+            ModuleDescriptor vd = ModuleDescriptor.read(ByteBuffer.wrap(e.getValue()));
+            if (!(isValidVersionedDescriptor(vd, rd)))
+                return false;
+            e.setValue(extendedInfoBytes(rd, vd, e.getValue(), conceals));
+        }
+        return true;
+    }
+
+    private static boolean isPlatformModule(String name) {
+        return name.startsWith("java.") || name.startsWith("jdk.");
+    }
+
+    /**
+     * Tells whether or not the given versioned module descriptor's attributes
+     * are valid when compared against the given root module descriptor.
+     *
+     * A versioned module descriptor must be identical to the root module
+     * descriptor, with two exceptions:
+     *  - A versioned descriptor can have different non-public `requires`
+     *    clauses of platform ( `java.*` and `jdk.*` ) modules, and
+     *  - A versioned descriptor can have different `uses` clauses, even of
+     *    service types defined outside of the platform modules.
+     */
+    private boolean isValidVersionedDescriptor(ModuleDescriptor vd,
+                                               ModuleDescriptor rd)
+        throws IOException
+    {
+        if (!rd.name().equals(vd.name())) {
+            fatalError(getMsg("error.versioned.info.name.notequal"));
+            return false;
+        }
+        if (!rd.requires().equals(vd.requires())) {
+            Set<Requires> rootRequires = rd.requires();
+            for (Requires r : vd.requires()) {
+                if (rootRequires.contains(r)) {
+                    continue;
+                } else if (r.modifiers().contains(Requires.Modifier.PUBLIC)) {
+                    fatalError(getMsg("error.versioned.info.requires.public"));
+                    return false;
+                } else if (!isPlatformModule(r.name())) {
+                    fatalError(getMsg("error.versioned.info.requires.added"));
+                    return false;
+                }
+            }
+            for (Requires r : rootRequires) {
+                Set<Requires> mdRequires = vd.requires();
+                if (mdRequires.contains(r)) {
+                    continue;
+                } else if (!isPlatformModule(r.name())) {
+                    fatalError(getMsg("error.versioned.info.requires.dropped"));
+                    return false;
+                }
+            }
+        }
+        if (!rd.exports().equals(vd.exports())) {
+            fatalError(getMsg("error.versioned.info.exports.notequal"));
+            return false;
+        }
+        if (!rd.provides().equals(vd.provides())) {
+            fatalError(getMsg("error.versioned.info.provides.notequal"));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Returns a byte array containing the given module-info.class plus any
+     * extended attributes.
      *
      * If --module-version, --main-class, or other options were provided
      * then the corresponding class file attributes are added to the
      * module-info here.
      */
-    private byte[] addExtendedModuleAttributes(byte[] moduleInfoBytes)
+    private byte[] extendedInfoBytes(ModuleDescriptor rootDescriptor,
+                                     ModuleDescriptor md,
+                                     byte[] miBytes,
+                                     Set<String> conceals)
         throws IOException
     {
-        assert isModularJar();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        InputStream is = new ByteArrayInputStream(miBytes);
+        ModuleInfoExtender extender = ModuleInfoExtender.newExtender(is);
 
-        ModuleDescriptor md;
-        try (InputStream in = new ByteArrayInputStream(moduleInfoBytes)) {
-            md = ModuleDescriptor.read(in);
-        }
-        String name = md.name();
-        Set<String> exported = md.exports()
-                                 .stream()
-                                 .map(ModuleDescriptor.Exports::source)
-                                 .collect(Collectors.toSet());
+        // Add (or replace) the ConcealedPackages attribute
+        extender.conceals(conceals);
 
-        // copy the module-info.class into the jmod with the additional
-        // attributes for the version, main class and other meta data
-        try (InputStream in = new ByteArrayInputStream(moduleInfoBytes);
-             ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
-            ModuleInfoExtender extender = ModuleInfoExtender.newExtender(in);
+        // --main-class
+        if (ename != null)
+            extender.mainClass(ename);
+        else if (rootDescriptor.mainClass().isPresent())
+            extender.mainClass(rootDescriptor.mainClass().get());
 
-            // Add (or replace) the ConcealedPackages attribute
-            Set<String> conceals = packages.stream()
-                                            .filter(p -> !exported.contains(p))
-                                            .collect(Collectors.toSet());
+        // --module-version
+        if (moduleVersion != null)
+            extender.version(moduleVersion);
+        else if (rootDescriptor.version().isPresent())
+            extender.version(rootDescriptor.version().get());
 
-            extender.conceals(conceals);
-
-            // --main-class
-            if (ename != null)
-                extender.mainClass(ename);
-
-            // --module-version
-            if (moduleVersion != null)
-                extender.version(moduleVersion);
-
-            // --hash-modules
-            if (modulesToHash != null) {
-                Hasher hasher = new Hasher(md, fname);
-                ModuleHashes moduleHashes = hasher.computeHashes(name);
-                if (moduleHashes != null) {
-                    extender.hashes(moduleHashes);
-                } else {
-                    // should it issue warning or silent?
-                    System.out.println("warning: no module is recorded in hash in " + name);
-                }
+        // --hash-modules
+        if (modulesToHash != null) {
+            String mn = md.name();
+            Hasher hasher = new Hasher(md, fname);
+            ModuleHashes moduleHashes = hasher.computeHashes(mn);
+            if (moduleHashes != null) {
+                extender.hashes(moduleHashes);
+            } else {
+                // should it issue warning or silent?
+                System.out.println("warning: no module is recorded in hash in " + mn);
             }
-
-            extender.write(baos);
-            return baos.toByteArray();
         }
+
+        extender.write(baos);
+        return baos.toByteArray();
     }
 
     /**
@@ -1865,8 +1983,8 @@
             deque.add(name);
             Set<String> mods = visitNodes(graph, deque);
 
-            // filter modules matching the pattern specified --hash-modules
-            // as well as itself as the jmod file is being generated
+            // filter modules matching the pattern specified in --hash-modules,
+            // as well as the modular jar file that is being created / updated
             Map<String, Path> modulesForHash = mods.stream()
                 .filter(mn -> !mn.equals(name) && modules.contains(mn))
                 .collect(Collectors.toMap(Function.identity(), moduleNameToPath::get));
diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties
index 0b21bca..85316df 100644
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties
@@ -62,16 +62,33 @@
         Unexpected module descriptor {0}
 error.module.descriptor.not.found=\
         Module descriptor not found
+error.versioned.info.without.root=\
+        module-info.class found in versioned section without module-info.class \
+        in the root
+error.versioned.info.name.notequal=\
+        module-info.class in versioned section contains incorrect name
+error.versioned.info.requires.public=\
+        module-info.class in versioned section contains additional requires public
+error.versioned.info.requires.added=\
+        module-info.class in versioned section contains additional requires
+error.versioned.info.requires.dropped=\
+        module-info.class in versioned section contains missing requires
+error.versioned.info.exports.notequal=\
+        module-info.class in versioned section contains different exports
+error.versioned.info.provides.notequal=\
+        module-info.class in versioned section contains different provides
+error.invalid.versioned.module.attribute=\
+        Invalid module descriptor attribute {0}
 error.missing.provider=\
         Service provider not found: {0}
 out.added.manifest=\
         added manifest
 out.added.module-info=\
-        added module-info.class
+        added module-info: {0}
 out.update.manifest=\
         updated manifest
 out.update.module-info=\
-        updated module-info.class
+        updated module-info: {0}
 out.ignore.entry=\
         ignoring entry {0}
 out.adding=\
diff --git a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java b/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java
deleted file mode 100644
index b96e6ae..0000000
--- a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.vm.agent.spi;
-
-import java.lang.reflect.Layer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ServiceLoader;
-
-public final class ToolProviderFinder {
-    private static final Map<String, ToolProvider> providers = init();
-
-    public static ToolProvider find(String name) {
-        return providers.get(name);
-    }
-
-    private static Map<String, ToolProvider> init() {
-        Map<String, ToolProvider> providers = new HashMap<>();
-        ServiceLoader.load(Layer.boot(), ToolProvider.class)
-                     .forEach(p -> providers.putIfAbsent(p.getName(), p));
-        return providers;
-    }
-}
diff --git a/jdk/src/jdk.jcmd/share/classes/module-info.java b/jdk/src/jdk.jcmd/share/classes/module-info.java
index 4b8dbce..c78803b 100644
--- a/jdk/src/jdk.jcmd/share/classes/module-info.java
+++ b/jdk/src/jdk.jcmd/share/classes/module-info.java
@@ -26,9 +26,4 @@
 module jdk.jcmd {
     requires jdk.attach;
     requires jdk.jvmstat;
-
-    exports jdk.internal.vm.agent.spi to jdk.hotspot.agent;
-
-    uses jdk.internal.vm.agent.spi.ToolProvider;
 }
-
diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java
new file mode 100644
index 0000000..e08b11d
--- /dev/null
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.tools.common;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.VirtualMachineDescriptor;
+
+import sun.jvmstat.monitor.MonitorException;
+import sun.jvmstat.monitor.MonitoredHost;
+import sun.jvmstat.monitor.MonitoredVm;
+import sun.jvmstat.monitor.MonitoredVmUtil;
+import sun.jvmstat.monitor.VmIdentifier;
+
+/**
+ * Class for finding process matching a process argument,
+ * excluding tool it self and returning a list containing
+ * the process identifiers.
+ */
+public class ProcessArgumentMatcher {
+    private String excludeCls;
+    private String matchClass = null;
+    private String singlePid = null;
+    private boolean matchAll = false;
+
+    public ProcessArgumentMatcher(String pidArg, Class<?> excludeClass) {
+        excludeCls = excludeClass.getName();
+        if (pidArg == null || pidArg.isEmpty()) {
+            throw new IllegalArgumentException("Pid string is invalid");
+        }
+        if (pidArg.charAt(0) == '-') {
+            throw new IllegalArgumentException("Unrecognized " + pidArg);
+        }
+        try {
+            long pid = Long.parseLong(pidArg);
+            if (pid == 0) {
+                matchAll = true;
+            } else {
+                singlePid = String.valueOf(pid);
+            }
+        } catch (NumberFormatException nfe) {
+            matchClass = pidArg;
+        }
+    }
+
+    private boolean check(VirtualMachineDescriptor vmd) {
+        String mainClass = null;
+        try {
+            VmIdentifier vmId = new VmIdentifier(vmd.id());
+            MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
+            MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
+            mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
+            monitoredHost.detach(monitoredVm);
+        } catch (NullPointerException npe) {
+            // There is a potential race, where a running java app is being
+            // queried, unfortunately the java app has shutdown after this
+            // method is started but before getMonitoredVM is called.
+            // If this is the case, then the /tmp/hsperfdata_xxx/pid file
+            // will have disappeared and we will get a NullPointerException.
+            // Handle this gracefully....
+            return false;
+        } catch (MonitorException | URISyntaxException e) {
+            if (e.getMessage() != null) {
+                System.err.println(e.getMessage());
+            } else {
+                Throwable cause = e.getCause();
+                if ((cause != null) && (cause.getMessage() != null)) {
+                    System.err.println(cause.getMessage());
+                } else {
+                    e.printStackTrace();
+                }
+            }
+            return false;
+        }
+
+        if (mainClass.equals(excludeCls)) {
+            return false;
+        }
+
+        if (matchAll || mainClass.indexOf(matchClass) != -1) {
+            return true;
+        }
+
+        return false;
+    }
+
+    public Collection<String> getPids() {
+        Collection<String> pids = new ArrayList<>();
+        if (singlePid != null) {
+            pids.add(singlePid);
+            return pids;
+        }
+        List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
+        for (VirtualMachineDescriptor vmd : vmds) {
+            if (check(vmd)) {
+                pids.add(vmd.id());
+            }
+        }
+        return pids;
+    }
+}
diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java
index fbd4ca9..80708f5 100644
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java
@@ -33,16 +33,14 @@
     private boolean listProcesses = false;
     private boolean listCounters  = false;
     private boolean showUsage     = false;
-    private int     pid           = -1;
     private String  command       = null;
-    private String  processSubstring;
+    private String  processString = null;
 
     public boolean isListProcesses() { return listProcesses; }
     public boolean isListCounters() { return listCounters; }
     public boolean isShowUsage() { return showUsage; }
-    public int getPid() { return pid; }
     public String getCommand() { return command; }
-    public String getProcessSubstring() { return processSubstring; }
+    public String getProcessString() { return processString; }
 
     public Arguments(String[] args) {
         if (args.length == 0 || args[0].equals("-l")) {
@@ -55,15 +53,7 @@
             return;
         }
 
-        try {
-            pid = Integer.parseInt(args[0]);
-        } catch (NumberFormatException ex) {
-            // use as a partial class-name instead
-            if (args[0].charAt(0) != '-') {
-                // unless it starts with a '-'
-                processSubstring = args[0];
-            }
-        }
+        processString = args[0];
 
         StringBuilder sb = new StringBuilder();
         for (int i = 1; i < args.length; i++) {
diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java
index 0ff4632..ab77547 100644
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java
@@ -29,22 +29,22 @@
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.List;
-import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.net.URISyntaxException;
 
 import com.sun.tools.attach.AttachOperationFailedException;
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.VirtualMachineDescriptor;
-import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AttachNotSupportedException;
 
 import sun.tools.attach.HotSpotVirtualMachine;
+import sun.tools.common.ProcessArgumentMatcher;
 import sun.tools.jstat.JStatLogger;
 import sun.jvmstat.monitor.Monitor;
 import sun.jvmstat.monitor.MonitoredHost;
 import sun.jvmstat.monitor.MonitoredVm;
-import sun.jvmstat.monitor.MonitoredVmUtil;
 import sun.jvmstat.monitor.MonitorException;
 import sun.jvmstat.monitor.VmIdentifier;
 
@@ -73,52 +73,18 @@
             System.exit(0);
         }
 
-        List<String> pids = new ArrayList<String>();
-        if (arg.getPid() == 0) {
-            // find all VMs
-            List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
-            for (VirtualMachineDescriptor vmd : vmds) {
-                if (!isJCmdProcess(vmd)) {
-                    pids.add(vmd.id());
-                }
-            }
-        } else if (arg.getProcessSubstring() != null) {
-            // use the partial class-name match
-            List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
-            for (VirtualMachineDescriptor vmd : vmds) {
-                if (isJCmdProcess(vmd)) {
-                    continue;
-                }
-                try {
-                    String mainClass = getMainClass(vmd);
-                    if (mainClass != null
-                        && mainClass.indexOf(arg.getProcessSubstring()) != -1) {
-                            pids.add(vmd.id());
-                    }
-                } catch (MonitorException|URISyntaxException e) {
-                    if (e.getMessage() != null) {
-                        System.err.println(e.getMessage());
-                    } else {
-                        Throwable cause = e.getCause();
-                        if ((cause != null) && (cause.getMessage() != null)) {
-                            System.err.println(cause.getMessage());
-                        } else {
-                            e.printStackTrace();
-                        }
-                    }
-                }
-            }
-            if (pids.isEmpty()) {
-                System.err.println("Could not find any processes matching : '"
-                                   + arg.getProcessSubstring() + "'");
-                System.exit(1);
-            }
-        } else if (arg.getPid() == -1) {
+        Collection<String> pids = Collections.emptyList();
+        try {
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(arg.getProcessString(), JCmd.class);
+            pids = ap.getPids();
+        } catch (IllegalArgumentException iae) {
             System.err.println("Invalid pid specified");
             System.exit(1);
-        } else {
-            // Use the found pid
-            pids.add(arg.getPid() + "");
+        }
+        if (pids.isEmpty()) {
+            System.err.println("Could not find any processes matching : '"
+                               + arg.getProcessString() + "'");
+            System.exit(1);
         }
 
         boolean success = true;
@@ -199,36 +165,6 @@
         }
     }
 
-    private static boolean isJCmdProcess(VirtualMachineDescriptor vmd) {
-        try {
-            String mainClass = getMainClass(vmd);
-            return mainClass != null && mainClass.equals(JCmd.class.getName());
-        } catch (URISyntaxException|MonitorException ex) {
-            return false;
-        }
-    }
-
-    private static String getMainClass(VirtualMachineDescriptor vmd)
-            throws URISyntaxException, MonitorException {
-        try {
-            String mainClass = null;
-            VmIdentifier vmId = new VmIdentifier(vmd.id());
-            MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
-            MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
-            mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
-            monitoredHost.detach(monitoredVm);
-            return mainClass;
-        } catch(NullPointerException e) {
-            // There is a potential race, where a running java app is being
-            // queried, unfortunately the java app has shutdown after this
-            // method is started but before getMonitoredVM is called.
-            // If this is the case, then the /tmp/hsperfdata_xxx/pid file
-            // will have disappeared and we will get a NullPointerException.
-            // Handle this gracefully....
-            return null;
-        }
-    }
-
     /**
      * Class to compare two Monitor objects by name in ascending order.
      * (from jstat)
diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java
index f19b6d1..ca77412 100644
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java
@@ -25,15 +25,14 @@
 
 package sun.tools.jinfo;
 
-import java.util.Arrays;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Collection;
 
 import com.sun.tools.attach.VirtualMachine;
 
 import sun.tools.attach.HotSpotVirtualMachine;
-import jdk.internal.vm.agent.spi.ToolProvider;
-import jdk.internal.vm.agent.spi.ToolProviderFinder;
+import sun.tools.common.ProcessArgumentMatcher;
 
 /*
  * This class is the main class for the JInfo utility. It parses its arguments
@@ -41,155 +40,94 @@
  * or an SA tool.
  */
 final public class JInfo {
-    private static final String SA_JINFO_TOOL_NAME = "jinfo";
-    private boolean useSA = false;
-    private String[] args = null;
-
-    private JInfo(String[] args) throws IllegalArgumentException {
-        if (args.length == 0) {
-            throw new IllegalArgumentException();
-        }
-
-        int argCopyIndex = 0;
-        // First determine if we should launch SA or not
-        if (args[0].equals("-F")) {
-            // delete the -F
-            argCopyIndex = 1;
-            useSA = true;
-        } else if (args[0].equals("-flags")
-                   || args[0].equals("-sysprops"))
-        {
-            if (args.length == 2) {
-                if (!isPid(args[1])) {
-                    // If args[1] doesn't parse to a number then
-                    // it must be the SA debug server
-                    // (otherwise it is the pid)
-                    useSA = true;
-                }
-            } else if (args.length == 3) {
-                // arguments include an executable and a core file
-                useSA = true;
-            } else {
-                throw new IllegalArgumentException();
-            }
-        } else if (!args[0].startsWith("-")) {
-            if (args.length == 2) {
-                // the only arguments are an executable and a core file
-                useSA = true;
-            } else if (args.length == 1) {
-                if (!isPid(args[0])) {
-                    // The only argument is not a PID; it must be SA debug
-                    // server
-                    useSA = true;
-                }
-            } else {
-                throw new IllegalArgumentException();
-            }
-        } else if (args[0].equals("-h") || args[0].equals("-help")) {
-            if (args.length > 1) {
-                throw new IllegalArgumentException();
-            }
-        } else if (args[0].equals("-flag")) {
-            if (args.length == 3) {
-                if (!isPid(args[2])) {
-                    throw new IllegalArgumentException();
-                }
-            } else {
-                throw new IllegalArgumentException();
-            }
-        } else {
-            throw new IllegalArgumentException();
-        }
-
-        this.args = Arrays.copyOfRange(args, argCopyIndex, args.length);
-    }
-
-    @SuppressWarnings("fallthrough")
-    private void execute() throws Exception {
-        if (args[0].equals("-h")
-            || args[0].equals("-help")) {
-            usage(0);
-        }
-
-        if (useSA) {
-            // SA only supports -flags or -sysprops
-            if (args[0].startsWith("-")) {
-                if (!(args[0].equals("-flags") || args[0].equals("-sysprops"))) {
-                    usage(1);
-                }
-            }
-
-            // invoke SA which does it's own argument parsing
-            runTool();
-
-        } else {
-            // Now we can parse arguments for the non-SA case
-            String pid = null;
-
-            switch(args[0]) {
-                case "-flag":
-                    if (args.length != 3) {
-                        usage(1);
-                    }
-                    String option = args[1];
-                    pid = args[2];
-                    flag(pid, option);
-                    break;
-                case "-flags":
-                    if (args.length != 2) {
-                        usage(1);
-                    }
-                    pid = args[1];
-                    flags(pid);
-                    break;
-                case "-sysprops":
-                    if (args.length != 2) {
-                        usage(1);
-                    }
-                    pid = args[1];
-                    sysprops(pid);
-                    break;
-                case "-help":
-                case "-h":
-                    usage(0);
-                    // Fall through
-                default:
-                    if (args.length == 1) {
-                        // no flags specified, we do -sysprops and -flags
-                        pid = args[0];
-                        sysprops(pid);
-                        System.out.println();
-                        flags(pid);
-                        System.out.println();
-                        commandLine(pid);
-                    } else {
-                        usage(1);
-                    }
-            }
-        }
-    }
 
     public static void main(String[] args) throws Exception {
-        JInfo jinfo = null;
-        try {
-            jinfo = new JInfo(args);
-            jinfo.execute();
-        } catch (IllegalArgumentException e) {
+        if (args.length == 0) {
+            usage(1); // no arguments
+        }
+        checkForUnsupportedOptions(args);
+
+        boolean doFlag = false;
+        boolean doFlags = false;
+        boolean doSysprops = false;
+
+        // Parse the options (arguments starting with "-" )
+        int optionCount = 0;
+        while (optionCount < args.length) {
+            String arg = args[optionCount];
+            if (!arg.startsWith("-")) {
+                break;
+            }
+
+            optionCount++;
+
+            if (arg.equals("-help") || arg.equals("-h")) {
+                usage(0);
+            }
+
+            if (arg.equals("-flag")) {
+                doFlag = true;
+                continue;
+            }
+
+            if (arg.equals("-flags")) {
+                doFlags = true;
+                continue;
+            }
+
+            if (arg.equals("-sysprops")) {
+                doSysprops = true;
+                continue;
+            }
+        }
+
+        // Next we check the parameter count. -flag allows extra parameters
+        int paramCount = args.length - optionCount;
+        if ((doFlag && paramCount != 2) || ((!doFlag && paramCount != 1))) {
             usage(1);
         }
-    }
 
-    private static boolean isPid(String arg) {
-        return arg.matches("[0-9]+");
-    }
-
-    // Invoke SA tool with the given arguments
-    private void runTool() throws Exception {
-        ToolProvider tool = ToolProviderFinder.find(SA_JINFO_TOOL_NAME);
-        if (tool == null) {
-            usage(1);
+        if (!doFlag && !doFlags && !doSysprops) {
+            // Print flags and sysporps if no options given
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(args[optionCount], JInfo.class);
+            Collection<String> pids = ap.getPids();
+            for (String pid : pids) {
+                if (pids.size() > 1) {
+                    System.out.println("Pid:" + pid);
+                }
+                sysprops(pid);
+                System.out.println();
+                flags(pid);
+                System.out.println();
+                commandLine(pid);
+            }
         }
-        tool.run(args);
+
+        if (doFlag) {
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(args[optionCount+1], JInfo.class);
+            Collection<String> pids = ap.getPids();
+            for (String pid : pids) {
+                if (pids.size() > 1) {
+                    System.out.println("Pid:" + pid);
+                }
+                flag(pid, args[optionCount]);
+            }
+        }
+        else if (doFlags || doSysprops) {
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(args[optionCount], JInfo.class);
+            Collection<String> pids = ap.getPids();
+            for (String pid : pids) {
+                if (pids.size() > 1) {
+                    System.out.println("Pid:" + pid);
+                }
+                if (doFlags) {
+                    flags(pid);
+                }
+                else if (doSysprops) {
+                    sysprops(pid);
+                }
+            }
+        }
     }
 
     private static void flag(String pid, String option) throws IOException {
@@ -274,46 +212,49 @@
         vm.detach();
     }
 
+    private static void checkForUnsupportedOptions(String[] args) {
+        // Check arguments for -F, and non-numeric value
+        // and warn the user that SA is not supported anymore
+        int maxCount = 1;
+        int paramCount = 0;
 
-    // print usage message
-    private static void usage(int exit) {
-        boolean usageSA = ToolProviderFinder.find(SA_JINFO_TOOL_NAME) != null;
-
-        System.err.println("Usage:");
-        if (usageSA) {
-            System.err.println("    jinfo [option] <pid>");
-            System.err.println("        (to connect to a running process)");
-            System.err.println("    jinfo -F [option] <pid>");
-            System.err.println("        (to connect to a hung process)");
-            System.err.println("    jinfo [option] <executable> <core>");
-            System.err.println("        (to connect to a core file)");
-            System.err.println("    jinfo [option] [server_id@]<remote server IP or hostname>");
-            System.err.println("        (to connect to remote debug server)");
-            System.err.println("");
-            System.err.println("where <option> is one of:");
-            System.err.println("  for running processes:");
-            System.err.println("    -flag <name>         to print the value of the named VM flag");
-            System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
-            System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
-            System.err.println("  for running or hung processes and core files:");
-            System.err.println("    -flags               to print VM flags");
-            System.err.println("    -sysprops            to print Java system properties");
-            System.err.println("    <no option>          to print both VM flags and system properties");
-            System.err.println("    -h | -help           to print this help message");
-        } else {
-            System.err.println("    jinfo <option> <pid>");
-            System.err.println("       (to connect to a running process)");
-            System.err.println("");
-            System.err.println("where <option> is one of:");
-            System.err.println("    -flag <name>         to print the value of the named VM flag");
-            System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
-            System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
-            System.err.println("    -flags               to print VM flags");
-            System.err.println("    -sysprops            to print Java system properties");
-            System.err.println("    <no option>          to print both VM flags and system properties");
-            System.err.println("    -h | -help           to print this help message");
+        for (String s : args) {
+            if (s.equals("-F")) {
+                SAOptionError("-F option used");
+            }
+            if (s.equals("-flag")) {
+                maxCount = 2;
+            }
+            if (! s.startsWith("-")) {
+                paramCount += 1;
+            }
         }
 
+        if (paramCount > maxCount) {
+            SAOptionError("More than " + maxCount + " non-option argument");
+        }
+    }
+
+    private static void SAOptionError(String msg) {
+        System.err.println("Error: " + msg);
+        System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jinfo instead");
+        System.exit(1);
+    }
+
+     // print usage message
+    private static void usage(int exit) {
+        System.err.println("Usage:");
+        System.err.println("    jinfo <option> <pid>");
+        System.err.println("       (to connect to a running process)");
+        System.err.println("");
+        System.err.println("where <option> is one of:");
+        System.err.println("    -flag <name>         to print the value of the named VM flag");
+        System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
+        System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
+        System.err.println("    -flags               to print VM flags");
+        System.err.println("    -sysprops            to print Java system properties");
+        System.err.println("    <no option>          to print both VM flags and system properties");
+        System.err.println("    -h | -help           to print this help message");
         System.exit(exit);
     }
 }
diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java
index cb7651e..810a44e 100644
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java
@@ -28,12 +28,13 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
 
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.AttachNotSupportedException;
 import sun.tools.attach.HotSpotVirtualMachine;
-import jdk.internal.vm.agent.spi.ToolProvider;
-import jdk.internal.vm.agent.spi.ToolProviderFinder;
+import sun.tools.common.ProcessArgumentMatcher;
 
 /*
  * This class is the main class for the JMap utility. It parses its arguments
@@ -44,34 +45,18 @@
  */
 public class JMap {
 
-    // Options handled by the attach mechanism
-    private static String HISTO_OPTION = "-histo";
-    private static String LIVE_HISTO_OPTION = "-histo:live";
-    private static String DUMP_OPTION_PREFIX = "-dump:";
-
-    // These options imply the use of a SA tool
-    private static String SA_TOOL_OPTIONS =
-      "-heap|-heap:format=b|-clstats|-finalizerinfo";
-
-    // The -F (force) option is currently not passed through to SA
-    private static String FORCE_SA_OPTION = "-F";
-
-    // Default option (if nothing provided)
-    private static String DEFAULT_OPTION = "-pmap";
-
     public static void main(String[] args) throws Exception {
         if (args.length == 0) {
             usage(1); // no arguments
         }
 
-        // used to indicate if we should use SA
-        boolean useSA = false;
+        checkForUnsupportedOptions(args);
 
-        // the chosen option (-heap, -dump:*, ... )
+        // the chosen option
         String option = null;
 
         // First iterate over the options (arguments starting with -).  There should be
-        // one (but maybe two if -F is also used).
+        // one.
         int optionCount = 0;
         while (optionCount < args.length) {
             String arg = args[optionCount];
@@ -80,8 +65,6 @@
             }
             if (arg.equals("-help") || arg.equals("-h")) {
                 usage(0);
-            } else if (arg.equals(FORCE_SA_OPTION)) {
-                useSA = true;
             } else {
                 if (option != null) {
                     usage(1);  // option already specified
@@ -93,123 +76,102 @@
 
         // if no option provided then use default.
         if (option == null) {
-            option = DEFAULT_OPTION;
-        }
-        if (option.matches(SA_TOOL_OPTIONS)) {
-            useSA = true;
+            usage(0);
         }
 
-        // Next we check the parameter count. For the SA tools there are
-        // one or two parameters. For the built-in -dump option there is
-        // only one parameter (the process-id)
+        // Next we check the parameter count.
         int paramCount = args.length - optionCount;
-        if (paramCount == 0 || paramCount > 2) {
+        if (paramCount != 1) {
             usage(1);
         }
 
-        if (optionCount == 0 || paramCount != 1) {
-            useSA = true;
-        } else {
-            // the parameter for the -dump option is a process-id.
-            // If it doesn't parse to a number then it must be SA
-            // debug server
-            if (!args[optionCount].matches("[0-9]+")) {
-                useSA = true;
+        String pidArg = args[1];
+        // Here we handle the built-in options
+        // As more options are added we should create an abstract tool class and
+        // have a table to map the options
+        ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg, JMap.class);
+        Collection<String> pids = ap.getPids();
+        for (String pid : pids) {
+            if (pids.size() > 1) {
+                System.out.println("Pid:" + pid);
             }
-        }
-
-
-        // at this point we know if we are executing an SA tool or a built-in
-        // option.
-
-        if (useSA) {
-            // parameters (<pid> or <exe> <core>)
-            String params[] = new String[paramCount];
-            for (int i=optionCount; i<args.length; i++ ){
-                params[i-optionCount] = args[i];
-            }
-            runTool(option, params);
-
-        } else {
-            String pid = args[1];
-            // Here we handle the built-in options
-            // As more options are added we should create an abstract tool class and
-            // have a table to map the options
-            if (option.equals(HISTO_OPTION)) {
-                histo(pid, false);
-            } else if (option.equals(LIVE_HISTO_OPTION)) {
-                histo(pid, true);
-            } else if (option.startsWith(DUMP_OPTION_PREFIX)) {
-                dump(pid, option);
+            if (option.equals("-histo")) {
+                histo(pid, "");
+            } else if (option.startsWith("-histo:")) {
+                histo(pid, option.substring("-histo:".length()));
+            } else if (option.startsWith("-dump:")) {
+                dump(pid, option.substring("-dump:".length()));
+            } else if (option.equals("-finalizerinfo")) {
+                executeCommandForPid(pid, "jcmd", "GC.finalizer_info");
+            } else if (option.equals("-clstats")) {
+                executeCommandForPid(pid, "jcmd", "GC.class_stats");
             } else {
-                usage(1);
+              usage(1);
             }
         }
     }
 
-    // Invoke SA tool  with the given arguments
-    private static void runTool(String option, String args[]) throws Exception {
-        String[][] tools = {
-            { "-pmap",          "pmap"             },
-            { "-heap",          "heapSummary"      },
-            { "-heap:format=b", "heapDumper"       },
-            { "-histo",         "objectHistogram"  },
-            { "-clstats",       "classLoaderStats" },
-            { "-finalizerinfo", "finalizerInfo"    },
-        };
+    private static void executeCommandForPid(String pid, String command, Object ... args)
+        throws AttachNotSupportedException, IOException,
+               UnsupportedEncodingException {
+        VirtualMachine vm = VirtualMachine.attach(pid);
 
-        String name = null;
-
-        // -dump option needs to be handled in a special way
-        if (option.startsWith(DUMP_OPTION_PREFIX)) {
-            // first check that the option can be parsed
-            String fn = parseDumpOptions(option);
-            if (fn == null) {
-                usage(1);
-            }
-
-            // tool for heap dumping
-            name = "heapDumper";
-
-            // HeapDumper -f <file>
-            args = prepend(fn, args);
-            args = prepend("-f", args);
-        } else {
-            int i=0;
-            while (i < tools.length) {
-                if (option.equals(tools[i][0])) {
-                    name = tools[i][1];
-                    break;
-                }
-                i++;
-            }
+        // Cast to HotSpotVirtualMachine as this is an
+        // implementation specific method.
+        HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm;
+        try (InputStream in = hvm.executeCommand(command, args)) {
+          // read to EOF and just print output
+          byte b[] = new byte[256];
+          int n;
+          do {
+              n = in.read(b);
+              if (n > 0) {
+                  String s = new String(b, 0, n, "UTF-8");
+                  System.out.print(s);
+              }
+          } while (n > 0);
         }
-        if (name == null) {
-            usage(1);   // no mapping to tool
-        }
+        vm.detach();
+    }
 
-        // Tool not available on this platform.
-        ToolProvider tool = ToolProviderFinder.find(name);
-        if (tool == null) {
+    private static void histo(String pid, String options)
+        throws AttachNotSupportedException, IOException,
+               UnsupportedEncodingException {
+        String liveopt = "-all";
+        if (options.equals("") || options.equals("all")) {
+            //  pass
+        }
+        else if (options.equals("live")) {
+            liveopt = "-live";
+        }
+        else {
             usage(1);
         }
 
-        // invoke the main method with the arguments
-        tool.run(args);
+        // inspectHeap is not the same as jcmd GC.class_histogram
+        executeCommandForPid(pid, "inspectheap", liveopt);
     }
 
-    private static final String LIVE_OBJECTS_OPTION = "-live";
-    private static final String ALL_OBJECTS_OPTION = "-all";
-    private static void histo(String pid, boolean live) throws IOException {
-        VirtualMachine vm = attach(pid);
-        InputStream in = ((HotSpotVirtualMachine)vm).
-            heapHisto(live ? LIVE_OBJECTS_OPTION : ALL_OBJECTS_OPTION);
-        drain(vm, in);
-    }
+    private static void dump(String pid, String options)
+        throws AttachNotSupportedException, IOException,
+               UnsupportedEncodingException {
 
-    private static void dump(String pid, String options) throws IOException {
-        // parse the options to get the dump filename
-        String filename = parseDumpOptions(options);
+        String subopts[] = options.split(",");
+        String filename = null;
+        String liveopt = "-all";
+
+        for (int i = 0; i < subopts.length; i++) {
+            String subopt = subopts[i];
+            if (subopt.equals("live")) {
+                liveopt = "-live";
+            } else if (subopt.startsWith("file=")) {
+                // file=<file> - check that <file> is specified
+                if (subopt.length() > 5) {
+                    filename = subopt.substring(5);
+                }
+            }
+        }
+
         if (filename == null) {
             usage(1);  // invalid options or no filename
         }
@@ -219,156 +181,73 @@
         // working directory rather than the directory where jmap
         // is executed.
         filename = new File(filename).getCanonicalPath();
-
-        // dump live objects only or not
-        boolean live = isDumpLiveObjects(options);
-
-        VirtualMachine vm = attach(pid);
-        System.out.println("Dumping heap to " + filename + " ...");
-        InputStream in = ((HotSpotVirtualMachine)vm).
-            dumpHeap((Object)filename,
-                     (live ? LIVE_OBJECTS_OPTION : ALL_OBJECTS_OPTION));
-        drain(vm, in);
+        // dumpHeap is not the same as jcmd GC.heap_dump
+        executeCommandForPid(pid, "dumpheap", filename, liveopt);
     }
 
-    // Parse the options to the -dump option. Valid options are format=b and
-    // file=<file>. Returns <file> if provided. Returns null if <file> not
-    // provided, or invalid option.
-    private static String parseDumpOptions(String arg) {
-        assert arg.startsWith(DUMP_OPTION_PREFIX);
+    private static void checkForUnsupportedOptions(String[] args) {
+        // Check arguments for -F, -m, and non-numeric value
+        // and warn the user that SA is not supported anymore
 
-        String filename = null;
+        int paramCount = 0;
 
-        // options are separated by comma (,)
-        String options[] = arg.substring(DUMP_OPTION_PREFIX.length()).split(",");
+        for (String s : args) {
+            if (s.equals("-F")) {
+                SAOptionError("-F option used");
+            }
 
-        for (int i=0; i<options.length; i++) {
-            String option = options[i];
+            if (s.equals("-heap")) {
+                SAOptionError("-heap option used");
+            }
 
-            if (option.equals("format=b")) {
-                // ignore format (not needed at this time)
-            } else if (option.equals("live")) {
-                // a valid suboption
-            } else {
+            /* Reimplemented using jcmd, output format is different
+               from original one
 
-                // file=<file> - check that <file> is specified
-                if (option.startsWith("file=")) {
-                    filename = option.substring(5);
-                    if (filename.length() == 0) {
-                        return null;
-                    }
-                } else {
-                    return null;  // option not recognized
-                }
+            if (s.equals("-clstats")) {
+                warnSA("-clstats option used");
+            }
+
+            if (s.equals("-finalizerinfo")) {
+                warnSA("-finalizerinfo option used");
+            }
+            */
+
+            if (! s.startsWith("-")) {
+                paramCount += 1;
             }
         }
-        return filename;
-    }
 
-    private static boolean isDumpLiveObjects(String arg) {
-        // options are separated by comma (,)
-        String options[] = arg.substring(DUMP_OPTION_PREFIX.length()).split(",");
-        for (String suboption : options) {
-            if (suboption.equals("live")) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    // Attach to <pid>, existing if we fail to attach
-    private static VirtualMachine attach(String pid) {
-        try {
-            return VirtualMachine.attach(pid);
-        } catch (Exception x) {
-            String msg = x.getMessage();
-            if (msg != null) {
-                System.err.println(pid + ": " + msg);
-            } else {
-                x.printStackTrace();
-            }
-            if ((x instanceof AttachNotSupportedException) && haveSA()) {
-                System.err.println("The -F option can be used when the " +
-                  "target process is not responding");
-            }
-            System.exit(1);
-            return null; // keep compiler happy
+        if (paramCount > 1) {
+            SAOptionError("More than one non-option argument");
         }
     }
 
-    // Read the stream from the target VM until EOF, then detach
-    private static void drain(VirtualMachine vm, InputStream in) throws IOException {
-        // read to EOF and just print output
-        byte b[] = new byte[256];
-        int n;
-        do {
-            n = in.read(b);
-            if (n > 0) {
-                String s = new String(b, 0, n, "UTF-8");
-                System.out.print(s);
-            }
-        } while (n > 0);
-        in.close();
-        vm.detach();
-    }
-
-    // return a new string array with arg as the first element
-    private static String[] prepend(String arg, String args[]) {
-        String[] newargs = new String[args.length+1];
-        newargs[0] = arg;
-        System.arraycopy(args, 0, newargs, 1, args.length);
-        return newargs;
-    }
-
-    // returns true if SA is available
-    private static boolean haveSA() {
-        return ToolProviderFinder.find("heapSummary") != null;
+    private static void SAOptionError(String msg) {
+        System.err.println("Error: " + msg);
+        System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jmap instead");
+        System.exit(1);
     }
 
     // print usage message
     private static void usage(int exit) {
         System.err.println("Usage:");
-        if (haveSA()) {
-            System.err.println("    jmap [option] <pid>");
-            System.err.println("        (to connect to running process)");
-            System.err.println("    jmap [option] <executable <core>");
-            System.err.println("        (to connect to a core file)");
-            System.err.println("    jmap [option] [server_id@]<remote server IP or hostname>");
-            System.err.println("        (to connect to remote debug server)");
-            System.err.println("");
-            System.err.println("where <option> is one of:");
-            System.err.println("    <none>               to print same info as Solaris pmap");
-            System.err.println("    -heap                to print java heap summary");
-            System.err.println("    -histo[:live]        to print histogram of java object heap; if the \"live\"");
-            System.err.println("                         suboption is specified, only count live objects");
-            System.err.println("    -clstats             to print class loader statistics");
-            System.err.println("    -finalizerinfo       to print information on objects awaiting finalization");
-            System.err.println("    -dump:<dump-options> to dump java heap in hprof binary format");
-            System.err.println("                         dump-options:");
-            System.err.println("                           live         dump only live objects; if not specified,");
-            System.err.println("                                        all objects in the heap are dumped.");
-            System.err.println("                           format=b     binary format");
-            System.err.println("                           file=<file>  dump heap to <file>");
-            System.err.println("                         Example: jmap -dump:live,format=b,file=heap.bin <pid>");
-            System.err.println("    -F                   force. Use with -dump:<dump-options> <pid> or -histo");
-            System.err.println("                         to force a heap dump or histogram when <pid> does not");
-            System.err.println("                         respond. The \"live\" suboption is not supported");
-            System.err.println("                         in this mode.");
-            System.err.println("    -h | -help           to print this help message");
-            System.err.println("    -J<flag>             to pass <flag> directly to the runtime system");
-        } else {
-            System.err.println("    jmap -histo <pid>");
-            System.err.println("      (to connect to running process and print histogram of java object heap");
-            System.err.println("    jmap -dump:<dump-options> <pid>");
-            System.err.println("      (to connect to running process and dump java heap)");
-            System.err.println("");
-            System.err.println("    dump-options:");
-            System.err.println("      format=b     binary default");
-            System.err.println("      file=<file>  dump heap to <file>");
-            System.err.println("");
-            System.err.println("    Example:       jmap -dump:format=b,file=heap.bin <pid>");
-        }
-
+        System.err.println("    jmap -clstats <pid>");
+        System.err.println("        to connect to running process and print class loader statistics");
+        System.err.println("    jmap -finalizerinfo <pid>");
+        System.err.println("        to connect to running process and print information on objects awaiting finalization");
+        System.err.println("    jmap -histo[:live] <pid>");
+        System.err.println("        to connect to running process and print histogram of java object heap");
+        System.err.println("        if the \"live\" suboption is specified, only count live objects");
+        System.err.println("    jmap -dump:<dump-options> <pid>");
+        System.err.println("        to connect to running process and dump java heap");
+        System.err.println("");
+        System.err.println("    dump-options:");
+        System.err.println("      live         dump only live objects; if not specified,");
+        System.err.println("                   all objects in the heap are dumped.");
+        System.err.println("      format=b     binary format");
+        System.err.println("      file=<file>  dump heap to <file>");
+        System.err.println("");
+        System.err.println("    Example: jmap -dump:live,format=b,file=heap.bin <pid>");
         System.exit(exit);
     }
 }
diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java
index 3553284..7d629e3 100644
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java
@@ -26,12 +26,11 @@
 package sun.tools.jstack;
 
 import java.io.InputStream;
+import java.util.Collection;
 
 import com.sun.tools.attach.VirtualMachine;
-import com.sun.tools.attach.AttachNotSupportedException;
 import sun.tools.attach.HotSpotVirtualMachine;
-import jdk.internal.vm.agent.spi.ToolProvider;
-import jdk.internal.vm.agent.spi.ToolProviderFinder;
+import sun.tools.common.ProcessArgumentMatcher;
 
 /*
  * This class is the main class for the JStack utility. It parses its arguments
@@ -39,15 +38,14 @@
  * obtained the thread dump from a target process using the VM attach mechanism
  */
 public class JStack {
-    private static final String SA_JSTACK_TOOL_NAME = "jstack";
 
     public static void main(String[] args) throws Exception {
         if (args.length == 0) {
             usage(1); // no arguments
         }
 
-        boolean useSA = false;
-        boolean mixed = false;
+        checkForUnsupportedOptions(args);
+
         boolean locks = false;
 
         // Parse the options (arguments starting with "-" )
@@ -60,87 +58,40 @@
             if (arg.equals("-help") || arg.equals("-h")) {
                 usage(0);
             }
-            else if (arg.equals("-F")) {
-                useSA = true;
-            }
             else {
-                if (arg.equals("-m")) {
-                    mixed = true;
+                if (arg.equals("-l")) {
+                    locks = true;
                 } else {
-                    if (arg.equals("-l")) {
-                       locks = true;
-                    } else {
-                        usage(1);
-                    }
+                    usage(1);
                 }
             }
             optionCount++;
         }
 
-        // mixed stack implies SA tool
-        if (mixed) {
-            useSA = true;
-        }
-
-        // Next we check the parameter count. If there are two parameters
-        // we assume core file and executable so we use SA.
+        // Next we check the parameter count.
         int paramCount = args.length - optionCount;
-        if (paramCount == 0 || paramCount > 2) {
+        if (paramCount != 1) {
             usage(1);
         }
-        if (paramCount == 2) {
-            useSA = true;
-        } else {
-            // If we can't parse it as a pid then it must be debug server
-            if (!args[optionCount].matches("[0-9]+")) {
-                useSA = true;
-            }
-        }
 
-        // now execute using the SA JStack tool or the built-in thread dumper
-        if (useSA) {
-            // parameters (<pid> or <exe> <core>
-            String params[] = new String[paramCount];
-            for (int i=optionCount; i<args.length; i++ ){
-                params[i-optionCount] = args[i];
-            }
-            runJStackTool(mixed, locks, params);
+        // pass -l to thread dump operation to get extra lock info
+        String pidArg = args[optionCount];
+        String params[];
+        if (locks) {
+            params = new String[] { "-l" };
         } else {
-            // pass -l to thread dump operation to get extra lock info
-            String pid = args[optionCount];
-            String params[];
-            if (locks) {
-                params = new String[] { "-l" };
-            } else {
-                params = new String[0];
+            params = new String[0];
+        }
+        ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg, JStack.class);
+        Collection<String> pids = ap.getPids();
+        for (String pid : pids) {
+            if (pids.size() > 1) {
+                System.out.println("Pid:" + pid);
             }
             runThreadDump(pid, params);
         }
     }
 
-    // SA JStack tool
-    private static boolean isAgentToolPresent() {
-        return ToolProviderFinder.find(SA_JSTACK_TOOL_NAME) != null;
-    }
-
-    private static void runJStackTool(boolean mixed, boolean locks, String args[]) throws Exception {
-        ToolProvider tool = ToolProviderFinder.find(SA_JSTACK_TOOL_NAME);
-        if (tool == null) {
-            usage(1);            // SA not available
-        }
-
-        // JStack tool also takes -m and -l arguments
-        if (mixed) {
-            args = prepend("-m", args);
-        }
-        if (locks) {
-            args = prepend("-l", args);
-        }
-
-        tool.run(args);
-    }
-
-
     // Attach to pid and perform a thread dump
     private static void runThreadDump(String pid, String args[]) throws Exception {
         VirtualMachine vm = null;
@@ -153,10 +104,6 @@
             } else {
                 x.printStackTrace();
             }
-            if ((x instanceof AttachNotSupportedException) && isAgentToolPresent()) {
-                System.err.println("The -F option can be used when the target " +
-                    "process is not responding");
-            }
             System.exit(1);
         }
 
@@ -178,12 +125,35 @@
         vm.detach();
     }
 
-    // return a new string array with arg as the first element
-    private static String[] prepend(String arg, String args[]) {
-        String[] newargs = new String[args.length+1];
-        newargs[0] = arg;
-        System.arraycopy(args, 0, newargs, 1, args.length);
-        return newargs;
+    private static void checkForUnsupportedOptions(String[] args) {
+        // Check arguments for -F, -m, and non-numeric value
+        // and warn the user that SA is not supported anymore
+
+        int paramCount = 0;
+
+        for (String s : args) {
+            if (s.equals("-F")) {
+                SAOptionError("-F option used");
+            }
+
+            if (s.equals("-m")) {
+                SAOptionError("-m option used");
+            }
+
+            if (! s.startsWith("-")) {
+                paramCount += 1;
+            }
+        }
+
+        if (paramCount > 1) {
+            SAOptionError("More than one non-option argument");
+        }
+    }
+
+    private static void SAOptionError(String msg) {
+        System.err.println("Error: " + msg);
+        System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jstack instead");
+        System.exit(1);
     }
 
     // print usage message
@@ -191,25 +161,8 @@
         System.err.println("Usage:");
         System.err.println("    jstack [-l] <pid>");
         System.err.println("        (to connect to running process)");
-
-        if (isAgentToolPresent()) {
-            System.err.println("    jstack -F [-m] [-l] <pid>");
-            System.err.println("        (to connect to a hung process)");
-            System.err.println("    jstack [-m] [-l] <executable> <core>");
-            System.err.println("        (to connect to a core file)");
-            System.err.println("    jstack [-m] [-l] [server_id@]<remote server IP or hostname>");
-            System.err.println("        (to connect to a remote debug server)");
-        }
-
         System.err.println("");
         System.err.println("Options:");
-
-        if (isAgentToolPresent()) {
-            System.err.println("    -F  to force a thread dump. Use when jstack <pid> does not respond" +
-                " (process is hung)");
-            System.err.println("    -m  to print both java and native frames (mixed mode)");
-        }
-
         System.err.println("    -l  long listing. Prints additional information about locks");
         System.err.println("    -h or -help to print this help message");
         System.exit(exit);
diff --git a/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java b/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java
index 8e54a70..b4d4d11 100644
--- a/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java
+++ b/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -181,7 +181,7 @@
     }
 
     private static String getOnlineDocUrl() {
-        String version = Integer.toString(jdk.Version.current().major());
+        String version = Integer.toString(Runtime.version().major());
         return Resources.format(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL,
                                 version);
     }
diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java
index bbae8bc..5e6438d 100644
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java
@@ -1534,7 +1534,6 @@
             PathSearchingVirtualMachine vm = (PathSearchingVirtualMachine)Env.vm();
             MessageOutput.println("base directory:", vm.baseDirectory());
             MessageOutput.println("classpath:", vm.classPath().toString());
-            MessageOutput.println("bootclasspath:", vm.bootClassPath().toString());
         } else {
             MessageOutput.println("The VM does not use paths");
         }
diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java
index fe6dd07..cd416cc 100644
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -133,6 +133,10 @@
             if (!vmDied) {
                 vmDisconnectEvent(event);
             }
+            /*
+             * Inform jdb command line processor that jdb is being shutdown. JDK-8154144.
+             */
+            ((TTY)notifier).setShuttingDown(true);
             Env.shutdown(shutdownMessageKey);
             return false;
         } else {
diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java
index 0bd403a..ee716a5 100644
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,16 @@
      */
     private static final String progname = "jdb";
 
+    private volatile boolean shuttingDown = false;
+
+    public void setShuttingDown(boolean s) {
+       shuttingDown = s;
+    }
+
+    public boolean isShuttingDown() {
+        return shuttingDown;
+    }
+
     @Override
     public void vmStartEvent(VMStartEvent se)  {
         Thread.yield();  // fetch output
@@ -750,7 +760,13 @@
             while (true) {
                 String ln = in.readLine();
                 if (ln == null) {
-                    MessageOutput.println("Input stream closed.");
+                    /*
+                     *  Jdb is being shutdown because debuggee exited, ignore any 'null'
+                     *  returned by readLine() during shutdown. JDK-8154144.
+                     */
+                    if (!isShuttingDown()) {
+                        MessageOutput.println("Input stream closed.");
+                    }
                     ln = "quit";
                 }
 
diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java
index c412743..39e703d 100644
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java
@@ -74,7 +74,6 @@
         {"Array element is not a method", "Array element is not a method"},
         {"Array index must be a integer type", "Array index must be a integer type"},
         {"base directory:", "base directory: {0}"},
-        {"bootclasspath:", "bootclasspath: {0}"},
         {"Breakpoint hit:", "Breakpoint hit: "},
         {"breakpoint", "breakpoint {0}"},
         {"Breakpoints set:", "Breakpoints set:"},
diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java
index 1cb6d23..b356222 100644
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java
@@ -74,7 +74,6 @@
         {"Array element is not a method", "\u914D\u5217\u8981\u7D20\u306F\u30E1\u30BD\u30C3\u30C9\u3067\u306F\u3042\u308A\u307E\u305B\u3093"},
         {"Array index must be a integer type", "\u914D\u5217\u306E\u6DFB\u3048\u5B57\u306F\u6574\u6570\u578B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"},
         {"base directory:", "\u30D9\u30FC\u30B9\u30FB\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA: {0}"},
-        {"bootclasspath:", "\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9: {0}"},
         {"Breakpoint hit:", "\u30D2\u30C3\u30C8\u3057\u305F\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8: "},
         {"breakpoint", "\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8{0}"},
         {"Breakpoints set:", "\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8:"},
diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java
index 50790cb..79dc926 100644
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java
@@ -74,7 +74,6 @@
         {"Array element is not a method", "\u6570\u7EC4\u5143\u7D20\u4E0D\u662F\u65B9\u6CD5"},
         {"Array index must be a integer type", "\u6570\u7EC4\u7D22\u5F15\u5FC5\u987B\u4E3A\u6574\u6570\u7C7B\u578B"},
         {"base directory:", "\u57FA\u76EE\u5F55: {0}"},
-        {"bootclasspath:", "\u5F15\u5BFC\u7C7B\u8DEF\u5F84: {0}"},
         {"Breakpoint hit:", "\u65AD\u70B9\u547D\u4E2D: "},
         {"breakpoint", "\u65AD\u70B9{0}"},
         {"Breakpoints set:", "\u65AD\u70B9\u96C6:"},
diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
index 47e7434..28c3dfb 100644
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
@@ -1439,7 +1439,7 @@
    }
 
    public List<String> bootClassPath() {
-       return Arrays.asList(getClasspath().bootclasspaths);
+       return Collections.emptyList();
    }
 
    public String baseDirectory() {
diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
index 2718ad1..8e1639c 100644
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
@@ -126,7 +126,7 @@
             int writtenCount = 0;
             int i;
 
-            for (i=0; i<classCount; i++) {
+            for (i = 0; i < classCount; i++) {
                 jclass clazz = theClasses[i];
                 jint status = classStatus(clazz);
                 char *candidate_signature = NULL;
@@ -141,7 +141,13 @@
 
                 error = classSignature(clazz, &candidate_signature, NULL);
                 if (error != JVMTI_ERROR_NONE) {
-                    break;
+                  // Clazz become invalid since the time we get the class list
+                  // Skip this entry
+                  if (error == JVMTI_ERROR_INVALID_CLASS) {
+                    continue;
+                  }
+
+                  break;
                 }
 
                 if (strcmp(candidate_signature, signature) == 0) {
diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c
index cd1cd2f..3baf486 100644
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c
@@ -277,12 +277,14 @@
 
     JDI_ASSERT(thread);
 
+    debugMonitorEnter(invokerLock);
     request = threadControl_getInvokeRequest(thread);
     if (request == NULL) {
         EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request");
     }
 
     request->available = JNI_TRUE;
+    debugMonitorExit(invokerLock);
 }
 
 jvmtiError
@@ -739,29 +741,20 @@
 }
 
 jboolean
-invoker_isPending(jthread thread)
-{
-    InvokeRequest *request;
-
-    JDI_ASSERT(thread);
-    request = threadControl_getInvokeRequest(thread);
-    if (request == NULL) {
-        EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request");
-    }
-    return request->pending;
-}
-
-jboolean
 invoker_isEnabled(jthread thread)
 {
     InvokeRequest *request;
+    jboolean isEnabled;
 
     JDI_ASSERT(thread);
+    debugMonitorEnter(invokerLock);
     request = threadControl_getInvokeRequest(thread);
     if (request == NULL) {
         EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request");
     }
-    return request->available;
+    isEnabled = request->available;
+    debugMonitorExit(invokerLock);
+    return isEnabled;
 }
 
 void
diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h
index 29ecdb5..e004ce6 100644
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h
@@ -67,7 +67,6 @@
 jboolean invoker_doInvoke(jthread thread);
 
 void invoker_completeInvokeRequest(jthread thread);
-jboolean invoker_isPending(jthread thread);
 jboolean invoker_isEnabled(jthread thread);
 void invoker_detach(InvokeRequest *request);
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties
index ef94fd3..ef10923 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties
@@ -1,3 +1,28 @@
+#
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
 main.usage.summary=\
 Usage: {0} <extract|info|list|set|verify> <options> jimage...\n\
 use --help for a list of possible options
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java
index 92d7eb6..e899d37 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java
@@ -34,11 +34,9 @@
 import java.util.Set;
 import jdk.tools.jlink.internal.JlinkTask;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
-import jdk.tools.jlink.internal.PluginContextImpl;
 import jdk.tools.jlink.internal.PluginRepository;
 
 /**
@@ -71,7 +69,6 @@
         private final List<Plugin> plugins;
         private final ImageBuilder imageBuilder;
         private final String lastSorterPluginName;
-        private final PluginContext pluginContext;
 
         /**
          * Empty plugins configuration.
@@ -86,7 +83,7 @@
          * @param plugins List of plugins.
          */
         public PluginsConfiguration(List<Plugin> plugins) {
-            this(plugins, null, null, null);
+            this(plugins, null, null);
         }
 
         /**
@@ -101,28 +98,10 @@
          */
         public PluginsConfiguration(List<Plugin> plugins,
                 ImageBuilder imageBuilder, String lastSorterPluginName) {
-            this(plugins, imageBuilder, lastSorterPluginName, null);
-        }
-
-        /**
-         * Plugins configuration with a last sorter and an ImageBuilder. No
-         * sorting can occur after the last sorter plugin. The ImageBuilder is
-         * in charge to layout the image content on disk.
-         *
-         * @param plugins List of transformer plugins.
-         * @param imageBuilder Image builder.
-         * @param lastSorterPluginName Name of last sorter plugin, no sorting
-         * @param ctx the plugin context
-         * can occur after it.
-         */
-        public PluginsConfiguration(List<Plugin> plugins,
-                ImageBuilder imageBuilder, String lastSorterPluginName,
-                PluginContext ctx) {
             this.plugins = plugins == null ? Collections.emptyList()
                     : plugins;
             this.imageBuilder = imageBuilder;
             this.lastSorterPluginName = lastSorterPluginName;
-            this.pluginContext = ctx != null? ctx : new PluginContextImpl();
         }
 
         /**
@@ -146,13 +125,6 @@
             return lastSorterPluginName;
         }
 
-        /**
-         * @return the pluginContext
-         */
-        public PluginContext getPluginContext() {
-            return pluginContext;
-        }
-
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
index a394314..2c0620a 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -24,8 +25,6 @@
  */
 package jdk.tools.jlink.builder;
 
-import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.PluginException;
 import java.io.BufferedOutputStream;
 import java.io.BufferedWriter;
 import java.io.ByteArrayInputStream;
@@ -47,8 +46,10 @@
 import java.nio.file.attribute.PosixFileAttributeView;
 import java.nio.file.attribute.PosixFilePermission;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Properties;
@@ -56,23 +57,40 @@
 import jdk.tools.jlink.internal.BasicImageWriter;
 import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
 import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.Module;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ExecutableImage;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.PluginException;
 
 /**
  *
  * Default Image Builder. This builder creates the default runtime image layout.
  */
-public class DefaultImageBuilder implements ImageBuilder {
+public final class DefaultImageBuilder implements ImageBuilder {
 
     /**
      * The default java executable Image.
      */
-    static class DefaultExecutableImage extends ExecutableImage {
+    static final class DefaultExecutableImage implements ExecutableImage {
+
+        private final Path home;
+        private final List<String> args;
+        private final Set<String> modules;
 
         public DefaultExecutableImage(Path home, Set<String> modules) {
-            super(home, modules, createArgs(home));
+            this(home, modules, createArgs(home));
+        }
+
+        private DefaultExecutableImage(Path home, Set<String> modules,
+                List<String> args) {
+            Objects.requireNonNull(home);
+            Objects.requireNonNull(args);
+            if (!Files.exists(home)) {
+                throw new IllegalArgumentException("Invalid image home");
+            }
+            this.home = home;
+            this.modules = Collections.unmodifiableSet(modules);
+            this.args = Collections.unmodifiableList(args);
         }
 
         private static List<String> createArgs(Path home) {
@@ -84,6 +102,21 @@
         }
 
         @Override
+        public Path getHome() {
+            return home;
+        }
+
+        @Override
+        public Set<String> getModules() {
+            return modules;
+        }
+
+        @Override
+        public List<String> getExecutionArgs() {
+            return args;
+        }
+
+        @Override
         public void storeLaunchArgs(List<String> args) {
             try {
                 patchScripts(this, args);
@@ -111,17 +144,19 @@
         Files.createDirectories(mdir);
     }
 
-    private void storeFiles(Set<String> modules, Properties release) throws IOException {
+    private void storeFiles(Set<String> modules, Map<String, String> release) throws IOException {
         if (release != null) {
-            addModules(release, modules);
+            Properties props = new Properties();
+            props.putAll(release);
+            addModules(props, modules);
             File r = new File(root.toFile(), "release");
             try (FileOutputStream fo = new FileOutputStream(r)) {
-                release.store(fo, null);
+                props.store(fo, null);
             }
         }
     }
 
-    private void addModules(Properties release, Set<String> modules) throws IOException {
+    private void addModules(Properties props, Set<String> modules) throws IOException {
         StringBuilder builder = new StringBuilder();
         int i = 0;
         for (String m : modules) {
@@ -131,28 +166,32 @@
             }
             i++;
         }
-        release.setProperty("MODULES", builder.toString());
+        props.setProperty("MODULES", builder.toString());
     }
 
     @Override
-    public void storeFiles(Pool files, Properties release) {
+    public void storeFiles(ModulePool files) {
         try {
-            for (ModuleData f : files.getContent()) {
-               if (!f.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
-                    accept(f);
+            files.entries().forEach(f -> {
+                if (!f.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
+                    try {
+                        accept(f);
+                    } catch (IOException ioExp) {
+                        throw new UncheckedIOException(ioExp);
+                    }
                 }
-            }
-            for (Module m : files.getModules()) {
+            });
+            files.modules().forEach(m -> {
                 // Only add modules that contain packages
                 if (!m.getAllPackages().isEmpty()) {
                     // Skip the fake module used by FileCopierPlugin when copying files.
                     if (m.getName().equals(FileCopierPlugin.FAKE_MODULE)) {
-                       continue;
+                        return;
                     }
                     modules.add(m.getName());
                 }
-            }
-            storeFiles(modules, release);
+            });
+            storeFiles(modules, files.getReleaseProperties());
 
             if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) {
                 // launchers in the bin directory need execute permission
@@ -168,8 +207,8 @@
                 Path lib = root.resolve("lib");
                 if (Files.isDirectory(lib)) {
                     Files.find(lib, 2, (path, attrs) -> {
-                        return path.getFileName().toString().equals("jspawnhelper") ||
-                               path.getFileName().toString().equals("jexec");
+                        return path.getFileName().toString().equals("jspawnhelper")
+                                || path.getFileName().toString().equals("jexec");
                     }).forEach(this::setExecutable);
                 }
             }
@@ -180,27 +219,23 @@
         }
     }
 
-    @Override
-    public void storeFiles(Pool files) {
-        storeFiles(files, new Properties());
-    }
-
     /**
      * Generates launcher scripts.
+     *
      * @param imageContent The image content.
      * @param modules The set of modules that the runtime image contains.
      * @throws IOException
      */
-    protected void prepareApplicationFiles(Pool imageContent, Set<String> modules) throws IOException {
+    protected void prepareApplicationFiles(ModulePool imageContent, Set<String> modules) throws IOException {
         // generate launch scripts for the modules with a main class
         for (String module : modules) {
             String path = "/" + module + "/module-info.class";
-            ModuleData res = imageContent.get(path);
-            if (res == null) {
+            Optional<ModuleEntry> res = imageContent.findEntry(path);
+            if (!res.isPresent()) {
                 throw new IOException("module-info.class not found for " + module + " module");
             }
             Optional<String> mainClass;
-            ByteArrayInputStream stream = new ByteArrayInputStream(res.getBytes());
+            ByteArrayInputStream stream = new ByteArrayInputStream(res.get().getBytes());
             mainClass = ModuleDescriptor.read(stream).mainClass();
             if (mainClass.isPresent()) {
                 Path cmd = root.resolve("bin").resolve(module);
@@ -263,9 +298,9 @@
         }
     }
 
-    private void accept(ModuleData file) throws IOException {
+    private void accept(ModuleEntry file) throws IOException {
         String fullPath = file.getPath();
-        String module = "/" + file.getModule()+ "/";
+        String module = "/" + file.getModule() + "/";
         String filename = fullPath.substring(module.length());
         // Remove radical native|config|...
         filename = filename.substring(filename.indexOf('/') + 1);
@@ -404,8 +439,7 @@
 
     public static ExecutableImage getExecutableImage(Path root) {
         if (Files.exists(root.resolve("bin").resolve(getJavaProcessName()))) {
-            return new DefaultImageBuilder.DefaultExecutableImage(root,
-                    retrieveModules(root));
+            return new DefaultExecutableImage(root, retrieveModules(root));
         }
         return null;
     }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java
index dc0bf71..10cea85 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java
@@ -29,7 +29,7 @@
 
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * Implement this interface to develop your own image layout. First the jimage
@@ -45,7 +45,7 @@
      * @param release the release properties
      * @throws PluginException
      */
-    public default void storeFiles(Pool content, Properties release) {
+    public default void storeFiles(ModulePool content, Properties release) {
         storeFiles(content);
     }
 
@@ -55,7 +55,7 @@
      * @param content Pool of module content.
      * @throws PluginException
      */
-    public default void storeFiles(Pool content) {
+    public default void storeFiles(ModulePool content) {
         throw new UnsupportedOperationException("storeFiles");
     }
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
index e0347e5..f765be2 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
@@ -44,12 +44,11 @@
 import java.util.stream.Stream;
 import jdk.tools.jlink.internal.Archive.Entry;
 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
-import jdk.tools.jlink.internal.PoolImpl.CompressedModuleData;
+import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
 
 /**
  * An image (native endian.)
@@ -145,7 +144,7 @@
                                     }));
             ByteOrder order = ByteOrder.nativeOrder();
             BasicImageWriter writer = new BasicImageWriter(order);
-            PoolImpl pool = createPools(archives, entriesForModule, order, writer);
+            ModulePoolImpl pool = createPools(archives, entriesForModule, order, writer);
             try (OutputStream fos = Files.newOutputStream(jimageFile);
                     BufferedOutputStream bos = new BufferedOutputStream(fos);
                     DataOutputStream out = new DataOutputStream(bos)) {
@@ -163,9 +162,9 @@
             ByteOrder byteOrder)
             throws IOException {
         BasicImageWriter writer = new BasicImageWriter(byteOrder);
-        PoolImpl allContent = createPools(archives,
+        ModulePoolImpl allContent = createPools(archives,
                 entriesForModule, byteOrder, writer);
-        PoolImpl result = generateJImage(allContent,
+        ModulePoolImpl result = generateJImage(allContent,
              writer, plugins, plugins.getJImageFileOutputStream());
 
         //Handle files.
@@ -176,12 +175,12 @@
         }
     }
 
-    private static PoolImpl generateJImage(PoolImpl allContent,
+    private static ModulePoolImpl generateJImage(ModulePoolImpl allContent,
             BasicImageWriter writer,
             ImagePluginStack pluginSupport,
             DataOutputStream out
     ) throws IOException {
-        PoolImpl resultResources;
+        ModulePoolImpl resultResources;
         try {
             resultResources = pluginSupport.visitResources(allContent);
         } catch (PluginException pe) {
@@ -190,14 +189,14 @@
             throw new IOException(ex);
         }
         Set<String> duplicates = new HashSet<>();
-        long offset = 0;
+        long[] offset = new long[1];
 
-        List<ModuleData> content = new ArrayList<>();
+        List<ModuleEntry> content = new ArrayList<>();
         List<String> paths = new ArrayList<>();
                  // the order of traversing the resources and the order of
         // the module content being written must be the same
-        for (ModuleData res : resultResources.getContent()) {
-            if (res.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+        resultResources.entries().forEach(res -> {
+            if (res.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 String path = res.getPath();
                 content.add(res);
                 long uncompressedSize = res.getLength();
@@ -216,24 +215,24 @@
                     // TODO Need to hang bytes on resource and write
                     // from resource not zip.
                     // Skipping resource throws off writing from zip.
-                    offset += onFileSize;
-                    continue;
+                    offset[0] += onFileSize;
+                    return;
                 }
                 duplicates.add(path);
-                writer.addLocation(path, offset, compressedSize, uncompressedSize);
+                writer.addLocation(path, offset[0], compressedSize, uncompressedSize);
                 paths.add(path);
-                offset += onFileSize;
+                offset[0] += onFileSize;
             }
-        }
+        });
 
-        ImageResourcesTree tree = new ImageResourcesTree(offset, writer, paths);
+        ImageResourcesTree tree = new ImageResourcesTree(offset[0], writer, paths);
 
         // write header and indices
         byte[] bytes = writer.getBytes();
         out.write(bytes, 0, bytes.length);
 
         // write module content
-        for (ModuleData res : content) {
+        for (ModuleEntry res : content) {
             byte[] buf = res.getBytes();
             out.write(buf, 0, buf.length);
         }
@@ -245,26 +244,26 @@
         return resultResources;
     }
 
-    private static Pool.ModuleDataType mapImageFileType(EntryType type) {
+    private static ModuleEntry.Type mapImageFileType(EntryType type) {
         switch(type) {
             case CONFIG: {
-                return Pool.ModuleDataType.CONFIG;
+                return ModuleEntry.Type.CONFIG;
             }
             case NATIVE_CMD: {
-                return Pool.ModuleDataType.NATIVE_CMD;
+                return ModuleEntry.Type.NATIVE_CMD;
             }
             case NATIVE_LIB: {
-                return Pool.ModuleDataType.NATIVE_LIB;
+                return ModuleEntry.Type.NATIVE_LIB;
             }
         }
         return null;
     }
 
-    private static PoolImpl createPools(Set<Archive> archives,
+    private static ModulePoolImpl createPools(Set<Archive> archives,
             Map<String, List<Entry>> entriesForModule,
             ByteOrder byteOrder,
             BasicImageWriter writer) throws IOException {
-        PoolImpl resources = new PoolImpl(byteOrder, new StringTable() {
+        ModulePoolImpl resources = new ModulePoolImpl(byteOrder, new StringTable() {
 
             @Override
             public int addString(String str) {
@@ -291,7 +290,7 @@
                             path = "/" + mn + "/" + path;
                         }
                         try {
-                            resources.add(Pool.newResource(path, bytes));
+                            resources.add(ModuleEntry.create(path, bytes));
                         } catch (Exception ex) {
                             throw new IOException(ex);
                         }
@@ -300,7 +299,7 @@
                     try {
                         // Entry.path() contains the kind of file native, conf, bin, ...
                         // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg
-                        resources.add(Pool.newImageFile(mn,
+                        resources.add(ModuleEntry.create(mn,
                                 "/" + mn + "/" + entry.path(), mapImageFileType(entry.type()),
                                 entry.stream(), entry.size()));
                     } catch (Exception ex) {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java
index 7bd631a..08ff3cb 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java
@@ -28,22 +28,17 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Properties;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.PostProcessorPlugin;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
@@ -52,17 +47,18 @@
  */
 public final class ImagePluginConfiguration {
 
-    private static final List<Plugin.CATEGORY> CATEGORIES_ORDER = new ArrayList<>();
+    private static final List<Plugin.Category> CATEGORIES_ORDER = new ArrayList<>();
 
     static {
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.FILTER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.TRANSFORMER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.MODULEINFO_TRANSFORMER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.SORTER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.COMPRESSOR);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.VERIFIER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.PROCESSOR);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.PACKAGER);
+        CATEGORIES_ORDER.add(Plugin.Category.FILTER);
+        CATEGORIES_ORDER.add(Plugin.Category.TRANSFORMER);
+        CATEGORIES_ORDER.add(Plugin.Category.MODULEINFO_TRANSFORMER);
+        CATEGORIES_ORDER.add(Plugin.Category.SORTER);
+        CATEGORIES_ORDER.add(Plugin.Category.COMPRESSOR);
+        CATEGORIES_ORDER.add(Plugin.Category.METAINFO_ADDER);
+        CATEGORIES_ORDER.add(Plugin.Category.VERIFIER);
+        CATEGORIES_ORDER.add(Plugin.Category.PROCESSOR);
+        CATEGORIES_ORDER.add(Plugin.Category.PACKAGER);
     }
 
     private ImagePluginConfiguration() {
@@ -76,8 +72,8 @@
         if (pluginsConfiguration == null) {
             return new ImagePluginStack();
         }
-        Map<Plugin.CATEGORY, List<Plugin>> plugins = new LinkedHashMap<>();
-        for (Plugin.CATEGORY cat : CATEGORIES_ORDER) {
+        Map<Plugin.Category, List<Plugin>> plugins = new LinkedHashMap<>();
+        for (Plugin.Category cat : CATEGORIES_ORDER) {
             plugins.put(cat, new ArrayList<>());
         }
 
@@ -89,7 +85,7 @@
                         + " added more than once to stack ");
             }
             seen.add(plug.getName());
-            CATEGORY category = Utils.getCategory(plug);
+            Category category = Utils.getCategory(plug);
             if (category == null) {
                 throw new PluginException("Invalid category for "
                         + plug.getName());
@@ -100,10 +96,10 @@
 
         List<TransformerPlugin> transformerPlugins = new ArrayList<>();
         List<PostProcessorPlugin> postProcessingPlugins = new ArrayList<>();
-        for (Entry<Plugin.CATEGORY, List<Plugin>> entry : plugins.entrySet()) {
+        for (Entry<Plugin.Category, List<Plugin>> entry : plugins.entrySet()) {
             // Sort according to plugin constraints
             List<Plugin> orderedPlugins = PluginOrderingGraph.sort(entry.getValue());
-            CATEGORY category = entry.getKey();
+            Category category = entry.getKey();
             for (Plugin p : orderedPlugins) {
                 if (Utils.isPostProcessor(category)) {
                     @SuppressWarnings("unchecked")
@@ -143,14 +139,13 @@
                 }
 
                 @Override
-                public void storeFiles(Pool files) {
+                public void storeFiles(ModulePool files) {
                     throw new PluginException("No directory setup to store files");
                 }
             };
         }
 
-        PluginContext ctxt = pluginsConfiguration.getPluginContext();
         return new ImagePluginStack(builder, transformerPlugins,
-                lastSorter, postProcessingPlugins, ctxt);
+                lastSorter, postProcessingPlugins);
     }
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java
index 6a5db82..24b8aeb 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java
@@ -37,20 +37,21 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Properties;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import jdk.internal.jimage.decompressor.Decompressor;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PostProcessorPlugin;
 
 /**
@@ -64,9 +65,9 @@
         ExecutableImage retrieve(ImagePluginStack stack) throws IOException;
     }
 
-    public static final class OrderedResourcePool extends PoolImpl {
+    public static final class OrderedResourcePool extends ModulePoolImpl {
 
-        private final List<ModuleData> orderedList = new ArrayList<>();
+        private final List<ModuleEntry> orderedList = new ArrayList<>();
 
         public OrderedResourcePool(ByteOrder order, StringTable table) {
             super(order, table);
@@ -78,22 +79,22 @@
          * @param resource The Resource to add.
          */
         @Override
-        public void add(ModuleData resource) {
+        public void add(ModuleEntry resource) {
             super.add(resource);
             orderedList.add(resource);
         }
 
-        List<ModuleData> getOrderedList() {
+        List<ModuleEntry> getOrderedList() {
             return Collections.unmodifiableList(orderedList);
         }
     }
 
-    private final static class CheckOrderResourcePool extends PoolImpl {
+    private final static class CheckOrderResourcePool extends ModulePoolImpl {
 
-        private final List<ModuleData> orderedList;
+        private final List<ModuleEntry> orderedList;
         private int currentIndex;
 
-        public CheckOrderResourcePool(ByteOrder order, List<ModuleData> orderedList, StringTable table) {
+        public CheckOrderResourcePool(ByteOrder order, List<ModuleEntry> orderedList, StringTable table) {
             super(order, table);
             this.orderedList = orderedList;
         }
@@ -104,8 +105,8 @@
          * @param resource The Resource to add.
          */
         @Override
-        public void add(ModuleData resource) {
-            ModuleData ordered = orderedList.get(currentIndex);
+        public void add(ModuleEntry resource) {
+            ModuleEntry ordered = orderedList.get(currentIndex);
             if (!resource.equals(ordered)) {
                 throw new PluginException("Resource " + resource.getPath() + " not in the right order");
             }
@@ -166,26 +167,16 @@
     private final List<ResourcePrevisitor> resourcePrevisitors = new ArrayList<>();
 
     private final ImageBuilder imageBuilder;
-    private final Properties release;
 
     public ImagePluginStack() {
         this(null, Collections.emptyList(), null,
-                Collections.emptyList(), null);
+                Collections.emptyList());
     }
 
     public ImagePluginStack(ImageBuilder imageBuilder,
             List<TransformerPlugin> contentPlugins,
             Plugin lastSorter,
             List<PostProcessorPlugin> postprocessingPlugins) {
-        this(imageBuilder, contentPlugins, lastSorter,
-            postprocessingPlugins, null);
-    }
-
-    public ImagePluginStack(ImageBuilder imageBuilder,
-            List<TransformerPlugin> contentPlugins,
-            Plugin lastSorter,
-            List<PostProcessorPlugin> postprocessingPlugins,
-            PluginContext ctxt) {
         Objects.requireNonNull(contentPlugins);
         this.lastSorter = lastSorter;
         for (TransformerPlugin p : contentPlugins) {
@@ -200,7 +191,6 @@
             this.postProcessingPlugins.add(p);
         }
         this.imageBuilder = imageBuilder;
-        this.release = ctxt != null? ctxt.getReleaseProperties() : new Properties();
     }
 
     public void operate(ImageProvider provider) throws Exception {
@@ -231,12 +221,12 @@
      * @return The result of the visit.
      * @throws IOException
      */
-    public PoolImpl visitResources(PoolImpl resources)
+    public ModulePoolImpl visitResources(ModulePoolImpl resources)
             throws Exception {
         Objects.requireNonNull(resources);
         resources.setReadOnly();
         if (resources.isEmpty()) {
-            return new PoolImpl(resources.getByteOrder(),
+            return new ModulePoolImpl(resources.getByteOrder(),
                     resources.getStringTable());
         }
         PreVisitStrings previsit = new PreVisitStrings();
@@ -250,11 +240,11 @@
             resources.getStringTable().addString(s);
         }
 
-        PoolImpl current = resources;
-        List<Pool.ModuleData> frozenOrder = null;
+        ModulePoolImpl current = resources;
+        List<ModuleEntry> frozenOrder = null;
         for (TransformerPlugin p : contentPlugins) {
             current.setReadOnly();
-            PoolImpl output = null;
+            ModulePoolImpl output = null;
             if (p == lastSorter) {
                 if (frozenOrder != null) {
                     throw new Exception("Order of resources is already frozen. Plugin "
@@ -268,7 +258,7 @@
                     output = new CheckOrderResourcePool(current.getByteOrder(),
                             frozenOrder, resources.getStringTable());
                 } else {
-                    output = new PoolImpl(current.getByteOrder(),
+                    output = new ModulePoolImpl(current.getByteOrder(),
                             resources.getStringTable());
                 }
             }
@@ -287,15 +277,15 @@
     }
 
     /**
-     * This pool wrap the original pool and automatically uncompress moduledata
+     * This pool wrap the original pool and automatically uncompress ModuleEntry
      * if needed.
      */
-    private class LastPool extends Pool {
-        private class LastModule implements Module {
+    private class LastPool implements ModulePool {
+        private class LastModule implements LinkModule {
 
-            private final Module module;
+            final LinkModule module;
 
-            LastModule(Module module) {
+            LastModule(LinkModule module) {
                 this.module = module;
             }
 
@@ -305,9 +295,9 @@
             }
 
             @Override
-            public ModuleData get(String path) {
-                ModuleData d = module.get(path);
-                return getUncompressed(d);
+            public Optional<ModuleEntry> findEntry(String path) {
+                Optional<ModuleEntry> d = module.findEntry(path);
+                return d.isPresent()? Optional.of(getUncompressed(d.get())) : Optional.empty();
             }
 
             @Override
@@ -316,7 +306,7 @@
             }
 
             @Override
-            public void add(ModuleData data) {
+            public void add(ModuleEntry data) {
                 throw new PluginException("pool is readonly");
             }
 
@@ -331,19 +321,24 @@
             }
 
             @Override
-            public Collection<ModuleData> getContent() {
-                List<ModuleData> lst = new ArrayList<>();
-                for(ModuleData md : module.getContent()) {
+            public Stream<ModuleEntry> entries() {
+                List<ModuleEntry> lst = new ArrayList<>();
+                module.entries().forEach(md -> {
                     lst.add(getUncompressed(md));
-                }
-                return lst;
+                });
+                return lst.stream();
+            }
+
+            @Override
+            public int getEntryCount() {
+                return module.getEntryCount();
             }
         }
-        private final PoolImpl pool;
+        private final ModulePoolImpl pool;
         Decompressor decompressor = new Decompressor();
-        Collection<ModuleData> content;
+        Collection<ModuleEntry> content;
 
-        LastPool(PoolImpl pool) {
+        LastPool(ModulePoolImpl pool) {
             this.pool = pool;
         }
 
@@ -353,23 +348,14 @@
         }
 
         @Override
-        public void add(ModuleData resource) {
+        public void add(ModuleEntry resource) {
             throw new PluginException("pool is readonly");
         }
 
-        /**
-         * Retrieves the module of the provided name.
-         *
-         * @param name The module name
-         * @return the module or null if the module doesn't exist.
-         */
         @Override
-        public Module getModule(String name) {
-            Module module = pool.getModule(name);
-            if (module != null) {
-                module = new LastModule(module);
-            }
-            return module;
+        public Optional<LinkModule> findModule(String name) {
+            Optional<LinkModule> module = pool.findModule(name);
+            return module.isPresent()? Optional.of(new LastModule(module.get())) : Optional.empty();
         }
 
         /**
@@ -378,45 +364,55 @@
          * @return The collection of modules.
          */
         @Override
-        public Collection<Module> getModules() {
-            List<Module> modules = new ArrayList<>();
-            for (Module m : pool.getModules()) {
+        public Stream<? extends LinkModule> modules() {
+            List<LinkModule> modules = new ArrayList<>();
+            pool.modules().forEach(m -> {
                 modules.add(new LastModule(m));
-            }
-            return modules;
+            });
+            return modules.stream();
+        }
+
+        @Override
+        public int getModuleCount() {
+            return pool.getModuleCount();
         }
 
         /**
          * Get all resources contained in this pool instance.
          *
-         * @return The collection of resources;
+         * @return The stream of resources;
          */
         @Override
-        public Collection<ModuleData> getContent() {
+        public Stream<? extends ModuleEntry> entries() {
             if (content == null) {
                 content = new ArrayList<>();
-                for (ModuleData md : pool.getContent()) {
+                pool.entries().forEach(md -> {
                     content.add(getUncompressed(md));
-                }
+                });
             }
-            return content;
+            return content.stream();
+        }
+
+        @Override
+        public int getEntryCount() {
+            return pool.getEntryCount();
         }
 
         /**
          * Get the resource for the passed path.
          *
          * @param path A resource path
-         * @return A Resource instance or null if the resource is not found
+         * @return A Resource instance if the resource is found
          */
         @Override
-        public ModuleData get(String path) {
+        public Optional<ModuleEntry> findEntry(String path) {
             Objects.requireNonNull(path);
-            Pool.ModuleData res = pool.get(path);
-            return getUncompressed(res);
+            Optional<ModuleEntry> res = pool.findEntry(path);
+            return res.isPresent()? Optional.of(getUncompressed(res.get())) : Optional.empty();
         }
 
         @Override
-        public boolean contains(ModuleData res) {
+        public boolean contains(ModuleEntry res) {
             return pool.contains(res);
         }
 
@@ -426,8 +422,8 @@
         }
 
         @Override
-        public void visit(Visitor visitor, Pool output) {
-            pool.visit(visitor, output);
+        public void transformAndCopy(Function<ModuleEntry, ModuleEntry> visitor, ModulePool output) {
+            pool.transformAndCopy(visitor, output);
         }
 
         @Override
@@ -435,14 +431,19 @@
             return pool.getByteOrder();
         }
 
-        private ModuleData getUncompressed(ModuleData res) {
+        @Override
+        public Map<String, String> getReleaseProperties() {
+            return Collections.unmodifiableMap(pool.getReleaseProperties());
+        }
+
+        private ModuleEntry getUncompressed(ModuleEntry res) {
             if (res != null) {
-                if (res instanceof PoolImpl.CompressedModuleData) {
+                if (res instanceof ModulePoolImpl.CompressedModuleData) {
                     try {
                         byte[] bytes = decompressor.decompressResource(getByteOrder(),
                                 (int offset) -> pool.getStringTable().getString(offset),
                                 res.getBytes());
-                        res = Pool.newResource(res.getPath(),
+                        res = ModuleEntry.create(res.getPath(),
                                 new ByteArrayInputStream(bytes),
                                 bytes.length);
                     } catch (IOException ex) {
@@ -462,20 +463,24 @@
      * @param writer
      * @throws java.lang.Exception
      */
-    public void storeFiles(PoolImpl original, PoolImpl transformed,
+    public void storeFiles(ModulePoolImpl original, ModulePoolImpl transformed,
             BasicImageWriter writer)
             throws Exception {
         Objects.requireNonNull(original);
-        try {
-            // fill release information available from transformed "java.base" module!
-            ModuleDescriptor desc = transformed.getModule("java.base").getDescriptor();
-            desc.osName().ifPresent(s -> release.put("OS_NAME", s));
-            desc.osVersion().ifPresent(s -> release.put("OS_VERSION", s));
-            desc.osArch().ifPresent(s -> release.put("OS_ARCH", s));
-        } catch (Exception ignored) {
-        }
+        Objects.requireNonNull(transformed);
+        Optional<LinkModule> javaBase = transformed.findModule("java.base");
+        javaBase.ifPresent(mod -> {
+            try {
+                Map<String, String> release = transformed.getReleaseProperties();
+                // fill release information available from transformed "java.base" module!
+                ModuleDescriptor desc = mod.getDescriptor();
+                desc.osName().ifPresent(s -> release.put("OS_NAME", s));
+                desc.osVersion().ifPresent(s -> release.put("OS_VERSION", s));
+                desc.osArch().ifPresent(s -> release.put("OS_ARCH", s));
+            } catch (Exception ignored) {}
+        });
 
-        imageBuilder.storeFiles(new LastPool(transformed), release);
+        imageBuilder.storeFiles(new LastPool(transformed));
     }
 
     public ExecutableImage getExecutableImage() throws IOException {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java
index a5b4ba6..a5df2d7 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java
@@ -371,7 +371,7 @@
 
         Configuration cf = Configuration.empty()
                 .resolveRequires(finder,
-                                 ModuleFinder.empty(),
+                                 ModuleFinder.of(),
                                  addMods);
 
         Map<String, Path> mods = cf.modules().stream()
@@ -390,7 +390,7 @@
         // resolve all root modules
         Configuration cf = Configuration.empty()
                 .resolveRequires(finder,
-                                 ModuleFinder.empty(),
+                                 ModuleFinder.of(),
                                  roots);
 
         // module name -> reference
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java
new file mode 100644
index 0000000..30c07a3
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.tools.jlink.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.util.Objects;
+import jdk.tools.jlink.plugin.ModuleEntry;
+
+/**
+ * A LinkModuleEntry is the elementary unit of data inside an image. It is
+ * generally a file. e.g.: a java class file, a resource file, a shared library,
+ * ...
+ * <br>
+ * A LinkModuleEntry is identified by a path of the form:
+ * <ul>
+ * <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file
+ * name}</li>
+ * <li>For other files (shared lib, launchers, config, ...):/{module name}/
+ * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}</li>
+ * </ul>
+ */
+public class ModuleEntryImpl implements ModuleEntry {
+
+    private final Type type;
+    private final String path;
+    private final String module;
+    private final long length;
+    private final InputStream stream;
+    private byte[] buffer;
+
+    /**
+     * Create a new LinkModuleEntry.
+     *
+     * @param module The module name.
+     * @param path The data path identifier.
+     * @param type The data type.
+     * @param stream The data content stream.
+     * @param length The stream length.
+     */
+    public ModuleEntryImpl(String module, String path, Type type, InputStream stream, long length) {
+        Objects.requireNonNull(module);
+        Objects.requireNonNull(path);
+        Objects.requireNonNull(type);
+        Objects.requireNonNull(stream);
+        this.path = path;
+        this.type = type;
+        this.module = module;
+        this.stream = stream;
+        this.length = length;
+    }
+
+    /**
+     * The LinkModuleEntry module name.
+     *
+     * @return The module name.
+     */
+    @Override
+    public final String getModule() {
+        return module;
+    }
+
+    /**
+     * The LinkModuleEntry path.
+     *
+     * @return The module path.
+     */
+    @Override
+    public final String getPath() {
+        return path;
+    }
+
+    /**
+     * The LinkModuleEntry's type.
+     *
+     * @return The data type.
+     */
+    @Override
+    public final Type getType() {
+        return type;
+    }
+
+    /**
+     * The LinkModuleEntry content as an array of byte.
+     *
+     * @return An Array of bytes.
+     */
+    @Override
+    public byte[] getBytes() {
+        if (buffer == null) {
+            try (InputStream is = stream) {
+                buffer = is.readAllBytes();
+            } catch (IOException ex) {
+                throw new UncheckedIOException(ex);
+            }
+        }
+        return buffer;
+    }
+
+    /**
+     * The LinkModuleEntry content length.
+     *
+     * @return The length.
+     */
+    @Override
+    public long getLength() {
+        return length;
+    }
+
+    /**
+     * The LinkModuleEntry stream.
+     *
+     * @return The module data stream.
+     */
+    @Override
+    public InputStream stream() {
+        return stream;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 89 * hash + Objects.hashCode(this.path);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof ModuleEntryImpl)) {
+            return false;
+        }
+        ModuleEntryImpl f = (ModuleEntryImpl) other;
+        return f.path.equals(path);
+    }
+
+    @Override
+    public String toString() {
+        return getPath();
+    }
+}
\ No newline at end of file
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java
new file mode 100644
index 0000000..a572fa4
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java
@@ -0,0 +1,421 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.module.ModuleDescriptor;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import jdk.internal.jimage.decompressor.CompressedResourceHeader;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.PluginException;
+import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
+
+/**
+ * Pool of module data.
+ */
+public class ModulePoolImpl implements ModulePool {
+
+    private class ModuleImpl implements LinkModule {
+
+        final Map<String, ModuleEntry> moduleContent = new LinkedHashMap<>();
+        private ModuleDescriptor descriptor;
+        final String name;
+
+        private ModuleImpl(String name) {
+            this.name = name;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public Optional<ModuleEntry> findEntry(String path) {
+            if (!path.startsWith("/")) {
+                path = "/" + path;
+            }
+            if (!path.startsWith("/" + name)) {
+                path = "/" + name + path;
+            }
+            return Optional.ofNullable(moduleContent.get(path));
+        }
+
+        @Override
+        public ModuleDescriptor getDescriptor() {
+            if (descriptor == null) {
+                String p = "/" + name + "/module-info.class";
+                Optional<ModuleEntry> content = findEntry(p);
+                if (!content.isPresent()) {
+                    throw new PluginException("No module-info for " + name
+                            + " module");
+                }
+                ByteBuffer bb = ByteBuffer.wrap(content.get().getBytes());
+                descriptor = ModuleDescriptor.read(bb);
+            }
+            return descriptor;
+        }
+
+        @Override
+        public void add(ModuleEntry data) {
+            if (isReadOnly()) {
+                throw new PluginException("LinkConfiguration is readonly");
+            }
+            Objects.requireNonNull(data);
+            if (!data.getModule().equals(name)) {
+                throw new PluginException("Can't add resource " + data.getPath()
+                        + " to module " + name);
+            }
+            ModulePoolImpl.this.add(data);
+        }
+
+        @Override
+        public Set<String> getAllPackages() {
+            Set<String> pkgs = new HashSet<>();
+            moduleContent.values().stream().filter(m -> m.getType().
+                    equals(ModuleEntry.Type.CLASS_OR_RESOURCE)).forEach(res -> {
+                // Module metadata only contains packages with .class files
+                if (ImageFileCreator.isClassPackage(res.getPath())) {
+                    String[] split = ImageFileCreator.splitPath(res.getPath());
+                    String pkg = split[1];
+                    if (pkg != null && !pkg.isEmpty()) {
+                        pkgs.add(pkg);
+                    }
+                }
+            });
+            return pkgs;
+        }
+
+        @Override
+        public String toString() {
+            return getName();
+        }
+
+        @Override
+        public Stream<? extends ModuleEntry> entries() {
+            return moduleContent.values().stream();
+        }
+
+        @Override
+        public int getEntryCount() {
+            return moduleContent.values().size();
+        }
+    }
+
+    private final Map<String, ModuleEntry> resources = new LinkedHashMap<>();
+    private final Map<String, ModuleImpl> modules = new LinkedHashMap<>();
+    private final ModuleImpl fileCopierModule = new ModuleImpl(FileCopierPlugin.FAKE_MODULE);
+    private Map<String, String> releaseProps = new HashMap<>();
+
+    private final ByteOrder order;
+
+    private boolean isReadOnly;
+    private final StringTable table;
+
+    public ModulePoolImpl() {
+        this(ByteOrder.nativeOrder());
+    }
+
+    public ModulePoolImpl(ByteOrder order) {
+        this(order, new StringTable() {
+
+            @Override
+            public int addString(String str) {
+                return -1;
+            }
+
+            @Override
+            public String getString(int id) {
+                return null;
+            }
+        });
+    }
+
+    public ModulePoolImpl(ByteOrder order, StringTable table) {
+        this.order = order;
+        this.table = table;
+    }
+
+    /**
+     * Add a ModuleEntry.
+     *
+     * @param data The ModuleEntry to add.
+     */
+    @Override
+    public void add(ModuleEntry data) {
+        if (isReadOnly()) {
+            throw new PluginException("LinkConfiguration is readonly");
+        }
+        Objects.requireNonNull(data);
+        if (resources.get(data.getPath()) != null) {
+            throw new PluginException("Resource " + data.getPath()
+                    + " already present");
+        }
+        String modulename = data.getModule();
+        ModuleImpl m = modules.get(modulename);
+        // ## TODO: FileCopierPlugin should not add content to a module
+        // FAKE_MODULE is not really a module to be added in the image
+        if (FileCopierPlugin.FAKE_MODULE.equals(modulename)) {
+            m = fileCopierModule;
+        }
+        if (m == null) {
+            m = new ModuleImpl(modulename);
+            modules.put(modulename, m);
+        }
+        resources.put(data.getPath(), data);
+        m.moduleContent.put(data.getPath(), data);
+    }
+
+    /**
+     * Retrieves the module for the provided name.
+     *
+     * @param name The module name
+     * @return the module of matching name, if found
+     */
+    @Override
+    public Optional<LinkModule> findModule(String name) {
+        Objects.requireNonNull(name);
+        return Optional.ofNullable(modules.get(name));
+    }
+
+    /**
+     * The stream of modules contained in this LinkConfiguration.
+     *
+     * @return The stream of modules.
+     */
+    @Override
+    public Stream<? extends LinkModule> modules() {
+        return modules.values().stream();
+    }
+
+    /**
+     * Return the number of LinkModule count in this LinkConfiguration.
+     *
+     * @return the module count.
+     */
+    @Override
+    public int getModuleCount() {
+        return modules.size();
+    }
+
+    /**
+     * Get all ModuleEntry contained in this LinkConfiguration instance.
+     *
+     * @return The stream of LinkModuleEntries.
+     */
+    @Override
+    public Stream<? extends ModuleEntry> entries() {
+        return resources.values().stream();
+    }
+
+    /**
+     * Return the number of ModuleEntry count in this LinkConfiguration.
+     *
+     * @return the entry count.
+     */
+    @Override
+    public int getEntryCount() {
+        return resources.values().size();
+    }
+
+    /**
+     * Get the ModuleEntry for the passed path.
+     *
+     * @param path A data path
+     * @return A ModuleEntry instance or null if the data is not found
+     */
+    @Override
+    public Optional<ModuleEntry> findEntry(String path) {
+        Objects.requireNonNull(path);
+        return Optional.ofNullable(resources.get(path));
+    }
+
+    /**
+     * Check if the LinkConfiguration contains the given ModuleEntry.
+     *
+     * @param data The module data to check existence for.
+     * @return The module data or null if not found.
+     */
+    @Override
+    public boolean contains(ModuleEntry data) {
+        Objects.requireNonNull(data);
+        return findEntry(data.getPath()).isPresent();
+    }
+
+    /**
+     * Check if the LinkConfiguration contains some content at all.
+     *
+     * @return True, no content, false otherwise.
+     */
+    @Override
+    public boolean isEmpty() {
+        return resources.isEmpty();
+    }
+
+    /**
+     * Visit each ModuleEntry in this LinkConfiguration to transform it and
+     * copy the transformed ModuleEntry to the output LinkConfiguration.
+     *
+     * @param transform The function called for each ModuleEntry found in
+     * the LinkConfiguration. The transform function should return a
+     * ModuleEntry instance which will be added to the output or it should
+     * return null if the passed ModuleEntry is to be ignored for the
+     * output.
+     *
+     * @param output The LinkConfiguration to be filled with Visitor returned
+     * ModuleEntry.
+     */
+    @Override
+    public void transformAndCopy(Function<ModuleEntry, ModuleEntry> transform,
+            ModulePool output) {
+        entries().forEach(resource -> {
+            ModuleEntry res = transform.apply(resource);
+            if (res != null) {
+                output.add(res);
+            }
+        });
+    }
+
+    /**
+     * The ByteOrder currently in use when generating the jimage file.
+     *
+     * @return The ByteOrder.
+     */
+    @Override
+    public ByteOrder getByteOrder() {
+        return order;
+    }
+
+    @Override
+    public Map<String, String> getReleaseProperties() {
+        return isReadOnly()? Collections.unmodifiableMap(releaseProps) : releaseProps;
+    }
+
+    public StringTable getStringTable() {
+        return table;
+    }
+
+    /**
+     * Make this Resources instance read-only. No resource can be added.
+     */
+    public void setReadOnly() {
+        isReadOnly = true;
+    }
+
+    /**
+     * Read only state.
+     *
+     * @return true if readonly false otherwise.
+     */
+    @Override
+    public boolean isReadOnly() {
+        return isReadOnly;
+    }
+
+    /**
+     * A resource that has been compressed.
+     */
+    public static final class CompressedModuleData extends ModuleEntryImpl {
+
+        final long uncompressed_size;
+
+        private CompressedModuleData(String module, String path,
+                InputStream stream, long size,
+                long uncompressed_size) {
+            super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, stream, size);
+            this.uncompressed_size = uncompressed_size;
+        }
+
+        public long getUncompressedSize() {
+            return uncompressed_size;
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!(other instanceof CompressedModuleData)) {
+                return false;
+            }
+            CompressedModuleData f = (CompressedModuleData) other;
+            return f.getPath().equals(getPath());
+        }
+
+        @Override
+        public int hashCode() {
+            return super.hashCode();
+        }
+    }
+
+    public static CompressedModuleData newCompressedResource(ModuleEntry original,
+            ByteBuffer compressed,
+            String plugin, String pluginConfig, StringTable strings,
+            ByteOrder order) {
+        Objects.requireNonNull(original);
+        Objects.requireNonNull(compressed);
+        Objects.requireNonNull(plugin);
+
+        boolean isTerminal = !(original instanceof CompressedModuleData);
+        long uncompressed_size = original.getLength();
+        if (original instanceof CompressedModuleData) {
+            CompressedModuleData comp = (CompressedModuleData) original;
+            uncompressed_size = comp.getUncompressedSize();
+        }
+        int nameOffset = strings.addString(plugin);
+        int configOffset = -1;
+        if (pluginConfig != null) {
+            configOffset = strings.addString(plugin);
+        }
+        CompressedResourceHeader rh
+                = new CompressedResourceHeader(compressed.limit(), original.getLength(),
+                        nameOffset, configOffset, isTerminal);
+        // Merge header with content;
+        byte[] h = rh.getBytes(order);
+        ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length);
+        bb.order(order);
+        bb.put(h);
+        bb.put(compressed);
+        byte[] contentWithHeader = bb.array();
+
+        CompressedModuleData compressedResource
+                = new CompressedModuleData(original.getModule(), original.getPath(),
+                        new ByteArrayInputStream(contentWithHeader),
+                        contentWithHeader.length, uncompressed_size);
+        return compressedResource;
+    }
+
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java
deleted file mode 100644
index 2b1dd82..0000000
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Objects;
-import jdk.internal.jimage.decompressor.CompressedResourceHeader;
-import jdk.tools.jlink.plugin.Pool;
-
-/**
- * Pool of module data.
- */
-public class PoolImpl extends Pool {
-
-    /**
-     * A resource that has been compressed.
-     */
-    public static final class CompressedModuleData extends ModuleData {
-
-        private final long uncompressed_size;
-
-        private CompressedModuleData(String module, String path,
-                InputStream stream, long size,
-                long uncompressed_size) {
-            super(module, path, ModuleDataType.CLASS_OR_RESOURCE, stream, size);
-            this.uncompressed_size = uncompressed_size;
-        }
-
-        public long getUncompressedSize() {
-            return uncompressed_size;
-        }
-
-        @Override
-        public boolean equals(Object other) {
-            if (!(other instanceof CompressedModuleData)) {
-                return false;
-            }
-            CompressedModuleData f = (CompressedModuleData) other;
-            return f.getPath().equals(getPath());
-        }
-
-        @Override
-        public int hashCode() {
-            return super.hashCode();
-        }
-    }
-
-    private boolean isReadOnly;
-    private final StringTable table;
-
-    public PoolImpl() {
-        this(ByteOrder.nativeOrder(), new StringTable() {
-
-            @Override
-            public int addString(String str) {
-                return -1;
-            }
-            @Override
-            public String getString(int id) {
-                return null;
-            }
-        });
-    }
-
-    public PoolImpl(ByteOrder order) {
-        this(order, new StringTable() {
-
-            @Override
-            public int addString(String str) {
-                return -1;
-            }
-            @Override
-            public String getString(int id) {
-                return null;
-            }
-        });
-    }
-
-    public PoolImpl(ByteOrder order, StringTable table) {
-        super(order);
-        this.table = table;
-    }
-
-    public StringTable getStringTable() {
-        return table;
-    }
-
-    /**
-     * Make this Resources instance read-only. No resource can be added.
-     */
-    public void setReadOnly() {
-        isReadOnly = true;
-    }
-
-    /**
-     * Read only state.
-     *
-     * @return true if readonly false otherwise.
-     */
-    @Override
-    public boolean isReadOnly() {
-        return isReadOnly;
-    }
-
-    public static CompressedModuleData newCompressedResource(ModuleData original,
-            ByteBuffer compressed,
-            String plugin, String pluginConfig, StringTable strings,
-            ByteOrder order) {
-        Objects.requireNonNull(original);
-        Objects.requireNonNull(compressed);
-        Objects.requireNonNull(plugin);
-
-        boolean isTerminal = !(original instanceof CompressedModuleData);
-        long uncompressed_size = original.getLength();
-        if (original instanceof CompressedModuleData) {
-            CompressedModuleData comp = (CompressedModuleData) original;
-            uncompressed_size = comp.getUncompressedSize();
-        }
-        int nameOffset = strings.addString(plugin);
-        int configOffset = -1;
-        if (pluginConfig != null) {
-            configOffset = strings.addString(plugin);
-        }
-        CompressedResourceHeader rh
-                = new CompressedResourceHeader(compressed.limit(), original.getLength(),
-                        nameOffset, configOffset, isTerminal);
-        // Merge header with content;
-        byte[] h = rh.getBytes(order);
-        ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length);
-        bb.order(order);
-        bb.put(h);
-        bb.put(compressed);
-        byte[] contentWithHeader = bb.array();
-
-        CompressedModuleData compressedResource
-                = new CompressedModuleData(original.getModule(), original.getPath(),
-                        new ByteArrayInputStream(contentWithHeader),
-                        contentWithHeader.length, uncompressed_size);
-        return compressedResource;
-    }
-
-}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java
index d9c5bab..c8b8bc7 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java
@@ -24,7 +24,7 @@
  */
 package jdk.tools.jlink.internal;
 
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * Plugin wishing to pre-visit the resources must implement this interface.
@@ -44,5 +44,5 @@
      * usage.
      * @throws PluginException
      */
-    public void previsit(Pool resources, StringTable strings);
+    public void previsit(ModulePool resources, StringTable strings);
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
index 31064ab..e8e69ee 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
@@ -52,7 +52,7 @@
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
+import jdk.tools.jlink.plugin.Plugin.Category;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.plugin.PluginException;
@@ -346,7 +346,6 @@
                 }
             }
 
-            PluginContextImpl pluginContext = new PluginContextImpl();
             List<Plugin> pluginsList = new ArrayList<>();
             for (Entry<Plugin, List<Map<String, String>>> entry : pluginToMaps.entrySet()) {
                 Plugin plugin = entry.getKey();
@@ -356,7 +355,7 @@
                 // we call configure once for each occurrence. It is upto the plugin
                 // to 'merge' and/or 'override' arguments.
                 for (Map<String, String> map : argsMaps) {
-                    plugin.configure(Collections.unmodifiableMap(map), pluginContext);
+                    plugin.configure(Collections.unmodifiableMap(map));
                 }
 
                 if (!Utils.isDisabled(plugin)) {
@@ -371,7 +370,7 @@
 
             }
             return new Jlink.PluginsConfiguration(pluginsList,
-                    builder, lastSorter, pluginContext);
+                    builder, lastSorter);
         }
     }
 
@@ -594,7 +593,7 @@
                          + ": " + plugin.getClass().getName());
                     log.println(bundleHelper.getMessage("main.plugin.module")
                          + ": " + plugin.getClass().getModule().getName());
-                    CATEGORY category = Utils.getCategory(plugin);
+                    Category category = Utils.getCategory(plugin);
                     log.println(bundleHelper.getMessage("main.plugin.category")
                          + ": " + category.getName());
                     log.println(bundleHelper.getMessage("main.plugin.state")
@@ -706,7 +705,7 @@
         Configuration bootConfiguration = Layer.boot().configuration();
         try {
             Configuration cf = bootConfiguration
-                .resolveRequiresAndUses(ModuleFinder.empty(),
+                .resolveRequiresAndUses(ModuleFinder.of(),
                                         finder,
                                         Collections.emptySet());
             ClassLoader scl = ClassLoader.getSystemClassLoader();
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
index a8a9a45..0e29969 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
@@ -30,7 +30,6 @@
 import java.util.List;
 import java.util.function.Function;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.PluginType;
 
 public class Utils {
 
@@ -50,25 +49,26 @@
         return arguments;
     };
 
-    public static boolean isPostProcessor(Plugin.CATEGORY category) {
-        return category.equals(Plugin.CATEGORY.VERIFIER)
-                || category.equals(Plugin.CATEGORY.PROCESSOR)
-                || category.equals(Plugin.CATEGORY.PACKAGER);
+    public static boolean isPostProcessor(Plugin.Category category) {
+        return category.equals(Plugin.Category.VERIFIER)
+                || category.equals(Plugin.Category.PROCESSOR)
+                || category.equals(Plugin.Category.PACKAGER);
     }
 
-    public static boolean isPreProcessor(Plugin.CATEGORY category) {
-        return category.equals(Plugin.CATEGORY.COMPRESSOR)
-                || category.equals(Plugin.CATEGORY.FILTER)
-                || category.equals(Plugin.CATEGORY.MODULEINFO_TRANSFORMER)
-                || category.equals(Plugin.CATEGORY.SORTER)
-                || category.equals(Plugin.CATEGORY.TRANSFORMER);
+    public static boolean isPreProcessor(Plugin.Category category) {
+        return category.equals(Plugin.Category.COMPRESSOR)
+                || category.equals(Plugin.Category.FILTER)
+                || category.equals(Plugin.Category.MODULEINFO_TRANSFORMER)
+                || category.equals(Plugin.Category.SORTER)
+                || category.equals(Plugin.Category.TRANSFORMER)
+                || category.equals(Plugin.Category.METAINFO_ADDER);
     }
 
     public static boolean isPostProcessor(Plugin prov) {
         if (prov.getType() != null) {
-            for (PluginType pt : prov.getType()) {
-                if (pt instanceof Plugin.CATEGORY) {
-                    return isPostProcessor((Plugin.CATEGORY) pt);
+            for (Plugin.Category pt : prov.getType()) {
+                if (pt instanceof Plugin.Category) {
+                    return isPostProcessor(pt);
                 }
             }
         }
@@ -77,20 +77,20 @@
 
     public static boolean isPreProcessor(Plugin prov) {
         if (prov.getType() != null) {
-            for (PluginType pt : prov.getType()) {
-                if (pt instanceof Plugin.CATEGORY) {
-                    return isPreProcessor((Plugin.CATEGORY) pt);
+            for (Plugin.Category pt : prov.getType()) {
+                if (pt instanceof Plugin.Category) {
+                    return isPreProcessor(pt);
                 }
             }
         }
         return false;
     }
 
-    public static Plugin.CATEGORY getCategory(Plugin provider) {
+    public static Plugin.Category getCategory(Plugin provider) {
         if (provider.getType() != null) {
-            for (Plugin.PluginType t : provider.getType()) {
-                if (t instanceof Plugin.CATEGORY) {
-                    return (Plugin.CATEGORY) t;
+            for (Plugin.Category t : provider.getType()) {
+                if (t instanceof Plugin.Category) {
+                    return t;
                 }
             }
         }
@@ -140,15 +140,15 @@
     }
 
     public static boolean isFunctional(Plugin prov) {
-        return prov.getState().contains(Plugin.STATE.FUNCTIONAL);
+        return prov.getState().contains(Plugin.State.FUNCTIONAL);
     }
 
     public static boolean isAutoEnabled(Plugin prov) {
-        return prov.getState().contains(Plugin.STATE.AUTO_ENABLED);
+        return prov.getState().contains(Plugin.State.AUTO_ENABLED);
     }
 
     public static boolean isDisabled(Plugin prov) {
-        return prov.getState().contains(Plugin.STATE.DISABLED);
+        return prov.getState().contains(Plugin.State.DISABLED);
     }
 
     // is this a builtin (jdk.jlink) plugin?
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java
index e448acd..874b338 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java
@@ -30,7 +30,7 @@
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.builder.*;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java
index aa068f1..43eb6f2 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java
@@ -26,16 +26,13 @@
 
 import java.io.IOException;
 import java.io.UncheckedIOException;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.ImagePluginStack;
 import jdk.tools.jlink.internal.ResourcePrevisitor;
@@ -62,10 +59,10 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         if (ss != null && zip != null) {
-            Pool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(),
-                    ((PoolImpl) in).getStringTable());
+            ModulePool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(),
+                    ((ModulePoolImpl) in).getStringTable());
             ss.visit(in, output);
             zip.visit(output, out);
         } else if (ss != null) {
@@ -76,16 +73,16 @@
     }
 
     @Override
-    public void previsit(Pool resources, StringTable strings) {
+    public void previsit(ModulePool resources, StringTable strings) {
         if (ss != null) {
             ss.previsit(resources, strings);
         }
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.COMPRESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.COMPRESSOR);
         return Collections.unmodifiableSet(set);
     }
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java
index 0271670..628d8f6 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java
@@ -32,8 +32,8 @@
 import java.util.Set;
 import java.util.function.Predicate;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.internal.Utils;
 
 /**
@@ -51,9 +51,9 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((file) -> {
-            if (!file.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((file) -> {
+            if (!file.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 file = predicate.test(file.getPath()) ? file : null;
             }
             return file;
@@ -61,9 +61,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java
index 6d4737a..626087b 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java
@@ -32,7 +32,8 @@
 import java.util.function.Predicate;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.Utils;
 
 /**
@@ -50,9 +51,9 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((resource) -> {
-            if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((resource) -> {
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 resource = predicate.test(resource.getPath()) ? resource : null;
             }
             return resource;
@@ -75,9 +76,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java
index 4d50290..753d63e 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java
@@ -40,9 +40,10 @@
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
 
 /**
@@ -102,24 +103,24 @@
      * e.g.: /java.base/native/amd64/server/libjvm.so
      * /java.base/native/server/libjvm.dylib
      */
-    private List<Pool.ModuleData> getVMs(Pool in) {
+    private List<ModuleEntry> getVMs(ModulePool in) {
         String jvmlib = jvmlib();
-        List<Pool.ModuleData> ret = in.getModule("java.base").getContent().stream().filter((t) -> {
+        List<ModuleEntry> ret = in.findModule("java.base").get().entries().filter((t) -> {
             return t.getPath().endsWith("/" + jvmlib);
         }).collect(Collectors.toList());
         return ret;
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         String jvmlib = jvmlib();
         TreeSet<Jvm> existing = new TreeSet<>(new JvmComparator());
         TreeSet<Jvm> removed = new TreeSet<>(new JvmComparator());
         if (!keepAll) {
             // First retrieve all available VM names and removed VM
-            List<Pool.ModuleData> jvms = getVMs(in);
+            List<ModuleEntry> jvms = getVMs(in);
             for (Jvm jvm : Jvm.values()) {
-                for (Pool.ModuleData md : jvms) {
+                for (ModuleEntry md : jvms) {
                     if (md.getPath().endsWith("/" + jvm.getName() + "/" + jvmlib)) {
                         existing.add(jvm);
                         if (isRemoved(md)) {
@@ -137,9 +138,9 @@
         }
 
         // Rewrite the jvm.cfg file.
-        in.visit((file) -> {
+        in.transformAndCopy((file) -> {
             if (!keepAll) {
-                if (file.getType().equals(ModuleDataType.NATIVE_LIB)) {
+                if (file.getType().equals(ModuleEntry.Type.NATIVE_LIB)) {
                     if (file.getPath().endsWith(JVM_CFG)) {
                         try {
                             file = handleJvmCfgFile(file, existing, removed);
@@ -155,14 +156,14 @@
 
     }
 
-    private boolean isRemoved(Pool.ModuleData file) {
+    private boolean isRemoved(ModuleEntry file) {
         return !predicate.test(file.getPath());
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -217,7 +218,7 @@
         }
     }
 
-    private Pool.ModuleData handleJvmCfgFile(Pool.ModuleData orig,
+    private ModuleEntry handleJvmCfgFile(ModuleEntry orig,
             TreeSet<Jvm> existing,
             TreeSet<Jvm> removed) throws IOException {
         if (keepAll) {
@@ -253,7 +254,7 @@
 
         byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8);
 
-        return Pool.newImageFile(orig.getModule(),
+        return ModuleEntry.create(orig.getModule(),
                 orig.getPath(),
                 orig.getType(),
                 new ByteArrayInputStream(content), content.length);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java
index 7a51d6c..497d97e 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java
@@ -41,10 +41,10 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import jdk.tools.jlink.internal.ModuleEntryImpl;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.Utils;
 
@@ -68,12 +68,12 @@
     /**
      * Symbolic link to another path.
      */
-    public static abstract class SymImageFile extends Pool.ModuleData {
+    public static abstract class SymImageFile extends ModuleEntryImpl {
 
         private final String targetPath;
 
         public SymImageFile(String targetPath, String module, String path,
-                Pool.ModuleDataType type, InputStream stream, long size) {
+                ModuleEntry.Type type, InputStream stream, long size) {
             super(module, path, type, stream, size);
             this.targetPath = targetPath;
         }
@@ -86,7 +86,7 @@
     private static final class SymImageFileImpl extends SymImageFile {
 
         public SymImageFileImpl(String targetPath, Path file, String module,
-                String path, ModuleDataType type) {
+                String path, ModuleEntry.Type type) {
             super(targetPath, module, path, type, newStream(file), length(file));
         }
     }
@@ -110,11 +110,11 @@
     private static final class DirectoryCopy implements FileVisitor<Path> {
 
         private final Path source;
-        private final Pool pool;
+        private final ModulePool pool;
         private final String targetDir;
         private final List<SymImageFile> symlinks = new ArrayList<>();
 
-        DirectoryCopy(Path source, Pool pool, String targetDir) {
+        DirectoryCopy(Path source, ModulePool pool, String targetDir) {
             this.source = source;
             this.pool = pool;
             this.targetDir = targetDir;
@@ -148,7 +148,7 @@
                 }
                 SymImageFileImpl impl = new SymImageFileImpl(symTarget.toString(),
                         file, path, Objects.requireNonNull(file.getFileName()).toString(),
-                        Pool.ModuleDataType.OTHER);
+                        ModuleEntry.Type.OTHER);
                 symlinks.add(impl);
             } else {
                 addFile(pool, file, path);
@@ -172,14 +172,14 @@
         }
     }
 
-    private static void addFile(Pool pool, Path file, String path)
+    private static void addFile(ModulePool pool, Path file, String path)
             throws IOException {
         Objects.requireNonNull(pool);
         Objects.requireNonNull(file);
         Objects.requireNonNull(path);
-        ModuleData impl = Pool.newImageFile(FAKE_MODULE,
+        ModuleEntry impl = ModuleEntry.create(FAKE_MODULE,
                 "/" + FAKE_MODULE + "/other/" + path,
-                Pool.ModuleDataType.OTHER, newStream(file), length(file));
+                ModuleEntry.Type.OTHER, newStream(file), length(file));
         try {
             pool.add(impl);
         } catch (Exception ex) {
@@ -188,9 +188,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -239,8 +239,8 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((file) -> {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((file) -> {
             return file;
         }, out);
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
index d2b2995..2e07579 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
@@ -33,8 +33,9 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -60,8 +61,8 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        return Collections.singleton(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        return Collections.singleton(Category.TRANSFORMER);
     }
 
     @Override
@@ -75,8 +76,8 @@
     }
 
     @Override
-    public Set<STATE> getState() {
-        return EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL);
+    public Set<State> getState() {
+        return EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL);
     }
 
     @Override
@@ -100,8 +101,8 @@
      */
     public static List<String> defaultSpecies() {
         return List.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I",
-                "L7II", "L7IIL", "L8", "L9", "L10", "L11", "L11I", "L11II",
-                "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL",
+                "L7II", "L7IIL", "L8", "L9", "L10", "L10I", "L10II", "L10IIL",
+                "L11", "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL",
                 "LILL", "I", "LLILL");
     }
 
@@ -151,8 +152,8 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        for (Pool.ModuleData data : in.getContent()) {
+    public void visit(ModulePool in, ModulePool out) {
+        in.entries().forEach(data -> {
             if (("/java.base/" + BMH + ".class").equals(data.getPath())) {
                 // Add BoundMethodHandle unchanged
                 out.add(data);
@@ -162,11 +163,11 @@
                     out.add(data);
                 }
             }
-        }
+        });
     }
 
     @SuppressWarnings("unchecked")
-    private void generateConcreteClass(String types, Pool.ModuleData data, Pool out) {
+    private void generateConcreteClass(String types, ModuleEntry data, ModulePool out) {
         try {
             // Generate class
             Map.Entry<String, byte[]> result = (Map.Entry<String, byte[]>)
@@ -175,9 +176,9 @@
             byte[] bytes = result.getValue();
 
             // Add class to pool
-            Pool.ModuleData ndata = new Pool.ModuleData(data.getModule(),
+            ModuleEntry ndata = ModuleEntry.create(data.getModule(),
                     "/java.base/" + className + ".class",
-                    Pool.ModuleDataType.CLASS_OR_RESOURCE,
+                    ModuleEntry.Type.CLASS_OR_RESOURCE,
                     new ByteArrayInputStream(bytes), bytes.length);
             if (!out.contains(ndata)) {
                 out.add(ndata);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
index b8b7aa4..3083c19 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
@@ -34,6 +34,7 @@
 import java.util.Locale;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.function.Predicate;
 import java.util.regex.Pattern;
@@ -44,9 +45,10 @@
 import jdk.tools.jlink.internal.ResourcePrevisitor;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -112,19 +114,19 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((resource) -> {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((resource) -> {
             if (resource.getModule().equals(MODULENAME)) {
                 String path = resource.getPath();
                 resource = predicate.test(path) ? resource: null;
                 if (resource != null &&
-                    resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+                    resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                     byte[] bytes = resource.getBytes();
                     ClassReader cr = new ClassReader(bytes);
                     if (Arrays.stream(cr.getInterfaces())
                         .anyMatch(i -> i.contains(METAINFONAME)) &&
                         stripUnsupportedLocales(bytes, cr)) {
-                        resource = new Pool.ModuleData(MODULENAME, path,
+                        resource = ModuleEntry.create(MODULENAME, path,
                             resource.getType(),
                             new ByteArrayInputStream(bytes), bytes.length);
                     }
@@ -135,9 +137,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -172,12 +174,13 @@
     }
 
     @Override
-    public void previsit(Pool resources, StringTable strings) {
+    public void previsit(ModulePool resources, StringTable strings) {
         final Pattern p = Pattern.compile(".*((Data_)|(Names_))(?<tag>.*)\\.class");
-        Pool.Module module = resources.getModule(MODULENAME);
+        Optional<LinkModule> optMod = resources.findModule(MODULENAME);
 
         // jdk.localedata module validation
-        if (module != null) {
+        if (optMod.isPresent()) {
+            LinkModule module = optMod.get();
             Set<String> packages = module.getAllPackages();
             if (!packages.containsAll(LOCALEDATA_PACKAGES)) {
                 throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".missingpackages") +
@@ -186,7 +189,7 @@
                         .collect(Collectors.joining(",\n\t")));
             }
 
-            available = Stream.concat(module.getContent().stream()
+            available = Stream.concat(module.entries()
                                         .map(md -> p.matcher(md.getPath()))
                                         .filter(m -> m.matches())
                                         .map(m -> m.group("tag").replaceAll("_", "-")),
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java
index 4f8e5ea..9632cdf 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -287,9 +286,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java
index 8fb124d..5060bf5 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java
@@ -36,9 +36,8 @@
 import java.util.Set;
 import java.util.function.ToIntFunction;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.Utils;
 
@@ -62,15 +61,15 @@
     }
 
     static class SortWrapper {
-        private final ModuleData resource;
+        private final ModuleEntry resource;
         private final int ordinal;
 
-        SortWrapper(ModuleData resource, int ordinal) {
+        SortWrapper(ModuleEntry resource, int ordinal) {
             this.resource = resource;
             this.ordinal = ordinal;
         }
 
-        ModuleData getResource() {
+        ModuleEntry getResource() {
             return resource;
         }
 
@@ -95,7 +94,7 @@
         return path;
     }
 
-    private int getOrdinal(ModuleData resource) {
+    private int getOrdinal(ModuleEntry resource) {
         String path = resource.getPath();
 
         Integer value = orderedPaths.get(stripModule(path));
@@ -126,23 +125,23 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.getContent().stream()
+    public void visit(ModulePool in, ModulePool out) {
+        in.entries()
                 .filter(resource -> resource.getType()
-                        .equals(ModuleDataType.CLASS_OR_RESOURCE))
+                        .equals(ModuleEntry.Type.CLASS_OR_RESOURCE))
                 .map((resource) -> new SortWrapper(resource, getOrdinal(resource)))
                 .sorted(OrderResourcesPlugin::compare)
                 .forEach((wrapper) -> out.add(wrapper.getResource()));
-        in.getContent().stream()
+        in.entries()
                 .filter(other -> !other.getType()
-                        .equals(ModuleDataType.CLASS_OR_RESOURCE))
+                        .equals(ModuleEntry.Type.CLASS_OR_RESOURCE))
                 .forEach((other) -> out.add(other));
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.SORTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.SORTER);
 
         return Collections.unmodifiableSet(set);
     }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
index bbc7428..579aace 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
@@ -24,34 +24,33 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.lang.module.ModuleDescriptor;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.EnumSet;
-import java.util.List;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 import java.util.Properties;
-
+import java.util.Set;
+import java.util.function.Function;
 import jdk.tools.jlink.internal.Utils;
-import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.PluginContext;
-import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.PostProcessorPlugin;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.Plugin.State;
+import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
  * This plugin adds/deletes information for 'release' file.
  */
-public final class ReleaseInfoPlugin implements PostProcessorPlugin {
+public final class ReleaseInfoPlugin implements TransformerPlugin {
     // option name
     public static final String NAME = "release-info";
     public static final String KEYS = "keys";
+    private final Map<String, String> release = new HashMap<>();
 
     @Override
-    public Set<PluginType> getType() {
-        return Collections.singleton(CATEGORY.PROCESSOR);
+    public Set<Category> getType() {
+        return Collections.singleton(Category.METAINFO_ADDER);
     }
 
     @Override
@@ -65,8 +64,8 @@
     }
 
     @Override
-    public Set<STATE> getState() {
-        return EnumSet.of(STATE.FUNCTIONAL);
+    public Set<State> getState() {
+        return EnumSet.of(State.FUNCTIONAL);
     }
 
     @Override
@@ -80,49 +79,49 @@
     }
 
     @Override
-    public void configure(Map<String, String> config, PluginContext ctx) {
-        Properties release = ctx != null? ctx.getReleaseProperties() : null;
-        if (release != null) {
-            String operation = config.get(NAME);
-            switch (operation) {
-                case "add": {
-                    // leave it to open-ended! source, java_version, java_full_version
-                    // can be passed via this option like:
-                    //
-                    //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
-                    // and put whatever value that was passed in command line.
+    public void configure(Map<String, String> config) {
+        String operation = config.get(NAME);
+        switch (operation) {
+            case "add": {
+                // leave it to open-ended! source, java_version, java_full_version
+                // can be passed via this option like:
+                //
+                //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
+                // and put whatever value that was passed in command line.
 
-                    config.keySet().stream().
-                        filter(s -> !NAME.equals(s)).
-                        forEach(s -> release.put(s, config.get(s)));
-                }
-                break;
-
-                case "del": {
-                    // --release-info del:keys=openjdk,java_version
-                    String[] keys = Utils.listParser.apply(config.get(KEYS));
-                    for (String k : keys) {
-                        release.remove(k);
-                    }
-                }
-                break;
-
-                default: {
-                    // --release-info <file>
-                    try (FileInputStream fis = new FileInputStream(operation)) {
-                        release.load(fis);
-                    } catch (IOException exp) {
-                        throw new RuntimeException(exp);
-                    }
-                }
-                break;
+                config.keySet().stream().
+                    filter(s -> !NAME.equals(s)).
+                    forEach(s -> release.put(s, config.get(s)));
             }
+            break;
+
+            case "del": {
+                // --release-info del:keys=openjdk,java_version
+                String[] keys = Utils.listParser.apply(config.get(KEYS));
+                for (String k : keys) {
+                    release.remove(k);
+                }
+            }
+            break;
+
+            default: {
+                // --release-info <file>
+                Properties props = new Properties();
+                try (FileInputStream fis = new FileInputStream(operation)) {
+                    props.load(fis);
+                } catch (IOException exp) {
+                    throw new RuntimeException(exp);
+                }
+                props.forEach((k, v) -> release.put(k.toString(), v.toString()));
+            }
+            break;
         }
     }
 
     @Override
-    public List<String> process(ExecutableImage image) {
-        // Nothing to do! Release info copied already during configure!
-        return Collections.emptyList();
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy(Function.identity(), out);
+        out.getReleaseProperties().putAll(in.getReleaseProperties());
+        out.getReleaseProperties().putAll(release);
     }
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java
index a4aa8f9..b3a1e7c 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java
@@ -56,11 +56,11 @@
 import jdk.internal.jimage.decompressor.CompressIndexes;
 import jdk.internal.jimage.decompressor.SignatureParser;
 import jdk.internal.jimage.decompressor.StringSharingDecompressor;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.ResourcePrevisitor;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.Utils;
@@ -228,7 +228,7 @@
             }
         }
 
-        public byte[] transform(ModuleData resource, Pool out,
+        public byte[] transform(ModuleEntry resource, ModulePool out,
                 StringTable strings) throws IOException, Exception {
             byte[] content = resource.getBytes();
             ClassFile cf;
@@ -243,7 +243,7 @@
         }
 
         @SuppressWarnings("fallthrough")
-        private byte[] optimize(ModuleData resource, Pool resources,
+        private byte[] optimize(ModuleEntry resource, ModulePool resources,
                 StringTable strings,
                 Set<Integer> descriptorIndexes, byte[] content) throws Exception {
             DataInputStream stream = new DataInputStream(new ByteArrayInputStream(content));
@@ -348,27 +348,27 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.COMPRESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.COMPRESSOR);
         return Collections.unmodifiableSet(set);
     }
 
     @Override
-    public void visit(Pool in, Pool result) {
+    public void visit(ModulePool in, ModulePool result) {
         CompactCPHelper visit = new CompactCPHelper();
-        in.visit((resource) -> {
-            ModuleData res = resource;
+        in.transformAndCopy((resource) -> {
+            ModuleEntry res = resource;
             if (predicate.test(resource.getPath()) && resource.getPath().endsWith(".class")) {
                 byte[] compressed = null;
                 try {
-                    compressed = visit.transform(resource, result, ((PoolImpl) in).getStringTable());
+                    compressed = visit.transform(resource, result, ((ModulePoolImpl) in).getStringTable());
                 } catch (Exception ex) {
                     throw new PluginException(ex);
                 }
-                res = PoolImpl.newCompressedResource(resource,
+                res = ModulePoolImpl.newCompressedResource(resource,
                         ByteBuffer.wrap(compressed), getName(), null,
-                        ((PoolImpl) in).getStringTable(), in.getByteOrder());
+                        ((ModulePoolImpl) in).getStringTable(), in.getByteOrder());
             }
             return res;
         }, result);
@@ -405,10 +405,10 @@
     }
 
     @Override
-    public void previsit(Pool resources, StringTable strings) {
+    public void previsit(ModulePool resources, StringTable strings) {
         CompactCPHelper preVisit = new CompactCPHelper();
-        for (ModuleData resource : resources.getContent()) {
-            if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)
+        resources.entries().forEach(resource -> {
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)
                     && resource.getPath().endsWith(".class") && predicate.test(resource.getPath())) {
                 try {
                     preVisit.transform(resource, null, strings);
@@ -416,6 +416,6 @@
                     throw new PluginException(ex);
                 }
             }
-        }
+        });
     }
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
index ae92795..4e7a036 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
@@ -29,14 +29,12 @@
 import java.io.UncheckedIOException;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 import java.util.function.Predicate;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -61,9 +59,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -73,11 +71,11 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         //remove *.diz files as well as debug attributes.
-        in.visit((resource) -> {
-            ModuleData res = resource;
-            if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+        in.transformAndCopy((resource) -> {
+            ModuleEntry res = resource;
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 String path = resource.getPath();
                 if (path.endsWith(".class")) {
                     if (path.endsWith("module-info.class")) {
@@ -87,7 +85,7 @@
                         ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
                         reader.accept(writer, ClassReader.SKIP_DEBUG);
                         byte[] content = writer.toByteArray();
-                        res = Pool.newResource(path, new ByteArrayInputStream(content), content.length);
+                        res = ModuleEntry.create(path, new ByteArrayInputStream(content), content.length);
                     }
                 }
             } else if (predicate.test(res.getPath())) {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java
index dc64582..496a4e5 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java
@@ -26,9 +26,9 @@
 
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -45,16 +45,16 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((file) -> {
-            return file.getType() == Pool.ModuleDataType.NATIVE_CMD ? null : file;
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((file) -> {
+            return file.getType() == ModuleEntry.Type.NATIVE_CMD ? null : file;
         }, out);
     }
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java
index f4cba76..b60fecb 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java
@@ -36,6 +36,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -50,9 +51,10 @@
 
 import static jdk.internal.org.objectweb.asm.Opcodes.*;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin.Builder.*;
+import jdk.tools.jlink.plugin.ModuleEntry;
 
 /**
  * Jlink plugin to reconstitute module descriptors for installed modules.
@@ -81,8 +83,8 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        return Collections.singleton(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        return Collections.singleton(Category.TRANSFORMER);
     }
 
     @Override
@@ -96,9 +98,9 @@
     }
 
     @Override
-    public Set<STATE> getState() {
-        return enabled ? EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL)
-                       : EnumSet.of(STATE.DISABLED);
+    public Set<State> getState() {
+        return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL)
+                       : EnumSet.of(State.DISABLED);
     }
 
     @Override
@@ -110,7 +112,7 @@
 
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         if (!enabled) {
             throw new PluginException(NAME + " was set");
         }
@@ -119,13 +121,14 @@
 
         // generate the byte code to create ModuleDescriptors
         // skip parsing module-info.class and skip name check
-        for (Pool.Module module : in.getModules()) {
-            Pool.ModuleData data = module.get("module-info.class");
-            if (data == null) {
+        in.modules().forEach(module -> {
+            Optional<ModuleEntry> optData = module.findEntry("module-info.class");
+            if (! optData.isPresent()) {
                 // automatic module not supported yet
                 throw new PluginException("module-info.class not found for " +
                                           module.getName() + " module");
             }
+            ModuleEntry data = optData.get();
             assert module.getName().equals(data.getModule());
             try {
                 ByteArrayInputStream bain = new ByteArrayInputStream(data.getBytes());
@@ -141,7 +144,7 @@
                     ModuleInfoRewriter minfoWriter =
                         new ModuleInfoRewriter(bain, mbuilder.conceals());
                     // replace with the overridden version
-                    data = new Pool.ModuleData(data.getModule(),
+                    data = ModuleEntry.create(data.getModule(),
                                                data.getPath(),
                                                data.getType(),
                                                minfoWriter.stream(),
@@ -151,19 +154,17 @@
             } catch (IOException e) {
                 throw new PluginException(e);
             }
-
-        }
+        });
 
         // Generate the new class
         ClassWriter cwriter = builder.build();
-        for (Pool.ModuleData data : in.getContent()) {
+        in.entries().forEach(data -> {
             if (data.getPath().endsWith("module-info.class"))
-                continue;
-
+                return;
             if (builder.isOverriddenClass(data.getPath())) {
                 byte[] bytes = cwriter.toByteArray();
-                Pool.ModuleData ndata =
-                    new Pool.ModuleData(data.getModule(),
+                ModuleEntry ndata =
+                    ModuleEntry.create(data.getModule(),
                                         data.getPath(),
                                         data.getType(),
                                         new ByteArrayInputStream(bytes),
@@ -172,7 +173,7 @@
             } else {
                 out.add(data);
             }
-        }
+        });
     }
 
     /*
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java
index df66e30..d3dd7bf 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java
@@ -34,10 +34,9 @@
 import java.util.function.Predicate;
 import java.util.zip.Deflater;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.Utils;
 
@@ -68,9 +67,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.COMPRESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.COMPRESSOR);
         return Collections.unmodifiableSet(set);
     }
 
@@ -124,16 +123,16 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((resource) -> {
-            ModuleData res = resource;
-            if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((resource) -> {
+            ModuleEntry res = resource;
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)
                     && predicate.test(resource.getPath())) {
                 byte[] compressed;
                 compressed = compress(resource.getBytes());
-                res = PoolImpl.newCompressedResource(resource,
+                res = ModulePoolImpl.newCompressedResource(resource,
                         ByteBuffer.wrap(compressed), getName(), null,
-                        ((PoolImpl) in).getStringTable(), in.getByteOrder());
+                        ((ModulePoolImpl) in).getStringTable(), in.getByteOrder());
             }
             return res;
         }, out);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java
index 9902959..5271217 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java
@@ -26,9 +26,9 @@
 
 import java.util.Objects;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 /**
  * Extend this class to develop your own plugin in order to transform jimage
@@ -41,17 +41,17 @@
     }
 
     @Override
-    public void visit(Pool allContent, Pool outResources) {
+    public void visit(ModulePool allContent, ModulePool outResources) {
         Objects.requireNonNull(allContent);
         Objects.requireNonNull(outResources);
-        PoolImpl resources = new PoolImpl(allContent.getByteOrder());
-        for(ModuleData md : allContent.getContent()) {
-            if(md.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
+        ModulePoolImpl resources = new ModulePoolImpl(allContent.getByteOrder());
+        allContent.entries().forEach(md -> {
+            if(md.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 resources.add(md);
             } else {
                 outResources.add(md);
             }
-        }
+        });
         AsmPools pools = new AsmPools(resources);
         visit(pools);
         pools.fillOutputResources(outResources);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java
index 9184bb8..aa5c1cb 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java
@@ -24,13 +24,12 @@
  */
 package jdk.tools.jlink.internal.plugins.asm;
 
-import java.io.InputStream;
-import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * A pool of ClassReader and other resource files.
@@ -138,14 +137,14 @@
          * @return The ClassReader or null if the class is not found.
          * @throws jdk.tools.jlink.plugin.PluginException
          */
-        public ClassReader getClassReader(Pool.ModuleData res);
+        public ClassReader getClassReader(ModuleEntry res);
 
         /**
          * Returns all the classes contained in the writable pool.
          *
          * @return The collection of classes.
          */
-        public Collection<Pool.ModuleData> getClasses();
+        public Collection<ModuleEntry> getClasses();
     }
 
     /**
@@ -185,14 +184,14 @@
          * @param res The java resource
          * @return The Resource or null if the resource is not found.
          */
-        public ResourceFile getResourceFile(Pool.ModuleData res);
+        public ResourceFile getResourceFile(ModuleEntry res);
 
         /**
          * Returns all the resources contained in the writable pool.
          *
          * @return The array of resources.
          */
-        public Collection<Pool.ModuleData> getResourceFiles();
+        public Collection<ModuleEntry> getResourceFiles();
     }
 
     /**
@@ -206,7 +205,7 @@
          * @return The resource paths ordered in the way to use for storage in the jimage.
          * @throws jdk.tools.jlink.plugin.PluginException
          */
-        public List<String> sort(Pool resources);
+        public List<String> sort(ModulePool resources);
     }
 
     /**
@@ -237,7 +236,7 @@
      *
      * @return The classes.
      */
-    public Collection<Pool.ModuleData> getClasses();
+    public Collection<ModuleEntry> getClasses();
 
     /**
      * Returns the resources contained in the pool. Resources are all the file
@@ -245,7 +244,7 @@
      *
      * @return The array of resource files.
      */
-    public Collection<Pool.ModuleData> getResourceFiles();
+    public Collection<ModuleEntry> getResourceFiles();
 
     /**
      * Retrieves a resource based on the binary name. This name doesn't contain
@@ -266,7 +265,7 @@
      * @param res The resource
      * @return The resource file or null if it doesn't exist.
      */
-    public ResourceFile getResourceFile(Pool.ModuleData res);
+    public ResourceFile getResourceFile(ModuleEntry res);
 
     /**
      * Retrieve a ClassReader from the pool.
@@ -284,7 +283,7 @@
      * @return A reader or null if the class is unknown
      * @throws jdk.tools.jlink.plugin.PluginException
      */
-    public ClassReader getClassReader(Pool.ModuleData res);
+    public ClassReader getClassReader(ModuleEntry res);
 
     /**
      * To visit the set of ClassReaders.
@@ -310,6 +309,6 @@
      * @param output The pool used to fill the jimage.
      * @throws jdk.tools.jlink.plugin.PluginException
      */
-    public void fillOutputResources(Pool output);
+    public void fillOutputResources(ModulePool output);
 
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java
index cb838d1..20c17c8 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java
@@ -41,15 +41,14 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Objects;
-import java.util.Optional;
 import java.util.Set;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.tools.jlink.internal.ImageFileCreator;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * A pool of ClassReader and other resource files. This class allows to
@@ -94,7 +93,7 @@
             }
 
             byte[] content = writer.toByteArray();
-            ModuleData res = Pool.newResource(path,
+            ModuleEntry res = ModuleEntry.create(path,
                     new ByteArrayInputStream(content), content.length);
             transformedClasses.put(className, res);
         }
@@ -108,7 +107,7 @@
         public void forgetClass(String className) {
             Objects.requireNonNull(className);
             // do we have a resource?
-            ModuleData res = transformedClasses.get(className);
+            ModuleEntry res = transformedClasses.get(className);
             if (res == null) {
                 res = inputClasses.get(className);
                 if (res == null) {
@@ -130,7 +129,7 @@
         @Override
         public ClassReader getClassReader(String binaryName) {
             Objects.requireNonNull(binaryName);
-            ModuleData res = transformedClasses.get(binaryName);
+            ModuleEntry res = transformedClasses.get(binaryName);
             ClassReader reader = null;
             if (res != null) {
                 reader = getClassReader(res);
@@ -144,16 +143,16 @@
          * @return The array of transformed classes.
          */
         @Override
-        public Collection<ModuleData> getClasses() {
-            List<ModuleData> classes = new ArrayList<>();
-            for (Entry<String, ModuleData> entry : transformedClasses.entrySet()) {
+        public Collection<ModuleEntry> getClasses() {
+            List<ModuleEntry> classes = new ArrayList<>();
+            for (Entry<String, ModuleEntry> entry : transformedClasses.entrySet()) {
                 classes.add(entry.getValue());
             }
             return classes;
         }
 
         @Override
-        public ClassReader getClassReader(ModuleData res) {
+        public ClassReader getClassReader(ModuleEntry res) {
             return newClassReader(res.getBytes());
         }
     }
@@ -176,7 +175,7 @@
         public void addResourceFile(ResourceFile resFile) {
             Objects.requireNonNull(resFile);
             String path = toResourceNamePath(resFile.getPath());
-            ModuleData res = Pool.newResource(path, resFile.getContent());
+            ModuleEntry res = ModuleEntry.create(path, resFile.getContent());
             transformedResources.put(resFile.getPath(), res);
         }
 
@@ -191,7 +190,7 @@
             Objects.requireNonNull(resourceName);
             String path = toResourceNamePath(resourceName);
             // do we have a resource?
-            ModuleData res = transformedResources.get(resourceName);
+            ModuleEntry res = transformedResources.get(resourceName);
             if (res == null) {
                 res = inputResources.get(resourceName);
                 if (res == null) {
@@ -212,7 +211,7 @@
         @Override
         public ResourceFile getResourceFile(String name) {
             Objects.requireNonNull(name);
-            ModuleData res = transformedResources.get(name);
+            ModuleEntry res = transformedResources.get(name);
             ResourceFile resFile = null;
             if (res != null) {
                 resFile = getResourceFile(res);
@@ -226,24 +225,24 @@
          * @return The array of transformed classes.
          */
         @Override
-        public Collection<ModuleData> getResourceFiles() {
-            List<ModuleData> resources = new ArrayList<>();
-            for (Entry<String, ModuleData> entry : transformedResources.entrySet()) {
+        public Collection<ModuleEntry> getResourceFiles() {
+            List<ModuleEntry> resources = new ArrayList<>();
+            for (Entry<String, ModuleEntry> entry : transformedResources.entrySet()) {
                 resources.add(entry.getValue());
             }
             return resources;
         }
 
         @Override
-        public ResourceFile getResourceFile(ModuleData res) {
+        public ResourceFile getResourceFile(ModuleEntry res) {
             return new ResourceFile(toJavaBinaryResourceName(res.getPath()),
                     res.getBytes());
         }
     }
 
-    private final Pool jimageResources;
-    private final Map<String, ModuleData> inputClasses;
-    private final Map<String, ModuleData> inputResources;
+    private final ModulePool jimageResources;
+    private final Map<String, ModuleEntry> inputClasses;
+    private final Map<String, ModuleEntry> inputResources;
     private final Map<String, String> inputClassPackageMapping;
     private final Map<String, String> inputOtherPackageMapping;
 
@@ -254,9 +253,9 @@
 
     private Sorter sorter;
 
-    private final Map<String, ModuleData> transformedClasses
+    private final Map<String, ModuleEntry> transformedClasses
             =            new LinkedHashMap<>();
-    private final Map<String, ModuleData> transformedResources
+    private final Map<String, ModuleEntry> transformedResources
             =            new LinkedHashMap<>();
     private final List<String> forgetResources = new ArrayList<>();
     private final Map<String, String> newPackageMapping = new HashMap<>();
@@ -274,7 +273,7 @@
      * @param pools The resource pools.
      * @param descriptor The module descriptor.
      */
-    AsmPoolImpl(Pool inputResources, String moduleName,
+    AsmPoolImpl(ModulePool inputResources, String moduleName,
             AsmPools pools,
             ModuleDescriptor descriptor) {
         Objects.requireNonNull(inputResources);
@@ -285,11 +284,11 @@
         this.moduleName = moduleName;
         this.pools = pools;
         this.descriptor = descriptor;
-        Map<String, ModuleData> classes = new LinkedHashMap<>();
-        Map<String, ModuleData> resources = new LinkedHashMap<>();
+        Map<String, ModuleEntry> classes = new LinkedHashMap<>();
+        Map<String, ModuleEntry> resources = new LinkedHashMap<>();
         Map<String, String> packageClassToModule = new HashMap<>();
         Map<String, String> packageOtherToModule = new HashMap<>();
-        for (ModuleData res : inputResources.getContent()) {
+        inputResources.entries().forEach(res -> {
             if (res.getPath().endsWith(".class")) {
                 classes.put(toJavaBinaryClassName(res.getPath()), res);
             } else {
@@ -305,7 +304,7 @@
                     packageOtherToModule.put(split[1], res.getModule());
                 }
             }
-        }
+        });
         this.inputClasses = Collections.unmodifiableMap(classes);
         this.inputResources = Collections.unmodifiableMap(resources);
 
@@ -356,7 +355,7 @@
      * @return The array of classes.
      */
     @Override
-    public Collection<ModuleData> getClasses() {
+    public Collection<ModuleEntry> getClasses() {
         return inputClasses.values();
     }
 
@@ -367,7 +366,7 @@
      * @return The array of classes.
      */
     @Override
-    public Collection<ModuleData> getResourceFiles() {
+    public Collection<ModuleEntry> getResourceFiles() {
         return inputResources.values();
     }
 
@@ -385,7 +384,7 @@
     @Override
     public ResourceFile getResourceFile(String binaryName) {
         Objects.requireNonNull(binaryName);
-        ModuleData res = inputResources.get(binaryName);
+        ModuleEntry res = inputResources.get(binaryName);
         ResourceFile resFile = null;
         if (res != null) {
             resFile = getResourceFile(res);
@@ -402,7 +401,7 @@
     @Override
     public ClassReader getClassReader(String binaryName) {
         Objects.requireNonNull(binaryName);
-        ModuleData res = inputClasses.get(binaryName);
+        ModuleEntry res = inputClasses.get(binaryName);
         ClassReader reader = null;
         if (res != null) {
             reader = getClassReader(res);
@@ -411,13 +410,13 @@
     }
 
     @Override
-    public ResourceFile getResourceFile(ModuleData res) {
+    public ResourceFile getResourceFile(ModuleEntry res) {
         return new ResourceFile(toJavaBinaryResourceName(res.getPath()),
                 res.getBytes());
     }
 
     @Override
-    public ClassReader getClassReader(ModuleData res) {
+    public ClassReader getClassReader(ModuleEntry res) {
         return newClassReader(res.getBytes());
     }
 
@@ -505,7 +504,7 @@
     @Override
     public void visitClassReaders(ClassReaderVisitor visitor) {
         Objects.requireNonNull(visitor);
-        for (ModuleData res : getClasses()) {
+        for (ModuleEntry res : getClasses()) {
             ClassReader reader = newClassReader(res.getBytes());
             ClassWriter writer = visitor.visit(reader);
             if (writer != null) {
@@ -523,7 +522,7 @@
     @Override
     public void visitResourceFiles(ResourceFileVisitor visitor) {
         Objects.requireNonNull(visitor);
-        for (ModuleData resource : getResourceFiles()) {
+        for (ModuleEntry resource : getResourceFiles()) {
             ResourceFile resFile
                     = new ResourceFile(toJavaBinaryResourceName(resource.getPath()),
                             resource.getBytes());
@@ -540,18 +539,18 @@
      * been set, it is used to sort the returned resources.     *
      */
     @Override
-    public void fillOutputResources(Pool outputResources) {
+    public void fillOutputResources(ModulePool outputResources) {
         List<String> added = new ArrayList<>();
         // If the sorter is null, use the input order.
         // New resources are added at the end
         // First input classes that have not been removed
-        Pool output = new PoolImpl(outputResources.getByteOrder(),
-                ((PoolImpl)outputResources).getStringTable());
-        for (ModuleData inResource : jimageResources.getContent()) {
+        ModulePool output = new ModulePoolImpl(outputResources.getByteOrder(),
+                ((ModulePoolImpl)outputResources).getStringTable());
+        jimageResources.entries().forEach(inResource -> {
             if (!forgetResources.contains(inResource.getPath())) {
-                ModuleData resource = inResource;
+                ModuleEntry resource = inResource;
                 // Do we have a transformed class with the same name?
-                ModuleData res = transformedResources.
+                ModuleEntry res = transformedResources.
                         get(toJavaBinaryResourceName(inResource.getPath()));
                 if (res != null) {
                     resource = res;
@@ -565,10 +564,10 @@
                 output.add(resource);
                 added.add(resource.getPath());
             }
-        }
+        });
         // Then new resources
-        for (Map.Entry<String, ModuleData> entry : transformedResources.entrySet()) {
-            ModuleData resource = entry.getValue();
+        for (Map.Entry<String, ModuleEntry> entry : transformedResources.entrySet()) {
+            ModuleEntry resource = entry.getValue();
             if (!forgetResources.contains(resource.getPath())) {
                 if (!added.contains(resource.getPath())) {
                     output.add(resource);
@@ -576,8 +575,8 @@
             }
         }
         // And new classes
-        for (Map.Entry<String, ModuleData> entry : transformedClasses.entrySet()) {
-            ModuleData resource = entry.getValue();
+        for (Map.Entry<String, ModuleEntry> entry : transformedClasses.entrySet()) {
+            ModuleEntry resource = entry.getValue();
             if (!forgetResources.contains(resource.getPath())) {
                 if (!added.contains(resource.getPath())) {
                     output.add(resource);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java
index bbb2d54..53742ee 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java
@@ -41,11 +41,11 @@
 import java.util.Set;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.Sorter;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * A container for pools of ClassReader and other resource files. A pool of all
@@ -97,10 +97,10 @@
             }
 
             @Override
-            public Collection<Pool.ModuleData> getClasses() {
-                List<Pool.ModuleData> all = new ArrayList<>();
+            public Collection<ModuleEntry> getClasses() {
+                List<ModuleEntry> all = new ArrayList<>();
                 visitAllPools((AsmModulePool pool) -> {
-                    for (Pool.ModuleData rf : pool.getTransformedClasses().getClasses()) {
+                    for (ModuleEntry rf : pool.getTransformedClasses().getClasses()) {
                         all.add(rf);
                     }
                 });
@@ -108,7 +108,7 @@
             }
 
             @Override
-            public ClassReader getClassReader(Pool.ModuleData res) {
+            public ClassReader getClassReader(ModuleEntry res) {
                 return visitPools((AsmModulePool pool) -> {
                     return pool.getTransformedClasses().getClassReader(res);
                 });
@@ -140,10 +140,10 @@
             }
 
             @Override
-            public Collection<Pool.ModuleData> getResourceFiles() {
-                List<Pool.ModuleData> all = new ArrayList<>();
+            public Collection<ModuleEntry> getResourceFiles() {
+                List<ModuleEntry> all = new ArrayList<>();
                 visitAllPools((AsmModulePool pool) -> {
-                    for (Pool.ModuleData rf : pool.getTransformedResourceFiles().getResourceFiles()) {
+                    for (ModuleEntry rf : pool.getTransformedResourceFiles().getResourceFiles()) {
                         all.add(rf);
                     }
                 });
@@ -151,7 +151,7 @@
             }
 
             @Override
-            public ResourceFile getResourceFile(Pool.ModuleData res) {
+            public ResourceFile getResourceFile(ModuleEntry res) {
                 return visitPools((AsmModulePool pool) -> {
                     return pool.getTransformedResourceFiles().getResourceFile(res);
                 });
@@ -175,10 +175,10 @@
         }
 
         @Override
-        public Collection<Pool.ModuleData> getClasses() {
-            List<Pool.ModuleData> all = new ArrayList<>();
+        public Collection<ModuleEntry> getClasses() {
+            List<ModuleEntry> all = new ArrayList<>();
             visitAllPools((AsmModulePool pool) -> {
-                for (Pool.ModuleData rf : pool.getClasses()) {
+                for (ModuleEntry rf : pool.getClasses()) {
                     all.add(rf);
                 }
             });
@@ -186,10 +186,10 @@
         }
 
         @Override
-        public Collection<Pool.ModuleData> getResourceFiles() {
-            List<Pool.ModuleData> all = new ArrayList<>();
+        public Collection<ModuleEntry> getResourceFiles() {
+            List<ModuleEntry> all = new ArrayList<>();
             visitAllPools((AsmModulePool pool) -> {
-                for (Pool.ModuleData rf : pool.getResourceFiles()) {
+                for (ModuleEntry rf : pool.getResourceFiles()) {
                     all.add(rf);
                 }
             });
@@ -211,14 +211,14 @@
         }
 
         @Override
-        public ResourceFile getResourceFile(Pool.ModuleData res) {
+        public ResourceFile getResourceFile(ModuleEntry res) {
             return visitPools((AsmModulePool pool) -> {
                 return pool.getResourceFile(res);
             });
         }
 
         @Override
-        public ClassReader getClassReader(Pool.ModuleData res) {
+        public ClassReader getClassReader(ModuleEntry res) {
             return visitPoolsEx((AsmModulePool pool) -> {
                 return pool.getClassReader(res);
             });
@@ -239,7 +239,7 @@
         }
 
         @Override
-        public void fillOutputResources(Pool outputResources) {
+        public void fillOutputResources(ModulePool outputResources) {
             AsmPools.this.fillOutputResources(outputResources);
         }
 
@@ -324,15 +324,15 @@
      *
      * @param inputResources The raw resources to build the pool from.
      */
-    public AsmPools(Pool inputResources) {
+    public AsmPools(ModulePool inputResources) {
         Objects.requireNonNull(inputResources);
-        Map<String, Pool> resPools = new LinkedHashMap<>();
+        Map<String, ModulePool> resPools = new LinkedHashMap<>();
         Map<String, ModuleDescriptor> descriptors = new HashMap<>();
-        for (Pool.ModuleData res : inputResources.getContent()) {
-            Pool p = resPools.get(res.getModule());
+        inputResources.entries().forEach(res -> {
+            ModulePool p = resPools.get(res.getModule());
             if (p == null) {
-                p = new PoolImpl(inputResources.getByteOrder(),
-                        ((PoolImpl)inputResources).getStringTable());
+                p = new ModulePoolImpl(inputResources.getByteOrder(),
+                        ((ModulePoolImpl)inputResources).getStringTable());
                 resPools.put(res.getModule(), p);
             }
             if (res.getPath().endsWith("module-info.class")) {
@@ -341,11 +341,11 @@
                 descriptors.put(res.getModule(), descriptor);
             }
             p.add(res);
-        }
+        });
         poolsArray = new AsmModulePool[resPools.size()];
         int i = 0;
 
-        for (Entry<String, Pool> entry : resPools.entrySet()) {
+        for (Entry<String, ModulePool> entry : resPools.entrySet()) {
             ModuleDescriptor descriptor = descriptors.get(entry.getKey());
             if (descriptor == null) {
                 throw new PluginException("module-info.class not found for " + entry.getKey() + " module");
@@ -405,7 +405,7 @@
      *
      * @param outputResources The pool used to fill the jimage.
      */
-    public void fillOutputResources(Pool outputResources) {
+    public void fillOutputResources(ModulePool outputResources) {
         // First sort modules
         List<String> modules = new ArrayList<>();
         for (String k : pools.keySet()) {
@@ -414,8 +414,8 @@
         if (moduleSorter != null) {
             modules = moduleSorter.sort(modules);
         }
-        Pool output = new PoolImpl(outputResources.getByteOrder(),
-                ((PoolImpl)outputResources).getStringTable());
+        ModulePool output = new ModulePoolImpl(outputResources.getByteOrder(),
+                ((ModulePoolImpl)outputResources).getStringTable());
         for (String mn : modules) {
             AsmPool pool = pools.get(mn);
             pool.fillOutputResources(output);
@@ -423,17 +423,17 @@
         sort(outputResources, output, global.sorter);
     }
 
-    static void sort(Pool outputResources,
-            Pool transientOutput, Sorter sorter) {
+    static void sort(ModulePool outputResources,
+            ModulePool transientOutput, Sorter sorter) {
         if (sorter != null) {
             List<String> order = sorter.sort(transientOutput);
             for (String s : order) {
-                outputResources.add(transientOutput.get(s));
+                outputResources.add(transientOutput.findEntry(s).get());
             }
         } else {
-            for (ModuleData res : transientOutput.getContent()) {
+            transientOutput.entries().forEach(res-> {
                 outputResources.add(res);
-            }
+            });
         }
     }
 
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java
index d5e767c..499d23d 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java
@@ -24,66 +24,41 @@
  */
 package jdk.tools.jlink.plugin;
 
-import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.Collections;
 import java.util.List;
-import java.util.Objects;
 import java.util.Set;
 
 /**
- * An executable runtime image. Instance of this class contains the information
- * needed to create image processes.
+ * An executable runtime image. Contains the information about the executable
+ * image created.
  */
-public abstract class ExecutableImage {
-
-    private final Path home;
-    private final List<String> args;
-    private final Set<String> modules;
-
-    protected ExecutableImage(Path home, Set<String> modules,
-            List<String> args) {
-        Objects.requireNonNull(home);
-        Objects.requireNonNull(args);
-        if (!Files.exists(home)) {
-            throw new IllegalArgumentException("Invalid image home");
-        }
-        this.home = home;
-        this.modules = Collections.unmodifiableSet(modules);
-        this.args = Collections.unmodifiableList(args);
-    }
+public interface ExecutableImage {
 
     /**
      * Image home directory,
      *
      * @return The home directory.
      */
-    public Path getHome() {
-        return home;
-    }
+    public Path getHome();
 
     /**
      * The names of the modules located in the image.
      *
      * @return The set of modules.
      */
-    public Set<String> getModules() {
-        return modules;
-    }
+    public Set<String> getModules();
 
     /**
      * The list of arguments required to execute the image.
      *
      * @return The list of arguments.
      */
-    public List<String> getExecutionArgs() {
-        return args;
-    }
+    public List<String> getExecutionArgs();
 
     /**
      * Store new arguments required to execute the image.
      *
      * @param args Additional arguments
      */
-    public abstract void storeLaunchArgs(List<String> args);
+    public void storeLaunchArgs(List<String> args);
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java
new file mode 100644
index 0000000..f516d8d
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.plugin;
+
+import java.lang.module.ModuleDescriptor;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+  * Link-time representation of a Java module.
+  */
+public interface LinkModule {
+
+    /**
+     * The module name.
+     *
+     * @return The name.
+     */
+    public String getName();
+
+    /**
+     * Retrieves a LinkModuleEntry from the given path (e.g:
+     * /mymodule/com.foo.bar/MyClass.class)
+     *
+     * @param path The piece of data path.
+     * @return A LinkModuleEntry of the given path, if found.
+     */
+    public Optional<ModuleEntry> findEntry(String path);
+
+    /**
+     * The module descriptor of this module.
+     *
+     * @return The module descriptor.
+     */
+    public ModuleDescriptor getDescriptor();
+
+    /**
+     * Add a LinkModuleEntry to this module.
+     *
+     * @param data The LinkModuleEntry to add.
+     */
+    public void add(ModuleEntry data);
+
+    /**
+     * Retrieves all the packages located in this module.
+     *
+     * @return The set of packages.
+     */
+    public Set<String> getAllPackages();
+
+    /**
+     * Retrieves the stream of LinkModuleEntry.
+     *
+     * @return The LinkModuleEntry stream.
+     */
+    public Stream<? extends ModuleEntry> entries();
+
+    /**
+     * Return the number of LinkModuleEntry count in this LinkModule.
+     *
+     * @return the entry count.
+     */
+    public int getEntryCount();
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java
new file mode 100644
index 0000000..61f828f
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.plugin;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Objects;
+import jdk.tools.jlink.internal.ImageFileCreator;
+import jdk.tools.jlink.internal.ModuleEntryImpl;
+
+/**
+ * A LinkModuleEntry is the elementary unit of data inside an image. It is
+ * generally a file. e.g.: a java class file, a resource file, a shared library,
+ * ...
+ * <br>
+ * A LinkModuleEntry is identified by a path of the form:
+ * <ul>
+ * <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file
+ * name}</li>
+ * <li>For other files (shared lib, launchers, config, ...):/{module name}/
+ * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}</li>
+ * </ul>
+ */
+public interface ModuleEntry {
+
+    /**
+     * Type of module data.
+     * <li>
+     * <ul>CLASS_OR_RESOURCE: A java class or resource file.</ul>
+     * <ul>CONFIG: A configuration file.</ul>
+     * <ul>NATIVE_CMD: A native process launcher.</ul>
+     * <ul>NATIVE_LIB: A native library.</ul>
+     * <ul>OTHER: Other kind of file.</ul>
+     * </li>
+     */
+    public enum Type {
+        CLASS_OR_RESOURCE,
+        CONFIG,
+        NATIVE_CMD,
+        NATIVE_LIB,
+        OTHER
+    }
+    /**
+     * The LinkModuleEntry module name.
+     *
+     * @return The module name.
+     */
+    public String getModule();
+
+    /**
+     * The LinkModuleEntry path.
+     *
+     * @return The module path.
+     */
+    public String getPath();
+
+    /**
+     * The LinkModuleEntry's type.
+     *
+     * @return The data type.
+     */
+    public Type getType();
+
+    /**
+     * The LinkModuleEntry content as an array of byte.
+     *
+     * @return An Array of bytes.
+     */
+    public byte[] getBytes();
+
+    /**
+     * The LinkModuleEntry content length.
+     *
+     * @return The length.
+     */
+    public long getLength();
+
+    /**
+     * The LinkModuleEntry stream.
+     *
+     * @return The module data stream.
+     */
+    public InputStream stream();
+
+
+    /**
+     * Create a LinkModuleEntry located inside a jimage file. Such
+     * LinkModuleEntry has a Type being equals to CLASS_OR_RESOURCE.
+     *
+     * @param path The complete resource path (contains the module radical).
+     * @param content The resource content.
+     * @param size The content size.
+     * @return A new LinkModuleEntry.
+     */
+    public static ModuleEntry create(String path, InputStream content, long size) {
+        Objects.requireNonNull(path);
+        Objects.requireNonNull(content);
+        String[] split = ImageFileCreator.splitPath(path);
+        String module = split[0];
+        return new ModuleEntryImpl(module, path, Type.CLASS_OR_RESOURCE, content, size);
+    }
+
+    /**
+     * Create a LinkModuleEntry for a file that will be located inside a jimage
+     * file.
+     *
+     * @param path The resource path.
+     * @param content The resource content.
+     * @return A new LinkModuleEntry.
+     */
+    public static ModuleEntry create(String path, byte[] content) {
+        return create(path, new ByteArrayInputStream(content),
+                content.length);
+    }
+
+    /**
+     * Create a LinkModuleEntry for a file that will be located outside a jimage
+     * file.
+     *
+     * @param module The module in which this files is located.
+     * @param path The file path locator (doesn't contain the module name).
+     * @param type The LinkModuleEntry type.
+     * @param content The file content.
+     * @param size The content size.
+     * @return A new LinkModuleEntry.
+     */
+    public static ModuleEntry create(String module, String path, ModuleEntry.Type type,
+            InputStream content, long size) {
+        Objects.requireNonNull(path);
+        Objects.requireNonNull(content);
+        return new ModuleEntryImpl(module, path, type, content, size);
+    }
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java
new file mode 100644
index 0000000..4d0f230
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.plugin;
+
+import java.nio.ByteOrder;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+/**
+ * Pool of module data.
+ */
+public interface ModulePool {
+/**
+     * Is this a read-only ModulePool?
+     *
+     * @return true if this is a read-only configuration.
+     */
+    public boolean isReadOnly();
+
+    /**
+     * Add a ModuleEntry.
+     *
+     * @param data The ModuleEntry to add.
+     */
+    public void add(ModuleEntry data);
+    /**
+     * Retrieves the module for the provided name.
+     *
+     * @param name The module name
+     * @return the module of matching name, if found
+     */
+    public Optional<LinkModule> findModule(String name);
+
+    /**
+     * The stream of modules contained in this ModulePool.
+     *
+     * @return The stream of modules.
+     */
+    public Stream<? extends LinkModule> modules();
+
+    /**
+     * Return the number of LinkModule count in this ModulePool.
+     *
+     * @return the module count.
+     */
+    public int getModuleCount();
+
+    /**
+     * Get all ModuleEntry contained in this ModulePool instance.
+     *
+     * @return The stream of LinkModuleEntries.
+     */
+    public Stream<? extends ModuleEntry> entries();
+
+    /**
+     * Return the number of ModuleEntry count in this ModulePool.
+     *
+     * @return the entry count.
+     */
+    public int getEntryCount();
+
+    /**
+     * Get the ModuleEntry for the passed path.
+     *
+     * @param path A data path
+     * @return A ModuleEntry instance or null if the data is not found
+     */
+   public Optional<ModuleEntry> findEntry(String path);
+
+    /**
+     * Check if the ModulePool contains the given ModuleEntry.
+     *
+     * @param data The module data to check existence for.
+     * @return The module data or null if not found.
+     */
+    public boolean contains(ModuleEntry data);
+
+    /**
+     * Check if the ModulePool contains some content at all.
+     *
+     * @return True, no content, false otherwise.
+     */
+    public boolean isEmpty();
+
+    /**
+     * Visit each ModuleEntry in this ModulePool to transform it and copy
+     * the transformed ModuleEntry to the output ModulePool.
+     *
+     * @param transform The function called for each ModuleEntry found in the
+     * ModulePool. The transform function should return a ModuleEntry
+     * instance which will be added to the output or it should return null if
+     * the passed ModuleEntry is to be ignored for the output.
+     *
+     * @param output The ModulePool to be filled with Visitor returned
+     * ModuleEntry.
+     */
+    public void transformAndCopy(Function<ModuleEntry, ModuleEntry> transform, ModulePool output);
+
+    /**
+     * The ByteOrder currently in use when generating the jimage file.
+     *
+     * @return The ByteOrder.
+     */
+    public ByteOrder getByteOrder();
+
+    /**
+     * Release properties such as OS, CPU name, version etc.
+     *
+     * @return the release properties
+     */
+    public Map<String, String> getReleaseProperties();
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java
index 56e51bc..30633b5 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java
@@ -26,7 +26,6 @@
 
 import java.util.Collections;
 import java.util.EnumSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import jdk.tools.jlink.internal.plugins.PluginsResourceBundle;
@@ -37,14 +36,6 @@
 public interface Plugin {
 
     /**
-     * Type of plugin.
-     */
-    public interface PluginType {
-
-        public String getName();
-    }
-
-    /**
      * Order of categories:
      * <ol>
      * <li>FILTER: Filter in/out resources or files.</li>
@@ -53,28 +44,29 @@
      * <li>MODULEINFO_TRANSFORMER: Transform only module-info.class</li>
      * <li>SORTER: Sort resources within the resource container.</li>
      * <li>COMPRESSOR: Compress resource within the resouce containers.</li>
+     * <li>METAINFO_ADDER: Added meta info (like release, copyright etc.)</li>
      * <li>VERIFIER: Does some image verification.</li>
      * <li>PROCESSOR: Does some post processing on image.</li>
      * <li>PACKAGER: Final processing</li>
      * </ol>
      */
-    public enum CATEGORY implements PluginType {
+    public enum Category {
         FILTER("FILTER"),
         TRANSFORMER("TRANSFORMER"),
         MODULEINFO_TRANSFORMER("MODULEINFO_TRANSFORMER"),
         SORTER("SORTER"),
         COMPRESSOR("COMPRESSOR"),
+        METAINFO_ADDER("METAINFO_ADDER"),
         VERIFIER("VERIFIER"),
         PROCESSOR("PROCESSOR"),
         PACKAGER("PACKAGER");
 
         private final String name;
 
-        CATEGORY(String name) {
+        Category(String name) {
             this.name = name;
         }
 
-        @Override
         public String getName() {
             return name;
         }
@@ -91,7 +83,7 @@
      * {@link #getStateDescription() getStateDescription} method</li>
      * </ul>
      */
-    public enum STATE {
+    public enum State {
         DISABLED,
         AUTO_ENABLED,
         FUNCTIONAL
@@ -101,7 +93,7 @@
      * The Plugin set of types.
      * @return The set of types.
      */
-    public default Set<PluginType> getType() {
+    public default Set<Category> getType() {
         return Collections.emptySet();
     }
 
@@ -109,8 +101,8 @@
      * The Plugin set of states.
      * @return The set of states.
      */
-    public default Set<STATE> getState() {
-        return EnumSet.of(STATE.FUNCTIONAL);
+    public default Set<State> getState() {
+        return EnumSet.of(State.FUNCTIONAL);
     }
 
     /**
@@ -191,7 +183,7 @@
      * @return A status description.
      */
     public default String getStateDescription() {
-        return getState().contains(STATE.FUNCTIONAL)
+        return getState().contains(State.FUNCTIONAL)
                 ? PluginsResourceBundle.getMessage("main.status.ok")
                 : PluginsResourceBundle.getMessage("main.status.not.ok");
     }
@@ -206,18 +198,4 @@
      */
     public default void configure(Map<String, String> config) {
     }
-
-    /**
-     * Configure the plugin based on the passed configuration.
-     * This method is called prior to invoke the plugin.
-     *
-     * @param config The plugin configuration.
-     * @param ctx The plugin context
-     * @throws IllegalArgumentException if a mandatory argument is missing or
-     * if an argument has invalid value.
-     *
-     */
-    public default void configure(Map<String, String> config, PluginContext ctx) {
-        configure(config);
-    }
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java
deleted file mode 100644
index 380ca41..0000000
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.plugin;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UncheckedIOException;
-import java.lang.module.ModuleDescriptor;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import jdk.tools.jlink.internal.ImageFileCreator;
-import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
-
-/**
- * Pool of module data.
- *
- */
-public abstract class Pool {
-
-    /**
-     * Interface to visit the content of a Pool.
-     */
-    public interface Visitor {
-
-        /**
-         * Called for each visited ModuleData.
-         *
-         * @param content A ModuleData
-         * @return A ModuleData instance or null if the passed ModuleData is to
-         * be removed from the image.
-         * @throws PluginException
-         */
-        public ModuleData visit(ModuleData content);
-    }
-
-    /**
-     * Type of module data.
-     * <li>
-     * <ul>CLASS_OR_RESOURCE: A java class or resource file.</ul>
-     * <ul>CONFIG: A configuration file.</ul>
-     * <ul>NATIVE_CMD: A native process launcher.</ul>
-     * <ul>NATIVE_LIB: A native library.</ul>
-     * <ul>OTHER: Other kind of file.</ul>
-     * </li>
-     */
-    public static enum ModuleDataType {
-
-        CLASS_OR_RESOURCE,
-        CONFIG,
-        NATIVE_CMD,
-        NATIVE_LIB,
-        OTHER;
-    }
-
-    /**
-     * A module in the pool.
-     */
-    public interface Module {
-
-        /**
-         * The module name.
-         *
-         * @return The name.
-         */
-        public String getName();
-
-        /**
-         * Retrieves a ModuleData from a path (e.g:
-         * /mymodule/com.foo.bar/MyClass.class)
-         *
-         * @param path The piece of data path.
-         * @return A ModuleData or null if the path doesn't identify a
-         * ModuleData.
-         */
-        public ModuleData get(String path);
-
-        /**
-         * The module descriptor of this module.
-         *
-         * @return The module descriptor.
-         */
-        public ModuleDescriptor getDescriptor();
-
-        /**
-         * Add a ModuleData to this module.
-         *
-         * @param data The ModuleData to add.
-         */
-        public void add(ModuleData data);
-
-        /**
-         * Retrieves all the packages located in this module.
-         *
-         * @return The set of packages.
-         */
-        public Set<String> getAllPackages();
-
-        /**
-         * Retrieves the collection of ModuleData.
-         *
-         * @return The ModuleData collection.
-         */
-        public Collection<ModuleData> getContent();
-
-    }
-
-    private class ModuleImpl implements Module {
-
-        private final Map<String, ModuleData> moduleContent = new LinkedHashMap<>();
-        private ModuleDescriptor descriptor;
-        private final String name;
-
-        private ModuleImpl(String name) {
-            this.name = name;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public ModuleData get(String path) {
-            if (!path.startsWith("/")) {
-                path = "/" + path;
-            }
-            if (!path.startsWith("/" + name)) {
-                path = "/" + name + path;
-            }
-            return moduleContent.get(path);
-        }
-
-        @Override
-        public ModuleDescriptor getDescriptor() {
-            if (descriptor == null) {
-                String p = "/" + name + "/module-info.class";
-                ModuleData content = moduleContent.get(p);
-                if (content == null) {
-                    throw new PluginException("No module-info for " + name
-                            + " module");
-                }
-                ByteBuffer bb = ByteBuffer.wrap(content.getBytes());
-                descriptor = ModuleDescriptor.read(bb);
-            }
-            return descriptor;
-        }
-
-        @Override
-        public void add(ModuleData data) {
-            if (isReadOnly()) {
-                throw new PluginException("pool is readonly");
-            }
-            Objects.requireNonNull(data);
-            if (!data.getModule().equals(name)) {
-                throw new PluginException("Can't add resource " + data.getPath()
-                        + " to module " + name);
-            }
-            Pool.this.add(data);
-        }
-
-        @Override
-        public Set<String> getAllPackages() {
-            Set<String> pkgs = new HashSet<>();
-            moduleContent.values().stream().filter(m -> m.getType().
-                    equals(ModuleDataType.CLASS_OR_RESOURCE)).forEach((res) -> {
-                // Module metadata only contains packages with .class files
-                if (ImageFileCreator.isClassPackage(res.getPath())) {
-                    String[] split = ImageFileCreator.splitPath(res.getPath());
-                    String pkg = split[1];
-                    if (pkg != null && !pkg.isEmpty()) {
-                        pkgs.add(pkg);
-                    }
-                }
-            });
-            return pkgs;
-        }
-
-        @Override
-        public String toString() {
-            return getName();
-        }
-
-        @Override
-        public Collection<ModuleData> getContent() {
-            return Collections.unmodifiableCollection(moduleContent.values());
-        }
-    }
-
-    /**
-     * A ModuleData is the elementary unit of data inside an image. It is
-     * generally a file. e.g.: a java class file, a resource file, a shared
-     * library, ...
-     * <br>
-     * A ModuleData is identified by a path of the form:
-     * <ul>
-     * <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file
-     * name}</li>
-     * <li>For other files (shared lib, launchers, config, ...):/{module name}/
-     * {@literal bin|conf|native}/{dir1}/.../{dirN}/{file name}</li>
-     * </ul>
-     */
-    public static class ModuleData {
-
-        private final ModuleDataType type;
-        private final String path;
-        private final String module;
-        private final long length;
-        private final InputStream stream;
-        private byte[] buffer;
-
-        /**
-         * Create a new ModuleData.
-         *
-         * @param module The module name.
-         * @param path The data path identifier.
-         * @param type The data type.
-         * @param stream The data content stream.
-         * @param length The stream length.
-         */
-        public ModuleData(String module, String path, ModuleDataType type,
-                InputStream stream, long length) {
-            Objects.requireNonNull(module);
-            Objects.requireNonNull(path);
-            Objects.requireNonNull(type);
-            Objects.requireNonNull(stream);
-            this.path = path;
-            this.type = type;
-            this.module = module;
-            this.stream = stream;
-            this.length = length;
-        }
-
-        /**
-         * The ModuleData module name.
-         *
-         * @return The module name.
-         */
-        public final String getModule() {
-            return module;
-        }
-
-        /**
-         * The ModuleData path.
-         *
-         * @return The module path.
-         */
-        public final String getPath() {
-            return path;
-        }
-
-        /**
-         * The ModuleData type.
-         *
-         * @return The data type.
-         */
-        public final ModuleDataType getType() {
-            return type;
-        }
-
-        /**
-         * The ModuleData content as an array of byte.
-         *
-         * @return An Array of bytes.
-         */
-        public byte[] getBytes() {
-            if (buffer == null) {
-                try {
-                    buffer = stream.readAllBytes();
-                } catch (IOException ex) {
-                    throw new UncheckedIOException(ex);
-                }
-            }
-            return buffer;
-        }
-
-        /**
-         * The ModuleData content length.
-         *
-         * @return The length.
-         */
-        public long getLength() {
-            return length;
-        }
-
-        /**
-         * The ModuleData stream.
-         *
-         * @return The module data stream.
-         */
-        public InputStream stream() {
-            return stream;
-        }
-
-        @Override
-        public int hashCode() {
-            int hash = 7;
-            hash = 89 * hash + Objects.hashCode(this.path);
-            return hash;
-        }
-
-        @Override
-        public boolean equals(Object other) {
-            if (!(other instanceof ModuleData)) {
-                return false;
-            }
-            ModuleData f = (ModuleData) other;
-            return f.path.equals(path);
-        }
-
-        @Override
-        public String toString() {
-            return getPath();
-        }
-    }
-
-    private final Map<String, ModuleData> resources = new LinkedHashMap<>();
-    private final Map<String, ModuleImpl> modules = new LinkedHashMap<>();
-    private final ModuleImpl fileCopierModule = new ModuleImpl(FileCopierPlugin.FAKE_MODULE);
-
-    private final ByteOrder order;
-
-    protected Pool() {
-        this(ByteOrder.nativeOrder());
-    }
-
-    protected Pool(ByteOrder order) {
-        Objects.requireNonNull(order);
-        this.order = order;
-    }
-
-    /**
-     * Read only state. No data can be added to a ReadOnly Pool.
-     *
-     * @return true if readonly false otherwise.
-     */
-    public abstract boolean isReadOnly();
-
-    /**
-     * Add a ModuleData.
-     *
-     * @param data The ModuleData to add.
-     */
-    public void add(ModuleData data) {
-        if (isReadOnly()) {
-            throw new PluginException("pool is readonly");
-        }
-        Objects.requireNonNull(data);
-        if (resources.get(data.getPath()) != null) {
-            throw new PluginException("Resource " + data.getPath()
-                    + " already present");
-        }
-        String modulename = data.getModule();
-        ModuleImpl m = modules.get(modulename);
-        // ## TODO: FileCopierPlugin should not add content to a module
-        // FAKE_MODULE is not really a module to be added in the image
-        if (FileCopierPlugin.FAKE_MODULE.equals(modulename)) {
-            m = fileCopierModule;
-        }
-        if (m == null) {
-            m = new ModuleImpl(modulename);
-            modules.put(modulename, m);
-        }
-        resources.put(data.getPath(), data);
-        m.moduleContent.put(data.getPath(), data);
-    }
-
-    /**
-     * Retrieves the module for the provided name.
-     *
-     * @param name The module name
-     * @return the module or null if the module doesn't exist.
-     */
-    public Module getModule(String name) {
-        Objects.requireNonNull(name);
-        return modules.get(name);
-    }
-
-    /**
-     * The collection of modules contained in this pool.
-     *
-     * @return The collection of modules.
-     */
-    public Collection<Module> getModules() {
-        return Collections.unmodifiableCollection(modules.values());
-    }
-
-    /**
-     * Get all ModuleData contained in this pool instance.
-     *
-     * @return The collection of resources;
-     */
-    public Collection<ModuleData> getContent() {
-        return Collections.unmodifiableCollection(resources.values());
-    }
-
-    /**
-     * Get the ModuleData for the passed path.
-     *
-     * @param path A data path
-     * @return A ModuleData instance or null if the data is not found
-     */
-    public ModuleData get(String path) {
-        Objects.requireNonNull(path);
-        return resources.get(path);
-    }
-
-    /**
-     * Check if the pool contains this data.
-     *
-     * @param data The module data to check existence for.
-     * @return The module data or null if not found.
-     */
-    public boolean contains(ModuleData data) {
-        Objects.requireNonNull(data);
-        return get(data.getPath()) != null;
-    }
-
-    /**
-     * Check if the Pool contains some content.
-     *
-     * @return True, no content, false otherwise.
-     */
-    public boolean isEmpty() {
-        return resources.isEmpty();
-    }
-
-    /**
-     * Visit the pool.
-     *
-     * @param visitor The Visitor called for each ModuleData found in the pool.
-     * @param output The pool to be filled with Visitor returned ModuleData.
-     */
-    public void visit(Visitor visitor, Pool output) {
-        for (ModuleData resource : getContent()) {
-            ModuleData res = visitor.visit(resource);
-            if (res != null) {
-                output.add(res);
-            }
-        }
-    }
-
-    /**
-     * The ByteOrder currently in use when generating the jimage file.
-     *
-     * @return The ByteOrder.
-     */
-    public ByteOrder getByteOrder() {
-        return order;
-    }
-
-    /**
-     * Create a ModuleData located inside a jimage file. Such ModuleData has a
-     * ModuleDataType being equals to CLASS_OR_RESOURCE.
-     *
-     * @param path The complete resource path (contains the module radical).
-     * @param content The resource content.
-     * @param size The content size.
-     * @return A new ModuleData.
-     */
-    public static ModuleData newResource(String path, InputStream content, long size) {
-        Objects.requireNonNull(path);
-        Objects.requireNonNull(content);
-        String[] split = ImageFileCreator.splitPath(path);
-        String module = split[0];
-        return new ModuleData(module, path, ModuleDataType.CLASS_OR_RESOURCE, content, size);
-    }
-
-    /**
-     * Create a ModuleData for a file that will be located inside a jimage file.
-     *
-     * @param path The resource path.
-     * @param content The resource content.
-     * @return A new ModuleData.
-     */
-    public static ModuleData newResource(String path, byte[] content) {
-        return newResource(path, new ByteArrayInputStream(content),
-                content.length);
-    }
-
-    /**
-     * Create a ModuleData for a file that will be located outside a jimage
-     * file.
-     *
-     * @param module The module in which this files is located.
-     * @param path The file path locator (doesn't contain the module name).
-     * @param type The ModuleData type.
-     * @param content The file content.
-     * @param size The content size.
-     * @return A new ModuleData.
-     */
-    public static ModuleData newImageFile(String module, String path, ModuleDataType type,
-            InputStream content, long size) {
-        Objects.requireNonNull(path);
-        Objects.requireNonNull(content);
-        return new ModuleData(module, path, type, content, size);
-    }
-
-}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java
index 4af4897..1513322 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java
@@ -40,5 +40,5 @@
      *
      * @throws PluginException
      */
-    public void visit(Pool in, Pool out);
+    public void visit(ModulePool in, ModulePool out);
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties
index 1aa3343..975dc81 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties
@@ -1,3 +1,28 @@
+#
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
 main.usage.summary=\
 Usage: {0} <options> --modulepath <modulepath> --addmods <mods> --output <path>\n\
 use --help for a list of possible options
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
index 5b03646..66fc5ef 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
@@ -1,3 +1,28 @@
+#
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
 release-info.argument=<file>|add:<key1>=<value1>:<key2>=<value2>:...|del:<key list>
 
 release-info.description=\
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties
index 555adb0..12cb85c 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties
@@ -1,3 +1,28 @@
+#
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
 main.usage.summary=\
 Usage: {0} (create|list|describe|hash) <OPTIONS> <jmod-file>\n\
 use --help for a list of possible options
diff --git a/jdk/src/jdk.jlink/share/classes/module-info.java b/jdk/src/jdk.jlink/share/classes/module-info.java
index 49e426f..c231164 100644
--- a/jdk/src/jdk.jlink/share/classes/module-info.java
+++ b/jdk/src/jdk.jlink/share/classes/module-info.java
@@ -24,9 +24,7 @@
  */
 
 module jdk.jlink {
-    exports jdk.tools.jlink;
     exports jdk.tools.jlink.plugin;
-    exports jdk.tools.jlink.builder;
 
     requires jdk.internal.opt;
     requires jdk.jdeps;
@@ -46,5 +44,5 @@
     provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
     provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin;
     provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin;
-    provides jdk.tools.jlink.plugin.PostProcessorPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin;
+    provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin;
 }
diff --git a/jdk/src/jdk.jsobject/share/classes/jdk/internal/netscape/javascript/spi/JSObjectProvider.java b/jdk/src/jdk.jsobject/share/classes/jdk/internal/netscape/javascript/spi/JSObjectProvider.java
index 69c1235..176d0a0 100644
--- a/jdk/src/jdk.jsobject/share/classes/jdk/internal/netscape/javascript/spi/JSObjectProvider.java
+++ b/jdk/src/jdk.jsobject/share/classes/jdk/internal/netscape/javascript/spi/JSObjectProvider.java
@@ -29,6 +29,7 @@
 import netscape.javascript.JSException;
 import netscape.javascript.JSObject;
 
+@SuppressWarnings("deprecation")
 public interface JSObjectProvider {
     /**
      * Return a JSObject for the window containing the given applet.
diff --git a/jdk/src/jdk.jsobject/share/classes/netscape/javascript/JSObject.java b/jdk/src/jdk.jsobject/share/classes/netscape/javascript/JSObject.java
index 250825a..7ef7e3b 100644
--- a/jdk/src/jdk.jsobject/share/classes/netscape/javascript/JSObject.java
+++ b/jdk/src/jdk.jsobject/share/classes/netscape/javascript/JSObject.java
@@ -52,6 +52,7 @@
  * </p>
  *
  */
+@SuppressWarnings("deprecation")
 public abstract class JSObject {
     /**
      * Constructs a new JSObject. Users should neither call this method nor
diff --git a/jdk/src/jdk.pack200/share/native/common-unpack/constants.h b/jdk/src/jdk.pack200/share/native/common-unpack/constants.h
index f1a1f73..8d8376d 100644
--- a/jdk/src/jdk.pack200/share/native/common-unpack/constants.h
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/constants.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,30 +23,10 @@
  * questions.
  */
 
-/*
-  Java Class Version numbers history
-  1.0 to 1.3.X 45,3
-  1.4 to 1.4.X 46,0
-  1.5 to 1.5.X 49,0
-  1.6 to 1.5.x 50,0 NOTE Assumed for now
-*/
-
 // classfile constants
 #define JAVA_MAGIC 0xCAFEBABE
-#define JAVA_MIN_MAJOR_VERSION 45
-#define JAVA_MIN_MINOR_VERSION 3
 
-#define JAVA5_MAX_MAJOR_VERSION 49
-#define JAVA5_MAX_MINOR_VERSION 0
-
-#define JAVA6_MAX_MAJOR_VERSION 50
-#define JAVA6_MAX_MINOR_VERSION 0
-
-#define JAVA7_MAX_MAJOR_VERSION 51
-#define JAVA7_MAX_MINOR_VERSION 0
-
-#define JAVA8_MAX_MAJOR_VERSION 52
-#define JAVA8_MAX_MINOR_VERSION 0
+// Class version history, refer to Constants.java
 
 // package file constants
 #define JAVA_PACKAGE_MAGIC 0xCAFED00D
diff --git a/jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java b/jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java
deleted file mode 100644
index 180a5d5..0000000
--- a/jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * This class is used to prevent multiple calling of g_thread_init ()
- * and gdk_thread_init ().
- *
- * Since version 2.24 of GLib, calling g_thread_init () multiple times is
- * allowed, but it will crash for older versions. There are two ways to
- * find out if g_thread_init () has been called:
- * g_thread_get_initialized (), but it was introduced in 2.20
- * g_thread_supported (), but it is a macro and cannot be loaded with dlsym.
- *
- * usage:
- * <pre>
- * lock();
- * try {
- *    if (!getAndSetInitializationNeededFlag()) {
- *        //call to g_thread_init();
- *        //call to gdk_thread_init();
- *    }
- * } finally {
- *    unlock();
- * }
- * </pre>
- */
-public final class GThreadHelper {
-
-    private static final ReentrantLock LOCK = new ReentrantLock();
-    private static boolean isGThreadInitialized = false;
-
-    /**
-     * Acquires the lock.
-     */
-    public static void lock() {
-        LOCK.lock();
-    }
-
-    /**
-     * Releases the lock.
-     */
-    public static void unlock() {
-        LOCK.unlock();
-    }
-
-    /**
-     * Gets current value of initialization flag and sets it to {@code true}.
-     * MUST be called under the lock.
-     *
-     * A return value of {@code false} indicates that the calling code
-     * should call the g_thread_init() and gdk_thread_init() functions
-     * before releasing the lock.
-     *
-     * @return {@code true} if initialization has been completed.
-     */
-    public static boolean getAndSetInitializationNeededFlag() {
-        boolean ret = isGThreadInitialized;
-        isGThreadInitialized = true;
-        return ret;
-    }
-}
diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
index 4ddeaff..1e05e84 100644
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.Runtime.Version;
 import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -36,7 +37,6 @@
 import java.util.function.Function;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
-import jdk.Version;
 
 /**
  * Adds aliasing to ZipFileSystem to support multi-release jar files.  An alias map
@@ -69,7 +69,7 @@
             if (o instanceof String) {
                 String s = (String)o;
                 if (s.equals("runtime")) {
-                    version = jdk.Version.current().major();
+                    version = Runtime.version().major();
                 } else {
                     version = Integer.parseInt(s);
                 }
diff --git a/jdk/test/Makefile b/jdk/test/Makefile
index 4879392..86e69f0 100644
--- a/jdk/test/Makefile
+++ b/jdk/test/Makefile
@@ -301,7 +301,10 @@
 endif
 
 ifdef CONCURRENCY
-  EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
+  JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+endif
+ifdef EXTRA_JTREG_OPTIONS
+  JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 endif
 
 # Default JTREG to run
@@ -328,8 +331,6 @@
 JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION)
 # Give tests access to JT_JAVA, see JDK-8141609
 JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA}
-# Add any extra options
-JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 # Set other vm and test options
 JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%)
 # Set the GC options for test vms
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index 67dd85f..5d2113b 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -116,10 +116,8 @@
 
 # jdk_beans
 
-java/beans/XMLEncoder/Test4903007.java                          8060027 generic-all
-java/beans/XMLEncoder/java_awt_GridBagLayout.java               8060027 generic-all
-java/beans/XMLDecoder/8028054/TestConstructorFinder.java        8060027 generic-all
-java/beans/XMLDecoder/8028054/TestMethodFinder.java             8060027 generic-all
+java/beans/XMLDecoder/8028054/TestConstructorFinder.java        8156579 generic-all
+java/beans/XMLDecoder/8028054/TestMethodFinder.java             8156579 generic-all
 
 java/beans/Introspector/8132566/OverridePropertyInfoTest.java   8132565 generic-all
 java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 generic-all
@@ -128,8 +126,6 @@
 
 # jdk_lang
 
-java/lang/ClassLoader/deadlock/GetResource.java                 8029891 generic-all
-
 java/lang/StringCoding/CheckEncodings.sh                        7008363 generic-all
 
 ############################################################################
@@ -145,6 +141,12 @@
 
 ############################################################################
 
+# jdk_io
+
+java/io/pathNames/GeneralWin32.java                             8156595 windows-all
+
+############################################################################
+
 # jdk_jmx
 
 com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all
@@ -290,11 +292,12 @@
 
 sun/security/x509/URICertStore/ExtensionsWithLDAP.java          8134577 generic-all
 
+sun/security/provider/SecureRandom/StrongSecureRandom.java      8157387 linux-all
+
 ############################################################################
 
 # jdk_sound
 
-javax/sound/midi/Gervill/SoftProvider/GetDevice.java            8059743 generic-all
 javax/sound/sampled/DirectAudio/bug6400879.java                 8148915 linux-all
 
 ############################################################################
diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups
index 3f54615..3c2ee6c 100644
--- a/jdk/test/TEST.groups
+++ b/jdk/test/TEST.groups
@@ -34,7 +34,8 @@
     sun/nio/cs/ISO8859x.java \
     java/nio/Buffer \
     com/sun/crypto/provider/Cipher \
-    :jdk_math
+    :jdk_math \
+    tools/pack200
 
 tier2 = \
     java/lang/ProcessHandle/TreeTest.java \
@@ -50,6 +51,7 @@
     -com/sun/crypto/provider/Cipher \
     :jdk_text \
     :core_tools \
+    -tools/pack200 \
     :jdk_other
 
 tier3 = \
@@ -76,6 +78,7 @@
     jdk/lambda \
     jdk/internal/misc \
     jdk/internal/ref \
+    jdk/internal/jimage \
     jdk/modules \
     vm
 
@@ -352,7 +355,7 @@
 # SwingSet3 tests.
 jdk_client_sanity = \
     sanity/client/SwingSet
-    
+
 ###############################################################################
 #
 # Serviceability sanity groups
diff --git a/jdk/test/com/sun/jdi/ReferrersTest.java b/jdk/test/com/sun/jdi/ReferrersTest.java
index b78a561..3293b08 100644
--- a/jdk/test/com/sun/jdi/ReferrersTest.java
+++ b/jdk/test/com/sun/jdi/ReferrersTest.java
@@ -446,7 +446,7 @@
         if (rt instanceof ClassType) {
             ClassType ct = (ClassType)rt;
             String name = ct.name();
-            if (name.equals("sun.misc.SoftCache$ValueCell")) {
+            if (name.equals("sun.awt.SoftCache$ValueCell")) {
                 return;
             }
             if (name.equals("java.lang.ref.Finalizer")) {
diff --git a/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java
index 5cdc808..1e94147 100644
--- a/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java
+++ b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,17 +21,23 @@
  * questions.
  */
 
-
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.EventQueue;
+import java.awt.Frame;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
 
 import static jdk.testlibrary.Asserts.assertTrue;
 
 /*
- * @test
+ * @test 8155742
  * @summary Make sure that modifier key mask is set when robot press
- * some key with one or more modifiers.
- *
+ *          some key with one or more modifiers.
  * @library ../../../../lib/testlibrary/
  * @build ExtendedRobot
  * @run main ModifierRobotKeyTest
@@ -60,15 +66,17 @@
     }
 
     public ModifierRobotKeyTest() throws Exception {
-        modifierKeys =  new int[3];
+        modifierKeys =  new int[4];
         modifierKeys[0] = KeyEvent.VK_SHIFT;
         modifierKeys[1] = KeyEvent.VK_CONTROL;
         modifierKeys[2] = KeyEvent.VK_ALT;
+        modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;
 
-        inputMasks = new int[3];
+        inputMasks = new int[4];
         inputMasks[0] =  InputEvent.SHIFT_MASK;
         inputMasks[1] =  InputEvent.CTRL_MASK;
         inputMasks[2] =  InputEvent.ALT_MASK;
+        inputMasks[3] =  InputEvent.ALT_GRAPH_MASK;
 
         modifierStatus = new boolean[modifierKeys.length];
 
diff --git a/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java b/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java
index 7c61804..2c4f041 100644
--- a/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java
+++ b/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -45,16 +45,34 @@
 
     public static void main(final String[] args) throws Exception {
         final StubbedToolkit t = new StubbedToolkit();
-
+        final Boolean dynamicLayoutSupported
+                = (Boolean) t.getDesktopProperty("awt.dynamicLayoutSupported");
         t.setDynamicLayout(true);
         if(!t.isDynamicLayoutSet()){
             throw new RuntimeException("'true' expected but 'false' returned");
         }
+        if (dynamicLayoutSupported) {
+            if (!t.isDynamicLayoutActive()) {
+                throw new RuntimeException("is inactive but set+supported");
+            }
+        } else {
+            if (t.isDynamicLayoutActive()) {
+                throw new RuntimeException("is active but unsupported");
+            }
+        }
 
         t.setDynamicLayout(false);
         if(t.isDynamicLayoutSet()){
             throw new RuntimeException("'false' expected but 'true' returned");
         }
+        if (dynamicLayoutSupported) {
+            // Layout is supported and was set to false, cannot verifym because
+            // the native system is free to ignore our request.
+        } else {
+            if (t.isDynamicLayoutActive()) {
+                throw new RuntimeException("is active but unset+unsupported");
+            }
+        }
     }
 
     static final class StubbedToolkit extends Toolkit {
diff --git a/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java b/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java
index 7a5f87a..95879ce 100644
--- a/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java
+++ b/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java
@@ -23,10 +23,13 @@
 
 /*
  * @test
- * @bug 6191390
+ * @bug 6191390 8154328
  * @summary Verify that ActionEvent is received with correct modifiers set.
  * @library ../../../../lib/testlibrary ../
+ * @library /java/awt/patchlib
+ * @build java.desktop/java.awt.Helper
  * @build ExtendedRobot SystemTrayIconHelper
+ * @run main ActionEventTest
  */
 
 import java.awt.Image;
@@ -46,6 +49,7 @@
     Image image;
     TrayIcon icon;
     Robot robot;
+    boolean actionPerformed;
 
     public static void main(String[] args) throws Exception {
         if (!SystemTray.isSupported()) {
@@ -82,6 +86,7 @@
         icon.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent ae) {
+                actionPerformed = true;
                 int md = ae.getModifiers();
                 int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                         | ActionEvent.SHIFT_MASK;
@@ -102,6 +107,9 @@
     }
 
     public void clear() {
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.keyRelease(KeyEvent.VK_CONTROL);
         SystemTray.getSystemTray().remove(icon);
     }
 
@@ -123,10 +131,9 @@
         robot.delay(100);
         robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
-        robot.delay(100);
         robot.waitForIdle();
-        robot.keyRelease(KeyEvent.VK_ALT);
-        robot.keyRelease(KeyEvent.VK_SHIFT);
-        robot.keyRelease(KeyEvent.VK_CONTROL);
+        if (!actionPerformed) {
+            robot.delay(500);
+        }
     }
 }
diff --git a/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java b/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java
index 551878e..f7549a3 100644
--- a/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java
+++ b/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,16 +21,19 @@
  * questions.
  */
 
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.SystemTray;
+import java.awt.TrayIcon;
+import java.awt.event.InputEvent;
 import java.awt.image.BufferedImage;
 
 /*
- * @test
- * @summary Check if ActionEvent is triggered by a TrayIcon only when
- *          it is double clicked using mouse button 1 (or single clicked
- *          with button 3 (on Mac OS X))
- * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @test 6384991
+ * @summary Check if ActionEvent is triggered by a TrayIcon when
+ *          it is double clicked with mouse button 1 on windows
+ *          or single clicked with button 3 on Mac OS X
+ *          or single clicked with button 1 on rest.
  * @library /java/awt/patchlib
  * @library ../../../../lib/testlibrary ../
  * @build java.desktop/java.awt.Helper
@@ -42,19 +45,17 @@
 
     TrayIcon icon;
     ExtendedRobot robot;
-
     boolean actionPerformed = false;
     Object actionLock = new Object();
     static boolean isMacOS = false;
-
+    static boolean isWinOS = false;
+    static boolean isOelOS = false;
     String caption = "Sample Icon";
-
     int[] buttonTypes = {
         InputEvent.BUTTON1_MASK,
         InputEvent.BUTTON2_MASK,
         InputEvent.BUTTON3_MASK
     };
-
     String[] buttonNames = {
         "BUTTON1",
         "BUTTON2",
@@ -62,30 +63,31 @@
     };
 
     public static void main(String[] args) throws Exception {
-        if (! SystemTray.isSupported()) {
-            System.out.println("SystemTray not supported on the platform under test. " +
-                    "Marking the test passed");
+        if (!SystemTray.isSupported()) {
+            System.out.println("SystemTray not supported on the platform "
+                    + "under test. Marking the test passed");
         } else {
-            if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
+            String osName = System.getProperty("os.name").toLowerCase();
+            if (osName.startsWith("mac")) {
                 isMacOS = true;
-            } else if (SystemTrayIconHelper.isOel7()) {
-                System.out.println("OEL 7 doesn't support double click in " +
-                        "systray. Skipped");
-                return;
+            } else if (osName.startsWith("win")) {
+                isWinOS = true;
+            } else {
+                isOelOS = SystemTrayIconHelper.isOel7();
             }
             new TrayIconMouseTest().doTest();
         }
     }
 
-    TrayIconMouseTest() throws Exception{
+    TrayIconMouseTest() throws Exception {
         robot = new ExtendedRobot();
         EventQueue.invokeAndWait(this::initializeGUI);
     }
 
     void initializeGUI() {
-
         SystemTray tray = SystemTray.getSystemTray();
-        icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), caption);
+        icon = new TrayIcon(
+                new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), caption);
         icon.addActionListener(event -> {
             actionPerformed = true;
             synchronized (actionLock) {
@@ -103,31 +105,32 @@
     }
 
     private void doTest() throws Exception {
-
         Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
-        if (iconPosition == null)
+        if (iconPosition == null) {
             throw new RuntimeException("Unable to find the icon location!");
-
+        }
         robot.mouseMove(iconPosition.x, iconPosition.y);
         robot.waitForIdle();
 
         for (int i = 0; i < buttonTypes.length; i++) {
             actionPerformed = false;
             robot.click(buttonTypes[i]);
-            robot.waitForIdle(6000);
+            robot.waitForIdle();
+            delayIfRequired();
 
-            if (isMacOS && actionPerformed && i == 2) {
-
-            }else if (isMacOS && i == 2) {
-                throw new RuntimeException("FAIL: ActionEvent NOT triggered when " +
-                        buttonNames[i] + " is single clicked on Mac OS");
-            }else if (actionPerformed) {
-                throw new RuntimeException("FAIL: ActionEvent triggered when " +
-                        buttonNames[i] + " is single clicked");
+            if (isMacOS && i == 2 && !actionPerformed) {
+                throw new RuntimeException("FAIL: ActionEvent NOT triggered "
+                    + "when " + buttonNames[i] + " is single clicked on Mac");
+            } else if (isWinOS && actionPerformed) {
+                throw new RuntimeException("FAIL: ActionEvent triggered "
+                    + "when " + buttonNames[i] + " is single clicked");
+            } else if (!isMacOS && !isWinOS && i == 0 && !actionPerformed) {
+                throw new RuntimeException("FAIL: ActionEvent NOT triggered "
+                    + "when " + buttonNames[i] + " is single clicked");
             }
         }
 
-        if(!isMacOS) {
+        if (!isMacOS && !isOelOS) {
             for (int i = 0; i < buttonTypes.length; i++) {
                 for (int j = 0; j < buttonTypes.length; j++) {
                     if (j != i) {
@@ -136,13 +139,22 @@
                         robot.mousePress(buttonTypes[j]);
                         robot.mouseRelease(buttonTypes[j]);
                         robot.mouseRelease(buttonTypes[i]);
-
                         robot.waitForIdle();
+                        delayIfRequired();
 
-                        if (actionPerformed)
-                            throw new RuntimeException("FAIL: ActionEvent triggered when " +
-                                    buttonNames[i] + " and " + buttonNames[j] +
-                                    " is clicked and released");
+                        if (isWinOS) {
+                            if (actionPerformed) {
+                                throw new RuntimeException(
+                                    "FAIL: ActionEvent triggered when "
+                                    + buttonNames[i] + " & " + buttonNames[j]
+                                    + " is clicked and released");
+                            }
+
+                        } else if ((i == 0 || j == 0) && !actionPerformed) {
+                            throw new RuntimeException("FAIL: ActionEvent is "
+                                + "NOT triggered when " + buttonNames[i] + " & "
+                                + buttonNames[j] + " is pressed & released");
+                        }
                     }
                 }
             }
@@ -150,31 +162,34 @@
             for (int i = 0; i < buttonTypes.length; i++) {
                 actionPerformed = false;
                 robot.mousePress(buttonTypes[i]);
-                robot.delay(50);
                 robot.mouseRelease(buttonTypes[i]);
                 robot.delay(50);
                 robot.mousePress(buttonTypes[i]);
-                robot.delay(50);
                 robot.mouseRelease(buttonTypes[i]);
+                robot.waitForIdle();
+                delayIfRequired();
 
                 if (i == 0) {
-                    if (! actionPerformed) {
-                        synchronized (actionLock) {
-                            try {
-                                actionLock.wait(6000);
-                            } catch (Exception e) {
-                            }
-                        }
+                    if (!actionPerformed) {
+                        throw new RuntimeException("FAIL: ActionEvent not "
+                                + "triggered when " + buttonNames[i]
+                                + " is double clicked");
                     }
-                    if (! actionPerformed)
-                        throw new RuntimeException("FAIL: ActionEvent not triggered when " +
-                                buttonNames[i] + " is double clicked");
-                } else {
-                    robot.waitForIdle();
+                } else if (actionPerformed) {
+                    throw new RuntimeException("FAIL: ActionEvent "
+                            + "triggered when " + buttonNames[i]
+                            + " is double clicked");
+                }
+            }
+        }
+    }
 
-                    if (actionPerformed)
-                        throw new RuntimeException("FAIL: ActionEvent triggered when " +
-                                buttonNames[i] + " is double clicked");
+    public void delayIfRequired() {
+        if (!actionPerformed) {
+            synchronized (actionLock) {
+                try {
+                    actionLock.wait(500);
+                } catch (Exception e) {
                 }
             }
         }
diff --git a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html
deleted file mode 100644
index 91dcf4f..0000000
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<!--
- Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 only, as
- published by the Free Software Foundation.
-
- This code is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- version 2 for more details (a copy is included in the LICENSE file that
- accompanied this code).
-
- You should have received a copy of the GNU General Public License version
- 2 along with this work; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
--->
-
-<html>
-<!--
-  @test
-  @bug 4955110
-  @summary tests that a drag ends on button2 release
-  @author Alexander.Gerasimov area=dnd
-  @library    ../../regtesthelpers
-  @build      Util
-  @run applet/othervm Button2DragTest.html
-  -->
-<head>
-<title>  </title>
-</head>
-<body>
-
-<h1>Button2DragTest<br>Bug ID: 4955110</h1>
-
-<p> This is an AUTOMATIC test, simply wait for completion </p>
-
-<APPLET CODE="Button2DragTest.class" WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
diff --git a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java
index 33bb505..c5045ed 100644
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java
+++ b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,45 +21,52 @@
  * questions.
  */
 
-/*
-  test
-  @bug 4955110
-  @summary tests that a drag ends on button2 release
-  @author Alexander.Gerasimov area=dnd
-  @library    ../../regtesthelpers
-  @build      Util
-  @run applet/othervm Button2DragTest.html
-*/
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
 
-
-/**
- * Button2DragTest.java
- *
- * summary: tests that DragSourceDragEvent.getDropAction() accords to its new spec
- *          (does not depend on the user drop action)
- *
- */
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.datatransfer.*;
-import java.awt.dnd.*;
 import test.java.awt.regtesthelpers.Util;
 
-
-public class Button2DragTest extends Applet {
+/**
+ * @test
+ * @bug 4955110
+ * @summary tests that DragSourceDragEvent.getDropAction() accords to its new
+ *          spec (does not depend on the user drop action)
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/othervm Button2DragTest
+ * @author Alexander.Gerasimov area=dnd
+ */
+public final class Button2DragTest {
 
     private volatile boolean dropSuccess;
 
-    private Frame frame;
+    private static Frame frame;
 
+    public static void main(final String[] args) {
+        Button2DragTest test = new Button2DragTest();
+        try {
+            test.run();
+        } finally {
+            if (frame != null) {
+                frame.dispose();
+            }
+        }
+    }
 
-    public void init() {
-        // Set up the environment -- set the layout manager, add
-        // buttons, etc.
-        setLayout(new BorderLayout());
-
+    public void run() {
         frame = new Frame();
 
         final DragSourceListener dragSourceListener = new DragSourceAdapter() {
@@ -84,20 +91,13 @@
             }
         };
         new DropTarget(frame, dropTargetListener);
-    }
-
-
-    public void start() {
-        //Get things going.  Request focus, set size, et cetera
-        setSize(200,200);
-        setVisible(true);
-        validate();
 
         //What would normally go into main() will probably go here.
         //Use System.out.println for diagnostic messages that you want
         //to read after the test is done.
-
+        frame.setUndecorated(true);
         frame.setBounds(100, 100, 200, 200);
+        frame.setLocationRelativeTo(null);
         frame.setVisible(true);
 
         Robot robot = Util.createRobot();
diff --git a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java
index 92dcc21..11cd886 100644
--- a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java
+++ b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,13 +44,9 @@
                 = {
                     "This test is for verifying Alt-Gr modifier of an event.",
                     "Windows :-",
-                    "1. Please check if Alt-Gr key is present on keyboard.",
-                    "2. If present, press the Alt-Gr key and perform",
-                    "   mouse click on the TestWindow.",
-                    "3. If Alt-Gr key is not present, press Ctrl+Alt keys &",
-                    "   perform mouse click on the TestWindow.",
-                    "4. Test will exit by itself with appropriate result.",
-                    "",
+                    "1. Click Pass.",
+                    "2. Alt-Gr modifier is tested under Robot tests.",
+                    " ",
                     "Linux :-",
                     "1. Please check if Alt-Gr key is present on keyboard.",
                     "2. If present, press the Alt-Gr key and perform",
@@ -63,10 +59,11 @@
                     "6. Press Right Alt Key & perform mouse click on the",
                     "   TestWindow",
                     "7. Test will exit by itself with appropriate result.",
-                    "",
+                    " ",
                     "Mac :-",
-                    "   Mac fix is under progress, & will be fixed soon.",
-                    "   Please click Fail"
+                    "1. Press Right Option key on the keyboard and mouse click",
+                    "   on the TestWindow",
+                    "3. Test will exit by itself with appropriate result.",
                 };
 
         Sysout.createDialog();
@@ -77,7 +74,7 @@
     public static void initTestWindow() {
         mainFrame = new Frame();
         mainFrame.setTitle("TestWindow");
-        mainFrame.setSize(300, 200);
+        mainFrame.setBounds(700, 10, 300, 300);
         mainFrame.addMouseListener(new MouseAdapter() {
             @Override
             public void mousePressed(MouseEvent e) {
diff --git a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html b/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html
deleted file mode 100644
index 9973c03..0000000
--- a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
- Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- 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.
--->
-
-<html>
-<!--  
-  @test
-  @bug 6365992 6379599
-  @summary REG: Showing and disposing a native print dialog makes the main frame inactive, Win32
-  @author Dmitry.Cherepanov@SUN.COM area=awt.printdialog
-  @run applet/manual=yesno RestoreActiveWindowTest.html
-  -->
-<head>
-<title>RestoreActiveWindowTest</title>
-</head>
-<body>
-
-<h1>RestoreActiveWindowTest<br>Bug ID: 6365992</h1>
-
-<p> See the dialog box (usually in upper left corner) for instructions</p>
-
-<APPLET CODE="RestoreActiveWindowTest.class" WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
diff --git a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java b/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java
index 66e4148..8d29dbb 100644
--- a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java
+++ b/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,210 +22,194 @@
  */
 
 /*
-  test
-  @bug 6365992 6379599
-  @summary REG: Showing and disposing a native print dialog makes the main frame inactive, Win32
-  @author Dmitry.Cherepanov@SUN.COM area=awt.printdialog
-  @run applet/manual=yesno RestoreActiveWindowTest.html
-*/
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.print.*;
-import javax.print.attribute.*;
-
-public class RestoreActiveWindowTest extends Applet
-{
-    Button showBtn1 = new Button("show a native print dialog");
-    Button showBtn2 = new Button("show a native page dialog");
-
-    public void init()
-    {
-        showBtn1.addActionListener(new ActionListener(){
-                public void actionPerformed(ActionEvent ae) {
-                    PrinterJob.getPrinterJob().printDialog();
-                }
-            });
-        showBtn2.addActionListener(new ActionListener(){
-                public void actionPerformed(ActionEvent ae){
-                    PrinterJob.getPrinterJob().pageDialog(new PageFormat());
-                }
-            });
-
-        add(showBtn1);
-        add(showBtn2);
-
-        String[] instructions = {
-            "1.1) Click on 'show a native print dialog'. A native print dialog will come up.",
-            "1.2) Click on the 'close'(X) button. The dialog will be closed.",
-            "1.3) After the dialog closing another window should become the active window.",
-            "1.4) If there no any active window then the test failed.",
-            "2.1) Click on 'show a native page dialog'. A native page dialog will come up.",
-            "2.2) Click on the 'close'(X) button. The dialog will be closed.",
-            "2.3) After the dialog closing another window should become the active window.",
-            "2.4) If there no any active window then the test failed.",
-            "3) Test Passed."
-        };
-
-        Sysout.createDialogWithInstructions( instructions );
-
-    }//End  init()
-
-   public void start ()
-    {
-      //Get things going.  Request focus, set size, et cetera
-      setSize (200,200);
-      show();
-
-    }// start()
-
-    //The rest of this class is the actions which perform the test...
-
-    //Use Sysout.println to communicate with the user NOT System.out!!
-    //Sysout.println ("Something Happened!");
-
-}// class ManualYesNoTest
-
-/* Place other classes related to the test after this line */
-
-
-
-
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
-  chunk of code whose purpose is to make user
-  interaction uniform, and thereby make it simpler
-  to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
-  for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
-  WithInstructions method.  Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
-  with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
-  as standalone.
+ * @test
+ * @bug 6365992 6379599 8137137
+ * @summary REG: Showing and disposing a native print dialog makes the main
+ *  frame inactive, Win32
+ * @run main/manual RestoreActiveWindowTest
  */
+import java.awt.Frame;
+import java.awt.Button;
+import java.awt.GridBagLayout;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.GridLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.print.PrinterJob;
+import java.awt.print.PageFormat;
 
-class Sysout
-{
-    private static TestDialog dialog;
+public class RestoreActiveWindowTest implements ActionListener {
 
-    public static void createDialogWithInstructions( String[] instructions )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        dialog.printInstructions( instructions );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
+    private static Frame mainFrame;
+    private static Button printDialogButton;
+    private static Button pageDialogButton;
+    private static Frame instructionFrame;
+    private static GridBagLayout layout;
+    private static Panel mainControlPanel;
+    private static Panel resultButtonPanel;
+    private static TextArea instructionTextArea;
+    private static Button passButton;
+    private static Button failButton;
+    private static Thread mainThread = null;
+    private static boolean testPassed = false;
+    private static boolean isInterrupted = false;
+    private static final int testTimeOut = 300000;
+    private static String testFailMessage;
+
+    public void createAndShowGUI() {
+        mainFrame = new Frame("Test");
+        mainFrame.setSize(200, 200);
+        mainFrame.setLocationRelativeTo(null);
+        mainFrame.setLayout(new GridLayout(2, 1));
+
+        printDialogButton = new Button("show a native print dialog");
+        pageDialogButton = new Button("show a native page dialog");
+        printDialogButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                PrinterJob.getPrinterJob().printDialog();
+                setButtonEnable(true);
+                testFailMessage = "Print dialog test failed.";
+            }
+        });
+        pageDialogButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                PrinterJob.getPrinterJob().pageDialog(new PageFormat());
+                setButtonEnable(true);
+                testFailMessage = "Page dialog test failed.";
+            }
+        });
+
+        mainFrame.add(printDialogButton);
+        mainFrame.add(pageDialogButton);
+        mainFrame.setVisible(true);
+
+       mainFrame.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent we) {
+                cleanUp();
+                throw new RuntimeException("User has closed the test window "
+                        + "without clicking Pass or Fail.");
+            }
+        });
     }
 
-    public static void createDialog( )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        String[] defInstr = { "Instructions will appear here. ", "" } ;
-        dialog.printInstructions( defInstr );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
+    private void createInstructionUI() {
+        instructionFrame = new Frame("Native Print Dialog and Page Dialog");
+        layout = new GridBagLayout();
+        mainControlPanel = new Panel(layout);
+        resultButtonPanel = new Panel(layout);
+
+        GridBagConstraints gbc = new GridBagConstraints();
+        String instructions
+                = "\nINSTRUCTIONS:\n"
+                + "\n   1. Click on the 'show a native print dialog' button. A "
+                + "native print dialog will come up."
+                + "\n   2. Click on the 'Cancel' button on Mac OS X or "
+                + "'close'(X) on other paltforms. Dialog will be closed."
+                + "\n   3. After the dialog is closed another window should "
+                + "become the active window."
+                + "\n   4. If there no any active window then the test has "
+                + "failed. Click on 'Fail' Button."
+                + "\n   5. Click on the 'show a native page dialog' button. A "
+                + "native page dialog will come up."
+                + "\n   6. Click on the 'Cancel' button on Mac OS X or "
+                + "'close'(X) on other paltforms. Dialog will be closed."
+                + "\n   7. After the dialog is closed another window should "
+                + "become the active window."
+                + "\n   8. If there no any active window then the test has "
+                + "failed. Click on 'Fail' Button."
+                + "\n   9. Test Passed. Click on 'Pass' Button.";
+
+        instructionTextArea = new TextArea(13, 80);
+        instructionTextArea.setText(instructions);
+        instructionTextArea.setEnabled(false);
+        instructionTextArea.setBackground(Color.white);
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        gbc.weightx = 0.5;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(instructionTextArea, gbc);
+
+        passButton = new Button("Pass");
+        passButton.setName("Pass");
+        passButton.addActionListener((ActionListener) this);
+
+        failButton = new Button("Fail");
+        failButton.setName("Fail");
+        failButton.addActionListener((ActionListener) this);
+
+        setButtonEnable(false);
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        resultButtonPanel.add(passButton, gbc);
+        gbc.gridx = 1;
+        gbc.gridy = 0;
+        resultButtonPanel.add(failButton, gbc);
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        mainControlPanel.add(resultButtonPanel, gbc);
+
+        instructionFrame.add(mainControlPanel);
+        instructionFrame.pack();
+        instructionFrame.setVisible(true);
     }
 
-
-    public static void printInstructions( String[] instructions )
-    {
-        dialog.printInstructions( instructions );
+    @Override
+    public void actionPerformed(ActionEvent ae) {
+        if (ae.getSource() instanceof Button) {
+            Button btn = (Button) ae.getSource();
+            switch (btn.getName()) {
+                case "Pass":
+                    testPassed = true;
+                    isInterrupted = true;
+                    mainThread.interrupt();
+                    break;
+                case "Fail":
+                    testPassed = false;
+                    isInterrupted = true;
+                    mainThread.interrupt();
+                    break;
+            }
+        }
     }
 
-
-    public static void println( String messageIn )
-    {
-        dialog.displayMessage( messageIn );
+    private static void setButtonEnable(boolean status) {
+        passButton.setEnabled(status);
+        failButton.setEnabled(status);
     }
 
-}// Sysout  class
-
-/**
-  This is part of the standard test machinery.  It provides a place for the
-   test instructions to be displayed, and a place for interactive messages
-   to the user to be displayed.
-  To have the test instructions displayed, see Sysout.
-  To have a message to the user be displayed, see Sysout.
-  Do not call anything in this dialog directly.
-  */
-class TestDialog extends Dialog
-{
-
-    TextArea instructionsText;
-    TextArea messageText;
-    int maxStringLength = 80;
-
-    //DO NOT call this directly, go through Sysout
-    public TestDialog( Frame frame, String name )
-    {
-        super( frame, name );
-        int scrollBoth = TextArea.SCROLLBARS_BOTH;
-        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
-        add( "North", instructionsText );
-
-        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
-        add("Center", messageText);
-
-        pack();
-
-        setVisible(true);
-    }// TestDialog()
-
-    //DO NOT call this directly, go through Sysout
-    public void printInstructions( String[] instructions )
-    {
-        //Clear out any current instructions
-        instructionsText.setText( "" );
-
-        //Go down array of instruction strings
-
-        String printStr, remainingStr;
-        for( int i=0; i < instructions.length; i++ )
-        {
-            //chop up each into pieces maxSringLength long
-            remainingStr = instructions[ i ];
-            while( remainingStr.length() > 0 )
-            {
-                //if longer than max then chop off first max chars to print
-                if( remainingStr.length() >= maxStringLength )
-                {
-                    //Try to chop on a word boundary
-                    int posOfSpace = remainingStr.
-                        lastIndexOf( ' ', maxStringLength - 1 );
-
-                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
-                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
-                    remainingStr = remainingStr.substring( posOfSpace + 1 );
-                }
-                //else just print
-                else
-                {
-                    printStr = remainingStr;
-                    remainingStr = "";
-                }
-
-                instructionsText.append( printStr + "\n" );
-
-            }// while
-
-        }// for
-
-    }//printInstructions()
-
-    //DO NOT call this directly, go through Sysout
-    public void displayMessage( String messageIn )
-    {
-        messageText.append( messageIn + "\n" );
-        System.out.println(messageIn);
+    private static void cleanUp() {
+        mainFrame.dispose();
+        instructionFrame.dispose();
     }
 
-}// TestDialog  class
+    public static void main(String args[]) {
+        RestoreActiveWindowTest printDialogs = new RestoreActiveWindowTest();
+        printDialogs.createInstructionUI();
+        printDialogs.createAndShowGUI();
+
+        mainThread = Thread.currentThread();
+        try {
+            mainThread.sleep(testTimeOut);
+        } catch (InterruptedException ex) {
+            if (!testPassed) {
+                throw new RuntimeException(testFailMessage);
+            }
+        } finally {
+            cleanUp();
+        }
+
+        if (!isInterrupted) {
+            throw new RuntimeException("Test Timed out after "
+                    + testTimeOut / 1000 + " seconds");
+        }
+    }
+}
diff --git a/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java
index a8ec7d4..b5fc366 100644
--- a/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java
+++ b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java
@@ -33,7 +33,7 @@
 
 /**
  * @test
- * @bug 8132973 8132732 8155013
+ * @bug 8132973 8132732 8155013 8154958
  * @summary Some check for BeanProperty annotation
  * @author a.stepanov
  * @run main AnonymousClassBeanPropertyTest
@@ -62,6 +62,10 @@
 
     // ---------- test cases (interfaces) ----------
 
+    public interface IPublic {
+        double getX();
+    }
+
     private interface IGet {
         double getX();
     }
@@ -113,6 +117,10 @@
         void setX(double a[]);
     }
 
+    private interface IIs {
+        boolean isX();
+    }
+
 
     // ---------- checks ----------
 
@@ -124,7 +132,7 @@
         return ok;
     }
 
-    private static boolean checkInfo(Class<?> c, String what) {
+    private static boolean checkInfo(Class<?> c, String what, boolean checkVals) {
 
         BeanInfo i;
         try { i = Introspector.getBeanInfo(c, Object.class); }
@@ -154,6 +162,8 @@
         ok &= check("visualUpdate",
             (boolean) d.getValue("visualUpdate"), UPDATE);
 
+        if (!checkVals) { return ok; }
+
         Object vals[] = (Object[]) d.getValue("enumerationValues");
         if (vals == null) {
             System.out.println("null enumerationValues");
@@ -210,8 +220,10 @@
             (boolean) d.getValue("visualUpdate"), !UPDATE);
 
         Object vals[] = (Object[]) d.getValue("enumerationValues");
-        if (vals != null || vals.length > 0) {
-            System.out.println("non-empty enumerationValues");
+        if (vals != null && vals.length > 0) {
+            System.out.println("non-empty enumerationValues:");
+            for (Object v: vals) { System.out.print(v.toString()); }
+            System.out.println();
             return false;
         }
 
@@ -228,6 +240,31 @@
 
         //----------------------------------------------------------------------
 
+        // TODO: please uncomment/update after 8154958 fix
+        /*
+        IPublic testPublic = new IPublic() {
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX() { return X; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testPublic.getClass(), "IPublic", true);
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        //----------------------------------------------------------------------
+
         IGet testGet = new IGet() {
             @BeanProperty(
                 description  = DESCRIPTION,
@@ -244,7 +281,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGet.getClass(), "IGet");
+        ok = checkInfo(testGet.getClass(), "IGet", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -269,7 +306,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSet.getClass(), "ISet");
+        ok = checkInfo(testSet.getClass(), "ISet", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -294,7 +331,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex");
+        ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -319,7 +356,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex");
+        ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -346,7 +383,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetArray.getClass(), "IGetArray");
+        ok = checkInfo(testGetArray.getClass(), "IGetArray", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -374,7 +411,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetArray.getClass(), "ISetArray");
+        ok = checkInfo(testSetArray.getClass(), "ISetArray", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -402,7 +439,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1");
+        ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -429,7 +466,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2");
+        ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -465,11 +502,11 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3");
+        ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(testGetBoth_3.getClass(), "IGetBoth-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -495,7 +532,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1");
+        ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -522,7 +559,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2");
+        ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -558,11 +595,11 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3");
+        ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(testSetBoth_3.getClass(), "ISetBoth-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -588,7 +625,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1");
+        ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -614,7 +651,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2");
+        ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -649,11 +686,11 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3");
+        ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(testGetSet_3.getClass(), "IGetSet-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -679,7 +716,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1");
+        ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -705,7 +742,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2");
+        ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -744,12 +781,12 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
+        ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(
             testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -781,7 +818,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1");
+        ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -813,7 +850,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2");
+        ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -853,14 +890,135 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3");
+        ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(
             testGetSetBoth_3.getClass(), "IGetSetBoth-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
+        //----------------------------------------------------------------------
+
+        IIs testIs_1 = new IIs() {
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            @Override
+            public boolean isX() { return false; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_1.getClass(), "IIs-1", false);
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+
+        IIs testIs_2 = new IIs() {
+
+            private boolean b;
+
+            @Override
+            public boolean isX() { return b; }
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            public void setX(boolean v) { b = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_2.getClass(), "IIs-2", false);
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+
+        IIs testIs_3 = new IIs() {
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            @Override
+            public boolean isX() { return false; }
+
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            public boolean getX() { return false; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_3.getClass(), "IIs-3", false);
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(testIs_3.getClass(), "IIs-3");
+        System.out.println("OK = " + ok2);
+        passed = passed && (ok || ok2);
+
+        // TODO: please uncomment/update after 8132973 fix
+        /*
+        IIs testIs_4 = new IIs() {
+
+            private boolean b;
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            @Override
+            public boolean isX() { return b; }
+
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            public void setX(boolean v) { b = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_4.getClass(), "IIs-4", false);
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(testIs_4.getClass(), "IIs-4");
+        System.out.println("OK = " + ok2);
+        passed = passed && (ok || ok2);
+        */
+
+
+        //----------------------------------------------------------------------
+
+
         if (!passed) { throw new RuntimeException("test failed"); }
         System.out.println("\ntest passed");
     }
diff --git a/jdk/test/java/beans/Introspector/BeanPropertyTest.java b/jdk/test/java/beans/Introspector/BeanPropertyTest.java
index 6f95707..5e84aaa 100644
--- a/jdk/test/java/beans/Introspector/BeanPropertyTest.java
+++ b/jdk/test/java/beans/Introspector/BeanPropertyTest.java
@@ -33,7 +33,7 @@
 
 /**
  * @test
- * @bug 8132703 8132163 8132732 8132973 8154756 8132888
+ * @bug 8132703 8132163 8132732 8132973 8154756 8132888 8155103
  * @summary Some check for BeanProperty annotation
  * @author a.stepanov
  * @run main BeanPropertyTest
@@ -853,6 +853,64 @@
         public void removePropertyChangeListener(PropertyChangeListener l) {}
     }
 
+    // JDK-8155103
+    public static enum E {
+
+        ONE,
+        TWO {
+            @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+            public void setX(int v) {}
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int v) {}
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+
+    }
+
+    private static enum EB {
+
+        TRUE(true), FALSE(false);
+
+        private boolean b;
+        private EB(boolean v) { b = v; }
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public boolean isTrue() { return true; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+
+    }
+
 
     // ---------- checks ----------
 
@@ -953,7 +1011,7 @@
     }
 
     private static boolean ignoreVals(Class<?> c) {
-        return (c.equals(Self.class) || c.equals(SelfArr.class));
+        return (c.equals(Self.class) || c.equals(SelfArr.class)) || c.equals(EB.class);
     }
 
 
@@ -1003,6 +1061,29 @@
             passed = passed && ok;
         }
 
+        // enums
+
+        Class<?> enumCases[] = {
+
+            // TODO: uncomment/update after 8155103 fix
+            //E.class, E.TWO.getClass(), EB.class
+        };
+
+        int ne = 1;
+        for (Class<?> c: enumCases) {
+
+            System.out.println("\nEnum-" + ne + ":");
+            ne++;
+
+            BeanInfo i;
+            try { i = Introspector.getBeanInfo(c, Object.class); }
+            catch (IntrospectionException e) { throw new RuntimeException(e); }
+            boolean ok = checkInfo(i, !ignoreVals(c));
+            System.out.println(ok ? "OK" : "NOK");
+            passed = passed && ok;
+        }
+
+
         if (!passed) { throw new RuntimeException("test failed"); }
         System.out.println("\ntest passed");
     }
diff --git a/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java b/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java
new file mode 100644
index 0000000..e42fa62
--- /dev/null
+++ b/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java
@@ -0,0 +1,1281 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.beans.BeanInfo;
+import java.beans.BeanProperty;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+
+import java.util.Arrays;
+
+
+/**
+ * @test
+ * @bug 8132565 8155013
+ * @summary Some inheritance check for BeanProperty annotation
+ * @author a.stepanov
+ * @run main InheritanceBeanPropertyTest
+ */
+
+
+public class InheritanceBeanPropertyTest {
+
+    private final static String  DESCRIPTION = "TEST";
+    private final static boolean BOUND       = true;
+    private final static boolean EXPERT      = false;
+    private final static boolean HIDDEN      = true;
+    private final static boolean PREFERRED   = false;
+    private final static boolean REQUIRED    = true;
+    private final static boolean UPDATE      = false;
+
+    private final static double X = java.lang.Math.PI;
+
+    private final static String
+        V_NAME  = "java.lang.Math.PI",
+        V_SHORT = "PI",
+        V = Double.toString(X);
+
+    private final static String DESCRIPTION_2 = "XYZ";
+
+
+    // ---------- test cases ----------
+
+    public static class BaseGet {
+
+        private final static String TESTCASE = "base getter";
+
+        public double getX() { return X; }
+    }
+
+    public static class OverloadGet extends BaseGet {
+
+        private final static String TESTCASE = "overload getter";
+
+        private final double x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX(int i) { return x[i]; } // indexed
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BaseSet {
+
+        private final static String TESTCASE = "base setter";
+
+        double u;
+        public void setX(double v) { u = v; }
+    }
+
+    public static class OverloadSet extends BaseSet {
+
+        private final static String TESTCASE = "overload setter";
+
+        private final double x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int i, double v) { x[i] = v; } // indexed
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BaseIGet {
+
+        protected final double x[] = {X, X, X};
+        public double[] getX() { return x; }
+    }
+
+    public static class OverloadIGet extends BaseIGet {
+
+        private final static String TESTCASE = "overload indexed getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX(int i) { return x[i]; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BaseISet {
+
+        protected double x[] = {X, X, X};
+        public void setX(double a[]) { x = Arrays.copyOf(a, a.length); }
+    }
+
+    public static class OverloadISet extends BaseISet {
+
+        private final static String TESTCASE = "overload indexed setter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int i, double v) { x[i] = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BoolGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean getX() { return false; }
+    }
+
+    public static class BoolGetIs extends BoolGet {
+
+        private final static String TESTCASE = "base boolean getter + is";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public boolean isX() { return false; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+    // ----------
+
+    public static class BoolIs {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean isX() { return false; }
+    }
+
+    public static class BoolIsGet extends BoolIs {
+
+        private final static String TESTCASE = "base is + boolean getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public boolean getX() { return false; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class AnnotatedGet {
+
+        private final static String TESTCASE = "annotated super getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX() { return 0.; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class OverrideAnnotatedGet extends AnnotatedGet {
+
+        private final static String TESTCASE = "override annotated getter";
+
+        @Override
+        public double getX() { return X; }
+    }
+
+    // ----------
+
+    public static class AnnotatedIs {
+
+        private final static String TESTCASE = "annotated super is";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public boolean isX() { return false; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class OverrideAnnotatedIs extends AnnotatedIs {
+
+        private final static String TESTCASE = "override annotated is";
+
+        @Override
+        public boolean isX() { return false; }
+    }
+
+    // ----------
+
+    public static class AnnotatedSet {
+
+        private final static String TESTCASE = "annotated super set";
+
+        protected double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(double v) { x = -v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class OverrideAnnotatedSet extends AnnotatedSet {
+
+        private final static String TESTCASE = "override annotated setter";
+
+        @Override
+        public void setX(double v) { x = v; }
+    }
+
+    // ----------
+
+    public static class AnnotatedGet2 {
+
+        protected double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public double getX() { return 0.; }
+    }
+
+    public static class OverrideAnnotatedGet2 extends AnnotatedGet2 {
+
+        private final static String TESTCASE = "override annotated getter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class AnnotatedGet2Ext extends AnnotatedGet2 {
+
+        private final static String TESTCASE = "extend annotated getter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class AnnotatedIs2 {
+
+        protected boolean b = false;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean isX() { return false; }
+    }
+
+    public static class OverrideAnnotatedIs2 extends AnnotatedIs2 {
+
+        private final static String TESTCASE = "override annotated is - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        @Override
+        public boolean isX() { return b; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class AnnotatedIs2Ext extends AnnotatedIs2 {
+
+        private final static String TESTCASE = "extend annotated is - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public void setX(boolean v) { b = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class AnnotatedSet2 {
+
+        protected double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public void setX(double v) { x = -v; }
+    }
+
+    public static class OverrideAnnotatedSet2 extends AnnotatedSet2 {
+
+        private final static String TESTCASE = "override annotated setter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class AnnotatedSet2Ext extends AnnotatedSet2 {
+
+        private final static String TESTCASE = "extend annotated setter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public abstract static class AbstractGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract double getX();
+    }
+
+    public static class OverrideAbstractGet extends AbstractGet {
+
+        private final static String TESTCASE =
+            "override abstract annotated getter";
+
+        @Override
+        public double getX() { return X; }
+    }
+
+    public static class OverrideAbstractGet2 extends AbstractGet {
+
+        private final static String TESTCASE =
+            "override abstract annotated getter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class AbstractGetExt extends AbstractGet {
+
+        private final static String TESTCASE =
+            "extend abstract annotated getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract void setX(double v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public abstract static class AbstractIs {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract boolean isX();
+    }
+
+    public static class OverrideAbstractIs extends AbstractIs {
+
+        private final static String TESTCASE =
+            "override abstract annotated is";
+
+        @Override
+        public boolean isX() { return true; }
+    }
+
+    public static class OverrideAbstractIs2 extends AbstractIs {
+
+        private final static String TESTCASE =
+            "override abstract annotated is - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        @Override
+        public boolean isX() { return true; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+
+    public abstract static class AbstractIsExt extends AbstractIs {
+
+        private final static String TESTCASE =
+            "extend abstract annotated is";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public abstract boolean getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public abstract static class AbstractSet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract void setX(double v);
+    }
+
+    public static class OverrideAbstractSet extends AbstractSet {
+
+        private final static String TESTCASE =
+            "override abstract annotated setter";
+
+        private double x;
+
+        @Override
+        public void setX(double v) { x = v; }
+    }
+
+    public static class OverrideAbstractSet2 extends AbstractSet {
+
+        private final static String TESTCASE =
+            "override abstract annotated setter - 2";
+
+        private double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class AbstractSetExt extends AbstractSet {
+
+        private final static String TESTCASE =
+            "extend abstract annotated setter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract void setX(double v[]);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static abstract class AbstractGet2 {
+
+        private final static String TESTCASE = "abstract super getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract double getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static abstract class AbstractGet2Ext extends AbstractGet2 {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract void setX(double a[]);
+    }
+
+    // ----------
+
+    public static interface IGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        double getX();
+    }
+
+    public static class IGetImpl implements IGet {
+
+        private final static String TESTCASE = "implement getter interface";
+
+        @Override
+        public double getX() { return X; }
+    }
+
+    public static class IGetImpl2 implements IGet {
+
+        private final static String TESTCASE = "implement getter interface - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class IGetImpl3 implements IGet {
+
+        private final static String TESTCASE = "implement getter interface - 3";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract void setX(double v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface IIs {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean isX();
+    }
+
+    public static class IIsImpl implements IIs {
+
+        private final static String TESTCASE = "implement is interface";
+
+        @Override
+        public boolean isX() { return true; }
+    }
+
+    public static class IIsImpl2 implements IIs {
+
+        private final static String TESTCASE = "implement is interface - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        @Override
+        public boolean isX() { return true; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class IIsImpl3 implements IIs {
+
+        private final static String TESTCASE = "implement is interface - 3";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public abstract void setX(boolean v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface ISet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public void setX(double v);
+    }
+
+    public static class ISetImpl implements ISet {
+
+        private final static String TESTCASE = "implement getter interface";
+
+        private double x;
+
+        @Override
+        public void setX(double v) { x = v; }
+    }
+
+    public static class ISetImpl2 implements ISet {
+
+        private final static String TESTCASE = "implement getter interface - 2";
+
+        private double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class ISetImpl3 implements ISet {
+
+        private final static String TESTCASE = "implement getter interface - 3";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract double getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface ISet2 {
+
+        final static String TESTCASE = "super interface - setter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(double v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l);
+        public void removePropertyChangeListener(PropertyChangeListener l);
+    }
+
+    public static class ISet2Impl implements ISet2 {
+
+        private double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        @Override
+        public void setX(double v) { x = v; }
+
+        @Override
+        public void addPropertyChangeListener(PropertyChangeListener l) {}
+        @Override
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface IGet2 {
+
+        final static String TESTCASE = "super interface - indexed getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double[] getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l);
+        public void removePropertyChangeListener(PropertyChangeListener l);
+    }
+
+    public static class IGet2Impl implements IGet2 {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        @Override
+        public double[] getX() { return new double[]{X, X}; }
+
+        @Override
+        public void addPropertyChangeListener(PropertyChangeListener l) {}
+        @Override
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class ProtectedGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        protected double getX() { return 0.; }
+    }
+
+    public static class OverrideProtectedGet extends ProtectedGet {
+
+        final static String TESTCASE = "override protected getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l) {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    // static getter - see also JDK-8154938
+    public static class StaticGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public static double getProp() { return 0.; }
+    }
+
+    public static class HideStaticGet extends StaticGet {
+
+        final static String TESTCASE = "hide static getter";
+
+        public double getX() { return X; } // add to get the "default" info
+        public static double getProp() { return X; }
+    }
+
+    // TODO: if 8154938 is considered to be a real issue,
+    // create one more test case "HideStaticGet2 extends StaticGet" with an
+    // annotated getter and check the correctness of the corresponding bean info
+
+    // ---------- checks ----------
+
+    private static boolean check(String what, boolean v, boolean ref) {
+
+        boolean ok = (v == ref);
+        if (!ok) { System.out.println(
+            "invalid " + what + ": " + v + ", expected: " + ref); }
+        return ok;
+    }
+
+    private static boolean checkInfo(BeanInfo i, boolean ignoreValsCheck) {
+
+        System.out.println("checking info...");
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals(DESCRIPTION);
+        if (!ok) { System.out.println("invalid description: " + descr +
+                ", expected: " + DESCRIPTION); }
+
+        ok &= check("isBound",  d.isBound(),  BOUND);
+        ok &= check("isExpert", d.isExpert(), EXPERT);
+        ok &= check("isHidden", d.isHidden(), HIDDEN);
+        ok &= check("isPreferred", d.isPreferred(), PREFERRED);
+        ok &= check("required", (boolean) d.getValue("required"), REQUIRED);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), UPDATE);
+
+        if (ignoreValsCheck) { return ok; }
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals == null) {
+            System.out.println("null enumerationValues");
+            return false;
+        }
+
+        boolean okVals = (
+            (vals.length == 3) &&
+             vals[0].toString().equals(V_SHORT) &&
+             vals[1].toString().equals(V)       &&
+             vals[2].toString().equals(V_NAME));
+
+        if (!okVals) { System.out.println("invalid enumerationValues"); }
+
+        return (ok && okVals);
+    }
+
+    private static boolean checkDefault(BeanInfo i) {
+
+        System.out.println("checking default info...");
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals("x");
+        if (!ok) { System.out.println("invalid description: " + descr +
+                ", expected: x"); }
+
+        ok &= check("isBound",  d.isBound(),  false);
+        ok &= check("isExpert", d.isExpert(), false);
+        ok &= check("isHidden", d.isHidden(), false);
+        ok &= check("isPreferred", d.isPreferred(), false);
+        ok &= check("required", (boolean) d.getValue("required"), false);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), false);
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals != null && vals.length > 0) {
+            System.out.println("non-empty enumerationValues");
+            ok = false;
+        }
+
+        return ok;
+    }
+
+    // do not check enumerationValues for these classes
+    private static boolean ignoreVals(Class<?> c) {
+        return (
+            c.equals(BoolGetIs.class)            ||
+            c.equals(BoolIsGet.class)            ||
+            c.equals(AnnotatedIs.class)          ||
+            c.equals(OverrideAnnotatedIs2.class) ||
+            c.equals(AnnotatedIs2Ext.class)      ||
+            c.equals(OverrideAbstractIs.class)   ||
+            c.equals(OverrideAbstractIs2.class)  ||
+            c.equals(AbstractIsExt.class)        ||
+            c.equals(OverrideAbstractIs.class)   ||
+            c.equals(IIsImpl.class)              ||
+            c.equals(IIsImpl2.class)             ||
+            c.equals(IIsImpl3.class)
+        );
+    }
+
+    // default property descriptor data are expected for these classes
+    private static boolean isDefault(Class<?> c) {
+        return (
+            c.equals(OverrideAnnotatedGet.class) ||
+            c.equals(OverrideAnnotatedIs.class ) ||
+            c.equals(OverrideAnnotatedSet.class) ||
+            c.equals(OverrideAbstractGet.class)  ||
+            c.equals(OverrideAbstractIs.class)   ||
+            c.equals(OverrideAbstractSet.class)  ||
+            c.equals(IGetImpl.class)             ||
+            c.equals(IIsImpl.class)              ||
+            c.equals(ISetImpl.class)             ||
+            c.equals(BaseGet.class)              ||
+            c.equals(BaseSet.class)              ||
+            c.equals(HideStaticGet.class)
+        );
+    }
+
+
+    // ---------- run test ----------
+
+    public static void main(String[] args) throws Exception {
+
+        Class<?>
+            ic1 = ISet2Impl.class.getInterfaces()[0],
+            ic2 = IGet2Impl.class.getInterfaces()[0];
+
+        Class<?> cases[] = {
+
+            OverloadGet.class,
+            OverloadGet.class.getSuperclass(),
+            OverloadSet.class,
+            OverloadSet.class.getSuperclass(),
+            OverloadIGet.class,
+            OverloadISet.class,
+
+            // TODO: uncomment/update after 8132565 fix
+            //BoolGetIs.class,
+            //BoolIsGet.class,
+            //OverrideAnnotatedGet.class,
+            //OverrideAnnotatedIs.class,
+            //OverrideAnnotatedSet.class,
+            //OverrideAnnotatedGet2.class,
+            //AnnotatedGet2Ext.class,
+            //OverrideAnnotatedIs2.class
+            //AnnotatedIs2Ext.class,
+            //OverrideAnnotatedSet2.class,
+            //AnnotatedSet2Ext.class,
+
+            OverrideAnnotatedGet.class.getSuperclass(),
+            OverrideAnnotatedIs.class.getSuperclass(),
+            OverrideAnnotatedSet.class.getSuperclass(),
+
+            // TODO: uncomment/update after 8132565 fix
+            //OverrideAbstractGet.class,
+            //OverrideAbstractGet2.class,
+            //AbstractGetExt.class,
+            //OverrideAbstractIs.class,
+            //OverrideAbstractIs2.class,
+            //AbstractIsExt.class
+            //OverrideAbstractSet.class,
+            //OverrideAbstractSet2.class,
+            //AbstractSetExt.class,
+
+            AbstractGet2Ext.class.getSuperclass(),
+            IGetImpl.class,
+            IGetImpl2.class,
+            IGetImpl3.class,
+            IIsImpl.class,
+            IIsImpl2.class,
+            IIsImpl3.class,
+            ISetImpl.class,
+            ISetImpl2.class,
+            ISetImpl3.class,
+            ic1,
+            // ic2,  // TODO: uncomment/update after 8155013 fix
+            OverrideProtectedGet.class,
+            HideStaticGet.class
+        };
+
+        boolean passed = true;
+
+        for (Class<?> c: cases) {
+
+            java.lang.reflect.Field f = c.getDeclaredField("TESTCASE");
+            f.setAccessible(true);
+            String descr = f.get(c).toString();
+
+            System.out.println("\n" + c.getSimpleName() + " (" + descr + "):");
+            BeanInfo i;
+            try {
+                i = Introspector.getBeanInfo(c,
+                    (c.equals(ic1) || c.equals(ic2)) ? null : Object.class);
+            }
+            catch (IntrospectionException e) { throw new RuntimeException(e); }
+
+            boolean ok;
+
+            if (isDefault(c)) {
+                ok = checkDefault(i);
+            } else {
+                ok = checkInfo(i, ignoreVals(c));
+            }
+            System.out.println(ok ? "OK" : "NOK");
+            passed = passed && ok;
+        }
+
+        if (!passed) { throw new RuntimeException("test failed"); }
+        System.out.println("\ntest passed");
+    }
+}
diff --git a/jdk/test/java/beans/XMLEncoder/Test4625418.java b/jdk/test/java/beans/XMLEncoder/Test4625418.java
index 0f9203e..a8a23ac 100644
--- a/jdk/test/java/beans/XMLEncoder/Test4625418.java
+++ b/jdk/test/java/beans/XMLEncoder/Test4625418.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,332 +26,338 @@
  * @bug 4625418
  * @summary Tests XML <a href="http://download.java.net/jdk6/docs/technotes/guides/intl/encoding.doc.html">encoding</a>
  * @author Sergey Malenkov
- *
- * @run main Test4625418 ASCII
- * @run main Test4625418 Big5
- * ?run main Test4625418 Big5-HKSCS
- * ?run main Test4625418 Big5_HKSCS
- * @run main Test4625418 Big5_Solaris
- * ?run main Test4625418 Cp037
- * @run main Test4625418 Cp1006
- * ?run main Test4625418 Cp1025
- * -run main Test4625418 Cp1026
- * @run main Test4625418 Cp1046
- * @run main Test4625418 Cp1047
- * @run main Test4625418 Cp1097
- * @run main Test4625418 Cp1098
- * ?run main Test4625418 Cp1112
- * ?run main Test4625418 Cp1122
- * ?run main Test4625418 Cp1123
- * @run main Test4625418 Cp1124
- * ?run main Test4625418 Cp1140
- * ?run main Test4625418 Cp1141
- * ?run main Test4625418 Cp1142
- * ?run main Test4625418 Cp1143
- * ?run main Test4625418 Cp1144
- * ?run main Test4625418 Cp1145
- * ?run main Test4625418 Cp1146
- * ?run main Test4625418 Cp1147
- * ?run main Test4625418 Cp1148
- * ?run main Test4625418 Cp1149
- * @run main Test4625418 Cp1250
- * @run main Test4625418 Cp1251
- * @run main Test4625418 Cp1252
- * @run main Test4625418 Cp1253
- * @run main Test4625418 Cp1254
- * @run main Test4625418 Cp1255
- * @run main Test4625418 Cp1256
- * @run main Test4625418 Cp1257
- * @run main Test4625418 Cp1258
- * ?run main Test4625418 Cp1381
- * ?run main Test4625418 Cp1383
- * ?run main Test4625418 Cp273
- * ?run main Test4625418 Cp277
- * ?run main Test4625418 Cp278
- * ?run main Test4625418 Cp280
- * ?run main Test4625418 Cp284
- * ?run main Test4625418 Cp285
- * ?run main Test4625418 Cp297
- * ?run main Test4625418 Cp33722
- * ?run main Test4625418 Cp420
- * ?run main Test4625418 Cp424
- * @run main Test4625418 Cp437
- * ?run main Test4625418 Cp500
- * ?run main Test4625418 Cp50220
- * ?run main Test4625418 Cp50221
- * @run main Test4625418 Cp737
- * @run main Test4625418 Cp775
- * -run main Test4625418 Cp834
- * ?run main Test4625418 Cp838
- * @run main Test4625418 Cp850
- * @run main Test4625418 Cp852
- * @run main Test4625418 Cp855
- * @run main Test4625418 Cp856
- * @run main Test4625418 Cp857
- * @run main Test4625418 Cp858
- * @run main Test4625418 Cp860
- * @run main Test4625418 Cp861
- * @run main Test4625418 Cp862
- * @run main Test4625418 Cp863
- * @run main Test4625418 Cp864
- * @run main Test4625418 Cp865
- * @run main Test4625418 Cp866
- * @run main Test4625418 Cp868
- * @run main Test4625418 Cp869
- * ?run main Test4625418 Cp870
- * ?run main Test4625418 Cp871
- * @run main Test4625418 Cp874
- * ?run main Test4625418 Cp875
- * ?run main Test4625418 Cp918
- * @run main Test4625418 Cp921
- * @run main Test4625418 Cp922
- * -run main Test4625418 Cp930
- * @run main Test4625418 Cp933
- * ?run main Test4625418 Cp935
- * ?run main Test4625418 Cp937
- * ?run main Test4625418 Cp939
- * ?run main Test4625418 Cp942
- * ?run main Test4625418 Cp942C
- * @run main Test4625418 Cp943
- * ?run main Test4625418 Cp943C
- * @run main Test4625418 Cp948
- * @run main Test4625418 Cp949
- * ?run main Test4625418 Cp949C
- * @run main Test4625418 Cp950
- * @run main Test4625418 Cp964
- * ?run main Test4625418 Cp970
- * ?run main Test4625418 EUC-JP
- * @run main Test4625418 EUC-KR
- * @run main Test4625418 EUC_CN
- * ?run main Test4625418 EUC_JP
- * ?run main Test4625418 EUC_JP_LINUX
- * ?run main Test4625418 EUC_JP_Solaris
- * @run main Test4625418 EUC_KR
- * ?run main Test4625418 EUC_TW
- * @run main Test4625418 GB18030
- * @run main Test4625418 GB2312
- * @run main Test4625418 GBK
- * ?run main Test4625418 IBM-Thai
- * @run main Test4625418 IBM00858
- * ?run main Test4625418 IBM01140
- * ?run main Test4625418 IBM01141
- * ?run main Test4625418 IBM01142
- * ?run main Test4625418 IBM01143
- * ?run main Test4625418 IBM01144
- * ?run main Test4625418 IBM01145
- * ?run main Test4625418 IBM01146
- * ?run main Test4625418 IBM01147
- * ?run main Test4625418 IBM01148
- * ?run main Test4625418 IBM01149
- * ?run main Test4625418 IBM037
- * -run main Test4625418 IBM1026
- * @run main Test4625418 IBM1047
- * ?run main Test4625418 IBM273
- * ?run main Test4625418 IBM277
- * ?run main Test4625418 IBM278
- * ?run main Test4625418 IBM280
- * ?run main Test4625418 IBM284
- * ?run main Test4625418 IBM285
- * ?run main Test4625418 IBM297
- * ?run main Test4625418 IBM420
- * ?run main Test4625418 IBM424
- * @run main Test4625418 IBM437
- * ?run main Test4625418 IBM500
- * @run main Test4625418 IBM775
- * @run main Test4625418 IBM850
- * @run main Test4625418 IBM852
- * @run main Test4625418 IBM855
- * @run main Test4625418 IBM857
- * @run main Test4625418 IBM860
- * @run main Test4625418 IBM861
- * @run main Test4625418 IBM862
- * @run main Test4625418 IBM863
- * @run main Test4625418 IBM864
- * @run main Test4625418 IBM865
- * @run main Test4625418 IBM866
- * @run main Test4625418 IBM868
- * @run main Test4625418 IBM869
- * ?run main Test4625418 IBM870
- * ?run main Test4625418 IBM871
- * ?run main Test4625418 IBM918
- * ?run main Test4625418 ISCII91
- * -run main Test4625418 ISO-2022-CN
- * @run main Test4625418 ISO-2022-JP
- * @run main Test4625418 ISO-2022-KR
- * @run main Test4625418 ISO-8859-1
- * @run main Test4625418 ISO-8859-13
- * @run main Test4625418 ISO-8859-15
- * @run main Test4625418 ISO-8859-2
- * @run main Test4625418 ISO-8859-3
- * @run main Test4625418 ISO-8859-4
- * @run main Test4625418 ISO-8859-5
- * @run main Test4625418 ISO-8859-6
- * @run main Test4625418 ISO-8859-7
- * @run main Test4625418 ISO-8859-8
- * @run main Test4625418 ISO-8859-9
- * -run main Test4625418 ISO2022CN
- * @run main Test4625418 ISO2022JP
- * @run main Test4625418 ISO2022KR
- * -run main Test4625418 ISO2022_CN_CNS
- * -run main Test4625418 ISO2022_CN_GB
- * @run main Test4625418 ISO8859_1
- * @run main Test4625418 ISO8859_13
- * @run main Test4625418 ISO8859_15
- * @run main Test4625418 ISO8859_2
- * @run main Test4625418 ISO8859_3
- * @run main Test4625418 ISO8859_4
- * @run main Test4625418 ISO8859_5
- * @run main Test4625418 ISO8859_6
- * @run main Test4625418 ISO8859_7
- * @run main Test4625418 ISO8859_8
- * @run main Test4625418 ISO8859_9
- * -run main Test4625418 JISAutoDetect
- * ?run main Test4625418 JIS_X0201
- * -run main Test4625418 JIS_X0212-1990
- * @run main Test4625418 KOI8-R
- * @run main Test4625418 KOI8-U
- * @run main Test4625418 KOI8_R
- * @run main Test4625418 KOI8_U
- * @run main Test4625418 MS874
- * ?run main Test4625418 MS932
- * ?run main Test4625418 MS936
- * @run main Test4625418 MS949
- * @run main Test4625418 MS950
- * ?run main Test4625418 MS950_HKSCS
- * @run main Test4625418 MacArabic
- * @run main Test4625418 MacCentralEurope
- * @run main Test4625418 MacCroatian
- * @run main Test4625418 MacCyrillic
- * -run main Test4625418 MacDingbat
- * @run main Test4625418 MacGreek
- * @run main Test4625418 MacHebrew
- * @run main Test4625418 MacIceland
- * @run main Test4625418 MacRoman
- * @run main Test4625418 MacRomania
- * -run main Test4625418 MacSymbol
- * @run main Test4625418 MacThai
- * @run main Test4625418 MacTurkish
- * @run main Test4625418 MacUkraine
- * ?run main Test4625418 PCK
- * ?run main Test4625418 SJIS
- * ?run main Test4625418 Shift_JIS
- * @run main Test4625418 TIS-620
- * @run main Test4625418 TIS620
- * @run main Test4625418 US-ASCII
- * @run main Test4625418 UTF-16
- * @run main Test4625418 UTF-16BE
- * @run main Test4625418 UTF-16LE
- * @run main Test4625418 UTF-32
- * @run main Test4625418 UTF-32BE
- * @run main Test4625418 UTF-32LE
- * @run main Test4625418 UTF-8
- * @run main Test4625418 UTF8
- * @run main Test4625418 UTF_32
- * @run main Test4625418 UTF_32BE
- * -run main Test4625418 UTF_32BE_BOM
- * @run main Test4625418 UTF_32LE
- * -run main Test4625418 UTF_32LE_BOM
- * @run main Test4625418 UnicodeBig
- * @run main Test4625418 UnicodeBigUnmarked
- * @run main Test4625418 UnicodeLittle
- * @run main Test4625418 UnicodeLittleUnmarked
- * @run main Test4625418 windows-1250
- * @run main Test4625418 windows-1251
- * @run main Test4625418 windows-1252
- * @run main Test4625418 windows-1253
- * @run main Test4625418 windows-1254
- * @run main Test4625418 windows-1255
- * @run main Test4625418 windows-1256
- * @run main Test4625418 windows-1257
- * @run main Test4625418 windows-1258
- * ?run main Test4625418 windows-31j
- * -run main Test4625418 x-Big5_Solaris
- * ?run main Test4625418 x-EUC-TW
- * @run main Test4625418 x-IBM1006
- * ?run main Test4625418 x-IBM1025
- * @run main Test4625418 x-IBM1046
- * @run main Test4625418 x-IBM1097
- * @run main Test4625418 x-IBM1098
- * ?run main Test4625418 x-IBM1112
- * ?run main Test4625418 x-IBM1122
- * ?run main Test4625418 x-IBM1123
- * @run main Test4625418 x-IBM1124
- * ?run main Test4625418 x-IBM1381
- * ?run main Test4625418 x-IBM1383
- * ?run main Test4625418 x-IBM33722
- * @run main Test4625418 x-IBM737
- * -run main Test4625418 x-IBM834
- * @run main Test4625418 x-IBM856
- * @run main Test4625418 x-IBM874
- * ?run main Test4625418 x-IBM875
- * @run main Test4625418 x-IBM921
- * @run main Test4625418 x-IBM922
- * -run main Test4625418 x-IBM930
- * @run main Test4625418 x-IBM933
- * ?run main Test4625418 x-IBM935
- * ?run main Test4625418 x-IBM937
- * ?run main Test4625418 x-IBM939
- * ?run main Test4625418 x-IBM942
- * ?run main Test4625418 x-IBM942C
- * @run main Test4625418 x-IBM943
- * ?run main Test4625418 x-IBM943C
- * @run main Test4625418 x-IBM948
- * @run main Test4625418 x-IBM949
- * ?run main Test4625418 x-IBM949C
- * @run main Test4625418 x-IBM950
- * @run main Test4625418 x-IBM964
- * ?run main Test4625418 x-IBM970
- * ?run main Test4625418 x-ISCII91
- * -run main Test4625418 x-ISO2022-CN-CNS
- * -run main Test4625418 x-ISO2022-CN-GB
- * -run main Test4625418 x-JIS0208
- * -run main Test4625418 x-JISAutoDetect
- * @run main Test4625418 x-Johab
- * ?run main Test4625418 x-MS950-HKSCS
- * @run main Test4625418 x-MacArabic
- * @run main Test4625418 x-MacCentralEurope
- * @run main Test4625418 x-MacCroatian
- * @run main Test4625418 x-MacCyrillic
- * -run main Test4625418 x-MacDingbat
- * @run main Test4625418 x-MacGreek
- * @run main Test4625418 x-MacHebrew
- * @run main Test4625418 x-MacIceland
- * @run main Test4625418 x-MacRoman
- * @run main Test4625418 x-MacRomania
- * -run main Test4625418 x-MacSymbol
- * @run main Test4625418 x-MacThai
- * @run main Test4625418 x-MacTurkish
- * @run main Test4625418 x-MacUkraine
- * ?run main Test4625418 x-PCK
- * @run main Test4625418 x-UTF-16LE-BOM
- * -run main Test4625418 x-UTF-32BE-BOM
- * -run main Test4625418 x-UTF-32LE-BOM
- * ?run main Test4625418 x-euc-jp-linux
- * ?run main Test4625418 x-eucJP-Open
- * @run main Test4625418 x-iso-8859-11
- * @run main Test4625418 x-mswin-936
- * ?run main Test4625418 x-windows-50220
- * ?run main Test4625418 x-windows-50221
- * @run main Test4625418 x-windows-874
- * @run main Test4625418 x-windows-949
- * @run main Test4625418 x-windows-950
- * ?run main Test4625418 x-windows-iso2022jp
+ * @run main/timeout=360 Test4625418
  */
 
 import java.beans.ExceptionListener;
 import java.beans.XMLDecoder;
 import java.beans.XMLEncoder;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
 import java.nio.charset.IllegalCharsetNameException;
 import java.nio.charset.UnsupportedCharsetException;
 
 public final class Test4625418 implements ExceptionListener {
-    public static void main(String[] args) {
-        new Test4625418(args[0]).test(createString(0x10000));
-        System.out.println("Test passed: " + args[0]);
+
+    private static final String[] encodings = {
+        "ASCII",
+        "Big5",
+        //"Big5-HKSCS",
+        //"Big5_HKSCS",
+        "Big5_Solaris",
+        //"Cp037",
+        "Cp1006",
+        //"Cp1025",
+        //"Cp1026",
+        "Cp1046",
+        "Cp1047",
+        "Cp1097",
+        "Cp1098",
+        //"Cp1112",
+        //"Cp1122",
+        //"Cp1123",
+        "Cp1124",
+        //"Cp1140",
+        //"Cp1141",
+        //"Cp1142",
+        //"Cp1143",
+        //"Cp1144",
+        //"Cp1145",
+        //"Cp1146",
+        //"Cp1147",
+        //"Cp1148",
+        //"Cp1149",
+        "Cp1250",
+        "Cp1251",
+        "Cp1252",
+        "Cp1253",
+        "Cp1254",
+        "Cp1255",
+        "Cp1256",
+        "Cp1257",
+        "Cp1258",
+        //"Cp1381",
+        //"Cp1383",
+        //"Cp273",
+        //"Cp277",
+        //"Cp278",
+        //"Cp280",
+        //"Cp284",
+        //"Cp285",
+        //"Cp297",
+        //"Cp33722",
+        //"Cp420",
+        //"Cp424",
+        "Cp437",
+        //"Cp500",
+        //"Cp50220",
+        //"Cp50221",
+        "Cp737",
+        "Cp775",
+        //"Cp834",
+        //"Cp838",
+        "Cp850",
+        "Cp852",
+        "Cp855",
+        "Cp856",
+        "Cp857",
+        "Cp858",
+        "Cp860",
+        "Cp861",
+        "Cp862",
+        "Cp863",
+        "Cp864",
+        "Cp865",
+        "Cp866",
+        "Cp868",
+        "Cp869",
+        //"Cp870",
+        //"Cp871",
+        "Cp874",
+        //"Cp875",
+        //"Cp918",
+        "Cp921",
+        "Cp922",
+        //"Cp930",
+        "Cp933",
+        //"Cp935",
+        //"Cp937",
+        //"Cp939",
+        //"Cp942",
+        //"Cp942C",
+        "Cp943",
+        //"Cp943C",
+        "Cp948",
+        "Cp949",
+        //"Cp949C",
+        "Cp950",
+        "Cp964",
+        //"Cp970",
+        //"EUC-JP",
+        "EUC-KR",
+        "EUC_CN",
+        //"EUC_JP",
+        //"EUC_JP_LINUX",
+        //"EUC_JP_Solaris",
+        "EUC_KR",
+        //"EUC_TW",
+        "GB18030",
+        "GB2312",
+        "GBK",
+        //"IBM-Thai",
+        "IBM00858",
+        //"IBM01140",
+        //"IBM01141",
+        //"IBM01142",
+        //"IBM01143",
+        //"IBM01144",
+        //"IBM01145",
+        //"IBM01146",
+        //"IBM01147",
+        //"IBM01148",
+        //"IBM01149",
+        //"IBM037",
+        //"IBM1026",
+        "IBM1047",
+        //"IBM273",
+        //"IBM277",
+        //"IBM278",
+        //"IBM280",
+        //"IBM284",
+        //"IBM285",
+        //"IBM297",
+        //"IBM420",
+        //"IBM424",
+        "IBM437",
+        //"IBM500",
+        "IBM775",
+        "IBM850",
+        "IBM852",
+        "IBM855",
+        "IBM857",
+        "IBM860",
+        "IBM861",
+        "IBM862",
+        "IBM863",
+        "IBM864",
+        "IBM865",
+        "IBM866",
+        "IBM868",
+        "IBM869",
+        //"IBM870",
+        //"IBM871",
+        //"IBM918",
+        //"ISCII91",
+        //"ISO-2022-CN",
+        "ISO-2022-JP",
+        "ISO-2022-KR",
+        "ISO-8859-1",
+        "ISO-8859-13",
+        "ISO-8859-15",
+        "ISO-8859-2",
+        "ISO-8859-3",
+        "ISO-8859-4",
+        "ISO-8859-5",
+        "ISO-8859-6",
+        "ISO-8859-7",
+        "ISO-8859-8",
+        "ISO-8859-9",
+        //"ISO2022CN",
+        "ISO2022JP",
+        "ISO2022KR",
+        //"ISO2022_CN_CNS",
+        //"ISO2022_CN_GB",
+        "ISO8859_1",
+        "ISO8859_13",
+        "ISO8859_15",
+        "ISO8859_2",
+        "ISO8859_3",
+        "ISO8859_4",
+        "ISO8859_5",
+        "ISO8859_6",
+        "ISO8859_7",
+        "ISO8859_8",
+        "ISO8859_9",
+        //"JISAutoDetect",
+        //"JIS_X0201",
+        //"JIS_X0212-1990",
+        "KOI8-R",
+        "KOI8-U",
+        "KOI8_R",
+        "KOI8_U",
+        "MS874",
+        //"MS932",
+        //"MS936",
+        "MS949",
+        "MS950",
+        //"MS950_HKSCS",
+        "MacArabic",
+        "MacCentralEurope",
+        "MacCroatian",
+        "MacCyrillic",
+        //"MacDingbat",
+        "MacGreek",
+        "MacHebrew",
+        "MacIceland",
+        "MacRoman",
+        "MacRomania",
+        //"MacSymbol",
+        "MacThai",
+        "MacTurkish",
+        "MacUkraine",
+        //"PCK",
+        //"SJIS",
+        //"Shift_JIS",
+        "TIS-620",
+        "TIS620",
+        "US-ASCII",
+        "UTF-16",
+        "UTF-16BE",
+        "UTF-16LE",
+        "UTF-32",
+        "UTF-32BE",
+        "UTF-32LE",
+        "UTF-8",
+        "UTF8",
+        "UTF_32",
+        "UTF_32BE",
+        //"UTF_32BE_BOM",
+        "UTF_32LE",
+        //"UTF_32LE_BOM",
+        "UnicodeBig",
+        "UnicodeBigUnmarked",
+        "UnicodeLittle",
+        "UnicodeLittleUnmarked",
+        "windows-1250",
+        "windows-1251",
+        "windows-1252",
+        "windows-1253",
+        "windows-1254",
+        "windows-1255",
+        "windows-1256",
+        "windows-1257",
+        "windows-1258",
+        //"windows-31j",
+        //"x-Big5_Solaris",
+        //"x-EUC-TW",
+        "x-IBM1006",
+        //"x-IBM1025",
+        "x-IBM1046",
+        "x-IBM1097",
+        "x-IBM1098",
+        //"x-IBM1112",
+        //"x-IBM1122",
+        //"x-IBM1123",
+        "x-IBM1124",
+        //"x-IBM1381",
+        //"x-IBM1383",
+        //"x-IBM33722",
+        "x-IBM737",
+        //"x-IBM834",
+        "x-IBM856",
+        "x-IBM874",
+        //"x-IBM875",
+        "x-IBM921",
+        "x-IBM922",
+        //"x-IBM930",
+        "x-IBM933",
+        //"x-IBM935",
+        //"x-IBM937",
+        //"x-IBM939",
+        //"x-IBM942",
+        //"x-IBM942C",
+        "x-IBM943",
+        //"x-IBM943C",
+        "x-IBM948",
+        "x-IBM949",
+        //"x-IBM949C",
+        "x-IBM950",
+        "x-IBM964",
+        //"x-IBM970",
+        //"x-ISCII91",
+        //"x-ISO2022-CN-CNS",
+        //"x-ISO2022-CN-GB",
+        //"x-JIS0208",
+        //"x-JISAutoDetect",
+        "x-Johab",
+        //"x-MS950-HKSCS",
+        "x-MacArabic",
+        "x-MacCentralEurope",
+        "x-MacCroatian",
+        "x-MacCyrillic",
+        //"x-MacDingbat",
+        "x-MacGreek",
+        "x-MacHebrew",
+        "x-MacIceland",
+        "x-MacRoman",
+        "x-MacRomania",
+        //"x-MacSymbol",
+        "x-MacThai",
+        "x-MacTurkish",
+        "x-MacUkraine",
+        //"x-PCK",
+        "x-UTF-16LE-BOM",
+        //"x-UTF-32BE-BOM",
+        //"x-UTF-32LE-BOM",
+        //"x-euc-jp-linux",
+        //"x-eucJP-Open",
+        "x-iso-8859-11",
+        "x-mswin-936",
+        //"x-windows-50220",
+        //"x-windows-50221",
+        "x-windows-874",
+        "x-windows-949",
+        "x-windows-950",
+        //"x-windows-iso2022jp",
+    };
+
+    public static void main(final String[] args) {
+        final String string = createString(0x10000);
+        for (String encoding : encodings) {
+            System.out.println("Test encoding: " + encoding);
+            new Test4625418(encoding).test(string);
+        }
     }
 
     private static String createString(int length) {
@@ -364,33 +370,27 @@
 
     private final String encoding;
 
-    private Test4625418(String encoding) {
+    private Test4625418(final String encoding) {
         this.encoding = encoding;
     }
 
     private void test(String string) {
         try {
-            File file = new File("4625418." + this.encoding + ".xml");
-
-            FileOutputStream output = new FileOutputStream(file);
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
             XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0);
             encoder.setExceptionListener(this);
             encoder.writeObject(string);
             encoder.close();
 
-            FileInputStream input = new FileInputStream(file);
+            InputStream input = new ByteArrayInputStream(output.toByteArray());
             XMLDecoder decoder = new XMLDecoder(input);
             decoder.setExceptionListener(this);
             Object object = decoder.readObject();
             decoder.close();
 
-            if (!string.equals(object))
+            if (!string.equals(object)) {
                 throw new Error(this.encoding + " - can't read properly");
-
-            file.delete();
-        }
-        catch (FileNotFoundException exception) {
-            throw new Error(this.encoding + " - file not found", exception);
+            }
         }
         catch (IllegalCharsetNameException exception) {
             throw new Error(this.encoding + " - illegal charset name", exception);
diff --git a/jdk/test/java/lang/Class/forName/modules/TestLayer.java b/jdk/test/java/lang/Class/forName/modules/TestLayer.java
index 8a01cb1..645e04d 100644
--- a/jdk/test/java/lang/Class/forName/modules/TestLayer.java
+++ b/jdk/test/java/lang/Class/forName/modules/TestLayer.java
@@ -46,7 +46,7 @@
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
 
         Configuration parent = Layer.boot().configuration();
-        Configuration cf = parent.resolveRequiresAndUses(ModuleFinder.empty(),
+        Configuration cf = parent.resolveRequiresAndUses(ModuleFinder.of(),
                                                          finder,
                                                          modules);
 
diff --git a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java
index 902e92d..618b2fd 100644
--- a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java
+++ b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java
@@ -51,7 +51,7 @@
         Configuration parent = bootLayer.configuration();
 
         Configuration cf = parent.resolveRequiresAndUses(finder,
-                                                         ModuleFinder.empty(),
+                                                         ModuleFinder.of(),
                                                          Set.of("m1", "m2"));
 
         ClassLoader scl = ClassLoader.getSystemClassLoader();
diff --git a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
index a162deb..9052737 100644
--- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
+++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
@@ -228,12 +228,18 @@
     }
 
     static boolean test(String s, boolean addExports) {
+        String clsName = s.replace('/', '.').substring(0, s.length() - 6);
         try {
+            System.out.println("Loading " + clsName);
             final Class<?> c = Class.forName(
-                    s.replace('/', '.').substring(0, s.length() - 6),
+                    clsName,
                     false,
                     systemClassLoader);
             return test(c, addExports);
+        } catch (VerifyError ve) {
+            System.err.println("VerifyError for " + clsName);
+            ve.printStackTrace(System.err);
+            failed.add(s);
         } catch (Exception t) {
             t.printStackTrace(System.err);
             failed.add(s);
diff --git a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java
index a1a1b4e..26fbe3d 100644
--- a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java
+++ b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
 import java.net.URL;
 
 /* @test
- * @bug 6977738
+ * @bug 6977738 8029891
  * @summary Test ClassLoader.getResource() that should not deadlock
  #          if another thread is holding the system properties object
  *
@@ -70,10 +70,6 @@
                     go.await();  // wait until t1 holds the lock of the system properties
 
                     URL u1 = Thread.currentThread().getContextClassLoader().getResource("unknownresource");
-                    URL u2 = Thread.currentThread().getContextClassLoader().getResource("sun/util/resources/CalendarData.class");
-                    if (u2 == null) {
-                        throw new RuntimeException("Test failed: resource not found");
-                    }
                     done.await();
                 } catch (InterruptedException e) {
                     throw new RuntimeException(e);
diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh
index 3872f81..a00c140 100644
--- a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh
+++ b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh
@@ -106,7 +106,7 @@
 # run test
 ${TESTJAVA}${FS}bin${FS}java \
         ${TESTVMOPTS} \
-        -verbose:class -Xlog:classload -cp . \
+        -verbose:class -Xlog:class+load -cp . \
         -Dtest.classes=${TESTCLASSES} \
         Starter cross
 # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \
diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh
index 198cd70..1289b4c 100644
--- a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh
+++ b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh
@@ -102,7 +102,7 @@
 # run test
 ${TESTJAVA}${FS}bin${FS}java \
         ${TESTVMOPTS} \
-        -verbose:class -Xlog:classload -cp . \
+        -verbose:class -Xlog:class+load -cp . \
         -Dtest.classes=${TESTCLASSES} \
         Starter one-way
 # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \
diff --git a/jdk/test/java/lang/Math/DivModTests.java b/jdk/test/java/lang/Math/DivModTests.java
index fbd98e6..772bb1c 100644
--- a/jdk/test/java/lang/Math/DivModTests.java
+++ b/jdk/test/java/lang/Math/DivModTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -184,7 +184,7 @@
     }
 
     /**
-     * Test the integer floorDiv and floorMod methods.
+     * Test the long floorDiv and floorMod methods.
      * Math and StrictMath are tested and the same results are expected for both.
      */
     static void testLongFloorDivMod(long x, long y, Object divExpected, Object modExpected) {
@@ -253,6 +253,110 @@
     }
 
     /**
+     * Test the floorDiv and floorMod methods for mixed long and int.
+     */
+    static void testLongIntFloorDivMod() {
+        testLongIntFloorDivMod(4L, 0, new ArithmeticException(), new ArithmeticException()); // Should throw ArithmeticException
+        testLongIntFloorDivMod(4L, 3, 1L, 1);
+        testLongIntFloorDivMod(3L, 3, 1L, 0);
+        testLongIntFloorDivMod(2L, 3, 0L, 2);
+        testLongIntFloorDivMod(1L, 3, 0L, 1);
+        testLongIntFloorDivMod(0L, 3, 0L, 0);
+        testLongIntFloorDivMod(4L, -3, -2L, -2);
+        testLongIntFloorDivMod(3L, -3, -1L, 0);
+        testLongIntFloorDivMod(2L, -3, -1L, -1);
+        testLongIntFloorDivMod(1L, -3, -1L, -2);
+        testLongIntFloorDivMod(0L, -3, 0L, 0);
+        testLongIntFloorDivMod(-1L, 3, -1L, 2);
+        testLongIntFloorDivMod(-2L, 3, -1L, 1);
+        testLongIntFloorDivMod(-3L, 3, -1L, 0);
+        testLongIntFloorDivMod(-4L, 3, -2L, 2);
+        testLongIntFloorDivMod(-1L, -3, 0L, -1);
+        testLongIntFloorDivMod(-2L, -3, 0L, -2);
+        testLongIntFloorDivMod(-3L, -3, 1L, 0);
+        testLongIntFloorDivMod(-4L, -3, 1L, -1);
+
+        testLongIntFloorDivMod(Long.MAX_VALUE, 1, Long.MAX_VALUE, 0L);
+        testLongIntFloorDivMod(Long.MAX_VALUE, -1, -Long.MAX_VALUE, 0L);
+        testLongIntFloorDivMod(Long.MAX_VALUE, 3, Long.MAX_VALUE / 3L, 1L);
+        testLongIntFloorDivMod(Long.MAX_VALUE - 1L, 3, (Long.MAX_VALUE - 1L) / 3L, 0L);
+        testLongIntFloorDivMod(Long.MIN_VALUE, 3, Long.MIN_VALUE / 3L - 1L, 1L);
+        testLongIntFloorDivMod(Long.MIN_VALUE + 1L, 3, Long.MIN_VALUE / 3L - 1L, 2L);
+        testLongIntFloorDivMod(Long.MIN_VALUE + 1, -1, Long.MAX_VALUE, 0L);
+        // Special case of integer overflow
+        testLongIntFloorDivMod(Long.MIN_VALUE, -1, Long.MIN_VALUE, 0L);
+    }
+
+    /**
+     * Test the integer floorDiv and floorMod methods.
+     * Math and StrictMath are tested and the same results are expected for both.
+     */
+    static void testLongIntFloorDivMod(long x, int y, Object divExpected, Object modExpected) {
+        testLongIntFloorDiv(x, y, divExpected);
+        testLongIntFloorMod(x, y, modExpected);
+    }
+
+    /**
+     * Test FloorDiv with long arguments against expected value.
+     * The expected value is usually a Long but in some cases  is
+     * an ArithmeticException.
+     *
+     * @param x dividend
+     * @param y modulus
+     * @param expected expected value,
+     */
+    static void testLongIntFloorDiv(long x, int y, Object expected) {
+        Object result = doFloorDiv(x, y);
+        if (!resultEquals(result, expected)) {
+            fail("FAIL: long Math.floorDiv(%d, %d) = %s; expected %s%n", x, y, result, expected);
+        }
+
+        Object strict_result = doStrictFloorDiv(x, y);
+        if (!resultEquals(strict_result, expected)) {
+            fail("FAIL: long StrictMath.floorDiv(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
+        }
+    }
+
+    /**
+     * Test FloorMod of long arguments against expected value.
+     * The expected value is usually a Long but in some cases  is
+     * an ArithmeticException.
+     *
+     * @param x dividend
+     * @param y modulus
+     * @param expected expected value
+     */
+    static void testLongIntFloorMod(long x, int y, Object expected) {
+        Object result = doFloorMod(x, y);
+        if (!resultEquals(result, expected)) {
+            fail("FAIL: long Math.floorMod(%d, %d) = %s; expected %s%n", x, y, result, expected);
+        }
+
+        Object strict_result = doStrictFloorMod(x, y);
+        if (!resultEquals(strict_result, expected)) {
+            fail("FAIL: long StrictMath.floorMod(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
+        }
+
+        try {
+            // Verify the result against BigDecimal rounding mode.
+            BigDecimal xD = new BigDecimal(x);
+            BigDecimal yD = new BigDecimal(y);
+            BigDecimal resultD = xD.divide(yD, RoundingMode.FLOOR);
+            resultD = resultD.multiply(yD);
+            resultD = xD.subtract(resultD);
+            long fr = resultD.longValue();
+            if (!result.equals(fr)) {
+                fail("FAIL: Long.floorMod(%d, %d) = %d is different than BigDecimal result: %d%n", x, y, result, fr);
+
+            }
+        } catch (ArithmeticException ae) {
+            if (y != 0) {
+                fail("FAIL: long Math.floorMod(%d, %d); unexpected ArithmeticException from bigdecimal");
+            }
+        }
+    }
+
+    /**
      * Invoke floorDiv and return the result or any exception.
      * @param x the x value
      * @param y the y value
@@ -272,6 +376,20 @@
      * @param y the y value
      * @return the result Integer or an exception.
      */
+    static Object doFloorDiv(long x, int y) {
+        try {
+            return Math.floorDiv(x, y);
+        } catch (ArithmeticException ae) {
+            return ae;
+        }
+    }
+
+    /**
+     * Invoke floorDiv and return the result or any exception.
+     * @param x the x value
+     * @param y the y value
+     * @return the result Integer or an exception.
+     */
     static Object doFloorDiv(long x, long y) {
         try {
             return Math.floorDiv(x, y);
@@ -300,6 +418,20 @@
      * @param y the y value
      * @return the result Integer or an exception.
      */
+    static Object doFloorMod(long x, int y) {
+        try {
+            return Math.floorMod(x, y);
+        } catch (ArithmeticException ae) {
+            return ae;
+        }
+    }
+
+    /**
+     * Invoke floorDiv and return the result or any exception.
+     * @param x the x value
+     * @param y the y value
+     * @return the result Integer or an exception.
+     */
     static Object doFloorMod(long x, long y) {
         try {
             return Math.floorMod(x, y);
@@ -328,6 +460,20 @@
      * @param y the y value
      * @return the result Integer or an exception.
      */
+    static Object doStrictFloorDiv(long x, int y) {
+        try {
+            return StrictMath.floorDiv(x, y);
+        } catch (ArithmeticException ae) {
+            return ae;
+        }
+    }
+
+    /**
+     * Invoke floorDiv and return the result or any exception.
+     * @param x the x value
+     * @param y the y value
+     * @return the result Integer or an exception.
+     */
     static Object doStrictFloorDiv(long x, long y) {
         try {
             return StrictMath.floorDiv(x, y);
@@ -356,6 +502,20 @@
      * @param y the y value
      * @return the result Integer or an exception.
      */
+    static Object doStrictFloorMod(long x, int y) {
+        try {
+            return StrictMath.floorMod(x, y);
+        } catch (ArithmeticException ae) {
+            return ae;
+        }
+    }
+
+    /**
+     * Invoke floorDiv and return the result or any exception.
+     * @param x the x value
+     * @param y the y value
+     * @return the result Integer or an exception.
+     */
     static Object doStrictFloorMod(long x, long y) {
         try {
             return StrictMath.floorMod(x, y);
diff --git a/jdk/test/java/lang/Math/ExactArithTests.java b/jdk/test/java/lang/Math/ExactArithTests.java
index 709ea61..37a8a1f 100644
--- a/jdk/test/java/lang/Math/ExactArithTests.java
+++ b/jdk/test/java/lang/Math/ExactArithTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
     public static void main(String[] args) {
         testIntegerExact();
         testLongExact();
+        testLongIntExact();
 
         if (errors > 0) {
             throw new RuntimeException(errors + " errors found in ExactArithTests.");
@@ -132,6 +133,7 @@
                 fail("FAIL: int Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
             }
         }
+
         try {
             // Test incrementExact
             int inc = Math.incrementExact(x);
@@ -345,4 +347,60 @@
     static boolean inLongRange(BigInteger value) {
         return value.bitLength() <= 63;
     }
+
+    /**
+     * Test Math.multiplyExact method with {@code long} and {@code int}
+     * arguments.
+     */
+    static void testLongIntExact() {
+        testLongIntExact(0, 0);
+        testLongIntExact(1, 1);
+        testLongIntExact(1, -1);
+        testLongIntExact(1000, 2000);
+
+        testLongIntExact(Long.MIN_VALUE, Integer.MIN_VALUE);
+        testLongIntExact(Long.MAX_VALUE, Integer.MAX_VALUE);
+        testLongIntExact(Long.MIN_VALUE, 1);
+        testLongIntExact(Long.MAX_VALUE, 1);
+        testLongIntExact(Long.MIN_VALUE, 2);
+        testLongIntExact(Long.MAX_VALUE, 2);
+        testLongIntExact(Long.MIN_VALUE, -1);
+        testLongIntExact(Long.MAX_VALUE, -1);
+        testLongIntExact(Long.MIN_VALUE, -2);
+        testLongIntExact(Long.MAX_VALUE, -2);
+        testLongIntExact(Long.MIN_VALUE/2, 2);
+        testLongIntExact(Long.MAX_VALUE, 2);
+        testLongIntExact(Integer.MAX_VALUE, Integer.MAX_VALUE);
+        testLongIntExact(Integer.MAX_VALUE, -Integer.MAX_VALUE);
+        testLongIntExact((long)Integer.MAX_VALUE+1L, Integer.MAX_VALUE);
+        testLongIntExact((long)Integer.MAX_VALUE+1L, -Integer.MAX_VALUE+1);
+        testLongIntExact((long)Integer.MIN_VALUE-1L, Integer.MIN_VALUE);
+        testLongIntExact((long)Integer.MIN_VALUE-1, Integer.MAX_VALUE);
+        testLongIntExact(Integer.MIN_VALUE/2, 2);
+    }
+
+    /**
+     * Test long-int exact arithmetic by comparing with the same operations using BigInteger
+     * and checking that the result is the same as the long truncation.
+     * Errors are reported with {@link fail}.
+     *
+     * @param x first parameter
+     * @param y second parameter
+     */
+    static void testLongIntExact(long x, int y) {
+        BigInteger resultBig = null;
+        final BigInteger xBig = BigInteger.valueOf(x);
+        final BigInteger yBig = BigInteger.valueOf(y);
+
+        try {
+            // Test multiplyExact
+            resultBig = xBig.multiply(yBig);
+            long product = Math.multiplyExact(x, y);
+            checkResult("long Math.multiplyExact", x, y, product, resultBig);
+        } catch (ArithmeticException ex) {
+            if (inLongRange(resultBig)) {
+                fail("FAIL: long Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+            }
+        }
+    }
 }
diff --git a/jdk/test/java/lang/Math/MultiplicationTests.java b/jdk/test/java/lang/Math/MultiplicationTests.java
new file mode 100644
index 0000000..1a9c3da
--- /dev/null
+++ b/jdk/test/java/lang/Math/MultiplicationTests.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @library /lib/testlibrary/
+ * @build jdk.testlibrary.*
+ * @run main MultiplicationTests
+ * @bug 5100935
+ * @summary Tests for multiplication methods (use -Dseed=X to set PRNG seed)
+ * @key randomness
+ */
+
+import java.math.BigInteger;
+import jdk.testlibrary.RandomFactory;
+
+public class MultiplicationTests {
+    private MultiplicationTests(){}
+
+    // Number of random products to test.
+    private static final int COUNT = 1 << 16;
+
+    // Initialize shared random number generator
+    private static java.util.Random rnd = RandomFactory.getRandom();
+
+    // Calculate high 64 bits of 128 product using BigInteger.
+    private static long multiplyHighBigInt(long x, long y) {
+        return BigInteger.valueOf(x).multiply(BigInteger.valueOf(y))
+            .shiftRight(64).longValue();
+    }
+
+    // Check Math.multiplyHigh(x,y) against multiplyHighBigInt(x,y)
+    private static boolean check(long x, long y) {
+        long p1 = multiplyHighBigInt(x, y);
+        long p2 = Math.multiplyHigh(x, y);
+        if (p1 != p2) {
+            System.err.printf("Error - x:%d y:%d p1:%d p2:%d\n", x, y, p1, p2);
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private static int testMultiplyHigh() {
+        int failures = 0;
+
+        // check some boundary cases
+        long[][] v = new long[][]{
+            {0L, 0L},
+            {-1L, 0L},
+            {0L, -1L},
+            {1L, 0L},
+            {0L, 1L},
+            {-1L, -1L},
+            {-1L, 1L},
+            {1L, -1L},
+            {1L, 1L},
+            {Long.MAX_VALUE, Long.MAX_VALUE},
+            {Long.MAX_VALUE, -Long.MAX_VALUE},
+            {-Long.MAX_VALUE, Long.MAX_VALUE},
+            {Long.MAX_VALUE, Long.MIN_VALUE},
+            {Long.MIN_VALUE, Long.MAX_VALUE},
+            {Long.MIN_VALUE, Long.MIN_VALUE}
+        };
+
+        for (long[] xy : v) {
+            if(!check(xy[0], xy[1])) {
+                failures++;
+            }
+        }
+
+        // check some random values
+        for (int i = 0; i < COUNT; i++) {
+            if (!check(rnd.nextLong(), rnd.nextLong())) {
+                failures++;
+            }
+        }
+
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = testMultiplyHigh();
+
+        if (failures > 0) {
+            System.err.println("Multiplication testing encountered "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        } else {
+            System.out.println("MultiplicationTests succeeded");
+        }
+    }
+}
diff --git a/jdk/test/jdk/Version/Basic.java b/jdk/test/java/lang/Runtime/Version/Basic.java
similarity index 95%
rename from jdk/test/jdk/Version/Basic.java
rename to jdk/test/java/lang/Runtime/Version/Basic.java
index b94180c..0a60ad2 100644
--- a/jdk/test/jdk/Version/Basic.java
+++ b/jdk/test/java/lang/Runtime/Version/Basic.java
@@ -23,12 +23,13 @@
 
 /*
  * @test
- * @summary Unit test for jdk.Version.
- * @bug 8072379
+ * @summary Unit test for java.lang.Runtime.Version.
+ * @bug 8072379 8144062
  */
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.Runtime.Version;
 import java.math.BigInteger;
 import java.util.stream.Collectors;
 import java.util.Arrays;
@@ -36,7 +37,6 @@
 import java.util.List;
 import java.util.Optional;
 
-import jdk.Version;
 import static java.lang.System.out;
 
 public class Basic {
@@ -116,8 +116,8 @@
         tryCatch("1.4142+-",   IAE);
         tryCatch("2.9979+-%",  IAE);
 
-        //// Test for current()
-        testCurrent();
+        //// Test for Runtime.version()
+        testVersion();
 
         //// Test for equals{IgnoreOpt}?(), hashCode(), compareTo{IgnoreOpt}?()
         // compare: after "<" == -1, equal == 0, before ">" == 1
@@ -219,18 +219,19 @@
             pass();
     }
 
-    private static void testCurrent() {
-        Version current = Version.current();
-        String javaVer = System.getProperty("java.version");
+    private static void testVersion() {
+        Version current = Runtime.version();
+        String javaVer = System.getProperty("java.runtime.version");
 
-        // java.version == $VNUM(\-$PRE)
-        String [] ver = javaVer.split("-");
+        // java.runtime.version == $VNUM(\-$PRE)?(\+$BUILD)?(-$OPT)?
+        String [] jv  = javaVer.split("\\+");
+        String [] ver = jv[0].split("-");
         List<Integer> javaVerVNum
             = Arrays.stream(ver[0].split("\\."))
             .map(v -> Integer.parseInt(v))
             .collect(Collectors.toList());
         if (!javaVerVNum.equals(current.version())) {
-            fail("testCurrent() version()", javaVerVNum.toString(),
+            fail("Runtime.version()", javaVerVNum.toString(),
                  current.version().toString());
         } else {
             pass();
diff --git a/jdk/test/java/lang/StackWalker/CountLocalSlots.java b/jdk/test/java/lang/StackWalker/CountLocalSlots.java
new file mode 100644
index 0000000..c78a4cb
--- /dev/null
+++ b/jdk/test/java/lang/StackWalker/CountLocalSlots.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8147039
+ * @summary Confirm locals[] always has expected length, even for "dead" locals
+ * @compile LocalsAndOperands.java
+ * @run testng/othervm -Xcomp CountLocalSlots
+ */
+
+import org.testng.annotations.Test;
+import java.lang.StackWalker.StackFrame;
+
+public class CountLocalSlots {
+    final static boolean debug = true;
+
+    @Test(dataProvider = "provider", dataProviderClass = LocalsAndOperands.class)
+    public void countLocalSlots(StackFrame... frames) {
+        for (StackFrame frame : frames) {
+            if (debug) {
+                System.out.println("Running countLocalSlots");
+                LocalsAndOperands.dumpStackWithLocals(frames);
+            }
+            // Confirm expected number of locals
+            String methodName = frame.getMethodName();
+            Integer expectedObj = (Integer) LocalsAndOperands.Tester.NUM_LOCALS.get(methodName);
+            if (expectedObj == null) {
+                if (!debug) { LocalsAndOperands.dumpStackWithLocals(frames); }
+                throw new RuntimeException("No NUM_LOCALS entry for " +
+                        methodName + "().  Update test?");
+            }
+            Object[] locals = (Object[]) LocalsAndOperands.invokeGetLocals(frame);
+            if (locals.length != expectedObj) {
+                if (!debug) { LocalsAndOperands.dumpStackWithLocals(frames); }
+                throw new RuntimeException(methodName + "(): number of locals (" +
+                        locals.length + ") did not match expected (" + expectedObj + ")");
+            }
+        }
+    }
+}
diff --git a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java
index 63a6731..b253ab2 100644
--- a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java
+++ b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,17 +23,20 @@
 
 /*
  * @test
- * @bug 8020968
- * @summary Sanity test for locals and operands
- * @run main LocalsAndOperands
+ * @bug 8020968 8147039
+ * @summary Tests for locals and operands
+ * @run testng LocalsAndOperands
  */
 
+import org.testng.annotations.*;
 import java.lang.StackWalker.StackFrame;
 import java.lang.reflect.*;
-import java.util.List;
-import java.util.stream.Collectors;
+import java.util.*;
+import java.util.stream.*;
 
 public class LocalsAndOperands {
+    static final boolean debug = true;
+
     static Class<?> liveStackFrameClass;
     static Class<?> primitiveValueClass;
     static StackWalker extendedWalker;
@@ -41,92 +44,319 @@
     static Method getOperands;
     static Method getMonitors;
     static Method primitiveType;
-    public static void main(String... args) throws Exception {
-        liveStackFrameClass = Class.forName("java.lang.LiveStackFrame");
-        primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue");
 
-        getLocals = liveStackFrameClass.getDeclaredMethod("getLocals");
-        getLocals.setAccessible(true);
+    static {
+        try {
+            liveStackFrameClass = Class.forName("java.lang.LiveStackFrame");
+            primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue");
 
-        getOperands = liveStackFrameClass.getDeclaredMethod("getStack");
-        getOperands.setAccessible(true);
+            getLocals = liveStackFrameClass.getDeclaredMethod("getLocals");
+            getLocals.setAccessible(true);
 
-        getMonitors = liveStackFrameClass.getDeclaredMethod("getMonitors");
-        getMonitors.setAccessible(true);
+            getOperands = liveStackFrameClass.getDeclaredMethod("getStack");
+            getOperands.setAccessible(true);
 
-        primitiveType = primitiveValueClass.getDeclaredMethod("type");
-        primitiveType.setAccessible(true);
+            getMonitors = liveStackFrameClass.getDeclaredMethod("getMonitors");
+            getMonitors.setAccessible(true);
 
-        Method method = liveStackFrameClass.getMethod("getStackWalker");
-        method.setAccessible(true);
-        extendedWalker = (StackWalker) method.invoke(null);
-        new LocalsAndOperands(extendedWalker, true).test();
+            primitiveType = primitiveValueClass.getDeclaredMethod("type");
+            primitiveType.setAccessible(true);
 
-        // no access to local and operands.
-        new LocalsAndOperands(StackWalker.getInstance(), false).test();
+            Method method = liveStackFrameClass.getMethod("getStackWalker");
+            method.setAccessible(true);
+            extendedWalker = (StackWalker) method.invoke(null);
+        } catch (Throwable t) { throw new RuntimeException(t); }
     }
 
-    private final StackWalker walker;
-    private final boolean extended;
-    LocalsAndOperands(StackWalker walker, boolean extended) {
-        this.walker = walker;
-        this.extended = extended;
+    /** Helper method to return a StackFrame's locals */
+    static Object[] invokeGetLocals(StackFrame arg) {
+        try {
+            return (Object[]) getLocals.invoke(arg);
+        } catch (Exception e) { throw new RuntimeException(e); }
     }
 
-    synchronized void test() throws Exception {
-        int x = 10;
-        char c = 'z';
-        String hi = "himom";
-        long l = 1000000L;
-        double d =  3.1415926;
+    /*****************
+     * DataProviders *
+     *****************/
 
-        List<StackWalker.StackFrame> frames = walker.walk(s -> s.collect(Collectors.toList()));
-        if (extended) {
-            for (StackWalker.StackFrame f : frames) {
-                System.out.println("frame: " + f);
-                Object[] locals = (Object[]) getLocals.invoke(f);
+    /** Calls testLocals() and provides LiveStackFrames for testLocals* methods */
+    @DataProvider
+    public static StackFrame[][] provider() {
+        return new StackFrame[][] {
+            new Tester().testLocals()
+        };
+    }
+
+    /**
+     * Calls testLocalsKeepAlive() and provides LiveStackFrames for testLocals* methods.
+     * Local variables in testLocalsKeepAlive() are ensured to not become dead.
+     */
+    @DataProvider
+    public static StackFrame[][] keepAliveProvider() {
+        return new StackFrame[][] {
+            new Tester().testLocalsKeepAlive()
+        };
+    }
+
+    /**
+     * Provides StackFrames from a StackWalker without the LOCALS_AND_OPERANDS
+     * option.
+     */
+    @DataProvider
+    public static StackFrame[][] noLocalsProvider() {
+        // Use default StackWalker
+        return new StackFrame[][] {
+            new Tester(StackWalker.getInstance(), true).testLocals()
+        };
+    }
+
+    /**
+     * Calls testLocals() and provides LiveStackFrames for *all* called methods,
+     * including test infrastructure (jtreg, testng, etc)
+     *
+     */
+    @DataProvider
+    public static StackFrame[][] unfilteredProvider() {
+        return new StackFrame[][] {
+            new Tester(extendedWalker, false).testLocals()
+        };
+    }
+
+    /****************
+     * Test methods *
+     ****************/
+
+    /**
+     * Check for expected local values and types in the LiveStackFrame
+     */
+    @Test(dataProvider = "keepAliveProvider")
+    public static void checkLocalValues(StackFrame... frames) {
+        if (debug) {
+            System.out.println("Running checkLocalValues");
+            dumpStackWithLocals(frames);
+        }
+        Arrays.stream(frames).filter(f -> f.getMethodName()
+                                           .equals("testLocalsKeepAlive"))
+                                           .forEach(
+            f -> {
+                Object[] locals = invokeGetLocals(f);
                 for (int i = 0; i < locals.length; i++) {
-                    System.out.format("  local %d: %s type %s\n", i, locals[i], type(locals[i]));
+                    // Value
+                    String expected = Tester.LOCAL_VALUES[i];
+                    Object observed = locals[i];
+                    if (expected != null /* skip nulls in golden values */ &&
+                            !expected.equals(observed.toString())) {
+                        System.err.println("Local value mismatch:");
+                        if (!debug) { dumpStackWithLocals(frames); }
+                        throw new RuntimeException("local " + i + " value is " +
+                                observed + ", expected " + expected);
+                    }
 
-                    // check for non-null locals in LocalsAndOperands.test()
-                    if (f.getClassName().equals("LocalsAndOperands") &&
-                            f.getMethodName().equals("test")) {
-                        if (locals[i] == null) {
-                            throw new RuntimeException("kept-alive locals should not be null");
-                        }
+                    // Type
+                    expected = Tester.LOCAL_TYPES[i];
+                    observed = type(locals[i]);
+                    if (expected != null /* skip nulls in golden values */ &&
+                            !expected.equals(observed)) {
+                        System.err.println("Local type mismatch:");
+                        if (!debug) { dumpStackWithLocals(frames); }
+                        throw new RuntimeException("local " + i + " type is " +
+                                observed + ", expected " + expected);
                     }
                 }
-
-                Object[] operands = (Object[]) getOperands.invoke(f);
-                for (int i = 0; i < operands.length; i++) {
-                    System.out.format("  operand %d: %s type %s%n", i, operands[i],
-                                      type(operands[i]));
-                }
-
-                Object[] monitors = (Object[]) getMonitors.invoke(f);
-                for (int i = 0; i < monitors.length; i++) {
-                    System.out.format("  monitor %d: %s%n", i, monitors[i]);
-                }
             }
-        } else {
-            for (StackFrame f : frames) {
-                if (liveStackFrameClass.isInstance(f)) {
-                    throw new RuntimeException("should not be LiveStackFrame");
-                }
-            }
-        }
-        // Use local variables so they stay alive
-        System.out.println("Stayin' alive: "+x+" "+c+" "+hi+" "+l+" "+d);
+        );
     }
 
-    String type(Object o) throws Exception {
-        if (o == null) {
-            return "null";
-        } else if (primitiveValueClass.isInstance(o)) {
-            char c = (char)primitiveType.invoke(o);
-            return String.valueOf(c);
-        } else {
-            return o.getClass().getName();
+    /**
+     * Basic sanity check for locals and operands
+     */
+    @Test(dataProvider = "provider")
+    public static void sanityCheck(StackFrame... frames) {
+        if (debug) {
+            System.out.println("Running sanityCheck");
         }
+        try {
+            Stream<StackFrame> stream = Arrays.stream(frames);
+            if (debug) {
+                stream.forEach(LocalsAndOperands::printLocals);
+            } else {
+                System.out.println(stream.count() + " frames");
+            }
+        } catch (Throwable t) {
+            dumpStackWithLocals(frames);
+            throw t;
+        }
+    }
+
+    /**
+     * Sanity check for locals and operands, including testng/jtreg frames
+     */
+    @Test(dataProvider = "unfilteredProvider")
+    public static void unfilteredSanityCheck(StackFrame... frames) {
+        if (debug) {
+            System.out.println("Running unfilteredSanityCheck");
+        }
+        try {
+            Stream<StackFrame> stream = Arrays.stream(frames);
+            if (debug) {
+                stream.forEach(f -> { System.out.println(f + ": " +
+                        invokeGetLocals(f).length + " locals"); } );
+            } else {
+                System.out.println(stream.count() + " frames");
+            }
+        } catch (Throwable t) {
+            dumpStackWithLocals(frames);
+            throw t;
+        }
+    }
+
+    /**
+     * Test that LiveStackFrames are not provided with the default StackWalker
+     * options.
+     */
+    @Test(dataProvider = "noLocalsProvider")
+    public static void withoutLocalsAndOperands(StackFrame... frames) {
+        for (StackFrame frame : frames) {
+            if (liveStackFrameClass.isInstance(frame)) {
+                throw new RuntimeException("should not be LiveStackFrame");
+            }
+        }
+    }
+
+    static class Tester {
+        private StackWalker walker;
+        private boolean filter = true; // Filter out testng/jtreg/etc frames?
+
+        Tester() {
+            this.walker = extendedWalker;
+        }
+
+        Tester(StackWalker walker, boolean filter) {
+            this.walker = walker;
+            this.filter = filter;
+        }
+
+        /**
+         * Perform stackwalk without keeping local variables alive and return an
+         * array of the collected StackFrames
+         */
+        private synchronized StackFrame[] testLocals() {
+            // Unused local variables will become dead
+            int x = 10;
+            char c = 'z';
+            String hi = "himom";
+            long l = 1000000L;
+            double d =  3.1415926;
+
+            if (filter) {
+                return walker.walk(s -> s.filter(f -> TEST_METHODS.contains(f
+                        .getMethodName())).collect(Collectors.toList()))
+                        .toArray(new StackFrame[0]);
+            } else {
+                return walker.walk(s -> s.collect(Collectors.toList()))
+                        .toArray(new StackFrame[0]);
+            }
+        }
+
+        /**
+         * Perform stackwalk, keeping local variables alive, and return a list of
+         * the collected StackFrames
+         */
+        private synchronized StackFrame[] testLocalsKeepAlive() {
+            int x = 10;
+            char c = 'z';
+            String hi = "himom";
+            long l = 1000000L;
+            double d =  3.1415926;
+
+            List<StackWalker.StackFrame> frames;
+            if (filter) {
+                frames = walker.walk(s -> s.filter(f -> TEST_METHODS.contains(f
+                        .getMethodName())).collect(Collectors.toList()));
+            } else {
+                frames = walker.walk(s -> s.collect(Collectors.toList()));
+            }
+
+            // Use local variables so they stay alive
+            System.out.println("Stayin' alive: "+x+" "+c+" "+hi+" "+l+" "+d);
+            return frames.toArray(new StackFrame[0]); // FIXME: convert to Array here
+        }
+
+        // Expected values for locals in testLocals() & testLocalsKeepAlive()
+        // TODO: use real values instead of Strings, rebuild doubles & floats, etc
+        private final static String[] LOCAL_VALUES = new String[] {
+            null, // skip, LocalsAndOperands$Tester@XXX identity is different each run
+            "10",
+            "122",
+            "himom",
+            "0",
+            null, // skip, fix in 8156073
+            null, // skip, fix in 8156073
+            null, // skip, fix in 8156073
+            "0"
+        };
+
+        // Expected types for locals in testLocals() & testLocalsKeepAlive()
+        // TODO: use real types
+        private final static String[] LOCAL_TYPES = new String[] {
+            null, // skip
+            "I",
+            "I",
+            "java.lang.String",
+            "I",
+            "I",
+            "I",
+            "I",
+            "I"
+        };
+
+        final static Map NUM_LOCALS = Map.of("testLocals", 8,
+                                             "testLocalsKeepAlive",
+                                             LOCAL_VALUES.length);
+        private final static Collection<String> TEST_METHODS = NUM_LOCALS.keySet();
+    }
+
+    /**
+     * Print stack trace with locals
+     */
+    public static void dumpStackWithLocals(StackFrame...frames) {
+        Arrays.stream(frames).forEach(LocalsAndOperands::printLocals);
+    }
+
+    /**
+     * Print the StackFrame and an indexed list of its locals
+     */
+    public static void printLocals(StackWalker.StackFrame frame) {
+        try {
+            System.out.println(frame);
+            Object[] locals = (Object[]) getLocals.invoke(frame);
+            for (int i = 0; i < locals.length; i++) {
+                System.out.format("  local %d: %s type %s\n", i, locals[i], type(locals[i]));
+            }
+
+            Object[] operands = (Object[]) getOperands.invoke(frame);
+            for (int i = 0; i < operands.length; i++) {
+                System.out.format("  operand %d: %s type %s%n", i, operands[i],
+                                  type(operands[i]));
+            }
+
+            Object[] monitors = (Object[]) getMonitors.invoke(frame);
+            for (int i = 0; i < monitors.length; i++) {
+                System.out.format("  monitor %d: %s%n", i, monitors[i]);
+            }
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
+
+    private static String type(Object o) {
+        try {
+            if (o == null) {
+                return "null";
+            } else if (primitiveValueClass.isInstance(o)) {
+                char c = (char)primitiveType.invoke(o);
+                return String.valueOf(c);
+            } else {
+                return o.getClass().getName();
+            }
+        } catch(Exception e) { throw new RuntimeException(e); }
     }
 }
diff --git a/jdk/test/java/lang/StackWalker/LocalsCrash.java b/jdk/test/java/lang/StackWalker/LocalsCrash.java
new file mode 100644
index 0000000..b50dd26
--- /dev/null
+++ b/jdk/test/java/lang/StackWalker/LocalsCrash.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8147039
+ * @summary Test for -Xcomp crash that happened before 8147039 fix
+ * @run testng/othervm -Xcomp LocalsCrash
+ */
+
+import org.testng.annotations.*;
+import java.lang.reflect.*;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class LocalsCrash {
+    static Class<?> liveStackFrameClass;
+    static Method getStackWalker;
+
+    static {
+        try {
+            liveStackFrameClass = Class.forName("java.lang.LiveStackFrame");
+            getStackWalker = liveStackFrameClass.getMethod("getStackWalker");
+            getStackWalker.setAccessible(true);
+        } catch (Throwable t) { throw new RuntimeException(t); }
+    }
+
+    private StackWalker walker;
+
+    LocalsCrash() {
+        try {
+            walker = (StackWalker) getStackWalker.invoke(null);
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
+
+    @Test
+    public void test00() { doStackWalk(); }
+
+    @Test
+    public void test01() { doStackWalk(); }
+
+    private synchronized List<StackWalker.StackFrame> doStackWalk() {
+        try {
+            // Unused local variables will become dead
+            int x = 10;
+            char c = 'z';
+            String hi = "himom";
+            long l = 1000000L;
+            double d =  3.1415926;
+
+            return walker.walk(s -> s.collect(Collectors.toList()));
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
+}
diff --git a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh
index f5bb3b8..b428a59 100644
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh
@@ -80,5 +80,5 @@
 
 # Finally we run the test
 (cd "${TESTCLASSES}"; \
-  $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:classunload \
+  $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:class+unload \
     -javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar)
diff --git a/jdk/test/java/lang/invoke/ArrayLengthTest.java b/jdk/test/java/lang/invoke/ArrayLengthTest.java
new file mode 100644
index 0000000..3eabf97
--- /dev/null
+++ b/jdk/test/java/lang/invoke/ArrayLengthTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @run testng/othervm -ea -esa test.java.lang.invoke.ArrayLengthTest
+ */
+package test.java.lang.invoke;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+
+import static org.testng.AssertJUnit.*;
+
+import org.testng.annotations.*;
+
+public class ArrayLengthTest {
+
+    @DataProvider
+    Object[][] arrayClasses() {
+        return new Object[][] {
+                {int[].class},
+                {long[].class},
+                {float[].class},
+                {double[].class},
+                {boolean[].class},
+                {byte[].class},
+                {short[].class},
+                {char[].class},
+                {Object[].class},
+                {StringBuffer[].class}
+        };
+    }
+
+    @Test(dataProvider = "arrayClasses")
+    public void testArrayLength(Class<?> arrayClass) throws Throwable {
+        MethodHandle arrayLength = MethodHandles.arrayLength(arrayClass);
+        assertEquals(int.class, arrayLength.type().returnType());
+        assertEquals(arrayClass, arrayLength.type().parameterType(0));
+        Object array = MethodHandles.arrayConstructor(arrayClass).invoke(10);
+        assertEquals(10, arrayLength.invoke(array));
+    }
+
+    @Test(dataProvider = "arrayClasses", expectedExceptions = NullPointerException.class)
+    public void testArrayLengthInvokeNPE(Class<?> arrayClass) throws Throwable {
+        MethodHandle arrayLength = MethodHandles.arrayLength(arrayClass);
+        arrayLength.invoke(null);
+    }
+
+    @Test(expectedExceptions = IllegalArgumentException.class)
+    public void testArrayLengthNoArray() {
+        MethodHandles.arrayLength(String.class);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void testArrayLengthNPE() {
+        MethodHandles.arrayLength(null);
+    }
+
+}
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java
index 59737db..b8cbc17 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java
@@ -40,6 +40,7 @@
 
 abstract class VarHandleBaseTest {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     interface ThrowingRunnable {
         void run() throws Throwable;
@@ -211,7 +212,6 @@
     }
 
     static MethodHandle findVirtual(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        mt = vh.accessModeType(tam.toAccessMode());
         MethodHandle mh;
         try {
             mh = MethodHandles.publicLookup().
@@ -221,36 +221,26 @@
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
-        return bind(vh, tam, mh, mt);
+        return bind(vh, mh, mt);
     }
 
-    static MethodHandle varHandleInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        mt = vh.accessModeType(tam.toAccessMode());
+    static MethodHandle varHandleInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) {
         MethodHandle mh = MethodHandles.varHandleInvoker(
                 tam.toAccessMode(),
                 mt);
 
-        return bind(vh, tam, mh, mt);
+        return bind(vh, mh, mt);
     }
 
-    static MethodHandle varHandleInvokerWithSymbolicTypeDescriptor(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        MethodHandle mh = MethodHandles.varHandleInvoker(
-                tam.toAccessMode(),
-                mt);
-
-        return bind(vh, tam, mh, mt);
-    }
-
-    static MethodHandle varHandleExactInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        mt = vh.accessModeType(tam.toAccessMode());
+    static MethodHandle varHandleExactInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) {
         MethodHandle mh = MethodHandles.varHandleExactInvoker(
                 tam.toAccessMode(),
                 mt);
 
-        return bind(vh, tam, mh, mt);
+        return bind(vh, mh, mt);
     }
 
-    private static MethodHandle bind(VarHandle vh, TestAccessMode testAccessMode, MethodHandle mh, MethodType emt) {
+    private static MethodHandle bind(VarHandle vh, MethodHandle mh, MethodType emt) {
         assertEquals(mh.type(), emt.insertParameterTypes(0, VarHandle.class),
                      "MethodHandle type differs from access mode type");
 
@@ -268,33 +258,30 @@
     enum VarHandleToMethodHandle {
         VAR_HANDLE_TO_METHOD_HANDLE(
                 "VarHandle.toMethodHandle",
+                true,
                 VarHandleBaseTest::toMethodHandle),
         METHOD_HANDLES_LOOKUP_FIND_VIRTUAL(
                 "Lookup.findVirtual",
+                false,
                 VarHandleBaseTest::findVirtual),
-        METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_ACCESS_MODE_TYPE(
-                "MethodHandles.varHandleInvoker(accessModeType)",
-                VarHandleBaseTest::varHandleInvokerWithAccessModeType),
-        METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_SYMBOLIC_TYPE_DESCRIPTOR(
-                "MethodHandles.varHandleInvoker(symbolicTypeDescriptor)",
-                VarHandleBaseTest::varHandleInvokerWithSymbolicTypeDescriptor),
-        METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER_WITH_ACCESS_MODE_TYPE(
-                "MethodHandles.varHandleExactInvoker(accessModeType)",
-                VarHandleBaseTest::varHandleExactInvokerWithAccessModeType);
+        METHOD_HANDLES_VAR_HANDLE_INVOKER(
+                "MethodHandles.varHandleInvoker",
+                false,
+                VarHandleBaseTest::varHandleInvoker),
+        METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER(
+                "MethodHandles.varHandleExactInvoker",
+                true,
+                VarHandleBaseTest::varHandleExactInvoker);
 
         final String desc;
+        final boolean isExact;
         final TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f;
-        final boolean exact;
 
-        VarHandleToMethodHandle(String desc, TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f) {
-            this(desc, f, false);
-        }
-
-        VarHandleToMethodHandle(String desc, TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f,
-                                boolean exact) {
+        VarHandleToMethodHandle(String desc, boolean isExact,
+                                TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f) {
             this.desc = desc;
             this.f = f;
-            this.exact = exact;
+            this.isExact = isExact;
         }
 
         MethodHandle apply(VarHandle vh, TestAccessMode am, MethodType mt) {
@@ -363,6 +350,15 @@
             return amToHandle.computeIfAbsent(
                     amt, k -> f.apply(vh, am, mt));
         }
+
+        Class<? extends Throwable> getWMTEOOrOther(Class<? extends Throwable> c) {
+            return f.isExact ? WrongMethodTypeException.class : c;
+        }
+
+        void checkWMTEOrCCE(ThrowingRunnable r) {
+            checkWithThrowable(getWMTEOOrOther(ClassCastException.class), null, r);
+        }
+
     }
 
     interface AccessTestAction<T> {
@@ -475,4 +471,4 @@
             assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType());
         }
     }
-}
\ No newline at end of file
+}
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java
index 0210914..9a02753 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(recv, true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(recv, true);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(true);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(recv, true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(recv, true);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(true);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(array, i, true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(array, i, true);
         });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java
index e550815..1754490 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet(recv, (byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd(recv, (byte)1);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet((byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd((byte)1);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet(recv, (byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd(recv, (byte)1);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet((byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd((byte)1);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet(array, i, (byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd(array, i, (byte)1);
         });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java
index 5c13c6d..88bad84 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet(recv, 'a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd(recv, 'a');
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet('a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd('a');
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet(recv, 'a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd(recv, 'a');
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet('a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd('a');
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet(array, i, 'a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd(array, i, 'a');
         });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java
index 65125e3..1861e59 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(recv, 1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(recv, 1.0d);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(1.0d);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(recv, 1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(recv, 1.0d);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(1.0d);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(array, i, 1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(array, i, 1.0d);
         });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java
index 8e7491a..dce87f7 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(recv, 1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(recv, 1.0f);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(1.0f);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(recv, 1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(recv, 1.0f);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(1.0f);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(array, i, 1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(array, i, 1.0f);
         });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java
index bfcb5fe..1897821 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java
@@ -402,29 +402,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) vh.get(recv);
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) vh.get(recv);
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) vh.get(recv);
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) vh.get(recv);
             assertEquals(x, 1, "weakCompareAndSetVolatile int value");
         }
@@ -543,36 +555,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet(1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) vh.get();
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire(2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) vh.get();
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease(1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) vh.get();
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile(2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) vh.get();
-            assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+            assertEquals(x, 1, "weakCompareAndSetVolatile int");
         }
 
         // Compare set and get
         {
-            int o = (int) vh.getAndSet( 2);
+            int o = (int) vh.getAndSet(2);
             assertEquals(o, 1, "getAndSet int");
             int x = (int) vh.get();
             assertEquals(x, 2, "getAndSet int value");
@@ -687,31 +711,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSet int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSet int");
                 int x = (int) vh.get(array, i);
                 assertEquals(x, 2, "weakCompareAndSet int value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetAcquire int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire int");
                 int x = (int) vh.get(array, i);
                 assertEquals(x, 1, "weakCompareAndSetAcquire int");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSetRelease int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease int");
                 int x = (int) vh.get(array, i);
                 assertEquals(x, 2, "weakCompareAndSetRelease int");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetVolatile int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile int");
                 int x = (int) vh.get(array, i);
-                assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+                assertEquals(x, 1, "weakCompareAndSetVolatile int");
             }
 
             // Compare set and get
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java
index 1f02bed..adea5ed 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java
@@ -402,29 +402,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) vh.get(recv);
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) vh.get(recv);
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) vh.get(recv);
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) vh.get(recv);
             assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
         }
@@ -543,36 +555,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) vh.get();
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) vh.get();
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) vh.get();
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) vh.get();
-            assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+            assertEquals(x, 1L, "weakCompareAndSetVolatile long");
         }
 
         // Compare set and get
         {
-            long o = (long) vh.getAndSet( 2L);
+            long o = (long) vh.getAndSet(2L);
             assertEquals(o, 1L, "getAndSet long");
             long x = (long) vh.get();
             assertEquals(x, 2L, "getAndSet long value");
@@ -687,31 +711,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSet long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSet long");
                 long x = (long) vh.get(array, i);
                 assertEquals(x, 2L, "weakCompareAndSet long value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetAcquire long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire long");
                 long x = (long) vh.get(array, i);
                 assertEquals(x, 1L, "weakCompareAndSetAcquire long");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSetRelease long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease long");
                 long x = (long) vh.get(array, i);
                 assertEquals(x, 2L, "weakCompareAndSetRelease long");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetVolatile long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile long");
                 long x = (long) vh.get(array, i);
-                assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+                assertEquals(x, 1L, "weakCompareAndSetVolatile long");
             }
 
             // Compare set and get
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java
index 822252f..a8091a8 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet(recv, (short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd(recv, (short)1);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet((short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd((short)1);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet(recv, (short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd(recv, (short)1);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet((short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd((short)1);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet(array, i, (short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd(array, i, (short)1);
         });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java
index 9e4ec77..405206e 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java
@@ -416,29 +416,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) vh.get(recv);
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) vh.get(recv);
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) vh.get(recv);
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) vh.get(recv);
             assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
         }
@@ -555,36 +567,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) vh.get();
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) vh.get();
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) vh.get();
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) vh.get();
-            assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+            assertEquals(x, "foo", "weakCompareAndSetVolatile String");
         }
 
         // Compare set and get
         {
-            String o = (String) vh.getAndSet( "bar");
+            String o = (String) vh.getAndSet("bar");
             assertEquals(o, "foo", "getAndSet String");
             String x = (String) vh.get();
             assertEquals(x, "bar", "getAndSet String value");
@@ -697,31 +721,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSet String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSet String");
                 String x = (String) vh.get(array, i);
                 assertEquals(x, "bar", "weakCompareAndSet String value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetAcquire String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire String");
                 String x = (String) vh.get(array, i);
                 assertEquals(x, "foo", "weakCompareAndSetAcquire String");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSetRelease String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease String");
                 String x = (String) vh.get(array, i);
                 assertEquals(x, "bar", "weakCompareAndSetRelease String");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetVolatile String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile String");
                 String x = (String) vh.get(array, i);
-                assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+                assertEquals(x, "foo", "weakCompareAndSetVolatile String");
             }
 
             // Compare set and get
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java
index 8159e16..8038315 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java
@@ -50,7 +50,7 @@
 
     static final char VALUE_2 = (char)0x1112;
 
-    static final char VALUE_3 = (char)0x2122;
+    static final char VALUE_3 = (char)0xFFFE;
 
 
     @Override
@@ -254,6 +254,10 @@
                 vh.setOpaque(array, ci, VALUE_1);
             });
             checkUOE(() -> {
+                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
+            });
+
+            checkUOE(() -> {
                 char r = (char) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
             });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java
index a327b00..53db9cd 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java
@@ -50,7 +50,7 @@
 
     static final double VALUE_2 = 0x1112131415161718L;
 
-    static final double VALUE_3 = 0x2122232425262728L;
+    static final double VALUE_3 = 0xFFFEFDFCFBFAF9F8L;
 
 
     @Override
@@ -254,9 +254,7 @@
             checkROBE(() -> {
                 double o = (double) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkUOE(() -> {
                 double o = (double) vh.getAndAdd(array, ci, VALUE_1);
@@ -700,22 +698,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet double value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease double");
                 }
@@ -840,22 +847,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet double value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease double");
                 }
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java
index 196c810..d2688cf 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java
@@ -50,7 +50,7 @@
 
     static final float VALUE_2 = 0x11121314;
 
-    static final float VALUE_3 = 0x21222324;
+    static final float VALUE_3 = 0xFFFEFDFC;
 
 
     @Override
@@ -254,9 +254,7 @@
             checkROBE(() -> {
                 float o = (float) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkUOE(() -> {
                 float o = (float) vh.getAndAdd(array, ci, VALUE_1);
@@ -700,22 +698,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet float value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease float");
                 }
@@ -840,22 +847,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet float value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease float");
                 }
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java
index 400c206..9e47532 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java
@@ -50,7 +50,7 @@
 
     static final int VALUE_2 = 0x11121314;
 
-    static final int VALUE_3 = 0x21222324;
+    static final int VALUE_3 = 0xFFFEFDFC;
 
 
     @Override
@@ -247,9 +247,7 @@
             checkROBE(() -> {
                 int o = (int) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkROBE(() -> {
                 int o = (int) vh.getAndAdd(array, ci, VALUE_1);
@@ -714,22 +712,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
                 }
@@ -863,22 +870,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
                 }
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java
index a0cabc8..f9ed92f 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java
@@ -50,7 +50,7 @@
 
     static final long VALUE_2 = 0x1112131415161718L;
 
-    static final long VALUE_3 = 0x2122232425262728L;
+    static final long VALUE_3 = 0xFFFEFDFCFBFAF9F8L;
 
 
     @Override
@@ -247,9 +247,7 @@
             checkROBE(() -> {
                 long o = (long) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkROBE(() -> {
                 long o = (long) vh.getAndAdd(array, ci, VALUE_1);
@@ -714,22 +712,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet long value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease long");
                 }
@@ -863,22 +870,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet long value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease long");
                 }
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java
index 2632b00..0a9aa6e 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java
@@ -50,7 +50,7 @@
 
     static final short VALUE_2 = (short)0x1112;
 
-    static final short VALUE_3 = (short)0x2122;
+    static final short VALUE_3 = (short)0xFFFE;
 
 
     @Override
@@ -254,6 +254,10 @@
                 vh.setOpaque(array, ci, VALUE_1);
             });
             checkUOE(() -> {
+                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
+            });
+
+            checkUOE(() -> {
                 short r = (short) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
             });
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java
index 8ccf798..00f78a5 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java
@@ -208,31 +208,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+            assertEquals(x, 1, "weakCompareAndSetVolatile int");
         }
 
         // Compare set and get
@@ -349,36 +361,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+            assertEquals(x, 1, "weakCompareAndSetVolatile int");
         }
 
         // Compare set and get
         {
-            int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2);
+            int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2);
             assertEquals(o, 1, "getAndSet int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2, "getAndSet int value");
@@ -493,31 +517,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSet int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSet int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2, "weakCompareAndSet int value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetAcquire int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 1, "weakCompareAndSetAcquire int");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSetRelease int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2, "weakCompareAndSetRelease int");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetVolatile int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+                assertEquals(x, 1, "weakCompareAndSetVolatile int");
             }
 
             // Compare set and get
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java
index 65493ec..2bb8b9a 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java
@@ -208,31 +208,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+            assertEquals(x, 1L, "weakCompareAndSetVolatile long");
         }
 
         // Compare set and get
@@ -349,36 +361,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+            assertEquals(x, 1L, "weakCompareAndSetVolatile long");
         }
 
         // Compare set and get
         {
-            long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2L);
+            long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2L);
             assertEquals(o, 1L, "getAndSet long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2L, "getAndSet long value");
@@ -493,31 +517,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSet long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSet long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2L, "weakCompareAndSet long value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetAcquire long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 1L, "weakCompareAndSetAcquire long");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSetRelease long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2L, "weakCompareAndSetRelease long");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetVolatile long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+                assertEquals(x, 1L, "weakCompareAndSetVolatile long");
             }
 
             // Compare set and get
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java
index 5ae7c87..dc6f8ec 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java
@@ -208,31 +208,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+            assertEquals(x, "foo", "weakCompareAndSetVolatile String");
         }
 
         // Compare set and get
@@ -345,36 +357,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+            assertEquals(x, "foo", "weakCompareAndSetVolatile String");
         }
 
         // Compare set and get
         {
-            String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact("bar");
+            String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact( "bar");
             assertEquals(o, "foo", "getAndSet String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "bar", "getAndSet String value");
@@ -485,31 +509,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSet String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSet String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, "bar", "weakCompareAndSet String value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetAcquire String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, "foo", "weakCompareAndSetAcquire String");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSetRelease String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, "bar", "weakCompareAndSetRelease String");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetVolatile String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+                assertEquals(x, "foo", "weakCompareAndSetVolatile String");
             }
 
             // Compare set and get
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java
index 75ba7ae..df68014 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeBoolean
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeBoolean
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class)).
-                    invoke(null);
+                boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)).
+                    invokeExact((VarHandleTestMethodTypeBoolean) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, boolean.class)).
-                    invoke(null, true);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
+                    invokeExact((VarHandleTestMethodTypeBoolean) null, true);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, boolean.class)).
-                    invoke(Void.class, true);
+                    invokeExact(Void.class, true);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, boolean.class)).
-                    invoke(0, true);
+                    invokeExact(0, true);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
-                    invoke(recv, true, Void.class);
+                    invokeExact(recv, true, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 boolean x = (boolean) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, boolean.class, Class.class)).
-                    invoke(true, Void.class);
+                    invokeExact(true, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class)).
-                    invoke(null, 0);
+                boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class)).
+                    invokeExact((boolean[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, boolean.class)).
-                    invoke(null, 0, true);
+                hs.get(am, methodType(void.class, boolean[].class, int.class, boolean.class)).
+                    invokeExact((boolean[]) null, 0, true);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, boolean.class)).
-                    invoke(Void.class, 0, true);
+                    invokeExact(Void.class, 0, true);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, boolean.class)).
-                    invoke(0, 0, true);
+                    invokeExact(0, 0, true);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, boolean[].class, Class.class, boolean.class)).
-                    invoke(array, Void.class, true);
+                    invokeExact(array, Void.class, true);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
-                    invoke(array, 0, true, Void.class);
+                    invokeExact(array, 0, true, Void.class);
             });
         }
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java
index b212bfc..0bfddc7 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeByte
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeByte
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeByte::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeByte::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                byte x = (byte) hs.get(am, methodType(byte.class, Void.class)).
-                    invoke(null);
+                byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)).
+                    invokeExact((VarHandleTestMethodTypeByte) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 byte x = (byte) hs.get(am, methodType(byte.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 byte x = (byte) hs.get(am, methodType(byte.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 byte x = (byte) hs.get(am, methodType(byte.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, byte.class)).
-                    invoke(null, (byte)1);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class)).
+                    invokeExact((VarHandleTestMethodTypeByte) null, (byte)1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, byte.class)).
-                    invoke(Void.class, (byte)1);
+                    invokeExact(Void.class, (byte)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, byte.class)).
-                    invoke(0, (byte)1);
+                    invokeExact(0, (byte)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)).
-                    invoke(recv, (byte)1, Void.class);
+                    invokeExact(recv, (byte)1, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 byte x = (byte) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, byte.class, Class.class)).
-                    invoke((byte)1, Void.class);
+                    invokeExact((byte)1, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class)).
-                    invoke(null, 0);
+                byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class)).
+                    invokeExact((byte[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 byte x = (byte) hs.get(am, methodType(byte.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, byte.class)).
-                    invoke(null, 0, (byte)1);
+                hs.get(am, methodType(void.class, byte[].class, int.class, byte.class)).
+                    invokeExact((byte[]) null, 0, (byte)1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, byte.class)).
-                    invoke(Void.class, 0, (byte)1);
+                    invokeExact(Void.class, 0, (byte)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, byte.class)).
-                    invoke(0, 0, (byte)1);
+                    invokeExact(0, 0, (byte)1);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, byte[].class, Class.class, byte.class)).
-                    invoke(array, Void.class, (byte)1);
+                    invokeExact(array, Void.class, (byte)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
-                    invoke(array, 0, (byte)1, Void.class);
+                    invokeExact(array, 0, (byte)1, Void.class);
             });
         }
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java
index 6ac8a0f..8d5166d 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeChar
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeChar
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeChar::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeChar::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                char x = (char) hs.get(am, methodType(char.class, Void.class)).
-                    invoke(null);
+                char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)).
+                    invokeExact((VarHandleTestMethodTypeChar) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 char x = (char) hs.get(am, methodType(char.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 char x = (char) hs.get(am, methodType(char.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 char x = (char) hs.get(am, methodType(char.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, char.class)).
-                    invoke(null, 'a');
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class)).
+                    invokeExact((VarHandleTestMethodTypeChar) null, 'a');
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, char.class)).
-                    invoke(Void.class, 'a');
+                    invokeExact(Void.class, 'a');
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, char.class)).
-                    invoke(0, 'a');
+                    invokeExact(0, 'a');
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)).
-                    invoke(recv, 'a', Void.class);
+                    invokeExact(recv, 'a', Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 char x = (char) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, char.class, Class.class)).
-                    invoke('a', Void.class);
+                    invokeExact('a', Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                char x = (char) hs.get(am, methodType(char.class, Void.class, int.class)).
-                    invoke(null, 0);
+                char x = (char) hs.get(am, methodType(char.class, char[].class, int.class)).
+                    invokeExact((char[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 char x = (char) hs.get(am, methodType(char.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 char x = (char) hs.get(am, methodType(char.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, char[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 char x = (char) hs.get(am, methodType(char.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, char.class)).
-                    invoke(null, 0, 'a');
+                hs.get(am, methodType(void.class, char[].class, int.class, char.class)).
+                    invokeExact((char[]) null, 0, 'a');
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, char.class)).
-                    invoke(Void.class, 0, 'a');
+                    invokeExact(Void.class, 0, 'a');
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, char.class)).
-                    invoke(0, 0, 'a');
+                    invokeExact(0, 0, 'a');
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, char[].class, Class.class, char.class)).
-                    invoke(array, Void.class, 'a');
+                    invokeExact(array, Void.class, 'a');
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
-                    invoke(array, 0, 'a', Void.class);
+                    invokeExact(array, 0, 'a', Void.class);
             });
         }
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java
index e5fc073..f353101 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeDouble
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeDouble
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeDouble::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeDouble::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                double x = (double) hs.get(am, methodType(double.class, Void.class)).
-                    invoke(null);
+                double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)).
+                    invokeExact((VarHandleTestMethodTypeDouble) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 double x = (double) hs.get(am, methodType(double.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 double x = (double) hs.get(am, methodType(double.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeDouble.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeDouble.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 double x = (double) hs.get(am, methodType(double.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, double.class)).
-                    invoke(null, 1.0d);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class)).
+                    invokeExact((VarHandleTestMethodTypeDouble) null, 1.0d);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, double.class)).
-                    invoke(Void.class, 1.0d);
+                    invokeExact(Void.class, 1.0d);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, double.class)).
-                    invoke(0, 1.0d);
+                    invokeExact(0, 1.0d);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class, Class.class)).
-                    invoke(recv, 1.0d, Void.class);
+                    invokeExact(recv, 1.0d, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 double x = (double) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, double.class, Class.class)).
-                    invoke(1.0d, Void.class);
+                    invokeExact(1.0d, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                double x = (double) hs.get(am, methodType(double.class, Void.class, int.class)).
-                    invoke(null, 0);
+                double x = (double) hs.get(am, methodType(double.class, double[].class, int.class)).
+                    invokeExact((double[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 double x = (double) hs.get(am, methodType(double.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 double x = (double) hs.get(am, methodType(double.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 double x = (double) hs.get(am, methodType(double.class, double[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, double[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, double[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 double x = (double) hs.get(am, methodType(double.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 double x = (double) hs.get(am, methodType(double.class, double[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, double.class)).
-                    invoke(null, 0, 1.0d);
+                hs.get(am, methodType(void.class, double[].class, int.class, double.class)).
+                    invokeExact((double[]) null, 0, 1.0d);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, double.class)).
-                    invoke(Void.class, 0, 1.0d);
+                    invokeExact(Void.class, 0, 1.0d);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, double[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, double.class)).
-                    invoke(0, 0, 1.0d);
+                    invokeExact(0, 0, 1.0d);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, double[].class, Class.class, double.class)).
-                    invoke(array, Void.class, 1.0d);
+                    invokeExact(array, Void.class, 1.0d);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, double[].class, int.class, Class.class)).
-                    invoke(array, 0, 1.0d, Void.class);
+                    invokeExact(array, 0, 1.0d, Void.class);
             });
         }
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java
index c1bee03..b07049d 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeFloat
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeFloat
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeFloat::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeFloat::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                float x = (float) hs.get(am, methodType(float.class, Void.class)).
-                    invoke(null);
+                float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)).
+                    invokeExact((VarHandleTestMethodTypeFloat) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 float x = (float) hs.get(am, methodType(float.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 float x = (float) hs.get(am, methodType(float.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeFloat.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeFloat.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 float x = (float) hs.get(am, methodType(float.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, float.class)).
-                    invoke(null, 1.0f);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class)).
+                    invokeExact((VarHandleTestMethodTypeFloat) null, 1.0f);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, float.class)).
-                    invoke(Void.class, 1.0f);
+                    invokeExact(Void.class, 1.0f);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, float.class)).
-                    invoke(0, 1.0f);
+                    invokeExact(0, 1.0f);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class, Class.class)).
-                    invoke(recv, 1.0f, Void.class);
+                    invokeExact(recv, 1.0f, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 float x = (float) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, float.class, Class.class)).
-                    invoke(1.0f, Void.class);
+                    invokeExact(1.0f, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                float x = (float) hs.get(am, methodType(float.class, Void.class, int.class)).
-                    invoke(null, 0);
+                float x = (float) hs.get(am, methodType(float.class, float[].class, int.class)).
+                    invokeExact((float[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 float x = (float) hs.get(am, methodType(float.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 float x = (float) hs.get(am, methodType(float.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 float x = (float) hs.get(am, methodType(float.class, float[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, float[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, float[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 float x = (float) hs.get(am, methodType(float.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 float x = (float) hs.get(am, methodType(float.class, float[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, float.class)).
-                    invoke(null, 0, 1.0f);
+                hs.get(am, methodType(void.class, float[].class, int.class, float.class)).
+                    invokeExact((float[]) null, 0, 1.0f);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, float.class)).
-                    invoke(Void.class, 0, 1.0f);
+                    invokeExact(Void.class, 0, 1.0f);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, float[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, float.class)).
-                    invoke(0, 0, 1.0f);
+                    invokeExact(0, 0, 1.0f);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, float[].class, Class.class, float.class)).
-                    invoke(array, Void.class, 1.0f);
+                    invokeExact(array, Void.class, 1.0f);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, float[].class, int.class, Class.class)).
-                    invoke(array, 0, 1.0f, Void.class);
+                    invokeExact(array, 0, 1.0f, Void.class);
             });
         }
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java
index 13b6b06..67fca94 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeInt
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeInt
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
                                                      false));
         }
@@ -644,211 +646,211 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class)).
-                    invoke(null);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, int.class)).
-                    invoke(null, 1);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class)).
-                    invoke(0, 1);
+                    invokeExact(0, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class)).
-                    invoke(null, 1, 1);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 1, 1);
+                    invokeExact(Void.class, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
-                    invoke(recv, Void.class, 1);
+                    invokeExact(recv, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , int.class, int.class)).
-                    invoke(0, 1, 1);
+                    invokeExact(0, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
-                    invoke(recv, 1, 1, Void.class);
+                    invokeExact(recv, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
-                    invoke(null, 1, 1);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 1, 1);
+                    invokeExact(Void.class, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
-                    invoke(recv, Void.class, 1);
+                    invokeExact(recv, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class , int.class, int.class)).
-                    invoke(0, 1, 1);
+                    invokeExact(0, 1, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
-                    invoke(recv, 1, 1);
+                    invokeExact(recv, 1, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
-                    invoke(recv, 1, 1);
+                    invokeExact(recv, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
-                    invoke(recv, 1, 1, Void.class);
+                    invokeExact(recv, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
-                    invoke(null, 1);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
-                    invoke(0, 1);
+                    invokeExact(0, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
-                    invoke(null, 1);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
-                    invoke(0, 1);
+                    invokeExact(0, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
         }
     }
@@ -1190,52 +1192,52 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Class.class)).
-                    invoke(1, 1, Void.class);
+                    invokeExact(1, 1, Void.class);
             });
         }
 
@@ -1243,29 +1245,29 @@
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int.class, int.class)).
-                    invoke(1, 1);
+                    invokeExact(1, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
-                    invoke(1, 1);
+                    invokeExact(1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, Class.class)).
-                    invoke(1, 1, Void.class);
+                    invokeExact(1, 1, Void.class);
             });
         }
 
@@ -1273,25 +1275,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
         }
 
@@ -1299,25 +1301,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
         }
     }
@@ -1909,237 +1911,237 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
-                    invoke(null, 0);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class)).
+                    invokeExact((int[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, int[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, int.class)).
-                    invoke(null, 0, 1);
+                hs.get(am, methodType(void.class, int[].class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1);
+                    invokeExact(Void.class, 0, 1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1);
+                    invokeExact(0, 0, 1);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, int[].class, Class.class, int.class)).
-                    invoke(array, Void.class, 1);
+                    invokeExact(array, Void.class, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class, int.class)).
-                    invoke(null, 0, 1, 1);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1, 1);
+                    invokeExact(Void.class, 0, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, Class.class, int.class)).
-                    invoke(array, 0, Void.class, 1);
+                    invokeExact(array, 0, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1, 1);
+                    invokeExact(0, 0, 1, 1);
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, Class.class, int.class, int.class)).
-                    invoke(array, Void.class, 1, 1);
+                    invokeExact(array, Void.class, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, 1, Void.class);
+                    invokeExact(array, 0, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class, int.class)).
-                    invoke(null, 0, 1, 1);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1, 1);
+                    invokeExact(Void.class, 0, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class, int.class)).
-                    invoke(array, 0, Void.class, 1);
+                    invokeExact(array, 0, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1, 1);
+                    invokeExact(0, 0, 1, 1);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class, int.class)).
-                    invoke(array, Void.class, 1, 1);
+                    invokeExact(array, Void.class, 1, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class, int.class)).
-                    invoke(array, 0, 1, 1);
+                    invokeExact(array, 0, 1, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
-                    invoke(array, 0, 1, 1);
+                    invokeExact(array, 0, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, 1, Void.class);
+                    invokeExact(array, 0, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
-                    invoke(null, 0, 1);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1);
+                    invokeExact(Void.class, 0, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1);
+                    invokeExact(0, 0, 1);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
-                    invoke(array, Void.class, 1);
+                    invokeExact(array, Void.class, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
-                    invoke(null, 0, 1);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1);
+                    invokeExact(Void.class, 0, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1);
+                    invokeExact(0, 0, 1);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
-                    invoke(array, Void.class, 1);
+                    invokeExact(array, Void.class, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
         }
     }
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java
index 4415168..0972e66 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeLong
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeLong
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeLong::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeLong::testArrayWrongMethodType,
                                                      false));
         }
@@ -644,211 +646,211 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class)).
-                    invoke(null);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, long.class)).
-                    invoke(null, 1L);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, long.class)).
-                    invoke(0, 1L);
+                    invokeExact(0, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, long.class, long.class)).
-                    invoke(null, 1L, 1L);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class, long.class)).
-                    invoke(Void.class, 1L, 1L);
+                    invokeExact(Void.class, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
-                    invoke(recv, Void.class, 1L);
+                    invokeExact(recv, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , long.class, long.class)).
-                    invoke(0, 1L, 1L);
+                    invokeExact(0, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
-                    invoke(recv, 1L, 1L, Void.class);
+                    invokeExact(recv, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, long.class, long.class)).
-                    invoke(null, 1L, 1L);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class, long.class)).
-                    invoke(Void.class, 1L, 1L);
+                    invokeExact(Void.class, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
-                    invoke(recv, Void.class, 1L);
+                    invokeExact(recv, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class , long.class, long.class)).
-                    invoke(0, 1L, 1L);
+                    invokeExact(0, 1L, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
-                    invoke(recv, 1L, 1L);
+                    invokeExact(recv, 1L, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
-                    invoke(recv, 1L, 1L);
+                    invokeExact(recv, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
-                    invoke(recv, 1L, 1L, Void.class);
+                    invokeExact(recv, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)).
-                    invoke(null, 1L);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
-                    invoke(0, 1L);
+                    invokeExact(0, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)).
-                    invoke(null, 1L);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
-                    invoke(0, 1L);
+                    invokeExact(0, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
         }
     }
@@ -1190,52 +1192,52 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class, Class.class)).
-                    invoke(1L, 1L, Void.class);
+                    invokeExact(1L, 1L, Void.class);
             });
         }
 
@@ -1243,29 +1245,29 @@
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long.class, long.class)).
-                    invoke(1L, 1L);
+                    invokeExact(1L, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class)).
-                    invoke(1L, 1L);
+                    invokeExact(1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long.class, long.class, Class.class)).
-                    invoke(1L, 1L, Void.class);
+                    invokeExact(1L, 1L, Void.class);
             });
         }
 
@@ -1273,25 +1275,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
         }
 
@@ -1299,25 +1301,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
         }
     }
@@ -1909,237 +1911,237 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class)).
-                    invoke(null, 0);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class)).
+                    invokeExact((long[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, long[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, long.class)).
-                    invoke(null, 0, 1L);
+                hs.get(am, methodType(void.class, long[].class, int.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, long.class)).
-                    invoke(Void.class, 0, 1L);
+                    invokeExact(Void.class, 0, 1L);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, long.class)).
-                    invoke(0, 0, 1L);
+                    invokeExact(0, 0, 1L);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, long[].class, Class.class, long.class)).
-                    invoke(array, Void.class, 1L);
+                    invokeExact(array, Void.class, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, long.class, long.class)).
-                    invoke(null, 0, 1L, 1L);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, long.class, long.class)).
-                    invoke(Void.class, 0, 1L, 1L);
+                    invokeExact(Void.class, 0, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, Class.class, long.class)).
-                    invoke(array, 0, Void.class, 1L);
+                    invokeExact(array, 0, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, long.class, long.class)).
-                    invoke(0, 0, 1L, 1L);
+                    invokeExact(0, 0, 1L, 1L);
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, Class.class, long.class, long.class)).
-                    invoke(array, Void.class, 1L, 1L);
+                    invokeExact(array, Void.class, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, 1L, Void.class);
+                    invokeExact(array, 0, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class, long.class)).
-                    invoke(null, 0, 1L, 1L);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class, long.class)).
-                    invoke(Void.class, 0, 1L, 1L);
+                    invokeExact(Void.class, 0, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class, long.class)).
-                    invoke(array, 0, Void.class, 1L);
+                    invokeExact(array, 0, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class, long.class)).
-                    invoke(0, 0, 1L, 1L);
+                    invokeExact(0, 0, 1L, 1L);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class, long.class)).
-                    invoke(array, Void.class, 1L, 1L);
+                    invokeExact(array, Void.class, 1L, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class, long.class)).
-                    invoke(array, 0, 1L, 1L);
+                    invokeExact(array, 0, 1L, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)).
-                    invoke(array, 0, 1L, 1L);
+                    invokeExact(array, 0, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, 1L, Void.class);
+                    invokeExact(array, 0, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)).
-                    invoke(null, 0, 1L);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
-                    invoke(Void.class, 0, 1L);
+                    invokeExact(Void.class, 0, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
-                    invoke(0, 0, 1L);
+                    invokeExact(0, 0, 1L);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
-                    invoke(array, Void.class, 1L);
+                    invokeExact(array, Void.class, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)).
-                    invoke(null, 0, 1L);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
-                    invoke(Void.class, 0, 1L);
+                    invokeExact(Void.class, 0, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
-                    invoke(0, 0, 1L);
+                    invokeExact(0, 0, 1L);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
-                    invoke(array, Void.class, 1L);
+                    invokeExact(array, Void.class, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
         }
     }
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java
index 634646e..16efabe 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeShort
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeShort
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeShort::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeShort::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                short x = (short) hs.get(am, methodType(short.class, Void.class)).
-                    invoke(null);
+                short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)).
+                    invokeExact((VarHandleTestMethodTypeShort) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 short x = (short) hs.get(am, methodType(short.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 short x = (short) hs.get(am, methodType(short.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 short x = (short) hs.get(am, methodType(short.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, short.class)).
-                    invoke(null, (short)1);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class)).
+                    invokeExact((VarHandleTestMethodTypeShort) null, (short)1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, short.class)).
-                    invoke(Void.class, (short)1);
+                    invokeExact(Void.class, (short)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, short.class)).
-                    invoke(0, (short)1);
+                    invokeExact(0, (short)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)).
-                    invoke(recv, (short)1, Void.class);
+                    invokeExact(recv, (short)1, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 short x = (short) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, short.class, Class.class)).
-                    invoke((short)1, Void.class);
+                    invokeExact((short)1, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                short x = (short) hs.get(am, methodType(short.class, Void.class, int.class)).
-                    invoke(null, 0);
+                short x = (short) hs.get(am, methodType(short.class, short[].class, int.class)).
+                    invokeExact((short[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 short x = (short) hs.get(am, methodType(short.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 short x = (short) hs.get(am, methodType(short.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, short[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 short x = (short) hs.get(am, methodType(short.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, short.class)).
-                    invoke(null, 0, (short)1);
+                hs.get(am, methodType(void.class, short[].class, int.class, short.class)).
+                    invokeExact((short[]) null, 0, (short)1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, short.class)).
-                    invoke(Void.class, 0, (short)1);
+                    invokeExact(Void.class, 0, (short)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, short.class)).
-                    invoke(0, 0, (short)1);
+                    invokeExact(0, 0, (short)1);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, short[].class, Class.class, short.class)).
-                    invoke(array, Void.class, (short)1);
+                    invokeExact(array, Void.class, (short)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
-                    invoke(array, 0, (short)1, Void.class);
+                    invokeExact(array, 0, (short)1, Void.class);
             });
         }
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java
index f3b58c9..2cc8533 100644
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeString
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeString
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeString::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeString::testArrayWrongMethodType,
                                                      false));
         }
@@ -586,174 +588,174 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class)).
-                    invoke(null);
+                String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)).
-                    invoke(recv);
+            hs.checkWMTEOrCCE(() -> { // reference class
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, String.class)).
-                    invoke(null, "foo");
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, String.class)).
-                    invoke(0, "foo");
+                    invokeExact(0, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, String.class, String.class)).
-                    invoke(null, "foo", "foo");
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class, String.class)).
-                    invoke(Void.class, "foo", "foo");
+                    invokeExact(Void.class, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, Class.class, String.class)).
-                    invoke(recv, Void.class, "foo");
+                    invokeExact(recv, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , String.class, String.class)).
-                    invoke(0, "foo", "foo");
+                    invokeExact(0, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)).
-                    invoke(recv, "foo", "foo", Void.class);
+                    invokeExact(recv, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class, String.class, String.class)).
-                    invoke(null, "foo", "foo");
+                String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, String.class, String.class)).
-                    invoke(Void.class, "foo", "foo");
+                    invokeExact(Void.class, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class, String.class)).
-                    invoke(recv, Void.class, "foo");
+                    invokeExact(recv, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class , String.class, String.class)).
-                    invoke(0, "foo", "foo");
+                    invokeExact(0, "foo", "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class , String.class, String.class)).
-                    invoke(recv, "foo", "foo");
+                    invokeExact(recv, "foo", "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class , String.class, String.class)).
-                    invoke(recv, "foo", "foo");
+                    invokeExact(recv, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)).
-                    invoke(recv, "foo", "foo", Void.class);
+                    invokeExact(recv, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class, String.class)).
-                    invoke(null, "foo");
+                String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, String.class)).
-                    invoke(0, "foo");
+                    invokeExact(0, "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class, String.class)).
-                    invoke(recv, "foo");
+                    invokeExact(recv, "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class)).
-                    invoke(recv, "foo");
+                    invokeExact(recv, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
         }
 
@@ -1054,110 +1056,110 @@
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class, Class.class)).
-                    invoke("foo", "foo", Void.class);
+                    invokeExact("foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String.class, String.class)).
-                    invoke("foo", "foo");
+                    invokeExact("foo", "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class)).
-                    invoke("foo", "foo");
+                    invokeExact("foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String.class, String.class, Class.class)).
-                    invoke("foo", "foo", Void.class);
+                    invokeExact("foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String.class)).
-                    invoke("foo");
+                    invokeExact("foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class)).
-                    invoke("foo");
+                    invokeExact("foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
         }
 
@@ -1686,195 +1688,195 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                String x = (String) hs.get(am, methodType(String.class, Void.class, int.class)).
-                    invoke(null, 0);
+                String x = (String) hs.get(am, methodType(String.class, String[].class, int.class)).
+                    invokeExact((String[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, String[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, String.class)).
-                    invoke(null, 0, "foo");
+                hs.get(am, methodType(void.class, String[].class, int.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo");
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, String.class)).
-                    invoke(Void.class, 0, "foo");
+                    invokeExact(Void.class, 0, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 hs.get(am, methodType(void.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, String.class)).
-                    invoke(0, 0, "foo");
+                    invokeExact(0, 0, "foo");
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, String[].class, Class.class, String.class)).
-                    invoke(array, Void.class, "foo");
+                    invokeExact(array, Void.class, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, String.class, String.class)).
-                    invoke(null, 0, "foo", "foo");
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo", "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, String.class, String.class)).
-                    invoke(Void.class, 0, "foo", "foo");
+                    invokeExact(Void.class, 0, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, Class.class, String.class)).
-                    invoke(array, 0, Void.class, "foo");
+                    invokeExact(array, 0, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, String.class, String.class)).
-                    invoke(0, 0, "foo", "foo");
+                    invokeExact(0, 0, "foo", "foo");
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, Class.class, String.class, String.class)).
-                    invoke(array, Void.class, "foo", "foo");
+                    invokeExact(array, Void.class, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", "foo", Void.class);
+                    invokeExact(array, 0, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class, String.class)).
-                    invoke(null, 0, "foo", "foo");
+                String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo", "foo");
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class, String.class)).
-                    invoke(Void.class, 0, "foo", "foo");
+                    invokeExact(Void.class, 0, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class, String.class)).
-                    invoke(array, 0, Void.class, "foo");
+                    invokeExact(array, 0, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class, String.class)).
-                    invoke(0, 0, "foo", "foo");
+                    invokeExact(0, 0, "foo", "foo");
             });
             checkWMTE(() -> { // index reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class, String.class)).
-                    invoke(array, Void.class, "foo", "foo");
+                    invokeExact(array, Void.class, "foo", "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class, String.class)).
-                    invoke(array, 0, "foo", "foo");
+                    invokeExact(array, 0, "foo", "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)).
-                    invoke(array, 0, "foo", "foo");
+                    invokeExact(array, 0, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", "foo", Void.class);
+                    invokeExact(array, 0, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class)).
-                    invoke(null, 0, "foo");
+                String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo");
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class)).
-                    invoke(Void.class, 0, "foo");
+                    invokeExact(Void.class, 0, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class)).
-                    invoke(0, 0, "foo");
+                    invokeExact(0, 0, "foo");
             });
             checkWMTE(() -> { // index reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class)).
-                    invoke(array, Void.class, "foo");
+                    invokeExact(array, Void.class, "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class)).
-                    invoke(array, 0, "foo");
+                    invokeExact(array, 0, "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class)).
-                    invoke(array, 0, "foo");
+                    invokeExact(array, 0, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
         }
 
diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template
index 391dc1a..5dfd82f 100644
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template
@@ -309,6 +309,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet(recv, $value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -399,6 +403,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease($value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet($value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -504,29 +512,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
         }
@@ -586,6 +606,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet(recv, $value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -691,36 +715,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) vh.get();
-            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
         }
 
         // Compare set and get
         {
-            $type$ o = ($type$) vh.getAndSet( $value2$);
+            $type$ o = ($type$) vh.getAndSet($value2$);
             assertEquals(o, $value1$, "getAndSet $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value2$, "getAndSet $type$ value");
@@ -773,6 +809,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease($value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet($value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -881,31 +921,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSet $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSet $type$");
                 $type$ x = ($type$) vh.get(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                 $type$ x = ($type$) vh.get(array, i);
                 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease $type$");
                 $type$ x = ($type$) vh.get(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile $type$");
                 $type$ x = ($type$) vh.get(array, i);
-                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
             }
 
             // Compare set and get
@@ -967,6 +1019,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet(array, i, $value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template
index e433789..615bb52 100644
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template
@@ -311,10 +311,12 @@
             checkROBE(() -> {
                 $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1);
             });
+
+#else[CAS]
             checkUOE(() -> {
                 boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
             });
-#else[CAS]
+
             checkUOE(() -> {
                 $type$ r = ($type$) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
             });
@@ -884,22 +886,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$");
                 }
@@ -1037,22 +1048,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$");
                 }
diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template
index f56d9a6..e4bd78e 100644
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template
@@ -209,31 +209,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
         }
 
         // Compare set and get
@@ -380,36 +392,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
         }
 
         // Compare set and get
         {
-            $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact($value2$);
+            $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value2$);
             assertEquals(o, $value1$, "getAndSet $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value2$, "getAndSet $type$ value");
@@ -554,31 +578,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSet $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSet $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
             }
 
             // Compare set and get
diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template
index fe50490..5bec8b4 100644
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodType$Type$
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodType$Type$
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodType$Type$::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodType$Type$::testArrayWrongMethodType,
                                                      false));
         }
@@ -648,63 +650,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class)).
-                    invoke(null);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)).
-                    invoke(recv);
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, $type$.class)).
-                    invoke(null, $value1$);
+                hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, $type$.class)).
-                    invoke(0, $value1$);
+                    invokeExact(0, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
         }
 
@@ -712,111 +714,111 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, $type$.class, $type$.class)).
-                    invoke(null, $value1$, $value1$);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class, $type$.class)).
-                    invoke(Void.class, $value1$, $value1$);
+                    invokeExact(Void.class, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)).
-                    invoke(recv, Void.class, $value1$);
+                    invokeExact(recv, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , $type$.class, $type$.class)).
-                    invoke(0, $value1$, $value1$);
+                    invokeExact(0, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, $value1$, Void.class);
+                    invokeExact(recv, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class, $type$.class)).
-                    invoke(null, $value1$, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class, $type$.class)).
-                    invoke(Void.class, $value1$, $value1$);
+                    invokeExact(Void.class, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)).
-                    invoke(recv, Void.class, $value1$);
+                    invokeExact(recv, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class , $type$.class, $type$.class)).
-                    invoke(0, $value1$, $value1$);
+                    invokeExact(0, $value1$, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)).
-                    invoke(recv, $value1$, $value1$);
+                    invokeExact(recv, $value1$, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)).
-                    invoke(recv, $value1$, $value1$);
+                    invokeExact(recv, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, $value1$, Void.class);
+                    invokeExact(recv, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)).
-                    invoke(null, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)).
-                    invoke(0, $value1$);
+                    invokeExact(0, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
         }
 #end[CAS]
@@ -824,38 +826,38 @@
 #if[AtomicAdd]
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)).
-                    invoke(null, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)).
-                    invoke(0, $value1$);
+                    invokeExact(0, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
         }
 #end[AtomicAdd]
@@ -1200,111 +1202,111 @@
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
         }
 #if[CAS]
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, $type$.class, Class.class)).
-                    invoke($value1$, $value1$, Void.class);
+                    invokeExact($value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$.class, $type$.class)).
-                    invoke($value1$, $value1$);
+                    invokeExact($value1$, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class, $type$.class)).
-                    invoke($value1$, $value1$);
+                    invokeExact($value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, $type$.class, Class.class)).
-                    invoke($value1$, $value1$, Void.class);
+                    invokeExact($value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
         }
 #end[CAS]
@@ -1314,25 +1316,25 @@
             // Incorrect argument types
             check{#if[String]?CCE:WMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             check{#if[String]?CCE:WMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
         }
 #end[AtomicAdd]
@@ -1929,196 +1931,196 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class)).
-                    invoke(null, 0);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class)).
+                    invokeExact(($type$[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, $type$.class)).
-                    invoke(null, 0, $value1$);
+                hs.get(am, methodType(void.class, $type$[].class, int.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$);
+                    invokeExact(Void.class, 0, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, $type$.class)).
-                    invoke(0, 0, $value1$);
+                    invokeExact(0, 0, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, $type$[].class, Class.class, $type$.class)).
-                    invoke(array, Void.class, $value1$);
+                    invokeExact(array, Void.class, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
         }
 #if[CAS]
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, $type$.class, $type$.class)).
-                    invoke(null, 0, $value1$, $value1$);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, $type$.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$, $value1$);
+                    invokeExact(Void.class, 0, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, Class.class, $type$.class)).
-                    invoke(array, 0, Void.class, $value1$);
+                    invokeExact(array, 0, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, $type$.class, $type$.class)).
-                    invoke(0, 0, $value1$, $value1$);
+                    invokeExact(0, 0, $value1$, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, Class.class, $type$.class, $type$.class)).
-                    invoke(array, Void.class, $value1$, $value1$);
+                    invokeExact(array, Void.class, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class, $type$.class)).
-                    invoke(null, 0, $value1$, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$, $value1$);
+                    invokeExact(Void.class, 0, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class, $type$.class)).
-                    invoke(array, 0, Void.class, $value1$);
+                    invokeExact(array, 0, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class, $type$.class)).
-                    invoke(0, 0, $value1$, $value1$);
+                    invokeExact(0, 0, $value1$, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class, $type$.class)).
-                    invoke(array, Void.class, $value1$, $value1$);
+                    invokeExact(array, Void.class, $value1$, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class, $type$.class)).
-                    invoke(array, 0, $value1$, $value1$);
+                    invokeExact(array, 0, $value1$, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class, $type$.class)).
-                    invoke(array, 0, $value1$, $value1$);
+                    invokeExact(array, 0, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)).
-                    invoke(null, 0, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$);
+                    invokeExact(Void.class, 0, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)).
-                    invoke(0, 0, $value1$);
+                    invokeExact(0, 0, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)).
-                    invoke(array, Void.class, $value1$);
+                    invokeExact(array, Void.class, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
         }
 #end[CAS]
@@ -2127,42 +2129,42 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)).
-                    invoke(null, 0, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$);
+                    invokeExact(Void.class, 0, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)).
-                    invoke(0, 0, $value1$);
+                    invokeExact(0, 0, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)).
-                    invoke(array, Void.class, $value1$);
+                    invokeExact(array, Void.class, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
         }
 #end[AtomicAdd]
diff --git a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh
index 7d6afc7..436d2d3 100644
--- a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh
+++ b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh
@@ -113,36 +113,40 @@
       ;;
   esac
 
+  # The value of `value3` is chosen such that when added to `value1` or `value2`
+  # it will result in carrying of bits over to the next byte, thereby detecting
+  # possible errors in endianness conversion e.g. if say for atomic addition the
+  # augend is incorrectly processed
   case $type in
     short)
       value1=(short)0x0102
       value2=(short)0x1112
-      value3=(short)0x2122
+      value3=(short)0xFFFE
       ;;
     char)
       value1=(char)0x0102
       value2=(char)0x1112
-      value3=(char)0x2122
+      value3=(char)0xFFFE
       ;;
     int)
       value1=0x01020304
       value2=0x11121314
-      value3=0x21222324
+      value3=0xFFFEFDFC
       ;;
     long)
       value1=0x0102030405060708L
       value2=0x1112131415161718L
-      value3=0x2122232425262728L
+      value3=0xFFFEFDFCFBFAF9F8L
       ;;
     float)
       value1=0x01020304
       value2=0x11121314
-      value3=0x21222324
+      value3=0xFFFEFDFC
       ;;
     double)
       value1=0x0102030405060708L
       value2=0x1112131415161718L
-      value3=0x2122232425262728L
+      value3=0xFFFEFDFCFBFAF9F8L
       ;;
   esac
 
diff --git a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
index 195cb3a..2d52eeb 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
+++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
@@ -36,9 +36,13 @@
  * @modules jdk.management
  * @build jdk.testlibrary.* ResetPeakMemoryUsage MemoryUtil RunUtil
  * @run main ResetPeakMemoryUsage
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != "true"
+ * @requires vm.opt.ExplicitGCInvokesConcurrentAndUnloadsClasses != "true"
+ * @requires vm.opt.DisableExplicitGC != "true"
  */
 
 import java.lang.management.*;
+import java.lang.ref.WeakReference;
 import java.util.*;
 
 public class ResetPeakMemoryUsage {
@@ -100,6 +104,7 @@
         printMemoryUsage(usage0, peak0);
 
         obj = new Object[largeArraySize];
+        WeakReference<Object> weakRef = new WeakReference<>(obj);
 
         MemoryUsage usage1 = mpool.getUsage();
         MemoryUsage peak1 = mpool.getPeakUsage();
@@ -124,7 +129,11 @@
         // The object is now garbage and do a GC
         // memory usage should drop
         obj = null;
-        mbean.gc();
+
+        //This will cause sure shot GC unlike Runtime.gc() invoked by mbean.gc()
+        while(weakRef.get() != null) {
+            mbean.gc();
+        }
 
         MemoryUsage usage2 = mpool.getUsage();
         MemoryUsage peak2 = mpool.getPeakUsage();
diff --git a/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java b/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
index ac0bc89..63f5c5f 100644
--- a/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
+++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
@@ -270,8 +270,7 @@
         // Calling getMBeanInfo will throw exception if not found.
         platformMBS.getMBeanInfo(objName);
 
-        if (!platformMBS.isInstanceOf(objName, "java.lang.management.PlatformLoggingMXBean") ||
-            !platformMBS.isInstanceOf(objName, "java.util.logging.LoggingMXBean")) {
+        if (!platformMBS.isInstanceOf(objName, "java.lang.management.PlatformLoggingMXBean")) {
             throw new RuntimeException(objName + " is of unexpected type");
         }
 
diff --git a/jdk/test/java/lang/module/AutomaticModulesTest.java b/jdk/test/java/lang/module/AutomaticModulesTest.java
index d400ffb..93dd5f7 100644
--- a/jdk/test/java/lang/module/AutomaticModulesTest.java
+++ b/jdk/test/java/lang/module/AutomaticModulesTest.java
@@ -469,7 +469,7 @@
     static Configuration resolve(Configuration parent,
                                  ModuleFinder finder,
                                  String... roots) {
-        return parent.resolveRequires(finder, ModuleFinder.empty(), Set.of(roots));
+        return parent.resolveRequires(finder, ModuleFinder.of(), Set.of(roots));
     }
 
     /**
diff --git a/jdk/test/java/lang/module/ConfigurationTest.java b/jdk/test/java/lang/module/ConfigurationTest.java
index 9e7e9d4..4d885cd 100644
--- a/jdk/test/java/lang/module/ConfigurationTest.java
+++ b/jdk/test/java/lang/module/ConfigurationTest.java
@@ -721,7 +721,7 @@
         // finder2 is the after ModuleFinder and so p@2.0 should not be located
         // as module p is in parent configuration.
 
-        cf2 = resolveRequiresAndUses(cf1, ModuleFinder.empty(), finder2, "m1");
+        cf2 = resolveRequiresAndUses(cf1, ModuleFinder.of(), finder2, "m1");
 
         assertTrue(cf2.parent().get() == cf1);
         assertTrue(cf2.modules().size() == 1);
@@ -865,7 +865,7 @@
 
         ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
 
-        Configuration cf2 = resolveRequires(cf1, ModuleFinder.empty(), finder2, "m2");
+        Configuration cf2 = resolveRequires(cf1, ModuleFinder.of(), finder2, "m2");
 
         assertTrue(cf2.modules().size() == 1);
         assertTrue(cf2.findModule("m2").isPresent());
@@ -967,7 +967,7 @@
      */
     @Test(expectedExceptions = { ResolutionException.class })
     public void testRootNotFound() {
-        resolveRequires(ModuleFinder.empty(), "m1");
+        resolveRequires(ModuleFinder.of(), "m1");
     }
 
 
@@ -1440,22 +1440,22 @@
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresWithNull1() {
-        resolveRequires((ModuleFinder)null, ModuleFinder.empty());
+        resolveRequires((ModuleFinder)null, ModuleFinder.of());
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresWithNull2() {
-        resolveRequires(ModuleFinder.empty(), (ModuleFinder)null);
+        resolveRequires(ModuleFinder.of(), (ModuleFinder)null);
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresAndUsesWithNull1() {
-        resolveRequiresAndUses((ModuleFinder) null, ModuleFinder.empty());
+        resolveRequiresAndUses((ModuleFinder) null, ModuleFinder.of());
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresAndUsesWithNull2() {
-        resolveRequiresAndUses(ModuleFinder.empty(), (ModuleFinder) null);
+        resolveRequiresAndUses(ModuleFinder.of(), (ModuleFinder) null);
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
@@ -1493,7 +1493,7 @@
     private Configuration resolveRequires(Configuration parent,
                                           ModuleFinder before,
                                           String... roots) {
-        return resolveRequires(parent, before, ModuleFinder.empty(), roots);
+        return resolveRequires(parent, before, ModuleFinder.of(), roots);
     }
 
     private Configuration resolveRequires(ModuleFinder before,
@@ -1521,7 +1521,7 @@
     private Configuration resolveRequiresAndUses(Configuration parent,
                                                  ModuleFinder before,
                                                  String... roots) {
-        return resolveRequiresAndUses(parent, before, ModuleFinder.empty(), roots);
+        return resolveRequiresAndUses(parent, before, ModuleFinder.of(), roots);
     }
 
     private Configuration resolveRequiresAndUses(ModuleFinder before,
diff --git a/jdk/test/java/lang/module/ModuleFinderTest.java b/jdk/test/java/lang/module/ModuleFinderTest.java
index 3270dfd..58c2ae5 100644
--- a/jdk/test/java/lang/module/ModuleFinderTest.java
+++ b/jdk/test/java/lang/module/ModuleFinderTest.java
@@ -76,9 +76,9 @@
 
 
     /**
-     * Test ModuleFinder.of with zero entries
+     * Test ModuleFinder.of with no entries
      */
-    public void testOfZeroEntries() {
+    public void testOfNoEntries() {
         ModuleFinder finder = ModuleFinder.of();
         assertTrue(finder.findAll().isEmpty());
         assertFalse(finder.find("java.rhubarb").isPresent());
@@ -454,18 +454,46 @@
 
 
     /**
-     * Test ModuleFinder.compose
+     * Test ModuleFinder.compose with no module finders
      */
-    public void testCompose() throws Exception {
+    public void testComposeOfNone() throws Exception {
+        ModuleFinder finder = ModuleFinder.of();
+        assertTrue(finder.findAll().isEmpty());
+        assertFalse(finder.find("java.rhubarb").isPresent());
+    }
+
+
+    /**
+     * Test ModuleFinder.compose with one module finder
+     */
+    public void testComposeOfOne() throws Exception {
+        Path dir = Files.createTempDirectory(USER_DIR, "mods");
+        createModularJar(dir.resolve("m1.jar"), "m1");
+        createModularJar(dir.resolve("m2.jar"), "m2");
+
+        ModuleFinder finder1 = ModuleFinder.of(dir);
+
+        ModuleFinder finder = ModuleFinder.compose(finder1);
+        assertTrue(finder.findAll().size() == 2);
+        assertTrue(finder.find("m1").isPresent());
+        assertTrue(finder.find("m2").isPresent());
+        assertFalse(finder.find("java.rhubarb").isPresent());
+    }
+
+
+    /**
+     * Test ModuleFinder.compose with two module finders
+     */
+    public void testComposeOfTwo() throws Exception {
         Path dir1 = Files.createTempDirectory(USER_DIR, "mods1");
-        createExplodedModule(dir1.resolve("m1"), "m1@1.0");
-        createExplodedModule(dir1.resolve("m2"), "m2@1.0");
+        createModularJar(dir1.resolve("m1.jar"), "m1@1.0");
+        createModularJar(dir1.resolve("m2.jar"), "m2@1.0");
 
         Path dir2 = Files.createTempDirectory(USER_DIR, "mods2");
-        createExplodedModule(dir2.resolve("m1"), "m1@2.0");
-        createExplodedModule(dir2.resolve("m2"), "m2@2.0");
-        createExplodedModule(dir2.resolve("m3"), "m3");
-        createExplodedModule(dir2.resolve("m4"), "m4");
+        createModularJar(dir2.resolve("m1.jar"), "m1@2.0");
+        createModularJar(dir2.resolve("m2.jar"), "m2@2.0");
+        createModularJar(dir2.resolve("m3.jar"), "m3");
+        createModularJar(dir2.resolve("m4.jar"), "m4");
 
         ModuleFinder finder1 = ModuleFinder.of(dir1);
         ModuleFinder finder2 = ModuleFinder.of(dir2);
@@ -478,23 +506,65 @@
         assertTrue(finder.find("m4").isPresent());
         assertFalse(finder.find("java.rhubarb").isPresent());
 
-        // check that m1@1.0 (and not m1@2.0) is found
+        // check that m1@1.0 is found
         ModuleDescriptor m1 = finder.find("m1").get().descriptor();
         assertEquals(m1.version().get().toString(), "1.0");
 
-        // check that m2@1.0 (and not m2@2.0) is found
+        // check that m2@1.0 is found
         ModuleDescriptor m2 = finder.find("m2").get().descriptor();
         assertEquals(m2.version().get().toString(), "1.0");
     }
 
 
     /**
-     * Test ModuleFinder.empty
+     * Test ModuleFinder.compose with three module finders
      */
-    public void testEmpty() {
-        ModuleFinder finder = ModuleFinder.empty();
-        assertTrue(finder.findAll().isEmpty());
+    public void testComposeOfThree() throws Exception {
+        Path dir1 = Files.createTempDirectory(USER_DIR, "mods1");
+        createModularJar(dir1.resolve("m1.jar"), "m1@1.0");
+        createModularJar(dir1.resolve("m2.jar"), "m2@1.0");
+
+        Path dir2 = Files.createTempDirectory(USER_DIR, "mods2");
+        createModularJar(dir2.resolve("m1.jar"), "m1@2.0");
+        createModularJar(dir2.resolve("m2.jar"), "m2@2.0");
+        createModularJar(dir2.resolve("m3.jar"), "m3@2.0");
+        createModularJar(dir2.resolve("m4.jar"), "m4@2.0");
+
+        Path dir3 = Files.createTempDirectory(USER_DIR, "mods3");
+        createModularJar(dir3.resolve("m3.jar"), "m3@3.0");
+        createModularJar(dir3.resolve("m4.jar"), "m4@3.0");
+        createModularJar(dir3.resolve("m5.jar"), "m5");
+        createModularJar(dir3.resolve("m6.jar"), "m6");
+
+        ModuleFinder finder1 = ModuleFinder.of(dir1);
+        ModuleFinder finder2 = ModuleFinder.of(dir2);
+        ModuleFinder finder3 = ModuleFinder.of(dir3);
+
+        ModuleFinder finder = ModuleFinder.compose(finder1, finder2, finder3);
+        assertTrue(finder.findAll().size() == 6);
+        assertTrue(finder.find("m1").isPresent());
+        assertTrue(finder.find("m2").isPresent());
+        assertTrue(finder.find("m3").isPresent());
+        assertTrue(finder.find("m4").isPresent());
+        assertTrue(finder.find("m5").isPresent());
+        assertTrue(finder.find("m6").isPresent());
         assertFalse(finder.find("java.rhubarb").isPresent());
+
+        // check that m1@1.0 is found
+        ModuleDescriptor m1 = finder.find("m1").get().descriptor();
+        assertEquals(m1.version().get().toString(), "1.0");
+
+        // check that m2@1.0 is found
+        ModuleDescriptor m2 = finder.find("m2").get().descriptor();
+        assertEquals(m2.version().get().toString(), "1.0");
+
+        // check that m3@2.0 is found
+        ModuleDescriptor m3 = finder.find("m3").get().descriptor();
+        assertEquals(m3.version().get().toString(), "2.0");
+
+        // check that m4@2.0 is found
+        ModuleDescriptor m4 = finder.find("m4").get().descriptor();
+        assertEquals(m4.version().get().toString(), "2.0");
     }
 
 
@@ -503,34 +573,46 @@
      */
     public void testNulls() {
 
+        // ofSystem
         try {
             ModuleFinder.ofSystem().find(null);
             assertTrue(false);
         } catch (NullPointerException expected) { }
 
+        // of
+        Path dir = Paths.get("d");
         try {
             ModuleFinder.of().find(null);
             assertTrue(false);
         } catch (NullPointerException expected) { }
-
         try {
-            ModuleFinder.empty().find(null);
+            ModuleFinder.of((Path)null);
             assertTrue(false);
         } catch (NullPointerException expected) { }
-
         try {
             ModuleFinder.of((Path[])null);
             assertTrue(false);
         } catch (NullPointerException expected) { }
-
         try {
-            ModuleFinder.of((Path)null);
+            ModuleFinder.of(dir, null);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+        try {
+            ModuleFinder.of(null, dir);
             assertTrue(false);
         } catch (NullPointerException expected) { }
 
         // compose
         ModuleFinder finder = ModuleFinder.of();
         try {
+            ModuleFinder.compose((ModuleFinder)null);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+        try {
+            ModuleFinder.compose((ModuleFinder[])null);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+        try {
             ModuleFinder.compose(finder, null);
             assertTrue(false);
         } catch (NullPointerException expected) { }
diff --git a/jdk/test/java/lang/module/ModuleReader/MultiReleaseJarTest.java b/jdk/test/java/lang/module/ModuleReader/MultiReleaseJarTest.java
new file mode 100644
index 0000000..4bb6cea
--- /dev/null
+++ b/jdk/test/java/lang/module/ModuleReader/MultiReleaseJarTest.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @library /lib/testlibrary
+ * @modules java.base/jdk.internal.module
+ * @build MultiReleaseJarTest JarUtils
+ * @run testng MultiReleaseJarTest
+ * @run testng/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarTest
+ * @summary Basic test of ModuleReader with a modular JAR that is also a
+ *          multi-release JAR
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReader;
+import java.lang.module.ModuleReference;
+import java.net.URI;
+import java.net.URLConnection;
+import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Optional;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.stream.Collectors;
+
+import jdk.internal.module.ModuleInfoWriter;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * Exercises ModuleReader with a modular JAR containing the following files:
+ *
+ * <pre>{@code
+ *     module-info.class
+ *     META-INF/versions/<version>/module.class
+ * }</pre>
+ *
+ * The module-info.class in the top-level directory is the binary form of:
+ * <pre>{@code
+ *     module jdk.test {
+ *         requires java.base;
+ *     }
+ * }</pre>
+ *
+ * The module-info.class in the versioned section is the binary form of:
+ * <pre>{@code
+ *     module jdk.test {
+ *         requires java.base;
+ *         requires jdk.unsupported;
+ *     }
+ * }</pre>
+ */
+
+@Test
+public class MultiReleaseJarTest {
+
+    // Java SE/JDK major release
+    private static final int RELEASE = Runtime.version().major();
+
+    // the name of the test module
+    private static final String MODULE_NAME = "jdk.test";
+
+    private static final String MODULE_INFO_CLASS = "module-info.class";
+
+    /**
+     * Uses the ModuleFinder API to locate the module packaged as a modular
+     * and mutli-release JAR and then creates a ModuleReader to access the
+     * contents of the module.
+     */
+    public void testMultiReleaseJar() throws IOException {
+
+        // are multi-release JARs enabled?
+        String s = System.getProperty("jdk.util.jar.enableMultiRelease");
+        boolean multiRelease = (s == null || Boolean.parseBoolean(s));
+
+        // create the multi-release modular JAR
+        Path jarfile = createJarFile();
+
+        // find the module
+        ModuleFinder finder = ModuleFinder.of(jarfile);
+        Optional<ModuleReference> omref = finder.find(MODULE_NAME);
+        assertTrue((omref.isPresent()));
+        ModuleReference mref = omref.get();
+
+        // test that correct module-info.class was read
+        checkDescriptor(mref.descriptor(), multiRelease);
+
+        // test ModuleReader
+        try (ModuleReader reader = mref.open()) {
+
+            // open resource
+            Optional<InputStream> oin = reader.open(MODULE_INFO_CLASS);
+            assertTrue(oin.isPresent());
+            try (InputStream in = oin.get()) {
+                checkDescriptor(ModuleDescriptor.read(in), multiRelease);
+            }
+
+            // read resource
+            Optional<ByteBuffer> obb = reader.read(MODULE_INFO_CLASS);
+            assertTrue(obb.isPresent());
+            ByteBuffer bb = obb.get();
+            try {
+                checkDescriptor(ModuleDescriptor.read(bb), multiRelease);
+            } finally {
+                reader.release(bb);
+            }
+
+            // find resource
+            Optional<URI> ouri = reader.find(MODULE_INFO_CLASS);
+            assertTrue(ouri.isPresent());
+            URI uri = ouri.get();
+
+            String expectedTail = "!/";
+            if (multiRelease)
+                expectedTail += "META-INF/versions/" + RELEASE + "/";
+            expectedTail += MODULE_INFO_CLASS;
+            assertTrue(uri.toString().endsWith(expectedTail));
+
+            URLConnection uc = uri.toURL().openConnection();
+            uc.setUseCaches(false);
+            try (InputStream in = uc.getInputStream()) {
+                checkDescriptor(ModuleDescriptor.read(in), multiRelease);
+            }
+
+        }
+
+    }
+
+    /**
+     * Checks that the module descriptor is the expected module descriptor.
+     * When the multi release JAR feature is enabled then the module
+     * descriptor is expected to have been read from the versioned section
+     * of the JAR file.
+     */
+    private void checkDescriptor(ModuleDescriptor descriptor, boolean multiRelease) {
+        Set<String> requires = descriptor.requires().stream()
+                .map(ModuleDescriptor.Requires::name)
+                .collect(Collectors.toSet());
+        assertTrue(requires.contains("java.base"));
+        assertTrue(requires.contains("jdk.unsupported") == multiRelease);
+    }
+
+    /**
+     * Creates the modular JAR for the test, returning the Path to the JAR file.
+     */
+    private Path createJarFile() throws IOException {
+
+        // module descriptor for top-level directory
+        ModuleDescriptor descriptor1
+            = new ModuleDescriptor.Builder(MODULE_NAME)
+                .requires("java.base")
+                .build();
+
+        // module descriptor for versioned section
+        ModuleDescriptor descriptor2
+            = new ModuleDescriptor.Builder(MODULE_NAME)
+                .requires("java.base")
+                .requires("jdk.unsupported")
+                .build();
+
+        Path top = Paths.get(MODULE_NAME);
+        Files.createDirectories(top);
+
+        Path mi1 = Paths.get(MODULE_INFO_CLASS);
+        try (OutputStream out = Files.newOutputStream(top.resolve(mi1))) {
+            ModuleInfoWriter.write(descriptor1, out);
+        }
+
+        Path vdir = Paths.get("META-INF", "versions", Integer.toString(RELEASE));
+        Files.createDirectories(top.resolve(vdir));
+
+        Path mi2 = vdir.resolve(MODULE_INFO_CLASS);
+        try (OutputStream out = Files.newOutputStream(top.resolve(mi2))) {
+            ModuleInfoWriter.write(descriptor2, out);
+        }
+
+        Manifest man = new Manifest();
+        Attributes attrs = man.getMainAttributes();
+        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        attrs.put(Attributes.Name.MULTI_RELEASE, "true");
+
+        Path jarfile = Paths.get(MODULE_NAME + ".jar");
+        JarUtils.createJarFile(jarfile, man, top, mi1, mi2);
+
+        return jarfile;
+    }
+}
diff --git a/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java b/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java
index f54a320..f6aeb6b 100644
--- a/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java
+++ b/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java
@@ -33,7 +33,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import static java.lang.module.ModuleFinder.empty;
 import java.lang.reflect.Layer;
 import java.lang.reflect.LayerInstantiationException;
 import java.lang.reflect.Module;
@@ -358,7 +357,7 @@
         ModuleFinder finder = ModuleUtils.finderOf(descriptor);
 
         Configuration parent = Layer.boot().configuration();
-        Configuration cf = parent.resolveRequires(finder, empty(), Set.of("m1"));
+        Configuration cf = parent.resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
         assertTrue(cf.modules().size() == 1);
 
         ClassLoader loader = new ClassLoader() { };
@@ -684,7 +683,7 @@
 
         Configuration parent = Layer.boot().configuration();
 
-        Configuration cf = parent.resolveRequires(finder, empty(), Set.of("m"));
+        Configuration cf = parent.resolveRequires(finder, ModuleFinder.of(), Set.of("m"));
 
         ClassLoader loader = new ClassLoader() { };
 
@@ -724,13 +723,13 @@
 
         Configuration parent = Layer.boot().configuration();
 
-        Configuration cf1 = parent.resolveRequires(finder, empty(), Set.of("m1"));
+        Configuration cf1 = parent.resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         Layer layer1 = Layer.boot().defineModules(cf1, mn -> loader);
 
         // attempt to define m2 containing package p to class loader
 
-        Configuration cf2 = parent.resolveRequires(finder, empty(), Set.of("m2"));
+        Configuration cf2 = parent.resolveRequires(finder, ModuleFinder.of(), Set.of("m2"));
 
         // should throw exception because p already in m1
         Layer layer2 = Layer.boot().defineModules(cf2, mn -> loader);
@@ -757,7 +756,7 @@
         ModuleFinder finder = ModuleUtils.finderOf(md);
 
         Configuration parent = Layer.boot().configuration();
-        Configuration cf = parent.resolveRequires(finder, empty(), Set.of("m"));
+        Configuration cf = parent.resolveRequires(finder, ModuleFinder.of(), Set.of("m"));
 
         Layer.boot().defineModules(cf, mn -> c.getClassLoader());
     }
@@ -777,7 +776,7 @@
         ModuleFinder finder = ModuleUtils.finderOf(descriptor1);
 
         Configuration parent = Layer.boot().configuration();
-        Configuration cf = parent.resolveRequires(finder, empty(), Set.of("m1"));
+        Configuration cf = parent.resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         ClassLoader loader = new ClassLoader() { };
         Layer.empty().defineModules(cf, mn -> loader);
@@ -814,7 +813,7 @@
     @Test(expectedExceptions = { NullPointerException.class })
     public void testCreateWithNull2() {
         ClassLoader loader = new ClassLoader() { };
-        Configuration cf = resolveRequires(Layer.boot().configuration(), empty());
+        Configuration cf = resolveRequires(Layer.boot().configuration(), ModuleFinder.of());
         Layer.boot().defineModules(cf, null);
     }
 
@@ -857,7 +856,7 @@
     private static Configuration resolveRequires(Configuration cf,
                                                  ModuleFinder finder,
                                                  String... roots) {
-        return cf.resolveRequires(finder, empty(), Set.of(roots));
+        return cf.resolveRequires(finder, ModuleFinder.of(), Set.of(roots));
     }
 
     private static Configuration resolveRequires(ModuleFinder finder,
diff --git a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java
index b37813f..c07ab26 100644
--- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java
+++ b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /lib/testlibrary
+ * @modules jdk.compiler
  * @build LayerAndLoadersTest CompilerUtils ModuleUtils
  * @run testng LayerAndLoadersTest
  * @summary Tests for java.lang.reflect.Layer@createWithXXX methods
@@ -32,7 +33,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import static java.lang.module.ModuleFinder.empty;
 import java.lang.module.ModuleReference;
 import java.lang.reflect.Layer;
 import java.lang.reflect.LayerInstantiationException;
@@ -70,7 +70,7 @@
 
 
     /**
-     * Basic test of Layer.createWithOneLoader
+     * Basic test of Layer.defineModulesWithOneLoader
      *
      * Test scenario:
      *   m1 requires m2 and m3
@@ -99,7 +99,7 @@
 
 
     /**
-     * Basic test of Layer.createWithManyLoaders
+     * Basic test of Layer.defineModulesWithManyLoaders
      *
      * Test scenario:
      *   m1 requires m2 and m3
@@ -131,7 +131,7 @@
 
 
     /**
-     * Basic test of Layer.createWithOneLoader where one of the modules
+     * Basic test of Layer.defineModulesWithOneLoader where one of the modules
      * is a service provider module.
      *
      * Test scenario:
@@ -172,7 +172,7 @@
 
 
     /**
-     * Basic test of Layer.createWithManyLoaders where one of the modules
+     * Basic test of Layer.defineModulesWithManyLoaders where one of the modules
      * is a service provider module.
      *
      * Test scenario:
@@ -272,7 +272,7 @@
 
         Configuration cf = Layer.boot()
             .configuration()
-            .resolveRequires(finder, empty(), Set.of("m1", "m2"));
+            .resolveRequires(finder, ModuleFinder.of(), Set.of("m1", "m2"));
 
         // cannot define both module m1 and m2 to the same class loader
         try {
@@ -306,7 +306,7 @@
 
         Configuration cf1 = Layer.boot()
             .configuration()
-            .resolveRequires(finder1, empty(), Set.of("m1", "m2"));
+            .resolveRequires(finder1, ModuleFinder.of(), Set.of("m1", "m2"));
 
         Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, null);
         checkLayer(layer1, "m1", "m2");
@@ -319,7 +319,7 @@
 
         ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3, descriptor4);
 
-        Configuration cf2 = cf1.resolveRequires(finder2, empty(), Set.of("m3", "m4"));
+        Configuration cf2 = cf1.resolveRequires(finder2, ModuleFinder.of(), Set.of("m3", "m4"));
 
         // package p cannot be supplied by two class loaders
         try {
@@ -350,7 +350,7 @@
         checkLayer(layer1, "m1", "m2", "m3");
 
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Configuration cf2 = cf1.resolveRequires(finder, empty(), Set.of("m1"));
+        Configuration cf2 = cf1.resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         Layer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
         checkLayer(layer2, "m1", "m2", "m3");
@@ -398,7 +398,7 @@
         checkLayer(layer1, "m1", "m2", "m3");
 
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Configuration cf2 = cf1.resolveRequires(finder, empty(), Set.of("m1"));
+        Configuration cf2 = cf1.resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
         checkLayer(layer2, "m1", "m2", "m3");
@@ -492,7 +492,7 @@
 
         ModuleFinder finder = finderFor("m1", "m3");
 
-        Configuration cf2 = cf1.resolveRequires(finder, empty(), Set.of("m1"));
+        Configuration cf2 = cf1.resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         Layer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
         checkLayer(layer2, "m1", "m3");
@@ -528,7 +528,7 @@
 
         ModuleFinder finder = finderFor("m1", "m3");
 
-        Configuration cf2 = cf1.resolveRequires(finder, empty(), Set.of("m1"));
+        Configuration cf2 = cf1.resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
 
         Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
         checkLayer(layer2, "m1", "m3");
@@ -574,7 +574,7 @@
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
         return Layer.boot()
             .configuration()
-            .resolveRequires(finder, empty(), Set.of(roots));
+            .resolveRequires(finder, ModuleFinder.of(), Set.of(roots));
     }
 
     /**
@@ -585,7 +585,7 @@
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
         return Layer.boot()
             .configuration()
-            .resolveRequiresAndUses(finder, empty(), Set.of(roots));
+            .resolveRequiresAndUses(finder, ModuleFinder.of(), Set.of(roots));
     }
 
 
diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java
index 529f294..fcc6739 100644
--- a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java
@@ -91,7 +91,7 @@
         Layer bootLayer = Layer.boot();
         Configuration cf = bootLayer
                 .configuration()
-                .resolveRequiresAndUses(ModuleFinder.empty(), finder, modules);
+                .resolveRequiresAndUses(ModuleFinder.of(), finder, modules);
         ClassLoader parentLoader = this.getClass().getClassLoader();
         Layer layer = bootLayer.defineModulesWithOneLoader(cf, parentLoader);
 
diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java
index 4ee43ea..37c0bd5 100644
--- a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java
@@ -79,7 +79,7 @@
         Layer bootLayer = Layer.boot();
         Configuration cf = bootLayer
                 .configuration()
-                .resolveRequiresAndUses(ModuleFinder.empty(), finder, Arrays.asList(modules));
+                .resolveRequiresAndUses(ModuleFinder.of(), finder, Arrays.asList(modules));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
 
@@ -113,7 +113,7 @@
         Layer bootLayer = Layer.boot();
         Configuration cf = bootLayer
                 .configuration()
-                .resolveRequiresAndUses(ModuleFinder.empty(), finder, Arrays.asList(modules));
+                .resolveRequiresAndUses(ModuleFinder.of(), finder, Arrays.asList(modules));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
 
@@ -143,7 +143,7 @@
         Layer bootLayer = Layer.boot();
         Configuration cf = bootLayer
                 .configuration()
-                .resolveRequiresAndUses(ModuleFinder.empty(), finder, Arrays.asList(modules));
+                .resolveRequiresAndUses(ModuleFinder.of(), finder, Arrays.asList(modules));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
 
diff --git a/jdk/test/java/math/BigDecimal/SquareRootTests.java b/jdk/test/java/math/BigDecimal/SquareRootTests.java
new file mode 100644
index 0000000..1ad72d0
--- /dev/null
+++ b/jdk/test/java/math/BigDecimal/SquareRootTests.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4851777
+ * @summary Tests of BigDecimal.sqrt().
+ */
+
+import java.math.*;
+import java.util.*;
+
+public class SquareRootTests {
+
+    public static void main(String... args) {
+        int failures = 0;
+
+        failures += negativeTests();
+        failures += zeroTests();
+        failures += evenPowersOfTenTests();
+        failures += squareRootTwoTests();
+        failures += lowPrecisionPerfectSquares();
+
+        if (failures > 0 ) {
+            throw new RuntimeException("Incurred " + failures + " failures" +
+                                       " testing BigDecimal.sqrt().");
+        }
+    }
+
+    private static int negativeTests() {
+        int failures = 0;
+
+        for (long i = -10; i < 0; i++) {
+            for (int j = -5; j < 5; j++) {
+                try {
+                    BigDecimal input = BigDecimal.valueOf(i, j);
+                    BigDecimal result = input.sqrt(MathContext.DECIMAL64);
+                    System.err.println("Unexpected sqrt of negative: (" +
+                                       input + ").sqrt()  = " + result );
+                    failures += 1;
+                } catch (ArithmeticException e) {
+                    ; // Expected
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    private static int zeroTests() {
+        int failures = 0;
+
+        for (int i = -100; i < 100; i++) {
+            BigDecimal expected = BigDecimal.valueOf(0L, i/2);
+            // These results are independent of rounding mode
+            failures += compare(BigDecimal.valueOf(0L, i).sqrt(MathContext.UNLIMITED),
+                                expected, true, "zeros");
+
+            failures += compare(BigDecimal.valueOf(0L, i).sqrt(MathContext.DECIMAL64),
+                                expected, true, "zeros");
+        }
+
+        return failures;
+    }
+
+    /**
+     * sqrt(10^2N) is 10^N
+     * Both numerical value and representation should be verified
+     */
+    private static int evenPowersOfTenTests() {
+        int failures = 0;
+        MathContext oneDigitExactly = new MathContext(1, RoundingMode.UNNECESSARY);
+
+        for (int scale = -100; scale <= 100; scale++) {
+            BigDecimal testValue       = BigDecimal.valueOf(1, 2*scale);
+            BigDecimal expectedNumericalResult = BigDecimal.valueOf(1, scale);
+
+            BigDecimal result;
+
+
+            failures += equalNumerically(expectedNumericalResult,
+                                           result = testValue.sqrt(MathContext.DECIMAL64),
+                                           "Even powers of 10, DECIMAL64");
+
+            // Can round to one digit of precision exactly
+            failures += equalNumerically(expectedNumericalResult,
+                                           result = testValue.sqrt(oneDigitExactly),
+                                           "even powers of 10, 1 digit");
+            if (result.precision() > 1) {
+                failures += 1;
+                System.err.println("Excess precision for " + result);
+            }
+
+
+            // If rounding to more than one digit, do precision / scale checking...
+
+        }
+
+        return failures;
+    }
+
+    private static int squareRootTwoTests() {
+        int failures = 0;
+        BigDecimal TWO = new BigDecimal(2);
+
+        // Square root of 2 truncated to 65 digits
+        BigDecimal highPrecisionRoot2 =
+            new BigDecimal("1.41421356237309504880168872420969807856967187537694807317667973799");
+
+
+        RoundingMode[] modes = {
+            RoundingMode.UP,       RoundingMode.DOWN,
+            RoundingMode.CEILING, RoundingMode.FLOOR,
+            RoundingMode.HALF_UP, RoundingMode.HALF_DOWN, RoundingMode.HALF_EVEN
+        };
+
+        // For each iteresting rounding mode, for precisions 1 to, say
+        // 63 numerically compare TWO.sqrt(mc) to
+        // highPrecisionRoot2.round(mc)
+
+        for (RoundingMode mode : modes) {
+            for (int precision = 1; precision < 63; precision++) {
+                MathContext mc = new MathContext(precision, mode);
+                BigDecimal expected = highPrecisionRoot2.round(mc);
+                BigDecimal computed = TWO.sqrt(mc);
+
+                equalNumerically(expected, computed, "sqrt(2)");
+            }
+        }
+
+        return failures;
+    }
+
+    private static int lowPrecisionPerfectSquares() {
+        int failures = 0;
+
+        // For 5^2 through 9^2, if the input is rounded to one digit
+        // first before the root is computed, the wrong answer will
+        // result. Verify results and scale for different rounding
+        // modes and precisions.
+        long[][] squaresWithOneDigitRoot = {{ 4, 2},
+                                            { 9, 3},
+                                            {25, 5},
+                                            {36, 6},
+                                            {49, 7},
+                                            {64, 8},
+                                            {81, 9}};
+
+        for (long[] squareAndRoot : squaresWithOneDigitRoot) {
+            BigDecimal square     = new BigDecimal(squareAndRoot[0]);
+            BigDecimal expected   = new BigDecimal(squareAndRoot[1]);
+
+            for (int scale = 0; scale <= 4; scale++) {
+                BigDecimal scaledSquare = square.setScale(scale, RoundingMode.UNNECESSARY);
+                int expectedScale = scale/2;
+                for (int precision = 0; precision <= 5; precision++) {
+                    for (RoundingMode rm : RoundingMode.values()) {
+                        MathContext mc = new MathContext(precision, rm);
+                        BigDecimal computedRoot = scaledSquare.sqrt(mc);
+                        failures += equalNumerically(expected, computedRoot, "simple squares");
+                        int computedScale = computedRoot.scale();
+                        if (precision >=  expectedScale + 1 &&
+                            computedScale != expectedScale) {
+                        System.err.printf("%s\tprecision=%d\trm=%s%n",
+                                          computedRoot.toString(), precision, rm);
+                            failures++;
+                            System.err.printf("\t%s does not have expected scale of %d%n.",
+                                              computedRoot, expectedScale);
+                        }
+                    }
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    private static int compare(BigDecimal a, BigDecimal b, boolean expected, String prefix) {
+        boolean result = a.equals(b);
+        int failed = (result==expected) ? 0 : 1;
+        if (failed == 1) {
+            System.err.println("Testing " + prefix +
+                               "(" + a + ").compareTo(" + b + ") => " + result +
+                               "\n\tExpected " + expected);
+        }
+        return failed;
+    }
+
+    private static int equalNumerically(BigDecimal a, BigDecimal b,
+                                        String prefix) {
+        return compareNumerically(a, b, 0, prefix);
+    }
+
+
+    private static int compareNumerically(BigDecimal a, BigDecimal b,
+                                          int expected, String prefix) {
+        int result = a.compareTo(b);
+        int failed = (result==expected) ? 0 : 1;
+        if (failed == 1) {
+            System.err.println("Testing " + prefix +
+                               "(" + a + ").compareTo(" + b + ") => " + result +
+                               "\n\tExpected " + expected);
+        }
+        return failed;
+    }
+
+}
diff --git a/jdk/test/java/net/DatagramSocket/PortUnreachable.java b/jdk/test/java/net/DatagramSocket/PortUnreachable.java
index 91e6847..143c842 100644
--- a/jdk/test/java/net/DatagramSocket/PortUnreachable.java
+++ b/jdk/test/java/net/DatagramSocket/PortUnreachable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /**
  * @test
  * @bug 4361783
+ * @key intermittent
  * @summary  Test to see if ICMP Port Unreachable on non-connected
  *           DatagramSocket causes a SocketException "socket closed"
  *           exception on Windows 2000.
diff --git a/jdk/test/java/net/InetAddress/IsReachableViaLoopbackTest.java b/jdk/test/java/net/InetAddress/IsReachableViaLoopbackTest.java
index 4d7f266..5364ba7 100644
--- a/jdk/test/java/net/InetAddress/IsReachableViaLoopbackTest.java
+++ b/jdk/test/java/net/InetAddress/IsReachableViaLoopbackTest.java
@@ -5,6 +5,7 @@
 /**
  * @test
  * @bug 8135305
+ * @key intermittent
  * @summary ensure we can't ping external hosts via loopback if
  */
 
diff --git a/jdk/test/java/net/MulticastSocket/TestInterfaces.java b/jdk/test/java/net/MulticastSocket/TestInterfaces.java
index b9b641d..2d90cb8 100644
--- a/jdk/test/java/net/MulticastSocket/TestInterfaces.java
+++ b/jdk/test/java/net/MulticastSocket/TestInterfaces.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 4422122
+ * @key intermittent
  * @summary Test that MulticastSocket.getInterface returns the
  *          same InetAddress set by MulticastSocket.setInterface
  */
diff --git a/jdk/test/java/net/SocketOption/OptionsTest.java b/jdk/test/java/net/SocketOption/OptionsTest.java
index 81f33f7..f1309f1 100644
--- a/jdk/test/java/net/SocketOption/OptionsTest.java
+++ b/jdk/test/java/net/SocketOption/OptionsTest.java
@@ -26,7 +26,7 @@
  * @bug 8036979 8072384 8044773
  * @run main/othervm -Xcheck:jni OptionsTest
  * @run main/othervm -Xcheck:jni -Djava.net.preferIPv4Stack=true OptionsTest
- * @run main/othervm -Djdk.launcher.limitmods=java.base OptionsTest
+ * @run main/othervm -limitmods java.base OptionsTest
  */
 
 import java.lang.reflect.Method;
diff --git a/jdk/test/java/net/SocketOption/SupportedOptionsSet.java b/jdk/test/java/net/SocketOption/SupportedOptionsSet.java
new file mode 100644
index 0000000..eaa31e1
--- /dev/null
+++ b/jdk/test/java/net/SocketOption/SupportedOptionsSet.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.net.*;
+import java.util.Set;
+import static java.lang.System.out;
+
+/*
+ * @test
+ * @bug 8143923
+ * @summary java.net socket supportedOptions set depends on call order
+ * @run main/othervm SupportedOptionsSet first
+ * @run main/othervm SupportedOptionsSet second
+ */
+
+// Run with othervm as the implementation of the supported options sets, once
+// calculated, stores them in a private static fields.
+
+public class SupportedOptionsSet {
+
+    public static void main(String[] args) throws IOException {
+        if (args[0].equals("first"))
+            first();
+        else if (args[0].equals("second"))
+            second();
+    }
+
+    static void first() throws IOException {
+        try (Socket s = new Socket();
+             ServerSocket ss = new ServerSocket();
+             DatagramSocket ds = new DatagramSocket();
+             MulticastSocket ms = new MulticastSocket()) {
+
+            Set<?> first = s.supportedOptions();
+            Set<?> second = ss.supportedOptions();
+            assertNotEqual(first, second,
+                 "Socket and ServerSocket should have different options.");
+
+            first = ds.supportedOptions();
+            second = ms.supportedOptions();
+            assertNotEqual(first, second,
+                "DatagramSocket and MulticastSocket should have different options.");
+        }
+    }
+
+    /** Tests with the order of access to supportedOptions reversed.  */
+    static void second() throws IOException {
+        try (ServerSocket ss = new ServerSocket();
+             Socket s = new Socket();
+             DatagramSocket ds = new DatagramSocket();
+             MulticastSocket ms = new MulticastSocket()) {
+
+            Set<?> first = ss.supportedOptions();
+            Set<?> second = s.supportedOptions();
+            assertNotEqual(first, second,
+                "ServerSocket and Socket should have different options.");
+
+            first = ms.supportedOptions();
+            second = ds.supportedOptions();
+            assertNotEqual(first, second,
+                "MulticastSocket and DatagramSocket should have different options.");
+
+        }
+    }
+
+    static void assertNotEqual(Set<?> s1, Set<?> s2, String message) {
+        if (s1.equals(s2)) {
+            out.println("s1: " + s1);
+            out.println("s2: " + s2);
+            throw new RuntimeException(message);
+        }
+    }
+}
diff --git a/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java b/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java
index 0ab43f6..488960c 100644
--- a/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java
+++ b/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java
@@ -33,7 +33,7 @@
  * @summary Test checks that UnsupportedOperationException for unsupported
  * SOCKET_OPTIONS is thrown by both getOption() and setOption() methods.
  * @run main UnsupportedOptionsTest
- * @run main/othervm -Djdk.launcher.limitmods=java.base UnsupportedOptionsTest
+ * @run main/othervm -limitmods java.base UnsupportedOptionsTest
  */
 
 public class UnsupportedOptionsTest {
diff --git a/jdk/test/java/net/httpclient/HeadersTest1.java b/jdk/test/java/net/httpclient/HeadersTest1.java
new file mode 100644
index 0000000..79f6200
--- /dev/null
+++ b/jdk/test/java/net/httpclient/HeadersTest1.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ */
+
+/**
+ * @test
+ * @bug 8153142
+ * @run main/othervm HeadersTest1
+ * @summary HeadersTest1
+ */
+
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.Headers;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.PasswordAuthentication;
+import java.net.URI;
+import java.net.http.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.List;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
+public class HeadersTest1 {
+
+    final static String RESPONSE = "Hello world";
+
+    public static void main(String[] args) throws Exception {
+        HttpServer server = HttpServer.create(new InetSocketAddress(0), 10);
+        ExecutorService e = Executors.newCachedThreadPool();
+        Handler h = new Handler();
+        HttpContext serverContext = server.createContext("/test", h);
+        int port = server.getAddress().getPort();
+        System.out.println("Server port = " + port);
+
+        server.setExecutor(e);
+        server.start();
+        HttpClient client = HttpClient.create()
+                                      .build();
+
+        try {
+            URI uri = new URI("http://127.0.0.1:" + Integer.toString(port) + "/test/foo");
+            HttpRequest req = client.request(uri)
+                .headers("X-Bar", "foo1")
+                .headers("X-Bar", "foo2")
+                .GET();
+
+            HttpResponse resp = req.response();
+            if (resp.statusCode() != 200)
+                throw new RuntimeException("Test failed: status code");
+            HttpHeaders hd = resp.headers();
+            List<String> v = hd.allValues("X-Foo-Response");
+            if (!v.contains("resp1"))
+                throw new RuntimeException("Test failed: resp1");
+            if (!v.contains("resp2"))
+                throw new RuntimeException("Test failed: resp2");
+
+        } finally {
+            client.executorService().shutdownNow();
+            server.stop(0);
+            e.shutdownNow();
+        }
+        System.out.println("OK");
+    }
+
+   static class Handler implements HttpHandler {
+
+        @Override
+        public void handle(HttpExchange he) throws IOException {
+            String method = he.getRequestMethod();
+            InputStream is = he.getRequestBody();
+            List<String> l = he.getRequestHeaders().get("X-Bar");
+            if (!l.contains("foo1") || !l.contains("foo2")) {
+                for (String s : l)
+                    System.out.println("HH: " + s);
+                he.sendResponseHeaders(500, -1);
+                he.close();
+                return;
+            }
+            Headers h = he.getResponseHeaders();
+            h.add("X-Foo-Response", "resp1");
+            h.add("X-Foo-Response", "resp2");
+            he.sendResponseHeaders(200, RESPONSE.length());
+            OutputStream os = he.getResponseBody();
+            os.write(RESPONSE.getBytes(US_ASCII));
+            os.close();
+        }
+
+   }
+}
diff --git a/jdk/test/java/net/httpclient/http2/ErrorTest.java b/jdk/test/java/net/httpclient/http2/ErrorTest.java
new file mode 100644
index 0000000..578dc4d
--- /dev/null
+++ b/jdk/test/java/net/httpclient/http2/ErrorTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8157105
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.SimpleSSLContext
+ * @modules java.httpclient
+ * @compile/module=java.httpclient java/net/http/BodyOutputStream.java
+ * @compile/module=java.httpclient java/net/http/BodyInputStream.java
+ * @compile/module=java.httpclient java/net/http/EchoHandler.java
+ * @compile/module=java.httpclient java/net/http/Http2Handler.java
+ * @compile/module=java.httpclient java/net/http/Http2TestExchange.java
+ * @compile/module=java.httpclient java/net/http/Http2TestServerConnection.java
+ * @compile/module=java.httpclient java/net/http/Http2TestServer.java
+ * @compile/module=java.httpclient java/net/http/OutgoingPushPromise.java
+ * @compile/module=java.httpclient java/net/http/TestUtil.java
+ * @run testng/othervm -Djava.net.http.HttpClient.log=ssl,errors ErrorTest
+ * @summary check exception thrown when bad TLS parameters selected
+ */
+
+import java.io.*;
+import java.net.*;
+import java.net.http.*;
+import static java.net.http.HttpClient.Version.HTTP_2;
+import javax.net.ssl.*;
+import java.nio.file.*;
+import java.util.concurrent.*;
+import jdk.testlibrary.SimpleSSLContext;
+
+
+import org.testng.annotations.Test;
+import org.testng.annotations.Parameters;
+
+/**
+ * When selecting an unacceptable cipher suite the TLS handshake will fail.
+ * But, the exception that was thrown was not being returned up to application
+ * causing hang problems
+ */
+@Test
+public class ErrorTest {
+    static int httpsPort;
+    static Http2TestServer httpsServer;
+    static HttpClient client = null;
+    static ExecutorService exec;
+    static SSLContext sslContext;
+
+    static String httpsURIString;
+
+    static HttpClient getClient() {
+        if (client == null) {
+            client = HttpClient.create()
+                .sslContext(sslContext)
+                .sslParameters(new SSLParameters(
+                    new String[]{"TLS_KRB5_WITH_3DES_EDE_CBC_SHA"}))
+                .version(HTTP_2)
+                .build();
+        }
+        return client;
+    }
+
+    static URI getURI() {
+        return URI.create(httpsURIString);
+    }
+
+    static final String SIMPLE_STRING = "Hello world Goodbye world";
+
+    @Test(timeOut=5000)
+    static void test() throws Exception {
+        try {
+            SimpleSSLContext sslct = new SimpleSSLContext();
+            sslContext = sslct.get();
+            client = getClient();
+            exec = client.executorService();
+
+            httpsServer = new Http2TestServer(true, 0, new EchoHandler(),
+                    exec, sslContext);
+
+            httpsPort = httpsServer.getAddress().getPort();
+            httpsURIString = "https://127.0.0.1:" +
+                Integer.toString(httpsPort) + "/bar/";
+
+            httpsServer.start();
+            URI uri = getURI();
+            System.err.println("Request to " + uri);
+
+            HttpClient client = getClient();
+            HttpRequest req = client.request(uri)
+                    .body(HttpRequest.fromString(SIMPLE_STRING))
+                    .POST();
+            HttpResponse response = null;
+            try {
+                response = req.response();
+                throw new RuntimeException("Expected exception");
+            } catch (IOException e) {
+                System.err.println("Expected IOException received " + e);
+            }
+            System.err.println("DONE");
+        } finally {
+            httpsServer.stop();
+            exec.shutdownNow();
+        }
+    }
+}
diff --git a/jdk/test/java/net/httpclient/http2/TLSConnection.java b/jdk/test/java/net/httpclient/http2/TLSConnection.java
new file mode 100644
index 0000000..f2721eb
--- /dev/null
+++ b/jdk/test/java/net/httpclient/http2/TLSConnection.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.http.Http2Handler;
+import java.net.http.Http2TestExchange;
+import java.net.http.Http2TestServer;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLSession;
+
+/*
+ * @test
+ * @bug 8150769 8157107
+ * @summary Checks that SSL parameters can be set for HTTP/2 connection
+ * @modules java.httpclient
+ * @compile/module=java.httpclient java/net/http/Http2Handler.java
+ * @compile/module=java.httpclient java/net/http/Http2TestExchange.java
+ * @compile/module=java.httpclient java/net/http/Http2TestServer.java
+ * @run main/othervm TLSConnection
+ */
+public class TLSConnection {
+
+    private static final String KEYSTORE = System.getProperty("test.src")
+            + File.separator + "keystore.p12";
+   private static final String PASSWORD = "password";
+
+    public static void main(String[] args) throws Exception {
+
+        // enable all logging
+        System.setProperty("java.net.http.HttpClient.log", "all,frames:all");
+
+        // initialize JSSE
+        System.setProperty("javax.net.ssl.keyStore", KEYSTORE);
+        System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);
+        System.setProperty("javax.net.ssl.trustStore", KEYSTORE);
+        System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
+
+        Handler handler = new Handler();
+
+        try (Http2TestServer server = new Http2TestServer(true, 0, handler)) {
+            server.start();
+
+            int port = server.getAddress().getPort();
+            String uriString = "https://127.0.0.1:" + Integer.toString(port);
+
+            // run test cases
+            boolean success = true;
+
+            SSLParameters parameters = null;
+            success &= expectFailure(
+                    "Test #1: SSL parameters is null, expect NPE",
+                    () -> connect(uriString, parameters),
+                    NullPointerException.class);
+
+            success &= expectSuccess(
+                    "Test #2: default SSL parameters, "
+                            + "expect successful connection",
+                    () -> connect(uriString, new SSLParameters()));
+            success &= checkProtocol(handler.getSSLSession(), "TLSv1.2");
+
+            // set SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA cipher suite
+            // which has less priority in default cipher suite list
+            success &= expectSuccess(
+                    "Test #3: SSL parameters with "
+                            + "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA cipher suite, "
+                            + "expect successful connection",
+                    () -> connect(uriString, new SSLParameters(
+                            new String[] { "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA" })));
+            success &= checkProtocol(handler.getSSLSession(), "TLSv1.2");
+            success &= checkCipherSuite(handler.getSSLSession(),
+                    "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA");
+
+            // set TLS_RSA_WITH_AES_128_CBC_SHA cipher suite
+            // which has less priority in default cipher suite list
+            // also set TLSv11 protocol
+            success &= expectSuccess(
+                    "Test #4: SSL parameters with "
+                            + "TLS_RSA_WITH_AES_128_CBC_SHA cipher suite,"
+                            + " expect successful connection",
+                    () -> connect(uriString, new SSLParameters(
+                            new String[] { "TLS_RSA_WITH_AES_128_CBC_SHA" },
+                            new String[] { "TLSv1.1" })));
+            success &= checkProtocol(handler.getSSLSession(), "TLSv1.1");
+            success &= checkCipherSuite(handler.getSSLSession(),
+                    "TLS_RSA_WITH_AES_128_CBC_SHA");
+
+            if (success) {
+                System.out.println("Test passed");
+            } else {
+                throw new RuntimeException("At least one test case failed");
+            }
+        }
+    }
+
+    private static interface Test {
+
+        public void run() throws Exception;
+    }
+
+    private static class Handler implements Http2Handler {
+
+        private static final byte[] BODY = "Test response".getBytes();
+
+        private volatile SSLSession sslSession;
+
+        @Override
+        public void handle(Http2TestExchange t) throws IOException {
+            System.out.println("Handler: received request to "
+                    + t.getRequestURI());
+
+            try (InputStream is = t.getRequestBody()) {
+                byte[] body = is.readAllBytes();
+                System.out.println("Handler: read " + body.length
+                        + " bytes of body: ");
+                System.out.println(new String(body));
+            }
+
+            try (OutputStream os = t.getResponseBody()) {
+                t.sendResponseHeaders(200, BODY.length);
+                os.write(BODY);
+            }
+
+            sslSession = t.getSSLSession();
+        }
+
+        SSLSession getSSLSession() {
+            return sslSession;
+        }
+    }
+
+    private static void connect(String uriString, SSLParameters sslParameters)
+            throws URISyntaxException, IOException, InterruptedException {
+
+        String body = HttpClient.create()
+                .sslParameters(sslParameters)
+                .version(HttpClient.Version.HTTP_2)
+                .build()
+                .request(new URI(uriString))
+                .body(HttpRequest.fromString("body"))
+                .GET()
+                .response()
+                .body(HttpResponse.asString());
+
+        System.out.println("Response: " + body);
+    }
+
+    private static boolean checkProtocol(SSLSession session, String protocol) {
+        if (session == null) {
+            System.out.println("Check protocol: no session provided");
+            return false;
+        }
+
+        System.out.println("Check protocol: negotiated protocol: "
+                + session.getProtocol());
+        System.out.println("Check protocol: expected protocol: "
+                + protocol);
+        if (!protocol.equals(session.getProtocol())) {
+            System.out.println("Check protocol: unexpected negotiated protocol");
+            return false;
+        }
+
+        return true;
+    }
+
+    private static boolean checkCipherSuite(SSLSession session, String ciphersuite) {
+        if (session == null) {
+            System.out.println("Check protocol: no session provided");
+            return false;
+        }
+
+        System.out.println("Check protocol: negotiated ciphersuite: "
+                + session.getCipherSuite());
+        System.out.println("Check protocol: expected ciphersuite: "
+                + ciphersuite);
+        if (!ciphersuite.equals(session.getCipherSuite())) {
+            System.out.println("Check protocol: unexpected negotiated ciphersuite");
+            return false;
+        }
+
+        return true;
+    }
+
+    private static boolean expectSuccess(String message, Test test) {
+        System.out.println(message);
+        try {
+            test.run();
+            System.out.println("Passed");
+            return true;
+        } catch (Exception e) {
+            System.out.println("Failed: unexpected exception:");
+            e.printStackTrace(System.out);
+            return false;
+        }
+    }
+
+    private static boolean expectFailure(String message, Test test,
+            Class<? extends Throwable> expectedException) {
+
+        System.out.println(message);
+        try {
+            test.run();
+            System.out.println("Failed: unexpected successful connection");
+            return false;
+        } catch (Exception e) {
+            System.out.println("Got an exception:");
+            e.printStackTrace(System.out);
+            if (expectedException != null
+                    && !expectedException.isAssignableFrom(e.getClass())) {
+                System.out.printf("Failed: expected %s, but got %s%n",
+                        expectedException.getName(),
+                        e.getClass().getName());
+                return false;
+            }
+            System.out.println("Passed: expected exception");
+            return true;
+        }
+    }
+
+}
diff --git a/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java b/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java
index 667a1d6..3baefe1 100644
--- a/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java
+++ b/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java
@@ -42,7 +42,7 @@
  * Http2Handler on additional threads. All threads
  * obtained from the supplied ExecutorService.
  */
-public class Http2TestServer {
+public class Http2TestServer implements AutoCloseable {
     final ServerSocket server;
     boolean secure;
     SettingsFrame serverSettings, clientSettings;
@@ -156,4 +156,9 @@
         });
     }
 
+    @Override
+    public void close() throws Exception {
+        stop();
+    }
+
 }
diff --git a/jdk/test/java/nio/Buffer/Order-X.java.template b/jdk/test/java/nio/Buffer/Order-X.java.template
index a8753a5..97313a8 100644
--- a/jdk/test/java/nio/Buffer/Order-X.java.template
+++ b/jdk/test/java/nio/Buffer/Order-X.java.template
@@ -52,8 +52,5 @@
         buf = $Type$Buffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ck$Type$Buffer(buf, nord);
-
-        ck$Type$Buffer(ByteBuffer.allocate(LENGTH).as$Type$Buffer(), be);
-        ck$Type$Buffer(ByteBuffer.allocateDirect(LENGTH).as$Type$Buffer(), be);
     }
 }
diff --git a/jdk/test/java/nio/Buffer/Order.java b/jdk/test/java/nio/Buffer/Order.java
index 0232992..33ae418 100644
--- a/jdk/test/java/nio/Buffer/Order.java
+++ b/jdk/test/java/nio/Buffer/Order.java
@@ -51,25 +51,31 @@
         ck(bb.asDoubleBuffer().order(), bb.order());
     }
 
+    private static void ckCopyViews(ByteBuffer bb) {
+        ck(bb.asReadOnlyBuffer().order(), be);
+        ck(bb.duplicate().order(), be);
+        ck(bb.slice().order(), be);
+    }
+
     private static void ckByteBuffer(ByteBuffer bb) {
         ckViews(bb);
+        ckCopyViews(bb);
         bb.order(be);
         ckViews(bb);
+        ckCopyViews(bb);
         bb.order(le);
         ckViews(bb);
-
-        if (bb.hasArray()) {
-            byte[] array = bb.array();
-            ck(ByteBuffer.wrap(array, LENGTH/2, LENGTH/2).order(), be);
-            ck(ByteBuffer.wrap(array).order(), be);
-            ck(bb.asReadOnlyBuffer().order(), be);
-            ck(bb.duplicate().order(), be);
-            ck(bb.slice().order(), be);
-        }
+        ckCopyViews(bb);
     }
 
     public static void main(String args[]) throws Exception {
 
+        ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH]).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(be).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH]).order(be).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(le).order(), le);
+        ck(ByteBuffer.wrap(new byte[LENGTH]).order(le).order(), le);
         ck(ByteBuffer.allocate(LENGTH).order(), be);
         ck(ByteBuffer.allocateDirect(LENGTH).order(), be);
         ck(ByteBuffer.allocate(LENGTH).order(be).order(), be);
diff --git a/jdk/test/java/nio/Buffer/OrderChar.java b/jdk/test/java/nio/Buffer/OrderChar.java
index ebf9faa..f72828b 100644
--- a/jdk/test/java/nio/Buffer/OrderChar.java
+++ b/jdk/test/java/nio/Buffer/OrderChar.java
@@ -52,8 +52,5 @@
         buf = CharBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckCharBuffer(buf, nord);
-
-        ckCharBuffer(ByteBuffer.allocate(LENGTH).asCharBuffer(), be);
-        ckCharBuffer(ByteBuffer.allocateDirect(LENGTH).asCharBuffer(), be);
     }
 }
diff --git a/jdk/test/java/nio/Buffer/OrderDouble.java b/jdk/test/java/nio/Buffer/OrderDouble.java
index deaa6a3..4100695 100644
--- a/jdk/test/java/nio/Buffer/OrderDouble.java
+++ b/jdk/test/java/nio/Buffer/OrderDouble.java
@@ -52,8 +52,5 @@
         buf = DoubleBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckDoubleBuffer(buf, nord);
-
-        ckDoubleBuffer(ByteBuffer.allocate(LENGTH).asDoubleBuffer(), be);
-        ckDoubleBuffer(ByteBuffer.allocateDirect(LENGTH).asDoubleBuffer(), be);
     }
 }
diff --git a/jdk/test/java/nio/Buffer/OrderFloat.java b/jdk/test/java/nio/Buffer/OrderFloat.java
index 6a65eaa..905d531 100644
--- a/jdk/test/java/nio/Buffer/OrderFloat.java
+++ b/jdk/test/java/nio/Buffer/OrderFloat.java
@@ -52,8 +52,5 @@
         buf = FloatBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckFloatBuffer(buf, nord);
-
-        ckFloatBuffer(ByteBuffer.allocate(LENGTH).asFloatBuffer(), be);
-        ckFloatBuffer(ByteBuffer.allocateDirect(LENGTH).asFloatBuffer(), be);
     }
 }
diff --git a/jdk/test/java/nio/Buffer/OrderInt.java b/jdk/test/java/nio/Buffer/OrderInt.java
index 5d3843f..700fc07 100644
--- a/jdk/test/java/nio/Buffer/OrderInt.java
+++ b/jdk/test/java/nio/Buffer/OrderInt.java
@@ -52,8 +52,5 @@
         buf = IntBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckIntBuffer(buf, nord);
-
-        ckIntBuffer(ByteBuffer.allocate(LENGTH).asIntBuffer(), be);
-        ckIntBuffer(ByteBuffer.allocateDirect(LENGTH).asIntBuffer(), be);
     }
 }
diff --git a/jdk/test/java/nio/Buffer/OrderLong.java b/jdk/test/java/nio/Buffer/OrderLong.java
index abda8b22..9e507ff 100644
--- a/jdk/test/java/nio/Buffer/OrderLong.java
+++ b/jdk/test/java/nio/Buffer/OrderLong.java
@@ -52,8 +52,5 @@
         buf = LongBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckLongBuffer(buf, nord);
-
-        ckLongBuffer(ByteBuffer.allocate(LENGTH).asLongBuffer(), be);
-        ckLongBuffer(ByteBuffer.allocateDirect(LENGTH).asLongBuffer(), be);
     }
 }
diff --git a/jdk/test/java/nio/Buffer/OrderShort.java b/jdk/test/java/nio/Buffer/OrderShort.java
index d19b43a..f385b62 100644
--- a/jdk/test/java/nio/Buffer/OrderShort.java
+++ b/jdk/test/java/nio/Buffer/OrderShort.java
@@ -52,8 +52,5 @@
         buf = ShortBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckShortBuffer(buf, nord);
-
-        ckShortBuffer(ByteBuffer.allocate(LENGTH).asShortBuffer(), be);
-        ckShortBuffer(ByteBuffer.allocateDirect(LENGTH).asShortBuffer(), be);
     }
 }
diff --git a/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java b/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java
index 0028164..270efce 100644
--- a/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java
+++ b/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java
@@ -25,7 +25,7 @@
  * @bug 4640544 8044773
  * @summary Unit test for setOption/getOption/options methods
  * @run main SocketOptionTests
- * @run main/othervm -Djdk.launcher.limitmods=java.base SocketOptionTests
+ * @run main/othervm -limitmods java.base SocketOptionTests
  */
 
 import java.nio.*;
diff --git a/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java b/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java
index a0b2b6a..b8c7c32 100644
--- a/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java
+++ b/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java
@@ -26,7 +26,7 @@
  * @summary Unit test for ServerSocketChannel setOption/getOption/options
  *          methods.
  * @run main SocketOptionTests
- * @run main/othervm -Djdk.launcher.limitmods=java.base SocketOptionTests
+ * @run main/othervm -limitmods java.base SocketOptionTests
  */
 
 import java.nio.*;
diff --git a/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java b/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java
index 74f87c7..38a4e9c 100644
--- a/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java
+++ b/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java
@@ -26,7 +26,7 @@
  * @summary Unit test to check SocketChannel setOption/getOption/options
  *          methods.
  * @run main SocketOptionTests
- * @run main/othervm -Djdk.launcher.limitmods=java.base SocketOptionTests
+ * @run main/othervm -limitmods java.base SocketOptionTests
  */
 
 import java.nio.*;
diff --git a/jdk/test/java/security/Provider/DefaultProviderList.java b/jdk/test/java/security/Provider/DefaultProviderList.java
index c283664..ba63c76 100644
--- a/jdk/test/java/security/Provider/DefaultProviderList.java
+++ b/jdk/test/java/security/Provider/DefaultProviderList.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,13 +23,16 @@
 
 /**
  * @test
- * @bug 7191662
+ * @bug 7191662 8157469
  * @summary Ensure non-java.base providers can be found by ServiceLoader
  * @author Valerie Peng
  */
 
-import java.util.*;
-import java.security.*;
+import java.security.Provider;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.ServiceLoader;
 
 public class DefaultProviderList {
 
@@ -44,7 +47,8 @@
             String pName = p.getName();
             // only providers outside java.base are loaded by ServiceLoader
             if (pName.equals("SUN") || pName.equals("SunRsaSign") ||
-                pName.equals("SunJCE") || pName.equals("SunJSSE")) {
+                pName.equals("SunJCE") || pName.equals("SunJSSE") ||
+                pName.equals("Apple")) {
                 System.out.println("Skip test for provider " + pName);
                 continue;
             }
diff --git a/jdk/test/java/security/SecureRandom/ApiTest.java b/jdk/test/java/security/SecureRandom/ApiTest.java
new file mode 100644
index 0000000..e48ee4a
--- /dev/null
+++ b/jdk/test/java/security/SecureRandom/ApiTest.java
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8141039
+ * @library /lib/testlibrary
+ * @summary This test do API coverage for SecureRandom. It covers most of
+ *          supported operations along with possible positive and negative
+ *          parameters for DRBG mechanism.
+ * @run main/othervm ApiTest Hash_DRBG
+ * @run main/othervm ApiTest HMAC_DRBG
+ * @run main/othervm ApiTest CTR_DRBG
+ * @run main/othervm ApiTest SHA1PRNG
+ * @run main/othervm ApiTest NATIVE
+ */
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.SecureRandomParameters;
+import java.security.DrbgParameters;
+import java.security.DrbgParameters.Instantiation;
+import java.security.DrbgParameters.Capability;
+import javax.crypto.Cipher;
+
+public class ApiTest {
+
+    private static final boolean SHOULD_PASS = true;
+    private static final long SEED = 1l;
+    private static final String INVALID_ALGO = "INVALID";
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) throws Exception {
+        System.setProperty("java.security.egd", "file:/dev/urandom");
+
+        if (args == null || args.length < 1) {
+            throw new RuntimeException("No mechanism available to run test.");
+        }
+        String mech
+                = "NATIVE".equals(args[0]) ? supportedNativeAlgo() : args[0];
+        String[] algs = null;
+        boolean success = true;
+
+        try {
+            if (!isDRBG(mech)) {
+                SecureRandom random = SecureRandom.getInstance(mech);
+                verifyAPI(random, mech);
+                return;
+            } else if (mech.equals("CTR_DRBG")) {
+                algs = new String[]{"AES-128", "AES-192", "AES-256",
+                    INVALID_ALGO};
+            } else if (mech.equals("Hash_DRBG") || mech.equals("HMAC_DRBG")) {
+                algs = new String[]{"SHA-224", "SHA-256", "SHA-512/224",
+                    "SHA-512/256", "SHA-384", "SHA-512", INVALID_ALGO};
+            } else {
+                throw new RuntimeException(
+                        String.format("Not a valid mechanism '%s'", mech));
+            }
+            runForEachMech(mech, algs);
+        } catch (Exception e) {
+            e.printStackTrace(System.out);
+            success = false;
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Run the test for a DRBG mechanism with a possible set of parameter
+     * combination.
+     * @param mech DRBG mechanism name
+     * @param algs Algorithm supported by each mechanism
+     * @throws Exception
+     */
+    private static void runForEachMech(String mech, String[] algs)
+            throws Exception {
+        for (String alg : algs) {
+            runForEachAlg(mech, alg);
+        }
+    }
+
+    private static void runForEachAlg(String mech, String alg)
+            throws Exception {
+        for (int strength : new int[]{Integer.MIN_VALUE, -1, 0, 1, 223, 224,
+            192, 255, 256}) {
+            for (Capability cp : Capability.values()) {
+                for (byte[] pr : new byte[][]{null, new byte[]{},
+                    "personal".getBytes()}) {
+                    SecureRandomParameters param
+                            = DrbgParameters.instantiation(strength, cp, pr);
+                    runForEachParam(mech, alg, param);
+                }
+            }
+        }
+    }
+
+    private static void runForEachParam(String mech, String alg,
+            SecureRandomParameters param) throws Exception {
+
+        for (boolean df : new Boolean[]{true, false}) {
+            try {
+                Security.setProperty(DRBG_CONFIG, mech + "," + alg + ","
+                        + (df ? "use_df" : "no_df"));
+                System.out.printf("%nParameter for SecureRandom "
+                        + "mechanism: %s is (param:%s, algo:%s, df:%s)",
+                        mech, param, alg, df);
+                SecureRandom sr = SecureRandom.getInstance("DRBG", param);
+                verifyAPI(sr, mech);
+            } catch (NoSuchAlgorithmException e) {
+                // Verify exception status for current test.
+                checkException(getDefaultAlg(mech, alg), param, e);
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+        }
+    }
+
+    /**
+     * Returns the algorithm supported for input mechanism.
+     * @param mech Mechanism name
+     * @param alg Algorithm name
+     * @return Algorithm name
+     */
+    private static String getDefaultAlg(String mech, String alg)
+            throws NoSuchAlgorithmException {
+        if (alg == null) {
+            switch (mech) {
+                case "Hash_DRBG":
+                case "HMAC_DRBG":
+                    return "SHA-256";
+                case "CTR_DRBG":
+                    return (Cipher.getMaxAllowedKeyLength("AES") < 256)
+                            ? "AES-128" : "AES-256";
+                default:
+                    throw new RuntimeException("Mechanism not supported");
+            }
+        }
+        return alg;
+    }
+
+    /**
+     * Verify the exception type either it is expected to occur or not.
+     * @param alg Algorithm name
+     * @param param DRBG parameter
+     * @param e Exception to verify
+     * @throws NoSuchAlgorithmException
+     */
+    private static void checkException(String alg, SecureRandomParameters param,
+            NoSuchAlgorithmException e) throws NoSuchAlgorithmException {
+
+        int strength = ((Instantiation) param).getStrength();
+        boolean error = true;
+        switch (alg) {
+            case INVALID_ALGO:
+                error = false;
+                break;
+            case "SHA-224":
+            case "SHA-512/224":
+                if (strength > 192) {
+                    error = false;
+                }
+                break;
+            case "SHA-256":
+            case "SHA-512/256":
+            case "SHA-384":
+            case "SHA-512":
+                if (strength > 256) {
+                    error = false;
+                }
+                break;
+            case "AES-128":
+            case "AES-192":
+            case "AES-256":
+                int algoStrength = Integer.parseInt(alg.replaceAll("AES-", ""));
+                int maxStrengthSupported = Cipher.getMaxAllowedKeyLength("AES");
+                if (strength > maxStrengthSupported
+                        || algoStrength > maxStrengthSupported) {
+                    error = false;
+                }
+                break;
+        }
+        if (error) {
+            throw new RuntimeException("Unknown :", e);
+        }
+    }
+
+    /**
+     * Find if the mechanism is a DRBG mechanism.
+     * @param mech Mechanism name
+     * @return True for DRBG mechanism else False
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
+
+    /**
+     * Find the name of supported native mechanism name for current platform.
+     */
+    private static String supportedNativeAlgo() {
+        String nativeSr = "Windows-PRNG";
+        try {
+            SecureRandom.getInstance(nativeSr);
+        } catch (NoSuchAlgorithmException e) {
+            nativeSr = "NativePRNG";
+        }
+        return nativeSr;
+    }
+
+    /**
+     * Test a possible set of SecureRandom API for a SecureRandom instance.
+     * @param random SecureRandom instance
+     * @param mech Mechanism used to create SecureRandom instance
+     */
+    private static void verifyAPI(SecureRandom random, String mech)
+            throws Exception {
+
+        System.out.printf("%nTest SecureRandom mechanism: %s for provider: %s",
+                mech, random.getProvider().getName());
+        byte[] output = new byte[2];
+
+        // Generate random number.
+        random.nextBytes(output);
+
+        // Seed the SecureRandom with a generated seed value of lesser size.
+        byte[] seed = random.generateSeed(1);
+        random.setSeed(seed);
+        random.nextBytes(output);
+
+        // Seed the SecureRandom with a fixed seed value.
+        random.setSeed(SEED);
+        random.nextBytes(output);
+
+        // Seed the SecureRandom with a larger seed value.
+        seed = random.generateSeed(128);
+        random.setSeed(seed);
+        random.nextBytes(output);
+
+        // Additional operation only supported for DRBG based SecureRandom.
+        // Execute the code block and expect to pass for DRBG. If it will fail
+        // then it should fail with specified exception type. Else the case
+        // will be considered as a test case failure.
+        matchExc(() -> {
+            random.reseed();
+            random.nextBytes(output);
+        },
+                isDRBG(mech),
+                UnsupportedOperationException.class,
+                String.format("PASS - Unsupported reseed() method for "
+                        + "SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> {
+            random.reseed(DrbgParameters.reseed(false, new byte[]{}));
+            random.nextBytes(output);
+        },
+                isDRBG(mech),
+                UnsupportedOperationException.class,
+                String.format("PASS - Unsupported reseed(param) method for "
+                        + "SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> {
+            random.reseed(DrbgParameters.reseed(true, new byte[]{}));
+            random.nextBytes(output);
+        },
+                isDRBG(mech),
+                !isSupportPR(mech, random) ? IllegalArgumentException.class
+                        : UnsupportedOperationException.class,
+                String.format("PASS - Unsupported or illegal reseed(param) "
+                        + "method for SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> random.nextBytes(output,
+                DrbgParameters.nextBytes(-1, false, new byte[]{})),
+                isDRBG(mech),
+                UnsupportedOperationException.class,
+                String.format("PASS - Unsupported nextBytes(out, nextByteParam)"
+                        + " method for SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> random.nextBytes(output,
+                DrbgParameters.nextBytes(-1, true, new byte[]{})),
+                isDRBG(mech),
+                !isSupportPR(mech, random) ? IllegalArgumentException.class
+                        : UnsupportedOperationException.class,
+                String.format("PASS - Unsupported or illegal "
+                        + "nextBytes(out, nextByteParam) method for "
+                        + "SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> {
+            random.reseed(null);
+            random.nextBytes(output);
+        },
+                !SHOULD_PASS,
+                IllegalArgumentException.class,
+                "PASS - Test is expected to fail when parameter for reseed() "
+                + "is null");
+
+        matchExc(() -> random.nextBytes(output, null),
+                !SHOULD_PASS,
+                IllegalArgumentException.class,
+                "PASS - Test is expected to fail when parameter for nextBytes()"
+                + " is null");
+
+    }
+
+    private static boolean isSupportPR(String mech, SecureRandom random) {
+        return (isDRBG(mech) && ((Instantiation) random.getParameters())
+                .getCapability()
+                .supportsPredictionResistance());
+    }
+
+    private interface RunnableCode {
+
+        void run() throws Exception;
+    }
+
+    /**
+     * Execute a given code block and verify, if the exception type is expected.
+     * @param r Code block to run
+     * @param ex Expected exception type
+     * @param shouldPass If the code execution expected to pass without failure
+     * @param msg Message to log in case of expected failure
+     */
+    private static void matchExc(RunnableCode r, boolean shouldPass, Class ex,
+            String msg) {
+        try {
+            r.run();
+            if (!shouldPass) {
+                throw new RuntimeException("Excecution should fail here.");
+            }
+        } catch (Exception e) {
+            System.out.printf("%nOccured exception: %s - Expected exception: "
+                    + "%s : ", e.getClass(), ex.getCanonicalName());
+            if (ex.isAssignableFrom(e.getClass())) {
+                System.out.printf("%n%s : Expected Exception occured: %s : ",
+                        e.getClass(), msg);
+            } else if (shouldPass) {
+                throw new RuntimeException(e);
+            } else {
+                System.out.printf("Ignore the following exception: %s%n",
+                        e.getMessage());
+            }
+        }
+    }
+}
diff --git a/jdk/test/java/security/SecureRandom/EnoughSeedTest.java b/jdk/test/java/security/SecureRandom/EnoughSeedTest.java
new file mode 100644
index 0000000..a42807d
--- /dev/null
+++ b/jdk/test/java/security/SecureRandom/EnoughSeedTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8141039
+ * @library /lib/testlibrary
+ * @summary Check SecureRandom generate expected seed counts what the caller
+ *          asked for.
+ * @run main/othervm EnoughSeedTest
+ */
+import java.security.SecureRandom;
+import java.security.Security;
+import static java.lang.Math.*;
+
+public class EnoughSeedTest {
+
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) {
+        System.setProperty("java.security.egd", "file:/dev/urandom");
+
+        boolean success = true;
+        for (String mech : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            System.out.printf("%nTest for SecureRandom algorithm: '%s'", mech);
+            try {
+                SecureRandom sr = null;
+                if (!mech.contains("_DRBG")) {
+                    sr = SecureRandom.getInstance(mech);
+                } else {
+                    Security.setProperty(DRBG_CONFIG, mech);
+                    sr = SecureRandom.getInstance("DRBG");
+                }
+
+                success &= forEachSeedBytes(sr);
+                System.out.printf("%nCompleted test for SecureRandom "
+                        + "mechanism: '%s'", mech);
+            } catch (Exception e) {
+                success &= false;
+                e.printStackTrace(System.out);
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+        }
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Generates fixed number of seed bytes through a SecureRandom instance
+     * to verify it's seed generation status.
+     * @param sr SecureRandom instance
+     * @return The test success indicator
+     */
+    private static boolean forEachSeedBytes(SecureRandom sr) {
+        boolean success = true;
+        sr.setSeed(1l);
+        for (int seedByte : new int[]{Integer.MIN_VALUE, -1, 0, 1, 256, 1024,
+            Short.MAX_VALUE, (int) pow(2, 20)}) {
+            try {
+                byte[] seed = sr.generateSeed(seedByte);
+                if (seed.length != seedByte) {
+                    throw new RuntimeException("Not able to produce expected "
+                            + "seed size.");
+                }
+            } catch (IllegalArgumentException e) {
+                if (seedByte >= 0) {
+                    throw new RuntimeException("Unknown Exception occured.", e);
+                }
+                System.out.printf("%nPASS - Exception expected when required "
+                        + "seed size requested is negative: %s", seedByte);
+            }
+        }
+        return success;
+    }
+
+}
diff --git a/jdk/test/java/security/SecureRandom/GetAlgorithm.java b/jdk/test/java/security/SecureRandom/GetAlgorithm.java
index b1947ef..1ec3fd2 100644
--- a/jdk/test/java/security/SecureRandom/GetAlgorithm.java
+++ b/jdk/test/java/security/SecureRandom/GetAlgorithm.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,49 +23,54 @@
 
 /**
  * @test
- * @bug 4915392
+ * @bug 4915392 8141039
  * @summary test that the getAlgorithm() method works correctly
  * @author Andreas Sterbenz
+ * @run main GetAlgorithm
  */
-
 import java.io.*;
-
 import java.security.*;
+import java.util.Arrays;
+import java.util.List;
 
 public class GetAlgorithm {
 
-    private final static String BASE = System.getProperty("test.src", ".");
+    private static final String BASE = System.getProperty("test.src", ".");
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
 
     public static void main(String[] args) throws Exception {
-        SecureRandom sr;
-
-        sr = new SecureRandom();
+        SecureRandom sr = new SecureRandom();
         if (sr.getAlgorithm().equals("unknown")) {
             throw new Exception("Unknown: " + sr.getAlgorithm());
         }
 
-        sr = SecureRandom.getInstance("SHA1PRNG");
-        check("SHA1PRNG", sr);
+        for (String mech : new String[]{supportedNativeAlgo(), "SHA1PRNG",
+            "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            if (!mech.contains("_DRBG")) {
+                check(mech, SecureRandom.getInstance(mech));
+            } else {
+                try {
+                    Security.setProperty(DRBG_CONFIG, mech);
+                    check("DRBG", SecureRandom.getInstance("DRBG"));
+                } finally {
+                    Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+                }
+            }
+        }
+        check("unknown", new MySecureRandom());
 
-//      OutputStream out = new FileOutputStream("sha1prng.bin");
-//      ObjectOutputStream oout = new ObjectOutputStream(out);
-//      sr.nextInt();
-//      oout.writeObject(sr);
-//      oout.flush();
-//      oout.close();
-
-        sr = new MySecureRandom();
-        check("unknown", sr);
-
-        InputStream in = new FileInputStream(new File(BASE, "sha1prng-old.bin"));
+        InputStream in = new FileInputStream(
+                new File(BASE, "sha1prng-old.bin"));
         ObjectInputStream oin = new ObjectInputStream(in);
-        sr = (SecureRandom)oin.readObject();
+        sr = (SecureRandom) oin.readObject();
         oin.close();
         check("unknown", sr);
 
         in = new FileInputStream(new File(BASE, "sha1prng-new.bin"));
         oin = new ObjectInputStream(in);
-        sr = (SecureRandom)oin.readObject();
+        sr = (SecureRandom) oin.readObject();
         oin.close();
         check("SHA1PRNG", sr);
 
@@ -83,4 +88,17 @@
 
     }
 
+    /**
+     * Find the name of supported native mechanism name for current platform.
+     */
+    private static String supportedNativeAlgo() {
+        String nativeSr = "Windows-PRNG";
+        try {
+            SecureRandom.getInstance(nativeSr);
+        } catch (NoSuchAlgorithmException e) {
+            nativeSr = "NativePRNG";
+        }
+        return nativeSr;
+    }
+
 }
diff --git a/jdk/test/java/security/SecureRandom/GetInstanceTest.java b/jdk/test/java/security/SecureRandom/GetInstanceTest.java
new file mode 100644
index 0000000..08477da
--- /dev/null
+++ b/jdk/test/java/security/SecureRandom/GetInstanceTest.java
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8141039
+ * @library /lib/testlibrary
+ * @summary SecureRandom supports multiple getInstance method including
+ *          getInstanceStrong() method. This test verifies a set of possible
+ *          cases for getInstance with different SecureRandom mechanism
+ *          supported in Java.
+ * @run main GetInstanceTest
+ */
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
+import java.security.SecureRandomParameters;
+import java.security.DrbgParameters;
+import static java.security.DrbgParameters.Capability.*;
+import java.security.Security;
+import java.util.Arrays;
+import jdk.testlibrary.Asserts;
+
+public class GetInstanceTest {
+
+    private static final boolean PASS = true;
+    private static final String INVALID_ALGO = "INVALID";
+    private static final String SUN_PROVIDER = "SUN";
+    private static final String INVALID_PROVIDER = "INVALID";
+    private static final String STRONG_ALG_SEC_PROP
+            = "securerandom.strongAlgorithms";
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) throws Exception {
+
+        boolean success = true;
+        // Only accepted failure is NoSuchAlgorithmException.
+        // For any other failure the test case will fail here.
+        SecureRandom sr = matchExc(() -> SecureRandom.getInstanceStrong(),
+                PASS, NoSuchAlgorithmException.class,
+                "PASS - Undefined security Property "
+                + "'securerandom.strongAlgorithms'");
+        System.out.format("Current platform supports mechanism: '%s' through "
+                + "provider: '%s' for the method getInstanceStrong().",
+                sr.getAlgorithm(), sr.getProvider().getName());
+
+        // DRBG name should appear with "securerandom.strongAlgorithms"
+        // security property.
+        String origDRBGConfig = Security.getProperty(STRONG_ALG_SEC_PROP);
+        if (!origDRBGConfig.contains("DRBG")) {
+            throw new RuntimeException("DRBG is not associated with default "
+                    + "strong algorithm through security Property: "
+                    + "'securerandom.strongAlgorithms'.");
+        }
+        try {
+            Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN");
+            sr = matchExc(() -> SecureRandom.getInstanceStrong(),
+                    PASS, NoSuchAlgorithmException.class,
+                    "PASS - Undefined security Property "
+                    + "'securerandom.strongAlgorithms'");
+            checkAttributes(sr, "DRBG");
+        } finally {
+            Security.setProperty(STRONG_ALG_SEC_PROP, origDRBGConfig);
+        }
+
+        for (String mech : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", INVALID_ALGO,}) {
+            System.out.printf("%nTest SecureRandom mechanism: '%s'", mech);
+            try {
+                if (isDRBG(mech)) {
+                    Security.setProperty(DRBG_CONFIG, mech);
+                }
+                verifyInstance(mech);
+            } catch (Exception e) {
+                e.printStackTrace(System.out);
+                success = false;
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+        }
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    private static void verifyInstance(String mech) throws Exception {
+
+        String srAlgo = isDRBG(mech) ? "DRBG" : mech;
+
+        // Test for getInstance(algorithm) method.
+        // It should pass for all case other than invalid algorithm name.
+        // If it fails then the expected exception type should be
+        // NoSuchAlgorithmException. Any other Exception type occured will be
+        // treated as failure.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(srAlgo), !(nsa(mech)),
+                        NoSuchAlgorithmException.class,
+                        String.format("PASS - It is expected to fail for"
+                                + " getInstance(algorithm) when algorithm: '%s'"
+                                + " is null or invalid.", mech)), mech);
+        // Test for getInstance(algorithm, provider) method.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(srAlgo,
+                                Security.getProvider(SUN_PROVIDER)),
+                        !(nsa(mech)),
+                        NoSuchAlgorithmException.class,
+                        String.format("PASS - It is expected to fail for"
+                                + " getInstance(algorithm, provider) when"
+                                + " algorithm:'%s' is null or invalid.", mech)),
+                mech);
+        // Test for getInstance(algorithm, providerName) method.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(srAlgo, SUN_PROVIDER),
+                        !(nsa(mech)), NoSuchAlgorithmException.class,
+                        String.format("PASS - It is expected to fail for "
+                                + "getInstance(algorithm, providerName) when "
+                                + "algorithm: '%s' is null or invalid.", mech)),
+                mech);
+        // Test for getInstance(algorithm, providerName) method.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(
+                                srAlgo, INVALID_PROVIDER),
+                        !PASS, NoSuchProviderException.class,
+                        String.format("PASS - It is expected to fail for "
+                                + "getInstance(algorithm, providerName) when "
+                                + "provider name: '%s' is invalid and "
+                                + "algorithm: '%s'", INVALID_PROVIDER, mech)),
+                mech);
+
+        // Run the test for a set of SecureRandomParameters
+        for (SecureRandomParameters param : Arrays.asList(null,
+                DrbgParameters.instantiation(-1, NONE, null))) {
+
+            System.out.printf("%nRunning DRBG param getInstance() methods "
+                    + "for algorithm: %s and DRBG param type: %s", mech,
+                    (param != null) ? param.getClass().getName() : param);
+
+            // Following Test are applicable for new DRBG methods only.
+            // Test for getInstance(algorithm, params) method.
+            // Tests are expected to pass for DRBG type with valid parameter
+            // If it fails the expected exception type is derived from
+            // getExcType(mech, param) method. If exception type is not
+            // expected then the test will be considered as failure.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param),
+                            (isDRBG(mech)) && (isValidDRBGParam(param)),
+                            getExcType(mech, param),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params) "
+                                    + "for algorithm: %s and parameter: %s",
+                                    mech, param)),
+                    mech);
+            // Test for getInstance(algorithm, params, provider) method.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    Security.getProvider(SUN_PROVIDER)),
+                            (isDRBG(mech)) && (isValidDRBGParam(param)),
+                            getExcType(mech, param),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "provider) for algorithm: %s and "
+                                    + "parameter: %s", mech, param)),
+                    mech);
+            // Test for getInstance(algorithm, params, providerName) method.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    SUN_PROVIDER),
+                            (isDRBG(mech)) && (isValidDRBGParam(param)),
+                            getExcType(mech, param),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) for algorithm: %s and "
+                                    + "parameter: %s", mech, param)), mech);
+            // getInstance(algorithm, params, providerName) when
+            // providerName is invalid
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    INVALID_PROVIDER),
+                            !PASS, ((param == null)
+                                    ? IllegalArgumentException.class
+                                    : NoSuchProviderException.class),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) when param is null or"
+                                    + " provider: %s is invalid for "
+                                    + "algorithm: '%s'", INVALID_PROVIDER,
+                                    mech)), mech);
+            // getInstance(algorithm, params, provider) when provider=null
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    (String) null),
+                            !PASS, IllegalArgumentException.class,
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) when provider name "
+                                    + "is null")), mech);
+            // getInstance(algorithm, params, providerName) when
+            // providerName is empty.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(
+                                    srAlgo, param, ""),
+                            !PASS, IllegalArgumentException.class,
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) when provider name "
+                                    + "is empty")), mech);
+        }
+    }
+
+    private static boolean isValidDRBGParam(SecureRandomParameters param) {
+        return (param instanceof DrbgParameters.Instantiation);
+    }
+
+    /**
+     * If the mechanism should occur NoSuchAlgorithmException.
+     */
+    private static boolean nsa(String mech) {
+        return mech.equals(INVALID_ALGO);
+    }
+
+    /**
+     * Verify if the mechanism is DRBG type.
+     * @param mech Mechanism name
+     * @return True if the mechanism name is DRBG type else False.
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
+
+    /**
+     * Type of exception expected for a SecureRandom instance when exception
+     * occurred while calling getInstance method with a fixed set of parameter.
+     * @param mech Mechanism used to create a SecureRandom instance
+     * @param param Parameter to getInstance() method
+     * @return Exception type expected
+     */
+    private static Class getExcType(String mech, SecureRandomParameters param) {
+        return ((isDRBG(mech) && !isValidDRBGParam(param)) || param == null)
+                ? IllegalArgumentException.class
+                : NoSuchAlgorithmException.class;
+    }
+
+    private interface RunnableCode {
+
+        SecureRandom run() throws Exception;
+    }
+
+    /**
+     * Execute a given code block and verify, if the exception type is expected.
+     * @param r Code block to run
+     * @param ex Expected exception type
+     * @param shouldPass If the code execution expected to pass without failure
+     * @param msg Message to log in case of expected failure
+     */
+    private static SecureRandom matchExc(RunnableCode r, boolean shouldPass,
+            Class ex, String msg) {
+        SecureRandom sr = null;
+        try {
+            sr = r.run();
+            if (!shouldPass) {
+                throw new RuntimeException("Excecution should fail here.");
+            }
+        } catch (Exception e) {
+            System.out.printf("%nOccured exception: %s - Expected exception: %s"
+                    + " : ", e.getClass(), ex.getCanonicalName());
+            if (ex.isAssignableFrom(e.getClass())) {
+                System.out.printf("%n%s : Expected Exception: %s : ",
+                        e.getClass(), msg);
+            } else if (shouldPass) {
+                throw new RuntimeException(e);
+            } else {
+                System.out.printf("%nIgnore the following exception: %s%n",
+                        e.getMessage());
+            }
+        }
+        return sr;
+    }
+
+    /**
+     * Check specific attributes of a SecureRandom instance.
+     */
+    private static void checkAttributes(SecureRandom sr, String mech) {
+        if (sr == null) {
+            return;
+        }
+        Asserts.assertEquals(sr.getAlgorithm(), (isDRBG(mech) ? "DRBG" : mech));
+        Asserts.assertEquals(sr.getProvider().getName(), SUN_PROVIDER);
+    }
+
+}
diff --git a/jdk/test/java/security/SecureRandom/MultiThreadTest.java b/jdk/test/java/security/SecureRandom/MultiThreadTest.java
new file mode 100644
index 0000000..82c6d68
--- /dev/null
+++ b/jdk/test/java/security/SecureRandom/MultiThreadTest.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.math.BigInteger;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import static java.lang.Math.*;
+
+/*
+ * @test
+ * @bug 8141039
+ * @library /lib/testlibrary
+ * @summary Test behavior of a shared SecureRandom object when it is operated
+ *          by multiple threads concurrently.
+ * @run main/othervm -Djava.security.egd=file:/dev/urandom MultiThreadTest
+ */
+public class MultiThreadTest {
+
+    private static final byte[] GEN_RND_BYTES = {1};
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    private enum SEED {
+
+        NONE, RESEED, SETSEED
+    }
+
+    public static void main(String[] args) {
+
+        boolean success = true;
+        for (int byteLen : GEN_RND_BYTES) {
+            for (SEED reSeed : SEED.values()) {
+                for (String mech : new String[]{
+                    "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+                    try {
+                        forEachMech(mech, byteLen, reSeed);
+                    } catch (Exception e) {
+                        success = false;
+                        e.printStackTrace(System.out);
+                    } finally {
+                        Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+                    }
+                }
+            }
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Generate a number of threads to fetch random numbers of certain bits
+     * generated through a shared SecureRandom instance.
+     * @param mech Mechanism name
+     * @param byteLen Number of bytes of random number to produce
+     * @param reSeed Call reseed() before generating random numbers
+     * @throws NoSuchAlgorithmException
+     * @throws InterruptedException
+     * @throws ExecutionException
+     */
+    private static void forEachMech(String mech, int byteLen, SEED reSeed)
+            throws NoSuchAlgorithmException, InterruptedException,
+            ExecutionException {
+
+        if ("SHA1PRNG".equals(mech) && SEED.RESEED.equals(reSeed)) {
+            System.out.printf(
+                    "%nreseed() api is not supported for '%s'", mech);
+            return;
+        }
+        System.out.printf("%nTest SecureRandom mechanism: '%s' with support of"
+                + " reseed: '%s'", mech, reSeed);
+        int threadCount = (int) pow(2, 8 * byteLen);
+        System.out.printf("%nCreating %s number of threads to generate secure "
+                + "random numbers concurrently.", threadCount);
+
+        ExecutorService executor
+                = Executors.newCachedThreadPool(new ThreadFactory() {
+                    @Override
+                    public Thread newThread(Runnable r) {
+                        Thread t = Executors.defaultThreadFactory()
+                        .newThread(r);
+                        t.setDaemon(true);
+                        return t;
+                    }
+                });
+        CompletionService<Integer> completionService
+                = new ExecutorCompletionService<Integer>(executor);
+
+        CountDownLatch latch = new CountDownLatch(1);
+        SecureRandom rnd = null;
+        if (!mech.contains("_DRBG")) {
+            rnd = SecureRandom.getInstance(mech);
+        } else {
+            Security.setProperty(DRBG_CONFIG, mech);
+            rnd = SecureRandom.getInstance("DRBG");
+        }
+        try {
+            for (int i = 0; i < threadCount; i++) {
+                completionService.submit(new Task(rnd, latch, byteLen, reSeed));
+            }
+            latch.countDown();
+
+            for (int i = 0; i < threadCount; i++) {
+                completionService.take();
+            }
+        } finally {
+            executor.shutdown();
+        }
+        System.out.printf("%nCompleted Test for algorithm '%s' with thread "
+                + "counts to '%s' using reseeding '%s'",
+                mech, threadCount, reSeed);
+
+    }
+
+    /**
+     * Define a Task to be executed by multiple thread to produce random numbers
+     * from a shared SecureRandom instance.
+     */
+    private static class Task implements Callable<Integer> {
+
+        private final SecureRandom random;
+        private final CountDownLatch latch;
+        private final SEED reSeed;
+        private final int byteSize;
+
+        public Task(SecureRandom random, CountDownLatch latch, int byteSize,
+                SEED reSeed) {
+            this.random = random;
+            this.latch = latch;
+            this.byteSize = byteSize;
+            this.reSeed = reSeed;
+        }
+
+        @Override
+        public Integer call() throws Exception {
+            latch.await();
+            switch (this.reSeed) {
+                case RESEED:
+                    this.random.reseed();
+                    break;
+                case SETSEED:
+                    this.random.setSeed(1l);
+                    break;
+            }
+            byte[] bytes = new byte[byteSize];
+            random.nextBytes(bytes);
+            return new BigInteger(bytes).intValue();
+        }
+    }
+
+}
diff --git a/jdk/test/java/security/SecureRandom/Serialize.java b/jdk/test/java/security/SecureRandom/Serialize.java
index 799f1bf..2e36487 100644
--- a/jdk/test/java/security/SecureRandom/Serialize.java
+++ b/jdk/test/java/security/SecureRandom/Serialize.java
@@ -24,6 +24,7 @@
 /* @test
  * @bug 4102896
  * @summary Make sure that a SecureRandom object can be serialized
+ * @run main/othervm Serialize
  */
 
 import java.security.*;
@@ -32,6 +33,8 @@
 public class Serialize {
 
     public static void main(String args[]) throws Exception {
+        System.setProperty("java.security.egd", "file:/dev/urandom");
+
         for (String alg: new String[]{
                 "SHA1PRNG", "DRBG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG",
                 "Hash_DRBG,SHA-512,192,pr_and_reseed"}) {
diff --git a/jdk/test/java/security/SecureRandom/SerializedSeedTest.java b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java
new file mode 100644
index 0000000..9af7296
--- /dev/null
+++ b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8141039
+ * @library /lib/testlibrary
+ * @summary When random number is generated through the a SecureRandom instance
+ *          as well from it's serialized instance in the same time then the
+ *          generated random numbers should be different when one or both are
+ *          reseeded.
+ * @run main/othervm -Djava.security.egd=file:/dev/urandom SerializedSeedTest
+ */
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.Security;
+import jdk.testlibrary.Asserts;
+
+public class SerializedSeedTest {
+
+    private static final byte[] SEED = "seed".getBytes();
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) {
+        boolean success = true;
+
+        for (String mech : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            System.out.printf(
+                    "%nRunning test for SecureRandom mechanism: '%s'", mech);
+            try {
+                // Serialize without seed and compare generated random numbers
+                // produced through original and serialized instances.
+                SecureRandom orig = getSRInstance(mech);
+                SecureRandom copy = deserializedCopy(orig);
+                System.out.printf("%nSerialize without seed. Generated random"
+                        + " numbers should be different.");
+                check(orig, copy, false, mech);
+
+                // Serialize after default seed and compare generated random
+                // numbers produced through original and serialized instances.
+                orig = getSRInstance(mech);
+                orig.nextInt(); // Default seeded
+                copy = deserializedCopy(orig);
+                System.out.printf("%nSerialize after default seed. Generated"
+                        + " random numbers should be same till 20-bytes.");
+                check(orig, copy, !isDRBG(mech), mech);
+
+                // Serialize after explicit seed and compare generated random
+                // numbers produced through original and serialized instances.
+                orig = getSRInstance(mech);
+                orig.setSeed(SEED); // Explicitly seeded
+                copy = deserializedCopy(orig);
+                System.out.printf("%nSerialize after explicit seed. Generated "
+                        + "random numbers should be same till 20-bytes.");
+                check(orig, copy, !isDRBG(mech), mech);
+
+                // Serialize without seed but original is explicitly seeded
+                // before generating any random number. Then compare generated
+                // random numbers produced through original and serialized
+                // instances.
+                orig = getSRInstance(mech);
+                copy = deserializedCopy(orig);
+                orig.setSeed(SEED); // Explicitly seeded
+                System.out.printf("%nSerialize without seed. When original is "
+                        + "explicitly seeded before generating random numbers,"
+                        + " Generated random numbers should be different.");
+                check(orig, copy, false, mech);
+
+                // Serialize after default seed but original is explicitly
+                // seeded before generating any random number. Then compare
+                // generated random numbers produced through original and
+                // serialized instances.
+                orig = getSRInstance(mech);
+                orig.nextInt(); // Default seeded
+                copy = deserializedCopy(orig);
+                orig.setSeed(SEED); // Explicitly seeded
+                System.out.printf("%nSerialize after default seed but original "
+                        + "is explicitly seeded before generating random number"
+                        + ". Generated random numbers should be different.");
+                check(orig, copy, false, mech);
+
+                // Serialize after explicit seed but original is explicitly
+                // seeded again before generating random number. Then compare
+                // generated random numbers produced through original and
+                // serialized instances.
+                orig = getSRInstance(mech);
+                orig.setSeed(SEED); // Explicitly seeded
+                copy = deserializedCopy(orig);
+                orig.setSeed(SEED); // Explicitly seeded
+                System.out.printf("%nSerialize after explicit seed but "
+                        + "original is explicitly seeded again before "
+                        + "generating random number. Generated random "
+                        + "numbers should be different.");
+                check(orig, copy, false, mech);
+
+            } catch (Exception e) {
+                e.printStackTrace(System.out);
+                success = false;
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+            System.out.printf("%n------Completed Test for %s------", mech);
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Find if the mechanism is a DRBG mechanism.
+     * @param mech Mechanism name
+     * @return True for DRBG mechanism else False
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
+
+    /**
+     * Verify the similarity of random numbers generated though both original
+     * as well as deserialized instance.
+     */
+    private static void check(SecureRandom orig, SecureRandom copy,
+            boolean equal, String mech) {
+        int o = orig.nextInt();
+        int c = copy.nextInt();
+        System.out.printf("%nRandom number generated for mechanism: '%s' "
+                + "from original instance as: '%s' and from serialized "
+                + "instance as: '%s'", mech, o, c);
+        if (equal) {
+            Asserts.assertEquals(o, c, mech);
+        } else {
+            Asserts.assertNotEquals(o, c, mech);
+        }
+    }
+
+    /**
+     * Get a copy of SecureRandom instance through deserialization.
+     * @param orig Original SecureRandom instance
+     * @return Deserialized SecureRandom instance
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    private static SecureRandom deserializedCopy(SecureRandom orig)
+            throws IOException, ClassNotFoundException {
+        return deserialize(serialize(orig));
+    }
+
+    /**
+     * Deserialize the SecureRandom object.
+     */
+    private static SecureRandom deserialize(byte[] serialized)
+            throws IOException, ClassNotFoundException {
+        SecureRandom sr = null;
+        try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
+                ObjectInputStream ois = new ObjectInputStream(bis)) {
+            sr = (SecureRandom) ois.readObject();
+        }
+        return sr;
+    }
+
+    /**
+     * Serialize the given SecureRandom object.
+     */
+    private static byte[] serialize(SecureRandom sr) throws IOException {
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+            oos.writeObject(sr);
+            return bos.toByteArray();
+        }
+    }
+
+    /**
+     * Create a SecureRandom instance for a given mechanism.
+     */
+    private static SecureRandom getSRInstance(String mech)
+            throws NoSuchAlgorithmException {
+        if (!isDRBG(mech)) {
+            return SecureRandom.getInstance(mech);
+        } else {
+            Security.setProperty(DRBG_CONFIG, mech);
+            return SecureRandom.getInstance("DRBG");
+        }
+    }
+
+}
diff --git a/jdk/test/java/sql/TEST.properties b/jdk/test/java/sql/TEST.properties
new file mode 100644
index 0000000..878b05f
--- /dev/null
+++ b/jdk/test/java/sql/TEST.properties
@@ -0,0 +1,2 @@
+modules = java.sql
+
diff --git a/jdk/test/java/util/Currency/PropertiesTest.java b/jdk/test/java/util/Currency/PropertiesTest.java
index 96127bf..fe35f2e 100644
--- a/jdk/test/java/util/Currency/PropertiesTest.java
+++ b/jdk/test/java/util/Currency/PropertiesTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 import java.text.*;
 import java.util.*;
 import java.util.regex.*;
+import java.util.stream.Collectors;
 
 public class PropertiesTest {
     public static void main(String[] args) throws Exception {
@@ -32,9 +33,14 @@
             dump(args[1]);
         } else if (args.length == 4 && args[0].equals("-c")) {
             compare(args[1], args[2], args[3]);
+        } else if (args.length == 1 && args[0].equals("bug7102969")) {
+            bug7102969();
+        } else if (args.length == 1 && args[0].equals("bug8157138")) {
+            bug8157138();
         } else {
             System.err.println("Usage:  java PropertiesTest -d <dumpfile>");
             System.err.println("        java PropertiesTest -c <beforedump> <afterdump> <propsfile>");
+            System.err.println("        java PropertiesTest bug[JBS bug id number] e.g. bug7102969");
             System.exit(-1);
         }
     }
@@ -174,6 +180,74 @@
         }
     }
 
+    private static void bug7102969() {
+
+        // check the correct overriding of special case entries
+        Currency cur = Currency.getInstance(new Locale("", "JP"));
+        if (!cur.getCurrencyCode().equals("ABC")) {
+            throw new RuntimeException("[Expected: ABC as currency code of JP, found: "
+                    + cur.getCurrencyCode() + "]");
+        }
+
+        /* check if the currency instance is returned by
+         * getAvailableCurrencies() method
+         */
+        if (!Currency.getAvailableCurrencies().contains(cur)) {
+            throw new RuntimeException("[The Currency instance ["
+                    + cur.getCurrencyCode() + ", "
+                    + cur.getNumericCode() + ", "
+                    + cur.getDefaultFractionDigits()
+                    + "] is not available in the currencies list]");
+        }
+
+    }
+
+    private static void bug8157138() {
+
+        /* check the currencies which exist only as a special case are
+         * accessible i.e. it should not throw IllegalArgumentException
+         */
+        try {
+            Currency.getInstance("MAD");
+        } catch (IllegalArgumentException ex) {
+            throw new RuntimeException("Test Failed: "
+                    + "special case currency instance MAD not found"
+                    + " via Currency.getInstance(\"MAD\")");
+        }
+
+        try {
+            Currency.getInstance("ABC");
+        } catch (IllegalArgumentException ex) {
+            throw new RuntimeException("Test Failed: "
+                    + "special case currency instance ABC not found"
+                    + " via Currency.getInstance(\"ABC\")");
+        }
+
+        /* check the currency value is returned by getAvailableCurrencies()
+         * method
+        */
+        List<Currency> list = Currency.getAvailableCurrencies().stream()
+                .filter(cur -> cur.getCurrencyCode().equals("MAD"))
+                .collect(Collectors.toList());
+
+        if (list.isEmpty()) {
+            throw new RuntimeException("Test Failed: "
+                    + "special case currency instance MAD not found"
+                    + " in Currency.getAvailableCurrencies() list");
+        }
+
+        list = Currency.getAvailableCurrencies().stream()
+                .filter(cur -> cur.getCurrencyCode().equals("ABC"))
+                .collect(Collectors.toList());
+
+        if (list.isEmpty()) {
+            throw new RuntimeException("Test Failed: "
+                    + "special case currency instance ABC not found"
+                    + " in Currency.getAvailableCurrencies() list");
+        }
+
+    }
+
     private static boolean isPastCutoverDate(String s)
             throws IndexOutOfBoundsException, NullPointerException, ParseException {
         String dateString = s.substring(s.lastIndexOf(',')+1, s.length()).trim();
diff --git a/jdk/test/java/util/Currency/PropertiesTest.sh b/jdk/test/java/util/Currency/PropertiesTest.sh
index a6f8a76..215be92 100644
--- a/jdk/test/java/util/Currency/PropertiesTest.sh
+++ b/jdk/test/java/util/Currency/PropertiesTest.sh
@@ -23,7 +23,8 @@
 #
 
 # @test
-# @bug 6332666 6863624 7180362 8003846 8074350 8074351 8130246 8149735
+# @bug 6332666 6863624 7180362 8003846 8074350 8074351 8130246 8149735 7102969
+#      8157138
 # @summary tests the capability of replacing the currency data with user
 #     specified currency properties file
 # @build PropertiesTest
@@ -113,6 +114,16 @@
 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 if [ ! -f dump3 ]; then  echo "file dump3 not created. Test cannot execute.  Failed."; exit 1; fi
 
+# run bug7102969 test
+echo ''
+${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest bug7102969
+if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+
+# run bug8157138 test
+echo ''
+${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest bug8157138
+if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+
 # Cleanup
 rm -rf $WRITABLEJDK
 
diff --git a/jdk/test/java/util/Currency/currency.properties b/jdk/test/java/util/Currency/currency.properties
index d8e874d..57b2935 100644
--- a/jdk/test/java/util/Currency/currency.properties
+++ b/jdk/test/java/util/Currency/currency.properties
@@ -6,7 +6,7 @@
 CL=CLF,990,4
 CM=IED,111,2, 2004-01-01T00:70:00
 ES=ESD,877,2
-JP=JPZ,123,2
+JP=ABC,999,0
 MA=MAA,555,5
 MC=MCC,555,6
 MD=MDD,555,7
diff --git a/jdk/test/java/util/Currency/tablea1.txt b/jdk/test/java/util/Currency/tablea1.txt
index 92e43ad..dacc0fb 100644
--- a/jdk/test/java/util/Currency/tablea1.txt
+++ b/jdk/test/java/util/Currency/tablea1.txt
@@ -5,7 +5,7 @@
 #
 
 # Version
-FILEVERSION=2
+FILEVERSION=3
 DATAVERSION=160
 
 # ISO 4217 currency data
diff --git a/jdk/test/java/util/Objects/CheckIndex.java b/jdk/test/java/util/Objects/CheckIndex.java
index c4efdb1..bcfa1d5 100644
--- a/jdk/test/java/util/Objects/CheckIndex.java
+++ b/jdk/test/java/util/Objects/CheckIndex.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,13 @@
 
 /**
  * @test
- * @summary IndexOutOfBoundsException check index tests
+ * @summary Objects.checkIndex/jdk.internal.util.Preconditions.checkIndex tests
  * @run testng CheckIndex
- * @bug 8135248 8142493
+ * @bug 8135248 8142493 8155794
+ * @modules java.base/jdk.internal.util
  */
 
+import jdk.internal.util.Preconditions;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
@@ -95,7 +97,7 @@
     public void testCheckIndex(int index, int length, boolean withinBounds) {
         String expectedMessage = withinBounds
                                  ? null
-                                 : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+                                 : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
                 apply("checkIndex", List.of(index, length)).getMessage();
 
         BiConsumer<Class<? extends RuntimeException>, IntSupplier> checker = (ec, s) -> {
@@ -117,21 +119,21 @@
         };
 
         checker.accept(AssertingOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              assertingOutOfBounds(expectedMessage, "checkIndex", index, length)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    assertingOutOfBounds(expectedMessage, "checkIndex", index, length)));
         checker.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              assertingOutOfBoundsReturnNull("checkIndex", index, length)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    assertingOutOfBoundsReturnNull("checkIndex", index, length)));
         checker.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length, null));
+                     () -> Preconditions.checkIndex(index, length, null));
         checker.accept(IndexOutOfBoundsException.class,
                      () -> Objects.checkIndex(index, length));
         checker.accept(ArrayIndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
         checker.accept(StringIndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
     }
 
 
@@ -157,7 +159,7 @@
     public void testCheckFromToIndex(int fromIndex, int toIndex, int length, boolean withinBounds) {
         String expectedMessage = withinBounds
                                  ? null
-                                 : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+                                 : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
                 apply("checkFromToIndex", List.of(fromIndex, toIndex, length)).getMessage();
 
         BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
@@ -179,21 +181,21 @@
         };
 
         check.accept(AssertingOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                                    assertingOutOfBounds(expectedMessage, "checkFromToIndex", fromIndex, toIndex, length)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          assertingOutOfBounds(expectedMessage, "checkFromToIndex", fromIndex, toIndex, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                                    assertingOutOfBoundsReturnNull("checkFromToIndex", fromIndex, toIndex, length)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          assertingOutOfBoundsReturnNull("checkFromToIndex", fromIndex, toIndex, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length, null));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length, null));
         check.accept(IndexOutOfBoundsException.class,
                      () -> Objects.checkFromToIndex(fromIndex, toIndex, length));
         check.accept(ArrayIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                              Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
         check.accept(StringIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                              Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
     }
 
 
@@ -226,7 +228,7 @@
     public void testCheckFromIndexSize(int fromIndex, int size, int length, boolean withinBounds) {
         String expectedMessage = withinBounds
                                  ? null
-                                 : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+                                 : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
                 apply("checkFromIndexSize", List.of(fromIndex, size, length)).getMessage();
 
         BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
@@ -248,27 +250,27 @@
         };
 
         check.accept(AssertingOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                      assertingOutOfBounds(expectedMessage, "checkFromIndexSize", fromIndex, size, length)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            assertingOutOfBounds(expectedMessage, "checkFromIndexSize", fromIndex, size, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                      assertingOutOfBoundsReturnNull("checkFromIndexSize", fromIndex, size, length)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            assertingOutOfBoundsReturnNull("checkFromIndexSize", fromIndex, size, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length, null));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length, null));
         check.accept(IndexOutOfBoundsException.class,
                      () -> Objects.checkFromIndexSize(fromIndex, size, length));
         check.accept(ArrayIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                    Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
         check.accept(StringIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                    Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
     }
 
     @Test
     public void uniqueMessagesForCheckKinds() {
         BiFunction<String, List<Integer>, IndexOutOfBoundsException> f =
-                Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new);
+                Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new);
 
         List<String> messages = new ArrayList<>();
         // Exact arguments
diff --git a/jdk/test/java/util/Properties/CheckOverrides.java b/jdk/test/java/util/Properties/CheckOverrides.java
new file mode 100644
index 0000000..327143a
--- /dev/null
+++ b/jdk/test/java/util/Properties/CheckOverrides.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/*
+ * @test
+ * @bug 8029891
+ * @summary Test that the Properties class overrides all public+protected
+ *          methods of all ancestor classes and interfaces
+ * @run main CheckOverrides
+ */
+public class CheckOverrides {
+
+    public static void main(String[] args) {
+        Set<MethodSignature> pMethodSignatures =
+            Stream.of(Properties.class.getDeclaredMethods())
+                .filter(CheckOverrides::isMethodOfInterest)
+                .map(MethodSignature::new)
+                .collect(Collectors.toSet());
+
+        Map<MethodSignature, Method> unoverriddenMethods = new HashMap<>();
+        for (Class<?> superclass = Properties.class.getSuperclass();
+             superclass != Object.class;
+             superclass = superclass.getSuperclass()) {
+            Stream.of(superclass.getDeclaredMethods())
+                .filter(CheckOverrides::isMethodOfInterest)
+                .forEach(m -> unoverriddenMethods.putIfAbsent(new MethodSignature(m), m));
+        }
+        unoverriddenMethods.keySet().removeAll(pMethodSignatures);
+
+        if (!unoverriddenMethods.isEmpty()) {
+            throw new RuntimeException(
+                "The following methods should be overridden by Properties class:\n" +
+                    unoverriddenMethods.values().stream()
+                        .map(Method::toString)
+                        .collect(Collectors.joining("\n  ", "  ", "\n"))
+            );
+        }
+    }
+
+    static boolean isMethodOfInterest(Method method) {
+        int mods = method.getModifiers();
+        return !Modifier.isStatic(mods) &&
+            (Modifier.isPublic(mods) || Modifier.isProtected(mods));
+    }
+
+    static class MethodSignature {
+        final Class<?> returnType;
+        final String name;
+        final Class<?>[] parameterTypes;
+
+        MethodSignature(Method method) {
+            this(method.getReturnType(), method.getName(), method.getParameterTypes());
+        }
+
+        private MethodSignature(Class<?> returnType, String name, Class<?>[] parameterTypes) {
+            this.returnType = returnType;
+            this.name = name;
+            this.parameterTypes = parameterTypes;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+            MethodSignature that = (MethodSignature) o;
+            if (!returnType.equals(that.returnType)) return false;
+            if (!name.equals(that.name)) return false;
+            return Arrays.equals(parameterTypes, that.parameterTypes);
+        }
+
+        @Override
+        public int hashCode() {
+            int result = returnType.hashCode();
+            result = 31 * result + name.hashCode();
+            result = 31 * result + Arrays.hashCode(parameterTypes);
+            return result;
+        }
+    }
+}
+
diff --git a/jdk/test/java/util/Properties/CheckUnsynchronized.java b/jdk/test/java/util/Properties/CheckUnsynchronized.java
new file mode 100644
index 0000000..1b32cca
--- /dev/null
+++ b/jdk/test/java/util/Properties/CheckUnsynchronized.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.concurrent.CompletableFuture;
+
+/*
+ * @test
+ * @bug 8029891
+ * @summary Test Properties methods that do not synchronize any more
+ * @run main CheckUnsynchronized
+ */
+public class CheckUnsynchronized {
+    public static void main(String[] args) {
+        Properties props = new Properties();
+        synchronized (props) {
+            props.setProperty("key", "value");
+            System.out.println("contains(value)? " +
+                    CompletableFuture.supplyAsync(() -> props.contains("value")).join());
+            System.out.println("containsKey(key)? " +
+                    CompletableFuture.supplyAsync(() -> props.containsKey("key")).join());
+            System.out.println("containsValue(value)? " +
+                    CompletableFuture.supplyAsync(() -> props.containsValue("value")).join());
+            Enumeration<Object> elems =
+                    CompletableFuture.supplyAsync(() -> props.elements()).join();
+            System.out.println("first value from elements(): " + elems.nextElement());
+            System.out.println("value from get(): " +
+                    CompletableFuture.supplyAsync(() -> props.getProperty("key")).join());
+            System.out.println("getOrDefault(\"missing\"): " +
+                    CompletableFuture.supplyAsync(() -> props.getOrDefault("missing", "default")).join());
+            System.out.println("isEmpty()? " +
+                    CompletableFuture.supplyAsync(() -> props.isEmpty()).join());
+            Enumeration<Object> keys =
+                    CompletableFuture.supplyAsync(() -> props.keys()).join();
+            System.out.println("first key from keys(): " + keys.nextElement());
+            System.out.println("size(): " +
+                    CompletableFuture.supplyAsync(() -> props.size()).join());
+        }
+    }
+}
diff --git a/jdk/test/java/util/Properties/PropertiesSerialization.java b/jdk/test/java/util/Properties/PropertiesSerialization.java
new file mode 100644
index 0000000..2fcf1dc
--- /dev/null
+++ b/jdk/test/java/util/Properties/PropertiesSerialization.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Base64;
+import java.util.Properties;
+
+/**
+ * @test
+ * @bug 8029891
+ * @summary tests the compatibility of Properties serial form
+ * @run main PropertiesSerialization read
+ *
+ * To update this test in case the serial form of Properties changes, run this
+ * test with the 'write' flag, and copy the resulting output back into this
+ * file, replacing the existing String declaration(s).
+ */
+public class PropertiesSerialization {
+    private static final Properties TEST_PROPS;
+    static {
+        TEST_PROPS = new Properties();
+        TEST_PROPS.setProperty("one", "two");
+        TEST_PROPS.setProperty("buckle", "shoe");
+        TEST_PROPS.setProperty("three", "four");
+        TEST_PROPS.setProperty("shut", "door");
+    }
+
+    /**
+     * Base64 encoded string for Properties object
+     * Java version: 1.8.0
+     **/
+    private static final String TEST_SER_BASE64 =
+         "rO0ABXNyABRqYXZhLnV0aWwuUHJvcGVydGllczkS0HpwNj6YAgABTAAIZGVmYXVs"
+       + "dHN0ABZMamF2YS91dGlsL1Byb3BlcnRpZXM7eHIAE2phdmEudXRpbC5IYXNodGFi"
+       + "bGUTuw8lIUrkuAMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAI"
+       + "dwgAAAALAAAABHQAA29uZXQAA3R3b3QABHNodXR0AARkb29ydAAGYnVja2xldAAE"
+       + "c2hvZXQABXRocmVldAAEZm91cnhw";
+
+    public static void main(String[] args) throws IOException,
+            ClassNotFoundException {
+        if (args.length == 0) {
+            System.err.println("Run with 'read' or 'write'");
+            System.err.println("  read mode:  normal test mode.");
+            System.err.println("              Confirms that serial stream can");
+            System.err.println("              be deserialized as expected.");
+            System.err.println("  write mode: meant for updating the test,");
+            System.err.println("              should the serial form change.");
+            System.err.println("              Test output should be pasted");
+            System.err.println("              back into the test source.");
+            return;
+        }
+
+        Properties deserializedObject;
+        if ("read".equals(args[0])) {
+            ByteArrayInputStream bais = new
+              ByteArrayInputStream(Base64.getDecoder().decode(TEST_SER_BASE64));
+            try (ObjectInputStream ois = new ObjectInputStream(bais)) {
+                deserializedObject = (Properties) ois.readObject();
+            }
+            if (!TEST_PROPS.equals(deserializedObject)) {
+                throw new RuntimeException("deserializedObject not equals()");
+            }
+            System.out.println("Test passed");
+        } else if ("write".equals(args[0])) {
+            System.out.println("\nTo update the test, paste the following back "
+                    + "into the test code:\n");
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(TEST_PROPS);
+            oos.flush();
+            oos.close();
+
+            byte[] byteArray = baos.toByteArray();
+            // Check that the Properties deserializes correctly
+            ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
+            ObjectInputStream ois = new ObjectInputStream(bais);
+            Properties deser = (Properties)ois.readObject();
+            if (!TEST_PROPS.equals(deser)) {
+                throw new RuntimeException("write: Deserialized != original");
+            }
+
+            // Now get a Base64 string representation of the serialized bytes.
+            final String base64 = Base64.getEncoder().encodeToString(byteArray);
+            // Check that we can deserialize the Base64 string we just computed.
+            ByteArrayInputStream bais2 =
+              new ByteArrayInputStream(Base64.getDecoder().decode(base64));
+            ObjectInputStream ois2 = new ObjectInputStream(bais2);
+            Properties deser2 = (Properties)ois2.readObject();
+            if (!TEST_PROPS.equals(deser2)) {
+                throw new RuntimeException("write: Deserialized base64 != "
+                        + "original");
+            }
+            System.out.println(dumpBase64SerialStream(base64));
+        }
+    }
+
+    private static final String INDENT = "   ";
+    /* Based on:
+     * java/util/logging/HigherResolutionTimeStamps/SerializeLogRecored.java
+     */
+    private static String dumpBase64SerialStream(String base64) {
+        // Generates the Java Pseudo code that can be cut & pasted into
+        // this test (see Jdk8SerializedLog and Jdk9SerializedLog below)
+        final StringBuilder sb = new StringBuilder();
+        sb.append(INDENT).append(" /**").append('\n');
+        sb.append(INDENT).append("  * Base64 encoded string for Properties object\n");
+        sb.append(INDENT).append("  * Java version: ")
+                .append(System.getProperty("java.version")).append('\n');
+        sb.append(INDENT).append("  **/").append('\n');
+        sb.append(INDENT).append(" private static final String TEST_SER_BASE64 = ")
+                .append("\n").append(INDENT).append("      ");
+        final int last = base64.length() - 1;
+        for (int i=0; i<base64.length();i++) {
+            if (i%64 == 0) sb.append("\"");
+            sb.append(base64.charAt(i));
+            if (i%64 == 63 || i == last) {
+                sb.append("\"");
+                if (i == last) sb.append(";\n");
+                else sb.append("\n").append(INDENT).append("    + ");
+            }
+        }
+        return sb.toString();
+    }
+}
diff --git a/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java b/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java
index abb90c0..55d4c2f 100644
--- a/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java
+++ b/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java
@@ -157,7 +157,7 @@
         Layer bootLayer = Layer.boot();
         Configuration parent = bootLayer.configuration();
         Configuration cf
-            = parent.resolveRequiresAndUses(finder, ModuleFinder.empty(), Set.of());
+            = parent.resolveRequiresAndUses(finder, ModuleFinder.of(), Set.of());
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
 
diff --git a/jdk/test/java/util/TimeZone/Bug8149452.java b/jdk/test/java/util/TimeZone/Bug8149452.java
new file mode 100644
index 0000000..eb4c0bc
--- /dev/null
+++ b/jdk/test/java/util/TimeZone/Bug8149452.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8149452
+ * @summary Check the missing time zone names.
+ */
+import java.text.DateFormatSymbols;
+import java.util.ArrayList;
+import java.util.TimeZone;
+import java.util.Arrays;
+import java.util.List;
+
+public class Bug8149452 {
+
+    public static void main(String[] args) {
+
+        List<String> listNotFound = new ArrayList<>();
+        String[][] zoneStrings = DateFormatSymbols.getInstance()
+                .getZoneStrings();
+        for (String tzID : TimeZone.getAvailableIDs()) {
+            if (!Arrays.stream(zoneStrings)
+                    .anyMatch(zone -> tzID.equalsIgnoreCase(zone[0]))) {
+                // to ignore names for Etc/GMT[+-][0-9]+ which are not supported
+                if (!tzID.startsWith("Etc/GMT") && !tzID.startsWith("GMT")) {
+                    listNotFound.add(tzID);
+                }
+            }
+        }
+
+        if (!listNotFound.isEmpty()) {
+            throw new RuntimeException("Test Failed: Time Zone Strings for "
+                    + listNotFound + " not found");
+        }
+
+    }
+
+}
diff --git a/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java b/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java
index 7d6da0b2..630f379 100644
--- a/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java
+++ b/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -167,7 +167,7 @@
                             final String childPid,
                             final String className) {
         final String regex =
-            "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E$";
+            "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E(?:$| )";
         final Callable<Integer> objectsInUse =
             new Callable<Integer>() { public Integer call() {
                 Integer i = Integer.parseInt(
diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
index e6dd04c..54b889f 100644
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8132734
+ * @bug 8132734 8144062
  * @summary Test the extended API and the aliasing additions in JarFile that
  *          support multi-release jar files
  * @library /lib/testlibrary/java/util/jar
@@ -39,7 +39,6 @@
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
-import jdk.Version;
 
 import static java.util.jar.JarFile.Release;
 
@@ -51,7 +50,7 @@
 
 public class MultiReleaseJarAPI {
 
-    static final int MAJOR_VERSION = Version.current().major();
+    static final int MAJOR_VERSION = Runtime.version().major();
 
     String userdir = System.getProperty("user.dir",".");
     CreateMultiReleaseTestJars creator =  new CreateMultiReleaseTestJars();
diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java
index 59900cf..60d5063 100644
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8132734
+ * @bug 8132734 8144062
  * @summary Test the extended API and the aliasing additions in JarFile that
  *          support multi-release jar files
  * @library /lib/testlibrary/java/util/jar
@@ -42,7 +42,6 @@
 import java.util.jar.JarFile;
 import java.util.stream.Collectors;
 import java.util.zip.ZipFile;
-import jdk.Version;
 
 import static java.util.jar.JarFile.Release;
 
@@ -54,7 +53,7 @@
 
 public class MultiReleaseJarIterators {
 
-    static final int MAJOR_VERSION = Version.current().major();
+    static final int MAJOR_VERSION = Runtime.version().major();
 
     String userdir = System.getProperty("user.dir", ".");
     File unversioned = new File(userdir, "unversioned.jar");
diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java
index 6bf059f..d729c43 100644
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8132734
+ * @bug 8132734 8144062
  * @summary Test the System properties for JarFile that support multi-release jar files
  * @library /lib/testlibrary/java/util/jar
  * @build Compiler JarBuilder CreateMultiReleaseTestJars
@@ -54,7 +54,6 @@
 import java.nio.file.Files;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
-import jdk.Version;
 
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
@@ -63,7 +62,7 @@
 
 public class MultiReleaseJarProperties {
 
-    static final int MAJOR_VERSION = Version.current().major();
+    static final int MAJOR_VERSION = Runtime.version().major();
 
     final static int ROOTVERSION = 8; // magic number from knowledge of internals
     final static String userdir = System.getProperty("user.dir", ".");
diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java
index 348194a..538742c 100644
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8132734
+ * @bug 8132734 8144062
  * @summary Test potential security related issues
  * @library /lib/testlibrary/java/util/jar
  * @build Compiler JarBuilder CreateMultiReleaseTestJars
@@ -40,7 +40,6 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.zip.ZipFile;
-import jdk.Version;
 
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
@@ -49,7 +48,7 @@
 
 public class MultiReleaseJarSecurity {
 
-    static final int MAJOR_VERSION = Version.current().major();
+    static final int MAJOR_VERSION = Runtime.version().major();
 
     String userdir = System.getProperty("user.dir",".");
     File multirelease = new File(userdir, "multi-release.jar");
diff --git a/jdk/test/java/util/regex/RegExTest.java b/jdk/test/java/util/regex/RegExTest.java
index 815cb99..34f9cdb 100644
--- a/jdk/test/java/util/regex/RegExTest.java
+++ b/jdk/test/java/util/regex/RegExTest.java
@@ -34,7 +34,7 @@
  * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590
  * 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819
  * 8151481 4867170 7080302 6728861 6995635 6736245 4916384
- * 6328855 6192895 6345469 6988218 6693451 7006761 8140212
+ * 6328855 6192895 6345469 6988218 6693451 7006761 8140212 8143282
  *
  * @library /lib/testlibrary
  * @build jdk.testlibrary.*
@@ -4345,12 +4345,13 @@
         Matcher definedP = Pattern.compile("\\p{IsAssigned}").matcher("");
         Matcher nonCCPP = Pattern.compile("\\p{IsNoncharacterCodePoint}").matcher("");
         Matcher joinCrtl = Pattern.compile("\\p{IsJoinControl}").matcher("");
-
         // javaMethod
         Matcher lowerJ  = Pattern.compile("\\p{javaLowerCase}").matcher("");
         Matcher upperJ  = Pattern.compile("\\p{javaUpperCase}").matcher("");
         Matcher alphaJ  = Pattern.compile("\\p{javaAlphabetic}").matcher("");
         Matcher ideogJ  = Pattern.compile("\\p{javaIdeographic}").matcher("");
+        // GC/C
+        Matcher gcC  = Pattern.compile("\\p{C}").matcher("");
 
         for (int cp = 1; cp < 0x30000; cp++) {
             String str = new String(Character.toChars(cp));
@@ -4416,8 +4417,14 @@
                 Character.isIdeographic(cp) != ideogJ.reset(str).matches() ||
                 (Character.UNASSIGNED == type) == definedP.reset(str).matches() ||
                 POSIX_Unicode.isNoncharacterCodePoint(cp) != nonCCPP.reset(str).matches() ||
-                POSIX_Unicode.isJoinControl(cp) != joinCrtl.reset(str).matches())
+                POSIX_Unicode.isJoinControl(cp) != joinCrtl.reset(str).matches() ||
+                // gc_C
+                (Character.CONTROL == type || Character.FORMAT == type ||
+                 Character.PRIVATE_USE == type || Character.SURROGATE == type ||
+                 Character.UNASSIGNED == type)
+                != gcC.reset(str).matches()) {
                 failCount++;
+            }
         }
 
         // bounds/word align
diff --git a/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java b/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java
new file mode 100644
index 0000000..87f35b4
--- /dev/null
+++ b/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Component;
+import javax.swing.JLabel;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+/*
+ * @test
+ * @bug 8017112
+ * @summary JTabbedPane components have inconsistent accessibility tree
+ * @run main AccessibleIndexInParentTest
+ */
+
+public class AccessibleIndexInParentTest {
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(AccessibleIndexInParentTest::test);
+    }
+
+    private static void test() {
+
+        int N = 5;
+        JTabbedPane tabbedPane = new JTabbedPane();
+
+        for (int i = 0; i < N; i++) {
+            tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i));
+        }
+
+        for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+            Component child = tabbedPane.getComponentAt(i);
+
+            AccessibleContext ac = child.getAccessibleContext();
+            if (ac == null) {
+                throw new RuntimeException("Accessible Context is null!");
+            }
+
+            int index = ac.getAccessibleIndexInParent();
+            Accessible parent = ac.getAccessibleParent();
+
+            if (parent.getAccessibleContext().getAccessibleChild(index) != child) {
+                throw new RuntimeException("Wrong getAccessibleIndexInParent!");
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java b/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java
index 6592555..35f35a5 100644
--- a/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,8 +47,16 @@
  * An example to show the way to use SSLEngine in datagram connections.
  */
 public class DTLSOverDatagram {
+
+    static {
+        System.setProperty("javax.net.debug", "ssl");
+    }
+
     private static int MAX_HANDSHAKE_LOOPS = 200;
     private static int MAX_APP_READ_LOOPS = 60;
+    private static int SOCKET_TIMEOUT = 10 * 1000; // in millis
+    private static int BUFFER_SIZE = 1024;
+    private static int MAXIMUM_PACKET_SIZE = 1024;
 
     /*
      * The following is to set up the keystores.
@@ -84,37 +92,33 @@
     /*
      * Define the server side of the test.
      */
-    void doServerSide() throws Exception {
-        DatagramSocket socket = serverDatagramSocket;
-        socket.setSoTimeout(10000);   // 10 second
+    void doServerSide(DatagramSocket socket, InetSocketAddress clientSocketAddr)
+            throws Exception {
 
         // create SSLEngine
         SSLEngine engine = createSSLEngine(false);
 
         // handshaking
-        handshake(engine, socket, clientSocketAddr);
+        handshake(engine, socket, clientSocketAddr, "Server");
 
         // read client application data
         receiveAppData(engine, socket, clientApp);
 
         // write server application data
         deliverAppData(engine, socket, serverApp, clientSocketAddr);
-
-        socket.close();
     }
 
     /*
      * Define the client side of the test.
      */
-    void doClientSide() throws Exception {
-        DatagramSocket socket = clientDatagramSocket;
-        socket.setSoTimeout(1000);     // 1 second read timeout
+    void doClientSide(DatagramSocket socket, InetSocketAddress serverSocketAddr)
+            throws Exception {
 
         // create SSLEngine
         SSLEngine engine = createSSLEngine(true);
 
         // handshaking
-        handshake(engine, socket, serverSocketAddr);
+        handshake(engine, socket, serverSocketAddr, "Client");
 
         // write client application data
         deliverAppData(engine, socket, clientApp, serverSocketAddr);
@@ -132,7 +136,7 @@
         SSLEngine engine = context.createSSLEngine();
 
         SSLParameters paras = engine.getSSLParameters();
-        paras.setMaximumPacketSize(1024);
+        paras.setMaximumPacketSize(MAXIMUM_PACKET_SIZE);
 
         engine.setUseClientMode(isClient);
         engine.setSSLParameters(paras);
@@ -142,7 +146,7 @@
 
     // handshake
     void handshake(SSLEngine engine, DatagramSocket socket,
-            SocketAddress peerAddr) throws Exception {
+            SocketAddress peerAddr, String side) throws Exception {
 
         boolean endLoops = false;
         int loops = MAX_HANDSHAKE_LOOPS;
@@ -159,39 +163,60 @@
             if (hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP ||
                 hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP_AGAIN) {
 
+                log(side, "Receive DTLS records, handshake status is " + hs);
+
                 ByteBuffer iNet;
                 ByteBuffer iApp;
                 if (hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) {
-                    // receive ClientHello request and other SSL/TLS records
-                    byte[] buf = new byte[1024];
+                    byte[] buf = new byte[BUFFER_SIZE];
                     DatagramPacket packet = new DatagramPacket(buf, buf.length);
                     try {
                         socket.receive(packet);
                     } catch (SocketTimeoutException ste) {
-                        List<DatagramPacket> packets =
-                                onReceiveTimeout(engine, peerAddr);
+                        log(side, "Warning: " + ste);
+
+                        List<DatagramPacket> packets = new ArrayList<>();
+                        boolean finished = onReceiveTimeout(
+                                engine, peerAddr, side, packets);
+
                         for (DatagramPacket p : packets) {
                             socket.send(p);
                         }
 
+                        if (finished) {
+                            log(side, "Handshake status is FINISHED "
+                                    + "after calling onReceiveTimeout(), "
+                                    + "finish the loop");
+                            endLoops = true;
+                        }
+
+                        log(side, "New handshake status is "
+                                + engine.getHandshakeStatus());
+
                         continue;
                     }
 
                     iNet = ByteBuffer.wrap(buf, 0, packet.getLength());
-                    iApp = ByteBuffer.allocate(1024);
+                    iApp = ByteBuffer.allocate(BUFFER_SIZE);
                 } else {
                     iNet = ByteBuffer.allocate(0);
-                    iApp = ByteBuffer.allocate(1024);
+                    iApp = ByteBuffer.allocate(BUFFER_SIZE);
                 }
 
                 SSLEngineResult r = engine.unwrap(iNet, iApp);
                 SSLEngineResult.Status rs = r.getStatus();
                 hs = r.getHandshakeStatus();
-                if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) {
+                if (rs == SSLEngineResult.Status.OK) {
+                    // OK
+                } else if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) {
+                    log(side, "BUFFER_OVERFLOW, handshake status is " + hs);
+
                     // the client maximum fragment size config does not work?
                     throw new Exception("Buffer overflow: " +
                         "incorrect client maximum fragment size");
                 } else if (rs == SSLEngineResult.Status.BUFFER_UNDERFLOW) {
+                    log(side, "BUFFER_UNDERFLOW, handshake status is " + hs);
+
                     // bad packet, or the client maximum fragment size
                     // config does not work?
                     if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
@@ -199,31 +224,64 @@
                             "incorrect client maximum fragment size");
                     } // otherwise, ignore this packet
                 } else if (rs == SSLEngineResult.Status.CLOSED) {
-                    endLoops = true;
-                }   // otherwise, SSLEngineResult.Status.OK:
+                    throw new Exception(
+                            "SSL engine closed, handshake status is " + hs);
+                } else {
+                    throw new Exception("Can't reach here, result is " + rs);
+                }
 
-                if (rs != SSLEngineResult.Status.OK) {
-                    continue;
+                if (hs == SSLEngineResult.HandshakeStatus.FINISHED) {
+                    log(side, "Handshake status is FINISHED, finish the loop");
+                    endLoops = true;
                 }
             } else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP) {
-                List<DatagramPacket> packets =
-                        produceHandshakePackets(engine, peerAddr);
+                List<DatagramPacket> packets = new ArrayList<>();
+                boolean finished = produceHandshakePackets(
+                    engine, peerAddr, side, packets);
+
                 for (DatagramPacket p : packets) {
                     socket.send(p);
                 }
+
+                if (finished) {
+                    log(side, "Handshake status is FINISHED "
+                            + "after producing handshake packets, "
+                            + "finish the loop");
+                    endLoops = true;
+                }
             } else if (hs == SSLEngineResult.HandshakeStatus.NEED_TASK) {
                 runDelegatedTasks(engine);
             } else if (hs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
-                // OK, time to do application data exchange.
+                log(side, "Handshake status is NOT_HANDSHAKING, finish the loop");
                 endLoops = true;
             } else if (hs == SSLEngineResult.HandshakeStatus.FINISHED) {
-                endLoops = true;
+                throw new Exception(
+                        "Unexpected status, SSLEngine.getHandshakeStatus() "
+                                + "shouldn't return FINISHED");
+            } else {
+                throw new Exception("Can't reach here, handshake status is " + hs);
             }
         }
 
         SSLEngineResult.HandshakeStatus hs = engine.getHandshakeStatus();
+        log(side, "Handshake finished, status is " + hs);
+
+        if (engine.getHandshakeSession() != null) {
+            throw new Exception(
+                    "Handshake finished, but handshake session is not null");
+        }
+
+        SSLSession session = engine.getSession();
+        if (session == null) {
+            throw new Exception("Handshake finished, but session is null");
+        }
+        log(side, "Negotiated protocol is " + session.getProtocol());
+        log(side, "Negotiated cipher suite is " + session.getCipherSuite());
+
+        // handshake status should be NOT_HANDSHAKING
+        // according to the spec, SSLEngine.getHandshakeStatus() can't return FINISHED
         if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
-            throw new Exception("Not ready for application data yet");
+            throw new Exception("Unexpected handshake status " + hs);
         }
     }
 
@@ -251,11 +309,11 @@
                         "Too much loops to receive application data");
             }
 
-            byte[] buf = new byte[1024];
+            byte[] buf = new byte[BUFFER_SIZE];
             DatagramPacket packet = new DatagramPacket(buf, buf.length);
             socket.receive(packet);
             ByteBuffer netBuffer = ByteBuffer.wrap(buf, 0, packet.getLength());
-            ByteBuffer recBuffer = ByteBuffer.allocate(1024);
+            ByteBuffer recBuffer = ByteBuffer.allocate(BUFFER_SIZE);
             SSLEngineResult rs = engine.unwrap(netBuffer, recBuffer);
             recBuffer.flip();
             if (recBuffer.remaining() != 0) {
@@ -270,10 +328,9 @@
     }
 
     // produce handshake packets
-    List<DatagramPacket> produceHandshakePackets(
-            SSLEngine engine, SocketAddress socketAddr) throws Exception {
+    boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
+            String side, List<DatagramPacket> packets) throws Exception {
 
-        List<DatagramPacket> packets = new ArrayList<>();
         boolean endLoops = false;
         int loops = MAX_HANDSHAKE_LOOPS;
         while (!endLoops &&
@@ -296,6 +353,8 @@
                 throw new Exception("Buffer overflow: " +
                             "incorrect server maximum fragment size");
             } else if (rs == SSLEngineResult.Status.BUFFER_UNDERFLOW) {
+                log(side, "Produce handshake packets: BUFFER_UNDERFLOW occured");
+                log(side, "Produce handshake packets: Handshake status: " + hs);
                 // bad packet, or the client maximum fragment size
                 // config does not work?
                 if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
@@ -304,7 +363,11 @@
                 } // otherwise, ignore this packet
             } else if (rs == SSLEngineResult.Status.CLOSED) {
                 throw new Exception("SSLEngine has closed");
-            }   // otherwise, SSLEngineResult.Status.OK
+            } else if (rs == SSLEngineResult.Status.OK) {
+                // OK
+            } else {
+                throw new Exception("Can't reach here, result is " + rs);
+            }
 
             // SSLEngineResult.Status.OK:
             if (oNet.hasRemaining()) {
@@ -313,25 +376,39 @@
                 DatagramPacket packet = createHandshakePacket(ba, socketAddr);
                 packets.add(packet);
             }
+
+            if (hs == SSLEngineResult.HandshakeStatus.FINISHED) {
+                log(side, "Produce handshake packets: "
+                            + "Handshake status is FINISHED, finish the loop");
+                return true;
+            }
+
             boolean endInnerLoop = false;
             SSLEngineResult.HandshakeStatus nhs = hs;
             while (!endInnerLoop) {
                 if (nhs == SSLEngineResult.HandshakeStatus.NEED_TASK) {
                     runDelegatedTasks(engine);
-                    nhs = engine.getHandshakeStatus();
-                } else if ((nhs == SSLEngineResult.HandshakeStatus.FINISHED) ||
-                    (nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) ||
-                    (nhs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING)) {
+                } else if (nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP ||
+                    nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP_AGAIN ||
+                    nhs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
 
                     endInnerLoop = true;
                     endLoops = true;
                 } else if (nhs == SSLEngineResult.HandshakeStatus.NEED_WRAP) {
                     endInnerLoop = true;
+                } else if (nhs == SSLEngineResult.HandshakeStatus.FINISHED) {
+                    throw new Exception(
+                            "Unexpected status, SSLEngine.getHandshakeStatus() "
+                                    + "shouldn't return FINISHED");
+                } else {
+                    throw new Exception("Can't reach here, handshake status is "
+                            + nhs);
                 }
+                nhs = engine.getHandshakeStatus();
             }
         }
 
-        return packets;
+        return false;
     }
 
     DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) {
@@ -358,7 +435,11 @@
             throw new Exception("Buffer underflow during wraping");
         } else if (rs == SSLEngineResult.Status.CLOSED) {
                 throw new Exception("SSLEngine has closed");
-        }   // otherwise, SSLEngineResult.Status.OK
+        } else if (rs == SSLEngineResult.Status.OK) {
+            // OK
+        } else {
+            throw new Exception("Can't reach here, result is " + rs);
+        }
 
         // SSLEngineResult.Status.OK:
         if (appNet.hasRemaining()) {
@@ -386,15 +467,15 @@
     }
 
     // retransmission if timeout
-    List<DatagramPacket> onReceiveTimeout(
-            SSLEngine engine, SocketAddress socketAddr) throws Exception {
+    boolean onReceiveTimeout(SSLEngine engine, SocketAddress socketAddr,
+            String side, List<DatagramPacket> packets) throws Exception {
 
         SSLEngineResult.HandshakeStatus hs = engine.getHandshakeStatus();
         if (hs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
-            return new ArrayList<DatagramPacket>();
+            return false;
         } else {
             // retransmission of handshake messages
-            return produceHandshakePackets(engine, socketAddr);
+            return produceHandshakePackets(engine, socketAddr, side, packets);
         }
     }
 
@@ -405,8 +486,13 @@
 
         char[] passphrase = "passphrase".toCharArray();
 
-        ks.load(new FileInputStream(keyFilename), passphrase);
-        ts.load(new FileInputStream(trustFilename), passphrase);
+        try (FileInputStream fis = new FileInputStream(keyFilename)) {
+            ks.load(fis, passphrase);
+        }
+
+        try (FileInputStream fis = new FileInputStream(trustFilename)) {
+            ts.load(fis, passphrase);
+        }
 
         KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
         kmf.init(ks, passphrase);
@@ -427,94 +513,84 @@
      * The remainder is support stuff to kickstart the testing.
      */
 
-    // the server side SocketAddress
-    volatile static SocketAddress serverSocketAddr = null;
-
-    // the client side SocketAddress
-    volatile static SocketAddress clientSocketAddr = null;
-
-    // the server side DatagramSocket instance
-    volatile static DatagramSocket serverDatagramSocket = null;
-
-    // the server side DatagramSocket instance
-    volatile static DatagramSocket clientDatagramSocket = null;
-
-    // get server side SocketAddress object
-    public SocketAddress getServerSocketAddress() {
-        return serverSocketAddr;
-    }
-
-    // get client side SocketAddress object
-    public SocketAddress getClientSocketAddress() {
-        return clientSocketAddr;
-    }
-
-    // get server side DatagramSocket object
-    public DatagramSocket getServerDatagramSocket() {
-        return serverDatagramSocket;
-    }
-
-    // get client side DatagramSocket object
-    public DatagramSocket getClientDatagramSocket() {
-        return clientDatagramSocket;
-    }
-
     // Will the handshaking and application data exchange succeed?
     public boolean isGoodJob() {
         return true;
     }
 
     public final void runTest(DTLSOverDatagram testCase) throws Exception {
-        serverDatagramSocket = new DatagramSocket();
-        serverSocketAddr = new InetSocketAddress(
-            InetAddress.getLocalHost(), serverDatagramSocket.getLocalPort());
+        try (DatagramSocket serverSocket = new DatagramSocket();
+                DatagramSocket clientSocket = new DatagramSocket()) {
 
-        clientDatagramSocket = new DatagramSocket();
-        clientSocketAddr = new InetSocketAddress(
-            InetAddress.getLocalHost(), clientDatagramSocket.getLocalPort());
+            serverSocket.setSoTimeout(SOCKET_TIMEOUT);
+            clientSocket.setSoTimeout(SOCKET_TIMEOUT);
 
-        ExecutorService pool = Executors.newFixedThreadPool(2);
-        List<Future<String>> list = new ArrayList<Future<String>>();
+            InetSocketAddress serverSocketAddr = new InetSocketAddress(
+                    InetAddress.getLocalHost(), serverSocket.getLocalPort());
 
-        try {
-            list.add(pool.submit(new ServerCallable(testCase)));  // server task
-            list.add(pool.submit(new ClientCallable(testCase)));  // client task
-        } finally {
-            pool.shutdown();
-        }
+            InetSocketAddress clientSocketAddr = new InetSocketAddress(
+                    InetAddress.getLocalHost(), clientSocket.getLocalPort());
 
-        Exception reserved = null;
-        for (Future<String> fut : list) {
+            ExecutorService pool = Executors.newFixedThreadPool(2);
+            Future<String> server, client;
+
             try {
-                System.out.println(fut.get());
-            } catch (CancellationException |
-                    InterruptedException | ExecutionException cie) {
-                if (reserved != null) {
-                    cie.addSuppressed(reserved);
-                    reserved = cie;
-                } else {
-                    reserved = cie;
-                }
+                server = pool.submit(new ServerCallable(
+                        testCase, serverSocket, clientSocketAddr));
+                client = pool.submit(new ClientCallable(
+                        testCase, clientSocket, serverSocketAddr));
+            } finally {
+                pool.shutdown();
             }
-        }
 
-        if (reserved != null) {
-            throw reserved;
+            boolean failed = false;
+
+            // wait for client to finish
+            try {
+                System.out.println("Client finished: " + client.get());
+            } catch (CancellationException | InterruptedException
+                        | ExecutionException e) {
+                System.out.println("Exception on client side: ");
+                e.printStackTrace(System.out);
+                failed = true;
+            }
+
+            // wait for server to finish
+            try {
+                System.out.println("Client finished: " + server.get());
+            } catch (CancellationException | InterruptedException
+                        | ExecutionException e) {
+                System.out.println("Exception on server side: ");
+                e.printStackTrace(System.out);
+                failed = true;
+            }
+
+            if (failed) {
+                throw new RuntimeException("Test failed");
+            }
         }
     }
 
     final static class ServerCallable implements Callable<String> {
-        DTLSOverDatagram testCase;
 
-        ServerCallable(DTLSOverDatagram testCase) {
+        private final DTLSOverDatagram testCase;
+        private final DatagramSocket socket;
+        private final InetSocketAddress clientSocketAddr;
+
+        ServerCallable(DTLSOverDatagram testCase, DatagramSocket socket,
+                InetSocketAddress clientSocketAddr) {
+
             this.testCase = testCase;
+            this.socket = socket;
+            this.clientSocketAddr = clientSocketAddr;
         }
 
         @Override
         public String call() throws Exception {
             try {
-                testCase.doServerSide();
+                testCase.doServerSide(socket, clientSocketAddr);
             } catch (Exception e) {
+                System.out.println("Exception in  ServerCallable.call():");
                 e.printStackTrace(System.out);
                 serverException = e;
 
@@ -523,10 +599,6 @@
                 } else {
                     return "Well done, server!";
                 }
-            } finally {
-                if (serverDatagramSocket != null) {
-                    serverDatagramSocket.close();
-                }
             }
 
             if (testCase.isGoodJob()) {
@@ -538,28 +610,33 @@
     }
 
     final static class ClientCallable implements Callable<String> {
-        DTLSOverDatagram testCase;
 
-        ClientCallable(DTLSOverDatagram testCase) {
+        private final DTLSOverDatagram testCase;
+        private final DatagramSocket socket;
+        private final InetSocketAddress serverSocketAddr;
+
+        ClientCallable(DTLSOverDatagram testCase, DatagramSocket socket,
+                InetSocketAddress serverSocketAddr) {
+
             this.testCase = testCase;
+            this.socket = socket;
+            this.serverSocketAddr = serverSocketAddr;
         }
 
         @Override
         public String call() throws Exception {
             try {
-                testCase.doClientSide();
+                testCase.doClientSide(socket, serverSocketAddr);
             } catch (Exception e) {
+                System.out.println("Exception in ClientCallable.call():");
                 e.printStackTrace(System.out);
                 clientException = e;
+
                 if (testCase.isGoodJob()) {
                     throw e;
                 } else {
                     return "Well done, client!";
                 }
-            } finally {
-                if (clientDatagramSocket != null) {
-                    clientDatagramSocket.close();
-                }
             }
 
             if (testCase.isGoodJob()) {
@@ -600,4 +677,8 @@
             System.out.flush();
         }
     }
+
+    static void log(String side, String message) {
+        System.out.println(side + ": " + message);
+    }
 }
diff --git a/jdk/test/javax/net/ssl/DTLS/Reordered.java b/jdk/test/javax/net/ssl/DTLS/Reordered.java
index 9e91979..25053d2 100644
--- a/jdk/test/javax/net/ssl/DTLS/Reordered.java
+++ b/jdk/test/javax/net/ssl/DTLS/Reordered.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,16 +51,17 @@
     }
 
     @Override
-    List<DatagramPacket> produceHandshakePackets(
-            SSLEngine engine, SocketAddress socketAddr) throws Exception {
-        List<DatagramPacket> packets =
-                super.produceHandshakePackets(engine, socketAddr);
+    boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
+            String side, List<DatagramPacket> packets) throws Exception {
+
+        boolean finished = super.produceHandshakePackets(
+                engine, socketAddr, side, packets);
 
         if (needPacketReorder && (!engine.getUseClientMode())) {
             needPacketReorder = false;
             Collections.reverse(packets);
         }
 
-        return packets;
+        return finished;
     }
 }
diff --git a/jdk/test/javax/net/ssl/DTLS/Retransmission.java b/jdk/test/javax/net/ssl/DTLS/Retransmission.java
index 75aecab..840b08a 100644
--- a/jdk/test/javax/net/ssl/DTLS/Retransmission.java
+++ b/jdk/test/javax/net/ssl/DTLS/Retransmission.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,13 +52,14 @@
     }
 
     @Override
-    List<DatagramPacket> produceHandshakePackets(
-            SSLEngine engine, SocketAddress socketAddr) throws Exception {
-        List<DatagramPacket> packets =
-                super.produceHandshakePackets(engine, socketAddr);
+    boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
+            String side, List<DatagramPacket> packets) throws Exception {
+
+        boolean finished = super.produceHandshakePackets(
+                engine, socketAddr, side, packets);
 
         if (!needPacketLoss || (!engine.getUseClientMode())) {
-            return packets;
+            return finished;
         }
 
         List<DatagramPacket> parts = new ArrayList<>();
@@ -75,6 +76,9 @@
             parts.add(packet);
         }
 
-        return parts;
+        packets.clear();
+        packets.addAll(parts);
+
+        return finished;
     }
 }
diff --git a/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java b/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java
index 0a482f3..0e40e52 100644
--- a/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java
+++ b/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /lib/testlibrary
+ * @modules jdk.httpserver
  * @build jdk.testlibrary.SimpleSSLContext
  * @run main Equals
  * @bug 8055299
diff --git a/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java b/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
index ba3e5f1..bda0710 100644
--- a/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
+++ b/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
@@ -34,9 +34,6 @@
  */
 
 import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-import java.util.*;
 import java.net.*;
 import javax.net.ssl.*;
 
@@ -197,6 +194,7 @@
                 hostname);
         // Ignore the test if the hostname does not sound like a domain name.
         if ((hostname == null) || hostname.isEmpty() ||
+                !hostname.contains(".") || hostname.endsWith(".") ||
                 hostname.startsWith("localhost") ||
                 Character.isDigit(hostname.charAt(hostname.length() - 1))) {
 
diff --git a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java
index a86b10a..04020bc 100644
--- a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java
+++ b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it under
@@ -202,6 +202,8 @@
         @Override
         public abstract void run();
 
+        abstract int getPort();
+
         void handleRequest(InputStream in, OutputStream out)
                 throws IOException {
             boolean newline = false;
@@ -528,9 +530,9 @@
         return ks;
     }
 
-    public static void main(PeerFactory peerFactory, String mode,
-            String expectedException)
-            throws Exception {
+    public static int mainServer(PeerFactory peerFactory,
+            String expectedException) throws Exception {
+
         long time = System.currentTimeMillis();
         setTestedArguments(peerFactory.getTestedProtocol(),
                 peerFactory.getTestedCipher());
@@ -540,33 +542,49 @@
         secureRandom.nextInt();
 
         CipherTestUtils cipherTest = CipherTestUtils.getInstance();
-        if (mode.equalsIgnoreCase("Server")) {  // server mode
-            Thread serverThread = new Thread(peerFactory.newServer(cipherTest),
-                    "Server");
-            serverThread.start();
-        } else if (mode.equalsIgnoreCase("Client")) {
-            peerFactory.newClient(cipherTest).run();
-            cipherTest.checkResult(expectedException);
-            JSSEServer.closeServer = true;
-        } else {
-            throw new RuntimeException("unsupported mode");
-        }
+        Server server = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT);
+        Thread serverThread = new Thread(server, "Server");
+        serverThread.start();
+
         time = System.currentTimeMillis() - time;
         System.out.println("Elapsed time " + time);
 
+        return server.getPort();
+    }
+
+    public static void mainClient(PeerFactory peerFactory, int port,
+            String expectedException) throws Exception {
+
+        long time = System.currentTimeMillis();
+        setTestedArguments(peerFactory.getTestedProtocol(),
+                peerFactory.getTestedCipher());
+
+        System.out.print(
+                " Initializing test '" + peerFactory.getName() + "'...");
+        secureRandom.nextInt();
+
+        CipherTestUtils cipherTest = CipherTestUtils.getInstance();
+        peerFactory.newClient(cipherTest, port).run();
+        cipherTest.checkResult(expectedException);
+        JSSEServer.closeServer = true;
+
+        time = System.currentTimeMillis() - time;
+        System.out.println("Elapsed time " + time);
     }
 
     public static abstract class PeerFactory {
 
+        public static final int FREE_PORT = 0;
+
         abstract String getName();
 
         abstract String getTestedProtocol();
 
         abstract String getTestedCipher();
 
-        abstract Client newClient(CipherTestUtils cipherTest) throws Exception;
+        abstract Client newClient(CipherTestUtils cipherTest, int testPort) throws Exception;
 
-        abstract Server newServer(CipherTestUtils cipherTest) throws Exception;
+        abstract Server newServer(CipherTestUtils cipherTest, int testPort) throws Exception;
 
         boolean isSupported(String cipherSuite) {
             return true;
diff --git a/jdk/test/javax/net/ssl/TLS/JSSEServer.java b/jdk/test/javax/net/ssl/TLS/JSSEServer.java
index f6e55a3..1ece6f0 100644
--- a/jdk/test/javax/net/ssl/TLS/JSSEServer.java
+++ b/jdk/test/javax/net/ssl/TLS/JSSEServer.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it under
@@ -77,4 +77,8 @@
             }
         }
     }
+
+    int getPort() {
+        return serverSocket.getLocalPort();
+    }
 }
diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSE.java b/jdk/test/javax/net/ssl/TLS/TestJSSE.java
index d4c4148..d477e4f 100644
--- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java
@@ -27,10 +27,8 @@
 /**
  * @test
  * @bug 8049429
- * @library ../../../../lib/testlibrary/
  * @modules java.management
  *          jdk.crypto.ec/sun.security.ec
- * @build jdk.testlibrary.Utils
  * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
  * @summary Test that all cipher suites work in all versions and all client
  * authentication types. The way this is setup the server is stateless and
@@ -86,7 +84,6 @@
 
         String serverProtocol = System.getProperty("SERVER_PROTOCOL");
         String clientProtocol = System.getProperty("CLIENT_PROTOCOL");
-        int port = jdk.testlibrary.Utils.getFreePort();
         String cipher = System.getProperty("CIPHER");
         if (serverProtocol == null
                 || clientProtocol == null
@@ -97,7 +94,7 @@
         out.println("ServerProtocol =" + serverProtocol);
         out.println("ClientProtocol =" + clientProtocol);
         out.println("Cipher         =" + cipher);
-        server(serverProtocol, cipher, port, args);
+        int port = server(serverProtocol, cipher, args);
         client(port, clientProtocol, cipher, args);
 
     }
@@ -112,28 +109,30 @@
         out.println(" Testing - Protocol : " + testProtocols);
         out.println(" Testing - Cipher : " + testCipher);
         try {
-            CipherTestUtils.main(new JSSEFactory(LOCAL_IP,
-                    testPort, testProtocols,
-                    testCipher, "client JSSE"),
-                    "client", expectedException);
+            CipherTestUtils.mainClient(new JSSEFactory(LOCAL_IP, testProtocols,
+                        testCipher, "Client JSSE"),
+                    testPort, expectedException);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
 
-    public static void server(String testProtocol, String testCipher,
-            int testPort,
+    public static int server(String testProtocol, String testCipher,
             String... exception) throws Exception {
+
         String expectedException = exception.length >= 1
                 ? exception[0] : null;
         out.println(" This is Server");
         out.println(" Testing Protocol: " + testProtocol);
         out.println(" Testing Cipher: " + testCipher);
-        out.println(" Testing Port: " + testPort);
+
         try {
-            CipherTestUtils.main(new JSSEFactory(null, testPort,
-                    testProtocol, testCipher, "Server JSSE"),
-                    "Server", expectedException);
+            int port = CipherTestUtils.mainServer(new JSSEFactory(
+                        null, testProtocol, testCipher, "Server JSSE"),
+                    expectedException);
+
+            out.println(" Testing Port: " + port);
+            return port;
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -142,15 +141,13 @@
     private static class JSSEFactory extends CipherTestUtils.PeerFactory {
 
         final String testedCipherSuite, testedProtocol, testHost;
-        final int testPort;
         final String name;
 
-        JSSEFactory(String testHost, int testPort, String testedProtocol,
+        JSSEFactory(String testHost, String testedProtocol,
                 String testedCipherSuite, String name) {
             this.testedCipherSuite = testedCipherSuite;
             this.testedProtocol = testedProtocol;
             this.testHost = testHost;
-            this.testPort = testPort;
             this.name = name;
         }
 
@@ -170,14 +167,14 @@
         }
 
         @Override
-        CipherTestUtils.Client newClient(CipherTestUtils cipherTest)
+        CipherTestUtils.Client newClient(CipherTestUtils cipherTest, int testPort)
                 throws Exception {
             return new JSSEClient(cipherTest, testHost, testPort,
                     testedProtocol, testedCipherSuite);
         }
 
         @Override
-        CipherTestUtils.Server newServer(CipherTestUtils cipherTest)
+        CipherTestUtils.Server newServer(CipherTestUtils cipherTest, int testPort)
                 throws Exception {
             return new JSSEServer(cipherTest, testPort,
                     testedProtocol, testedCipherSuite);
diff --git a/jdk/test/javax/net/ssl/etc/README b/jdk/test/javax/net/ssl/etc/README
new file mode 100644
index 0000000..0ac6a84
--- /dev/null
+++ b/jdk/test/javax/net/ssl/etc/README
@@ -0,0 +1,94 @@
+Keystores used for the JSSE regression test suite.
+
+keystore
+truststore
+==========
+
+These are the primary two keystores and contain entries for testing most
+of the JSSE regression test files.  There are three entries, one RSA-based,
+one DSA-based and one EC-based.  If they expire, simply recreate them
+using keytool and most of the test cases should work.
+
+The password on both files is:
+
+    passphrase
+
+There are no individual key entry passwords at this time.
+
+
+keystore entries
+================
+
+Alias name: dummy
+-----------------
+Creation date: May 16, 2016
+Entry type: PrivateKeyEntry
+Certificate chain length: 1
+Certificate[1]:
+Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Serial number: 57399b87
+Valid from: Mon May 16 10:06:38 UTC 2016 until: Sat May 16 10:06:38 UTC 2026
+Signature algorithm name: SHA256withRSA
+Version: 1
+
+This can be generated using hacked (update the keytool source code so that
+it can be used for version 1 X.509 certificate) keytool command:
+% keytool -genkeypair -alias dummy -keyalg RSA -keysize 2048 \
+  -sigalg SHA256withRSA \
+  -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \
+  -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase
+
+
+Alias name: dummyecdsa
+----------------------
+Creation date: May 16, 2016
+Entry type: PrivateKeyEntry
+Certificate chain length: 1
+Certificate[1]:
+Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Serial number: 57399c1d
+Valid from: Mon May 16 10:09:01 UTC 2016 until: Sat May 16 10:09:01 UTC 2026
+Signature algorithm name: SHA256withECDSA
+Version: 1
+
+This can be generated using hacked (update the keytool source code so that
+it can be used for version 1 X.509 certificate) keytool command:
+% keytool -genkeypair -alias dummy -keyalg EC -keysize 256 \
+  -sigalg SHA256withECDSA \
+  -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \
+  -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase
+
+Alias name: dummydsa
+--------------------
+Creation date: Mar 11, 2007
+Entry type: PrivateKeyEntry
+Certificate chain length: 1
+Certificate[1]:
+Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Serial number: 45f3a314
+Valid from: Sun Mar 11 06:35:00 UTC 2007 until: Wed Mar 08 06:35:00 UTC 2017
+Certificate fingerprints:
+Signature algorithm name: SHA1withDSA
+Version: 1
+
+This can be generated using hacked (update the keytool source code so that
+it can be used for version 1 X.509 certificate) keytool command:
+% keytool -genkeypair -alias dummy -keyalg DSA -keysize 1024 \
+  -sigalg SHA1withDSA \
+  -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \
+  -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase
+
+
+truststore entries
+==================
+This key store contains only trusted certificate entries.  The same
+certificates are used in both keystore and truststore.
+
+
+unknown_keystore
+================
+A keystore you can use when you don't want things to be verified.
+Use this with keystore/truststore, and you'll never get a match.
diff --git a/jdk/test/javax/net/ssl/etc/keystore b/jdk/test/javax/net/ssl/etc/keystore
index 2eb1993..4062e17 100644
--- a/jdk/test/javax/net/ssl/etc/keystore
+++ b/jdk/test/javax/net/ssl/etc/keystore
Binary files differ
diff --git a/jdk/test/javax/net/ssl/etc/truststore b/jdk/test/javax/net/ssl/etc/truststore
index 65a140d..12da39e 100644
--- a/jdk/test/javax/net/ssl/etc/truststore
+++ b/jdk/test/javax/net/ssl/etc/truststore
Binary files differ
diff --git a/jdk/test/javax/rmi/TEST.properties b/jdk/test/javax/rmi/TEST.properties
new file mode 100644
index 0000000..d4bbfc9
--- /dev/null
+++ b/jdk/test/javax/rmi/TEST.properties
@@ -0,0 +1 @@
+modules = java.rmi
diff --git a/jdk/test/javax/script/ProviderTest.sh b/jdk/test/javax/script/ProviderTest.sh
index 1db161d..24b4120 100644
--- a/jdk/test/javax/script/ProviderTest.sh
+++ b/jdk/test/javax/script/ProviderTest.sh
@@ -43,8 +43,18 @@
     -C ${TESTCLASSES} DummyScriptEngineFactory.class \
     -C "${TESTSRC}" META-INF/services/javax.script.ScriptEngineFactory
 
-echo "Running test ..."
+echo "Running test with security manager ..."
+$JAVA ${TESTVMOPTS} -Djava.security.manager -classpath \
+  "${TESTCLASSES}${PS}${TESTCLASSES}/dummy.jar" \
+  ProviderTest
 
+ret=$?
+if [ $ret -ne 0 ]
+then
+  exit $ret
+fi
+
+echo "Running test without security manager ..."
 $JAVA ${TESTVMOPTS} -classpath \
   "${TESTCLASSES}${PS}${TESTCLASSES}/dummy.jar" \
   ProviderTest
diff --git a/jdk/test/javax/script/TEST.properties b/jdk/test/javax/script/TEST.properties
new file mode 100644
index 0000000..3bb100c
--- /dev/null
+++ b/jdk/test/javax/script/TEST.properties
@@ -0,0 +1 @@
+modules = java.scripting
diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java
new file mode 100644
index 0000000..c089948
--- /dev/null
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.ByteArrayInputStream;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+
+/**
+ * @test
+ * @bug 6729836
+ */
+public final class RecognizeHugeAiffFiles {
+
+    /**
+     * The maximum number of sample frames per AIFF specification.
+     */
+    private static final /* unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL;
+
+    /**
+     * The supported aiff sample size in bits.
+     */
+    private static final byte[] aiffBits = {
+            1, 2, 4, 8, 11, 16, 20, 24, 27, 32
+    };
+
+    /**
+     * The list of supported sample rates.
+     */
+    private static final int[] sampleRates = {
+            8000, 11025, 16000, 22050, 32000, 37800, 44056, 44100, 47250, 48000,
+            50000, 50400, 88200, 96000, 176400, 192000, 352800, 2822400,
+            5644800, Integer.MAX_VALUE
+    };
+
+    /**
+     * The list of supported channels.
+     */
+    private static final int[] channels = {
+            1, 2, 3, 4, 5, 6, 7, 8, 9, 10
+    };
+
+    /**
+     * The list of supported number of frames.
+     * <p>
+     * The {@code MAX_UNSIGNED_INT} is a maximum.
+     */
+    private static final long[] numberOfFrames = {
+            0, 1, 2, 3, Integer.MAX_VALUE - 1, Integer.MAX_VALUE,
+            (long) Integer.MAX_VALUE + 1, MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT
+    };
+
+    public static void main(final String[] args) throws Exception {
+        for (final byte bits : aiffBits) {
+            for (final int sampleRate : sampleRates) {
+                for (final int channel : channels) {
+                    for (final long dataSize : numberOfFrames) {
+                        testAFF(bits, sampleRate, channel, dataSize);
+                        testAIS(bits, sampleRate, channel, dataSize);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Tests the {@code AudioFileFormat} fetched from the fake header.
+     * <p>
+     * Note that the frameLength and byteLength are stored as int which means
+     * that {@code AudioFileFormat} will store the data above {@code MAX_INT} as
+     * NOT_SPECIFIED.
+     */
+    private static void testAFF(final byte bits, final int rate,
+                                final int channel, final long frameLength)
+            throws Exception {
+        final byte[] header = createHeader(bits, rate, channel, frameLength);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake);
+
+        if (aff.getType() != AudioFileFormat.Type.AIFF) {
+            throw new RuntimeException("Error");
+        }
+
+        if (frameLength <= Integer.MAX_VALUE) {
+            if (aff.getFrameLength() != frameLength) {
+                System.err.println("Expected: " + frameLength);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        }
+        validateFormat(bits, rate, channel, aff.getFormat());
+    }
+
+    /**
+     * Tests the {@code AudioInputStream} fetched from the fake header.
+     * <p>
+     * Note that the frameLength is stored as long which means that {@code
+     * AudioInputStream} must store all possible data from aiff file.
+     */
+    private static void testAIS(final byte bits, final int rate,
+                                final int channel, final long frameLength)
+            throws Exception {
+        final byte[] header = createHeader(bits, rate, channel, frameLength);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
+        final AudioFormat format = ais.getFormat();
+
+        if (frameLength != ais.getFrameLength()) {
+            System.err.println("Expected: " + frameLength);
+            System.err.println("Actual: " + ais.getFrameLength());
+            throw new RuntimeException();
+        }
+        if (ais.available() < 0) {
+            System.err.println("available should be >=0: " + ais.available());
+            throw new RuntimeException();
+        }
+
+        validateFormat(bits, rate, channel, format);
+    }
+
+    /**
+     * Tests that format contains the same data as were provided to the fake
+     * stream.
+     */
+    private static void validateFormat(final byte bits, final int rate,
+                                       final int channel,
+                                       final AudioFormat format) {
+
+        if (Float.compare(format.getSampleRate(), rate) != 0) {
+            System.err.println("Expected: " + rate);
+            System.err.println("Actual: " + format.getSampleRate());
+            throw new RuntimeException();
+        }
+        if (format.getChannels() != channel) {
+            System.err.println("Expected: " + channel);
+            System.err.println("Actual: " + format.getChannels());
+            throw new RuntimeException();
+        }
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.out.println("Expected: " + frameSize);
+            System.err.println("Actual: " + format.getFrameSize());
+            throw new RuntimeException();
+        }
+    }
+
+    private static final int DOUBLE_MANTISSA_LENGTH = 52;
+    private static final int DOUBLE_EXPONENT_LENGTH = 11;
+    private static final long DOUBLE_SIGN_MASK     = 0x8000000000000000L;
+    private static final long DOUBLE_EXPONENT_MASK = 0x7FF0000000000000L;
+    private static final long DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFL;
+    private static final int DOUBLE_EXPONENT_OFFSET = 1023;
+
+    private static final int EXTENDED_EXPONENT_OFFSET = 16383;
+    private static final int EXTENDED_MANTISSA_LENGTH = 63;
+    private static final int EXTENDED_EXPONENT_LENGTH = 15;
+    private static final long EXTENDED_INTEGER_MASK = 0x8000000000000000L;
+
+    /**
+     * Creates the custom header of the AIFF file. It is expected that all
+     * passed data are supported.
+     */
+    private static byte[] createHeader(final byte bits, final int rate,
+                                       final int channel, final long frameLength) {
+        long doubleBits = Double.doubleToLongBits(rate);
+
+        long sign = (doubleBits & DOUBLE_SIGN_MASK)
+                >> (DOUBLE_EXPONENT_LENGTH + DOUBLE_MANTISSA_LENGTH);
+        long doubleExponent = (doubleBits & DOUBLE_EXPONENT_MASK)
+                >> DOUBLE_MANTISSA_LENGTH;
+        long doubleMantissa = doubleBits & DOUBLE_MANTISSA_MASK;
+
+        long extendedExponent = doubleExponent - DOUBLE_EXPONENT_OFFSET
+                + EXTENDED_EXPONENT_OFFSET;
+        long extendedMantissa = doubleMantissa
+                << (EXTENDED_MANTISSA_LENGTH - DOUBLE_MANTISSA_LENGTH);
+        long extendedSign = sign << EXTENDED_EXPONENT_LENGTH;
+        short extendedBits79To64 = (short) (extendedSign | extendedExponent);
+        long extendedBits63To0 = EXTENDED_INTEGER_MASK | extendedMantissa;
+
+        return new byte[]{
+                // AIFF_MAGIC
+                0x46, 0x4f, 0x52, 0x4d,
+                // fileLength (will use the number of frames for testing)
+                (byte) (frameLength >> 24), (byte) (frameLength >> 16),
+                (byte) (frameLength >> 8), (byte) frameLength,
+                //  form aiff
+                0x41, 0x49, 0x46, 0x46,
+                // COMM_MAGIC
+                0x43, 0x4f, 0x4d, 0x4d,
+                // comm chunk size
+                0, 0, 0, 18,
+                // channels
+                (byte) (channel >> 8),(byte) channel,
+                // numSampleFrames
+                (byte) (frameLength >> 24), (byte) (frameLength >> 16),
+                (byte) (frameLength >> 8), (byte) (frameLength),
+                // samplesize
+                (byte) (bits >> 8),(byte) (bits),
+                // samplerate
+                (byte) (extendedBits79To64 >> 8),
+                (byte) extendedBits79To64,
+                (byte) (extendedBits63To0 >> 56),
+                (byte) (extendedBits63To0 >> 48),
+                (byte) (extendedBits63To0 >> 40),
+                (byte) (extendedBits63To0 >> 32), (byte) (extendedBits63To0 >> 24),
+                (byte) (extendedBits63To0 >> 16), (byte) (extendedBits63To0 >> 8),
+                (byte) extendedBits63To0,
+                // SND_MAGIC
+                0x53, 0x53, 0x4e, 0x44,
+                // data chunk size
+                0, 0, 0, 0,
+                // dataOffset
+                0, 0, 0, 0,
+                // blocksize
+                0, 0, 0, 0,
+        };
+    }
+}
diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java
similarity index 60%
copy from jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java
copy to jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java
index e36a7e2..ba90866 100644
--- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java
@@ -30,20 +30,25 @@
 
 /**
  * @test
- * @bug 8132782
+ * @bug 6729836
  */
-public final class RecognizeHugeWaveFloatFiles {
+public final class RecognizeHugeAuFiles {
 
     /**
-     * The maximum size in bytes per WAVE specification.
+     * The size of the header's data.
      */
-    private static final /*unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL;
+    private static final byte AU_HEADER = 44;
 
     /**
-     * The  supported wave pcm_float format and sample size in bits.
+     * This value should be used if the size in bytes is unknown.
      */
-    private static final byte[][] waveTypeBits = {
-            {0x0003/*WAVE_FORMAT_IEEE_FLOAT*/, 32}
+    private static final /* unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL;
+
+    /**
+     * The list of supported au formats and sample size in bits per format.
+     */
+    private static final byte[][] auTypeBits = {
+            {1, 8}, {2, 8}, {3, 16}, {4, 24}, {5, 32}, {6, 32}, {27, 8}
     };
 
     /**
@@ -65,15 +70,17 @@
     /**
      * The list of supported size of data (stored as unsigned int).
      * <p>
-     * The {@code MAX_UNSIGNED_INT} is a maximum size.
+     * The {@code MAX_UNSIGNED_INT} used if the size in bytes is unknown.
      */
     private static final long[] dataSizes = {
-            0, 1, 2, 3, Integer.MAX_VALUE - 1, Integer.MAX_VALUE,
-            (long) Integer.MAX_VALUE + 1, MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT
+            0, 1, 2, 3, Integer.MAX_VALUE - AU_HEADER, Integer.MAX_VALUE - 1,
+            Integer.MAX_VALUE, (long) Integer.MAX_VALUE + 1,
+            (long) Integer.MAX_VALUE + AU_HEADER, MAX_UNSIGNED_INT - AU_HEADER,
+            MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT
     };
 
     public static void main(final String[] args) throws Exception {
-        for (final byte[] type : waveTypeBits) {
+        for (final byte[] type : auTypeBits) {
             for (final int sampleRate : sampleRates) {
                 for (final int channel : channels) {
                     for (final long dataSize : dataSizes) {
@@ -89,8 +96,8 @@
      * Tests the {@code AudioFileFormat} fetched from the fake header.
      * <p>
      * Note that the frameLength and byteLength are stored as int which means
-     * that {@code AudioFileFormat} will store the data above {@code MAX_INT} as
-     * NOT_SPECIFIED.
+     * that {@code AudioFileFormat} will store the data above {@code  MAX_INT}
+     * as NOT_SPECIFIED.
      */
     private static void testAFF(final byte[] type, final int rate,
                                 final int channel, final long size)
@@ -100,12 +107,12 @@
         final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake);
         final AudioFormat format = aff.getFormat();
 
-        if (aff.getType() != AudioFileFormat.Type.WAVE) {
+        if (aff.getType() != AudioFileFormat.Type.AU) {
             throw new RuntimeException("Error");
         }
 
         final long frameLength = size / format.getFrameSize();
-        if (frameLength <= Integer.MAX_VALUE) {
+        if (size != MAX_UNSIGNED_INT && frameLength <= Integer.MAX_VALUE) {
             if (aff.getFrameLength() != frameLength) {
                 System.err.println("Expected: " + frameLength);
                 System.err.println("Actual: " + aff.getFrameLength());
@@ -118,14 +125,29 @@
                 throw new RuntimeException();
             }
         }
+
+        final long byteLength = size + AU_HEADER;
+        if (byteLength <= Integer.MAX_VALUE) {
+            if (aff.getByteLength() != byteLength) {
+                System.err.println("Expected: " + byteLength);
+                System.err.println("Actual: " + aff.getByteLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (aff.getByteLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + aff.getByteLength());
+                throw new RuntimeException();
+            }
+        }
         validateFormat(type[1], rate, channel, aff.getFormat());
     }
 
     /**
      * Tests the {@code AudioInputStream} fetched from the fake header.
      * <p>
-     * Note that the frameLength is stored as long which means that {@code
-     * AudioInputStream} must store all possible data from au file.
+     * Note that the frameLength is stored as long which means
+     * that {@code AudioInputStream} must store all possible data from au file.
      */
     private static void testAIS(final byte[] type, final int rate,
                                 final int channel, final long size)
@@ -135,16 +157,23 @@
         final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
         final AudioFormat format = ais.getFormat();
         final long frameLength = size / format.getFrameSize();
-        if (frameLength != ais.getFrameLength()) {
-            System.err.println("Expected: " + frameLength);
-            System.err.println("Actual: " + ais.getFrameLength());
-            throw new RuntimeException();
+        if (size != MAX_UNSIGNED_INT) {
+            if (frameLength != ais.getFrameLength()) {
+                System.err.println("Expected: " + frameLength);
+                System.err.println("Actual: " + ais.getFrameLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (ais.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + ais.getFrameLength());
+                throw new RuntimeException();
+            }
         }
         if (ais.available() < 0) {
             System.err.println("available should be >=0: " + ais.available());
             throw new RuntimeException();
         }
-
         validateFormat(type[1], rate, channel, format);
     }
 
@@ -157,60 +186,47 @@
                                        final AudioFormat format) {
 
         if (Float.compare(format.getSampleRate(), rate) != 0) {
-            System.err.println("Expected: " + rate);
-            System.err.println("Actual: " + format.getSampleRate());
+            System.out.println("Expected: " + rate);
+            System.out.println("Actual: " + format.getSampleRate());
             throw new RuntimeException();
         }
         if (format.getChannels() != channel) {
-            System.err.println("Expected: " + channel);
-            System.err.println("Actual: " + format.getChannels());
+            System.out.println("Expected: " + channel);
+            System.out.println("Actual: " + format.getChannels());
             throw new RuntimeException();
         }
-        if (format.getFrameSize() != ((bits + 7) / 8) * channel) {
-            System.err.println("Expected: " + (bits * channel + 1) / 8);
-            System.err.println("Actual: " + format.getFrameSize());
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.out.println("Expected: " + frameSize);
+            System.out.println("Actual: " + format.getFrameSize());
             throw new RuntimeException();
         }
     }
 
     /**
-     * Creates the custom header of the WAVE file. It is expected that all
-     * passed data are supported.
+     * Creates the custom header of the AU file. It is expected that all passed
+     * data are supported.
      */
     private static byte[] createHeader(final byte[] type, final int rate,
                                        final int channel, final long size) {
-        final int frameSize = ((type[1] + 7) / 8) * channel;
         return new byte[]{
-                // RIFF_MAGIC
-                0x52, 0x49, 0x46, 0x46,
-                // fileLength
-                -1, -1, -1, -1,
-                //  waveMagic
-                0x57, 0x41, 0x56, 0x45,
-                // FMT_MAGIC
-                0x66, 0x6d, 0x74, 0x20,
-                // size
-                16, 0, 0, 0,
-                // wav_type  WAVE_FORMAT_IEEE_FLOAT
-                type[0], 0,
+                // AU_SUN_MAGIC
+                0x2e, 0x73, 0x6e, 0x64,
+                // headerSize
+                0, 0, 0, AU_HEADER,
+                // dataSize
+                (byte) (size >> 24), (byte) (size >> 16), (byte) (size >> 8),
+                (byte) size,
+                // encoding
+                0, 0, 0, type[0],
+                // sampleRate
+                (byte) (rate >> 24), (byte) (rate >> 16), (byte) (rate >> 8),
+                (byte) (rate),
                 // channels
-                (byte) (channel), (byte) (channel >> 8),
-                // samplerate
-                (byte) (rate), (byte) (rate >> 8), (byte) (rate >> 16),
-                (byte) (rate >> 24),
-                // framerate
-                1, 0, 0, 0,
-                // framesize
-                (byte) (frameSize), (byte) (frameSize >> 8),
-                // bits
-                type[1], 0,
-                // DATA_MAGIC
-                0x64, 0x61, 0x74, 0x61,
-                // data size
-                (byte) (size), (byte) (size >> 8), (byte) (size >> 16),
-                (byte) (size >> 24)
+                (byte) (channel >> 24), (byte) (channel >> 16),
+                (byte) (channel >> 8), (byte) (channel),
                 // data
-                , 0, 0, 0, 0, 0
+                0, 0, 0, 0, 0, 0
         };
     }
 }
diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java
index 88b231d..ca8d17e 100644
--- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java
@@ -125,7 +125,7 @@
      * Tests the {@code AudioInputStream} fetched from the fake header.
      * <p>
      * Note that the frameLength is stored as long which means that {@code
-     * AudioInputStream} must store all possible data from au file.
+     * AudioInputStream} must store all possible data from wave file.
      */
     private static void testAIS(final int[] type, final int rate,
                                 final int channel, final long size)
@@ -166,8 +166,9 @@
             System.err.println("Actual: " + format.getChannels());
             throw new RuntimeException();
         }
-        if (format.getFrameSize() != ((bits + 7) / 8) * channel) {
-            System.err.println("Expected: " + (bits * channel + 1) / 8);
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.err.println("Expected: " + frameSize);
             System.err.println("Actual: " + format.getFrameSize());
             throw new RuntimeException();
         }
diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFiles.java
similarity index 90%
rename from jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java
rename to jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFiles.java
index e36a7e2..191290a 100644
--- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFiles.java
@@ -30,9 +30,9 @@
 
 /**
  * @test
- * @bug 8132782
+ * @bug 8132782 6729836
  */
-public final class RecognizeHugeWaveFloatFiles {
+public final class RecognizeHugeWaveFiles {
 
     /**
      * The maximum size in bytes per WAVE specification.
@@ -43,7 +43,17 @@
      * The  supported wave pcm_float format and sample size in bits.
      */
     private static final byte[][] waveTypeBits = {
-            {0x0003/*WAVE_FORMAT_IEEE_FLOAT*/, 32}
+            {0x0001/*WAVE_FORMAT_PCM*/,1},
+            {0x0001/*WAVE_FORMAT_PCM*/,2},
+            {0x0001/*WAVE_FORMAT_PCM*/,4},
+            {0x0001/*WAVE_FORMAT_PCM*/,8},
+            {0x0001/*WAVE_FORMAT_PCM*/,16},
+            {0x0001/*WAVE_FORMAT_PCM*/,20},
+            {0x0001/*WAVE_FORMAT_PCM*/,24},
+            {0x0001/*WAVE_FORMAT_PCM*/,32},
+            {0x0003/*WAVE_FORMAT_IEEE_FLOAT*/, 32},
+            {0x0006/*WAVE_FORMAT_ALAW*/, 8},
+            {0x0007/*WAVE_FORMAT_MULAW*/, 8}
     };
 
     /**
@@ -125,7 +135,7 @@
      * Tests the {@code AudioInputStream} fetched from the fake header.
      * <p>
      * Note that the frameLength is stored as long which means that {@code
-     * AudioInputStream} must store all possible data from au file.
+     * AudioInputStream} must store all possible data from wave file.
      */
     private static void testAIS(final byte[] type, final int rate,
                                 final int channel, final long size)
@@ -166,8 +176,9 @@
             System.err.println("Actual: " + format.getChannels());
             throw new RuntimeException();
         }
-        if (format.getFrameSize() != ((bits + 7) / 8) * channel) {
-            System.err.println("Expected: " + (bits * channel + 1) / 8);
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.err.println("Expected: " + frameSize);
             System.err.println("Actual: " + format.getFrameSize());
             throw new RuntimeException();
         }
diff --git a/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java b/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java
new file mode 100644
index 0000000..bc17b04
--- /dev/null
+++ b/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Robot;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+/*
+ * @test
+ * @bug 8152677
+ * @requires (os.family == "mac")
+ * @summary [macosx] All files filter can't be selected in JFileChooser
+ * @run main SelectAllFilesFilterTest
+ */
+
+public class SelectAllFilesFilterTest {
+
+    private static final String LABEL_TEXT = "File Format:";
+    private static volatile JFileChooser fileChooser;
+    private static JComboBox comboBox;
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeLater(SelectAllFilesFilterTest::createAndShowGUI);
+
+        while (fileChooser == null) {
+            Thread.sleep(100);
+        }
+
+        Robot robot = new Robot();
+        robot.waitForIdle();
+
+        SwingUtilities.invokeAndWait(() -> {
+            comboBox = findComboBox(fileChooser);
+            comboBox.setSelectedIndex(0);
+        });
+        robot.waitForIdle();
+
+        SwingUtilities.invokeAndWait(() -> {
+            int selectedIndex = comboBox.getSelectedIndex();
+            fileChooser.setVisible(false);
+
+            if (selectedIndex != 0) {
+                throw new RuntimeException("Select All file filter is not selected!");
+            }
+        });
+    }
+
+    private static void createAndShowGUI() {
+        fileChooser = new JFileChooser();
+        fileChooser.setAcceptAllFileFilterUsed(true);
+        fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
+
+        FileFilter txtFilter = new FileNameExtensionFilter("Text files", "txt");
+        fileChooser.addChoosableFileFilter(txtFilter);
+        fileChooser.setFileFilter(txtFilter);
+        fileChooser.showOpenDialog(null);
+    }
+
+    private static JComboBox findComboBox(Component comp) {
+
+        if (comp instanceof JLabel) {
+            JLabel label = (JLabel) comp;
+            if (LABEL_TEXT.equals(label.getText())) {
+                return (JComboBox) label.getLabelFor();
+            }
+        }
+
+        if (comp instanceof Container) {
+            Container cont = (Container) comp;
+            for (int i = 0; i < cont.getComponentCount(); i++) {
+
+                JComboBox result = findComboBox(cont.getComponent(i));
+                if (result != null) {
+                    return result;
+                }
+            }
+        }
+
+        return null;
+    }
+}
diff --git a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
index 1a9f421..589bb9b 100644
--- a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
+++ b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
@@ -21,23 +21,23 @@
  * questions.
  */
 
-/*
+ /*
  * @test
- * @bug 7160951
+ * @bug 7160951 8152492
  * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
  * @author vera.akulova@oracle.com
  * @library ../../../../lib/testlibrary
  * @build jdk.testlibrary.OSInfo
  * @run main ActionListenerCalledTwiceTest
  */
-
 import jdk.testlibrary.OSInfo;
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
 
 public class ActionListenerCalledTwiceTest {
-    static String menuItems[] = { "Item1", "Item2", "Item3", "Item4", "Item5", "Item6" };
+
+    static String menuItems[] = {"Item1", "Item2", "Item3", "Item4", "Item5", "Item6"};
     static KeyStroke keyStrokes[] = {
         KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
         KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
@@ -46,8 +46,10 @@
         KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK),
         KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK)
     };
-
+    static JMenu menu;
+    static JFrame frame;
     static volatile int listenerCallCounter = 0;
+
     public static void main(String[] args) throws Exception {
         if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
@@ -82,33 +84,38 @@
             robot.waitForIdle();
 
             if (listenerCallCounter != 1) {
-                throw new Exception("Test failed: ActionListener for " + menuItems[i] +
-                    " called " + listenerCallCounter + " times instead of 1!");
+                throw new Exception("Test failed: ActionListener for " + menuItems[i]
+                        + " called " + listenerCallCounter + " times instead of 1!");
             }
 
             listenerCallCounter = 0;
         }
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.dispose();
+            }
+        });
     }
 
     private static void createAndShowGUI() {
-        JMenu menu = new JMenu("Menu");
+        menu = new JMenu("Menu");
 
         for (int i = 0; i < menuItems.length; ++i) {
             JMenuItem newItem = new JMenuItem(menuItems[i]);
             newItem.setAccelerator(keyStrokes[i]);
             newItem.addActionListener(
-                new ActionListener(){
-                    public void actionPerformed(ActionEvent e) {
-                        listenerCallCounter++;
-                    }
+                    new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    listenerCallCounter++;
                 }
+            }
             );
             menu.add(newItem);
         }
 
         JMenuBar bar = new JMenuBar();
         bar.add(menu);
-        JFrame frame = new JFrame("Test");
+        frame = new JFrame("Test");
         frame.setJMenuBar(bar);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.pack();
diff --git a/jdk/test/javax/swing/JSpinner/6421058/bug6421058.java b/jdk/test/javax/swing/JSpinner/6421058/bug6421058.java
new file mode 100644
index 0000000..d67762b
--- /dev/null
+++ b/jdk/test/javax/swing/JSpinner/6421058/bug6421058.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+  * @test
+  * @bug 6421058
+  * @summary Verify font of the text field is changed to the font of
+  *        JSpinner if the font of text field was NOT set by the user
+  * @run main bug6421058
+  */
+
+import java.awt.Font;
+import javax.swing.JFrame;
+import javax.swing.JSpinner;
+import javax.swing.JSpinner.DefaultEditor;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.UIResource;
+import static javax.swing.UIManager.getInstalledLookAndFeels;
+
+public class bug6421058 implements Runnable {
+
+    public static void main(final String[] args) throws Exception {
+        for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
+            SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
+            SwingUtilities.invokeAndWait(new bug6421058());
+        }
+    }
+
+    @Override
+    public void run() {
+        final JFrame mainFrame = new JFrame();
+        try {
+            testDefaultFont(mainFrame);
+        } finally {
+            mainFrame.dispose();
+        }
+    }
+
+    private static void testDefaultFont(final JFrame frame) {
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JSpinner spinner = new JSpinner();
+        frame.add(spinner);
+        frame.setSize(300, 100);
+        frame.setVisible(true);
+
+        final DefaultEditor editor = (DefaultEditor) spinner.getEditor();
+        final Font editorFont = editor.getTextField().getFont();
+
+        /*
+         * Validate that the font of the text field is changed to the
+         * font of JSpinner if the font of text field was not set by the
+         * user.
+         */
+
+        if (!(editorFont instanceof UIResource)) {
+            throw new RuntimeException("Font must be UIResource");
+        }
+        if (!editorFont.equals(spinner.getFont())) {
+            throw new RuntimeException("Wrong FONT");
+        }
+    }
+
+    private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) {
+        try {
+            UIManager.setLookAndFeel(laf.getClassName());
+        } catch (ClassNotFoundException | InstantiationException |
+                UnsupportedLookAndFeelException | IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java
new file mode 100644
index 0000000..c1b7214
--- /dev/null
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @summary  Tests that GTK LaF is supported on solaris
+            regardless of jdk.gtk.version flag values.
+  @bug 8156121
+  @requires (os.name == "linux" | os.name == "solaris")
+  @run main/othervm -Djdk.gtk.version=2 DemandGTK
+  @run main/othervm -Djdk.gtk.version=3 DemandGTK
+*/
+
+import javax.swing.JFrame;
+import javax.swing.UIManager;
+import javax.swing.SwingUtilities;
+import java.awt.Robot;
+
+public class DemandGTK {
+
+    static JFrame frame;
+    public static void createAndShow() {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
+        } catch(Exception cnf) {
+            cnf.printStackTrace();
+            throw new RuntimeException("GTK LaF must be supported");
+        }
+        frame = new JFrame("JFrame");
+        frame.setSize(200, 200);
+
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setVisible(true);
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(DemandGTK::createAndShow);
+        Robot robot = new Robot();
+        robot.waitForIdle();
+        robot.delay(1000);
+        SwingUtilities.invokeAndWait( () -> {
+            frame.setVisible(false);
+            frame.dispose();
+        });
+
+    }
+}
+
diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh
new file mode 100644
index 0000000..93de979
--- /dev/null
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh
@@ -0,0 +1,89 @@
+#!/bin/ksh -p
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#   @test
+#   @summary  Try to force GTK2. We must bail out to GTK3 (if any) if no 2 available.
+#
+#   @compile ProvokeGTK.java
+#   @requires os.family == "linux"
+#   @run shell/timeout=400 DemandGTK2.sh
+
+#
+# Note that we depend on
+# strace in the PATH
+# /sbin/ldconfig (which may be not in PATH)
+# It is true for OEL 7 and Ubuntu 14, 16
+# but may fail in future. Save tomorrow for tomorrow.
+#
+# Read DemandGTK2.txt how to prepare GTK2-less machine.
+#
+
+which strace
+if [ $?  -ne 0 ]
+then
+    echo "Please provide strace: \"which strace\" failed."
+    exit 1
+fi
+
+HAVE_2=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-x11-2 | wc -l`
+HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l`
+
+
+if [ "${HAVE_2}" = "0" ]
+then
+    
+    if [ "${HAVE_3}" = "0" ]
+    then
+        echo "Neither GTK2 nor GTK3 found: system misconfiguration. Exit."
+        exit 1
+    fi
+    echo "No GTK 2 library found: we should bail out to 3"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=2 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-3.*=\ *[0-9]*$' strace.log > logg
+else
+    echo "There is GTK 2 library: we should use it"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=2 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-x11.*=\ *[0-9]*$' strace.log > logg
+fi
+
+if [ ${EXECRES}  -ne 0 ]
+then
+    echo "java execution failed for unknown reason, see logs"
+    exit 2
+fi
+
+cat logg
+if [ -s logg ]
+then
+    echo "Success."
+    exit 0
+else
+    echo "Failed. Examine logs."
+    exit 3
+fi
+
+
diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt
new file mode 100644
index 0000000..7313e3e
--- /dev/null
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt
@@ -0,0 +1,36 @@
+How to prepare an Ubuntu machine for GTK-2-less test run.
+
+The test DemandGTK2.sh should work well without GTK-2 switching to version 3
+if there's no GTK-2 library available. 
+At the moment, it's not easy to find a system with GTK-3 and without GTK-2:
+many programs still depend on version 2.
+We can, however, rename GTK-2 library for a single test run and then restore
+it back.
+
+(1) Find GTK2 library: run
+  /sbin/ldconfig -v 2>/dev/null |  grep libgtk-x11-2
+
+It will output one or two lines like 
+libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.23
+Search for the target of that symlink for instance with locate:
+locate libgtk-x11-2.0.so.0.2400.23
+Finally, you'll find the libraries. On my current machine they are
+/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+
+I'm running 64-bit JDK and need to tamper with x86_64 copy only.
+
+(2) Find running programs depending on this library. They probably would crash
+if you rename it. Stop them for this test run.
+That said, I'm afraid it would be impossible to do on a system older than Ubuntu 16.04.
+On my Ubuntu 16.04 I have only hud-service using this library, and that's OK, it will restart
+after a crash, if any.
+To find these programs, run
+lsof /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+
+(3) Now,
+sudo mv  /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23  /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23
+jtreg DemandGTK2.sh 
+sudo mv  /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23  /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+
+Needless to say, you should substitute your own library path and however you run jtreg.
diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh
new file mode 100644
index 0000000..1a9038a
--- /dev/null
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh
@@ -0,0 +1,81 @@
+#!/bin/ksh -p
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+
+#   @test
+#   @summary  Try to force GTK3. We must bail out to GTK2 if no 3 available.
+#
+#   @compile ProvokeGTK.java
+#   @requires os.family == "linux"
+#   @run shell/timeout=400 DemandGTK3.sh
+
+#
+# Note that we depend on
+# strace in the PATH
+# /sbin/ldconfig (which may be is not in PATH)
+# It is true for OEL 7 and Ubuntu 14, 16
+# but may fail in future. Save tomorrow for tomorrow.
+#
+
+which strace
+if [ $?  -ne 0 ]
+then
+    echo "Please provide strace: \"which strace\" failed."
+    exit 1
+fi
+
+HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l`
+
+
+if [ "${HAVE_3}" = "0" ]
+then
+    
+    echo "No GTK 3 library found: we should bail out to 2"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=3 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-x11.*=\ *[0-9]*$' strace.log > logg
+else
+    echo "There is GTK 3 library: we should use it"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=3 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-3.*=\ *[0-9]*$' strace.log > logg
+fi
+
+if [ ${EXECRES}  -ne 0 ]
+then
+    echo "java execution failed for unknown reason, see logs"
+    exit 2
+fi
+
+cat logg
+if [  -s logg ]
+then
+    echo "Success."
+    exit 0
+else
+    echo "Failed. Examine logs."
+    exit 3
+fi
+
diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java b/jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java
new file mode 100644
index 0000000..485ea05
--- /dev/null
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.JFrame;
+import javax.swing.UIManager;
+import javax.swing.SwingUtilities;
+
+public class ProvokeGTK {
+
+    static JFrame frame;
+    public static void createAndShow() {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
+        } catch(Exception cnf) {
+            cnf.printStackTrace();
+        }
+        frame = new JFrame("JFrame");
+        frame.setSize(200, 200);
+
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setVisible(true);
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(ProvokeGTK::createAndShow);
+        Thread.sleep(1000);
+        SwingUtilities.invokeAndWait( () -> {
+            frame.setVisible(false);
+            frame.dispose();
+        });
+
+    }
+}
+
diff --git a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java
index 4a556ef..9cc57cf 100644
--- a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java
+++ b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,47 +23,107 @@
 
 /*
  * @test
- * @bug 8032884
+ * @bug 8032884 8072579
  * @summary Globalbindings optionalProperty="primitive" does not work when minOccurs=0
- * @run shell compile-schema.sh
- * @compile -addmods java.xml.bind XjcOptionalPropertyTest.java
- * @run main/othervm XjcOptionalPropertyTest
+ * @library /lib/testlibrary
+ * @modules java.xml.bind
+ * @run testng/othervm XjcOptionalPropertyTest
  */
 
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import java.util.Arrays;
+import jdk.testlibrary.JDKToolLauncher;
+import org.testng.Assert;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
 
 public class XjcOptionalPropertyTest {
 
-    public static void main(String[] args) throws IOException {
-
-        generated.Foo foo = new generated.Foo();
-        log("foo = " + foo);
+    @Test
+    public void optionalPropertyTest() throws Exception {
+        runXjc();
+        compileXjcGeneratedClasses();
+        URLClassLoader testClassLoader;
+        testClassLoader = URLClassLoader.newInstance(new URL[]{testWorkDirUrl});
+        Class fooClass = testClassLoader.loadClass(CLASS_TO_TEST);
+        Object foo = fooClass.newInstance();
         Method[] methods = foo.getClass().getMethods();
-        log("Found [" + methods.length + "] methods");
+        System.out.println("Found [" + methods.length + "] methods");
         for (int i = 0; i < methods.length; i++) {
             Method method = methods[i];
             if (method.getName().equals("setFoo")) {
-                log("Checking method [" + method.getName() + "]");
+                System.out.println("Checking method [" + method.getName() + "]");
                 Class[] parameterTypes = method.getParameterTypes();
-                if (parameterTypes.length != 1)
-                    fail("more than 1 parameter");
-                if (!parameterTypes[0].isPrimitive()) {
-                    fail("Found [" + parameterTypes[0].getName() + "], but expected primitive!");
-                }
+                Assert.assertEquals(parameterTypes.length, 1);
+                Assert.assertTrue(parameterTypes[0].isPrimitive());
                 break;
             }
         }
-        log("TEST PASSED.");
-
     }
 
-    private static void fail(String message) {
-        throw new RuntimeException(message);
+    @BeforeTest
+    public void setUp() throws IOException {
+        // Create test directory inside scratch
+        testWorkDir = Paths.get(System.getProperty("user.dir", "."));
+        // Save its URL
+        testWorkDirUrl = testWorkDir.toUri().toURL();
+        // Get test source directory path
+        testSrcDir = Paths.get(System.getProperty("test.src", "."));
+        // Get path of xjc result folder
+        xjcResultDir = testWorkDir.resolve(TEST_PACKAGE);
+        // Copy schema document file to scratch directory
+        Files.copy(testSrcDir.resolve(XSD_FILENAME), testWorkDir.resolve(XSD_FILENAME), REPLACE_EXISTING);
     }
 
-    private static void log(String msg) {
-        System.out.println(msg);
+    // Compile schema file into java classes definitions
+    void runXjc() throws Exception {
+        // Prepare process builder to run schemagen tool and save its output
+        JDKToolLauncher xjcLauncher = JDKToolLauncher.createUsingTestJDK("xjc");
+        xjcLauncher.addToolArg(XSD_FILENAME);
+        System.out.println("Executing xjc command: " + Arrays.asList(xjcLauncher.getCommand()));
+        ProcessBuilder pb = new ProcessBuilder(xjcLauncher.getCommand());
+        // Set xjc work directory with the input java file
+        pb.directory(testWorkDir.toFile());
+        pb.inheritIO();
+        Process p = pb.start();
+        p.waitFor();
+        p.destroy();
     }
 
+    // Compile java classes with javac tool
+    void compileXjcGeneratedClasses() throws Exception {
+        JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
+        javacLauncher.addToolArg("-addmods");
+        javacLauncher.addToolArg("java.xml.bind");
+        javacLauncher.addToolArg(xjcResultDir.resolve("Foo.java").toString());
+        System.out.println("Compiling xjc generated class: " + Arrays.asList(javacLauncher.getCommand()));
+        ProcessBuilder pb = new ProcessBuilder(javacLauncher.getCommand());
+        pb.inheritIO();
+        pb.directory(testWorkDir.toFile());
+        Process p = pb.start();
+        p.waitFor();
+        p.destroy();
+    }
+
+    // Test schema filename
+    static final String XSD_FILENAME = "optional-property-schema.xsd";
+    // Test package with generated class
+    static final String TEST_PACKAGE = "anamespace";
+    // Name of generated java class
+    static final String CLASS_TO_TEST = TEST_PACKAGE+".Foo";
+    // Test working directory
+    Path testWorkDir;
+    // Test working directory URL
+    URL testWorkDirUrl;
+    // Directory with test src
+    Path testSrcDir;
+    // Directory with java files generated by xjc
+    Path xjcResultDir;
 }
diff --git a/jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh b/jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh
deleted file mode 100644
index 8051abf..0000000
--- a/jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-
-#
-
-if [ "x$TESTJAVA" = x ]; then
-  TESTJAVA=$1; shift
-  TESTCLASSES=.
-fi
-
-echo "cleaning generated files ..."
-rm -rfv ${TESTSRC}/generated
-
-echo "compiling [optional-property-schema.xsd] schema ..."
-$TESTJAVA/bin/xjc -p generated -d ${TESTSRC} ${TESTSRC}/optional-property-schema.xsd
-
-echo "Schema compiled. Verification of generated files can be done now."
diff --git a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java
index 37b817d..cc1be25 100644
--- a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java
+++ b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java
@@ -23,10 +23,10 @@
 
 /*
  * @test
- * @bug 8145039
+ * @bug 8145039 8157096
  * @summary Check that marshalling of xjc generated class doesn't throw
  *          ClassCast exception.
- * @modules javax.xml.bind
+ * @modules java.xml.bind
  * @library /lib/testlibrary
  * @run testng/othervm JaxbMarshallTest
  */
@@ -127,6 +127,8 @@
     // Compile java classes with javac tool
     void compileXjcGeneratedClasses() throws Exception {
         JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
+        javacLauncher.addToolArg("-addmods");
+        javacLauncher.addToolArg("java.xml.bind");
         javacLauncher.addToolArg(xjcResultDir.resolve("ObjectFactory.java").toString());
         javacLauncher.addToolArg(xjcResultDir.resolve("TypesLongList.java").toString());
         javacLauncher.addToolArg(xjcResultDir.resolve("package-info.java").toString());
diff --git a/jdk/test/javax/xml/jaxp/TEST.properties b/jdk/test/javax/xml/jaxp/TEST.properties
new file mode 100644
index 0000000..fbf9f77
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/TEST.properties
@@ -0,0 +1 @@
+modules = java.xml
diff --git a/jdk/test/jdk/internal/jimage/JImageOpenTest.java b/jdk/test/jdk/internal/jimage/JImageOpenTest.java
new file mode 100644
index 0000000..06c1993
--- /dev/null
+++ b/jdk/test/jdk/internal/jimage/JImageOpenTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.reflect.Layer;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/*
+ * jimage shared open testing.
+ * @test
+ * @summary Test to see if thread interrupt handling interferes with other threads.
+ * @build JImageOpenTest.java
+ * @run main/othervm -Djdk.image.map.all=false JImageOpenTest
+ */
+public class JImageOpenTest {
+    private static final int NTHREADS = 10;
+
+    public static void main(String[] args) throws Exception {
+
+        final FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
+        final Path root = fs.getPath("/modules");
+
+        final List<String> names = Files.walk(root)
+                .filter(p -> p.getNameCount() > 2)
+                .filter(p -> Layer.boot().findModule(p.getName(1).toString()).isPresent())
+                .map(p -> p.subpath(2, p.getNameCount()))
+                .map(p -> p.toString())
+                .filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class"))
+                .collect(Collectors.toList());
+
+        Runnable r = new Runnable() {
+            @Override
+            public void run() {
+                names.forEach(name -> {
+                    String cn = name.substring(0, name.length() - 6).replace('/', '.');
+                    try {
+                        Class.forName(cn, false, ClassLoader.getSystemClassLoader());
+                    } catch (Exception ex) {
+                        System.err.println(Thread.currentThread() + " " + ex.getClass());
+                    }
+                });
+            }
+        };
+
+        Thread[] threads = new Thread[NTHREADS];
+
+        for (int i = 0; i < NTHREADS; i++) {
+            Thread thread =  new Thread(r);
+            threads[i] = thread;
+            thread.start();
+        }
+
+        Thread.sleep(1);
+
+        for (int i = 0; i < NTHREADS; i++) {
+            Thread thread = threads[i];
+
+            if (thread.isAlive()) {
+                thread.interrupt();
+                break;
+            }
+        }
+
+        for (int i = 0; i < NTHREADS; i++) {
+            Thread thread = threads[i];
+            thread.join();
+        }
+    }
+}
diff --git a/jdk/test/jdk/internal/jline/extra/HistoryTest.java b/jdk/test/jdk/internal/jline/extra/HistoryTest.java
new file mode 100644
index 0000000..f8d3084
--- /dev/null
+++ b/jdk/test/jdk/internal/jline/extra/HistoryTest.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test Completion
+ * @modules jdk.internal.le/jdk.internal.jline
+ *          jdk.internal.le/jdk.internal.jline.console
+ *          jdk.internal.le/jdk.internal.jline.console.history
+ *          jdk.internal.le/jdk.internal.jline.extra
+ * @build HistoryTest
+ * @run testng HistoryTest
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import jdk.internal.jline.UnsupportedTerminal;
+import jdk.internal.jline.console.ConsoleReader;
+import jdk.internal.jline.console.history.MemoryHistory;
+import jdk.internal.jline.extra.EditingHistory;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+@Test
+public class HistoryTest {
+
+    public void testHistory() throws IOException {
+        ConsoleReader in = new ConsoleReader(new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream(), new UnsupportedTerminal());
+        AtomicBoolean complete = new AtomicBoolean();
+        EditingHistory history = new EditingHistory(in, Collections.emptyList()) {
+            @Override
+            protected boolean isComplete(CharSequence input) {
+                return complete.get();
+            }
+        };
+        complete.set(false); history.add("void test() {");
+        complete.set(false); history.add("    System.err.println(1);");
+        complete.set(true);  history.add("}");
+        complete.set(true);  history.add("/exit");
+
+        previousAndAssert(history, "/exit");
+
+        history.previous(); history.previous(); history.previous();
+
+        complete.set(false); history.add("void test() { /*changed*/");
+
+        complete.set(true);
+        previousAndAssert(history, "}");
+        previousAndAssert(history, "    System.err.println(1);");
+        previousAndAssert(history, "void test() {");
+
+        assertFalse(history.previous());
+
+        nextAndAssert(history, "    System.err.println(1);");
+        nextAndAssert(history, "}");
+        nextAndAssert(history, "");
+
+        complete.set(false); history.add("    System.err.println(2);");
+        complete.set(true);  history.add("} /*changed*/");
+
+        assertEquals(history.size(), 7);
+
+        Collection<? extends String> persistentHistory = history.save();
+
+        history = new EditingHistory(in, persistentHistory) {
+            @Override
+            protected boolean isComplete(CharSequence input) {
+                return complete.get();
+            }
+        };
+
+        previousSnippetAndAssert(history, "void test() { /*changed*/");
+        previousSnippetAndAssert(history, "/exit");
+        previousSnippetAndAssert(history, "void test() {");
+
+        assertFalse(history.previousSnippet());
+
+        nextSnippetAndAssert(history, "/exit");
+        nextSnippetAndAssert(history, "void test() { /*changed*/");
+        nextSnippetAndAssert(history, "");
+
+        assertFalse(history.nextSnippet());
+
+        complete.set(false); history.add("{");
+        complete.set(true);  history.add("}");
+
+        persistentHistory = history.save();
+
+        history = new EditingHistory(in, persistentHistory) {
+            @Override
+            protected boolean isComplete(CharSequence input) {
+                return complete.get();
+            }
+        };
+
+        previousSnippetAndAssert(history, "{");
+        previousSnippetAndAssert(history, "void test() { /*changed*/");
+        previousSnippetAndAssert(history, "/exit");
+        previousSnippetAndAssert(history, "void test() {");
+
+        while (history.next());
+
+        complete.set(true);  history.add("/*current1*/");
+        complete.set(true);  history.add("/*current2*/");
+        complete.set(true);  history.add("/*current3*/");
+
+        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
+
+        history.remove(0);
+
+        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
+
+        while (history.size() > 2)
+            history.remove(0);
+
+        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current2*/", "/*current3*/"));
+
+        for (int i = 0; i < MemoryHistory.DEFAULT_MAX_SIZE * 2; i++) {
+            complete.set(true);  history.add("/exit");
+        }
+
+        complete.set(false); history.add("void test() { /*after full*/");
+        complete.set(false); history.add("    System.err.println(1);");
+        complete.set(true);  history.add("}");
+
+        previousSnippetAndAssert(history, "void test() { /*after full*/");
+    }
+
+    private void previousAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.previous());
+        assertEquals(history.current().toString(), expected);
+    }
+
+    private void nextAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.next());
+        assertEquals(history.current().toString(), expected);
+    }
+
+    private void previousSnippetAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.previousSnippet());
+        assertEquals(history.current().toString(), expected);
+    }
+
+    private void nextSnippetAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.nextSnippet());
+        assertEquals(history.current().toString(), expected);
+    }
+
+}
diff --git a/jdk/test/jdk/modules/scenarios/container/src/container/container/Main.java b/jdk/test/jdk/modules/scenarios/container/src/container/container/Main.java
index 4c86c6e..67f2416 100644
--- a/jdk/test/jdk/modules/scenarios/container/src/container/container/Main.java
+++ b/jdk/test/jdk/modules/scenarios/container/src/container/container/Main.java
@@ -72,7 +72,7 @@
 
         Configuration cf = Layer.boot().configuration()
             .resolveRequiresAndUses(finder,
-                                    ModuleFinder.empty(),
+                                    ModuleFinder.of(),
                                     Set.of(appModuleName));
 
         System.out.println("Resolved");
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java
index 826e282..529996e 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java
@@ -66,13 +66,7 @@
         }
         Path srcMisc = SRC_DIR.resolve("misc");
         Path modsMisc = MODS_DIR.resolve("misc");
-        assertTrue(CompilerUtils.compile(srcMisc.resolve("sun")
-                                                .resolve("misc")
-                                                .resolve("Unsafe.java"),
-                                         modsMisc,
-                                         "-Xmodule:java.base"));
-        assertTrue(CompilerUtils.compile(srcMisc.resolve("module-info.java"),
-                                         modsMisc));
+        assertTrue(CompilerUtils.compile(srcMisc, modsMisc));
     }
 
     /**
@@ -92,7 +86,7 @@
 
     /**
      * Run the test with "-addmods misc", the misc module has package
-     * sun.misc and so should overlap with the base module.
+     * jdk.internal.misc and so should overlap with the base module.
      */
     public void testOverlapWithBaseModule() throws Exception {
         int exitValue
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/jdk/internal/misc/Unsafe.java
similarity index 97%
rename from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
rename to jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/jdk/internal/misc/Unsafe.java
index 135652e..0b4aa91 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/jdk/internal/misc/Unsafe.java
@@ -21,7 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package jdk.internal.misc;
 
 public class Unsafe {
     private Unsafe() { }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java
index 65cc15d..d4f3bd9 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java
@@ -22,6 +22,6 @@
  */
 
 module misc {
-    exports sun.misc;
+    exports jdk.internal.misc;
 }
 
diff --git a/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java b/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java
index 6f87dc688..7f5f37b 100644
--- a/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java
+++ b/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8144355
+ * @bug 8144355 8144062
  * @summary Test aliasing additions to ZipFileSystem for multi-release jar files
  * @library /lib/testlibrary/java/util/jar
  * @build Compiler JarBuilder CreateMultiReleaseTestJars
@@ -34,17 +34,17 @@
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
+import java.lang.Runtime.Version;
 import java.net.URI;
 import java.nio.file.*;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.Version;
 
 import org.testng.Assert;
 import org.testng.annotations.*;
 
 public class MultiReleaseJarTest {
-    final private int MAJOR_VERSION = Version.current().major();
+    final private int MAJOR_VERSION = Runtime.version().major();
 
     final private String userdir = System.getProperty("user.dir",".");
     final private Map<String,String> stringEnv = new HashMap<>();
diff --git a/jdk/test/lib/testlibrary/CompilerUtils.java b/jdk/test/lib/testlibrary/CompilerUtils.java
index 91ca918..261c2c8 100644
--- a/jdk/test/lib/testlibrary/CompilerUtils.java
+++ b/jdk/test/lib/testlibrary/CompilerUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,13 +50,21 @@
      *
      * @return true if the compilation is successful
      *
-     * @throws IOException if there is an I/O error scanning the source tree or
-     *                     creating the destination directory
+     * @throws IOException
+     *         if there is an I/O error scanning the source tree or
+     *         creating the destination directory
+     * @throws UnsupportedOperationException
+     *         if there is no system java compiler
      */
     public static boolean compile(Path source, Path destination, String ... options)
         throws IOException
     {
         JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            // no compiler available
+            throw new UnsupportedOperationException("Unable to get system java compiler. " +
+                "Perhaps, jdk.compiler module is not available.");
+        }
         StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
 
         List<Path> sources
diff --git a/jdk/test/lib/testlibrary/JarUtils.java b/jdk/test/lib/testlibrary/JarUtils.java
index 94905cc..8f0e973 100644
--- a/jdk/test/lib/testlibrary/JarUtils.java
+++ b/jdk/test/lib/testlibrary/JarUtils.java
@@ -35,6 +35,7 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -49,12 +50,12 @@
     /**
      * Creates a JAR file.
      *
-     * Equivalent to {@code jar cf <jarfile> -C <dir> file...}
+     * Equivalent to {@code jar cfm <jarfile> <manifest> -C <dir> file...}
      *
      * The input files are resolved against the given directory. Any input
      * files that are directories are processed recursively.
      */
-    public static void createJarFile(Path jarfile, Path dir, Path... file)
+    public static void createJarFile(Path jarfile, Manifest man, Path dir, Path... file)
         throws IOException
     {
         // create the target directory
@@ -73,10 +74,18 @@
         try (OutputStream out = Files.newOutputStream(jarfile);
              JarOutputStream jos = new JarOutputStream(out))
         {
+            if (man != null) {
+                JarEntry je = new JarEntry(JarFile.MANIFEST_NAME);
+                jos.putNextEntry(je);
+                man.write(jos);
+                jos.closeEntry();
+            }
+
             for (Path entry : entries) {
                 String name = toJarEntryName(entry);
                 jos.putNextEntry(new JarEntry(name));
                 Files.copy(dir.resolve(entry), jos);
+                jos.closeEntry();
             }
         }
     }
@@ -84,6 +93,20 @@
     /**
      * Creates a JAR file.
      *
+     * Equivalent to {@code jar cf <jarfile>  -C <dir> file...}
+     *
+     * The input files are resolved against the given directory. Any input
+     * files that are directories are processed recursively.
+     */
+    public static void createJarFile(Path jarfile, Path dir, Path... file)
+        throws IOException
+    {
+        createJarFile(jarfile, null, dir, file);
+    }
+
+    /**
+     * Creates a JAR file.
+     *
      * Equivalent to {@code jar cf <jarfile> -C <dir> file...}
      *
      * The input files are resolved against the given directory. Any input
diff --git a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java
index f3b43f8..27cf033 100644
--- a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java
+++ b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java
@@ -32,17 +32,18 @@
  */
 public final class DeprecatedAppletViewer {
 
-    private static final String TEXT = "AppletViewer is deprecated.";
+    private static final String TEXT
+            = "Warning: Applet API and AppletViewer are deprecated.";
 
     public static void main(final String[] args) {
-        final PrintStream old = System.out;
+        final PrintStream old = System.err;
         final ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
         final PrintStream ps = new PrintStream(baos);
         try {
-            System.setOut(ps);
+            System.setErr(ps);
             sun.applet.Main.main(new String[]{});
         } finally {
-            System.setOut(old);
+            System.setErr(old);
         }
 
         final String text = new String(baos.toByteArray());
diff --git a/jdk/test/sun/net/www/http/ChunkedOutputStream/checkError.java b/jdk/test/sun/net/www/http/ChunkedOutputStream/checkError.java
index 4575f91..50435ea 100644
--- a/jdk/test/sun/net/www/http/ChunkedOutputStream/checkError.java
+++ b/jdk/test/sun/net/www/http/ChunkedOutputStream/checkError.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /**
  * @test
  * @bug 5054016
+ * @key intermittent
  * @run main/othervm/timeout=300 checkError
  * @summary get the failure immediately when writing individual chunks over socket fail
  */
diff --git a/jdk/test/sun/net/www/protocol/http/ZoneId.java b/jdk/test/sun/net/www/protocol/http/ZoneId.java
index 125c97d..fb611a4 100644
--- a/jdk/test/sun/net/www/protocol/http/ZoneId.java
+++ b/jdk/test/sun/net/www/protocol/http/ZoneId.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 8027308
+ * @key intermittent
  * @modules java.base/sun.net.www.protocol.http
  * @summary  verifies that HttpURLConnection does not send the zone id in the
  *           'Host' field of the header:
diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
index 4e0f0bd..d90d947 100644
--- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
+++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
@@ -235,6 +235,7 @@
                 hostname);
         // Ignore the test if the hostname does not sound like a domain name.
         if ((hostname == null) || hostname.isEmpty() ||
+                !hostname.contains(".") || hostname.endsWith(".") ||
                 hostname.startsWith("localhost") ||
                 Character.isDigit(hostname.charAt(hostname.length() - 1))) {
 
diff --git a/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java b/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java
index 0f55457..f6b01a0 100644
--- a/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java
+++ b/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8132734
+ * @bug 8132734 8144062
  * @summary Test that URL connections to multi-release jars can be runtime versioned
  * @library /lib/testlibrary/java/util/jar
  * @build Compiler JarBuilder CreateMultiReleaseTestJars SimpleHttpServer
@@ -43,8 +43,6 @@
 import java.nio.file.Paths;
 import java.util.jar.JarFile;
 
-import jdk.Version;
-
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
@@ -94,7 +92,7 @@
     public void testRuntimeVersioning(String style, String file) throws Exception {
         String urlFile = "jar:file:" + file + "!/";
         String baseUrlEntry = urlFile + "version/Version.java";
-        String rtreturn = "return " + Version.current().major();
+        String rtreturn = "return " + Runtime.version().major();
 
         Assert.assertTrue(readAndCompare(new URL(baseUrlEntry), "return 8"));
         // #runtime is "magic" for a multi-release jar, but not for unversioned jar
@@ -109,7 +107,7 @@
         if (style.equals("unversioned")) return;
 
         // direct access to versioned entry
-        String versUrlEntry = urlFile + "META-INF/versions/" + Version.current().major()
+        String versUrlEntry = urlFile + "META-INF/versions/" + Runtime.version().major()
                 + "/version/Version.java";
         Assert.assertTrue(readAndCompare(new URL(versUrlEntry), rtreturn));
         // adding any fragment does not change things
@@ -187,7 +185,7 @@
         MethodType mt = MethodType.methodType(int.class);
         MethodHandle mh = MethodHandles.lookup().findVirtual(vcls, "getVersion", mt);
         Assert.assertEquals((int)mh.invoke(vcls.newInstance()),
-                style.equals("unversioned") ? 8 : Version.current().major());
+                style.equals("unversioned") ? 8 : Runtime.version().major());
 
         // now get a resource and verify that we don't have a fragment attached
         URL vclsUrl = vcls.getResource("/version/Version.class");
@@ -206,7 +204,7 @@
         if (style.equals("unversioned")) {
             suffix = ".jar!/version/Version.class";
         } else {
-            suffix = ".jar!/META-INF/versions/" + Version.current().major()
+            suffix = ".jar!/META-INF/versions/" + Runtime.version().major()
                     + "/version/Version.class";
         }
         Assert.assertTrue(rep.endsWith(suffix));
diff --git a/jdk/test/sun/security/jca/PreferredProviderTest.java b/jdk/test/sun/security/jca/PreferredProviderTest.java
index 56aa4a0..7202622 100644
--- a/jdk/test/sun/security/jca/PreferredProviderTest.java
+++ b/jdk/test/sun/security/jca/PreferredProviderTest.java
@@ -25,15 +25,17 @@
 import java.security.KeyFactory;
 import java.security.NoSuchAlgorithmException;
 import java.security.Security;
+import java.security.Signature;
 import java.security.Provider;
 import java.util.Arrays;
 import java.util.List;
 import javax.crypto.Cipher;
+import javax.crypto.Mac;
 import javax.crypto.NoSuchPaddingException;
 
 /**
  * @test
- * @bug 8076359 8133151 8145344 8150512
+ * @bug 8076359 8133151 8145344 8150512 8155847
  * @summary Test the value for new jdk.security.provider.preferred
  *          security property
  */
@@ -61,8 +63,8 @@
             //java.security file which will be verified.
             switch (type) {
                 case "sparcv9":
-                    preferredProp = "AES:SunJCE, SHA1:SUN, SHA-224:SUN,"
-                            + " SHA-256:SUN, SHA-384:SUN, SHA-512:SUN";
+                    preferredProp = "AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, " +
+                            "HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE";
                     verifyPreferredProviderProperty(os, type, preferredProp);
 
                     verifyDigestProvider(os, type, Arrays.asList(
@@ -71,14 +73,51 @@
                             new DataTuple("SHA-224", "SUN"),
                             new DataTuple("SHA-256", "SUN"),
                             new DataTuple("SHA-384", "SUN"),
-                            new DataTuple("SHA-512", "SUN")));
+                            new DataTuple("SHA-512", "SUN"),
+                            new DataTuple("SHA-512/224", "SUN"),
+                            new DataTuple("SHA-512/256", "SUN")));
+
+                    verifyMacProvider(os, type, Arrays.asList(
+                            new DataTuple("HmacSHA1", "SunJCE"),
+                            new DataTuple("HmacSHA224", "SunJCE"),
+                            new DataTuple("HmacSHA256", "SunJCE"),
+                            new DataTuple("HmacSHA384", "SunJCE"),
+                            new DataTuple("HmacSHA512", "SunJCE")));
                     break;
                 case "amd64":
-                    preferredProp = "AES:SunJCE, RSA:SunRsaSign";
+                    preferredProp = "AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, " +
+                            "HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE, " +
+                            "RSA:SunRsaSign, SHA1withRSA:SunRsaSign, " +
+                            "Group.SHA2RSA:SunRsaSign";
+
                     verifyPreferredProviderProperty(os, type, preferredProp);
 
                     verifyKeyFactoryProvider(os, type, Arrays.asList(
                             new DataTuple("RSA", "SunRsaSign")));
+
+                    verifyDigestProvider(os, type, Arrays.asList(
+                            new DataTuple("SHA1", "SUN"),
+                            new DataTuple("SHA-1", "SUN"),
+                            new DataTuple("SHA-224", "SUN"),
+                            new DataTuple("SHA-256", "SUN"),
+                            new DataTuple("SHA-384", "SUN"),
+                            new DataTuple("SHA-512", "SUN"),
+                            new DataTuple("SHA-512/224", "SUN"),
+                            new DataTuple("SHA-512/256", "SUN")));
+
+                    verifyMacProvider(os, type, Arrays.asList(
+                            new DataTuple("HmacSHA1", "SunJCE"),
+                            new DataTuple("HmacSHA224", "SunJCE"),
+                            new DataTuple("HmacSHA256", "SunJCE"),
+                            new DataTuple("HmacSHA384", "SunJCE"),
+                            new DataTuple("HmacSHA512", "SunJCE")));
+
+                    verifySignatureProvider(os, type, Arrays.asList(
+                            new DataTuple("SHA1withRSA", "SunRsaSign"),
+                            new DataTuple("SHA224withRSA", "SunRsaSign"),
+                            new DataTuple("SHA256withRSA", "SunRsaSign"),
+                            new DataTuple("SHA384withRSA", "SunRsaSign"),
+                            new DataTuple("SHA512withRSA", "SunRsaSign")));
                     break;
             }
             verifyDigestProvider(os, type, Arrays.asList(
@@ -99,6 +138,8 @@
         String preferredProvider
                 = Security.getProperty("jdk.security.provider.preferred");
         if (!preferredProvider.equals(preferred)) {
+            System.out.println("Expected: " + preferred + "\nResult: " +
+                    preferredProvider);
             throw new RuntimeException(String.format(
                     "Test Failed: wrong jdk.security.provider.preferred value "
                     + "on %s-%s", os, arch));
@@ -120,6 +161,19 @@
                 "Preferred MessageDigest algorithm verification successful.");
     }
 
+    private static void verifyMacProvider(String os, String arch,
+            List<DataTuple> algoProviders) throws NoSuchAlgorithmException {
+        for (DataTuple dataTuple : algoProviders) {
+            System.out.printf(
+                    "Verifying Mac for '%s'%n", dataTuple.algorithm);
+            Mac mac = Mac.getInstance(dataTuple.algorithm);
+            matchProvider(mac.getProvider(), dataTuple.provider,
+                    dataTuple.algorithm, os, arch);
+        }
+        System.out.println(
+                "Preferred Mac algorithm verification successful.");
+    }
+
     private static void verifyKeyFactoryProvider(String os, String arch,
             List<DataTuple> algoProviders) throws NoSuchAlgorithmException {
         for (DataTuple dataTuple : algoProviders) {
@@ -133,6 +187,19 @@
                 "Preferred KeyFactory algorithm verification successful.");
     }
 
+    private static void verifySignatureProvider(String os, String arch,
+            List<DataTuple> algoProviders) throws NoSuchAlgorithmException {
+        for (DataTuple dataTuple : algoProviders) {
+            System.out.printf(
+                    "Verifying Signature for '%s'%n", dataTuple.algorithm);
+            Signature si = Signature.getInstance(dataTuple.algorithm);
+            matchProvider(si.getProvider(), dataTuple.provider,
+                    dataTuple.algorithm, os, arch);
+        }
+        System.out.println(
+                "Preferred Signature algorithm verification successful.");
+    }
+
     private static void matchProvider(Provider provider, String expected,
             String algo, String os, String arch) {
         if (!provider.getName().equals(expected)) {
diff --git a/jdk/test/sun/security/krb5/canonicalize/Test.java b/jdk/test/sun/security/krb5/canonicalize/Test.java
index 8d21a50..62c44de 100644
--- a/jdk/test/sun/security/krb5/canonicalize/Test.java
+++ b/jdk/test/sun/security/krb5/canonicalize/Test.java
@@ -22,7 +22,7 @@
  */
 /*
  * @test
- * @bug 6682516
+ * @bug 6682516 8149521
  * @summary SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
  * @modules java.security.jgss/sun.security.krb5
  * @run main/othervm  -Djava.security.krb5.conf=krb5.conf Test
@@ -44,9 +44,11 @@
         check("c1", "c1.this.domain");
         check("c1.this", "c1.this.domain");
         check("c1.this.domain", "c1.this.domain");
+        check("c1.this.domain.", "c1.this.domain");
 
         // canonicalized name goes IP, reject
         check("c2", "c2");
+        check("c2.", "c2");
 
         // canonicalized name goes strange, reject
         check("c3", "c3");
@@ -63,4 +65,4 @@
             throw new Exception("Output is " + pn);
         }
     }
-            }
+}
diff --git a/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java
new file mode 100644
index 0000000..17a4c5d
--- /dev/null
+++ b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8150468
+ * @summary check that a badly formatted policy file is handled correctly
+ * @run main/othervm BadPolicyFile
+ */
+
+import java.io.File;
+import java.net.URI;
+import java.security.AccessControlException;
+import java.security.Policy;
+import java.security.URIParameter;
+
+public class BadPolicyFile {
+
+    public static void main(String[] args) throws Exception {
+        URI uri = new File(System.getProperty("test.src", "."),
+                           "BadPolicyFile.policy").toURI();
+        Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(uri)));
+        System.setSecurityManager(new SecurityManager());
+        try {
+            String javahome = System.getProperty("java.home");
+            throw new Exception("Expected AccessControlException");
+        } catch (AccessControlException ace) {
+            System.out.println("Test PASSED");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy
new file mode 100644
index 0000000..b5abfaf
--- /dev/null
+++ b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy
@@ -0,0 +1,4 @@
+grant {
+    // permission statement is missing trailing semi-colon
+    permission "java.util.PropertyPermission" "java.home", "read"
+};
diff --git a/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java b/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java
index 2a45522..fd0b20c 100644
--- a/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java
+++ b/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,11 +21,11 @@
  * questions.
  */
 
-/**
+/*
  * @test
- * @bug 6425477
+ * @bug 6425477 8141039
  * @summary Better support for generation of high entropy random numbers
- * @run main/othervm StrongSecureRandom
+ * @run main StrongSecureRandom
  */
 import java.security.*;
 import java.util.*;
@@ -35,7 +35,10 @@
  */
 public class StrongSecureRandom {
 
-    private static String os = System.getProperty("os.name", "unknown");
+    private static final String os = System.getProperty("os.name", "unknown");
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
 
     private static void testDefaultEgd() throws Exception {
         // No SecurityManager installed.
@@ -47,31 +50,53 @@
         }
     }
 
-    private static void testSHA1PRNGImpl() throws Exception {
-        SecureRandom sr;
+    /**
+     * Verify if the mechanism is DRBG type.
+     * @param mech Mechanism name
+     * @return True if the mechanism name is DRBG type else False.
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
+
+    private static void testSecureRandomImpl(String algo, boolean drbg)
+            throws Exception {
+
         byte[] ba;
+        final String secureRandomSource
+                = Security.getProperty("securerandom.source");
+        try {
+            String urandom = "file:/dev/urandom";
 
-        String urandom = "file:/dev/urandom";
+            System.out.println("Testing new SeedGenerator and EGD");
 
-        System.out.println("Testing new SeedGenerator and EGD");
+            Security.setProperty("securerandom.source", urandom);
+            if (!Security.getProperty("securerandom.source").equals(urandom)) {
+                throw new Exception("Couldn't set securerandom.source");
+            }
 
-        Security.setProperty("securerandom.source", urandom);
-        if (!Security.getProperty("securerandom.source").equals(urandom)) {
-            throw new Exception("Couldn't set securerandom.source");
+            /*
+             * Take out a large number of bytes in hopes of blocking.
+             * Don't expect this to happen, unless something is broken on Linux
+             */
+            SecureRandom sr = null;
+            if (drbg) {
+                Security.setProperty(DRBG_CONFIG, algo);
+                sr = SecureRandom.getInstance("DRBG");
+            } else {
+                sr = SecureRandom.getInstance(algo);
+            }
+            if (!sr.getAlgorithm().equals(isDRBG(algo) ? "DRBG" : algo)) {
+                throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
+            }
+
+            ba = sr.generateSeed(4096);
+            sr.nextBytes(ba);
+            sr.setSeed(ba);
+        } finally {
+            Security.setProperty("securerandom.source", secureRandomSource);
+            Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
         }
-
-        /*
-         * Take out a large number of bytes in hopes of blocking.
-         * Don't expect this to happen, unless something is broken on Linux
-         */
-        sr = SecureRandom.getInstance("SHA1PRNG");
-        if (!sr.getAlgorithm().equals("SHA1PRNG")) {
-            throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
-        }
-
-        ba = sr.generateSeed(4096);
-        sr.nextBytes(ba);
-        sr.setSeed(ba);
     }
 
     private static void testNativePRNGImpls() throws Exception {
@@ -85,7 +110,7 @@
             return;
         }
 
-        System.out.println("    Testing regular");
+        System.out.println("Testing regular");
         sr = SecureRandom.getInstance("NativePRNG");
         if (!sr.getAlgorithm().equals("NativePRNG")) {
             throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
@@ -94,7 +119,7 @@
         sr.nextBytes(ba);
         sr.setSeed(ba);
 
-        System.out.println("    Testing NonBlocking");
+        System.out.println("Testing NonBlocking");
         sr = SecureRandom.getInstance("NativePRNGNonBlocking");
         if (!sr.getAlgorithm().equals("NativePRNGNonBlocking")) {
             throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
@@ -108,7 +133,7 @@
             return;
         }
 
-        System.out.println("    Testing Blocking");
+        System.out.println("Testing Blocking");
         sr = SecureRandom.getInstance("NativePRNGBlocking");
         if (!sr.getAlgorithm().equals("NativePRNGBlocking")) {
             throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
@@ -141,9 +166,15 @@
             throws Exception {
 
         System.out.println("Testing: '" + property + "' " + expected);
-
-        Security.setProperty("securerandom.strongAlgorithms", property);
-        testStrongInstance(expected);
+        final String origStrongAlgoProp
+                = Security.getProperty("securerandom.strongAlgorithms");
+        try {
+            Security.setProperty("securerandom.strongAlgorithms", property);
+            testStrongInstance(expected);
+        } finally {
+            Security.setProperty(
+                    "securerandom.strongAlgorithms", origStrongAlgoProp);
+        }
     }
 
     private static void testProperties() throws Exception {
@@ -228,7 +259,10 @@
 
     public static void main(String args[]) throws Exception {
         testDefaultEgd();
-        testSHA1PRNGImpl();
+        for (String algo : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            testSecureRandomImpl(algo, isDRBG(algo));
+        }
         testNativePRNGImpls();
         testAllImpls();
 
diff --git a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java
index d91ce78..9388972 100644
--- a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java
+++ b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 2016, Oracle and/or its affiliates. All rights
+ * reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +24,9 @@
 
 /*
  * @test
- * @bug 6998583
+ * @bug 6998583 8141039
  * @summary NativeSeedGenerator is making 8192 byte read requests from
  *             entropy pool on each init.
- * @run main SeedGeneratorChoice
  * @run main/othervm -Djava.security.egd=file:/dev/random SeedGeneratorChoice
  * @run main/othervm -Djava.security.egd=file:filename  SeedGeneratorChoice
  */
@@ -39,14 +39,24 @@
  * We should always fall back to the ThreadedSeedGenerator if exceptions
  * are encountered with user defined source of entropy.
  */
-
 import java.security.SecureRandom;
+import java.security.Security;
 
 public class SeedGeneratorChoice {
 
     public static void main(String... arguments) throws Exception {
-        byte[] bytes;
-        SecureRandom prng = SecureRandom.getInstance("SHA1PRNG");
-        bytes = prng.generateSeed(1);
+        for (String mech : new String[]{"SHA1PRNG", "Hash_DRBG", "HMAC_DRBG",
+            "CTR_DRBG"}) {
+
+            SecureRandom prng = null;
+            if (!mech.contains("_DRBG")) {
+                prng = SecureRandom.getInstance(mech);
+            } else {
+                Security.setProperty("securerandom.drbg.config", mech);
+                prng = SecureRandom.getInstance("DRBG");
+            }
+            prng.generateSeed(1);
+        }
     }
+
 }
diff --git a/jdk/test/sun/security/rsa/SpecTest.java b/jdk/test/sun/security/rsa/SpecTest.java
index 24cddfe..7b3c52e 100644
--- a/jdk/test/sun/security/rsa/SpecTest.java
+++ b/jdk/test/sun/security/rsa/SpecTest.java
@@ -24,7 +24,6 @@
 /**
  * @test
  * @bug 8044199 8137231
- * @key intermittent
  * @summary Check same KeyPair's private key and public key have same modulus.
  * also check public key's public exponent equals to given spec's public
  * exponent. Only key size 1024 is tested with RSAKeyGenParameterSpec.F0 (3).
diff --git a/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java b/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java
new file mode 100644
index 0000000..ad6297f
--- /dev/null
+++ b/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8138766
+ * @summary New default -sigalg for keytool
+ * @modules java.base/sun.security.tools.keytool
+ */
+
+import sun.security.tools.keytool.Main;
+
+import java.io.File;
+import java.security.KeyStore;
+import java.security.cert.X509Certificate;
+
+public class DefaultSignatureAlgorithm {
+
+    private static int counter = 0;
+
+    public static void main(String[] args) throws Exception {
+
+        // Calculating large RSA keys are too slow.
+        run("RSA", 1024, null, "SHA256withRSA");
+        run("RSA", 3072, null, "SHA256withRSA");
+        run("RSA", 3073, null, "SHA384withRSA");
+
+        run("DSA", 1024, null, "SHA256withDSA");
+        run("DSA", 3072, null, "SHA256withDSA");
+
+        run("EC", 192, null, "SHA256withECDSA");
+        run("EC", 384, null, "SHA384withECDSA");
+        run("EC", 571, null, "SHA512withECDSA");
+
+        // If you specify one, it will be used.
+        run("EC", 571, "SHA256withECDSA", "SHA256withECDSA");
+    }
+
+    private static void run(String keyAlg, int keySize,
+                    String sigAlg, String expectedSigAlg) throws Exception {
+        String alias = keyAlg + keySize + (counter++);
+        String cmd = "-keystore ks -storepass changeit" +
+                " -keypass changeit -alias " + alias +
+                " -keyalg " + keyAlg + " -keysize " + keySize +
+                " -genkeypair -dname CN=" + alias + " -debug";
+        if (sigAlg != null) {
+            cmd += " -sigalg " + sigAlg;
+        }
+        Main.main(cmd.split(" "));
+
+        KeyStore ks = KeyStore.getInstance(
+                new File("ks"), "changeit".toCharArray());
+        X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
+        String actualSigAlg = cert.getSigAlgName();
+        if (!actualSigAlg.equals(expectedSigAlg)) {
+            throw new Exception("Failure at " + alias + ": expected "
+                    + expectedSigAlg + ", actually " + actualSigAlg);
+        }
+    }
+}
diff --git a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java
index afba30c..b0f3b8d 100644
--- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java
+++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java
@@ -31,9 +31,12 @@
  * @run main BasicLauncherTest
  */
 
+import static jdk.testlibrary.Asserts.assertTrue;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Arrays;
@@ -99,7 +102,7 @@
 
         System.out.println("Starting LingeredApp");
         try {
-            theApp = LingeredApp.startApp();
+            theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m"));
 
             System.out.println("Starting " + toolName + " " + toolArgs.get(0) + " against " + theApp.getPid());
             JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
@@ -129,6 +132,21 @@
         launch(expectedMessage, Arrays.asList(toolArgs));
     }
 
+    public static void testHeapDump() throws IOException {
+        File dump = new File("jhsdb.jmap.dump." +
+                             System.currentTimeMillis() + ".hprof");
+        if (dump.exists()) {
+            dump.delete();
+        }
+        dump.deleteOnExit();
+
+        launch("heap written to", "jmap",
+               "--binaryheap", "--dumpfile=" + dump.getAbsolutePath());
+
+        assertTrue(dump.exists() && dump.isFile(),
+                   "Could not create dump file " + dump.getAbsolutePath());
+    }
+
     public static void main(String[] args)
         throws IOException {
 
@@ -145,6 +163,8 @@
         launch("Java System Properties", "jinfo");
         launch("java.threads", "jsnap");
 
+        testHeapDump();
+
         // The test throws RuntimeException on error.
         // IOException is thrown if LingeredApp can't start because of some bad
         // environment condition
diff --git a/jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java
similarity index 98%
rename from jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java
rename to jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java
index 5a84b62..c768dd6 100644
--- a/jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java
+++ b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java
@@ -36,9 +36,9 @@
  * @test
  * @bug 8042397
  * @summary Unit test for jmap utility test heap configuration reader
+ * @modules jdk.hotspot.agent/sun.jvm.hotspot
  * @library /test/lib/share/classes
  * @library /lib/testlibrary
- * @modules java.management
  * @build jdk.testlibrary.*
  * @build jdk.test.lib.apps.*
  * @build JMapHeapConfigTest TmtoolTestScenario
@@ -149,7 +149,7 @@
         }
         cmd.add("-XX:+PrintFlagsFinal");
 
-        TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "-heap");
+        TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "--heap");
         int exitcode = tmt.launch(cmd);
         if (exitcode != 0) {
             throw new RuntimeException("Test FAILED jmap exits with non zero exit code " + exitcode);
diff --git a/jdk/test/sun/tools/jmap/heapconfig/TmtoolTestScenario.java b/jdk/test/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java
similarity index 97%
rename from jdk/test/sun/tools/jmap/heapconfig/TmtoolTestScenario.java
rename to jdk/test/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java
index 4558f3e..25beea6 100644
--- a/jdk/test/sun/tools/jmap/heapconfig/TmtoolTestScenario.java
+++ b/jdk/test/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java
@@ -100,11 +100,13 @@
                 theApp = LingeredApp.startApp(vmArgsExtended);
 
                 System.out.println("Starting " + toolName + " against " + theApp.getPid());
-                JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
+                JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
+                launcher.addToolArg(toolName);
 
                 for (String cmd : toolArgs) {
                     launcher.addToolArg(cmd);
                 }
+                launcher.addToolArg("--pid");
                 launcher.addToolArg(Long.toString(theApp.getPid()));
 
                 ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
diff --git a/jdk/test/sun/tools/jinfo/BasicJInfoTest.java b/jdk/test/sun/tools/jinfo/BasicJInfoTest.java
new file mode 100644
index 0000000..c612652
--- /dev/null
+++ b/jdk/test/sun/tools/jinfo/BasicJInfoTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Arrays;
+
+import jdk.testlibrary.JDKToolLauncher;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+/*
+ * @test
+ * @summary Unit test for jinfo utility
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
+ * @run main BasicJInfoTest
+ */
+public class BasicJInfoTest {
+
+    private static ProcessBuilder processBuilder = new ProcessBuilder();
+
+    public static void main(String[] args) throws Exception {
+        testJinfoNoArgs();
+        testJinfoFlags();
+        testJinfoProps();
+        testJinfoFlagInvalid();
+    }
+
+    private static void testJinfoNoArgs() throws Exception {
+        OutputAnalyzer output = jinfo();
+        output.shouldContain("-XX");
+        output.shouldContain("test.jdk=");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static void testJinfoFlagInvalid() throws Exception {
+        OutputAnalyzer output = jinfo("-flag");
+        output.shouldHaveExitValue(1);
+    }
+
+    private static void testJinfoFlags() throws Exception {
+        OutputAnalyzer output = jinfo("-flags");
+        output.shouldContain("-XX");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static void testJinfoProps() throws Exception {
+        OutputAnalyzer output = jinfo("-props");
+        output.shouldContain("test.jdk=");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static OutputAnalyzer jinfo(String... toolArgs) throws Exception {
+        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo");
+        if (toolArgs != null) {
+            for (String toolArg : toolArgs) {
+                launcher.addToolArg(toolArg);
+            }
+        }
+        launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
+
+        processBuilder.command(launcher.getCommand());
+        System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
+        OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
+        System.out.println(output.getOutput());
+
+        return output;
+    }
+
+}
diff --git a/jdk/test/sun/tools/jinfo/JInfoHelper.java b/jdk/test/sun/tools/jinfo/JInfoHelper.java
deleted file mode 100644
index 7f94513..0000000
--- a/jdk/test/sun/tools/jinfo/JInfoHelper.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2014, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.Arrays;
-
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-
-/**
- *  The helper class for running jinfo utility.
- */
-public final class JInfoHelper {
-
-    /**
-     * Print configuration information for the current process
-     *
-     * @param toolArgs List of jinfo options
-     */
-    public static OutputAnalyzer jinfo(String... toolArgs) throws Exception {
-        return jinfo(true, toolArgs);
-    }
-
-    /**
-     * Print usage information
-     *
-     * @param toolArgs List of jinfo options
-     */
-    public static OutputAnalyzer jinfoNoPid(String... toolArgs) throws Exception {
-        return jinfo(false, toolArgs);
-    }
-
-    private static OutputAnalyzer jinfo(boolean toPid, String... toolArgs) throws Exception {
-        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo");
-        if (toolArgs != null) {
-            for (String toolArg : toolArgs) {
-                launcher.addToolArg(toolArg);
-            }
-        }
-        if (toPid) {
-            launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
-        }
-
-        ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
-        System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
-        OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
-        System.out.println(output.getOutput());
-
-        return output;
-    }
-
-}
diff --git a/jdk/test/sun/tools/jinfo/JInfoLauncherTest.java b/jdk/test/sun/tools/jinfo/JInfoLauncherTest.java
deleted file mode 100644
index 09b4750..0000000
--- a/jdk/test/sun/tools/jinfo/JInfoLauncherTest.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
-import sun.tools.jinfo.JInfo;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-
-import static org.testng.Assert.*;
-
-/**
- * @test
- * @bug 8039080
- * @modules jdk.jcmd/sun.tools.jinfo
- * @run testng JInfoLauncherTest
- * @summary Test JInfo launcher argument parsing
- */
-@Test
-public class JInfoLauncherTest {
-    public static final String VALIDATION_EXCEPTION_CLSNAME =
-                                IllegalArgumentException.class.getName();
-
-    private Constructor<JInfo> jInfoConstructor;
-    private Field fldUseSA;
-
-    @BeforeClass
-    public void setup() throws Exception {
-        jInfoConstructor = JInfo.class.getDeclaredConstructor(String[].class);
-        jInfoConstructor.setAccessible(true);
-        fldUseSA = JInfo.class.getDeclaredField("useSA");
-        fldUseSA.setAccessible(true);
-    }
-
-    private JInfo newJInfo(String[] args) throws Exception {
-        try {
-            return jInfoConstructor.newInstance((Object) args);
-        } catch (Exception e) {
-            if (isValidationException(e.getCause())) {
-                throw (Exception)e.getCause();
-            }
-            throw e;
-        }
-    }
-
-    private boolean getUseSA(JInfo jinfo) throws Exception {
-        return fldUseSA.getBoolean(jinfo);
-    }
-
-    private void cmdPID(String cmd, String ... params) throws Exception {
-        int offset = (cmd != null ? 1 : 0);
-        String[] args = new String[offset + params.length];
-        args[0] = cmd;
-        System.arraycopy(params, 0, args, offset, params.length);
-        JInfo j = newJInfo(args);
-        assertFalse(getUseSA(j), "Local jinfo must not forward to SA");
-    }
-
-    private void cmdCore(String cmd, String ... params) throws Exception {
-        int offset = (cmd != null ? 1 : 0);
-        String[] args = new String[offset + params.length];
-        args[0] = cmd;
-        System.arraycopy(params, 0, args, offset, params.length);
-        JInfo j = newJInfo(args);
-        assertTrue(getUseSA(j), "Core jinfo must forward to SA");
-    }
-
-    private void cmdRemote(String cmd, String ... params) throws Exception {
-        int offset = (cmd != null ? 1 : 0);
-        String[] args = new String[offset + params.length];
-        args[0] = cmd;
-        System.arraycopy(params, 0, args, offset, params.length);
-        JInfo j = newJInfo(args);
-        assertTrue(getUseSA(j), "Remote jinfo must forward to SA");
-    }
-
-    private void cmdExtraArgs(String cmd, int argsLen) throws Exception {
-        String[] args = new String[argsLen + 1 + (cmd != null ? 1 : 0)];
-        Arrays.fill(args, "a");
-        if (cmd != null) {
-            args[0] = cmd;
-        } else {
-            cmd = "default";
-        }
-        try {
-            JInfo j = newJInfo(args);
-            fail("\"" + cmd + "\" does not support more than " + argsLen +
-                 " arguments");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    private void cmdMissingArgs(String cmd, int reqArgs) throws Exception {
-        String[] args = new String[reqArgs - 1 + (cmd != null ? 1 : 0)];
-        Arrays.fill(args, "a");
-        if (cmd != null) {
-            args[0] = cmd;
-        } else {
-            cmd = "default";
-        }
-        try {
-            JInfo j = newJInfo(args);
-            fail("\"" + cmd + "\" requires at least " + reqArgs + " argument");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testDefaultPID() throws Exception {
-        cmdPID(null, "1234");
-    }
-
-    public void testFlagsPID() throws Exception {
-        cmdPID("-flags", "1234");
-    }
-
-    public void testSyspropsPID() throws Exception {
-        cmdPID("-sysprops", "1234");
-    }
-
-    public void testReadFlagPID() throws Exception {
-        cmdPID("-flag", "SomeManagementFlag", "1234");
-    }
-
-    public void testSetFlag1PID() throws Exception {
-        cmdPID("-flag", "+SomeManagementFlag", "1234");
-    }
-
-    public void testSetFlag2PID() throws Exception {
-        cmdPID("-flag", "-SomeManagementFlag", "1234");
-    }
-
-    public void testSetFlag3PID() throws Exception {
-        cmdPID("-flag", "SomeManagementFlag=314", "1234");
-    }
-
-    public void testDefaultCore() throws Exception {
-        cmdCore(null, "myapp.exe", "my.core");
-    }
-
-    public void testFlagsCore() throws Exception {
-        cmdCore("-flags", "myapp.exe", "my.core");
-    }
-
-    public void testSyspropsCore() throws Exception {
-        cmdCore("-sysprops", "myapp.exe", "my.core");
-    }
-
-    public void testReadFlagCore() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag", "myapp.exe", "my.core");
-            fail("Flags can not be read from core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag1Core() throws Exception {
-        try {
-            cmdCore("-flag", "+SomeManagementFlag", "myapp.exe", "my.core");
-            fail("Flags can not be set in core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag2Core() throws Exception {
-        try {
-            cmdCore("-flag", "-SomeManagementFlag", "myapp.exe", "my.core");
-            fail("Flags can not be set in core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag3Core() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag=314", "myapp.exe", "my.core");
-            fail("Flags can not be set in core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testDefaultRemote() throws Exception {
-        cmdRemote(null, "serverid@host");
-    }
-
-    public void testFlagsRemote() throws Exception {
-        cmdRemote("-flags", "serverid@host");
-    }
-
-    public void testSyspropsRemote() throws Exception {
-        cmdRemote("-sysprops", "serverid@host");
-    }
-
-    public void testReadFlagRemote() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag", "serverid@host");
-            fail("Flags can not be read from SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag1Remote() throws Exception {
-        try {
-            cmdCore("-flag", "+SomeManagementFlag","serverid@host");
-            fail("Flags can not be set on SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag2Remote() throws Exception {
-        try {
-            cmdCore("-flag", "-SomeManagementFlag", "serverid@host");
-            fail("Flags can not be read set on SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag3Remote() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag=314", "serverid@host");
-            fail("Flags can not be read set on SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testDefaultExtraArgs() throws Exception {
-        cmdExtraArgs(null, 2);
-    }
-
-    public void testFlagsExtraArgs() throws Exception {
-        cmdExtraArgs("-flags", 2);
-    }
-
-    public void testSyspropsExtraArgs() throws Exception {
-        cmdExtraArgs("-sysprops", 2);
-    }
-
-    public void testFlagExtraArgs() throws Exception {
-        cmdExtraArgs("-flag", 2);
-    }
-
-    public void testHelp1ExtraArgs() throws Exception {
-        cmdExtraArgs("-h", 0);
-    }
-
-    public void testHelp2ExtraArgs() throws Exception {
-        cmdExtraArgs("-help", 0);
-    }
-
-    public void testDefaultMissingArgs() throws Exception {
-        cmdMissingArgs(null, 1);
-    }
-
-    public void testFlagsMissingArgs() throws Exception {
-        cmdMissingArgs("-flags", 1);
-    }
-
-    public void testSyspropsMissingArgs() throws Exception {
-        cmdMissingArgs("-sysprops", 1);
-    }
-
-    public void testFlagMissingArgs() throws Exception {
-        cmdMissingArgs("-flag", 2);
-    }
-
-    public void testUnknownCommand() throws Exception {
-        try {
-            JInfo j = newJInfo(new String[]{"-unknown_command"});
-            fail("JInfo accepts unknown commands");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    private static boolean isValidationException(Throwable e) {
-        return e.getClass().getName().equals(VALIDATION_EXCEPTION_CLSNAME);
-    }
-}
diff --git a/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java b/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java
deleted file mode 100644
index cb28cc7..0000000
--- a/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2014, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.lang.management.ManagementFactory;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.Platform.isSolaris;
-import static jdk.testlibrary.Asserts.assertEquals;
-import static jdk.testlibrary.Asserts.assertNotEquals;
-import static jdk.testlibrary.Asserts.assertTrue;
-
-/**
- * @test
- * @summary The test sanity checks 'jinfo -flag' option.
- * @library /lib/testlibrary
- * @modules java.management
- * @build jdk.testlibrary.* JInfoHelper
- * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessFlagTest
- */
-public class JInfoRunningProcessFlagTest {
-
-    public static void main(String[] args) throws Exception {
-        testFlag();
-        testFlagPlus();
-        testFlagMinus();
-        testFlagEqual();
-
-        testInvalidFlag();
-
-        testSolarisSpecificFlag();
-    }
-
-    private static void testFlag() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo -flag HeapDumpOnOutOfMemoryError' stderr should be empty");
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testFlagPlus() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-        verifyIsEnabled("HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testFlagMinus() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output.shouldContain("-HeapDumpOnOutOfMemoryError");
-        verifyIsDisabled("HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testFlagEqual() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError=1");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-        verifyIsEnabled("HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testInvalidFlag() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "monkey");
-        assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid flag");
-    }
-
-    private static void testSolarisSpecificFlag() throws Exception {
-        if (!isSolaris())
-            return;
-
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+ExtendedDTraceProbes");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo();
-        output.shouldContain("+ExtendedDTraceProbes");
-        verifyIsEnabled("ExtendedDTraceProbes");
-
-        output = JInfoHelper.jinfo("-flag", "-ExtendedDTraceProbes");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo();
-        output.shouldContain("-ExtendedDTraceProbes");
-        verifyIsDisabled("ExtendedDTraceProbes");
-
-        output = JInfoHelper.jinfo("-flag", "ExtendedDTraceProbes");
-        output.shouldContain("-ExtendedDTraceProbes");
-        output.shouldHaveExitValue(0);
-    }
-
-    private static void verifyIsEnabled(String flag) {
-        HotSpotDiagnosticMXBean hotspotDiagnostic =
-                ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
-        String flagValue = hotspotDiagnostic.getVMOption(flag).getValue();
-        assertEquals(flagValue, "true", "Expected '" + flag + "' flag be enabled");
-    }
-
-    private static void verifyIsDisabled(String flag) {
-        HotSpotDiagnosticMXBean hotspotDiagnostic =
-                ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
-        String flagValue = hotspotDiagnostic.getVMOption(flag).getValue();
-        assertEquals(flagValue, "false", "Expected '" + flag + "' flag be disabled");
-    }
-
-}
diff --git a/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java b/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java
deleted file mode 100644
index 633a2c9..0000000
--- a/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2014, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.Asserts.assertTrue;
-
-/**
- * @test
- * @summary The test sanity checks functionality of 'jinfo', 'jinfo -sysprops' and 'jinfo -flags'
- * @library /lib/testlibrary
- * @modules java.management
- * @build jdk.testlibrary.* JInfoHelper
- * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessTest
- */
-public class JInfoRunningProcessTest {
-
-    public static void main(String[] args) throws Exception {
-        testNoOptions();
-        testSysprops();
-        testFlags();
-    }
-
-    private static void testNoOptions() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo();
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo' stderr should be empty");
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testSysprops() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-sysprops");
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo -sysprops' stderr should be empty");
-    }
-
-    private static void testFlags() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flags");
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo -flags' stderr should be empty");
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-    }
-
-}
diff --git a/jdk/test/sun/tools/jinfo/JInfoSanityTest.java b/jdk/test/sun/tools/jinfo/JInfoSanityTest.java
deleted file mode 100644
index 9b0bcf1..0000000
--- a/jdk/test/sun/tools/jinfo/JInfoSanityTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2014, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import static jdk.testlibrary.Asserts.assertNotEquals;
-import static jdk.testlibrary.Asserts.assertTrue;
-import static jdk.testlibrary.Asserts.assertFalse;
-import jdk.testlibrary.OutputAnalyzer;
-
-/**
- * @test
- * @summary The test sanity checks functionality of 'jinfo -h', 'jinfo -help',
- *          and verifies jinfo exits abnormally if started with invalid options.
- * @library /lib/testlibrary
- * @modules java.management
- * @build jdk.testlibrary.* JInfoHelper
- * @run main JInfoSanityTest
- */
-public class JInfoSanityTest {
-
-    public static void main(String[] args) throws Exception {
-        test_h();
-        test_help();
-        testVersion();
-        testUnknownHost();
-    }
-
-    private static void test_h() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("-h");
-        output.shouldHaveExitValue(0);
-        assertFalse(output.getStderr().isEmpty(), "'jinfo -h' stderr should not be empty");
-        assertTrue(output.getStdout().isEmpty(), "'jinfo -h' stdout should be empty");
-    }
-
-    private static void test_help() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("-help");
-        output.shouldHaveExitValue(0);
-        assertFalse(output.getStderr().isEmpty(), "'jinfo -help' stderr should not be empty");
-        assertTrue(output.getStdout().isEmpty(), "'jinfo -help' stdout should be empty");
-    }
-
-    private static void testVersion() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("-version");
-        output.shouldHaveExitValue(1);
-        assertFalse(output.getStderr().isEmpty(), "'jinfo -version' stderr should not be empty");
-        assertTrue(output.getStdout().isEmpty(), "'jinfo -version' stdout should be empty");
-    }
-
-    private static void testUnknownHost() throws Exception {
-        String unknownHost = "Oja781nh2ev7vcvbajdg-Sda1-C";
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("med@" + unknownHost);
-        assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid operation");
-        output.shouldMatch(".*(Connection refused to host\\:|UnknownHostException\\:) " + unknownHost + ".*");
-    }
-
-}
diff --git a/jdk/test/sun/tools/jmap/BasicJMapTest.java b/jdk/test/sun/tools/jmap/BasicJMapTest.java
index 75c80a2..fa333cd 100644
--- a/jdk/test/sun/tools/jmap/BasicJMapTest.java
+++ b/jdk/test/sun/tools/jmap/BasicJMapTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,12 +34,10 @@
 
 /*
  * @test
- * @bug 6321286
  * @summary Unit test for jmap utility
  * @key intermittent
  * @library /lib/testlibrary
  * @library /test/lib/share/classes
- * @modules java.management
  * @build jdk.testlibrary.*
  * @build jdk.test.lib.hprof.*
  * @build jdk.test.lib.hprof.model.*
@@ -54,6 +52,8 @@
     public static void main(String[] args) throws Exception {
         testHisto();
         testHistoLive();
+        testFinalizerInfo();
+        testClstats();
         testDump();
         testDumpLive();
     }
@@ -68,6 +68,16 @@
         output.shouldHaveExitValue(0);
     }
 
+    private static void testFinalizerInfo() throws Exception {
+        OutputAnalyzer output = jmap("-finalizerinfo");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static void testClstats() throws Exception {
+        OutputAnalyzer output = jmap("-clstats");
+        output.shouldHaveExitValue(0);
+    }
+
     private static void testDump() throws Exception {
         dump(false);
     }
@@ -105,7 +115,6 @@
 
     private static OutputAnalyzer jmap(String... toolArgs) throws Exception {
         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jmap");
-        launcher.addVMArg("-XX:+UsePerfData");
         if (toolArgs != null) {
             for (String toolArg : toolArgs) {
                 launcher.addToolArg(toolArg);
diff --git a/jdk/test/sun/tools/jstack/BasicJStackTest.java b/jdk/test/sun/tools/jstack/BasicJStackTest.java
index 9fd0b66..997876a 100644
--- a/jdk/test/sun/tools/jstack/BasicJStackTest.java
+++ b/jdk/test/sun/tools/jstack/BasicJStackTest.java
@@ -29,10 +29,8 @@
 
 /*
  * @test
- * @bug 6260070
  * @summary Unit test for jstack utility
  * @library /lib/testlibrary
- * @modules java.management
  * @build jdk.testlibrary.*
  * @run main BasicJStackTest
  */
diff --git a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java
index 4ff2508..771fd12 100644
--- a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java
+++ b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java
@@ -39,7 +39,6 @@
  * @summary Test deadlock detection
  * @library /test/lib/share/classes
  * @library /lib/testlibrary
- * @modules java.management
  * @build jdk.testlibrary.*
  * @build jdk.test.lib.apps.*
  * @build DeadlockDetectionTest
diff --git a/jdk/test/sun/util/logging/PlatformLoggerTest.java b/jdk/test/sun/util/logging/PlatformLoggerTest.java
index 530a2ac..4fbf0c9 100644
--- a/jdk/test/sun/util/logging/PlatformLoggerTest.java
+++ b/jdk/test/sun/util/logging/PlatformLoggerTest.java
@@ -31,7 +31,6 @@
  *
  * @modules java.base/sun.util.logging
  *          java.logging/sun.util.logging.internal
- * @compile -XDignore.symbol.file PlatformLoggerTest.java
  * @run main/othervm PlatformLoggerTest
  */
 
@@ -42,25 +41,31 @@
 import static sun.util.logging.PlatformLogger.Level.*;
 
 public class PlatformLoggerTest {
+
+    static Logger logger;
+    static PlatformLogger bar;
+    static PlatformLogger goo;
+    static PlatformLogger foo;
+
     public static void main(String[] args) throws Exception {
         final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
         final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
         final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo";
         final String BAR_LOGGER = "test.logger.bar";
-        PlatformLogger goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
+        goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
         // test the PlatformLogger methods
         testLogMethods(goo);
 
         // Create a platform logger using the default
-        PlatformLogger foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
+        foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
         checkPlatformLogger(foo, FOO_PLATFORM_LOGGER);
 
         // create a java.util.logging.Logger
         // now java.util.logging.Logger should be created for each platform logger
-        Logger logger = Logger.getLogger(BAR_LOGGER);
+        logger = Logger.getLogger(BAR_LOGGER);
         logger.setLevel(Level.WARNING);
 
-        PlatformLogger bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
+        bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
         checkPlatformLogger(bar, BAR_PLATFORM_LOGGER);
 
         // test the PlatformLogger methods
diff --git a/jdk/test/tools/jar/modularJar/Basic.java b/jdk/test/tools/jar/modularJar/Basic.java
index 417f71a..4ce94a2 100644
--- a/jdk/test/tools/jar/modularJar/Basic.java
+++ b/jdk/test/tools/jar/modularJar/Basic.java
@@ -33,6 +33,7 @@
 import java.util.function.Consumer;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
 import java.util.regex.Pattern;
 import java.util.stream.Stream;
 import javax.tools.JavaCompiler;
@@ -52,45 +53,64 @@
 /*
  * @test
  * @library /lib/testlibrary
+ * @modules jdk.compiler
+ *          jdk.jartool
  * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
  * @compile Basic.java
  * @run testng Basic
- * @summary Basic test for Modular jars
+ * @summary Tests for plain Modular jars & Multi-Release Modular jars
  */
 
 public class Basic {
     static final Path TEST_SRC = Paths.get(System.getProperty("test.src", "."));
     static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", "."));
     static final Path MODULE_CLASSES = TEST_CLASSES.resolve("build");
+    static final Path MRJAR_DIR = MODULE_CLASSES.resolve("mrjar");
 
     // Details based on the checked in module source
     static TestModuleData FOO = new TestModuleData("foo",
                                                    "1.123",
                                                    "jdk.test.foo.Foo",
-                                                   "Hello World!!!", null,
-                                                   "jdk.test.foo.internal");
+                                                   "Hello World!!!",
+                                                   null, // no hashes
+                                                   Set.of("java.base"),
+                                                   Set.of("jdk.test.foo"),
+                                                   null, // no uses
+                                                   null, // no provides
+                                                   Set.of("jdk.test.foo.internal"));
     static TestModuleData BAR = new TestModuleData("bar",
                                                    "4.5.6.7",
                                                    "jdk.test.bar.Bar",
-                                                   "Hello from Bar!", null,
-                                                   "jdk.test.bar",
-                                                   "jdk.test.bar.internal");
+                                                   "Hello from Bar!",
+                                                   null, // no hashes
+                                                   Set.of("java.base", "foo"),
+                                                   null, // no exports
+                                                   null, // no uses
+                                                   null, // no provides
+                                                   Set.of("jdk.test.bar",
+                                                          "jdk.test.bar.internal"));
 
     static class TestModuleData {
         final String moduleName;
+        final Set<String> requires;
+        final Set<String> exports;
+        final Set<String> uses;
+        final Set<String> provides;
         final String mainClass;
         final String version;
         final String message;
         final String hashes;
         final Set<String> conceals;
-        TestModuleData(String mn, String v, String mc, String m, String h, String... pkgs) {
+
+        TestModuleData(String mn, String v, String mc, String m, String h,
+                       Set<String> requires, Set<String> exports, Set<String> uses,
+                       Set<String> provides, Set<String> conceals) {
             moduleName = mn; mainClass = mc; version = v; message = m; hashes = h;
-            conceals = new HashSet<>();
-            Stream.of(pkgs).forEach(conceals::add);
-        }
-        TestModuleData(String mn, String v, String mc, String m, String h, Set<String> pkgs) {
-            moduleName = mn; mainClass = mc; version = v; message = m; hashes = h;
-            conceals = pkgs;
+            this.requires = requires;
+            this.exports = exports;
+            this.uses = uses;
+            this.provides = provides;
+            this.conceals = conceals;
         }
         static TestModuleData from(String s) {
             try {
@@ -99,7 +119,8 @@
                 String message = null;
                 String name = null, version = null, mainClass = null;
                 String hashes = null;
-                Set<String> conceals = null;
+                Set<String> requires, exports, uses, provides, conceals;
+                requires = exports = uses = provides = conceals = null;
                 while ((line = reader.readLine()) != null) {
                     if (line.startsWith("message:")) {
                         message = line.substring("message:".length());
@@ -114,28 +135,46 @@
                         }
                     } else if (line.startsWith("mainClass:")) {
                         mainClass = line.substring("mainClass:".length());
+                    } else if (line.startsWith("requires:")) {
+                        line = line.substring("requires:".length());
+                        requires = stringToSet(line);
+                    } else if (line.startsWith("exports:")) {
+                        line = line.substring("exports:".length());
+                        exports = stringToSet(line);
+                    } else if (line.startsWith("uses:")) {
+                        line = line.substring("uses:".length());
+                        uses = stringToSet(line);
+                    } else if (line.startsWith("provides:")) {
+                        line = line.substring("provides:".length());
+                        provides = stringToSet(line);
                     } else if (line.startsWith("hashes:")) {
                         hashes = line.substring("hashes:".length());
-                    }  else if (line.startsWith("conceals:")) {
+                    } else if (line.startsWith("conceals:")) {
                         line = line.substring("conceals:".length());
-                        conceals = new HashSet<>();
-                        int i = line.indexOf(',');
-                        if (i != -1) {
-                            String[] p = line.split(",");
-                            Stream.of(p).forEach(conceals::add);
-                        } else {
-                            conceals.add(line);
-                        }
+                        conceals = stringToSet(line);
                     } else {
                         throw new AssertionError("Unknown value " + line);
                     }
                 }
 
-                return new TestModuleData(name, version, mainClass, message, hashes, conceals);
+                return new TestModuleData(name, version, mainClass, message,
+                                          hashes, requires, exports, uses,
+                                          provides, conceals);
             } catch (IOException x) {
                 throw new UncheckedIOException(x);
             }
         }
+        static Set<String> stringToSet(String commaList) {
+            Set<String> s = new HashSet<>();
+            int i = commaList.indexOf(',');
+            if (i != -1) {
+                String[] p = commaList.split(",");
+                Stream.of(p).forEach(s::add);
+            } else {
+                s.add(commaList);
+            }
+            return s;
+        }
     }
 
     static void assertModuleData(Result r, TestModuleData expected) {
@@ -150,10 +189,19 @@
                    "Expected version: ", expected.version, ", got:", received.version);
         assertTrue(expected.mainClass.equals(received.mainClass),
                    "Expected mainClass: ", expected.mainClass, ", got:", received.mainClass);
-        expected.conceals.forEach(p -> assertTrue(received.conceals.contains(p),
-                                                  "Expected ", p, ", in ", received.conceals));
-        received.conceals.forEach(p -> assertTrue(expected.conceals.contains(p),
-                                                  "Expected ", p, ", in ", expected.conceals));
+        assertSetsEqual(expected.requires, received.requires);
+        assertSetsEqual(expected.exports, received.exports);
+        assertSetsEqual(expected.uses, received.uses);
+        assertSetsEqual(expected.provides, received.provides);
+        assertSetsEqual(expected.conceals, received.conceals);
+    }
+
+    static void assertSetsEqual(Set<String> s1, Set<String> s2) {
+        if (s1 == null && s2 == null) // none expected, or received
+            return;
+        assertTrue(s1.size() == s2.size(),
+                   "Unexpected set size difference: ", s1.size(), ", ", s2.size());
+        s1.forEach(p -> assertTrue(s2.contains(p), "Expected ", p, ", in ", s2));
     }
 
     @BeforeTest
@@ -161,6 +209,10 @@
         compileModule(FOO.moduleName);
         compileModule(BAR.moduleName, MODULE_CLASSES);
         compileModule("baz");  // for service provider consistency checking
+
+        setupMRJARModuleInfo(FOO.moduleName);
+        setupMRJARModuleInfo(BAR.moduleName);
+        setupMRJARModuleInfo("baz");
     }
 
     @Test
@@ -180,7 +232,6 @@
         java(mp, FOO.moduleName + "/" + FOO.mainClass)
             .assertSuccess()
             .resultChecker(r -> assertModuleData(r, FOO));
-
         try (InputStream fis = Files.newInputStream(modularJar);
              JarInputStream jis = new JarInputStream(fis)) {
             assertTrue(!jarContains(jis, "./"),
@@ -188,6 +239,30 @@
         }
     }
 
+    /** Similar to createFoo, but with a Multi-Release Modular jar. */
+    @Test
+    public void createMRMJarFoo() throws IOException {
+        Path mp = Paths.get("createMRMJarFoo");
+        createTestDir(mp);
+        Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
+        Path mrjarDir = MRJAR_DIR.resolve(FOO.moduleName);
+        Path modularJar = mp.resolve(FOO.moduleName + ".jar");
+
+        // Positive test, create
+        jar("--create",
+            "--file=" + modularJar.toString(),
+            "--main-class=" + FOO.mainClass,
+            "--module-version=" + FOO.version,
+            "-m", mrjarDir.resolve("META-INF/MANIFEST.MF").toRealPath().toString(),
+            "-C", mrjarDir.toString(), "META-INF/versions/9/module-info.class",
+            "-C", modClasses.toString(), ".")
+            .assertSuccess();
+        java(mp, FOO.moduleName + "/" + FOO.mainClass)
+            .assertSuccess()
+            .resultChecker(r -> assertModuleData(r, FOO));
+    }
+
+
     @Test
     public void updateFoo() throws IOException {
         Path mp = Paths.get("updateFoo");
@@ -213,6 +288,32 @@
     }
 
     @Test
+    public void updateMRMJarFoo() throws IOException {
+        Path mp = Paths.get("updateMRMJarFoo");
+        createTestDir(mp);
+        Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
+        Path mrjarDir = MRJAR_DIR.resolve(FOO.moduleName);
+        Path modularJar = mp.resolve(FOO.moduleName + ".jar");
+
+        jar("--create",
+            "--file=" + modularJar.toString(),
+            "--no-manifest",
+            "-C", modClasses.toString(), "jdk")
+            .assertSuccess();
+        jar("--update",
+            "--file=" + modularJar.toString(),
+            "--main-class=" + FOO.mainClass,
+            "--module-version=" + FOO.version,
+            "-m", mrjarDir.resolve("META-INF/MANIFEST.MF").toRealPath().toString(),
+            "-C", mrjarDir.toString(), "META-INF/versions/9/module-info.class",
+            "-C", modClasses.toString(), "module-info.class")
+            .assertSuccess();
+        java(mp, FOO.moduleName + "/" + FOO.mainClass)
+            .assertSuccess()
+            .resultChecker(r -> assertModuleData(r, FOO));
+    }
+
+    @Test
     public void partialUpdateFooMainClass() throws IOException {
         Path mp = Paths.get("partialUpdateFooMainClass");
         createTestDir(mp);
@@ -290,6 +391,30 @@
     }
 
     @Test
+    public void partialUpdateMRMJarFooNotAllFiles() throws IOException {
+        Path mp = Paths.get("partialUpdateMRMJarFooNotAllFiles");
+        createTestDir(mp);
+        Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
+        Path mrjarDir = MRJAR_DIR.resolve(FOO.moduleName);
+        Path modularJar = mp.resolve(FOO.moduleName + ".jar");
+
+        jar("--create",
+            "--file=" + modularJar.toString(),
+            "--module-version=" + FOO.version,
+            "-C", modClasses.toString(), ".")
+            .assertSuccess();
+        jar("--update",
+            "--file=" + modularJar.toString(),
+            "--main-class=" + FOO.mainClass,
+            "-m", mrjarDir.resolve("META-INF/MANIFEST.MF").toRealPath().toString(),
+            "-C", mrjarDir.toString(), "META-INF/versions/9/module-info.class")
+            .assertSuccess();
+        java(mp, FOO.moduleName + "/" + FOO.mainClass)
+            .assertSuccess()
+            .resultChecker(r -> assertModuleData(r, FOO));
+    }
+
+    @Test
     public void partialUpdateFooAllFilesAndAttributes() throws IOException {
         Path mp = Paths.get("partialUpdateFooAllFilesAndAttributes");
         createTestDir(mp);
@@ -528,6 +653,24 @@
     }
 
     @Test
+    public void servicesCreateWithoutFailureMRMJAR() throws IOException {
+        Path mp = Paths.get("servicesCreateWithoutFailureMRMJAR");
+        createTestDir(mp);
+        Path modClasses = MODULE_CLASSES.resolve("baz");
+        Path mrjarDir = MRJAR_DIR.resolve("baz");
+        Path modularJar = mp.resolve("baz" + ".jar");
+
+        jar("--create",
+            "--file=" + modularJar.toString(),
+            "-m", mrjarDir.resolve("META-INF/MANIFEST.MF").toRealPath().toString(),
+            "-C", modClasses.toString(), "module-info.class",
+            "-C", mrjarDir.toString(), "META-INF/versions/9/module-info.class",
+            "-C", modClasses.toString(), "jdk/test/baz/BazService.class",
+            "-C", modClasses.toString(), "jdk/test/baz/internal/BazServiceImpl.class")
+            .assertSuccess();
+    }
+
+    @Test
     public void printModuleDescriptorFoo() throws IOException {
         Path mp = Paths.get("printModuleDescriptorFoo");
         createTestDir(mp);
@@ -611,6 +754,24 @@
         return build;
     }
 
+    static void setupMRJARModuleInfo(String moduleName) throws IOException {
+        Path modClasses = MODULE_CLASSES.resolve(moduleName);
+        Path metaInfDir = MRJAR_DIR.resolve(moduleName).resolve("META-INF");
+        Path versionSection = metaInfDir.resolve("versions").resolve("9");
+        createTestDir(versionSection);
+
+        Path versionModuleInfo = versionSection.resolve("module-info.class");
+        System.out.println("copying " + modClasses.resolve("module-info.class") + " to " + versionModuleInfo);
+        Files.copy(modClasses.resolve("module-info.class"), versionModuleInfo);
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
+        manifest.getMainAttributes().putValue("Multi-Release", "true");
+        try (OutputStream os = Files.newOutputStream(metaInfDir.resolve("MANIFEST.MF"))) {
+            manifest.write(os);
+        }
+    }
+
     // Re-enable when there is support in javax.tools for module path
 //    static void javac(Path dest, Path... sourceFiles) throws IOException {
 //        out.printf("Compiling %d source files %s%n", sourceFiles.length,
@@ -690,7 +851,7 @@
     static void createTestDir(Path p) throws IOException{
         if (Files.exists(p))
             FileUtils.deleteFileTreeWithRetry(p);
-        Files.createDirectory(p);
+        Files.createDirectories(p);
     }
 
     static boolean jarContains(JarInputStream jis, String entryName)
diff --git a/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/Bar.java b/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/Bar.java
index 181491a..5267814 100644
--- a/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/Bar.java
+++ b/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/Bar.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -26,6 +24,8 @@
 package jdk.test.bar;
 
 import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Requires;
 import java.lang.reflect.Method;
 import java.util.Optional;
 import java.util.StringJoiner;
@@ -39,18 +39,36 @@
 
         ModuleDescriptor md = Bar.class.getModule().getDescriptor();
         System.out.println("nameAndVersion:" + md.toNameAndVersion());
-        System.out.println("mainClass:" + md.mainClass().get());
+        md.mainClass().ifPresent(mc -> System.out.println("mainClass:" + mc));
+
+        StringJoiner sj = new StringJoiner(",");
+        md.requires().stream().map(ModuleDescriptor.Requires::name).sorted().forEach(sj::add);
+        System.out.println("requires:" + sj.toString());
+
+        sj = new StringJoiner(",");
+        md.exports().stream().map(ModuleDescriptor.Exports::source).sorted().forEach(sj::add);
+        if (!sj.toString().equals(""))
+            System.out.println("exports:" + sj.toString());
+
+        sj = new StringJoiner(",");
+        md.uses().stream().sorted().forEach(sj::add);
+        if (!sj.toString().equals(""))
+            System.out.println("uses:" + sj.toString());
+
+        sj = new StringJoiner(",");
+        md.provides().keySet().stream().sorted().forEach(sj::add);
+        if (!sj.toString().equals(""))
+            System.out.println("provides:" + sj.toString());
+
+        sj = new StringJoiner(",");
+        md.conceals().forEach(sj::add);
+        if (!sj.toString().equals(""))
+            System.out.println("conceals:" + sj.toString());
 
         Method m = ModuleDescriptor.class.getDeclaredMethod("hashes");
         m.setAccessible(true);
         ModuleDescriptor foo = jdk.test.foo.Foo.class.getModule().getDescriptor();
-        Optional<ModuleHashes> oHashes =
-                (Optional<ModuleHashes>) m.invoke(foo);
-
+        Optional<ModuleHashes> oHashes = (Optional<ModuleHashes>) m.invoke(foo);
         System.out.println("hashes:" + oHashes.get().hashFor("bar"));
-
-        StringJoiner sj = new StringJoiner(",");
-        md.conceals().forEach(sj::add);
-        System.out.println("conceals:" + sj.toString());
     }
 }
diff --git a/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/internal/Message.java b/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/internal/Message.java
index 17cbe3a..fe8698d 100644
--- a/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/internal/Message.java
+++ b/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/internal/Message.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/jdk/test/tools/jar/modularJar/src/bar/module-info.java b/jdk/test/tools/jar/modularJar/src/bar/module-info.java
index 7296518..84480e2 100644
--- a/jdk/test/tools/jar/modularJar/src/bar/module-info.java
+++ b/jdk/test/tools/jar/modularJar/src/bar/module-info.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/BazService.java b/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/BazService.java
index 85c585f..c443204 100644
--- a/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/BazService.java
+++ b/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/BazService.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/internal/BazServiceImpl.java b/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/internal/BazServiceImpl.java
index 5f41732..fba16b7 100644
--- a/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/internal/BazServiceImpl.java
+++ b/jdk/test/tools/jar/modularJar/src/baz/jdk/test/baz/internal/BazServiceImpl.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/jdk/test/tools/jar/modularJar/src/baz/module-info.java b/jdk/test/tools/jar/modularJar/src/baz/module-info.java
index 8a35edb..5672f74 100644
--- a/jdk/test/tools/jar/modularJar/src/baz/module-info.java
+++ b/jdk/test/tools/jar/modularJar/src/baz/module-info.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/Foo.java b/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/Foo.java
index 1cb3535..3e0ce9f 100644
--- a/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/Foo.java
+++ b/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/Foo.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -26,6 +24,8 @@
 package jdk.test.foo;
 
 import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Requires;
 import java.util.StringJoiner;
 
 import jdk.test.foo.internal.Message;
@@ -36,10 +36,30 @@
 
         ModuleDescriptor md = Foo.class.getModule().getDescriptor();
         System.out.println("nameAndVersion:" + md.toNameAndVersion());
-        System.out.println("mainClass:" + md.mainClass().get());
+        md.mainClass().ifPresent(mc -> System.out.println("mainClass:" + mc));
 
         StringJoiner sj = new StringJoiner(",");
+        md.requires().stream().map(Requires::name).sorted().forEach(sj::add);
+        System.out.println("requires:" + sj.toString());
+
+        sj = new StringJoiner(",");
+        md.exports().stream().map(Exports::source).sorted().forEach(sj::add);
+        if (!sj.toString().equals(""))
+            System.out.println("exports:" + sj.toString());
+
+        sj = new StringJoiner(",");
+        md.uses().stream().sorted().forEach(sj::add);
+        if (!sj.toString().equals(""))
+            System.out.println("uses:" + sj.toString());
+
+        sj = new StringJoiner(",");
+        md.provides().keySet().stream().sorted().forEach(sj::add);
+        if (!sj.toString().equals(""))
+            System.out.println("provides:" + sj.toString());
+
+        sj = new StringJoiner(",");
         md.conceals().forEach(sj::add);
-        System.out.println("conceals:" + sj.toString());
+        if (!sj.toString().equals(""))
+            System.out.println("conceals:" + sj.toString());
     }
 }
diff --git a/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/internal/Message.java b/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/internal/Message.java
index 298a4fc..a5959e8 100644
--- a/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/internal/Message.java
+++ b/jdk/test/tools/jar/modularJar/src/foo/jdk/test/foo/internal/Message.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/jdk/test/tools/jar/modularJar/src/foo/module-info.java b/jdk/test/tools/jar/modularJar/src/foo/module-info.java
index b46afa0..7f3e0f7 100644
--- a/jdk/test/tools/jar/modularJar/src/foo/module-info.java
+++ b/jdk/test/tools/jar/modularJar/src/foo/module-info.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/jdk/test/tools/jimage/VerifyJimage.java b/jdk/test/tools/jimage/VerifyJimage.java
index 9c33cc3..5056e63 100644
--- a/jdk/test/tools/jimage/VerifyJimage.java
+++ b/jdk/test/tools/jimage/VerifyJimage.java
@@ -188,7 +188,11 @@
                         String cn = removeModule(n).replaceAll("\\.class$", "").replace('/', '.');
                         count.incrementAndGet();
                         try {
+                            System.out.println("Loading " + cn);
                             Class.forName(cn, false, loader);
+                        } catch (VerifyError ve) {
+                            System.err.println("VerifyError for " + cn);
+                            failed.add(reader.imageName() + ": " + cn + " not verified: " + ve.getMessage());
                         } catch (ClassNotFoundException e) {
                             failed.add(reader.imageName() + ": " + cn + " not found");
                         }
diff --git a/jdk/test/tools/jlink/DefaultProviderTest.java b/jdk/test/tools/jlink/DefaultProviderTest.java
index 22c6828..c10e9d3 100644
--- a/jdk/test/tools/jlink/DefaultProviderTest.java
+++ b/jdk/test/tools/jlink/DefaultProviderTest.java
@@ -33,7 +33,7 @@
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import tests.Helper;
 
@@ -65,26 +65,26 @@
         private boolean enabled = true;
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
         @Override
-        public Set<STATE> getState() {
-             return enabled ? EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL)
-                : EnumSet.of(STATE.DISABLED);
+        public Set<State> getState() {
+             return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL)
+                : EnumSet.of(State.DISABLED);
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
             if (!enabled) {
                 throw new PluginException(NAME + " was set");
             }
 
             DefaultProviderTest.isNewPluginsCalled = true;
-            in.visit((Pool.ModuleData content) -> {
+            in.transformAndCopy(content -> {
                 return content;
             }, out);
         }
diff --git a/jdk/test/tools/jlink/ImageFileCreatorTest.java b/jdk/test/tools/jlink/ImageFileCreatorTest.java
index 449d950..8e093c6 100644
--- a/jdk/test/tools/jlink/ImageFileCreatorTest.java
+++ b/jdk/test/tools/jlink/ImageFileCreatorTest.java
@@ -39,7 +39,7 @@
 import jdk.tools.jlink.internal.ImagePluginStack;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 
 /*
@@ -47,6 +47,7 @@
  * @summary ImageFileCreator class test
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.builder
  *          java.base/jdk.internal.jimage
  * @run main/othervm -verbose:gc -Xmx1g ImageFileCreatorTest
  */
@@ -214,7 +215,7 @@
             }
 
             @Override
-            public void storeFiles(Pool content) {
+            public void storeFiles(ModulePool content) {
             }
         };
 
diff --git a/jdk/test/tools/jlink/ImageFilePoolTest.java b/jdk/test/tools/jlink/ImageFilePoolTest.java
index 7d35f9d..1ea0fad 100644
--- a/jdk/test/tools/jlink/ImageFilePoolTest.java
+++ b/jdk/test/tools/jlink/ImageFilePoolTest.java
@@ -31,11 +31,12 @@
  */
 
 import java.io.ByteArrayInputStream;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
-import jdk.tools.jlink.plugin.Pool.Visitor;
+import java.util.Optional;
+import java.util.function.Function;
+import jdk.tools.jlink.internal.ModuleEntryImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class ImageFilePoolTest {
     public static void main(String[] args) throws Exception {
@@ -50,45 +51,45 @@
     private static final String SUFFIX = "END";
 
     private void checkVisitor() throws Exception {
-        Pool input = new PoolImpl();
+        ModulePool input = new ModulePoolImpl();
         for (int i = 0; i < 1000; ++i) {
             String module = "module" + (i / 100);
             input.add(new InMemoryImageFile(module, "/" + module + "/java/class" + i,
-                    ModuleDataType.CONFIG, "class" + i));
+                    ModuleEntry.Type.CONFIG, "class" + i));
         }
-        if (input.getContent().size() != 1000) {
+        if (input.getEntryCount() != 1000) {
             throw new AssertionError();
         }
-        Pool output = new PoolImpl();
+        ModulePool output = new ModulePoolImpl();
         ResourceVisitor visitor = new ResourceVisitor();
-        input.visit(visitor, output);
+        input.transformAndCopy(visitor, output);
         if (visitor.getAmountBefore() == 0) {
             throw new AssertionError("Resources not found");
         }
-        if (visitor.getAmountBefore() != input.getContent().size()) {
+        if (visitor.getAmountBefore() != input.getEntryCount()) {
             throw new AssertionError("Number of visited resources. Expected: " +
-                    visitor.getAmountBefore() + ", got: " + input.getContent().size());
+                    visitor.getAmountBefore() + ", got: " + input.getEntryCount());
         }
-        if (visitor.getAmountAfter() != output.getContent().size()) {
+        if (visitor.getAmountAfter() != output.getEntryCount()) {
             throw new AssertionError("Number of added resources. Expected: " +
-                    visitor.getAmountAfter() + ", got: " + output.getContent().size());
+                    visitor.getAmountAfter() + ", got: " + output.getEntryCount());
         }
-        for (ModuleData outFile : output.getContent()) {
+        output.entries().forEach(outFile -> {
             String path = outFile.getPath().replaceAll(SUFFIX + "$", "");
-            ModuleData inFile = input.get(path);
-            if (inFile == null) {
+            Optional<ModuleEntry> inFile = input.findEntry(path);
+            if (!inFile.isPresent()) {
                 throw new AssertionError("Unknown resource: " + path);
             }
-        }
+        });
     }
 
-    private static class ResourceVisitor implements Visitor {
+    private static class ResourceVisitor implements Function<ModuleEntry, ModuleEntry> {
 
         private int amountBefore;
         private int amountAfter;
 
         @Override
-        public ModuleData visit(ModuleData file) {
+        public ModuleEntry apply(ModuleEntry file) {
             int index = ++amountBefore % 3;
             switch (index) {
                 case 0:
@@ -113,7 +114,7 @@
     }
 
     private void checkNegative() throws Exception {
-        PoolImpl input = new PoolImpl();
+        ModulePoolImpl input = new ModulePoolImpl();
         try {
             input.add(null);
             throw new AssertionError("NullPointerException is not thrown");
@@ -126,30 +127,30 @@
         } catch (NullPointerException e) {
             // expected
         }
-        if (input.get("unknown") != null) {
-            throw new AssertionError("ImageFilePool does not return null for unknown file");
+        if (input.findEntry("unknown").isPresent()) {
+            throw new AssertionError("ImageFileModulePool does not return null for unknown file");
         }
-        if (input.contains(new InMemoryImageFile("", "unknown", ModuleDataType.CONFIG, "unknown"))) {
+        if (input.contains(new InMemoryImageFile("", "unknown", ModuleEntry.Type.CONFIG, "unknown"))) {
             throw new AssertionError("'contain' returns true for unknown file");
         }
-        input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleDataType.CONFIG, ""));
+        input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, ""));
         try {
-            input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleDataType.CONFIG, ""));
+            input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, ""));
             throw new AssertionError("Exception expected");
         } catch (Exception e) {
             // expected
         }
         input.setReadOnly();
         try {
-            input.add(new InMemoryImageFile("", "/aaa/ccc", ModuleDataType.CONFIG, ""));
+            input.add(new InMemoryImageFile("", "/aaa/ccc", ModuleEntry.Type.CONFIG, ""));
             throw new AssertionError("Exception expected");
         } catch (Exception e) {
             // expected
         }
     }
 
-    private static class InMemoryImageFile extends ModuleData {
-        public InMemoryImageFile(String module, String path, ModuleDataType type, String content) {
+    private static class InMemoryImageFile extends ModuleEntryImpl {
+        public InMemoryImageFile(String module, String path, ModuleEntry.Type type, String content) {
             super(module, path, type, new ByteArrayInputStream(content.getBytes()), content.getBytes().length);
         }
     }
diff --git a/jdk/test/tools/jlink/IntegrationTest.java b/jdk/test/tools/jlink/IntegrationTest.java
index 951c16c..e5637b4 100644
--- a/jdk/test/tools/jlink/IntegrationTest.java
+++ b/jdk/test/tools/jlink/IntegrationTest.java
@@ -39,7 +39,7 @@
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.PostProcessorPlugin;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
@@ -56,6 +56,8 @@
  * @library ../lib
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
+ *          jdk.jlink/jdk.tools.jlink
+ *          jdk.jlink/jdk.tools.jlink.builder
  *          jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
  *          jdk.jlink/jdk.tools.jmod
@@ -88,9 +90,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.PROCESSOR);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.PROCESSOR);
             return Collections.unmodifiableSet(set);
         }
 
@@ -128,18 +130,18 @@
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
             System.err.println(NAME + index);
             ordered.add(index);
-            in.visit((file) -> {
+            in.transformAndCopy((file) -> {
                 return file;
             }, out);
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
diff --git a/jdk/test/tools/jlink/JLinkOptimTest.java b/jdk/test/tools/jlink/JLinkOptimTest.java
index 82c5431..acc089c 100644
--- a/jdk/test/tools/jlink/JLinkOptimTest.java
+++ b/jdk/test/tools/jlink/JLinkOptimTest.java
@@ -23,15 +23,15 @@
 import jdk.internal.org.objectweb.asm.tree.MethodNode;
 import jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode;
 import jdk.tools.jlink.internal.PluginRepository;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.OptimizationPlugin;
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPlugin;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
 import jdk.tools.jlink.internal.plugins.optim.ControlFlow;
 import jdk.tools.jlink.internal.plugins.optim.ControlFlow.Block;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 import tests.Helper;
 import tests.JImageGenerator;
@@ -134,9 +134,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
     }
@@ -150,13 +150,13 @@
         FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
         Path root = fs.getPath("/modules/java.base");
         // Access module-info.class to be reused as fake module-info.class
-        List<ModuleData> javabaseResources = new ArrayList<>();
+        List<ModuleEntry> javabaseResources = new ArrayList<>();
         try (Stream<Path> stream = Files.walk(root)) {
             for (Iterator<Path> iterator = stream.iterator(); iterator.hasNext();) {
                 Path p = iterator.next();
                 if (Files.isRegularFile(p)) {
                     try {
-                        javabaseResources.add(Pool.newResource(p.toString().
+                        javabaseResources.add(ModuleEntry.create(p.toString().
                                 substring("/modules".length()), Files.readAllBytes(p)));
                     } catch (Exception ex) {
                         throw new RuntimeException(ex);
@@ -166,18 +166,18 @@
         }
 
         //forName folding
-        PoolImpl pool = new PoolImpl();
+        ModulePoolImpl pool = new ModulePoolImpl();
         byte[] content = Files.readAllBytes(classes.
                 resolve("optim").resolve("ForNameTestCase.class"));
         byte[] content2 = Files.readAllBytes(classes.
                 resolve("optim").resolve("AType.class"));
         byte[] mcontent = Files.readAllBytes(classes.resolve("module-info.class"));
 
-        pool.add(Pool.newResource("/optimplugin/optim/ForNameTestCase.class", content));
-        pool.add(Pool.newResource("/optimplugin/optim/AType.class", content2));
-        pool.add(Pool.newResource("/optimplugin/module-info.class", mcontent));
+        pool.add(ModuleEntry.create("/optimplugin/optim/ForNameTestCase.class", content));
+        pool.add(ModuleEntry.create("/optimplugin/optim/AType.class", content2));
+        pool.add(ModuleEntry.create("/optimplugin/module-info.class", mcontent));
 
-        for (ModuleData r : javabaseResources) {
+        for (ModuleEntry r : javabaseResources) {
             pool.add(r);
         }
 
@@ -186,10 +186,10 @@
         optional.put(OptimizationPlugin.NAME, OptimizationPlugin.FORNAME_REMOVAL);
         optional.put(OptimizationPlugin.LOG, "forName.log");
         plugin.configure(optional);
-        Pool out = new PoolImpl();
+        ModulePool out = new ModulePoolImpl();
         plugin.visit(pool, out);
 
-        ModuleData result = out.getContent().iterator().next();
+        ModuleEntry result = out.entries().iterator().next();
 
         ClassReader optimReader = new ClassReader(result.getBytes());
         ClassNode optimClass = new ClassNode();
diff --git a/jdk/test/tools/jlink/JLinkOptionsTest.java b/jdk/test/tools/jlink/JLinkOptionsTest.java
index 8c8d241..565c58b 100644
--- a/jdk/test/tools/jlink/JLinkOptionsTest.java
+++ b/jdk/test/tools/jlink/JLinkOptionsTest.java
@@ -24,7 +24,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
@@ -62,7 +62,7 @@
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
 
         }
 
diff --git a/jdk/test/tools/jlink/JLinkPostProcessingTest.java b/jdk/test/tools/jlink/JLinkPostProcessingTest.java
index b32bf20..abc2b58 100644
--- a/jdk/test/tools/jlink/JLinkPostProcessingTest.java
+++ b/jdk/test/tools/jlink/JLinkPostProcessingTest.java
@@ -75,9 +75,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.PROCESSOR);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.PROCESSOR);
             return Collections.unmodifiableSet(set);
         }
 
diff --git a/jdk/test/tools/jlink/ResourcePoolTest.java b/jdk/test/tools/jlink/ResourcePoolTest.java
index 77a82e5..523503c 100644
--- a/jdk/test/tools/jlink/ResourcePoolTest.java
+++ b/jdk/test/tools/jlink/ResourcePoolTest.java
@@ -37,14 +37,14 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
-
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.Module;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
-import jdk.tools.jlink.plugin.Pool.Visitor;
+import java.util.function.Function;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class ResourcePoolTest {
 
@@ -61,54 +61,53 @@
     private static final String SUFFIX = "END";
 
     private void checkResourceVisitor() throws Exception {
-        Pool input = new PoolImpl();
+        ModulePool input = new ModulePoolImpl();
         for (int i = 0; i < 1000; ++i) {
             String module = "/module" + (i / 10);
             String resourcePath = module + "/java/package" + i;
             byte[] bytes = resourcePath.getBytes();
-            input.add(new ModuleData(module, resourcePath,
-                    ModuleDataType.CLASS_OR_RESOURCE,
+            input.add(ModuleEntry.create(module, resourcePath,
+                    ModuleEntry.Type.CLASS_OR_RESOURCE,
                     new ByteArrayInputStream(bytes), bytes.length));
         }
-        Pool output = new PoolImpl();
+        ModulePool output = new ModulePoolImpl();
         ResourceVisitor visitor = new ResourceVisitor();
-        input.visit(visitor, output);
+        input.transformAndCopy(visitor, output);
         if (visitor.getAmountBefore() == 0) {
             throw new AssertionError("Resources not found");
         }
-        if (visitor.getAmountBefore() != input.getContent().size()) {
+        if (visitor.getAmountBefore() != input.getEntryCount()) {
             throw new AssertionError("Number of visited resources. Expected: " +
-                    visitor.getAmountBefore() + ", got: " + input.getContent().size());
+                    visitor.getAmountBefore() + ", got: " + input.getEntryCount());
         }
-        if (visitor.getAmountAfter() != output.getContent().size()) {
+        if (visitor.getAmountAfter() != output.getEntryCount()) {
             throw new AssertionError("Number of added resources. Expected: " +
-                    visitor.getAmountAfter() + ", got: " + output.getContent().size());
+                    visitor.getAmountAfter() + ", got: " + output.getEntryCount());
         }
-        for (ModuleData outResource : output.getContent()) {
+        output.entries().forEach(outResource -> {
             String path = outResource.getPath().replaceAll(SUFFIX + "$", "");
-            ModuleData inResource = input.get(path);
-            if (inResource == null) {
+            if (!input.findEntry(path).isPresent()) {
                 throw new AssertionError("Unknown resource: " + path);
             }
-        }
+        });
     }
 
-    private static class ResourceVisitor implements Visitor {
+    private static class ResourceVisitor implements Function<ModuleEntry, ModuleEntry> {
 
         private int amountBefore;
         private int amountAfter;
 
         @Override
-        public ModuleData visit(ModuleData resource) {
+        public ModuleEntry apply(ModuleEntry resource) {
             int index = ++amountBefore % 3;
             switch (index) {
                 case 0:
                     ++amountAfter;
-                    return new ModuleData(resource.getModule(), resource.getPath() + SUFFIX,
+                    return ModuleEntry.create(resource.getModule(), resource.getPath() + SUFFIX,
                             resource.getType(), resource.stream(), resource.getLength());
                 case 1:
                     ++amountAfter;
-                    return new ModuleData(resource.getModule(), resource.getPath(),
+                    return ModuleEntry.create(resource.getModule(), resource.getPath(),
                             resource.getType(), resource.stream(), resource.getLength());
             }
             return null;
@@ -133,8 +132,8 @@
         samples.add("javax/management/ObjectName");
         test(samples, (resources, module, path) -> {
             try {
-                resources.add(new ModuleData(module, path,
-                        ModuleDataType.CLASS_OR_RESOURCE,
+                resources.add(ModuleEntry.create(module, path,
+                        ModuleEntry.Type.CLASS_OR_RESOURCE,
                         new ByteArrayInputStream(new byte[0]), 0));
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
@@ -142,12 +141,12 @@
         });
         test(samples, (resources, module, path) -> {
             try {
-                resources.add(PoolImpl.
-                        newCompressedResource(new ModuleData(module, path,
-                                ModuleDataType.CLASS_OR_RESOURCE,
+                resources.add(ModulePoolImpl.
+                        newCompressedResource(ModuleEntry.create(module, path,
+                                ModuleEntry.Type.CLASS_OR_RESOURCE,
                                 new ByteArrayInputStream(new byte[0]), 0),
                                 ByteBuffer.allocate(99), "bitcruncher", null,
-                                ((PoolImpl)resources).getStringTable(), ByteOrder.nativeOrder()));
+                                ((ModulePoolImpl)resources).getStringTable(), ByteOrder.nativeOrder()));
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
             }
@@ -158,7 +157,7 @@
         if (samples.isEmpty()) {
             throw new AssertionError("No sample to test");
         }
-        Pool resources = new PoolImpl();
+        ModulePool resources = new ModulePoolImpl();
         Set<String> modules = new HashSet<>();
         for (int i = 0; i < samples.size(); i++) {
             String module = samples.get(i);
@@ -173,70 +172,69 @@
             i++;
             String clazz = samples.get(i);
             String path = "/" + module + "/" + clazz + ".class";
-            ModuleData res = resources.get(path);
-            checkModule(resources, res);
-            if (res == null) {
+            Optional<ModuleEntry> res = resources.findEntry(path);
+            if (!res.isPresent()) {
                 throw new AssertionError("Resource not found " + path);
             }
-            ModuleData res2 = resources.get(clazz);
-            if (res2 != null) {
+            checkModule(resources, res.get());
+            if (resources.findEntry(clazz).isPresent()) {
                 throw new AssertionError("Resource found " + clazz);
             }
         }
-        if (resources.getContent().size() != samples.size() / 2) {
+        if (resources.getEntryCount() != samples.size() / 2) {
             throw new AssertionError("Invalid number of resources");
         }
     }
 
-    private void checkModule(Pool resources, ModuleData res) {
-        Module m = resources.getModule(res.getModule());
-        if (m == null) {
+    private void checkModule(ModulePool resources, ModuleEntry res) {
+        Optional<LinkModule> optMod = resources.findModule(res.getModule());
+        if (!optMod.isPresent()) {
             throw new AssertionError("No module " + res.getModule());
         }
+        LinkModule m = optMod.get();
         if (!m.getName().equals(res.getModule())) {
             throw new AssertionError("Not right module name " + res.getModule());
         }
-        if (m.get(res.getPath()) == null) {
+        if (!m.findEntry(res.getPath()).isPresent()) {
             throw new AssertionError("resource " + res.getPath()
                     + " not in module " + m.getName());
         }
     }
 
     private void checkResourcesAfterCompression() throws Exception {
-        PoolImpl resources1 = new PoolImpl();
-        ModuleData res1 = new ModuleData("module1", "/module1/toto1",
-                ModuleDataType.CLASS_OR_RESOURCE,
+        ModulePoolImpl resources1 = new ModulePoolImpl();
+        ModuleEntry res1 = ModuleEntry.create("module1", "/module1/toto1",
+                ModuleEntry.Type.CLASS_OR_RESOURCE,
                 new ByteArrayInputStream(new byte[0]), 0);
-        ModuleData res2 = new ModuleData("module2", "/module2/toto1",
-                ModuleDataType.CLASS_OR_RESOURCE,
+        ModuleEntry res2 = ModuleEntry.create("module2", "/module2/toto1",
+                ModuleEntry.Type.CLASS_OR_RESOURCE,
                 new ByteArrayInputStream(new byte[0]), 0);
         resources1.add(res1);
         resources1.add(res2);
 
         checkResources(resources1, res1, res2);
-        Pool resources2 = new PoolImpl();
-        ModuleData res3 = new ModuleData("module2", "/module2/toto1",
-                ModuleDataType.CLASS_OR_RESOURCE,
+        ModulePool resources2 = new ModulePoolImpl();
+        ModuleEntry res3 = ModuleEntry.create("module2", "/module2/toto1",
+                ModuleEntry.Type.CLASS_OR_RESOURCE,
                 new ByteArrayInputStream(new byte[7]), 7);
         resources2.add(res3);
-        resources2.add(PoolImpl.newCompressedResource(res1,
+        resources2.add(ModulePoolImpl.newCompressedResource(res1,
                 ByteBuffer.allocate(7), "zip", null, resources1.getStringTable(),
                 ByteOrder.nativeOrder()));
         checkResources(resources2, res1, res2);
     }
 
-    private void checkResources(Pool resources, ModuleData... expected) {
-        Collection<Module> ms = resources.getModules();
+    private void checkResources(ModulePool resources, ModuleEntry... expected) {
         List<String> modules = new ArrayList();
-        for(Module m : ms) {
+        resources.modules().forEach(m -> {
             modules.add(m.getName());
-        }
-        for (ModuleData res : expected) {
+        });
+        for (ModuleEntry res : expected) {
             if (!resources.contains(res)) {
                 throw new AssertionError("Resource not found: " + res);
             }
 
-            if (resources.get(res.getPath()) == null) {
+            if (!resources.findEntry(res.getPath()).isPresent()) {
                 throw new AssertionError("Resource not found: " + res);
             }
 
@@ -244,7 +242,7 @@
                 throw new AssertionError("Module not found: " + res.getModule());
             }
 
-            if (!resources.getContent().contains(res)) {
+            if (!resources.contains(res)) {
                 throw new AssertionError("Resources not found: " + res);
             }
 
@@ -260,17 +258,17 @@
             throw new AssertionError("ReadOnly resources");
         }
 
-        ((PoolImpl) resources).setReadOnly();
+        ((ModulePoolImpl) resources).setReadOnly();
         try {
-            resources.add(new ModuleData("module2",  "/module2/toto1",
-                    ModuleDataType.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0));
-            throw new AssertionError("Pool is read-only, but an exception is not thrown");
+            resources.add(ModuleEntry.create("module2",  "/module2/toto1",
+                    ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0));
+            throw new AssertionError("ModulePool is read-only, but an exception is not thrown");
         } catch (Exception ex) {
             // Expected
         }
     }
 
     interface ResourceAdder {
-        void add(Pool resources, String module, String path);
+        void add(ModulePool resources, String module, String path);
     }
 }
diff --git a/jdk/test/tools/jlink/SecurityTest.java b/jdk/test/tools/jlink/SecurityTest.java
index 9497d6f..dbf593b 100644
--- a/jdk/test/tools/jlink/SecurityTest.java
+++ b/jdk/test/tools/jlink/SecurityTest.java
@@ -25,6 +25,7 @@
  * @test
  * @summary Test JlinkPermission
  * @author Jean-Francois Denise
+ * @modules jdk.jlink/jdk.tools.jlink
  * @run main/othervm SecurityTest
  */
 
diff --git a/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java b/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java
index 6a414b5..4385534 100644
--- a/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java
+++ b/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java
@@ -55,8 +55,8 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableClassPool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableResourcePool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class AddForgetResourcesTest extends AsmPluginTestBase {
 
@@ -82,7 +82,7 @@
                 new ComboPlugin()
         };
         for (TestPlugin p : plugins) {
-            Pool out = p.visit(getPool());
+            ModulePool out = p.visit(getPool());
             p.test(getPool(), out);
         }
     }
@@ -124,7 +124,7 @@
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
             expected = globalPool.getClasses().size();
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 ClassReader reader = globalPool.getClassReader(res);
                 String className = reader.getClassName();
                 if (!className.endsWith("module-info")) {
@@ -137,14 +137,14 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) {
-            Collection<ModuleData> inClasses = extractClasses(inResources);
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) {
+            Collection<ModuleEntry> inClasses = extractClasses(inResources);
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (expected != outClasses.size()) {
                 throw new AssertionError("Classes were not added. Expected: " + expected
                         + ", got: " + outClasses.size());
             }
-            for (ModuleData in : inClasses) {
+            for (ModuleEntry in : inClasses) {
                 String path = in.getPath();
                 if (!outClasses.contains(in)) {
                     throw new AssertionError("Class not found: " + path);
@@ -153,7 +153,7 @@
                     continue;
                 }
                 String modifiedPath = path.replace(".class", SUFFIX + ".class");
-                if (!outClasses.contains(Pool.newResource(modifiedPath, new byte[0]))) {
+                if (!outClasses.contains(ModuleEntry.create(modifiedPath, new byte[0]))) {
                     throw new AssertionError("Class not found: " + modifiedPath);
                 }
             }
@@ -166,7 +166,7 @@
         public void visit() {
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 String moduleName = getModule(path);
                 AsmModulePool modulePool = pools.getModulePool(moduleName);
@@ -177,20 +177,20 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inResources = extractResources(in);
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inResources = extractResources(in);
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (2 * inResources.size() != outResources.size()) {
                 throw new AssertionError("Classes were not added. Expected: " + (2 * inResources.size())
                         + ", got: " + outResources.size());
             }
-            for (ModuleData r : inResources) {
+            for (ModuleEntry r : inResources) {
                 String path = r.getPath();
                 if (!outResources.contains(r)) {
                     throw new AssertionError("Class not found: " + path);
                 }
                 String modifiedPath = path + SUFFIX;
-                if (!outResources.contains(Pool.newResource(modifiedPath, new byte[0]))) {
+                if (!outResources.contains(ModuleEntry.create(modifiedPath, new byte[0]))) {
                     throw new AssertionError("Class not found: " + modifiedPath);
                 }
             }
@@ -204,7 +204,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 ClassReader reader = globalPool.getClassReader(res);
                 ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
                 reader.accept(new AddMethodClassVisitor(writer), ClassReader.EXPAND_FRAMES);
@@ -213,14 +213,14 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
-            Collection<ModuleData> inClasses = extractClasses(inResources);
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
+            Collection<ModuleEntry> inClasses = extractClasses(inResources);
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (inClasses.size() != outClasses.size()) {
                 throw new AssertionError("Number of classes. Expected: " + (inClasses.size())
                         + ", got: " + outClasses.size());
             }
-            for (ModuleData out : outClasses) {
+            for (ModuleEntry out : outClasses) {
                 String path = out.getPath();
                 if (!inClasses.contains(out)) {
                     throw new AssertionError("Class not found: " + path);
@@ -248,7 +248,7 @@
         public void visit() {
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 AsmModulePool modulePool = pools.getModulePool(getModule(path));
                 modulePool.getTransformedResourceFiles().addResourceFile(new ResourceFile(removeModule(path),
@@ -257,14 +257,14 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inResources = extractResources(in);
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inResources = extractResources(in);
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (inResources.size() != outResources.size()) {
                 throw new AssertionError("Number of resources. Expected: " + inResources.size()
                         + ", got: " + outResources.size());
             }
-            for (ModuleData r : outResources) {
+            for (ModuleEntry r : outResources) {
                 String path = r.getPath();
                 if (!inResources.contains(r)) {
                     throw new AssertionError("Resource not found: " + path);
@@ -287,7 +287,7 @@
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
             int i = 0;
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 String path = removeModule(res.getPath());
                 String className = path.replace(".class", "");
                 if ((i & 1) == 0 && !className.endsWith("module-info")) {
@@ -300,8 +300,8 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (expected != outClasses.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expected +
                         ", got: " + outClasses.size());
@@ -318,7 +318,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             int i = 0;
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 if (!path.contains("META-INF/services")) {
                     if ((i & 1) == 0) {
@@ -335,8 +335,8 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (expectedAmount != outResources.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expectedAmount
                         + ", got: " + outResources.size());
@@ -354,7 +354,7 @@
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
             int i = 0;
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 ClassReader reader = globalPool.getClassReader(res);
                 String className = reader.getClassName();
                 ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
@@ -374,8 +374,8 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (expected != outClasses.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expected
                         + ", got: " + outClasses.size());
@@ -392,7 +392,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             int i = 0;
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 String moduleName = getModule(path);
                 if (!path.contains("META-INF")) {
@@ -412,8 +412,8 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool out) throws Exception {
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool inResources, ModulePool out) throws Exception {
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (expectedAmount != outResources.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expectedAmount
                         + ", got: " + outResources.size());
@@ -446,7 +446,7 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
@@ -455,7 +455,7 @@
                 throw new AssertionError("Number of transformed classes not equal to expected");
             }
             // Check that only renamed classes and resource files are in the result.
-            for (ModuleData r : outResources.getContent()) {
+            outResources.entries().forEach(r -> {
                 String resourceName = r.getPath();
                 if (resourceName.endsWith(".class") && !resourceName.endsWith("module-info.class")) {
                     if (!resourceName.endsWith(SUFFIX + ".class")) {
@@ -467,7 +467,7 @@
                         throw new AssertionError("Resource file not renamed " + resourceName);
                     }
                 }
-            }
+            });
         }
 
         private void renameResources() throws IOException {
@@ -476,7 +476,7 @@
             for (Map.Entry<String, List<String>> mod : MODULES.entrySet()) {
                 String moduleName = mod.getKey();
                 AsmModulePool modulePool = pools.getModulePool(moduleName);
-                for (ModuleData res : modulePool.getResourceFiles()) {
+                for (ModuleEntry res : modulePool.getResourceFiles()) {
                     ResourceFile resFile = modulePool.getResourceFile(res);
                     if (resFile.getPath().startsWith("META-INF/services/")) {
                         String newContent = new String(resFile.getContent()) + SUFFIX;
@@ -492,7 +492,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 if (res.getPath().endsWith("module-info.class")) {
                     continue;
                 }
diff --git a/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java b/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java
index d5c0355..c51419e 100644
--- a/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java
+++ b/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java
@@ -38,23 +38,23 @@
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 
 import jdk.tools.jlink.internal.plugins.asm.AsmPlugin;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public abstract class AsmPluginTestBase {
 
     protected static final String TEST_MODULE = "jlink.test";
     protected static final Map<String, List<String>> MODULES;
 
-    private static final Predicate<ModuleData> isClass = r -> r.getPath().endsWith(".class");
+    private static final Predicate<ModuleEntry> isClass = r -> r.getPath().endsWith(".class");
     private final List<String> classes;
     private final List<String> resources;
-    private final Pool pool;
+    private final ModulePool pool;
 
     static {
         Map<String, List<String>> map = new HashMap<>();
@@ -75,7 +75,7 @@
             List<String> classes = new ArrayList<>();
             List<String> resources = new ArrayList<>();
 
-            pool = new PoolImpl();
+            pool = new ModulePoolImpl();
 
             FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
             Path root = fs.getPath("/modules");
@@ -100,7 +100,7 @@
                                     MODULES.get(module).add(toResourceFile(p));
                                 }
                                 resources.add(toPath(p.toString()));
-                                ModuleData res = Pool.newResource(toPath(p.toString()), content);
+                                ModuleEntry res = ModuleEntry.create(toPath(p.toString()), content);
                                 pool.add(res);
                             } catch (Exception ex) {
                                 throw new RuntimeException(ex);
@@ -110,17 +110,17 @@
                 }
             }
             // There is more than 10 classes in java.base...
-            if (classes.size() < 10 || pool.getContent().size() < 10) {
+            if (classes.size() < 10 || pool.getEntryCount() < 10) {
                 throw new AssertionError("Not expected resource or class number");
             }
 
             //Add a fake resource file
             String content = "java.lang.Object";
             String path = "META-INF/services/com.foo.BarProvider";
-            ModuleData resFile = Pool.newResource("/" + TEST_MODULE + "/" +
+            ModuleEntry resFile = ModuleEntry.create("/" + TEST_MODULE + "/" +
                     path, content.getBytes());
             pool.add(resFile);
-            ModuleData fakeInfoFile = Pool.newResource("/" + TEST_MODULE
+            ModuleEntry fakeInfoFile = ModuleEntry.create("/" + TEST_MODULE
                     + "/module-info.class", moduleInfos.get(0));
             pool.add(fakeInfoFile);
             MODULES.get(TEST_MODULE).add(path);
@@ -144,20 +144,20 @@
         return resources;
     }
 
-    public Pool getPool() {
+    public ModulePool getPool() {
         return pool;
     }
 
     public abstract void test() throws Exception;
 
-    public Collection<ModuleData> extractClasses(Pool pool) {
-        return pool.getContent().stream()
+    public Collection<ModuleEntry> extractClasses(ModulePool pool) {
+        return pool.entries()
                 .filter(isClass)
                 .collect(Collectors.toSet());
     }
 
-    public Collection<ModuleData> extractResources(Pool pool) {
-        return pool.getContent().stream()
+    public Collection<ModuleEntry> extractResources(ModulePool pool) {
+        return pool.entries()
                 .filter(isClass.negate())
                 .collect(Collectors.toSet());
     }
@@ -209,9 +209,9 @@
             return pools != null;
         }
 
-        public Pool visit(Pool inResources) throws IOException {
+        public ModulePool visit(ModulePool inResources) throws IOException {
             try {
-                Pool outResources = new PoolImpl(inResources.getByteOrder(), new StringTable() {
+                ModulePool outResources = new ModulePoolImpl(inResources.getByteOrder(), new StringTable() {
                     @Override
                     public int addString(String str) {
                         return -1;
@@ -239,7 +239,7 @@
         }
 
         public abstract void visit();
-        public abstract void test(Pool inResources, Pool outResources) throws Exception;
+        public abstract void test(ModulePool inResources, ModulePool outResources) throws Exception;
 
         @Override
         public String getName() {
diff --git a/jdk/test/tools/jlink/asmplugin/BasicTest.java b/jdk/test/tools/jlink/asmplugin/BasicTest.java
index 0c42d4c..afc5fd5 100644
--- a/jdk/test/tools/jlink/asmplugin/BasicTest.java
+++ b/jdk/test/tools/jlink/asmplugin/BasicTest.java
@@ -45,8 +45,8 @@
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class BasicTest extends AsmPluginTestBase {
 
@@ -61,7 +61,7 @@
     @Override
     public void test() throws Exception {
         BasicPlugin basicPlugin = new BasicPlugin(getClasses());
-        Pool res = basicPlugin.visit(getPool());
+        ModulePool res = basicPlugin.visit(getPool());
         basicPlugin.test(getPool(), res);
     }
 
@@ -107,13 +107,13 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
-            if (inResources.getContent().size() != outResources.getContent().size()) {
-                throw new AssertionError("Input size " + inResources.getContent().size() +
-                        " != to " + outResources.getContent().size());
+            if (inResources.getEntryCount() != outResources.getEntryCount()) {
+                throw new AssertionError("Input size " + inResources.getEntryCount() +
+                        " != to " + outResources.getEntryCount());
             }
         }
 
@@ -142,7 +142,7 @@
 
         private void testPools() throws IOException {
             Set<String> remain = new HashSet<>(classes);
-            for (ModuleData res : getPools().getGlobalPool().getClasses()) {
+            for (ModuleEntry res : getPools().getGlobalPool().getClasses()) {
                 ClassReader reader = getPools().getGlobalPool().getClassReader(res);
                 String className = reader.getClassName();
                 // Wrong naming of module-info.class in ASM
diff --git a/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java b/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java
index ceb2e50..416d358 100644
--- a/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java
+++ b/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java
@@ -35,14 +35,15 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassVisitor;
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.Opcodes;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableClassPool;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class IdentityPluginTest extends AsmPluginTestBase {
 
@@ -56,7 +57,7 @@
 
     public void test() throws Exception {
         IdentityPlugin asm = new IdentityPlugin();
-        Pool resourcePool = asm.visit(getPool());
+        ModulePool resourcePool = asm.visit(getPool());
         asm.test(getPool(), resourcePool);
     }
 
@@ -64,7 +65,7 @@
 
         @Override
         public void visit() {
-            for (ModuleData res : getPools().getGlobalPool().getClasses()) {
+            for (ModuleEntry res : getPools().getGlobalPool().getClasses()) {
                 if (res.getPath().endsWith("module-info.class")) {
                     continue;
                 }
@@ -77,7 +78,7 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws IOException {
+        public void test(ModulePool inResources, ModulePool outResources) throws IOException {
             if (outResources.isEmpty()) {
                 throw new AssertionError("Empty result");
             }
@@ -93,13 +94,17 @@
                     throw new AssertionError("Class not transformed " + className);
                 }
             }
-            for (ModuleData r : outResources.getContent()) {
+            outResources.entries().forEach(r -> {
                 if (r.getPath().endsWith(".class") && !r.getPath().endsWith("module-info.class")) {
-                    ClassReader reader = new ClassReader(new ByteArrayInputStream(r.getBytes()));
-                    ClassWriter w = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
-                    reader.accept(w, ClassReader.EXPAND_FRAMES);
+                    try {
+                        ClassReader reader = new ClassReader(new ByteArrayInputStream(r.getBytes()));
+                        ClassWriter w = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
+                        reader.accept(w, ClassReader.EXPAND_FRAMES);
+                    } catch (IOException exp) {
+                        throw new UncheckedIOException(exp);
+                    }
                 }
-            }
+            });
         }
 
         @Override
diff --git a/jdk/test/tools/jlink/asmplugin/NegativeTest.java b/jdk/test/tools/jlink/asmplugin/NegativeTest.java
index f95b7c6..6263fca 100644
--- a/jdk/test/tools/jlink/asmplugin/NegativeTest.java
+++ b/jdk/test/tools/jlink/asmplugin/NegativeTest.java
@@ -43,7 +43,7 @@
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.Opcodes;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.plugins.asm.AsmGlobalPool;
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
@@ -51,7 +51,7 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class NegativeTest extends AsmPluginTestBase {
     public static void main(String[] args) throws Exception {
@@ -102,7 +102,7 @@
                 }
             }
         };
-        Pool resources = new PoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
+        ModulePool resources = new ModulePoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
             @Override
             public int addString(String str) {
                 return -1;
@@ -136,7 +136,7 @@
                 action(() -> pools.fillOutputResources(null), "Output resource is null", NullPointerException.class);
             }
         };
-        Pool resources = new PoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
+        ModulePool resources = new ModulePoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
             @Override
             public int addString(String str) {
                 return -1;
diff --git a/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java b/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java
index 9453ac5..bd0a8fd 100644
--- a/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java
+++ b/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java
@@ -48,8 +48,8 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableResourcePool;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class PackageMappingTest extends AsmPluginTestBase {
 
@@ -72,7 +72,7 @@
             new PackageMappingPlugin(newFiles, true)
         };
         for (TestPlugin p : plugins) {
-            Pool pool = p.visit(getPool());
+            ModulePool pool = p.visit(getPool());
             p.test(getPool(), pool);
         }
     }
@@ -105,12 +105,12 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) {
+        public void test(ModulePool inResources, ModulePool outResources) {
             Set<String> in = getPools().getGlobalPool().getResourceFiles().stream()
-                    .map(ModuleData::getPath)
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toSet());
             Set<String> out = extractResources(outResources).stream()
-                    .map(ModuleData::getPath)
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toSet());
             in.addAll(PackageMappingTest.this.newFiles);
             if (!Objects.equals(in, out)) {
diff --git a/jdk/test/tools/jlink/asmplugin/SortingTest.java b/jdk/test/tools/jlink/asmplugin/SortingTest.java
index 0fc4c7a..26974b3 100644
--- a/jdk/test/tools/jlink/asmplugin/SortingTest.java
+++ b/jdk/test/tools/jlink/asmplugin/SortingTest.java
@@ -35,12 +35,13 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class SortingTest extends AsmPluginTestBase {
 
@@ -66,7 +67,7 @@
         List<String> sorted = new ArrayList<>(getResources());
         sorted.sort(null);
         ClassSorterPlugin sorterPlugin = new ClassSorterPlugin(sorted);
-        Pool resourcePool = sorterPlugin.visit(getPool());
+        ModulePool resourcePool = sorterPlugin.visit(getPool());
         sorterPlugin.test(getPool(), resourcePool);
     }
 
@@ -78,7 +79,7 @@
         List<String> sorted = new ArrayList<>(getResources());
         sorted.sort((s1, s2) -> -getModuleName(s1).compareTo(getModuleName(s2)));
         ModuleSorterPlugin sorterPlugin = new ModuleSorterPlugin();
-        Pool resourcePool = sorterPlugin.visit(getPool());
+        ModulePool resourcePool = sorterPlugin.visit(getPool());
         sorterPlugin.test(getPool(), resourcePool);
     }
 
@@ -88,8 +89,8 @@
         public void visit() {
             for (AsmModulePool modulePool : getPools().getModulePools()) {
                 modulePool.setSorter(resources -> {
-                    List<String> sort = resources.getContent().stream()
-                            .map(ModuleData::getPath)
+                    List<String> sort = resources.entries()
+                            .map(ModuleEntry::getPath)
                             .collect(Collectors.toList());
                     sort.sort(null);
                     return sort;
@@ -102,21 +103,21 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
-            List<String> sortedResourcePaths = outResources.getContent().stream()
-                    .map(ModuleData::getPath)
+            List<String> sortedResourcePaths = outResources.entries()
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toList());
 
             List<String> defaultResourceOrder = new ArrayList<>();
-            for (ModuleData r : inResources.getContent()) {
-                if (!inResources.getContent().contains(r)) {
+            inResources.entries().forEach(r -> {
+                if (!inResources.contains(r)) {
                     throw new AssertionError("Resource " + r.getPath() + " not in result pool");
                 }
                 defaultResourceOrder.add(r.getPath());
-            }
+            });
             // Check that default sorting is not equal to sorted one
             if (defaultResourceOrder.equals(sortedResourcePaths)) {
                 throw new AssertionError("Sorting not applied, default ordering");
@@ -147,27 +148,28 @@
         public void visit() {
             getPools().getGlobalPool().setSorter(
                     (resources) -> expectedClassesOrder.stream()
-                            .map(resources::get)
-                            .map(ModuleData::getPath)
+                            .map(resources::findEntry)
+                            .map(Optional::get)
+                            .map(ModuleEntry::getPath)
                             .collect(Collectors.toList()));
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
-            List<String> sortedResourcePaths = outResources.getContent().stream()
-                    .map(ModuleData::getPath)
+            List<String> sortedResourcePaths = outResources.entries()
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toList());
 
             List<String> defaultResourceOrder = new ArrayList<>();
-            for (ModuleData r : getPool().getContent()) {
-                if (!getPool().getContent().contains(r)) {
+            getPool().entries().forEach(r -> {
+                if (!getPool().contains(r)) {
                     throw new AssertionError("Resource " + r.getPath() + " not in result pool");
                 }
                 defaultResourceOrder.add(r.getPath());
-            }
+            });
             // Check that default sorting is not equal to sorted one
             if (defaultResourceOrder.equals(sortedResourcePaths)) {
                 throw new AssertionError("Sorting not applied, default ordering");
diff --git a/jdk/test/tools/jlink/asmplugin/VisitorTest.java b/jdk/test/tools/jlink/asmplugin/VisitorTest.java
index 1b278a8..500d415 100644
--- a/jdk/test/tools/jlink/asmplugin/VisitorTest.java
+++ b/jdk/test/tools/jlink/asmplugin/VisitorTest.java
@@ -46,8 +46,8 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFileVisitor;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class VisitorTest extends AsmPluginTestBase {
 
@@ -69,7 +69,7 @@
         };
         for (TestPlugin p : plugins) {
             System.err.println("Testing: " + p.getName());
-            Pool out = p.visit(getPool());
+            ModulePool out = p.visit(getPool());
             p.test(getPool(), out);
         }
     }
@@ -149,15 +149,15 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inClasses = getPool.apply(getPools()).getClasses();
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inClasses = getPool.apply(getPools()).getClasses();
             if (inClasses.size() != classReaderVisitor.getAmount()) {
                 throw new AssertionError("Testing " + name + ". Number of visited classes. Expected: " +
                         inClasses.size() + ", got: " + classReaderVisitor.getAmount());
             }
-            Collection<ModuleData> outClasses = extractClasses(out);
+            Collection<ModuleEntry> outClasses = extractClasses(out);
             int changedClasses = 0;
-            for (ModuleData r : outClasses) {
+            for (ModuleEntry r : outClasses) {
                 if (r.getPath().endsWith("Changed.class")) {
                     ++changedClasses;
                 }
@@ -192,15 +192,15 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inResources = getPool.apply(getPools()).getResourceFiles();
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inResources = getPool.apply(getPools()).getResourceFiles();
             if (inResources.size() != resourceFileVisitor.getAmount()) {
                 throw new AssertionError("Testing " + name + ". Number of visited resources. Expected: " +
                         inResources.size() + ", got: " + resourceFileVisitor.getAmount());
             }
-            Collection<ModuleData> outResources = extractResources(out);
+            Collection<ModuleEntry> outResources = extractResources(out);
             int changedClasses = 0;
-            for (ModuleData r : outResources) {
+            for (ModuleEntry r : outResources) {
                 if (r.getPath().endsWith("Changed")) {
                     ++changedClasses;
                 }
diff --git a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java
index 38054ec..781039a 100644
--- a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java
+++ b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java
@@ -26,7 +26,9 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
+import java.util.function.Function;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class CustomPlugin implements TransformerPlugin {
@@ -37,13 +39,8 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit(new Pool.Visitor() {
-            @Override
-            public Pool.ModuleData visit(Pool.ModuleData content) {
-                return content;
-            }
-        }, out);
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy(Function.identity(), out);
     }
 
     @Override
@@ -61,9 +58,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.PROCESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.PROCESSOR);
         return Collections.unmodifiableSet(set);
     }
 }
diff --git a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java
index d06f990..aa15035 100644
--- a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java
+++ b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java
@@ -29,8 +29,8 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -49,23 +49,23 @@
     }
 
     @Override
-    public void visit(Pool inResources, Pool outResources) {
+    public void visit(ModulePool inResources, ModulePool outResources) {
         try {
             System.out.println("Hello!!!!!!!!!!");
             File f = new File(OUTPUT_FILE);
             f.createNewFile();
-            for (ModuleData res : inResources.getContent()) {
+            inResources.entries().forEach(res -> {
                 outResources.add(res);
-            }
+            });
         } catch (IOException ex) {
             throw new UncheckedIOException(ex);
         }
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 
diff --git a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java
index cd01b93..d37bf1b 100644
--- a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java
@@ -53,14 +53,14 @@
 import jdk.internal.jimage.decompressor.ResourceDecompressorFactory;
 import jdk.internal.jimage.decompressor.StringSharingDecompressorFactory;
 import jdk.internal.jimage.decompressor.ZipDecompressorFactory;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
 import jdk.tools.jlink.internal.plugins.StringSharingPlugin;
 import jdk.tools.jlink.internal.plugins.ZipPlugin;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class CompressorPluginTest {
@@ -86,7 +86,7 @@
                     new ZipDecompressorFactory()
                 });
 
-        Pool classes = gatherClasses(javabase);
+        ModulePool classes = gatherClasses(javabase);
         // compress = String sharing
         checkCompress(classes, new StringSharingPlugin(), null,
                 new ResourceDecompressorFactory[]{
@@ -173,8 +173,8 @@
                 Collections.singletonList(".*IOException.class"));
     }
 
-    private Pool gatherResources(Path module) throws Exception {
-        Pool pool = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+    private ModulePool gatherResources(Path module) throws Exception {
+        ModulePool pool = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
 
             @Override
             public int addString(String str) {
@@ -191,15 +191,15 @@
                 Path p = iterator.next();
                 if (Files.isRegularFile(p)) {
                     byte[] content = Files.readAllBytes(p);
-                    pool.add(Pool.newResource(p.toString(), content));
+                    pool.add(ModuleEntry.create(p.toString(), content));
                 }
             }
         }
         return pool;
     }
 
-    private Pool gatherClasses(Path module) throws Exception {
-        Pool pool = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+    private ModulePool gatherClasses(Path module) throws Exception {
+        ModulePool pool = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
 
             @Override
             public int addString(String str) {
@@ -216,27 +216,27 @@
                 Path p = iterator.next();
                 if (Files.isRegularFile(p) && p.toString().endsWith(".class")) {
                     byte[] content = Files.readAllBytes(p);
-                    pool.add(Pool.newResource(p.toString(), content));
+                    pool.add(ModuleEntry.create(p.toString(), content));
                 }
             }
         }
         return pool;
     }
 
-    private void checkCompress(Pool resources, Plugin prov,
+    private void checkCompress(ModulePool resources, Plugin prov,
             Properties config,
             ResourceDecompressorFactory[] factories) throws Exception {
         checkCompress(resources, prov, config, factories, Collections.emptyList(), Collections.emptyList());
     }
 
-    private void checkCompress(Pool resources, Plugin prov,
+    private void checkCompress(ModulePool resources, Plugin prov,
             Properties config,
             ResourceDecompressorFactory[] factories,
             List<String> includes,
             List<String> excludes) throws Exception {
-        long original = 0;
-        long compressed = 0;
-        for (ModuleData resource : resources.getContent()) {
+        long[] original = new long[1];
+        long[] compressed = new long[1];
+        resources.entries().forEach(resource -> {
             List<Pattern> includesPatterns = includes.stream()
                     .map(Pattern::compile)
                     .collect(Collectors.toList());
@@ -252,7 +252,7 @@
             }
             prov.configure(props);
             final Map<Integer, String> strings = new HashMap<>();
-            PoolImpl inputResources = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+            ModulePoolImpl inputResources = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
                 @Override
                 public int addString(String str) {
                     int id = strID;
@@ -267,32 +267,32 @@
                 }
             });
             inputResources.add(resource);
-            Pool compressedResources = applyCompressor(prov, inputResources, resource, includesPatterns, excludesPatterns);
-            original += resource.getLength();
-            compressed += compressedResources.get(resource.getPath()).getLength();
+            ModulePool compressedResources = applyCompressor(prov, inputResources, resource, includesPatterns, excludesPatterns);
+            original[0] += resource.getLength();
+            compressed[0] += compressedResources.findEntry(resource.getPath()).get().getLength();
             applyDecompressors(factories, inputResources, compressedResources, strings, includesPatterns, excludesPatterns);
-        }
+        });
         String compressors = Stream.of(factories)
                 .map(Object::getClass)
                 .map(Class::getSimpleName)
                 .collect(Collectors.joining(", "));
-        String size = "Compressed size: " + compressed + ", original size: " + original;
+        String size = "Compressed size: " + compressed[0] + ", original size: " + original[0];
         System.out.println("Used " + compressors + ". " + size);
-        if (original <= compressed) {
+        if (original[0] <= compressed[0]) {
             throw new AssertionError("java.base not compressed.");
         }
     }
 
-    private Pool applyCompressor(Plugin plugin,
-            PoolImpl inputResources,
-            ModuleData res,
+    private ModulePool applyCompressor(Plugin plugin,
+            ModulePoolImpl inputResources,
+            ModuleEntry res,
             List<Pattern> includesPatterns,
-            List<Pattern> excludesPatterns) throws Exception {
+            List<Pattern> excludesPatterns) {
         TransformerPlugin compressor = (TransformerPlugin) plugin;
-        Pool compressedPool = new PoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable());
-        compressor.visit(inputResources, compressedPool);
+        ModulePool compressedModulePool = new ModulePoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable());
+        compressor.visit(inputResources, compressedModulePool);
         String path = res.getPath();
-        ModuleData compressed = compressedPool.get(path);
+        ModuleEntry compressed = compressedModulePool.findEntry(path).get();
         CompressedResourceHeader header
                 = CompressedResourceHeader.readFromResource(ByteOrder.nativeOrder(), compressed.getBytes());
         if (isIncluded(includesPatterns, excludesPatterns, path)) {
@@ -310,29 +310,33 @@
         } else if (header != null) {
             throw new AssertionError("Path should not be compressed: " + path);
         }
-        return compressedPool;
+        return compressedModulePool;
     }
 
     private void applyDecompressors(ResourceDecompressorFactory[] decompressors,
-            Pool inputResources,
-            Pool compressedResources,
+            ModulePool inputResources,
+            ModulePool compressedResources,
             Map<Integer, String> strings,
             List<Pattern> includesPatterns,
-            List<Pattern> excludesPatterns) throws Exception {
-        for (ModuleData compressed : compressedResources.getContent()) {
+            List<Pattern> excludesPatterns) {
+        compressedResources.entries().forEach(compressed -> {
             CompressedResourceHeader header = CompressedResourceHeader.readFromResource(
                     ByteOrder.nativeOrder(), compressed.getBytes());
             String path = compressed.getPath();
-            ModuleData orig = inputResources.get(path);
+            ModuleEntry orig = inputResources.findEntry(path).get();
             if (!isIncluded(includesPatterns, excludesPatterns, path)) {
-                continue;
+                return;
             }
             byte[] decompressed = compressed.getBytes();
             for (ResourceDecompressorFactory factory : decompressors) {
-                ResourceDecompressor decompressor = factory.newDecompressor(new Properties());
-                decompressed = decompressor.decompress(
+                try {
+                    ResourceDecompressor decompressor = factory.newDecompressor(new Properties());
+                    decompressed = decompressor.decompress(
                         strings::get, decompressed,
                         CompressedResourceHeader.getSize(), header.getUncompressedSize());
+                } catch (Exception exp) {
+                    throw new RuntimeException(exp);
+                }
             }
 
             if (decompressed.length != orig.getLength()) {
@@ -345,7 +349,7 @@
                     throw new AssertionError("Decompressed and original differ at index " + i);
                 }
             }
-        }
+        });
     }
 
     private boolean isIncluded(List<Pattern> includesPatterns, List<Pattern> excludesPatterns, String path) {
diff --git a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java
index cde83aa..744d7a2 100644
--- a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java
@@ -35,12 +35,11 @@
 import java.nio.file.Files;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class ExcludeFilesPluginTest {
@@ -73,20 +72,20 @@
         prop.put(ExcludeFilesPlugin.NAME, s);
         ExcludeFilesPlugin fplug = new ExcludeFilesPlugin();
         fplug.configure(prop);
-        PoolImpl files = new PoolImpl();
-        PoolImpl fresult = new PoolImpl();
-        ModuleData f = Pool.newImageFile(module, "/" + module + "/" + sample,
-                ModuleDataType.CONFIG, new ByteArrayInputStream(new byte[0]), 0);
+        ModulePoolImpl files = new ModulePoolImpl();
+        ModulePoolImpl fresult = new ModulePoolImpl();
+        ModuleEntry f = ModuleEntry.create(module, "/" + module + "/" + sample,
+                ModuleEntry.Type.CONFIG, new ByteArrayInputStream(new byte[0]), 0);
         files.add(f);
 
         fplug.visit(files, fresult);
 
         if (exclude) {
-            if (fresult.getContent().contains(f)) {
+            if (fresult.contains(f)) {
                 throw new Exception(sample + " should be excluded by " + s);
             }
         } else {
-            if (!fresult.getContent().contains(f)) {
+            if (!fresult.contains(f)) {
                 throw new Exception(sample + " shouldn't be excluded by " + s);
             }
         }
diff --git a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java
index 0f50807..c39e738 100644
--- a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java
+++ b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java
@@ -34,11 +34,11 @@
 import java.nio.file.Files;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 import jdk.tools.jlink.internal.plugins.ExcludePlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class ExcludePluginTest {
 
@@ -75,17 +75,17 @@
         prop.put(ExcludePlugin.NAME, s);
         ExcludePlugin excludePlugin = new ExcludePlugin();
         excludePlugin.configure(prop);
-        Pool resources = new PoolImpl();
-        ModuleData resource = Pool.newResource(sample, new byte[0]);
+        ModulePool resources = new ModulePoolImpl();
+        ModuleEntry resource = ModuleEntry.create(sample, new byte[0]);
         resources.add(resource);
-        Pool result = new PoolImpl();
+        ModulePool result = new ModulePoolImpl();
         excludePlugin.visit(resources, result);
         if (exclude) {
-            if (result.getContent().contains(resource)) {
+            if (result.contains(resource)) {
                 throw new AssertionError(sample + " should be excluded by " + s);
             }
         } else {
-            if (!result.getContent().contains(resource)) {
+            if (!result.contains(resource)) {
                 throw new AssertionError(sample + " shouldn't be excluded by " + s);
             }
         }
diff --git a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java
index 701368c..edc1070 100644
--- a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java
@@ -32,13 +32,12 @@
 import java.io.ByteArrayInputStream;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 import jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class ExcludeVMPluginTest {
@@ -165,14 +164,14 @@
     private void doCheckVM(String vm, String[] input, String jvmcfg, String[] expectedOutput, String expectdJvmCfg) throws Exception {
         // Create a pool with jvm.cfg and the input paths.
         byte[] jvmcfgContent = jvmcfg.getBytes();
-        Pool pool = new PoolImpl();
-        pool.add(Pool.newImageFile("java.base", "/java.base/native/jvm.cfg",
-                ModuleDataType.NATIVE_LIB, new ByteArrayInputStream(jvmcfgContent), jvmcfgContent.length));
+        ModulePool pool = new ModulePoolImpl();
+        pool.add(ModuleEntry.create("java.base", "/java.base/native/jvm.cfg",
+                ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(jvmcfgContent), jvmcfgContent.length));
         for (String in : input) {
-            pool.add(Pool.newImageFile("java.base", in,
-                    ModuleDataType.NATIVE_LIB, new ByteArrayInputStream(new byte[0]), 0));
+            pool.add(ModuleEntry.create("java.base", in,
+                    ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(new byte[0]), 0));
         }
-        Pool out = new PoolImpl();
+        ModulePool out = new ModulePoolImpl();
 
         TransformerPlugin p = new ExcludeVMPlugin();
         Map<String, String> config = new HashMap<>();
@@ -182,22 +181,22 @@
         p.configure(config);
         p.visit(pool, out);
 
-        String newContent = new String(out.get("/java.base/native/jvm.cfg").stream().readAllBytes());
+        String newContent = new String(out.findEntry("/java.base/native/jvm.cfg").get().stream().readAllBytes());
 
         if (!expectdJvmCfg.equals(newContent)) {
             throw new Exception("Got content " + newContent + " expected " + expectdJvmCfg);
         }
 
-        if (out.getContent().size() != (expectedOutput.length + 1)) {
-            for (ModuleData m : out.getContent()) {
+        if (out.getEntryCount() != (expectedOutput.length + 1)) {
+            out.entries().forEach(m -> {
                 System.err.println(m.getPath());
-            }
-            throw new Exception("Invalid output size " + out.getContent().size() + " expected " + (expectedOutput.length + 1));
+            });
+            throw new Exception("Invalid output size " + out.getEntryCount() + " expected " + (expectedOutput.length + 1));
         }
 
-        for (ModuleData md : out.getContent()) {
+        out.entries().forEach(md -> {
             if (md.getPath().equals("/java.base/native/jvm.cfg")) {
-                continue;
+                return;
             }
             boolean contained = false;
             for (String o : expectedOutput) {
@@ -207,9 +206,9 @@
                 }
             }
             if (!contained) {
-                throw new Exception(md.getPath() + " not expected");
+                throw new RuntimeException(md.getPath() + " not expected");
             }
-        }
+        });
 
     }
 
diff --git a/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java b/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java
index 5fecfec..a6fb749 100644
--- a/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java
@@ -26,6 +26,7 @@
  * @summary Test files copy plugin
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.builder
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
  * @run main FileCopierPluginTest
  */
@@ -36,13 +37,12 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 
 import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class FileCopierPluginTest {
 
@@ -85,21 +85,20 @@
         Map<String, String> conf = new HashMap<>();
         conf.put(FileCopierPlugin.NAME, builder.toString());
         plug.configure(conf);
-        Pool pool = new PoolImpl();
-        plug.visit(new PoolImpl(), pool);
-        if (pool.getContent().size() != expected) {
+        ModulePool pool = new ModulePoolImpl();
+        plug.visit(new ModulePoolImpl(), pool);
+        if (pool.getEntryCount() != expected) {
             throw new AssertionError("Wrong number of added files");
         }
-        for (ModuleData f : pool.getContent()) {
-            if (!f.getType().equals(ModuleDataType.OTHER)) {
+        pool.entries().forEach(f -> {
+            if (!f.getType().equals(ModuleEntry.Type.OTHER)) {
                 throw new AssertionError("Invalid type " + f.getType()
                         + " for file " + f.getPath());
             }
             if (f.stream() == null) {
                 throw new AssertionError("Null stream for file " + f.getPath());
             }
-
-        }
+        });
         Path root = new File(".").toPath();
         DefaultImageBuilder imgbuilder = new DefaultImageBuilder(root);
         imgbuilder.storeFiles(pool);
diff --git a/jdk/test/tools/jlink/plugins/LastSorterTest.java b/jdk/test/tools/jlink/plugins/LastSorterTest.java
index 100ca1e..0dc27b4 100644
--- a/jdk/test/tools/jlink/plugins/LastSorterTest.java
+++ b/jdk/test/tools/jlink/plugins/LastSorterTest.java
@@ -26,6 +26,7 @@
  * @summary Test last sorter property
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink
  * @run main/othervm LastSorterTest
  */
 
@@ -40,12 +41,12 @@
 import jdk.tools.jlink.internal.ImagePluginConfiguration;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.internal.ImagePluginStack;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class LastSorterTest {
@@ -80,7 +81,7 @@
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
 
         // check order
-        PoolImpl res = fillOutResourcePool();
+        ModulePoolImpl res = fillOutResourceModulePool();
 
         try {
             stack.visitResources(res);
@@ -91,18 +92,18 @@
         }
     }
 
-    private PoolImpl fillOutResourcePool() throws Exception {
-        PoolImpl res = new PoolImpl();
-        res.add(Pool.newResource("/eee/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/aaaa/bbb/res2.class", new byte[90]));
-        res.add(Pool.newResource("/bbb/aa/res1.class", new byte[90]));
-        res.add(Pool.newResource("/aaaa/bbb/res3.class", new byte[90]));
-        res.add(Pool.newResource("/bbb/aa/res2.class", new byte[90]));
-        res.add(Pool.newResource("/fff/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/aaaa/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/bbb/aa/res3.class", new byte[90]));
-        res.add(Pool.newResource("/ccc/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/ddd/bbb/res1.class", new byte[90]));
+    private ModulePoolImpl fillOutResourceModulePool() throws Exception {
+        ModulePoolImpl res = new ModulePoolImpl();
+        res.add(ModuleEntry.create("/eee/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/aaaa/bbb/res2.class", new byte[90]));
+        res.add(ModuleEntry.create("/bbb/aa/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/aaaa/bbb/res3.class", new byte[90]));
+        res.add(ModuleEntry.create("/bbb/aa/res2.class", new byte[90]));
+        res.add(ModuleEntry.create("/fff/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/aaaa/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/bbb/aa/res3.class", new byte[90]));
+        res.add(ModuleEntry.create("/ccc/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/ddd/bbb/res1.class", new byte[90]));
         return res;
     }
 
@@ -124,7 +125,7 @@
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
 
         // check order
-        PoolImpl res = fillOutResourcePool();
+        ModulePoolImpl res = fillOutResourceModulePool();
 
         stack.visitResources(res);
     }
@@ -159,7 +160,7 @@
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
 
         // check order
-        PoolImpl res = fillOutResourcePool();
+        ModulePoolImpl res = fillOutResourceModulePool();
         try {
             stack.visitResources(res);
             throw new AssertionError("Order was changed after the last sorter, but no exception occurred");
@@ -178,17 +179,17 @@
         }
 
         @Override
-        public void visit(Pool resources, Pool output) {
-            List<ModuleData> paths = new ArrayList<>();
-            for (ModuleData res : resources.getContent()) {
+        public void visit(ModulePool resources, ModulePool output) {
+            List<ModuleEntry> paths = new ArrayList<>();
+            resources.entries().forEach(res -> {
                 if (res.getPath().startsWith(starts)) {
                     paths.add(0, res);
                 } else {
                     paths.add(res);
                 }
-            }
+            });
 
-            for (ModuleData r : paths) {
+            for (ModuleEntry r : paths) {
                 output.add(r);
             }
         }
@@ -199,9 +200,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
diff --git a/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java b/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java
index cbf4186..7017361 100644
--- a/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java
@@ -36,11 +36,12 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import java.util.stream.Collectors;
 
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.OrderResourcesPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class OrderResourcesPluginTest {
@@ -50,52 +51,52 @@
     }
 
     public void test() throws Exception {
-        ModuleData[] array = {
-                Pool.newResource("/module1/toto1.class", new byte[0]),
-                Pool.newResource("/module2/toto2.class", new byte[0]),
-                Pool.newResource("/module3/toto3.class", new byte[0]),
-                Pool.newResource("/module3/toto3/module-info.class", new byte[0]),
-                Pool.newResource("/zazou/toto.class", new byte[0]),
-                Pool.newResource("/module4/zazou.class", new byte[0]),
-                Pool.newResource("/module5/toto5.class", new byte[0]),
-                Pool.newResource("/module6/toto6/module-info.class", new byte[0])
+        ModuleEntry[] array = {
+                ModuleEntry.create("/module1/toto1.class", new byte[0]),
+                ModuleEntry.create("/module2/toto2.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]),
+                ModuleEntry.create("/zazou/toto.class", new byte[0]),
+                ModuleEntry.create("/module4/zazou.class", new byte[0]),
+                ModuleEntry.create("/module5/toto5.class", new byte[0]),
+                ModuleEntry.create("/module6/toto6/module-info.class", new byte[0])
         };
 
-        ModuleData[] sorted = {
-                Pool.newResource("/zazou/toto.class", new byte[0]),
-                Pool.newResource("/module3/toto3/module-info.class", new byte[0]),
-                Pool.newResource("/module6/toto6/module-info.class", new byte[0]),
-                Pool.newResource("/module1/toto1.class", new byte[0]),
-                Pool.newResource("/module2/toto2.class", new byte[0]),
-                Pool.newResource("/module3/toto3.class", new byte[0]),
-                Pool.newResource("/module4/zazou.class", new byte[0]),
-                Pool.newResource("/module5/toto5.class", new byte[0])
+        ModuleEntry[] sorted = {
+                ModuleEntry.create("/zazou/toto.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]),
+                ModuleEntry.create("/module6/toto6/module-info.class", new byte[0]),
+                ModuleEntry.create("/module1/toto1.class", new byte[0]),
+                ModuleEntry.create("/module2/toto2.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3.class", new byte[0]),
+                ModuleEntry.create("/module4/zazou.class", new byte[0]),
+                ModuleEntry.create("/module5/toto5.class", new byte[0])
         };
 
-        ModuleData[] sorted2 = {
-            Pool.newResource("/module5/toto5.class", new byte[0]),
-            Pool.newResource("/module6/toto6/module-info.class", new byte[0]),
-            Pool.newResource("/module4/zazou.class", new byte[0]),
-            Pool.newResource("/module3/toto3.class", new byte[0]),
-            Pool.newResource("/module3/toto3/module-info.class", new byte[0]),
-            Pool.newResource("/module1/toto1.class", new byte[0]),
-            Pool.newResource("/module2/toto2.class", new byte[0]),
-            Pool.newResource("/zazou/toto.class", new byte[0])
+        ModuleEntry[] sorted2 = {
+            ModuleEntry.create("/module5/toto5.class", new byte[0]),
+            ModuleEntry.create("/module6/toto6/module-info.class", new byte[0]),
+            ModuleEntry.create("/module4/zazou.class", new byte[0]),
+            ModuleEntry.create("/module3/toto3.class", new byte[0]),
+            ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]),
+            ModuleEntry.create("/module1/toto1.class", new byte[0]),
+            ModuleEntry.create("/module2/toto2.class", new byte[0]),
+            ModuleEntry.create("/zazou/toto.class", new byte[0])
         };
 
-        Pool resources = new PoolImpl();
-        for (ModuleData r : array) {
+        ModulePool resources = new ModulePoolImpl();
+        for (ModuleEntry r : array) {
             resources.add(r);
         }
 
         {
-            Pool out = new PoolImpl();
+            ModulePool out = new ModulePoolImpl();
             Map<String, String> config = new HashMap<>();
             config.put(OrderResourcesPlugin.NAME, "/zazou/*,*/module-info.class");
             TransformerPlugin p = new OrderResourcesPlugin();
             p.configure(config);
             p.visit(resources, out);
-            check(out.getContent(), sorted);
+            check(out.entries().collect(Collectors.toList()), sorted);
         }
 
         {
@@ -112,26 +113,26 @@
             }
             Files.write(order.toPath(), builder.toString().getBytes());
 
-            Pool out = new PoolImpl();
+            ModulePool out = new ModulePoolImpl();
             Map<String, String> config = new HashMap<>();
             config.put(OrderResourcesPlugin.NAME, "@" + order.getAbsolutePath());
             TransformerPlugin p = new OrderResourcesPlugin();
             p.configure(config);
             p.visit(resources, out);
-            check(out.getContent(), sorted2);
+            check(out.entries().collect(Collectors.toList()), sorted2);
 
         }
     }
 
-    private void check(Collection<ModuleData> outResources,
-            ModuleData[] sorted) {
+    private void check(Collection<ModuleEntry> outResources,
+            ModuleEntry[] sorted) {
         if (outResources.size() != sorted.length) {
             throw new AssertionError("Wrong number of resources:\n"
                     + "expected: " + Arrays.toString(sorted) + ",\n"
                     + "     got: " + outResources);
         }
         int i = 0;
-        for (ModuleData r : outResources) {
+        for (ModuleEntry r : outResources) {
             System.err.println("Resource: " + r);
             if (!sorted[i].getPath().equals(r.getPath())) {
                 throw new AssertionError("Resource not properly sorted, difference at: " + i + "\n"
diff --git a/jdk/test/tools/jlink/plugins/PluginOrderTest.java b/jdk/test/tools/jlink/plugins/PluginOrderTest.java
index 42655d4..4c9f2c2 100644
--- a/jdk/test/tools/jlink/plugins/PluginOrderTest.java
+++ b/jdk/test/tools/jlink/plugins/PluginOrderTest.java
@@ -44,8 +44,8 @@
 
 import jdk.tools.jlink.internal.PluginOrderingGraph;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class PluginOrderTest {
@@ -96,8 +96,8 @@
         set.add("plug2");
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(new Plug("plug2", Collections.emptySet(), Collections.emptySet(),
-                CATEGORY.TRANSFORMER));
-        plugins.add(new Plug("plug1", set, Collections.emptySet(), CATEGORY.TRANSFORMER));
+                Category.TRANSFORMER));
+        plugins.add(new Plug("plug1", set, Collections.emptySet(), Category.TRANSFORMER));
         List<Plugin> ordered = PluginOrderingGraph.sort(plugins);
         if (ordered.get(0) != plugins.get(1) || ordered.get(1) != plugins.get(0)) {
             throw new Exception("Invalid sorting");
@@ -108,32 +108,32 @@
         Set<String> lst1 = new HashSet<>();
         lst1.add("plug2");
         lst1.add("plug3");
-        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst3 = new HashSet<>();
         lst3.add("plug4");
         lst3.add("plug6");
-        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst5 = new HashSet<>();
         lst5.add("plug3");
         lst5.add("plug1");
         lst5.add("plug2");
         lst5.add("plug6");
-        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst6 = new HashSet<>();
         lst6.add("plug4");
         lst6.add("plug2");
-        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(p1);
@@ -153,11 +153,11 @@
         set2.add("plug1");
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(new Plug("plug2", set2, Collections.emptySet(),
-                CATEGORY.TRANSFORMER));
+                Category.TRANSFORMER));
 
         Set<String> set1 = new HashSet<>();
         set1.add("plug2");
-        plugins.add(new Plug("plug1", set1, Collections.emptySet(), CATEGORY.TRANSFORMER));
+        plugins.add(new Plug("plug1", set1, Collections.emptySet(), Category.TRANSFORMER));
         PluginOrderingGraph.sort(plugins);
 
     }
@@ -166,31 +166,31 @@
         Set<String> lst1 = new HashSet<>();
         lst1.add("plug2");
         lst1.add("plug3");
-        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst3 = new HashSet<>();
         lst3.add("plug4");
         lst3.add("plug6");
-        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst5 = new HashSet<>();
         lst5.add("plug3");
         lst5.add("plug1");
         lst5.add("plug2");
-        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst6 = new HashSet<>();
         lst6.add("plug4");
         lst6.add("plug1");
-        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(p1);
@@ -208,8 +208,8 @@
         Set<String> lst1 = new HashSet<>();
         lst1.add("plug2");
         lst1.add("plug3");
-        Plugin p = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER);
-        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
+        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst3 = new HashSet<>();
         lst3.add("plug2");
@@ -217,7 +217,7 @@
         Set<String> lst4 = new HashSet<>();
         lst4.add("plug1");
 
-        Plugin p3 = new Plug("plug3", lst4, lst3, CATEGORY.TRANSFORMER);
+        Plugin p3 = new Plug("plug3", lst4, lst3, Category.TRANSFORMER);
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(p);
         plugins.add(p2);
@@ -229,10 +229,10 @@
 
         private final Set<String> isBefore;
         private final Set<String> isAfter;
-        private final CATEGORY category;
+        private final Category category;
         private final String name;
 
-        private Plug(String name, Set<String> isBefore, Set<String> isAfter, CATEGORY category) {
+        private Plug(String name, Set<String> isBefore, Set<String> isAfter, Category category) {
             this.name = name;
             this.isBefore = isBefore;
             this.isAfter = isAfter;
@@ -255,12 +255,12 @@
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
 
         }
 
         @Override
-        public Set<PluginType> getType() {
+        public Set<Category> getType() {
             return Collections.singleton(category);
         }
 
diff --git a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java
index 525fb0b..5b8ed2d 100644
--- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java
+++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java
@@ -26,6 +26,7 @@
  * @summary Negative test for ImagePluginStack.
  * @author Andrei Eremeev
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink
  * @run main/othervm PluginsNegativeTest
  */
 import java.lang.reflect.Layer;
@@ -39,11 +40,12 @@
 import jdk.tools.jlink.internal.ImagePluginConfiguration;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.internal.ImagePluginStack;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class PluginsNegativeTest {
@@ -96,8 +98,8 @@
         plugins.add(createPlugin("plugin"));
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new PluginsConfiguration(plugins,
                 null, null));
-        PoolImpl inResources = new PoolImpl();
-        inResources.add(Pool.newResource("/aaa/bbb/A", new byte[10]));
+        ModulePoolImpl inResources = new ModulePoolImpl();
+        inResources.add(ModuleEntry.create("/aaa/bbb/A", new byte[10]));
         try {
             stack.visitResources(inResources);
             throw new AssertionError("Exception expected when output resource is empty");
@@ -110,8 +112,8 @@
         plugins.add(createPlugin("plugin"));
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new PluginsConfiguration(plugins,
                 null, null));
-        PoolImpl inResources = new PoolImpl();
-        PoolImpl outResources = (PoolImpl) stack.visitResources(inResources);
+        ModulePoolImpl inResources = new ModulePoolImpl();
+        ModulePoolImpl outResources = (ModulePoolImpl) stack.visitResources(inResources);
         if (!outResources.isEmpty()) {
             throw new AssertionError("Output resource is not empty");
         }
@@ -126,7 +128,7 @@
         }
 
         @Override
-        public void visit(Pool inResources, Pool outResources) {
+        public void visit(ModulePool inResources, ModulePool outResources) {
             // do nothing
         }
 
@@ -136,9 +138,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
diff --git a/jdk/test/tools/jlink/plugins/PrevisitorTest.java b/jdk/test/tools/jlink/plugins/PrevisitorTest.java
index 16d79f0..1f721d6 100644
--- a/jdk/test/tools/jlink/plugins/PrevisitorTest.java
+++ b/jdk/test/tools/jlink/plugins/PrevisitorTest.java
@@ -26,6 +26,7 @@
  * @summary Test previsitor
  * @author Andrei Eremeev
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink
  * @run main/othervm PrevisitorTest
  */
 import java.nio.ByteOrder;
@@ -36,19 +37,20 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
 import jdk.tools.jlink.internal.ImagePluginConfiguration;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.internal.ImagePluginStack;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.ResourcePrevisitor;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class PrevisitorTest {
@@ -68,17 +70,17 @@
         plugins.add(createPlugin(CustomPlugin.NAME));
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new Jlink.PluginsConfiguration(plugins,
                 null, null));
-        PoolImpl inResources = new PoolImpl(ByteOrder.nativeOrder(), new CustomStringTable());
-        inResources.add(Pool.newResource("/aaa/bbb/res1.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/bbb/res2.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/bbb/res3.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/ddd/res1.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/res1.class", new byte[90]));
-        Pool outResources = stack.visitResources(inResources);
-        Collection<String> input = inResources.getContent().stream()
+        ModulePoolImpl inResources = new ModulePoolImpl(ByteOrder.nativeOrder(), new CustomStringTable());
+        inResources.add(ModuleEntry.create("/aaa/bbb/res1.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/bbb/res2.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/bbb/res3.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/ddd/res1.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/res1.class", new byte[90]));
+        ModulePool outResources = stack.visitResources(inResources);
+        Collection<String> input = inResources.entries()
                 .map(Object::toString)
                 .collect(Collectors.toList());
-        Collection<String> output = outResources.getContent().stream()
+        Collection<String> output = outResources.entries()
                 .map(Object::toString)
                 .collect(Collectors.toList());
         if (!input.equals(output)) {
@@ -114,19 +116,20 @@
         private boolean isPrevisitCalled = false;
 
         @Override
-        public void visit(Pool inResources, Pool outResources) {
+        public void visit(ModulePool inResources, ModulePool outResources) {
             if (!isPrevisitCalled) {
                 throw new AssertionError("Previsit was not called");
             }
             CustomStringTable table = (CustomStringTable)
-                    ((PoolImpl) inResources).getStringTable();
+                    ((ModulePoolImpl) inResources).getStringTable();
             if (table.size() == 0) {
                 throw new AssertionError("Table is empty");
             }
             Map<String, Integer> count = new HashMap<>();
             for (int i = 0; i < table.size(); ++i) {
                 String s = table.getString(i);
-                if (inResources.get(s) != null) {
+                Optional<ModuleEntry> e = inResources.findEntry(s);
+                if (e.isPresent()) {
                     throw new AssertionError();
                 }
                 count.compute(s, (k, c) -> 1 + (c == null ? 0 : c));
@@ -136,9 +139,9 @@
                     throw new AssertionError("Expected one entry in the table, got: " + v + " for " + k);
                 }
             });
-            for (ModuleData r : inResources.getContent()) {
+            inResources.entries().forEach(r -> {
                 outResources.add(r);
-            }
+            });
         }
 
         @Override
@@ -147,21 +150,21 @@
         }
 
         @Override
-        public void previsit(Pool resources, StringTable strings) {
+        public void previsit(ModulePool resources, StringTable strings) {
             isPrevisitCalled = true;
-            for (ModuleData r : resources.getContent()) {
+            resources.entries().forEach(r -> {
                 String s = r.getPath();
                 int lastIndexOf = s.lastIndexOf('/');
                 if (lastIndexOf >= 0) {
                     strings.addString(s.substring(0, lastIndexOf));
                 }
-            }
+            });
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
     }
diff --git a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java
index 786da46..c02a8e6 100644
--- a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java
@@ -38,6 +38,8 @@
  * @run main StringSharingPluginTest
  */
 
+import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.file.Files;
@@ -50,11 +52,11 @@
 
 import jdk.internal.jimage.decompressor.CompressedResourceHeader;
 import jdk.internal.jimage.decompressor.StringSharingDecompressor;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.plugins.StringSharingPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import tests.Helper;
 import tests.JImageValidator;
@@ -78,7 +80,7 @@
         Map<String, Integer> map = new HashMap<>();
         Map<Integer, String> reversedMap = new HashMap<>();
 
-        PoolImpl resources = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+        ModulePoolImpl resources = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
             @Override
             public int addString(String str) {
                 Integer id = map.get(str);
@@ -104,7 +106,7 @@
                     byte[] content = Files.readAllBytes(p);
                     String path = p.toString().replace('\\', '/');
                     path = path.substring("/modules".length());
-                    ModuleData res = Pool.newResource(path, content);
+                    ModuleEntry res = ModuleEntry.create(path, content);
                     resources.add(res);
                 } catch (Exception ex) {
                     throw new RuntimeException(ex);
@@ -115,19 +117,23 @@
             stream.forEach(c);
         }
         TransformerPlugin plugin = new StringSharingPlugin();
-        PoolImpl result = new PoolImpl(resources.getByteOrder(), resources.getStringTable());
+        ModulePoolImpl result = new ModulePoolImpl(resources.getByteOrder(), resources.getStringTable());
         plugin.visit(resources, result);
 
         if (result.isEmpty()) {
             throw new AssertionError("No result");
         }
 
-        for (ModuleData res : result.getContent()) {
+        result.entries().forEach(res -> {
             if (res.getPath().endsWith(".class")) {
-                byte[] uncompacted = StringSharingDecompressor.normalize(reversedMap::get, res.getBytes(),
+                try {
+                    byte[] uncompacted = StringSharingDecompressor.normalize(reversedMap::get, res.getBytes(),
                         CompressedResourceHeader.getSize());
-                JImageValidator.readClass(uncompacted);
+                    JImageValidator.readClass(uncompacted);
+                } catch (IOException exp) {
+                    throw new UncheckedIOException(exp);
+                }
             }
-        }
+        });
     }
 }
diff --git a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java
index fd8acae..d3617db 100644
--- a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java
@@ -54,10 +54,10 @@
 import com.sun.tools.classfile.Method;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import tests.Helper;
 
@@ -106,7 +106,7 @@
         path = path.replace('\\', '/');
         StripDebugPlugin debug = new StripDebugPlugin();
         debug.configure(new HashMap<>());
-        ModuleData result1 = stripDebug(debug, Pool.newResource(path,content), path, infoPath, moduleInfo);
+        ModuleEntry result1 = stripDebug(debug, ModuleEntry.create(path,content), path, infoPath, moduleInfo);
 
         if (!path.endsWith("module-info.class")) {
             if (result1.getLength() >= content.length) {
@@ -116,7 +116,7 @@
             checkDebugAttributes(result1.getBytes());
         }
 
-        ModuleData result2 = stripDebug(debug, result1, path, infoPath, moduleInfo);
+        ModuleEntry result2 = stripDebug(debug, result1, path, infoPath, moduleInfo);
         if (result1.getLength() != result2.getLength()) {
             throw new AssertionError("removing debug info twice reduces class size of "
                     + path);
@@ -124,18 +124,18 @@
         checkDebugAttributes(result1.getBytes());
     }
 
-    private ModuleData stripDebug(TransformerPlugin debug, ModuleData classResource,
+    private ModuleEntry stripDebug(TransformerPlugin debug, ModuleEntry classResource,
             String path, String infoPath, byte[] moduleInfo) throws Exception {
-        Pool resources = new PoolImpl();
+        ModulePool resources = new ModulePoolImpl();
         resources.add(classResource);
         if (!path.endsWith("module-info.class")) {
-            ModuleData res2 = Pool.newResource(infoPath, moduleInfo);
+            ModuleEntry res2 = ModuleEntry.create(infoPath, moduleInfo);
             resources.add(res2);
         }
-        Pool results = new PoolImpl();
+        ModulePool results = new ModulePoolImpl();
         debug.visit(resources, results);
         System.out.println(classResource.getPath());
-        return results.get(classResource.getPath());
+        return results.findEntry(classResource.getPath()).get();
     }
 
     private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException {
diff --git a/jdk/test/tools/launcher/FXLauncherTest.java b/jdk/test/tools/launcher/FXLauncherTest.java
index 0ee9d98..7fec8d5 100644
--- a/jdk/test/tools/launcher/FXLauncherTest.java
+++ b/jdk/test/tools/launcher/FXLauncherTest.java
@@ -29,6 +29,7 @@
  * jfx app class, a main-class for the manifest, a bogus one and none.
  * All should execute except the incorrect fx app class entries.
  * @run main/othervm FXLauncherTest
+ * @key intermittent
  */
 import java.io.File;
 import java.io.IOException;
diff --git a/jdk/test/tools/launcher/modules/patch/PatchTest.java b/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/PatchTest.java
rename to jdk/test/tools/launcher/modules/patch/basic/PatchTest.java
diff --git a/jdk/test/tools/launcher/modules/patch/src/test/jdk/test/Main.java b/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src/test/jdk/test/Main.java
rename to jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java
diff --git a/jdk/test/tools/launcher/modules/patch/src/test/module-info.java b/jdk/test/tools/launcher/modules/patch/basic/src/test/module-info.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src/test/module-info.java
rename to jdk/test/tools/launcher/modules/patch/basic/src/test/module-info.java
diff --git a/jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/Annotation.java b/jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/Annotation.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/Annotation.java
rename to jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/Annotation.java
diff --git a/jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/AnnotationBuddy.java b/jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/AnnotationBuddy.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/AnnotationBuddy.java
rename to jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/AnnotationBuddy.java
diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/Main.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/Main.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/Main.java
rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/Main.java
diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java
rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java
diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java
rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java
diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java
rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java
diff --git a/jdk/test/tools/launcher/modules/patch/src2/java.base/java/lang2/Object.java b/jdk/test/tools/launcher/modules/patch/basic/src2/java.base/java/lang2/Object.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src2/java.base/java/lang2/Object.java
rename to jdk/test/tools/launcher/modules/patch/basic/src2/java.base/java/lang2/Object.java
diff --git a/jdk/test/tools/launcher/modules/patch/src2/jdk.compiler/com/sun/tools/javac2/Main.java b/jdk/test/tools/launcher/modules/patch/basic/src2/jdk.compiler/com/sun/tools/javac2/Main.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src2/jdk.compiler/com/sun/tools/javac2/Main.java
rename to jdk/test/tools/launcher/modules/patch/basic/src2/jdk.compiler/com/sun/tools/javac2/Main.java
diff --git a/jdk/test/tools/launcher/modules/patch/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java b/jdk/test/tools/launcher/modules/patch/basic/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java
similarity index 100%
rename from jdk/test/tools/launcher/modules/patch/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java
rename to jdk/test/tools/launcher/modules/patch/basic/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java
diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java
new file mode 100644
index 0000000..0e5345a
--- /dev/null
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java
@@ -0,0 +1,225 @@
+/**
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8157068
+ * @summary Patch java.base and user module with Hashes attribute tied with
+ *          other module.
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ * @build CompilerUtils
+ * @run testng PatchSystemModules
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import jdk.testlibrary.FileUtils;
+import jdk.testlibrary.JDKToolFinder;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import static jdk.testlibrary.ProcessTools.executeCommand;
+import static org.testng.Assert.*;
+
+public class PatchSystemModules {
+    private static final String JAVA_HOME = System.getProperty("java.home");
+
+    private static final Path TEST_SRC = Paths.get(System.getProperty("test.src"));
+    private static final Path PATCH_SRC_DIR = TEST_SRC.resolve("src1");
+
+    private static final Path JMODS = Paths.get(JAVA_HOME, "jmods");
+    private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path JARS_DIR = Paths.get("jars");
+    private static final Path PATCH_DIR = Paths.get("patches");
+    private static final Path IMAGE = Paths.get("image");
+
+    private static final String JAVA_BASE = "java.base";
+    private final String[] modules = new String[] { "m1", "m2" };
+
+    @BeforeTest
+    private void setup() throws Throwable {
+        Path src = TEST_SRC.resolve("src");
+        for (String name : modules) {
+            assertTrue(CompilerUtils.compile(src.resolve(name),
+                                             MODS_DIR,
+                                             "-modulesourcepath", src.toString()));
+        }
+
+        // compile patched source
+        assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve(JAVA_BASE),
+                                         PATCH_DIR.resolve(JAVA_BASE),
+                                         "-Xmodule:java.base"));
+        assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve("m2"),
+                                         PATCH_DIR.resolve("m2")));
+
+        // create an image with only m1 and m2
+        if (Files.exists(JMODS)) {
+            // create an image with m1,m2
+            createImage();
+        }
+    }
+
+    @Test
+    public void test() throws Throwable {
+        Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE);
+        Path patchedM2 = PATCH_DIR.resolve("m2");
+
+        Path home = Paths.get(JAVA_HOME);
+        runTest(home,
+                "-mp", MODS_DIR.toString(),
+                "-m", "m1/p1.Main", "1");
+        runTest(home,
+                "-Xpatch:java.base=" + patchedJavaBase.toString(),
+                "-mp", MODS_DIR.toString(),
+                "-m", "m1/p1.Main", "1");
+
+        runTest(home,
+                "-Xpatch:m2=" + patchedM2.toString(),
+                "-mp", MODS_DIR.toString(),
+                "-m", "m1/p1.Main", "2");
+    }
+
+    @Test
+    public void testImage() throws Throwable {
+        if (Files.notExists(JMODS))
+            return;
+
+        Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE);
+        Path patchedM2 = PATCH_DIR.resolve("m2");
+
+        runTest(IMAGE,
+                "-m", "m1/p1.Main", "1");
+        runTest(IMAGE,
+                "-Xpatch:java.base=" + patchedJavaBase.toString(),
+                "-m", "m1/p1.Main", "1");
+        runTest(IMAGE,
+                "-Xpatch:m2=" + patchedM2.toString(),
+                "-m", "m1/p1.Main", "2");
+    }
+
+    @Test
+    public void upgradeTiedModule() throws Throwable {
+        if (Files.notExists(JMODS))
+            return;
+
+        Path m1 = MODS_DIR.resolve("m1.jar");
+
+        // create another m1.jar
+        jar("--create",
+            "--file=" + m1.toString(),
+            "-C", MODS_DIR.resolve("m1").toString(), ".");
+
+        // Fail to upgrade m1.jar with mismatched hash
+        runTestWithExitCode(getJava(IMAGE),
+                "-upgrademodulepath", m1.toString(),
+                "-m", "m1/p1.Main");
+
+        runTestWithExitCode(getJava(IMAGE),
+                "-Xpatch:java.base=" + PATCH_DIR.resolve(JAVA_BASE).toString(),
+                "-upgrademodulepath", m1.toString(),
+                "-m", "m1/p1.Main", "1");
+    }
+
+    private void runTestWithExitCode(String... options) throws Throwable {
+        assertTrue(executeCommand(options)
+                        .outputTo(System.out)
+                        .errorTo(System.out)
+                        .shouldContain("differs to expected hash")
+                        .getExitValue() != 0);
+    }
+
+    private void runTest(Path image, String... opts) throws Throwable {
+        String[] options =
+            Stream.concat(Stream.of(getJava(image)),
+                          Stream.of(opts))
+                  .toArray(String[]::new);
+
+        ProcessBuilder pb = new ProcessBuilder(options);
+        int exitValue =  executeCommand(pb)
+                            .outputTo(System.out)
+                            .errorTo(System.out)
+                            .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+    static void createImage() throws Throwable {
+        FileUtils.deleteFileTreeUnchecked(JARS_DIR);
+        FileUtils.deleteFileTreeUnchecked(IMAGE);
+
+        Files.createDirectories(JARS_DIR);
+        Path m1 = JARS_DIR.resolve("m1.jar");
+        Path m2 = JARS_DIR.resolve("m2.jar");
+
+        // hash m1 in m2's Hashes attribute
+        jar("--create",
+            "--file=" + m1.toString(),
+            "-C", MODS_DIR.resolve("m1").toString(), ".");
+
+        jar("--create",
+            "--file=" + m2.toString(),
+            "--modulepath", JARS_DIR.toString(),
+            "--hash-modules", "m1",
+            "-C", MODS_DIR.resolve("m2").toString(), ".");
+
+
+        String mpath = JARS_DIR.toString() + File.pathSeparator + JMODS.toString();
+        execTool("jlink", "--modulepath", mpath,
+                 "--addmods", "m1",
+                 "--output", IMAGE.toString());
+    }
+
+    static void jar(String... args) throws Throwable {
+        execTool("jar", args);
+    }
+
+    static void execTool(String tool, String... args) throws Throwable {
+        String path = JDKToolFinder.getJDKTool(tool);
+        List<String> commands = new ArrayList<>();
+        commands.add(path);
+        Stream.of(args).forEach(commands::add);
+        ProcessBuilder pb = new ProcessBuilder(commands);
+        int exitValue =  executeCommand(pb)
+            .outputTo(System.out)
+            .errorTo(System.out)
+            .shouldNotContain("no module is recorded in hash")
+            .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+    static String getJava(Path image) {
+        boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win");
+        Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java");
+        if (Files.notExists(java))
+            throw new RuntimeException(java + " not found");
+        return java.toAbsolutePath().toString();
+    }
+}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java
index 135652e..d23aeb1 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+/**
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m1 {
+    requires m2;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java
similarity index 71%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java
index 135652e..2329905 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+/**
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,14 @@
  * questions.
  */
 
-package sun.misc;
+package p1;
 
-public class Unsafe {
-    private Unsafe() { }
+public class Main {
+    public static void main(String[] args) throws Exception {
+        int version = p2.Lib.version();
+        int expected = args.length == 0 ? 1 : Integer.parseInt(args[0]);
 
-    public static long getLong(long address) {
-        return 0L;
+        if (version != expected)
+            throw new RuntimeException(version + " != " + expected + " (expected)");
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java
index 135652e..bc0f12b 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+/**
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m2 {
+    exports p2;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java
index 135652e..1d43aed 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+/**
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,10 @@
  * questions.
  */
 
-package sun.misc;
+package p2;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
+public class Lib {
+    public static int version() {
+        return 1;
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java
similarity index 76%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java
index 135652e..e307612 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,12 @@
  * questions.
  */
 
-package sun.misc;
+package jdk.internal.module;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+/*
+ * Test -Xpatch:java.base=jdk/modules/java.base to override
+ * java.base with an exploded image
+ */
+public final class SystemModules {
+    public static final String[] MODULE_NAMES = new String[0];
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java
index 135652e..5313c7e 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+/**
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,10 @@
  * questions.
  */
 
-package sun.misc;
+package p2;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
+public class Lib {
+    public static int version() {
+        return 2;
     }
 }
diff --git a/jdk/test/tools/pack200/TestNormal.java b/jdk/test/tools/pack200/TestNormal.java
index 0172a5e..a85a9d4 100644
--- a/jdk/test/tools/pack200/TestNormal.java
+++ b/jdk/test/tools/pack200/TestNormal.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,85 +25,37 @@
 /*
  * @test
  * @run main/timeout=600 TestNormal
- * @bug 8020802
+ * @bug 8020802 8156807
  * @summary Need an ability to create jar files that are invariant to the pack200 packing/unpacking
  * @author Alexander Zuev
  */
 
 import java.io.*;
-import java.util.Collections;
-import java.util.Properties;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
 
 public class TestNormal {
     private static String FS = File.separator;
 
     public static void main(String args[]) throws Exception {
-        Properties p = System.getProperties();
-        String java_home = p.getProperty("test.jdk");
         String testdir = Utils.TEST_CLS_DIR.getAbsolutePath();
 
         try {
-            execJavaCommand(java_home, "jar cnf normalized.jar -C " + testdir + " .");
-            execJavaCommand(java_home, "jar cf original.jar -C " + testdir + " .");
-            execJavaCommand(java_home, "pack200 -r repacked.jar original.jar");
-            compareJars(new JarFile("normalized.jar"), new JarFile("repacked.jar"));
+            String jarCmd = Utils.getJarCmd();
+            String packCmd = Utils.getPack200Cmd();
+
+            // create the original jar
+            Utils.runExec(jarCmd, "cf", "original.jar", "-C", testdir, ".");
+
+            // create the reference jar
+            Utils.runExec(packCmd, "-r", "repacked.jar", "original.jar");
+
+            // create the normalized jar using jar(1)
+            Utils.runExec(jarCmd, "cnf", "normalized.jar", "-C", testdir, ".");
+
+            // compare archive contents bit wise, these should be identical!
+            Utils.doCompareBitWise(new File("repacked.jar"),
+                    new File("normalized.jar"));
         } finally {
-            String[] cleanupList = {"normalized.jar", "original.jar", "repacked.jar"};
-            for (String s : cleanupList) {
-                delete(new File(s));
-            }
-        }
-    }
-
-    public static void execJavaCommand(String java_home, String cmd) throws Exception {
-        Process proc = Runtime.getRuntime().exec(java_home + FS + "bin" + FS + cmd);
-        String s;
-        BufferedReader stdInput =
-                new BufferedReader(new InputStreamReader(proc.getInputStream()));
-        BufferedReader stdError =
-                new BufferedReader(new InputStreamReader(proc.getErrorStream()));
-        while ((s = stdInput.readLine()) != null) {
-            System.out.println(s);
-        }
-        while ((s = stdError.readLine()) != null) {
-            System.err.println(s);
-        }
-    }
-
-    public static void compareJars(JarFile jf1, JarFile jf2) throws Exception {
-        try {
-            if (jf1.size() != jf2.size()) {
-                throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName()
-                        + " have different number of entries");
-            }
-            for (JarEntry elem1 : Collections.list(jf1.entries())) {
-                JarEntry elem2 = jf2.getJarEntry(elem1.getName());
-                if (elem2 == null) {
-                    throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName());
-                }
-                if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) {
-                    throw new Exception("The crc of " + elem1.getName() + " is different.");
-                }
-            }
-        } finally {
-            jf1.close();
-            jf2.close();
-        }
-    }
-
-    static void delete(File f) throws IOException {
-        if (!f.exists()) {
-            return;
-        }
-        if (f.isDirectory()) {
-            for (File c : f.listFiles()) {
-                delete(c);
-            }
-        }
-        if (!f.delete()) {
-            throw new FileNotFoundException("Failed to delete file: " + f);
+           Utils.cleanup();
         }
     }
 }
diff --git a/jdk/test/tools/pack200/Utils.java b/jdk/test/tools/pack200/Utils.java
index f464198..45e09c3 100644
--- a/jdk/test/tools/pack200/Utils.java
+++ b/jdk/test/tools/pack200/Utils.java
@@ -33,7 +33,6 @@
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.URI;
-import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.nio.file.FileSystem;
@@ -483,9 +482,15 @@
         }
         return out;
     }
+
+    static List<String> runExec(String... cmds) {
+        return runExec(Arrays.asList(cmds));
+    }
+
     static List<String> runExec(List<String> cmdsList) {
         return runExec(cmdsList, null);
     }
+
     static List<String> runExec(List<String> cmdsList, Map<String, String> penv) {
         ArrayList<String> alist = new ArrayList<String>();
         ProcessBuilder pb =
diff --git a/langtools/.hgtags b/langtools/.hgtags
index 5f79796..28b589f 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -361,3 +361,4 @@
 3e3553ee39d9e081573bc7c88a252214a3152763 jdk-9+116
 59adcdd0cd3b6724b4fc0083c258bf4682689f2f jdk-9+117
 59a16fa5dedea9ff5bea0a501e4d0d40193426f3 jdk-9+118
+6347efd1be03b4fdcf18f64c4fe4be5f60c0831a jdk-9+119
diff --git a/langtools/make/build.properties b/langtools/make/build.properties
index 38939fa..c65ccb6 100644
--- a/langtools/make/build.properties
+++ b/langtools/make/build.properties
@@ -28,6 +28,10 @@
 javac.source = 9
 javac.target = 9
 
+#version used to compile build tools
+javac.build.source = 8
+javac.build.target = 8
+
 langtools.resource.includes = \
         com/sun/tools/javac/resources/compiler.properties
 
diff --git a/langtools/make/build.xml b/langtools/make/build.xml
index e96ec89..564c2b5 100644
--- a/langtools/make/build.xml
+++ b/langtools/make/build.xml
@@ -239,11 +239,12 @@
         </condition>
         <replace file=".idea/ant.xml" token="@IDEA_JTREG_HOME@" value="${idea.jtreg.home}"/>
         <replace file=".idea/ant.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
-        <replace file=".idea/workspace.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
-        <replace file=".idea/workspace.xml" token="@XPATCH@" value="${xpatch.cmd}"/>
-        <replace file=".idea/workspace.xml" token="@PATH_SEP@" value="${path.separator}"/>
+        <replace dir=".idea/runConfigurations" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
+        <replace dir=".idea/runConfigurations" token="@XPATCH@" value="${xpatch.cmd}"/>
         <mkdir dir=".idea/classes"/>
-        <javac srcdir="make/intellij/src"
+        <javac source="${javac.build.source}"
+               target="${javac.build.target}"
+               srcdir="make/intellij/src"
                destdir=".idea/classes"/>
     </target>
 
@@ -255,10 +256,8 @@
         <copy todir="${build.tools}/propertiesparser" >
             <fileset dir="${make.tools.dir}/propertiesparser" includes="**/resources/**"/>
         </copy>
-        <javac fork="true"
-               source="${javac.source}"
-               target="${javac.target}"
-               executable="${langtools.jdk.home}/bin/javac"
+        <javac source="${javac.build.source}"
+               target="${javac.build.target}"
                srcdir="${make.tools.dir}"
                includes="propertiesparser/* anttasks/PropertiesParser* anttasks/PathFileSet*"
                destdir="${build.tools}"
@@ -273,10 +272,9 @@
     </target>
 
      <target name="-def-pcompile">
-        <javac fork="true"
-               source="${javac.source}"
-               target="${javac.target}"
-               executable="${langtools.jdk.home}/bin/javac"
+        <javac
+               source="${javac.build.source}"
+               target="${javac.build.target}"
                srcdir="${make.tools.dir}"
                includes="compileproperties/* anttasks/CompileProperties* anttasks/PathFileSet*"
                destdir="${build.dir}/toolclasses/"
diff --git a/langtools/make/intellij/runConfigurations/javac.xml b/langtools/make/intellij/runConfigurations/javac.xml
new file mode 100644
index 0000000..e5b9810
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/javac.xml
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="javac" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
+    <option name="VM_PARAMETERS" value="@XPATCH@" />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/runConfigurations/javadoc.xml b/langtools/make/intellij/runConfigurations/javadoc.xml
new file mode 100644
index 0000000..159a471
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/javadoc.xml
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="javadoc" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javadoc.Main" />
+    <option name="VM_PARAMETERS" value="@XPATCH@" />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/runConfigurations/javah.xml b/langtools/make/intellij/runConfigurations/javah.xml
new file mode 100644
index 0000000..4f7003d
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/javah.xml
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="javah" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javah.Main" />
+    <option name="VM_PARAMETERS" value="@XPATCH@ -XaddExports:jdk.compiler/com.sun.tools.javah=ALL-UNNAMED" />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/runConfigurations/javap.xml b/langtools/make/intellij/runConfigurations/javap.xml
new file mode 100644
index 0000000..8e3caf2
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/javap.xml
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="javap" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" />
+    <option name="VM_PARAMETERS" value="@XPATCH@ -XaddExports:jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED" />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/runConfigurations/jshell.xml b/langtools/make/intellij/runConfigurations/jshell.xml
new file mode 100644
index 0000000..36e0ced
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/jshell.xml
@@ -0,0 +1,20 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="jshell" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellTool" />
+    <option name="VM_PARAMETERS" value="@XPATCH@ -XaddExports:jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED" />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/runConfigurations/jtreg__debug_.xml b/langtools/make/intellij/runConfigurations/jtreg__debug_.xml
new file mode 100644
index 0000000..fd1bdcc
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/jtreg__debug_.xml
@@ -0,0 +1,18 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="jtreg (debug)" type="Remote" factoryName="Remote" singleton="true">
+    <option name="USE_SOCKET_TRANSPORT" value="true" />
+    <option name="SERVER_MODE" value="true" />
+    <option name="SHMEM_ADDRESS" />
+    <option name="HOST" value="localhost" />
+    <option name="PORT" value="5900" />
+    <RunnerSettings RunnerId="Debug">
+      <option name="DEBUG_PORT" value="5900" />
+      <option name="TRANSPORT" value="0" />
+      <option name="LOCAL" value="false" />
+    </RunnerSettings>
+    <ConfigurationWrapper RunnerId="Debug" />
+    <method>
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="jtreg-debug" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/runConfigurations/jtreg__run_.xml b/langtools/make/intellij/runConfigurations/jtreg__run_.xml
new file mode 100644
index 0000000..b9f655f
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/jtreg__run_.xml
@@ -0,0 +1,8 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="jtreg (run)" type="AntRunConfiguration" factoryName="Ant Target">
+    <antsettings antfile="file://$PROJECT_DIR$/.idea/build.xml" target="jtreg" />
+    <method>
+      <option name="Make" enabled="false" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/runConfigurations/sjavac.xml b/langtools/make/intellij/runConfigurations/sjavac.xml
new file mode 100644
index 0000000..d310b1a
--- /dev/null
+++ b/langtools/make/intellij/runConfigurations/sjavac.xml
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="sjavac" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" />
+    <option name="VM_PARAMETERS" value="@XPATCH@ -XaddExports:jdk.compiler/com.sun.tools.sjavac=ALL-UNNAMED" />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
diff --git a/langtools/make/intellij/workspace.xml b/langtools/make/intellij/workspace.xml
index e0e0c57..babc8a4 100644
--- a/langtools/make/intellij/workspace.xml
+++ b/langtools/make/intellij/workspace.xml
@@ -1,157 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="ChangeListManager">
-    <ignored path=".idea/" />
-  </component>
-  <component name="CompilerWorkspaceConfiguration">
-    <option name="MAKE_PROJECT_ON_SAVE" value="true" />
-  </component>
-  <component name="RunManager" selected="Application.javac">
-    <!-- javac -->
-    <configuration default="false" name="javac" type="Application" factoryName="Application">
-      <option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
-      <option name="VM_PARAMETERS" value="@XPATCH@" />
-      <option name="PROGRAM_PARAMETERS" value="" />
-      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-      <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <option name="ENV_VARIABLES" />
-      <option name="PASS_PARENT_ENVS" value="true" />
-      <module name="langtools" />
-      <envs />
-      <RunnerSettings RunnerId="Run" />
-      <ConfigurationWrapper RunnerId="Run" />
-      <method>
-        <option name="Make" enabled="false" />
-        <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-      </method>
-    </configuration>
-    <!-- javadoc -->
-    <configuration default="false" name="javadoc" type="Application" factoryName="Application">
-      <option name="MAIN_CLASS_NAME" value="com.sun.tools.javadoc.Main" />
-      <option name="VM_PARAMETERS" value="@XPATCH@" />
-      <option name="PROGRAM_PARAMETERS" value="" />
-      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-      <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <option name="ENV_VARIABLES" />
-      <option name="PASS_PARENT_ENVS" value="true" />
-      <module name="langtools" />
-      <envs />
-      <RunnerSettings RunnerId="Run" />
-      <ConfigurationWrapper RunnerId="Run" />
-      <method>
-        <option name="Make" enabled="false" />
-        <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-      </method>
-    </configuration>
-    <!-- javap -->
-    <configuration default="false" name="javap" type="Application" factoryName="Application">
-      <option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" />
-      <option name="VM_PARAMETERS" value="@XPATCH@" />
-      <option name="PROGRAM_PARAMETERS" value="" />
-      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-      <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <option name="ENV_VARIABLES" />
-      <option name="PASS_PARENT_ENVS" value="true" />
-      <module name="langtools" />
-      <envs />
-      <RunnerSettings RunnerId="Run" />
-      <ConfigurationWrapper RunnerId="Run" />
-      <method>
-        <option name="Make" enabled="false" />
-        <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-      </method>
-    </configuration>
-    <!-- javah -->
-    <configuration default="false" name="javah" type="Application" factoryName="Application">
-      <option name="MAIN_CLASS_NAME" value="com.sun.tools.javah.Main" />
-      <option name="VM_PARAMETERS" value="@XPATCH@" />
-      <option name="PROGRAM_PARAMETERS" value="" />
-      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-      <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <option name="ENV_VARIABLES" />
-      <option name="PASS_PARENT_ENVS" value="true" />
-      <module name="langtools" />
-      <envs />
-      <RunnerSettings RunnerId="Run" />
-      <ConfigurationWrapper RunnerId="Run" />
-      <method>
-        <option name="Make" enabled="false" />
-        <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-      </method>
-    </configuration>
-    <!-- sjavac -->
-    <configuration default="false" name="sjavac" type="Application" factoryName="Application">
-      <option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" />
-      <option name="VM_PARAMETERS" value="@XPATCH@" />
-      <option name="PROGRAM_PARAMETERS" value="" />
-      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-      <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <option name="ENV_VARIABLES" />
-      <option name="PASS_PARENT_ENVS" value="true" />
-      <module name="langtools" />
-      <envs />
-      <RunnerSettings RunnerId="Run" />
-      <ConfigurationWrapper RunnerId="Run" />
-      <method>
-        <option name="Make" enabled="false" />
-        <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-      </method>
-    </configuration>
-    <!-- jshell -->
-    <configuration default="false" name="jshell" type="Application" factoryName="Application">
-      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-      <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellTool" />
-      <option name="VM_PARAMETERS" value="@XPATCH@ -XaddExports:jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED" />
-      <option name="PROGRAM_PARAMETERS" value="" />
-      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-      <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <option name="ENV_VARIABLES" />
-      <option name="PASS_PARENT_ENVS" value="true" />
-      <module name="langtools" />
-      <envs />
-      <method>
-        <option name="Make" enabled="false" />
-        <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-      </method>
-    </configuration>
-    <!-- jtreg run -->
-    <configuration default="false" name="jtreg (run)" type="AntRunConfiguration" factoryName="Ant Target">
-      <antsettings antfile="file://$PROJECT_DIR$/.idea/build.xml" target="jtreg" />
-      <method>
-        <option name="Make" enabled="false" />
-      </method>
-    </configuration>
-    <!-- jtreg debug -->
-    <configuration default="false" name="jtreg (debug)" type="Remote" factoryName="Remote" singleton="true">
-      <option name="USE_SOCKET_TRANSPORT" value="true" />
-      <option name="SERVER_MODE" value="true" />
-      <option name="SHMEM_ADDRESS" />
-      <option name="HOST" value="localhost" />
-      <option name="PORT" value="5900" />
-      <RunnerSettings RunnerId="Debug">
-        <option name="DEBUG_PORT" value="5900" />
-        <option name="TRANSPORT" value="0" />
-        <option name="LOCAL" value="false" />
-      </RunnerSettings>
-      <ConfigurationWrapper RunnerId="Debug" />
-      <method>
-        <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="jtreg-debug" />
-      </method>
-      <method />
-    </configuration>
-  </component>
   <component name="StructureViewFactory">
     <option name="ACTIVE_ACTIONS" value=",ALPHA_COMPARATOR" />
   </component>
diff --git a/langtools/make/tools/crules/AssertCheckAnalyzer.java b/langtools/make/tools/crules/AssertCheckAnalyzer.java
index d46b5e1..b665d74 100644
--- a/langtools/make/tools/crules/AssertCheckAnalyzer.java
+++ b/langtools/make/tools/crules/AssertCheckAnalyzer.java
@@ -37,6 +37,9 @@
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.Assert;
 
+/**This analyzer guards against complex messages (i.e. those that use string concatenation) passed
+ * to various Assert.check methods.
+ */
 public class AssertCheckAnalyzer extends AbstractCodingRulesAnalyzer {
 
     enum AssertOverloadKind {
diff --git a/langtools/make/tools/crules/MutableFieldsAnalyzer.java b/langtools/make/tools/crules/MutableFieldsAnalyzer.java
index a992f55..5609556 100644
--- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java
+++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java
@@ -41,6 +41,7 @@
 import static com.sun.tools.javac.code.Flags.SYNTHETIC;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 
+/**This analyzer guards against non-final static fields.*/
 public class MutableFieldsAnalyzer extends AbstractCodingRulesAnalyzer {
 
     public MutableFieldsAnalyzer(JavacTask task) {
@@ -98,12 +99,14 @@
         ignoreFields("com.sun.tools.javac.code.Type", "moreInfo");
         ignoreFields("com.sun.tools.javac.util.SharedNameTable", "freelist");
         ignoreFields("com.sun.tools.javac.util.Log", "useRawMessages");
-        ignoreFields("com.sun.tools.javac.util.ModuleWrappers$ModuleFinderHelper",
-                "moduleFinderInterface", "ofMethod", "emptyMethod");
-        ignoreFields("com.sun.tools.javac.util.ModuleWrappers$ConfigurationHelper",
+        ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ModuleFinder",
+                "moduleFinderClass", "ofMethod");
+        ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Configuration",
                 "configurationClass", "resolveRequiresAndUsesMethod");
-        ignoreFields("com.sun.tools.javac.util.ModuleWrappers$LayerHelper",
+        ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Layer",
                 "layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod");
+        ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ServiceLoaderHelper",
+                "loadMethod");
         ignoreFields("com.sun.tools.javac.util.ModuleHelper",
                 "addExportsMethod", "getUnnamedModuleMethod", "getModuleMethod");
     }
diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
index a4ae3e8..768c7ba 100644
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
      * 1.6: no changes
      * 1.7: diamond syntax, try-with-resources, etc.
      * 1.8: lambda expressions and default methods
-     * 9: To be determined
+     *   9: modules, small cleanups to 1.7 and 1.8 changes
      */
 
     /**
@@ -145,6 +145,9 @@
      * The version recognized by the Java Platform, Standard Edition
      * 9.
      *
+     * Additions in this release include modules and removal of a
+     * single underscore from the set of legal identifier names.
+     *
      * @since 9
      */
      RELEASE_9;
@@ -233,10 +236,10 @@
     }
 
     /**
-     *  Returns whether or not {@code name} is a syntactically valid
-     *  qualified name in the latest source version.  Unlike {@link
-     *  #isIdentifier isIdentifier}, this method returns {@code false}
-     *  for keywords and literals.
+     * Returns whether or not {@code name} is a syntactically valid
+     * qualified name in the latest source version.  Unlike {@link
+     * #isIdentifier isIdentifier}, this method returns {@code false}
+     * for keywords, boolean literals, and the null literal.
      *
      * @param name the string to check
      * @return {@code true} if this string is a
@@ -244,45 +247,115 @@
      * @jls 6.2 Names and Identifiers
      */
     public static boolean isName(CharSequence name) {
+        return isName(name, latest());
+    }
+
+    /**
+     * Returns whether or not {@code name} is a syntactically valid
+     * qualified name in the given source version.  Unlike {@link
+     * #isIdentifier isIdentifier}, this method returns {@code false}
+     * for keywords, boolean literals, and the null literal.
+     *
+     * @param name the string to check
+     * @param version the version to use
+     * @return {@code true} if this string is a
+     * syntactically valid name, {@code false} otherwise.
+     * @jls 6.2 Names and Identifiers
+     * @since 9
+     */
+    public static boolean isName(CharSequence name, SourceVersion version) {
         String id = name.toString();
 
         for(String s : id.split("\\.", -1)) {
-            if (!isIdentifier(s) || isKeyword(s))
+            if (!isIdentifier(s) || isKeyword(s, version))
                 return false;
         }
         return true;
     }
 
-    private final static Set<String> keywords;
-    static {
-        Set<String> s = new HashSet<>();
-        String [] kws = {
-            "abstract", "continue",     "for",          "new",          "switch",
-            "assert",   "default",      "if",           "package",      "synchronized",
-            "boolean",  "do",           "goto",         "private",      "this",
-            "break",    "double",       "implements",   "protected",    "throw",
-            "byte",     "else",         "import",       "public",       "throws",
-            "case",     "enum",         "instanceof",   "return",       "transient",
-            "catch",    "extends",      "int",          "short",        "try",
-            "char",     "final",        "interface",    "static",       "void",
-            "class",    "finally",      "long",         "strictfp",     "volatile",
-            "const",    "float",        "native",       "super",        "while",
-            // literals
-            "null",     "true",         "false"
-        };
-        for(String kw : kws)
-            s.add(kw);
-        keywords = Collections.unmodifiableSet(s);
+    /**
+     * Returns whether or not {@code s} is a keyword, boolean literal,
+     * or null literal in the latest source version.
+     *
+     * @param s the string to check
+     * @return {@code true} if {@code s} is a keyword, or boolean
+     * literal, or null literal, {@code false} otherwise.
+     * @jls 3.9 Keywords
+     * @jls 3.10.3 Boolean Literals
+     * @jls 3.10.7 The Null Literal
+     */
+    public static boolean isKeyword(CharSequence s) {
+        return isKeyword(s, latest());
     }
 
     /**
-     *  Returns whether or not {@code s} is a keyword or literal in the
-     *  latest source version.
+     * Returns whether or not {@code s} is a keyword, boolean literal,
+     * or null literal in the given source version.
      *
      * @param s the string to check
-     * @return {@code true} if {@code s} is a keyword or literal, {@code false} otherwise.
+     * @param version the version to use
+     * @return {@code true} if {@code s} is a keyword, or boolean
+     * literal, or null literal, {@code false} otherwise.
+     * @jls 3.9 Keywords
+     * @jls 3.10.3 Boolean Literals
+     * @jls 3.10.7 The Null Literal
+     * @since 9
      */
-    public static boolean isKeyword(CharSequence s) {
-        return keywords.contains(s.toString());
+    public static boolean isKeyword(CharSequence s, SourceVersion version) {
+        String id = s.toString();
+        switch(id) {
+            // A trip through history
+        case "strictfp":
+            return version.compareTo(RELEASE_2) >= 0;
+
+        case "assert":
+            return version.compareTo(RELEASE_4) >= 0;
+
+        case "enum":
+            return version.compareTo(RELEASE_5) >= 0;
+
+        case "_":
+            return version.compareTo(RELEASE_9) >= 0;
+
+            // Keywords common across versions
+
+            // Modifiers
+        case "public":    case "protected": case "private":
+        case "abstract":  case "static":    case "final":
+        case "transient": case "volatile":  case "synchronized":
+        case "native":
+
+            // Declarations
+        case "class":     case "interface": case "extends":
+        case "package":   case "throws":    case "implements":
+
+            // Primitive types and void
+        case "boolean":   case "byte":      case "char":
+        case "short":     case "int":       case "long":
+        case "float":     case "double":
+        case "void":
+
+            // Control flow
+        case "if":      case "else":
+        case "try":     case "catch":    case "finally":
+        case "do":      case "while":
+        case "for":     case "continue":
+        case "switch":  case "case":     case "default":
+        case "break":   case "throw":    case "return":
+
+            // Other keywords
+        case  "this":   case "new":      case "super":
+        case "import":  case "instanceof":
+
+            // Forbidden!
+        case "goto":        case "const":
+
+            // literals
+        case "null":         case "true":       case "false":
+            return true;
+
+        default:
+            return false;
+        }
     }
 }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java
index 7ce6ccd..7030511 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java
@@ -365,18 +365,22 @@
 
         @Override
         Type speculativeType(Symbol msym, MethodResolutionPhase phase) {
-            for (Map.Entry<ResultInfo, Type> _entry : speculativeTypes.entrySet()) {
-                DeferredAttrContext deferredAttrContext = _entry.getKey().checkContext.deferredAttrContext();
-                if (deferredAttrContext.phase == phase && deferredAttrContext.msym == msym) {
-                    return _entry.getValue();
+            if (pertinentToApplicability) {
+                for (Map.Entry<ResultInfo, Type> _entry : speculativeTypes.entrySet()) {
+                    DeferredAttrContext deferredAttrContext = _entry.getKey().checkContext.deferredAttrContext();
+                    if (deferredAttrContext.phase == phase && deferredAttrContext.msym == msym) {
+                        return _entry.getValue();
+                    }
                 }
+                return Type.noType;
+            } else {
+                return super.speculativeType(msym, phase);
             }
-            return Type.noType;
         }
 
         @Override
         JCTree speculativeTree(DeferredAttrContext deferredAttrContext) {
-            return speculativeTree;
+            return pertinentToApplicability ? speculativeTree : super.speculativeTree(deferredAttrContext);
         }
 
         /**
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
index 1fd1d37..87f005b 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -2666,7 +2666,7 @@
             @Override
             public boolean compatible(Type found, Type req, Warner warn) {
                 //return type must be compatible in both current context and assignment context
-                return chk.basicHandler.compatible(found, inferenceContext().asUndetVar(req), warn);
+                return chk.basicHandler.compatible(inferenceContext().asUndetVar(found), inferenceContext().asUndetVar(req), warn);
             }
 
             @Override
@@ -2678,6 +2678,7 @@
         class ExpressionLambdaReturnContext extends FunctionalReturnContext {
 
             JCExpression expr;
+            boolean expStmtExpected;
 
             ExpressionLambdaReturnContext(JCExpression expr, CheckContext enclosingContext) {
                 super(enclosingContext);
@@ -2685,10 +2686,23 @@
             }
 
             @Override
+            public void report(DiagnosticPosition pos, JCDiagnostic details) {
+                if (expStmtExpected) {
+                    enclosingContext.report(pos, diags.fragment(Fragments.StatExprExpected));
+                } else {
+                    super.report(pos, details);
+                }
+            }
+
+            @Override
             public boolean compatible(Type found, Type req, Warner warn) {
                 //a void return is compatible with an expression statement lambda
-                return TreeInfo.isExpressionStatement(expr) && req.hasTag(VOID) ||
-                        super.compatible(found, req, warn);
+                if (req.hasTag(VOID)) {
+                    expStmtExpected = true;
+                    return TreeInfo.isExpressionStatement(expr);
+                } else {
+                    return super.compatible(found, req, warn);
+                }
             }
         }
 
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
index c588ecd..fa861b0 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
@@ -35,6 +35,7 @@
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.GraphUtils.DependencyKind;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.Attr.ResultInfo;
@@ -44,9 +45,10 @@
 import com.sun.tools.javac.util.Log.DeferredDiagnosticHandler;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
-import java.util.LinkedHashMap;
+import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
@@ -172,6 +174,7 @@
         public JCExpression tree;
         Env<AttrContext> env;
         AttrMode mode;
+        boolean pertinentToApplicability = true;
         SpeculativeCache speculativeCache;
 
         DeferredType(JCExpression tree, Env<AttrContext> env) {
@@ -290,6 +293,7 @@
                     resultInfo.checkContext.deferredAttrContext();
             Assert.check(deferredAttrContext != emptyDeferredAttrContext);
             if (deferredStuckPolicy.isStuck()) {
+                pertinentToApplicability = false;
                 deferredAttrContext.addDeferredAttrNode(this, resultInfo, deferredStuckPolicy);
                 return Type.noType;
             } else {
@@ -574,28 +578,11 @@
          */
         void complete() {
             while (!deferredAttrNodes.isEmpty()) {
-                Map<Type, Set<Type>> depVarsMap = new LinkedHashMap<>();
-                List<Type> stuckVars = List.nil();
                 boolean progress = false;
                 //scan a defensive copy of the node list - this is because a deferred
                 //attribution round can add new nodes to the list
                 for (DeferredAttrNode deferredAttrNode : List.from(deferredAttrNodes)) {
-                    if (!deferredAttrNode.process(this)) {
-                        List<Type> restStuckVars =
-                                List.from(deferredAttrNode.deferredStuckPolicy.stuckVars())
-                                .intersect(inferenceContext.restvars());
-                        stuckVars = stuckVars.prependList(restStuckVars);
-                        //update dependency map
-                        for (Type t : List.from(deferredAttrNode.deferredStuckPolicy.depVars())
-                                .intersect(inferenceContext.restvars())) {
-                            Set<Type> prevDeps = depVarsMap.get(t);
-                            if (prevDeps == null) {
-                                prevDeps = new LinkedHashSet<>();
-                                depVarsMap.put(t, prevDeps);
-                            }
-                            prevDeps.addAll(restStuckVars);
-                        }
-                    } else {
+                    if (deferredAttrNode.process(this)) {
                         deferredAttrNodes.remove(deferredAttrNode);
                         progress = true;
                     }
@@ -610,7 +597,9 @@
                     //remove all variables that have already been instantiated
                     //from the list of stuck variables
                     try {
-                        inferenceContext.solveAny(stuckVars, depVarsMap, warn);
+                        //find stuck expression to unstuck
+                        DeferredAttrNode toUnstuck = pickDeferredNode();
+                        inferenceContext.solveAny(List.from(toUnstuck.deferredStuckPolicy.stuckVars()), warn);
                         inferenceContext.notifyChange();
                     } catch (Infer.GraphStrategy.NodeNotFoundException ex) {
                         //this means that we are in speculative mode and the
@@ -632,6 +621,59 @@
             }
             return dac.parent.insideOverloadPhase();
         }
+
+        /**
+         * Pick the deferred node to be unstuck. The chosen node is the first strongly connected
+         * component containing exactly one node found in the dependency graph induced by deferred nodes.
+         * If no such component is found, the first deferred node is returned.
+         */
+        DeferredAttrNode pickDeferredNode() {
+            List<StuckNode> nodes = deferredAttrNodes.stream()
+                    .map(StuckNode::new)
+                    .collect(List.collector());
+            //init stuck expression graph; a deferred node A depends on a deferred node B iff
+            //the intersection between A's input variable and B's output variable is non-empty.
+            for (StuckNode sn1 : nodes) {
+                for (Type t : sn1.data.deferredStuckPolicy.stuckVars()) {
+                    for (StuckNode sn2 : nodes) {
+                        if (sn1 != sn2 && sn2.data.deferredStuckPolicy.depVars().contains(t)) {
+                            sn1.deps.add(sn2);
+                        }
+                    }
+                }
+            }
+            //compute tarjan on the stuck graph
+            List<? extends StuckNode> csn = GraphUtils.tarjan(nodes).get(0);
+            return csn.length() == 1 ? csn.get(0).data : deferredAttrNodes.get(0);
+        }
+
+        class StuckNode extends GraphUtils.TarjanNode<DeferredAttrNode, StuckNode> {
+
+            Set<StuckNode> deps = new HashSet<>();
+
+            StuckNode(DeferredAttrNode data) {
+                super(data);
+            }
+
+            @Override
+            public DependencyKind[] getSupportedDependencyKinds() {
+                return new DependencyKind[] { Infer.DependencyKind.STUCK };
+            }
+
+            @Override
+            public Collection<? extends StuckNode> getDependenciesByKind(DependencyKind dk) {
+                if (dk == Infer.DependencyKind.STUCK) {
+                    return deps;
+                } else {
+                    throw new IllegalStateException();
+                }
+            }
+
+            @Override
+            public Iterable<? extends StuckNode> getAllDependencies() {
+                return deps;
+            }
+        }
     }
 
     /**
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
index 776a1bf..d0e49a2 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
@@ -2345,10 +2345,11 @@
         // assigned before reading their value
         public void visitSelect(JCFieldAccess tree) {
             super.visitSelect(tree);
+            JCTree sel = TreeInfo.skipParens(tree.selected);
             if (enforceThisDotInit &&
-                tree.selected.hasTag(IDENT) &&
-                ((JCIdent)tree.selected).name == names._this &&
-                tree.sym.kind == VAR) {
+                    sel.hasTag(IDENT) &&
+                    ((JCIdent)sel).name == names._this &&
+                    tree.sym.kind == VAR) {
                 checkInit(tree.pos(), (VarSymbol)tree.sym);
             }
         }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
index 87026e6..4ecbca5 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
@@ -52,11 +52,9 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -196,7 +194,7 @@
                 //inject return constraints earlier
                 doIncorporation(inferenceContext, warn); //propagation
 
-                boolean shouldPropagate = resultInfo.checkContext.inferenceContext().free(resultInfo.pt);
+                boolean shouldPropagate = shouldPropagate(mt.getReturnType(), resultInfo, inferenceContext);
 
                 InferenceContext minContext = shouldPropagate ?
                         inferenceContext.min(roots(mt, deferredAttrContext), true, warn) :
@@ -257,6 +255,13 @@
         }
     }
     //where
+        private boolean shouldPropagate(Type restype, Attr.ResultInfo target, InferenceContext inferenceContext) {
+            return target.checkContext.inferenceContext() != emptyContext && //enclosing context is a generic method
+                        inferenceContext.free(restype) && //return type contains inference vars
+                        (!inferenceContext.inferencevars.contains(restype) || //no eager instantiation is required (as per 18.5.2)
+                                !needsEagerInstantiation((UndetVar)inferenceContext.asUndetVar(restype), target.pt, inferenceContext));
+        }
+
         private List<Type> roots(MethodType mt, DeferredAttrContext deferredAttrContext) {
             ListBuffer<Type> roots = new ListBuffer<>();
             roots.add(mt.getReturnType());
@@ -311,7 +316,7 @@
                  */
                 saved_undet = inferenceContext.save();
                 if (allowGraphInference && !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
-                    boolean shouldPropagate = resultInfo.checkContext.inferenceContext().free(resultInfo.pt);
+                    boolean shouldPropagate = shouldPropagate(getReturnType(), resultInfo, inferenceContext);
 
                     InferenceContext minContext = shouldPropagate ?
                             inferenceContext.min(roots(asMethodType(), null), false, warn) :
@@ -396,8 +401,9 @@
             to = from.isPrimitive() ? from : syms.objectType;
         } else if (qtype.hasTag(UNDETVAR)) {
             if (resultInfo.pt.isReference()) {
-                to = generateReturnConstraintsUndetVarToReference(
-                        tree, (UndetVar)qtype, to, resultInfo, inferenceContext);
+                if (needsEagerInstantiation((UndetVar)qtype, to, inferenceContext)) {
+                    to = generateReferenceToTargetConstraint(tree, (UndetVar)qtype, to, resultInfo, inferenceContext);
+                }
             } else {
                 if (to.isPrimitive()) {
                     to = generateReturnConstraintsPrimitive(tree, (UndetVar)qtype, to,
@@ -441,9 +447,7 @@
         return types.boxedClass(to).type;
     }
 
-    private Type generateReturnConstraintsUndetVarToReference(JCTree tree,
-            UndetVar from, Type to, Attr.ResultInfo resultInfo,
-            InferenceContext inferenceContext) {
+    private boolean needsEagerInstantiation(UndetVar from, Type to, InferenceContext inferenceContext) {
         Type captureOfTo = types.capture(to);
         /* T is a reference type, but is not a wildcard-parameterized type, and either
          */
@@ -454,8 +458,7 @@
             for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) {
                 Type captureOfBound = types.capture(t);
                 if (captureOfBound != t) {
-                    return generateReferenceToTargetConstraint(tree, from, to,
-                            resultInfo, inferenceContext);
+                    return true;
                 }
             }
 
@@ -469,8 +472,7 @@
                             !inferenceContext.free(aLowerBound) &&
                             !inferenceContext.free(anotherLowerBound) &&
                             commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) {
-                        return generateReferenceToTargetConstraint(tree, from, to,
-                            resultInfo, inferenceContext);
+                        return true;
                     }
                 }
             }
@@ -485,12 +487,11 @@
             for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) {
                 Type sup = types.asSuper(t, to.tsym);
                 if (sup != null && sup.isRaw()) {
-                    return generateReferenceToTargetConstraint(tree, from, to,
-                            resultInfo, inferenceContext);
+                    return true;
                 }
             }
         }
-        return to;
+        return false;
     }
 
     private boolean commonSuperWithDiffParameterization(Type t, Type s) {
@@ -1477,21 +1478,16 @@
                     //not a throws undet var
                     return false;
                 }
-                if (t.getBounds(InferenceBound.EQ, InferenceBound.LOWER, InferenceBound.UPPER)
-                            .diff(t.getDeclaredBounds()).nonEmpty()) {
-                    //not an unbounded undet var
-                    return false;
-                }
                 Infer infer = inferenceContext.infer;
-                for (Type db : t.getDeclaredBounds()) {
+                for (Type db : t.getBounds(InferenceBound.UPPER)) {
                     if (t.isInterface()) continue;
-                    if (infer.types.asSuper(infer.syms.runtimeExceptionType, db.tsym) != null) {
-                        //declared bound is a supertype of RuntimeException
-                        return true;
+                    if (infer.types.asSuper(infer.syms.runtimeExceptionType, db.tsym) == null) {
+                        //upper bound is not a supertype of RuntimeException - give up
+                        return false;
                     }
                 }
-                //declared bound is more specific then RuntimeException - give up
-                return false;
+
+                return true;
             }
 
             @Override
@@ -1655,12 +1651,10 @@
     class GraphSolver {
 
         InferenceContext inferenceContext;
-        Map<Type, Set<Type>> stuckDeps;
         Warner warn;
 
-        GraphSolver(InferenceContext inferenceContext, Map<Type, Set<Type>> stuckDeps, Warner warn) {
+        GraphSolver(InferenceContext inferenceContext, Warner warn) {
             this.inferenceContext = inferenceContext;
-            this.stuckDeps = stuckDeps;
             this.warn = warn;
         }
 
@@ -1671,7 +1665,7 @@
          */
         void solve(GraphStrategy sstrategy) {
             doIncorporation(inferenceContext, warn); //initial propagation of bounds
-            InferenceGraph inferenceGraph = new InferenceGraph(stuckDeps);
+            InferenceGraph inferenceGraph = new InferenceGraph();
             while (!sstrategy.done()) {
                 if (dependenciesFolder != null) {
                     //add this graph to the pending queue
@@ -1720,12 +1714,12 @@
              */
             class Node extends GraphUtils.TarjanNode<ListBuffer<Type>, Node> implements DottableNode<ListBuffer<Type>, Node> {
 
-                /** map listing all dependencies (grouped by kind) */
-                EnumMap<DependencyKind, Set<Node>> deps;
+                /** node dependencies */
+                Set<Node> deps;
 
                 Node(Type ivar) {
                     super(ListBuffer.of(ivar));
-                    this.deps = new EnumMap<>(DependencyKind.class);
+                    this.deps = new HashSet<>();
                 }
 
                 @Override
@@ -1734,76 +1728,53 @@
                 }
 
                 public Iterable<? extends Node> getAllDependencies() {
-                    return getDependencies(DependencyKind.values());
+                    return deps;
                 }
 
                 @Override
                 public Collection<? extends Node> getDependenciesByKind(GraphUtils.DependencyKind dk) {
-                    return getDependencies((DependencyKind)dk);
-                }
-
-                /**
-                 * Retrieves all dependencies with given kind(s).
-                 */
-                protected Set<Node> getDependencies(DependencyKind... depKinds) {
-                    Set<Node> buf = new LinkedHashSet<>();
-                    for (DependencyKind dk : depKinds) {
-                        Set<Node> depsByKind = deps.get(dk);
-                        if (depsByKind != null) {
-                            buf.addAll(depsByKind);
-                        }
+                    if (dk == DependencyKind.BOUND) {
+                        return deps;
+                    } else {
+                        throw new IllegalStateException();
                     }
-                    return buf;
                 }
 
                 /**
                  * Adds dependency with given kind.
                  */
-                protected void addDependency(DependencyKind dk, Node depToAdd) {
-                    Set<Node> depsByKind = deps.get(dk);
-                    if (depsByKind == null) {
-                        depsByKind = new LinkedHashSet<>();
-                        deps.put(dk, depsByKind);
-                    }
-                    depsByKind.add(depToAdd);
+                protected void addDependency(Node depToAdd) {
+                    deps.add(depToAdd);
                 }
 
                 /**
                  * Add multiple dependencies of same given kind.
                  */
-                protected void addDependencies(DependencyKind dk, Set<Node> depsToAdd) {
+                protected void addDependencies(Set<Node> depsToAdd) {
                     for (Node n : depsToAdd) {
-                        addDependency(dk, n);
+                        addDependency(n);
                     }
                 }
 
                 /**
                  * Remove a dependency, regardless of its kind.
                  */
-                protected Set<DependencyKind> removeDependency(Node n) {
-                    Set<DependencyKind> removedKinds = new HashSet<>();
-                    for (DependencyKind dk : DependencyKind.values()) {
-                        Set<Node> depsByKind = deps.get(dk);
-                        if (depsByKind == null) continue;
-                        if (depsByKind.remove(n)) {
-                            removedKinds.add(dk);
-                        }
-                    }
-                    return removedKinds;
+                protected boolean removeDependency(Node n) {
+                    return deps.remove(n);
                 }
 
                 /**
                  * Compute closure of a give node, by recursively walking
                  * through all its dependencies (of given kinds)
                  */
-                protected Set<Node> closure(DependencyKind... depKinds) {
+                protected Set<Node> closure() {
                     boolean progress = true;
                     Set<Node> closure = new HashSet<>();
                     closure.add(this);
                     while (progress) {
                         progress = false;
                         for (Node n1 : new HashSet<>(closure)) {
-                            progress = closure.addAll(n1.getDependencies(depKinds));
+                            progress = closure.addAll(n1.deps);
                         }
                     }
                     return closure;
@@ -1815,9 +1786,8 @@
                  */
                 protected boolean isLeaf() {
                     //no deps, or only one self dep
-                    Set<Node> allDeps = getDependencies(DependencyKind.BOUND, DependencyKind.STUCK);
-                    if (allDeps.isEmpty()) return true;
-                    for (Node n : allDeps) {
+                    if (deps.isEmpty()) return true;
+                    for (Node n : deps) {
                         if (n != this) {
                             return false;
                         }
@@ -1834,24 +1804,15 @@
                     for (Node n : nodes) {
                         Assert.check(n.data.length() == 1, "Attempt to merge a compound node!");
                         data.appendList(n.data);
-                        for (DependencyKind dk : DependencyKind.values()) {
-                            addDependencies(dk, n.getDependencies(dk));
-                        }
+                        addDependencies(n.deps);
                     }
                     //update deps
-                    EnumMap<DependencyKind, Set<Node>> deps2 = new EnumMap<>(DependencyKind.class);
-                    for (DependencyKind dk : DependencyKind.values()) {
-                        for (Node d : getDependencies(dk)) {
-                            Set<Node> depsByKind = deps2.get(dk);
-                            if (depsByKind == null) {
-                                depsByKind = new LinkedHashSet<>();
-                                deps2.put(dk, depsByKind);
-                            }
-                            if (data.contains(d.data.first())) {
-                                depsByKind.add(this);
-                            } else {
-                                depsByKind.add(d);
-                            }
+                    Set<Node> deps2 = new HashSet<>();
+                    for (Node d : deps) {
+                        if (data.contains(d.data.first())) {
+                            deps2.add(this);
+                        } else {
+                            deps2.add(d);
                         }
                     }
                     deps = deps2;
@@ -1862,9 +1823,9 @@
                  * topology.
                  */
                 private void graphChanged(Node from, Node to) {
-                    for (DependencyKind dk : removeDependency(from)) {
+                    if (removeDependency(from)) {
                         if (to != null) {
-                            addDependency(dk, to);
+                            addDependency(to);
                         }
                     }
                 }
@@ -1880,22 +1841,19 @@
                 public Properties dependencyAttributes(Node sink, GraphUtils.DependencyKind dk) {
                     Properties p = new Properties();
                     p.put("style", ((DependencyKind)dk).dotSyle);
-                    if (dk == DependencyKind.STUCK) return p;
-                    else {
-                        StringBuilder buf = new StringBuilder();
-                        String sep = "";
-                        for (Type from : data) {
-                            UndetVar uv = (UndetVar)inferenceContext.asUndetVar(from);
-                            for (Type bound : uv.getBounds(InferenceBound.values())) {
-                                if (bound.containsAny(List.from(sink.data))) {
-                                    buf.append(sep);
-                                    buf.append(bound);
-                                    sep = ",";
-                                }
+                    StringBuilder buf = new StringBuilder();
+                    String sep = "";
+                    for (Type from : data) {
+                        UndetVar uv = (UndetVar)inferenceContext.asUndetVar(from);
+                        for (Type bound : uv.getBounds(InferenceBound.values())) {
+                            if (bound.containsAny(List.from(sink.data))) {
+                                buf.append(sep);
+                                buf.append(bound);
+                                sep = ",";
                             }
                         }
-                        p.put("label", "\"" + buf.toString() + "\"");
                     }
+                    p.put("label", "\"" + buf.toString() + "\"");
                     return p;
                 }
             }
@@ -1903,8 +1861,8 @@
             /** the nodes in the inference graph */
             ArrayList<Node> nodes;
 
-            InferenceGraph(Map<Type, Set<Type>> optDeps) {
-                initNodes(optDeps);
+            InferenceGraph() {
+                initNodes();
             }
 
             /**
@@ -1946,7 +1904,7 @@
              * in the graph. For each component containing more than one node, a super node is
              * created, effectively replacing the original cyclic nodes.
              */
-            void initNodes(Map<Type, Set<Type>> stuckDeps) {
+            void initNodes() {
                 //add nodes
                 nodes = new ArrayList<>();
                 for (Type t : inferenceContext.restvars()) {
@@ -1955,17 +1913,12 @@
                 //add dependencies
                 for (Node n_i : nodes) {
                     Type i = n_i.data.first();
-                    Set<Type> optDepsByNode = stuckDeps.get(i);
                     for (Node n_j : nodes) {
                         Type j = n_j.data.first();
                         UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
                         if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                             //update i's bound dependencies
-                            n_i.addDependency(DependencyKind.BOUND, n_j);
-                        }
-                        if (optDepsByNode != null && optDepsByNode.contains(j)) {
-                            //update i's stuck dependencies
-                            n_i.addDependency(DependencyKind.STUCK, n_j);
+                            n_i.addDependency(n_j);
                         }
                     }
                 }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java
index 398e291..f44cdc5 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java
@@ -469,15 +469,11 @@
         }
     }
 
-    private void solve(GraphStrategy ss, Warner warn) {
-        solve(ss, new HashMap<Type, Set<Type>>(), warn);
-    }
-
     /**
      * Solve with given graph strategy.
      */
-    private void solve(GraphStrategy ss, Map<Type, Set<Type>> stuckDeps, Warner warn) {
-        GraphSolver s = infer.new GraphSolver(this, stuckDeps, warn);
+    private void solve(GraphStrategy ss, Warner warn) {
+        GraphSolver s = infer.new GraphSolver(this, warn);
         s.solve(ss);
     }
 
@@ -506,12 +502,12 @@
     /**
      * Solve at least one variable in given list.
      */
-    public void solveAny(List<Type> varsToSolve, Map<Type, Set<Type>> optDeps, Warner warn) {
+    public void solveAny(List<Type> varsToSolve, Warner warn) {
         solve(infer.new BestLeafSolver(varsToSolve.intersect(restvars())) {
             public boolean done() {
                 return instvars().intersect(varsToSolve).nonEmpty();
             }
-        }, optDeps, warn);
+        }, warn);
     }
 
     /**
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java
index 1c84b51..899365f 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java
@@ -380,13 +380,17 @@
                 dest = CharBuffer.allocate(newCapacity).put(dest);
             } else if (result.isMalformed() || result.isUnmappable()) {
                 // bad character in input
+                StringBuilder unmappable = new StringBuilder();
+                int len = result.length();
 
-                log.error(new SimpleDiagnosticPosition(dest.limit()),
-                          "illegal.char.for.encoding",
-                          charset == null ? encodingName : charset.name());
+                for (int i = 0; i < len; i++) {
+                    unmappable.append(String.format("%02X", inbuf.get()));
+                }
 
-                // skip past the coding error
-                inbuf.position(inbuf.position() + result.length());
+                String charsetName = charset == null ? encodingName : charset.name();
+
+                log.error(dest.limit(),
+                          Errors.IllegalCharForEncoding(unmappable.toString(), charsetName));
 
                 // undo the flip() to prepare the output buffer
                 // for more translation
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
index 53f515d..1f1b1c7 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
@@ -74,10 +74,10 @@
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.ModuleWrappers.Configuration;
-import com.sun.tools.javac.util.ModuleWrappers.Layer;
-import com.sun.tools.javac.util.ModuleWrappers.ModuleFinder;
-import com.sun.tools.javac.util.ModuleWrappers.ServiceLoaderHelper;
+import com.sun.tools.javac.util.JDK9Wrappers.Configuration;
+import com.sun.tools.javac.util.JDK9Wrappers.Layer;
+import com.sun.tools.javac.util.JDK9Wrappers.ModuleFinder;
+import com.sun.tools.javac.util.JDK9Wrappers.ServiceLoaderHelper;
 
 import static java.nio.file.FileVisitOption.FOLLOW_LINKS;
 
@@ -972,7 +972,7 @@
             Collection<Path> paths = locations.getLocation(location);
             ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[paths.size()]));
             Layer bootLayer = Layer.boot();
-            Configuration cf = bootLayer.configuration().resolveRequiresAndUses(ModuleFinder.empty(), finder, Collections.emptySet());
+            Configuration cf = bootLayer.configuration().resolveRequiresAndUses(ModuleFinder.of(), finder, Collections.emptySet());
             Layer layer = bootLayer.defineModulesWithOneLoader(cf, ClassLoader.getSystemClassLoader());
             return ServiceLoaderHelper.load(layer, service);
         } else {
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
index 12106e3..2ec0256 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
@@ -1062,7 +1062,7 @@
                     return null;
                 }
 
-                if (p.getFileName().toString().endsWith(".jar")) {
+                if (p.getFileName().toString().endsWith(".jar") && fsInfo.exists(p)) {
                     try (FileSystem fs = FileSystems.newFileSystem(p, null)) {
                         Path moduleInfoClass = fs.getPath("module-info.class");
                         if (Files.exists(moduleInfoClass)) {
@@ -1138,7 +1138,7 @@
                     }
                 }
 
-                if (warn && false) {  // temp disable
+                if (warn && false) {  // temp disable, when enabled, massage examples.not-yet.txt suitably.
                     log.warning(Warnings.LocnUnknownFileOnModulePath(p));
                 }
                 return null;
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
index a531e17..3d6169d 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
@@ -522,8 +522,9 @@
 compiler.err.illegal.char=\
     illegal character: ''{0}''
 
+# 0: string, 1: string
 compiler.err.illegal.char.for.encoding=\
-    unmappable character for encoding {0}
+    unmappable character (0x{0}) for encoding {1}
 
 # 0: set of modifier, 1: set of modifier
 compiler.err.illegal.combination.of.modifiers=\
@@ -779,6 +780,10 @@
     bad return type in lambda expression\n\
     {0}
 
+compiler.misc.stat.expr.expected=\
+    lambda body is not compatible with a void functional interface\n\
+    (consider using a block lambda body, or use a statement expression instead)
+
 # 0: type
 compiler.misc.incompatible.ret.type.in.mref=\
     bad return type in method reference\n\
@@ -2747,9 +2752,6 @@
 compiler.err.module.decl.sb.in.module-info.java=\
     module declarations should be in a file named module-info.java
 
-compiler.err.unexpected.after.module=\
-    unexpected input after module declaration
-
 compiler.err.module-info.with.xmodule.sourcepath=\
     illegal combination of -Xmodule and module-info on sourcepath
 
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java
new file mode 100644
index 0000000..c9c9046
--- /dev/null
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.ServiceLoader;
+
+/**
+ *  This class provides wrappers for classes and methods that are new in JDK 9, and which are not
+ *  available on older versions of the platform on which javac may be compiled and run.
+ *  In future releases, when javac is always compiled on JDK 9 or later, the use of these wrappers
+ *  can be replaced by use of the real underlying classes.
+ *
+ *  <p>Wrapper classes provide a subset of the API of the wrapped classes, as needed for use
+ *  in javac. Wrapper objects contain an {@code Object} reference to the underlying runtime object,
+ *  and {@code Class} and {@code Method} objects for obtaining or using such instances via
+ *  runtime reflection.  The {@code Class} and {@code Method} objects are set up on a per-class
+ *  basis, by an {@code init} method, which is called from static methods on the wrapper class,
+ *  or in the constructor, when instances are created.
+ *  <p>
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class JDK9Wrappers {
+
+    /**
+     * Helper class for new method in java.util.ServiceLoader.
+     */
+    public static final class ServiceLoaderHelper {
+        @SuppressWarnings("unchecked")
+        public static <S> ServiceLoader<S> load(Layer layer, Class<S> service) {
+            try {
+                init();
+                Object result = loadMethod.invoke(null, layer.theRealLayer, service);
+                return (ServiceLoader<S>)result;
+            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        // -----------------------------------------------------------------------------------------
+
+        private static Method loadMethod = null;
+
+        private static void init() {
+            if (loadMethod == null) {
+                try {
+                    Class<?> layerClass = Layer.layerClass;
+                    loadMethod = ServiceLoader.class.getDeclaredMethod("load", layerClass, Class.class);
+                } catch (NoSuchMethodException | SecurityException ex) {
+                    throw new Abort(ex);
+                }
+            }
+        }
+    }
+
+    /**
+     * Wrapper class for java.lang.module.ModuleFinder.
+     */
+    public static class ModuleFinder {
+        private final Object theRealModuleFinder;
+
+        private ModuleFinder(Object moduleFinder) {
+            this.theRealModuleFinder = moduleFinder;
+            init();
+        }
+
+        public static ModuleFinder of(Path... dirs) {
+            try {
+                init();
+                Object result = ofMethod.invoke(null, (Object)dirs);
+                ModuleFinder mFinder = new ModuleFinder(result);
+                return mFinder;
+            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        // -----------------------------------------------------------------------------------------
+
+        private static Class<?> moduleFinderClass = null;
+        private static Method ofMethod;
+
+        static final Class<?> getModuleFinderClass() {
+            init();
+            return moduleFinderClass;
+        }
+
+        private static void init() {
+            if (moduleFinderClass == null) {
+                try {
+                    moduleFinderClass = Class.forName("java.lang.module.ModuleFinder", false, null);
+                    ofMethod = moduleFinderClass.getDeclaredMethod("of", Path[].class);
+                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
+                    throw new Abort(ex);
+                }
+            }
+        }
+    }
+
+    /**
+     * Wrapper class for java.lang.module.Configuration.
+     */
+    public static final class Configuration {
+        private final Object theRealConfiguration;
+
+        private Configuration(Object configuration) {
+            this.theRealConfiguration = configuration;
+            init();
+        }
+
+        public Configuration resolveRequiresAndUses(
+                ModuleFinder beforeFinder,
+                ModuleFinder afterFinder,
+                Collection<String> roots) {
+            try {
+                Object result = resolveRequiresAndUsesMethod.invoke(theRealConfiguration,
+                                    beforeFinder.theRealModuleFinder,
+                                    afterFinder.theRealModuleFinder,
+                                    roots
+                                );
+                Configuration configuration = new Configuration(result);
+                return configuration;
+            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        // -----------------------------------------------------------------------------------------
+
+        private static Class<?> configurationClass = null;
+        private static Method resolveRequiresAndUsesMethod;
+
+        static final Class<?> getConfigurationClass() {
+            init();
+            return configurationClass;
+        }
+
+        private static void init() {
+            if (configurationClass == null) {
+                try {
+                    configurationClass = Class.forName("java.lang.module.Configuration", false, null);
+                    Class<?> moduleFinderInterface = ModuleFinder.getModuleFinderClass();
+                    resolveRequiresAndUsesMethod = configurationClass.getDeclaredMethod("resolveRequiresAndUses",
+                                moduleFinderInterface,
+                                moduleFinderInterface,
+                                Collection.class
+                    );
+                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
+                    throw new Abort(ex);
+                }
+            }
+        }
+    }
+
+    /**
+     * Wrapper class for java.lang.module.Layer.
+     */
+    public static final class Layer {
+        private final Object theRealLayer;
+
+        private Layer(Object layer) {
+            this.theRealLayer = layer;
+        }
+
+        public static Layer boot() {
+            try {
+                init();
+                Object result = bootMethod.invoke(null);
+                Layer layer = new Layer(result);
+                return layer;
+            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        public Configuration configuration() {
+            try {
+                Object result = configurationMethod.invoke(theRealLayer);
+                Configuration configuration = new Configuration(result);
+                return configuration;
+            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        public Layer defineModulesWithOneLoader(Configuration configuration, ClassLoader parentClassLoader) {
+            try {
+                Object result = defineModulesWithOneLoaderMethod.invoke(
+                        theRealLayer, configuration.theRealConfiguration, parentClassLoader);
+                Layer layer = new Layer(result);
+                return layer;
+            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        // -----------------------------------------------------------------------------------------
+
+        private static Class<?> layerClass = null;
+        private static Method bootMethod;
+        private static Method defineModulesWithOneLoaderMethod;
+        private static Method configurationMethod;
+
+        private static void init() {
+            if (layerClass == null) {
+                try {
+                    layerClass = Class.forName("java.lang.reflect.Layer", false, null);
+                    bootMethod = layerClass.getDeclaredMethod("boot");
+                    defineModulesWithOneLoaderMethod = layerClass.getDeclaredMethod("defineModulesWithOneLoader",
+                                Configuration.getConfigurationClass(),
+                                ClassLoader.class);
+                    configurationMethod = layerClass.getDeclaredMethod("configuration");
+                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
+                    throw new Abort(ex);
+                }
+            }
+        }
+    }
+}
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleWrappers.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleWrappers.java
deleted file mode 100644
index a2adaac..0000000
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleWrappers.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.util;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.ServiceLoader;
-
-/** This class provides wrappers for classes and methods that are new in JDK 9, and which are not
- *  available on older versions of the platform on which javac may be compiled and run.
- *  In future releases, when javac is always compiled on JDK 9 or later, the use of these wrappers
- *  can be replaced by use of the real underlying classes.
- */
-public class ModuleWrappers {
-    public static final class ServiceLoaderHelper {
-        @SuppressWarnings("unchecked")
-        public static <S> ServiceLoader<S> load(Layer layer, Class<S> service) {
-            try {
-                Class<?> layerClass = LayerHelper.getLayerClass();
-                Method loadMethod = ServiceLoader.class
-                        .getDeclaredMethod("load", layerClass, Class.class);
-                Object result = loadMethod.invoke(ServiceLoader.class, layer.theRealLayer, service);
-                return (ServiceLoader<S>)result;
-            } catch (NoSuchMethodException |
-                    SecurityException |
-                    IllegalArgumentException |
-                    IllegalAccessException |
-                    InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-        }
-    }
-
-    public static class ModuleFinder {
-        Object theRealModuleFinder;
-
-        private ModuleFinder(Object moduleFinder) {
-            this.theRealModuleFinder = moduleFinder;
-        }
-
-        public static ModuleFinder of(Path... dirs) {
-            try {
-                Object result = ModuleFinderHelper.getOfMethod()
-                        .invoke(ModuleFinderHelper.moduleFinderInterface, (Object)dirs);
-                ModuleFinder mFinder = new ModuleFinder(result);
-                return mFinder;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        public static ModuleFinder empty() {
-            try {
-                Object result = ModuleFinderHelper.getEmptyMethod()
-                        .invoke(ModuleFinderHelper.moduleFinderInterface);
-                ModuleFinder mFinder = new ModuleFinder(result);
-                return mFinder;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-        }
-    }
-
-    private static class ModuleFinderHelper {
-        static Method ofMethod = null;
-        static Method emptyMethod = null;
-        static Class<?> moduleFinderInterface;
-
-        static Method getOfMethod() {
-            if (ModuleFinderHelper.ofMethod == null) {
-                try {
-                    getModuleFinderInterface();
-                    ofMethod = moduleFinderInterface.getDeclaredMethod("of", Path[].class);
-                } catch (NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return ofMethod;
-        }
-
-        static Method getEmptyMethod() {
-            if (emptyMethod == null) {
-                try {
-                    getModuleFinderInterface();
-                    emptyMethod = moduleFinderInterface.getDeclaredMethod("empty");
-                } catch (NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return emptyMethod;
-        }
-
-        static Class<?> getModuleFinderInterface() {
-            if (moduleFinderInterface == null) {
-                try {
-                    moduleFinderInterface = Class.forName("java.lang.module.ModuleFinder", false, ClassLoader.getSystemClassLoader());
-                } catch (ClassNotFoundException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return moduleFinderInterface;
-        }
-    }
-
-    public static final class Configuration {
-        Object theRealConfiguration;
-
-        private Configuration(Object configuration) {
-            this.theRealConfiguration = configuration;
-        }
-
-        public Configuration resolveRequiresAndUses(
-                ModuleFinder beforeFinder,
-                ModuleFinder afterFinder,
-                Collection<String> roots) {
-            try {
-                Object result = ConfigurationHelper.getResolveRequiresAndUses()
-                        .invoke(theRealConfiguration,
-                                    beforeFinder.theRealModuleFinder,
-                                    afterFinder.theRealModuleFinder,
-                                    roots
-                                );
-                Configuration configuration = new Configuration(result);
-                return configuration;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-        }
-    }
-
-    private static class ConfigurationHelper {
-        static Method resolveRequiresAndUsesMethod;
-        static Class<?> configurationClass;
-
-        static Method getResolveRequiresAndUses() {
-            if (resolveRequiresAndUsesMethod == null) {
-                try {
-                    getConfigurationClass();
-                    Class<?> moduleFinderInterface = ModuleFinderHelper.getModuleFinderInterface();
-                    Class<?> configurationClass = ConfigurationHelper.getConfigurationClass();
-                    resolveRequiresAndUsesMethod = configurationClass.getDeclaredMethod("resolveRequiresAndUses",
-                                moduleFinderInterface,
-                                moduleFinderInterface,
-                                Collection.class
-                    );
-                } catch (NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return resolveRequiresAndUsesMethod;
-        }
-
-        static Class<?> getConfigurationClass() {
-            if (configurationClass == null) {
-                try {
-                    configurationClass = Class.forName("java.lang.module.Configuration", false, ClassLoader.getSystemClassLoader());
-                } catch (ClassNotFoundException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return configurationClass;
-        }
-    }
-
-    public static final class Layer {
-        Object theRealLayer;
-
-        private Layer(Object layer) {
-            this.theRealLayer = layer;
-        }
-
-        public static Layer boot() {
-            try {
-                Object result = LayerHelper.getBootMethod().invoke(LayerHelper.getLayerClass());
-                Layer layer = new Layer(result);
-                return layer;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        public Configuration configuration() {
-            try {
-                Object result = LayerHelper.getConfigurationMethod().invoke(theRealLayer);
-                Layer layer = new Layer(result);
-                return new Configuration(result);
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        public Layer defineModulesWithOneLoader(Configuration configuration, ClassLoader parentClassLoader) {
-            try {
-                Object result = LayerHelper.getDefineModulesWithOneLoaderMethod()
-                        .invoke(theRealLayer, configuration.theRealConfiguration, parentClassLoader);
-                Layer layer = new Layer(result);
-                return layer;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-    }
-
-    private static class LayerHelper {
-        static Class<?> layerClass;
-        static Method bootMethod;
-        static Method defineModulesWithOneLoaderMethod = null;
-        static Method configurationMethod;
-
-        static Class<?> getLayerClass() {
-            if (layerClass == null) {
-                try {
-                    layerClass = Class.forName("java.lang.reflect.Layer", false, ClassLoader.getSystemClassLoader());
-                } catch (ClassNotFoundException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return layerClass;
-        }
-
-        static Method getBootMethod() {
-            if (bootMethod == null) {
-                try {
-                    bootMethod = getLayerClass().getDeclaredMethod("boot");
-                } catch (NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return bootMethod;
-        }
-
-        static Method getDefineModulesWithOneLoaderMethod() {
-            if (defineModulesWithOneLoaderMethod == null) {
-                try {
-                    defineModulesWithOneLoaderMethod = getLayerClass().getDeclaredMethod("defineModulesWithOneLoader",
-                                ConfigurationHelper.getConfigurationClass(),
-                                ClassLoader.class
-                    );
-                } catch (NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return defineModulesWithOneLoaderMethod;
-        }
-
-        static Method getConfigurationMethod() {
-            if (configurationMethod == null) {
-                try {
-                    configurationMethod =  getLayerClass().getDeclaredMethod("configuration");
-                } catch (NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-            return configurationMethod;
-        }
-    }
-}
diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
index f86f874..9ab985b 100644
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
@@ -714,43 +714,43 @@
     }
 
     public String getText(String key) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key);
-        } catch (Exception e) {
-            //Check the shared properties file.
-            return message.getText(key);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key);
         }
+        // Check the shared properties file.
+        return message.getText(key);
     }
 
     public String getText(String key, String a1) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key, a1);
-        } catch (Exception e) {
-            //Check the shared properties file.
-            return message.getText(key, a1);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key, a1);
         }
+        // Check the shared properties file.
+        return message.getText(key, a1);
     }
 
     public String getText(String key, String a1, String a2) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key, a1, a2);
-        } catch (Exception e) {
-            //Check the shared properties file.
-            return message.getText(key, a1, a2);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key, a1, a2);
         }
+        // Check the shared properties file.
+        return message.getText(key, a1, a2);
     }
 
     public String getText(String key, String a1, String a2, String a3) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key, a1, a2, a3);
-        } catch (Exception e) {
-            //Check the shared properties file.
-            return message.getText(key, a1, a2, a3);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key, a1, a2, a3);
         }
+        // Check the shared properties file.
+        return message.getText(key, a1, a2, a3);
     }
 
     public abstract Content newContent();
diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
index e357556..094e699 100644
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
@@ -83,6 +83,34 @@
         this.resourcelocation = resourcelocation;
     }
 
+    private ResourceBundle initRB() {
+        ResourceBundle bundle = messageRB;
+        if (bundle == null) {
+            try {
+                messageRB = bundle =
+                        ResourceBundle.getBundle(resourcelocation, configuration.getLocale());
+            } catch (MissingResourceException e) {
+                throw new Error("Fatal: Resource (" + resourcelocation
+                        + ") for javadoc doclets is missing.");
+            }
+        }
+        return bundle;
+    }
+
+    /**
+     * Determines whether the given <code>key</code> can be retrieved
+     * from this <code>MessageRetriever</code>
+     *
+     * @param key
+     *        the resource <code>key</code>
+     * @return <code>true</code> if the given <code>key</code> is
+     *        contained in the underlying <code>ResourceBundle</code>.
+     */
+    public boolean containsKey(String key) {
+        ResourceBundle bundle = initRB();
+        return bundle.containsKey(key);
+    }
+
     /**
      * Get and format message string from resource
      *
@@ -92,15 +120,8 @@
      * exist in the properties file.
      */
     public String getText(String key, Object... args) throws MissingResourceException {
-        if (messageRB == null) {
-            try {
-                messageRB = ResourceBundle.getBundle(resourcelocation);
-            } catch (MissingResourceException e) {
-                throw new Error("Fatal: Resource (" + resourcelocation +
-                                    ") for javadoc doclets is missing.");
-            }
-        }
-        String message = messageRB.getString(key);
+        ResourceBundle bundle = initRB();
+        String message = bundle.getString(key);
         return MessageFormat.format(message, args);
     }
 
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java
index 34eced1..96f5549 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java
@@ -894,43 +894,43 @@
     }
 
     public String getText(String key) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key);
-        } catch (Exception e) {
-            //Check the shared properties file.
-            return message.getText(key);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key);
         }
+        // Check the shared properties file.
+        return message.getText(key);
     }
 
     public String getText(String key, String a1) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key, a1);
-        } catch (MissingResourceException e) {
-            //Check the shared properties file.
-            return message.getText(key, a1);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key, a1);
         }
+        // Check the shared properties file.
+        return message.getText(key, a1);
     }
 
     public String getText(String key, String a1, String a2) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key, a1, a2);
-        } catch (MissingResourceException e) {
-            //Check the shared properties file.
-            return message.getText(key, a1, a2);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key, a1, a2);
         }
+        // Check the shared properties file.
+        return message.getText(key, a1, a2);
     }
 
     public String getText(String key, String a1, String a2, String a3) {
-        try {
-            //Check the doclet specific properties file.
-            return getDocletSpecificMsg().getText(key, a1, a2, a3);
-        } catch (MissingResourceException e) {
-            //Check the shared properties file.
-            return message.getText(key, a1, a2, a3);
+        // Check the doclet specific properties file.
+        MessageRetriever docletMessage = getDocletSpecificMsg();
+        if (docletMessage.containsKey(key)) {
+            return docletMessage.getText(key, a1, a2, a3);
         }
+        // Check the shared properties file.
+        return message.getText(key, a1, a2, a3);
     }
 
     public abstract Content newContent();
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java
index 46d9a92..63f2ce7 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java
@@ -86,15 +86,32 @@
         this.resourcelocation = resourcelocation;
     }
 
-    private void initRB() {
-        if (messageRB == null) {
+    private ResourceBundle initRB() {
+        ResourceBundle bundle = messageRB;
+        if (bundle == null) {
             try {
-                messageRB = ResourceBundle.getBundle(resourcelocation, configuration.getLocale());
+                messageRB = bundle =
+                        ResourceBundle.getBundle(resourcelocation, configuration.getLocale());
             } catch (MissingResourceException e) {
                 throw new Error("Fatal: Resource (" + resourcelocation
                         + ") for javadoc doclets is missing.");
             }
         }
+        return bundle;
+    }
+
+    /**
+     * Determines whether the given <code>key</code> can be retrieved
+     * from this <code>MessageRetriever</code>
+     *
+     * @param key
+     *        the resource <code>key</code>
+     * @return <code>true</code> if the given <code>key</code> is
+     *        contained in the underlying <code>ResourceBundle</code>.
+     */
+    public boolean containsKey(String key) {
+        ResourceBundle bundle = initRB();
+        return bundle.containsKey(key);
     }
 
     /**
@@ -107,8 +124,8 @@
      * exist in the properties file.
      */
     public String getText(String key, Object... args) throws MissingResourceException {
-        initRB();
-        String message = messageRB.getString(key);
+        ResourceBundle bundle = initRB();
+        String message = bundle.getString(key);
         return MessageFormat.format(message, args);
     }
 
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependencies.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependencies.java
index c6fe442..5de014a 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependencies.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependencies.java
@@ -33,6 +33,7 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.regex.Pattern;
 
 import com.sun.tools.classfile.Dependency.Filter;
@@ -561,13 +562,10 @@
     }
 
     static abstract class BasicDependencyFinder implements Finder {
-        private Map<String,Location> locations = new HashMap<>();
+        private Map<String,Location> locations = new ConcurrentHashMap<>();
 
         Location getLocation(String className) {
-            Location l = locations.get(className);
-            if (l == null)
-                locations.put(className, l = new SimpleLocation(className));
-            return l;
+            return locations.computeIfAbsent(className, cn -> new SimpleLocation(cn));
         }
 
         class Visitor implements ConstantPool.Visitor<Void,Void>, Type.Visitor<Void, Void> {
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java
index 1228622..c39f5f2 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java
@@ -25,23 +25,24 @@
 
 package com.sun.tools.jdeps;
 
-import java.io.PrintStream;
-import java.util.ArrayList;
+import static com.sun.tools.jdeps.JdepsConfiguration.*;
+
+import com.sun.tools.classfile.Dependency.Location;
+import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
 import java.util.Map;
+import java.util.MissingResourceException;
 import java.util.Objects;
+import java.util.Optional;
+import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import com.sun.tools.classfile.Dependency.Location;
-
 /**
  * Dependency Analyzer.
  */
@@ -52,6 +53,7 @@
      */
     public enum Type {
         SUMMARY,
+        MODULE,  // equivalent to summary in addition, print module descriptor
         PACKAGE,
         CLASS,
         VERBOSE
@@ -62,9 +64,11 @@
      * Only the accepted dependencies are recorded.
      */
     interface Filter {
-        boolean accepts(Location origin, Archive originArchive, Location target, Archive targetArchive);
+        boolean accepts(Location origin, Archive originArchive,
+                        Location target, Archive targetArchive);
     }
 
+    protected final JdepsConfiguration configuration;
     protected final Type type;
     protected final Filter filter;
     protected final Map<Archive, Dependences> results = new HashMap<>();
@@ -78,7 +82,8 @@
      * @param type Type of the dependency analysis
      * @param filter
      */
-    public Analyzer(Type type, Filter filter) {
+    Analyzer(JdepsConfiguration config, Type type, Filter filter) {
+        this.configuration = config;
         this.type = type;
         this.filter = filter;
     }
@@ -86,16 +91,10 @@
     /**
      * Performs the dependency analysis on the given archives.
      */
-    public boolean run(Stream<? extends Archive> archives) {
-        return run(archives.collect(Collectors.toList()));
-    }
-
-    /**
-     * Performs the dependency analysis on the given archives.
-     */
-    public boolean run(Iterable<? extends Archive> archives) {
-        // build a map from Location to Archive
-        buildLocationArchiveMap(archives);
+    boolean run(Iterable<? extends Archive> archives,
+                Map<Location, Archive> locationMap)
+    {
+        this.locationToArchive.putAll(locationMap);
 
         // traverse and analyze all dependencies
         for (Archive archive : archives) {
@@ -106,40 +105,50 @@
         return true;
     }
 
-    protected void buildLocationArchiveMap(Iterable<? extends Archive> archives) {
-        // build a map from Location to Archive
-        for (Archive archive: archives) {
-            archive.getClasses()
-                   .forEach(l -> locationToArchive.putIfAbsent(l, archive));
-        }
+    /**
+     * Returns the analyzed archives
+     */
+    Set<Archive> archives() {
+        return results.keySet();
     }
 
-    public boolean hasDependences(Archive archive) {
+    /**
+     * Returns true if the given archive has dependences.
+     */
+    boolean hasDependences(Archive archive) {
         if (results.containsKey(archive)) {
             return results.get(archive).dependencies().size() > 0;
         }
         return false;
     }
 
-    public Set<String> dependences(Archive source) {
+    /**
+     * Returns the dependences, either class name or package name
+     * as specified in the given verbose level, from the given source.
+     */
+    Set<String> dependences(Archive source) {
         if (!results.containsKey(source)) {
             return Collections.emptySet();
         }
-        Dependences result = results.get(source);
-        return result.dependencies().stream()
-                     .map(Dep::target)
-                     .collect(Collectors.toSet());
+
+        return results.get(source).dependencies()
+                      .stream()
+                      .map(Dep::target)
+                      .collect(Collectors.toSet());
     }
 
-    public Stream<Archive> requires(Archive source) {
+    /**
+     * Returns the direct dependences of the given source
+     */
+    Stream<Archive> requires(Archive source) {
         if (!results.containsKey(source)) {
             return Stream.empty();
         }
-        Dependences result = results.get(source);
-        return result.requires().stream().filter(a -> !a.isEmpty());
+        return results.get(source).requires()
+                      .stream();
     }
 
-    public interface Visitor {
+    interface Visitor {
         /**
          * Visits a recorded dependency from origin to target which can be
          * a fully-qualified classname, a package name, a module or
@@ -153,7 +162,7 @@
      * Visit the dependencies of the given source.
      * If the requested level is SUMMARY, it will visit the required archives list.
      */
-    public void visitDependences(Archive source, Visitor v, Type level) {
+    void visitDependences(Archive source, Visitor v, Type level) {
         if (level == Type.SUMMARY) {
             final Dependences result = results.get(source);
             final Set<Archive> reqs = result.requires();
@@ -187,7 +196,7 @@
         }
     }
 
-    public void visitDependences(Archive source, Visitor v) {
+    void visitDependences(Archive source, Visitor v) {
         visitDependences(source, v, type);
     }
 
@@ -224,14 +233,28 @@
             }
         }
 
+        /*
+         * Returns the archive that contains the given location.
+         */
         Archive findArchive(Location t) {
+            // local in this archive
             if (archive.getClasses().contains(t))
                 return archive;
 
-            return locationToArchive.computeIfAbsent(t, _k -> NOT_FOUND);
+            Archive target;
+            if (locationToArchive.containsKey(t)) {
+                target = locationToArchive.get(t);
+            } else {
+                // special case JDK removed API
+                target = configuration.findClass(t)
+                    .orElseGet(() -> REMOVED_JDK_INTERNALS.contains(t)
+                                        ? REMOVED_JDK_INTERNALS
+                                        : NOT_FOUND);
+            }
+            return locationToArchive.computeIfAbsent(t, _k -> target);
         }
 
-        // return classname or package name depedning on the level
+        // return classname or package name depending on the level
         private String getLocationName(Location o) {
             if (level == Type.CLASS || level == Type.VERBOSE) {
                 return o.getClassName();
@@ -345,4 +368,71 @@
                     target, targetArchive.getName());
         }
     }
+
+    static final JdkInternals REMOVED_JDK_INTERNALS = new JdkInternals();
+
+    static class JdkInternals extends Module {
+        private final String BUNDLE = "com.sun.tools.jdeps.resources.jdkinternals";
+
+        private final Set<String> jdkinternals;
+        private final Set<String> jdkUnsupportedClasses;
+        private JdkInternals() {
+            super("JDK removed internal API");
+
+            try {
+                ResourceBundle rb = ResourceBundle.getBundle(BUNDLE);
+                this.jdkinternals = rb.keySet();
+            } catch (MissingResourceException e) {
+                throw new InternalError("Cannot find jdkinternals resource bundle");
+            }
+
+            this.jdkUnsupportedClasses = getUnsupportedClasses();
+        }
+
+        public boolean contains(Location location) {
+            if (jdkUnsupportedClasses.contains(location.getName() + ".class")) {
+                return false;
+            }
+
+            String cn = location.getClassName();
+            int i = cn.lastIndexOf('.');
+            String pn = i > 0 ? cn.substring(0, i) : "";
+            return jdkinternals.contains(cn) || jdkinternals.contains(pn);
+        }
+
+        @Override
+        public String name() {
+            return getName();
+        }
+
+        @Override
+        public boolean isJDK() {
+            return true;
+        }
+
+        @Override
+        public boolean isExported(String pn) {
+            return false;
+        }
+
+        private Set<String> getUnsupportedClasses() {
+            // jdk.unsupported may not be observable
+            Optional<Module> om = Profile.FULL_JRE.findModule(JDK_UNSUPPORTED);
+            if (om.isPresent()) {
+                return om.get().reader().entries();
+            }
+
+            // find from local run-time image
+            SystemModuleFinder system = new SystemModuleFinder();
+            if (system.find(JDK_UNSUPPORTED).isPresent()) {
+                try {
+                    return system.getClassReader(JDK_UNSUPPORTED).entries();
+                } catch (IOException e) {
+                    throw new UncheckedIOException(e);
+                }
+            }
+
+            return Collections.emptySet();
+        }
+    }
 }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Archive.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Archive.java
index 90e4890..fd5b9a2 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Archive.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Archive.java
@@ -27,6 +27,7 @@
 
 import com.sun.tools.classfile.Dependency.Location;
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.net.URI;
@@ -38,11 +39,12 @@
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Stream;
 
 /**
  * Represents the source of the class files.
  */
-public class Archive {
+public class Archive implements Closeable {
     public static Archive getInstance(Path p) {
         try {
             return new Archive(p, ClassFileReader.newInstance(p));
@@ -86,6 +88,10 @@
         return Module.UNNAMED_MODULE;
     }
 
+    public boolean contains(String entry) {
+        return reader.entries().contains(entry);
+    }
+
     public void addClass(Location origin) {
         deps.computeIfAbsent(origin, _k -> new HashSet<>());
     }
@@ -98,6 +104,15 @@
         return deps.keySet();
     }
 
+    public Stream<Location> getDependencies() {
+        return deps.values().stream()
+                   .flatMap(Set::stream);
+    }
+
+    public boolean hasDependences() {
+        return getDependencies().count() > 0;
+    }
+
     public void visitDependences(Visitor v) {
         for (Map.Entry<Location,Set<Location>> e: deps.entrySet()) {
             for (Location target : e.getValue()) {
@@ -164,6 +179,13 @@
     private boolean isJrt() {
         return location != null && location.getScheme().equals("jrt");
     }
+
+    @Override
+    public void close() throws IOException {
+        if (reader != null)
+            reader.close();
+    }
+
     interface Visitor {
         void visit(Location origin, Location target);
     }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java
index aa2e6ff..c1b4311 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java
@@ -29,6 +29,7 @@
 import com.sun.tools.classfile.ConstantPoolException;
 import com.sun.tools.classfile.Dependencies.ClassFileError;
 
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -48,17 +49,18 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * ClassFileReader reads ClassFile(s) of a given path that can be
  * a .class file, a directory, or a JAR file.
  */
-public class ClassFileReader {
+public class ClassFileReader implements Closeable {
     /**
      * Returns a ClassFileReader instance of a given path.
      */
     public static ClassFileReader newInstance(Path path) throws IOException {
-        if (!Files.exists(path)) {
+        if (Files.notExists(path)) {
             throw new FileNotFoundException(path.toString());
         }
 
@@ -173,7 +175,11 @@
 
     static boolean isClass(Path file) {
         String fn = file.getFileName().toString();
-        return fn.endsWith(".class") && !fn.equals(MODULE_INFO);
+        return fn.endsWith(".class");
+    }
+
+    @Override
+    public void close() throws IOException {
     }
 
     class FileIterator implements Iterator<ClassFile> {
@@ -218,13 +224,12 @@
         }
 
         protected Set<String> scan() {
-            try {
-                return Files.walk(path, Integer.MAX_VALUE)
-                        .filter(ClassFileReader::isClass)
-                        .map(f -> path.relativize(f))
-                        .map(Path::toString)
-                        .map(p -> p.replace(File.separatorChar, '/'))
-                        .collect(Collectors.toSet());
+            try (Stream<Path> stream = Files.walk(path, Integer.MAX_VALUE)) {
+                return stream.filter(ClassFileReader::isClass)
+                             .map(f -> path.relativize(f))
+                             .map(Path::toString)
+                             .map(p -> p.replace(File.separatorChar, '/'))
+                             .collect(Collectors.toSet());
             } catch (IOException e) {
                 throw new UncheckedIOException(e);
             }
@@ -235,7 +240,7 @@
                 int i = name.lastIndexOf('.');
                 String pathname = name.replace(".", fsSep) + ".class";
                 Path p = path.resolve(pathname);
-                if (!Files.exists(p)) {
+                if (Files.notExists(p)) {
                     p = path.resolve(pathname.substring(0, i) + "$" +
                             pathname.substring(i+1, pathname.length()));
                 }
@@ -261,13 +266,16 @@
         }
 
         class DirectoryIterator implements Iterator<ClassFile> {
-            private List<Path> entries;
+            private final List<Path> entries;
             private int index = 0;
             DirectoryIterator() throws IOException {
-                entries = Files.walk(path, Integer.MAX_VALUE)
-                               .filter(ClassFileReader::isClass)
-                               .collect(Collectors.toList());
-                index = 0;
+                List<Path> paths = null;
+                try (Stream<Path> stream = Files.walk(path, Integer.MAX_VALUE)) {
+                    paths = stream.filter(ClassFileReader::isClass)
+                                  .collect(Collectors.toList());
+                }
+                this.entries = paths;
+                this.index = 0;
             }
 
             public boolean hasNext() {
@@ -303,10 +311,15 @@
             this.jarfile = jf;
         }
 
+        @Override
+        public void close() throws IOException {
+            jarfile.close();
+        }
+
         protected Set<String> scan() {
             try (JarFile jf = new JarFile(path.toFile())) {
                 return jf.stream().map(JarEntry::getName)
-                         .filter(n -> n.endsWith(".class") && !n.endsWith(MODULE_INFO))
+                         .filter(n -> n.endsWith(".class"))
                          .collect(Collectors.toSet());
             } catch (IOException e) {
                 throw new UncheckedIOException(e);
@@ -409,7 +422,7 @@
             while (entries.hasMoreElements()) {
                 JarEntry e = entries.nextElement();
                 String name = e.getName();
-                if (name.endsWith(".class") && !name.equals(MODULE_INFO)) {
+                if (name.endsWith(".class")) {
                     return e;
                 }
             }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java
index 086e13a..fbcb9a0 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java
@@ -24,360 +24,285 @@
  */
 package com.sun.tools.jdeps;
 
+import static com.sun.tools.jdeps.Module.*;
+import static com.sun.tools.jdeps.Analyzer.NOT_FOUND;
+import static java.util.stream.Collectors.*;
+
 import com.sun.tools.classfile.AccessFlags;
 import com.sun.tools.classfile.ClassFile;
 import com.sun.tools.classfile.ConstantPoolException;
 import com.sun.tools.classfile.Dependencies;
 import com.sun.tools.classfile.Dependency;
+import com.sun.tools.classfile.Dependency.Location;
 
 import java.io.IOException;
-import java.nio.file.Path;
-import java.util.ArrayList;
+import java.io.UncheckedIOException;
 import java.util.Deque;
 import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.HashSet;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static com.sun.tools.jdeps.Module.*;
-import static com.sun.tools.jdeps.ModulePaths.SystemModulePath.JAVA_BASE;
+/**
+ * Parses class files and finds dependences
+ */
+class DependencyFinder {
+    private static Finder API_FINDER = new Finder(true);
+    private static Finder CLASS_FINDER = new Finder(false);
 
-public class DependencyFinder {
-    private final List<Archive> roots = new ArrayList<>();
-    private final List<Archive> classpaths = new ArrayList<>();
-    private final List<Module> modulepaths = new ArrayList<>();
-    private final List<String> classes = new ArrayList<>();
-    private final boolean compileTimeView;
+    private final JdepsConfiguration configuration;
+    private final JdepsFilter filter;
 
-    DependencyFinder(boolean compileTimeView) {
-        this.compileTimeView = compileTimeView;
+    private final Map<Finder, Deque<Archive>> parsedArchives = new ConcurrentHashMap<>();
+    private final Map<Location, Archive> parsedClasses = new ConcurrentHashMap<>();
+
+    private final ExecutorService pool = Executors.newFixedThreadPool(2);
+    private final Deque<FutureTask<Set<Location>>> tasks = new ConcurrentLinkedDeque<>();
+
+    DependencyFinder(JdepsConfiguration configuration,
+                     JdepsFilter filter) {
+        this.configuration = configuration;
+        this.filter = filter;
+        this.parsedArchives.put(API_FINDER, new ConcurrentLinkedDeque<>());
+        this.parsedArchives.put(CLASS_FINDER, new ConcurrentLinkedDeque<>());
     }
 
-    /*
-     * Adds a class name to the root set
-     */
-    void addClassName(String cn) {
-        classes.add(cn);
-    }
-
-    /*
-     * Adds the archive of the given path to the root set
-     */
-    void addRoot(Path path) {
-        addRoot(Archive.getInstance(path));
-    }
-
-    /*
-     * Adds the given archive to the root set
-     */
-    void addRoot(Archive archive) {
-        Objects.requireNonNull(archive);
-        if (!roots.contains(archive))
-            roots.add(archive);
+    Map<Location, Archive> locationToArchive() {
+        return parsedClasses;
     }
 
     /**
-     * Add an archive specified in the classpath.
+     * Returns the modules of all dependencies found
      */
-    void addClassPathArchive(Path path) {
-        addClassPathArchive(Archive.getInstance(path));
+    Stream<Archive> getDependences(Archive source) {
+        return source.getDependencies()
+                     .map(this::locationToArchive)
+                     .filter(a -> a != source);
     }
 
     /**
-     * Add an archive specified in the classpath.
-     */
-    void addClassPathArchive(Archive archive) {
-        Objects.requireNonNull(archive);
-        classpaths.add(archive);
-    }
-
-    /**
-     * Add an archive specified in the modulepath.
-     */
-    void addModule(Module m) {
-        Objects.requireNonNull(m);
-        modulepaths.add(m);
-    }
-
-    /**
-     * Returns the root set.
-     */
-    List<Archive> roots() {
-        return roots;
-    }
-
-    /**
-     * Returns a stream of all archives including the root set, module paths,
-     * and classpath.
+     * Returns the location to archive map; or NOT_FOUND.
      *
-     * This only returns the archives with classes parsed.
+     * Location represents a parsed class.
      */
-    Stream<Archive> archives() {
-        Stream<Archive> archives = Stream.concat(roots.stream(), modulepaths.stream());
-        archives = Stream.concat(archives, classpaths.stream());
-        return archives.filter(a -> !a.isEmpty())
-                       .distinct();
+    Archive locationToArchive(Location location) {
+        return parsedClasses.containsKey(location)
+            ? parsedClasses.get(location)
+            : configuration.findClass(location).orElse(NOT_FOUND);
     }
 
     /**
-     * Finds dependencies
-     *
-     * @param apiOnly  API only
-     * @param maxDepth depth of transitive dependency analysis; zero indicates
-     * @throws IOException
+     * Returns a map from an archive to its required archives
      */
-    void findDependencies(JdepsFilter filter, boolean apiOnly, int maxDepth)
-            throws IOException
-    {
-        Dependency.Finder finder =
-                apiOnly ? Dependencies.getAPIFinder(AccessFlags.ACC_PROTECTED)
-                        : Dependencies.getClassDependencyFinder();
+    Map<Archive, Set<Archive>> dependences() {
+        Map<Archive, Set<Archive>> map = new HashMap<>();
+        parsedArchives.values().stream()
+            .flatMap(Deque::stream)
+            .filter(a -> !a.isEmpty())
+            .forEach(source -> {
+                Set<Archive> deps = getDependences(source).collect(toSet());
+                if (!deps.isEmpty()) {
+                    map.put(source, deps);
+                }
+        });
+        return map;
+    }
 
-        // list of archives to be analyzed
-        Set<Archive> roots = new LinkedHashSet<>(this.roots);
+    boolean isParsed(Location location) {
+        return parsedClasses.containsKey(location);
+    }
 
-        // include java.base in root set
-        roots.add(JAVA_BASE);
+    /**
+     * Parses all class files from the given archive stream and returns
+     * all target locations.
+     */
+    public Set<Location> parse(Stream<? extends Archive> archiveStream) {
+        archiveStream.forEach(archive -> parse(archive, CLASS_FINDER));
+        return waitForTasksCompleted();
+    }
 
-        // If -include pattern specified, classes may be in module path or class path.
-        // To get compile time view analysis, all classes are analyzed.
-        // add all modules except JDK modules to root set
-        modulepaths.stream()
-                   .filter(filter::matches)
-                   .forEach(roots::add);
+    /**
+     * Parses the exported API class files from the given archive stream and
+     * returns all target locations.
+     */
+    public Set<Location> parseExportedAPIs(Stream<? extends Archive> archiveStream) {
+        archiveStream.forEach(archive -> parse(archive, API_FINDER));
+        return waitForTasksCompleted();
+    }
 
-        // add classpath to the root set
-        classpaths.stream()
-                .filter(filter::matches)
-                .forEach(roots::add);
-
-        // transitive dependency
-        int depth = maxDepth > 0 ? maxDepth : Integer.MAX_VALUE;
-
-        // Work queue of names of classfiles to be searched.
-        // Entries will be unique, and for classes that do not yet have
-        // dependencies in the results map.
-        ConcurrentLinkedDeque<String> deque = new ConcurrentLinkedDeque<>();
-        ConcurrentSkipListSet<String> doneClasses = new ConcurrentSkipListSet<>();
-
-        TaskExecutor executor = new TaskExecutor(finder, filter, apiOnly, deque, doneClasses);
+    /**
+     * Parses the named class from the given archive and
+     * returns all target locations the named class references.
+     */
+    public Set<Location> parse(Archive archive, String name) {
         try {
-            // get the immediate dependencies of the input files
-            for (Archive source : roots) {
-                executor.task(source, deque);
-            }
-            executor.waitForTasksCompleted();
-
-            List<Archive> archives = Stream.concat(Stream.concat(roots.stream(),
-                    modulepaths.stream()),
-                    classpaths.stream())
-                    .collect(Collectors.toList());
-
-            // Additional pass to find archive where dependences are identified
-            // and also any specified classes, if any.
-            // If -R is specified, perform transitive dependency analysis.
-            Deque<String> unresolved = new LinkedList<>(classes);
-            do {
-                String name;
-                while ((name = unresolved.poll()) != null) {
-                    if (doneClasses.contains(name)) {
-                        continue;
-                    }
-                    if (compileTimeView) {
-                        final String cn = name + ".class";
-                        // parse all classes in the source archive
-                        Optional<Archive> source = archives.stream()
-                                .filter(a -> a.reader().entries().contains(cn))
-                                .findFirst();
-                        trace("%s compile time view %s%n", name, source.map(Archive::getName).orElse(" not found"));
-                        if (source.isPresent()) {
-                            executor.runTask(source.get(), deque);
-                        }
-                    }
-                    ClassFile cf = null;
-                    for (Archive archive : archives) {
-                        cf = archive.reader().getClassFile(name);
-
-                        if (cf != null) {
-                            String classFileName;
-                            try {
-                                classFileName = cf.getName();
-                            } catch (ConstantPoolException e) {
-                                throw new Dependencies.ClassFileError(e);
-                            }
-                            if (!doneClasses.contains(classFileName)) {
-                                // if name is a fully-qualified class name specified
-                                // from command-line, this class might already be parsed
-                                doneClasses.add(classFileName);
-                                for (Dependency d : finder.findDependencies(cf)) {
-                                    if (depth == 0) {
-                                        // ignore the dependency
-                                        archive.addClass(d.getOrigin());
-                                        break;
-                                    } else if (filter.accepts(d) && filter.accept(archive)) {
-                                        // continue analysis on non-JDK classes
-                                        archive.addClass(d.getOrigin(), d.getTarget());
-                                        String cn = d.getTarget().getName();
-                                        if (!doneClasses.contains(cn) && !deque.contains(cn)) {
-                                            deque.add(cn);
-                                        }
-                                    } else {
-                                        // ensure that the parsed class is added the archive
-                                        archive.addClass(d.getOrigin());
-                                    }
-                                }
-                            }
-                            break;
-                        }
-                    }
-                    if (cf == null) {
-                        doneClasses.add(name);
-                    }
-                }
-                unresolved = deque;
-                deque = new ConcurrentLinkedDeque<>();
-            } while (!unresolved.isEmpty() && depth-- > 0);
-        } finally {
-            executor.shutdown();
+            return parse(archive, CLASS_FINDER, name);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
         }
-     }
+    }
 
     /**
-     * TaskExecutor creates FutureTask to analyze all classes in a given archive
+     * Parses the exported API of the named class from the given archive and
+     * returns all target locations the named class references.
      */
-    private class TaskExecutor {
-        final ExecutorService pool;
-        final Dependency.Finder finder;
-        final JdepsFilter filter;
-        final boolean apiOnly;
-        final Set<String> doneClasses;
-        final Map<Archive, FutureTask<Void>> tasks = new HashMap<>();
-
-        TaskExecutor(Dependency.Finder finder,
-                     JdepsFilter filter,
-                     boolean apiOnly,
-                     ConcurrentLinkedDeque<String> deque,
-                     Set<String> doneClasses) {
-            this.pool = Executors.newFixedThreadPool(2);
-            this.finder = finder;
-            this.filter = filter;
-            this.apiOnly = apiOnly;
-            this.doneClasses = doneClasses;
+    public Set<Location> parseExportedAPIs(Archive archive, String name)
+    {
+        try {
+            return parse(archive, API_FINDER, name);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
         }
+    }
 
-        /**
-         * Creates a new task to analyze class files in the given archive.
-         * The dependences are added to the given deque for analysis.
-         */
-        FutureTask<Void> task(Archive archive, final ConcurrentLinkedDeque<String> deque) {
-            trace("parsing %s %s%n", archive.getName(), archive.path());
-            FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
-                public Void call() throws Exception {
-                    for (ClassFile cf : archive.reader().getClassFiles()) {
-                        String classFileName;
-                        try {
-                            classFileName = cf.getName();
-                        } catch (ConstantPoolException e) {
-                            throw new Dependencies.ClassFileError(e);
-                        }
+    private Optional<FutureTask<Set<Location>>> parse(Archive archive, Finder finder) {
+        if (parsedArchives.get(finder).contains(archive))
+            return Optional.empty();
 
-                        // tests if this class matches the -include
-                        String cn = classFileName.replace('/', '.');
-                        if (!filter.matches(cn))
-                            continue;
+        parsedArchives.get(finder).add(archive);
 
-                        // if -apionly is specified, analyze only exported and public types
-                        if (apiOnly && !(isExported(archive, cn) && cf.access_flags.is(AccessFlags.ACC_PUBLIC)))
-                            continue;
-
-                        if (!doneClasses.contains(classFileName)) {
-                            doneClasses.add(classFileName);
-                        }
-
-                        for (Dependency d : finder.findDependencies(cf)) {
-                            if (filter.accepts(d) && filter.accept(archive)) {
-                                String name = d.getTarget().getName();
-                                if (!doneClasses.contains(name) && !deque.contains(name)) {
-                                    deque.add(name);
-                                }
-                                archive.addClass(d.getOrigin(), d.getTarget());
-                            } else {
-                                // ensure that the parsed class is added the archive
-                                archive.addClass(d.getOrigin());
-                            }
-                        }
+        trace("parsing %s %s%n", archive.getName(), archive.path());
+        FutureTask<Set<Location>> task = new FutureTask<>(new Callable<>() {
+            public Set<Location> call() throws Exception {
+                Set<Location> targets = new HashSet<>();
+                for (ClassFile cf : archive.reader().getClassFiles()) {
+                    String classFileName;
+                    try {
+                        classFileName = cf.getName();
+                    } catch (ConstantPoolException e) {
+                        throw new Dependencies.ClassFileError(e);
                     }
-                    return null;
-                }
-            });
-            tasks.put(archive, task);
-            pool.submit(task);
-            return task;
-        }
 
-        /*
-         * This task will parse all class files of the given archive, if it's a new task.
-         * This method waits until the task is completed.
-         */
-        void runTask(Archive archive, final ConcurrentLinkedDeque<String> deque) {
-            if (tasks.containsKey(archive))
-                return;
-
-            FutureTask<Void> task = task(archive, deque);
-            try {
-                // wait for completion
-                task.get();
-            } catch (InterruptedException|ExecutionException e) {
-                throw new Error(e);
-            }
-        }
-
-        /*
-         * Waits until all submitted tasks are completed.
-         */
-        void waitForTasksCompleted() {
-            try {
-                for (FutureTask<Void> t : tasks.values()) {
-                    if (t.isDone())
+                    // filter source class/archive
+                    String cn = classFileName.replace('/', '.');
+                    if (!finder.accept(archive, cn, cf.access_flags))
                         continue;
 
-                    // wait for completion
-                    t.get();
+                    // tests if this class matches the -include
+                    if (!filter.matches(cn))
+                        continue;
+
+                    for (Dependency d : finder.findDependencies(cf)) {
+                        if (filter.accepts(d)) {
+                            archive.addClass(d.getOrigin(), d.getTarget());
+                            targets.add(d.getTarget());
+                        } else {
+                            // ensure that the parsed class is added the archive
+                            archive.addClass(d.getOrigin());
+                        }
+                        parsedClasses.putIfAbsent(d.getOrigin(), archive);
+                    }
                 }
-            } catch (InterruptedException|ExecutionException e) {
-                throw new Error(e);
+
+                return targets;
             }
+        });
+        tasks.add(task);
+        pool.submit(task);
+        return Optional.of(task);
+    }
+
+    private Set<Location> parse(Archive archive, Finder finder, String name)
+        throws IOException
+    {
+        ClassFile cf = archive.reader().getClassFile(name);
+        if (cf == null) {
+            throw new IllegalArgumentException(archive.getName() + " does not contain " + name);
         }
 
-        /*
-         * Shutdown the executor service.
-         */
-        void shutdown() {
-            pool.shutdown();
+        Set<Location> targets = new HashSet<>();
+        String cn;
+        try {
+            cn =  cf.getName().replace('/', '.');
+        } catch (ConstantPoolException e) {
+            throw new Dependencies.ClassFileError(e);
         }
 
-        /**
-         * Tests if the given class name is exported by the given archive.
-         *
-         * All packages are exported in unnamed module.
-         */
-        private boolean isExported(Archive archive, String classname) {
-            int i = classname.lastIndexOf('.');
-            String pn = i > 0 ? classname.substring(0, i) : "";
-            return archive.getModule().isExported(pn);
+        if (!finder.accept(archive, cn, cf.access_flags))
+            return targets;
+
+        // tests if this class matches the -include
+        if (!filter.matches(cn))
+            return targets;
+
+        // skip checking filter.matches
+        for (Dependency d : finder.findDependencies(cf)) {
+            if (filter.accepts(d)) {
+                targets.add(d.getTarget());
+                archive.addClass(d.getOrigin(), d.getTarget());
+            } else {
+                // ensure that the parsed class is added the archive
+                archive.addClass(d.getOrigin());
+            }
+            parsedClasses.putIfAbsent(d.getOrigin(), archive);
+        }
+        return targets;
+    }
+
+    /*
+     * Waits until all submitted tasks are completed.
+     */
+    private Set<Location> waitForTasksCompleted() {
+        try {
+            Set<Location> targets = new HashSet<>();
+            FutureTask<Set<Location>> task;
+            while ((task = tasks.poll()) != null) {
+                // wait for completion
+                if (!task.isDone())
+                    targets.addAll(task.get());
+            }
+            return targets;
+        } catch (InterruptedException|ExecutionException e) {
+            throw new Error(e);
+        }
+    }
+
+    /*
+     * Shutdown the executor service.
+     */
+    void shutdown() {
+        pool.shutdown();
+    }
+
+    private interface SourceFilter {
+        boolean accept(Archive archive, String cn, AccessFlags accessFlags);
+    }
+
+    private static class Finder implements Dependency.Finder, SourceFilter {
+        private final Dependency.Finder finder;
+        private final boolean apiOnly;
+        Finder(boolean apiOnly) {
+            this.apiOnly = apiOnly;
+            this.finder = apiOnly
+                ? Dependencies.getAPIFinder(AccessFlags.ACC_PROTECTED)
+                : Dependencies.getClassDependencyFinder();
+
+        }
+
+        @Override
+        public boolean accept(Archive archive, String cn, AccessFlags accessFlags) {
+            int i = cn.lastIndexOf('.');
+            String pn = i > 0 ? cn.substring(0, i) : "";
+
+            // if -apionly is specified, analyze only exported and public types
+            // All packages are exported in unnamed module.
+            return apiOnly ? archive.getModule().isExported(pn) &&
+                                 accessFlags.is(AccessFlags.ACC_PUBLIC)
+                           : true;
+        }
+
+        @Override
+        public Iterable<? extends Dependency> findDependencies(ClassFile classfile) {
+            return finder.findDependencies(classfile);
         }
     }
 }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java
new file mode 100644
index 0000000..c7444c7
--- /dev/null
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java
@@ -0,0 +1,392 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.jdeps;
+
+import com.sun.tools.classfile.Dependency.Location;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static com.sun.tools.jdeps.Analyzer.Type.CLASS;
+import static com.sun.tools.jdeps.Analyzer.Type.VERBOSE;
+import static com.sun.tools.jdeps.Module.trace;
+import static java.util.stream.Collectors.*;
+
+/**
+ * Dependency Analyzer.
+ *
+ * Type of filters:
+ * source filter: -include <pattern>
+ * target filter: -package, -regex, -requires
+ *
+ * The initial archive set for analysis includes
+ * 1. archives specified in the command line arguments
+ * 2. observable modules matching the source filter
+ * 3. classpath archives matching the source filter or target filter
+ * 4. -addmods and -m root modules
+ */
+public class DepsAnalyzer {
+    final JdepsConfiguration configuration;
+    final JdepsFilter filter;
+    final JdepsWriter writer;
+    final Analyzer.Type verbose;
+    final boolean apiOnly;
+
+    final DependencyFinder finder;
+    final Analyzer analyzer;
+    final List<Archive> rootArchives = new ArrayList<>();
+
+    // parsed archives
+    final Set<Archive> archives = new LinkedHashSet<>();
+
+    public DepsAnalyzer(JdepsConfiguration config,
+                        JdepsFilter filter,
+                        JdepsWriter writer,
+                        Analyzer.Type verbose,
+                        boolean apiOnly) {
+        this.configuration = config;
+        this.filter = filter;
+        this.writer = writer;
+        this.verbose = verbose;
+        this.apiOnly = apiOnly;
+
+        this.finder = new DependencyFinder(config, filter);
+        this.analyzer = new Analyzer(configuration, verbose, filter);
+
+        // determine initial archives to be analyzed
+        this.rootArchives.addAll(configuration.initialArchives());
+
+        // if -include pattern is specified, add the matching archives on
+        // classpath to the root archives
+        if (filter.hasIncludePattern() || filter.hasTargetFilter()) {
+            configuration.getModules().values().stream()
+                .filter(source -> filter.include(source) && filter.matches(source))
+                .forEach(this.rootArchives::add);
+        }
+
+        // class path archives
+        configuration.classPathArchives().stream()
+            .filter(filter::matches)
+            .forEach(this.rootArchives::add);
+
+        // Include the root modules for analysis
+        this.rootArchives.addAll(configuration.rootModules());
+
+        trace("analyze root archives: %s%n", this.rootArchives);
+    }
+
+    /*
+     * Perform runtime dependency analysis
+     */
+    public boolean run() throws IOException {
+        return run(false, 1);
+    }
+
+    /**
+     * Perform compile-time view or run-time view dependency analysis.
+     *
+     * @param compileTimeView
+     * @param maxDepth  depth of recursive analysis.  depth == 0 if -R is set
+     */
+    public boolean run(boolean compileTimeView, int maxDepth) throws IOException {
+        try {
+            // parse each packaged module or classpath archive
+            if (apiOnly) {
+                finder.parseExportedAPIs(rootArchives.stream());
+            } else {
+                finder.parse(rootArchives.stream());
+            }
+            archives.addAll(rootArchives);
+
+            int depth = maxDepth > 0 ? maxDepth : Integer.MAX_VALUE;
+
+            // transitive analysis
+            if (depth > 1) {
+                if (compileTimeView)
+                    transitiveArchiveDeps(depth-1);
+                else
+                    transitiveDeps(depth-1);
+            }
+
+            Set<Archive> archives = archives();
+
+            // analyze the dependencies collected
+            analyzer.run(archives, finder.locationToArchive());
+
+            writer.generateOutput(archives, analyzer);
+        } finally {
+            finder.shutdown();
+        }
+        return true;
+    }
+
+    /**
+     * Returns the archives for reporting that has matching dependences.
+     *
+     * If -requires is set, they should be excluded.
+     */
+    Set<Archive> archives() {
+        if (filter.requiresFilter().isEmpty()) {
+            return archives.stream()
+                .filter(filter::include)
+                .filter(Archive::hasDependences)
+                .collect(Collectors.toSet());
+        } else {
+            // use the archives that have dependences and not specified in -requires
+            return archives.stream()
+                .filter(filter::include)
+                .filter(source -> !filter.requiresFilter().contains(source))
+                .filter(source ->
+                        source.getDependencies()
+                              .map(finder::locationToArchive)
+                              .anyMatch(a -> a != source))
+                .collect(Collectors.toSet());
+        }
+    }
+
+    /**
+     * Returns the dependences, either class name or package name
+     * as specified in the given verbose level.
+     */
+    Stream<String> dependences() {
+        return analyzer.archives().stream()
+                       .map(analyzer::dependences)
+                       .flatMap(Set::stream)
+                       .distinct();
+    }
+
+    /**
+     * Returns the archives that contains the given locations and
+     * not parsed and analyzed.
+     */
+    private Set<Archive> unresolvedArchives(Stream<Location> locations) {
+        return locations.filter(l -> !finder.isParsed(l))
+                        .distinct()
+                        .map(configuration::findClass)
+                        .flatMap(Optional::stream)
+                        .filter(filter::include)
+                        .collect(toSet());
+    }
+
+    /*
+     * Recursively analyzes entire module/archives.
+    */
+    private void transitiveArchiveDeps(int depth) throws IOException {
+        Stream<Location> deps = archives.stream()
+                                        .flatMap(Archive::getDependencies);
+
+        // start with the unresolved archives
+        Set<Archive> unresolved = unresolvedArchives(deps);
+        do {
+            // parse all unresolved archives
+            Set<Location> targets = apiOnly
+                ? finder.parseExportedAPIs(unresolved.stream())
+                : finder.parse(unresolved.stream());
+            archives.addAll(unresolved);
+
+            // Add dependencies to the next batch for analysis
+            unresolved = unresolvedArchives(targets.stream());
+        } while (!unresolved.isEmpty() && depth-- > 0);
+    }
+
+    /*
+     * Recursively analyze the class dependences
+     */
+    private void transitiveDeps(int depth) throws IOException {
+        Stream<Location> deps = archives.stream()
+                                        .flatMap(Archive::getDependencies);
+
+        Deque<Location> unresolved = deps.collect(Collectors.toCollection(LinkedList::new));
+        ConcurrentLinkedDeque<Location> deque = new ConcurrentLinkedDeque<>();
+        do {
+            Location target;
+            while ((target = unresolved.poll()) != null) {
+                if (finder.isParsed(target))
+                    continue;
+
+                Archive archive = configuration.findClass(target).orElse(null);
+                if (archive != null && filter.include(archive)) {
+                    archives.add(archive);
+
+                    String name = target.getName();
+                    Set<Location> targets = apiOnly
+                            ? finder.parseExportedAPIs(archive, name)
+                            : finder.parse(archive, name);
+
+                    // build unresolved dependencies
+                    targets.stream()
+                           .filter(t -> !finder.isParsed(t))
+                           .forEach(deque::add);
+                }
+            }
+            unresolved = deque;
+            deque = new ConcurrentLinkedDeque<>();
+        } while (!unresolved.isEmpty() && depth-- > 0);
+    }
+
+    // ----- for testing purpose -----
+
+    public static enum Info {
+        REQUIRES,
+        REQUIRES_PUBLIC,
+        EXPORTED_API,
+        MODULE_PRIVATE,
+        QUALIFIED_EXPORTED_API,
+        INTERNAL_API,
+        JDK_INTERNAL_API,
+        JDK_REMOVED_INTERNAL_API
+    }
+
+    public static class Node {
+        public final String name;
+        public final String source;
+        public final Info info;
+        Node(String name, Info info) {
+            this(name, name, info);
+        }
+        Node(String name, String source, Info info) {
+            this.name = name;
+            this.source = source;
+            this.info = info;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            if (info != Info.REQUIRES && info != Info.REQUIRES_PUBLIC)
+                sb.append(source).append("/");
+
+            sb.append(name);
+            if (info == Info.QUALIFIED_EXPORTED_API)
+                sb.append(" (qualified)");
+            else if (info == Info.JDK_INTERNAL_API)
+                sb.append(" (JDK internal)");
+            else if (info == Info.INTERNAL_API)
+                sb.append(" (internal)");
+            return sb.toString();
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof Node))
+                return false;
+
+            Node other = (Node)o;
+            return this.name.equals(other.name) &&
+                    this.source.equals(other.source) &&
+                    this.info.equals(other.info);
+        }
+
+        @Override
+        public int hashCode() {
+            int result = name.hashCode();
+            result = 31 * result + source.hashCode();
+            result = 31 * result + info.hashCode();
+            return result;
+        }
+    }
+
+    /**
+     * Returns a graph of module dependences.
+     *
+     * Each Node represents a module and each edge is a dependence.
+     * No analysis on "requires public".
+     */
+    public Graph<Node> moduleGraph() {
+        Graph.Builder<Node> builder = new Graph.Builder<>();
+
+        archives().stream()
+            .forEach(m -> {
+                Node u = new Node(m.getName(), Info.REQUIRES);
+                builder.addNode(u);
+                analyzer.requires(m)
+                    .map(req -> new Node(req.getName(), Info.REQUIRES))
+                    .forEach(v -> builder.addEdge(u, v));
+            });
+        return builder.build();
+    }
+
+    /**
+     * Returns a graph of dependences.
+     *
+     * Each Node represents a class or package per the specified verbose level.
+     * Each edge indicates
+     */
+    public Graph<Node> dependenceGraph() {
+        Graph.Builder<Node> builder = new Graph.Builder<>();
+
+        archives().stream()
+            .map(analyzer.results::get)
+            .filter(deps -> !deps.dependencies().isEmpty())
+            .flatMap(deps -> deps.dependencies().stream())
+            .forEach(d -> addEdge(builder, d));
+        return builder.build();
+    }
+
+    private void addEdge(Graph.Builder<Node> builder, Analyzer.Dep dep) {
+        Archive source = dep.originArchive();
+        Archive target = dep.targetArchive();
+        String pn = dep.target();
+        if ((verbose == CLASS || verbose == VERBOSE)) {
+            int i = dep.target().lastIndexOf('.');
+            pn = i > 0 ? dep.target().substring(0, i) : "";
+        }
+        final Info info;
+        if (source == target) {
+            info = Info.MODULE_PRIVATE;
+        } else if (!target.getModule().isNamed()) {
+            info = Info.EXPORTED_API;
+        } else if (target.getModule().isExported(pn)) {
+            info = Info.EXPORTED_API;
+        } else {
+            Module module = target.getModule();
+            if (module == Analyzer.REMOVED_JDK_INTERNALS) {
+                info = Info.JDK_REMOVED_INTERNAL_API;
+            } else if (!source.getModule().isJDK() && module.isJDK())
+                info = Info.JDK_INTERNAL_API;
+                // qualified exports or inaccessible
+            else if (module.isExported(pn, source.getModule().name()))
+                info = Info.QUALIFIED_EXPORTED_API;
+            else
+                info = Info.INTERNAL_API;
+        }
+
+        Node u = new Node(dep.origin(), source.getName(), info);
+        Node v = new Node(dep.target(), target.getName(), info);
+        builder.addEdge(u, v);
+    }
+
+}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java
new file mode 100644
index 0000000..5e9450c
--- /dev/null
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java
@@ -0,0 +1,401 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.jdeps;
+
+import java.io.PrintWriter;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public final class Graph<T> {
+    private final Set<T> nodes;
+    private final Map<T, Set<T>> edges;
+
+    public Graph(Set<T> nodes, Map<T, Set<T>> edges) {
+        this.nodes = Collections.unmodifiableSet(nodes);
+        this.edges = Collections.unmodifiableMap(edges);
+    }
+
+    public Set<T> nodes() {
+        return nodes;
+    }
+
+    public Map<T, Set<T>> edges() {
+        return edges;
+    }
+
+    public Set<T> adjacentNodes(T u) {
+        return edges.get(u);
+    }
+
+    public boolean contains(T u) {
+        return nodes.contains(u);
+    }
+
+    public Set<Edge<T>> edgesFrom(T u) {
+        return edges.get(u).stream()
+                    .map(v -> new Edge<T>(u, v))
+                    .collect(Collectors.toSet());
+    }
+
+    /**
+     * Returns a new Graph after transitive reduction
+     */
+    public Graph<T> reduce() {
+        Builder<T> builder = new Builder<>();
+        nodes.stream()
+                .forEach(u -> {
+                    builder.addNode(u);
+                    edges.get(u).stream()
+                         .filter(v -> !pathExists(u, v, false))
+                         .forEach(v -> builder.addEdge(u, v));
+                });
+        return builder.build();
+    }
+
+    /**
+     * Returns a new Graph after transitive reduction.  All edges in
+     * the given g takes precedence over this graph.
+     *
+     * @throw IllegalArgumentException g must be a subgraph this graph
+     */
+    public Graph<T> reduce(Graph<T> g) {
+        boolean subgraph = nodes.containsAll(g.nodes) &&
+                g.edges.keySet().stream()
+                       .allMatch(u -> adjacentNodes(u).containsAll(g.adjacentNodes(u)));
+        if (!subgraph) {
+            throw new IllegalArgumentException(g + " is not a subgraph of " + this);
+        }
+
+        Builder<T> builder = new Builder<>();
+        nodes.stream()
+                .forEach(u -> {
+                    builder.addNode(u);
+                    // filter the edge if there exists a path from u to v in the given g
+                    // or there exists another path from u to v in this graph
+                    edges.get(u).stream()
+                         .filter(v -> !g.pathExists(u, v) && !pathExists(u, v, false))
+                         .forEach(v -> builder.addEdge(u, v));
+                });
+
+        // add the overlapped edges from this graph and the given g
+        g.edges().keySet().stream()
+                .forEach(u -> g.adjacentNodes(u).stream()
+                                .filter(v -> isAdjacent(u, v))
+                                .forEach(v -> builder.addEdge(u, v)));
+        return builder.build();
+    }
+
+    /**
+     * Returns nodes sorted in topological order.
+     */
+    public Stream<T> orderedNodes() {
+        TopoSorter<T> sorter = new TopoSorter<>(this);
+        return sorter.result.stream();
+    }
+
+    /**
+     * Traverse this graph and performs the given action in topological order
+     */
+    public void ordered(Consumer<T> action) {
+        TopoSorter<T> sorter = new TopoSorter<>(this);
+        sorter.ordered(action);
+    }
+
+    /**
+     * Traverses this graph and performs the given action in reverse topological order
+     */
+    public void reverse(Consumer<T> action) {
+        TopoSorter<T> sorter = new TopoSorter<>(this);
+        sorter.reverse(action);
+    }
+
+    /**
+     * Returns a transposed graph from this graph
+     */
+    public Graph<T> transpose() {
+        Builder<T> builder = new Builder<>();
+        builder.addNodes(nodes);
+        // reverse edges
+        edges.keySet().forEach(u -> {
+            edges.get(u).stream()
+                .forEach(v -> builder.addEdge(v, u));
+        });
+        return builder.build();
+    }
+
+    /**
+     * Returns all nodes reachable from the given set of roots.
+     */
+    public Set<T> dfs(Set<T> roots) {
+        Deque<T> deque = new LinkedList<>(roots);
+        Set<T> visited = new HashSet<>();
+        while (!deque.isEmpty()) {
+            T u = deque.pop();
+            if (!visited.contains(u)) {
+                visited.add(u);
+                if (contains(u)) {
+                    adjacentNodes(u).stream()
+                        .filter(v -> !visited.contains(v))
+                        .forEach(deque::push);
+                }
+            }
+        }
+        return visited;
+    }
+
+    private boolean isAdjacent(T u, T v) {
+        return edges.containsKey(u) && edges.get(u).contains(v);
+    }
+
+    private boolean pathExists(T u, T v) {
+        return pathExists(u, v, true);
+    }
+
+    /**
+     * Returns true if there exists a path from u to v in this graph.
+     * If includeAdjacent is false, it returns true if there exists
+     * another path from u to v of distance > 1
+     */
+    private boolean pathExists(T u, T v, boolean includeAdjacent) {
+        if (!nodes.contains(u) || !nodes.contains(v)) {
+            return false;
+        }
+        if (includeAdjacent && isAdjacent(u, v)) {
+            return true;
+        }
+        Deque<T> stack = new LinkedList<>();
+        Set<T> visited = new HashSet<>();
+        stack.push(u);
+        while (!stack.isEmpty()) {
+            T node = stack.pop();
+            if (node.equals(v)) {
+                return true;
+            }
+            if (!visited.contains(node)) {
+                visited.add(node);
+                edges.get(node).stream()
+                     .filter(e -> includeAdjacent || !node.equals(u) || !e.equals(v))
+                     .forEach(e -> stack.push(e));
+            }
+        }
+        assert !visited.contains(v);
+        return false;
+    }
+
+    public void printGraph(PrintWriter out) {
+        out.println("graph for " + nodes);
+        nodes.stream()
+             .forEach(u -> adjacentNodes(u).stream()
+                               .forEach(v -> out.format("  %s -> %s%n", u, v)));
+    }
+
+    @Override
+    public String toString() {
+        return nodes.toString();
+    }
+
+    static class Edge<T> {
+        final T u;
+        final T v;
+        Edge(T u, T v) {
+            this.u = u;
+            this.v = v;
+        }
+
+        @Override
+        public String toString() {
+            return String.format("%s -> %s", u, v);
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (o == null || !(o instanceof Edge))
+                return false;
+
+            @SuppressWarnings("unchecked")
+            Edge<T> edge = (Edge<T>) o;
+
+            return u.equals(edge.u) && v.equals(edge.v);
+        }
+
+        @Override
+        public int hashCode() {
+            int result = u.hashCode();
+            result = 31 * result + v.hashCode();
+            return result;
+        }
+    }
+
+    static class Builder<T> {
+        final Set<T> nodes = new HashSet<>();
+        final Map<T, Set<T>> edges = new HashMap<>();
+
+        public void addNode(T node) {
+            if (nodes.contains(node)) {
+                return;
+            }
+            nodes.add(node);
+            edges.computeIfAbsent(node, _e -> new HashSet<>());
+        }
+
+        public void addNodes(Set<T> nodes) {
+            nodes.addAll(nodes);
+        }
+
+        public void addEdge(T u, T v) {
+            addNode(u);
+            addNode(v);
+            edges.get(u).add(v);
+        }
+
+        public Graph<T> build() {
+            return new Graph<T>(nodes, edges);
+        }
+    }
+
+    /**
+     * Topological sort
+     */
+    static class TopoSorter<T> {
+        final Deque<T> result = new LinkedList<>();
+        final Deque<T> nodes;
+        final Graph<T> graph;
+        TopoSorter(Graph<T> graph) {
+            this.graph = graph;
+            this.nodes = new LinkedList<>(graph.nodes);
+            sort();
+        }
+
+        public void ordered(Consumer<T> action) {
+            result.iterator().forEachRemaining(action);
+        }
+
+        public void reverse(Consumer<T> action) {
+            result.descendingIterator().forEachRemaining(action);
+        }
+
+        private void sort() {
+            Deque<T> visited = new LinkedList<>();
+            Deque<T> done = new LinkedList<>();
+            T node;
+            while ((node = nodes.poll()) != null) {
+                if (!visited.contains(node)) {
+                    visit(node, visited, done);
+                }
+            }
+        }
+
+        private void visit(T node, Deque<T> visited, Deque<T> done) {
+            if (visited.contains(node)) {
+                if (!done.contains(node)) {
+                    throw new IllegalArgumentException("Cyclic detected: " +
+                        node + " " + graph.edges().get(node));
+                }
+                return;
+            }
+            visited.add(node);
+            graph.edges().get(node).stream()
+                .forEach(x -> visit(x, visited, done));
+            done.add(node);
+            result.addLast(node);
+        }
+    }
+
+    public static class DotGraph {
+        static final String ORANGE = "#e76f00";
+        static final String BLUE = "#437291";
+        static final String GRAY = "#dddddd";
+
+        static final String REEXPORTS = "";
+        static final String REQUIRES = "style=\"dashed\"";
+        static final String REQUIRES_BASE = "color=\"" + GRAY + "\"";
+
+        static final Set<String> javaModules = modules(name ->
+            (name.startsWith("java.") && !name.equals("java.smartcardio")));
+        static final Set<String> jdkModules = modules(name ->
+            (name.startsWith("java.") ||
+                name.startsWith("jdk.") ||
+                name.startsWith("javafx.")) && !javaModules.contains(name));
+
+        private static Set<String> modules(Predicate<String> predicate) {
+            return ModuleFinder.ofSystem().findAll()
+                               .stream()
+                               .map(ModuleReference::descriptor)
+                               .map(ModuleDescriptor::name)
+                               .filter(predicate)
+                               .collect(Collectors.toSet());
+        }
+
+        static void printAttributes(PrintWriter out) {
+            out.format("  size=\"25,25\";%n");
+            out.format("  nodesep=.5;%n");
+            out.format("  ranksep=1.5;%n");
+            out.format("  pencolor=transparent;%n");
+            out.format("  node [shape=plaintext, fontname=\"DejaVuSans\", fontsize=36, margin=\".2,.2\"];%n");
+            out.format("  edge [penwidth=4, color=\"#999999\", arrowhead=open, arrowsize=2];%n");
+        }
+
+        static void printNodes(PrintWriter out, Graph<String> graph) {
+            out.format("  subgraph se {%n");
+            graph.nodes().stream()
+                 .filter(javaModules::contains)
+                 .forEach(mn -> out.format("  \"%s\" [fontcolor=\"%s\", group=%s];%n",
+                                           mn, ORANGE, "java"));
+            out.format("  }%n");
+            graph.nodes().stream()
+                 .filter(jdkModules::contains)
+                 .forEach(mn -> out.format("    \"%s\" [fontcolor=\"%s\", group=%s];%n",
+                                           mn, BLUE, "jdk"));
+
+            graph.nodes().stream()
+                 .filter(mn -> !javaModules.contains(mn) && !jdkModules.contains(mn))
+                 .forEach(mn -> out.format("  \"%s\";%n", mn));
+        }
+
+        static void printEdges(PrintWriter out, Graph<String> graph,
+                               String node, Set<String> requiresPublic) {
+            graph.adjacentNodes(node).forEach(dn -> {
+                String attr = dn.equals("java.base") ? REQUIRES_BASE
+                        : (requiresPublic.contains(dn) ? REEXPORTS : REQUIRES);
+                out.format("  \"%s\" -> \"%s\" [%s];%n", node, dn, attr);
+            });
+        }
+    }
+
+
+}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/InverseDepsAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/InverseDepsAnalyzer.java
new file mode 100644
index 0000000..7e640d0
--- /dev/null
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/InverseDepsAnalyzer.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.jdeps;
+
+import static com.sun.tools.jdeps.JdepsFilter.DEFAULT_FILTER;
+import static com.sun.tools.jdeps.Module.trace;
+import static com.sun.tools.jdeps.Graph.*;
+
+import java.lang.module.ModuleDescriptor.Requires;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Inverse transitive dependency analysis (compile-time view)
+ */
+public class InverseDepsAnalyzer extends DepsAnalyzer {
+    // the end points for the resulting paths to be reported
+    private final Map<Archive, Set<Archive>> endPoints = new HashMap<>();
+    // target archives for inverse transitive dependence analysis
+    private final Set<Archive> targets = new HashSet<>();
+
+    public InverseDepsAnalyzer(JdepsConfiguration config,
+                               JdepsFilter filter,
+                               JdepsWriter writer,
+                               Analyzer.Type verbose,
+                               boolean apiOnly) {
+        super(config, filter, writer, verbose, apiOnly);
+    }
+
+    public boolean run() throws IOException {
+        try {
+            if (apiOnly) {
+                finder.parseExportedAPIs(rootArchives.stream());
+            } else {
+                finder.parse(rootArchives.stream());
+            }
+            archives.addAll(rootArchives);
+
+            Set<Archive> archives = archives();
+
+            // If -package or -regex is specified, the archives that reference
+            // the matching types are used as the targets for inverse
+            // transitive analysis.  If -requires is specified, the
+            // specified modules are the targets.
+
+            if (filter.requiresFilter().isEmpty()) {
+                targets.addAll(archives);
+            } else {
+                filter.requiresFilter().stream()
+                      .map(configuration::findModule)
+                      .flatMap(Optional::stream)
+                      .forEach(targets::add);
+            }
+
+            // If -package or -regex is specified, the end points are
+            // the matching archives.  If -requires is specified,
+            // the end points are the modules specified in -requires.
+            if (filter.requiresFilter().isEmpty()) {
+                Map<Archive, Set<Archive>> dependences = finder.dependences();
+                targets.forEach(source -> endPoints.put(source, dependences.get(source)));
+            } else {
+                targets.forEach(t -> endPoints.put(t, Collections.emptySet()));
+            }
+
+            analyzer.run(archives, finder.locationToArchive());
+
+            // print the first-level of dependencies
+            if (writer != null) {
+                writer.generateOutput(archives, analyzer);
+            }
+
+        } finally {
+            finder.shutdown();
+        }
+        return true;
+    }
+
+    /**
+     * Returns the target archives determined from the dependency analysis.
+     *
+     * Inverse transitive dependency will find all nodes that depend
+     * upon the returned set of archives directly and indirectly.
+     */
+    public Set<Archive> targets() {
+        return Collections.unmodifiableSet(targets);
+    }
+
+    /**
+     * Finds all inverse transitive dependencies using the given requires set
+     * as the targets, if non-empty.  If the given requires set is empty,
+     * use the archives depending the packages specified in -regex or -p options.
+     */
+    public Set<Deque<Archive>> inverseDependences() throws IOException {
+        // create a new dependency finder to do the analysis
+        DependencyFinder dependencyFinder = new DependencyFinder(configuration, DEFAULT_FILTER);
+        try {
+            // parse all archives in unnamed module to get compile-time dependences
+            Stream<Archive> archives =
+                Stream.concat(configuration.initialArchives().stream(),
+                              configuration.classPathArchives().stream());
+            if (apiOnly) {
+                dependencyFinder.parseExportedAPIs(archives);
+            } else {
+                dependencyFinder.parse(archives);
+            }
+
+            Graph.Builder<Archive> builder = new Graph.Builder<>();
+            // include all target nodes
+            targets().forEach(builder::addNode);
+
+            // transpose the module graph - may filter JDK module
+            configuration.getModules().values().stream()
+                .filter(filter::include)
+                .forEach(m -> {
+                    builder.addNode(m);
+                    m.descriptor().requires().stream()
+                        .map(Requires::name)
+                        .map(configuration::findModule)  // must be present
+                        .forEach(v -> builder.addEdge(v.get(), m));
+                });
+
+            // add the dependences from the analysis
+            Map<Archive, Set<Archive>> dependences = dependencyFinder.dependences();
+            dependences.entrySet().stream()
+                .forEach(e -> {
+                    Archive u = e.getKey();
+                    builder.addNode(u);
+                    e.getValue().forEach(v -> builder.addEdge(v, u));
+                });
+
+            // transposed dependence graph.
+            Graph<Archive> graph = builder.build();
+            trace("targets: %s%n", targets());
+
+            // Traverse from the targets and find all paths
+            // rebuild a graph with all nodes that depends on targets
+            // targets directly and indirectly
+            return targets().stream()
+                .map(t -> findPaths(graph, t))
+                .flatMap(Set::stream)
+                .collect(Collectors.toSet());
+        } finally {
+            dependencyFinder.shutdown();
+        }
+    }
+
+    /**
+     * Returns all paths reachable from the given targets.
+     */
+    private Set<Deque<Archive>> findPaths(Graph<Archive> graph, Archive target) {
+
+        // path is in reversed order
+        Deque<Archive> path = new LinkedList<>();
+        path.push(target);
+
+        Set<Edge<Archive>> visited = new HashSet<>();
+
+        Deque<Edge<Archive>> deque = new LinkedList<>();
+        deque.addAll(graph.edgesFrom(target));
+        if (deque.isEmpty()) {
+            return makePaths(path).collect(Collectors.toSet());
+        }
+
+        Set<Deque<Archive>> allPaths = new HashSet<>();
+        while (!deque.isEmpty()) {
+            Edge<Archive> edge = deque.pop();
+
+            if (visited.contains(edge))
+                continue;
+
+            Archive node = edge.v;
+            path.addLast(node);
+            visited.add(edge);
+
+            Set<Edge<Archive>> unvisitedDeps = graph.edgesFrom(node)
+                    .stream()
+                    .filter(e -> !visited.contains(e))
+                    .collect(Collectors.toSet());
+
+            trace("visiting %s %s (%s)%n", edge, path, unvisitedDeps);
+            if (unvisitedDeps.isEmpty()) {
+                makePaths(path).forEach(allPaths::add);
+                path.removeLast();
+            }
+
+            // push unvisited adjacent edges
+            unvisitedDeps.stream().forEach(deque::push);
+
+
+            // when the adjacent edges of a node are visited, pop it from the path
+            while (!path.isEmpty()) {
+                if (visited.containsAll(graph.edgesFrom(path.peekLast())))
+                    path.removeLast();
+                else
+                    break;
+            }
+        }
+
+       return allPaths;
+    }
+
+    /**
+     * Prepend end point to the path
+     */
+    private Stream<Deque<Archive>> makePaths(Deque<Archive> path) {
+        Set<Archive> nodes = endPoints.get(path.peekFirst());
+        if (nodes == null || nodes.isEmpty()) {
+            return Stream.of(new LinkedList<>(path));
+        } else {
+            return nodes.stream().map(n -> {
+                Deque<Archive> newPath = new LinkedList<>();
+                newPath.addFirst(n);
+                newPath.addAll(path);
+                return newPath;
+            });
+        }
+    }
+}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java
new file mode 100644
index 0000000..a4186d2
--- /dev/null
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java
@@ -0,0 +1,620 @@
+/*
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.jdeps;
+
+import static com.sun.tools.jdeps.Module.trace;
+import static java.util.stream.Collectors.*;
+
+import com.sun.tools.classfile.Dependency;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReader;
+import java.lang.module.ModuleReference;
+import java.lang.module.ResolvedModule;
+import java.net.URI;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+public class JdepsConfiguration implements AutoCloseable {
+    // the token for "all modules on the module path"
+    public static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
+    public static final String ALL_DEFAULT = "ALL-DEFAULT";
+    public static final String MODULE_INFO = "module-info.class";
+
+    private final SystemModuleFinder system;
+    private final ModuleFinder finder;
+
+    private final Map<String, Module> nameToModule = new LinkedHashMap<>();
+    private final Map<String, Module> packageToModule = new HashMap<>();
+    private final Map<String, List<Archive>> packageToUnnamedModule = new HashMap<>();
+
+    private final List<Archive> classpathArchives = new ArrayList<>();
+    private final List<Archive> initialArchives = new ArrayList<>();
+    private final Set<Module> rootModules = new HashSet<>();
+    private final Configuration configuration;
+
+    private JdepsConfiguration(SystemModuleFinder systemModulePath,
+                               ModuleFinder finder,
+                               Set<String> roots,
+                               List<Path> classpaths,
+                               List<Archive> initialArchives,
+                               boolean allDefaultModules)
+        throws IOException
+    {
+        trace("root: %s%n", roots);
+
+        this.system = systemModulePath;
+        this.finder = finder;
+
+        // build root set for resolution
+        Set<String> mods = new HashSet<>(roots);
+
+        // add default modules to the root set
+        // unnamed module
+        if (!initialArchives.isEmpty() || !classpaths.isEmpty() ||
+                roots.isEmpty() || allDefaultModules) {
+            mods.addAll(systemModulePath.defaultSystemRoots());
+        }
+
+        this.configuration = Configuration.empty()
+                .resolveRequires(finder, ModuleFinder.of(), mods);
+
+        this.configuration.modules().stream()
+                .map(ResolvedModule::reference)
+                .forEach(this::addModuleReference);
+
+        // packages in unnamed module
+        initialArchives.forEach(archive -> {
+            addPackagesInUnnamedModule(archive);
+            this.initialArchives.add(archive);
+        });
+
+        // classpath archives
+        for (Path p : classpaths) {
+            if (Files.exists(p)) {
+                Archive archive = Archive.getInstance(p);
+                addPackagesInUnnamedModule(archive);
+                classpathArchives.add(archive);
+            }
+        }
+
+        // all roots specified in -addmods or -m are included
+        // as the initial set for analysis.
+        roots.stream()
+             .map(nameToModule::get)
+             .forEach(this.rootModules::add);
+
+        initProfiles();
+
+        trace("resolved modules: %s%n", nameToModule.keySet().stream()
+                .sorted().collect(joining("\n", "\n", "")));
+    }
+
+    private void initProfiles() {
+        // other system modules are not observed and not added in nameToModule map
+        Map<String, Module> systemModules =
+            system.moduleNames()
+                .collect(toMap(Function.identity(), (mn) -> {
+                    Module m = nameToModule.get(mn);
+                    if (m == null) {
+                        ModuleReference mref = finder.find(mn).get();
+                        m = toModule(mref);
+                    }
+                    return m;
+                }));
+        Profile.init(systemModules);
+    }
+
+    private void addModuleReference(ModuleReference mref) {
+        Module module = toModule(mref);
+        nameToModule.put(mref.descriptor().name(), module);
+        mref.descriptor().packages()
+            .forEach(pn -> packageToModule.putIfAbsent(pn, module));
+    }
+
+    private void addPackagesInUnnamedModule(Archive archive) {
+        archive.reader().entries().stream()
+               .filter(e -> e.endsWith(".class") && !e.equals(MODULE_INFO))
+               .map(this::toPackageName)
+               .distinct()
+               .forEach(pn -> packageToUnnamedModule
+                   .computeIfAbsent(pn, _n -> new ArrayList<>()).add(archive));
+    }
+
+    private String toPackageName(String name) {
+        int i = name.lastIndexOf('/');
+        return i > 0 ? name.replace('/', '.').substring(0, i) : "";
+    }
+
+    public Optional<Module> findModule(String name) {
+        Objects.requireNonNull(name);
+        Module m = nameToModule.get(name);
+        return m!= null ? Optional.of(m) : Optional.empty();
+
+    }
+
+    public Optional<ModuleDescriptor> findModuleDescriptor(String name) {
+        Objects.requireNonNull(name);
+        Module m = nameToModule.get(name);
+        return m!= null ? Optional.of(m.descriptor()) : Optional.empty();
+    }
+
+    boolean isSystem(Module m) {
+        return system.find(m.name()).isPresent();
+    }
+
+    boolean isValidToken(String name) {
+        return ALL_MODULE_PATH.equals(name) || ALL_DEFAULT.equals(name);
+    }
+
+    /**
+     * Returns the modules that the given module can read
+     */
+    public Stream<Module> reads(Module module) {
+        return configuration.findModule(module.name()).get()
+            .reads().stream()
+            .map(ResolvedModule::name)
+            .map(nameToModule::get);
+    }
+
+    /**
+     * Returns the list of packages that split between resolved module and
+     * unnamed module
+     */
+    public Map<String, Set<String>> splitPackages() {
+        Set<String> splitPkgs = packageToModule.keySet().stream()
+                                       .filter(packageToUnnamedModule::containsKey)
+                                       .collect(toSet());
+        if (splitPkgs.isEmpty())
+            return Collections.emptyMap();
+
+        return splitPkgs.stream().collect(toMap(Function.identity(), (pn) -> {
+            Set<String> sources = new LinkedHashSet<>();
+            sources.add(packageToModule.get(pn).getModule().location().toString());
+            packageToUnnamedModule.get(pn).stream()
+                .map(Archive::getPathName)
+                .forEach(sources::add);
+            return sources;
+        }));
+    }
+
+    /**
+     * Returns an optional archive containing the given Location
+     */
+    public Optional<Archive> findClass(Dependency.Location location) {
+        String name = location.getName();
+        int i = name.lastIndexOf('/');
+        String pn = i > 0 ? name.substring(0, i).replace('/', '.') : "";
+        Archive archive = packageToModule.get(pn);
+        if (archive != null) {
+            return archive.contains(name + ".class")
+                        ? Optional.of(archive)
+                        : Optional.empty();
+        }
+
+        if (packageToUnnamedModule.containsKey(pn)) {
+            return packageToUnnamedModule.get(pn).stream()
+                    .filter(a -> a.contains(name + ".class"))
+                    .findFirst();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Returns the list of Modules that can be found in the specified
+     * module paths.
+     */
+    public Map<String, Module> getModules() {
+        return nameToModule;
+    }
+
+    public Stream<Module> resolve(Set<String> roots) {
+        if (roots.isEmpty()) {
+            return nameToModule.values().stream();
+        } else {
+            return Configuration.empty()
+                    .resolveRequires(finder, ModuleFinder.of(), roots)
+                    .modules().stream()
+                    .map(ResolvedModule::name)
+                    .map(nameToModule::get);
+        }
+    }
+
+    public List<Archive> classPathArchives() {
+        return classpathArchives;
+    }
+
+    public List<Archive> initialArchives() {
+        return initialArchives;
+    }
+
+    public Set<Module> rootModules() {
+        return rootModules;
+    }
+
+    public Module toModule(ModuleReference mref) {
+        try {
+            String mn = mref.descriptor().name();
+            URI location = mref.location().orElseThrow(FileNotFoundException::new);
+            ModuleDescriptor md = mref.descriptor();
+            Module.Builder builder = new Module.Builder(md, system.find(mn).isPresent());
+
+            final ClassFileReader reader;
+            if (location.getScheme().equals("jrt")) {
+                reader = system.getClassReader(mn);
+            } else {
+                reader = ClassFileReader.newInstance(Paths.get(location));
+            }
+
+            builder.classes(reader);
+            builder.location(location);
+
+            return builder.build();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
+    /*
+     * Close all archives e.g. JarFile
+     */
+    @Override
+    public void close() throws IOException {
+        for (Archive archive : initialArchives)
+            archive.close();
+        for (Archive archive : classpathArchives)
+            archive.close();
+        for (Module module : nameToModule.values())
+            module.close();
+    }
+
+    static class SystemModuleFinder implements ModuleFinder {
+        private static final String JAVA_HOME = System.getProperty("java.home");
+        private static final String JAVA_SE = "java.se";
+
+        private final FileSystem fileSystem;
+        private final Path root;
+        private final Map<String, ModuleReference> systemModules;
+
+        SystemModuleFinder() {
+            if (Files.isRegularFile(Paths.get(JAVA_HOME, "lib", "modules"))) {
+                // jrt file system
+                this.fileSystem = FileSystems.getFileSystem(URI.create("jrt:/"));
+                this.root = fileSystem.getPath("/modules");
+                this.systemModules = walk(root);
+            } else {
+                // exploded image
+                this.fileSystem = FileSystems.getDefault();
+                root = Paths.get(JAVA_HOME, "modules");
+                this.systemModules = ModuleFinder.ofSystem().findAll().stream()
+                    .collect(toMap(mref -> mref.descriptor().name(), Function.identity()));
+            }
+        }
+
+        SystemModuleFinder(String javaHome) throws IOException {
+            if (javaHome == null) {
+                // -system none
+                this.fileSystem = null;
+                this.root = null;
+                this.systemModules = Collections.emptyMap();
+            } else {
+                if (Files.isRegularFile(Paths.get(javaHome, "lib", "modules")))
+                    throw new IllegalArgumentException("Invalid java.home: " + javaHome);
+
+                // alternate java.home
+                Map<String, String> env = new HashMap<>();
+                env.put("java.home", javaHome);
+                // a remote run-time image
+                this.fileSystem = FileSystems.newFileSystem(URI.create("jrt:/"), env);
+                this.root = fileSystem.getPath("/modules");
+                this.systemModules = walk(root);
+            }
+        }
+
+        private Map<String, ModuleReference> walk(Path root) {
+            try (Stream<Path> stream = Files.walk(root, 1)) {
+                return stream.filter(path -> !path.equals(root))
+                             .map(this::toModuleReference)
+                             .collect(toMap(mref -> mref.descriptor().name(),
+                                            Function.identity()));
+            } catch (IOException e) {
+                throw new UncheckedIOException(e);
+            }
+        }
+
+        private ModuleReference toModuleReference(Path path) {
+            Path minfo = path.resolve(MODULE_INFO);
+            try (InputStream in = Files.newInputStream(minfo);
+                 BufferedInputStream bin = new BufferedInputStream(in)) {
+
+                ModuleDescriptor descriptor = dropHashes(ModuleDescriptor.read(bin));
+                String mn = descriptor.name();
+                URI uri = URI.create("jrt:/" + path.getFileName().toString());
+                Supplier<ModuleReader> readerSupplier = new Supplier<>() {
+                    @Override
+                    public ModuleReader get() {
+                        return new ModuleReader() {
+                            @Override
+                            public Optional<URI> find(String name) throws IOException {
+                                return name.equals(mn)
+                                    ? Optional.of(uri) : Optional.empty();
+                            }
+
+                            @Override
+                            public void close() throws IOException {
+                            }
+                        };
+                    }
+                };
+
+                return new ModuleReference(descriptor, uri, readerSupplier);
+            } catch (IOException e) {
+                throw new UncheckedIOException(e);
+            }
+        }
+
+        private ModuleDescriptor dropHashes(ModuleDescriptor md) {
+            ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(md.name());
+            md.requires().forEach(builder::requires);
+            md.exports().forEach(builder::exports);
+            md.provides().values().stream().forEach(builder::provides);
+            md.uses().stream().forEach(builder::uses);
+            builder.conceals(md.conceals());
+            return builder.build();
+        }
+
+        @Override
+        public Set<ModuleReference> findAll() {
+            return systemModules.values().stream().collect(toSet());
+        }
+
+        @Override
+        public Optional<ModuleReference> find(String mn) {
+            return systemModules.containsKey(mn)
+                    ? Optional.of(systemModules.get(mn)) : Optional.empty();
+        }
+
+        public Stream<String> moduleNames() {
+            return systemModules.values().stream()
+                .map(mref -> mref.descriptor().name());
+        }
+
+        public ClassFileReader getClassReader(String modulename) throws IOException {
+            Path mp = root.resolve(modulename);
+            if (Files.exists(mp) && Files.isDirectory(mp)) {
+                return ClassFileReader.newInstance(fileSystem, mp);
+            } else {
+                throw new FileNotFoundException(mp.toString());
+            }
+        }
+
+        public Set<String> defaultSystemRoots() {
+            Set<String> roots = new HashSet<>();
+            boolean hasJava = false;
+            if (systemModules.containsKey(JAVA_SE)) {
+                // java.se is a system module
+                hasJava = true;
+                roots.add(JAVA_SE);
+            }
+
+            for (ModuleReference mref : systemModules.values()) {
+                String mn = mref.descriptor().name();
+                if (hasJava && mn.startsWith("java."))
+                    continue;
+
+                // add as root if observable and exports at least one package
+                ModuleDescriptor descriptor = mref.descriptor();
+                for (ModuleDescriptor.Exports e : descriptor.exports()) {
+                    if (!e.isQualified()) {
+                        roots.add(mn);
+                        break;
+                    }
+                }
+            }
+            return roots;
+        }
+    }
+
+    public static class Builder {
+
+        final SystemModuleFinder systemModulePath;
+        final Set<String> rootModules = new HashSet<>();
+        final List<Archive> initialArchives = new ArrayList<>();
+        final List<Path> paths = new ArrayList<>();
+        final List<Path> classPaths = new ArrayList<>();
+
+        ModuleFinder upgradeModulePath;
+        ModuleFinder appModulePath;
+        boolean addAllApplicationModules;
+        boolean addAllDefaultModules;
+
+        public Builder() {
+            this.systemModulePath = new SystemModuleFinder();
+        }
+
+        public Builder(String javaHome) throws IOException {
+            this.systemModulePath = SystemModuleFinder.JAVA_HOME.equals(javaHome)
+                ? new SystemModuleFinder()
+                : new SystemModuleFinder(javaHome);
+        }
+
+        public Builder upgradeModulePath(String upgradeModulePath) {
+            this.upgradeModulePath = createModulePathFinder(upgradeModulePath);
+            return this;
+        }
+
+        public Builder appModulePath(String modulePath) {
+            this.appModulePath = createModulePathFinder(modulePath);
+            return this;
+        }
+
+        public Builder addmods(Set<String> addmods) {
+            for (String mn : addmods) {
+                switch (mn) {
+                    case ALL_MODULE_PATH:
+                        this.addAllApplicationModules = true;
+                        break;
+                    case ALL_DEFAULT:
+                        this.addAllDefaultModules = true;
+                        break;
+                    default:
+                        this.rootModules.add(mn);
+                }
+            }
+            return this;
+        }
+
+        /*
+         * This method is for -check option to find all target modules specified
+         * in qualified exports.
+         *
+         * Include all system modules and modules found on modulepath
+         */
+        public Builder allModules() {
+            systemModulePath.moduleNames()
+                            .forEach(this.rootModules::add);
+            this.addAllApplicationModules = true;
+            return this;
+        }
+
+        public Builder addRoot(Path path) {
+            Archive archive = Archive.getInstance(path);
+            if (archive.contains(MODULE_INFO)) {
+                paths.add(path);
+            } else {
+                initialArchives.add(archive);
+            }
+            return this;
+        }
+
+        public Builder addClassPath(String classPath) {
+            this.classPaths.addAll(getClassPaths(classPath));
+            return this;
+        }
+
+        public JdepsConfiguration build() throws  IOException {
+            ModuleFinder finder = systemModulePath;
+            if (upgradeModulePath != null) {
+                finder = ModuleFinder.compose(upgradeModulePath, systemModulePath);
+            }
+            if (appModulePath != null) {
+                finder = ModuleFinder.compose(finder, appModulePath);
+            }
+            if (!paths.isEmpty()) {
+                ModuleFinder otherModulePath = ModuleFinder.of(paths.toArray(new Path[0]));
+
+                finder = ModuleFinder.compose(finder, otherModulePath);
+                // add modules specified on command-line (convenience) as root set
+                otherModulePath.findAll().stream()
+                        .map(mref -> mref.descriptor().name())
+                        .forEach(rootModules::add);
+            }
+            if (addAllApplicationModules && appModulePath != null) {
+                appModulePath.findAll().stream()
+                    .map(mref -> mref.descriptor().name())
+                    .forEach(rootModules::add);
+            }
+
+            return new JdepsConfiguration(systemModulePath,
+                                          finder,
+                                          rootModules,
+                                          classPaths,
+                                          initialArchives,
+                                          addAllDefaultModules);
+        }
+
+        private static ModuleFinder createModulePathFinder(String mpaths) {
+            if (mpaths == null) {
+                return null;
+            } else {
+                String[] dirs = mpaths.split(File.pathSeparator);
+                Path[] paths = new Path[dirs.length];
+                int i = 0;
+                for (String dir : dirs) {
+                    paths[i++] = Paths.get(dir);
+                }
+                return ModuleFinder.of(paths);
+            }
+        }
+
+        /*
+         * Returns the list of Archive specified in cpaths and not included
+         * initialArchives
+         */
+        private List<Path> getClassPaths(String cpaths) {
+            if (cpaths.isEmpty()) {
+                return Collections.emptyList();
+            }
+            List<Path> paths = new ArrayList<>();
+            for (String p : cpaths.split(File.pathSeparator)) {
+                if (p.length() > 0) {
+                    // wildcard to parse all JAR files e.g. -classpath dir/*
+                    int i = p.lastIndexOf(".*");
+                    if (i > 0) {
+                        Path dir = Paths.get(p.substring(0, i));
+                        try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) {
+                            for (Path entry : stream) {
+                                paths.add(entry);
+                            }
+                        } catch (IOException e) {
+                            throw new UncheckedIOException(e);
+                        }
+                    } else {
+                        paths.add(Paths.get(p));
+                    }
+                }
+            }
+            return paths;
+        }
+    }
+
+}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java
index 84b04e2..585ec52 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java
@@ -41,22 +41,27 @@
  * 2. -filter:package to filter out same-package dependencies
  *    This filter is applied when jdeps parses the class files
  *    and filtered dependencies are not stored in the Analyzer.
- * 3. -module specifies to match target dependencies from the given module
+ * 3. -requires specifies to match target dependence from the given module
  *    This gets expanded into package lists to be filtered.
  * 4. -filter:archive to filter out same-archive dependencies
  *    This filter is applied later in the Analyzer as the
  *    containing archive of a target class may not be known until
  *    the entire archive
  */
-class JdepsFilter implements Dependency.Filter, Analyzer.Filter {
+public class JdepsFilter implements Dependency.Filter, Analyzer.Filter {
+
+    public static final JdepsFilter DEFAULT_FILTER =
+        new JdepsFilter.Builder().filter(true, true).build();
+
     private final Dependency.Filter filter;
     private final Pattern filterPattern;
     private final boolean filterSamePackage;
     private final boolean filterSameArchive;
     private final boolean findJDKInternals;
     private final Pattern includePattern;
-    private final Set<String> includePackages;
-    private final Set<String> excludeModules;
+    private final Pattern includeSystemModules;
+
+    private final Set<String> requires;
 
     private JdepsFilter(Dependency.Filter filter,
                         Pattern filterPattern,
@@ -64,16 +69,16 @@
                         boolean filterSameArchive,
                         boolean findJDKInternals,
                         Pattern includePattern,
-                        Set<String> includePackages,
-                        Set<String> excludeModules) {
+                        Pattern includeSystemModules,
+                        Set<String> requires) {
         this.filter = filter;
         this.filterPattern = filterPattern;
         this.filterSamePackage = filterSamePackage;
         this.filterSameArchive = filterSameArchive;
         this.findJDKInternals = findJDKInternals;
         this.includePattern = includePattern;
-        this.includePackages = includePackages;
-        this.excludeModules = excludeModules;
+        this.includeSystemModules = includeSystemModules;
+        this.requires = requires;
     }
 
     /**
@@ -82,12 +87,7 @@
      * @param cn fully-qualified name
      */
     public boolean matches(String cn) {
-        if (includePackages.isEmpty() && includePattern == null)
-            return true;
-
-        int i = cn.lastIndexOf('.');
-        String pn = i > 0 ? cn.substring(0, i) : "";
-        if (includePackages.contains(pn))
+        if (includePattern == null)
             return true;
 
         if (includePattern != null)
@@ -97,29 +97,39 @@
     }
 
     /**
-     * Tests if the given source includes classes specified in includePattern
-     * or includePackages filters.
+     * Tests if the given source includes classes specified in -include option
      *
      * This method can be used to determine if the given source should eagerly
      * be processed.
      */
     public boolean matches(Archive source) {
-        if (!includePackages.isEmpty() && source.getModule().isNamed()) {
-            boolean found = source.getModule().packages()
-                                  .stream()
-                                  .filter(pn -> includePackages.contains(pn))
-                                  .findAny().isPresent();
-            if (found)
-                return true;
+        if (includePattern != null) {
+            return source.reader().entries().stream()
+                    .map(name -> name.replace('/', '.'))
+                    .filter(name -> !name.equals("module-info.class"))
+                    .anyMatch(this::matches);
         }
-        if (!includePackages.isEmpty() || includePattern != null) {
-            return source.reader().entries()
-                         .stream()
-                         .map(name -> name.replace('/', '.'))
-                         .filter(this::matches)
-                         .findAny().isPresent();
-        }
-        return false;
+        return hasTargetFilter();
+    }
+
+    public boolean include(Archive source) {
+        Module module = source.getModule();
+        // skip system module by default; or if includeSystemModules is set
+        // only include the ones matching the pattern
+        return  !module.isSystem() || (includeSystemModules != null &&
+            includeSystemModules.matcher(module.name()).matches());
+    }
+
+    public boolean hasIncludePattern() {
+        return includePattern != null || includeSystemModules != null;
+    }
+
+    public boolean hasTargetFilter() {
+        return filter != null;
+    }
+
+    public Set<String> requiresFilter() {
+        return requires;
     }
 
     // ----- Dependency.Filter -----
@@ -164,42 +174,35 @@
         return true;
     }
 
-    /**
-     * Returns true if dependency should be recorded for the given source.
-     */
-    public boolean accept(Archive source) {
-        return !excludeModules.contains(source.getName());
-    }
-
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
-        sb.append("exclude modules: ")
-          .append(excludeModules.stream().sorted().collect(Collectors.joining(",")))
-          .append("\n");
+        sb.append("include pattern: ").append(includePattern).append("\n");
         sb.append("filter same archive: ").append(filterSameArchive).append("\n");
         sb.append("filter same package: ").append(filterSamePackage).append("\n");
+        sb.append("requires: ").append(requires).append("\n");
         return sb.toString();
     }
 
-    static class Builder {
-        Dependency.Filter filter;
+    public static class Builder {
+        static Pattern SYSTEM_MODULE_PATTERN = Pattern.compile("java\\..*|jdk\\..*|javafx\\..*");
         Pattern filterPattern;
+        Pattern regex;
         boolean filterSamePackage;
         boolean filterSameArchive;
         boolean findJDKInterals;
         // source filters
         Pattern includePattern;
-        Set<String> includePackages = new HashSet<>();
-        Set<String> includeModules = new HashSet<>();
-        Set<String> excludeModules = new HashSet<>();
+        Pattern includeSystemModules;
+        Set<String> requires = new HashSet<>();
+        Set<String> targetPackages = new HashSet<>();
 
         public Builder packages(Set<String> packageNames) {
-            this.filter = Dependencies.getPackageFilter(packageNames, false);
+            this.targetPackages.addAll(packageNames);
             return this;
         }
         public Builder regex(Pattern regex) {
-            this.filter = Dependencies.getRegexFilter(regex);
+            this.regex = regex;
             return this;
         }
         public Builder filter(Pattern regex) {
@@ -211,6 +214,13 @@
             this.filterSameArchive = sameArchive;
             return this;
         }
+        public Builder requires(String name, Set<String> packageNames) {
+            this.requires.add(name);
+            this.targetPackages.addAll(packageNames);
+
+            includeIfSystemModule(name);
+            return this;
+        }
         public Builder findJDKInternals(boolean value) {
             this.findJDKInterals = value;
             return this;
@@ -219,30 +229,33 @@
             this.includePattern = regex;
             return this;
         }
-        public Builder includePackage(String pn) {
-            this.includePackages.add(pn);
+        public Builder includeSystemModules(Pattern regex) {
+            this.includeSystemModules = regex;
             return this;
         }
-        public Builder includeModules(Set<String> includes) {
-            this.includeModules.addAll(includes);
-            return this;
-        }
-        public Builder excludeModules(Set<String> excludes) {
-            this.excludeModules.addAll(excludes);
+        public Builder includeIfSystemModule(String name) {
+            if (includeSystemModules == null &&
+                    SYSTEM_MODULE_PATTERN.matcher(name).matches()) {
+                this.includeSystemModules = SYSTEM_MODULE_PATTERN;
+            }
             return this;
         }
 
-        JdepsFilter build() {
+        public JdepsFilter build() {
+            Dependency.Filter filter = null;
+            if (regex != null)
+                filter = Dependencies.getRegexFilter(regex);
+            else if (!targetPackages.isEmpty()) {
+                filter = Dependencies.getPackageFilter(targetPackages, false);
+            }
             return new JdepsFilter(filter,
                                    filterPattern,
                                    filterSamePackage,
                                    filterSameArchive,
                                    findJDKInterals,
                                    includePattern,
-                                   includePackages,
-                                   excludeModules.stream()
-                                        .filter(mn -> !includeModules.contains(mn))
-                                        .collect(Collectors.toSet()));
+                                   includeSystemModules,
+                                   requires);
         }
 
     }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
index 649e53e..edaafa2 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
@@ -25,31 +25,30 @@
 
 package com.sun.tools.jdeps;
 
+import static com.sun.tools.jdeps.Analyzer.NOT_FOUND;
+import static com.sun.tools.jdeps.Analyzer.REMOVED_JDK_INTERNALS;
 import static com.sun.tools.jdeps.Analyzer.Type.*;
 import static com.sun.tools.jdeps.JdepsWriter.*;
-import static com.sun.tools.jdeps.ModuleAnalyzer.Graph;
+import static com.sun.tools.jdeps.JdepsConfiguration.ALL_MODULE_PATH;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.lang.module.ResolutionException;
-import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
+import java.util.Comparator;
+import java.util.Deque;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
-import java.util.Optional;
 import java.util.ResourceBundle;
 import java.util.Set;
-import java.util.TreeMap;
+import java.util.function.Function;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -58,7 +57,12 @@
  * Implementation for the jdeps tool for static class dependency analysis.
  */
 class JdepsTask {
-    static class BadArgs extends Exception {
+    static interface BadArguments {
+        String getKey();
+        Object[] getArgs();
+        boolean showUsage();
+    }
+    static class BadArgs extends Exception implements BadArguments {
         static final long serialVersionUID = 8765093759964640721L;
         BadArgs(String key, Object... args) {
             super(JdepsTask.getMessage(key, args));
@@ -73,6 +77,44 @@
         final String key;
         final Object[] args;
         boolean showUsage;
+
+        @Override
+        public String getKey() {
+            return key;
+        }
+
+        @Override
+        public Object[] getArgs() {
+            return args;
+        }
+
+        @Override
+        public boolean showUsage() {
+            return showUsage;
+        }
+    }
+
+    static class UncheckedBadArgs extends RuntimeException implements BadArguments {
+        static final long serialVersionUID = -1L;
+        final BadArgs cause;
+        UncheckedBadArgs(BadArgs cause) {
+            super(cause);
+            this.cause = cause;
+        }
+        @Override
+        public String getKey() {
+            return cause.key;
+        }
+
+        @Override
+        public Object[] getArgs() {
+            return cause.args;
+        }
+
+        @Override
+        public boolean showUsage() {
+            return cause.showUsage;
+        }
     }
 
     static abstract class Option {
@@ -126,7 +168,7 @@
                 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
                     throw new BadArgs("err.invalid.path", arg);
                 }
-                task.options.dotOutputDir = arg;
+                task.options.dotOutputDir = Paths.get(arg);;
             }
         },
         new Option(false, "-s", "-summary") {
@@ -136,8 +178,9 @@
             }
         },
         new Option(false, "-v", "-verbose",
-                          "-verbose:package",
-                          "-verbose:class") {
+                                "-verbose:module",
+                                "-verbose:package",
+                                "-verbose:class") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 switch (opt) {
                     case "-v":
@@ -146,6 +189,9 @@
                         task.options.filterSameArchive = false;
                         task.options.filterSamePackage = false;
                         break;
+                    case "-verbose:module":
+                        task.options.verbose = MODULE;
+                        break;
                     case "-verbose:package":
                         task.options.verbose = PACKAGE;
                         break;
@@ -157,6 +203,80 @@
                 }
             }
         },
+        new Option(false, "-apionly") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.apiOnly = true;
+            }
+        },
+        new Option(true, "-check") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                Set<String> mods =  Set.of(arg.split(","));
+                task.options.checkModuleDeps = mods;
+                task.options.addmods.addAll(mods);
+            }
+        },
+        new Option(true, "-genmoduleinfo") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                Path p = Paths.get(arg);
+                if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
+                    throw new BadArgs("err.invalid.path", arg);
+                }
+                task.options.genModuleInfo = Paths.get(arg);
+            }
+        },
+        new Option(false, "-jdkinternals") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.findJDKInternals = true;
+                task.options.verbose = CLASS;
+                if (task.options.includePattern == null) {
+                    task.options.includePattern = Pattern.compile(".*");
+                }
+            }
+        },
+
+        // ---- paths option ----
+        new Option(true, "-cp", "-classpath") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.classpath = arg;
+            }
+        },
+        new Option(true, "-mp", "-modulepath") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                task.options.modulePath = arg;
+            }
+        },
+        new Option(true, "-upgrademodulepath") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                task.options.upgradeModulePath = arg;
+            }
+        },
+        new Option(true, "-system") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (arg.equals("none")) {
+                    task.options.systemModulePath = null;
+                } else {
+                    Path path = Paths.get(arg);
+                    if (Files.isRegularFile(path.resolve("lib").resolve("modules")))
+                        task.options.systemModulePath = arg;
+                    else
+                        throw new BadArgs("err.invalid.path", arg);
+                }
+            }
+        },
+        new Option(true, "-addmods") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                Set<String> mods = Set.of(arg.split(","));
+                task.options.addmods.addAll(mods);
+            }
+        },
+        new Option(true, "-m") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                task.options.rootModule = arg;
+                task.options.addmods.add(arg);
+            }
+        },
+
+        // ---- Target filtering options ----
         new Option(true, "-p", "-package") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.packageNames.add(arg);
@@ -167,7 +287,7 @@
                 task.options.regex = Pattern.compile(arg);
             }
         },
-        new Option(true, "-module") {
+        new Option(true, "-requires") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.requires.add(arg);
             }
@@ -198,28 +318,27 @@
                 }
             }
         },
+
+        // ---- Source filtering options ----
         new Option(true, "-include") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 task.options.includePattern = Pattern.compile(arg);
             }
         },
+
+        // Another alternative to list modules in -addmods option
+        new HiddenOption(true, "-include-system-modules") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                task.options.includeSystemModulePattern = Pattern.compile(arg);
+            }
+        },
+
         new Option(false, "-P", "-profile") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 task.options.showProfile = true;
-                task.options.showModule = false;
             }
         },
-        new Option(false, "-M") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                task.options.showModule = true;
-                task.options.showProfile = false;
-            }
-        },
-        new Option(false, "-apionly") {
-            void process(JdepsTask task, String opt, String arg) {
-                task.options.apiOnly = true;
-            }
-        },
+
         new Option(false, "-R", "-recursive") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.depth = 0;
@@ -228,15 +347,17 @@
                 task.options.filterSamePackage = false;
             }
         },
-        new Option(true, "-genmoduleinfo") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                Path p = Paths.get(arg);
-                if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
-                    throw new BadArgs("err.invalid.path", arg);
-                }
-                task.options.genModuleInfo = arg;
+
+        new Option(false, "-I", "-inverse") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.inverse = true;
+                // equivalent to the inverse of compile-time view analysis
+                task.options.compileTimeView = true;
+                task.options.filterSamePackage = true;
+                task.options.filterSameArchive = true;
             }
         },
+
         new Option(false, "-ct", "-compile-time") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.compileTimeView = true;
@@ -245,62 +366,11 @@
                 task.options.depth = 0;
             }
         },
-        new Option(false, "-jdkinternals") {
-            void process(JdepsTask task, String opt, String arg) {
-                task.options.findJDKInternals = true;
-                task.options.verbose = CLASS;
-                if (task.options.includePattern == null) {
-                    task.options.includePattern = Pattern.compile(".*");
-                }
-            }
-        },
-        new Option(true, "-cp", "-classpath") {
-            void process(JdepsTask task, String opt, String arg) {
-                    task.options.classpath = arg;
-                }
-        },
-        new Option(true, "-mp", "-modulepath") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                task.options.modulePath = arg;
-                task.options.showModule = true;
-            }
-        },
-        new Option(true, "-upgrademodulepath") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                task.options.upgradeModulePath = arg;
-                task.options.showModule = true;
-            }
-        },
-        new Option(true, "-m") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                task.options.rootModule = arg;
-                task.options.includes.add(arg);
-                task.options.showModule = true;
-            }
-        },
-        new Option(false, "-check") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                task.options.checkModuleDeps = true;
-            }
-        },
-        new HiddenOption(true, "-include-modules") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                Arrays.stream(arg.split(","))
-                        .forEach(task.options.includes::add);
-                task.options.showModule = true;
-            }
-        },
-        new HiddenOption(true, "-exclude-modules") {
-                void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                    Arrays.stream(arg.split(","))
-                            .forEach(task.options.excludes::add);
-                    task.options.showModule = true;
-                }
-        },
+
         new Option(false, "-q", "-quiet") {
             void process(JdepsTask task, String opt, String arg) {
-                    task.options.nowarning = true;
-                }
+                task.options.nowarning = true;
+            }
         },
 
         new Option(false, "-version") {
@@ -318,7 +388,11 @@
                 task.options.showLabel = true;
             }
         },
-
+        new HiddenOption(false, "-hide-module") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.showModule = false;
+            }
+        },
         new HiddenOption(true, "-depth") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 try {
@@ -332,7 +406,7 @@
 
     private static final String PROGNAME = "jdeps";
     private final Options options = new Options();
-    private final List<String> classes = new ArrayList<>();
+    private final List<String> inputArgs = new ArrayList<>();
 
     private PrintWriter log;
     void setLog(PrintWriter out) {
@@ -342,13 +416,13 @@
     /**
      * Result codes.
      */
-    static final int EXIT_OK = 0, // Completed with no errors.
-                     EXIT_ERROR = 1, // Completed but reported errors.
-                     EXIT_CMDERR = 2, // Bad command-line arguments
-                     EXIT_SYSERR = 3, // System error or resource exhaustion.
-                     EXIT_ABNORMAL = 4;// terminated abnormally
+    static final int EXIT_OK = 0,       // Completed with no errors.
+                     EXIT_ERROR = 1,    // Completed but reported errors.
+                     EXIT_CMDERR = 2,   // Bad command-line arguments
+                     EXIT_SYSERR = 3,   // System error or resource exhaustion.
+                     EXIT_ABNORMAL = 4; // terminated abnormally
 
-    int run(String[] args) {
+    int run(String... args) {
         if (log == null) {
             log = new PrintWriter(System.out);
         }
@@ -360,15 +434,11 @@
             if (options.version || options.fullVersion) {
                 showVersion(options.fullVersion);
             }
-            if (options.rootModule != null && !classes.isEmpty()) {
-                reportError("err.invalid.module.option", options.rootModule, classes);
-                return EXIT_CMDERR;
+            if (!inputArgs.isEmpty() && options.rootModule != null) {
+                reportError("err.invalid.arg.for.option", "-m");
             }
-            if (options.checkModuleDeps && options.rootModule == null) {
-                reportError("err.root.module.not.set");
-                return EXIT_CMDERR;
-            }
-            if (classes.isEmpty() && options.rootModule == null && options.includePattern == null) {
+            if (inputArgs.isEmpty() && options.addmods.isEmpty() && options.includePattern == null
+                    && options.includeSystemModulePattern == null && options.checkModuleDeps == null) {
                 if (options.help || options.version || options.fullVersion) {
                     return EXIT_OK;
                 } else {
@@ -377,19 +447,10 @@
                 }
             }
             if (options.genModuleInfo != null) {
-                if (options.dotOutputDir != null || !options.classpath.isEmpty() || options.hasFilter()) {
+                if (options.dotOutputDir != null || options.classpath != null || options.hasFilter()) {
                     showHelp();
                     return EXIT_CMDERR;
                 }
-                // default to compile time view analysis
-                options.compileTimeView = true;
-                for (String fn : classes) {
-                    Path p = Paths.get(fn);
-                    if (!Files.exists(p) || !fn.endsWith(".jar")) {
-                        reportError("err.genmoduleinfo.not.jarfile", fn);
-                        return EXIT_CMDERR;
-                    }
-                }
             }
 
             if (options.numFilters() > 1) {
@@ -397,6 +458,16 @@
                 return EXIT_CMDERR;
             }
 
+            if (options.inverse && options.depth != 1) {
+                reportError("err.invalid.inverse.option", "-R");
+                return EXIT_CMDERR;
+            }
+
+            if (options.inverse && options.numFilters() == 0) {
+                reportError("err.invalid.filters");
+                return EXIT_CMDERR;
+            }
+
             if ((options.findJDKInternals) && (options.hasFilter() || options.showSummary)) {
                 showHelp();
                 return EXIT_CMDERR;
@@ -405,12 +476,15 @@
                 showHelp();
                 return EXIT_CMDERR;
             }
+            if (options.checkModuleDeps != null && !inputArgs.isEmpty()) {
+                reportError("err.invalid.module.option", inputArgs, "-check");
+            }
 
             boolean ok = run();
             return ok ? EXIT_OK : EXIT_ERROR;
-        } catch (BadArgs e) {
-            reportError(e.key, e.args);
-            if (e.showUsage) {
+        } catch (BadArgs|UncheckedBadArgs e) {
+            reportError(e.getKey(), e.getArgs());
+            if (e.showUsage()) {
                 log.println(getMessage("main.usage.summary", PROGNAME));
             }
             return EXIT_CMDERR;
@@ -419,176 +493,216 @@
             return EXIT_CMDERR;
         } catch (IOException e) {
             e.printStackTrace();
-            return EXIT_ABNORMAL;
+            return EXIT_CMDERR;
         } finally {
             log.flush();
         }
     }
 
-    private ModulePaths modulePaths;
-    private boolean run() throws BadArgs, IOException {
-        DependencyFinder dependencyFinder =
-            new DependencyFinder(options.compileTimeView);
+    boolean run() throws IOException {
+        try (JdepsConfiguration config = buildConfig()) {
 
-        buildArchive(dependencyFinder);
+            // detect split packages
+            config.splitPackages().entrySet().stream()
+                .sorted(Map.Entry.comparingByKey())
+                .forEach(e -> System.out.format("split package: %s %s%n", e.getKey(),
+                    e.getValue().toString()));
 
-        if (options.rootModule != null &&
-                (options.checkModuleDeps || (options.dotOutputDir != null &&
-                                      options.verbose == SUMMARY))) {
-            // -dotfile -s prints the configuration of the given root
-            // -checkModuleDeps prints the suggested module-info.java
-            return analyzeModules(dependencyFinder);
-        }
+            // check if any module specified in -requires is missing
+            Stream.concat(options.addmods.stream(), options.requires.stream())
+                .filter(mn -> !config.isValidToken(mn))
+                .forEach(mn -> config.findModule(mn).orElseThrow(() ->
+                    new UncheckedBadArgs(new BadArgs("err.module.not.found", mn))));
 
-        // otherwise analyze the dependencies
-        if (options.genModuleInfo != null) {
-            return genModuleInfo(dependencyFinder);
-        } else {
-            return analyzeDeps(dependencyFinder);
+            // -genmoduleinfo
+            if (options.genModuleInfo != null) {
+                return genModuleInfo(config);
+            }
+
+            // -check
+            if (options.checkModuleDeps != null) {
+                return new ModuleAnalyzer(config, log, options.checkModuleDeps).run();
+            }
+
+            if (options.dotOutputDir != null &&
+                (options.verbose == SUMMARY || options.verbose == MODULE) &&
+                !options.addmods.isEmpty() && inputArgs.isEmpty()) {
+                return new ModuleAnalyzer(config, log).genDotFiles(options.dotOutputDir);
+            }
+
+            if (options.inverse) {
+                return analyzeInverseDeps(config);
+            } else {
+                return analyzeDeps(config);
+            }
         }
     }
 
-    private void buildArchive(DependencyFinder dependencyFinder)
-            throws BadArgs, IOException
-    {
-        // If -genmoduleinfo is specified, the input arguments must be JAR files
-        // Treat them as automatic modules for analysis
-        List<Path> jarfiles = options.genModuleInfo != null
-                                    ?  classes.stream().map(Paths::get)
-                                              .collect(Collectors.toList())
-                                    : Collections.emptyList();
-        // Set module paths
-        this.modulePaths = new ModulePaths(options.upgradeModulePath, options.modulePath, jarfiles);
+    private JdepsConfiguration buildConfig() throws IOException {
+        JdepsConfiguration.Builder builder =
+            new JdepsConfiguration.Builder(options.systemModulePath);
 
-        // add modules to dependency finder for analysis
-        Map<String, Module> modules = modulePaths.getModules();
-        modules.values().stream()
-               .forEach(dependencyFinder::addModule);
+        builder.upgradeModulePath(options.upgradeModulePath)
+               .appModulePath(options.modulePath)
+               .addmods(options.addmods);
 
-        // If -m option is set, add the specified module and its transitive dependences
-        // to the root set
-        if (options.rootModule != null) {
-            modulePaths.dependences(options.rootModule)
-                       .forEach(dependencyFinder::addRoot);
+        if (options.checkModuleDeps != null) {
+            // check all system modules in the image
+            builder.allModules();
         }
 
-        // check if any module specified in -requires is missing
-        Optional<String> req = options.requires.stream()
-                .filter(mn -> !modules.containsKey(mn))
-                .findFirst();
-        if (req.isPresent()) {
-            throw new BadArgs("err.module.not.found", req.get());
-        }
+        if (options.classpath != null)
+            builder.addClassPath(options.classpath);
 
-        // classpath
-        for (Path p : getClassPaths(options.classpath)) {
+        // build the root set of archives to be analyzed
+        for (String s : inputArgs) {
+            Path p = Paths.get(s);
             if (Files.exists(p)) {
-                dependencyFinder.addClassPathArchive(p);
+                builder.addRoot(p);
             }
         }
 
-        // if -genmoduleinfo is not set, the input arguments are considered as
-        // unnamed module.  Add them to the root set
-        if (options.genModuleInfo == null) {
-            // add root set
-            for (String s : classes) {
-                Path p = Paths.get(s);
-                if (Files.exists(p)) {
-                    // add to the initial root set
-                    dependencyFinder.addRoot(p);
-                } else {
-                    if (isValidClassName(s)) {
-                        dependencyFinder.addClassName(s);
-                    } else {
-                        warning("warn.invalid.arg", s);
-                    }
-                }
-            }
-        }
+        return builder.build();
     }
 
-    private boolean analyzeDeps(DependencyFinder dependencyFinder) throws IOException {
-        JdepsFilter filter = dependencyFilter();
-
-        // parse classfiles and find all dependencies
-        findDependencies(dependencyFinder, filter, options.apiOnly);
-
-        // analyze the dependencies collected
-        Analyzer analyzer = new Analyzer(options.verbose, filter);
-        analyzer.run(dependencyFinder.archives());
-
+    private boolean analyzeDeps(JdepsConfiguration config) throws IOException {
         // output result
         final JdepsWriter writer;
         if (options.dotOutputDir != null) {
-            Path dir = Paths.get(options.dotOutputDir);
-            Files.createDirectories(dir);
-            writer = new DotFileWriter(dir, options.verbose,
+            writer = new DotFileWriter(options.dotOutputDir,
+                                       options.verbose,
                                        options.showProfile,
                                        options.showModule,
                                        options.showLabel);
         } else {
-            writer = new SimpleWriter(log, options.verbose,
+            writer = new SimpleWriter(log,
+                                      options.verbose,
                                       options.showProfile,
                                       options.showModule);
         }
 
-        // Targets for reporting - include the root sets and other analyzed archives
-        final List<Archive> targets;
-        if (options.rootModule == null) {
-            // no module as the root set
-            targets = dependencyFinder.archives()
-                                      .filter(filter::accept)
-                                      .filter(a -> !a.getModule().isNamed())
-                                      .collect(Collectors.toList());
-        } else {
-            // named modules in topological order
-            Stream<Module> modules = dependencyFinder.archives()
-                                                     .filter(a -> a.getModule().isNamed())
-                                                     .map(Archive::getModule);
-            Graph<Module> graph = ModuleAnalyzer.graph(modulePaths, modules.toArray(Module[]::new));
-            // then add unnamed module
-            targets = graph.orderedNodes()
-                           .filter(filter::accept)
-                           .collect(Collectors.toList());
+        // analyze the dependencies
+        DepsAnalyzer analyzer = new DepsAnalyzer(config,
+                                        dependencyFilter(config),
+                                        writer,
+                                        options.verbose,
+                                        options.apiOnly);
 
-            // in case any reference not found
-            dependencyFinder.archives()
-                    .filter(a -> !a.getModule().isNamed())
-                    .forEach(targets::add);
-        }
+        boolean ok = analyzer.run(options.compileTimeView, options.depth);
 
-        writer.generateOutput(targets, analyzer);
+        // print skipped entries, if any
+        analyzer.archives()
+            .forEach(archive -> archive.reader()
+                .skippedEntries().stream()
+                .forEach(name -> warning("warn.skipped.entry",
+                                         name, archive.getPathName())));
+
         if (options.findJDKInternals && !options.nowarning) {
-            showReplacements(targets, analyzer);
+            Map<String, String> jdkInternals = analyzer.dependences()
+                .collect(Collectors.toMap(Function.identity(), this::replacementFor));
+
+            if (!jdkInternals.isEmpty()) {
+                log.println();
+                warning("warn.replace.useJDKInternals", getMessage("jdeps.wiki.url"));
+
+                if (jdkInternals.values().stream().anyMatch(repl -> repl != null)) {
+                    log.println();
+                    log.format("%-40s %s%n", "JDK Internal API", "Suggested Replacement");
+                    log.format("%-40s %s%n", "----------------", "---------------------");
+                        jdkInternals.entrySet().stream()
+                            .filter(e -> e.getValue() != null)
+                            .sorted(Map.Entry.comparingByKey())
+                            .forEach(e -> log.format("%-40s %s%n", e.getKey(), e.getValue()));
+                }
+            }
+
         }
-        return true;
+        return ok;
     }
 
-    private JdepsFilter dependencyFilter() {
-        // Filter specified by -filter, -package, -regex, and -module options
-        JdepsFilter.Builder builder = new JdepsFilter.Builder();
+    private boolean analyzeInverseDeps(JdepsConfiguration config) throws IOException {
+        JdepsWriter writer = new SimpleWriter(log,
+                                              options.verbose,
+                                              options.showProfile,
+                                              options.showModule);
 
-        // Exclude JDK modules from analysis and reporting if -m specified.
-        modulePaths.getModules().values().stream()
-                   .filter(m -> m.isJDK())
-                   .map(Module::name)
-                   .forEach(options.excludes::add);
+        InverseDepsAnalyzer analyzer = new InverseDepsAnalyzer(config,
+                                                               dependencyFilter(config),
+                                                               writer,
+                                                               options.verbose,
+                                                               options.apiOnly);
+        boolean ok = analyzer.run();
+
+        log.println();
+        if (!options.requires.isEmpty())
+            log.format("Inverse transitive dependences on %s%n", options.requires);
+        else
+            log.format("Inverse transitive dependences matching %s%n",
+                options.regex != null
+                    ? options.regex.toString()
+                    : "packages " + options.packageNames);
+
+        analyzer.inverseDependences().stream()
+                .sorted(Comparator.comparing(this::sortPath))
+                .forEach(path -> log.println(path.stream()
+                                                .map(Archive::getName)
+                                                .collect(Collectors.joining(" <- "))));
+        return ok;
+    }
+
+    private String sortPath(Deque<Archive> path) {
+        return path.peekFirst().getName();
+    }
+
+    private boolean genModuleInfo(JdepsConfiguration config) throws IOException {
+        ModuleInfoBuilder builder
+            = new ModuleInfoBuilder(config, inputArgs, options.genModuleInfo);
+        boolean ok = builder.run();
+
+        builder.modules().forEach(module -> {
+            if (module.packages().contains("")) {
+                reportError("ERROR: %s contains unnamed package.  " +
+                    "module-info.java not generated%n", module.getPathName());
+            }
+        });
+
+        if (!ok && !options.nowarning) {
+            log.println("ERROR: missing dependencies");
+            builder.visitMissingDeps(
+                new Analyzer.Visitor() {
+                    @Override
+                    public void visitDependence(String origin, Archive originArchive,
+                                                String target, Archive targetArchive) {
+                        if (builder.notFound(targetArchive))
+                            log.format("   %-50s -> %-50s %s%n",
+                                origin, target, targetArchive.getName());
+                    }
+                });
+        }
+        return ok;
+    }
+
+    /**
+     * Returns a filter used during dependency analysis
+     */
+    private JdepsFilter dependencyFilter(JdepsConfiguration config) {
+        // Filter specified by -filter, -package, -regex, and -requires options
+        JdepsFilter.Builder builder = new JdepsFilter.Builder();
 
         // source filters
         builder.includePattern(options.includePattern);
-        builder.includeModules(options.includes);
-        builder.excludeModules(options.excludes);
+        builder.includeSystemModules(options.includeSystemModulePattern);
 
         builder.filter(options.filterSamePackage, options.filterSameArchive);
         builder.findJDKInternals(options.findJDKInternals);
 
-        // -module
+        // -requires
         if (!options.requires.isEmpty()) {
-            Map<String, Module> modules = modulePaths.getModules();
-            builder.packages(options.requires.stream()
-                    .map(modules::get)
-                    .flatMap(m -> m.packages().stream())
-                    .collect(Collectors.toSet()));
+            options.requires.stream()
+                .forEach(mn -> {
+                    Module m = config.findModule(mn).get();
+                    builder.requires(mn, m.packages());
+                });
         }
         // -regex
         if (options.regex != null)
@@ -600,62 +714,14 @@
         if (options.filterRegex != null)
             builder.filter(options.filterRegex);
 
+        // check if system module is set
+        config.rootModules().stream()
+            .map(Module::name)
+            .forEach(builder::includeIfSystemModule);
+
         return builder.build();
     }
 
-    private void findDependencies(DependencyFinder dependencyFinder,
-                                  JdepsFilter filter,
-                                  boolean apiOnly)
-        throws IOException
-    {
-        dependencyFinder.findDependencies(filter, apiOnly, options.depth);
-
-        // print skipped entries, if any
-        for (Archive a : dependencyFinder.roots()) {
-            for (String name : a.reader().skippedEntries()) {
-                warning("warn.skipped.entry", name, a.getPathName());
-            }
-        }
-    }
-
-    private boolean genModuleInfo(DependencyFinder dependencyFinder) throws IOException {
-        ModuleInfoBuilder builder = new ModuleInfoBuilder(modulePaths, dependencyFinder);
-        boolean result = builder.run(options.verbose, options.nowarning);
-        builder.build(Paths.get(options.genModuleInfo));
-        return result;
-    }
-
-    private boolean analyzeModules(DependencyFinder dependencyFinder)
-            throws IOException
-    {
-        ModuleAnalyzer analyzer = new ModuleAnalyzer(modulePaths,
-                                                     dependencyFinder,
-                                                     options.rootModule);
-        if (options.checkModuleDeps) {
-            return analyzer.run();
-        }
-        if (options.dotOutputDir != null && options.verbose == SUMMARY) {
-            Path dir = Paths.get(options.dotOutputDir);
-            Files.createDirectories(dir);
-            analyzer.genDotFile(dir);
-            return true;
-        }
-        return false;
-    }
-
-    private boolean isValidClassName(String name) {
-        if (!Character.isJavaIdentifierStart(name.charAt(0))) {
-            return false;
-        }
-        for (int i=1; i < name.length(); i++) {
-            char c = name.charAt(i);
-            if (c != '.'  && !Character.isJavaIdentifierPart(c)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
     public void handleOptions(String[] args) throws BadArgs {
         // process options
         for (int i=0; i < args.length; i++) {
@@ -684,7 +750,7 @@
                     if (name.charAt(0) == '-') {
                         throw new BadArgs("err.option.after.class", name).showUsage(true);
                     }
-                    classes.add(name);
+                    inputArgs.add(name);
                 }
             }
         }
@@ -703,7 +769,7 @@
         log.println(getMessage("error.prefix") + " " + getMessage(key, args));
     }
 
-    private void warning(String key, Object... args) {
+    void warning(String key, Object... args) {
         log.println(getMessage("warn.prefix") + " " + getMessage(key, args));
     }
 
@@ -749,7 +815,7 @@
         boolean version;
         boolean fullVersion;
         boolean showProfile;
-        boolean showModule;
+        boolean showModule = true;
         boolean showSummary;
         boolean apiOnly;
         boolean showLabel;
@@ -761,22 +827,23 @@
         boolean filterSamePackage = true;
         boolean filterSameArchive = false;
         Pattern filterRegex;
-        String dotOutputDir;
-        String genModuleInfo;
-        String classpath = "";
+        Path dotOutputDir;
+        Path genModuleInfo;
+        String classpath;
         int depth = 1;
         Set<String> requires = new HashSet<>();
         Set<String> packageNames = new HashSet<>();
         Pattern regex;             // apply to the dependences
-        Pattern includePattern;    // apply to classes
+        Pattern includePattern;
+        Pattern includeSystemModulePattern;
+        boolean inverse = false;
         boolean compileTimeView = false;
-        boolean checkModuleDeps = false;
+        Set<String> checkModuleDeps;
+        String systemModulePath = System.getProperty("java.home");
         String upgradeModulePath;
         String modulePath;
         String rootModule;
-        // modules to be included or excluded
-        Set<String> includes = new HashSet<>();
-        Set<String> excludes = new HashSet<>();
+        Set<String> addmods = new HashSet<>();
 
         boolean hasFilter() {
             return numFilters() > 0;
@@ -789,11 +856,8 @@
             if (packageNames.size() > 0) count++;
             return count;
         }
-
-        boolean isRootModule() {
-            return rootModule != null;
-        }
     }
+
     private static class ResourceBundleHelper {
         static final ResourceBundle versionRB;
         static final ResourceBundle bundle;
@@ -819,35 +883,6 @@
         }
     }
 
-    /*
-     * Returns the list of Archive specified in cpaths and not included
-     * initialArchives
-     */
-    private List<Path> getClassPaths(String cpaths) throws IOException
-    {
-        if (cpaths.isEmpty()) {
-            return Collections.emptyList();
-        }
-        List<Path> paths = new ArrayList<>();
-        for (String p : cpaths.split(File.pathSeparator)) {
-            if (p.length() > 0) {
-                // wildcard to parse all JAR files e.g. -classpath dir/*
-                int i = p.lastIndexOf(".*");
-                if (i > 0) {
-                    Path dir = Paths.get(p.substring(0, i));
-                    try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) {
-                        for (Path entry : stream) {
-                            paths.add(entry);
-                        }
-                    }
-                } else {
-                    paths.add(Paths.get(p));
-                }
-            }
-        }
-        return paths;
-    }
-
     /**
      * Returns the recommended replacement API for the given classname;
      * or return null if replacement API is not known.
@@ -865,32 +900,5 @@
             }
         }
         return value;
-    };
-
-    private void showReplacements(List<Archive> archives, Analyzer analyzer) {
-        Map<String,String> jdkinternals = new TreeMap<>();
-        boolean useInternals = false;
-        for (Archive source : archives) {
-            useInternals = useInternals || analyzer.hasDependences(source);
-            for (String cn : analyzer.dependences(source)) {
-                String repl = replacementFor(cn);
-                if (repl != null) {
-                    jdkinternals.putIfAbsent(cn, repl);
-                }
-            }
-        }
-        if (useInternals) {
-            log.println();
-            warning("warn.replace.useJDKInternals", getMessage("jdeps.wiki.url"));
-        }
-        if (!jdkinternals.isEmpty()) {
-            log.println();
-            log.format("%-40s %s%n", "JDK Internal API", "Suggested Replacement");
-            log.format("%-40s %s%n", "----------------", "---------------------");
-            for (Map.Entry<String,String> e : jdkinternals.entrySet()) {
-                log.format("%-40s %s%n", e.getKey(), e.getValue());
-            }
-        }
     }
-
 }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java
index 06449fa..fdfb370 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java
@@ -24,23 +24,33 @@
  */
 package com.sun.tools.jdeps;
 
+import static com.sun.tools.jdeps.Analyzer.Type.*;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.UncheckedIOException;
+import java.lang.module.ModuleDescriptor.Requires;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 
-import static com.sun.tools.jdeps.Analyzer.Type.*;
-
 public abstract class JdepsWriter {
+    public static JdepsWriter newDotWriter(Path outputdir, Analyzer.Type type) {
+        return new DotFileWriter(outputdir, type, false, true, false);
+    }
+
+    public static JdepsWriter newSimpleWriter(PrintWriter writer,  Analyzer.Type type) {
+        return new SimpleWriter(writer, type, false, true);
+    }
+
     final Analyzer.Type type;
     final boolean showProfile;
     final boolean showModule;
 
-    JdepsWriter(Analyzer.Type type, boolean showProfile, boolean showModule) {
+    private JdepsWriter(Analyzer.Type type, boolean showProfile, boolean showModule) {
         this.type = type;
         this.showProfile = showProfile;
         this.showModule = showModule;
@@ -48,7 +58,7 @@
 
     abstract void generateOutput(Collection<Archive> archives, Analyzer analyzer) throws IOException;
 
-    public static class DotFileWriter extends JdepsWriter {
+    static class DotFileWriter extends JdepsWriter {
         final boolean showLabel;
         final Path outputDir;
         DotFileWriter(Path dir, Analyzer.Type type,
@@ -62,8 +72,10 @@
         void generateOutput(Collection<Archive> archives, Analyzer analyzer)
                 throws IOException
         {
+            Files.createDirectories(outputDir);
+
             // output individual .dot file for each archive
-            if (type != SUMMARY) {
+            if (type != SUMMARY && type != MODULE) {
                 archives.stream()
                         .filter(analyzer::hasDependences)
                         .forEach(archive -> {
@@ -85,13 +97,13 @@
         {
             // If verbose mode (-v or -verbose option),
             // the summary.dot file shows package-level dependencies.
-            Analyzer.Type summaryType =
-                (type == PACKAGE || type == SUMMARY) ? SUMMARY : PACKAGE;
+            boolean isSummary =  type == PACKAGE || type == SUMMARY || type == MODULE;
+            Analyzer.Type summaryType = isSummary ? SUMMARY : PACKAGE;
             Path summary = outputDir.resolve("summary.dot");
             try (PrintWriter sw = new PrintWriter(Files.newOutputStream(summary));
                  SummaryDotFile dotfile = new SummaryDotFile(sw, summaryType)) {
                 for (Archive archive : archives) {
-                    if (type == PACKAGE || type == SUMMARY) {
+                    if (isSummary) {
                         if (showLabel) {
                             // build labels listing package-level dependencies
                             analyzer.visitDependences(archive, dotfile.labelBuilder(), PACKAGE);
@@ -208,19 +220,22 @@
         void generateOutput(Collection<Archive> archives, Analyzer analyzer) {
             RawOutputFormatter depFormatter = new RawOutputFormatter(writer);
             RawSummaryFormatter summaryFormatter = new RawSummaryFormatter(writer);
-            for (Archive archive : archives) {
-                // print summary
-                if (showModule && archive.getModule().isNamed()) {
-                    summaryFormatter.showModuleRequires(archive.getModule());
-                } else {
+            archives.stream()
+                .filter(analyzer::hasDependences)
+                .sorted(Comparator.comparing(Archive::getName))
+                .forEach(archive -> {
+                    if (showModule && archive.getModule().isNamed() && type != SUMMARY) {
+                        // print module-info except -summary
+                        summaryFormatter.printModuleDescriptor(archive.getModule());
+                    }
+                    // print summary
                     analyzer.visitDependences(archive, summaryFormatter, SUMMARY);
-                }
 
-                if (analyzer.hasDependences(archive) && type != SUMMARY) {
-                    // print the class-level or package-level dependences
-                    analyzer.visitDependences(archive, depFormatter);
-                }
-            }
+                    if (analyzer.hasDependences(archive) && type != SUMMARY) {
+                        // print the class-level or package-level dependences
+                        analyzer.visitDependences(archive, depFormatter);
+                    }
+            });
         }
 
         class RawOutputFormatter implements Analyzer.Visitor {
@@ -269,20 +284,16 @@
                 writer.format("%n");
             }
 
-            public void showModuleRequires(Module module) {
+            public void printModuleDescriptor(Module module) {
                 if (!module.isNamed())
                     return;
 
-                writer.format("module %s", module.name());
-                if (module.isAutomatic())
-                    writer.format(" (automatic)");
-                writer.println();
-                module.requires().keySet()
+                writer.format("%s%s%n", module.name(), module.isAutomatic() ? " automatic" : "");
+                writer.format(" [%s]%n", module.location());
+                module.descriptor().requires()
                         .stream()
-                        .sorted()
-                        .forEach(req -> writer.format(" requires %s%s%n",
-                                                      module.requires.get(req) ? "public " : "",
-                                                      req));
+                        .sorted(Comparator.comparing(Requires::name))
+                        .forEach(req -> writer.format("   requires %s%n", req));
             }
         }
     }
@@ -307,7 +318,7 @@
         }
 
         // exported API
-        boolean jdkunsupported = Module.isJDKUnsupported(module, pn);
+        boolean jdkunsupported = Module.JDK_UNSUPPORTED.equals(module.name());
         if (module.isExported(pn) && !jdkunsupported) {
             return showProfileOrModule(module);
         }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java
index a3ede30..4f67a73 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java
@@ -25,67 +25,56 @@
 
 package com.sun.tools.jdeps;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UncheckedIOException;
 import java.lang.module.ModuleDescriptor;
 import java.net.URI;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
 import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.stream.Collectors;
 
 /**
- * JDeps internal representation of module for dependency analysis.
+ * Jdeps internal representation of module for dependency analysis.
  */
 class Module extends Archive {
-    static final boolean traceOn = Boolean.getBoolean("jdeps.debug");
+    static final Module UNNAMED_MODULE = new UnnamedModule();
+    static final String JDK_UNSUPPORTED = "jdk.unsupported";
+
+    static final boolean DEBUG = Boolean.getBoolean("jdeps.debug");
     static void trace(String fmt, Object... args) {
+        trace(DEBUG, fmt, args);
+    }
+
+    static void trace(boolean traceOn, String fmt, Object... args) {
         if (traceOn) {
             System.err.format(fmt, args);
         }
     }
 
-    /*
-     * Returns true if the given package name is JDK critical internal API
-     * in jdk.unsupported module
-     */
-    static boolean isJDKUnsupported(Module m, String pn) {
-        return JDK_UNSUPPORTED.equals(m.name()) || unsupported.contains(pn);
-    };
+    private final ModuleDescriptor descriptor;
+    private final Map<String, Set<String>> exports;
+    private final boolean isSystem;
+    private final URI location;
 
-    protected final ModuleDescriptor descriptor;
-    protected final Map<String, Boolean> requires;
-    protected final Map<String, Set<String>> exports;
-    protected final Set<String> packages;
-    protected final boolean isJDK;
-    protected final URI location;
+    protected Module(String name) {
+        super(name);
+        this.descriptor = null;
+        this.location = null;
+        this.exports = Collections.emptyMap();
+        this.isSystem = true;
+    }
 
     private Module(String name,
                    URI location,
                    ModuleDescriptor descriptor,
-                   Map<String, Boolean> requires,
                    Map<String, Set<String>> exports,
-                   Set<String> packages,
-                   boolean isJDK,
+                   boolean isSystem,
                    ClassFileReader reader) {
         super(name, location, reader);
         this.descriptor = descriptor;
         this.location = location;
-        this.requires = Collections.unmodifiableMap(requires);
         this.exports = Collections.unmodifiableMap(exports);
-        this.packages = Collections.unmodifiableSet(packages);
-        this.isJDK = isJDK;
+        this.isSystem = isSystem;
     }
 
     /**
@@ -111,31 +100,35 @@
         return descriptor;
     }
 
-    public boolean isJDK() {
-        return isJDK;
+    public URI location() {
+        return location;
     }
 
-    public Map<String, Boolean> requires() {
-        return requires;
+    public boolean isJDK() {
+        String mn = name();
+        return isSystem &&
+            (mn.startsWith("java.") || mn.startsWith("jdk.") || mn.startsWith("javafx."));
+    }
+
+    public boolean isSystem() {
+        return isSystem;
     }
 
     public Map<String, Set<String>> exports() {
         return exports;
     }
 
-    public Map<String, Set<String>> provides() {
-        return descriptor.provides().entrySet().stream()
-                .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().providers()));
-    }
-
     public Set<String> packages() {
-        return packages;
+        return descriptor.packages();
     }
 
     /**
      * Tests if the package of the given name is exported.
      */
     public boolean isExported(String pn) {
+        if (JDK_UNSUPPORTED.equals(this.name())) {
+            return false;
+        }
         return exports.containsKey(pn) ? exports.get(pn).isEmpty() : false;
     }
 
@@ -159,11 +152,6 @@
         return isExported(pn) || exports.containsKey(pn) && exports.get(pn).contains(target);
     }
 
-    private final static String JDK_UNSUPPORTED = "jdk.unsupported";
-
-    // temporary until jdk.unsupported module
-    private final static List<String> unsupported = Arrays.asList("sun.misc", "sun.reflect");
-
     @Override
     public String toString() {
         return name();
@@ -171,21 +159,19 @@
 
     public final static class Builder {
         final String name;
-        final Map<String, Boolean> requires = new HashMap<>();
-        final Map<String, Set<String>> exports = new HashMap<>();
-        final Set<String> packages = new HashSet<>();
-        final boolean isJDK;
+        final ModuleDescriptor descriptor;
+        final boolean isSystem;
         ClassFileReader reader;
-        ModuleDescriptor descriptor;
         URI location;
 
-        public Builder(String name) {
-            this(name, false);
+        public Builder(ModuleDescriptor md) {
+            this(md, false);
         }
 
-        public Builder(String name, boolean isJDK) {
-            this.name = name;
-            this.isJDK = isJDK;
+        public Builder(ModuleDescriptor md, boolean isSystem) {
+            this.name = md.name();
+            this.descriptor = md;
+            this.isSystem = isSystem;
         }
 
         public Builder location(URI location) {
@@ -193,48 +179,30 @@
             return this;
         }
 
-        public Builder descriptor(ModuleDescriptor md) {
-            this.descriptor = md;
-            return this;
-        }
-
-        public Builder require(String d, boolean reexport) {
-            requires.put(d, reexport);
-            return this;
-        }
-
-        public Builder packages(Set<String> pkgs) {
-            packages.addAll(pkgs);
-            return this;
-        }
-
-        public Builder export(String p, Set<String> ms) {
-            Objects.requireNonNull(p);
-            Objects.requireNonNull(ms);
-            exports.put(p, new HashSet<>(ms));
-            return this;
-        }
         public Builder classes(ClassFileReader reader) {
             this.reader = reader;
             return this;
         }
 
         public Module build() {
-            if (descriptor.isAutomatic() && isJDK) {
+            if (descriptor.isAutomatic() && isSystem) {
                 throw new InternalError("JDK module: " + name + " can't be automatic module");
             }
 
-            return new Module(name, location, descriptor, requires, exports, packages, isJDK, reader);
+            Map<String, Set<String>> exports = new HashMap<>();
+
+            descriptor.exports().stream()
+                .forEach(exp -> exports.computeIfAbsent(exp.source(), _k -> new HashSet<>())
+                                    .addAll(exp.targets()));
+
+            return new Module(name, location, descriptor, exports, isSystem, reader);
         }
     }
 
-    final static Module UNNAMED_MODULE = new UnnamedModule();
     private static class UnnamedModule extends Module {
         private UnnamedModule() {
             super("unnamed", null, null,
                   Collections.emptyMap(),
-                  Collections.emptyMap(),
-                  Collections.emptySet(),
                   false, null);
         }
 
@@ -260,10 +228,7 @@
     }
 
     private static class StrictModule extends Module {
-        private static final String SERVICES_PREFIX = "META-INF/services/";
-        private final Map<String, Set<String>> provides;
-        private final Module module;
-        private final JarFile jarfile;
+        private final ModuleDescriptor md;
 
         /**
          * Converts the given automatic module to a strict module.
@@ -272,114 +237,26 @@
          * declare service providers, if specified in META-INF/services configuration file
          */
         private StrictModule(Module m, Map<String, Boolean> requires) {
-            super(m.name(), m.location, m.descriptor, requires, m.exports, m.packages, m.isJDK, m.reader());
-            this.module = m;
-            try {
-                this.jarfile = new JarFile(m.path().toFile(), false);
-            } catch (IOException e) {
-                throw new UncheckedIOException(e);
-            }
-            this.provides = providers(jarfile);
+            super(m.name(), m.location, m.descriptor, m.exports, m.isSystem, m.reader());
+
+            ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(m.name());
+            requires.keySet().forEach(mn -> {
+                if (requires.get(mn).equals(Boolean.TRUE)) {
+                    builder.requires(ModuleDescriptor.Requires.Modifier.PUBLIC, mn);
+                } else {
+                    builder.requires(mn);
+                }
+            });
+            m.descriptor.exports().forEach(e -> builder.exports(e));
+            m.descriptor.uses().forEach(s -> builder.uses(s));
+            m.descriptor.provides().values().forEach(p -> builder.provides(p));
+            builder.conceals(m.descriptor.conceals());
+            this.md = builder.build();
         }
 
         @Override
-        public Map<String, Set<String>> provides() {
-            return provides;
-        }
-
-        private Map<String, Set<String>> providers(JarFile jf) {
-            Map<String, Set<String>> provides = new HashMap<>();
-            // map names of service configuration files to service names
-            Set<String> serviceNames =  jf.stream()
-                    .map(e -> e.getName())
-                    .filter(e -> e.startsWith(SERVICES_PREFIX))
-                    .distinct()
-                    .map(this::toServiceName)
-                    .filter(Optional::isPresent)
-                    .map(Optional::get)
-                    .collect(Collectors.toSet());
-
-            // parse each service configuration file
-            for (String sn : serviceNames) {
-                JarEntry entry = jf.getJarEntry(SERVICES_PREFIX + sn);
-                Set<String> providerClasses = new HashSet<>();
-                try (InputStream in = jf.getInputStream(entry)) {
-                    BufferedReader reader
-                            = new BufferedReader(new InputStreamReader(in, "UTF-8"));
-                    String cn;
-                    while ((cn = nextLine(reader)) != null) {
-                        if (isJavaIdentifier(cn)) {
-                            providerClasses.add(cn);
-                        }
-                    }
-                } catch (IOException e) {
-                    throw new UncheckedIOException(e);
-                }
-                if (!providerClasses.isEmpty())
-                    provides.put(sn, providerClasses);
-            }
-
-            return provides;
-        }
-
-        /**
-         * Returns a container with the service type corresponding to the name of
-         * a services configuration file.
-         *
-         * For example, if called with "META-INF/services/p.S" then this method
-         * returns a container with the value "p.S".
-         */
-        private Optional<String> toServiceName(String cf) {
-            assert cf.startsWith(SERVICES_PREFIX);
-            int index = cf.lastIndexOf("/") + 1;
-            if (index < cf.length()) {
-                String prefix = cf.substring(0, index);
-                if (prefix.equals(SERVICES_PREFIX)) {
-                    String sn = cf.substring(index);
-                    if (isJavaIdentifier(sn))
-                        return Optional.of(sn);
-                }
-            }
-            return Optional.empty();
-        }
-
-        /**
-         * Reads the next line from the given reader and trims it of comments and
-         * leading/trailing white space.
-         *
-         * Returns null if the reader is at EOF.
-         */
-        private String nextLine(BufferedReader reader) throws IOException {
-            String ln = reader.readLine();
-            if (ln != null) {
-                int ci = ln.indexOf('#');
-                if (ci >= 0)
-                    ln = ln.substring(0, ci);
-                ln = ln.trim();
-            }
-            return ln;
-        }
-
-        /**
-         * Returns {@code true} if the given identifier is a legal Java identifier.
-         */
-        private static boolean isJavaIdentifier(String id) {
-            int n = id.length();
-            if (n == 0)
-                return false;
-            if (!Character.isJavaIdentifierStart(id.codePointAt(0)))
-                return false;
-            int cp = id.codePointAt(0);
-            int i = Character.charCount(cp);
-            for (; i < n; i += Character.charCount(cp)) {
-                cp = id.codePointAt(i);
-                if (!Character.isJavaIdentifierPart(cp) && id.charAt(i) != '.')
-                    return false;
-            }
-            if (cp == '.')
-                return false;
-
-            return true;
+        public ModuleDescriptor descriptor() {
+            return md;
         }
     }
 }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java
index f419e56..d174240 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java
@@ -24,277 +24,364 @@
  */
 package com.sun.tools.jdeps;
 
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.UncheckedIOException;
-
+import static com.sun.tools.jdeps.Graph.*;
+import static com.sun.tools.jdeps.JdepsFilter.DEFAULT_FILTER;
+import static com.sun.tools.jdeps.Module.*;
 import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
+import static java.util.stream.Collectors.*;
 
-import java.lang.module.Configuration;
+import com.sun.tools.classfile.Dependency;
+import com.sun.tools.jdeps.JdepsTask.BadArgs;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
 import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReference;
-import java.lang.module.ResolvedModule;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
-import java.util.function.Consumer;
 import java.util.function.Function;
-import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static com.sun.tools.jdeps.Module.*;
-import static com.sun.tools.jdeps.ModulePaths.SystemModulePath.JAVA_BASE;
-
 /**
  * Analyze module dependences and compare with module descriptor.
  * Also identify any qualified exports not used by the target module.
  */
-class ModuleAnalyzer {
-    private final ModulePaths modulePaths;
+public class ModuleAnalyzer {
+    private static final String JAVA_BASE = "java.base";
+
+    private final JdepsConfiguration configuration;
+    private final PrintWriter log;
+
     private final DependencyFinder dependencyFinder;
-    private final Module root;
-    private final Set<Module> modules;
-    private final Set<String> requiresPublic = new HashSet<>();
-    private final Set<String> requires = new HashSet<>();
-    private final Set<Module> exportTargets = new HashSet<>();
-    private final JdepsFilter filter;
-    private Graph<Module> graph;
-    ModuleAnalyzer(ModulePaths modulePaths, DependencyFinder finder,
-                   String moduleName) {
-        this.modulePaths = modulePaths;
-        this.dependencyFinder = finder;
-        this.root = modulePaths.getModules().get(moduleName);
-        this.modules = modulePaths.dependences(moduleName);
+    private final Map<Module, ModuleDeps> modules;
 
-        root.exports().values().stream()
-             .flatMap(Set::stream)
-             .map(target -> modulePaths.getModules().get(target))
-             .forEach(this.exportTargets::add);
-
-        this.filter = new JdepsFilter.Builder().filter(true, true).build();
+    public ModuleAnalyzer(JdepsConfiguration config,
+                          PrintWriter log) {
+        this(config, log, Collections.emptySet());
     }
+    public ModuleAnalyzer(JdepsConfiguration config,
+                          PrintWriter log,
+                          Set<String> names) {
 
-    /**
-     * Returns a graph of transitive closure of the given modules.
-     *
-     * This method does not add the implicit read edges and is intended to
-     * get all transitive closures in (reverse) topological sort.
-     */
-    public static Graph<Module> graph(ModulePaths modulePaths, Module... modules) {
-        Graph.Builder<Module> gb = new Graph.Builder<>();
-        for (Module module : modules) {
-            module.descriptor().requires().stream()
-                    .map(ModuleDescriptor.Requires::name)
-                    .map(mn -> modulePaths.getModules().get(mn))
-                    .forEach(m -> {
-                        gb.addNode(m);
-                        gb.addEdge(module, m);
-                    });
+        if (!config.initialArchives().isEmpty()) {
+            String list = config.initialArchives().stream()
+                .map(Archive::getPathName).collect(joining(" "));
+            throw new JdepsTask.UncheckedBadArgs(new BadArgs("err.invalid.module.option",
+                list, "-check"));
         }
-        return gb.build();
+
+        this.configuration = config;
+        this.log = log;
+
+        this.dependencyFinder = new DependencyFinder(config, DEFAULT_FILTER);
+        if (names.isEmpty()) {
+            this.modules = configuration.rootModules().stream()
+                .collect(toMap(Function.identity(), ModuleDeps::new));
+        } else {
+            this.modules = names.stream()
+                .map(configuration::findModule)
+                .flatMap(Optional::stream)
+                .collect(toMap(Function.identity(), ModuleDeps::new));
+        }
     }
 
-    /**
-     * Do the analysis
-     */
-    public boolean run() {
+    public boolean run() throws IOException {
         try {
-            computeRequiresPublic();
-            computeRequires();
-            // apply transitive reduction and reports recommended requires.
-            analyzeDeps();
-            // detect any qualiifed exports not used by the target module
-            checkQualifiedExports();
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
+            // compute "requires public" dependences
+            modules.values().forEach(ModuleDeps::computeRequiresPublic);
+
+            modules.values().forEach(md -> {
+                // compute "requires" dependences
+                md.computeRequires();
+                // apply transitive reduction and reports recommended requires.
+                md.analyzeDeps();
+            });
+        } finally {
+            dependencyFinder.shutdown();
         }
         return true;
     }
 
-    /**
-     * Compute 'requires public' dependences by analyzing API dependencies
-     */
-    private void computeRequiresPublic() throws IOException {
-        JdepsFilter.Builder builder = new JdepsFilter.Builder();
-        // only analyze exported API
-        root.descriptor.exports().stream()
-                .filter(exp -> !exp.isQualified())
-                .map(ModuleDescriptor.Exports::source)
-                .forEach(builder::includePackage);
+    class ModuleDeps {
+        final Module root;
+        Set<Module> requiresPublic;
+        Set<Module> requires;
+        Map<String, Set<String>> unusedQualifiedExports;
 
-        JdepsFilter filter = builder.filter(true, true).build();
-
-        // analyze dependences for exported packages
-        dependencyFinder.findDependencies(filter, true /* api only */, 1);
-        Analyzer analyzer = new Analyzer(Analyzer.Type.CLASS, filter);
-        analyzer.run(modules);
-
-        // record requires public
-        analyzer.requires(root)
-                .filter(m -> m != JAVA_BASE && m != root)
-                .map(Archive::getName)
-                .forEach(requiresPublic::add);
-        trace("requires public: %s%n", requiresPublic);
-    }
-
-    private void computeRequires() throws IOException {
-        // add the exportTargets of the qualified exports to the root set
-        exportTargets.stream()
-                .peek(target -> trace("add root: %s%n", target))
-                .forEach(dependencyFinder::addRoot);
-
-        // analyze all classes
-        dependencyFinder.findDependencies(filter, false /* all classes */, 1);
-        Analyzer analyzer = new Analyzer(Analyzer.Type.CLASS, filter);
-        analyzer.run(modules);
-
-        // record requires
-        analyzer.requires(root)
-                .filter(m -> m != JAVA_BASE && m != root)
-                .map(Archive::getName)
-                .forEach(requires::add);
-
-        this.graph = buildGraph(analyzer, root);
-        if (traceOn) {
-            trace("dependences: %s%n", graph.nodes());
-            graph.printGraph(System.out);
+        ModuleDeps(Module root) {
+            this.root = root;
         }
-    }
 
-    /**
-     * Apply transitive reduction on the resulting graph and reports
-     * recommended requires.
-     */
-    private void analyzeDeps() {
-        String moduleName = root.name();
+        /**
+         * Compute 'requires public' dependences by analyzing API dependencies
+         */
+        private void computeRequiresPublic() {
+            // record requires public
+            this.requiresPublic = computeRequires(true)
+                .filter(m -> !m.name().equals(JAVA_BASE))
+                .collect(toSet());
 
-        Graph.Builder<String> builder = new Graph.Builder<>();
-        requiresPublic.stream()
-                .forEach(mn -> {
-                    builder.addNode(mn);
-                    builder.addEdge(moduleName, mn);
-                });
-        // requires public graph
-        Graph<String> rbg = builder.build().reduce();
+            trace("requires public: %s%n", requiresPublic);
+        }
 
-        // convert the dependence graph from Module to name
-        Set<String> nodes = this.graph.nodes().stream()
+        private void computeRequires() {
+            this.requires = computeRequires(false).collect(toSet());
+            trace("requires: %s%n", requires);
+        }
+
+        private Stream<Module> computeRequires(boolean apionly) {
+            // analyze all classes
+
+            if (apionly) {
+                dependencyFinder.parseExportedAPIs(Stream.of(root));
+            } else {
+                dependencyFinder.parse(Stream.of(root));
+            }
+
+            // find the modules of all the dependencies found
+            return dependencyFinder.getDependences(root)
+                        .map(Archive::getModule);
+        }
+
+        ModuleDescriptor descriptor() {
+            return descriptor(requiresPublic, requires);
+        }
+
+        private ModuleDescriptor descriptor(Set<Module> requiresPublic,
+                                            Set<Module> requires) {
+
+            ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(root.name());
+
+            if (!root.name().equals(JAVA_BASE))
+                builder.requires(MANDATED, JAVA_BASE);
+
+            requiresPublic.stream()
+                .filter(m -> !m.name().equals(JAVA_BASE))
                 .map(Module::name)
-                .collect(Collectors.toSet());
-        Map<String, Set<String>> edges = new HashMap<>();
-        this.graph.edges().keySet().stream()
+                .forEach(mn -> builder.requires(PUBLIC, mn));
+
+            requires.stream()
+                .filter(m -> !requiresPublic.contains(m))
+                .filter(m -> !m.name().equals(JAVA_BASE))
+                .map(Module::name)
+                .forEach(mn -> builder.requires(mn));
+
+            return builder.build();
+        }
+
+        ModuleDescriptor reduced() {
+            Graph.Builder<Module> bd = new Graph.Builder<>();
+            requiresPublic.stream()
                 .forEach(m -> {
-                    String mn = m.name();
-                    Set<String> es = edges.computeIfAbsent(mn, _k -> new HashSet<String>());
-                    this.graph.edges().get(m).stream()
-                            .map(Module::name)
-                            .forEach(es::add);
+                    bd.addNode(m);
+                    bd.addEdge(root, m);
                 });
 
-        // transitive reduction
-        Graph<String> newGraph = new Graph<>(nodes, edges).reduce(rbg);
-        if (traceOn) {
-            System.out.println("after transitive reduction");
-            newGraph.printGraph(System.out);
-        };
+            // requires public graph
+            Graph<Module> rbg = bd.build().reduce();
 
-        Set<String> reducedRequires = newGraph.adjacentNodes(moduleName);
-        if (matches(root.descriptor(), requires, requiresPublic) &&
-                matches(root.descriptor(), reducedRequires, requiresPublic)) {
-            System.out.println("--- Analysis result: no change for " + root.name());
-        } else {
-            System.out.println("--- Analysis result: suggested requires for " + root.name());
-            System.out.format("module %s%n", root.name());
-                requires.stream()
+            // transitive reduction
+            Graph<Module> newGraph = buildGraph(requires).reduce(rbg);
+            if (DEBUG) {
+                System.err.println("after transitive reduction: ");
+                newGraph.printGraph(log);
+            }
+
+            return descriptor(requiresPublic, newGraph.adjacentNodes(root));
+        }
+
+
+        /**
+         * Apply transitive reduction on the resulting graph and reports
+         * recommended requires.
+         */
+        private void analyzeDeps() {
+            Graph.Builder<Module> builder = new Graph.Builder<>();
+            requiresPublic.stream()
+                .forEach(m -> {
+                    builder.addNode(m);
+                    builder.addEdge(root, m);
+                });
+
+            // requires public graph
+            Graph<Module> rbg = buildGraph(requiresPublic).reduce();
+
+            // transitive reduction
+            Graph<Module> newGraph = buildGraph(requires).reduce(builder.build().reduce());
+            if (DEBUG) {
+                System.err.println("after transitive reduction: ");
+                newGraph.printGraph(log);
+            }
+
+            printModuleDescriptor(log, root);
+
+            ModuleDescriptor analyzedDescriptor = descriptor();
+            if (!matches(root.descriptor(), analyzedDescriptor)) {
+                log.format("  [Suggested module descriptor for %s]%n", root.name());
+                analyzedDescriptor.requires()
+                    .stream()
+                    .sorted(Comparator.comparing(ModuleDescriptor.Requires::name))
+                    .forEach(req -> log.format("    requires %s;%n", req));
+            }
+
+            ModuleDescriptor reduced = reduced();
+            if (!matches(root.descriptor(), reduced)) {
+                log.format("  [Transitive reduced graph for %s]%n", root.name());
+                reduced.requires()
+                    .stream()
+                    .sorted(Comparator.comparing(ModuleDescriptor.Requires::name))
+                    .forEach(req -> log.format("    requires %s;%n", req));
+            }
+
+            checkQualifiedExports();
+            log.println();
+        }
+
+        private void checkQualifiedExports() {
+            // detect any qualified exports not used by the target module
+            unusedQualifiedExports = unusedQualifiedExports();
+            if (!unusedQualifiedExports.isEmpty())
+                log.format("  [Unused qualified exports in %s]%n", root.name());
+
+            unusedQualifiedExports.keySet().stream()
+                .sorted()
+                .forEach(pn -> log.format("    exports %s to %s%n", pn,
+                    unusedQualifiedExports.get(pn).stream()
                         .sorted()
-                        .forEach(dn -> System.out.format("  requires %s%s;%n",
-                                requiresPublic.contains(dn) ? "public " : "", dn));
-            if (!requires.equals(reducedRequires) && !reducedRequires.isEmpty()) {
-                System.out.format("%nmodule %s (reduced)%n", root.name());
-                newGraph.adjacentNodes(moduleName)
-                     .stream()
-                     .sorted()
-                     .forEach(dn -> System.out.format("  requires %s%s;%n",
-                                requiresPublic.contains(dn) ? "public " : "", dn));
-            }
-            System.out.println("\n---  Module descriptor");
-            Graph<Module> mdGraph = graph(modulePaths, root);
-            mdGraph.reverse(m -> printModuleDescriptor(System.out, m.descriptor()));
+                        .collect(joining(","))));
         }
-    }
 
-    /**
-     * Detects any qualified exports not used by the target module.
-     */
-    private void checkQualifiedExports() throws IOException {
-        Analyzer analyzer = new Analyzer(Analyzer.Type.CLASS, filter);
-        analyzer.run(dependencyFinder.roots());
+        private void printModuleDescriptor(PrintWriter out, Module module) {
+            ModuleDescriptor descriptor = module.descriptor();
+            out.format("%s (%s)%n", descriptor.name(), module.location());
 
-        // build the qualified exports map
-        Map<String, Set<String>> qualifiedExports =
-            root.exports().entrySet().stream()
-                .filter(e -> !e.getValue().isEmpty())
-                .map(Map.Entry::getKey)
-                .collect(Collectors.toMap(Function.identity(), _k -> new HashSet<>()));
+            if (descriptor.name().equals(JAVA_BASE))
+                return;
 
-        // adds to the qualified exports map if a module references it
-        for (Module m : exportTargets) {
-            analyzer.dependences(m).stream()
-                    .map(this::toPackageName)
+            out.println("  [Module descriptor]");
+            descriptor.requires()
+                .stream()
+                .sorted(Comparator.comparing(ModuleDescriptor.Requires::name))
+                .forEach(req -> out.format("    requires %s;%n", req));
+        }
+
+
+        /**
+         * Returns a graph of modules required by the specified module.
+         *
+         * Requires public edges of the dependences are added to the graph.
+         */
+        private Graph<Module> buildGraph(Set<Module> deps) {
+            Graph.Builder<Module> builder = new Graph.Builder<>();
+            builder.addNode(root);
+            Set<Module> visited = new HashSet<>();
+            visited.add(root);
+            Deque<Module> deque = new LinkedList<>();
+            deps.stream()
+                .forEach(m -> {
+                    deque.add(m);
+                    builder.addEdge(root, m);
+                });
+
+            // read requires public from ModuleDescription
+            Module source;
+            while ((source = deque.poll()) != null) {
+                if (visited.contains(source))
+                    continue;
+
+                visited.add(source);
+                builder.addNode(source);
+                Module from = source;
+                source.descriptor().requires().stream()
+                    .filter(req -> req.modifiers().contains(PUBLIC))
+                    .map(ModuleDescriptor.Requires::name)
+                    .map(configuration::findModule)
+                    .flatMap(Optional::stream)
+                    .forEach(m -> {
+                        deque.add(m);
+                        builder.addEdge(from, m);
+                    });
+            }
+            return builder.build();
+        }
+
+        /**
+         * Detects any qualified exports not used by the target module.
+         */
+        private Map<String, Set<String>> unusedQualifiedExports() {
+            Map<String, Set<String>> unused = new HashMap<>();
+
+            // build the qualified exports map
+            Map<String, Set<String>> qualifiedExports =
+                root.exports().entrySet().stream()
+                    .filter(e -> !e.getValue().isEmpty())
+                    .map(Map.Entry::getKey)
+                    .collect(toMap(Function.identity(), _k -> new HashSet<>()));
+
+            Set<Module> mods = new HashSet<>();
+            root.exports().values()
+                .stream()
+                .flatMap(Set::stream)
+                .forEach(target -> configuration.findModule(target)
+                    .ifPresentOrElse(mods::add,
+                        () -> log.format("Warning: %s not found%n", target))
+                );
+
+            // parse all target modules
+            dependencyFinder.parse(mods.stream());
+
+            // adds to the qualified exports map if a module references it
+            mods.stream().forEach(m ->
+                m.getDependencies()
+                    .map(Dependency.Location::getPackageName)
                     .filter(qualifiedExports::containsKey)
-                    .forEach(pn -> qualifiedExports.get(pn).add(m.name()));
-        }
+                    .forEach(pn -> qualifiedExports.get(pn).add(m.name())));
 
-        // compare with the exports from ModuleDescriptor
-        Set<String> staleQualifiedExports =
-            qualifiedExports.keySet().stream()
-                .filter(pn -> !qualifiedExports.get(pn).equals(root.exports().get(pn)))
-                .collect(Collectors.toSet());
+            // compare with the exports from ModuleDescriptor
+            Set<String> staleQualifiedExports =
+                qualifiedExports.keySet().stream()
+                    .filter(pn -> !qualifiedExports.get(pn).equals(root.exports().get(pn)))
+                    .collect(toSet());
 
-        if (!staleQualifiedExports.isEmpty()) {
-            System.out.println("--- Unused qualified exports in " + root.name());
-            for (String pn : staleQualifiedExports) {
-                Set<String> unused = new HashSet<>(root.exports().get(pn));
-                unused.removeAll(qualifiedExports.get(pn));
-                System.out.format("  exports %s to %s%n", pn,
-                                  unused.stream().collect(Collectors.joining(",")));
+            if (!staleQualifiedExports.isEmpty()) {
+                for (String pn : staleQualifiedExports) {
+                    Set<String> targets = new HashSet<>(root.exports().get(pn));
+                    targets.removeAll(qualifiedExports.get(pn));
+                    unused.put(pn, targets);
+                }
             }
+            return unused;
         }
     }
 
-    private String toPackageName(String cn) {
-        int i = cn.lastIndexOf('.');
-        return i > 0 ? cn.substring(0, i) : "";
-    }
+    private boolean matches(ModuleDescriptor md, ModuleDescriptor other) {
+        // build requires public from ModuleDescriptor
+        Set<ModuleDescriptor.Requires> reqPublic = md.requires().stream()
+            .filter(req -> req.modifiers().contains(PUBLIC))
+            .collect(toSet());
+        Set<ModuleDescriptor.Requires> otherReqPublic = other.requires().stream()
+            .filter(req -> req.modifiers().contains(PUBLIC))
+            .collect(toSet());
 
-    private boolean matches(ModuleDescriptor md, Set<String> requires, Set<String> requiresPublic) {
-        Set<String> reqPublic = md.requires().stream()
-                .filter(req -> req.modifiers().contains(PUBLIC))
-                .map(ModuleDescriptor.Requires::name)
-                .collect(Collectors.toSet());
-        if (!requiresPublic.equals(reqPublic)) {
+        if (!reqPublic.equals(otherReqPublic)) {
             trace("mismatch requires public: %s%n", reqPublic);
             return false;
         }
-        // java.base is not in requires
-        int javaBase = md.name().equals(JAVA_BASE.name()) ? 0 : 1;
-        if (requires.size()+javaBase != md.requires().size()) {
-            trace("mismatch requires: %d != %d%n", requires.size()+1, md.requires().size());
-            return false;
-        }
 
-        Set<String> unused = md.requires().stream()
-                 .map(ModuleDescriptor.Requires::name)
-                 .filter(req -> !requires.contains(req) && !req.equals(JAVA_BASE.name()))
-                 .collect(Collectors.toSet());
+        Set<ModuleDescriptor.Requires> unused = md.requires().stream()
+            .filter(req -> !other.requires().contains(req))
+            .collect(Collectors.toSet());
+
         if (!unused.isEmpty()) {
             trace("mismatch requires: %s%n", unused);
             return false;
@@ -302,371 +389,50 @@
         return true;
     }
 
-    private void printModuleDescriptor(PrintStream out, ModuleDescriptor descriptor) {
-        if (descriptor.name().equals("java.base"))
-            return;
-
-        out.format("module %s%n", descriptor.name());
-        descriptor.requires()
-                .stream()
-                .sorted(Comparator.comparing(ModuleDescriptor.Requires::name))
-                .forEach(req -> out.format("  requires %s;%n", req));
-    }
-
     /**
-     * Returns a graph of modules required by the specified module.
+     * Generate dotfile from module descriptor
      *
-     * Requires public edges of the dependences are added to the graph.
+     * @param dir output directory
      */
-    private Graph<Module> buildGraph(Analyzer analyzer, Module module) {
-        Graph.Builder<Module> builder = new Graph.Builder<>();
-        builder.addNode(module);
-        Set<Module> visited = new HashSet<>();
-        visited.add(module);
-        Deque<Module> deque = new LinkedList<>();
-        analyzer.requires(module)
-                .map(Archive::getModule)
-                .filter(m -> m != JAVA_BASE)
-                .forEach(m -> {
-                    deque.add(m);
-                    builder.addEdge(module, m);
-                });
-
-        // read requires public from ModuleDescription
-        Module source;
-        while ((source = deque.poll()) != null) {
-            if (visited.contains(source))
-                continue;
-            visited.add(source);
-            builder.addNode(source);
-            Module from = source;
-            source.descriptor().requires().stream()
-                    .filter(req -> req.modifiers().contains(PUBLIC))
-                    .map(ModuleDescriptor.Requires::name)
-                    .map(req -> modulePaths.getModules().get(req))
-                    .filter(m -> m != JAVA_BASE)
-                    .forEach(m -> {
-                        deque.add(m);
-                        builder.addEdge(from, m);
-                    });
+    public boolean genDotFiles(Path dir) throws IOException {
+        Files.createDirectories(dir);
+        for (Module m : modules.keySet()) {
+            genDotFile(dir, m.name());
         }
-        return builder.build();
+        return true;
     }
 
-    static class Graph<T> {
-        private final Set<T> nodes;
-        private final Map<T, Set<T>> edges;
 
-        private Graph(Set<T> nodes, Map<T, Set<T>> edges) {
-            this.nodes = nodes;
-            this.edges = edges;
-        }
-
-        public Set<T> nodes() {
-            return nodes;
-        }
-
-        public Map<T, Set<T>> edges() {
-            return edges;
-        }
-
-        public Set<T> adjacentNodes(T u) {
-            return edges.get(u);
-        }
-
-        /**
-         * Returns a new Graph after transitive reduction
-         */
-        public Graph<T> reduce() {
-            Graph.Builder<T> builder = new Builder<>();
-            nodes.stream()
-                    .forEach(u -> {
-                        builder.addNode(u);
-                        edges.get(u).stream()
-                                .filter(v -> !pathExists(u, v, false))
-                                .forEach(v -> builder.addEdge(u, v));
-                    });
-            return builder.build();
-        }
-
-        /**
-         * Returns a new Graph after transitive reduction.  All edges in
-         * the given g takes precedence over this graph.
-         *
-         * @throw IllegalArgumentException g must be a subgraph this graph
-         */
-        public Graph<T> reduce(Graph<T> g) {
-            boolean subgraph = nodes.containsAll(g.nodes) && g.edges.keySet().stream()
-                    .allMatch(u -> adjacentNodes(u).containsAll(g.adjacentNodes(u)));
-            if (!subgraph) {
-                throw new IllegalArgumentException(g + " is not a subgraph of " + this);
-            }
-
-            Graph.Builder<T> builder = new Builder<>();
-            nodes.stream()
-                    .forEach(u -> {
-                        builder.addNode(u);
-                        // filter the edge if there exists a path from u to v in the given g
-                        // or there exists another path from u to v in this graph
-                        edges.get(u).stream()
-                                .filter(v -> !g.pathExists(u, v) && !pathExists(u, v, false))
-                                .forEach(v -> builder.addEdge(u, v));
-                    });
-
-            // add the overlapped edges from this graph and the given g
-            g.edges().keySet().stream()
-                    .forEach(u -> g.adjacentNodes(u).stream()
-                                    .filter(v -> isAdjacent(u, v))
-                                    .forEach(v -> builder.addEdge(u, v)));
-            return builder.build();
-        }
-
-        /**
-         * Returns nodes sorted in topological order.
-         */
-        public Stream<T> orderedNodes() {
-            TopoSorter<T> sorter = new TopoSorter<>(this);
-            return sorter.result.stream();
-        }
-
-        /**
-         * Iterates the nodes sorted in topological order and performs the
-         * given action.
-         */
-        public void ordered(Consumer<T> action) {
-            TopoSorter<T> sorter = new TopoSorter<>(this);
-            sorter.ordered(action);
-        }
-
-        /**
-         * Iterates the nodes sorted in reverse topological order and
-         * performs the given action.
-         */
-        public void reverse(Consumer<T> action) {
-            TopoSorter<T> sorter = new TopoSorter<>(this);
-            sorter.reverse(action);
-        }
-
-        private boolean isAdjacent(T u, T v) {
-            return edges.containsKey(u) && edges.get(u).contains(v);
-        }
-
-        private boolean pathExists(T u, T v) {
-            return pathExists(u, v, true);
-        }
-
-        /**
-         * Returns true if there exists a path from u to v in this graph.
-         * If includeAdjacent is false, it returns true if there exists
-         * another path from u to v of distance > 1
-         */
-        private boolean pathExists(T u, T v, boolean includeAdjacent) {
-            if (!nodes.contains(u) || !nodes.contains(v)) {
-                return false;
-            }
-            if (includeAdjacent && isAdjacent(u, v)) {
-                return true;
-            }
-            Deque<T> stack = new LinkedList<>();
-            Set<T> visited = new HashSet<>();
-            stack.push(u);
-            while (!stack.isEmpty()) {
-                T node = stack.pop();
-                if (node.equals(v)) {
-                    return true;
-                }
-                if (!visited.contains(node)) {
-                    visited.add(node);
-                    edges.get(node).stream()
-                            .filter(e -> includeAdjacent || !node.equals(u) || !e.equals(v))
-                            .forEach(e -> stack.push(e));
-                }
-            }
-            assert !visited.contains(v);
-            return false;
-        }
-
-        void printGraph(PrintStream out) {
-            out.println("graph for " + nodes);
-            nodes.stream()
-                 .forEach(u -> adjacentNodes(u).stream()
-                                   .forEach(v -> out.format("%s -> %s%n", u, v)));
-        }
-
-        @Override
-        public String toString() {
-            return nodes.toString();
-        }
-
-        static class Builder<T> {
-            final Set<T> nodes = new HashSet<>();
-            final Map<T, Set<T>> edges = new HashMap<>();
-
-            public void addNode(T node) {
-                if (nodes.contains(node)) {
-                    return;
-                }
-                nodes.add(node);
-                edges.computeIfAbsent(node, _e -> new HashSet<>());
-            }
-
-            public void addEdge(T u, T v) {
-                addNode(u);
-                addNode(v);
-                edges.get(u).add(v);
-            }
-
-            public Graph<T> build() {
-                return new Graph<>(nodes, edges);
-            }
-
-            void print(PrintStream out) {
-                out.println(nodes);
-                nodes.stream()
-                        .forEach(u -> edges.get(u).stream()
-                                        .forEach(v -> out.format("%s -> %s%n", u, v)));
-            }
-        }
-    }
-
-    static class TopoSorter<T> {
-        final Deque<T> result = new LinkedList<>();
-        final Deque<T> nodes;
-        final Graph<T> graph;
-        TopoSorter(Graph<T> graph) {
-            this.graph = graph;
-            this.nodes = new LinkedList<>(graph.nodes);
-            sort();
-        }
-
-        public void ordered(Consumer<T> action) {
-            result.iterator().forEachRemaining(action);
-        }
-
-        public void reverse(Consumer<T> action) {
-            result.descendingIterator().forEachRemaining(action);
-        }
-
-        private void sort() {
-            Deque<T> visited = new LinkedList<>();
-            Deque<T> done = new LinkedList<>();
-            T node;
-            while ((node = nodes.poll()) != null) {
-                if (!visited.contains(node)) {
-                    visit(node, visited, done);
-                }
-            }
-        }
-
-        private void visit(T node, Deque<T> visited, Deque<T> done) {
-            if (visited.contains(node)) {
-                if (!done.contains(node)) {
-                    throw new IllegalArgumentException("Cyclic detected: " +
-                            node + " " + graph.edges().get(node));
-                }
-                return;
-            }
-            visited.add(node);
-            graph.edges().get(node).stream()
-                 .forEach(x -> visit(x, visited, done));
-            done.add(node);
-            result.addLast(node);
-        }
-    }
-
-    static class DotGraph {
-        static final String ORANGE = "#e76f00";
-        static final String BLUE = "#437291";
-        static final String GRAY = "#dddddd";
-
-        static final String REEXPORTS = "";
-        static final String REQUIRES = "style=\"dashed\"";
-        static final String REQUIRES_BASE = "color=\"" + GRAY + "\"";
-
-        static final Set<String> javaModules = modules(name ->
-                (name.startsWith("java.") && !name.equals("java.smartcardio")));
-        static final Set<String> jdkModules = modules(name ->
-                (name.startsWith("java.") ||
-                        name.startsWith("jdk.") ||
-                        name.startsWith("javafx.")) && !javaModules.contains(name));
-
-        private static Set<String> modules(Predicate<String> predicate) {
-            return ModuleFinder.ofSystem().findAll()
-                               .stream()
-                               .map(ModuleReference::descriptor)
-                               .map(ModuleDescriptor::name)
-                               .filter(predicate)
-                               .collect(Collectors.toSet());
-        }
-
-        static void printAttributes(PrintStream out) {
-            out.format("  size=\"25,25\";%n");
-            out.format("  nodesep=.5;%n");
-            out.format("  ranksep=1.5;%n");
-            out.format("  pencolor=transparent;%n");
-            out.format("  node [shape=plaintext, fontname=\"DejaVuSans\", fontsize=36, margin=\".2,.2\"];%n");
-            out.format("  edge [penwidth=4, color=\"#999999\", arrowhead=open, arrowsize=2];%n");
-        }
-
-        static void printNodes(PrintStream out, Graph<String> graph) {
-            out.format("  subgraph se {%n");
-            graph.nodes().stream()
-                 .filter(javaModules::contains)
-                 .forEach(mn -> out.format("  \"%s\" [fontcolor=\"%s\", group=%s];%n",
-                                           mn, ORANGE, "java"));
-            out.format("  }%n");
-            graph.nodes().stream()
-                 .filter(jdkModules::contains)
-                 .forEach(mn -> out.format("    \"%s\" [fontcolor=\"%s\", group=%s];%n",
-                                              mn, BLUE, "jdk"));
-
-            graph.nodes().stream()
-                    .filter(mn -> !javaModules.contains(mn) && !jdkModules.contains(mn))
-                    .forEach(mn -> out.format("  \"%s\";%n", mn));
-        }
-
-        static void printEdges(PrintStream out, Graph<String> graph,
-                               String node, Set<String> requiresPublic) {
-            graph.adjacentNodes(node).forEach(dn -> {
-                String attr = dn.equals("java.base") ? REQUIRES_BASE
-                        : (requiresPublic.contains(dn) ? REEXPORTS : REQUIRES);
-                out.format("  \"%s\" -> \"%s\" [%s];%n", node, dn, attr);
-            });
-        }
-    }
-
-    public void genDotFile(Path dir) throws IOException {
-        String name = root.name();
-        try (PrintStream out
-                     = new PrintStream(Files.newOutputStream(dir.resolve(name + ".dot")))) {
-            Configuration cf = modulePaths.configuration(name);
+    private void genDotFile(Path dir, String name) throws IOException {
+        try (OutputStream os = Files.newOutputStream(dir.resolve(name + ".dot"));
+             PrintWriter out = new PrintWriter(os)) {
+            Set<Module> modules = configuration.resolve(Set.of(name))
+                .collect(Collectors.toSet());
 
             // transitive reduction
-            Graph<String> graph = gengraph(cf);
+            Graph<String> graph = gengraph(modules);
 
             out.format("digraph \"%s\" {%n", name);
             DotGraph.printAttributes(out);
             DotGraph.printNodes(out, graph);
 
-            cf.modules().stream()
-                    .map(ResolvedModule::reference)
-                    .map(ModuleReference::descriptor)
-                    .sorted(Comparator.comparing(ModuleDescriptor::name))
-                    .forEach(md -> {
-                String mn = md.name();
-                Set<String> requiresPublic = md.requires().stream()
+            modules.stream()
+                .map(Module::descriptor)
+                .sorted(Comparator.comparing(ModuleDescriptor::name))
+                .forEach(md -> {
+                    String mn = md.name();
+                    Set<String> requiresPublic = md.requires().stream()
                         .filter(d -> d.modifiers().contains(PUBLIC))
                         .map(d -> d.name())
-                        .collect(Collectors.toSet());
+                        .collect(toSet());
 
-                DotGraph.printEdges(out, graph, mn, requiresPublic);
-            });
+                    DotGraph.printEdges(out, graph, mn, requiresPublic);
+                });
 
             out.println("}");
         }
     }
 
-
     /**
      * Returns a Graph of the given Configuration after transitive reduction.
      *
@@ -675,12 +441,12 @@
      * (e.g. U -> V) from being reduced by a path (U -> X -> Y -> V)
      * in which  V would not be re-exported from U.
      */
-    private Graph<String> gengraph(Configuration cf) {
+    private Graph<String> gengraph(Set<Module> modules) {
         // build a Graph containing only requires public edges
         // with transitive reduction.
         Graph.Builder<String> rpgbuilder = new Graph.Builder<>();
-        for (ResolvedModule resolvedModule : cf.modules()) {
-            ModuleDescriptor md = resolvedModule.reference().descriptor();
+        for (Module module : modules) {
+            ModuleDescriptor md = module.descriptor();
             String mn = md.name();
             md.requires().stream()
                     .filter(d -> d.modifiers().contains(PUBLIC))
@@ -692,12 +458,12 @@
 
         // build the readability graph
         Graph.Builder<String> builder = new Graph.Builder<>();
-        for (ResolvedModule resolvedModule : cf.modules()) {
-            ModuleDescriptor md = resolvedModule.reference().descriptor();
+        for (Module module : modules) {
+            ModuleDescriptor md = module.descriptor();
             String mn = md.name();
             builder.addNode(mn);
-            resolvedModule.reads().stream()
-                    .map(ResolvedModule::name)
+            configuration.reads(module)
+                    .map(Module::name)
                     .forEach(d -> builder.addEdge(mn, d));
         }
 
@@ -705,4 +471,25 @@
         return builder.build().reduce(rpg);
     }
 
+    // ---- for testing purpose
+    public ModuleDescriptor[] descriptors(String name) {
+        ModuleDeps moduleDeps = modules.keySet().stream()
+            .filter(m -> m.name().equals(name))
+            .map(modules::get)
+            .findFirst().get();
+
+        ModuleDescriptor[] descriptors = new ModuleDescriptor[3];
+        descriptors[0] = moduleDeps.root.descriptor();
+        descriptors[1] = moduleDeps.descriptor();
+        descriptors[2] = moduleDeps.reduced();
+        return descriptors;
+    }
+
+    public Map<String, Set<String>> unusedQualifiedExports(String name) {
+        ModuleDeps moduleDeps = modules.keySet().stream()
+            .filter(m -> m.name().equals(name))
+            .map(modules::get)
+            .findFirst().get();
+        return moduleDeps.unusedQualifiedExports;
+    }
 }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java
index 1afed6b..ab493a6 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java
@@ -24,15 +24,25 @@
  */
 package com.sun.tools.jdeps;
 
-import static com.sun.tools.jdeps.Analyzer.Type.CLASS;
-import static com.sun.tools.jdeps.Analyzer.NOT_FOUND;
-import static com.sun.tools.jdeps.Module.trace;
+import static com.sun.tools.jdeps.JdepsTask.*;
+import static com.sun.tools.jdeps.Analyzer.*;
+import static com.sun.tools.jdeps.JdepsFilter.DEFAULT_FILTER;
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.UncheckedIOException;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Provides;
+import java.lang.module.ModuleDescriptor.Requires;
+import java.lang.module.ModuleFinder;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
@@ -40,168 +50,189 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+
 public class ModuleInfoBuilder {
-    final ModulePaths modulePaths;
+    final JdepsConfiguration configuration;
+    final Path outputdir;
+
     final DependencyFinder dependencyFinder;
-    final JdepsFilter filter;
     final Analyzer analyzer;
-    final Map<Module, Module> strictModules = new HashMap<>();
-    ModuleInfoBuilder(ModulePaths modulePaths, DependencyFinder finder) {
-        this.modulePaths = modulePaths;
-        this.dependencyFinder = finder;
-        this.filter = new JdepsFilter.Builder().filter(true, true).build();
-        this.analyzer = new Analyzer(CLASS, filter);
+
+    // an input JAR file (loaded as an automatic module for analysis)
+    // maps to an explicit module to generate module-info.java
+    final Map<Module, Module> automaticToExplicitModule;
+    public ModuleInfoBuilder(JdepsConfiguration configuration,
+                             List<String> args,
+                             Path outputdir) {
+        this.configuration = configuration;
+        this.outputdir = outputdir;
+
+        this.dependencyFinder = new DependencyFinder(configuration, DEFAULT_FILTER);
+        this.analyzer = new Analyzer(configuration, Type.CLASS, DEFAULT_FILTER);
+
+        // add targets to modulepath if it has module-info.class
+        List<Path> paths = args.stream()
+            .map(fn -> Paths.get(fn))
+            .collect(Collectors.toList());
+
+        // automatic module to convert to explicit module
+        this.automaticToExplicitModule = ModuleFinder.of(paths.toArray(new Path[0]))
+                .findAll().stream()
+                .map(configuration::toModule)
+                .collect(Collectors.toMap(Function.identity(), Function.identity()));
+
+        Optional<Module> om = automaticToExplicitModule.keySet().stream()
+                                    .filter(m -> !m.descriptor().isAutomatic())
+                                    .findAny();
+        if (om.isPresent()) {
+            throw new UncheckedBadArgs(new BadArgs("err.genmoduleinfo.not.jarfile",
+                                                   om.get().getPathName()));
+        }
+        if (automaticToExplicitModule.isEmpty()) {
+            throw new UncheckedBadArgs(new BadArgs("err.invalid.path", args));
+        }
     }
 
-    private Stream<Module> automaticModules() {
-        return modulePaths.getModules().values()
-                .stream()
-                .filter(Module::isAutomatic);
+    public boolean run() throws IOException {
+        try {
+            // pass 1: find API dependencies
+            Map<Archive, Set<Archive>> requiresPublic = computeRequiresPublic();
+
+            // pass 2: analyze all class dependences
+            dependencyFinder.parse(automaticModules().stream());
+
+            analyzer.run(automaticModules(), dependencyFinder.locationToArchive());
+
+            boolean missingDeps = false;
+            for (Module m : automaticModules()) {
+                Set<Archive> apiDeps = requiresPublic.containsKey(m)
+                                            ? requiresPublic.get(m)
+                                            : Collections.emptySet();
+
+                Path file = outputdir.resolve(m.name()).resolve("module-info.java");
+
+                // computes requires and requires public
+                Module explicitModule = toExplicitModule(m, apiDeps);
+                if (explicitModule != null) {
+                    automaticToExplicitModule.put(m, explicitModule);
+
+                    // generate module-info.java
+                    System.out.format("writing to %s%n", file);
+                    writeModuleInfo(file,  explicitModule.descriptor());
+                } else {
+                    // find missing dependences
+                    System.out.format("Missing dependence: %s not generated%n", file);
+                    missingDeps = true;
+                }
+            }
+
+            return !missingDeps;
+        } finally {
+            dependencyFinder.shutdown();
+        }
+    }
+
+    boolean notFound(Archive m) {
+        return m == NOT_FOUND || m == REMOVED_JDK_INTERNALS;
+    }
+
+    private Module toExplicitModule(Module module, Set<Archive> requiresPublic)
+        throws IOException
+    {
+        // done analysis
+        module.close();
+
+        if (analyzer.requires(module).anyMatch(this::notFound)) {
+            // missing dependencies
+            return null;
+        }
+
+        Map<String, Boolean> requires = new HashMap<>();
+        requiresPublic.stream()
+            .map(Archive::getModule)
+            .forEach(m -> requires.put(m.name(), Boolean.TRUE));
+
+        analyzer.requires(module)
+            .map(Archive::getModule)
+            .forEach(d -> requires.putIfAbsent(d.name(), Boolean.FALSE));
+
+        return module.toStrictModule(requires);
+    }
+
+    /**
+     * Returns the stream of resulting modules
+     */
+    Stream<Module> modules() {
+        return automaticToExplicitModule.values().stream();
+    }
+
+    /**
+     * Returns the stream of resulting ModuleDescriptors
+     */
+    public Stream<ModuleDescriptor> descriptors() {
+        return automaticToExplicitModule.entrySet().stream()
+                    .map(Map.Entry::getValue)
+                    .map(Module::descriptor);
+    }
+
+    void visitMissingDeps(Analyzer.Visitor visitor) {
+        automaticModules().stream()
+            .filter(m -> analyzer.requires(m).anyMatch(this::notFound))
+            .forEach(m -> {
+                analyzer.visitDependences(m, visitor, Analyzer.Type.VERBOSE);
+            });
+    }
+
+    void writeModuleInfo(Path file, ModuleDescriptor descriptor) {
+        try {
+            Files.createDirectories(file.getParent());
+            try (PrintWriter pw = new PrintWriter(Files.newOutputStream(file))) {
+                printModuleInfo(pw, descriptor);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
+    private void printModuleInfo(PrintWriter writer, ModuleDescriptor descriptor) {
+        writer.format("module %s {%n", descriptor.name());
+
+        Map<String, Module> modules = configuration.getModules();
+        // first print the JDK modules
+        descriptor.requires().stream()
+                  .filter(req -> !req.name().equals("java.base"))   // implicit requires
+                  .sorted(Comparator.comparing(Requires::name))
+                  .forEach(req -> writer.format("    requires %s;%n", req));
+
+        descriptor.exports().stream()
+                  .peek(exp -> {
+                      if (exp.targets().size() > 0)
+                          throw new InternalError(descriptor.name() + " qualified exports: " + exp);
+                  })
+                  .sorted(Comparator.comparing(Exports::source))
+                  .forEach(exp -> writer.format("    exports %s;%n", exp.source()));
+
+        descriptor.provides().values().stream()
+                    .sorted(Comparator.comparing(Provides::service))
+                    .forEach(p -> p.providers().stream()
+                        .sorted()
+                        .forEach(impl -> writer.format("    provides %s with %s;%n", p.service(), impl)));
+
+        writer.println("}");
+    }
+
+
+    private Set<Module> automaticModules() {
+        return automaticToExplicitModule.keySet();
     }
 
     /**
      * Compute 'requires public' dependences by analyzing API dependencies
      */
-    Map<Module, Set<Module>> computeRequiresPublic() throws IOException {
-        dependencyFinder.findDependencies(filter, true /* api only */, 1);
-        Analyzer pass1 = new Analyzer(Analyzer.Type.CLASS, filter);
+    private Map<Archive, Set<Archive>> computeRequiresPublic() throws IOException {
+        // parse the input modules
+        dependencyFinder.parseExportedAPIs(automaticModules().stream());
 
-        pass1.run(dependencyFinder.archives());
-
-        return automaticModules().collect(Collectors.toMap(Function.identity(),
-                source -> pass1.requires(source)
-                               .map(Archive::getModule)
-                               .collect(Collectors.toSet())));
-    }
-
-    boolean run(Analyzer.Type verbose, boolean quiet) throws IOException {
-        // add all automatic modules to the root set
-        automaticModules().forEach(dependencyFinder::addRoot);
-
-        // pass 1: find API dependencies
-        Map<Module, Set<Module>> requiresPublic = computeRequiresPublic();
-
-        // pass 2: analyze all class dependences
-        dependencyFinder.findDependencies(filter, false /* all classes */, 1);
-        analyzer.run(dependencyFinder.archives());
-
-        // computes requires and requires public
-        automaticModules().forEach(m -> {
-            Map<String, Boolean> requires;
-            if (requiresPublic.containsKey(m)) {
-                requires = requiresPublic.get(m)
-                        .stream()
-                        .collect(Collectors.toMap(Archive::getName, (v) -> Boolean.TRUE));
-            } else {
-                requires = new HashMap<>();
-            }
-            analyzer.requires(m)
-                    .forEach(d -> requires.putIfAbsent(d.getName(), Boolean.FALSE));
-
-            trace("strict module %s requires %s%n", m.name(), requires);
-            strictModules.put(m, m.toStrictModule(requires));
-        });
-
-        // find any missing dependences
-        Optional<Module> missingDeps = automaticModules()
-                .filter(this::missingDep)
-                .findAny();
-        if (missingDeps.isPresent()) {
-            automaticModules()
-                    .filter(this::missingDep)
-                    .forEach(m -> {
-                        System.err.format("Missing dependencies from %s%n", m.name());
-                        analyzer.visitDependences(m,
-                                new Analyzer.Visitor() {
-                                    @Override
-                                    public void visitDependence(String origin, Archive originArchive,
-                                                                String target, Archive targetArchive) {
-                                        if (targetArchive == NOT_FOUND)
-                                            System.err.format("   %-50s -> %-50s %s%n",
-                                                    origin, target, targetArchive.getName());
-                                    }
-                                }, verbose);
-                        System.err.println();
-                    });
-
-            System.err.println("ERROR: missing dependencies (check \"requires NOT_FOUND;\")");
-        }
-        return missingDeps.isPresent() ? false : true;
-    }
-
-    private boolean missingDep(Archive m) {
-        return analyzer.requires(m).filter(a -> a.equals(NOT_FOUND))
-                       .findAny().isPresent();
-    }
-
-    void build(Path dir) throws IOException {
-        ModuleInfoWriter writer = new ModuleInfoWriter(dir);
-        writer.generateOutput(strictModules.values(), analyzer);
-    }
-
-    private class ModuleInfoWriter {
-        private final Path outputDir;
-        ModuleInfoWriter(Path dir) {
-            this.outputDir = dir;
-        }
-
-        void generateOutput(Iterable<Module> modules, Analyzer analyzer) throws IOException {
-            // generate module-info.java file for each archive
-            for (Module m : modules) {
-                if (m.packages().contains("")) {
-                    System.err.format("ERROR: %s contains unnamed package.  " +
-                                      "module-info.java not generated%n", m.getPathName());
-                    continue;
-                }
-
-                String mn = m.getName();
-                Path srcFile = outputDir.resolve(mn).resolve("module-info.java");
-                Files.createDirectories(srcFile.getParent());
-                System.out.println("writing to " + srcFile);
-                try (PrintWriter pw = new PrintWriter(Files.newOutputStream(srcFile))) {
-                    printModuleInfo(pw, m);
-                }
-            }
-        }
-
-        private void printModuleInfo(PrintWriter writer, Module m) {
-            writer.format("module %s {%n", m.name());
-
-            Map<String, Module> modules = modulePaths.getModules();
-            Map<String, Boolean> requires = m.requires();
-            // first print the JDK modules
-            requires.keySet().stream()
-                    .filter(mn -> !mn.equals("java.base"))   // implicit requires
-                    .filter(mn -> modules.containsKey(mn) && modules.get(mn).isJDK())
-                    .sorted()
-                    .forEach(mn -> {
-                        String modifier = requires.get(mn) ? "public " : "";
-                        writer.format("    requires %s%s;%n", modifier, mn);
-                    });
-
-            // print requires non-JDK modules
-            requires.keySet().stream()
-                    .filter(mn -> !modules.containsKey(mn) || !modules.get(mn).isJDK())
-                    .sorted()
-                    .forEach(mn -> {
-                        String modifier = requires.get(mn) ? "public " : "";
-                        writer.format("    requires %s%s;%n", modifier, mn);
-                    });
-
-            m.packages().stream()
-                    .sorted()
-                    .forEach(pn -> writer.format("    exports %s;%n", pn));
-
-            m.provides().entrySet().stream()
-                    .sorted(Map.Entry.comparingByKey())
-                    .forEach(e -> {
-                        String service = e.getKey();
-                        e.getValue().stream()
-                                .sorted()
-                                .forEach(impl -> writer.format("    provides %s with %s;%n", service, impl));
-                    });
-
-            writer.println("}");
-        }
+        return dependencyFinder.dependences();
     }
 }
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModulePaths.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModulePaths.java
deleted file mode 100644
index 8e1cdb8..0000000
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModulePaths.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.jdeps;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.lang.module.Configuration;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReference;
-import java.lang.module.ResolvedModule;
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystemNotFoundException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.ProviderNotFoundException;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
-
-public class ModulePaths {
-    final ModuleFinder finder;
-    final Map<String, Module> modules = new LinkedHashMap<>();
-
-    public ModulePaths(String upgradeModulePath, String modulePath) {
-        this(upgradeModulePath, modulePath, Collections.emptyList());
-    }
-
-    public ModulePaths(String upgradeModulePath, String modulePath, List<Path> jars) {
-        ModuleFinder finder = ModuleFinder.ofSystem();
-        if (upgradeModulePath != null) {
-            finder = ModuleFinder.compose(createModulePathFinder(upgradeModulePath), finder);
-        }
-        if (jars.size() > 0) {
-            finder = ModuleFinder.compose(finder, ModuleFinder.of(jars.toArray(new Path[0])));
-        }
-        if (modulePath != null) {
-            finder = ModuleFinder.compose(finder, createModulePathFinder(modulePath));
-        }
-        this.finder = finder;
-
-        // add modules from modulepaths
-        finder.findAll().stream().forEach(mref ->
-            modules.computeIfAbsent(mref.descriptor().name(), mn -> toModule(mn, mref))
-        );
-    }
-
-    /**
-     * Returns the list of Modules that can be found in the specified
-     * module paths.
-     */
-    Map<String, Module> getModules() {
-        return modules;
-    }
-
-    Set<Module> dependences(String... roots) {
-        Configuration cf = configuration(roots);
-        return cf.modules().stream()
-                .map(ResolvedModule::name)
-                .map(modules::get)
-                .collect(Collectors.toSet());
-    }
-
-    Configuration configuration(String... roots) {
-        return Configuration.empty().resolveRequires(finder, ModuleFinder.empty(), Set.of(roots));
-    }
-
-    private static ModuleFinder createModulePathFinder(String mpaths) {
-        if (mpaths == null) {
-            return null;
-        } else {
-            String[] dirs = mpaths.split(File.pathSeparator);
-            Path[] paths = new Path[dirs.length];
-            int i = 0;
-            for (String dir : dirs) {
-                paths[i++] = Paths.get(dir);
-            }
-            return ModuleFinder.of(paths);
-        }
-    }
-
-    private static Module toModule(String mn, ModuleReference mref) {
-        return SystemModulePath.find(mn)
-                               .orElse(toModule(new Module.Builder(mn), mref));
-    }
-
-    private static Module toModule(Module.Builder builder, ModuleReference mref) {
-        ModuleDescriptor md = mref.descriptor();
-        builder.descriptor(md);
-        for (ModuleDescriptor.Requires req : md.requires()) {
-            builder.require(req.name(), req.modifiers().contains(PUBLIC));
-        }
-        for (ModuleDescriptor.Exports exp : md.exports()) {
-            builder.export(exp.source(), exp.targets());
-        }
-        builder.packages(md.packages());
-
-        try {
-            URI location = mref.location()
-                               .orElseThrow(FileNotFoundException::new);
-            builder.location(location);
-            builder.classes(getClassReader(location, md.name()));
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-        return builder.build();
-    }
-
-    static class SystemModulePath {
-        final static Module JAVA_BASE;
-
-        private final static FileSystem fs;
-        private final static Path root;
-        private final static Map<String, Module> installed = new HashMap<>();
-        static {
-            if (isJrtAvailable()) {
-                // jrt file system
-                fs = FileSystems.getFileSystem(URI.create("jrt:/"));
-                root = fs.getPath("/modules");
-            } else {
-                // exploded image
-                String javahome = System.getProperty("java.home");
-                fs = FileSystems.getDefault();
-                root = Paths.get(javahome, "modules");
-            }
-
-            ModuleFinder.ofSystem().findAll().stream()
-                 .forEach(mref ->
-                     installed.computeIfAbsent(mref.descriptor().name(),
-                                               mn -> toModule(new Module.Builder(mn, true), mref))
-                 );
-            JAVA_BASE = installed.get("java.base");
-
-            Profile.init(installed);
-        }
-
-        private static boolean isJrtAvailable() {
-            try {
-                FileSystems.getFileSystem(URI.create("jrt:/"));
-                return true;
-            } catch (ProviderNotFoundException | FileSystemNotFoundException e) {
-                return false;
-            }
-        }
-
-        public static Optional<Module> find(String mn) {
-            return installed.containsKey(mn) ? Optional.of(installed.get(mn))
-                                             : Optional.empty();
-        }
-
-        public static boolean contains(Module m) {
-            return installed.containsValue(m);
-        }
-
-        public static ClassFileReader getClassReader(String modulename) throws IOException {
-            Path mp = root.resolve(modulename);
-            if (Files.exists(mp) && Files.isDirectory(mp)) {
-                return ClassFileReader.newInstance(fs, mp);
-            } else {
-                throw new FileNotFoundException(mp.toString());
-            }
-        }
-    }
-
-    /**
-     * Returns a ModuleClassReader that only reads classes for the given modulename.
-     */
-    public static ClassFileReader getClassReader(URI location, String modulename)
-            throws IOException {
-        if (location.getScheme().equals("jrt")) {
-            return SystemModulePath.getClassReader(modulename);
-        } else {
-            Path path = Paths.get(location);
-            return ClassFileReader.newInstance(path);
-        }
-    }
-}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java
index c0790ab..c150ca8 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java
@@ -26,9 +26,13 @@
 package com.sun.tools.jdeps;
 
 import java.io.IOException;
+import java.lang.module.ModuleDescriptor;
+import java.util.Arrays;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
 /**
@@ -44,17 +48,18 @@
     // need a way to determine JRE modules
     SE_JRE("Java SE JRE", 4, "java.se", "jdk.charsets",
                             "jdk.crypto.ec", "jdk.crypto.pkcs11",
-                            "jdk.crypto.mscapi", "jdk.crypto.ucrypto", "jdk.jvmstat",
+                            "jdk.crypto.mscapi", "jdk.crypto.ucrypto",
                             "jdk.localedata", "jdk.scripting.nashorn", "jdk.zipfs"),
     FULL_JRE("Full JRE", 5, "java.se.ee", "jdk.charsets",
                             "jdk.crypto.ec", "jdk.crypto.pkcs11",
                             "jdk.crypto.mscapi", "jdk.crypto.ucrypto", "jdk.jvmstat",
-                            "jdk.localedata", "jdk.scripting.nashorn", "jdk.zipfs");
+                            "jdk.localedata", "jdk.scripting.nashorn",
+                            "jdk.unsupported", "jdk.zipfs");
 
     final String name;
     final int profile;
     final String[] mnames;
-    final Set<Module> modules = new HashSet<>();
+    final Map<String, Module> modules = new HashMap<>();
 
     Profile(String name, int profile, String... mnames) {
         this.name = name;
@@ -75,12 +80,18 @@
         return JDK.isEmpty() ? 0 : Profile.values().length;
     }
 
+    Optional<Module> findModule(String name) {
+        return modules.containsKey(name)
+            ? Optional.of(modules.get(name))
+            : Optional.empty();
+    }
+
     /**
      * Returns the Profile for the given package name; null if not found.
      */
     public static Profile getProfile(String pn) {
         for (Profile p : Profile.values()) {
-            for (Module m : p.modules) {
+            for (Module m : p.modules.values()) {
                 if (m.packages().contains(pn)) {
                     return p;
                 }
@@ -94,7 +105,7 @@
      */
     public static Profile getProfile(Module m) {
         for (Profile p : Profile.values()) {
-            if (p.modules.contains(m)) {
+            if (p.modules.containsValue(m)) {
                 return p;
             }
         }
@@ -102,34 +113,28 @@
     }
 
     private final static Set<Module> JDK = new HashSet<>();
-    static synchronized void init(Map<String, Module> installed) {
-        for (Profile p : Profile.values()) {
-            for (String mn : p.mnames) {
-                // this includes platform-dependent module that may not exist
-                Module m = installed.get(mn);
-                if (m != null) {
-                    p.addModule(installed, m);
-                }
-            }
-        }
+    static synchronized void init(Map<String, Module> systemModules) {
+        Arrays.stream(Profile.values()).forEach(p ->
+            // this includes platform-dependent module that may not exist
+            Arrays.stream(p.mnames)
+                  .filter(systemModules::containsKey)
+                  .map(systemModules::get)
+                  .forEach(m -> p.addModule(systemModules, m)));
 
         // JDK modules should include full JRE plus other jdk.* modules
         // Just include all installed modules.  Assume jdeps is running
         // in JDK image
-        JDK.addAll(installed.values());
+        JDK.addAll(systemModules.values());
     }
 
-    private void addModule(Map<String, Module> installed, Module m) {
-        modules.add(m);
-        for (String n : m.requires().keySet()) {
-            Module d = installed.get(n);
-            if (d == null) {
-                throw new InternalError("module " + n + " required by " +
-                        m.name() + " doesn't exist");
-            }
-            modules.add(d);
-        }
+    private void addModule(Map<String, Module> systemModules, Module module) {
+        modules.put(module.name(), module);
+        module.descriptor().requires().stream()
+              .map(ModuleDescriptor.Requires::name)
+              .map(systemModules::get)
+              .forEach(m -> modules.put(m.name(), m));
     }
+
     // for debugging
     public static void main(String[] args) throws IOException {
         // find platform modules
@@ -139,14 +144,6 @@
         for (Profile p : Profile.values()) {
             String profileName = p.name;
             System.out.format("%2d: %-10s  %s%n", p.profile, profileName, p.modules);
-            for (Module m: p.modules) {
-                System.out.format("module %s%n", m.name());
-                System.out.format("   requires %s%n", m.requires());
-                for (Map.Entry<String,Set<String>> e: m.exports().entrySet()) {
-                    System.out.format("   exports %s %s%n", e.getKey(),
-                        e.getValue().isEmpty() ? "" : "to " + e.getValue());
-                }
-            }
         }
         System.out.println("All JDK modules:-");
         JDK.stream().sorted(Comparator.comparing(Module::name))
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
index b0fc19b..117baf1 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
@@ -1,12 +1,10 @@
 main.usage.summary=\
-Usage: {0} <options> [-m <module-name> | <classes...>]\n\
+Usage: {0} <options> <path ...>]\n\
 use -h, -? or -help for a list of possible options
 
 main.usage=\
-Usage: {0} <options> [-m <module-name> | <classes...>]\n\
-If -m <module-name> is specified, the specified module will be analyzed\n\
-otherwise, <classes> can be a pathname to a .class file, a directory,\n\
-a JAR file, or a fully-qualified class name.\n\
+Usage: {0} <options> <path ...>]\n\
+<path> can be a pathname to a .class file, a directory, a JAR file.\n\
 \n\
 Possible options include:
 
@@ -14,134 +12,156 @@
 warn.prefix=Warning:
 
 main.opt.h=\
-\  -h -?        -help                   Print this usage message
+\  -h -?        -help                Print this usage message
 
 main.opt.version=\
-\  -version                             Version information
+\  -version                          Version information
 
 main.opt.v=\
-\  -v           -verbose                Print all class level dependencies\n\
-\                                       Equivalent to -verbose:class -filter:none.\n\
-\  -verbose:package                     Print package-level dependencies excluding\n\
-\                                       dependencies within the same package by default\n\
-\  -verbose:class                       Print class-level dependencies excluding\n\
-\                                       dependencies within the same package by default
-
-main.opt.f=\
-\  -f <regex>  -filter <regex>          Filter dependences matching the given pattern\n\
-\                                       If given multiple times, the last one will be used.\n\
-\  -filter:package                      Filter dependences within the same package (default)\n\
-\  -filter:module                       Filter dependences within the same module\n\
-\  -filter:archive                      Filter dependences within the same archive\n\
-\  -filter:none                         No -filter:package and -filter:archive filtering\n\
-\                                       Filtering specified via the -filter option still applies.
+\  -v           -verbose             Print all class level dependencies\n\
+\                                    Equivalent to -verbose:class -filter:none.\n\
+\  -verbose:package                  Print package-level dependencies excluding\n\
+\                                    dependencies within the same package by default\n\
+\  -verbose:class                    Print class-level dependencies excluding\n\
+\                                    dependencies within the same package by default
 
 main.opt.s=\
-\  -s           -summary                Print dependency summary only.\n\
-\                                       If -s option is used with -m, the module descriptor of\n\
-\                                       the given module will be read to generate the graph.
+\  -s           -summary             Print dependency summary only.
 
-main.opt.p=\
-\  -p <pkgname>                         Finds dependences matching the given package name\n\
-\  -package <pkgname>                   (may be given multiple times).
+main.opt.f=\
+\  -f <regex>  -filter <regex>       Filter dependences matching the given\n\
+\                                    pattern. If given multiple times, the last\n\
+\                                    one will be used.\n\
+\  -filter:package                   Filter dependences within the same package.\n\
+\                                    This is the default.\n\
+\  -filter:archive                   Filter dependences within the same archive.\n\
+\  -filter:module                    Filter dependences within the same module.\n\
+\  -filter:none                      No -filter:package and -filter:archive\n\
+\                                    filtering.  Filtering specified via the\n\
+\                                    -filter option still applies.\n\
+
+main.opt.p=\n\
+\Options to filter dependencies:\n\
+\  -p <pkgname> -package <pkgname>   Finds dependences matching the given package\n\
+\                                    name (may be given multiple times).
 
 main.opt.e=\
-\  -e <regex>\n\
-\  -regex <regex>                       Finds dependences matching the given pattern.
+\  -e <regex> -regex <regex>         Finds dependences matching the given pattern.
 
-main.opt.module=\
-\  -module <module-name>                Finds dependences matching the given module name\n\
-\                                       (may be given multiple times).\n\
-\                                       -package, -regex, -requires are mutual exclusive.
+main.opt.requires=\
+\  -requires <module-name>           Finds dependences matching the given module\n\
+\                                    name (may be given multiple times).\n\
+\                                    -package, -regex, -requires are mutual exclusive.
 
-main.opt.include=\
-\  -include <regex>                     Restrict analysis to classes matching pattern\n\
-\                                       This option filters the list of classes to\n\
-\                                       be analyzed.  It can be used together with\n\
-\                                       -p and -e which apply pattern to the dependences
+main.opt.include=\n\
+ \Options to filter classes to be analyzed:\n\
+\  -include <regex>                  Restrict analysis to classes matching pattern\n\
+\                                    This option filters the list of classes to\n\
+\                                    be analyzed.  It can be used together with\n\
+\                                    -p and -e which apply pattern to the dependences
 
 main.opt.P=\
-\  -P           -profile                Show profile containing a package
-
-main.opt.M=\
-\  -M                                   Show module containing a package
+\  -P           -profile             Show profile containing a package
 
 main.opt.cp=\
-\  -cp <path>   -classpath <path>       Specify where to find class files
+\  -cp <path>   -classpath <path>    Specify where to find class files
 
 main.opt.mp=\
 \  -mp <module path>...\n\
-\  -modulepath <module path>...         Specify module path
+\  -modulepath <module path>...      Specify module path
 
 main.opt.upgrademodulepath=\
 \  -upgrademodulepath <module path>...  Specify upgrade module path
 
+main.opt.system=\
+\  -system <java-home>               Specify an alternate system module path
+
+main.opt.addmods=\
+\  -addmods <module-name>[,<module-name>...]\n\
+\                                    Adds modules to the root set for analysis
+
 main.opt.m=\
-\  -m <module-name>                     Specify the name of the module and its transitive\n\
-\                                       dependences to be analyzed.
+\  -m <module-name>                  Specify the root module for analysis
 
 main.opt.R=\
-\  -R           -recursive              Recursively traverse all run-time dependencies.\n\
-\                                       The -R option implies -filter:none.  If -p, -e, -f\n\
-\                                       option is specified, only the matching dependences\n\
-\                                       are analyzed.
+\  -R           -recursive           Recursively traverse all run-time dependencies.\n\
+\                                    The -R option implies -filter:none.  If -p,\n\
+\                                    -e, -foption is specified, only the matching\n\
+\                                    dependences are analyzed.
+
+main.opt.I=\
+\  -I           -inverse             Analyzes the dependences per other given options\n\
+\                                    and then find all artifacts that directly\n\
+\                                    and indirectly depend on the matching nodes.\n\
+\                                    This is equivalent to the inverse of\n\
+\                                    compile-time view analysis and print\n\
+\                                    dependency summary.  This option must use\n\
+\                                    with -requires, -package or -regex option.
 
 main.opt.ct=\
-\  -ct          -compile-time           Compile-time view of transitive dependencies\n\
-\                                       i.e. compile-time view of -R option.  If a dependence\n\
-\                                       is found from a directory, a JAR file or a module,\n\
-\                                       all class files in that containing archive are analyzed.
+\  -ct          -compile-time        Compile-time view of transitive dependencies\n\
+\                                    i.e. compile-time view of -R option.\n\
+\                                    Analyzes the dependences per other given options\n\
+\                                    If a dependence is found from a directory,\n\
+\                                    a JAR file or a module, all classes in that \n\
+\                                    containing archive are analyzed.
 
 main.opt.apionly=\
-\  -apionly                             Restrict analysis to APIs i.e. dependences\n\
-\                                       from the signature of public and protected\n\
-\                                       members of public classes including field\n\
-\                                       type, method parameter types, returned type,\n\
-\                                       checked exception types etc
+\  -apionly                          Restrict analysis to APIs i.e. dependences\n\
+\                                    from the signature of public and protected\n\
+\                                    members of public classes including field\n\
+\                                    type, method parameter types, returned type,\n\
+\                                    checked exception types etc.
 
 main.opt.genmoduleinfo=\
-\  -genmoduleinfo <dir>                 Generate module-info.java under the specified directory.\n\
-\                                       The specified JAR files will be analyzed.\n\
-\                                       This option cannot be used with -dotoutput or -cp.
+\  -genmoduleinfo <dir>              Generate module-info.java under the specified\n\
+\                                    directory. The specified JAR files will be\n\
+\                                    analyzed. This option cannot be used with\n\
+\                                    -dotoutput or -cp.
 
 main.opt.check=\
-\  -check                               Analyze the dependence of a given module specified via\n\
-\                                       -m option.  It prints out the resulting module dependency\n\
-\                                       graph after transition reduction and also identifies any\n\
-\                                       unused qualified exports.
+\  -check <module-name>[,<module-name>...\n\
+\                                    Analyze the dependence of the specified modules\n\
+\                                    It prints the module descriptor, the resulting\n\
+\                                    module dependences after analysis and the\n\
+\                                    graph after transition reduction.  It also\n\
+\                                    identifies any unused qualified exports.
 
 
 main.opt.dotoutput=\
-\  -dotoutput <dir>                     Destination directory for DOT file output
+\  -dotoutput <dir>                  Destination directory for DOT file output
 
 main.opt.jdkinternals=\
-\  -jdkinternals                        Finds class-level dependences on JDK internal APIs.\n\
-\                                       By default, it analyzes all classes on -classpath\n\
-\                                       and input files unless -include option is specified.\n\
-\                                       This option cannot be used with -p, -e and -s options.\n\
-\                                       WARNING: JDK internal APIs may not be accessible in\n\
-\                                       the next release.
+\  -jdkinternals                     Finds class-level dependences on JDK internal\n\
+\                                    APIs. By default, it analyzes all classes\n\
+\                                    on -classpath and input files unless -include\n\
+\                                    option is specified. This option cannot be\n\
+\                                    used with -p, -e and -s options.\n\
+\                                    WARNING: JDK internal APIs are inaccessible.
 
 main.opt.depth=\
-\  -depth=<depth>                       Specify the depth of the transitive\n\
-\                                       dependency analysis
+\  -depth=<depth>                    Specify the depth of the transitive\n\
+\                                    dependency analysis
 
 main.opt.q=\
-\  -q           -quiet                  Do not show missing dependencies from -genmoduleinfo output.
+\  -q           -quiet               Do not show missing dependencies from \n\
+\                                    -genmoduleinfo output.
 
 err.unknown.option=unknown option: {0}
 err.missing.arg=no value given for {0}
 err.invalid.arg.for.option=invalid argument for option: {0}
 err.option.after.class=option must be specified before classes: {0}
-err.genmoduleinfo.not.jarfile={0} not valid for -genmoduleinfo option (must be JAR file)
+err.genmoduleinfo.not.jarfile={0} not valid for -genmoduleinfo option (must be non-modular JAR file)
 err.profiles.msg=No profile information
 err.exception.message={0}
 err.invalid.path=invalid path: {0}
-err.invalid.module.option=-m {0} is set but {1} is specified.
+err.invalid.module.option=Cannot set {0} with {1} option.
 err.invalid.filters=Only one of -package (-p), -regex (-e), -requires option can be set
 err.module.not.found=module not found: {0}
-err.root.module.not.set=-m is not set
-warn.invalid.arg=Invalid classname or pathname not exist: {0}
+err.root.module.not.set=root module set empty
+err.invalid.inverse.option={0} cannot be used with -inverse option
+err.inverse.filter.not.set={0} cannot be used with -inverse option
+warn.invalid.arg=Path not exist: {0}
 warn.split.package=package {0} defined in {1} {2}
 warn.replace.useJDKInternals=\
 JDK internal APIs are unsupported and private to JDK implementation that are\n\
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties
index 6dd8380..1644f11 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties
@@ -1,6 +1,5 @@
-// No translation needed
+# No translation needed
 com.sun.crypto.provider.SunJCE=Use java.security.Security.getProvider(provider-name) @since 1.3
-com.sun.image.codec=Use javax.imageio @since 1.4
 com.sun.org.apache.xml.internal.security=Use java.xml.crypto @since 1.6
 com.sun.org.apache.xml.internal.security.utils.Base64=Use java.util.Base64 @since 1.8
 com.sun.org.apache.xml.internal.resolver=Use javax.xml.catalog @since 9
@@ -9,11 +8,16 @@
 com.sun.rowset=Use javax.sql.rowset.RowSetProvider @since 1.7
 com.sun.tools.javac.tree=Use com.sun.source @since 1.6
 com.sun.tools.javac=Use javax.tools and javax.lang.model @since 1.6
-sun.awt.image.codec=Use javax.imageio @since 1.4
-sun.misc.BASE64Encoder=Use java.util.Base64 @since 1.8
-sun.misc.BASE64Decoder=Use java.util.Base64 @since 1.8
-sun.misc.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 or java.lang.ref.Cleaner @since 9
-sun.misc.Service=Use java.util.ServiceLoader @since 1.6
+java.awt.peer=Should not use. See https://bugs.openjdk.java.net/browse/JDK-8037739
+java.awt.dnd.peer=Should not use. See https://bugs.openjdk.java.net/browse/JDK-8037739
+jdk.internal.ref.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 or java.lang.ref.Cleaner @since 9
+sun.awt.CausedFocusEvent=Use java.awt.event.FocusEvent::getCause @since 9
+sun.font.FontUtilities=See java.awt.Font.textRequiresLayout	@since 9
+sun.reflect.Reflection=Use java.lang.StackWalker @since 9
+sun.reflect.ReflectionFactory=See http://openjdk.java.net/jeps/260
+sun.misc.Unsafe=See http://openjdk.java.net/jeps/260
+sun.misc.Signal=See http://openjdk.java.net/jeps/260
+sun.misc.SignalHandler=See http://openjdk.java.net/jeps/260
 sun.security.action=Use java.security.PrivilegedAction @since 1.1
 sun.security.krb5=Use com.sun.security.jgss
 sun.security.provider.PolicyFile=Use java.security.Policy.getInstance("JavaPolicy", new URIParameter(uri)) @since 1.6
@@ -21,5 +25,17 @@
 sun.security.util.SecurityConstants=Use appropriate java.security.Permission subclass @since 1.1
 sun.security.x509.X500Name=Use javax.security.auth.x500.X500Principal @since 1.4
 sun.tools.jar=Use java.util.jar or jar tool @since 1.2
-jdk.internal.ref.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 or java.lang.ref.Cleaner @since 9
+# Internal APIs removed in JDK 9
+com.apple.eawt=Use java.awt.desktop and JEP 272 @since 9
+com.apple.concurrent=Removed. See https://bugs.openjdk.java.net/browse/JDK-8148187
+com.sun.image.codec.jpeg=Use javax.imageio @since 1.4
+sun.awt.image.codec=Use javax.imageio @since 1.4
+sun.misc.BASE64Encoder=Use java.util.Base64 @since 1.8
+sun.misc.BASE64Decoder=Use java.util.Base64 @since 1.8
+sun.misc.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 or java.lang.ref.Cleaner @since 9
+sun.misc.Service=Use java.util.ServiceLoader @since 1.6
+sun.misc=Removed. See http://openjdk.java.net/jeps/260
+sun.reflect=Removed. See http://openjdk.java.net/jeps/260
+
+
 
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java
index 5a378eb..4f759c7 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java
@@ -23,24 +23,60 @@
 
 package jdk.internal.jshell.debug;
 
+import java.io.PrintStream;
 import java.util.HashMap;
 import java.util.Map;
 import jdk.jshell.JShell;
 
 /**
- * Used to externally control output messages for debugging the implementation
- * of the JShell API.  This is NOT a supported interface,
- * @author Robert Field
+/**
+ * This class is used to externally control output messages for debugging the
+ * implementation of the JShell API.
+ * <p>
+ * This is not part of the SPI, not API.
  */
 public class InternalDebugControl {
-    public static final int DBG_GEN   = 0b0000001;
-    public static final int DBG_FMGR  = 0b0000010;
+
+    /**
+     * This is a static only class; The constructor should never be called.
+     */
+    private InternalDebugControl() {
+    }
+
+    /**
+     * General debugging.
+     */
+    public static final int DBG_GEN = 0b0000001;
+
+    /**
+     * File manager debuging.
+     */
+    public static final int DBG_FMGR = 0b0000010;
+
+    /**
+     * Completion analysis debugging.
+     */
     public static final int DBG_COMPA = 0b0000100;
-    public static final int DBG_DEP   = 0b0001000;
-    public static final int DBG_EVNT  = 0b0010000;
+
+    /**
+     * Dependency debugging.
+     */
+    public static final int DBG_DEP = 0b0001000;
+
+    /**
+     * Event debugging.
+     */
+    public static final int DBG_EVNT = 0b0010000;
 
     private static Map<JShell, Integer> debugMap = null;
 
+    /**
+     * Sets which debug flags are enabled for a given JShell instance. The flags
+     * are or'ed bits as defined in {@code DBG_*}.
+     *
+     * @param state the JShell instance
+     * @param flags the or'ed debug bits
+     */
     public static void setDebugFlags(JShell state, int flags) {
         if (debugMap == null) {
             debugMap = new HashMap<>();
@@ -48,7 +84,14 @@
         debugMap.put(state, flags);
     }
 
-    public static boolean debugEnabled(JShell state, int flag) {
+    /**
+     * Tests if any of the specified debug flags are enabled.
+     *
+     * @param state the JShell instance
+     * @param flag the {@code DBG_*} bits to check
+     * @return true if any of the flags are enabled
+     */
+    public static boolean isDebugEnabled(JShell state, int flag) {
         if (debugMap == null) {
             return false;
         }
@@ -58,4 +101,34 @@
         }
         return (flags & flag) != 0;
     }
+
+    /**
+     * Displays debug info if the specified debug flags are enabled.
+     *
+     * @param state the current JShell instance
+     * @param err the {@code PrintStream} to report on
+     * @param flags {@code DBG_*} flag bits to check
+     * @param format format string for the output
+     * @param args args for the format string
+     */
+    public static void debug(JShell state, PrintStream err, int flags, String format, Object... args) {
+        if (isDebugEnabled(state, flags)) {
+            err.printf(format, args);
+        }
+    }
+
+    /**
+     * Displays a fatal exception as debug info.
+     *
+     * @param state the current JShell instance
+     * @param err the {@code PrintStream} to report on
+     * @param ex the fatal Exception
+     * @param where additional context
+     */
+    public static void debug(JShell state, PrintStream err, Exception ex, String where) {
+        if (isDebugEnabled(state, 0xFFFFFFFF)) {
+            err.printf("Fatal error: %s: %s\n", where, ex.getMessage());
+            ex.printStackTrace(err);
+        }
+    }
 }
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/ClassTracker.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/ClassTracker.java
new file mode 100644
index 0000000..40053f1
--- /dev/null
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/ClassTracker.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.internal.jshell.jdi;
+
+import java.util.HashMap;
+import java.util.Objects;
+import com.sun.jdi.ReferenceType;
+import java.util.List;
+
+/**
+ * Tracks the state of a class.
+ */
+class ClassTracker {
+
+    private final JDIEnv jdiEnv;
+    private final HashMap<String, ClassInfo> map;
+
+    ClassTracker(JDIEnv jdiEnv) {
+        this.jdiEnv = jdiEnv;
+        this.map = new HashMap<>();
+    }
+
+    /**
+     * Associates a class name, class bytes, and ReferenceType.
+     */
+    class ClassInfo {
+
+        // The name of the class -- always set
+        private final String className;
+
+        // The corresponding compiled class bytes when a load or redefine
+        // is started.  May not be the loaded bytes.  May be null.
+        private byte[] bytes;
+
+        // The class bytes successfully loaded/redefined into the remote VM.
+        private byte[] loadedBytes;
+
+        // The corresponding JDI ReferenceType.  Used by redefineClasses and
+        // acts as indicator of successful load (null if not loaded).
+        private ReferenceType rt;
+
+        private ClassInfo(String className) {
+            this.className = className;
+        }
+
+        String getClassName() {
+            return className;
+        }
+
+        byte[] getLoadedBytes() {
+            return loadedBytes;
+        }
+
+        byte[] getBytes() {
+            return bytes;
+        }
+
+        private void setBytes(byte[] potentialBytes) {
+            this.bytes = potentialBytes;
+        }
+
+        // The class has been successful loaded redefined.  The class bytes
+        // sent are now actually loaded.
+        void markLoaded() {
+            loadedBytes = bytes;
+        }
+
+        // Ask JDI for the ReferenceType, null if not loaded.
+        ReferenceType getReferenceTypeOrNull() {
+            if (rt == null) {
+                rt = nameToRef(className);
+            }
+            return rt;
+        }
+
+        private ReferenceType nameToRef(String name) {
+            List<ReferenceType> rtl = jdiEnv.vm().classesByName(name);
+            if (rtl.size() != 1) {
+                return null;
+            }
+            return rtl.get(0);
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            return o instanceof ClassInfo
+                    && ((ClassInfo) o).className.equals(className);
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(this.className);
+        }
+    }
+
+    // Map a class name to the current compiled class bytes.
+    ClassInfo classInfo(String className, byte[] bytes) {
+        ClassInfo ci = get(className);
+        ci.setBytes(bytes);
+        return ci;
+    }
+
+    // Lookup the ClassInfo by class name, create if it does not exist.
+    ClassInfo get(String className) {
+        return map.computeIfAbsent(className, k -> new ClassInfo(k));
+    }
+}
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIConnection.java
similarity index 92%
rename from langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java
rename to langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIConnection.java
index 56cf4d9..2c90e8b 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIConnection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
  */
 
 
-package jdk.jshell;
+package jdk.internal.jshell.jdi;
 
 import com.sun.jdi.*;
 import com.sun.jdi.connect.*;
@@ -40,7 +40,6 @@
 import java.util.*;
 import java.util.Map.Entry;
 import java.io.*;
-
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
 
 /**
@@ -54,8 +53,7 @@
     private Process process = null;
     private int outputCompleteCount = 0;
 
-    private final JShell proc;
-    private final JDIEnv env;
+    private final JDIExecutionControl ec;
     private final Connector connector;
     private final Map<String, com.sun.jdi.connect.Connector.Argument> connectorArgs;
     private final int traceFlags;
@@ -103,9 +101,9 @@
         return arguments;
     }
 
-    JDIConnection(JDIEnv env, String connectorName, Map<String, String> argumentName2Value, int traceFlags, JShell proc) {
-        this.env = env;
-        this.proc = proc;
+
+    JDIConnection(JDIExecutionControl ec, String connectorName, Map<String, String> argumentName2Value, int traceFlags) {
+        this.ec = ec;
         this.connector = findConnector(connectorName);
 
         if (connector == null) {
@@ -260,8 +258,8 @@
                 try {
                     dumpStream(inStream, pStream);
                 } catch (IOException ex) {
-                    proc.debug(ex, "Failed reading output");
-                    env.shutdown();
+                    ec.debug(ex, "Failed reading output");
+                    ec.jdiEnv.shutdown();
                 } finally {
                     notifyOutputComplete();
                 }
@@ -287,8 +285,8 @@
                         outStream.flush();
                     }
                 } catch (IOException ex) {
-                    proc.debug(ex, "Failed reading output");
-                    env.shutdown();
+                    ec.debug(ex, "Failed reading output");
+                    ec.jdiEnv.shutdown();
                 }
             }
         };
@@ -302,9 +300,9 @@
         try {
             VirtualMachine new_vm = launcher.launch(connectorArgs);
             process = new_vm.process();
-            displayRemoteOutput(process.getErrorStream(), proc.err);
-            displayRemoteOutput(process.getInputStream(), proc.out);
-            readRemoteInput(process.getOutputStream(), proc.in);
+            displayRemoteOutput(process.getErrorStream(), ec.execEnv.userErr());
+            displayRemoteOutput(process.getInputStream(), ec.execEnv.userOut());
+            readRemoteInput(process.getOutputStream(), ec.execEnv.userIn());
             return new_vm;
         } catch (Exception ex) {
             reportLaunchFail(ex, "launch");
@@ -330,7 +328,7 @@
         ListeningConnector listener = (ListeningConnector)connector;
         try {
             String retAddress = listener.startListening(connectorArgs);
-            proc.debug(DBG_GEN, "Listening at address: " + retAddress);
+            ec.debug(DBG_GEN, "Listening at address: " + retAddress);
             vm = listener.accept(connectorArgs);
             listener.stopListening(connectorArgs);
             return vm;
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEnv.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIEnv.java
similarity index 82%
rename from langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEnv.java
rename to langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIEnv.java
index e280ade..16e6229 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEnv.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIEnv.java
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package jdk.jshell;
+package jdk.internal.jshell.jdi;
 
 import java.util.Map;
 
@@ -37,14 +37,14 @@
 class JDIEnv {
 
     private JDIConnection connection;
-    private final JShell state;
+    private final JDIExecutionControl ec;
 
-    JDIEnv(JShell state) {
-        this.state = state;
+    JDIEnv(JDIExecutionControl ec) {
+        this.ec = ec;
     }
 
     void init(String connectorName, Map<String, String> argumentName2Value, boolean openNow, int flags) {
-        connection = new JDIConnection(this, connectorName, argumentName2Value, flags, state);
+        connection = new JDIConnection(ec, connectorName, argumentName2Value, flags);
         if (!connection.isLaunch() || openNow) {
             connection.open();
         }
@@ -66,14 +66,14 @@
                 // Shutting down after the VM has gone away. This is
                 // not an error, and we just ignore it.
             } catch (Throwable e) {
-                state.debug(DBG_GEN, null, "disposeVM threw: " + e);
+                ec.debug(DBG_GEN, null, "disposeVM threw: " + e);
             }
         }
-        if (state != null) { // If state has been set-up
+        if (ec.execEnv.state() != null) { // If state has been set-up
             try {
-                state.closeDown();
+                ec.execEnv.closeDown();
             } catch (Throwable e) {
-                state.debug(DBG_GEN, null, "state().closeDown() threw: " + e);
+                ec.debug(DBG_GEN, null, "state().closeDown() threw: " + e);
             }
         }
     }
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEventHandler.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIEventHandler.java
similarity index 99%
rename from langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEventHandler.java
rename to langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIEventHandler.java
index fc18b1e..7c1bf9e 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEventHandler.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIEventHandler.java
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package jdk.jshell;
+package jdk.internal.jshell.jdi;
 
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIExecutionControl.java
new file mode 100644
index 0000000..440db5a
--- /dev/null
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIExecutionControl.java
@@ -0,0 +1,595 @@
+/*
+ * Copyright (c) 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.jshell.jdi;
+
+import static jdk.internal.jshell.remote.RemoteCodes.*;
+import java.io.DataInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import com.sun.jdi.*;
+import java.io.EOFException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static java.util.stream.Collectors.toList;
+import jdk.jshell.JShellException;
+import jdk.jshell.spi.ExecutionControl;
+import jdk.jshell.spi.ExecutionEnv;
+import jdk.internal.jshell.jdi.ClassTracker.ClassInfo;
+import static java.util.stream.Collectors.toMap;
+import jdk.internal.jshell.debug.InternalDebugControl;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
+
+/**
+ * Controls the remote execution environment.
+ * Interfaces to the JShell-core by implementing ExecutionControl SPI.
+ * Interfaces to RemoteAgent over a socket and via JDI.
+ * Launches a remote process.
+ */
+public class JDIExecutionControl implements ExecutionControl {
+
+    ExecutionEnv execEnv;
+    JDIEnv jdiEnv;
+    private ClassTracker tracker;
+    private JDIEventHandler handler;
+    private Socket socket;
+    private ObjectInputStream remoteIn;
+    private ObjectOutputStream remoteOut;
+    private String remoteVMOptions;
+
+    /**
+     * Initializes the launching JDI execution engine. Initialize JDI and use it
+     * to launch the remote JVM. Set-up control and result communications socket
+     * to the remote execution environment. This socket also transports the
+     * input/output channels.
+     *
+     * @param execEnv the execution environment provided by the JShell-core
+     * @throws IOException
+     */
+    @Override
+    public void start(ExecutionEnv execEnv) throws IOException {
+        this.execEnv = execEnv;
+        this.jdiEnv = new JDIEnv(this);
+        this.tracker = new ClassTracker(jdiEnv);
+        StringBuilder sb = new StringBuilder();
+        execEnv.extraRemoteVMOptions().stream()
+                .forEach(s -> {
+                    sb.append(" ");
+                    sb.append(s);
+                });
+        this.remoteVMOptions = sb.toString();
+        try (ServerSocket listener = new ServerSocket(0)) {
+            // timeout after 60 seconds
+            listener.setSoTimeout(60000);
+            int port = listener.getLocalPort();
+            jdiGo(port);
+            this.socket = listener.accept();
+            // out before in -- match remote creation so we don't hang
+            this.remoteOut = new ObjectOutputStream(socket.getOutputStream());
+            PipeInputStream commandIn = new PipeInputStream();
+            new DemultiplexInput(socket.getInputStream(), commandIn, execEnv.userOut(), execEnv.userErr()).start();
+            this.remoteIn = new ObjectInputStream(commandIn);
+        }
+    }
+
+    /**
+     * Closes the execution engine. Send an exit command to the remote agent.
+     * Shuts down the JDI connection. Should this close the socket?
+     */
+    @Override
+    public void close() {
+        try {
+            if (remoteOut != null) {
+                remoteOut.writeInt(CMD_EXIT);
+                remoteOut.flush();
+            }
+            JDIConnection c = jdiEnv.connection();
+            if (c != null) {
+                c.disposeVM();
+            }
+        } catch (IOException ex) {
+            debug(DBG_GEN, "Exception on JDI exit: %s\n", ex);
+        }
+    }
+
+    /**
+     * Loads the list of classes specified. Sends a load command to the remote
+     * agent with pairs of classname/bytes.
+     *
+     * @param classes the names of the wrapper classes to loaded
+     * @return true if all classes loaded successfully
+     */
+    @Override
+    public boolean load(Collection<String> classes) {
+        try {
+            // Create corresponding ClassInfo instances to track the classes.
+            // Each ClassInfo has the current class bytes associated with it.
+            List<ClassInfo> infos = withBytes(classes);
+            // Send a load command to the remote agent.
+            remoteOut.writeInt(CMD_LOAD);
+            remoteOut.writeInt(classes.size());
+            for (ClassInfo ci : infos) {
+                remoteOut.writeUTF(ci.getClassName());
+                remoteOut.writeObject(ci.getBytes());
+            }
+            remoteOut.flush();
+            // Retrieve and report results from the remote agent.
+            boolean result = readAndReportResult();
+            // For each class that now has a JDI ReferenceType, mark the bytes
+            // as loaded.
+            infos.stream()
+                    .filter(ci -> ci.getReferenceTypeOrNull() != null)
+                    .forEach(ci -> ci.markLoaded());
+            return result;
+        } catch (IOException ex) {
+            debug(DBG_GEN, "IOException on remote load operation: %s\n", ex);
+            return false;
+        }
+    }
+
+    /**
+     * Invoke the doit method on the specified class.
+     *
+     * @param classname name of the wrapper class whose doit should be invoked
+     * @return return the result value of the doit
+     * @throws JShellException if a user exception was thrown (EvalException) or
+     * an unresolved reference was encountered (UnresolvedReferenceException)
+     */
+    @Override
+    public String invoke(String classname, String methodname) throws JShellException {
+        try {
+            synchronized (STOP_LOCK) {
+                userCodeRunning = true;
+            }
+            // Send the invoke command to the remote agent.
+            remoteOut.writeInt(CMD_INVOKE);
+            remoteOut.writeUTF(classname);
+            remoteOut.writeUTF(methodname);
+            remoteOut.flush();
+            // Retrieve and report results from the remote agent.
+            if (readAndReportExecutionResult()) {
+                String result = remoteIn.readUTF();
+                return result;
+            }
+        } catch (IOException | RuntimeException ex) {
+            if (!jdiEnv.connection().isRunning()) {
+                // The JDI connection is no longer live, shutdown.
+                jdiEnv.shutdown();
+            } else {
+                debug(DBG_GEN, "Exception on remote invoke: %s\n", ex);
+                return "Execution failure: " + ex.getMessage();
+            }
+        } finally {
+            synchronized (STOP_LOCK) {
+                userCodeRunning = false;
+            }
+        }
+        return "";
+    }
+
+    /**
+     * Retrieves the value of a JShell variable.
+     *
+     * @param classname name of the wrapper class holding the variable
+     * @param varname name of the variable
+     * @return the value as a String
+     */
+    @Override
+    public String varValue(String classname, String varname) {
+        try {
+            // Send the variable-value command to the remote agent.
+            remoteOut.writeInt(CMD_VARVALUE);
+            remoteOut.writeUTF(classname);
+            remoteOut.writeUTF(varname);
+            remoteOut.flush();
+            // Retrieve and report results from the remote agent.
+            if (readAndReportResult()) {
+                String result = remoteIn.readUTF();
+                return result;
+            }
+        } catch (EOFException ex) {
+            jdiEnv.shutdown();
+        } catch (IOException ex) {
+            debug(DBG_GEN, "Exception on remote var value: %s\n", ex);
+            return "Execution failure: " + ex.getMessage();
+        }
+        return "";
+    }
+
+    /**
+     * Adds a path to the remote classpath.
+     *
+     * @param cp the additional path element
+     * @return true if succesful
+     */
+    @Override
+    public boolean addToClasspath(String cp) {
+        try {
+            // Send the classpath addition command to the remote agent.
+            remoteOut.writeInt(CMD_CLASSPATH);
+            remoteOut.writeUTF(cp);
+            remoteOut.flush();
+            // Retrieve and report results from the remote agent.
+            return readAndReportResult();
+        } catch (IOException ex) {
+            throw new InternalError("Classpath addition failed: " + cp, ex);
+        }
+    }
+
+    /**
+     * Redefine the specified classes. Where 'redefine' is, as in JDI and JVMTI,
+     * an in-place replacement of the classes (preserving class identity) --
+     * that is, existing references to the class do not need to be recompiled.
+     * This implementation uses JDI redefineClasses. It will be unsuccessful if
+     * the signature of the class has changed (see the JDI spec). The
+     * JShell-core is designed to adapt to unsuccessful redefine.
+     *
+     * @param classes the names of the classes to redefine
+     * @return true if all the classes were redefined
+     */
+    @Override
+    public boolean redefine(Collection<String> classes) {
+        try {
+            // Create corresponding ClassInfo instances to track the classes.
+            // Each ClassInfo has the current class bytes associated with it.
+            List<ClassInfo> infos = withBytes(classes);
+            // Convert to the JDI ReferenceType to class bytes map form needed
+            // by JDI.
+            Map<ReferenceType, byte[]> rmp = infos.stream()
+                    .collect(toMap(
+                            ci -> ci.getReferenceTypeOrNull(),
+                            ci -> ci.getBytes()));
+            // Attempt redefine.  Throws exceptions on failure.
+            jdiEnv.vm().redefineClasses(rmp);
+            // Successful: mark the bytes as loaded.
+            infos.stream()
+                    .forEach(ci -> ci.markLoaded());
+            return true;
+        } catch (UnsupportedOperationException ex) {
+            // A form of class transformation not supported by JDI
+            return false;
+        } catch (Exception ex) {
+            debug(DBG_GEN, "Exception on JDI redefine: %s\n", ex);
+            return false;
+        }
+    }
+
+    /**
+     * Converts a collection of class names into ClassInfo instances associated
+     * with the most recently compiled class bytes.
+     *
+     * @param classes names of the classes
+     * @return a list of corresponding ClassInfo instances
+     */
+    private List<ClassInfo> withBytes(Collection<String> classes) {
+        return classes.stream()
+                .map(cn -> tracker.classInfo(cn, execEnv.getClassBytes(cn)))
+                .collect(toList());
+    }
+
+    /**
+     * Reports the status of the named class. UNKNOWN if not loaded. CURRENT if
+     * the most recent successfully loaded/redefined bytes match the current
+     * compiled bytes.
+     *
+     * @param classname the name of the class to test
+     * @return the status
+     */
+    @Override
+    public ClassStatus getClassStatus(String classname) {
+        ClassInfo ci = tracker.get(classname);
+        if (ci.getReferenceTypeOrNull() == null) {
+            // If the class does not have a JDI ReferenceType it has not been loaded
+            return ClassStatus.UNKNOWN;
+        }
+        // Compare successfully loaded with last compiled bytes.
+        return (Arrays.equals(execEnv.getClassBytes(classname), ci.getLoadedBytes()))
+                ? ClassStatus.CURRENT
+                : ClassStatus.NOT_CURRENT;
+    }
+
+    /**
+     * Reports results from a remote agent command that does not expect
+     * exceptions.
+     *
+     * @return true if successful
+     * @throws IOException if the connection has dropped
+     */
+    private boolean readAndReportResult() throws IOException {
+        int ok = remoteIn.readInt();
+        switch (ok) {
+            case RESULT_SUCCESS:
+                return true;
+            case RESULT_FAIL: {
+                String ex = remoteIn.readUTF();
+                debug(DBG_GEN, "Exception on remote operation: %s\n", ex);
+                return false;
+            }
+            default: {
+                debug(DBG_GEN, "Bad remote result code: %s\n", ok);
+                return false;
+            }
+        }
+    }
+
+    /**
+     * Reports results from a remote agent command that expects runtime
+     * exceptions.
+     *
+     * @return true if successful
+     * @throws IOException if the connection has dropped
+     * @throws EvalException if a user exception was encountered on invoke
+     * @throws UnresolvedReferenceException if an unresolved reference was
+     * encountered
+     */
+    private boolean readAndReportExecutionResult() throws IOException, JShellException {
+        int ok = remoteIn.readInt();
+        switch (ok) {
+            case RESULT_SUCCESS:
+                return true;
+            case RESULT_FAIL: {
+                // An internal error has occurred.
+                String ex = remoteIn.readUTF();
+                return false;
+            }
+            case RESULT_EXCEPTION: {
+                // A user exception was encountered.
+                String exceptionClassName = remoteIn.readUTF();
+                String message = remoteIn.readUTF();
+                StackTraceElement[] elems = readStackTrace();
+                throw execEnv.createEvalException(message, exceptionClassName, elems);
+            }
+            case RESULT_CORRALLED: {
+                // An unresolved reference was encountered.
+                int id = remoteIn.readInt();
+                StackTraceElement[] elems = readStackTrace();
+                throw execEnv.createUnresolvedReferenceException(id, elems);
+            }
+            case RESULT_KILLED: {
+                // Execution was aborted by the stop()
+                debug(DBG_GEN, "Killed.");
+                return false;
+            }
+            default: {
+                debug(DBG_GEN, "Bad remote result code: %s\n", ok);
+                return false;
+            }
+        }
+    }
+
+    private StackTraceElement[] readStackTrace() throws IOException {
+        int elemCount = remoteIn.readInt();
+        StackTraceElement[] elems = new StackTraceElement[elemCount];
+        for (int i = 0; i < elemCount; ++i) {
+            String className = remoteIn.readUTF();
+            String methodName = remoteIn.readUTF();
+            String fileName = remoteIn.readUTF();
+            int line = remoteIn.readInt();
+            elems[i] = new StackTraceElement(className, methodName, fileName, line);
+        }
+        return elems;
+    }
+
+    /**
+     * Launch the remote agent as a JDI connection.
+     *
+     * @param port the socket port for (non-JDI) commands
+     */
+    private void jdiGo(int port) {
+        //MessageOutput.textResources = ResourceBundle.getBundle("impl.TTYResources",
+        //        Locale.getDefault());
+
+        // Set-up for a fresh launch of a remote agent with any user-specified VM options.
+        String connectorName = "com.sun.jdi.CommandLineLaunch";
+        Map<String, String> argumentName2Value = new HashMap<>();
+        argumentName2Value.put("main", "jdk.internal.jshell.remote.RemoteAgent " + port);
+        argumentName2Value.put("options", remoteVMOptions);
+
+        boolean launchImmediately = true;
+        int traceFlags = 0;// VirtualMachine.TRACE_SENDS | VirtualMachine.TRACE_EVENTS;
+
+        // Launch.
+        jdiEnv.init(connectorName, argumentName2Value, launchImmediately, traceFlags);
+
+        if (jdiEnv.connection().isOpen() && jdiEnv.vm().canBeModified()) {
+            /*
+             * Connection opened on startup. Start event handler
+             * immediately, telling it (through arg 2) to stop on the
+             * VM start event.
+             */
+            handler = new JDIEventHandler(jdiEnv);
+        }
+    }
+
+    private final Object STOP_LOCK = new Object();
+    private boolean userCodeRunning = false;
+
+    /**
+     * Interrupt a running invoke.
+     */
+    @Override
+    public void stop() {
+        synchronized (STOP_LOCK) {
+            if (!userCodeRunning) {
+                return;
+            }
+
+            VirtualMachine vm = handler.env.vm();
+            vm.suspend();
+            try {
+                OUTER:
+                for (ThreadReference thread : vm.allThreads()) {
+                    // could also tag the thread (e.g. using name), to find it easier
+                    for (StackFrame frame : thread.frames()) {
+                        String remoteAgentName = "jdk.internal.jshell.remote.RemoteAgent";
+                        if (remoteAgentName.equals(frame.location().declaringType().name())
+                                && "commandLoop".equals(frame.location().method().name())) {
+                            ObjectReference thiz = frame.thisObject();
+                            if (((BooleanValue) thiz.getValue(thiz.referenceType().fieldByName("inClientCode"))).value()) {
+                                thiz.setValue(thiz.referenceType().fieldByName("expectingStop"), vm.mirrorOf(true));
+                                ObjectReference stopInstance = (ObjectReference) thiz.getValue(thiz.referenceType().fieldByName("stopException"));
+
+                                vm.resume();
+                                debug(DBG_GEN, "Attempting to stop the client code...\n");
+                                thread.stop(stopInstance);
+                                thiz.setValue(thiz.referenceType().fieldByName("expectingStop"), vm.mirrorOf(false));
+                            }
+
+                            break OUTER;
+                        }
+                    }
+                }
+            } catch (ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException ex) {
+                debug(DBG_GEN, "Exception on remote stop: %s\n", ex);
+            } finally {
+                vm.resume();
+            }
+        }
+    }
+
+    void debug(int flags, String format, Object... args) {
+        InternalDebugControl.debug(execEnv.state(), execEnv.userErr(), flags, format, args);
+    }
+
+    void debug(Exception ex, String where) {
+        InternalDebugControl.debug(execEnv.state(), execEnv.userErr(), ex, where);
+    }
+
+    private final class DemultiplexInput extends Thread {
+
+        private final DataInputStream delegate;
+        private final PipeInputStream command;
+        private final PrintStream out;
+        private final PrintStream err;
+
+        public DemultiplexInput(InputStream input,
+                PipeInputStream command,
+                PrintStream out,
+                PrintStream err) {
+            super("output reader");
+            this.delegate = new DataInputStream(input);
+            this.command = command;
+            this.out = out;
+            this.err = err;
+        }
+
+        public void run() {
+            try {
+                while (true) {
+                    int nameLen = delegate.read();
+                    if (nameLen == (-1))
+                        break;
+                    byte[] name = new byte[nameLen];
+                    DemultiplexInput.this.delegate.readFully(name);
+                    int dataLen = delegate.read();
+                    byte[] data = new byte[dataLen];
+                    DemultiplexInput.this.delegate.readFully(data);
+                    switch (new String(name, "UTF-8")) {
+                        case "err":
+                            err.write(data);
+                            break;
+                        case "out":
+                            out.write(data);
+                            break;
+                        case "command":
+                            for (byte b : data) {
+                                command.write(Byte.toUnsignedInt(b));
+                            }
+                            break;
+                    }
+                }
+            } catch (IOException ex) {
+                debug(ex, "Failed reading output");
+            } finally {
+                command.close();
+            }
+        }
+
+    }
+
+    public static final class PipeInputStream extends InputStream {
+        public static final int INITIAL_SIZE = 128;
+
+        private int[] buffer = new int[INITIAL_SIZE];
+        private int start;
+        private int end;
+        private boolean closed;
+
+        @Override
+        public synchronized int read() {
+            while (start == end) {
+                if (closed) {
+                    return -1;
+                }
+                try {
+                    wait();
+                } catch (InterruptedException ex) {
+                    //ignore
+                }
+            }
+            try {
+                return buffer[start];
+            } finally {
+                start = (start + 1) % buffer.length;
+            }
+        }
+
+        public synchronized void write(int b) {
+            if (closed)
+                throw new IllegalStateException("Already closed.");
+            int newEnd = (end + 1) % buffer.length;
+            if (newEnd == start) {
+                //overflow:
+                int[] newBuffer = new int[buffer.length * 2];
+                int rightPart = (end > start ? end : buffer.length) - start;
+                int leftPart = end > start ? 0 : start - 1;
+                System.arraycopy(buffer, start, newBuffer, 0, rightPart);
+                System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart);
+                buffer = newBuffer;
+                start = 0;
+                end = rightPart + leftPart;
+                newEnd = end + 1;
+            }
+            buffer[end] = b;
+            end = newEnd;
+            notifyAll();
+        }
+
+        @Override
+        public synchronized void close() {
+            closed = true;
+            notifyAll();
+        }
+
+    }
+}
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDINotConnectedException.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDINotConnectedException.java
similarity index 97%
rename from langtools/src/jdk.jshell/share/classes/jdk/jshell/JDINotConnectedException.java
rename to langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDINotConnectedException.java
index 2b9407c..ac22d09 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDINotConnectedException.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDINotConnectedException.java
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package jdk.jshell;
+package jdk.internal.jshell.jdi;
 
 /**
  * Internal exception when Java Debug Interface VirtualMacine is not connected.
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java
index 83d6419..25c1d9b 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java
@@ -24,6 +24,7 @@
  */
 
 package jdk.internal.jshell.remote;
+import jdk.jshell.spi.SPIResolutionException;
 import java.io.File;
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -111,10 +112,11 @@
                         out.flush();
                         break;
                     }
+                    String methodName = in.readUTF();
                     Method doitMethod;
                     try {
-                        this.getClass().getModule().addExports(RemoteResolutionException.class.getPackage().getName(), klass.getModule());
-                        doitMethod = klass.getDeclaredMethod(DOIT_METHOD_NAME, new Class<?>[0]);
+                        this.getClass().getModule().addExports(SPIResolutionException.class.getPackage().getName(), klass.getModule());
+                        doitMethod = klass.getDeclaredMethod(methodName, new Class<?>[0]);
                         doitMethod.setAccessible(true);
                         Object res;
                         try {
@@ -138,9 +140,9 @@
                     } catch (InvocationTargetException ex) {
                         Throwable cause = ex.getCause();
                         StackTraceElement[] elems = cause.getStackTrace();
-                        if (cause instanceof RemoteResolutionException) {
+                        if (cause instanceof SPIResolutionException) {
                             out.writeInt(RESULT_CORRALLED);
-                            out.writeInt(((RemoteResolutionException) cause).id);
+                            out.writeInt(((SPIResolutionException) cause).id());
                         } else {
                             out.writeInt(RESULT_EXCEPTION);
                             out.writeUTF(cause.getClass().getName());
@@ -254,27 +256,14 @@
         if (value == null) {
             return "null";
         } else if (value instanceof String) {
-            return "\"" + expunge((String)value) + "\"";
+            return "\"" + (String)value + "\"";
         } else if (value instanceof Character) {
             return "'" + value + "'";
         } else {
-            return expunge(value.toString());
+            return value.toString();
         }
     }
 
-    /**
-     * Expunge internal info from string
-     * @param s string to process
-     * @return string the display, JShell package and wrapper class names removed
-     */
-    static String expunge(String s) {
-        StringBuilder sb = new StringBuilder();
-        for (String comp : PREFIX_PATTERN.split(s)) {
-            sb.append(comp);
-        }
-        return sb.toString();
-    }
-
     private static final class MultiplexingOutputStream extends OutputStream {
 
         private static final int PACKET_SIZE = 127;
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteCodes.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteCodes.java
index e8deae7..ee71a63 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteCodes.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteCodes.java
@@ -25,8 +25,6 @@
 
 package jdk.internal.jshell.remote;
 
-import java.util.regex.Pattern;
-
 /**
  * Communication constants shared between the main process and the remote
  * execution process
@@ -46,13 +44,4 @@
     public static final int RESULT_EXCEPTION = 102;
     public static final int RESULT_CORRALLED = 103;
     public static final int RESULT_KILLED    = 104;
-
-    // String constants
-    public static final String REPL_PACKAGE = "REPL";
-    public static final String REPL_CLASS_PREFIX = "$JShell$";
-    public static final String DOIT_METHOD_NAME = "do_it$";
-    public static final Pattern PREFIX_PATTERN = Pattern.compile(
-            "(" + REPL_PACKAGE + "\\.)?" +
-            "(?<class>" + Pattern.quote(REPL_CLASS_PREFIX) +
-            "\\w+" + ")" + "[\\$\\.]?");
 }
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteResolutionException.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteResolutionException.java
deleted file mode 100644
index 8026979..0000000
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteResolutionException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.jshell.remote;
-
-/**
- * The exception thrown on the remote side upon executing a
- * {@link jdk.jshell.Snippet.Status#RECOVERABLE_DEFINED RECOVERABLE_DEFINED}
- * user method. This exception is not seen by the end user nor through the API.
- * @author Robert Field
- */
-@SuppressWarnings("serial")             // serialVersionUID intentionally omitted
-public class RemoteResolutionException extends RuntimeException {
-
-    final int id;
-
-    /**
-     * The throw of this exception is generated into the body of a
-     * {@link jdk.jshell.Snippet.Status#RECOVERABLE_DEFINED RECOVERABLE_DEFINED}
-     * method.
-     * @param id An internal identifier of the specific method
-     */
-    public RemoteResolutionException(int id) {
-        super("RemoteResolutionException");
-        this.id = id;
-    }
-}
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
index a7105cf..8334d78 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
@@ -25,8 +25,13 @@
 
 package jdk.internal.jshell.tool;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Stream;
+import static java.util.stream.Collectors.toList;
 
 /**
  * Parse command arguments, derived from StreamTokenizer by
@@ -49,13 +54,12 @@
     private String sval;
     private boolean isQuoted = false;
 
-    ArgTokenizer(String arg) {
-        this("", arg);
-    }
+    private final Map<String, Boolean> options = new HashMap<>();
+    private final List<String> badOptions = new ArrayList<>();
 
     ArgTokenizer(String prefix, String arg) {
         this.str = arg;
-        this.prefix = prefix;
+        this.prefix = prefix + " ";
         this.length = arg.length();
         quoteChar('"');
         quoteChar('\'');
@@ -65,17 +69,47 @@
         whitespaceChars(0xA0, 0xA0);
     }
 
+    /**
+     * Return the next non-option argument. Encountered options are stored.
+     *
+     * @return the token string, or null if there are no more tokens
+     */
     String next() {
-        nextToken();
+        while (true) {
+            nextToken();
+            if (sval != null && !isQuoted() && sval.startsWith("-")) {
+                foundOption(sval);
+            } else {
+                break;
+            }
+        }
         return sval;
     }
 
+    private void foundOption(String opt) {
+        if (options.containsKey(opt)) {
+            options.put(opt, true);
+            return;
+        }
+
+        List<Map.Entry<String,Boolean>> matches =
+                options.entrySet()
+                       .stream()
+                       .filter(e -> e.getKey().startsWith(opt))
+                       .collect(toList());
+        if (matches.size() == 1) {
+            matches.get(0).setValue(true);
+        } else {
+            badOptions.add(opt);
+        }
+    }
+
     String[] next(String... strings) {
         return next(Arrays.stream(strings));
     }
 
     String[] next(Stream<String> stream) {
-        nextToken();
+        next();
         if (sval == null) {
             return null;
         }
@@ -85,6 +119,68 @@
         return matches;
     }
 
+    /**
+     * Set the allowed options. Must be called before any options would be read
+     * and before calling any of the option functionality below.
+     */
+    void allowedOptions(String... opts) {
+        for (String opt : opts) {
+            options.put(opt, false);
+        }
+    }
+
+    /**
+     * Has the specified option been encountered.
+     *
+     * @param opt the option to check
+     * @return true if the option has been encountered
+     */
+    boolean hasOption(String opt) {
+        Boolean has = options.get(opt);
+        if (has == null) {
+            throw new InternalError("hasOption called before allowedOptions or on bad option");
+        }
+        return has;
+    }
+
+    /**
+     * Return the number of encountered options
+     *
+     * @return the option count
+     */
+    int optionCount() {
+        return (int) options.entrySet().stream()
+                .filter(e -> e.getValue())
+                .count();
+    }
+
+    /**
+     * Return the bad options encountered. Bad options are those that were not
+     * listed in the call to allowedOptions().
+     *
+     * @return as space-separated list the bad options encountered, or the empty
+     * string if none.
+     */
+    String badOptions() {
+        return String.join(" ", badOptions);
+    }
+
+    /**
+     * Consume the remainder of the input. This is useful to sure all options
+     * have been encountered and to check to unexpected additional non-option
+     * input.
+     *
+     * @return the string-separated concatenation of all remaining non-option
+     * arguments.
+     */
+    String remainder() {
+        List<String> rem = new ArrayList<>();
+        while (next() != null) {
+            rem.add(sval);
+        }
+        return String.join(" ", rem);
+    }
+
     String val() {
         return sval;
     }
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java
index 8b8c6dd..4f1cc57 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 
 package jdk.internal.jshell.tool;
 
-import jdk.jshell.SourceCodeAnalysis.CompletionInfo;
 import jdk.jshell.SourceCodeAnalysis.QualifiedNames;
 import jdk.jshell.SourceCodeAnalysis.Suggestion;
 
@@ -36,6 +35,7 @@
 import java.io.UncheckedIOException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -44,6 +44,9 @@
 import java.util.Objects;
 import java.util.Optional;
 import java.util.function.Supplier;
+import java.util.prefs.BackingStoreException;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import jdk.internal.jline.NoInterruptUnixTerminal;
 import jdk.internal.jline.Terminal;
@@ -54,10 +57,13 @@
 import jdk.internal.jline.console.KeyMap;
 import jdk.internal.jline.console.UserInterruptException;
 import jdk.internal.jline.console.completer.Completer;
+import jdk.internal.jline.extra.EditingHistory;
 import jdk.internal.jshell.tool.StopDetectingInputStream.State;
 
 class ConsoleIOContext extends IOContext {
 
+    private static final String HISTORY_LINE_PREFIX = "HISTORY_LINE_";
+
     final JShellTool repl;
     final StopDetectingInputStream input;
     final ConsoleReader in;
@@ -80,12 +86,18 @@
         in = new ConsoleReader(cmdin, cmdout, term);
         in.setExpandEvents(false);
         in.setHandleUserInterrupt(true);
-        in.setHistory(history = new EditingHistory(repl.prefs) {
-            @Override protected CompletionInfo analyzeCompletion(String input) {
-                return repl.analysis.analyzeCompletion(input);
+        List<String> persistenHistory = Stream.of(repl.prefs.keys())
+                                              .filter(key -> key.startsWith(HISTORY_LINE_PREFIX))
+                                              .sorted()
+                                              .map(key -> repl.prefs.get(key, null))
+                                              .collect(Collectors.toList());
+        in.setHistory(history = new EditingHistory(in, persistenHistory) {
+            @Override protected boolean isComplete(CharSequence input) {
+                return repl.analysis.analyzeCompletion(input.toString()).completeness.isComplete;
             }
         });
         in.setBellEnabled(true);
+        in.setCopyPasteDetection(true);
         in.addCompleter(new Completer() {
             private String lastTest;
             private int lastCursor;
@@ -150,8 +162,6 @@
             }
         });
         bind(DOCUMENTATION_SHORTCUT, (ActionListener) evt -> documentation(repl));
-        bind(CTRL_UP, (ActionListener) evt -> moveHistoryToSnippet(((EditingHistory) in.getHistory())::previousSnippet));
-        bind(CTRL_DOWN, (ActionListener) evt -> moveHistoryToSnippet(((EditingHistory) in.getHistory())::nextSnippet));
         for (FixComputer computer : FIX_COMPUTERS) {
             for (String shortcuts : SHORTCUT_FIXES) {
                 bind(shortcuts + computer.shortcut, (ActionListener) evt -> fixes(computer));
@@ -181,7 +191,24 @@
 
     @Override
     public void close() throws IOException {
-        history.save();
+        //save history:
+        try {
+            for (String key : repl.prefs.keys()) {
+                if (key.startsWith(HISTORY_LINE_PREFIX))
+                    repl.prefs.remove(key);
+            }
+            Collection<? extends String> savedHistory = history.save();
+            if (!savedHistory.isEmpty()) {
+                int len = (int) Math.ceil(Math.log10(savedHistory.size()+1));
+                String format = HISTORY_LINE_PREFIX + "%0" + len + "d";
+                int index = 0;
+                for (String historyLine : savedHistory) {
+                    repl.prefs.put(String.format(format, index++), historyLine);
+                }
+            }
+        } catch (BackingStoreException ex) {
+            throw new IllegalStateException(ex);
+        }
         in.shutdown();
         try {
             in.getTerminal().restore();
@@ -190,30 +217,6 @@
         }
     }
 
-    private void moveHistoryToSnippet(Supplier<Boolean> action) {
-        if (!action.get()) {
-            try {
-                in.beep();
-            } catch (IOException ex) {
-                throw new IllegalStateException(ex);
-            }
-        } else {
-            try {
-                //could use:
-                //in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1);
-                //but that would mean more re-writing on the screen, (and prints an additional
-                //empty line), so using setBuffer directly:
-                Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class);
-
-                setBuffer.setAccessible(true);
-                setBuffer.invoke(in, in.getHistory().current().toString());
-                in.flush();
-            } catch (ReflectiveOperationException | IOException ex) {
-                throw new IllegalStateException(ex);
-            }
-        }
-    }
-
     private void bind(String shortcut, Object action) {
         KeyMap km = in.getKeys();
         for (int i = 0; i < shortcut.length(); i++) {
@@ -227,8 +230,6 @@
     }
 
     private static final String DOCUMENTATION_SHORTCUT = "\033\133\132"; //Shift-TAB
-    private static final String CTRL_UP = "\033\133\061\073\065\101"; //Ctrl-UP
-    private static final String CTRL_DOWN = "\033\133\061\073\065\102"; //Ctrl-DOWN
     private static final String[] SHORTCUT_FIXES = {
         "\033\015", //Alt-Enter (Linux)
         "\033\133\061\067\176", //F6/Alt-F1 (Mac)
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/EditingHistory.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/EditingHistory.java
deleted file mode 100644
index d6ec9d5..0000000
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/EditingHistory.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.jshell.tool;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import jdk.internal.jline.console.history.History;
-import jdk.internal.jline.console.history.History.Entry;
-import jdk.internal.jline.console.history.MemoryHistory;
-import jdk.jshell.SourceCodeAnalysis.CompletionInfo;
-
-/*Public for tests (HistoryTest).
- */
-public abstract class EditingHistory implements History {
-
-    private final Preferences prefs;
-    private final History fullHistory;
-    private History currentDelegate;
-
-    protected EditingHistory(Preferences prefs) {
-        this.prefs = prefs;
-        this.fullHistory = new MemoryHistory();
-        this.currentDelegate = fullHistory;
-        load();
-    }
-
-    @Override
-    public int size() {
-        return currentDelegate.size();
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return currentDelegate.isEmpty();
-    }
-
-    @Override
-    public int index() {
-        return currentDelegate.index();
-    }
-
-    @Override
-    public void clear() {
-        if (currentDelegate != fullHistory)
-            throw new IllegalStateException("narrowed");
-        currentDelegate.clear();
-    }
-
-    @Override
-    public CharSequence get(int index) {
-        return currentDelegate.get(index);
-    }
-
-    @Override
-    public void add(CharSequence line) {
-        NarrowingHistoryLine currentLine = null;
-        int origIndex = fullHistory.index();
-        int fullSize;
-        try {
-            fullHistory.moveToEnd();
-            fullSize = fullHistory.index();
-            if (currentDelegate == fullHistory) {
-                if (origIndex < fullHistory.index()) {
-                    for (Entry entry : fullHistory) {
-                        if (!(entry.value() instanceof NarrowingHistoryLine))
-                            continue;
-                        int[] cluster = ((NarrowingHistoryLine) entry.value()).span;
-                        if (cluster[0] == origIndex && cluster[1] > cluster[0]) {
-                            currentDelegate = new MemoryHistory();
-                            for (int i = cluster[0]; i <= cluster[1]; i++) {
-                                currentDelegate.add(fullHistory.get(i));
-                            }
-                        }
-                    }
-                }
-            }
-            fullHistory.moveToEnd();
-            while (fullHistory.previous()) {
-                CharSequence c = fullHistory.current();
-                if (c instanceof NarrowingHistoryLine) {
-                    currentLine = (NarrowingHistoryLine) c;
-                    break;
-                }
-            }
-        } finally {
-            fullHistory.moveTo(origIndex);
-        }
-        if (currentLine == null || currentLine.span[1] != (-1)) {
-            line = currentLine = new NarrowingHistoryLine(line, fullSize);
-        }
-        StringBuilder complete = new StringBuilder();
-        for (int i = currentLine.span[0]; i < fullSize; i++) {
-            complete.append(fullHistory.get(i));
-        }
-        complete.append(line);
-        if (analyzeCompletion(complete.toString()).completeness.isComplete) {
-            currentLine.span[1] = fullSize; //TODO: +1?
-            currentDelegate = fullHistory;
-        }
-        fullHistory.add(line);
-    }
-
-    protected abstract CompletionInfo analyzeCompletion(String input);
-
-    @Override
-    public void set(int index, CharSequence item) {
-        if (currentDelegate != fullHistory)
-            throw new IllegalStateException("narrowed");
-        currentDelegate.set(index, item);
-    }
-
-    @Override
-    public CharSequence remove(int i) {
-        if (currentDelegate != fullHistory)
-            throw new IllegalStateException("narrowed");
-        return currentDelegate.remove(i);
-    }
-
-    @Override
-    public CharSequence removeFirst() {
-        if (currentDelegate != fullHistory)
-            throw new IllegalStateException("narrowed");
-        return currentDelegate.removeFirst();
-    }
-
-    @Override
-    public CharSequence removeLast() {
-        if (currentDelegate != fullHistory)
-            throw new IllegalStateException("narrowed");
-        return currentDelegate.removeLast();
-    }
-
-    @Override
-    public void replace(CharSequence item) {
-        if (currentDelegate != fullHistory)
-            throw new IllegalStateException("narrowed");
-        currentDelegate.replace(item);
-    }
-
-    @Override
-    public ListIterator<Entry> entries(int index) {
-        return currentDelegate.entries(index);
-    }
-
-    @Override
-    public ListIterator<Entry> entries() {
-        return currentDelegate.entries();
-    }
-
-    @Override
-    public Iterator<Entry> iterator() {
-        return currentDelegate.iterator();
-    }
-
-    @Override
-    public CharSequence current() {
-        return currentDelegate.current();
-    }
-
-    @Override
-    public boolean previous() {
-        return currentDelegate.previous();
-    }
-
-    @Override
-    public boolean next() {
-        return currentDelegate.next();
-    }
-
-    @Override
-    public boolean moveToFirst() {
-        return currentDelegate.moveToFirst();
-    }
-
-    @Override
-    public boolean moveToLast() {
-        return currentDelegate.moveToLast();
-    }
-
-    @Override
-    public boolean moveTo(int index) {
-        return currentDelegate.moveTo(index);
-    }
-
-    @Override
-    public void moveToEnd() {
-        currentDelegate.moveToEnd();
-    }
-
-    public boolean previousSnippet() {
-        for (int i = index() - 1; i >= 0; i--) {
-            if (get(i) instanceof NarrowingHistoryLine) {
-                moveTo(i);
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    public boolean nextSnippet() {
-        for (int i = index() + 1; i < size(); i++) {
-            if (get(i) instanceof NarrowingHistoryLine) {
-                moveTo(i);
-                return true;
-            }
-        }
-
-        if (index() < size()) {
-            moveToEnd();
-            return true;
-        }
-
-        return false;
-    }
-
-    private static final String HISTORY_LINE_PREFIX = "HISTORY_LINE_";
-    private static final String HISTORY_SNIPPET_START = "HISTORY_SNIPPET";
-
-    public final void load() {
-        try {
-            Set<Integer> snippetsStart = new HashSet<>();
-            for (String start : prefs.get(HISTORY_SNIPPET_START, "").split(";")) {
-                if (!start.isEmpty())
-                    snippetsStart.add(Integer.parseInt(start));
-            }
-            List<String> keys = Stream.of(prefs.keys()).sorted().collect(Collectors.toList());
-            NarrowingHistoryLine currentHistoryLine = null;
-            int currentLine = 0;
-            for (String key : keys) {
-                if (!key.startsWith(HISTORY_LINE_PREFIX))
-                    continue;
-                CharSequence line = prefs.get(key, "");
-                if (snippetsStart.contains(currentLine)) {
-                    class PersistentNarrowingHistoryLine extends NarrowingHistoryLine implements PersistentEntryMarker {
-                        public PersistentNarrowingHistoryLine(CharSequence delegate, int start) {
-                            super(delegate, start);
-                        }
-                    }
-                    line = currentHistoryLine = new PersistentNarrowingHistoryLine(line, currentLine);
-                } else {
-                    class PersistentLine implements CharSequence, PersistentEntryMarker {
-                        private final CharSequence delegate;
-                        public PersistentLine(CharSequence delegate) {
-                            this.delegate = delegate;
-                        }
-                        @Override public int length() {
-                            return delegate.length();
-                        }
-                        @Override public char charAt(int index) {
-                            return delegate.charAt(index);
-                        }
-                        @Override public CharSequence subSequence(int start, int end) {
-                            return delegate.subSequence(start, end);
-                        }
-                        @Override public String toString() {
-                            return delegate.toString();
-                        }
-                    }
-                    line = new PersistentLine(line);
-                }
-                if (currentHistoryLine != null)
-                    currentHistoryLine.span[1] = currentLine;
-                currentLine++;
-                fullHistory.add(line);
-            }
-            currentLine = 0;
-        } catch (BackingStoreException ex) {
-            throw new IllegalStateException(ex);
-        }
-    }
-
-    public void save() {
-        try {
-            for (String key : prefs.keys()) {
-                if (key.startsWith(HISTORY_LINE_PREFIX))
-                    prefs.remove(key);
-            }
-            Iterator<Entry> entries = fullHistory.iterator();
-            if (entries.hasNext()) {
-                int len = (int) Math.ceil(Math.log10(fullHistory.size()+1));
-                String format = HISTORY_LINE_PREFIX + "%0" + len + "d";
-                StringBuilder snippetStarts = new StringBuilder();
-                String snippetStartDelimiter = "";
-                while (entries.hasNext()) {
-                    Entry entry = entries.next();
-                    prefs.put(String.format(format, entry.index()), entry.value().toString());
-                    if (entry.value() instanceof NarrowingHistoryLine) {
-                        snippetStarts.append(snippetStartDelimiter);
-                        snippetStarts.append(entry.index());
-                        snippetStartDelimiter = ";";
-                    }
-                }
-                prefs.put(HISTORY_SNIPPET_START, snippetStarts.toString());
-            }
-        } catch (BackingStoreException ex) {
-            throw new IllegalStateException(ex);
-        }
-    }
-
-    public List<String> currentSessionEntries() {
-        List<String> result = new ArrayList<>();
-
-        for (Entry e : fullHistory) {
-            if (!(e.value() instanceof PersistentEntryMarker)) {
-                result.add(e.value().toString());
-            }
-        }
-
-        return result;
-    }
-
-    void fullHistoryReplace(String source) {
-        fullHistory.replace(source);
-    }
-
-    private class NarrowingHistoryLine implements CharSequence {
-        private final CharSequence delegate;
-        private final int[] span;
-
-        public NarrowingHistoryLine(CharSequence delegate, int start) {
-            this.delegate = delegate;
-            this.span = new int[] {start, -1};
-        }
-
-        @Override
-        public int length() {
-            return delegate.length();
-        }
-
-        @Override
-        public char charAt(int index) {
-            return delegate.charAt(index);
-        }
-
-        @Override
-        public CharSequence subSequence(int start, int end) {
-            return delegate.subSequence(start, end);
-        }
-
-        @Override
-        public String toString() {
-            return delegate.toString();
-        }
-
-    }
-
-    private interface PersistentEntryMarker {}
-}
-
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java
index 21ac481..eedceff 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java
@@ -30,9 +30,11 @@
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import static java.util.stream.Collectors.joining;
@@ -47,12 +49,24 @@
     // Patern for substituted fields within a customized format string
     private static final Pattern FIELD_PATTERN = Pattern.compile("\\{(.*?)\\}");
 
-    // Current mode
-    private Mode mode = new Mode("", false); // initial value placeholder during start-up
+    // Internal field name for truncation length
+    private static final String TRUNCATION_FIELD = "<truncation>";
 
-    // Mapping of mode names to mode modes
+    // For encoding to Properties String
+    private static final String RECORD_SEPARATOR = "\u241E";
+
+    // Current mode -- initial value is placeholder during start-up
+    private Mode mode = new Mode("");
+
+    // Retained current mode -- for checks
+    private Mode retainedCurrentMode = null;
+
+    // Mapping of mode name to mode
     private final Map<String, Mode> modeMap = new HashMap<>();
 
+    // Mapping of mode names to encoded retained mode
+    private final Map<String, String> retainedMap = new HashMap<>();
+
     // Mapping selector enum names to enums
     private final Map<String, Selector<?>> selectorMap = new HashMap<>();
 
@@ -103,14 +117,35 @@
         return new Setter(messageHandler, at).setFormat();
     }
 
-    public boolean setNewMode(MessageHandler messageHandler, ArgTokenizer at) {
-        return new Setter(messageHandler, at).setNewMode();
+    public boolean setTruncation(MessageHandler messageHandler, ArgTokenizer at) {
+        return new Setter(messageHandler, at).setTruncation();
+    }
+
+    public boolean setMode(MessageHandler messageHandler, ArgTokenizer at) {
+        return new Setter(messageHandler, at).setMode();
     }
 
     public boolean setPrompt(MessageHandler messageHandler, ArgTokenizer at) {
         return new Setter(messageHandler, at).setPrompt();
     }
 
+    public String retainFeedback(MessageHandler messageHandler, ArgTokenizer at) {
+        return new Setter(messageHandler, at).retainFeedback();
+    }
+
+    public String retainMode(MessageHandler messageHandler, ArgTokenizer at) {
+        return new Setter(messageHandler, at).retainMode();
+    }
+
+    public boolean restoreEncodedModes(MessageHandler messageHandler, String encoded) {
+        return new Setter(messageHandler, new ArgTokenizer("<init>", "")).restoreEncodedModes(encoded);
+    }
+
+    public void markModesReadOnly() {
+        modeMap.values().stream()
+                .forEach(m -> m.readOnly = true);
+    }
+
     {
         for (FormatCase e : EnumSet.allOf(FormatCase.class))
             selectorMap.put(e.name().toLowerCase(Locale.US), e);
@@ -135,11 +170,13 @@
         final String name;
 
         // Display command verification/information
-        final boolean commandFluff;
+        boolean commandFluff;
 
         // Event cases: class, method, expression, ...
         final Map<String, List<Setting>> cases;
 
+        boolean readOnly = false;
+
         String prompt = "\n-> ";
         String continuationPrompt = ">> ";
 
@@ -158,10 +195,9 @@
          * @param name
          * @param commandFluff True if should display command fluff messages
          */
-        Mode(String name, boolean commandFluff) {
+        Mode(String name) {
             this.name = name;
-            this.commandFluff = commandFluff;
-            cases = new HashMap<>();
+            this.cases = new HashMap<>();
             add("name",       new Setting(ALWAYS, "%1$s"));
             add("type",       new Setting(ALWAYS, "%2$s"));
             add("value",      new Setting(ALWAYS, "%3$s"));
@@ -181,20 +217,79 @@
          * Set up a copied mode.
          *
          * @param name
-         * @param commandFluff True if should display command fluff messages
          * @param m Mode to copy, or null for no fresh
          */
-        Mode(String name, boolean commandFluff, Mode m) {
+        Mode(String name, Mode m) {
             this.name = name;
-            this.commandFluff = commandFluff;
-            cases = new HashMap<>();
-
+            this.commandFluff = m.commandFluff;
+            this.prompt = m.prompt;
+            this.continuationPrompt = m.continuationPrompt;
+            this.cases = new HashMap<>();
             m.cases.entrySet().stream()
                     .forEach(fes -> fes.getValue()
                     .forEach(ing -> add(fes.getKey(), ing)));
 
-            this.prompt = m.prompt;
-            this.continuationPrompt = m.continuationPrompt;
+        }
+
+        /**
+         * Set up a mode reconstituted from a preferences string.
+         *
+         * @param it the encoded Mode broken into String chunks, may contain
+         * subsequent encoded modes
+         */
+        Mode(Iterator<String> it) {
+            this.name = it.next();
+            this.commandFluff = Boolean.parseBoolean(it.next());
+            this.prompt = it.next();
+            this.continuationPrompt = it.next();
+            cases = new HashMap<>();
+            String field;
+            while (!(field = it.next()).equals("***")) {
+                String open = it.next();
+                assert open.equals("(");
+                List<Setting> settings = new ArrayList<>();
+                String bits;
+                while (!(bits = it.next()).equals(")")) {
+                    String format = it.next();
+                    Setting ing = new Setting(Long.parseLong(bits), format);
+                    settings.add(ing);
+                }
+                cases.put(field, settings);
+            }
+        }
+
+        /**
+         * Set if this mode displays informative/confirmational messages on
+         * commands.
+         *
+         * @param fluff the value to set
+         */
+        void setCommandFluff(boolean fluff) {
+            commandFluff = fluff;
+        }
+
+        /**
+         * Encodes the mode into a String so it can be saved in Preferences.
+         *
+         * @return the string representation
+         */
+        String encode() {
+            List<String> el = new ArrayList<>();
+            el.add(name);
+            el.add(String.valueOf(commandFluff));
+            el.add(prompt);
+            el.add(continuationPrompt);
+            for (Entry<String, List<Setting>> es : cases.entrySet()) {
+                el.add(es.getKey());
+                el.add("(");
+                for (Setting ing : es.getValue()) {
+                    el.add(String.valueOf(ing.enumBits));
+                    el.add(ing.format);
+                }
+                el.add(")");
+            }
+            el.add("***");
+            return String.join(RECORD_SEPARATOR, el);
         }
 
         private boolean add(String field, Setting ing) {
@@ -251,13 +346,42 @@
             return sb.toString();
         }
 
+        // Compute the display output given full context and values
         String format(FormatCase fc, FormatAction fa, FormatWhen fw,
                     FormatResolve fr, FormatUnresolved fu, FormatErrors fe,
                     String name, String type, String value, String unresolved, List<String> errorLines) {
+            // Convert the context into a bit representation used as selectors for store field formats
             long bits = bits(fc, fa, fw, fr, fu, fe);
             String fname = name==null? "" : name;
             String ftype = type==null? "" : type;
-            String fvalue = value==null? "" : value;
+            // Compute the representation of value
+            String fvalue;
+            if (value==null) {
+                fvalue = "";
+            } else {
+                // Retrieve the truncation length
+                String truncField = format(TRUNCATION_FIELD, bits);
+                if (truncField.isEmpty()) {
+                    // No truncation set, use whole value
+                    fvalue = value;
+                } else {
+                    // Convert truncation length to int
+                    // this is safe since it has been tested before it is set
+                    int trunc = Integer.parseUnsignedInt(truncField);
+                    if (value.length() > trunc) {
+                        if (trunc <= 5) {
+                            // Very short truncations have no room for "..."
+                            fvalue = value.substring(0, trunc);
+                        } else {
+                            // Normal truncation, make total length equal truncation length
+                            fvalue = value.substring(0, trunc - 4) + " ...";
+                        }
+                    } else {
+                        // Within truncation length, use whole value
+                        fvalue = value;
+                    }
+                }
+            }
             String funresolved = unresolved==null? "" : unresolved;
             String errors = errorLines.stream()
                     .map(el -> String.format(
@@ -554,8 +678,12 @@
         // For /set prompt <mode> "<prompt>" "<continuation-prompt>"
         boolean setPrompt() {
             Mode m = nextMode();
-            String prompt = nextFormat();
-            String continuationPrompt = nextFormat();
+            if (valid && m.readOnly) {
+                errorat("jshell.err.not.valid.with.predefined.mode", m.name);
+                valid = false;
+            }
+            String prompt = valid ? nextFormat() : null;
+            String continuationPrompt = valid ? nextFormat() : null;
             if (valid) {
                 m.setPrompts(prompt, continuationPrompt);
             } else {
@@ -564,36 +692,71 @@
             return valid;
         }
 
-        // For /set newmode <new-mode> [command|quiet [<old-mode>]]
-        boolean setNewMode() {
-            String umode = at.next();
-            if (umode == null) {
-                errorat("jshell.err.feedback.expected.new.feedback.mode");
-                valid = false;
-            }
-            if (modeMap.containsKey(umode)) {
-                errorat("jshell.err.feedback.expected.mode.name", umode);
-                valid = false;
-            }
-            String[] fluffOpt = at.next("command", "quiet");
-            boolean fluff = fluffOpt == null || fluffOpt.length != 1 || "command".equals(fluffOpt[0]);
-            if (fluffOpt != null && fluffOpt.length != 1) {
-                errorat("jshell.err.feedback.command.quiet");
-                valid = false;
-            }
+        /**
+         * Set mode. Create, changed, or delete a feedback mode. For @{code /set
+         * mode <mode> [<old-mode>] [-command|-quiet|-delete]}.
+         *
+         * @return true if successful
+         */
+        boolean setMode() {
+            at.allowedOptions("-command", "-quiet", "-delete");
+            String umode = nextModeIdentifier();
             Mode om = null;
             String omode = at.next();
-            if (omode != null) {
+            if (valid && omode != null) {
                 om = toMode(omode);
             }
+            checkOptionsAndRemainingInput();
+            boolean commandOption = at.hasOption("-command");
+            boolean quietOption = at.hasOption("-quiet");
+            boolean deleteOption = at.hasOption("-delete");
+            // Only one (or zero) of the options can be used
+            if (valid && at.optionCount() > 1) {
+                errorat("jshell.err.conflicting.options");
+                valid = false;
+            }
             if (valid) {
-                Mode nm = (om != null)
-                        ? new Mode(umode, fluff, om)
-                        : new Mode(umode, fluff);
-                modeMap.put(umode, nm);
-                fluffmsg("jshell.msg.feedback.new.mode", nm.name);
-            } else {
-                fluffmsg("jshell.msg.see", "/help /set newmode");
+                Mode m = modeMap.get(umode);
+                if (m != null && m.readOnly) {
+                    // Cannot make changes to a the built-in modes
+                    errorat("jshell.err.not.valid.with.predefined.mode", m.name);
+                    valid = false;
+                } else if (deleteOption) {
+                    if (m == null) {
+                        // Cannot delete a mode that does not exist
+                        errorat("jshell.err.mode.unknown", umode);
+                        valid = false;
+                    } else if (mode.name.equals(m.name)) {
+                        // Cannot delete the current mode out from under us
+                        errorat("jshell.err.cannot.delete.current.mode", umode);
+                        valid = false;
+                    } else {
+                        // Remove the mode
+                        modeMap.remove(umode);
+                    }
+                } else {
+                    if (om != null || m == null) {
+                        // We are copying and existing mode and/or creating a
+                        // brand-new mode -- in either case create from scratch
+                        m = (om != null)
+                                ? new Mode(umode, om)
+                                : new Mode(umode);
+                        modeMap.put(umode, m);
+                        fluffmsg("jshell.msg.feedback.new.mode", m.name);
+                        // Set the current mode by name, in case we just smashed
+                        // the current mode
+                        if (umode.equals(mode.name)) {
+                            mode = modeMap.get(mode.name);
+                        }
+                    }
+                    if (commandOption || quietOption || om == null) {
+                        // set command fluff, if explicit, or wholly new
+                        m.setCommandFluff(!quietOption);
+                    }
+                }
+            }
+            if (!valid) {
+                fluffmsg("jshell.msg.see", "/help /set mode");
             }
             return valid;
         }
@@ -601,7 +764,7 @@
         // For /set feedback <mode>
         boolean setFeedback() {
             Mode m = nextMode();
-            if (valid && m != null) {
+            if (valid) {
                 mode = m;
                 fluffmsg("jshell.msg.feedback.mode", mode.name);
             } else {
@@ -614,12 +777,149 @@
         // For /set format <mode> "<format>" <selector>...
         boolean setFormat() {
             Mode m = nextMode();
-            String field = at.next();
-            if (field == null || at.isQuoted()) {
-                errorat("jshell.err.feedback.expected.field");
+            if (valid && m.readOnly) {
+                errorat("jshell.err.not.valid.with.predefined.mode", m.name);
                 valid = false;
             }
-            String format = valid? nextFormat() : null;
+            String field = valid
+                    ? toIdentifier(at.next(), "jshell.err.missing.field", "jshell.err.field.name")
+                    : null;
+            String format = valid ? nextFormat() : null;
+            return installFormat(m, field, format, "/help /set format");
+        }
+
+        // For /set truncation <mode> <length> <selector>...
+        boolean setTruncation() {
+            Mode m = nextMode();
+            if (valid && m.readOnly) {
+                errorat("jshell.err.not.valid.with.predefined.mode", m.name);
+                valid = false;
+            }
+            String length = at.next();
+            if (length == null) {
+                errorat("jshell.err.truncation.expected.length");
+                valid = false;
+            } else {
+                try {
+                    // Assure that integer format is correct
+                    Integer.parseUnsignedInt(length);
+                } catch (NumberFormatException ex) {
+                    errorat("jshell.err.truncation.length.not.integer", length);
+                    valid = false;
+                }
+            }
+            // install length into an internal format field
+            return installFormat(m, TRUNCATION_FIELD, length, "/help /set truncation");
+        }
+
+        String retainFeedback() {
+            String umode = at.next();
+            if (umode != null) {
+                toModeIdentifier(umode);
+                Mode m = valid ? toMode(umode) : null;
+                if (valid && !m.readOnly && !retainedMap.containsKey(m.name)) {
+                    errorat("jshell.err.retained.feedback.mode.must.be.retained.or.predefined");
+                    valid = false;
+                }
+                if (valid) {
+                    mode = m;
+                    retainedCurrentMode = m;
+                    fluffmsg("jshell.msg.feedback.mode", mode.name);
+                } else {
+                    fluffmsg("jshell.msg.see", "/help /retain feedback");
+                    return null;
+                }
+            }
+            return mode.name;
+        }
+
+        /**
+         * Retain (or delete from retention) a previously set mode.
+         *
+         * @return all retained modes encoded into a String
+         */
+        String retainMode() {
+            at.allowedOptions("-delete");
+            String umode = nextModeIdentifier();
+            // -delete is the only valid option, fail for anything else
+            checkOptionsAndRemainingInput();
+            boolean deleteOption = at.hasOption("-delete");
+            // Lookup the mode
+            Mode m;
+            if (!valid) {
+                m = null;
+                // Skip this stuff, we have failed already
+            } else if (deleteOption) {
+                // If delete, allow for deleting, from retention, a mode that
+                // has been locally deleted but is retained.
+                // Also require the full name.
+                m = modeMap.get(umode);
+                if (m == null && !retainedMap.containsKey(umode)) {
+                    errorat("jshell.err.mode.unknown", umode);
+                    valid = false;
+                }
+            } else {
+                // For retain do normal lookup and checking
+                m = toMode(umode);
+            }
+
+            // Built-in modes cannot be retained or deleted
+            if (valid && m != null && m.readOnly) {
+                errorat("jshell.err.not.valid.with.predefined.mode", umode);
+                valid = false;
+            }
+            if (valid) {
+                if (deleteOption) {
+                    if (mode.name.equals(umode)) {
+                        // Cannot delete the current mode out from under us
+                        errorat("jshell.err.cannot.delete.current.mode", umode);
+                        valid = false;
+                    } else if (retainedCurrentMode != null && retainedCurrentMode.name.equals(umode)) {
+                        // Cannot delete the retained mode or re-start has error
+                        errorat("jshell.err.cannot.delete.retained.mode", umode);
+                        valid = false;
+                    } else {
+                        // Delete the mode
+                        modeMap.remove(umode);
+                        retainedMap.remove(umode);
+                    }
+                } else {
+                    // Retain the current encoding
+                    retainedMap.put(m.name, m.encode());
+                }
+            }
+            if (valid) {
+                // Join all the retained encodings
+                return String.join(RECORD_SEPARATOR, retainedMap.values());
+            } else {
+                fluffmsg("jshell.msg.see", "/help /retain mode");
+                return null;
+            }
+        }
+
+        boolean restoreEncodedModes(String allEncoded) {
+            try {
+                // Iterate over each record in each encoded mode
+                String[] ms = allEncoded.split(RECORD_SEPARATOR);
+                Iterator<String> itr = Arrays.asList(ms).iterator();
+                while (itr.hasNext()) {
+                    // Reconstruct the encoded mode
+                    Mode m = new Mode(itr);
+                    modeMap.put(m.name, m);
+                    // Continue to retain it a new retains occur
+                    retainedMap.put(m.name, m.encode());
+                }
+                return true;
+            } catch (Throwable exc) {
+                // Catastrophic corruption -- clear map
+                errorat("jshell.err.retained.mode.failure", exc);
+                retainedMap.clear();
+                return false;
+            }
+        }
+
+        // install the format of a field under parsed selectors
+        boolean installFormat(Mode m, String field, String format, String help) {
             String slRaw;
             List<SelectorList> slList = new ArrayList<>();
             while (valid && (slRaw = at.next()) != null) {
@@ -629,8 +929,10 @@
             }
             if (valid) {
                 if (slList.isEmpty()) {
+                    // No selectors specified, then always the format
                     m.set(field, ALWAYS, format);
                 } else {
+                    // Set the format of the field for specified selector
                     slList.stream()
                             .forEach(sl -> m.set(field,
                                 sl.cases.getSet(), sl.actions.getSet(), sl.whens.getSet(),
@@ -638,19 +940,73 @@
                                 format));
                 }
             } else {
-                fluffmsg("jshell.msg.see", "/help /set format");
+                fluffmsg("jshell.msg.see", help);
             }
             return valid;
         }
 
+        void checkOptionsAndRemainingInput() {
+            if (!valid) {
+                return;
+            }
+            String junk = at.remainder();
+            if (!junk.isEmpty()) {
+                errorat("jshell.err.unexpected.at.end", junk);
+                valid = false;
+            } else {
+                String bad = at.badOptions();
+                if (!bad.isEmpty()) {
+                    errorat("jshell.err.unknown.option", bad);
+                    valid = false;
+                }
+            }
+        }
+
+        /**
+         * Check that the specified string is an identifier (Java identifier).
+         * If null display the missing error. If it is not an identifier,
+         * display the error.
+         *
+         * @param id the string to check, MUST be the most recently retrieved
+         * token from 'at'.
+         * @param missing the resource error to display if null
+         * @param err the resource error to display if not an identifier
+         * @return the identifier string, or null if null or not an identifier
+         */
+        String toIdentifier(String id, String missing, String err) {
+            if (id == null) {
+                errorat(missing);
+                valid = false;
+                return null;
+            }
+            if (at.isQuoted() ||
+                    !id.codePoints().allMatch(cp -> Character.isJavaIdentifierPart(cp))) {
+                errorat(err, id);
+                valid = false;
+                return null;
+            }
+            return id;
+        }
+
+        String toModeIdentifier(String id) {
+            return toIdentifier(id, "jshell.err.missing.mode", "jshell.err.mode.name");
+        }
+
+        String nextModeIdentifier() {
+            return toModeIdentifier(at.next());
+        }
+
         Mode nextMode() {
-            String umode = at.next();
+            String umode = nextModeIdentifier();
             return toMode(umode);
         }
 
         Mode toMode(String umode) {
+            if (!valid) {
+                return null;
+            }
             if (umode == null) {
-                errorat("jshell.err.feedback.expected.mode");
+                errorat("jshell.err.missing.mode");
                 valid = false;
                 return null;
             }
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
index b6cd1a3..1ae6c18 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
@@ -101,8 +101,13 @@
 import jdk.internal.jshell.tool.Feedback.FormatUnresolved;
 import jdk.internal.jshell.tool.Feedback.FormatWhen;
 import static java.util.stream.Collectors.toList;
-import static java.util.stream.Collectors.toMap;
 import static jdk.jshell.Snippet.SubKind.VAR_VALUE_SUBKIND;
+import static java.util.stream.Collectors.toMap;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_COMPA;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_DEP;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_FMGR;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
 
 /**
  * Command line REPL tool for Java using the JShell API.
@@ -112,8 +117,6 @@
 
     private static final String LINE_SEP = System.getProperty("line.separator");
     private static final Pattern LINEBREAK = Pattern.compile("\\R");
-    private static final Pattern HISTORY_ALL_START_FILENAME = Pattern.compile(
-            "((?<cmd>(all|history|start))(\\z|\\p{javaWhitespace}+))?(?<filename>.*)");
     private static final String RECORD_SEPARATOR = "\u241E";
     private static final String RB_NAME_PREFIX  = "jdk.internal.jshell.tool.resources";
     private static final String VERSION_RB_NAME = RB_NAME_PREFIX + ".version";
@@ -166,7 +169,7 @@
     private boolean regenerateOnDeath = true;
     private boolean live = false;
     private boolean feedbackInitialized = false;
-    private String initialMode = null;
+    private String commandLineFeedbackMode = null;
     private List<String> remoteVMOptions = new ArrayList<>();
 
     SourceCodeAnalysis analysis;
@@ -176,14 +179,17 @@
     private boolean debug = false;
     public boolean testPrompt = false;
     private String cmdlineClasspath = null;
-    private String cmdlineStartup = null;
+    private String startup = null;
     private String[] editor = null;
 
     // Commands and snippets which should be replayed
     private List<String> replayableHistory;
     private List<String> replayableHistoryPrevious;
 
-    static final String STARTUP_KEY = "STARTUP";
+    static final String STARTUP_KEY  = "STARTUP";
+    static final String EDITOR_KEY   = "EDITOR";
+    static final String FEEDBACK_KEY = "FEEDBACK";
+    static final String MODE_KEY     = "MODE";
     static final String REPLAY_RESTORE_KEY = "REPLAY_RESTORE";
 
     static final String DEFAULT_STARTUP =
@@ -454,6 +460,22 @@
     }
 
     private void start(IOContext in, List<String> loadList) {
+        // If startup hasn't been set by command line, set from retained/default
+        if (startup == null) {
+            startup = prefs.get(STARTUP_KEY, null);
+            if (startup == null) {
+                startup = DEFAULT_STARTUP;
+            }
+        }
+
+        // Read retained editor setting (if any)
+        String editorString = prefs.get(EDITOR_KEY, "");
+        if (editorString == null || editorString.isEmpty()) {
+            editor = null;
+        } else {
+            editor = editorString.split(RECORD_SEPARATOR);
+        }
+
         resetState(); // Initialize
 
         // Read replay history from last jshell session into previous history
@@ -519,37 +541,37 @@
                         return null;
                     case "-feedback":
                         if (ai.hasNext()) {
-                            initialMode = ai.next();
+                            commandLineFeedbackMode = ai.next();
                         } else {
                             startmsg("jshell.err.opt.feedback.arg");
                             return null;
                         }
                         break;
                     case "-q":
-                        initialMode = "concise";
+                        commandLineFeedbackMode = "concise";
                         break;
                     case "-qq":
-                        initialMode = "silent";
+                        commandLineFeedbackMode = "silent";
                         break;
                     case "-v":
-                        initialMode = "verbose";
+                        commandLineFeedbackMode = "verbose";
                         break;
                     case "-startup":
-                        if (cmdlineStartup != null) {
+                        if (startup != null) {
                             startmsg("jshell.err.opt.startup.conflict");
                             return null;
                         }
-                        cmdlineStartup = readFile(ai.hasNext()? ai.next() : null, "'-startup'");
-                        if (cmdlineStartup == null) {
+                        startup = readFile(ai.hasNext()? ai.next() : null, "'-startup'");
+                        if (startup == null) {
                             return null;
                         }
                         break;
                     case "-nostartup":
-                        if (cmdlineStartup != null && !cmdlineStartup.isEmpty()) {
+                        if (startup != null && !startup.isEmpty()) {
                             startmsg("jshell.err.opt.startup.conflict");
                             return null;
                         }
-                        cmdlineStartup = "";
+                        startup = "";
                         break;
                     default:
                         if (arg.startsWith("-R")) {
@@ -571,6 +593,27 @@
         cmdout.print(getResourceString("help.usage"));
     }
 
+    /**
+     * Message handler to use during initial start-up.
+     */
+    private class InitMessageHandler implements MessageHandler {
+
+        @Override
+        public void fluff(String format, Object... args) {
+            //ignore
+        }
+
+        @Override
+        public void fluffmsg(String messageKey, Object... args) {
+            //ignore
+        }
+
+        @Override
+        public void errormsg(String messageKey, Object... args) {
+            startmsg(messageKey, args);
+        }
+    }
+
     private void resetState() {
         closeState();
 
@@ -604,53 +647,58 @@
         analysis = state.sourceCodeAnalysis();
         live = true;
         if (!feedbackInitialized) {
-            startUpRun(getResourceString("startup.feedback"));
+            // One time per run feedback initialization
             feedbackInitialized = true;
+            initFeedback();
         }
 
         if (cmdlineClasspath != null) {
             state.addToClasspath(cmdlineClasspath);
         }
 
-        String start;
-        if (cmdlineStartup == null) {
-            start = prefs.get(STARTUP_KEY, "<nada>");
-            if (start.equals("<nada>")) {
-                start = DEFAULT_STARTUP;
-                prefs.put(STARTUP_KEY, DEFAULT_STARTUP);
-            }
-        } else {
-            start = cmdlineStartup;
-        }
-        startUpRun(start);
-        if (initialMode != null) {
-            MessageHandler mh = new MessageHandler() {
-                @Override
-                public void fluff(String format, Object... args) {
-                }
-
-                @Override
-                public void fluffmsg(String messageKey, Object... args) {
-                }
-
-                @Override
-                public void errormsg(String messageKey, Object... args) {
-                    startmsg(messageKey, args);
-                }
-            };
-            if (!feedback.setFeedback(mh, new ArgTokenizer("-feedback ", initialMode))) {
-                regenerateOnDeath = false;
-            }
-            initialMode = null;
-        }
+        startUpRun(startup);
         currentNameSpace = mainNamespace;
     }
+
+    //where -- one-time per run initialization of feedback modes
+    private void initFeedback() {
+        // No fluff, no prefix, for init failures
+        MessageHandler initmh = new InitMessageHandler();
+        // Execute the feedback initialization code in the resource file
+        startUpRun(getResourceString("startup.feedback"));
+        // These predefined modes are read-only
+        feedback.markModesReadOnly();
+        // Restore user defined modes retained on previous run with /retain mode
+        String encoded = prefs.get(MODE_KEY, null);
+        if (encoded != null && !encoded.isEmpty()) {
+            if (!feedback.restoreEncodedModes(initmh, encoded)) {
+                // Catastrophic corruption -- remove the retained modes
+                prefs.remove(MODE_KEY);
+            }
+        }
+        if (commandLineFeedbackMode != null) {
+            // The feedback mode to use was specified on the command line, use it
+            if (!feedback.setFeedback(initmh, new ArgTokenizer("-feedback", commandLineFeedbackMode))) {
+                regenerateOnDeath = false;
+            }
+            commandLineFeedbackMode = null;
+        } else {
+            String fb = prefs.get(FEEDBACK_KEY, null);
+            if (fb != null) {
+                // Restore the feedback mode to use that was retained
+                // on a previous run with /retain feedback
+                feedback.retainFeedback(initmh, new ArgTokenizer("/retain feedback", fb));
+            }
+        }
+    }
+
     //where
     private void startUpRun(String start) {
         try (IOContext suin = new FileScannerIOContext(new StringReader(start))) {
             run(suin);
         } catch (Exception ex) {
             hardmsg("jshell.err.startup.unexpected.exception", ex);
+            ex.printStackTrace(cmdout);
         }
     }
 
@@ -879,8 +927,8 @@
     }
 
     private static final CompletionProvider EMPTY_COMPLETION_PROVIDER = new FixedCompletionProvider();
-    private static final CompletionProvider KEYWORD_COMPLETION_PROVIDER = new FixedCompletionProvider("all ", "start ", "history ");
-    private static final CompletionProvider RELOAD_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("restore", "quiet");
+    private static final CompletionProvider KEYWORD_COMPLETION_PROVIDER = new FixedCompletionProvider("-all ", "-start ", "-history ");
+    private static final CompletionProvider RELOAD_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("-restore", "-quiet");
     private static final CompletionProvider FILE_COMPLETION_PROVIDER = fileCompletions(p -> true);
     private final Map<String, Command> commands = new LinkedHashMap<>();
     private void registerCommand(Command cmd) {
@@ -917,11 +965,10 @@
                                     p.getFileName().toString().endsWith(".jar"));
     }
 
-    private CompletionProvider editCompletion() {
+    private CompletionProvider snippetCompletion(Supplier<List<? extends Snippet>> snippetsSupplier) {
         return (prefix, cursor, anchor) -> {
             anchor[0] = 0;
-            return state.snippets()
-                        .stream()
+            return snippetsSupplier.get()                        .stream()
                         .flatMap(k -> (k instanceof DeclarationSnippet)
                                 ? Stream.of(String.valueOf(k.id()), ((DeclarationSnippet) k).name())
                                 : Stream.of(String.valueOf(k.id())))
@@ -931,11 +978,11 @@
         };
     }
 
-    private CompletionProvider editKeywordCompletion() {
+    private CompletionProvider snippetKeywordCompletion(Supplier<List<? extends Snippet>> snippetsSupplier) {
         return (code, cursor, anchor) -> {
             List<Suggestion> result = new ArrayList<>();
             result.addAll(KEYWORD_COMPLETION_PROVIDER.completionSuggestions(code, cursor, anchor));
-            result.addAll(editCompletion().completionSuggestions(code, cursor, anchor));
+            result.addAll(snippetCompletion(snippetsSupplier).completionSuggestions(code, cursor, anchor));
             return result;
         };
     }
@@ -963,18 +1010,52 @@
         };
     }
 
+    // Snippet lists
+
+    List<Snippet> allSnippets() {
+        return state.snippets();
+    }
+
+    List<PersistentSnippet> dropableSnippets() {
+        return state.snippets().stream()
+                .filter(sn -> state.status(sn).isActive && sn instanceof PersistentSnippet)
+                .map(sn -> (PersistentSnippet) sn)
+                .collect(toList());
+    }
+
+    List<VarSnippet> allVarSnippets() {
+        return state.snippets().stream()
+                .filter(sn -> sn.kind() == Snippet.Kind.VAR)
+                .map(sn -> (VarSnippet) sn)
+                .collect(toList());
+    }
+
+    List<MethodSnippet> allMethodSnippets() {
+        return state.snippets().stream()
+                .filter(sn -> sn.kind() == Snippet.Kind.METHOD)
+                .map(sn -> (MethodSnippet) sn)
+                .collect(toList());
+    }
+
+    List<TypeDeclSnippet> allTypeSnippets() {
+        return state.snippets().stream()
+                .filter(sn -> sn.kind() == Snippet.Kind.TYPE_DECL)
+                .map(sn -> (TypeDeclSnippet) sn)
+                .collect(toList());
+    }
+
     // Table of commands -- with command forms, argument kinds, helpKey message, implementation, ...
 
     {
         registerCommand(new Command("/list",
                 arg -> cmdList(arg),
-                editKeywordCompletion()));
+                snippetKeywordCompletion(this::allSnippets)));
         registerCommand(new Command("/edit",
                 arg -> cmdEdit(arg),
-                editCompletion()));
+                snippetCompletion(this::allSnippets)));
         registerCommand(new Command("/drop",
                 arg -> cmdDrop(arg),
-                editCompletion(),
+                snippetCompletion(this::dropableSnippets),
                 CommandKind.REPLAY));
         registerCommand(new Command("/save",
                 arg -> cmdSave(arg),
@@ -983,14 +1064,14 @@
                 arg -> cmdOpen(arg),
                 FILE_COMPLETION_PROVIDER));
         registerCommand(new Command("/vars",
-                arg -> cmdVars(),
-                EMPTY_COMPLETION_PROVIDER));
+                arg -> cmdVars(arg),
+                snippetKeywordCompletion(this::allVarSnippets)));
         registerCommand(new Command("/methods",
-                arg -> cmdMethods(),
-                EMPTY_COMPLETION_PROVIDER));
-        registerCommand(new Command("/classes",
-                arg -> cmdClasses(),
-                EMPTY_COMPLETION_PROVIDER));
+                arg -> cmdMethods(arg),
+                snippetKeywordCompletion(this::allMethodSnippets)));
+        registerCommand(new Command("/types",
+                arg -> cmdTypes(arg),
+                snippetKeywordCompletion(this::allTypeSnippets)));
         registerCommand(new Command("/imports",
                 arg -> cmdImports(),
                 EMPTY_COMPLETION_PROVIDER));
@@ -1019,7 +1100,10 @@
                 EMPTY_COMPLETION_PROVIDER));
         registerCommand(new Command("/set",
                 arg -> cmdSet(arg),
-                new FixedCompletionProvider("format", "feedback", "prompt", "newmode", "start", "editor")));
+                new FixedCompletionProvider(SET_SUBCOMMANDS)));
+        registerCommand(new Command("/retain",
+                arg -> cmdRetain(arg),
+                new FixedCompletionProvider(RETAIN_SUBCOMMANDS)));
         registerCommand(new Command("/?",
                 "help.quest",
                 arg -> cmdHelp(arg),
@@ -1094,79 +1178,116 @@
     // --- Command implementations ---
 
     private static final String[] SET_SUBCOMMANDS = new String[]{
-        "format", "feedback", "newmode", "prompt", "editor", "start"};
+        "format", "truncation", "feedback", "mode", "prompt", "editor", "start"};
+
+    private static final String[] RETAIN_SUBCOMMANDS = new String[]{
+        "feedback", "mode", "editor", "start"};
 
     final boolean cmdSet(String arg) {
-        ArgTokenizer at = new ArgTokenizer("/set ", arg.trim());
-        String which = setSubCommand(at);
+        String cmd = "/set";
+        ArgTokenizer at = new ArgTokenizer(cmd, arg.trim());
+        String which = subCommand(cmd, at, SET_SUBCOMMANDS);
         if (which == null) {
             return false;
         }
         switch (which) {
             case "format":
                 return feedback.setFormat(this, at);
+            case "truncation":
+                return feedback.setTruncation(this, at);
             case "feedback":
                 return feedback.setFeedback(this, at);
-            case "newmode":
-                return feedback.setNewMode(this, at);
+            case "mode":
+                return feedback.setMode(this, at);
             case "prompt":
                 return feedback.setPrompt(this, at);
-            case "editor": {
-                String prog = at.next();
-                if (prog == null) {
-                    errormsg("jshell.err.set.editor.arg");
-                    return false;
-                } else {
-                    List<String> ed = new ArrayList<>();
-                    ed.add(prog);
-                    String n;
-                    while ((n = at.next()) != null) {
-                        ed.add(n);
-                    }
-                    editor = ed.toArray(new String[ed.size()]);
-                    fluffmsg("jshell.msg.set.editor.set", prog);
-                    return true;
-                }
-            }
-            case "start": {
-                String init = readFile(at.next(), "/set start");
-                if (init == null) {
-                    return false;
-                } else {
-                    prefs.put(STARTUP_KEY, init);
-                    return true;
-                }
-            }
+            case "editor":
+                return setEditor(at, true);
+            case "start":
+                return setStart(cmd, at, true);
             default:
-                errormsg("jshell.err.arg", "/set", at.val());
+                errormsg("jshell.err.arg", cmd, at.val());
                 return false;
         }
     }
 
-    boolean printSetHelp(ArgTokenizer at) {
-        String which = setSubCommand(at);
+    final boolean cmdRetain(String arg) {
+        String cmd = "/retain";
+        ArgTokenizer at = new ArgTokenizer(cmd, arg.trim());
+        String which = subCommand(cmd, at, RETAIN_SUBCOMMANDS);
         if (which == null) {
             return false;
         }
-        hardrb("help.set." + which);
+        switch (which) {
+            case "feedback": {
+                String fb = feedback.retainFeedback(this, at);
+                if (fb != null) {
+                    // If a feedback mode has been set now, or in the past, retain it
+                    prefs.put(FEEDBACK_KEY, fb);
+                    return true;
+                }
+                return false;
+            }
+            case "mode":
+                String retained = feedback.retainMode(this, at);
+                if (retained != null) {
+                    // Retain this mode and all previously retained modes
+                    prefs.put(MODE_KEY, retained);
+                    return true;
+                }
+                return false;
+            case "editor":
+                if (!setEditor(at, false)) {
+                    return false;
+                }
+                // retain editor setting
+                prefs.put(EDITOR_KEY, (editor == null)
+                        ? ""
+                        : String.join(RECORD_SEPARATOR, editor));
+                return true;
+            case "start": {
+                if (!setStart(cmd, at, false)) {
+                    return false;
+                }
+                // retain startup setting
+                prefs.put(STARTUP_KEY, startup);
+                return true;
+            }
+            default:
+                errormsg("jshell.err.arg", cmd, at.val());
+                return false;
+        }
+    }
+
+    // Print the help doc for the specified sub-command
+    boolean printSubCommandHelp(String cmd, ArgTokenizer at, String helpPrefix, String[] subs) {
+        String which = subCommand(cmd, at, subs);
+        if (which == null) {
+            return false;
+        }
+        hardrb(helpPrefix + which);
         return true;
     }
 
-    String setSubCommand(ArgTokenizer at) {
-        String[] matches = at.next(SET_SUBCOMMANDS);
+    // Find which, if any, sub-command matches
+    String subCommand(String cmd, ArgTokenizer at, String[] subs) {
+        String[] matches = at.next(subs);
         if (matches == null) {
-            errormsg("jshell.err.set.arg");
+            // No sub-command was given
+            errormsg("jshell.err.sub.arg", cmd);
             return null;
         }
         if (matches.length == 0) {
-            errormsg("jshell.err.arg", "/set", at.val());
-            fluffmsg("jshell.msg.use.one.of", Arrays.stream(SET_SUBCOMMANDS)
+            // There are no matching sub-commands
+            errormsg("jshell.err.arg", cmd, at.val());
+            fluffmsg("jshell.msg.use.one.of", Arrays.stream(subs)
                     .collect(Collectors.joining(", "))
             );
             return null;
         }
         if (matches.length > 1) {
-            errormsg("jshell.err.set.ambiguous", at.val());
+            // More than one sub-command matches the initial characters provided
+            errormsg("jshell.err.sub.ambiguous", cmd, at.val());
             fluffmsg("jshell.msg.use.one.of", Arrays.stream(matches)
                     .collect(Collectors.joining(", "))
             );
@@ -1175,6 +1296,63 @@
         return matches[0];
     }
 
+    // The sub-command:  /set editor <editor-command-line>>
+    boolean setEditor(ArgTokenizer at, boolean argsRequired) {
+        at.allowedOptions("-default");
+        String prog = at.next();
+        List<String> ed = new ArrayList<>();
+        while (at.val() != null) {
+            ed.add(at.val());
+            at.nextToken();
+        }
+        if (!checkOptionsAndRemainingInput(at)) {
+            return false;
+        }
+        boolean defaultOption = at.hasOption("-default");
+        if (prog != null) {
+            if (defaultOption) {
+                errormsg("jshell.err.default.option.or.program", at.whole());
+                return false;
+            }
+            editor = ed.toArray(new String[ed.size()]);
+            fluffmsg("jshell.msg.set.editor.set", prog);
+        } else if (defaultOption) {
+            editor = null;
+        } else if (argsRequired) {
+            errormsg("jshell.err.set.editor.arg");
+            return false;
+        }
+        return true;
+    }
+
+    // The sub-command:  /set start <start-file>
+    boolean setStart(String cmd, ArgTokenizer at, boolean argsRequired) {
+        at.allowedOptions("-default", "-none");
+        String fn = at.next();
+        if (!checkOptionsAndRemainingInput(at)) {
+            return false;
+        }
+        int argCount = at.optionCount() + ((fn != null) ? 1 : 0);
+        if (argCount > 1 || argsRequired && argCount == 0) {
+            errormsg("jshell.err.option.or.filename", at.whole());
+            return false;
+        }
+        if (fn != null) {
+            String init = readFile(fn, cmd + " start");
+            if (init == null) {
+                return false;
+            } else {
+                startup = init;
+                return true;
+            }
+        } else if (at.hasOption("-default")) {
+            startup = DEFAULT_STARTUP;
+        } else if (at.hasOption("-none")) {
+            startup = "";
+        }
+        return true;
+    }
+
     boolean cmdClasspath(String arg) {
         if (arg.isEmpty()) {
             errormsg("jshell.err.classpath.arg");
@@ -1189,7 +1367,7 @@
     boolean cmdDebug(String arg) {
         if (arg.isEmpty()) {
             debug = !debug;
-            InternalDebugControl.setDebugFlags(state, debug ? InternalDebugControl.DBG_GEN : 0);
+            InternalDebugControl.setDebugFlags(state, debug ? DBG_GEN : 0);
             fluff("Debugging %s", debug ? "on" : "off");
         } else {
             int flags = 0;
@@ -1205,23 +1383,23 @@
                         fluff("REPL tool debugging on");
                         break;
                     case 'g':
-                        flags |= InternalDebugControl.DBG_GEN;
+                        flags |= DBG_GEN;
                         fluff("General debugging on");
                         break;
                     case 'f':
-                        flags |= InternalDebugControl.DBG_FMGR;
+                        flags |= DBG_FMGR;
                         fluff("File manager debugging on");
                         break;
                     case 'c':
-                        flags |= InternalDebugControl.DBG_COMPA;
+                        flags |= DBG_COMPA;
                         fluff("Completion analysis debugging on");
                         break;
                     case 'd':
-                        flags |= InternalDebugControl.DBG_DEP;
+                        flags |= DBG_DEP;
                         fluff("Dependency debugging on");
                         break;
                     case 'e':
-                        flags |= InternalDebugControl.DBG_EVNT;
+                        flags |= DBG_EVNT;
                         fluff("Event debugging on");
                         break;
                     default:
@@ -1259,7 +1437,7 @@
     }
 
     boolean cmdHelp(String arg) {
-        ArgTokenizer at = new ArgTokenizer(arg);
+        ArgTokenizer at = new ArgTokenizer("/help", arg);
         String subject = at.next();
         if (subject != null) {
             Command[] matches = commands.values().stream()
@@ -1267,9 +1445,16 @@
                     .toArray(size -> new Command[size]);
             at.mark();
             String sub = at.next();
-            if (sub != null && matches.length == 1 && matches[0].command.equals("/set")) {
-                at.rewind();
-                return printSetHelp(at);
+            if (sub != null && matches.length == 1) {
+                String cmd = matches[0].command;
+                switch (cmd) {
+                    case "/set":
+                        at.rewind();
+                        return printSubCommandHelp(cmd, at, "help.set.", SET_SUBCOMMANDS);
+                    case "/retain":
+                        at.rewind();
+                        return printSubCommandHelp(cmd, at, "help.retain.", RETAIN_SUBCOMMANDS);
+                }
             }
             if (matches.length > 0) {
                 for (Command c : matches) {
@@ -1310,7 +1495,7 @@
     /**
      * Avoid parameterized varargs possible heap pollution warning.
      */
-    private interface SnippetPredicate extends Predicate<Snippet> { }
+    private interface SnippetPredicate<T extends Snippet> extends Predicate<T> { }
 
     /**
      * Apply filters to a stream until one that is non-empty is found.
@@ -1320,10 +1505,11 @@
      * @param filters Filters to attempt
      * @return The non-empty filtered Stream, or null
      */
-    private static Stream<Snippet> nonEmptyStream(Supplier<Stream<Snippet>> supplier,
-            SnippetPredicate... filters) {
-        for (SnippetPredicate filt : filters) {
-            Iterator<Snippet> iterator = supplier.get().filter(filt).iterator();
+    @SafeVarargs
+    private static <T extends Snippet> Stream<T> nonEmptyStream(Supplier<Stream<T>> supplier,
+            SnippetPredicate<T>... filters) {
+        for (SnippetPredicate<T> filt : filters) {
+            Iterator<T> iterator = supplier.get().filter(filt).iterator();
             if (iterator.hasNext()) {
                 return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false);
             }
@@ -1349,76 +1535,139 @@
     }
 
     /**
-     * Convert a user argument to a Stream of snippets referenced by that argument
-     * (or lack of argument).
+     * Convert user arguments to a Stream of snippets referenced by those
+     * arguments (or lack of arguments).
      *
-     * @param arg The user's argument to the command, maybe be the empty string
-     * @return a Stream of referenced snippets or null if no matches to specific arg
+     * @param snippets the base list of possible snippets
+     * @param defFilter the filter to apply to the arguments if no argument
+     * @param rawargs the user's argument to the command, maybe be the empty
+     * string
+     * @return a Stream of referenced snippets or null if no matches are found
      */
-    private Stream<Snippet> argToSnippets(String arg, boolean allowAll) {
-        List<Snippet> snippets = state.snippets();
-        if (allowAll && arg.equals("all")) {
+    private <T extends Snippet> Stream<T> argsOptionsToSnippets(List<T> snippets,
+            Predicate<Snippet> defFilter, String rawargs, String cmd) {
+        ArgTokenizer at = new ArgTokenizer(cmd, rawargs.trim());
+        at.allowedOptions("-all", "-start");
+        List<String> args = new ArrayList<>();
+        String s;
+        while ((s = at.next()) != null) {
+            args.add(s);
+        }
+        if (!checkOptionsAndRemainingInput(at)) {
+            return null;
+        }
+        if (at.optionCount() > 0 && args.size() > 0) {
+            errormsg("jshell.err.may.not.specify.options.and.snippets", at.whole());
+            return null;
+        }
+        if (at.optionCount() > 1) {
+            errormsg("jshell.err.conflicting.options", at.whole());
+            return null;
+        }
+        if (at.hasOption("-all")) {
             // all snippets including start-up, failed, and overwritten
             return snippets.stream();
-        } else if (allowAll && arg.equals("start")) {
+        }
+        if (at.hasOption("-start")) {
             // start-up snippets
             return snippets.stream()
                     .filter(this::inStartUp);
-        } else if (arg.isEmpty()) {
+        }
+        if (args.isEmpty()) {
             // Default is all active user snippets
             return snippets.stream()
-                    .filter(this::mainActive);
-        } else {
-            Stream<Snippet> result =
-                    nonEmptyStream(
-                            () -> snippets.stream(),
-                            // look for active user declarations matching the name
-                            sn -> isActive(sn) && matchingDeclaration(sn, arg),
-                            // else, look for any declarations matching the name
-                            sn -> matchingDeclaration(sn, arg),
-                            // else, look for an id of this name
-                            sn -> sn.id().equals(arg)
-                    );
-            return result;
+                    .filter(defFilter);
         }
+        return argsToSnippets(snippets, args);
     }
 
-    private boolean cmdDrop(String arg) {
-        if (arg.isEmpty()) {
+    /**
+     * Convert user arguments to a Stream of snippets referenced by those
+     * arguments.
+     *
+     * @param snippets the base list of possible snippets
+     * @param args the user's argument to the command, maybe be the empty list
+     * @return a Stream of referenced snippets or null if no matches to specific
+     * arg
+     */
+    private <T extends Snippet> Stream<T> argsToSnippets(List<T> snippets,
+            List<String> args) {
+        Stream<T> result = null;
+        for (String arg : args) {
+            // Find the best match
+            Stream<T> st = layeredSnippetSearch(snippets, arg);
+            if (st == null) {
+                Stream<Snippet> est = layeredSnippetSearch(state.snippets(), arg);
+                if (est == null) {
+                    errormsg("jshell.err.no.such.snippets", arg);
+                } else {
+                    errormsg("jshell.err.the.snippet.cannot.be.used.with.this.command",
+                            arg, est.findFirst().get().source());
+                }
+                return null;
+            }
+            if (result == null) {
+                result = st;
+            } else {
+                result = Stream.concat(result, st);
+            }
+        }
+        return result;
+    }
+
+    private <T extends Snippet> Stream<T> layeredSnippetSearch(List<T> snippets, String arg) {
+        return nonEmptyStream(
+                // the stream supplier
+                () -> snippets.stream(),
+                // look for active user declarations matching the name
+                sn -> isActive(sn) && matchingDeclaration(sn, arg),
+                // else, look for any declarations matching the name
+                sn -> matchingDeclaration(sn, arg),
+                // else, look for an id of this name
+                sn -> sn.id().equals(arg)
+        );
+    }
+
+    private boolean cmdDrop(String rawargs) {
+        ArgTokenizer at = new ArgTokenizer("/drop", rawargs.trim());
+        at.allowedOptions();
+        List<String> args = new ArrayList<>();
+        String s;
+        while ((s = at.next()) != null) {
+            args.add(s);
+        }
+        if (!checkOptionsAndRemainingInput(at)) {
+            return false;
+        }
+        if (args.isEmpty()) {
             errormsg("jshell.err.drop.arg");
             return false;
         }
-        Stream<Snippet> stream = argToSnippets(arg, false);
+        Stream<PersistentSnippet> stream = argsToSnippets(dropableSnippets(), args);
         if (stream == null) {
-            errormsg("jshell.err.def.or.id.not.found", arg);
+            // Snippet not found. Error already printed
             fluffmsg("jshell.msg.see.classes.etc");
             return false;
         }
-        List<Snippet> snippets = stream
-                .filter(sn -> state.status(sn).isActive && sn instanceof PersistentSnippet)
-                .collect(toList());
-        if (snippets.isEmpty()) {
-            errormsg("jshell.err.drop.not.active");
-            return false;
-        }
-        if (snippets.size() > 1) {
+        List<PersistentSnippet> snippets = stream.collect(toList());
+        if (snippets.size() > args.size()) {
+            // One of the args references more thean one snippet
             errormsg("jshell.err.drop.ambiguous");
             fluffmsg("jshell.msg.use.one.of", snippets.stream()
-                    .map(sn -> String.format("\n%4s : %s", sn.id(), sn.source().replace("\n", "\n       ")))
+                    .map(sn -> String.format("\n/drop %-5s :   %s", sn.id(), sn.source().replace("\n", "\n       ")))
                     .collect(Collectors.joining(", "))
             );
             return false;
         }
-        PersistentSnippet psn = (PersistentSnippet) snippets.get(0);
-        state.drop(psn).forEach(this::handleEvent);
+        snippets.stream()
+                .forEach(sn -> state.drop(sn).forEach(this::handleEvent));
         return true;
     }
 
     private boolean cmdEdit(String arg) {
-        Stream<Snippet> stream = argToSnippets(arg, true);
+        Stream<Snippet> stream = argsOptionsToSnippets(state.snippets(),
+                this::mainActive, arg, "/edit");
         if (stream == null) {
-            errormsg("jshell.err.def.or.id.not.found", arg);
-            fluffmsg("jshell.msg.see.classes.etc");
             return false;
         }
         Set<String> srcSet = new LinkedHashSet<>();
@@ -1518,18 +1767,12 @@
     }
 
     private boolean cmdList(String arg) {
-        if (arg.equals("history")) {
+        if (arg.length() >= 2 && "-history".startsWith(arg)) {
             return cmdHistory();
         }
-        Stream<Snippet> stream = argToSnippets(arg, true);
+        Stream<Snippet> stream = argsOptionsToSnippets(state.snippets(),
+                this::mainActive, arg, "/list");
         if (stream == null) {
-            errormsg("jshell.err.def.or.id.not.found", arg);
-            // Check if there are any definitions at all
-            if (argToSnippets("", false).iterator().hasNext()) {
-                fluffmsg("jshell.msg.try.list.without.args");
-            } else {
-                hardmsg("jshell.msg.no.active");
-            }
             return false;
         }
 
@@ -1597,75 +1840,63 @@
         return true;
     }
 
-    private boolean cmdReload(String arg) {
-        Iterable<String> history = replayableHistory;
-        boolean echo = true;
-        if (arg.length() > 0) {
-            if ("restore".startsWith(arg)) {
-                if (replayableHistoryPrevious == null) {
-                    errormsg("jshell.err.reload.no.previous");
-                    return false;
-                }
-                history = replayableHistoryPrevious;
-            } else if ("quiet".startsWith(arg)) {
-                echo = false;
-            } else {
-                errormsg("jshell.err.arg", "/reload", arg);
+    private boolean cmdReload(String rawargs) {
+        ArgTokenizer at = new ArgTokenizer("/reload", rawargs.trim());
+        at.allowedOptions("-restore", "-quiet");
+        if (!checkOptionsAndRemainingInput(at)) {
+            return false;
+        }
+        Iterable<String> history;
+        if (at.hasOption("-restore")) {
+            if (replayableHistoryPrevious == null) {
+                errormsg("jshell.err.reload.no.previous");
                 return false;
             }
+            history = replayableHistoryPrevious;
+            fluffmsg("jshell.err.reload.restarting.previous.state");
+        } else {
+            history = replayableHistory;
+            fluffmsg("jshell.err.reload.restarting.state");
         }
-        fluffmsg(history == replayableHistoryPrevious
-                        ? "jshell.err.reload.restarting.previous.state"
-                        : "jshell.err.reload.restarting.state");
+        boolean echo = !at.hasOption("-quiet");
         resetState();
         run(new ReloadIOContext(history,
-                echo? cmdout : null));
+                echo ? cmdout : null));
         return true;
     }
 
-    private boolean cmdSave(String arg_filename) {
-        Matcher mat = HISTORY_ALL_START_FILENAME.matcher(arg_filename);
-        if (!mat.find()) {
-            errormsg("jshell.err.arg", arg_filename);
+    private boolean cmdSave(String rawargs) {
+        ArgTokenizer at = new ArgTokenizer("/save", rawargs.trim());
+        at.allowedOptions("-all", "-start", "-history");
+        String filename = at.next();
+        if (filename == null) {
+            errormsg("jshell.err.file.filename", "/save");
             return false;
         }
-        boolean useHistory = false;
-        String saveAll = "";
-        boolean saveStart = false;
-        String cmd = mat.group("cmd");
-        if (cmd != null) switch (cmd) {
-            case "all":
-                saveAll = "all";
-                break;
-            case "history":
-                useHistory = true;
-                break;
-            case "start":
-                saveStart = true;
-                break;
+        if (!checkOptionsAndRemainingInput(at)) {
+            return false;
         }
-        String filename = mat.group("filename");
-        if (filename == null ||filename.isEmpty()) {
-            errormsg("jshell.err.file.filename", "/save");
+        if (at.optionCount() > 1) {
+            errormsg("jshell.err.conflicting.options", at.whole());
             return false;
         }
         try (BufferedWriter writer = Files.newBufferedWriter(toPathResolvingUserHome(filename),
                 Charset.defaultCharset(),
                 CREATE, TRUNCATE_EXISTING, WRITE)) {
-            if (useHistory) {
+            if (at.hasOption("-history")) {
                 for (String s : input.currentSessionHistory()) {
                     writer.write(s);
                     writer.write("\n");
                 }
-            } else if (saveStart) {
-                writer.append(DEFAULT_STARTUP);
+            } else if (at.hasOption("-start")) {
+                writer.append(startup);
             } else {
-                Stream<Snippet> stream = argToSnippets(saveAll, true);
-                if (stream != null) {
-                    for (Snippet sn : stream.collect(toList())) {
-                        writer.write(sn.source());
-                        writer.write("\n");
-                    }
+                List<Snippet> sns = at.hasOption("-all")
+                        ? state.snippets()
+                        : state.snippets().stream().filter(this::mainActive).collect(toList());
+                for (Snippet sn : sns) {
+                    writer.write(sn.source());
+                    writer.write("\n");
                 }
             }
         } catch (FileNotFoundException e) {
@@ -1678,25 +1909,42 @@
         return true;
     }
 
-    private boolean cmdVars() {
-        for (VarSnippet vk : state.variables()) {
+    private boolean cmdVars(String arg) {
+        Stream<VarSnippet> stream = argsOptionsToSnippets(allVarSnippets(),
+                this::isActive, arg, "/vars");
+        if (stream == null) {
+            return false;
+        }
+        stream.forEachOrdered(vk ->
+        {
             String val = state.status(vk) == Status.VALID
                     ? state.varValue(vk)
                     : "jshell.msg.vars.not.active";
             hard("  %s %s = %s", vk.typeName(), vk.name(), val);
-        }
+        });
         return true;
     }
 
-    private boolean cmdMethods() {
-        for (MethodSnippet mk : state.methods()) {
-            hard("  %s %s", mk.name(), mk.signature());
+    private boolean cmdMethods(String arg) {
+        Stream<MethodSnippet> stream = argsOptionsToSnippets(allMethodSnippets(),
+                this::isActive, arg, "/methods");
+        if (stream == null) {
+            return false;
         }
+        stream.forEachOrdered(mk
+                -> hard("  %s %s", mk.name(), mk.signature())
+        );
         return true;
     }
 
-    private boolean cmdClasses() {
-        for (TypeDeclSnippet ck : state.types()) {
+    private boolean cmdTypes(String arg) {
+        Stream<TypeDeclSnippet> stream = argsOptionsToSnippets(allTypeSnippets(),
+                this::isActive, arg, "/types");
+        if (stream == null) {
+            return false;
+        }
+        stream.forEachOrdered(ck
+        -> {
             String kind;
             switch (ck.subKind()) {
                 case INTERFACE_SUBKIND:
@@ -1717,7 +1965,7 @@
                     break;
             }
             hard("  %s %s", kind, ck.name());
-        }
+        });
         return true;
     }
 
@@ -1743,6 +1991,21 @@
         return true;
     }
 
+    boolean checkOptionsAndRemainingInput(ArgTokenizer at) {
+        String junk = at.remainder();
+        if (!junk.isEmpty()) {
+            errormsg("jshell.err.unexpected.at.end", junk, at.whole());
+            return false;
+        } else {
+            String bad = at.badOptions();
+            if (!bad.isEmpty()) {
+                errormsg("jshell.err.unknown.option", bad, at.whole());
+                return false;
+            }
+        }
+        return true;
+    }
+
     private boolean rerunHistoryEntryById(String id) {
         Optional<Snippet> snippet = state.snippets().stream()
             .filter(s -> s.id().equals(id))
@@ -1876,7 +2139,7 @@
                 List<String> disp = new ArrayList<>();
                 displayDiagnostics(source, d, disp);
                 disp.stream()
-                        .forEach(l -> hard(l));
+                        .forEach(l -> hard("%s", l));
             }
 
             if (ste.status() != Status.REJECTED) {
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties
index 06784c8..65cefd2 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties
@@ -34,11 +34,10 @@
 
 jshell.msg.terminated =\
 State engine terminated.\n\
-Restore definitions with: /reload restore
+Restore definitions with: /reload -restore
 
 jshell.msg.use.one.of = Use one of: {0}
-jshell.err.def.or.id.not.found = No definition or id found named: {0}
-jshell.msg.see.classes.etc = See /classes, /methods, /vars, or /list
+jshell.msg.see.classes.etc = See /types, /methods, /vars, or /list
 jshell.err.arg = Invalid ''{0}'' argument: {1}
 jshell.msg.see = See {0} for help.
 
@@ -57,7 +56,7 @@
 jshell.err.cant.launch.editor = Cannot launch editor -- unexpected exception: {0}
 jshell.msg.try.set.editor = Try /set editor to use external editor.
 
-jshell.msg.try.list.without.args = Try ''/list'' without arguments.
+jshell.msg.try.command.without.args = Try ''{0}'' without arguments.
 jshell.msg.no.active = There are no active definitions.
 
 jshell.msg.resetting = Resetting...
@@ -74,8 +73,8 @@
 jshell.msg.error = Error:
 jshell.msg.warning = Warning:
 
-jshell.err.set.arg = The ''/set'' command requires a sub-command and arguments. See: ''/help /set''
-jshell.err.set.ambiguous = Ambiguous sub-command argument to ''/set'': {0}
+jshell.err.sub.arg = The ''{0}'' command requires a sub-command. See: ''/help {0}''
+jshell.err.sub.ambiguous = Ambiguous sub-command argument to ''{0}'': {1}
 
 jshell.err.classpath.arg = The /classpath command requires a path argument.
 jshell.msg.classpath = Path ''{0}'' added to classpath
@@ -91,7 +90,6 @@
 jshell.err.drop.arg =\
 In the /drop argument, please specify an import, variable, method, or class to drop.\n\
 Specify by id or name. Use /list to see ids. Use /reset to reset all state.
-jshell.err.drop.not.active = The argument did not specify an active import, variable, method, or class to drop.
 jshell.err.drop.ambiguous = The argument references more than one import, variable, method, or class.
 jshell.err.failed = Failed.
 jshell.msg.native.method = Native Method
@@ -100,11 +98,12 @@
 
 jshell.msg.help.for.help = Type /help for help.
 
-jshell.err.feedback.expected.new.feedback.mode = Expected new feedback mode -- {0}
-jshell.err.feedback.expected.mode.name = Expected a new feedback mode name. ''{0}'' is a known feedback mode -- {1}
-jshell.err.feedback.command.quiet = Specify either ''command'' or ''quiet'' -- {0}
-jshell.err.feedback.expected.field = Expected field name missing -- {0}
-jshell.err.feedback.expected.mode = Expected a feedback mode -- {0}
+jshell.err.mode.name = Expected a feedback mode name: {0}
+jshell.err.missing.mode = Missing the feedback mode -- {0}
+jshell.err.field.name = Expected a field name: {0} -- {1}
+jshell.err.missing.field = Missing the field name -- {0}
+jshell.err.mode.unknown = No feedback mode named: {0} -- {1}
+
 jshell.err.feedback.does.not.match.mode = Does not match any current feedback mode: {0} -- {1}
 jshell.err.feedback.ambiguous.mode = Matches more then one current feedback mode: {0} -- {1}
 jshell.err.feedback.expected.format = Expected format missing -- {0}
@@ -117,6 +116,25 @@
 jshell.msg.feedback.mode = Feedback mode: {0}
 jshell.msg.feedback.mode.following = The feedback mode should be one of the following:
 
+jshell.err.truncation.expected.length = Expected truncation length -- {0}
+jshell.err.truncation.length.not.integer = Truncation length must be an integer: {0} -- {1}
+
+jshell.err.not.valid.with.predefined.mode = Not valid with a predefined mode: {0} -- {1}
+jshell.err.retained.feedback.mode.must.be.retained.or.predefined = \
+''/retain feedback <mode>'' requires that <mode> is predefined or has been retained with ''/retain mode'' -- {0}
+
+jshell.err.unknown.option = Unknown option: {0} -- {1}
+jshell.err.default.option.or.program = Specify -default option or program, not both -- {0}
+jshell.err.option.or.filename = Specify either one option or a startup file name -- {0}
+jshell.err.unexpected.at.end = Unexpected arguments at end of command: {0} -- {1}
+jshell.err.conflicting.options = Conflicting options -- {0}
+jshell.err.cannot.delete.current.mode = The current feedback mode ''{0}'' cannot be deleted, use ''/set feedback'' first -- {1}
+jshell.err.cannot.delete.retained.mode = The retained feedback mode ''{0}'' cannot be deleted, use ''/retain feedback'' first -- {1}
+jshell.err.may.not.specify.options.and.snippets = Options and snippets must not both be used: {0}
+jshell.err.no.such.snippets = No such snippet: {0}
+jshell.err.the.snippet.cannot.be.used.with.this.command = This command does not accept the snippet ''{0}'' : {1}
+jshell.err.retained.mode.failure = Failure in retained modes (modes cleared) -- {0} {1}
+
 jshell.console.see.more = <press tab to see more>
 jshell.console.do.nothing = Do nothing
 jshell.console.choice = Choice: \
@@ -148,15 +166,15 @@
 \    -version             Version information\n
 
 help.list.summary = list the source you have typed
-help.list.args = [all|start|<name or id>]
+help.list.args = [<name or id>|-all|-start]
 help.list =\
 Show the source of snippets, prefaced with the snippet id.\n\
 \n\
 /list\n\t\
     List the currently active snippets of code that you typed or read with /open\n\n\
-/list start\n\t\
+/list -start\n\t\
     List the automatically evaluated start-up snippets\n\n\
-/list all\n\t\
+/list -all\n\t\
     List all snippets including failed, overwritten, dropped, and start-up\n\n\
 /list <name>\n\t\
     List snippets with the specified name (preference for active snippets)\n\n\
@@ -188,18 +206,18 @@
     Drop the snippet with the specified snippet id
 
 help.save.summary = Save snippet source to a file.
-help.save.args = [all|history|start] <file>
+help.save.args = [-all|-history|-start] <file>
 help.save =\
 Save the specified snippets and/or commands to the specified file.\n\
 \n\
 /save <file>\n\t\
     Save the source of current active snippets to the file.\n\n\
-/save all <file>\n\t\
+/save -all <file>\n\t\
     Save the source of all snippets to the file.\n\t\
     Includes source including overwritten, failed, and start-up code.\n\n\
-/save history <file>\n\t\
+/save -history <file>\n\t\
     Save the sequential history of all commands and snippets entered since jshell was launched.\n\n\
-/save start <file>\n\t\
+/save -start <file>\n\t\
     Save the default start-up definitions to the file.
 
 help.open.summary = open a file as source input
@@ -211,19 +229,52 @@
     Read the specified file as jshell input.
 
 help.vars.summary = list the declared variables and their values
-help.vars.args =
+help.vars.args = [<name or id>|-all|-start]
 help.vars =\
-List the type, name, and value of the current active jshell variables.
+List the type, name, and value of jshell variables.\n\
+\n\
+/vars\n\t\
+    List the type, name, and value of the current active jshell variables\n\n\
+/vars <name>\n\t\
+    List jshell variables with the specified name (preference for active variables)\n\n\
+/vars <id>\n\t\
+    List the jshell variable with the specified snippet id\n\n\
+/vars -start\n\t\
+    List the automatically added start-up jshell variables\n\n\
+/vars -all\n\t\
+    List all jshell variables including failed, overwritten, dropped, and start-up
 
 help.methods.summary = list the declared methods and their signatures
-help.methods.args =
+help.methods.args = [<name or id>|-all|-start]
 help.methods =\
-List the name, parameter types, and return type of the current active jshell methods.
+List the name, parameter types, and return type of jshell methods.\n\
+\n\
+/methods\n\t\
+    List the name, parameter types, and return type of the current active jshell methods\n\n\
+/methods <name>\n\t\
+    List jshell methods with the specified name (preference for active methods)\n\n\
+/methods <id>\n\t\
+    List the jshell method with the specified snippet id\n\n\
+/methods -start\n\t\
+    List the automatically added start-up jshell methods\n\n\
+/methods -all\n\t\
+    List all snippets including failed, overwritten, dropped, and start-up
 
-help.classes.summary = list the declared classes
-help.classes.args =
-help.classes =\
-List the current active jshell classes, interfaces, and enums.
+help.types.summary = list the declared types
+help.types.args =[<name or id>|-all|-start]
+help.types =\
+List jshell classes, interfaces, and enums.\n\
+\n\
+/types\n\t\
+    List the current active jshell classes, interfaces, and enums.\n\n\
+/types <name>\n\t\
+    List jshell types with the specified name (preference for active types)\n\n\
+/types <id>\n\t\
+    List the jshell type with the specified snippet id\n\n\
+/types -start\n\t\
+    List the automatically added start-up jshell types\n\n\
+/types -all\n\t\
+    List all jshell types including failed, overwritten, dropped, and start-up
 
 help.imports.summary = list the imported items
 help.imports.args =
@@ -247,8 +298,8 @@
 Tool settings are maintained, as set with: /set ...\n\
 Save any work before using this command
 
-help.reload.summary = reset and replay relevant history -- current or previous (restore)
-help.reload.args = [restore] [quiet]
+help.reload.summary = reset and replay relevant history -- current or previous (-restore)
+help.reload.args = [-restore] [-quiet]
 help.reload =\
 Reset the jshell tool code and execution state then replay each\n\
 jshell valid command and valid snippet in the order they were entered.\n\
@@ -257,13 +308,13 @@
      Reset and replay the valid history since jshell was entered, or\n\t\
      a /reset, or /reload command was executed -- whichever is most\n\t\
      recent.\n\n\
-/reload restore\n\t\
+/reload -restore\n\t\
      Reset and replay the valid history between the previous and most\n\t\
      recent time that jshell was entered, or a /reset, or /reload\n\t\
      command was executed. This can thus be used to restore a previous\n\t\
      jshell tool sesson.\n\n\
-/reload [restore] quiet\n\t\
-     With the 'quiet' argument the replay is not shown.  Errors will display.
+/reload [-restore] -quiet\n\t\
+     With the '-quiet' argument the replay is not shown.  Errors will display.
 
 help.classpath.summary = add a path to the classpath
 help.classpath.args = <path>
@@ -301,7 +352,7 @@
      Display information about the specified help subject. Example: /help intro
 
 help.set.summary = set jshell configuration information
-help.set.args = editor|start|feedback|newmode|prompt|format ...
+help.set.args = editor|start|feedback|mode|prompt|truncation|format ...
 help.set =\
 Set jshell configuration information, including:\n\
 the external editor to use, the start-up definitions to use, a new feedback mode,\n\
@@ -314,15 +365,36 @@
      The contents of the specified <file> become the default start-up snippets and commands.\n\n\
 /set feedback <mode>\n\t\
      Set the feedback mode describing displayed feedback for entered snippets and commands.\n\n\
-/set newmode <new-mode> [command|quiet [<old-mode>]]\n\t\
-     Create a user-defined feedback mode, optionally copying from an existing mode.\n\n\
+/set mode <mode> [<old-mode>] [-command|-quiet|-delete]\n\t\
+     Create or update a user-defined feedback mode, optionally copying from an existing mode.\n\n\
 /set prompt <mode> "<prompt>" "<continuation-prompt>"\n\t\
      Set the displayed prompts for a given feedback mode.\n\n\
+/set truncation <mode> <length> <selector>...\n\t\
+     Set the maximum length of a displayed value\n\
 /set format <mode> <field> "<format>" <selector>...\n\t\
      Configure a feedback mode by setting the format of a field when the selector matchs.\n\n\
 To get more information about one of these forms, use /help with the form specified.\n\
 For example:   /help /set format
 
+help.retain.summary = retain jshell configuration information for subsequent sessions
+help.retain.args = editor|start|feedback|mode
+help.retain =\
+Retain jshell configuration information for future invocations of the jshell tool,\n\
+including: the external editor to use, the start-up definitions to use, the\n\
+configuration of a feedback mode, or the feedback mode to use.\n\
+\n\
+/retain editor [<command> <optional-arg>...]\n\t\
+     Specify the command to launch for the /edit command.\n\t\
+     The <command> is an operating system dependent string.\n\n\
+/retain start [<file>]\n\t\
+     The contents of the specified <file> become the default start-up snippets and commands.\n\n\
+/retain feedback [<mode>]\n\t\
+     Set the feedback mode describing displayed feedback for entered snippets and commands.\n\n\
+/retain mode <mode>\n\t\
+     Create a user-defined feedback mode, optionally copying from an existing mode.\n\n\
+To get more information about one of these forms, use /help with the form specified.\n\
+For example:   /help /retain feedback
+
 help.quest.summary = get information about jshell
 help.quest.args = [<command>|<subject>]
 help.quest =\
@@ -391,7 +463,7 @@
 \n\t\
 /set format <mode> <field> "<format>" <selector>...\n\
 \n\
-Where <mode> is the name of a previously defined feedback mode -- see '/help /set newmode'.\n\
+Where <mode> is the name of a previously defined feedback mode -- see '/help /set mode'.\n\
 Where <field> is the name of context-specific format to define.\n\
 Where <format> is a quoted string which will be the value of the field if one of\n\
 the selectors matches (or there are no selectors). When the format is used,\n\
@@ -462,6 +534,37 @@
 /set format myformat display '{pre}{action} variable {name}, reset to null{post}' replaced-vardecl,varinit-ok-update\n\n\
 Note that subsequent selectors for a field may overwrite some or all of previous used selectors -- last one wins\n
 
+help.set.truncation = \
+Set the max length a displayed value.\n\
+\n\t\
+/set truncation <mode> <length> <selector>...\n\
+\n\
+Where <mode> is the name of a previously defined feedback mode -- see '/help /set mode'.\n\
+Where <length> is an unsigned integer representing a maximum length.\n\
+Where <format> is a quoted string which will be the value of the field if one of\n\
+Where <selector> is only needed if you wish to fine-tune value truncation length\n\
+by context, <selector> is the context in which the truncation is applied.\n\
+The structure of selector is a hyphen separated list of selector kind lists.\n\
+A selector kind list is a comma separated list of values of one selector kind.\n\
+A selector matches if each selector kind list matches; A selector kind list\n\
+matches if one of the values matches.\n\n\
+Below are the relevant selector kinds for truncation.\n\n\
+The case selector kind describes the kind of snippet.  The values are:\n\t\
+   vardecl    -- variable declaration without init\n\t\
+   varinit    -- variable declaration with init\n\t\
+   expression -- expression -- note: {name}==scratch-variable-name\n\t\
+   varvalue   -- variable value expression\n\t\
+   assignment -- assign variable\n\t\
+The action selector kind describes what happened to the snippet.  The values are:\n\t\
+   added     -- snippet has been added\n\t\
+   modified  -- an existing snippet has been modified\n\t\
+   replaced  -- an existing snippet has been replaced with a new snippet\n\
+Examples:\n\t\
+/set trunc mymode 80\n\t\
+/set truncation mymode 45 expression\n\t\
+/set truncation mymode 0 vardecl-modified,replaced\n\n\
+Note that subsequent selectors for a field may overwrite some or all of previous used selectors -- last one wins\n
+
 help.set.feedback = \
 Set the feedback mode describing displayed feedback for entered snippets and commands.\n\
 \n\t\
@@ -469,18 +572,18 @@
 \n\
 Where <mode> is the name of a previously defined feedback mode.\n\
 You may use just enough letters to make it unique.\n\
-User-defined modes can be added, see '/help /set newmode'\n\
+User-defined modes can be added, see '/help /set mode'\n\
 Currently defined feedback modes:\n
 
-help.set.newmode = \
+help.set.mode = \
 Create a user-defined feedback mode, optionally copying from an existing mode.\n\
 \n\t\
-/set newmode <new-mode> [command|quiet [<old-mode>]]\n\
+/set mode <mode> [<old-mode>] [-command|-quiet|-delete]\n\
 \n\
 Where <new-mode> is the name of a mode you wish to create.\n\
 Where <old-mode> is the name of a previously defined feedback mode.\n\
 If <old-mode> is present, its settings are copied to the new mode.\n\
-'command' vs 'quiet' determines if informative/verifying command feedback is displayed.\n\
+'-command' vs '-quiet' determines if informative/verifying command feedback is displayed.\n\
 \n\
 Once the new mode is created, use '/set format' and '/set prompt' to configure it.\n\
 Use '/set feedback' to use the new mode.\n\
@@ -499,22 +602,82 @@
 help.set.editor =\
 Specify the command to launch for the /edit command.\n\
 \n\t\
-/set editor <command> <optional-arg>...\n\
+/set editor <command>|-default\n\
 \n\
 The <command> is an operating system dependent string.\n\
-The <command> may include space-separated arguments (such as flags) -- <optional-arg>....\n\
-When /edit is used, the temporary file to edit will be appended as the last argument.
+The <command> may include space-separated arguments (such as flags)\n\
+When /edit is used, the temporary file to edit will be appended as the last argument.\n\
+If instead the -default option is specified, the built-in default editor will be used.
 
 help.set.start =\
 Set the start-up configuration -- a sequence of snippets and commands read at start-up.\n\
 \n\t\
-/set start <file>\n\
+/set start <file>|-default|-none\n\
 \n\
-The contents of the specified <file> become the default start-up snippets and commands --\n\
-which are run when the jshell tool is started or reset.
+The contents of the specified <file> become the start-up snippets and commands used\n\
+when the /reset or /reload commands are used in this session.\n\
+If instead the -default option is specified, the predefined start-up snippets\n\
+will be used.\n\
+If the -none option is used, the start-up will be empty -- no start-up snippets\n\
+or commands will be used.\n\
+This command is good for testing the start-up settings.  To retain them for future\n\
+runs of the jshell tool use the command:\n\t\
+/retain start\n
+
+help.retain.feedback = \
+Retain which feedback mode to use for displayed feedback for entered snippets and commands.\n\
+This feedback mode will be used in this and future sessions of the jshell tool.\n\
+\n\t\
+/retain feedback [<mode>]\n\
+\n\
+Where <mode> is the name of a previously defined feedback mode.\n\
+You may use just enough letters to make it unique.\n\
+If the <mode> is not specified, this command retains the current mode (as set\n\
+with the most recent /set feedback or /retain feedback command.)\n\
+
+help.retain.mode = \
+Retain the existence and configuration of a user-defined feedback mode.\n\
+This mode will be available in this and future sessions of the jshell tool.
+\n\t\
+/retain mode <mode>\n\
+\n\
+Where <mode> is the name of a mode you wish to retain.\n\
+The <mode> must previously have been created with /set mode and\n\
+configured as desired with /set prompt, /set format, and /set truncation.\n
+
+help.retain.editor =\
+Retain the command to launch for the /edit command.  This command will be invoked when\n\
+the /edit command is used in this and future sessions of the jshell tool.\n\
+\n\t\
+/retain editor [<command>|-default]\n\
+\n\
+If <command> is specified, it is an operating system dependent string which\n\
+may include space-separated arguments (such as flags). When /edit is used, the\n\
+temporary file to edit will be appended as the last argument.\n\
+If instead the -default option is specified, the built-in default editor will be used.\n\
+If neither is specified, the editor set in the last /set editor or /retain editor\n\
+command will be used.\n\
+The editor will be retained and used in this and future runs of the jshell tool.
+
+help.retain.start =\
+Retain the start-up configuration -- a sequence of snippets and commands read\n\
+at start-up.\n\
+\n\t\
+/retain start [<file>|-default|-none]\n\
+\n\
+If <file> is specified, the contents of the specified <file> become the\n\
+start-up snippets\n\
+and commands.\n\
+If instead the -default option is specified, the predefined start-up snippets\n\
+will be the start-up.\n\
+If the -none option is used, the start-up will be empty -- no start-up snippets\n\
+or commands will be used.\n\
+If none of these is specified, the start-up is the last specified in a\n\
+''/set start'' or ''/retain start'' command.\n\
+The start-up will be retained and used when the jshell tool is started or reset
 
 startup.feedback = \
-/set newmode verbose command    \n\
+/set mode verbose -command    \n\
 \n\
 /set prompt verbose '\\njshell> '   '   ...> '    \n\
 \n\
@@ -564,12 +727,12 @@
 \n\
 /set format verbose result '{name} ==> {value}{post}'                                        added,modified,replaced-ok-primary    \n\
 \n\
-/set format verbose display '{result}{pre}created scratch variable {name} : {type}{post}'    expression-primary    \n\
+/set format verbose display '{result}{pre}created scratch variable {name} : {type}{post}'    expression-added,modified,replaced-primary    \n\
 /set format verbose display '{result}{pre}value of {name} : {type}{post}'                    varvalue-primary    \n\
 /set format verbose display '{result}{pre}assigned to {name} : {type}{post}'                 assignment-primary    \n\
 /set format verbose display '{result}{pre}{action} variable {name} : {type}{resolve}{post}'  varinit,vardecl    \n\
 /set format verbose display '{pre}{action} variable {name}{resolve}{post}'                   vardecl,varinit-notdefined    \n\
-/set format verbose display '{pre}{action} variable {name}{post}'                            dropped-vardecl,varinit    \n\
+/set format verbose display '{pre}{action} variable {name}{post}'                            dropped-vardecl,varinit,expression    \n\
 /set format verbose display '{pre}{action} variable {name}, reset to null{post}'             replaced-vardecl,varinit-ok-update    \n\
 \n\
 /set format verbose display '{pre}{action} {typeKind} {name}{resolve}{post}'                 class,interface,enum,annotation    \n\
@@ -578,11 +741,14 @@
 /set format verbose display '{pre}attempted to use {typeKind} {name}{resolve}{post}'         used-class,interface,enum,annotation    \n\
 /set format verbose display '{pre}attempted to call method {name}({type}){resolve}{post}'    used-method    \n\
 \n\
-/set newmode normal command verbose    \n\
+/set truncation verbose 80\n\
+/set truncation verbose 500                                                                  varvalue\n\
+\n\
+/set mode normal -command verbose    \n\
 /set format normal display ''                                                               added,modified,replaced,overwrote,dropped-update    \n\
 /set format normal display '{pre}{action} variable {name}, reset to null{post}'             replaced-vardecl,varinit-ok-update    \n\
 /set format normal display '{result}'                                                       added,modified,replaced-expression,varvalue,assignment,varinit,vardecl-ok-primary    \n\
-/set newmode concise quiet normal    \n\
+/set mode concise -quiet normal    \n\
 \n\
 /set prompt concise 'jshell> '   '   ...> '    \n\
 \n\
@@ -590,7 +756,7 @@
 \n\
 /set feedback normal    \n\
 \n\
-/set newmode silent quiet    \n\
+/set mode silent -quiet    \n\
 /set prompt silent '-> ' '>> '    \n\
 /set format silent pre '|  '    \n\
 /set format silent post '%n'    \n\
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ClassTracker.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ClassTracker.java
deleted file mode 100644
index 51af9ab..0000000
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ClassTracker.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.jshell;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Objects;
-import com.sun.jdi.ReferenceType;
-
-/**
- * Tracks the state of a class through compilation and loading in the remote
- * environment.
- *
- * @author Robert Field
- */
-class ClassTracker {
-
-    private final JShell state;
-    private final HashMap<String, ClassInfo> map;
-
-    ClassTracker(JShell state) {
-        this.state = state;
-        this.map = new HashMap<>();
-    }
-
-    class ClassInfo {
-
-        private final String className;
-        private byte[] bytes;
-        private byte[] loadedBytes;
-        private ReferenceType rt;
-
-        private ClassInfo(String className) {
-            this.className = className;
-        }
-
-        String getClassName() {
-            return className;
-        }
-
-        byte[] getBytes() {
-            return bytes;
-        }
-
-        void setBytes(byte[] bytes) {
-            this.bytes = bytes;
-        }
-
-        void setLoaded() {
-            loadedBytes = bytes;
-        }
-
-        boolean isLoaded() {
-            return Arrays.equals(loadedBytes, bytes);
-        }
-
-        ReferenceType getReferenceTypeOrNull() {
-            if (rt == null) {
-                rt = state.executionControl().nameToRef(className);
-            }
-            return rt;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            return o instanceof ClassInfo &&
-                    ((ClassInfo) o).className.equals(className);
-        }
-
-        @Override
-        public int hashCode() {
-            return Objects.hashCode(this.className);
-        }
-    }
-
-    ClassInfo classInfo(String className, byte[] bytes) {
-        ClassInfo ci = map.computeIfAbsent(className, k -> new ClassInfo(k));
-        ci.setBytes(bytes);
-        return ci;
-    }
-
-    ClassInfo get(String className) {
-        return map.get(className);
-    }
-}
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java
index ce9ee86..8cb4828 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java
@@ -49,6 +49,8 @@
 import static com.sun.tools.javac.code.Flags.INTERFACE;
 import static com.sun.tools.javac.code.Flags.ENUM;
 import static com.sun.tools.javac.code.Flags.PUBLIC;
+import com.sun.tools.javac.util.Name;
+import jdk.jshell.spi.SPIResolutionException;
 
 /**
  * Produce a corralled version of the Wrap for a snippet.
@@ -129,16 +131,22 @@
         super.visitClassDef(tree);
     }
 
+    // Build a compiler tree for an exception throwing block, e.g.:
+    // {
+    //     throw new jdk.jshell.spi.SPIResolutionException(9);
+    // }
     private JCBlock resolutionExceptionBlock() {
         if (resolutionExceptionBlock == null) {
-            JCExpression expClass
-                    = make.Select(make.Select(make.Select(make.Select(
-                            make.Ident(names.fromString("jdk")),
-                            names.fromString("internal")),
-                            names.fromString("jshell")),
-                            names.fromString("remote")),
-                            names.fromString("RemoteResolutionException")
-                    );
+            JCExpression expClass = null;
+            // Split the exception class name at dots
+            for (String id : SPIResolutionException.class.getName().split("\\.")) {
+                Name nm = names.fromString(id);
+                if (expClass == null) {
+                    expClass = make.Ident(nm);
+                } else {
+                    expClass = make.Select(expClass, nm);
+                }
+            }
             JCNewClass exp = make.NewClass(null,
                     null, expClass, List.of(make.Literal(keyIndex)), null);
             resolutionExceptionBlock = make.Block(0L, List.<JCStatement>of(
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java
index 1d8af24..6e0a3ca 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java
@@ -49,7 +49,6 @@
 import java.io.Writer;
 import java.util.LinkedHashSet;
 import java.util.Set;
-import jdk.jshell.ClassTracker.ClassInfo;
 import jdk.jshell.Key.ErroneousKey;
 import jdk.jshell.Key.MethodKey;
 import jdk.jshell.Key.TypeDeclKey;
@@ -64,9 +63,9 @@
 import static java.util.stream.Collectors.toList;
 import static java.util.stream.Collectors.toSet;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
-import static jdk.jshell.Util.*;
-import static jdk.internal.jshell.remote.RemoteCodes.DOIT_METHOD_NAME;
-import static jdk.internal.jshell.remote.RemoteCodes.PREFIX_PATTERN;
+import static jdk.jshell.Util.DOIT_METHOD_NAME;
+import static jdk.jshell.Util.PREFIX_PATTERN;
+import static jdk.jshell.Util.expunge;
 import static jdk.jshell.Snippet.SubKind.SINGLE_TYPE_IMPORT_SUBKIND;
 import static jdk.jshell.Snippet.SubKind.SINGLE_STATIC_IMPORT_SUBKIND;
 import static jdk.jshell.Snippet.SubKind.TYPE_IMPORT_ON_DEMAND_SUBKIND;
@@ -456,7 +455,7 @@
         if (si.status().isDefined) {
             if (si.isExecutable()) {
                 try {
-                value = state.executionControl().commandInvoke(si.classFullName());
+                value = state.executionControl().invoke(si.classFullName(), DOIT_METHOD_NAME);
                     value = si.subKind().hasValue()
                             ? expunge(value)
                             : "";
@@ -578,7 +577,7 @@
 
                     // load all new classes
                     load(legit.stream()
-                            .flatMap(u -> u.classesToLoad(ct.classInfoList(u.snippet().outerWrap())))
+                            .flatMap(u -> u.classesToLoad(ct.classList(u.snippet().outerWrap())))
                             .collect(toSet()));
                     // attempt to redefine the remaining classes
                     List<Unit> toReplace = legit.stream()
@@ -613,9 +612,13 @@
         }
     }
 
-    private void load(Set<ClassInfo> cil) {
-        if (!cil.isEmpty()) {
-            state.executionControl().commandLoad(cil);
+    /**
+     * If there are classes to load, loads by calling the execution engine.
+     * @param classnames names of the classes to load.
+     */
+    private void load(Collection<String> classnames) {
+        if (!classnames.isEmpty()) {
+            state.executionControl().load(classnames);
         }
     }
 
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java
deleted file mode 100644
index f28323e..0000000
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright (c) 2014, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.jshell;
-
-import static jdk.internal.jshell.remote.RemoteCodes.*;
-import java.io.DataInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.PrintStream;
-import java.net.ServerSocket;
-import java.net.Socket;
-import com.sun.jdi.*;
-import java.io.EOFException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import jdk.jshell.ClassTracker.ClassInfo;
-import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
-
-/**
- * Controls the remote execution environment.
- *
- * @author Robert Field
- */
-class ExecutionControl {
-
-    private final JDIEnv env;
-    private final SnippetMaps maps;
-    private JDIEventHandler handler;
-    private Socket socket;
-    private ObjectInputStream in;
-    private ObjectOutputStream out;
-    private final JShell proc;
-    private final String remoteVMOptions;
-
-    ExecutionControl(JDIEnv env, SnippetMaps maps, JShell proc, List<String> extraRemoteVMOptions) {
-        this.env = env;
-        this.maps = maps;
-        this.proc = proc;
-        StringBuilder sb = new StringBuilder();
-        extraRemoteVMOptions.stream()
-                .forEach(s -> {
-                    sb.append(" ");
-                    sb.append(s);
-                });
-        this.remoteVMOptions = sb.toString();
-    }
-
-    void launch() throws IOException {
-        try (ServerSocket listener = new ServerSocket(0)) {
-            // timeout after 60 seconds
-            listener.setSoTimeout(60000);
-            int port = listener.getLocalPort();
-            jdiGo(port);
-            socket = listener.accept();
-            // out before in -- match remote creation so we don't hang
-            out = new ObjectOutputStream(socket.getOutputStream());
-            PipeInputStream commandIn = new PipeInputStream();
-            new DemultiplexInput(socket.getInputStream(), commandIn, proc.out, proc.err).start();
-            in = new ObjectInputStream(commandIn);
-        }
-    }
-
-    void commandExit() {
-        try {
-            if (out != null) {
-                out.writeInt(CMD_EXIT);
-                out.flush();
-            }
-            JDIConnection c = env.connection();
-            if (c != null) {
-                c.disposeVM();
-            }
-        } catch (IOException ex) {
-            proc.debug(DBG_GEN, "Exception on JDI exit: %s\n", ex);
-        }
-    }
-
-
-    boolean commandLoad(Collection<ClassInfo> cil) {
-        try {
-            out.writeInt(CMD_LOAD);
-            out.writeInt(cil.size());
-            for (ClassInfo ci : cil) {
-                out.writeUTF(ci.getClassName());
-                out.writeObject(ci.getBytes());
-            }
-            out.flush();
-            return readAndReportResult();
-        } catch (IOException ex) {
-            proc.debug(DBG_GEN, "IOException on remote load operation: %s\n", ex);
-            return false;
-        }
-    }
-
-    String commandInvoke(String classname) throws JShellException {
-        try {
-            synchronized (STOP_LOCK) {
-                userCodeRunning = true;
-            }
-            out.writeInt(CMD_INVOKE);
-            out.writeUTF(classname);
-            out.flush();
-            if (readAndReportExecutionResult()) {
-                String result = in.readUTF();
-                return result;
-            }
-        } catch (IOException | RuntimeException ex) {
-            if (!env.connection().isRunning()) {
-                env.shutdown();
-            } else {
-                proc.debug(DBG_GEN, "Exception on remote invoke: %s\n", ex);
-                return "Execution failure: " + ex.getMessage();
-            }
-        } finally {
-            synchronized (STOP_LOCK) {
-                userCodeRunning = false;
-            }
-        }
-        return "";
-    }
-
-    String commandVarValue(String classname, String varname) {
-        try {
-            out.writeInt(CMD_VARVALUE);
-            out.writeUTF(classname);
-            out.writeUTF(varname);
-            out.flush();
-            if (readAndReportResult()) {
-                String result = in.readUTF();
-                return result;
-            }
-        } catch (EOFException ex) {
-            env.shutdown();
-        } catch (IOException ex) {
-            proc.debug(DBG_GEN, "Exception on remote var value: %s\n", ex);
-            return "Execution failure: " + ex.getMessage();
-        }
-        return "";
-    }
-
-    boolean commandAddToClasspath(String cp) {
-        try {
-            out.writeInt(CMD_CLASSPATH);
-            out.writeUTF(cp);
-            out.flush();
-            return readAndReportResult();
-        } catch (IOException ex) {
-            throw new InternalError("Classpath addition failed: " + cp, ex);
-        }
-    }
-
-    boolean commandRedefine(Map<ReferenceType, byte[]> mp) {
-        try {
-            env.vm().redefineClasses(mp);
-            return true;
-        } catch (UnsupportedOperationException ex) {
-            return false;
-        } catch (Exception ex) {
-            proc.debug(DBG_GEN, "Exception on JDI redefine: %s\n", ex);
-            return false;
-        }
-    }
-
-    ReferenceType nameToRef(String name) {
-        List<ReferenceType> rtl = env.vm().classesByName(name);
-        if (rtl.size() != 1) {
-            return null;
-        }
-        return rtl.get(0);
-    }
-
-    private boolean readAndReportResult() throws IOException {
-        int ok = in.readInt();
-        switch (ok) {
-            case RESULT_SUCCESS:
-                return true;
-            case RESULT_FAIL: {
-                String ex = in.readUTF();
-                proc.debug(DBG_GEN, "Exception on remote operation: %s\n", ex);
-                return false;
-            }
-            default: {
-                proc.debug(DBG_GEN, "Bad remote result code: %s\n", ok);
-                return false;
-            }
-        }
-    }
-
-    private boolean readAndReportExecutionResult() throws IOException, JShellException {
-        int ok = in.readInt();
-        switch (ok) {
-            case RESULT_SUCCESS:
-                return true;
-            case RESULT_FAIL: {
-                String ex = in.readUTF();
-                proc.debug(DBG_GEN, "Exception on remote operation: %s\n", ex);
-                return false;
-            }
-            case RESULT_EXCEPTION: {
-                String exceptionClassName = in.readUTF();
-                String message = in.readUTF();
-                StackTraceElement[] elems = readStackTrace();
-                EvalException ee = new EvalException(message, exceptionClassName, elems);
-                throw ee;
-            }
-            case RESULT_CORRALLED: {
-                int id = in.readInt();
-                StackTraceElement[] elems = readStackTrace();
-                Snippet si = maps.getSnippetDeadOrAlive(id);
-                throw new UnresolvedReferenceException((DeclarationSnippet) si, elems);
-            }
-            case RESULT_KILLED: {
-                proc.out.println("Killed.");
-                return false;
-            }
-            default: {
-                proc.debug(DBG_GEN, "Bad remote result code: %s\n", ok);
-                return false;
-            }
-        }
-    }
-
-    private StackTraceElement[] readStackTrace() throws IOException {
-        int elemCount = in.readInt();
-        StackTraceElement[] elems = new StackTraceElement[elemCount];
-        for (int i = 0; i < elemCount; ++i) {
-            String className = in.readUTF();
-            String methodName = in.readUTF();
-            String fileName = in.readUTF();
-            int line = in.readInt();
-            elems[i] = new StackTraceElement(className, methodName, fileName, line);
-        }
-        return elems;
-    }
-
-    private void jdiGo(int port) {
-        //MessageOutput.textResources = ResourceBundle.getBundle("impl.TTYResources",
-        //        Locale.getDefault());
-
-        String connectorName = "com.sun.jdi.CommandLineLaunch";
-        Map<String, String> argumentName2Value = new HashMap<>();
-        argumentName2Value.put("main", "jdk.internal.jshell.remote.RemoteAgent " + port);
-        argumentName2Value.put("options", remoteVMOptions);
-
-        boolean launchImmediately = true;
-        int traceFlags = 0;// VirtualMachine.TRACE_SENDS | VirtualMachine.TRACE_EVENTS;
-
-        env.init(connectorName, argumentName2Value, launchImmediately, traceFlags);
-
-        if (env.connection().isOpen() && env.vm().canBeModified()) {
-            /*
-             * Connection opened on startup. Start event handler
-             * immediately, telling it (through arg 2) to stop on the
-             * VM start event.
-             */
-            handler = new JDIEventHandler(env);
-        }
-    }
-
-    private final Object STOP_LOCK = new Object();
-    private boolean userCodeRunning = false;
-
-    void commandStop() {
-        synchronized (STOP_LOCK) {
-            if (!userCodeRunning)
-                return ;
-
-            VirtualMachine vm = handler.env.vm();
-            vm.suspend();
-            try {
-                OUTER: for (ThreadReference thread : vm.allThreads()) {
-                    // could also tag the thread (e.g. using name), to find it easier
-                    for (StackFrame frame : thread.frames()) {
-                        String remoteAgentName = "jdk.internal.jshell.remote.RemoteAgent";
-                        if (remoteAgentName.equals(frame.location().declaringType().name()) &&
-                            "commandLoop".equals(frame.location().method().name())) {
-                            ObjectReference thiz = frame.thisObject();
-                            if (((BooleanValue) thiz.getValue(thiz.referenceType().fieldByName("inClientCode"))).value()) {
-                                thiz.setValue(thiz.referenceType().fieldByName("expectingStop"), vm.mirrorOf(true));
-                                ObjectReference stopInstance = (ObjectReference) thiz.getValue(thiz.referenceType().fieldByName("stopException"));
-
-                                vm.resume();
-                                proc.debug(DBG_GEN, "Attempting to stop the client code...\n");
-                                thread.stop(stopInstance);
-                                thiz.setValue(thiz.referenceType().fieldByName("expectingStop"), vm.mirrorOf(false));
-                            }
-
-                            break OUTER;
-                        }
-                    }
-                }
-            } catch (ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException  ex) {
-                proc.debug(DBG_GEN, "Exception on remote stop: %s\n", ex);
-            } finally {
-                vm.resume();
-            }
-        }
-    }
-
-    private final class DemultiplexInput extends Thread {
-
-        private final DataInputStream delegate;
-        private final PipeInputStream command;
-        private final PrintStream out;
-        private final PrintStream err;
-
-        public DemultiplexInput(InputStream input,
-                                         PipeInputStream command,
-                                         PrintStream out,
-                                         PrintStream err) {
-            super("output reader");
-            this.delegate = new DataInputStream(input);
-            this.command = command;
-            this.out = out;
-            this.err = err;
-        }
-
-        public void run() {
-            try {
-                while (true) {
-                    int nameLen = delegate.read();
-                    if (nameLen == (-1))
-                        break;
-                    byte[] name = new byte[nameLen];
-                    DemultiplexInput.this.delegate.readFully(name);
-                    int dataLen = delegate.read();
-                    byte[] data = new byte[dataLen];
-                    DemultiplexInput.this.delegate.readFully(data);
-                    switch (new String(name, "UTF-8")) {
-                        case "err":
-                            err.write(data);
-                            break;
-                        case "out":
-                            out.write(data);
-                            break;
-                        case "command":
-                            for (byte b : data) {
-                                command.write(Byte.toUnsignedInt(b));
-                            }
-                            break;
-                    }
-                }
-            } catch (IOException ex) {
-                proc.debug(ex, "Failed reading output");
-            } finally {
-                command.close();
-            }
-        }
-
-    }
-
-    public static final class PipeInputStream extends InputStream {
-        public static final int INITIAL_SIZE = 128;
-
-        private int[] buffer = new int[INITIAL_SIZE];
-        private int start;
-        private int end;
-        private boolean closed;
-
-        @Override
-        public synchronized int read() {
-            while (start == end) {
-                if (closed) {
-                    return -1;
-                }
-                try {
-                    wait();
-                } catch (InterruptedException ex) {
-                    //ignore
-                }
-            }
-            try {
-                return buffer[start];
-            } finally {
-                start = (start + 1) % buffer.length;
-            }
-        }
-
-        public synchronized void write(int b) {
-            if (closed)
-                throw new IllegalStateException("Already closed.");
-            int newEnd = (end + 1) % buffer.length;
-            if (newEnd == start) {
-                //overflow:
-                int[] newBuffer = new int[buffer.length * 2];
-                int rightPart = (end > start ? end : buffer.length) - start;
-                int leftPart = end > start ? 0 : start - 1;
-                System.arraycopy(buffer, start, newBuffer, 0, rightPart);
-                System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart);
-                buffer = newBuffer;
-                start = 0;
-                end = rightPart + leftPart;
-                newEnd = end + 1;
-            }
-            buffer[end] = b;
-            end = newEnd;
-            notifyAll();
-        }
-
-        @Override
-        public synchronized void close() {
-            closed = true;
-            notifyAll();
-        }
-
-    }
-}
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
index 8b95bbd..f2a1496 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
@@ -25,6 +25,7 @@
 
 package jdk.jshell;
 
+import jdk.jshell.spi.ExecutionControl;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.PrintStream;
@@ -47,6 +48,8 @@
 import static java.util.stream.Collectors.toList;
 import static jdk.jshell.Util.expunge;
 import jdk.jshell.Snippet.Status;
+import jdk.internal.jshell.jdi.JDIExecutionControl;
+import jdk.jshell.spi.ExecutionEnv;
 
 /**
  * The JShell evaluation state engine.  This is the central class in the JShell
@@ -71,7 +74,6 @@
  * <p>
  * This class is not thread safe, except as noted, all access should be through
  * a single thread.
- * @see jdk.jshell
  * @author Robert Field
  */
 public class JShell implements AutoCloseable {
@@ -86,16 +88,17 @@
     final Supplier<String> tempVariableNameGenerator;
     final BiFunction<Snippet, Integer, String> idGenerator;
     final List<String> extraRemoteVMOptions;
+    final ExecutionControl executionControl;
 
     private int nextKeyIndex = 1;
 
     final Eval eval;
-    final ClassTracker classTracker;
+    private final Map<String, byte[]> classnameToBytes = new HashMap<>();
     private final Map<Subscription, Consumer<JShell>> shutdownListeners = new HashMap<>();
     private final Map<Subscription, Consumer<SnippetEvent>> keyStatusListeners = new HashMap<>();
     private boolean closed = false;
 
-    private ExecutionControl executionControl = null;
+    private boolean executionControlLaunched = false;
     private SourceCodeAnalysisImpl sourceCodeAnalysis = null;
 
     private static final String L10N_RB_NAME    = "jdk.jshell.resources.l10n";
@@ -108,13 +111,15 @@
         this.tempVariableNameGenerator = b.tempVariableNameGenerator;
         this.idGenerator = b.idGenerator;
         this.extraRemoteVMOptions = b.extraRemoteVMOptions;
+        this.executionControl = b.executionControl==null
+                ? new JDIExecutionControl()
+                : b.executionControl;
 
         this.maps = new SnippetMaps(this);
         this.keyMap = new KeyMap(this);
         this.outerMap = new OuterWrapMap(this);
         this.taskFactory = new TaskFactory(this);
         this.eval = new Eval(this);
-        this.classTracker = new ClassTracker(this);
     }
 
     /**
@@ -143,22 +148,23 @@
         Supplier<String> tempVariableNameGenerator = null;
         BiFunction<Snippet, Integer, String> idGenerator = null;
         List<String> extraRemoteVMOptions = new ArrayList<>();
+        ExecutionControl executionControl;
 
         Builder() { }
 
         /**
-         * Input for the running evaluation (it's <code>System.in</code>). Note:
-         * applications that use <code>System.in</code> for snippet or other
-         * user input cannot use <code>System.in</code> as the input stream for
+         * Sets the input for the running evaluation (it's {@code System.in}). Note:
+         * applications that use {@code System.in} for snippet or other
+         * user input cannot use {@code System.in} as the input stream for
          * the remote process.
          * <p>
          * The default, if this is not set, is to provide an empty input stream
-         * -- <code>new ByteArrayInputStream(new byte[0])</code>.
+         * -- {@code new ByteArrayInputStream(new byte[0])}.
          *
-         * @param in the <code>InputStream</code> to be channelled to
-         * <code>System.in</code> in the remote execution process.
-         * @return the <code>Builder</code> instance (for use in chained
-         * initialization).
+         * @param in the {@code InputStream} to be channelled to
+         * {@code System.in} in the remote execution process
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
          */
         public Builder in(InputStream in) {
             this.in = in;
@@ -166,16 +172,16 @@
         }
 
         /**
-         * Output for the running evaluation (it's <code>System.out</code>).
+         * Sets the output for the running evaluation (it's {@code System.out}).
          * The controlling process and
-         * the remote process can share <code>System.out</code>.
+         * the remote process can share {@code System.out}.
          * <p>
-         * The default, if this is not set, is <code>System.out</code>.
+         * The default, if this is not set, is {@code System.out}.
          *
-         * @param out the <code>PrintStream</code> to be channelled to
-         * <code>System.out</code> in the remote execution process.
-         * @return the <code>Builder</code> instance (for use in chained
-         * initialization).
+         * @param out the {@code PrintStream} to be channelled to
+         * {@code System.out} in the remote execution process
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
          */
         public Builder out(PrintStream out) {
             this.out = out;
@@ -183,16 +189,16 @@
         }
 
         /**
-         * Error output for the running evaluation (it's
-         * <code>System.err</code>). The controlling process and the remote
-         * process can share <code>System.err</code>.
+         * Sets the error output for the running evaluation (it's
+         * {@code System.err}). The controlling process and the remote
+         * process can share {@code System.err}.
          * <p>
-         * The default, if this is not set, is <code>System.err</code>.
+         * The default, if this is not set, is {@code System.err}.
          *
-         * @param err the <code>PrintStream</code> to be channelled to
-         * <code>System.err</code> in the remote execution process.
-         * @return the <code>Builder</code> instance (for use in chained
-         * initialization).
+         * @param err the {@code PrintStream} to be channelled to
+         * {@code System.err} in the remote execution process
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
          */
         public Builder err(PrintStream err) {
             this.err = err;
@@ -200,7 +206,7 @@
         }
 
         /**
-         * Set a generator of temp variable names for
+         * Sets a generator of temp variable names for
          * {@link jdk.jshell.VarSnippet} of
          * {@link jdk.jshell.Snippet.SubKind#TEMP_VAR_EXPRESSION_SUBKIND}.
          * <p>
@@ -221,9 +227,9 @@
          * prefixing dollar sign ("$").
          *
          * @param generator the <code>Supplier</code> to generate the temporary
-         * variable name string or <code>null</code>.
-         * @return the <code>Builder</code> instance (for use in chained
-         * initialization).
+         * variable name string or <code>null</code>
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
          */
         public Builder tempVariableNameGenerator(Supplier<String> generator) {
             this.tempVariableNameGenerator = generator;
@@ -231,7 +237,7 @@
         }
 
         /**
-         * Set the generator of identifying names for Snippets.
+         * Sets the generator of identifying names for Snippets.
          * <p>
          * Do not use this method unless you have explicit need for it.
          * <p>
@@ -258,9 +264,9 @@
          * is null) is to generate the id as the integer converted to a string.
          *
          * @param generator the <code>BiFunction</code> to generate the id
-         * string or <code>null</code>.
-         * @return the <code>Builder</code> instance (for use in chained
-         * initialization).
+         * string or <code>null</code>
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
          */
         public Builder idGenerator(BiFunction<Snippet, Integer, String> generator) {
             this.idGenerator = generator;
@@ -268,11 +274,11 @@
         }
 
         /**
-         * Set additional VM options for launching the VM.
+         * Sets additional VM options for launching the VM.
          *
-         * @param options The options for the remote VM.
-         * @return the <code>Builder</code> instance (for use in chained
-         * initialization).
+         * @param options The options for the remote VM
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
          */
         public Builder remoteVMOptions(String... options) {
             this.extraRemoteVMOptions.addAll(Arrays.asList(options));
@@ -280,11 +286,24 @@
         }
 
         /**
-         * Build a JShell state engine. This is the entry-point to all JShell
+         * Sets the custom engine for execution. Snippet execution will be
+         * provided by the specified {@link ExecutionControl} instance.
+         *
+         * @param execEngine the execution engine
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
+         */
+        public Builder executionEngine(ExecutionControl execEngine) {
+            this.executionControl = execEngine;
+            return this;
+        }
+
+        /**
+         * Builds a JShell state engine. This is the entry-point to all JShell
          * functionality. This creates a remote process for execution. It is
          * thus important to close the returned instance.
          *
-         * @return the state engine.
+         * @return the state engine
          */
         public JShell build() {
             return new JShell(this);
@@ -406,7 +425,7 @@
      */
     public void addToClasspath(String path) {
         taskFactory.addToClasspath(path);  // Compiler
-        executionControl().commandAddToClasspath(path);       // Runtime
+        executionControl().addToClasspath(path);       // Runtime
         if (sourceCodeAnalysis != null) {
             sourceCodeAnalysis.classpathChanged();
         }
@@ -427,7 +446,7 @@
      */
     public void stop() {
         if (executionControl != null)
-            executionControl.commandStop();
+            executionControl.stop();
     }
 
     /**
@@ -438,7 +457,7 @@
     public void close() {
         if (!closed) {
             closeDown();
-            executionControl().commandExit();
+            executionControl().close();
         }
     }
 
@@ -580,7 +599,7 @@
             throw new IllegalArgumentException(
                     messageFormat("jshell.exc.var.not.valid",  snippet, snippet.status()));
         }
-        String value = executionControl().commandVarValue(snippet.classFullName(), snippet.name());
+        String value = executionControl().varValue(snippet.classFullName(), snippet.name());
         return expunge(value);
     }
 
@@ -633,35 +652,86 @@
         }
     }
 
-    // --- private / package-private implementation support ---
+    /**
+     * Provide the environment for a execution engine.
+     */
+    class ExecutionEnvImpl implements ExecutionEnv {
 
+        @Override
+        public InputStream userIn() {
+            return in;
+        }
+
+        @Override
+        public PrintStream userOut() {
+            return out;
+        }
+
+        @Override
+        public PrintStream userErr() {
+            return err;
+        }
+
+        @Override
+        public JShell state() {
+            return JShell.this;
+        }
+
+        @Override
+        public List<String> extraRemoteVMOptions() {
+            return extraRemoteVMOptions;
+        }
+
+        @Override
+        public byte[] getClassBytes(String classname) {
+            return classnameToBytes.get(classname);
+        }
+
+        @Override
+        public EvalException createEvalException(String message, String exceptionClass, StackTraceElement[] stackElements) {
+            return new EvalException(message, exceptionClass, stackElements);
+        }
+
+        @Override
+        public UnresolvedReferenceException createUnresolvedReferenceException(int id, StackTraceElement[] stackElements) {
+            DeclarationSnippet sn = (DeclarationSnippet) maps.getSnippetDeadOrAlive(id);
+            return new UnresolvedReferenceException(sn, stackElements);
+        }
+
+        @Override
+        public void closeDown() {
+            JShell.this.closeDown();
+        }
+    }
+
+    // --- private / package-private implementation support ---
     ExecutionControl executionControl() {
-        if (executionControl == null) {
-            this.executionControl = new ExecutionControl(new JDIEnv(this), maps, this, extraRemoteVMOptions);
+        if (!executionControlLaunched) {
             try {
-                executionControl.launch();
+                executionControlLaunched = true;
+                executionControl.start(new ExecutionEnvImpl());
             } catch (Throwable ex) {
-                throw new InternalError("Launching JDI execution engine threw: " + ex.getMessage(), ex);
+                throw new InternalError("Launching execution engine threw: " + ex.getMessage(), ex);
             }
         }
         return executionControl;
     }
 
+    void setClassnameToBytes(String classname, byte[] bytes) {
+        classnameToBytes.put(classname, bytes);
+    }
+
     void debug(int flags, String format, Object... args) {
-        if (InternalDebugControl.debugEnabled(this, flags)) {
-            err.printf(format, args);
-        }
+        InternalDebugControl.debug(this, err, flags, format, args);
     }
 
     void debug(Exception ex, String where) {
-        if (InternalDebugControl.debugEnabled(this, 0xFFFFFFFF)) {
-            err.printf("Fatal error: %s: %s\n", where, ex.getMessage());
-            ex.printStackTrace(err);
-        }
+        InternalDebugControl.debug(this, err, ex, where);
     }
 
     /**
      * Generate the next key index, indicating a unique snippet signature.
+     *
      * @return the next key index
      */
     int nextKeyIndex() {
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java
index f61d8b4..8cb1ae8 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java
@@ -28,9 +28,11 @@
 import java.util.Locale;
 import javax.tools.Diagnostic;
 import javax.tools.JavaFileObject;
-import jdk.internal.jshell.remote.RemoteCodes;
-import static jdk.jshell.Util.*;
-import static jdk.internal.jshell.remote.RemoteCodes.REPL_PACKAGE;
+import static jdk.jshell.Util.PARSED_LOCALE;
+import static jdk.jshell.Util.REPL_CLASS_PREFIX;
+import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME;
+import static jdk.jshell.Util.REPL_PACKAGE;
+import static jdk.jshell.Util.expunge;
 
 /**
  *
@@ -163,7 +165,7 @@
             }
             for (String line : diag.getMessage(PARSED_LOCALE).split("\\r?\\n")) {
                 if (line.trim().startsWith("location:")) {
-                    if (!line.contains(RemoteCodes.REPL_CLASS_PREFIX)) {
+                    if (!line.contains(REPL_CLASS_PREFIX)) {
                         // Resolution error must occur within a REPL class or it is not resolvable
                         return false;
                     }
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrapMap.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrapMap.java
index 1576ebe..29f4351 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrapMap.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrapMap.java
@@ -35,8 +35,8 @@
 import java.util.regex.Matcher;
 import java.util.stream.Collectors;
 import jdk.jshell.Wrap.CompoundWrap;
-import static jdk.internal.jshell.remote.RemoteCodes.PREFIX_PATTERN;
-import static jdk.internal.jshell.remote.RemoteCodes.REPL_CLASS_PREFIX;
+import static jdk.jshell.Util.PREFIX_PATTERN;
+import static jdk.jshell.Util.REPL_CLASS_PREFIX;
 import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME;
 import static jdk.jshell.Util.asLetters;
 
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetMaps.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetMaps.java
index 9d0a485..7c2dc38 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetMaps.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetMaps.java
@@ -38,9 +38,9 @@
 import java.util.stream.Stream;
 
 import static java.util.stream.Collectors.toList;
-import static jdk.internal.jshell.remote.RemoteCodes.PREFIX_PATTERN;
+import static jdk.jshell.Util.PREFIX_PATTERN;
+import static jdk.jshell.Util.REPL_PACKAGE;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_DEP;
-import static jdk.internal.jshell.remote.RemoteCodes.REPL_PACKAGE;
 
 /**
  * Maintain relationships between the significant entities: Snippets,
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
index 50959ba..efbd2c7 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
@@ -104,7 +104,6 @@
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import static java.util.stream.Collectors.collectingAndThen;
-import static java.util.stream.Collectors.joining;
 import static java.util.stream.Collectors.toCollection;
 import static java.util.stream.Collectors.toList;
 import static java.util.stream.Collectors.toSet;
@@ -130,6 +129,7 @@
 import javax.tools.ToolProvider;
 
 import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME;
+import static java.util.stream.Collectors.joining;
 
 /**
  * The concrete implementation of SourceCodeAnalysis.
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java
index fe0a3b7..df6d856 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java
@@ -60,8 +60,7 @@
 import javax.lang.model.util.Elements;
 import javax.tools.FileObject;
 import jdk.jshell.MemoryFileManager.SourceMemoryJavaFileObject;
-import jdk.jshell.ClassTracker.ClassInfo;
-import jdk.Version;
+import java.lang.Runtime.Version;
 
 /**
  * The primary interface to the compiler API.  Parsing, analysis, and
@@ -278,13 +277,19 @@
             return result;
         }
 
-
-        List<ClassInfo> classInfoList(OuterWrap w) {
+        // Returns the list of classes generated during this compile.
+        // Stores the mapping between class name and current compiled bytes.
+        List<String> classList(OuterWrap w) {
             List<OutputMemoryJavaFileObject> l = classObjs.get(w);
-            if (l == null) return Collections.emptyList();
-            return l.stream()
-                    .map(fo -> state.classTracker.classInfo(fo.getName(), fo.getBytes()))
-                    .collect(Collectors.toList());
+            if (l == null) {
+                return Collections.emptyList();
+            }
+            List<String> list = new ArrayList<>();
+            for (OutputMemoryJavaFileObject fo : l) {
+                state.setClassnameToBytes(fo.getName(), fo.getBytes());
+                list.add(fo.getName());
+            }
+            return list;
         }
 
         private void listenForNewClassFile(OutputMemoryJavaFileObject jfo, JavaFileManager.Location location,
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java
index 987dc6b..bc1839e 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java
@@ -30,18 +30,14 @@
 import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.stream.Stream;
-import com.sun.jdi.ReferenceType;
 import jdk.jshell.Snippet.Kind;
 import jdk.jshell.Snippet.Status;
 import jdk.jshell.Snippet.SubKind;
 import jdk.jshell.TaskFactory.AnalyzeTask;
-import jdk.jshell.ClassTracker.ClassInfo;
 import jdk.jshell.TaskFactory.CompileTask;
 import static java.util.stream.Collectors.toList;
-import static java.util.stream.Collectors.toMap;
 import static java.util.stream.Collectors.toSet;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
@@ -79,7 +75,7 @@
     private SnippetEvent replaceOldEvent;
     private List<SnippetEvent> secondaryEvents;
     private boolean isAttemptingCorral;
-    private List<ClassInfo> toRedefine;
+    private List<String> toRedefine;
     private boolean dependenciesNeeded;
 
     Unit(JShell state, Snippet si, Snippet causalSnippet,
@@ -260,10 +256,6 @@
                 si, status);
     }
 
-    /**
-     * Must be called for each unit
-     * @return
-     */
     boolean isDefined() {
         return status.isDefined;
     }
@@ -273,21 +265,28 @@
      * Requires loading of returned list.
      * @return the list of classes to load
      */
-    Stream<ClassInfo> classesToLoad(List<ClassInfo> cil) {
+    Stream<String> classesToLoad(List<String> classnames) {
         toRedefine = new ArrayList<>();
-        List<ClassInfo> toLoad = new ArrayList<>();
+        List<String> toLoad = new ArrayList<>();
         if (status.isDefined && !isImport()) {
-            cil.stream().forEach(ci -> {
-                if (!ci.isLoaded()) {
-                    if (ci.getReferenceTypeOrNull() == null) {
-                        toLoad.add(ci);
-                        ci.setLoaded();
+            // Classes should only be loaded/redefined if the compile left them
+            // in a defined state.  Imports do not have code and are not loaded.
+            for (String cn : classnames) {
+                switch (state.executionControl().getClassStatus(cn)) {
+                    case UNKNOWN:
+                        // If not loaded, add to the list of classes to load.
+                        toLoad.add(cn);
                         dependenciesNeeded = true;
-                    } else {
-                        toRedefine.add(ci);
-                    }
+                        break;
+                    case NOT_CURRENT:
+                        // If loaded but out of date, add to the list of classes to attempt redefine.
+                        toRedefine.add(cn);
+                        break;
+                    case CURRENT:
+                        // Loaded and current, so nothing to do
+                        break;
                 }
-            });
+            }
         }
         return toLoad.stream();
     }
@@ -298,19 +297,9 @@
      * @return true if all redefines succeeded (can be vacuously true)
      */
     boolean doRedefines() {
-         if (toRedefine.isEmpty()) {
-            return true;
-        }
-        Map<ReferenceType, byte[]> mp = toRedefine.stream()
-                .collect(toMap(ci -> ci.getReferenceTypeOrNull(), ci -> ci.getBytes()));
-        if (state.executionControl().commandRedefine(mp)) {
-            // success, mark as loaded
-            toRedefine.stream().forEach(ci -> ci.setLoaded());
-            return true;
-        } else {
-            // failed to redefine
-            return false;
-        }
+        return toRedefine.isEmpty()
+                ? true
+                : state.executionControl().redefine(toRedefine);
     }
 
     void markForReplacement() {
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java
index 413c30b..3127753 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,20 +29,40 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Locale;
+import java.util.regex.Pattern;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 import javax.lang.model.element.Name;
-import static jdk.internal.jshell.remote.RemoteCodes.DOIT_METHOD_NAME;
-import static jdk.internal.jshell.remote.RemoteCodes.PREFIX_PATTERN;
-import static jdk.internal.jshell.remote.RemoteCodes.REPL_CLASS_PREFIX;
 
 /**
- * Assorted shared utilities.
- * @author Robert Field
+ * Assorted shared utilities and constants.
  */
 class Util {
 
-    static final String REPL_DOESNOTMATTER_CLASS_NAME = REPL_CLASS_PREFIX+"DOESNOTMATTER";
+    /**
+     * The package name of all wrapper classes.
+     */
+    static final String REPL_PACKAGE = "REPL";
+
+    /**
+     * The prefix for all wrapper class names.
+     */
+    static final String REPL_CLASS_PREFIX = "$JShell$";
+
+    /**
+     * The name of the invoke method.
+     */
+    static final String DOIT_METHOD_NAME = "do_it$";
+
+    /**
+     * A pattern matching the full or simple class name of a wrapper class.
+     */
+    static final Pattern PREFIX_PATTERN = Pattern.compile(
+            "(" + REPL_PACKAGE + "\\.)?"
+            + "(?<class>" + Pattern.quote(REPL_CLASS_PREFIX)
+            + "\\w+" + ")" + "[\\$\\.]?");
+
+    static final String REPL_DOESNOTMATTER_CLASS_NAME = REPL_CLASS_PREFIX + "DOESNOTMATTER";
 
     static final Locale PARSED_LOCALE = Locale.ROOT;
 
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java
index 873a0d1..3b4e4cb 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java
@@ -27,7 +27,7 @@
 
 import java.util.Arrays;
 import static java.util.stream.Collectors.joining;
-import static jdk.internal.jshell.remote.RemoteCodes.DOIT_METHOD_NAME;
+import static jdk.jshell.Util.DOIT_METHOD_NAME;
 
 /**
  * Wrapping of source into Java methods, fields, etc.  All but outer layer
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java
new file mode 100644
index 0000000..d0af4ba
--- /dev/null
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.jshell.spi;
+
+import java.util.Collection;
+import jdk.jshell.JShellException;
+
+/**
+ * This interface specifies the functionality that must provided to implement
+ * a pluggable JShell execution engine.
+ * <p>
+ * The audience for this Service Provider Interface is engineers
+ * wishing to implement their own version of the execution engine in support
+ * of the JShell API.  This is NOT a part of the JShell API.
+ * <p>
+ * A Snippet is compiled into code wrapped in a 'wrapper class'.  The execution
+ * engine is used by the core JShell implementation to load and, for
+ * executable Snippets, execute the Snippet.
+ * <p>
+ * Methods defined in this interface should only be called by the core JShell
+ * implementation.
+ * <p>
+ * To install an instance of ExecutionControl, it is passed to
+ * {@link jdk.jshell.JShell.Builder#executionEngine(jdk.jshell.spi.ExecutionControl) }.
+ */
+public interface ExecutionControl {
+
+    /**
+     * Represents the current status of a class in the execution engine.
+     */
+    public enum ClassStatus {
+        /**
+         * Class is not known to the execution engine (not loaded).
+         */
+        UNKNOWN,
+
+        /**
+         * Class is loaded, but the loaded/redefined bytes do not match those
+         * returned by {@link ExecutionEnv#getClassBytes(java.lang.String) }.
+         */
+        NOT_CURRENT,
+
+        /**
+         * Class is loaded and loaded/redefined bytes match those
+         * returned by {@link ExecutionEnv#getClassBytes(java.lang.String) }.
+         */
+        CURRENT
+    };
+
+    /**
+     * Initializes the instance. No methods in this interface can be called
+     * before this.
+     *
+     * @param env the execution environment information provided by JShell
+     * @throws Exception if the instance is unable to initialize
+     */
+    void start(ExecutionEnv env) throws Exception;
+
+    /**
+     * Shuts down this execution engine. Implementation should free all
+     * resources held by this execution engine.
+     * <p>
+     * No calls to methods on this interface should be made after close.
+     */
+    void close();
+
+    /**
+     * Adds the path to the execution class path.
+     *
+     * @param path the path to add
+     * @return true if successful
+     */
+    boolean addToClasspath(String path);
+
+    /**
+     * Invokes an executable Snippet by calling a method on the specified
+     * wrapper class. The method must have no arguments and return String.
+     *
+     * @param classname the class whose method should be invoked
+     * @param methodname the name of method to invoke
+     * @return the result of the execution or null if no result
+     * @throws JShellException if a user exception if thrown,
+     * {@link jdk.jshell.EvalException EvalException} will be thrown; if an
+     * unresolved reference is encountered,
+     * {@link jdk.jshell.UnresolvedReferenceException UnresolvedReferenceException}
+     * will be thrown
+     */
+    String invoke(String classname, String methodname) throws JShellException;
+
+    /**
+     * Attempts to load new classes. Class bytes are retrieved from
+     * {@link ExecutionEnv#getClassBytes(java.lang.String) }
+     *
+     * @param classes list of class names to load
+     * @return true if load succeeded
+     */
+    boolean load(Collection<String> classes);
+
+    /**
+     * Attempts to redefine previously loaded classes. Class bytes are retrieved
+     * from {@link ExecutionEnv#getClassBytes(java.lang.String) }
+     *
+     * @param classes list of class names to redefine
+     * @return true if redefine succeeded
+     */
+    boolean redefine(Collection<String> classes);
+
+    /**
+     * Queries if the class is loaded and the class bytes are current.
+     *
+     * @param classname name of the wrapper class to query
+     * @return {@code UNKNOWN} if the class is not loaded; {@code CURRENT} if
+     * the loaded/redefined bytes are equal to the most recent bytes for this
+     * wrapper class; otherwise {@code NOT_CURRENT}
+     */
+    ClassStatus getClassStatus(String classname);
+
+    /**
+     * Interrupt a running invoke.
+     */
+    void stop();
+
+    /**
+     * Returns the value of a variable.
+     *
+     * @param classname the name of the wrapper class of the variable
+     * @param varname the name of the variable
+     * @return the value of the variable
+     */
+    String varValue(String classname, String varname);
+}
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionEnv.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionEnv.java
new file mode 100644
index 0000000..3c07ba0
--- /dev/null
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionEnv.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.jshell.spi;
+
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.List;
+import jdk.jshell.EvalException;
+import jdk.jshell.JShell;
+import jdk.jshell.UnresolvedReferenceException;
+
+/**
+ * Functionality made available to a pluggable JShell execution engine.  It is
+ * provided to the execution engine by the core JShell implementation calling
+ * {@link ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }.
+ * <p>
+ * This interface is designed to provide the access to core JShell functionality
+ * needed to implement ExecutionControl.
+ *
+ * @see ExecutionControl
+ */
+public interface ExecutionEnv {
+
+    /**
+     * Returns the user's input stream.
+     *
+     * @return the user's input stream
+     */
+    InputStream userIn();
+
+    /**
+     * Returns the user's output stream.
+     *
+     * @return the user's output stream
+     */
+    PrintStream userOut();
+
+    /**
+     * Returns the user's error stream.
+     *
+     * @return the user's error stream
+     */
+    PrintStream userErr();
+
+    /**
+     * @return the JShell instance
+     */
+    JShell state();
+
+    /**
+     * Returns the additional VM options to be used when launching the remote
+     * JVM. This is advice to the execution engine.
+     * <p>
+     * Note: an execution engine need not launch a remote JVM.
+     *
+     * @return the additional options with which to launch the remote JVM
+     */
+    List<String> extraRemoteVMOptions();
+
+    /**
+     * Retrieves the class file bytes for the specified wrapper class.
+     *
+     * @param className the name of the wrapper class
+     * @return the current class file bytes as a byte array
+     */
+    byte[] getClassBytes(String className);
+
+    /**
+     * Creates an {@code EvalException} corresponding to a user exception. An
+     * user exception thrown during
+     * {@link ExecutionControl#invoke(java.lang.String, java.lang.String) }
+     * should be converted to an {@code EvalException} using this method.
+     *
+     * @param message the exception message to use (from the user exception)
+     * @param exceptionClass the class name of the user exception
+     * @param stackElements the stack trace elements to install
+     * @return a user API EvalException for the user exception
+     */
+    EvalException createEvalException(String message, String exceptionClass,
+            StackTraceElement[] stackElements);
+
+    /**
+     * Creates an {@code UnresolvedReferenceException} for the Snippet identifed
+     * by the specified identifier. An {@link SPIResolutionException} thrown
+     * during {@link ExecutionControl#invoke(java.lang.String, java.lang.String) }
+     * should be converted to an {@code UnresolvedReferenceException} using
+     * this method.
+     * <p>
+     * The identifier is an internal id, different from the id in the API. This
+     * internal id is returned by {@link SPIResolutionException#id()}.
+     *
+     * @param id the internal integer identifier
+     * @param stackElements the stack trace elements to install
+     * @return an {@code UnresolvedReferenceException} for the unresolved
+     * reference
+     */
+    UnresolvedReferenceException createUnresolvedReferenceException(int id,
+            StackTraceElement[] stackElements);
+
+    /**
+     * Reports that the execution engine has shutdown.
+     */
+    void closeDown();
+}
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/SPIResolutionException.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/SPIResolutionException.java
new file mode 100644
index 0000000..07f7455
--- /dev/null
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/SPIResolutionException.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.jshell.spi;
+
+/**
+ * The construction and throw of this exception is embedded in code generated by
+ * the JShell core implementation in such a way that, upon executing a
+ * {@link jdk.jshell.Snippet.Status#RECOVERABLE_DEFINED RECOVERABLE_DEFINED}
+ * user method, this exception is thrown.
+ * <p>
+ * This exception is seen by the execution engine, but not seen by
+ * the end user nor through the JShell API.
+ *
+ * @see ExecutionEnv#createUnresolvedReferenceException(int,
+ * java.lang.StackTraceElement[])
+ */
+@SuppressWarnings("serial")             // serialVersionUID intentionally omitted
+public class SPIResolutionException extends RuntimeException {
+
+    private final int id;
+
+    /**
+     * Constructs an SPI layer exception indicating that a
+     * {@code DeclarationSnippet} with unresolved references has been
+     * encountered. The throw of this exception is generated into the body of a
+     * {@link jdk.jshell.Snippet.Status#RECOVERABLE_DEFINED RECOVERABLE_DEFINED}
+     * method.
+     *
+     * @param id An internal identifier of the specific method
+     */
+    public SPIResolutionException(int id) {
+        super("resolution exception");
+        this.id = id;
+    }
+
+    /**
+     * Retrieves the internal identifer of the unresolved identifer.
+     *
+     * @return the internal identifer
+     * @see ExecutionEnv#createUnresolvedReferenceException(int,
+     * java.lang.StackTraceElement[])
+     */
+    public int id() {
+        return id;
+    }
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/package-info.java
similarity index 63%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/package-info.java
index 9e5a4a7..744e13b 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/package-info.java
@@ -22,16 +22,18 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
-
-import java.util.Properties;
 
 /**
- * Interface to plugin (container) context.
+ * Provides support for alternate implementations of the JShell execution
+ * engine.  The JShell core tracks and compiles Snippets then sends them
+ * (represented in a wrapper class) to the execution engine for loading,
+ * and in the case of executable Snippets, execution.  The JShell
+ * implementation includes a default execution engine (currently a remote
+ * process which is JDI controlled).  By implementing the
+ * {@link ExecutionControl} interface and installing it with
+ * {@link jdk.jshell.JShell.Builder#executionEngine(jdk.jshell.spi.ExecutionControl) }
+ * other execution engines can be used.
+ * <p>
+ * This is not a part of the JShell API.
  */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
-}
+package jdk.jshell.spi;
diff --git a/langtools/src/jdk.jshell/share/classes/module-info.java b/langtools/src/jdk.jshell/share/classes/module-info.java
index 93b16ba..0959583 100644
--- a/langtools/src/jdk.jshell/share/classes/module-info.java
+++ b/langtools/src/jdk.jshell/share/classes/module-info.java
@@ -32,4 +32,5 @@
     requires jdk.jdi;
 
     exports jdk.jshell;
+    exports jdk.jshell.spi;
 }
diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt
index a7000de..0d1f870 100644
--- a/langtools/test/ProblemList.txt
+++ b/langtools/test/ProblemList.txt
@@ -66,7 +66,6 @@
 # javac
 
 tools/javac/Paths/AbsolutePathTest.java                                         8055768    generic-all    ToolBox does not close opened files
-tools/javac/Paths/MineField.sh                                                  8149599	   generic-all    needs rewrite
 tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java      8057679    generic-all    clarify error messages trying to annotate scoping
 tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java       8057679    generic-all    clarify error messages trying to annotate scoping
 tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java  8057679    generic-all    clarify error messages trying to annotate scoping
@@ -95,6 +94,3 @@
 #
 # jdeps 
 
-tools/jdeps/modules/GenModuleInfo.java                                          8152502,8153481    generic-all    fails to clean up files, java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode
-tools/jdeps/modules/ModuleTest.java                                             8153481    generic-all    java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode
-
diff --git a/langtools/test/jdk/jshell/CommandCompletionTest.java b/langtools/test/jdk/jshell/CommandCompletionTest.java
index 92a08fc..0a986a6 100644
--- a/langtools/test/jdk/jshell/CommandCompletionTest.java
+++ b/langtools/test/jdk/jshell/CommandCompletionTest.java
@@ -53,18 +53,18 @@
 
     public void testCommand() {
         assertCompletion("/deb|", false);
-        assertCompletion("/c|", false, "/classes ", "/classpath ");
+        assertCompletion("/re|", false, "/reload ", "/reset ", "/retain ");
         assertCompletion("/h|", false, "/help ", "/history ");
     }
 
     public void testList() {
         test(false, new String[] {"-nostartup"},
                 a -> assertCompletion(a, "/l|", false, "/list "),
-                a -> assertCompletion(a, "/list |", false, "all ", "history ", "start "),
-                a -> assertCompletion(a, "/list h|", false, "history "),
+                a -> assertCompletion(a, "/list |", false, "-all ", "-history ", "-start "),
+                a -> assertCompletion(a, "/list -h|", false, "-history "),
                 a -> assertCompletion(a, "/list q|", false),
                 a -> assertVariable(a, "int", "xray"),
-                a -> assertCompletion(a, "/list |", false, "1", "all ", "history ", "start ", "xray"),
+                a -> assertCompletion(a, "/list |", false, "-all ", "-history ", "-start ", "1", "xray"),
                 a -> assertCompletion(a, "/list x|", false, "xray")
         );
     }
@@ -108,7 +108,7 @@
         Compiler compiler = new Compiler();
         assertCompletion("/s|", false, "/save ", "/set ");
         List<String> p1 = listFiles(Paths.get(""));
-        Collections.addAll(p1, "all ", "history ", "start ");
+        Collections.addAll(p1, "-all ", "-history ", "-start ");
         FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString()));
         Collections.sort(p1);
         assertCompletion("/save |", false, p1.toArray(new String[p1.size()]));
@@ -116,7 +116,7 @@
         List<String> p2 = listFiles(classDir);
         assertCompletion("/save " + classDir + "/|",
                 false, p2.toArray(new String[p2.size()]));
-        assertCompletion("/save all " + classDir + "/|",
+        assertCompletion("/save -all " + classDir + "/|",
                 false, p2.toArray(new String[p2.size()]));
     }
 
diff --git a/langtools/test/jdk/jshell/EditorTestBase.java b/langtools/test/jdk/jshell/EditorTestBase.java
index c2bd55a..76ba66f 100644
--- a/langtools/test/jdk/jshell/EditorTestBase.java
+++ b/langtools/test/jdk/jshell/EditorTestBase.java
@@ -142,7 +142,7 @@
                     exit();
                     loadClass(true, "enum A {}", "enum", "A");
                 }),
-                a -> assertCommandCheckOutput(a, "/classes", assertClasses())
+                a -> assertCommandCheckOutput(a, "/types", assertClasses())
         );
     }
 
@@ -161,7 +161,7 @@
                     exit();
                     loadClass(true, "enum A {}", "enum", "A");
                 }),
-                a -> assertCommandCheckOutput(a, "/classes", assertClasses())
+                a -> assertCommandCheckOutput(a, "/types", assertClasses())
         );
     }
 
diff --git a/langtools/test/jdk/jshell/ExecutionControlTest.java b/langtools/test/jdk/jshell/ExecutionControlTest.java
new file mode 100644
index 0000000..2150384
--- /dev/null
+++ b/langtools/test/jdk/jshell/ExecutionControlTest.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8156101
+ * @summary Tests for ExecutionControl SPI
+ * @build KullaTesting LocalExecutionControl
+ * @run testng ExecutionControlTest
+ */
+
+
+import javax.tools.Diagnostic;
+
+import jdk.jshell.VarSnippet;
+import org.testng.annotations.Test;
+
+import static jdk.jshell.Snippet.Status.VALID;
+import static jdk.jshell.Snippet.SubKind.*;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.BeforeMethod;
+
+@Test
+public class ExecutionControlTest extends KullaTesting {
+
+    @BeforeMethod
+    @Override
+    public void setUp() {
+        setUp(new LocalExecutionControl());
+    }
+
+    public void verifyLocal() throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
+        System.setProperty("LOCAL_CHECK", "TBD");
+        assertEquals(System.getProperty("LOCAL_CHECK"), "TBD");
+        assertEval("System.setProperty(\"LOCAL_CHECK\", \"local\")");
+        assertEquals(System.getProperty("LOCAL_CHECK"), "local");
+    }
+
+    public void classesDeclaration() {
+        assertEval("interface A { }");
+        assertEval("class B implements A { }");
+        assertEval("interface C extends A { }");
+        assertEval("enum D implements C { }");
+        assertEval("@interface E { }");
+        assertClasses(
+                clazz(KullaTesting.ClassType.INTERFACE, "A"),
+                clazz(KullaTesting.ClassType.CLASS, "B"),
+                clazz(KullaTesting.ClassType.INTERFACE, "C"),
+                clazz(KullaTesting.ClassType.ENUM, "D"),
+                clazz(KullaTesting.ClassType.ANNOTATION, "E"));
+        assertActiveKeys();
+    }
+
+    @Test
+    public void interfaceTest() {
+        String interfaceSource
+                = "interface A {\n"
+                + "   default int defaultMethod() { return 1; }\n"
+                + "   static int staticMethod() { return 2; }\n"
+                + "   int method();\n"
+                + "   class Inner1 {}\n"
+                + "   static class Inner2 {}\n"
+                + "}";
+        assertEval(interfaceSource);
+        assertEval("A.staticMethod();", "2");
+        String classSource
+                = "class B implements A {\n"
+                + "   public int method() { return 3; }\n"
+                + "}";
+        assertEval(classSource);
+        assertEval("B b = new B();");
+        assertEval("b.defaultMethod();", "1");
+        assertDeclareFail("B.staticMethod();",
+                new ExpectedDiagnostic("compiler.err.cant.resolve.location.args", 0, 14, 1, -1, -1, Diagnostic.Kind.ERROR));
+        assertEval("b.method();", "3");
+        assertEval("new A.Inner1();");
+        assertEval("new A.Inner2();");
+        assertEval("new B.Inner1();");
+        assertEval("new B.Inner2();");
+    }
+
+    public void variables() {
+        VarSnippet snx = varKey(assertEval("int x = 10;"));
+        VarSnippet sny = varKey(assertEval("String y = \"hi\";"));
+        VarSnippet snz = varKey(assertEval("long z;"));
+        assertVariables(variable("int", "x"), variable("String", "y"), variable("long", "z"));
+        assertVarValue(snx, "10");
+        assertVarValue(sny, "\"hi\"");
+        assertVarValue(snz, "0");
+        assertActiveKeys();
+    }
+
+    public void methodOverload() {
+        assertEval("int m() { return 1; }");
+        assertEval("int m(int x) { return 2; }");
+        assertEval("int m(String s) { return 3; }");
+        assertEval("int m(int x, int y) { return 4; }");
+        assertEval("int m(int x, String z) { return 5; }");
+        assertEval("int m(int x, String z, long g) { return 6; }");
+        assertMethods(
+                method("()int", "m"),
+                method("(int)int", "m"),
+                method("(String)int", "m"),
+                method("(int,int)int", "m"),
+                method("(int,String)int", "m"),
+                method("(int,String,long)int", "m")
+        );
+        assertEval("m();", "1");
+        assertEval("m(3);", "2");
+        assertEval("m(\"hi\");", "3");
+        assertEval("m(7, 8);", "4");
+        assertEval("m(7, \"eight\");", "5");
+        assertEval("m(7, \"eight\", 9L);", "6");
+        assertActiveKeys();
+    }
+
+    public void testExprSanity() {
+        assertEval("int x = 3;", "3");
+        assertEval("int y = 4;", "4");
+        assertEval("x + y;", "7");
+        assertActiveKeys();
+    }
+
+    public void testImportOnDemand() {
+        assertImportKeyMatch("import java.util.*;", "java.util.*", TYPE_IMPORT_ON_DEMAND_SUBKIND, added(VALID));
+        assertEval("List<Integer> list = new ArrayList<>();");
+        assertEval("list.add(45);");
+        assertEval("list.size();", "1");
+    }
+}
diff --git a/langtools/test/jdk/jshell/HistoryTest.java b/langtools/test/jdk/jshell/HistoryTest.java
index 0fa42b1..3513e77 100644
--- a/langtools/test/jdk/jshell/HistoryTest.java
+++ b/langtools/test/jdk/jshell/HistoryTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,152 +24,64 @@
 /*
  * @test
  * @summary Test Completion
- * @modules jdk.jshell/jdk.internal.jshell.tool
- *          jdk.internal.le/jdk.internal.jline.console.history
+ * @modules jdk.internal.le/jdk.internal.jline.extra
+ *          jdk.jshell/jdk.internal.jshell.tool
  * @build HistoryTest
  * @run testng HistoryTest
  */
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.prefs.AbstractPreferences;
-import java.util.prefs.BackingStoreException;
-import jdk.internal.jline.console.history.MemoryHistory;
-
-import jdk.jshell.JShell;
-import jdk.jshell.SourceCodeAnalysis;
-import jdk.jshell.SourceCodeAnalysis.CompletionInfo;
+import java.lang.reflect.Field;
+import jdk.internal.jline.extra.EditingHistory;
 import org.testng.annotations.Test;
-import jdk.internal.jshell.tool.EditingHistory;
-
 import static org.testng.Assert.*;
 
 @Test
-public class HistoryTest {
+public class HistoryTest extends ReplToolTesting {
 
     public void testHistory() {
-        JShell eval = JShell.builder()
-                .in(new ByteArrayInputStream(new byte[0]))
-                .out(new PrintStream(new ByteArrayOutputStream()))
-                .err(new PrintStream(new ByteArrayOutputStream()))
-                .build();
-        SourceCodeAnalysis analysis = eval.sourceCodeAnalysis();
-        MemoryPreferences prefs = new MemoryPreferences(null, "");
-        EditingHistory history = new EditingHistory(prefs) {
-            @Override protected CompletionInfo analyzeCompletion(String input) {
-                return analysis.analyzeCompletion(input);
-            }
-        };
-        history.add("void test() {");
-        history.add("    System.err.println(1);");
-        history.add("}");
-        history.add("/exit");
-
-        previousAndAssert(history, "/exit");
-
-        history.previous(); history.previous(); history.previous();
-
-        history.add("void test() { /*changed*/");
-
-        previousAndAssert(history, "}");
-        previousAndAssert(history, "    System.err.println(1);");
-        previousAndAssert(history, "void test() {");
-
-        assertFalse(history.previous());
-
-        nextAndAssert(history, "    System.err.println(1);");
-        nextAndAssert(history, "}");
-        nextAndAssert(history, "");
-
-        history.add("    System.err.println(2);");
-        history.add("} /*changed*/");
-
-        assertEquals(history.size(), 7);
-
-        history.save();
-
-        history = new EditingHistory(prefs) {
-            @Override protected CompletionInfo analyzeCompletion(String input) {
-                return analysis.analyzeCompletion(input);
-            }
-        };
-
-        previousSnippetAndAssert(history, "void test() { /*changed*/");
-        previousSnippetAndAssert(history, "/exit");
-        previousSnippetAndAssert(history, "void test() {");
-
-        assertFalse(history.previousSnippet());
-
-        nextSnippetAndAssert(history, "/exit");
-        nextSnippetAndAssert(history, "void test() { /*changed*/");
-        nextSnippetAndAssert(history, "");
-
-        assertFalse(history.nextSnippet());
-
-        history.add("{");
-        history.add("}");
-
-        history.save();
-
-        history = new EditingHistory(prefs) {
-            @Override protected CompletionInfo analyzeCompletion(String input) {
-                return analysis.analyzeCompletion(input);
-            }
-        };
-
-        previousSnippetAndAssert(history, "{");
-        previousSnippetAndAssert(history, "void test() { /*changed*/");
-        previousSnippetAndAssert(history, "/exit");
-        previousSnippetAndAssert(history, "void test() {");
-
-        while (history.next());
-
-        history.add("/*current1*/");
-        history.add("/*current2*/");
-        history.add("/*current3*/");
-
-        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
-
-        history.remove(0);
-
-        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
-
-        while (history.size() > 2)
-            history.remove(0);
-
-        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current2*/", "/*current3*/"));
-
-        for (int i = 0; i < MemoryHistory.DEFAULT_MAX_SIZE * 2; i++) {
-            history.add("/exit");
-        }
-
-        history.add("void test() { /*after full*/");
-        history.add("    System.err.println(1);");
-        history.add("}");
-
-        previousSnippetAndAssert(history, "void test() { /*after full*/");
+        test(
+             a -> {if (!a) setCommandInput("void test() {\n");},
+             a -> {if (!a) setCommandInput("    System.err.println(1);\n");},
+             a -> {if (!a) setCommandInput("    System.err.println(1);\n");},
+             a -> {assertCommand(a, "} //test", "|  created method test()");},
+             a -> {
+                 if (!a) {
+                     try {
+                         previousAndAssert(getHistory(), "} //test");
+                         previousSnippetAndAssert(getHistory(), "void test() {");
+                     } catch (Exception ex) {
+                         throw new IllegalStateException(ex);
+                     }
+                 }
+                 assertCommand(a, "int dummy;", "dummy ==> 0");
+             });
+        test(
+             a -> {if (!a) setCommandInput("void test2() {\n");},
+             a -> {assertCommand(a, "} //test2", "|  created method test2()");},
+             a -> {
+                 if (!a) {
+                     try {
+                         previousAndAssert(getHistory(), "} //test2");
+                         previousSnippetAndAssert(getHistory(), "void test2() {");
+                         previousSnippetAndAssert(getHistory(), "/debug 0"); //added by test framework
+                         previousSnippetAndAssert(getHistory(), "/exit");
+                         previousSnippetAndAssert(getHistory(), "int dummy;");
+                         previousSnippetAndAssert(getHistory(), "void test() {");
+                     } catch (Exception ex) {
+                         throw new IllegalStateException(ex);
+                     }
+                 }
+                 assertCommand(a, "int dummy;", "dummy ==> 0");
+             });
     }
 
-    public void testSaveOneHistory() {
-        JShell eval = JShell.builder()
-                .in(new ByteArrayInputStream(new byte[0]))
-                .out(new PrintStream(new ByteArrayOutputStream()))
-                .err(new PrintStream(new ByteArrayOutputStream()))
-                .build();
-        SourceCodeAnalysis analysis = eval.sourceCodeAnalysis();
-        MemoryPreferences prefs = new MemoryPreferences(null, "");
-        EditingHistory history = new EditingHistory(prefs) {
-            @Override protected CompletionInfo analyzeCompletion(String input) {
-                return analysis.analyzeCompletion(input);
-            }
-        };
-
-        history.add("first");
-        history.save();
+    private EditingHistory getHistory() throws Exception {
+        Field input = repl.getClass().getDeclaredField("input");
+        input.setAccessible(true);
+        Object console = input.get(repl);
+        Field history = console.getClass().getDeclaredField("history");
+        history.setAccessible(true);
+        return (EditingHistory) history.get(console);
     }
 
     private void previousAndAssert(EditingHistory history, String expected) {
@@ -177,71 +89,9 @@
         assertEquals(history.current().toString(), expected);
     }
 
-    private void nextAndAssert(EditingHistory history, String expected) {
-        assertTrue(history.next());
-        assertEquals(history.current().toString(), expected);
-    }
-
     private void previousSnippetAndAssert(EditingHistory history, String expected) {
         assertTrue(history.previousSnippet());
         assertEquals(history.current().toString(), expected);
     }
 
-    private void nextSnippetAndAssert(EditingHistory history, String expected) {
-        assertTrue(history.nextSnippet());
-        assertEquals(history.current().toString(), expected);
-    }
-
-    private static final class MemoryPreferences extends AbstractPreferences {
-
-        private final Map<String, String> key2Value = new HashMap<>();
-        private final Map<String, MemoryPreferences> key2SubNode = new HashMap<>();
-
-        public MemoryPreferences(AbstractPreferences parent, String name) {
-            super(parent, name);
-        }
-
-        @Override
-        protected void putSpi(String key, String value) {
-            key2Value.put(key, value);
-        }
-
-        @Override
-        protected String getSpi(String key) {
-            return key2Value.get(key);
-        }
-
-        @Override
-        protected void removeSpi(String key) {
-            key2Value.remove(key);
-        }
-
-        @Override
-        protected void removeNodeSpi() throws BackingStoreException {
-            ((MemoryPreferences) parent()).key2SubNode.remove(name());
-        }
-
-        @Override
-        protected String[] keysSpi() throws BackingStoreException {
-            return key2Value.keySet().toArray(new String[key2Value.size()]);
-        }
-
-        @Override
-        protected String[] childrenNamesSpi() throws BackingStoreException {
-            return key2SubNode.keySet().toArray(new String[key2SubNode.size()]);
-        }
-
-        @Override
-        protected AbstractPreferences childSpi(String name) {
-            return key2SubNode.computeIfAbsent(name, n -> new MemoryPreferences(this, n));
-        }
-
-        @Override
-        protected void syncSpi() throws BackingStoreException {}
-
-        @Override
-        protected void flushSpi() throws BackingStoreException {}
-
-    }
-
 }
diff --git a/langtools/test/jdk/jshell/KullaTesting.java b/langtools/test/jdk/jshell/KullaTesting.java
index 7c4224a..76f4892 100644
--- a/langtools/test/jdk/jshell/KullaTesting.java
+++ b/langtools/test/jdk/jshell/KullaTesting.java
@@ -72,6 +72,7 @@
 import static jdk.jshell.Snippet.Status.*;
 import static org.testng.Assert.*;
 import static jdk.jshell.Snippet.SubKind.METHOD_SUBKIND;
+import jdk.jshell.spi.ExecutionControl;
 
 public class KullaTesting {
 
@@ -166,6 +167,21 @@
         classpath = new ArrayList<>();
     }
 
+    public void setUp(ExecutionControl ec) {
+        inStream = new TestingInputStream();
+        outStream = new ByteArrayOutputStream();
+        errStream = new ByteArrayOutputStream();
+        state = JShell.builder()
+                .executionEngine(ec)
+                .in(inStream)
+                .out(new PrintStream(outStream))
+                .err(new PrintStream(errStream))
+                .build();
+        allSnippets = new LinkedHashSet<>();
+        idToSnippet = new LinkedHashMap<>();
+        classpath = new ArrayList<>();
+    }
+
     @AfterMethod
     public void tearDown() {
         if (state != null) state.close();
diff --git a/langtools/test/jdk/jshell/LocalExecutionControl.java b/langtools/test/jdk/jshell/LocalExecutionControl.java
new file mode 100644
index 0000000..e68d039
--- /dev/null
+++ b/langtools/test/jdk/jshell/LocalExecutionControl.java
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.jshell.spi.ExecutionControl;
+import jdk.jshell.spi.ExecutionEnv;
+import jdk.jshell.spi.SPIResolutionException;
+import jdk.jshell.EvalException;
+import jdk.jshell.UnresolvedReferenceException;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.CodeSource;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * An implementation of ExecutionControl which executes in the same JVM as the
+ * JShell core.
+ *
+ * @author Grigory Ptashko
+ */
+class LocalExecutionControl implements ExecutionControl {
+    private class REPLClassLoader extends URLClassLoader {
+        REPLClassLoader() {
+            super(new URL[0]);
+        }
+
+        @Override
+        protected Class<?> findClass(String name) throws ClassNotFoundException {
+            debug("findClass %s\n", name);
+            byte[] b = execEnv.getClassBytes(name);
+            if (b == null) {
+                return super.findClass(name);
+            }
+            return super.defineClass(name, b, 0, b.length, (CodeSource)null);
+        }
+
+        @Override
+        public void addURL(URL url) {
+            super.addURL(url);
+        }
+    }
+
+    private ExecutionEnv execEnv;
+    private final Object STOP_LOCK = new Object();
+    private boolean userCodeRunning = false;
+    private REPLClassLoader loader = new REPLClassLoader();
+    private final Map<String, Class<?>> klasses = new TreeMap<>();
+    private final Map<String, byte[]> classBytes = new HashMap<>();
+    private ThreadGroup execThreadGroup;
+
+    @Override
+    public void start(ExecutionEnv execEnv) throws Exception {
+        this.execEnv = execEnv;
+
+        debug("Process-local code snippets execution control started");
+    }
+
+    @Override
+    public void close() {
+    }
+
+    @Override
+    public boolean load(Collection<String> classes) {
+        try {
+            loadLocal(classes);
+
+            return true;
+        } catch (ClassNotFoundException | ClassCastException ex) {
+            debug(ex, "Exception on load operation");
+        }
+
+        return false;
+    }
+
+    @Override
+    public String invoke(String classname, String methodname) throws EvalException, UnresolvedReferenceException {
+        try {
+            synchronized (STOP_LOCK) {
+                userCodeRunning = true;
+            }
+
+            // Invoke executable entry point in loaded code
+            Class<?> klass = klasses.get(classname);
+            if (klass == null) {
+                debug("Invoke failure: no such class loaded %s\n", classname);
+
+                return "";
+            }
+
+            Method doitMethod;
+            try {
+                this.getClass().getModule().addReads(klass.getModule());
+                this.getClass().getModule().addExports(SPIResolutionException.class.getPackage()
+                        .getName(), klass.getModule());
+                doitMethod = klass.getDeclaredMethod(methodname, new Class<?>[0]);
+                doitMethod.setAccessible(true);
+
+                execThreadGroup = new ThreadGroup("JShell process local execution");
+
+                AtomicReference<InvocationTargetException> iteEx = new AtomicReference<>();
+                AtomicReference<IllegalAccessException> iaeEx = new AtomicReference<>();
+                AtomicReference<NoSuchMethodException> nmeEx = new AtomicReference<>();
+                AtomicReference<Boolean> stopped = new AtomicReference<>(false);
+
+                Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
+                    if (e instanceof InvocationTargetException) {
+                        if (e.getCause() instanceof ThreadDeath) {
+                            stopped.set(true);
+                        } else {
+                            iteEx.set((InvocationTargetException)e);
+                        }
+                    } else if (e instanceof IllegalAccessException) {
+                        iaeEx.set((IllegalAccessException)e);
+                    } else if (e instanceof NoSuchMethodException) {
+                        nmeEx.set((NoSuchMethodException)e);
+                    } else if (e instanceof ThreadDeath) {
+                        stopped.set(true);
+                    }
+                });
+
+                final Object[] res = new Object[1];
+                Thread snippetThread = new Thread(execThreadGroup, () -> {
+                    try {
+                        res[0] = doitMethod.invoke(null, new Object[0]);
+                    } catch (InvocationTargetException e) {
+                        if (e.getCause() instanceof ThreadDeath) {
+                            stopped.set(true);
+                        } else {
+                            iteEx.set(e);
+                        }
+                    } catch (IllegalAccessException e) {
+                        iaeEx.set(e);
+                    } catch (ThreadDeath e) {
+                        stopped.set(true);
+                    }
+                });
+
+                snippetThread.start();
+                Thread[] threadList = new Thread[execThreadGroup.activeCount()];
+                execThreadGroup.enumerate(threadList);
+                for (Thread thread : threadList) {
+                    if (thread != null)
+                        thread.join();
+                }
+
+                if (stopped.get()) {
+                    debug("Killed.");
+
+                    return "";
+                }
+
+                if (iteEx.get() != null) {
+                    throw iteEx.get();
+                } else if (nmeEx.get() != null) {
+                    throw nmeEx.get();
+                } else if (iaeEx.get() != null) {
+                    throw iaeEx.get();
+                }
+
+                return valueString(res[0]);
+            } catch (InvocationTargetException ex) {
+                Throwable cause = ex.getCause();
+                StackTraceElement[] elems = cause.getStackTrace();
+                if (cause instanceof SPIResolutionException) {
+                    int id = ((SPIResolutionException)cause).id();
+
+                    throw execEnv.createUnresolvedReferenceException(id, elems);
+                } else {
+                    throw execEnv.createEvalException(cause.getMessage() == null ?
+                            "<none>" : cause.getMessage(), cause.getClass().getName(), elems);
+                }
+            } catch (NoSuchMethodException | IllegalAccessException | InterruptedException ex) {
+                debug(ex, "Invoke failure");
+            }
+        } finally {
+            synchronized (STOP_LOCK) {
+                userCodeRunning = false;
+            }
+        }
+
+        return "";
+    }
+
+    @Override
+    @SuppressWarnings("deprecation")
+    public void stop() {
+        synchronized (STOP_LOCK) {
+            if (!userCodeRunning)
+                return;
+
+            if (execThreadGroup == null) {
+                debug("Process-local code snippets thread group is null. Aborting stop.");
+
+                return;
+            }
+
+            execThreadGroup.stop();
+        }
+    }
+
+    @Override
+    public String varValue(String classname, String varname) {
+        Class<?> klass = klasses.get(classname);
+        if (klass == null) {
+            debug("Var value failure: no such class loaded %s\n", classname);
+
+            return "";
+        }
+        try {
+            this.getClass().getModule().addReads(klass.getModule());
+            Field var = klass.getDeclaredField(varname);
+            var.setAccessible(true);
+            Object res = var.get(null);
+
+            return valueString(res);
+        } catch (Exception ex) {
+            debug("Var value failure: no such field %s.%s\n", classname, varname);
+        }
+
+        return "";
+    }
+
+    @Override
+    public boolean addToClasspath(String cp) {
+        // Append to the claspath
+        for (String path : cp.split(File.pathSeparator)) {
+            try {
+                loader.addURL(new File(path).toURI().toURL());
+            } catch (MalformedURLException e) {
+                throw new InternalError("Classpath addition failed: " + cp, e);
+            }
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean redefine(Collection<String> classes) {
+        return false;
+    }
+
+    @Override
+    public ClassStatus getClassStatus(String classname) {
+        if (!classBytes.containsKey(classname)) {
+            return ClassStatus.UNKNOWN;
+        } else if (!Arrays.equals(classBytes.get(classname), execEnv.getClassBytes(classname))) {
+            return ClassStatus.NOT_CURRENT;
+        } else {
+            return ClassStatus.CURRENT;
+        }
+    }
+
+    private void loadLocal(Collection<String> classes) throws ClassNotFoundException {
+        for (String className : classes) {
+            Class<?> klass = loader.loadClass(className);
+            klasses.put(className, klass);
+            classBytes.put(className, execEnv.getClassBytes(className));
+            klass.getDeclaredMethods();
+        }
+    }
+
+    private void debug(String format, Object... args) {
+        //debug(execEnv.state(), execEnv.userErr(), flags, format, args);
+    }
+
+    private void debug(Exception ex, String where) {
+        //debug(execEnv.state(), execEnv.userErr(), ex, where);
+    }
+
+    private static String valueString(Object value) {
+        if (value == null) {
+            return "null";
+        } else if (value instanceof String) {
+            return "\"" + (String)value + "\"";
+        } else if (value instanceof Character) {
+            return "'" + value + "'";
+        } else {
+            return value.toString();
+        }
+    }
+}
diff --git a/langtools/test/jdk/jshell/ReplToolTesting.java b/langtools/test/jdk/jshell/ReplToolTesting.java
index a2be490..503bfc8 100644
--- a/langtools/test/jdk/jshell/ReplToolTesting.java
+++ b/langtools/test/jdk/jshell/ReplToolTesting.java
@@ -70,6 +70,9 @@
                     new MethodInfo("void printf(String format, Object... args) { System.out.printf(format, args); }",
                             "(String,Object...)void", "printf"))
                     .collect(toList());
+    final static List<String> START_UP_CMD_METHOD = Stream.of(
+                    "|    printf (String,Object...)void")
+                    .collect(toList());
     final static List<String> START_UP = Collections.unmodifiableList(
             Stream.concat(START_UP_IMPORTS.stream(), START_UP_METHODS.stream())
             .map(s -> s.getSource())
diff --git a/langtools/test/jdk/jshell/ToolBasicTest.java b/langtools/test/jdk/jshell/ToolBasicTest.java
index 9d162d3..bf53c89 100644
--- a/langtools/test/jdk/jshell/ToolBasicTest.java
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java
@@ -118,9 +118,9 @@
                     (a) -> assertCommand(a, "class A {" + s, ""),
                     interrupt,
                     (a) -> assertCommand(a, "class A {}\u0003", ""),
-                    (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                    (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                     (a) -> assertClass(a, "interface A {}", "interface", "A"),
-                    (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                    (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                     (a) -> assertCommand(a, "import java.util.stream." + s, ""),
                     interrupt,
                     (a) -> assertCommand(a, "import java.util.stream.\u0003", ""),
@@ -338,13 +338,13 @@
                 (a) -> assertMethod(a, "void f() { }", "()void", "f"),
                 (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
                 (a) -> assertClass(a, "class A { }", "class", "A"),
-                (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
                 (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
                 (a) -> assertReset(a, "/reset"),
                 (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 (a) -> assertCommandCheckOutput(a, "/imports", assertImports())
         );
     }
@@ -369,7 +369,7 @@
                         loadClass(a, "class A { public String toString() { return \"A\"; } }",
                                 "class", "A");
                         loadImport(a, "import java.util.stream.*;", "", "java.util.stream.*");
-                        assertCommandCheckOutput(a, "/classes", assertClasses());
+                        assertCommandCheckOutput(a, "/types", assertClasses());
                     },
                     (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
                     (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
@@ -403,13 +403,13 @@
                     (a) -> assertCommand(a, "int a;", null),
                     (a) -> assertCommand(a, "()", null, null, null, "", ""),
                     (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
-                    (a) -> assertCommandCheckOutput(a, "/list all", (out) ->
+                    (a) -> assertCommandCheckOutput(a, "/list -all", (out) ->
                             output.addAll(Stream.of(out.split("\n"))
                                     .filter(str -> !str.isEmpty())
                                     .map(str -> str.substring(str.indexOf(':') + 2))
                                     .filter(str -> !str.startsWith("/"))
                                     .collect(Collectors.toList()))),
-                    (a) -> assertCommand(a, "/save all " + path.toString(), "")
+                    (a) -> assertCommand(a, "/save -all " + path.toString(), "")
             );
             assertEquals(Files.readAllLines(path), output);
         }
@@ -451,7 +451,7 @@
                         loadVariable(a, "double", "b", "10.0", "10.0");
                         loadMethod(a, "void f() {}", "()void", "f");
                         loadImport(a, "import java.util.stream.*;", "", "java.util.stream.*");
-                        assertCommandCheckOutput(a, "/classes", assertClasses());
+                        assertCommandCheckOutput(a, "/types", assertClasses());
                     },
                     (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                     (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
@@ -472,7 +472,7 @@
     public void testStartSave() throws IOException {
         Compiler compiler = new Compiler();
         Path startSave = compiler.getPath("startSave.txt");
-        test(a -> assertCommand(a, "/save start " + startSave.toString(), null));
+        test(a -> assertCommand(a, "/save -start " + startSave.toString(), null));
         List<String> lines = Files.lines(startSave)
                 .filter(s -> !s.isEmpty())
                 .collect(Collectors.toList());
@@ -569,4 +569,17 @@
             return ex.getMessage();
         }
     }
+
+    public void testHeadlessEditPad() {
+        String prevHeadless = System.getProperty("java.awt.headless");
+        try {
+            System.setProperty("java.awt.headless", "true");
+            test(
+                (a) -> assertCommandOutputStartsWith(a, "/edit printf", "|  Cannot launch editor -- unexpected exception:")
+            );
+        } finally {
+            System.setProperty("java.awt.headless", prevHeadless==null? "false" : prevHeadless);
+        }
+    }
+
 }
diff --git a/langtools/test/jdk/jshell/ToolCommandOptionTest.java b/langtools/test/jdk/jshell/ToolCommandOptionTest.java
new file mode 100644
index 0000000..030d016
--- /dev/null
+++ b/langtools/test/jdk/jshell/ToolCommandOptionTest.java
@@ -0,0 +1,357 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+ * @test
+ * @bug 8157395 8157393 8157517
+ * @summary Tests of jshell comand options, and undoing operations
+ * @modules jdk.jshell/jdk.internal.jshell.tool
+ * @build ToolCommandOptionTest ReplToolTesting
+ * @run testng ToolCommandOptionTest
+ */
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertFalse;
+
+@Test
+public class ToolCommandOptionTest extends ReplToolTesting {
+
+    public void listTest() {
+        test(
+                (a) -> assertCommand(a, "int x;",
+                        "x ==> 0"),
+                (a) -> assertCommand(a, "/li",
+                        "1 : int x;"),
+                (a) -> assertCommandOutputStartsWith(a, "/lis -st",
+                        "\n  s1 : import"),
+                (a) -> assertCommandOutputStartsWith(a, "/list -all",
+                        "\n  s1 : import"),
+                (a) -> assertCommandOutputContains(a, "/list -all",
+                        "1 : int x;"),
+                (a) -> assertCommandOutputContains(a, "/list -history",
+                        "int x;"),
+                (a) -> assertCommandOutputContains(a, "/li -h",
+                        "/lis -st"),
+                (a) -> assertCommand(a, "/list -furball",
+                        "|  Unknown option: -furball -- /list -furball"),
+                (a) -> assertCommand(a, "/list x",
+                        "1 : int x;"),
+                (a) -> assertCommand(a, "/li x -start",
+                        "|  Options and snippets must not both be used: /list x -start"),
+                (a) -> assertCommand(a, "/l -st -al",
+                        "|  Conflicting options -- /list -st -al")
+        );
+    }
+
+    public void typesTest() {
+        test(
+                (a) -> assertCommand(a, "int x",
+                        "x ==> 0"),
+                (a) -> assertCommand(a, "/types x",
+                        "|  This command does not accept the snippet 'x' : int x;"),
+                (a) -> assertCommand(a, "class C {}",
+                        "|  created class C"),
+                (a) -> assertCommand(a, "/ty",
+                        "|    class C"),
+                (a) -> assertCommand(a, "/ty -st",
+                        ""),
+                (a) -> assertCommand(a, "/types -all",
+                        "|    class C"),
+                (a) -> assertCommand(a, "/types -furball",
+                        "|  Unknown option: -furball -- /types -furball"),
+                (a) -> assertCommand(a, "/types C",
+                        "|    class C"),
+                (a) -> assertCommand(a, "/types C -start",
+                        "|  Options and snippets must not both be used: /types C -start"),
+                (a) -> assertCommand(a, "/ty -st -al",
+                        "|  Conflicting options -- /types -st -al")
+        );
+    }
+
+    public void dropTest() {
+        test(false, new String[]{"-nostartup"},
+                (a) -> assertCommand(a, "int x = 5;",
+                        "x ==> 5"),
+                (a) -> assertCommand(a, "x",
+                        "x ==> 5"),
+                (a) -> assertCommand(a, "long y;",
+                        "y ==> 0"),
+                (a) -> assertCommand(a, "/drop -furball",
+                        "|  Unknown option: -furball -- /drop -furball"),
+                (a) -> assertCommand(a, "/drop -all",
+                        "|  Unknown option: -all -- /drop -all"),
+                (a) -> assertCommandOutputStartsWith(a, "/drop z",
+                        "|  No such snippet: z"),
+                (a) -> assertCommandOutputStartsWith(a, "/drop 2",
+                        "|  This command does not accept the snippet '2' : x"),
+                (a) -> assertCommand(a, "/dr x y",
+                        "|  dropped variable x\n" +
+                        "|  dropped variable y"),
+                (a) -> assertCommand(a, "/list",
+                        "2 : x")
+        );
+    }
+
+    public void setEditorTest() {
+        test(
+                (a) -> assertCommand(a, "/set editor -furball",
+                        "|  Unknown option: -furball -- /set editor -furball"),
+                (a) -> assertCommand(a, "/set editor -furball prog",
+                        "|  Unknown option: -furball -- /set editor -furball prog"),
+                (a) -> assertCommand(a, "/set editor -furball -mattress",
+                        "|  Unknown option: -furball -mattress -- /set editor -furball -mattress"),
+                (a) -> assertCommand(a, "/set editor -default prog",
+                        "|  Specify -default option or program, not both -- /set editor -default prog"),
+                (a) -> assertCommand(a, "/set editor prog",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/set editor prog -default",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/se ed prog -furball",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/set editor prog arg1 -furball arg3 -default arg4",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/set editor -default",
+                        ""),
+                (a) -> assertCommand(a, "/se edi -def",
+                        ""),
+                (a) -> assertCommand(a, "/set editor",
+                        "|  The '/set editor' command requires a path argument")
+        );
+    }
+
+    public void retainEditorTest() {
+        test(
+                (a) -> assertCommand(a, "/retain editor -furball",
+                        "|  Unknown option: -furball -- /retain editor -furball"),
+                (a) -> assertCommand(a, "/retain editor -furball prog",
+                        "|  Unknown option: -furball -- /retain editor -furball prog"),
+                (a) -> assertCommand(a, "/retain editor -furball -mattress",
+                        "|  Unknown option: -furball -mattress -- /retain editor -furball -mattress"),
+                (a) -> assertCommand(a, "/retain editor -default prog",
+                        "|  Specify -default option or program, not both -- /retain editor -default prog"),
+                (a) -> assertCommand(a, "/retain editor prog",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/retain editor prog -default",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/ret ed prog -furball",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/retain editor prog arg1 -furball arg3 -default arg4",
+                        "|  Editor set to: prog"),
+                (a) -> assertCommand(a, "/retain editor -default",
+                        ""),
+                (a) -> assertCommand(a, "/reta edi -def",
+                        ""),
+                (a) -> assertCommand(a, "/retain editor",
+                        "")
+        );
+    }
+
+    public void setStartTest() {
+        test(
+                (a) -> assertCommand(a, "/set start -furball",
+                        "|  Unknown option: -furball -- /set start -furball"),
+                (a) -> assertCommand(a, "/set start -furball pyle",
+                        "|  Unknown option: -furball -- /set start -furball pyle"),
+                (a) -> assertCommand(a, "/se st pyle -furball",
+                        "|  Unknown option: -furball -- /set st pyle -furball"),
+                (a) -> assertCommand(a, "/set start -furball -mattress",
+                        "|  Unknown option: -furball -mattress -- /set start -furball -mattress"),
+                (a) -> assertCommand(a, "/set start foo -default",
+                        "|  Specify either one option or a startup file name -- /set start foo -default"),
+                (a) -> assertCommand(a, "/set start frfg",
+                        "|  File 'frfg' for '/set start' is not found."),
+                (a) -> assertCommand(a, "/set start -default",
+                        ""),
+                (a) -> assertCommand(a, "/se sta -no",
+                        ""),
+                (a) -> assertCommand(a, "/set start",
+                        "|  Specify either one option or a startup file name -- /set start")
+        );
+    }
+
+    public void retainStartTest() {
+        test(
+                (a) -> assertCommand(a, "/retain start -furball",
+                        "|  Unknown option: -furball -- /retain start -furball"),
+                (a) -> assertCommand(a, "/retain start -furball pyle",
+                        "|  Unknown option: -furball -- /retain start -furball pyle"),
+                (a) -> assertCommand(a, "/ret st pyle -furball",
+                        "|  Unknown option: -furball -- /retain st pyle -furball"),
+                (a) -> assertCommand(a, "/retain start -furball -mattress",
+                        "|  Unknown option: -furball -mattress -- /retain start -furball -mattress"),
+                (a) -> assertCommand(a, "/retain start foo -default",
+                        "|  Specify either one option or a startup file name -- /retain start foo -default"),
+                (a) -> assertCommand(a, "/retain start frfg",
+                        "|  File 'frfg' for '/retain start' is not found."),
+                (a) -> assertCommand(a, "/retain start -default",
+                        ""),
+                (a) -> assertCommand(a, "/ret sta -no",
+                        ""),
+                (a) -> assertCommand(a, "/retain start",
+                        "")
+        );
+    }
+
+    public void setModeTest() {
+        test(
+                (a) -> assertCommandOutputStartsWith(a, "/set mode",
+                        "|  Missing the feedback mode"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode *",
+                        "|  Expected a feedback mode name: *"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode -quiet",
+                        "|  Missing the feedback mode"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode -quiet *",
+                        "|  Expected a feedback mode name: *"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode amode normal thing",
+                        "|  Unexpected arguments at end of command: thing"),
+                (a) -> assertCommand(a, "/set mode mymode",
+                        "|  Created new feedback mode: mymode"),
+                (a) -> assertCommand(a, "/set mode mymode -delete",
+                        ""),
+                (a) -> assertCommand(a, "/set mode mymode normal",
+                        "|  Created new feedback mode: mymode"),
+                (a) -> assertCommand(a, "/set mode -del mymode",
+                        ""),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -command -quiet",
+                        "|  Conflicting options"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -delete -quiet",
+                        "|  Conflicting options"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -command -delete",
+                        "|  Conflicting options"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -d",
+                        "|  No feedback mode named: mymode"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode normal",
+                        "|  Not valid with a predefined mode: normal"),
+                (a) -> assertCommand(a, "/se mo -c mymode",
+                        "|  Created new feedback mode: mymode"),
+                (a) -> assertCommand(a, "/set feedback mymode",
+                        "|  Feedback mode: mymode"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -delete",
+                        "|  The current feedback mode 'mymode' cannot be deleted"),
+                (a) -> assertCommand(a, "/set feedback no",
+                        "|  Feedback mode: normal"),
+                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -delete",
+                        ""),
+                (a) -> assertCommandCheckOutput(a, "/set feedback",
+                        (s) -> assertFalse(s.contains("mymode"), "Didn't delete: " + s))
+        );
+    }
+
+    public void setModeSmashTest() {
+        test(
+                (a) -> assertCommand(a, "/set mode mymode -command",
+                        "|  Created new feedback mode: mymode"),
+                (a) -> assertCommand(a, "/set feedback mymode",
+                        "|  Feedback mode: mymode"),
+                (a) -> assertCommand(a, "/set format mymode display 'blurb'",
+                        ""),
+                (a) -> assertCommand(a, "45",
+                        "blurb"),
+                (a) -> assertCommand(a, "/set mode mymode normal",
+                        "|  Created new feedback mode: mymode"),
+                (a) -> assertCommandOutputContains(a, "45",
+                        " ==> 45")
+        );
+    }
+
+    public void retainModeTest() {
+        test(
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode",
+                        "|  Missing the feedback mode"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode *",
+                        "|  Expected a feedback mode name: *"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode amode normal",
+                        "|  Unexpected arguments at end of command: normal"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode mymode",
+                        "|  Does not match any current feedback mode: mymode"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode mymode -delete",
+                        "|  No feedback mode named: mymode"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode -d mymode",
+                        "|  No feedback mode named: mymode"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode normal",
+                        "|  Not valid with a predefined mode: normal"),
+                (a) -> assertCommand(a, "/set mode mymode verbose",
+                        "|  Created new feedback mode: mymode"),
+                (a) -> assertCommand(a, "/retain mode mymode",
+                        ""),
+                (a) -> assertCommand(a, "/set mode mymode -delete",
+                        ""),
+                (a) -> assertCommand(a, "/retain mode mymode -delete",
+                        ""),
+                (a) -> assertCommand(a, "/set mode kmode normal",
+                        "|  Created new feedback mode: kmode"),
+                (a) -> assertCommand(a, "/retain mode kmode",
+                        ""),
+                (a) -> assertCommand(a, "/set mode kmode -delete",
+                        ""),
+                (a) -> assertCommand(a, "/set mode tmode normal",
+                        "|  Created new feedback mode: tmode"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain feedback tmode",
+                        "|  '/retain feedback <mode>' requires that <mode> is predefined or has been retained with '/retain mode'"),
+                (a) -> assertCommand(a, "/set format tmode display 'YES'",
+                        ""),
+                (a) -> assertCommand(a, "/set feedback tmode",
+                        "|  Feedback mode: tmode"),
+                (a) -> assertCommand(a, "45",
+                        "YES"),
+                (a) -> assertCommand(a, "/retain mode tmode",
+                        ""),
+                (a) -> assertCommand(a, "/retain feedback tmode",
+                        "|  Feedback mode: tmode"),
+                (a) -> assertCommand(a, "/set format tmode display 'blurb'",
+                        ""),
+                (a) -> assertCommand(a, "45",
+                        "blurb")
+        );
+        test(
+                (a) -> assertCommand(a, "45",
+                        "YES"),
+                (a) -> assertCommand(a, "/set feedback kmode",
+                        "|  Feedback mode: kmode"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode kmode -delete",
+                        "|  The current feedback mode 'kmode' cannot be deleted"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode tmode -delete",
+                        "|  The retained feedback mode 'tmode' cannot be deleted"),
+                (a) -> assertCommand(a, "/retain feedback normal",
+                        "|  Feedback mode: normal"),
+                (a) -> assertCommand(a, "/retain mode tmode -delete",
+                        ""),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode kmode -delete",
+                        "")
+        );
+        test(
+                (a) -> assertCommandOutputStartsWith(a, "/set feedback tmode",
+                        "|  Does not match any current feedback mode: tmode"),
+                (a) -> assertCommandOutputStartsWith(a, "/set feedback kmode",
+                        "|  Does not match any current feedback mode: kmode"),
+                (a) -> assertCommandOutputStartsWith(a, "/set feedback mymode",
+                        "|  Does not match any current feedback mode: mymode"),
+                (a) -> assertCommandCheckOutput(a, "/set feedback",
+                        (s) -> assertFalse(s.contains("mymode"), "Didn't delete mymode: " + s)),
+                (a) -> assertCommandCheckOutput(a, "/set feedback",
+                        (s) -> assertFalse(s.contains("kmode"), "Didn't delete kmode: " + s)),
+                (a) -> assertCommandCheckOutput(a, "/set feedback",
+                        (s) -> assertFalse(s.contains("tmode"), "Didn't delete tmode: " + s))
+        );
+    }
+
+}
diff --git a/langtools/test/jdk/jshell/ToolFormatTest.java b/langtools/test/jdk/jshell/ToolFormatTest.java
index f4758f8..d85f692 100644
--- a/langtools/test/jdk/jshell/ToolFormatTest.java
+++ b/langtools/test/jdk/jshell/ToolFormatTest.java
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8148316 8148317 8151755 8152246 8153551
+ * @bug 8148316 8148317 8151755 8152246 8153551 8154812
  * @summary Tests for output customization
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
@@ -43,7 +43,7 @@
     public void testSetFormat() {
         try {
             test(
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode test command", "|  Created new feedback mode: test"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode test -command", "|  Created new feedback mode: test"),
                     (a) -> assertCommand(a, "/set format test pre '$ '", ""),
                     (a) -> assertCommand(a, "/set format test post ''", ""),
                     (a) -> assertCommand(a, "/set format test act 'ADD' added", ""),
@@ -82,7 +82,7 @@
 
     public void testSetFormatSelector() {
         List<ReplTest> tests = new ArrayList<>();
-        tests.add((a) -> assertCommandOutputStartsWith(a, "/set newmode ate quiet",
+        tests.add((a) -> assertCommandOutputStartsWith(a, "/set mode ate -quiet",
                             "|  Created new feedback mode: ate"));
         tests.add((a) -> assertCommand(a, "/set feedback ate", ""));
         StringBuilder sb = new StringBuilder();
@@ -155,6 +155,29 @@
         }
     }
 
+    public void testSetTruncation() {
+        try {
+            test(
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", ""),
+                    (a) -> assertCommand(a, "String s = java.util.stream.IntStream.range(65, 74)"+
+                            ".mapToObj(i -> \"\"+(char)i).reduce((a,b) -> a + b + a).get()",
+                            "s ==> \"ABACABADABACABAEABACABADABACABAFABACABADABACABAEABACABADABACABAGABACABADABA ..."),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode test -quiet", ""),
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback test", ""),
+                    (a) -> assertCommand(a, "/set format test display '{type}:{value}' primary", ""),
+                    (a) -> assertCommand(a, "/set truncation test 20", ""),
+                    (a) -> assertCommand(a, "/set trunc test 10 varvalue", ""),
+                    (a) -> assertCommand(a, "/set trunc test 3 assignment", ""),
+                    (a) -> assertCommand(a, "String r = s", "String:\"ABACABADABACABA ..."),
+                    (a) -> assertCommand(a, "r", "String:\"ABACA ..."),
+                    (a) -> assertCommand(a, "r=s", "String:\"AB")
+            );
+        } finally {
+            assertCommandCheckOutput(false, "/set feedback normal", s -> {
+            });
+        }
+    }
+
     public void testShowFeedbackModes() {
         test(
                 (a) -> assertCommandOutputContains(a, "/set feedback", "normal")
@@ -164,13 +187,13 @@
     public void testSetNewModeQuiet() {
         try {
             test(
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode nmq quiet normal", "|  Created new feedback mode: nmq"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode nmq -quiet normal", "|  Created new feedback mode: nmq"),
                     (a) -> assertCommand(a, "/set feedback nmq", ""),
-                    (a) -> assertCommand(a, "/se ne nmq2 q nor", ""),
+                    (a) -> assertCommand(a, "/se mo nmq2 -q nor", ""),
                     (a) -> assertCommand(a, "/se fee nmq2", ""),
-                    (a) -> assertCommand(a, "/set newmode nmc command normal", ""),
+                    (a) -> assertCommand(a, "/set mode nmc -command normal", ""),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback nmc", "|  Feedback mode: nmc"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode nm", "|  Created new feedback mode: nm"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode nm", "|  Created new feedback mode: nm"),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback nm", "|  Feedback mode: nm"),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
             );
@@ -183,37 +206,37 @@
     public void testSetError() {
         try {
             test(
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode tee command foo",
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode tee -command foo",
                             "|  Does not match any current feedback mode: foo"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode tee flurb",
-                            "|  Specify either 'command' or 'quiet'"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te2",
-                            "|  Created new feedback mode: te2"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te2 command",
-                            "|  Expected a new feedback mode name. 'te2' is a known feedback mode"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te command normal",
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode tee flurb",
+                            "|  Does not match any current feedback mode: flurb"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode tee",
+                            "|  Created new feedback mode: tee"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode verbose",
+                            "|  Not valid with a predefined mode: verbose"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode te -command normal",
                             "|  Created new feedback mode: te"),
                     (a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback te",
                             ""),
                     (a) -> assertCommandOutputStartsWith(a, "/set ",
-                            "ERROR: The '/set' command requires a sub-command and arguments"),
+                            "ERROR: The '/set' command requires a sub-command"),
                     (a) -> assertCommandOutputStartsWith(a, "/set xyz",
                             "ERROR: Invalid '/set' argument: xyz"),
                     (a) -> assertCommandOutputStartsWith(a, "/set f",
                             "ERROR: Ambiguous sub-command argument to '/set': f"),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback",
-                            "ERROR: Expected a feedback mode"),
+                            "ERROR: Missing the feedback mode"),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback xyz",
                             "ERROR: Does not match any current feedback mode"),
                     (a) -> assertCommandOutputStartsWith(a, "/set format",
-                            "ERROR: Expected a feedback mode"),
+                            "ERROR: Missing the feedback mode"),
                     (a) -> assertCommandOutputStartsWith(a, "/set format xyz",
                             "ERROR: Does not match any current feedback mode"),
                     (a) -> assertCommandOutputStartsWith(a, "/set format t",
                             "ERROR: Matches more then one current feedback mode: t"),
                     (a) -> assertCommandOutputStartsWith(a, "/set format te",
-                            "ERROR: Expected field name missing"),
+                            "ERROR: Missing the field name"),
                     (a) -> assertCommandOutputStartsWith(a, "/set format te fld",
                             "ERROR: Expected format missing"),
                     (a) -> assertCommandOutputStartsWith(a, "/set format te fld aaa",
@@ -226,16 +249,18 @@
                             "ERROR: Selector kind in multiple sections of"),
                     (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import,added",
                             "ERROR: Different selector kinds in same sections of"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode",
-                            "ERROR: Expected new feedback mode"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te",
-                            "ERROR: Expected a new feedback mode name"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode x xyz",
-                            "ERROR: Specify either 'command' or 'quiet'"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode x quiet y",
+                    (a) -> assertCommandOutputStartsWith(a, "/set trunc te 20x",
+                            "ERROR: Truncation length must be an integer: 20x"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set trunc te",
+                            "ERROR: Expected truncation length"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set truncation te 111 import,added",
+                            "ERROR: Different selector kinds in same sections of"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode",
+                            "ERROR: Missing the feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set mode x -quiet y",
                             "ERROR: Does not match any current feedback mode"),
                     (a) -> assertCommandOutputStartsWith(a, "/set prompt",
-                            "ERROR: Expected a feedback mode"),
+                            "ERROR: Missing the feedback mode"),
                     (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
                             "ERROR: Expected format missing"),
                     (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa xyz",
@@ -243,7 +268,7 @@
                     (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa' xyz",
                             "ERROR: Format 'xyz' must be quoted"),
                     (a) -> assertCommandOutputStartsWith(a, "/set prompt",
-                            "ERROR: Expected a feedback mode"),
+                            "ERROR: Missing the feedback mode"),
                     (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
                             "ERROR: Expected format missing"),
                     (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa",
diff --git a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java
index 76cc3ed..b2125d7 100644
--- a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java
+++ b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java
@@ -76,7 +76,7 @@
     public void testSample() {
         try {
             testLocale(
-                    (a) -> assertCommandOK(a, "/set newmode test command normal", "test"),
+                    (a) -> assertCommandOK(a, "/set mode test -command normal", "test"),
                     (a) -> assertCommandOK(a, "/set format test errorpre 'ERROR: '"),
                     (a) -> assertCommandOK(a, "/set feedback test", "test"),
 
@@ -101,7 +101,7 @@
     public void testCommand() {
         try {
             testLocale(
-                    (a) -> assertCommandOK(a, "/set newmode test command normal", "test"),
+                    (a) -> assertCommandOK(a, "/set mode test -command normal", "test"),
                     (a) -> assertCommandOK(a, "/set format test errorpre 'ERROR: '"),
                     (a) -> assertCommandOK(a, "/set feedback test", "test"),
 
@@ -118,10 +118,10 @@
                     (a) -> assertCommandOK(a, "int dup"),
                     (a) -> assertCommandFail(a, "/drop dup"),
                     (a) -> assertCommandFail(a, "/edit zebra", "zebra"),
-                    (a) -> assertCommandFail(a, "/list zebra", "zebra", "/list"),
+                    (a) -> assertCommandFail(a, "/list zebra", "zebra", "No such snippet: zebra"),
                     (a) -> assertCommandFail(a, "/open", "/open"),
                     (a) -> assertCommandFail(a, "/open zebra", "zebra", "/open"),
-                    (a) -> assertCommandFail(a, "/reload zebra", "zebra", "/reload"),
+                    (a) -> assertCommandFail(a, "/reload zebra", "zebra", "Unexpected arguments at end of command"),
                     (a) -> assertCommandFail(a, "/save", "/save"),
                     (a) -> assertCommandFail(a, "/-99"),
 
@@ -134,20 +134,20 @@
 
     public void testHelp() {
         testLocale(
-                (a) -> assertCommandOK(a, "/help", "/list", "/save", "/set", "[restore]"),
-                (a) -> assertCommandOK(a, "/help /list", "start", "all"),
+                (a) -> assertCommandOK(a, "/help", "/list", "/save", "/set", "[-restore]"),
+                (a) -> assertCommandOK(a, "/help /list", "-start", "-all"),
                 (a) -> assertCommandOK(a, "/help /edit", "/set editor"),
                 (a) -> assertCommandOK(a, "/help /drop", "/drop"),
-                (a) -> assertCommandOK(a, "/help /save", "all", "start"),
+                (a) -> assertCommandOK(a, "/help /save", "-all", "-start"),
                 (a) -> assertCommandOK(a, "/help /open", "/open"),
-                (a) -> assertCommandOK(a, "/help /reload", "restore"),
+                (a) -> assertCommandOK(a, "/help /reload", "-restore"),
                 (a) -> assertCommandOK(a, "/help /help", "intro"),
-                (a) -> assertCommandOK(a, "/help /set", "newmode"),
+                (a) -> assertCommandOK(a, "/help /set", "mode"),
                 (a) -> assertCommandOK(a, "/help /?", "intro"),
                 (a) -> assertCommandOK(a, "/help intro", "/help"),
                 (a) -> assertCommandOK(a, "/help /set format", "import", "case", "{value}", "added"),
-                (a) -> assertCommandOK(a, "/help /set feedback", "newmode"),
-                (a) -> assertCommandOK(a, "/help /set newmode", "feedback"),
+                (a) -> assertCommandOK(a, "/help /set feedback", "mode"),
+                (a) -> assertCommandOK(a, "/help /set mode", "feedback"),
                 (a) -> assertCommandOK(a, "/help /set prompt", "/set prompt"),
                 (a) -> assertCommandOK(a, "/help /set editor", "/edit")
         );
@@ -156,11 +156,11 @@
     public void testFeedbackError() {
         try {
             testLocale(
-                    (a) -> assertCommandOK(a, "/set newmode tee command foo", "foo"),
-                    (a) -> assertCommandOK(a, "/set newmode tee flurb", "command", "quiet"),
-                    (a) -> assertCommandOK(a, "/set newmode te2", "te2"),
-                    (a) -> assertCommandOK(a, "/set newmode te2 command", "te2"),
-                    (a) -> assertCommandOK(a, "/set newmode te command normal", "te"),
+                    (a) -> assertCommandOK(a, "/set mode te2", "te2"),
+                    (a) -> assertCommandOK(a, "/set mode te3 -command", "te3"),
+                    (a) -> assertCommandOK(a, "/set mode te2 -command"),
+                    (a) -> assertCommandOK(a, "/set mode te -command normal", "te"),
+                    (a) -> assertCommandOK(a, "/set mode te"),
                     (a) -> assertCommandOK(a, "/set format te errorpre 'ERROR: '"),
                     (a) -> assertCommandOK(a, "/set feedback te"),
 
@@ -179,16 +179,14 @@
                     (a) -> assertCommandFail(a, "/set format te fld 'aaa' import-frog"),
                     (a) -> assertCommandFail(a, "/set format te fld 'aaa' import-import"),
                     (a) -> assertCommandFail(a, "/set format te fld 'aaa' import,added"),
-                    (a) -> assertCommandFail(a, "/set newmode"),
-                    (a) -> assertCommandFail(a, "/set newmode te"),
-                    (a) -> assertCommandFail(a, "/set newmode x xyz"),
-                    (a) -> assertCommandFail(a, "/set newmode x quiet y"),
+                    (a) -> assertCommandFail(a, "/set mode"),
+                    (a) -> assertCommandFail(a, "/set mode x xyz"),
+                    (a) -> assertCommandFail(a, "/set mode x -quiet y"),
+                    (a) -> assertCommandFail(a, "/set mode tee -command foo", "foo"),
                     (a) -> assertCommandFail(a, "/set prompt"),
                     (a) -> assertCommandFail(a, "/set prompt te"),
                     (a) -> assertCommandFail(a, "/set prompt te aaa xyz", "aaa"),
                     (a) -> assertCommandFail(a, "/set prompt te 'aaa' xyz", "xyz"),
-                    (a) -> assertCommandFail(a, "/set prompt"),
-                    (a) -> assertCommandFail(a, "/set prompt te"),
                     (a) -> assertCommandFail(a, "/set prompt te aaa"),
                     (a) -> assertCommandFail(a, "/set prompt te 'aaa'"),
 
diff --git a/langtools/test/jdk/jshell/ToolReloadTest.java b/langtools/test/jdk/jshell/ToolReloadTest.java
index 6779fc1..0faf3e6 100644
--- a/langtools/test/jdk/jshell/ToolReloadTest.java
+++ b/langtools/test/jdk/jshell/ToolReloadTest.java
@@ -107,7 +107,7 @@
                         "-: /drop A\n"),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 a -> assertCommandCheckOutput(a, "/imports", assertImports())
         );
     }
@@ -120,11 +120,11 @@
                 a -> dropMethod(a, "/drop b", "b ()I", "|  dropped method b()"),
                 a -> assertClass(a, "class A {}", "class", "A"),
                 a -> dropClass(a, "/dr A", "class A", "|  dropped class A"),
-                a -> assertCommand(a, "/reload quiet",
+                a -> assertCommand(a, "/reload -quiet",
                         "|  Restarting and restoring state."),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 a -> assertCommandCheckOutput(a, "/imports", assertImports())
         );
     }
@@ -169,7 +169,7 @@
                         "(int)int", "m"),
                 (a) -> evaluateExpression(a, "int", "m(x)", "25"),
                 (a) -> assertCommand(a, "/reset", "|  Resetting state."),
-                (a) -> assertCommand(a, "/reload restore",
+                (a) -> assertCommand(a, "/reload -restore",
                         "|  Restarting and restoring from previous state.\n" +
                         "-: int x = 5;\n" +
                         "-: int m(int z) { return z * z; }\n" +
@@ -188,8 +188,8 @@
                 (a) -> evaluateExpression(a, "int", "m(x)", "25"),
                 (a) -> assertCommand(a, "System.exit(1);",
                         "|  State engine terminated.\n" +
-                        "|  Restore definitions with: /reload restore"),
-                (a) -> assertCommand(a, "/reload restore",
+                        "|  Restore definitions with: /reload -restore"),
+                (a) -> assertCommand(a, "/reload -restore",
                         "|  Restarting and restoring from previous state.\n" +
                         "-: int x = 5;\n" +
                         "-: int m(int z) { return z * z; }\n" +
@@ -208,7 +208,7 @@
                 (a) -> evaluateExpression(a, "int", "m(x)", "25")
         );
         test(false, new String[]{"-nostartup"},
-                (a) -> assertCommand(a, "/reload restore",
+                (a) -> assertCommand(a, "/reload -restore",
                         "|  Restarting and restoring from previous state.\n" +
                         "-: int x = 5;\n" +
                         "-: int m(int z) { return z * z; }\n" +
diff --git a/langtools/test/jdk/jshell/ToolRetainTest.java b/langtools/test/jdk/jshell/ToolRetainTest.java
new file mode 100644
index 0000000..e2eef0e
--- /dev/null
+++ b/langtools/test/jdk/jshell/ToolRetainTest.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8157200
+ * @summary Tests of what information is retained across jshell tool runs
+ * @modules jdk.jshell/jdk.internal.jshell.tool
+ * @build ToolRetainTest ReplToolTesting
+ * @run testng ToolRetainTest
+ */
+
+import org.testng.annotations.Test;
+
+@Test
+public class ToolRetainTest extends ReplToolTesting {
+
+    public void testRetainMode() {
+        test(
+                (a) -> assertCommand(a, "/set mode trm -quiet", "|  Created new feedback mode: trm"),
+                (a) -> assertCommand(a, "/set feedback trm", ""),
+                (a) -> assertCommand(a, "/set format trm display '{name}:{value}'", ""),
+                (a) -> assertCommand(a, "int x = 45", "x:45"),
+                (a) -> assertCommand(a, "/retain mode trm", ""),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommand(a, "/set feedback trm", ""),
+                (a) -> assertCommand(a, "int x = 45", "x:45")
+        );
+    }
+
+    public void testRetain2Mode() {
+        test(
+                (a) -> assertCommand(a, "/set mode trm1 -quiet", "|  Created new feedback mode: trm1"),
+                (a) -> assertCommand(a, "/retain mode trm1", ""),
+                (a) -> assertCommand(a, "/retain feedback trm1", ""),
+                (a) -> assertCommand(a, "/set format trm1 display '{name}:{value}'", ""),
+                (a) -> assertCommand(a, "int x = 66", "x:66"),
+                (a) -> assertCommand(a, "/retain mode trm1", ""),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommand(a, "/set mode trm2 -quiet", ""),
+                (a) -> assertCommand(a, "/set format trm2 display '{name}={value}'", ""),
+                (a) -> assertCommand(a, "int x = 45", "x:45"),
+                (a) -> assertCommand(a, "/retain mode trm2", ""),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommand(a, "int x = 99", "x:99"),
+                (a) -> assertCommand(a, "/set feedback trm2", ""),
+                (a) -> assertCommand(a, "int z = 77", "z=77")
+        );
+    }
+
+    public void testRetainFeedback() {
+        test(
+                (a) -> assertCommand(a, "/retain feedback verbose", "|  Feedback mode: verbose"),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommandOutputContains(a, "int h =8", "|  created variable h : int")
+        );
+    }
+
+    public void testRetainFeedbackBlank() {
+        test(
+                (a) -> assertCommand(a, "/set feedback verbose", "|  Feedback mode: verbose"),
+                (a) -> assertCommand(a, "/retain feedback", ""),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommandOutputContains(a, "int qw = 5", "|  created variable qw : int")
+        );
+    }
+
+    public void testRetainEditor() {
+        test(
+                (a) -> assertCommand(a, "/retain editor nonexistent", "|  Editor set to: nonexistent"),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommandOutputContains(a, "int h =8", ""),
+                (a) -> assertCommandOutputContains(a, "/edit h", "Edit Error:")
+        );
+    }
+
+    public void testRetainEditorBlank() {
+        test(
+                (a) -> assertCommand(a, "/set editor nonexistent", "|  Editor set to: nonexistent"),
+                (a) -> assertCommand(a, "/retain editor", ""),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommandOutputContains(a, "int h =8", ""),
+                (a) -> assertCommandOutputContains(a, "/edit h", "Edit Error:")
+        );
+    }
+
+    public void testRetainModeNeg() {
+        test(
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode verbose",
+                        "|  Not valid with a predefined mode"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain mode ????",
+                        "|  Expected a feedback mode name: ????")
+        );
+    }
+
+    public void testRetainFeedbackNeg() {
+        test(
+                (a) -> assertCommandOutputStartsWith(a, "/retain feedback babble1",
+                        "|  Does not match any current feedback mode"),
+                (a) -> assertCommand(a, "/set mode trfn",
+                        "|  Created new feedback mode: trfn"),
+                (a) -> assertCommandOutputContains(a, "/retain feedback trfn",
+                        "is predefined or has been retained"),
+                (a) -> assertCommandOutputStartsWith(a, "/retain feedback !!!!",
+                        "|  Expected a feedback mode name: !!!!")
+        );
+    }
+
+    public void testNoRetainMode() {
+        test(
+                (a) -> assertCommand(a, "/set mode trm -quiet", "|  Created new feedback mode: trm"),
+                (a) -> assertCommand(a, "/set feedback trm", ""),
+                (a) -> assertCommand(a, "/set format trm display '{name}:{value}'", ""),
+                (a) -> assertCommand(a, "int x = 45", "x:45"),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommandOutputStartsWith(a, "/set feedback trm",
+                        "|  Does not match any current feedback mode"),
+                (a) -> assertCommandOutputContains(a, "int x = 45", "==> 45")
+        );
+    }
+
+    public void testNoRetainFeedback() {
+        test(
+                (a) -> assertCommand(a, "/set feedback verbose", "|  Feedback mode: verbose"),
+                (a) -> assertCommand(a, "/exit", "")
+        );
+        test(
+                (a) -> assertCommand(a, "int h =8", "h ==> 8")
+        );
+    }
+
+}
diff --git a/langtools/test/jdk/jshell/ToolSimpleTest.java b/langtools/test/jdk/jshell/ToolSimpleTest.java
index b0c97a7..064e633 100644
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8153716 8143955 8151754 8150382
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910
  * @summary Simple jshell tool tests
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -101,22 +101,22 @@
         );
     }
 
-    public void defineClasses() {
+    public void defineTypes() {
         test(
                 (a) -> assertCommandCheckOutput(a, "/list", assertList()),
-                (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 (a) -> assertClass(a, "class A { }", "class", "A"),
                 (a) -> assertCommandCheckOutput(a, "/list", assertList()),
-                (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 (a) -> assertClass(a, "interface A { }", "interface", "A"),
                 (a) -> assertCommandCheckOutput(a, "/list", assertList()),
-                (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 (a) -> assertClass(a, "enum A { }", "enum", "A"),
                 (a) -> assertCommandCheckOutput(a, "/list", assertList()),
-                (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 (a) -> assertClass(a, "@interface A { }", "@interface", "A"),
                 (a) -> assertCommandCheckOutput(a, "/list", assertList()),
-                (a) -> assertCommandCheckOutput(a, "/classes", assertClasses())
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses())
         );
     }
 
@@ -179,15 +179,14 @@
     }
 
     public void testNoArgument() {
-        String[] commands = {"/save", "/open", "/set start"};
-        test(Stream.of(commands)
-                .map(cmd -> {
-                    String c = cmd;
-                    final String finalC = c;
-                    return (ReplTest) after -> assertCommand(after, cmd,
-                            "|  '" + finalC + "' requires a filename argument.");
-                })
-                .toArray(ReplTest[]::new));
+        test(
+                (a) -> assertCommand(a, "/save",
+                        "|  '/save' requires a filename argument."),
+                (a) -> assertCommand(a, "/open",
+                        "|  '/open' requires a filename argument."),
+                (a) -> assertCommand(a, "/set start",
+                        "|  Specify either one option or a startup file name -- /set start")
+        );
     }
 
     public void testDebug() {
@@ -211,7 +210,7 @@
                 a -> dropImport(a, "/drop 4", "import java.util.stream.*", ""),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 a -> assertCommandCheckOutput(a, "/imports", assertImports())
         );
         test(false, new String[]{"-nostartup"},
@@ -223,20 +222,22 @@
                 a -> dropClass(a, "/drop A", "class A", "|  dropped class A"),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 a -> assertCommandCheckOutput(a, "/imports", assertImports())
         );
     }
 
     public void testDropNegative() {
         test(false, new String[]{"-nostartup"},
-                a -> assertCommandOutputStartsWith(a, "/drop 0", "|  No definition or id found named: 0"),
-                a -> assertCommandOutputStartsWith(a, "/drop a", "|  No definition or id found named: a"),
+                a -> assertCommandOutputStartsWith(a, "/drop 0", "|  No such snippet: 0"),
+                a -> assertCommandOutputStartsWith(a, "/drop a", "|  No such snippet: a"),
                 a -> assertCommandCheckOutput(a, "/drop",
                         assertStartsWith("|  In the /drop argument, please specify an import, variable, method, or class to drop.")),
                 a -> assertVariable(a, "int", "a"),
                 a -> assertCommand(a, "a", "a ==> 0"),
-                a -> assertCommand(a, "/drop 2", "|  The argument did not specify an active import, variable, method, or class to drop.")
+                a -> assertCommand(a, "/drop 2",
+                        "|  This command does not accept the snippet '2' : a\n" +
+                        "|  See /types, /methods, /vars, or /list")
         );
     }
 
@@ -253,7 +254,7 @@
                 a -> assertCommandCheckOutput(a, "/drop a", check),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
                 a -> assertCommandCheckOutput(a, "/imports", assertImports())
         );
         test(
@@ -284,7 +285,7 @@
                 (a) -> assertHelp(a, "/?", "/list", "/help", "/exit", "intro"),
                 (a) -> assertHelp(a, "/help", "/list", "/help", "/exit", "intro"),
                 (a) -> assertHelp(a, "/help short", "shortcuts", "<tab>"),
-                (a) -> assertHelp(a, "/? /li", "/list all", "snippets"),
+                (a) -> assertHelp(a, "/? /li", "/list -all", "snippets"),
                 (a) -> assertHelp(a, "/help /help", "/help <command>")
         );
     }
@@ -299,7 +300,10 @@
 
     // Check that each line of output contains the corresponding string from the list
     private void checkLineToList(String in, List<String> match) {
-        String[] res = in.trim().split("\n");
+        String trimmed = in.trim();
+        String[] res = trimmed.isEmpty()
+                ? new String[0]
+                : trimmed.split("\n");
         assertEquals(res.length, match.size(), "Got: " + Arrays.asList(res));
         for (int i = 0; i < match.size(); ++i) {
             assertTrue(res[i].contains(match.get(i)));
@@ -311,23 +315,132 @@
         List<String> startVarList = new ArrayList<>(START_UP);
         startVarList.add("int aardvark");
         test(
-                a -> assertCommandCheckOutput(a, "/list all",
+                a -> assertCommandCheckOutput(a, "/list -all",
                         s -> checkLineToList(s, START_UP)),
                 a -> assertCommandOutputStartsWith(a, "/list " + arg,
-                        "|  No definition or id found named: " + arg),
+                        "|  No such snippet: " + arg),
                 a -> assertVariable(a, "int", "aardvark"),
                 a -> assertCommandOutputContains(a, "/list aardvark", "aardvark"),
-                a -> assertCommandCheckOutput(a, "/list start",
+                a -> assertCommandCheckOutput(a, "/list -start",
                         s -> checkLineToList(s, START_UP)),
-                a -> assertCommandCheckOutput(a, "/list all",
+                a -> assertCommandCheckOutput(a, "/list -all",
                         s -> checkLineToList(s, startVarList)),
                 a -> assertCommandCheckOutput(a, "/list printf",
                         s -> assertTrue(s.contains("void printf"))),
                 a -> assertCommandOutputStartsWith(a, "/list " + arg,
-                        "|  No definition or id found named: " + arg)
+                        "|  No such snippet: " + arg)
         );
     }
 
+    public void testVarsArgs() {
+        String arg = "qqqq";
+        List<String> startVarList = new ArrayList<>();
+        test(
+                a -> assertCommandCheckOutput(a, "/vars -all",
+                        s -> checkLineToList(s, startVarList)),
+                a -> assertCommand(a, "/vars " + arg,
+                        "|  No such snippet: " + arg),
+                a -> assertVariable(a, "int", "aardvark"),
+                a -> assertMethod(a, "int f() { return 0; }", "()int", "f"),
+                a -> assertVariable(a, "int", "a"),
+                a -> assertVariable(a, "double", "a", "1", "1.0"),
+                a -> assertCommandOutputStartsWith(a, "/vars aardvark",
+                        "|    int aardvark = 0"),
+                a -> assertCommandCheckOutput(a, "/vars -start",
+                        s -> checkLineToList(s, startVarList)),
+                a -> assertCommandOutputStartsWith(a, "/vars -all",
+                        "|    int aardvark = 0\n|    int a = "),
+                a -> assertCommandOutputStartsWith(a, "/vars printf",
+                        "|  This command does not accept the snippet 'printf'"),
+                a -> assertCommand(a, "/var " + arg,
+                        "|  No such snippet: " + arg)
+        );
+    }
+
+    public void testMethodsArgs() {
+        String arg = "qqqq";
+        List<String> startMethodList = new ArrayList<>(START_UP_CMD_METHOD);
+        test(
+                a -> assertCommandCheckOutput(a, "/methods -all",
+                        s -> checkLineToList(s, startMethodList)),
+                a -> assertCommandCheckOutput(a, "/methods -start",
+                        s -> checkLineToList(s, startMethodList)),
+                a -> assertCommandCheckOutput(a, "/methods printf",
+                        s -> checkLineToList(s, startMethodList)),
+                a -> assertCommandCheckOutput(a, "/methods",
+                        s -> checkLineToList(s, startMethodList)),
+                a -> assertCommandOutputStartsWith(a, "/methods " + arg,
+                        "|  No such snippet: " + arg),
+                a -> assertMethod(a, "int f() { return 0; }", "()int", "f"),
+                a -> assertVariable(a, "int", "aardvark"),
+                a -> assertMethod(a, "void f(int a) { g(); }", "(int)void", "f"),
+                a -> assertMethod(a, "void g() {}", "()void", "g"),
+                a -> assertCommandOutputStartsWith(a, "/methods " + arg,
+                        "|  No such snippet: " + arg),
+                a -> assertCommandOutputStartsWith(a, "/methods aardvark",
+                        "|  This command does not accept the snippet 'aardvark' : int aardvark"),
+                a -> assertCommandCheckOutput(a, "/methods -start",
+                        s -> checkLineToList(s, startMethodList)),
+                a -> assertCommandCheckOutput(a, "/methods printf",
+                        s -> checkLineToList(s, startMethodList)),
+                a -> assertCommandOutputStartsWith(a, "/methods g",
+                        "|    g ()void"),
+                a -> assertCommandOutputStartsWith(a, "/methods f",
+                        "|    f ()int\n" +
+                        "|    f (int)void")
+        );
+    }
+
+    public void testTypesArgs() {
+        String arg = "qqqq";
+        List<String> startTypeList = new ArrayList<>();
+        test(
+                a -> assertCommandCheckOutput(a, "/types -all",
+                        s -> checkLineToList(s, startTypeList)),
+                a -> assertCommandCheckOutput(a, "/types -start",
+                        s -> checkLineToList(s, startTypeList)),
+                a -> assertCommandOutputStartsWith(a, "/types " + arg,
+                        "|  No such snippet: " + arg),
+                a -> assertVariable(a, "int", "aardvark"),
+                (a) -> assertClass(a, "class A { }", "class", "A"),
+                (a) -> assertClass(a, "interface A { }", "interface", "A"),
+                a -> assertCommandOutputStartsWith(a, "/types -all",
+                        "|    class A\n" +
+                        "|    interface A"),
+                (a) -> assertClass(a, "enum E { }", "enum", "E"),
+                (a) -> assertClass(a, "@interface B { }", "@interface", "B"),
+                a -> assertCommand(a, "/types aardvark",
+                        "|  This command does not accept the snippet 'aardvark' : int aardvark;"),
+                a -> assertCommandOutputStartsWith(a, "/types A",
+                        "|    interface A"),
+                a -> assertCommandOutputStartsWith(a, "/types E",
+                        "|    enum E"),
+                a -> assertCommandOutputStartsWith(a, "/types B",
+                        "|    @interface B"),
+                a -> assertCommandOutputStartsWith(a, "/types " + arg,
+                        "|  No such snippet: " + arg),
+                a -> assertCommandCheckOutput(a, "/types -start",
+                        s -> checkLineToList(s, startTypeList))
+        );
+    }
+    public void defineClasses() {
+        test(
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
+                (a) -> assertClass(a, "class A { }", "class", "A"),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
+                (a) -> assertClass(a, "interface A { }", "interface", "A"),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
+                (a) -> assertClass(a, "enum A { }", "enum", "A"),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
+                (a) -> assertClass(a, "@interface A { }", "@interface", "A"),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/types", assertClasses())
+        );
+    }
     public void testCommandPrefix() {
         test(a -> assertCommandCheckOutput(a, "/s",
                       assertStartsWith("|  Command: '/s' is ambiguous: /save, /set")),
@@ -338,18 +451,6 @@
                       assertStartsWith("|  '/save' requires a filename argument.")));
     }
 
-    public void testHeadlessEditPad() {
-        String prevHeadless = System.getProperty("java.awt.headless");
-        try {
-            System.setProperty("java.awt.headless", "true");
-            test(
-                (a) -> assertCommandOutputStartsWith(a, "/edit printf", "|  Cannot launch editor -- unexpected exception:")
-            );
-        } finally {
-            System.setProperty("java.awt.headless", prevHeadless==null? "false" : prevHeadless);
-        }
-    }
-
     public void testOptionQ() {
         test(new String[]{"-q", "-nostartup"},
                 (a) -> assertCommand(a, "1+1", "$1 ==> 2"),
@@ -384,4 +485,11 @@
                         "$1 ==> \"blorp\"")
         );
     }
+
+    public void test8156910() {
+        test(
+                (a) -> assertCommandOutputContains(a, "System.out.println(\"%5d\", 10);", "%5d"),
+                (a) -> assertCommandOutputContains(a, "1234", "==> 1234")
+        );
+    }
 }
diff --git a/langtools/test/tools/all/RunCodingRules.java b/langtools/test/tools/all/RunCodingRules.java
index 4e3d5db..8e345ce 100644
--- a/langtools/test/tools/all/RunCodingRules.java
+++ b/langtools/test/tools/all/RunCodingRules.java
@@ -50,6 +50,17 @@
 
 import com.sun.tools.javac.util.Assert;
 
+/**
+ * This is a test to verify specific coding standards for source code in the langtools repository.
+ *
+ * As such, it is not a standard unit, regression or functional test, and will
+ * automatically skip if the langtools source code is not available.
+ *
+ * If the source code is available, it will find and compile the coding
+ * style analyzers found in langtools/make/tools/crules/*.java, and run the resulting
+ * code on all source files under langtools/src/share/classes. Any coding style
+ * violations will cause the test to fail.
+ */
 public class RunCodingRules {
     public static void main(String... args) throws Exception {
         new RunCodingRules().run();
diff --git a/langtools/test/tools/javac/DefiniteAssignment/8156180/T8156180.java b/langtools/test/tools/javac/DefiniteAssignment/8156180/T8156180.java
new file mode 100644
index 0000000..9a31081
--- /dev/null
+++ b/langtools/test/tools/javac/DefiniteAssignment/8156180/T8156180.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8156180
+ * @summary javac accepts code that violates JLS chapter 16
+ *
+ * @compile/fail/ref=T8156180.out -XDrawDiagnostics T8156180.java
+ */
+
+class T8156180 {
+    public final int a1, b1, c1, d1;
+    public int a2, b2, c2, d2;
+
+    T8156180(int value) {
+        a2 = this.a1;
+        b2 = (this).b1;
+        c2 = ((this)).c1;
+        d2 = (((this))).d1;
+        a1 = value;
+        b1 = value;
+        c1 = value;
+        d1 = value;
+    }
+}
diff --git a/langtools/test/tools/javac/DefiniteAssignment/8156180/T8156180.out b/langtools/test/tools/javac/DefiniteAssignment/8156180/T8156180.out
new file mode 100644
index 0000000..7668ee4
--- /dev/null
+++ b/langtools/test/tools/javac/DefiniteAssignment/8156180/T8156180.out
@@ -0,0 +1,5 @@
+T8156180.java:14:18: compiler.err.var.might.not.have.been.initialized: a1
+T8156180.java:15:20: compiler.err.var.might.not.have.been.initialized: b1
+T8156180.java:16:22: compiler.err.var.might.not.have.been.initialized: c1
+T8156180.java:17:24: compiler.err.var.might.not.have.been.initialized: d1
+4 errors
diff --git a/langtools/test/tools/javac/Diagnostics/compressed/T8012003b.out b/langtools/test/tools/javac/Diagnostics/compressed/T8012003b.out
index 246900b..fe2b6fd 100644
--- a/langtools/test/tools/javac/Diagnostics/compressed/T8012003b.out
+++ b/langtools/test/tools/javac/Diagnostics/compressed/T8012003b.out
@@ -1,5 +1,5 @@
 T8012003b.java:30:12: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, g, java.lang.String, compiler.misc.no.args, kindname.class, T8012003b, (compiler.misc.arg.length.mismatch)))
-T8012003b.java:31:16: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+T8012003b.java:31:16: compiler.err.prob.found.req: (compiler.misc.stat.expr.expected)
 T8012003b.java:32:22: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.conditional.target.cant.be.void))
 T8012003b.java:33:12: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)))
 T8012003b.java:34:12: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
diff --git a/langtools/test/tools/javac/Paths/MineField.sh b/langtools/test/tools/javac/Paths/MineField.sh
index f9843c4..064071f 100644
--- a/langtools/test/tools/javac/Paths/MineField.sh
+++ b/langtools/test/tools/javac/Paths/MineField.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 #
 # @test
-# @bug 4758537 4809833
+# @bug 4758537 4809833 8149599
 # @summary Test that javac and java find files in similar ways
 # @author Martin Buchholz
 #
@@ -49,14 +49,33 @@
 # - Only for the user classpath is an empty string value equivalent to "."
 # - Specifying a bootclasspath on the command line obliterates any
 #   previous -Xbootclasspath/p: or -Xbootclasspath/a: command line flags.
+#
+# JDK 9 update:
+#   java: The java launcher does not support any of the following:
+#       * -Xbootclasspath/p: -Xbootclasspath:
+#       * -endorseddirs -Djava.endorsed.dirs
+#       * -extdirs -Djava.ext.dirs
+#       All test cases exercising these features have been removed.
+#   javac: The following features are only supported when compiling
+#       for older releases:
+#       * -Xbootclasspath/p: -Xbootclasspath: -bootclasspath -Xbootclasspath/a:
+#       * -endorseddirs -Djava.endorsed.dirs
+#       * -extdirs -Djava.ext.dirs
+#       All test cases exercising these features have been modified to
+#       use -source 8 -target 8.  In addition, javac test cases involving
+#       use of the runtime properties java.endorsed.dirs and java.extdirs
+#       (by means of -J-Dname=value) have been removed.
+#       Although the primary purpose of the test cases in this file is to
+#       compare javac and java behavior, some tests remain for javac for
+#       which there is no java equivalent. However, the cases remain as useful
+#       test cases for javac handling of the paths involved.
+
 #----------------------------------------------------------------
 
 . ${TESTSRC-.}/Util.sh
 
 set -u
 
-# BCP=`DefaultBootClassPath`
-
 #----------------------------------------------------------------
 # Prepare the "Minefield"
 #----------------------------------------------------------------
@@ -64,6 +83,7 @@
     Sys rm -rf GooSrc GooJar GooZip GooClass
     Sys rm -rf BadSrc BadJar BadZip BadClass
     Sys rm -rf OneDir *.class Main.java MANIFEST.MF
+    Sys rm -f java-lang.jar
 }
 
 Cleanup
@@ -88,215 +108,95 @@
 
 echo 'public class Main {public static void main(String[] a) {Lib.f();}}' > Main.java
 
+# Create a jar file that is good enough to put on the javac boot class path (i.e. contains java.lang.**)
+Sys "$jimage" extract --dir modules ${TESTJAVA}/lib/modules
+Sys "$jar" cf java-lang.jar -C modules/java.base java/lang
+Sys rm -rf modules
+
 #----------------------------------------------------------------
 # Verify that javac class search order is the same as java's
 #----------------------------------------------------------------
-# Failure "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"BadClass" \
-#     -J-Djava.endorsed.dirs="GooJar" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"GooClass${PS}BadJar/Lib.jar" \
-#     -J-Djava.endorsed.dirs="BadJar${PS}GooZip" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"BadClass" \
-#     -Djava.endorsed.dirs="GooJar" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"GooClass${PS}BadJar/Lib.jar" \
-#     -Djava.endorsed.dirs="BadJar${PS}GooZip" \
-#     Main
+Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -Xbootclasspath/p:"GooClass" \
+    -bootclasspath "java-lang.jar${PS}BadZip/Lib.zip" \
+    Main.java
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -Xbootclasspath/p:"BadClass${PS}GooClass" \
+    -bootclasspath "java-lang.jar${PS}GooZip/Lib.zip${PS}BadClass" \
+    Main.java
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -Xbootclasspath/p:"BadJar/Lib.jar" \
+    -Xbootclasspath:"java-lang.jar${PS}GooClass" \
+    Main.java
 
 #----------------------------------------------------------------
-# Failure "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"GooClass" \
-#     -bootclasspath "$BCP${PS}BadZip/Lib.zip" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"BadClass${PS}GooClass" \
-#     -bootclasspath "$BCP${PS}GooZip/Lib.zip${PS}BadClass" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"BadJar/Lib.jar" \
-#     -Xbootclasspath:"$BCP${PS}GooClass" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"GooClass" \
-#     -Xbootclasspath:"$BCP${PS}BadZip/Lib.zip" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"BadClass${PS}GooClass" \
-#     -Xbootclasspath:"$BCP${PS}GooZip/Lib.zip${PS}BadClass" \
-#     Main
+Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -bootclasspath "java-lang.jar${PS}GooZip/Lib.zip" \
+    -Xbootclasspath/p:"BadClass" \
+    Main.java
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -bootclasspath "java-lang.jar${PS}BadZip/Lib.zip" \
+    -Xbootclasspath/p:"GooClass${PS}BadJar/Lib.jar" \
+    Main.java
 
 #----------------------------------------------------------------
-# Failure "$javac" ${TESTTOOLVMOPTS} \
-#     -bootclasspath "$BCP${PS}GooZip/Lib.zip" \
-#     -Xbootclasspath/p:"BadClass" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -bootclasspath "$BCP${PS}BadZip/Lib.zip" \
-#     -Xbootclasspath/p:"GooClass${PS}BadJar/Lib.jar" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath:"$BCP${PS}GooClass" \
-#     -Xbootclasspath/p:"BadClass" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath:"$BCP${PS}BadClass" \
-#     -Xbootclasspath/p:"GooClass${PS}BadJar/Lib.jar" \
-#     Main
-
-#----------------------------------------------------------------
-Failure "$javac" ${TESTTOOLVMOPTS} \
+Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
     -Xbootclasspath/p:"BadClass" \
     -Xbootclasspath/a:"GooClass" \
     Main.java
-Success "$javac" ${TESTTOOLVMOPTS} \
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
     -Xbootclasspath/p:"GooClass${PS}BadClass" \
     -Xbootclasspath/a:"BadClass" \
     Main.java
-Failure "$java" ${TESTVMOPTS} \
-    -Xbootclasspath/p:"BadClass" \
-    -Xbootclasspath/a:"GooClass" \
-    Main
 Success "$java" ${TESTVMOPTS} \
-    -Xbootclasspath/p:"GooClass${PS}BadClass" \
-    -Xbootclasspath/a:"BadClass" \
+    -Xbootclasspath/a:"GooClass" \
     Main
 
 #----------------------------------------------------------------
-# Failure "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"GooClass" \
-#     -J-Djava.endorsed.dirs="BadZip" \
-#     -bootclasspath "GooClass${PS}$BCP" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"BadClass" \
-#     -J-Djava.endorsed.dirs="BadClass${PS}GooZip${PS}BadJar" \
-#     -bootclasspath "BadClass${PS}$BCP" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"GooClass" \
-#     -Djava.endorsed.dirs="BadZip" \
-#     -Xbootclasspath:"GooClass${PS}$BCP" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"BadClass" \
-#     -Djava.endorsed.dirs="BadClass${PS}GooZip${PS}BadJar" \
-#     -Xbootclasspath:"BadClass${PS}$BCP" \
-#     Main
+Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -Xbootclasspath/p:"GooClass" \
+    -Xbootclasspath:"BadClass${PS}java-lang.jar" \
+    -Xbootclasspath/a:"GooClass" \
+    Main.java
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -Xbootclasspath/p:"BadClass" \
+    -Xbootclasspath:"GooClass${PS}BadClass${PS}java-lang.jar" \
+    -Xbootclasspath/a:"BadClass" \
+    Main.java
 
 #----------------------------------------------------------------
-# Failure "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"GooClass" \
-#     -Xbootclasspath:"BadClass${PS}$BCP" \
-#     -Xbootclasspath/a:"GooClass" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -Xbootclasspath/p:"BadClass" \
-#     -Xbootclasspath:"GooClass${PS}BadClass${PS}$BCP" \
-#     -Xbootclasspath/a:"BadClass" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"GooClass" \
-#     -Xbootclasspath:"BadClass${PS}$BCP" \
-#     -Xbootclasspath/a:"GooClass" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/p:"BadClass" \
-#     -Xbootclasspath:"GooClass${PS}BadClass${PS}$BCP" \
-#     -Xbootclasspath/a:"BadClass" \
-#     Main
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -endorseddirs "BadClass${PS}GooZip${PS}BadJar" \
+    -Xbootclasspath:"BadClass${PS}java-lang.jar" \
+    Main.java
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
+    -Djava.endorsed.dirs="BadClass${PS}GooZip${PS}BadJar" \
+    -Xbootclasspath:"BadClass${PS}java-lang.jar" \
+    Main.java
 
 #----------------------------------------------------------------
-# Failure "$javac" ${TESTTOOLVMOPTS} \
-#     -J-Djava.endorsed.dirs="BadZip" \
-#     -Xbootclasspath:"GooClass${PS}$BCP" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -endorseddirs "BadClass${PS}GooZip${PS}BadJar" \
-#     -Xbootclasspath:"BadClass${PS}$BCP" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -Djava.endorsed.dirs="BadClass${PS}GooZip${PS}BadJar" \
-#     -Xbootclasspath:"BadClass${PS}$BCP" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -J-Djava.endorsed.dirs="BadClass${PS}GooZip${PS}BadJar" \
-#     -Xbootclasspath:"BadClass${PS}$BCP" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Djava.endorsed.dirs="BadZip" \
-#     -Xbootclasspath:"GooClass${PS}$BCP" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Djava.endorsed.dirs="BadClass${PS}GooZip${PS}BadJar" \
-#     -Xbootclasspath:"BadClass${PS}$BCP" \
-#     Main
-
-#----------------------------------------------------------------
-Failure "$javac" ${TESTTOOLVMOPTS} \
+Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
     -Xbootclasspath/a:"BadClass" \
     -extdirs "GooZip" \
     Main.java
-Success "$javac" ${TESTTOOLVMOPTS} \
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
     -Xbootclasspath/a:"GooClass${PS}BadClass" \
     -extdirs "BadZip" \
     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/a:"BadClass" \
-#     -Djava.ext.dirs="GooZip" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath/a:"GooClass${PS}BadClass" \
-#     -Djava.ext.dirs="BadZip" \
-#     Main
 
 #----------------------------------------------------------------
-# Failure "$javac" ${TESTTOOLVMOPTS} \
-#     -bootclasspath "$BCP${PS}BadJar/Lib.jar" \
-#     -J-Djava.ext.dir="GooJar" \
-#     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -bootclasspath "$BCP${PS}GooJar/Lib.jar${PS}BadClass" \
-#     -J-Djava.ext.dir="BadJar" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath:"$BCP${PS}BadJar/Lib.jar" \
-#     -Djava.ext.dirs="GooJar" \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Xbootclasspath:"$BCP${PS}GooJar/Lib.jar${PS}BadClass" \
-#     -Djava.ext.dirs="BadJar" \
-#     Main
-
-#----------------------------------------------------------------
-Failure "$javac" ${TESTTOOLVMOPTS} \
+Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
     -extdirs "GooClass${PS}BadZip" \
     -cp "GooZip/Lib.zip" \
     Main.java
-Success "$javac" ${TESTTOOLVMOPTS} \
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
     -extdirs "BadClass${PS}GooZip${PS}BadJar" \
     -cp "BadZip/Lib.zip" \
     Main.java
-Success "$javac" ${TESTTOOLVMOPTS} \
+Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} \
     -Djava.ext.dirs="GooZip${PS}BadJar" \
     -classpath "BadZip/Lib.zip" \
     Main.java
-# Success "$javac" ${TESTTOOLVMOPTS} \
-#     -J-Djava.ext.dirs="GooZip${PS}BadJar" \
-#     -classpath "BadZip/Lib.zip" \
-#     Main.java
-# Failure "$java" ${TESTVMOPTS} \
-#     -Djava.ext.dirs="GooClass${PS}BadZip" \
-#     -cp "GooZip/Lib.zip${PS}." \
-#     Main
-# Success "$java" ${TESTVMOPTS} \
-#     -Djava.ext.dirs="GooZip${PS}BadJar" \
-#     -cp "BadZip/Lib.zip${PS}." \
-#     Main
 
 #----------------------------------------------------------------
 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "BadClass${PS}GooClass" Main.java
@@ -338,45 +238,32 @@
 In GooClass Success "$java" ${TESTVMOPTS}  -cp "..${PS}${PS}/xyzzy" Main
 
 # All other empty path elements are ignored.
-In GooJar Failure "$javac" ${TESTTOOLVMOPTS} -extdirs "" -cp ".." ../Main.java
-# In GooJar Failure "$java" ${TESTVMOPTS} -Djava.ext.dirs="" -cp ".." Main
+In GooJar Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -extdirs "" -cp ".." ../Main.java
 
-In GooJar Failure "$javac" ${TESTTOOLVMOPTS} -extdirs        "${PS}" -cp ".." ../Main.java
-In GooJar Failure "$javac" ${TESTTOOLVMOPTS} -Djava.ext.dirs="${PS}" -cp ".." ../Main.java
-# In GooJar Failure "$java" ${TESTVMOPTS}  -Djava.ext.dirs="${PS}" -cp ".." Main
+In GooJar Failure "$javac" -source 8 -targt 8 ${TESTTOOLVMOPTS} -extdirs        "${PS}" -cp ".." ../Main.java
+In GooJar Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Djava.ext.dirs="${PS}" -cp ".." ../Main.java
 
-In GooJar Success "$javac" ${TESTTOOLVMOPTS} -extdirs        "." -cp ".." ../Main.java
-In GooJar Success "$javac" ${TESTTOOLVMOPTS} -Djava.ext.dirs="." -cp ".." ../Main.java
-# In GooJar Success "$java" ${TESTVMOPTS}  -Djava.ext.dirs="." -cp ".." Main
+In GooJar Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -extdirs        "." -cp ".." ../Main.java
+In GooJar Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Djava.ext.dirs="." -cp ".." ../Main.java
 
-# In GooJar Failure "$javac" ${TESTTOOLVMOPTS} -J-Djava.endorsed.dirs="" -cp ".." ../Main.java
-In GooJar Failure "$javac" ${TESTTOOLVMOPTS}   -Djava.endorsed.dirs="" -cp ".." ../Main.java
-# In GooJar Failure "$java" ${TESTVMOPTS}    -Djava.endorsed.dirs="" -cp ".." Main
+In GooJar Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS}   -Djava.endorsed.dirs="" -cp ".." ../Main.java
 
-# In GooJar Failure "$javac" ${TESTTOOLVMOPTS} -J-Djava.endorsed.dirs="${PS}" -cp ".." ../Main.java
-In GooJar Failure "$javac" ${TESTTOOLVMOPTS}   -endorseddirs        "${PS}" -cp ".." ../Main.java
-# In GooJar Failure "$java" ${TESTVMOPTS}    -Djava.endorsed.dirs="${PS}" -cp ".." Main
+In GooJar Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS}   -endorseddirs        "${PS}" -cp ".." ../Main.java
 
-# In GooJar Success "$javac" ${TESTTOOLVMOPTS} -J-Djava.endorsed.dirs="." -cp ".." ../Main.java
-In GooJar Success "$javac" ${TESTTOOLVMOPTS}   -Djava.endorsed.dirs="." -cp ".." ../Main.java
-# In GooJar Success "$java" ${TESTVMOPTS}    -Djava.endorsed.dirs="." -cp ".." Main
+In GooJar Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS}   -Djava.endorsed.dirs="." -cp ".." ../Main.java
 
-In GooClass Failure "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath/p: -cp ".." ../Main.java
-In GooClass Failure "$java" ${TESTVMOPTS}  -Xbootclasspath/p: -cp ".." Main
+In GooClass Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Xbootclasspath/p: -cp ".." ../Main.java
 
-In GooClass Success "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath/p:. -cp ".." ../Main.java
-In GooClass Success "$java" ${TESTVMOPTS}  -Xbootclasspath/p:. -cp ".." Main
+In GooClass Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Xbootclasspath/p:. -cp ".." ../Main.java
 
-# In GooClass Failure "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath:"$BCP" -cp ".." ../Main.java
-# In GooClass Failure "$java" ${TESTVMOPTS}  -Xbootclasspath:"$BCP" -cp ".." Main
+In GooClass Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Xbootclasspath:"../java-lang.jar" -cp ".." ../Main.java
 
-# In GooClass Success "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath:"$BCP${PS}." -cp ".." ../Main.java
-# In GooClass Success "$java" ${TESTVMOPTS}  -Xbootclasspath:"$BCP${PS}." -cp ".." Main
+In GooClass Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Xbootclasspath:"../java-lang.jar${PS}." -cp ".." ../Main.java
 
-In GooClass Failure "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath/a: -cp ".." ../Main.java
+In GooClass Failure "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Xbootclasspath/a: -cp ".." ../Main.java
 In GooClass Failure "$java" ${TESTVMOPTS}  -Xbootclasspath/a: -cp ".." Main
 
-In GooClass Success "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath/a:. -cp ".." ../Main.java
+In GooClass Success "$javac" -source 8 -target 8 ${TESTTOOLVMOPTS} -Xbootclasspath/a:. -cp ".." ../Main.java
 In GooClass Success "$java" ${TESTVMOPTS}  -Xbootclasspath/a:. -cp ".." Main
 
 Cleanup
diff --git a/langtools/test/tools/javac/Paths/Util.sh b/langtools/test/tools/javac/Paths/Util.sh
index 3f41f70..1befd80 100644
--- a/langtools/test/tools/javac/Paths/Util.sh
+++ b/langtools/test/tools/javac/Paths/Util.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,10 @@
 # Utilities for shell tests
 
 : ${TESTSRC=.} ${TESTCLASSES=.}
- java="${TESTJAVA+${TESTJAVA}/bin/}java"
-javac="${TESTJAVA+${TESTJAVA}/bin/}javac"
-  jar="${TESTJAVA+${TESTJAVA}/bin/}jar"
+  java="${TESTJAVA+${TESTJAVA}/bin/}java"
+ javac="${TESTJAVA+${TESTJAVA}/bin/}javac"
+   jar="${TESTJAVA+${TESTJAVA}/bin/}jar"
+jimage="${TESTJAVA+${TESTJAVA}/bin/}jimage"
 
 case `uname -s` in
   Windows*|CYGWIN*)
@@ -105,21 +106,6 @@
     for jarfilename in "$@"; do pwd > "$jarfilename"; done
 }
 
-# #----------------------------------------------------------------
-# # Usage: BCP=`DefaultBootClassPath`
-# # Returns default bootclasspath, discarding non-existent entries
-# #----------------------------------------------------------------
-# DefaultBootClassPath() {
-#     echo 'public class B {public static void main(String[] a) {
-#     System.out.println(System.getProperty("sun.boot.class.path"));}}' > B.java
-#     "$javac" ${TESTTOOLVMOPTS} B.java
-#     _BCP_=""
-#     for elt in `"$java" ${TESTVMOPTS} B | tr "${PS}" " "`; do
-#       test -r "$elt" -a -n "$elt" && _BCP_="${_BCP_:+${_BCP_}${PS}}${elt}"
-#     done
-#     rm -f B.java B.class
-#     printf "%s" "$_BCP_"      # Don't use echo -- unsafe on Windows
-# }
 
 #----------------------------------------------------------------
 # Foil message localization
diff --git a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java
index a6a4cde..3134c72 100644
--- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java
+++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java
@@ -108,14 +108,14 @@
         // when running javac on JDK 8.
         ignore("com/sun/tools/javac/util/ModuleHelper",
                 "addExportsMethod", "getModuleMethod", "getUnnamedModuleMethod");
-        ignore("com/sun/tools/javac/util/ModuleWrappers$ConfigurationHelper",
+        ignore("com/sun/tools/javac/util/JDK9Wrappers$Configuration",
                 "resolveRequiresAndUsesMethod", "configurationClass");
-        ignore("com/sun/tools/javac/util/ModuleWrappers$LayerHelper",
+        ignore("com/sun/tools/javac/util/JDK9Wrappers$Layer",
                 "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod", "layerClass");
-        ignore("com/sun/tools/javac/util/ModuleWrappers$ModuleFinderHelper",
-                "emptyMethod", "moduleFinderInterface", "ofMethod");
-
-
+        ignore("com/sun/tools/javac/util/JDK9Wrappers$ModuleFinder",
+                "moduleFinderClass", "ofMethod");
+        ignore("com/sun/tools/javac/util/JDK9Wrappers$ServiceLoaderHelper",
+                "loadMethod");
     }
 
     private final List<String> errors = new ArrayList<>();
diff --git a/langtools/test/tools/javac/diags/Example.java b/langtools/test/tools/javac/diags/Example.java
index e7e2556..b9c09cf 100644
--- a/langtools/test/tools/javac/diags/Example.java
+++ b/langtools/test/tools/javac/diags/Example.java
@@ -63,6 +63,8 @@
         procFiles = new ArrayList<File>();
         supportFiles = new ArrayList<File>();
         srcPathFiles = new ArrayList<File>();
+        moduleSourcePathFiles = new ArrayList<File>();
+        additionalFiles = new ArrayList<File>();
 
         findFiles(file, srcFiles);
         for (File f: srcFiles) {
@@ -81,13 +83,23 @@
                 else if (files == srcFiles && c.getName().equals("sourcepath")) {
                     srcPathDir = c;
                     findFiles(c, srcPathFiles);
+                } else if (files == srcFiles && c.getName().equals("modulesourcepath")) {
+                    moduleSourcePathDir = c;
+                    findFiles(c, moduleSourcePathFiles);
+                } else if (files == srcFiles && c.getName().equals("additional")) {
+                    additionalFilesDir = c;
+                    findFiles(c, additionalFiles);
                 } else if (files == srcFiles && c.getName().equals("support"))
                     findFiles(c, supportFiles);
                 else
                     findFiles(c, files);
             }
-        } else if (f.isFile() && f.getName().endsWith(".java")) {
-            files.add(f);
+        } else if (f.isFile()) {
+                if (f.getName().endsWith(".java")) {
+                    files.add(f);
+                } else if (f.getName().equals("modulesourcepath")) {
+                    moduleSourcePathDir = f;
+                }
         }
     }
 
@@ -228,14 +240,27 @@
             }
         }
 
+        List<File> files = srcFiles;
+
         if (srcPathDir != null) {
             opts.add("-sourcepath");
             opts.add(srcPathDir.getPath());
         }
 
+        if (moduleSourcePathDir != null) {
+            opts.add("-modulesourcepath");
+            opts.add(moduleSourcePathDir.getPath());
+            files = moduleSourcePathFiles;
+        }
+
+        if (additionalFiles.size() > 0) {
+            List<String> sOpts = Arrays.asList("-d", classesDir.getPath());
+            new Jsr199Compiler(verbose).run(null, null, false, sOpts, additionalFiles);
+        }
+
         try {
             Compiler c = Compiler.getCompiler(runOpts, verbose);
-            c.run(out, keys, raw, opts, srcFiles);
+            c.run(out, keys, raw, opts, files);
         } catch (IllegalArgumentException e) {
             if (out != null) {
                 out.println("Invalid value for run tag: " + runOpts);
@@ -298,7 +323,11 @@
     List<File> srcFiles;
     List<File> procFiles;
     File srcPathDir;
+    File moduleSourcePathDir;
+    File additionalFilesDir;
     List<File> srcPathFiles;
+    List<File> moduleSourcePathFiles;
+    List<File> additionalFiles;
     List<File> supportFiles;
     File infoFile;
     private List<String> runOpts;
diff --git a/langtools/test/tools/javac/diags/examples.not-yet.txt b/langtools/test/tools/javac/diags/examples.not-yet.txt
index 6e2e5e7..cfe33c9 100644
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt
@@ -110,67 +110,26 @@
 compiler.misc.bad.class.file                            # class file is malformed
 compiler.misc.bad.const.pool.entry                      # constant pool entry has wrong type
 
-# The following are new module-related messages, that need new examples to be created
-compiler.err.addmods.all.module.path.invalid
-compiler.err.cant.find.module
-compiler.err.cyclic.requires
-compiler.err.duplicate.exports
-compiler.err.duplicate.module
+# The following module-related messages will have to stay on the not-yet list for various reasons:
+compiler.warn.locn.unknown.file.on.module.path                # Never issued ATM (short circuited with an if (false))
+compiler.err.no.output.dir                                    # -d is always specified by test infrastructure
+compiler.err.output.dir.must.be.specified.with.dash.m.option  # -d is always specified by test infrastructure
+compiler.warn.outdir.is.in.exploded.module                    # No control over -d specified by test infrastructure
+compiler.err.invalid.module.specifier                         # Not possible (?)
+compiler.err.locn.cant.get.module.name.for.jar                # bad binary ? Infer module name failure
+compiler.misc.bad.module-info.name                            # bad class file
+compiler.err.locn.bad.module-info                             # bad class file
+compiler.err.locn.cant.read.file                              # bad class file
+compiler.err.locn.cant.read.directory                         # file system issue
+compiler.misc.unnamed.module                                  # fragment uninteresting in and of itself
+compiler.misc.kindname.module                                 # fragment uninteresting in and of itself
+compiler.misc.locn.module_path                                # fragment uninteresting in and of itself
+compiler.misc.locn.module_source_path                         # fragment uninteresting in and of itself
+compiler.misc.locn.system_modules                             # fragment uninteresting in and of itself
+compiler.misc.locn.upgrade_module_path                        # fragment uninteresting in and of itself
+
+# The following are new module-related messages, that need new  examples to be created
 compiler.err.duplicate.module.on.path
-compiler.err.duplicate.provides
-compiler.err.duplicate.requires
-compiler.err.duplicate.uses
-compiler.err.expected.module
-compiler.err.illegal.argument.for.option
-compiler.err.invalid.module.specifier
-compiler.err.locn.bad.module-info
-compiler.err.locn.cant.get.module.name.for.jar
-compiler.err.locn.cant.read.directory
-compiler.err.locn.cant.read.file
-compiler.err.locn.invalid.arg.for.xpatch
 compiler.err.locn.module-info.not.allowed.on.patch.path
-compiler.err.module-info.with.xmodule.classpath
-compiler.err.module-info.with.xmodule.sourcepath
-compiler.err.module.decl.sb.in.module-info.java
-compiler.err.module.name.mismatch
-compiler.err.module.not.found
-compiler.err.module.not.found.in.module.source.path
-compiler.err.modules.not.supported.in.source
-compiler.err.modulesourcepath.must.be.specified.with.dash.m.option
-compiler.err.multi-module.outdir.cannot.be.exploded.module
-compiler.err.no.output.dir
-compiler.err.not.def.access.package.cant.access
-compiler.err.output.dir.must.be.specified.with.dash.m.option
-compiler.err.package.clash.from.requires
-compiler.err.package.empty.or.not.found
-compiler.err.package.in.other.module
-compiler.err.processorpath.no.processormodulepath
-compiler.err.service.definition.is.inner
-compiler.err.service.definition.is.enum
-compiler.err.service.implementation.doesnt.have.a.no.args.constructor
-compiler.err.service.implementation.is.abstract
-compiler.err.service.implementation.is.inner
-compiler.err.service.implementation.no.args.constructor.not.public
-compiler.err.service.implementation.not.in.right.module
-compiler.err.too.many.modules
-compiler.err.unexpected.after.module
-compiler.err.unnamed.pkg.not.allowed.named.modules
-compiler.err.xaddexports.malformed.entry
-compiler.err.xaddexports.too.many
-compiler.err.xaddreads.malformed.entry
-compiler.err.xaddreads.too.many
-compiler.err.xmodule.no.module.sourcepath
-compiler.misc.bad.module-info.name
 compiler.misc.cant.resolve.modules
 compiler.misc.file.does.not.contain.module
-compiler.misc.kindname.module
-compiler.misc.locn.module_path
-compiler.misc.locn.module_source_path
-compiler.misc.locn.system_modules
-compiler.misc.locn.upgrade_module_path
-compiler.misc.unnamed.module
-compiler.warn.dir.path.element.not.directory
-compiler.warn.locn.unknown.file.on.module.path
-compiler.warn.outdir.is.in.exploded.module
-compiler.warn.service.provided.but.not.exported.or.used
-
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java
index 135652e..95c566a 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.addmods.all.module.path.invalid
+// options: -addmods ALL-MODULE-PATH
+module m {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java
similarity index 81%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java
index 135652e..5446a4b 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.cant.find.module
+// key: compiler.err.doesnt.exist
 
-public class Unsafe {
-    private Unsafe() { }
+// options: -XaddExports:undef/undef=ALL-UNNAMED
 
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+import undef.Any;
+
+class Test {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/CyclicRequires/CyclicRequires.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/CyclicRequires/CyclicRequires.java
index 135652e..0d85201 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/CyclicRequires/CyclicRequires.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.cyclic.requires
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/CyclicRequires/modulesourcepath/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/CyclicRequires/modulesourcepath/m1/module-info.java
index 135652e..438f579 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/CyclicRequires/modulesourcepath/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m1 {
+     requires m2;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/CyclicRequires/modulesourcepath/m2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/CyclicRequires/modulesourcepath/m2/module-info.java
index 135652e..45858e7 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/CyclicRequires/modulesourcepath/m2/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m2 {
+     requires m1;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/DirPathElementNotDirectory.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/DirPathElementNotDirectory.java
index 135652e..9fb276d 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/DirPathElementNotDirectory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.warn.dir.path.element.not.directory
+// options: -Xlint:path
+// run: simple
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class DirPathElementNotDirectory { }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/modulesourcepath
similarity index 81%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/modulesourcepath
index 135652e..42c5a0c 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/modulesourcepath
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,5 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// a file to be passed in where a directory is expected (-modulesourcepath option)
+// to trigger an error deliberately.
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateExports/exported/Class.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateExports/exported/Class.java
index 135652e..31f1420 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateExports/exported/Class.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class Class {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateExports/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateExports/module-info.java
index 135652e..4c3b290 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateExports/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.duplicate.exports
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module DuplicateExports {
+     exports exported;
+     exports exported;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateModule/DuplicateModule.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateModule/DuplicateModule.java
index 135652e..d5350d4 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateModule/DuplicateModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,5 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.duplicate.module
+// key: compiler.err.module.name.mismatch
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateModule/modulesourcepath/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateModule/modulesourcepath/m1/module-info.java
index 135652e..c46643d 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateModule/modulesourcepath/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module blah {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateModule/modulesourcepath/m2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateModule/modulesourcepath/m2/module-info.java
index 135652e..c46643d 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateModule/modulesourcepath/m2/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module blah {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateProvides/exported/Service.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateProvides/exported/Service.java
index 135652e..b5b1029 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateProvides/exported/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateProvides/impl/ServiceImplementation.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateProvides/impl/ServiceImplementation.java
index 135652e..37403f5 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateProvides/impl/ServiceImplementation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+package impl;
 
-public class Unsafe {
-    private Unsafe() { }
+import exported.Service;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class ServiceImplementation implements Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateProvides/module-info.java
similarity index 77%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateProvides/module-info.java
index 135652e..d8e2916 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateProvides/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,10 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.duplicate.provides
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module DuplicateExports {
+     exports exported;
+     provides exported.Service with impl.ServiceImplementation;
+     provides exported.Service with impl.ServiceImplementation;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateRequires/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateRequires/module-info.java
index 135652e..b253c6e 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateRequires/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.duplicate.requires
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module DuplicateRequires {
+     requires java.se;
+     requires java.se;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateUses/exported/Service.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateUses/exported/Service.java
index 135652e..b5b1029 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateUses/exported/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/DuplicateUses/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/DuplicateUses/module-info.java
index 135652e..6edf4c0 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/DuplicateUses/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,10 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.duplicate.uses
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module DuplicateExports {
+     exports exported;
+     uses exported.Service;
+     uses exported.Service;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java
index 135652e..81205c4 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.illegal.argument.for.option
+// options: -modulepath doesNotExist
+// run: simple
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class X {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java
index 135652e..20d501b 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.locn.invalid.arg.for.xpatch
+// options: -Xpatch:blah
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class InvalidArgForXpatch {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleDeclSbInModuleInfoJava.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleDeclSbInModuleInfoJava.java
index 135652e..f5db585 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleDeclSbInModuleInfoJava.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+//key: compiler.err.module.decl.sb.in.module-info.java
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module ModuleDeclSbInModuleInfoJava {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/Extra.java
similarity index 81%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/Extra.java
index 135652e..cafc425 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/Extra.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.module-info.with.xmodule.sourcepath
+// options: -Xmodule:java.compiler
 
-public class Unsafe {
-    private Unsafe() { }
+package javax.lang.model.element;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+public interface Extra {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/module-info.java
index 135652e..7971526 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module java.compiler {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/ModuleInfoWithXmoduleClasspath.java
similarity index 79%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/ModuleInfoWithXmoduleClasspath.java
index 135652e..a9ea819 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/ModuleInfoWithXmoduleClasspath.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.module-info.with.xmodule.classpath
+// options: -Xmodule:java.compiler
 
-public class Unsafe {
-    private Unsafe() { }
+package javax.lang.model.element;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+public interface ModuleInfoWithXModuleClasspath {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/additional/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/additional/module-info.java
index 135652e..6faf7db 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/additional/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module mod {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleInfoWithoutModule/ModuleInfoWithoutModule.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleInfoWithoutModule/ModuleInfoWithoutModule.java
index 135652e..ce34abe 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithoutModule/ModuleInfoWithoutModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.expected.module
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleInfoWithoutModule/modulesourcepath/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleInfoWithoutModule/modulesourcepath/m1/module-info.java
index 135652e..7c7bc4d 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithoutModule/modulesourcepath/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// No module description here
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleNameMismatch/ModuleNameMismatch.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleNameMismatch/ModuleNameMismatch.java
index 135652e..9b55ba7 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleNameMismatch/ModuleNameMismatch.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.module.name.mismatch
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleNameMismatch/modulesourcepath/m/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleNameMismatch/modulesourcepath/m/module-info.java
index 135652e..760ce2e 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleNameMismatch/modulesourcepath/m/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,5 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module other {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleNotFound/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleNotFound/module-info.java
index 135652e..3d6b488 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleNotFound/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.module.not.found
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m {
+     requires does.not.exist;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleNotFoundInModuleSourcePath/ModuleNotFoundInModuleSourcePath.java
similarity index 81%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleNotFoundInModuleSourcePath/ModuleNotFoundInModuleSourcePath.java
index 135652e..71d1df0 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleNotFoundInModuleSourcePath/ModuleNotFoundInModuleSourcePath.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.module.not.found.in.module.source.path
+// options: -m m1 -modulesourcepath src
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class ModuleNotFoundInModuleSourcePath {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModuleSourcePathMustWithDashM/ModuleSourcePathMustWithDashM.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModuleSourcePathMustWithDashM/ModuleSourcePathMustWithDashM.java
index 135652e..8c92010 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModuleSourcePathMustWithDashM/ModuleSourcePathMustWithDashM.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,5 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.modulesourcepath.must.be.specified.with.dash.m.option
+// options: -m m1 -d blah
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ModulesNotSupportedInSource/module-info.java
similarity index 80%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ModulesNotSupportedInSource/module-info.java
index 135652e..5b53cb4 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ModulesNotSupportedInSource/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.modules.not.supported.in.source
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 8 -Xlint:-path
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module ModulesNotSupportedInSource {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/MultiModuleOutputCannotBeExplodedModule.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/MultiModuleOutputCannotBeExplodedModule.java
index 135652e..095f629 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/MultiModuleOutputCannotBeExplodedModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.multi-module.outdir.cannot.be.exploded.module
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/additional/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/additional/m1/module-info.java
index 135652e..f6ecf6b 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/additional/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,5 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m1 {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/modulesourcepath/m2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/modulesourcepath/m2/module-info.java
index 135652e..3c14a44 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/MultiModuleOutputCannotBeExplodedModule/modulesourcepath/m2/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,5 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m2 {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java
index 135652e..e40cbd3 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.not.def.access.package.cant.access
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1/module-info.java
index 135652e..7a30497 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module m1 {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1/p1/C1.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1/p1/C1.java
index 135652e..08db623 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1/p1/C1.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
+package p1;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+public class C1 {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2/module-info.java
index 135652e..8963c28 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module m2 {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2/p2/C2.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2/p2/C2.java
index 135652e..0f9bf21 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2/p2/C2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+package p2;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class C2 {
+    p1.C1 c1;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/PackageClashFromRequires.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageClashFromRequires/PackageClashFromRequires.java
index 135652e..743f585 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/PackageClashFromRequires.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.package.clash.from.requires
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib1/exported/Api1.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib1/exported/Api1.java
index 135652e..48ffdf7 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib1/exported/Api1.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class Api1 {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib1/module-info.java
index 135652e..fbe84dd 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module lib1 {
+     exports exported;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib2/exported/Api2.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib2/exported/Api2.java
index 135652e..9470a22 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib2/exported/Api2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class Api2 {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib2/module-info.java
index 135652e..d1ede79 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/lib2/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module lib2 {
+     exports exported;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/use/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/use/module-info.java
index 135652e..00d5d0c 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageClashFromRequires/modulesourcepath/use/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module use {
+     requires lib1;
+     requires lib2;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageEmptyOrNotFound/PackageEmptyOrNotFound.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageEmptyOrNotFound/PackageEmptyOrNotFound.java
index 135652e..fe43a9f 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageEmptyOrNotFound/PackageEmptyOrNotFound.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.package.empty.or.not.found
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageEmptyOrNotFound/modulesourcepath/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageEmptyOrNotFound/modulesourcepath/m1/module-info.java
index 135652e..44b2d01 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageEmptyOrNotFound/modulesourcepath/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m1 {
+    exports p1;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/PackageInOtherModule/PackageInOtherModule.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/PackageInOtherModule/PackageInOtherModule.java
index 135652e..9922411 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/PackageInOtherModule/PackageInOtherModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.package.in.other.module
 
-public class Unsafe {
-    private Unsafe() { }
+package java.util;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class PackageInOtherModule {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java
similarity index 80%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java
index 135652e..2e5d323 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.processorpath.no.processormodulepath
+// options: -processormodulepath mods -processorpath mods
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class ProcessorPathNoProcessorModulePath {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/ServiceDefinitionInner.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/ServiceDefinitionInner.java
index 135652e..f519259 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/ServiceDefinitionInner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,5 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.service.definition.is.inner
+// key: compiler.err.encl.class.required
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/module-info.java
index 135652e..137812f0 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m {
+    provides p1.C1.InnerDefinition with p2.C2;
+    exports p1;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p1/C1.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p1/C1.java
index 135652e..ac25bab 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p1/C1.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+package p1;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class C1 {
+    public class InnerDefinition {}
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p2/C2.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p2/C2.java
index 135652e..cb3738c 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p2/C2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
+package p2;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+public class C2 extends p1.C1.InnerDefinition {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceDefinitionIsEnum/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceDefinitionIsEnum/module-info.java
index 135652e..5a22750 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceDefinitionIsEnum/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.service.definition.is.enum
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m {
+    uses pkg.EnumST;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceDefinitionIsEnum/pkg/EnumST.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceDefinitionIsEnum/pkg/EnumST.java
index 135652e..4f75a1f 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceDefinitionIsEnum/pkg/EnumST.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+package pkg;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public enum EnumST {
+    A,
+    B
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/exported/Service.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/exported/Service.java
index 135652e..b5b1029 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/exported/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/impl/ServiceImplementation.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/impl/ServiceImplementation.java
index 135652e..0534dd8 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/impl/ServiceImplementation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+package impl;
 
-public class Unsafe {
-    private Unsafe() { }
+import exported.Service;
 
-    public static long getLong(long address) {
-        return 0L;
+public class ServiceImplementation implements Service {
+    public ServiceImplementation(int i) {
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/module-info.java
similarity index 76%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/module-info.java
index 135652e..24dc3f6 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationDoesntHaveANoArgsConstructor/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.service.implementation.doesnt.have.a.no.args.constructor
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module ServiceImplementationDoesntHaveANoArgsConstructor {
+     exports exported;
+     provides exported.Service with impl.ServiceImplementation;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/exported/Service.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/exported/Service.java
index 135652e..b5b1029 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/exported/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/impl/ServiceImplementation.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/impl/ServiceImplementation.java
index 135652e..a3a3ed4 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/impl/ServiceImplementation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+package impl;
 
-public class Unsafe {
-    private Unsafe() { }
+import exported.Service;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+public abstract class ServiceImplementation implements Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/module-info.java
similarity index 78%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/module-info.java
index 135652e..7f5fb61 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsAbstract/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.service.implementation.is.abstract
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module ServiceImplementationDoesntHaveANoArgsConstructor {
+     exports exported;
+     provides exported.Service with impl.ServiceImplementation;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/exported/Service.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/exported/Service.java
index 135652e..b5b1029 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/exported/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/impl/ServiceImplementation.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/impl/ServiceImplementation.java
index 135652e..947b34b 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/impl/ServiceImplementation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+package impl;
 
-public class Unsafe {
-    private Unsafe() { }
+import exported.Service;
 
-    public static long getLong(long address) {
-        return 0L;
+public class ServiceImplementation {
+    public class Inner  implements Service {
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/module-info.java
similarity index 79%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/module-info.java
index 135652e..4ebe4a7 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationIsInner/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.service.implementation.is.inner
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module ServiceImplementationIsInner {
+     exports exported;
+     provides exported.Service with impl.ServiceImplementation.Inner;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/exported/Service.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/exported/Service.java
index 135652e..b5b1029 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/exported/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/impl/ServiceImplementation.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/impl/ServiceImplementation.java
index 135652e..ee55405 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/impl/ServiceImplementation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+package impl;
 
-public class Unsafe {
-    private Unsafe() { }
+import exported.Service;
 
-    public static long getLong(long address) {
-        return 0L;
+public class ServiceImplementation implements Service {
+    ServiceImplementation() {
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/module-info.java
similarity index 77%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/module-info.java
index 135652e..379f771 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.service.implementation.no.args.constructor.not.public
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module ServiceImplementationNoArgsConstructorNotPublic {
+     exports exported;
+     provides exported.Service with impl.ServiceImplementation;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/ServiceImplementationNotInRightModule.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/ServiceImplementationNotInRightModule.java
index 135652e..f5eb40b 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/ServiceImplementationNotInRightModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.err.service.implementation.not.in.right.module
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/exported/Service.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/exported/Service.java
index 135652e..b5b1029 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/exported/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/exported/ServiceImplementation.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/exported/ServiceImplementation.java
index 135652e..d45b0de 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/exported/ServiceImplementation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package exported;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class ServiceImplementation implements Service {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/module-info.java
index 135652e..1f2444a 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m1 {
+     exports exported;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m2/module-info.java
index 135652e..cd0acce 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceImplementationNotInRightModule/modulesourcepath/m2/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m2 {
+     requires m1;
+     provides exported.Service with exported.ServiceImplementation;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/ServiceProvidedButNotExportedOrUsed.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/ServiceProvidedButNotExportedOrUsed.java
index 135652e..3d245dd 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/ServiceProvidedButNotExportedOrUsed.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+// key: compiler.warn.service.provided.but.not.exported.or.used
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/module-info.java
index 135652e..9242f68 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m {
+    provides p1.C1 with p2.C2;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/p1/C1.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/p1/C1.java
index 135652e..fbc3159 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/p1/C1.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package p1;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class C1 {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/p2/C2.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/p2/C2.java
index 135652e..4255515 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/ServiceProvidedButNotExportedOrUsed/modulesourcepath/m/p2/C2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
+package p2;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+public class C2 extends p1.C1 {}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/langtools/test/tools/javac/diags/examples/StatExprExpected.java
similarity index 82%
rename from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
rename to langtools/test/tools/javac/diags/examples/StatExprExpected.java
index 9e5a4a7..b009182 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/langtools/test/tools/javac/diags/examples/StatExprExpected.java
@@ -22,16 +22,14 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
 
-import java.util.Properties;
+// key: compiler.err.prob.found.req
+// key: compiler.misc.stat.expr.expected
 
-/**
- * Interface to plugin (container) context.
- */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+class StatExprExpected {
+    void test() {
+        Runnable r = () -> (foo());
+    }
+
+    int foo() { return 1; }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/TooManyModules/TooManyModules.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/TooManyModules/TooManyModules.java
index 135652e..2326873 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/TooManyModules/TooManyModules.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.too.many.modules
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class TooManyModules {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/TooManyModules/p1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/TooManyModules/p1/module-info.java
index 135652e..7a30497 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/TooManyModules/p1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module m1 {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/TooManyModules/p2/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/TooManyModules/p2/module-info.java
index 135652e..8963c28 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/TooManyModules/p2/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module m2 {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/UnnamedPackageInNamedModule.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/UnnamedPackageInNamedModule.java
index 135652e..ed94f3e 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/UnnamedPackageInNamedModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,6 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.unnamed.pkg.not.allowed.named.modules
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class UnnamedPackageInNamedModule {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/modulesourcepath/m1/UnnamedPackageInNamedModule.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/modulesourcepath/m1/UnnamedPackageInNamedModule.java
index 135652e..bfc760e 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/modulesourcepath/m1/UnnamedPackageInNamedModule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class UnnamedPackageInNamedModule {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/modulesourcepath/m1/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/modulesourcepath/m1/module-info.java
index 135652e..7a30497 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/modulesourcepath/m1/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,4 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+module m1 {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/XModuleWithModulePath/XModuleWithModulePath.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/XModuleWithModulePath/XModuleWithModulePath.java
index 135652e..a378792 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/XModuleWithModulePath/XModuleWithModulePath.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.xmodule.no.module.sourcepath
+// options: -Xmodule:java.compiler -modulesourcepath src
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class XModuleWithModulePath {}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java
similarity index 81%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java
index 135652e..07d5431 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.xaddexports.malformed.entry
+// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class XaddexportsMalformedEntry {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java
similarity index 77%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java
index 135652e..6f6c064 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.xaddexports.too.many
+// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED  -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class XaddexportsTooMany {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java
index 135652e..650cf61 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.xaddreads.malformed.entry
+// options: -XaddReads:jdk.compiler
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class XaddreadsMalformedEntry {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java
similarity index 81%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java
index 135652e..d0b2551 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+// key: compiler.err.xaddreads.too.many
+// options: -XaddReads:jdk.compiler=ALL-UNNAMED  -XaddReads:jdk.compiler=ALL-UNNAMED
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class XaddreadsTooMany {
 }
diff --git a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java
index b447546..ae83a78 100644
--- a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java
+++ b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8149757
+ * @bug 8149757 8144062
  * @summary Test that StandardJavaFileManager uses the correct version of a
  * class from a multi-release jar on classpath
  * @library /tools/lib
@@ -164,7 +164,7 @@
                 {"", 8},
                 {"8", 8},
                 {"9", 9},
-                {"runtime", jdk.Version.current().major()}
+                {"runtime", Runtime.version().major()}
         };
     }
 
diff --git a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java b/langtools/test/tools/javac/generics/inference/8156954/T8156954.java
similarity index 74%
rename from jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java
rename to langtools/test/tools/javac/generics/inference/8156954/T8156954.java
index 55be308..0baab42 100644
--- a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java
+++ b/langtools/test/tools/javac/generics/inference/8156954/T8156954.java
@@ -23,20 +23,21 @@
  * questions.
  */
 
-package jdk.internal.vm.agent.spi;
-
 /**
- * Service interface for jdk.hotspot.agent to provide the tools that
- * jstack, jmap, jinfo will invoke, if present.
+ * @test
+ * @bug 8156954
+ * @summary javac incorrectly complains of incompatible types
+ * @compile T8156954.java
  */
-public interface ToolProvider {
-    /**
-     * Returns the name of the tool provider
-     */
-    String getName();
+import java.util.function.Function;
 
-    /**
-     * Invoke the tool provider with the given arguments
-     */
-    void run(String... arguments);
+class T8156954 {
+
+    <T, R> void m1(Function<R, T> f1, Function<T, R> f2, R r) { }
+    <T, R> void m2(Function<T, R> f1, Function<R, T> f2, R r) { }
+
+    void m(Integer intValue) {
+        m1(o -> o, o -> o , intValue);
+        m2(o -> o, o -> o , intValue);
+    }
 }
diff --git a/langtools/test/tools/javac/generics/inference/8157149/T8157149a.java b/langtools/test/tools/javac/generics/inference/8157149/T8157149a.java
new file mode 100644
index 0000000..8808b2f
--- /dev/null
+++ b/langtools/test/tools/javac/generics/inference/8157149/T8157149a.java
@@ -0,0 +1,28 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8157149
+ * @summary Inference: weird propagation of thrown inference variables
+ *
+ * @compile/fail/ref=T8157149a.out -XDrawDiagnostics T8157149a.java
+ */
+
+import java.io.IOException;
+
+class T8157149a {
+   <Z extends Throwable> Z m_T() throws Z { return null; }
+   <Z extends Exception> Z m_E() throws Z { return null; }
+
+   void test_T() {
+       Throwable t1 = m_T();
+       Exception t2 = m_T();
+       RuntimeException t3 = m_T();
+       IOException t4 = m_T(); //thrown not caught
+   }
+
+   void test_E() {
+       Throwable t1 = m_E();
+       Exception t2 = m_E();
+       RuntimeException t3 = m_E();
+       IOException t4 = m_E(); //thrown not caught
+   }
+}
diff --git a/langtools/test/tools/javac/generics/inference/8157149/T8157149a.out b/langtools/test/tools/javac/generics/inference/8157149/T8157149a.out
new file mode 100644
index 0000000..057238d
--- /dev/null
+++ b/langtools/test/tools/javac/generics/inference/8157149/T8157149a.out
@@ -0,0 +1,3 @@
+T8157149a.java:19:28: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.IOException
+T8157149a.java:26:28: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.IOException
+2 errors
diff --git a/langtools/test/tools/javac/generics/inference/8157149/T8157149b.java b/langtools/test/tools/javac/generics/inference/8157149/T8157149b.java
new file mode 100644
index 0000000..adacefd
--- /dev/null
+++ b/langtools/test/tools/javac/generics/inference/8157149/T8157149b.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8157149
+ * @summary Inference: weird propagation of thrown inference variables
+ *
+ * @compile T8157149b.java
+ */
+
+class T8157149b {
+
+    void test() {
+        computeException1(this::computeThrowable);
+        computeException2(this::computeThrowable);
+        computeException1(() -> {
+            Integer integer = computeThrowable();
+            return integer;
+        });
+        computeException2(() -> {
+            Integer integer = computeThrowable();
+            return integer;
+        });
+    }
+
+    <T, E extends Exception> void computeException1(ThrowableComputable1<T, E> c) throws E {}
+
+    <T, E extends Exception> void computeException2(ThrowableComputable2<T, E> c) throws E {}
+
+    <E1 extends Throwable> Integer computeThrowable() throws E1 {
+        return 0;
+    }
+
+    interface ThrowableComputable1<T, E extends Throwable> {
+        T compute() throws E;
+    }
+
+    interface ThrowableComputable2<T, E extends Throwable> {
+        Integer compute() throws E;
+    }
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java b/langtools/test/tools/javac/generics/inference/8157149/T8157149c.java
similarity index 76%
rename from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java
rename to langtools/test/tools/javac/generics/inference/8157149/T8157149c.java
index 7fe7dce..41fc420 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java
+++ b/langtools/test/tools/javac/generics/inference/8157149/T8157149c.java
@@ -22,16 +22,28 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.internal;
 
-import java.util.Properties;
+/*
+ * @test
+ * @bug 8157149
+ * @summary Inference: weird propagation of thrown inference variables
+ *
+ * @compile T8157149c.java
+ */
 
-import jdk.tools.jlink.plugin.PluginContext;
+class T8157149c  {
 
-public final class PluginContextImpl implements PluginContext {
-    private final Properties releaseProps = new Properties();
+    interface I<T extends C<?, ?>, U> {
+        T m(U o);
+    }
 
-    public Properties getReleaseProperties() {
-        return releaseProps;
+    static class C<T, U> {
+        C(T f) { }
+    }
+
+    <T, A> void m(I<C<T, Object>, A> o1, A o2) { }
+
+    void test(Object o) {
+        m(C::new, o);
     }
 }
diff --git a/langtools/test/tools/javac/lambda/8153884/T8153884.java b/langtools/test/tools/javac/lambda/8153884/T8153884.java
new file mode 100644
index 0000000..23aef92
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/8153884/T8153884.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8153884
+ * @summary Expression lambda erroneously compatible with void-returning descriptor
+ * @compile/fail/ref=T8153884.out -XDrawDiagnostics T8153884.java
+ */
+
+class T8153884 {
+    void test() {
+        Runnable r = () -> (foo());
+    }
+
+    void foo() { }
+}
diff --git a/langtools/test/tools/javac/lambda/8153884/T8153884.out b/langtools/test/tools/javac/lambda/8153884/T8153884.out
new file mode 100644
index 0000000..90826a8
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/8153884/T8153884.out
@@ -0,0 +1,2 @@
+T8153884.java:10:32: compiler.err.prob.found.req: (compiler.misc.stat.expr.expected)
+1 error
diff --git a/langtools/test/tools/javac/lambda/LambdaExpr10.out b/langtools/test/tools/javac/lambda/LambdaExpr10.out
index 9270b14..7be5335 100644
--- a/langtools/test/tools/javac/lambda/LambdaExpr10.out
+++ b/langtools/test/tools/javac/lambda/LambdaExpr10.out
@@ -4,6 +4,6 @@
 LambdaExpr10.java:24:46: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
 LambdaExpr10.java:28:29: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
 LambdaExpr10.java:29:33: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
-LambdaExpr10.java:33:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
-LambdaExpr10.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+LambdaExpr10.java:33:35: compiler.err.prob.found.req: (compiler.misc.stat.expr.expected)
+LambdaExpr10.java:34:49: compiler.err.prob.found.req: (compiler.misc.stat.expr.expected)
 8 errors
diff --git a/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out
index 97b66c8..c2b7a68 100644
--- a/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out
+++ b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out
@@ -1,3 +1,3 @@
-LambdaExprNotVoid.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
-LambdaExprNotVoid.java:15:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+LambdaExprNotVoid.java:14:21: compiler.err.prob.found.req: (compiler.misc.stat.expr.expected)
+LambdaExprNotVoid.java:15:21: compiler.err.prob.found.req: (compiler.misc.stat.expr.expected)
 2 errors
diff --git a/langtools/test/tools/javac/lambda/speculative/8154180/T8154180a.java b/langtools/test/tools/javac/lambda/speculative/8154180/T8154180a.java
new file mode 100644
index 0000000..eebebd7
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/speculative/8154180/T8154180a.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.function.Consumer;
+import java.nio.ByteBuffer;
+
+/*
+ * @test
+ * @bug 8154180
+ * @summary Regression: stuck expressions do not behave correctly
+ * @compile T8154180a.java
+ */
+class T8154180a {
+    T8154180a(Consumer<ByteBuffer> cb) { }
+
+    public static void main(String[] args) {
+        new T8154180a(b -> System.out.println(asString(b)));
+        new T8154180a((b -> System.out.println(asString(b))));
+        new T8154180a(true ? b -> System.out.println(asString(b)) : b -> System.out.println(asString(b)));
+        new T8154180a((true ? b -> System.out.println(asString(b)) : b -> System.out.println(asString(b))));
+        new T8154180a((true ? (b -> System.out.println(asString(b))) : (b -> System.out.println(asString(b)))));
+    }
+
+    static String asString(ByteBuffer buf) {
+        return null;
+    }
+}
diff --git a/langtools/test/tools/javac/lambda/speculative/8154180/T8154180b.java b/langtools/test/tools/javac/lambda/speculative/8154180/T8154180b.java
new file mode 100644
index 0000000..6565f66
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/speculative/8154180/T8154180b.java
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8154180
+ * @summary Regression: stuck expressions do not behave correctly
+ * @compile/fail/ref=T8154180b.out -XDrawDiagnostics T8154180b.java
+ */
+class T8154180b {
+    interface Foo1 {
+       Object m(String s);
+    }
+
+    interface Foo2 {
+       String m(String s);
+    }
+
+
+    void m(Foo1 f1) { }
+    void m(Foo2 f2) { }
+
+    void test() {
+        m(x->"");
+        m((x->""));
+        m(true ? x -> "" : x -> "");
+        m((true ? x -> "" : x -> ""));
+        m((true ? (x -> "") : (x -> "")));
+    }
+}
diff --git a/langtools/test/tools/javac/lambda/speculative/8154180/T8154180b.out b/langtools/test/tools/javac/lambda/speculative/8154180/T8154180b.out
new file mode 100644
index 0000000..690634c
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/speculative/8154180/T8154180b.out
@@ -0,0 +1,6 @@
+T8154180b.java:21:9: compiler.err.ref.ambiguous: m, kindname.method, m(T8154180b.Foo1), T8154180b, kindname.method, m(T8154180b.Foo2), T8154180b
+T8154180b.java:22:9: compiler.err.ref.ambiguous: m, kindname.method, m(T8154180b.Foo1), T8154180b, kindname.method, m(T8154180b.Foo2), T8154180b
+T8154180b.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(T8154180b.Foo1), T8154180b, kindname.method, m(T8154180b.Foo2), T8154180b
+T8154180b.java:24:9: compiler.err.ref.ambiguous: m, kindname.method, m(T8154180b.Foo1), T8154180b, kindname.method, m(T8154180b.Foo2), T8154180b
+T8154180b.java:25:9: compiler.err.ref.ambiguous: m, kindname.method, m(T8154180b.Foo1), T8154180b, kindname.method, m(T8154180b.Foo2), T8154180b
+5 errors
diff --git a/langtools/test/tools/javac/meth/TestCP.java b/langtools/test/tools/javac/meth/TestCP.java
index 413c6f6..4b2b277 100644
--- a/langtools/test/tools/javac/meth/TestCP.java
+++ b/langtools/test/tools/javac/meth/TestCP.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,9 @@
 
 public class TestCP {
 
-    static class TestClass {
+    static class TestMethodHandleInvokeExact {
+        static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;";
+
         void test(MethodHandle mh) throws Throwable {
             Number n = (Number)mh.invokeExact("daddy",1,'n');
             n = (Number)mh.invokeExact("bunny",1,'d');
@@ -50,9 +52,43 @@
         }
     }
 
-    static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;";
+    static class TestVarHandleGet {
+        static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;";
+
+        // Test with sig-poly return type
+        void test(VarHandle vh) throws Throwable {
+            Number n = (Number)vh.get("daddy",1,'n');
+            n = (Number)vh.get("bunny",1,'d');
+            n = (Number)(vh.get("foo",1,'d'));
+            n = (Number)((vh.get("bar",1,'d')));
+        }
+    }
+
+    static class TestVarHandleSet {
+        static final String PS_TYPE = "(Ljava/lang/String;IC)V";
+
+        // Test with non-sig-poly void return type
+        void test(VarHandle vh) throws Throwable {
+            vh.set("daddy",1,'n');
+            vh.set("bunny",1,'d');
+            vh.set("foo",1,'d');
+            vh.set("bar",1,'d');
+        }
+    }
+
+    static class TestVarHandleCompareAndSet {
+        static final String PS_TYPE = "(Ljava/lang/String;IC)Z";
+
+        // Test with non-sig-poly boolean return type
+        void test(VarHandle vh) throws Throwable {
+            boolean r = vh.compareAndSet("daddy",1,'n');
+            r = vh.compareAndSet("bunny",1,'d');
+            r = (vh.compareAndSet("foo",1,'d'));
+            r = ((vh.compareAndSet("bar",1,'d')));
+        }
+    }
+
     static final int PS_CALLS_COUNT = 4;
-    static final String SUBTEST_NAME = TestClass.class.getName() + ".class";
     static final String TEST_METHOD_NAME = "test";
 
     public static void main(String... args) throws Exception {
@@ -60,12 +96,32 @@
     }
 
     public void run() throws Exception {
-        String workDir = System.getProperty("test.classes");
-        File compiledTest = new File(workDir, SUBTEST_NAME);
-        verifyMethodHandleInvocationDescriptors(compiledTest);
+        verifySigPolyInvokeVirtual(
+                getTestFile(TestMethodHandleInvokeExact.class),
+                TestMethodHandleInvokeExact.PS_TYPE);
+
+        verifySigPolyInvokeVirtual(
+                getTestFile(TestVarHandleGet.class),
+                TestVarHandleGet.PS_TYPE);
+
+        verifySigPolyInvokeVirtual(
+                getTestFile(TestVarHandleSet.class),
+                TestVarHandleSet.PS_TYPE);
+
+        verifySigPolyInvokeVirtual(
+                getTestFile(TestVarHandleCompareAndSet.class),
+                TestVarHandleCompareAndSet.PS_TYPE);
     }
 
-    void verifyMethodHandleInvocationDescriptors(File f) {
+    static File getTestFile(Class<?> c) {
+        String workDir = System.getProperty("test.classes");
+        return new File(workDir, getTestName(c));
+    }
+    static String getTestName(Class<?> c) {
+        return c.getName() + ".class";
+    }
+
+    void verifySigPolyInvokeVirtual(File f, String psType) {
         System.err.println("verify: " + f);
         try {
             int count = 0;
@@ -98,7 +154,7 @@
                     CONSTANT_Methodref_info methRef =
                             (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry);
                     String type = methRef.getNameAndTypeInfo().getType();
-                    if (!type.equals(PS_TYPE)) {
+                    if (!type.equals(psType)) {
                         throw new Error("Unexpected type in polymorphic signature call: " + type);
                     }
                 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java
similarity index 71%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/javac/modules/MissingJarInModulePathTest.java
index 135652e..ec4e637 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+/*
+ * @test
+ * @bug 8154824
+ * @summary Compiler should handle java.nio.file.FileSystemNotFoundException gracefully and not abort
+ * @compile/fail/ref=MissingJarInModulePathTest.out -XDrawDiagnostics -Xlint:path -Werror -modulepath missing.jar MissingJarInModulePathTest.java
+ */
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+class MissingJarInModulePathTest {}
diff --git a/langtools/test/tools/javac/modules/MissingJarInModulePathTest.out b/langtools/test/tools/javac/modules/MissingJarInModulePathTest.out
new file mode 100644
index 0000000..7bcef9d
--- /dev/null
+++ b/langtools/test/tools/javac/modules/MissingJarInModulePathTest.out
@@ -0,0 +1,4 @@
+- compiler.warn.path.element.not.found: missing.jar
+- compiler.err.warnings.and.werror
+1 error
+1 warning
\ No newline at end of file
diff --git a/langtools/test/tools/javac/processing/model/TestSourceVersion.java b/langtools/test/tools/javac/processing/model/TestSourceVersion.java
index 1a06c24..396fe10 100644
--- a/langtools/test/tools/javac/processing/model/TestSourceVersion.java
+++ b/langtools/test/tools/javac/processing/model/TestSourceVersion.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,13 +23,14 @@
 
 /*
  * @test
- * @bug 7025809 8028543
- * @summary Test latest and latestSupported
+ * @bug 7025809 8028543 6415644
+ * @summary Test latest, latestSupported, underscore as keyword, etc.
  * @author  Joseph D. Darcy
  * @modules java.compiler
  *          jdk.compiler
  */
 
+import java.util.*;
 import javax.lang.model.SourceVersion;
 import static javax.lang.model.SourceVersion.*;
 
@@ -38,10 +39,45 @@
  */
 public class TestSourceVersion {
     public static void main(String... args) {
+        testLatestSupported();
+        testVersionVaryingKeywords();
+    }
+
+    private static void testLatestSupported() {
         if (SourceVersion.latest() != RELEASE_9 ||
             SourceVersion.latestSupported() != RELEASE_9)
             throw new RuntimeException("Unexpected release value(s) found:\n" +
                                        "latest:\t" + SourceVersion.latest() + "\n" +
                                        "latestSupported:\t" + SourceVersion.latestSupported());
     }
+
+    private static void testVersionVaryingKeywords() {
+        Map<String, SourceVersion> keyWordStart =
+            Map.of("strictfp", RELEASE_2,
+                   "assert",   RELEASE_4,
+                   "enum",     RELEASE_5,
+                   "_",        RELEASE_9);
+
+        for (Map.Entry<String, SourceVersion> entry : keyWordStart.entrySet()) {
+            String key = entry.getKey();
+            SourceVersion value = entry.getValue();
+
+            check(true, isKeyword(key), "keyword", latest());
+            check(false, isName(key),   "name",    latest());
+
+            for(SourceVersion version : SourceVersion.values()) {
+                boolean isKeyword = version.compareTo(value) >= 0;
+
+                check(isKeyword,  isKeyword(key, version), "keyword", version);
+                check(!isKeyword, isName(key, version),    "name",    version);
+            }
+        }
+    }
+
+    private static void check(boolean result, boolean expected,
+                              String message, SourceVersion version) {
+        if (result != expected) {
+            throw new RuntimeException("Unexpected " + message +  "-ness of _ on " + version);
+        }
+    }
 }
diff --git a/langtools/test/tools/javac/unicode/Unmappable.java b/langtools/test/tools/javac/unicode/Unmappable.java
index 7cd0501..9e4ad95 100644
--- a/langtools/test/tools/javac/unicode/Unmappable.java
+++ b/langtools/test/tools/javac/unicode/Unmappable.java
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 4767128 5048557 5048773
+ * @bug 4767128 5048557 5048773 8078559
  * @summary diagnose encoding errors in Java source files
  * @author gafter
  *
diff --git a/langtools/test/tools/javac/unicode/Unmappable.out b/langtools/test/tools/javac/unicode/Unmappable.out
index e976667..71fff9a 100644
--- a/langtools/test/tools/javac/unicode/Unmappable.out
+++ b/langtools/test/tools/javac/unicode/Unmappable.out
@@ -1,2 +1,2 @@
-Unmappable.java:12:18: compiler.err.illegal.char.for.encoding: ascii
+Unmappable.java:12:18: compiler.err.illegal.char.for.encoding: E4, ascii
 1 error
diff --git a/langtools/test/tools/jdeps/APIDeps.java b/langtools/test/tools/jdeps/APIDeps.java
index 0f2bf99..66c2e65 100644
--- a/langtools/test/tools/jdeps/APIDeps.java
+++ b/langtools/test/tools/jdeps/APIDeps.java
@@ -25,6 +25,7 @@
  * @test
  * @bug 8015912 8029216 8048063 8050804
  * @summary Test -apionly and -jdkinternals options
+ * @library lib
  * @modules java.base/sun.security.x509
  *          java.management
  *          jdk.jdeps/com.sun.tools.classfile
@@ -154,7 +155,8 @@
     Map<String,String> jdeps(String... args) {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
-        System.err.println("jdeps " + Arrays.toString(args));
+        System.err.println("jdeps " + Arrays.stream(args)
+            .collect(Collectors.joining(" ")));
         int rc = com.sun.tools.jdeps.Main.run(args, pw);
         pw.close();
         String out = sw.toString();
diff --git a/langtools/test/tools/jdeps/Basic.java b/langtools/test/tools/jdeps/Basic.java
index fac5493..9834fef 100644
--- a/langtools/test/tools/jdeps/Basic.java
+++ b/langtools/test/tools/jdeps/Basic.java
@@ -39,6 +39,8 @@
 import java.nio.file.Path;
 import java.util.*;
 import java.util.regex.*;
+import java.util.stream.Collectors;
+
 import static java.nio.file.StandardCopyOption.*;
 
 public class Basic {
@@ -157,7 +159,7 @@
     Map<String,String> jdeps(String... args) {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
-        System.err.println("jdeps " + Arrays.toString(args));
+        System.err.println("jdeps " + Arrays.stream(args).collect(Collectors.joining(" ")));
         int rc = com.sun.tools.jdeps.Main.run(args, pw);
         pw.close();
         String out = sw.toString();
diff --git a/langtools/test/tools/jdeps/DotFileTest.java b/langtools/test/tools/jdeps/DotFileTest.java
index d560ce6..0dd4296 100644
--- a/langtools/test/tools/jdeps/DotFileTest.java
+++ b/langtools/test/tools/jdeps/DotFileTest.java
@@ -41,6 +41,7 @@
 import java.nio.file.Paths;
 import java.util.*;
 import java.util.regex.*;
+import java.util.stream.Collectors;
 
 public class DotFileTest {
     public static void main(String... args) throws Exception {
@@ -182,7 +183,7 @@
         // invoke jdeps
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
-        System.err.println("jdeps " + args);
+        System.err.println("jdeps " + args.stream().collect(Collectors.joining(" ")));
         int rc = com.sun.tools.jdeps.Main.run(args.toArray(new String[0]), pw);
         pw.close();
         String out = sw.toString();
diff --git a/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java b/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java
new file mode 100644
index 0000000..9bfda2a
--- /dev/null
+++ b/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8153042
+ * @summary Tests JDK internal APIs that have been removed.
+ * @library ../lib
+ * @build CompilerUtils JdepsUtil ModuleMetaData
+ * @modules jdk.jdeps/com.sun.tools.jdeps
+ * @run testng RemovedJDKInternals
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+
+import com.sun.tools.jdeps.DepsAnalyzer;
+import com.sun.tools.jdeps.Graph;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+public class RemovedJDKInternals {
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path CLASSES_DIR = Paths.get("classes");
+    private static final Path PATCHES_DIR = Paths.get("patches");
+
+    private static final String JDK_UNSUPPORTED = "jdk.unsupported";
+    /**
+     * Compiles classes used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        CompilerUtils.cleanDir(PATCHES_DIR);
+        CompilerUtils.cleanDir(CLASSES_DIR);
+
+        // compile sun.misc types
+        Path sunMiscSrc = Paths.get(TEST_SRC, "patches", JDK_UNSUPPORTED);
+        Path patchDir = PATCHES_DIR.resolve(JDK_UNSUPPORTED);
+        assertTrue(CompilerUtils.compile(sunMiscSrc, patchDir,
+                                         "-Xmodule:" + JDK_UNSUPPORTED));
+
+        // compile com.sun.image.codec.jpeg types
+        Path codecSrc = Paths.get(TEST_SRC, "patches", "java.desktop");
+        Path codecDest = PATCHES_DIR;
+        assertTrue(CompilerUtils.compile(codecSrc, codecDest));
+
+        // patch jdk.unsupported and set -cp to codec types
+        assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src"),
+                                         CLASSES_DIR,
+                                         "-Xpatch:jdk.unsupported=" + patchDir,
+                                         "-cp", codecDest.toString()));
+    }
+
+    @DataProvider(name = "deps")
+    public Object[][] deps() {
+        return new Object[][] {
+            { "classes", new ModuleMetaData("classes", false)
+                .reference("p.Main", "java.lang.Class", "java.base")
+                .reference("p.Main", "java.lang.Object", "java.base")
+                .reference("p.Main", "java.util.Iterator", "java.base")
+                .reference("p.S", "java.lang.Object", "java.base")
+                .jdkInternal("p.Main", "sun.reflect.Reflection", "jdk.unsupported")
+                .removedJdkInternal("p.Main", "com.sun.image.codec.jpeg.JPEGCodec")
+                .removedJdkInternal("p.Main", "sun.misc.Service")
+                .removedJdkInternal("p.Main", "sun.misc.SoftCache")
+            },
+        };
+    }
+
+    @Test(dataProvider = "deps")
+    public void runTest(String name, ModuleMetaData data) throws Exception {
+        String cmd = String.format("jdeps -verbose:class %s%n", CLASSES_DIR);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.verbose("-verbose:class")
+                .addRoot(CLASSES_DIR);
+
+            DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
+            assertTrue(analyzer.run());
+            jdeps.dumpOutput(System.err);
+
+            Graph<DepsAnalyzer.Node> g = analyzer.dependenceGraph();
+            // there are two node with p.Main as origin
+            // one for exported API and one for removed JDK internal
+            g.nodes().stream()
+                .filter(u -> u.source.equals(data.moduleName))
+                .forEach(u -> g.adjacentNodes(u).stream()
+                    .forEach(v -> data.checkDependence(u.name, v.name, v.source, v.info)));
+        }
+    }
+
+    private static final Map<String, String> REPLACEMENTS = Map.of(
+        "com.sun.image.codec.jpeg.JPEGCodec", "Use javax.imageio @since 1.4",
+        "sun.misc.Service", "Use java.util.ServiceLoader @since 1.6",
+        "sun.misc.SoftCache", "Removed. See http://openjdk.java.net/jeps/260",
+        "sun.reflect.Reflection", "Use java.lang.StackWalker @since 9"
+    );
+
+    @Test
+    public void checkReplacement() {
+        String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.toString());
+        int i = 0;
+        while (!output[i].contains("Suggested Replacement")) {
+            i++;
+        }
+
+        // must match the number of JDK internal APIs
+        int count = output.length-i-2;
+        assertEquals(count, REPLACEMENTS.size());
+
+        for (int j=i+2; j < output.length; j++) {
+            String line = output[j];
+            int pos = line.indexOf("Use ");
+            if (pos < 0)
+                pos = line.indexOf("Removed. ");
+
+            assertTrue(pos > 0);
+            String name = line.substring(0, pos).trim();
+            String repl = line.substring(pos, line.length()).trim();
+            assertEquals(REPLACEMENTS.get(name), repl);
+        }
+    }
+}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/jdkinternals/patches/java.desktop/com/sun/image/codec/jpeg/JPEGCodec.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/jdkinternals/patches/java.desktop/com/sun/image/codec/jpeg/JPEGCodec.java
index 135652e..49c9d70 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/jdkinternals/patches/java.desktop/com/sun/image/codec/jpeg/JPEGCodec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,10 @@
  * questions.
  */
 
-package sun.misc;
+package com.sun.image.codec.jpeg;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+/*
+ * JDK removed internal API
+ */
+public class JPEGCodec {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/jdkinternals/patches/jdk.unsupported/sun/misc/Service.java
similarity index 80%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/jdkinternals/patches/jdk.unsupported/sun/misc/Service.java
index 135652e..64aff17 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/jdkinternals/patches/jdk.unsupported/sun/misc/Service.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,13 @@
 
 package sun.misc;
 
-public class Unsafe {
-    private Unsafe() { }
+import java.util.Iterator;
 
-    public static long getLong(long address) {
-        return 0L;
+/*
+ * JDK removed internal API
+ */
+public final class Service<S> {
+    public static <S> Iterator<S> providers(Class<S> service) {
+        return null;
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/jdkinternals/patches/jdk.unsupported/sun/misc/SoftCache.java
similarity index 83%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/jdkinternals/patches/jdk.unsupported/sun/misc/SoftCache.java
index 135652e..fca5c81 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/jdkinternals/patches/jdk.unsupported/sun/misc/SoftCache.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,8 @@
 
 package sun.misc;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+/*
+ * JDK removed internal API
+ */
+public class SoftCache {
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/langtools/test/tools/jdeps/jdkinternals/src/p/Main.java
similarity index 66%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to langtools/test/tools/jdeps/jdkinternals/src/p/Main.java
index 9e5a4a7..aaa30af 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/langtools/test/tools/jdeps/jdkinternals/src/p/Main.java
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -22,16 +20,26 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
 
-import java.util.Properties;
+package p;
 
-/**
- * Interface to plugin (container) context.
- */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+import com.sun.image.codec.jpeg.JPEGCodec;
+import sun.misc.Service;
+import sun.misc.SoftCache;
+import sun.reflect.Reflection;
+
+public class Main {
+    public static void main() {
+        // in jdk.unsupported
+        Class<?> caller = Reflection.getCallerClass(2);
+
+        // removed
+        JPEGCodec r = new JPEGCodec();
+
+        // removed
+        SoftCache s = new SoftCache();
+
+        // removed
+        Service.providers(S.class);
+    }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/jdkinternals/src/p/S.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/jdkinternals/src/p/S.java
index 135652e..7f4dd00 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/jdkinternals/src/p/S.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package p;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public interface S {
 }
diff --git a/langtools/test/tools/jdeps/CompilerUtils.java b/langtools/test/tools/jdeps/lib/CompilerUtils.java
similarity index 100%
rename from langtools/test/tools/jdeps/CompilerUtils.java
rename to langtools/test/tools/jdeps/lib/CompilerUtils.java
diff --git a/langtools/test/tools/jdeps/lib/JdepsUtil.java b/langtools/test/tools/jdeps/lib/JdepsUtil.java
new file mode 100644
index 0000000..3ec1ad7
--- /dev/null
+++ b/langtools/test/tools/jdeps/lib/JdepsUtil.java
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.sun.tools.jdeps.Analyzer;
+import com.sun.tools.jdeps.DepsAnalyzer;
+import com.sun.tools.jdeps.InverseDepsAnalyzer;
+import com.sun.tools.jdeps.JdepsConfiguration;
+import com.sun.tools.jdeps.JdepsFilter;
+import com.sun.tools.jdeps.JdepsWriter;
+import com.sun.tools.jdeps.ModuleAnalyzer;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import java.lang.module.ModuleDescriptor;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Utilities to run jdeps command
+ */
+public final class JdepsUtil {
+    /*
+     * Runs jdeps with the given arguments
+     */
+    public static String[] jdeps(String... args) {
+        String lineSep =     System.getProperty("line.separator");
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        System.err.println("jdeps " + Arrays.stream(args).collect(Collectors.joining(" ")));
+        int rc = com.sun.tools.jdeps.Main.run(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            throw new Error("jdeps failed: rc=" + rc);
+        return out.split(lineSep);
+    }
+
+    public static Command newCommand(String cmd) {
+        return new Command(cmd);
+    }
+
+    public static class Command implements Closeable {
+
+        final StringWriter sw = new StringWriter();
+        final PrintWriter pw = new PrintWriter(sw);
+        final JdepsFilter.Builder filter = new JdepsFilter.Builder().filter(true, true);
+        final JdepsConfiguration.Builder builder =  new JdepsConfiguration.Builder();
+        final Set<String> requires = new HashSet<>();
+
+        JdepsConfiguration configuration;
+        Analyzer.Type verbose = Analyzer.Type.PACKAGE;
+        boolean apiOnly = false;
+
+        public Command(String cmd) {
+            System.err.println("============ ");
+            System.err.println(cmd);
+        }
+
+        public Command verbose(String verbose) {
+            switch (verbose) {
+                case "-verbose":
+                    this.verbose = Analyzer.Type.VERBOSE;
+                    filter.filter(false, false);
+                    break;
+                case "-verbose:package":
+                    this.verbose = Analyzer.Type.PACKAGE;
+                    break;
+                case "-verbose:class":
+                    this.verbose = Analyzer.Type.CLASS;
+                    break;
+                case "-summary":
+                    this.verbose = Analyzer.Type.SUMMARY;
+                    break;
+                default:
+                    throw new IllegalArgumentException(verbose);
+            }
+            return this;
+        }
+
+        public Command filter(String value) {
+            switch (value) {
+                case "-filter:package":
+                    filter.filter(true, false);
+                    break;
+                case "-filter:archive":
+                case "-filter:module":
+                    filter.filter(false, true);
+                    break;
+                default:
+                    throw new IllegalArgumentException(value);
+            }
+            return this;
+        }
+
+        public Command addClassPath(String classpath) {
+            builder.addClassPath(classpath);
+            return this;
+        }
+
+        public Command addRoot(Path path) {
+            builder.addRoot(path);
+            return this;
+        }
+
+        public Command appModulePath(String modulePath) {
+            builder.appModulePath(modulePath);
+            return this;
+        }
+
+        public Command addmods(Set<String> mods) {
+            builder.addmods(mods);
+            return this;
+        }
+
+        public Command requires(Set<String> mods) {
+            requires.addAll(mods);
+            return this;
+        }
+
+        public Command matchPackages(Set<String> pkgs) {
+            filter.packages(pkgs);
+            return this;
+        }
+
+        public Command regex(String regex) {
+            filter.regex(Pattern.compile(regex));
+            return this;
+        }
+
+        public Command include(String regex) {
+            filter.includePattern(Pattern.compile(regex));
+            return this;
+        }
+
+        public Command includeSystemMoudles(String regex) {
+            filter.includeSystemModules(Pattern.compile(regex));
+            return this;
+        }
+
+        public Command apiOnly() {
+            this.apiOnly = true;
+            return this;
+        }
+
+        public JdepsConfiguration configuration() throws IOException {
+            if (configuration == null) {
+                this.configuration = builder.build();
+                requires.forEach(name -> {
+                    ModuleDescriptor md = configuration.findModuleDescriptor(name).get();
+                    filter.requires(name, md.packages());
+                });
+            }
+            return configuration;
+        }
+
+        private JdepsWriter writer() {
+            return JdepsWriter.newSimpleWriter(pw, verbose);
+        }
+
+        public DepsAnalyzer getDepsAnalyzer() throws IOException {
+            return new DepsAnalyzer(configuration(), filter.build(), writer(),
+                                    verbose, apiOnly);
+        }
+
+        public ModuleAnalyzer getModuleAnalyzer(Set<String> mods) throws IOException {
+            // if -check is set, add to the root set and all modules are observable
+            addmods(mods);
+            builder.allModules();
+            return new ModuleAnalyzer(configuration(), pw, mods);
+        }
+
+        public InverseDepsAnalyzer getInverseDepsAnalyzer() throws IOException {
+            return new InverseDepsAnalyzer(configuration(), filter.build(), writer(),
+                                           verbose, false);
+        }
+
+        public void dumpOutput(PrintStream out) {
+            out.println(sw.toString());
+        }
+
+        @Override
+        public void close() throws IOException {
+            configuration.close();
+        }
+    }
+
+    /**
+     * Create a jar file using the list of files provided.
+     */
+    public static void createJar(Path jarfile, Path root, Stream<Path> files)
+        throws IOException {
+        Path dir = jarfile.getParent();
+        if (dir != null && Files.notExists(dir)) {
+            Files.createDirectories(dir);
+        }
+        try (JarOutputStream target = new JarOutputStream(
+            Files.newOutputStream(jarfile))) {
+            files.forEach(file -> add(root.relativize(file), file, target));
+        }
+    }
+
+    private static void add(Path path, Path source, JarOutputStream target) {
+        try {
+            String name = path.toString().replace(File.separatorChar, '/');
+            JarEntry entry = new JarEntry(name);
+            entry.setTime(source.toFile().lastModified());
+            target.putNextEntry(entry);
+            Files.copy(source, target);
+            target.closeEntry();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+}
diff --git a/langtools/test/tools/jdeps/lib/ModuleMetaData.java b/langtools/test/tools/jdeps/lib/ModuleMetaData.java
new file mode 100644
index 0000000..f37c3a7
--- /dev/null
+++ b/langtools/test/tools/jdeps/lib/ModuleMetaData.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import com.sun.tools.jdeps.DepsAnalyzer;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import static com.sun.tools.jdeps.DepsAnalyzer.Info.*;
+import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
+import static java.lang.module.ModuleDescriptor.*;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+
+public class ModuleMetaData {
+    public static final String JAVA_BASE = "java.base";
+
+    static final String INTERNAL = "(internal)";
+    static final String QUALIFIED = "(qualified)";
+    static final String JDK_INTERNAL = "JDK internal API";
+    static final String REMOVED_JDK_INTERNAL = "JDK removed internal API";
+
+    final String moduleName;
+    final boolean isNamed;
+    final Map<String, ModuleRequires> requires = new LinkedHashMap<>();
+    final Map<String, Dependence> references = new LinkedHashMap<>();
+    final Map<String, Set<String>> exports = new LinkedHashMap<>();
+
+    ModuleMetaData(String name) {
+        this(name, true);
+    }
+
+    ModuleMetaData(String name, boolean isNamed) {
+        this.moduleName = name;
+        this.isNamed = isNamed;
+        requires(JAVA_BASE);  // implicit requires
+    }
+
+    String name() {
+        return moduleName;
+    }
+
+    ModuleMetaData requires(String name) {
+        requires.put(name, new ModuleRequires(name));
+        return this;
+    }
+
+    ModuleMetaData requiresPublic(String name) {
+        requires.put(name, new ModuleRequires(name, PUBLIC));
+        return this;
+    }
+
+    // for unnamed module
+    ModuleMetaData depends(String name) {
+        requires.put(name, new ModuleRequires(name));
+        return this;
+    }
+
+    ModuleMetaData reference(String origin, String target, String module) {
+        return dependence(origin, target, module, "");
+    }
+
+    ModuleMetaData internal(String origin, String target, String module) {
+        return dependence(origin, target, module, INTERNAL);
+    }
+
+    ModuleMetaData qualified(String origin, String target, String module) {
+        return dependence(origin, target, module, QUALIFIED);
+    }
+
+    ModuleMetaData jdkInternal(String origin, String target, String module) {
+        return dependence(origin, target, module, JDK_INTERNAL);
+    }
+    ModuleMetaData removedJdkInternal(String origin, String target) {
+        return dependence(origin, target, REMOVED_JDK_INTERNAL, REMOVED_JDK_INTERNAL);
+    }
+
+    ModuleMetaData exports(String pn, Set<String> targets) {
+        exports.put(pn, targets);
+        return this;
+    }
+
+    private ModuleMetaData dependence(String origin, String target, String module, String access) {
+        references.put(key(origin, target), new Dependence(origin, target, module, access));
+        return this;
+    }
+
+    String key(String origin, String target) {
+        return origin + ":" + target;
+    }
+
+    void checkRequires(String name, Set<DepsAnalyzer.Node> adjacentNodes) {
+        // System.err.format("%s: Expected %s Found %s %n", name, requires, adjacentNodes);
+        adjacentNodes.stream()
+            .forEach(v -> checkRequires(v.name));
+        assertEquals(adjacentNodes.size(), requires.size());
+    }
+
+    void checkRequires(String name) {
+        ModuleRequires req = requires.get(name);
+        if (req == null)
+            System.err.println(moduleName + ": unexpected requires " + name);
+        assertTrue(requires.containsKey(name));
+    }
+
+    void checkRequires(Requires require) {
+        String name = require.name();
+        if (name.equals(JAVA_BASE))
+            return;
+
+        ModuleRequires req = requires.get(name);
+        if (req == null)
+            System.err.format("%s: unexpected dependence %s%n", moduleName, name);
+
+        assertTrue(requires.containsKey(name));
+
+        assertEquals(require.modifiers(), req.modifiers());
+    }
+
+    void checkDependences(String name, Set<DepsAnalyzer.Node> adjacentNodes) {
+        // System.err.format("%s: Expected %s Found %s %n", name, references, adjacentNodes);
+
+        adjacentNodes.stream()
+            .forEach(v -> checkDependence(name, v.name, v.source, v.info));
+        assertEquals(adjacentNodes.size(), references.size());
+    }
+
+    void checkDependence(String origin, String target, String module, DepsAnalyzer.Info info) {
+        String key = key(origin, target);
+        Dependence dep = references.get(key);
+        String access = "";
+        if (info == QUALIFIED_EXPORTED_API)
+            access = QUALIFIED;
+        else if (info == JDK_INTERNAL_API)
+            access = JDK_INTERNAL;
+        else if (info == JDK_REMOVED_INTERNAL_API)
+            access = REMOVED_JDK_INTERNAL;
+        else if (info == INTERNAL_API)
+            access = INTERNAL;
+
+        assertTrue(references.containsKey(key));
+
+        assertEquals(dep.access, access);
+        assertEquals(dep.module, module);
+    }
+
+
+    public static class ModuleRequires {
+        final String name;
+        final Requires.Modifier mod;
+
+        ModuleRequires(String name) {
+            this.name = name;
+            this.mod = null;
+        }
+
+        ModuleRequires(String name, Requires.Modifier mod) {
+            this.name = name;
+            this.mod = mod;
+        }
+
+        Set<Requires.Modifier> modifiers() {
+            return mod != null ? Set.of(mod) : Collections.emptySet();
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
+    public static class Dependence {
+        final String origin;
+        final String target;
+        final String module;
+        final String access;
+
+        Dependence(String origin, String target, String module, String access) {
+            this.origin = origin;
+            this.target = target;
+            this.module = module;
+            this.access = access;
+        }
+
+        @Override
+        public String toString() {
+            return String.format("%s -> %s (%s) %s", origin, target, module, access);
+        }
+    }
+}
diff --git a/langtools/test/tools/jdeps/m/Foo.java b/langtools/test/tools/jdeps/m/Foo.java
index 67b7578..991c847 100644
--- a/langtools/test/tools/jdeps/m/Foo.java
+++ b/langtools/test/tools/jdeps/m/Foo.java
@@ -30,4 +30,3 @@
       setF(new f.F());
    }
 }
-
diff --git a/langtools/test/tools/jdeps/modules/CheckModuleTest.java b/langtools/test/tools/jdeps/modules/CheckModuleTest.java
new file mode 100644
index 0000000..79fe817
--- /dev/null
+++ b/langtools/test/tools/jdeps/modules/CheckModuleTest.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests split packages
+ * @library ../lib
+ * @build CompilerUtils JdepsUtil
+ * @modules jdk.jdeps/com.sun.tools.jdeps
+ * @run testng CheckModuleTest
+ */
+
+import java.lang.module.ModuleDescriptor;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.Set;
+
+import com.sun.tools.jdeps.ModuleAnalyzer;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+
+public class CheckModuleTest {
+    private static final String TEST_SRC = System.getProperty("test.src");
+    private static final String TEST_CLASSES = System.getProperty("test.classes");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+    // m4 and m5 are analyzed.  Others are compiled to make sure they are present
+    // on the module path for analysis
+    private static final Set<String> modules = Set.of("unsafe", "m4", "m5", "m6", "m7", "m8");
+
+    private static final String JAVA_BASE = "java.base";
+
+    /**
+     * Compiles classes used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        CompilerUtils.cleanDir(MODS_DIR);
+        modules.forEach(mn ->
+            assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn)));
+    }
+
+    @DataProvider(name = "javaBase")
+    public Object[][] base() {
+        return new Object[][] {
+            { JAVA_BASE, new ModuleMetaData(JAVA_BASE)
+            },
+        };
+    };
+
+    @Test(dataProvider = "javaBase")
+    public void testJavaBase(String name, ModuleMetaData data) throws Exception {
+        String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.appModulePath(MODS_DIR.toString());
+
+            ModuleAnalyzer analyzer = jdeps.getModuleAnalyzer(Set.of(name));
+            assertTrue(analyzer.run());
+            jdeps.dumpOutput(System.err);
+
+            ModuleDescriptor[] descriptors = analyzer.descriptors(name);
+            for (int i = 0; i < 3; i++) {
+                descriptors[i].requires().stream()
+                    .forEach(req -> data.checkRequires(req));
+            }
+        }
+    }
+
+    @DataProvider(name = "modules")
+    public Object[][] unnamed() {
+        return new Object[][]{
+            { "m4", new ModuleMetaData[] {
+                        // original
+                        new ModuleMetaData("m4")
+                            .requiresPublic("java.compiler")
+                            .requires("java.logging")
+                            // unnused exports
+                            .exports("p4.internal", Set.of("m6", "m7")),
+                        // suggested version
+                        new ModuleMetaData("m4")
+                            .requires("java.compiler"),
+                        // reduced version
+                        new ModuleMetaData("m4")
+                            .requires("java.compiler")
+                    }
+            },
+            { "m5", new ModuleMetaData[] {
+                        // original
+                        new ModuleMetaData("m5")
+                            .requiresPublic("java.compiler")
+                            .requiresPublic("java.logging")
+                            .requires("java.sql")
+                            .requiresPublic("m4"),
+                        // suggested version
+                        new ModuleMetaData("m5")
+                            .requiresPublic("java.compiler")
+                            .requires("java.logging")
+                            .requiresPublic("java.sql")
+                            .requiresPublic("m4"),
+                        // reduced version
+                        new ModuleMetaData("m5")
+                            .requiresPublic("java.compiler")
+                            .requiresPublic("java.sql")
+                            .requiresPublic("m4"),
+                    }
+            },
+        };
+    }
+
+    @Test(dataProvider = "modules")
+    public void modularTest(String name, ModuleMetaData[] data) throws Exception {
+        String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR);
+
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.appModulePath(MODS_DIR.toString());
+
+            ModuleAnalyzer analyzer = jdeps.getModuleAnalyzer(Set.of(name));
+            assertTrue(analyzer.run());
+            jdeps.dumpOutput(System.err);
+
+            // compare the module descriptors and the suggested versions
+            ModuleDescriptor[] descriptors = analyzer.descriptors(name);
+            for (int i = 0; i < 3; i++) {
+                ModuleMetaData metaData = data[i];
+                descriptors[i].requires().stream()
+                    .forEach(req -> metaData.checkRequires(req));
+            }
+
+            Map<String, Set<String>> unused = analyzer.unusedQualifiedExports(name);
+            // verify unuused qualified exports
+            assertEquals(unused, data[0].exports);
+        }
+    }
+
+}
diff --git a/langtools/test/tools/jdeps/modules/GenModuleInfo.java b/langtools/test/tools/jdeps/modules/GenModuleInfo.java
index fcdcabb..dc79bec 100644
--- a/langtools/test/tools/jdeps/modules/GenModuleInfo.java
+++ b/langtools/test/tools/jdeps/modules/GenModuleInfo.java
@@ -24,8 +24,8 @@
 /*
  * @test
  * @summary Tests jdeps -genmoduleinfo option
- * @library ..
- * @build CompilerUtils
+ * @library ../lib
+ * @build CompilerUtils JdepsUtil
  * @modules jdk.jdeps/com.sun.tools.jdeps
  * @run testng GenModuleInfo
  */
@@ -39,16 +39,12 @@
 
 import java.util.Arrays;
 import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.testng.annotations.DataProvider;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
@@ -86,12 +82,13 @@
 
         for (String mn : modules) {
             Path root = MODS_DIR.resolve(mn);
-            createJar(LIBS_DIR.resolve(mn + ".jar"), root,
-                      Files.walk(root, Integer.MAX_VALUE)
-                           .filter(f -> {
-                                String fn = f.getFileName().toString();
-                                return fn.endsWith(".class") && !fn.equals("module-info.class");
-                           }));
+            try (Stream<Path> stream = Files.walk(root, Integer.MAX_VALUE)) {
+                Stream<Path> entries = stream.filter(f -> {
+                    String fn = f.getFileName().toString();
+                    return fn.endsWith(".class") && !fn.equals("module-info.class");
+                });
+                JdepsUtil.createJar(LIBS_DIR.resolve(mn + ".jar"), root, entries);
+            }
         }
     }
 
@@ -100,7 +97,7 @@
         Stream<String> files = Arrays.stream(modules)
                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                 .map(Path::toString);
-        jdeps(Stream.concat(Stream.of("-cp"), files).toArray(String[]::new));
+        JdepsUtil.jdeps(Stream.concat(Stream.of("-cp"), files).toArray(String[]::new));
     }
 
     @Test
@@ -109,9 +106,8 @@
                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                 .map(Path::toString);
 
-        jdeps(Stream.concat(Stream.of("-genmoduleinfo", DEST_DIR.toString()),
-                            files)
-                    .toArray(String[]::new));
+        JdepsUtil.jdeps(Stream.concat(Stream.of("-genmoduleinfo", DEST_DIR.toString()),
+                                      files).toArray(String[]::new));
 
         // check file exists
         Arrays.stream(modules)
@@ -119,19 +115,20 @@
                 .forEach(f -> assertTrue(Files.exists(f)));
 
         // copy classes except the original module-info.class
-        Files.walk(MODS_DIR, Integer.MAX_VALUE)
-                .filter(path -> !path.getFileName().toString().equals(MODULE_INFO) &&
-                                path.getFileName().toString().endsWith(".class"))
-                .map(path -> MODS_DIR.relativize(path))
-                .forEach(path -> {
-                    try {
-                        Path newFile = NEW_MODS_DIR.resolve(path);
-                        Files.createDirectories(newFile.getParent());
-                        Files.copy(MODS_DIR.resolve(path), newFile);
-                    } catch (IOException e) {
-                        throw new UncheckedIOException(e);
-                    }
-                });
+        try (Stream<Path> stream = Files.walk(MODS_DIR, Integer.MAX_VALUE)) {
+            stream.filter(path -> !path.getFileName().toString().equals(MODULE_INFO) &&
+                                    path.getFileName().toString().endsWith(".class"))
+                  .map(path -> MODS_DIR.relativize(path))
+                  .forEach(path -> {
+                      try {
+                          Path newFile = NEW_MODS_DIR.resolve(path);
+                          Files.createDirectories(newFile.getParent());
+                          Files.copy(MODS_DIR.resolve(path), newFile);
+                      } catch (IOException e) {
+                          throw new UncheckedIOException(e);
+                      }
+                  });
+        }
 
         // compile new module-info.java
         assertTrue(CompilerUtils.compileModule(DEST_DIR, NEW_MODS_DIR, UNSUPPORTED,
@@ -148,7 +145,7 @@
             try (InputStream in1 = Files.newInputStream(p1);
                  InputStream in2 = Files.newInputStream(p2)) {
                 verify(ModuleDescriptor.read(in1),
-                        ModuleDescriptor.read(in2, () -> packages(MODS_DIR.resolve(mn))));
+                       ModuleDescriptor.read(in2, () -> packages(MODS_DIR.resolve(mn))));
             }
         }
     }
@@ -164,14 +161,13 @@
     }
 
     private Set<String> packages(Path dir) {
-        try {
-            return Files.find(dir, Integer.MAX_VALUE,
+        try (Stream<Path> stream = Files.find(dir, Integer.MAX_VALUE,
                              ((path, attrs) -> attrs.isRegularFile() &&
-                                               path.toString().endsWith(".class")))
-                        .map(path -> toPackageName(dir.relativize(path)))
-                        .filter(pkg -> pkg.length() > 0)   // module-info
-                        .distinct()
-                        .collect(Collectors.toSet());
+                                               path.toString().endsWith(".class")))) {
+            return stream.map(path -> toPackageName(dir.relativize(path)))
+                         .filter(pkg -> pkg.length() > 0)   // module-info
+                         .distinct()
+                         .collect(Collectors.toSet());
         } catch (IOException x) {
             throw new UncheckedIOException(x);
         }
@@ -188,46 +184,4 @@
         }
     }
 
-    /*
-     * Runs jdeps with the given arguments
-     */
-    public static String[] jdeps(String... args) {
-        String lineSep =     System.getProperty("line.separator");
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        System.err.println("jdeps " + Arrays.toString(args));
-        int rc = com.sun.tools.jdeps.Main.run(args, pw);
-        pw.close();
-        String out = sw.toString();
-        if (!out.isEmpty())
-            System.err.println(out);
-        if (rc != 0)
-            throw new Error("jdeps failed: rc=" + rc);
-        return out.split(lineSep);
-    }
-
-    /**
-     * Create a jar file using the list of files provided.
-     */
-    public static void createJar(Path jarfile, Path root, Stream<Path> files)
-            throws IOException {
-        try (JarOutputStream target = new JarOutputStream(
-                Files.newOutputStream(jarfile))) {
-           files.forEach(file -> add(root.relativize(file), file, target));
-        }
-    }
-
-    private static void add(Path path, Path source, JarOutputStream target) {
-        try {
-            String name = path.toString().replace(File.separatorChar, '/');
-            JarEntry entry = new JarEntry(name);
-            entry.setTime(source.toFile().lastModified());
-            target.putNextEntry(entry);
-            Files.copy(source, target);
-            target.closeEntry();
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-
 }
diff --git a/langtools/test/tools/jdeps/modules/InverseDeps.java b/langtools/test/tools/jdeps/modules/InverseDeps.java
new file mode 100644
index 0000000..df0b2ca
--- /dev/null
+++ b/langtools/test/tools/jdeps/modules/InverseDeps.java
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests split packages
+ * @library ../lib
+ * @build CompilerUtils JdepsUtil
+ * @modules jdk.jdeps/com.sun.tools.jdeps
+ * @run testng InverseDeps
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import com.sun.tools.jdeps.Archive;
+import com.sun.tools.jdeps.InverseDepsAnalyzer;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertEquals;
+
+
+public class InverseDeps {
+    private static final String TEST_SRC = System.getProperty("test.src");
+    private static final String TEST_CLASSES = System.getProperty("test.classes");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path LIBS_DIR = Paths.get("libs");
+
+    private static final Set<String> modules = new LinkedHashSet(
+        List.of("unsafe", "m4", "m5", "m6", "m7")
+    );
+
+    /**
+     * Compiles classes used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        CompilerUtils.cleanDir(MODS_DIR);
+
+        for (String mn : modules) {
+            // compile a module
+            assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn));
+
+            // create JAR files with no module-info.class
+            Path root = MODS_DIR.resolve(mn);
+
+            try (Stream<Path> stream = Files.walk(root, Integer.MAX_VALUE)) {
+                Stream<Path> entries = stream.filter(f -> {
+                    String fn = f.getFileName().toString();
+                    return fn.endsWith(".class") && !fn.equals("module-info.class");
+                });
+                JdepsUtil.createJar(LIBS_DIR.resolve(mn + ".jar"), root, entries);
+            }
+        }
+    }
+
+    @DataProvider(name = "testrequires")
+    public Object[][] expected1() {
+        return new Object[][] {
+            // -requires and result
+            { "java.sql", new String[][] {
+                    new String[] { "java.sql", "m5" },
+                }
+            },
+            { "java.compiler", new String[][] {
+                    new String[] { "java.compiler", "m5" },
+                    new String[] { "java.compiler", "m4", "m5" },
+                }
+            },
+            { "java.logging", new String[][]{
+                    new String[] {"java.logging", "m5"},
+                    new String[] {"java.logging", "m4", "m5"},
+                    new String[] {"java.logging", "java.sql", "m5"},
+                }
+            },
+            { "jdk.unsupported", new String[][] {
+                    new String[] {"jdk.unsupported", "unsafe", "m6", "m7"},
+                    new String[] {"jdk.unsupported", "unsafe", "m7"}
+                }
+            },
+        };
+    }
+
+    @Test(dataProvider = "testrequires")
+    public void testrequires(String name, String[][] expected) throws Exception {
+        String cmd1 = String.format("jdeps -inverse -modulepath %s -requires %s -addmods %s%n",
+                MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
+
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
+            jdeps.appModulePath(MODS_DIR.toString())
+                .addmods(modules)
+                .requires(Set.of(name));
+
+            runJdeps(jdeps, expected);
+        }
+
+        String cmd2 = String.format("jdeps -inverse -modulepath %s -requires %s" +
+            " -addmods ALL-MODULE-PATH%n", LIBS_DIR, name);
+
+            // automatic module
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
+            jdeps.appModulePath(MODS_DIR.toString())
+                .addmods(Set.of("ALL-MODULE-PATH"))
+                .requires(Set.of(name));
+
+            runJdeps(jdeps, expected);
+        }
+    }
+
+    @DataProvider(name = "testpackage")
+    public Object[][] expected2() {
+        return new Object[][] {
+            // -package and result
+            { "p4", new String[][] {
+                        new String[] { "m4", "m5"},
+                    }
+            },
+            { "javax.tools", new String[][] {
+                        new String[] {"java.compiler", "m5"},
+                        new String[] {"java.compiler", "m4", "m5"},
+                    }
+            },
+            { "sun.misc", new String[][] {
+                        new String[] {"jdk.unsupported", "unsafe", "m6", "m7"},
+                        new String[] {"jdk.unsupported", "unsafe", "m7"}
+                    }
+            }
+        };
+    }
+
+    @Test(dataProvider = "testpackage")
+    public void testpackage(String name, String[][] expected) throws Exception {
+        String cmd = String.format("jdeps -inverse -modulepath %s -package %s -addmods %s%n",
+            MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.appModulePath(MODS_DIR.toString())
+                .addmods(modules)
+                .matchPackages(Set.of(name));
+
+            runJdeps(jdeps, expected);
+        }
+    }
+
+    @DataProvider(name = "testregex")
+    public Object[][] expected3() {
+        return new Object[][] {
+            // -regex and result
+            { "org.safe.Lib", new String[][] {
+                    new String[] { "unsafe", "m7"},
+                    new String[] { "unsafe", "m6", "m7"},
+                }
+            },
+            { "java.util.logging.*|org.safe.Lib", new String[][] {
+                    new String[] { "unsafe", "m7"},
+                    new String[] { "unsafe", "m6", "m7"},
+                    new String[] { "java.logging", "m5"},
+                }
+            }
+        };
+    }
+
+    @Test(dataProvider = "testregex")
+    public void testregex(String name, String[][] expected) throws Exception {
+        String cmd = String.format("jdeps -inverse -modulepath %s -regex %s -addmods %s%n",
+                MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
+
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.appModulePath(MODS_DIR.toString())
+                .addmods(modules)
+                .regex(name);
+
+            runJdeps(jdeps, expected);
+        }
+    }
+
+    @DataProvider(name = "classpath")
+    public Object[][] expected4() {
+        return new Object[][] {
+            // -regex and result
+            { "sun.misc.Unsafe", new String[][] {
+                    new String[] {"jdk.unsupported", "unsafe.jar", "m6.jar", "m7.jar"},
+                    new String[] {"jdk.unsupported", "unsafe.jar", "m7.jar"}
+                }
+            },
+            { "org.safe.Lib", new String[][] {
+                    new String[] { "unsafe.jar", "m7.jar"},
+                    new String[] { "unsafe.jar", "m6.jar", "m7.jar"},
+                }
+            },
+            { "java.util.logging.*|org.safe.Lib", new String[][] {
+                    new String[] { "unsafe.jar", "m7.jar"},
+                    new String[] { "unsafe.jar", "m6.jar", "m7.jar"},
+                    new String[] { "java.logging", "m5.jar"},
+                }
+            }
+        };
+    }
+
+    @Test(dataProvider = "classpath")
+    public void testClassPath(String name, String[][] expected) throws Exception {
+        // -classpath
+        String cpath = modules.stream()
+            .filter(mn -> !mn.equals("m7"))
+            .map(mn -> LIBS_DIR.resolve(mn + ".jar").toString())
+            .collect(Collectors.joining(File.pathSeparator));
+
+        Path jarfile = LIBS_DIR.resolve("m7.jar");
+
+        String cmd1 = String.format("jdeps -inverse -classpath %s -regex %s %s%n",
+            cpath, name, jarfile);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
+            jdeps.verbose("-verbose:class")
+                .addClassPath(cpath)
+                .regex(name).addRoot(jarfile);
+            runJdeps(jdeps, expected);
+        }
+
+        // all JAR files on the command-line arguments
+        Set<Path> paths = modules.stream()
+                                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
+                                 .collect(Collectors.toSet());
+        String cmd2 = String.format("jdeps -inverse -regex %s %s%n", name, paths);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
+            jdeps.verbose("-verbose:class").regex(name);
+            paths.forEach(jdeps::addRoot);
+            runJdeps(jdeps, expected);
+        }
+    }
+
+    private void runJdeps(JdepsUtil.Command jdeps, String[][] expected)  throws Exception {
+        InverseDepsAnalyzer analyzer = jdeps.getInverseDepsAnalyzer();
+
+        assertTrue(analyzer.run());
+
+        // get the inverse transitive dependences
+        List<String[]> paths = analyzer.inverseDependences().stream()
+            .map(deque -> deque.stream()
+                               .map(Archive::getName)
+                               .collect(Collectors.toList()).toArray(new String[0]))
+            .collect(Collectors.toList());
+
+        jdeps.dumpOutput(System.err);
+        paths.forEach(path -> System.err.println(Arrays.stream(path)
+                .collect(Collectors.joining(" <- "))));
+
+        // verify the dependences
+        assertEquals(paths.size(), expected.length);
+
+        for (int i=0; i < paths.size(); i++) {
+            String[] path = paths.get(i);
+            boolean noneMatched = Arrays.stream(expected)
+                    .filter(array -> array.length == path.length)
+                    .noneMatch(array -> Arrays.equals(array, path));
+            if (noneMatched)
+                System.err.format("Expected: %s found: %s%n",
+                                  Arrays.stream(expected)
+                                      .map(Arrays::toString)
+                                      .collect(Collectors.joining(", ")),
+                    Arrays.toString(path));
+
+            assertFalse(noneMatched);
+        }
+    }
+
+}
diff --git a/langtools/test/tools/jdeps/modules/ModuleTest.java b/langtools/test/tools/jdeps/modules/ModuleTest.java
index f9e6dd0..f210dec 100644
--- a/langtools/test/tools/jdeps/modules/ModuleTest.java
+++ b/langtools/test/tools/jdeps/modules/ModuleTest.java
@@ -24,30 +24,28 @@
 /*
  * @test
  * @summary Tests jdeps -m and -mp options on named modules and unnamed modules
- * @library ..
- * @build CompilerUtils
+ * @library ../lib
+ * @build CompilerUtils JdepsUtil
  * @modules jdk.jdeps/com.sun.tools.jdeps
  * @run testng ModuleTest
  */
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.Requires.Modifier;
-import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
+import java.io.File;
+import java.io.IOException;
 
+import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.*;
-
 import java.util.stream.Collectors;
 
+
+import com.sun.tools.jdeps.DepsAnalyzer;
+import com.sun.tools.jdeps.Graph;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
 public class ModuleTest {
@@ -56,6 +54,7 @@
 
     private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
     private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path UNNAMED_DIR = Paths.get("unnamed");
 
     // the names of the modules in this test
     private static final String UNSUPPORTED = "unsupported";
@@ -66,62 +65,68 @@
     @BeforeTest
     public void compileAll() throws Exception {
         CompilerUtils.cleanDir(MODS_DIR);
+        CompilerUtils.cleanDir(UNNAMED_DIR);
+
         assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED,
                                                "-XaddExports:java.base/jdk.internal.perf=" + UNSUPPORTED));
         // m4 is not referenced
         Arrays.asList("m1", "m2", "m3", "m4")
               .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn)));
+
+        assertTrue(CompilerUtils.compile(SRC_DIR.resolve("m3"), UNNAMED_DIR, "-mp", MODS_DIR.toString()));
+        Files.delete(UNNAMED_DIR.resolve("module-info.class"));
     }
 
     @DataProvider(name = "modules")
     public Object[][] expected() {
         return new Object[][]{
-                { "m3", new Data("m3").requiresPublic("java.sql")
-                                      .requiresPublic("m2")
-                                      .requires("java.logging")
-                                      .requiresPublic("m1")
-                                      .reference("p3", "java.lang", "java.base")
-                                      .reference("p3", "java.sql", "java.sql")
-                                      .reference("p3", "java.util.logging", "java.logging")
-                                      .reference("p3", "p1", "m1")
-                                      .reference("p3", "p2", "m2")
-                                      .qualified("p3", "p2.internal", "m2")
+                { "m3", new ModuleMetaData("m3").requiresPublic("java.sql")
+                            .requiresPublic("m2")
+                            .requires("java.logging")
+                            .requiresPublic("m1")
+                            .reference("p3", "java.lang", "java.base")
+                            .reference("p3", "java.sql", "java.sql")
+                            .reference("p3", "java.util.logging", "java.logging")
+                            .reference("p3", "p1", "m1")
+                            .reference("p3", "p2", "m2")
+                            .qualified("p3", "p2.internal", "m2")
                 },
-                { "m2", new Data("m2").requiresPublic("m1")
-                                      .reference("p2", "java.lang", "java.base")
-                                      .reference("p2", "p1", "m1")
-                                      .reference("p2.internal", "java.lang", "java.base")
-                                      .reference("p2.internal", "java.io", "java.base")
+                { "m2", new ModuleMetaData("m2").requiresPublic("m1")
+                            .reference("p2", "java.lang", "java.base")
+                            .reference("p2", "p1", "m1")
+                            .reference("p2.internal", "java.lang", "java.base")
+                            .reference("p2.internal", "java.io", "java.base")
                 },
-                { "m1", new Data("m1").requires("unsupported")
-                                      .reference("p1", "java.lang", "java.base")
-                                      .reference("p1.internal", "java.lang", "java.base")
-                                      .reference("p1.internal", "p1", "m1")
-                                      .reference("p1.internal", "q", "unsupported")
+                { "m1", new ModuleMetaData("m1").requires("unsupported")
+                            .reference("p1", "java.lang", "java.base")
+                            .reference("p1.internal", "java.lang", "java.base")
+                            .reference("p1.internal", "p1", "m1")
+                            .reference("p1.internal", "q", "unsupported")
                 },
-                { "unsupported", new Data("unsupported")
-                                      .reference("q", "java.lang", "java.base")
-                                      .jdkInternal("q", "jdk.internal.perf", "(java.base)")
+                { "unsupported", new ModuleMetaData("unsupported")
+                            .reference("q", "java.lang", "java.base")
+                            .jdkInternal("q", "jdk.internal.perf", "java.base")
                 },
         };
     }
 
     @Test(dataProvider = "modules")
-    public void modularTest(String name, Data data) {
-        // print only the specified module
-        String excludes = Arrays.stream(modules)
-                                .filter(mn -> !mn.endsWith(name))
-                                .collect(Collectors.joining(","));
-        String[] result = jdeps("-exclude-modules", excludes,
-                                "-mp", MODS_DIR.toString(),
-                                "-m", name);
-        assertTrue(data.check(result));
+    public void modularTest(String name, ModuleMetaData data) throws IOException {
+        // jdeps -modulepath mods -m <name>
+        runTest(data, MODS_DIR.toString(), Set.of(name));
+
+        // jdeps -modulepath libs/m1.jar:.... -m <name>
+        String mp = Arrays.stream(modules)
+                .filter(mn -> !mn.equals(name))
+                .map(mn -> MODS_DIR.resolve(mn).toString())
+                .collect(Collectors.joining(File.pathSeparator));
+        runTest(data, mp, Collections.emptySet(), MODS_DIR.resolve(name));
     }
 
     @DataProvider(name = "unnamed")
     public Object[][] unnamed() {
         return new Object[][]{
-                { "m3", new Data("m3", false)
+                { "unnamed", new ModuleMetaData("unnamed", false)
                             .depends("java.sql")
                             .depends("java.logging")
                             .depends("m1")
@@ -133,178 +138,43 @@
                             .reference("p3", "p2", "m2")
                             .internal("p3", "p2.internal", "m2")
                 },
-                { "unsupported", new Data("unsupported", false)
-                            .reference("q", "java.lang", "java.base")
-                            .jdkInternal("q", "jdk.internal.perf", "(java.base)")
-                },
         };
     }
 
     @Test(dataProvider = "unnamed")
-    public void unnamedTest(String name, Data data) {
-        String[] result = jdeps("-mp", MODS_DIR.toString(), MODS_DIR.resolve(name).toString());
-        assertTrue(data.check(result));
+    public void unnamedTest(String name, ModuleMetaData data) throws IOException {
+        runTest(data, MODS_DIR.toString(), Set.of("m1", "m2"), UNNAMED_DIR);
     }
 
-    /*
-     * Runs jdeps with the given arguments
-     */
-    public static String[] jdeps(String... args) {
-        String lineSep =     System.getProperty("line.separator");
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        System.err.println("jdeps " + Arrays.toString(args));
-        int rc = com.sun.tools.jdeps.Main.run(args, pw);
-        pw.close();
-        String out = sw.toString();
-        if (!out.isEmpty())
-            System.err.println(out);
-        if (rc != 0)
-            throw new Error("jdeps failed: rc=" + rc);
-        return out.split(lineSep);
-    }
+    private void runTest(ModuleMetaData data, String modulepath,
+                         Set<String> roots, Path... paths)
+        throws IOException
+    {
+        // jdeps -modulepath <modulepath> -m root paths
+        String cmd = String.format("jdeps -modulepath %s -addmods %s %s%n",
+            MODS_DIR, roots.stream().collect(Collectors.joining(",")), paths);
 
-    static class Data {
-        static final String INTERNAL = "(internal)";
-        static final String QUALIFIED = "(qualified)";
-        static final String JDK_INTERNAL = "JDK internal API";
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.appModulePath(modulepath)
+                .addmods(roots);
+            Arrays.stream(paths).forEach(jdeps::addRoot);
 
-        final String moduleName;
-        final boolean isNamed;
-        final Map<String, ModuleRequires> requires = new LinkedHashMap<>();
-        final Map<String, Dependence> references = new LinkedHashMap<>();
-        Data(String name) {
-            this(name, true);
-        }
-        Data(String name, boolean isNamed) {
-            this.moduleName = name;
-            this.isNamed = isNamed;
-            requires("java.base");  // implicit requires
-        }
+            // run the analyzer
+            DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
+            assertTrue(analyzer.run());
 
-        Data requires(String name) {
-            requires.put(name, new ModuleRequires(name));
-            return this;
-        }
-        Data requiresPublic(String name) {
-            requires.put(name, new ModuleRequires(name, PUBLIC));
-            return this;
-        }
-        // for unnamed module
-        Data depends(String name) {
-            requires.put(name, new ModuleRequires(name));
-            return this;
-        }
-        Data reference(String origin, String target, String module) {
-            return dependence(origin, target, module, "");
-        }
-        Data internal(String origin, String target, String module) {
-            return dependence(origin, target, module, INTERNAL);
-        }
-        Data qualified(String origin, String target, String module) {
-            return dependence(origin, target, module, QUALIFIED);
-        }
-        Data jdkInternal(String origin, String target, String module) {
-            return dependence(origin, target, module, JDK_INTERNAL);
-        }
-        private Data dependence(String origin, String target, String module, String access) {
-            references.put(key(origin, target), new Dependence(origin, target, module, access));
-            return this;
-        }
+            // analyze result
+            Graph<DepsAnalyzer.Node> g1 = analyzer.moduleGraph();
+            g1.nodes().stream()
+                .filter(u -> u.name.equals(data.moduleName))
+                .forEach(u -> data.checkRequires(u.name, g1.adjacentNodes(u)));
 
-        String key(String origin, String target) {
-            return origin+":"+target;
-        }
-        boolean check(String[] lines) {
-            System.out.format("verifying module %s%s%n", moduleName, isNamed ? "" : " (unnamed module)");
-            for (String l : lines) {
-                String[] tokens = l.trim().split("\\s+");
-                System.out.println("  " + Arrays.stream(tokens).collect(Collectors.joining(" ")));
-                switch (tokens[0]) {
-                    case "module":
-                        assertEquals(tokens.length, 2);
-                        assertEquals(moduleName, tokens[1]);
-                        break;
-                    case "requires":
-                        String name = tokens.length == 2 ? tokens[1] : tokens[2];
-                        Modifier modifier = null;
-                        if (tokens.length == 3) {
-                            assertEquals("public", tokens[1]);
-                            modifier = PUBLIC;
-                        }
-                        checkRequires(name, modifier);
-                        break;
-                    default:
-                        if (tokens.length == 3) {
-                            // unnamed module requires
-                            assertFalse(isNamed);
-                            assertEquals(moduleName, tokens[0]);
-                            String mn = tokens[2];
-                            checkRequires(mn, null);
-                        } else {
-                            checkDependence(tokens);
-                        }
-                }
-            }
-            return true;
-        }
+            Graph<DepsAnalyzer.Node> g2 = analyzer.dependenceGraph();
+            g2.nodes().stream()
+                .filter(u -> u.name.equals(data.moduleName))
+                .forEach(u -> data.checkDependences(u.name, g2.adjacentNodes(u)));
 
-        private void checkRequires(String name, Modifier modifier) {
-            assertTrue(requires.containsKey(name));
-            ModuleRequires req = requires.get(name);
-            assertEquals(req.mod, modifier);
-        }
-
-        private void checkDependence(String[] tokens) {
-            assertTrue(tokens.length >= 4);
-            String origin = tokens[0];
-            String target = tokens[2];
-            String module = tokens[3];
-            String key = key(origin, target);
-            assertTrue(references.containsKey(key));
-            Dependence dep = references.get(key);
-            if (tokens.length == 4) {
-                assertEquals(dep.access, "");
-            } else if (tokens.length == 5) {
-                assertEquals(dep.access, tokens[4]);
-            } else {
-                // JDK internal API
-                module = tokens[6];
-                assertEquals(tokens.length, 7);
-                assertEquals(tokens[3], "JDK");
-                assertEquals(tokens[4], "internal");
-                assertEquals(tokens[5], "API");
-            }
-            assertEquals(dep.module, module);
-        }
-
-        public static class ModuleRequires {
-            final String name;
-            final ModuleDescriptor.Requires.Modifier mod;
-
-            ModuleRequires(String name) {
-                this.name = name;
-                this.mod = null;
-            }
-
-            ModuleRequires(String name, ModuleDescriptor.Requires.Modifier mod) {
-                this.name = name;
-                this.mod = mod;
-            }
-        }
-
-        public static class Dependence {
-            final String origin;
-            final String target;
-            final String module;
-            final String access;
-
-            Dependence(String origin, String target, String module, String access) {
-                this.origin = origin;
-                this.target = target;
-                this.module = module;
-                this.access = access;
-            }
+            jdeps.dumpOutput(System.err);
         }
     }
 }
diff --git a/langtools/test/tools/jdeps/modules/SplitPackage.java b/langtools/test/tools/jdeps/modules/SplitPackage.java
new file mode 100644
index 0000000..b85aed9
--- /dev/null
+++ b/langtools/test/tools/jdeps/modules/SplitPackage.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests split packages
+ * @library ../lib
+ * @build CompilerUtils
+ * @modules jdk.jdeps/com.sun.tools.jdeps
+ * @run testng SplitPackage
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.sun.tools.jdeps.DepsAnalyzer;
+import com.sun.tools.jdeps.JdepsConfiguration;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+public class SplitPackage {
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path CLASSES_DIR = Paths.get("classes");
+
+    private static final String SPLIT_PKG_NAME = "javax.annotation";
+    private static final String JAVA_ANNOTATIONS_COMMON = "java.annotations.common";
+    /**
+     * Compiles classes used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        CompilerUtils.cleanDir(CLASSES_DIR);
+        assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "patches"), CLASSES_DIR));
+    }
+
+    @Test
+    public void runTest() throws Exception {
+        // Test jdeps classes
+        runTest(null);
+        // Test jdeps -addmods
+        runTest(JAVA_ANNOTATIONS_COMMON, SPLIT_PKG_NAME);
+    }
+
+    private void runTest(String root, String... splitPackages) throws Exception {
+        String cmd = String.format("jdeps -verbose:class -addmods %s %s%n",
+            root, CLASSES_DIR);
+
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.verbose("-verbose:class")
+                .addRoot(CLASSES_DIR);
+            if (root != null)
+                jdeps.addmods(Set.of(root));
+
+            JdepsConfiguration config = jdeps.configuration();
+            Map<String, Set<String>> pkgs = config.splitPackages();
+
+            final Set<String> expected;
+            if (splitPackages != null) {
+                expected = Arrays.stream(splitPackages).collect(Collectors.toSet());
+            } else {
+                expected = Collections.emptySet();
+            }
+
+            if (!pkgs.keySet().equals(expected)) {
+                throw new RuntimeException(splitPackages.toString());
+            }
+
+            // java.annotations.common is not observable
+            DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
+
+            assertTrue(analyzer.run());
+
+            jdeps.dumpOutput(System.err);
+        }
+    }
+}
diff --git a/langtools/test/tools/jdeps/modules/TransitiveDeps.java b/langtools/test/tools/jdeps/modules/TransitiveDeps.java
new file mode 100644
index 0000000..9953384
--- /dev/null
+++ b/langtools/test/tools/jdeps/modules/TransitiveDeps.java
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests jdeps -m and -mp options on named modules and unnamed modules
+ * @library ../lib
+ * @build CompilerUtils JdepsUtil
+ * @modules jdk.jdeps/com.sun.tools.jdeps
+ * @run testng TransitiveDeps
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+
+import com.sun.tools.jdeps.DepsAnalyzer;
+import com.sun.tools.jdeps.Graph;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+public class TransitiveDeps {
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path LIBS_DIR = Paths.get("libs");
+
+    // the names of the modules in this test
+    private static String[] modules = new String[] {"unsafe", "m6", "m7"};
+    /**
+     * Compiles all modules used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        CompilerUtils.cleanDir(MODS_DIR);
+        CompilerUtils.cleanDir(LIBS_DIR);
+
+        for (String mn : modules) {
+            // compile a module
+            assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn));
+
+            // create JAR files with no module-info.class
+            Path root = MODS_DIR.resolve(mn);
+            try (Stream<Path> stream = Files.walk(root, Integer.MAX_VALUE)) {
+                Stream<Path> entries = stream.filter(f -> {
+                    String fn = f.getFileName().toString();
+                    return fn.endsWith(".class") && !fn.equals("module-info.class");
+                });
+                JdepsUtil.createJar(LIBS_DIR.resolve(mn + ".jar"), root, entries);
+            }
+        }
+    }
+
+    @DataProvider(name = "modules")
+    public Object[][] expected1() {
+        return new Object[][]{
+            { "m7",
+               List.of(new ModuleMetaData("m7")
+                            .requires("m6")
+                            .requires("unsafe")
+                            .reference("p7.Main", "java.lang.Object", "java.base")
+                            .reference("p7.Main", "java.lang.String", "java.base")
+                            .reference("p7.Main", "org.safe.Lib", "unsafe")
+                            .reference("p7.Main", "p6.safe.Lib", "m6"),
+                        new ModuleMetaData("m6")
+                            .requires("unsafe")
+                            .reference("p6.indirect.UnsafeRef", "java.lang.Object", "java.base")
+                            .reference("p6.indirect.UnsafeRef", "org.unsafe.UseUnsafe ", "unsafe")
+                            .reference("p6.safe.Lib", "java.io.PrintStream", "java.base")
+                            .reference("p6.safe.Lib", "java.lang.Class", "java.base")
+                            .reference("p6.safe.Lib", "java.lang.Object", "java.base")
+                            .reference("p6.safe.Lib", "java.lang.String", "java.base")
+                            .reference("p6.safe.Lib", "java.lang.System", "java.base")
+                            .reference("p6.safe.Lib", "org.safe.Lib", "unsafe"),
+                        new ModuleMetaData("unsafe")
+                            .requires("jdk.unsupported")
+                            .reference("org.indirect.UnsafeRef", "java.lang.Object", "java.base")
+                            .reference("org.safe.Lib", "java.io.PrintStream", "java.base")
+                            .reference("org.safe.Lib", "java.lang.Class", "java.base")
+                            .reference("org.safe.Lib", "java.lang.Object", "java.base")
+                            .reference("org.safe.Lib", "java.lang.String", "java.base")
+                            .reference("org.safe.Lib", "java.lang.System", "java.base")
+                            .reference("org.unsafe.UseUnsafe", "java.lang.Object", "java.base")
+                            .jdkInternal("org.unsafe.UseUnsafe", "sun.misc.Unsafe", "java.base")
+                        )
+            },
+        };
+    }
+
+    @Test(dataProvider = "modules")
+    public void testModulePath(String name, List<ModuleMetaData> data) throws IOException {
+        Set<String> roots = Set.of("m6", "unsafe");
+
+        String cmd1 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", MODS_DIR,
+            roots.stream().collect(Collectors.joining(",")), name);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
+            jdeps.verbose("-verbose:class")
+                .appModulePath(MODS_DIR.toString())
+                .addmods(roots)
+                .addmods(Set.of(name));
+
+            runJdeps(jdeps, data);
+        }
+        // run automatic modules
+        roots = Set.of("ALL-MODULE-PATH", "jdk.unsupported");
+
+        String cmd2 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", LIBS_DIR,
+            roots.stream().collect(Collectors.joining(",")), name);
+
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
+            jdeps.verbose("-verbose:class")
+                .appModulePath(LIBS_DIR.toString())
+                .addmods(roots)
+                .addmods(Set.of(name));
+
+            runJdeps(jdeps, data);
+        }
+    }
+
+    @DataProvider(name = "jars")
+    public Object[][] expected2() {
+        return new Object[][]{
+            { "m7", List.of(new ModuleMetaData("m7.jar")
+                                .requires("m6.jar")
+                                .requires("unsafe.jar")
+                                .reference("p7.Main", "java.lang.Object", "java.base")
+                                .reference("p7.Main", "java.lang.String", "java.base")
+                                .reference("p7.Main", "org.safe.Lib", "unsafe.jar")
+                                .reference("p7.Main", "p6.safe.Lib", "m6.jar"))
+            },
+        };
+    }
+
+    @Test(dataProvider = "jars")
+    public void testClassPath(String name, List<ModuleMetaData> data) throws IOException {
+        String cpath = Arrays.stream(modules)
+            .filter(mn -> !mn.equals(name))
+            .map(mn -> LIBS_DIR.resolve(mn + ".jar").toString())
+            .collect(Collectors.joining(File.pathSeparator));
+
+        Path jarfile = LIBS_DIR.resolve(name + ".jar");
+
+        String cmd = String.format("jdeps -classpath %s %s%n", cpath, jarfile);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.verbose("-verbose:class")
+                .addClassPath(cpath)
+                .addRoot(jarfile);
+
+            runJdeps(jdeps, data);
+        }
+    }
+
+    @DataProvider(name = "compileTimeView")
+    public Object[][] expected3() {
+        return new Object[][] {
+            {"m7",
+             List.of(new ModuleMetaData("m7.jar")
+                        .requires("m6.jar")
+                        .requires("unsafe.jar")
+                        .reference("p7.Main", "java.lang.Object", "java.base")
+                        .reference("p7.Main", "java.lang.String", "java.base")
+                        .reference("p7.Main", "org.safe.Lib", "unsafe.jar")
+                        .reference("p7.Main", "p6.safe.Lib", "m6.jar"),
+                    new ModuleMetaData("m6.jar")
+                        .requires("unsafe.jar")
+                        .reference("p6.indirect.UnsafeRef", "java.lang.Object", "java.base")
+                        .reference("p6.indirect.UnsafeRef", "org.unsafe.UseUnsafe ", "unsafe.jar")
+                        .reference("p6.safe.Lib", "java.io.PrintStream", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.Class", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.Object", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.String", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.System", "java.base")
+                        .reference("p6.safe.Lib", "org.safe.Lib", "unsafe.jar"),
+                    new ModuleMetaData("unsafe.jar")
+                        .requires("jdk.unsupported")
+                        .reference("org.indirect.UnsafeRef", "java.lang.Object", "java.base")
+                        .reference("org.safe.Lib", "java.io.PrintStream", "java.base")
+                        .reference("org.safe.Lib", "java.lang.Class", "java.base")
+                        .reference("org.safe.Lib", "java.lang.Object", "java.base")
+                        .reference("org.safe.Lib", "java.lang.String", "java.base")
+                        .reference("org.safe.Lib", "java.lang.System", "java.base")
+                        .reference("org.unsafe.UseUnsafe", "java.lang.Object", "java.base")
+                        .jdkInternal("org.unsafe.UseUnsafe", "sun.misc.Unsafe", "java.base")
+                )
+            },
+        };
+    }
+
+    @Test(dataProvider = "compileTimeView")
+    public void compileTimeView(String name, List<ModuleMetaData> data) throws IOException {
+        String cpath = Arrays.stream(modules)
+                .filter(mn -> !mn.equals(name))
+                .map(mn -> LIBS_DIR.resolve(mn + ".jar").toString())
+                .collect(Collectors.joining(File.pathSeparator));
+
+        Path jarfile = LIBS_DIR.resolve(name + ".jar");
+
+        String cmd = String.format("jdeps -ct -classpath %s %s%n", cpath, jarfile);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.verbose("-verbose:class")
+                .addClassPath(cpath)
+                .addRoot(jarfile);
+
+            runJdeps(jdeps, data, true, 0 /* -recursive */);
+        }
+    }
+
+    @DataProvider(name = "recursiveDeps")
+    public Object[][] expected4() {
+        return new Object[][] {
+            {"m7",
+                List.of(new ModuleMetaData("m7.jar")
+                        .requires("m6.jar")
+                        .requires("unsafe.jar")
+                        .reference("p7.Main", "java.lang.Object", "java.base")
+                        .reference("p7.Main", "java.lang.String", "java.base")
+                        .reference("p7.Main", "org.safe.Lib", "unsafe.jar")
+                        .reference("p7.Main", "p6.safe.Lib", "m6.jar"),
+                    new ModuleMetaData("m6.jar")
+                        .requires("unsafe.jar")
+                        .reference("p6.safe.Lib", "java.io.PrintStream", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.Class", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.Object", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.String", "java.base")
+                        .reference("p6.safe.Lib", "java.lang.System", "java.base")
+                        .reference("p6.safe.Lib", "org.safe.Lib", "unsafe.jar"),
+                    new ModuleMetaData("unsafe.jar")
+                        .requires("jdk.unsupported")
+                        .reference("org.indirect.UnsafeRef", "java.lang.Object", "java.base")
+                        .reference("org.safe.Lib", "java.io.PrintStream", "java.base")
+                        .reference("org.safe.Lib", "java.lang.Class", "java.base")
+                        .reference("org.safe.Lib", "java.lang.Object", "java.base")
+                        .reference("org.safe.Lib", "java.lang.String", "java.base")
+                        .reference("org.safe.Lib", "java.lang.System", "java.base")
+                )
+            },
+        };
+    }
+    @Test(dataProvider = "recursiveDeps")
+    public void recursiveDeps(String name, List<ModuleMetaData> data) throws IOException {
+        String cpath = Arrays.stream(modules)
+            .filter(mn -> !mn.equals(name))
+            .map(mn -> LIBS_DIR.resolve(mn + ".jar").toString())
+            .collect(Collectors.joining(File.pathSeparator));
+
+        Path jarfile = LIBS_DIR.resolve(name + ".jar");
+
+        String cmd = String.format("jdeps -R -classpath %s %s%n", cpath, jarfile);
+        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
+            jdeps.verbose("-verbose:class").filter("-filter:archive")
+                .addClassPath(cpath)
+                .addRoot(jarfile);
+
+            runJdeps(jdeps, data, true, 0 /* -recursive */);
+        }
+    }
+
+    private void runJdeps(JdepsUtil.Command jdeps, List<ModuleMetaData> data)
+        throws IOException
+    {
+        runJdeps(jdeps, data, false, 1 /* depth */);
+    }
+
+    private void runJdeps(JdepsUtil.Command jdeps, List<ModuleMetaData> data,
+                          boolean compileTimeView, int depth)
+        throws IOException
+    {
+        // run the analyzer
+        DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
+        assertTrue(analyzer.run(compileTimeView, depth));
+        jdeps.dumpOutput(System.err);
+
+        // analyze result
+        Graph<DepsAnalyzer.Node> g1 = analyzer.moduleGraph();
+        Map<String, ModuleMetaData> dataMap = data.stream()
+            .collect(Collectors.toMap(ModuleMetaData::name, Function.identity()));
+
+        // the returned graph contains all nodes such as java.base and jdk.unsupported
+        g1.nodes().stream()
+            .filter(u -> dataMap.containsKey(u.name))
+            .forEach(u -> {
+                ModuleMetaData md = dataMap.get(u.name);
+                md.checkRequires(u.name, g1.adjacentNodes(u));
+            });
+
+        Graph<DepsAnalyzer.Node> g2 = analyzer.dependenceGraph();
+
+        g2.nodes().stream()
+            .filter(u -> dataMap.containsKey(u.name))
+            .forEach(u -> {
+                ModuleMetaData md = dataMap.get(u.name);
+                md.checkDependences(u.name, g2.adjacentNodes(u));
+            });
+    }
+}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/patches/javax/annotation/NonNull.java
similarity index 70%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/patches/javax/annotation/NonNull.java
index 135652e..4aab38a 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/patches/javax/annotation/NonNull.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,17 @@
  * questions.
  */
 
-package sun.misc;
+package javax.annotation;
 
-public class Unsafe {
-    private Unsafe() { }
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+import static java.lang.annotation.ElementType.*;
+
+@Documented
+@Target({FIELD, LOCAL_VARIABLE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NonNull {
 }
diff --git a/langtools/test/tools/jdeps/modules/src/m4/module-info.java b/langtools/test/tools/jdeps/modules/src/m4/module-info.java
index ddca4f5..d494909 100644
--- a/langtools/test/tools/jdeps/modules/src/m4/module-info.java
+++ b/langtools/test/tools/jdeps/modules/src/m4/module-info.java
@@ -22,8 +22,14 @@
  */
 
 module m4 {
+    // not used in signature
     requires public java.compiler;
+
+    // unused dependence
     requires java.logging;
+
     exports p4;
-    exports p4.internal to m1,m2,m3;
+
+    // unuused qualified exports
+    exports p4.internal to m6,m7;
 }
diff --git a/langtools/test/tools/jdeps/modules/src/m4/p4/internal/Impl.java b/langtools/test/tools/jdeps/modules/src/m4/p4/internal/Impl.java
index ea2c548..34bdab4 100644
--- a/langtools/test/tools/jdeps/modules/src/m4/p4/internal/Impl.java
+++ b/langtools/test/tools/jdeps/modules/src/m4/p4/internal/Impl.java
@@ -23,9 +23,14 @@
 
 package p4.internal;
 
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
 
 public class Impl {
+    private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+
     public String name() {
         return Impl.class.getName();
     }
+
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m5/module-info.java
similarity index 69%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m5/module-info.java
index 135652e..2affe5a 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m5/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,19 @@
  * questions.
  */
 
-package sun.misc;
+module m5 {
+    // m4 requires public java.compilerr
+    requires public m4;
+    requires public java.compiler;
 
-public class Unsafe {
-    private Unsafe() { }
+    // java.sql should be requires public
+    requires java.sql;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+    // java.logging is used for implementation only
+    requires public java.logging;
+
+    exports p5;
+
+    // m8 is not in the resolved graph but used by m8
+    exports p5.internal to m8;
 }
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/langtools/test/tools/jdeps/modules/src/m5/p5/Main.java
similarity index 68%
copy from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
copy to langtools/test/tools/jdeps/modules/src/m5/p5/Main.java
index 9e5a4a7..c0a8683 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
+++ b/langtools/test/tools/jdeps/modules/src/m5/p5/Main.java
@@ -4,9 +4,7 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -22,16 +20,25 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.tools.jlink.plugin;
 
-import java.util.Properties;
+package p5;
 
-/**
- * Interface to plugin (container) context.
- */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
+import java.sql.Driver;
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
+
+public class Main {
+    public void run(Driver driver) throws Exception {
+        driver.getParentLogger().config("test");
+
+    }
+
+    public p4.Lib getLib() {
+        return new p4.Lib();
+    }
+
+    public JavaCompiler getCompiler() {
+        return ToolProvider.getSystemJavaCompiler();
+    }
+
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m5/p5/internal/T.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m5/p5/internal/T.java
index 135652e..8eaac30 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m5/p5/internal/T.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,7 @@
  * questions.
  */
 
-package sun.misc;
+package p5.internal;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class T {
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m6/module-info.java
similarity index 76%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m6/module-info.java
index 135652e..374fbfa 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m6/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,13 @@
  * questions.
  */
 
-package sun.misc;
+module m6 {
+    requires unsafe;
 
-public class Unsafe {
-    private Unsafe() { }
+    // no dependency on sun.misc.Unsafe directly or indirectly
+    exports p6.safe;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+    // direct dependency on org.unsafe
+    // hence indirect dependency on sun.misc.Unsafe
+    exports p6.indirect;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m6/p6/indirect/UnsafeRef.java
similarity index 79%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m6/p6/indirect/UnsafeRef.java
index 135652e..28ba63d 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m6/p6/indirect/UnsafeRef.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+package p6.indirect;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+// indirectly depend on sun.misc.Unsafe
+public class UnsafeRef {
+     public static org.unsafe.UseUnsafe get() {
+         return new org.unsafe.UseUnsafe();
+     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m6/p6/safe/Lib.java
similarity index 78%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m6/p6/safe/Lib.java
index 135652e..9a943bd 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m6/p6/safe/Lib.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,12 @@
  * questions.
  */
 
-package sun.misc;
+package p6.safe;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
+// no direct or indirect dependency on sun.misc.Unsafe
+public class Lib {
+    public static void doit() {
+        System.out.println(Lib.class.getName());
+        org.safe.Lib.doit();
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m7/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m7/module-info.java
index 135652e..408efc2 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m7/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,9 @@
  * questions.
  */
 
-package sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+module m7 {
+    // only use classes that have no direct or indirect dependency
+    // to sun.misc.Unsafe
+    requires unsafe;
+    requires m6;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m7/p7/Main.java
similarity index 76%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m7/p7/Main.java
index 135652e..789cdb9 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m7/p7/Main.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,13 @@
  * questions.
  */
 
-package sun.misc;
+package p7;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
+// Only use classes in unsafe and m6 modules with no
+// direct or indirect dependency on sun.misc.Unsafe
+public class Main {
+    public static void main(String... args) {
+        p6.safe.Lib.doit();
+        org.safe.Lib.doit();
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m8/module-info.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m8/module-info.java
index 135652e..128025f 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m8/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,8 @@
  * questions.
  */
 
-package sun.misc;
+module m8 {
+    requires m5;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+    // use p5.internal
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/m8/p8/Main.java
similarity index 83%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/m8/p8/Main.java
index 135652e..1fc8a10 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/m8/p8/Main.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,12 @@
  * questions.
  */
 
-package sun.misc;
+package p8;
 
-public class Unsafe {
-    private Unsafe() { }
+import p5.internal.T;
 
-    public static long getLong(long address) {
-        return 0L;
+public class Main {
+    public static void main() {
+        T t = new T();
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/unsafe/module-info.java
similarity index 74%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/unsafe/module-info.java
index 135652e..363bd50 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/unsafe/module-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,15 @@
  * questions.
  */
 
-package sun.misc;
+module unsafe {
+    requires jdk.unsupported;
 
-public class Unsafe {
-    private Unsafe() { }
+    // direct dependency on sun.misc.Unsafe
+    exports org.unsafe;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+    // no dependency on sun.misc.Unsafe directly or indirectly
+    exports org.safe;
+
+    // indirect dependency on sun.misc.Unsafe
+    exports org.indirect;
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/unsafe/org/indirect/UnsafeRef.java
similarity index 79%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/unsafe/org/indirect/UnsafeRef.java
index 135652e..acd3e93 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/unsafe/org/indirect/UnsafeRef.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+package org.indirect;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
+// indirectly depend on sun.misc.Unsafe
+public class UnsafeRef {
+     public static org.unsafe.UseUnsafe get() {
+         return new org.unsafe.UseUnsafe();
+     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/unsafe/org/safe/Lib.java
similarity index 80%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/unsafe/org/safe/Lib.java
index 135652e..ad5769c 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/unsafe/org/safe/Lib.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package sun.misc;
+package org.safe;
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
+// no direct or indirect dependency on sun.misc.Unsafe
+public class Lib {
+    public static void doit() {
+        System.out.println(Lib.class.getName());
     }
 }
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/langtools/test/tools/jdeps/modules/src/unsafe/org/unsafe/UseUnsafe.java
similarity index 82%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to langtools/test/tools/jdeps/modules/src/unsafe/org/unsafe/UseUnsafe.java
index 135652e..ec010c3 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/langtools/test/tools/jdeps/modules/src/unsafe/org/unsafe/UseUnsafe.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,10 @@
  * questions.
  */
 
-package sun.misc;
+package org.unsafe;
 
-public class Unsafe {
-    private Unsafe() { }
+import sun.misc.Unsafe;
 
-    public static long getLong(long address) {
-        return 0L;
-    }
+public class UseUnsafe {
+    static Unsafe unsafe = Unsafe.getUnsafe();
 }
diff --git a/langtools/test/tools/jdeps/unsupported/JDKUnsupportedTest.java b/langtools/test/tools/jdeps/unsupported/JDKUnsupportedTest.java
index bf2c4c6..3e2e195 100644
--- a/langtools/test/tools/jdeps/unsupported/JDKUnsupportedTest.java
+++ b/langtools/test/tools/jdeps/unsupported/JDKUnsupportedTest.java
@@ -62,7 +62,7 @@
     public void test(String filename, String[][] expected) {
         Path path = Paths.get(TEST_CLASSES, filename);
 
-        Map<String, String> result = jdeps("-M", path.toString());
+        Map<String, String> result = jdeps(path.toString());
         for (String[] e : expected) {
             String pn = e[0];
             String module = e[1];
diff --git a/make/Bundles.gmk b/make/Bundles.gmk
new file mode 100644
index 0000000..140f31a
--- /dev/null
+++ b/make/Bundles.gmk
@@ -0,0 +1,300 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+
+PRODUCT_TARGETS :=
+TEST_TARGETS :=
+DOCS_TARGETS :=
+
+# On Windows tar frequently complains that "file changed as we read it" for
+# some random source files. This seems to be cause by anti virus scanners and
+# is most likely safe to ignore. When it happens, tar returns '1'.
+ifeq ($(OPENJDK_BUILD_OS), windows)
+  TAR_IGNORE_EXIT_VALUE := || test "$$$$?" = "1"
+endif
+
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, , Bundles-pre.gmk))
+################################################################################
+# BUNDLE : Name of bundle to create
+# FILES : Files in BASE_DIR to add to bundle
+# SPECIAL_INCLUDES : List of directories inside BASE_DIR to look for additional
+#     files in. These files will not get proper dependency handling. Use when
+#     files or directories may contain spaces.
+# BASE_DIR : Base directory for the root dir in the bundle.
+# SUBDIR : Optional name of root dir in bundle.
+SetupBundleFile = $(NamedParamsMacroTemplate)
+define SetupBundleFileBody
+
+  $1_RELATIVE_FILES := $$(patsubst $$($1_BASE_DIR)/%, ./%, $$($1_FILES))
+
+  ifneq ($$(filter %.tar.gz, $$($1_BUNDLE_NAME)), )
+    $1_TYPE := tar.gz
+  else ifneq ($$(filter %.zip, $$($1_BUNDLE_NAME)), )
+    $1_TYPE := zip
+  else
+    $$(error Unknown bundle type $$($1_BUNDLE_NAME))
+  endif
+
+  $$(call SetIfEmpty, $1_UNZIP_DEBUGINFO, false)
+
+  $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES)
+	$$(eval $$(call ListPathsSafely, \
+	    $1_RELATIVE_FILES, \
+	    $(SUPPORT_OUTPUTDIR)/bundles/_$1_files))
+	$$(call MakeDir, $$(@D))
+        ifneq ($$($1_SPECIAL_INCLUDES), )
+	  $$(foreach i, $$($1_SPECIAL_INCLUDES), \
+	      ($(CD) $$($1_BASE_DIR) && $(FIND) ./$$i \
+	          >> $(SUPPORT_OUTPUTDIR)/bundles/_$1_files ) ; )
+        endif
+        ifneq ($$($1_SUBDIR), )
+          ifeq ($$($1_TYPE)-$(TAR_SUPPORTS_TRANSFORM)-$$($1_UNZIP_DEBUGINFO), tar.gz-true-false)
+	    $(CD) $$($1_BASE_DIR) \
+	        && ( $(TAR) cf - -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \
+	            --transform 's|^|$$($1_SUBDIR)/|' $(TAR_IGNORE_EXIT_VALUE) ) \
+	        | $(GZIP) > $$@
+          else
+            # If a subdir has been specified, copy all files into a temporary
+            # location with this subdir before creating the tar file
+	    $(RM) -r $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR)
+	    $(MKDIR) -p $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR)
+	    ( $(CD) $$($1_BASE_DIR) \
+	        && $(TAR) cf - -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \
+	            $(TAR_IGNORE_EXIT_VALUE) ) \
+	        | ( $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) && $(TAR) xf - )
+            # Unzip any zipped debuginfo files
+            ifeq ($$($1_UNZIP_DEBUGINFO), true)
+	      for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.diz"`; do \
+	        $(CD) $$$${f%/*} && $(UNZIP) -q $$$${f} && $(RM) $$$${f}; \
+	      done
+            endif
+            ifeq ($$($1_TYPE), tar.gz)
+	      $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && \
+	          ( $(TAR) cf - $$($1_SUBDIR) $(TAR_IGNORE_EXIT_VALUE) ) | $(GZIP) > $$@
+            else ifeq ($$($1_TYPE), zip)
+	      $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && $(ZIP) -qr $$@ .
+            endif
+          endif
+        else
+          ifeq ($$($1_TYPE), tar.gz)
+	    $(CD) $$($1_BASE_DIR) \
+	        && ( $(TAR) cf - -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \
+	            $(TAR_IGNORE_EXIT_VALUE) ) \
+	        | $(GZIP) > $$@
+          else ifeq ($$($1_TYPE), zip)
+	    $(CD) $$($1_BASE_DIR) \
+	        && $(ZIP) -qr $$@ . -i@$(SUPPORT_OUTPUTDIR)/bundles/_$1_files
+          endif
+        endif
+
+  $1 += $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME)
+
+endef
+
+################################################################################
+
+# On Macosx, we bundle up the macosx specific images which already have the
+# correct base directories.
+ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release)
+  JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR)
+  JRE_IMAGE_DIR := $(JRE_MACOSX_BUNDLE_DIR)
+  JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home
+  JRE_IMAGE_HOMEDIR := $(JRE_MACOSX_CONTENTS_DIR)/Home
+  JDK_BUNDLE_SUBDIR :=
+  JRE_BUNDLE_SUBDIR :=
+else
+  JDK_IMAGE_HOMEDIR := $(JDK_IMAGE_DIR)
+  JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR)
+  JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER)
+  JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)
+  ifneq ($(DEBUG_LEVEL), release)
+    JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
+    JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
+  endif
+endif
+
+################################################################################
+
+ifneq ($(filter product-bundles, $(MAKECMDGOALS)), )
+  $(eval $(call FillCacheFind, $(IMAGES_OUTPUTDIR)))
+
+  SYMBOLS_EXCLUDE_PATTERN := %.debuginfo %.diz %.pdb %.map
+
+  ALL_JDK_FILES := $(call CacheFind, $(JDK_IMAGE_DIR))
+
+  # Create special filter rules when dealing with unzipped .dSYM directories on
+  # macosx
+  ifeq ($(OPENJDK_TARGET_OS), macosx)
+    ifeq ($(ZIP_DEBUGINFO_FILES), false)
+      JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \
+          $(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, $(ALL_JDK_FILES))))
+    endif
+  endif
+
+  JDK_BUNDLE_FILES := \
+      $(filter-out \
+          $(JDK_SYMBOLS_EXCLUDE_PATTERN) \
+          $(JDK_EXTRA_EXCLUDES) \
+          $(SYMBOLS_EXCLUDE_PATTERN) \
+          $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \
+          , \
+          $(ALL_JDK_FILES) \
+      )
+  DEMOS_BUNDLE_FILES := \
+      $(filter-out \
+          $(JDK_SYMBOLS_EXCLUDE_PATTERN) \
+          $(SYMBOLS_EXCLUDE_PATTERN) \
+          , \
+          $(filter \
+               $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \
+               $(JDK_IMAGE_HOMEDIR)/release \
+               , \
+               $(ALL_JDK_FILES) \
+          ) \
+      )
+  JDK_SYMBOLS_BUNDLE_FILES := \
+      $(filter \
+          $(JDK_SYMBOLS_EXCLUDE_PATTERN) \
+          $(SYMBOLS_EXCLUDE_PATTERN) \
+          , \
+          $(ALL_JDK_FILES) \
+      ) \
+      $(call CacheFind, $(SYMBOLS_IMAGE_DIR))
+
+  ALL_JRE_FILES := $(call CacheFind, $(JRE_IMAGE_DIR))
+
+  # Create special filter rules when dealing with unzipped .dSYM directories on
+  # macosx
+  ifeq ($(OPENJDK_TARGET_OS), macosx)
+    ifeq ($(ZIP_DEBUGINFO_FILES), false)
+      JRE_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \
+          $(call containing, .dSYM/, $(patsubst $(JRE_IMAGE_DIR)/%, %, $(ALL_JRE_FILES))))
+    endif
+  endif
+
+  JRE_BUNDLE_FILES := $(filter-out \
+      $(JRE_SYMBOLS_EXCLUDE_PATTERN) \
+      $(SYMBOLS_EXCLUDE_PATTERN), \
+      $(ALL_JRE_FILES))
+  JRE_SYMBOLS_BUNDLE_FILES := $(filter \
+      $(JRE_SYMBOLS_EXCLUDE_PATTERN) \
+      $(SYMBOLS_EXCLUDE_PATTERN), \
+      $(ALL_JRE_FILES))
+
+  $(eval $(call SetupBundleFile, BUILD_JDK_BUNDLE, \
+      BUNDLE_NAME := $(JDK_BUNDLE_NAME), \
+      FILES := $(JDK_BUNDLE_FILES), \
+      SPECIAL_INCLUDES := $(JDK_SPECIAL_INCLUDES), \
+      BASE_DIR := $(JDK_IMAGE_DIR), \
+      SUBDIR := $(JDK_BUNDLE_SUBDIR), \
+  ))
+
+  PRODUCT_TARGETS += $(BUILD_JDK_BUNDLE)
+
+  $(eval $(call SetupBundleFile, BUILD_JRE_BUNDLE, \
+      BUNDLE_NAME := $(JRE_BUNDLE_NAME), \
+      FILES := $(JRE_BUNDLE_FILES), \
+      BASE_DIR := $(JRE_IMAGE_DIR), \
+      SUBDIR := $(JRE_BUNDLE_SUBDIR), \
+  ))
+
+  PRODUCT_TARGETS += $(BUILD_JRE_BUNDLE)
+
+  $(eval $(call SetupBundleFile, BUILD_JDK_SYMBOLS_BUNDLE, \
+      BUNDLE_NAME := $(JDK_SYMBOLS_BUNDLE_NAME), \
+      FILES := $(JDK_SYMBOLS_BUNDLE_FILES), \
+      BASE_DIR := $(JDK_IMAGE_DIR), \
+      SUBDIR := $(JDK_BUNDLE_SUBDIR), \
+      UNZIP_DEBUGINFO := true, \
+  ))
+
+  PRODUCT_TARGETS += $(BUILD_JDK_SYMBOLS_BUNDLE)
+
+  $(eval $(call SetupBundleFile, BUILD_JRE_SYMBOLS_BUNDLE, \
+      BUNDLE_NAME := $(JRE_SYMBOLS_BUNDLE_NAME), \
+      FILES := $(JRE_SYMBOLS_BUNDLE_FILES), \
+      BASE_DIR := $(JRE_IMAGE_DIR), \
+      SUBDIR := $(JRE_BUNDLE_SUBDIR), \
+      UNZIP_DEBUGINFO := true, \
+  ))
+
+  PRODUCT_TARGETS += $(BUILD_JRE_SYMBOLS_BUNDLE)
+
+  $(eval $(call SetupBundleFile, BUILD_DEMOS_BUNDLE, \
+      BUNDLE_NAME := $(DEMOS_BUNDLE_NAME), \
+      FILES := $(call DoubleDollar, $(DEMOS_BUNDLE_FILES)), \
+      BASE_DIR := $(JDK_IMAGE_DIR), \
+      SUBDIR := $(JDK_BUNDLE_SUBDIR), \
+  ))
+
+  PRODUCT_TARGETS += $(BUILD_DEMOS_BUNDLE)
+endif
+
+################################################################################
+
+ifneq ($(filter test-bundles, $(MAKECMDGOALS)), )
+  TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR))
+
+  $(eval $(call SetupBundleFile, BUILD_TEST_BUNDLE, \
+      BUNDLE_NAME := $(TEST_BUNDLE_NAME), \
+      FILES := $(call DoubleDollar, $(TEST_BUNDLE_FILES)), \
+      BASE_DIR := $(TEST_IMAGE_DIR), \
+  ))
+
+  TEST_TARGETS += $(BUILD_TEST_BUNDLE)
+endif
+
+################################################################################
+
+ifneq ($(filter docs-bundles, $(MAKECMDGOALS)), )
+  DOCS_BUNDLE_FILES := $(call CacheFind, $(DOCS_IMAGE_DIR))
+
+  $(eval $(call SetupBundleFile, BUILD_DOCS_BUNDLE, \
+      BUNDLE_NAME := $(DOCS_BUNDLE_NAME), \
+      FILES := $(DOCS_BUNDLE_FILES), \
+      BASE_DIR := $(DOCS_IMAGE_DIR), \
+      SUBDIR := docs, \
+  ))
+
+  DOCS_TARGETS += $(BUILD_DOCS_BUNDLE)
+endif
+
+################################################################################
+
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, , Bundles.gmk))
+
+################################################################################
+
+product-bundles: $(PRODUCT_TARGETS)
+test-bundles: $(TEST_TARGETS)
+docs-bundles: $(DOCS_TARGETS)
+
+.PHONY: all default product-bundles test-bundles docs-bundles
diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk
index 394888c..40900ff 100644
--- a/make/CreateJmods.gmk
+++ b/make/CreateJmods.gmk
@@ -69,21 +69,13 @@
 # Add dependencies on other jmod files. Only java.base needs access to other
 # jmods.
 ifeq ($(MODULE), java.base)
+  ALL_UPGRADEABLE_MODULES = $(call FindAllUpgradeableModules)
   # When creating a BUILDJDK, we don't need to add hashes to java.base
   ifneq ($(CREATING_BUILDJDK), true)
     DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
-        $(filter-out java.base, $(call FindAllModules)))
+        $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
 
-    # TODO: find modules that directly and indirectly depend on upgradeable
-    # modules
-    EXCLUDE_HASH_MODULES := $(UPGRADEABLE_MODULES) \
-      java.se.ee \
-      jdk.rmic \
-      jdk.xml.bind \
-      jdk.xml.ws \
-      #
-
-    EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(EXCLUDE_HASH_MODULES))))
+    EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
 
     JMOD_FLAGS += --modulepath $(JMODS_DIR) \
         --hash-modules '^(?!$(EXCLUDE_PATTERN))'
diff --git a/make/GensrcModuleInfo.gmk b/make/GensrcModuleInfo.gmk
index 2fbcdc6..f3487b4 100644
--- a/make/GensrcModuleInfo.gmk
+++ b/make/GensrcModuleInfo.gmk
@@ -85,21 +85,41 @@
   MODS_REST := $(filter-out $(MODS_QUALIFIED_EXPORTS), $(MOD_FILE_CONTENTS))
 
   # Filter the contents for modules that are actually being built
-  MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
-  MODIFICATIONS := $(filter $(MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
+  ALL_MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
+  MODIFICATIONS := $(filter $(ALL_MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
       $(MODS_REST)
 
+  # Returns non empty if the package exists in the current module
+  # Param 1 - Name of package with dots
+  PackageExists = \
+      $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \
+          $(MODULE_CLASSES_DIRS) \
+          $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \
+      )))
+
   # Convert the modification lines into arguments for the modification tool.
   # Filter out modifications for non existing to-modules.
   $(foreach line, $(MODIFICATIONS), \
     $(eval split_line := $(subst /,$(SPACE),$(line))) \
     $(eval command := $(word 1, $(split_line))) \
-    $(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \
-    $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
-    $(if $(to_module), \
-      $(eval ARGS += -$(command) $(package)/$(to_module)) \
+    $(if $(filter $(command), exports), \
+      $(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \
+      $(if $(call PackageExists, $(package)), \
+        $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
+        $(if $(to_module), \
+          $(eval ARGS += -$(command) $(package)/$(to_module)) \
+        , \
+          $(eval ARGS += -$(command) $(package)) \
+        ) \
+      ) \
     , \
-      $(eval ARGS += -$(command) $(package)) \
+      $(if $(filter $(command), provides), \
+        $(eval provider := $(patsubst %;,%,$(word 2, $(split_line)))) \
+        $(eval class := $(patsubst %;,%,$(word 4, $(split_line)))) \
+        $(eval ARGS += -$(command) $(provider)/$(class)) \
+      , \
+        $(error A module-info.extra in $(MODULE) contains invalid command $(command)) \
+      ) \
     ) \
   )
 
diff --git a/make/HotspotWrapper.gmk b/make/HotspotWrapper.gmk
deleted file mode 100644
index 6632155..0000000
--- a/make/HotspotWrapper.gmk
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Include the legacy hotspot-spec.gmk (which in turns includes spec.gmk)
-BASE_SPEC:=$(SPEC)
-# Assign to HOTSPOT_SPEC so that the variable HOTSPOT_SPEC can be
-# overridden when building the buildjdk.
-HOTSPOT_SPEC := $(dir $(SPEC))hotspot-spec.gmk
-include $(HOTSPOT_SPEC)
-include MakeBase.gmk
-
-# Inclusion of this pseudo-target will cause make to execute this file
-# serially, regardless of -j. Recursively called makefiles will not be
-# affected, however. This is required for correct dependency management.
-.NOTPARALLEL:
-
-default: all
-
-# Get all files in src, make or agent subdirs in hotspot directory and
-# filter out .hg. This skips the test directory.
-HOTSPOT_FILES := $(shell $(FIND) -L \
-    $(HOTSPOT_TOPDIR)/src $(HOTSPOT_TOPDIR)/make \
-    -name ".hg" -prune -o -print)
-
-# The old build creates hotspot output dir before calling hotspot and
-# not doing it breaks builds on msys.
-$(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp: $(HOTSPOT_FILES)
-	@$(MKDIR) -p $(HOTSPOT_OUTPUTDIR)
-	($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(HOTSPOT_MAKE_ARGS) \
-	    LOG_LEVEL=$(LOG_LEVEL) SPEC=$(HOTSPOT_SPEC) BASE_SPEC=$(BASE_SPEC))
-	$(TOUCH) $@
-
-hotspot: $(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp
-
-all: hotspot
-
-.PHONY: default all hotspot
diff --git a/make/Images.gmk b/make/Images.gmk
index 564f2b2..92adf30 100644
--- a/make/Images.gmk
+++ b/make/Images.gmk
@@ -43,8 +43,9 @@
 
 $(eval $(call ReadImportMetaData))
 
-JRE_MODULES += $(filter-out $(MODULES_FILTER), $(BOOT_MODULES) $(PLATFORM_MODULES) $(JRE_TOOL_MODULES))
-JDK_MODULES += $(filter-out $(MODULES_FILTER), $(ALL_MODULES))
+JRE_MODULES += $(filter $(ALL_MODULES), $(BOOT_MODULES) \
+    $(PLATFORM_MODULES) $(JRE_TOOL_MODULES))
+JDK_MODULES += $(ALL_MODULES)
 
 # Compact builds have additional modules
 COMPACT1_EXTRA_MODULES := jdk.localedata jdk.crypto.pkcs11 jdk.crypto.ec
diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk
index d1e85b4..d27caaf 100644
--- a/make/Javadoc.gmk
+++ b/make/Javadoc.gmk
@@ -44,7 +44,7 @@
 # Definitions for directories
 #
 
-DOCSDIR := $(IMAGES_OUTPUTDIR)/docs
+DOCSDIR := $(DOCS_IMAGE_DIR)
 DOCSTMPDIR = $(SUPPORT_OUTPUTDIR)/docs
 
 HOTSPOT_DOCS_IMPORT_PATH=$(HOTSPOT_OUTPUTDIR)/docs
@@ -1437,7 +1437,6 @@
 	  $(call OptionPair,-windowtitle,$(DYNALINKAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
 	  $(call OptionPair,-header,$(DYNALINKAPI_HEADER)$(DRAFT_HEADER)) ; \
 	  $(call OptionPair,-bottom,$(DYNALINKAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
-	  $(call OptionTrip,-group,$(DYNALINKAPI_GROUPNAME),$(DYNALINKAPI_REGEXP)); \
 	  $(call OptionTrip,-linkoffline,$(DYNALINKAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
 	) >> $@
 
@@ -1634,9 +1633,7 @@
 JLINK_PLUGIN_WINDOWTITLE := JLink Plugin API - EXPERIMENTAL
 JLINK_PLUGIN_HEADER := <strong>JLink Plugin API - EXPERIMENTAL</strong>
 JLINK_PLUGIN_BOTTOM := $(call CommonBottom,$(JLINK_PLUGIN_FIRST_COPYRIGHT_YEAR))
-JLINK_PLUGIN_PKGS = jdk.tools.jlink \
-    jdk.tools.jlink.builder \
-    jdk.tools.jlink.plugin
+JLINK_PLUGIN_PKGS = jdk.tools.jlink.plugin
 
 JLINK_PLUGIN_INDEX_HTML = $(JLINK_PLUGIN_DOCDIR)/index.html
 JLINK_PLUGIN_OPTIONS_FILE = $(DOCSTMPDIR)/jlinkplugins.options
diff --git a/make/Jprt.gmk b/make/Jprt.gmk
index e82b84d..09d6dc7 100644
--- a/make/Jprt.gmk
+++ b/make/Jprt.gmk
@@ -32,14 +32,6 @@
   ifdef JPRT_ARCHIVE_BUNDLE
     override JPRT_ARCHIVE_BUNDLE := $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_BUNDLE))
   endif
-  ifdef JPRT_ARCHIVE_INSTALL_BUNDLE
-    override JPRT_ARCHIVE_INSTALL_BUNDLE := \
-        $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_INSTALL_BUNDLE))
-  endif
-  ifdef JPRT_ARCHIVE_MODULES_BUNDLE
-    override JPRT_ARCHIVE_MODULES_BUNDLE := \
-        $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_MODULES_BUNDLE))
-  endif
   ifdef JPRT_ARCHIVE_TEST_BUNDLE
     override JPRT_ARCHIVE_TEST_BUNDLE := \
         $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_TEST_BUNDLE))
@@ -55,12 +47,6 @@
 ifndef JPRT_ARCHIVE_BUNDLE
   JPRT_ARCHIVE_BUNDLE=/tmp/jprt_bundles/jdk-image.zip
 endif
-ifndef JPRT_ARCHIVE_INSTALL_BUNDLE
-  JPRT_ARCHIVE_INSTALL_BUNDLE=/tmp/jprt_bundles/product-install.zip
-endif
-ifndef JPRT_ARCHIVE_MODULES_BUNDLE
-  JPRT_ARCHIVE_MODULES_BUNDLE=/tmp/jprt_bundles/modules.zip
-endif
 ifndef JPRT_ARCHIVE_TEST_BUNDLE
   JPRT_ARCHIVE_TEST_BUNDLE=/tmp/jprt_bundles/test-image.zip
 endif
@@ -72,94 +58,51 @@
   jprt_bundle: bootcycle-images
 endif
 
-# This target must be called in the context of a SPEC file
-jprt_bundle: $(JPRT_ARCHIVE_BUNDLE) $(JPRT_ARCHIVE_TEST_BUNDLE) \
-    $(JPRT_ARCHIVE_MODULES_BUNDLE)
+################################################################################
+# JPRT specific bundling targets
+JPRT_TARGET ?= $(DEFAULT_MAKE_TARGET)
+ifeq ($(JPRT_TARGET), $(DEFAULT_MAKE_TARGET))
+  jprt_bundle: $(DEFAULT_MAKE_TARGET) $(JPRT_ARCHIVE_BUNDLE) \
+      $(JPRT_ARCHIVE_TEST_BUNDLE)
 
-ifeq ($(GCOV_ENABLED), true)
-  jprt_bundle: $(JPRT_ARCHIVE_SYMBOLS_BUNDLE)
-endif
+  SRC_JDK_IMAGE_DIR := $(JDK_IMAGE_DIR)
+  SRC_TEST_IMAGE_DIR := $(TEST_IMAGE_DIR)
 
-# This target must be called in the context of a SPEC file
-$(JPRT_ARCHIVE_BUNDLE): bundles
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(CP) $(BUILD_OUTPUT)/bundles/$(JDK_IMAGE_SUBDIR).zip $@
+  # This target must be called in the context of a SPEC file
+  $(JPRT_ARCHIVE_BUNDLE): product-images
+	$(call MakeDir, $(@D))
+	$(CD) $(SRC_JDK_IMAGE_DIR) && $(ZIP) -y -q -r $@ .
 
-$(JPRT_ARCHIVE_MODULES_BUNDLE): bundles
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(CP) $(BUILD_OUTPUT)/bundles/modules.zip $@
+  $(JPRT_ARCHIVE_TEST_BUNDLE): test-image
+	$(call MakeDir, $(@D))
+	$(CD) $(SRC_TEST_IMAGE_DIR) && $(ZIP) -y -q -r $@ .
 
-$(JPRT_ARCHIVE_TEST_BUNDLE): bundles
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(CP) $(BUILD_OUTPUT)/bundles/$(TEST_IMAGE_SUBDIR).zip $@
+  ##############################################################################
+  # Optional symbols bundle
+  ifeq ($(GCOV_ENABLED), true)
+    jprt_bundle: $(JPRT_ARCHIVE_SYMBOLS_BUNDLE)
+    zip-bundles: $(SYMBOLS_ZIP_BUNDLE)
 
-$(JPRT_ARCHIVE_SYMBOLS_BUNDLE): bundles
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(CP) $(BUILD_OUTPUT)/bundles/$(SYMBOLS_IMAGE_SUBDIR).zip $@
+    $(JPRT_ARCHIVE_SYMBOLS_BUNDLE): product-images
+	$(call MakeDir, $(@D))
+	$(CD) $(SYMBOLS_IMAGE_DIR) && $(ZIP) -y -q -r $@ .
 
-SRC_JDK_IMAGE_DIR := $(JDK_IMAGE_DIR)
-SRC_JRE_IMAGE_DIR := $(JRE_IMAGE_DIR)
-SRC_TEST_IMAGE_DIR := $(TEST_IMAGE_DIR)
-SRC_JDK_MACOSX_BUNDLE_DIR := $(JDK_MACOSX_BUNDLE_DIR)
-SRC_JRE_MACOSX_BUNDLE_DIR := $(JRE_MACOSX_BUNDLE_DIR)
+  endif
 
-# Bundle up the images
-JPRT_TARGET ?= default
-ifeq ($(JPRT_TARGET), default)
-  bundles: $(JPRT_TARGET)
-	@$(call TargetEnter)
-	$(MKDIR) -p $(BUILD_OUTPUT)/bundles
-	$(CD) $(SRC_JDK_IMAGE_DIR) && $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/$(JDK_IMAGE_SUBDIR).zip .
-	$(CD) $(SRC_JRE_IMAGE_DIR) && $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/$(JRE_IMAGE_SUBDIR).zip .
-	$(CD) $(SRC_TEST_IMAGE_DIR) && $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/$(TEST_IMAGE_SUBDIR).zip .
-	$(CD) $(IMAGES_OUTPUTDIR)/jmods && $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/modules.zip .
-	if [ -d $(BUILD_OUTPUT)/install/bundles ] ; then \
-	  $(CD) $(BUILD_OUTPUT)/install/bundles && $(ZIP) -y -q -r \
-	      $(JPRT_ARCHIVE_INSTALL_BUNDLE) . ; \
-	fi
-	if [ -d $(SYMBOLS_IMAGE_DIR) ] ; then \
-	  $(CD) $(SYMBOLS_IMAGE_DIR) && $(ZIP) -y -q -r \
-	      $(BUILD_OUTPUT)/bundles/$(SYMBOLS_IMAGE_SUBDIR).zip . ; \
-	fi
-	@$(call TargetExit)
+  ##############################################################################
+
 else
-  # Just fake the bundles
-  bundles: $(JPRT_TARGET)
+  # Just fake the main bundle to satisfy JPRT
+  jprt_bundle: $(JPRT_TARGET)
 	@$(call TargetEnter)
 	$(MKDIR) -p $(BUILD_OUTPUT)/bundles
-	$(CD) $(TOPDIR) &&  $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/$(JDK_IMAGE_SUBDIR).zip README
-	$(CD) $(TOPDIR) &&  $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/$(JRE_IMAGE_SUBDIR).zip README
-	$(CD) $(TOPDIR) &&  $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/$(TEST_IMAGE_SUBDIR).zip README
-	$(CD) $(TOPDIR) &&  $(ZIP) -y -q -r \
-	    $(BUILD_OUTPUT)/bundles/modules.zip README
+	$(CD) $(TOPDIR) && $(TAR) cf - README | $(GZIP) > \
+	    $(JPRT_ARCHIVE_BUNDLE)
 	@$(call TargetExit)
 endif
 
-# Copy images to one unified location regardless of platform etc.
-final-images: $(JPRT_TARGET)
-	@$(call TargetEnter)
-	$(RM) -r $(BUILD_OUTPUT)/final-images
-	$(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JDK_IMAGE_SUBDIR)
-	$(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JRE_IMAGE_SUBDIR)
-	$(CP) -R -P $(SRC_JDK_IMAGE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JDK_IMAGE_SUBDIR)/
-	$(CP) -R -P $(SRC_JRE_IMAGE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JRE_IMAGE_SUBDIR)/
-        ifeq ($(OPENJDK_TARGET_OS),macosx)
-	  $(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JDK_MACOSX_BUNDLE_SUBDIR)
-	  $(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JRE_MACOSX_BUNDLE_SUBDIR)
-	  $(CP) -R -P $(SRC_JDK_MACOSX_BUNDLE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JDK_MACOSX_BUNDLE_SUBDIR)/
-	  $(CP) -R -P $(SRC_JRE_MACOSX_BUNDLE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JRE_MACOSX_BUNDLE_SUBDIR)/
-        endif
-	@$(call TargetExit)
+ALL_TARGETS += jprt_bundle
 
-ALL_TARGETS += jprt_bundle bundles final-images
+################################################################################
+
+$(eval $(call IncludeCustomExtension, , Jprt.gmk))
diff --git a/make/MacBundles.gmk b/make/MacBundles.gmk
index ea8913e..f860e5e 100644
--- a/make/MacBundles.gmk
+++ b/make/MacBundles.gmk
@@ -34,7 +34,7 @@
 
   bundles: jre-bundle jdk-bundle
 
-  # JDK_MACOSX_BUNDLE_DIR and JRE_MACOSX_BUNDLE_DIR are defined in SPEC.
+  # JDK_MACOSX_CONTENTS_DIR and JRE_MACOSX_CONTENTS_DIR are defined in SPEC.
 
   MACOSX_PLIST_SRC := $(JDK_TOPDIR)/make/data/bundle
 
@@ -52,27 +52,27 @@
   JDK_FILE_LIST := $(shell $(FIND) $(JDK_IMAGE_DIR))
   JRE_FILE_LIST := $(shell $(FIND) $(JRE_IMAGE_DIR))
 
-  JDK_TARGET_LIST := $(subst $(JDK_IMAGE_DIR)/,$(JDK_MACOSX_BUNDLE_DIR)/Home/,$(JDK_FILE_LIST))
-  JRE_TARGET_LIST := $(subst $(JRE_IMAGE_DIR)/,$(JRE_MACOSX_BUNDLE_DIR)/Home/,$(JRE_FILE_LIST))
+  JDK_TARGET_LIST := $(subst $(JDK_IMAGE_DIR)/,$(JDK_MACOSX_CONTENTS_DIR)/Home/,$(JDK_FILE_LIST))
+  JRE_TARGET_LIST := $(subst $(JRE_IMAGE_DIR)/,$(JRE_MACOSX_CONTENTS_DIR)/Home/,$(JRE_FILE_LIST))
 
   # Copy empty directories (jre/lib/applet).
-  $(JDK_MACOSX_BUNDLE_DIR)/Home/%: $(JDK_IMAGE_DIR)/%
+  $(JDK_MACOSX_CONTENTS_DIR)/Home/%: $(JDK_IMAGE_DIR)/%
 	$(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@))
 	$(MKDIR) -p $(@D)
 	if [ -d "$<" ]; then $(MKDIR) -p $@; else $(CP) -f -R -P '$<' '$@'; fi
 
-  $(JRE_MACOSX_BUNDLE_DIR)/Home/%: $(JRE_IMAGE_DIR)/%
+  $(JRE_MACOSX_CONTENTS_DIR)/Home/%: $(JRE_IMAGE_DIR)/%
 	$(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@))
 	$(MKDIR) -p $(@D)
 	if [ -d "$<" ]; then $(MKDIR) -p $@; else $(CP) -f -R -P '$<' '$@'; fi
 
-  $(JDK_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib:
+  $(JDK_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib:
 	$(call LogInfo, Creating link $(patsubst $(OUTPUT_ROOT)/%,%,$@))
 	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(LN) -s ../Home/lib/jli/libjli.dylib $@
 
-  $(JRE_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib:
+  $(JRE_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib:
 	$(call LogInfo, Creating link $(patsubst $(OUTPUT_ROOT)/%,%,$@))
 	$(MKDIR) -p $(@D)
 	$(RM) $@
@@ -80,7 +80,7 @@
 
   $(eval $(call SetupTextFileProcessing, BUILD_JDK_PLIST, \
       SOURCE_FILES := $(MACOSX_PLIST_SRC)/JDK-Info.plist, \
-      OUTPUT_FILE := $(JDK_MACOSX_BUNDLE_DIR)/Info.plist, \
+      OUTPUT_FILE := $(JDK_MACOSX_CONTENTS_DIR)/Info.plist, \
       REPLACEMENTS := \
           @@ID@@ => $(BUNDLE_ID).jdk ; \
           @@NAME@@ => $(BUNDLE_NAME) ; \
@@ -92,7 +92,7 @@
 
   $(eval $(call SetupTextFileProcessing, BUILD_JRE_PLIST, \
       SOURCE_FILES := $(MACOSX_PLIST_SRC)/JRE-Info.plist, \
-      OUTPUT_FILE := $(JRE_MACOSX_BUNDLE_DIR)/Info.plist, \
+      OUTPUT_FILE := $(JRE_MACOSX_CONTENTS_DIR)/Info.plist, \
       REPLACEMENTS := \
           @@ID@@ => $(BUNDLE_ID).jre ; \
           @@NAME@@ => $(BUNDLE_NAME) ; \
@@ -102,13 +102,13 @@
           @@VENDOR@@ => $(BUNDLE_VENDOR) , \
   ))
 
-  jdk-bundle: $(JDK_TARGET_LIST) $(JDK_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib \
+  jdk-bundle: $(JDK_TARGET_LIST) $(JDK_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib \
       $(BUILD_JDK_PLIST)
-	$(SETFILE) -a B $(dir $(JDK_MACOSX_BUNDLE_DIR))
+	$(SETFILE) -a B $(dir $(JDK_MACOSX_CONTENTS_DIR))
 
-  jre-bundle: $(JRE_TARGET_LIST) $(JRE_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib \
+  jre-bundle: $(JRE_TARGET_LIST) $(JRE_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib \
       $(BUILD_JRE_PLIST)
-	$(SETFILE) -a B $(dir $(JRE_MACOSX_BUNDLE_DIR))
+	$(SETFILE) -a B $(dir $(JRE_MACOSX_CONTENTS_DIR))
 
 else # Not macosx
 
diff --git a/make/Main.gmk b/make/Main.gmk
index b1700f3..cbde81f 100644
--- a/make/Main.gmk
+++ b/make/Main.gmk
@@ -228,16 +228,12 @@
 # Build hotspot target
 
 ifeq ($(BUILD_HOTSPOT),true)
-  hotspot:
-        ifeq ($(USE_NEW_HOTSPOT_BUILD), true)
-	  +($(CD) $(HOTSPOT_TOPDIR)/makefiles && $(MAKE) $(MAKE_ARGS) -f BuildHotspot.gmk)
-        else
-	  +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
-        endif
+hotspot:
+	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildHotspot.gmk)
 endif
 
 hotspot-ide-project:
-	+($(CD) $(HOTSPOT_TOPDIR)/makefiles && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk)
+	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk)
 
 ALL_TARGETS += hotspot hotspot-ide-project
 
@@ -306,9 +302,13 @@
 
 BOOTCYCLE_TARGET := product-images
 bootcycle-images:
-	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
-	+$(MAKE) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
-	    JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
+        ifneq ($(COMPILE_TYPE), cross)
+	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
+	  +$(MAKE) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
+	      JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
+        else
+	  $(call LogWarn, Boot cycle build disabled when cross compiling)
+        endif
 
 zip-security:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk)
@@ -402,6 +402,11 @@
 	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
 	    test-image-jdk-jtreg-native)
 
+ifeq ($(BUILD_GTEST), true)
+  test-image-hotspot-gtest:
+	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk)
+endif
+
 build-test-lib:
 	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)
 
@@ -425,32 +430,49 @@
 ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
     test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
     test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
-    test-failure-handler test-image-failure-handler
+    test-failure-handler test-image-failure-handler test-image-hotspot-gtest
 
 ################################################################################
 # Run tests
 
 # Run tests specified by $(TEST), or the default test set.
 test:
-	$(call RunTests, $(TEST))
+	$(call RunTests, $(TEST), $(JDK_IMAGE_DIR))
 
 test-hotspot-jtreg:
-	$(call RunTests, "hotspot_all")
+	$(call RunTests, "hotspot_all", $(JDK_IMAGE_DIR))
 
 test-hotspot-jtreg-native:
-	$(call RunTests, "hotspot_native_sanity")
+	$(call RunTests, "hotspot_native_sanity", $(JDK_IMAGE_DIR))
 
 test-hotspot-internal:
-	$(call RunTests, "hotspot_internal")
+	$(call RunTests, "hotspot_internal", $(JDK_OUTPUTDIR))
+
+test-hotspot-gtest:
+	$(call RunTests, "hotspot_gtest", $(JDK_OUTPUTDIR))
 
 test-jdk-jtreg-native:
-	$(call RunTests, "jdk_native_sanity")
+	$(call RunTests, "jdk_native_sanity", $(JDK_IMAGE_DIR))
 
 test-make:
 	($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET))
 
 ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \
-    test-hotspot-internal test-jdk-jtreg-native test-make
+    test-hotspot-internal test-hotspot-gtest test-jdk-jtreg-native test-make
+
+################################################################################
+# Bundles
+
+product-bundles:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)
+
+test-bundles:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)
+
+docs-bundles:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)
+
+ALL_TARGETS += product-bundles test-bundles docs-bundles
 
 ################################################################################
 # Install targets
@@ -578,7 +600,8 @@
   # When creating a BUILDJDK, we don't need to add hashes to java.base, thus
   # we don't need to depend on all other jmods
   ifneq ($(CREATING_BUILDJDK), true)
-    java.base-jmod: $(filter-out java.base-jmod, $(JMOD_TARGETS))
+    java.base-jmod: $(filter-out java.base-jmod \
+        $(addsuffix -jmod, $(call FindAllUpgradeableModules)), $(JMOD_TARGETS))
   endif
 
   # Declare dependencies from <module>-jmod to all other module targets
@@ -669,12 +692,22 @@
 
   test-image-jdk-jtreg-native: build-test-jdk-jtreg-native
 
+  test-image-hotspot-gtest: hotspot
+
   test-hotspot-internal: exploded-image
 
   test-hotspot-jtreg: jimages test-image
 
+  test-hotspot-gtest: exploded-image test-image-hotspot-gtest
+
   install: product-images
 
+  product-bundles: product-images
+
+  test-bundles: test-image
+
+  docs-bundles: docs-image
+
   generate-summary: jmods
 
 endif
@@ -753,14 +786,18 @@
 
 # This target builds the test image
 test-image: prepare-test-image test-image-hotspot-jtreg-native \
-    test-image-jdk-jtreg-native test-image-failure-handler
+    test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest
 
-# all-images is the top-most target, it builds all our deliverables ("images").
+# all-images builds all our deliverables as images.
 all-images: product-images test-image docs-image
 
+# all-bundles packages all our deliverables as tar.gz bundles.
+all-bundles: product-bundles test-bundles docs-bundles
+
 ALL_TARGETS += buildtools gensrc gendata copy java rmic libs launchers jmods \
     jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples exploded-image \
-    create-buildjdk mac-bundles product-images docs-image test-image all-images
+    create-buildjdk mac-bundles product-images docs-image test-image all-images \
+    all-bundles
 
 ################################################################################
 
@@ -771,9 +808,10 @@
 jdk: exploded-image
 images: product-images
 docs: docs-image
+bundles: all-bundles
 all: all-images
 
-ALL_TARGETS += default jdk images docs all
+ALL_TARGETS += default jdk images docs bundles all
 
 ################################################################################
 ################################################################################
diff --git a/make/MainSupport.gmk b/make/MainSupport.gmk
index d09331a..7683cfe 100644
--- a/make/MainSupport.gmk
+++ b/make/MainSupport.gmk
@@ -30,10 +30,10 @@
 ifndef _MAINSUPPORT_GMK
 _MAINSUPPORT_GMK := 1
 
-# Run the tests specified by $1.
+# Run the tests specified by $1, with PRODUCT_HOME specified by $2
 define RunTests
 	($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \
-	    JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) \
+	    JT_HOME=$(JT_HOME) PRODUCT_HOME=$(strip $2) \
 	    TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \
 	    ALT_OUTPUTDIR=$(OUTPUT_ROOT) TEST_JOBS=$(TEST_JOBS) \
 	    JOBS=$(JOBS) $1) || true
diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk
index 1a33d69..3665297 100644
--- a/make/common/MakeBase.gmk
+++ b/make/common/MakeBase.gmk
@@ -145,7 +145,7 @@
         $$(strip $2),$$(subst $$(SPACE),$$(NEWLINE),$$(strip $$($$(strip $1)))))
   endef
 
-else # HAS_FILE_FUNCTION
+else # HAS_FILE_FUNCTION = false
 
   $(eval compress_paths = \
       $(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl)))
@@ -172,8 +172,8 @@
   # Param 2 - File to print to
   # Param 3 - Set to true to append to file instead of overwriting
   define ListPathsSafely
-    ifneq (,$$(word 10001,$$($1)))
-      $$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!)
+    ifneq (,$$(word 30001,$$($$(strip $1))))
+      $$(error Cannot list safely more than 30000 paths. $1 has $$(words $$($$(strip $1))) paths!)
     endif
     $$(call MakeDir, $$(dir $2))
     ifneq ($$(strip $3), true)
@@ -229,6 +229,106 @@
     $$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500)
     $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750)
     $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,10001,10250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,10251,10500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,10501,10750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,10751,11000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,11001,11250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,11251,11500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,11501,11750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,11751,12000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,12001,12250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,12251,12500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,12501,12750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,12751,13000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,13001,13250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,13251,13500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,13501,13750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,13751,14000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,14001,14250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,14251,14500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,14501,14750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,14751,15000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,15001,15250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,15251,15500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,15501,15750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,15751,16000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,16001,16250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,16251,16500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,16501,16750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,16751,17000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,17001,17250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,17251,17500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,17501,17750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,17751,18000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,18001,18250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,18251,18500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,18501,18750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,18751,19000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,19001,19250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,19251,19500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,19501,19750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,19751,20000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,20001,20250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,20251,20500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,20501,20750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,20751,21000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,21001,21250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,21251,21500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,21501,21750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,21751,22000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,22001,22250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,22251,22500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,22501,22750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,22751,23000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,23001,23250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,23251,23500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,23501,23750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,23751,24000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,24001,24250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,24251,24500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,24501,24750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,24751,25000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,25001,25250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,25251,25500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,25501,25750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,25751,26000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,26001,26250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,26251,26500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,26501,26750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,26751,27000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,27001,27250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,27251,27500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,27501,27750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,27751,28000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,28001,28250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,28251,28500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,28501,28750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,28751,29000)
+
+    $$(call ListPathsSafely_IfPrintf,$1,$2,29001,29250)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,29251,29500)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,29501,29750)
+    $$(call ListPathsSafely_IfPrintf,$1,$2,29751,30000)
   endef
 endif # HAS_FILE_FUNCTION
 
@@ -420,8 +520,12 @@
   # set. Some files get their write permissions removed after being copied to the
   # output dir. When these are copied again to images, xattr would fail. By only clearing
   # attributes when they are present, failing on this is avoided.
+  #
+  # If copying a soft link to a directory, need to delete the target first to avoid
+  # weird errors.
   define install-file
 	$(MKDIR) -p '$(@D)'
+	$(RM) '$@'
 	$(CP) -fRP '$<' '$@'
 	if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
   endef
diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk
index ba1f82e..90469d0 100644
--- a/make/common/Modules.gmk
+++ b/make/common/Modules.gmk
@@ -72,7 +72,6 @@
 
 # to be deprivileged
 BOOT_MODULES += \
-    java.scripting \
     java.sql.rowset \
     java.smartcardio \
     jdk.naming.rmi \
@@ -87,6 +86,10 @@
     java.xml.ws \
     #
 
+# Modules explicitly declared as not being upgradeable even though they require
+# an upgradeable module.
+NON_UPGRADEABLE_MODULES +=
+
 AGGREGATOR_MODULES += \
     java.compact1 \
     java.compact2 \
@@ -102,6 +105,7 @@
 
 PLATFORM_MODULES += \
     java.compiler \
+    java.scripting \
     jdk.accessibility \
     jdk.charsets \
     jdk.crypto.ec \
@@ -245,6 +249,19 @@
             $(foreach n, $(call FindDepsForModule, $m), \
                  $(call FindDepsForModule, $n))))
 
+# Upgradeable modules are those that are either defined as upgradeable or that
+# require an upradeable module.
+FindAllUpgradeableModules = \
+    $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
+        $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
+            $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
+          $(if $(filter $(UPGRADEABLE_MODULES), \
+              $(call FindTransitiveDepsForModule, $m)), \
+            $m \
+          ) \
+        )) \
+    )
+
 ################################################################################
 
 # Param 1 - Name of module
diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk
index db09eb5..cb2f96e 100644
--- a/make/common/NativeCompilation.gmk
+++ b/make/common/NativeCompilation.gmk
@@ -372,6 +372,9 @@
 #       toolchain when compiling C++ code
 #   STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it
 #   DEBUG_SYMBOLS Set to false to disable generation of debug symbols
+#   COPY_DEBUG_SYMBOLS Set to false to override global setting of debug symbol copying
+#   ZIP_EXTERNAL_DEBUG_SYMBOLS Set to false to override global setting of debug symbol
+#       zipping
 #   CFLAGS_DEBUG_SYMBOLS Overrides the default cflags for enabling debug symbols
 #   CXXFLAGS_DEBUG_SYMBOLS Overrides the default cxxflags for enabling debug symbols
 #   STRIPFLAGS Optionally change the flags given to the strip command
@@ -814,7 +817,15 @@
   # Need to make sure TARGET is first on list
   $1 := $$($1_TARGET)
 
-  ifeq ($(COPY_DEBUG_SYMBOLS), true)
+  ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
+    $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
+  endif
+
+  ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
+    $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
+  endif
+
+  ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
     ifneq ($$($1_DEBUG_SYMBOLS), false)
       # Only copy debug symbols for dynamic libraries and programs.
       ifeq ($$($1_STATIC_LIBRARY), )
@@ -861,7 +872,7 @@
         $$($1_TARGET): $$($1_DEBUGINFO_FILES)
         $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
 
-        ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+        ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
           $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
           $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
 
diff --git a/make/idea/idea.gmk b/make/idea/idea.gmk
index 329c01c..299ffe8 100644
--- a/make/idea/idea.gmk
+++ b/make/idea/idea.gmk
@@ -35,5 +35,6 @@
 	$(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT)
 	$(ECHO) "CYGPATH=\"$(CYGPATH)\"" >> $(OUT)
 	$(ECHO) "SPEC=\"$(SPEC)\"" >> $(OUT)
+	$(ECHO) "JT_HOME=\"$(JT_HOME)\"" >> $(OUT)
 
 endif
diff --git a/make/idea/template/ant.xml b/make/idea/template/ant.xml
index 6e72e47..f5274de 100644
--- a/make/idea/template/ant.xml
+++ b/make/idea/template/ant.xml
@@ -5,9 +5,8 @@
       <properties>
         <property name="boot.java.home" value="$JDKPath$" />
         <property name="jtreg.tests" value="$FilePath$" />
-        <property name="jtreg.home" value="###" />
+        <property name="jtreg.home" value="jtreg.home" />
         <property name="build.target.dir" value="specDir" /> <!-- this will be replaced --> 
-        <property name="jtreg.jpda.jvmargs" value="-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5900,suspend=y" />
         <property name="module.name" value="java.base" /> <!-- this will be replaced -->
       </properties>
       <executeOn event="afterCompilation" target="post-make" />
diff --git a/make/idea/template/build.xml b/make/idea/template/build.xml
index ed62f29..b10490f 100644
--- a/make/idea/template/build.xml
+++ b/make/idea/template/build.xml
@@ -16,6 +16,10 @@
         <os family="windows"/>
     </condition>
 
+    <target name="-check-jtreg.home" depends="-def-check">
+        <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
+    </target>
+
     <property name="test.dir" value="${basedir}/jdk/test"/>
 
     <macrodef name="call-make">
@@ -29,26 +33,6 @@
             </sequential>
         </macrodef>
 
-    <macrodef name="exec-target">
-        <attribute name="antfile" default="${ant.file}" />
-        <attribute name="target" />
-        <sequential>
-            <java classname="org.apache.tools.ant.Main" fork="true" spawn="true">
-                <arg value="-f"/>
-                <arg value="@{antfile}"/>  
-                <arg value="-Dboot.java.home=${boot.java.home}"/>
-                <arg value="-Dbuild.target.dir=${build.target.dir}"/>
-                <arg value="-Djtreg.home=${jtreg.home}"/>
-                <arg value="-Djtreg.tests=${jtreg.tests}"/>
-                <arg value="-Djtreg.jpda.jvmargs=${jtreg.jpda.jvmargs}"/>
-                <arg value="@{target}"/>
-                <classpath>           
-                    <pathelement path="${java.class.path}"/>
-                </classpath>
-            </java>
-        </sequential>
-    </macrodef>
-
     <target name="post-make" depends="build-module"/>
 
     <!--
@@ -59,7 +43,7 @@
         <echo message="base = ${basedir}"/>
         <call-make dir = "${build.target.dir}" args = "clean"/>
     </target>
-    
+
     <target name="-do-configure">
         <echo message="base = ${basedir}"/>
         <fail message="Not part of a full JDK forest">
@@ -122,5 +106,68 @@
             </sequential>
         </macrodef>
     </target>
-</project>
 
+    <macrodef name="exec-target">
+        <attribute name="antfile" default="${ant.file}" />
+        <attribute name="target" />
+        <sequential>
+            <java classname="org.apache.tools.ant.Main" fork="true" spawn="true">
+                <arg value="-f"/>
+                <arg value="@{antfile}"/>
+                <arg value="-Dbuild.target.dir=${build.target.dir}"/>
+                <arg value="-Djtreg.home=${jtreg.home}"/>
+                <arg value="-Djtreg.tests=${jtreg.tests}"/>
+                <arg value="-Djtreg.jpda.jvmargs=${jtreg.jpda.jvmargs}"/>
+                <arg value="@{target}"/>
+                <classpath>
+                    <pathelement path="${java.class.path}"/>
+                </classpath>
+            </java>
+        </sequential>
+    </macrodef>
+
+    <target name="jtreg" depends="images,-def-jtreg">
+        <jtreg-tool name="all" tests="${jtreg.tests}"/>
+    </target>
+
+    <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home">
+        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
+            <classpath>
+                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
+                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
+            </classpath>
+        </taskdef>
+        <macrodef name="jtreg-tool">
+            <attribute name="name"/>
+            <attribute name="tests"/>
+            <attribute name="jdk" default="${build.target.dir}/images/jdk"/>
+            <attribute name="agentvm" default="true"/>
+            <attribute name="verbose" default="${default.jtreg.verbose}"/>
+            <attribute name="options" default="${other.jtreg.options}"/>
+            <attribute name="keywords" default="-keywords:!ignore"/>
+            <attribute name="jpda.jvmargs" default=""/>
+            <attribute name="extra.jvmargs" default=""/>
+            <attribute name="build.modules" default="${build.modules}"/>
+            <sequential>
+                <property name="coverage.options" value=""/>              <!-- default -->
+                <property name="coverage.classpath" value=""/>            <!-- default -->
+                <property name="default.jtreg.verbose" value="summary"/>  <!-- default -->
+                <property name="other.jtreg.options" value=""/>           <!-- default -->
+                <property name="jtreg.classfiles.to.modules" value="@{agentvm}"/>
+                <jtreg
+                    dir="${test.dir}"
+                    workDir="${build.target.dir}/idea/@{name}/work"
+                    reportDir="${build.target.dir}/idea/@{name}/report"
+                    jdk="@{jdk}"
+                    agentvm="@{agentvm}" verbose="@{verbose}"
+                    failonerror="false" resultproperty="jtreg.@{name}.result">
+                    <arg value="-debug:@{jpda.jvmargs}"/>
+                    <arg line="@{keywords}"/>
+                    <arg line="@{options}"/>
+                    <arg line="@{tests}"/>
+                </jtreg>
+            </sequential>
+        </macrodef>
+        <property name="jtreg.defined" value="true"/>
+    </target>
+</project>
diff --git a/make/idea/template/src/idea/JdkIdeaAntLogger.java b/make/idea/template/src/idea/JdkIdeaAntLogger.java
index 9913499..22d42a9 100644
--- a/make/idea/template/src/idea/JdkIdeaAntLogger.java
+++ b/make/idea/template/src/idea/JdkIdeaAntLogger.java
@@ -99,7 +99,9 @@
         /** jtreg test failure */
         JTREG_TEST_FAILED(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "FAILED: "),
         /** jtreg test error */
-        JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: ");
+        JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: "),
+        /** jtreg report */
+        JTREG_TEST_REPORT(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "Report written");
 
         StringBinaryPredicate sbp;
         int priority;
@@ -132,7 +134,7 @@
         MAKE("exec", MessageKind.MAKE_ERROR, MessageKind.MAKE_WARNING, MessageKind.MAKE_NOTE,
                        MessageKind.MAKE_OTHER, MessageKind.JAVAC_CRASH),
         /** jtreg task - invoked during test execution */
-        JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR),
+        JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR, MessageKind.JTREG_TEST_REPORT),
         /** initial synthetic task when the logger is created */
         ROOT("") {
             @Override
diff --git a/make/idea/template/workspace.xml b/make/idea/template/workspace.xml
index 2423c3d..e6377dd 100644
--- a/make/idea/template/workspace.xml
+++ b/make/idea/template/workspace.xml
@@ -8,6 +8,14 @@
   <component name="StructureViewFactory">
     <option name="ACTIVE_ACTIONS" value=",ALPHA_COMPARATOR" />
   </component>
+  <component name="RunManager" selected="Ant Target.jtreg">
+    <configuration default="false" name="jtreg" type="AntRunConfiguration" factoryName="Ant Target">
+      <antsettings antfile="file://$PROJECT_DIR$/.idea/build.xml" target="jtreg" />
+      <method>
+        <option name="Make" enabled="false" />
+      </method>
+    </configuration>
+  </component>
   <component name="antWorkspaceConfiguration">
     <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
     <option name="FILTER_TARGETS" value="false" />
diff --git a/make/jprt.properties b/make/jprt.properties
index 40a75b1..93ccd1e 100644
--- a/make/jprt.properties
+++ b/make/jprt.properties
@@ -194,14 +194,15 @@
 my.build.flavors.default=fastdebug,product
 
 # Standard list of jprt build targets for this source tree
-my.build.targets.default=						\
-    solaris_sparcv9_5.11-{product|fastdebug},				\
-    solaris_x64_5.11-{product|fastdebug},				\
-    linux_i586_3.8-{product|fastdebug},					\
-    linux_x64_3.8-{product|fastdebug},					\
-    macosx_x64_10.9-{product|fastdebug},				\
-    windows_i586_6.3-{product|fastdebug},				\
-    windows_x64_6.3-{product|fastdebug}
+my.build.targets.default= \
+    solaris_sparcv9_5.11-{product|fastdebug}, \
+    solaris_x64_5.11-{product|fastdebug}, \
+    linux_i586_3.8-{product|fastdebug}, \
+    linux_x64_3.8-{product|fastdebug}, \
+    macosx_x64_10.9-{product|fastdebug}, \
+    windows_i586_6.3-{product|fastdebug}, \
+    windows_x64_6.3-{product|fastdebug}, \
+    ${my.additional.build.targets.default}
 
 # Test target list (no fastdebug & limited c2 testing)
 my.test.target.set=							\
@@ -438,6 +439,16 @@
   windows_i586_6.3-*-default-hotspot_basicvmtest,                       \
   windows_x64_6.3-*-default-hotspot_basicvmtest
 
+my.make.rule.test.targets.hotspot.gtest= \
+  linux_i586_3.8-*-default-hotspot_gtest, \
+  linux_x64_3.8-*-default-hotspot_gtest, \
+  macosx_x64_10.9-*-default-hotspot_gtest, \
+  solaris_sparcv9_5.11-*-default-hotspot_gtest, \
+  solaris_x64_5.11-*-default-hotspot_gtest, \
+  windows_i586_6.3-*-default-hotspot_gtest, \
+  windows_x64_6.3-*-default-hotspot_gtest, \
+  ${my.additional.make.rule.test.targets.hotspot.gtest}
+
 my.make.rule.test.targets.hotspot.reg.group=				\
   solaris_sparcv9_5.11-fastdebug-c2-GROUP,				\
   solaris_x64_5.11-fastdebug-c2-GROUP,					\
@@ -465,6 +476,7 @@
 # Other Makefile based Hotspot tests
 my.make.rule.test.targets.hotspot.other=                                \
   ${my.make.rule.test.targets.hotspot.basicvmtests},                    \
+  ${my.make.rule.test.targets.hotspot.gtest},                           \
   ${my.additional.make.rule.test.targets.hotspot.other}
 
 # All the makefile based tests to run
@@ -474,7 +486,9 @@
 
 # Install the test bundle for the testset hotspot jtreg tests
 # (but not for the other Makefile based tests)
-my.jprt.test.bundle.targets.hotspot=${my.make.rule.test.targets.hotspot.reg}
+my.jprt.test.bundle.targets.hotspot= \
+  ${my.make.rule.test.targets.hotspot.reg}, \
+  ${my.make.rule.test.targets.hotspot.gtest}
 
 # Native jdk and hotspot test targets (testset=nativesanity)
 my.make.rule.test.targets.nativesanity=					\
diff --git a/nashorn/.hgtags b/nashorn/.hgtags
index 2140054..4aa4df6 100644
--- a/nashorn/.hgtags
+++ b/nashorn/.hgtags
@@ -352,3 +352,4 @@
 208388a5622dcca8227d6ad6c268f2c88087d283 jdk-9+116
 5267e91811614bac129817e566f730e9d63cf22a jdk-9+117
 05679aac2f7ec3d8dd2a96d7e7899906224bf5cf jdk-9+118
+621ad507bf9b07e7c6da2150aa619fe7e78ec5a0 jdk-9+119
diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java
index 9eb9f47..9f3380c 100644
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java
@@ -280,6 +280,7 @@
         addField(cv, name, OBJECT_DESC);
     }
 
+    @SuppressWarnings("deprecation")
     static void newFunction(final MethodGenerator mi, final String objName, final String className, final MemberInfo memInfo, final List<MemberInfo> specs) {
         final boolean arityFound = (memInfo.getArity() != MemberInfo.DEFAULT_ARITY);
 
@@ -305,6 +306,7 @@
         mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATIONKEY, SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC);
     }
 
+    @SuppressWarnings("deprecation")
     static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) {
         final String propertyName = memInfo.getName();
         // stack: Collection
@@ -334,6 +336,7 @@
         // stack: Collection
     }
 
+    @SuppressWarnings("deprecation")
     static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) {
         final String propertyName = getter.getName();
         // stack: Collection
diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java
index 73bb21d..2d9cf74 100644
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java
@@ -178,6 +178,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private void callSuper(final MethodGenerator mi) {
         String superClass, superDesc;
         mi.loadThis();
diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java
index a4a906b..aecd9c5 100644
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java
@@ -390,6 +390,7 @@
         return EMPTY_LINK_LOGIC_TYPE.equals(type);
     }
 
+    @SuppressWarnings("deprecation")
     void memberInfoArray(final String className, final List<MemberInfo> mis) {
         if (mis.isEmpty()) {
             pushNull();
diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml
index 0f255e2..9aced2f 100644
--- a/nashorn/make/build.xml
+++ b/nashorn/make/build.xml
@@ -775,20 +775,16 @@
   <!-- octane benchmark -->
   <target name="get-octane" depends="init" unless="${test-sys-prop.external.octane}">
     <!-- checkout octane benchmarks -->
-    <exec executable="${svn.executable}">
-       <arg value="--non-interactive"/>
-       <arg value="--trust-server-cert"/>
-       <arg value="checkout"/>
-       <arg value="http://octane-benchmark.googlecode.com/svn/trunk/"/>
+    <exec executable="${git.executable}">
+       <arg value="clone"/>
+       <arg value="https://github.com/chromium/octane"/>
        <arg value="${test.external.dir}/octane"/>
     </exec>
   </target>
   <target name="update-octane" depends="init" if="${test-sys-prop.external.octane}">
     <!-- update octane benchmarks -->
-    <exec executable="${svn.executable}" dir="${test.external.dir}/octane">
-       <arg value="--non-interactive"/>
-       <arg value="--trust-server-cert"/>
-       <arg value="update"/>
+    <exec executable="${git.executable}" dir="${test.external.dir}/octane">
+       <arg value="pull"/>
     </exec>
   </target>
 
diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java
index 9b580f1..3f98c2b 100644
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,7 @@
             // Some languages won't have a notion of manipulating collections. Exposing "length" on arrays as an
             // explicit property is beneficial for them.
             // REVISIT: is it maybe a code smell that StandardOperation.GET_LENGTH is not needed?
-            setPropertyGetter("length", GET_ARRAY_LENGTH, ValidationType.IS_ARRAY);
+            setPropertyGetter("length", MethodHandles.arrayLength(clazz), ValidationType.EXACT_CLASS);
         } else if(List.class.isAssignableFrom(clazz)) {
             setPropertyGetter("length", GET_COLLECTION_LENGTH, ValidationType.INSTANCE_OF);
         }
@@ -518,9 +518,6 @@
                 gic.getValidatorClass(), gic.getValidationType());
     }
 
-    private static final MethodHandle GET_ARRAY_LENGTH = Lookup.PUBLIC.findStatic(Array.class, "getLength",
-            MethodType.methodType(int.class, Object.class));
-
     private static final MethodHandle GET_COLLECTION_LENGTH = Lookup.PUBLIC.findVirtual(Collection.class, "size",
             MethodType.methodType(int.class));
 
@@ -537,7 +534,7 @@
         // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
         // they're dealing with an array, collection, or map, but hey...
         if(declaredType.isArray()) {
-            return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
+            return new GuardedInvocationComponent(MethodHandles.arrayLength(declaredType).asType(callSiteType));
         } else if(Collection.class.isAssignableFrom(declaredType)) {
             return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
         } else if(Map.class.isAssignableFrom(declaredType)) {
@@ -546,8 +543,8 @@
 
         // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
         if(clazz.isArray()) {
-            return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
-                    callSiteType), ValidationType.IS_ARRAY);
+            return new GuardedInvocationComponent(MethodHandles.arrayLength(clazz).asType(callSiteType),
+                    Guards.isArray(0, callSiteType), ValidationType.EXACT_CLASS);
         } if(Collection.class.isAssignableFrom(clazz)) {
             return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                     COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java
index 51fa2d8..467da4b 100644
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java
@@ -88,9 +88,11 @@
 import java.lang.invoke.MethodType;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Executable;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.Module;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -98,6 +100,9 @@
 import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.internal.AccessControlContextFactory;
 import jdk.dynalink.linker.support.Lookup;
+import jdk.internal.module.Modules;
+import jdk.internal.reflect.CallerSensitive;
+
 
 /**
  * A dynamic method bound to exactly one Java method or constructor that is caller sensitive. Since the target method is
@@ -159,13 +164,13 @@
                 GET_LOOKUP_CONTEXT);
 
         if(target instanceof Method) {
-            final MethodHandle mh = Lookup.unreflectCallerSensitive(lookup, (Method)target);
+            final MethodHandle mh = unreflect(lookup, (Method)target);
             if(Modifier.isStatic(((Member)target).getModifiers())) {
                 return StaticClassIntrospector.editStaticMethodHandle(mh);
             }
             return mh;
         }
-        return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructorCallerSensitive(lookup,
+        return StaticClassIntrospector.editConstructorMethodHandle(unreflectConstructor(lookup,
                 (Constructor<?>)target));
     }
 
@@ -173,4 +178,59 @@
     boolean isConstructor() {
         return target instanceof Constructor;
     }
+
+    private static MethodHandle unreflect(final MethodHandles.Lookup lookup, final Method m) {
+        try {
+            return Lookup.unreflect(lookup, m);
+        } catch (final IllegalAccessError iae) {
+            if (addModuleRead(lookup, m)) {
+                try {
+                    return Lookup.unreflect(lookup, m);
+                } catch (final IllegalAccessError e2) {
+                    // fall through and throw original error as cause
+                }
+            }
+            throw iae;
+        }
+    }
+
+    private static MethodHandle unreflectConstructor(final MethodHandles.Lookup lookup, final Constructor<?> c) {
+        try {
+            return Lookup.unreflectConstructor(lookup, c);
+        } catch (final IllegalAccessError iae) {
+            if (addModuleRead(lookup, c)) {
+                try {
+                    return Lookup.unreflectConstructor(lookup, c);
+                } catch (final IllegalAccessError e2) {
+                    // fall through and throw original error as cause
+                }
+            }
+            throw iae;
+        }
+    }
+
+
+    private static boolean addModuleRead(final MethodHandles.Lookup lookup, final Executable e) {
+        // Don't add module read link if this is not a CallerSensitive member
+        if (!e.isAnnotationPresent(CallerSensitive.class)) {
+            return false;
+        }
+
+        // If the lookup is public lookup, don't bother adding module read link!
+        // public lookup cannot unreflect caller sensitives anyway!
+        if (lookup == MethodHandles.publicLookup()) {
+            return false;
+        }
+
+        // try to add missing module read from using module to declararing module!
+        final Class<?> declClass = e.getDeclaringClass();
+        final Module useModule = lookup.lookupClass().getModule();
+        final Module declModule = declClass.getModule();
+        if (useModule != null && declModule != null && declModule.isExported(declClass.getPackageName())) {
+            Modules.addReads(useModule, declModule);
+            return true;
+        }
+
+        return false;
+    }
 }
diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java
index adafcaa..b996821 100644
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java
@@ -91,7 +91,6 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.Module;
 import java.lang.reflect.Method;
-import jdk.internal.module.Modules;
 
 /**
  * A wrapper around {@link java.lang.invoke.MethodHandles.Lookup} that masks
@@ -130,42 +129,6 @@
         return unreflect(lookup, m);
     }
 
-    private static boolean addModuleRead(final MethodHandles.Lookup lookup, final Executable e) {
-        // may be module read missing from a script class!
-        final Class<?> declClass = e.getDeclaringClass();
-        final Module from = lookup.lookupClass().getModule();
-        final Module to = declClass.getModule();
-        if (from != null && to != null) {
-            Modules.addReads(from, to);
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Performs a {@link java.lang.invoke.MethodHandles.Lookup#unreflect(Method)}, of a caller sensitive method
-     * converting any encountered {@link IllegalAccessException} into an {@link IllegalAccessError}.
-     *
-     * @param lookup the lookup used to unreflect
-     * @param m the method to unreflect
-     * @return the unreflected method handle.
-     */
-    public static MethodHandle unreflectCallerSensitive(final MethodHandles.Lookup lookup, final Method m) {
-        try {
-            return unreflect(lookup, m);
-        } catch (final IllegalAccessError iae) {
-            if (addModuleRead(lookup, m)) {
-                try {
-                    return unreflect(lookup, m);
-                } catch (final IllegalAccessError e2) {
-                    // fall through and throw original error as cause
-                }
-            }
-            throw iae;
-        }
-    }
-
     /**
      * Performs a {@link java.lang.invoke.MethodHandles.Lookup#unreflect(Method)},
      * converting any encountered {@link IllegalAccessException} into an
@@ -267,29 +230,6 @@
     }
 
     /**
-     * Performs a caller sensitive {@link java.lang.invoke.MethodHandles.Lookup#unreflectConstructor(Constructor)}, converting any
-     * encountered {@link IllegalAccessException} into an {@link IllegalAccessError}.
-     *
-     * @param lookup the lookup used to unreflect
-     * @param c the constructor to unreflect
-     * @return the unreflected constructor handle.
-     */
-    public static MethodHandle unreflectConstructorCallerSensitive(final MethodHandles.Lookup lookup, final Constructor<?> c) {
-        try {
-            return unreflectConstructor(lookup, c);
-        } catch (final IllegalAccessError iae) {
-            if (addModuleRead(lookup, c)) {
-                try {
-                    return unreflectConstructor(lookup, c);
-                } catch (final IllegalAccessError e2) {
-                    // fall through and throw original error as cause
-                }
-            }
-            throw iae;
-        }
-    }
-
-    /**
      * Performs a {@link java.lang.invoke.MethodHandles.Lookup#unreflectConstructor(Constructor)},
      * converting any encountered {@link IllegalAccessException} into an
      * {@link IllegalAccessError}.
diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java
index 0c9b070..49408b4 100644
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java
@@ -30,12 +30,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
+import java.io.Writer;
+import java.nio.file.Files;
 import java.util.function.Function;
+import java.util.stream.Collectors;
 import jdk.internal.jline.NoInterruptUnixTerminal;
 import jdk.internal.jline.Terminal;
 import jdk.internal.jline.TerminalFactory;
@@ -43,23 +41,29 @@
 import jdk.internal.jline.WindowsTerminal;
 import jdk.internal.jline.console.ConsoleReader;
 import jdk.internal.jline.console.KeyMap;
-import jdk.internal.jline.console.completer.Completer;
-import jdk.internal.jline.console.history.FileHistory;
+import jdk.internal.jline.extra.EditingHistory;
 
 class Console implements AutoCloseable {
     private static final String DOCUMENTATION_SHORTCUT = "\033\133\132"; //Shift-TAB
     private final ConsoleReader in;
-    private final FileHistory history;
+    private final File historyFile;
 
     Console(final InputStream cmdin, final PrintStream cmdout, final File historyFile,
-            final Completer completer, final Function<String, String> docHelper) throws IOException {
+            final NashornCompleter completer, final Function<String, String> docHelper) throws IOException {
+        this.historyFile = historyFile;
+
         TerminalFactory.registerFlavor(Flavor.WINDOWS, isCygwin()? JJSUnixTerminal::new : JJSWindowsTerminal::new);
         TerminalFactory.registerFlavor(Flavor.UNIX, JJSUnixTerminal::new);
         in = new ConsoleReader(cmdin, cmdout);
         in.setExpandEvents(false);
         in.setHandleUserInterrupt(true);
         in.setBellEnabled(true);
-        in.setHistory(history = new FileHistory(historyFile));
+        in.setCopyPasteDetection(true);
+        in.setHistory(new EditingHistory(in, Files.readAllLines(historyFile.toPath())) {
+            @Override protected boolean isComplete(CharSequence input) {
+                return completer.isComplete(input.toString());
+            }
+        });
         in.addCompleter(completer);
         Runtime.getRuntime().addShutdownHook(new Thread((Runnable)this::saveHistory));
         bind(DOCUMENTATION_SHORTCUT, (ActionListener)evt -> showDocumentation(docHelper));
@@ -75,13 +79,17 @@
     }
 
     private void saveHistory() {
-        try {
-            getHistory().flush();
+        try (Writer out = Files.newBufferedWriter(historyFile.toPath())) {
+            String lineSeparator = System.getProperty("line.separator");
+
+            out.write(getHistory().save()
+                                  .stream()
+                                  .collect(Collectors.joining(lineSeparator)));
         } catch (final IOException exp) {}
     }
 
-    FileHistory getHistory() {
-        return (FileHistory) in.getHistory();
+    EditingHistory getHistory() {
+        return (EditingHistory) in.getHistory();
     }
 
     boolean terminalEditorRunning() {
diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java
index e7ae0db..c8b7c10 100644
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java
@@ -36,7 +36,6 @@
 import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Supplier;
-import jdk.internal.jline.console.history.FileHistory;
 import jdk.internal.jline.console.history.History;
 import jdk.nashorn.api.scripting.AbstractJSObject;
 import jdk.nashorn.api.scripting.JSObject;
@@ -61,11 +60,11 @@
         props = Collections.unmodifiableSet(s);
     }
 
-    private final FileHistory hist;
+    private final History hist;
     private final PrintWriter err;
     private final Consumer<String> evaluator;
 
-    HistoryObject(final FileHistory hist, final PrintWriter err,
+    HistoryObject(final History hist, final PrintWriter err,
             final Consumer<String> evaluator) {
         this.hist = hist;
         this.err = err;
diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java
index 521bb6e..65c5e28 100644
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java
@@ -185,6 +185,22 @@
         }
     }
 
+    public boolean isComplete(String input) {
+        try {
+            parser.parse("<shell>", input, null);
+        } catch (final Exception pexp) {
+            // Do we have a parse error at the end of current line?
+            // If so, read more lines from the console.
+            int line = input.split("\n").length;
+            int lastLineLen = input.length() - (input.lastIndexOf("\n") + 1);
+
+            if (isParseErrorAt(pexp, line, lastLineLen)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     // Pattern to match a unfinished member selection expression. object part and "."
     // but property name missing pattern.
     private static final Pattern SELECT_PROP_MISSING = Pattern.compile(".*\\.\\s*");
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java
index 9c0385d..6d92c68 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java
@@ -170,9 +170,11 @@
     }
 
     /** Bootstrap for normal indy:s */
+    @SuppressWarnings("deprecation")
     private static final Handle LINKERBOOTSTRAP  = new Handle(H_INVOKESTATIC, Bootstrap.BOOTSTRAP.className(), Bootstrap.BOOTSTRAP.name(), Bootstrap.BOOTSTRAP.descriptor());
 
     /** Bootstrap for array populators */
+    @SuppressWarnings("deprecation")
     private static final Handle POPULATE_ARRAY_BOOTSTRAP = new Handle(H_INVOKESTATIC, RewriteException.BOOTSTRAP.className(), RewriteException.BOOTSTRAP.name(), RewriteException.BOOTSTRAP.descriptor());
 
     /**
@@ -1005,6 +1007,7 @@
      *
      * @return the method emitter
      */
+    @SuppressWarnings("deprecation")
     MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
         debug("load handle ");
         pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
index ea64550..fba4d56 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
@@ -2839,6 +2839,7 @@
             sb.append("$Constructor");
 
             final Class<?> funcClass = Class.forName(sb.toString());
+            @SuppressWarnings("deprecation")
             final T res = clazz.cast(funcClass.newInstance());
 
             if (res instanceof ScriptFunction) {
@@ -2866,6 +2867,7 @@
             final String className = PACKAGE_PREFIX + name + "$Prototype";
 
             final Class<?> funcClass = Class.forName(className);
+            @SuppressWarnings("deprecation")
             final ScriptObject res = (ScriptObject) funcClass.newInstance();
 
             res.setIsBuiltin();
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java
index 4a27c1f..bfb8f10 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java
@@ -232,10 +232,10 @@
     }
 
     ByteBuffer getBuffer(final int offset) {
-        return (ByteBuffer)nb.duplicate().position(offset);
+        return nb.duplicate().position(offset);
     }
 
     ByteBuffer getBuffer(final int offset, final int length) {
-        return (ByteBuffer)getBuffer(offset).limit(length);
+        return getBuffer(offset).limit(length);
     }
 }
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java
index bc0d68b..0f67ec4 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java
@@ -81,7 +81,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Float32ArrayData.class, "setElem", void.class, int.class, double.class).methodHandle();
 
         private Float32ArrayData(final FloatBuffer nb, final int start, final int end) {
-            super(((FloatBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java
index cf7a15a..de3d0f0 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java
@@ -81,7 +81,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Float64ArrayData.class, "setElem", void.class, int.class, double.class).methodHandle();
 
         private Float64ArrayData(final DoubleBuffer nb, final int start, final int end) {
-            super(((DoubleBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java
index dce5174..735e6a3 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java
@@ -82,7 +82,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Int16ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
 
         private Int16ArrayData(final ShortBuffer nb, final int start, final int end) {
-            super(((ShortBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java
index 877e27a..7eacedc 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java
@@ -81,7 +81,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Int32ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
 
         private Int32ArrayData(final IntBuffer nb, final int start, final int end) {
-            super(((IntBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java
index 9f146dd..75fde20 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java
@@ -80,7 +80,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Int8ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
 
         private Int8ArrayData(final ByteBuffer nb, final int start, final int end) {
-            super(((ByteBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java
index edf59c7..b5e139c 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java
@@ -35,7 +35,10 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.Callable;
+import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Function;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
@@ -68,6 +71,17 @@
                 });
     }
 
+    private static final Object JSOBJECT_INVOKER = new Object();
+
+    private static MethodHandle getJSOBJECT_INVOKER() {
+        return Global.instance().getDynamicInvoker(JSOBJECT_INVOKER,
+                new Callable<MethodHandle>() {
+                    @Override
+                    public MethodHandle call() {
+                        return Bootstrap.createDynamicCallInvoker(Object.class, Object.class, Object.class);
+                    }
+                });
+    }
 
     private static final Object REPLACER_INVOKER = new Object();
 
@@ -77,7 +91,7 @@
                     @Override
                     public MethodHandle call() {
                         return Bootstrap.createDynamicCallInvoker(Object.class,
-                            ScriptFunction.class, ScriptObject.class, Object.class, Object.class);
+                            Object.class, Object.class, Object.class, Object.class);
                     }
                 });
     }
@@ -127,9 +141,10 @@
         final StringifyState state = new StringifyState();
 
         // If there is a replacer, it must be a function or an array.
-        if (replacer instanceof ScriptFunction) {
-            state.replacerFunction = (ScriptFunction) replacer;
+        if (Bootstrap.isCallable(replacer)) {
+            state.replacerFunction = replacer;
         } else if (isArray(replacer) ||
+                isJSObjectArray(replacer) ||
                 replacer instanceof Iterable ||
                 (replacer != null && replacer.getClass().isArray())) {
 
@@ -201,18 +216,19 @@
     // stringify helpers.
 
     private static class StringifyState {
-        final Map<ScriptObject, ScriptObject> stack = new IdentityHashMap<>();
+        final Map<Object, Object> stack = new IdentityHashMap<>();
 
         StringBuilder  indent = new StringBuilder();
         String         gap = "";
         List<String>   propertyList = null;
-        ScriptFunction replacerFunction = null;
+        Object         replacerFunction = null;
     }
 
     // Spec: The abstract operation Str(key, holder).
-    private static Object str(final Object key, final ScriptObject holder, final StringifyState state) {
-        Object value = holder.get(key);
+    private static Object str(final Object key, final Object holder, final StringifyState state) {
+        assert holder instanceof ScriptObject || holder instanceof JSObject;
 
+        Object value = getProperty(holder, key);
         try {
             if (value instanceof ScriptObject) {
                 final InvokeByName toJSONInvoker = getTO_JSON();
@@ -221,6 +237,12 @@
                 if (Bootstrap.isCallable(toJSON)) {
                     value = toJSONInvoker.getInvoker().invokeExact(toJSON, svalue, key);
                 }
+            } else if (value instanceof JSObject) {
+                final JSObject jsObj = (JSObject)value;
+                final Object toJSON = jsObj.getMember("toJSON");
+                if (Bootstrap.isCallable(toJSON)) {
+                    value = getJSOBJECT_INVOKER().invokeExact(toJSON, value);
+                }
             }
 
             if (state.replacerFunction != null) {
@@ -262,10 +284,10 @@
 
         final JSType type = JSType.of(value);
         if (type == JSType.OBJECT) {
-            if (isArray(value)) {
-                return JA((ScriptObject)value, state);
-            } else if (value instanceof ScriptObject) {
-                return JO((ScriptObject)value, state);
+            if (isArray(value) || isJSObjectArray(value)) {
+                return JA(value, state);
+            } else if (value instanceof ScriptObject || value instanceof JSObject) {
+                return JO(value, state);
             }
         }
 
@@ -273,7 +295,9 @@
     }
 
     // Spec: The abstract operation JO(value) serializes an object.
-    private static String JO(final ScriptObject value, final StringifyState state) {
+    private static String JO(final Object value, final StringifyState state) {
+        assert value instanceof ScriptObject || value instanceof JSObject;
+
         if (state.stack.containsKey(value)) {
             throw typeError("JSON.stringify.cyclic");
         }
@@ -284,7 +308,8 @@
 
         final StringBuilder finalStr = new StringBuilder();
         final List<Object>  partial  = new ArrayList<>();
-        final List<String>  k        = state.propertyList == null ? Arrays.asList(value.getOwnKeys(false)) : state.propertyList;
+        final List<String>  k        = state.propertyList == null ?
+                Arrays.asList(getOwnKeys(value)) : state.propertyList;
 
         for (final Object p : k) {
             final Object strP = str(p, value, state);
@@ -349,7 +374,9 @@
     }
 
     // Spec: The abstract operation JA(value) serializes an array.
-    private static Object JA(final ScriptObject value, final StringifyState state) {
+    private static Object JA(final Object value, final StringifyState state) {
+        assert value instanceof ScriptObject || value instanceof JSObject;
+
         if (state.stack.containsKey(value)) {
             throw typeError("JSON.stringify.cyclic");
         }
@@ -359,7 +386,7 @@
         state.indent.append(state.gap);
         final List<Object> partial = new ArrayList<>();
 
-        final int length = JSType.toInteger(value.getLength());
+        final int length = JSType.toInteger(getLength(value));
         int index = 0;
 
         while (index < length) {
@@ -413,4 +440,48 @@
 
         return finalStr.toString();
     }
+
+    private static String[] getOwnKeys(final Object obj) {
+        if (obj instanceof ScriptObject) {
+            return ((ScriptObject)obj).getOwnKeys(false);
+        } else if (obj instanceof ScriptObjectMirror) {
+            return ((ScriptObjectMirror)obj).getOwnKeys(false);
+        } else if (obj instanceof JSObject) {
+            // No notion of "own keys" or "proto" for general JSObject! We just
+            // return all keys of the object. This will be useful for POJOs
+            // implementing JSObject interface.
+            return ((JSObject)obj).keySet().toArray(new String[0]);
+        } else {
+            throw new AssertionError("should not reach here");
+        }
+    }
+
+    private static Object getLength(final Object obj) {
+        if (obj instanceof ScriptObject) {
+            return ((ScriptObject)obj).getLength();
+        } else if (obj instanceof JSObject) {
+            return ((JSObject)obj).getMember("length");
+        } else {
+            throw new AssertionError("should not reach here");
+        }
+    }
+
+    private static boolean isJSObjectArray(final Object obj) {
+        return (obj instanceof JSObject) && ((JSObject)obj).isArray();
+    }
+
+    private static Object getProperty(final Object holder, final Object key) {
+        if (holder instanceof ScriptObject) {
+            return ((ScriptObject)holder).get(key);
+        } else if (holder instanceof JSObject) {
+            JSObject jsObj = (JSObject)holder;
+            if (key instanceof Integer) {
+                return jsObj.getSlot((Integer)key);
+            } else {
+                return jsObj.getMember(Objects.toString(key));
+            }
+        } else {
+            return new AssertionError("should not reach here");
+        }
+    }
 }
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java
index d0b3e05..fb3a667 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java
@@ -81,7 +81,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint16ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
 
         private Uint16ArrayData(final CharBuffer nb, final int start, final int end) {
-            super(((CharBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java
index 6760bda..4d691b2 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java
@@ -84,7 +84,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
 
         private Uint32ArrayData(final IntBuffer nb, final int start, final int end) {
-            super(((IntBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java
index 5f76f8f..229099e 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java
@@ -81,7 +81,7 @@
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint8ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
 
         private Uint8ArrayData(final ByteBuffer nb, final int start, final int end) {
-            super(((ByteBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
index 485349b..905d99f 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
@@ -85,7 +85,7 @@
         private static final MethodHandle CLAMP_LONG = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "clampLong", long.class, long.class).methodHandle();
 
         private Uint8ClampedArrayData(final ByteBuffer nb, final int start, final int end) {
-            super(((ByteBuffer)nb.position(start).limit(end)).slice(), end - start);
+            super((nb.position(start).limit(end)).slice(), end - start);
         }
 
         @Override
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java
index 6527f6b..c8936ef 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java
@@ -2070,6 +2070,7 @@
         }
     }
 
+    @SuppressWarnings("fallthrough")
     private boolean lookaheadIsLetDeclaration(final boolean ofContextualKeyword) {
         assert type == LET;
         for (int i = 1;; i++) {
@@ -2323,6 +2324,7 @@
      *   yield [no LineTerminator here] AssignmentExpression[?In, Yield]
      *   yield [no LineTerminator here] * AssignmentExpression[?In, Yield]
      */
+    @SuppressWarnings("fallthrough")
     private Expression yieldExpression(final boolean noIn) {
         assert inGeneratorFunction();
         // Capture YIELD token.
@@ -2838,6 +2840,7 @@
      * Parse array literal.
      * @return Expression node.
      */
+    @SuppressWarnings("fallthrough")
     private LiteralNode<Expression[]> arrayLiteral() {
         // Capture LBRACKET token.
         final long arrayToken = token;
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java
index 59389e9..8dd697f6 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java
@@ -173,12 +173,14 @@
     private static final Call RUN = interfaceCallNoLookup(Runnable.class, "run", void.class);
 
     // ASM handle to the bootstrap method
+    @SuppressWarnings("deprecation")
     private static final Handle BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC,
             Type.getInternalName(JavaAdapterServices.class), "bootstrap",
             MethodType.methodType(CallSite.class, Lookup.class, String.class,
                     MethodType.class, int.class).toMethodDescriptorString());
 
     // ASM handle to the bootstrap method for array populator
+    @SuppressWarnings("deprecation")
     private static final Handle CREATE_ARRAY_BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC,
             Type.getInternalName(JavaAdapterServices.class), "createArrayBootstrap",
             MethodType.methodType(CallSite.class, Lookup.class, String.class,
@@ -1048,6 +1050,7 @@
         endMethod(mv);
     }
 
+    @SuppressWarnings("deprecation")
     private void generateFinalizerOverride() {
         final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize",
                 VOID_METHOD_DESCRIPTOR, null, null));
diff --git a/nashorn/test/Makefile b/nashorn/test/Makefile
index d4f5afe..ee2b874 100644
--- a/nashorn/test/Makefile
+++ b/nashorn/test/Makefile
@@ -301,7 +301,10 @@
 endif
 
 ifdef CONCURRENCY
-  EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
+  JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+endif
+ifdef EXTRA_JTREG_OPTIONS
+  JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 endif
 
 # Default JTREG to run
@@ -328,8 +331,6 @@
 JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION)
 # Give tests access to JT_JAVA, see JDK-8141609
 JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA}
-# Add any extra options
-JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 # Set other vm and test options
 JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%)
 # Set the GC options for test vms
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/nashorn/test/script/basic/JDK-8066229.js
similarity index 71%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to nashorn/test/script/basic/JDK-8066229.js
index 135652e..2f98f57 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/nashorn/test/script/basic/JDK-8066229.js
@@ -1,32 +1,42 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ * 
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- *
+ * 
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- *
+ * 
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
+ * 
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package sun.misc;
+/**
+ * JDK-8066229: Fuzzing bug: Can't find scope depth
+ *
+ * @test
+ * @run
+ */
 
-public class Unsafe {
-    private Unsafe() { }
+function f() { x; throw null; (function (){ var x; }); }
 
-    public static long getLong(long address) {
-        return 0L;
+try {
+    f();
+    throw new Error("Expected error");
+} catch (e) {
+    if (!(e instanceof ReferenceError)) {
+        throw new Error("Unexpected error: " + e);
     }
 }
+
+
diff --git a/nashorn/test/script/basic/JDK-8157160.js b/nashorn/test/script/basic/JDK-8157160.js
new file mode 100644
index 0000000..28077cd
--- /dev/null
+++ b/nashorn/test/script/basic/JDK-8157160.js
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8157160: JSON.stringify does not work on ScriptObjectMirror objects
+ *
+ * @test
+ * @option -scripting
+ * @run
+ */
+
+var SM = Java.type("javax.script.ScriptEngineManager");
+var AJSO = Java.type("jdk.nashorn.api.scripting.AbstractJSObject");
+var Supplier = Java.type("java.util.function.Supplier");
+
+var engine = new SM().getEngineByName("nashorn");
+
+// JSON stringify ScriptObjectMirror instances
+print(JSON.stringify(engine.eval("({ foo : 42 })")));
+print(JSON.stringify(engine.eval("([5, 6, 76, 7])")));
+print(JSON.stringify(engine.eval(<<EOF
+ ({
+     toJSON: function() "hello"
+ })
+EOF
+)));
+
+print(JSON.stringify(engine.eval(<<EOF
+obj = {
+    name: 'nashorn',
+    versions: [ 'es5.1', 'es6' ]
+}
+EOF
+)));
+
+var dm = engine.eval("new Date()");
+print('"' + dm.toJSON() + '"' == JSON.stringify(dm));
+
+// JSON stringifying an arbitrary JSObject impl.
+var jsObj = new AJSO() {
+    keySet: function() {
+        var keys = new java.util.HashSet();
+        keys.add("x");
+        keys.add("y");
+        return keys;
+    },
+
+    getMember: function(name) {
+        if (name == "x") {
+            return 42;
+        } else if (name == "y") {
+            return "hello";
+        }
+    }
+};
+print(JSON.stringify(jsObj));
+
+// try toJSON implementation on JSObject
+var jsObj2 = new AJSO() {
+    getMember: function(name) {
+        if (name == 'toJSON') {
+            return function() {
+                return "my json representation";
+            }
+        }
+    }
+};
+print(JSON.stringify(jsObj2));
+
+var jsObj3 = new AJSO() {
+    getMember: function(name) {
+        if (name == 'toJSON') {
+            return new Supplier() {
+                "get": function() {
+                    return "value from toJSON function";
+                }
+            };
+        }
+    }
+};
+print(JSON.stringify(jsObj3));
+
+// replacer function from another script world
+print(JSON.stringify({
+   foo: "hello"
+}, engine.eval(<<EOF
+    function (key, value) {
+       if (key == "foo") {
+           return value.toUpperCase()
+       }
+       return value;
+    }
+EOF)));
diff --git a/nashorn/test/script/basic/JDK-8157160.js.EXPECTED b/nashorn/test/script/basic/JDK-8157160.js.EXPECTED
new file mode 100644
index 0000000..e39fb75
--- /dev/null
+++ b/nashorn/test/script/basic/JDK-8157160.js.EXPECTED
@@ -0,0 +1,9 @@
+{"foo":42}
+[5,6,76,7]
+"hello"
+{"name":"nashorn","versions":["es5.1","es6"]}
+true
+{"x":42,"y":"hello"}
+"my json representation"
+"value from toJSON function"
+{"foo":"HELLO"}
diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/nashorn/test/script/basic/JDK-8157250.js
similarity index 75%
copy from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
copy to nashorn/test/script/basic/JDK-8157250.js
index 135652e..b392a0d 100644
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
+++ b/nashorn/test/script/basic/JDK-8157250.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,14 @@
  * questions.
  */
 
-package sun.misc;
+/**
+ * JDK-8157250: BeanLinker assumes fixed array type linkage
+ *
+ * @test
+ * @run
+ */
 
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
+var intArray = Java.type("int[]")
+var doubleArray = Java.type("double[]")
+var arrs = [new intArray(0), new doubleArray(0)]
+for (var i in arrs) arrs[i].length
diff --git a/nashorn/test/script/nosecurity/JDK-8144221.js b/nashorn/test/script/currently-failing/JDK-8144221.js
similarity index 100%
rename from nashorn/test/script/nosecurity/JDK-8144221.js
rename to nashorn/test/script/currently-failing/JDK-8144221.js
diff --git a/nashorn/test/script/nosecurity/JDK-8144221.js.EXPECTED b/nashorn/test/script/currently-failing/JDK-8144221.js.EXPECTED
similarity index 100%
rename from nashorn/test/script/nosecurity/JDK-8144221.js.EXPECTED
rename to nashorn/test/script/currently-failing/JDK-8144221.js.EXPECTED
diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java
index c6f5c2d..3a992f7 100644
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java
@@ -172,7 +172,7 @@
     }
 
     // @bug 8032948: Nashorn linkages awry
-    @SuppressWarnings("serial")
+    @SuppressWarnings({ "serial", "deprecation" })
     public static class FakeProxy extends Proxy {
         public FakeProxy(final InvocationHandler ih) {
             super(ih);
diff --git a/test/fmw/gtest/CHANGES b/test/fmw/gtest/CHANGES
new file mode 100644
index 0000000..0552132
--- /dev/null
+++ b/test/fmw/gtest/CHANGES
@@ -0,0 +1,157 @@
+Changes for 1.7.0:
+
+* New feature: death tests are supported on OpenBSD and in iOS
+  simulator now.
+* New feature: Google Test now implements a protocol to allow
+  a test runner to detect that a test program has exited
+  prematurely and report it as a failure (before it would be
+  falsely reported as a success if the exit code is 0).
+* New feature: Test::RecordProperty() can now be used outside of the
+  lifespan of a test method, in which case it will be attributed to
+  the current test case or the test program in the XML report.
+* New feature (potentially breaking): --gtest_list_tests now prints
+  the type parameters and value parameters for each test.
+* Improvement: char pointers and char arrays are now escaped properly
+  in failure messages.
+* Improvement: failure summary in XML reports now includes file and
+  line information.
+* Improvement: the <testsuites> XML element now has a timestamp attribute.
+* Improvement: When --gtest_filter is specified, XML report now doesn't
+  contain information about tests that are filtered out.
+* Fixed the bug where long --gtest_filter flag values are truncated in
+  death tests.
+* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a
+  function instead of a macro in order to work better with Clang.
+* Compatibility fixes with C++ 11 and various platforms.
+* Bug/warning fixes.
+
+Changes for 1.6.0:
+
+* New feature: ADD_FAILURE_AT() for reporting a test failure at the
+  given source location -- useful for writing testing utilities.
+* New feature: the universal value printer is moved from Google Mock
+  to Google Test.
+* New feature: type parameters and value parameters are reported in
+  the XML report now.
+* A gtest_disable_pthreads CMake option.
+* Colored output works in GNU Screen sessions now.
+* Parameters of value-parameterized tests are now printed in the
+  textual output.
+* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are
+  now correctly reported.
+* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to
+  ostream.
+* More complete handling of exceptions.
+* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter
+  name is already used by another library.
+* --gtest_catch_exceptions is now true by default, allowing a test
+  program to continue after an exception is thrown.
+* Value-parameterized test fixtures can now derive from Test and
+  WithParamInterface<T> separately, easing conversion of legacy tests.
+* Death test messages are clearly marked to make them more
+  distinguishable from other messages.
+* Compatibility fixes for Android, Google Native Client, MinGW, HP UX,
+  PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear),
+  IBM XL C++ (Visual Age C++), and C++0x.
+* Bug fixes and implementation clean-ups.
+* Potentially incompatible changes: disables the harmful 'make install'
+  command in autotools.
+
+Changes for 1.5.0:
+
+ * New feature: assertions can be safely called in multiple threads
+   where the pthreads library is available.
+ * New feature: predicates used inside EXPECT_TRUE() and friends
+   can now generate custom failure messages.
+ * New feature: Google Test can now be compiled as a DLL.
+ * New feature: fused source files are included.
+ * New feature: prints help when encountering unrecognized Google Test flags.
+ * Experimental feature: CMake build script (requires CMake 2.6.4+).
+ * Experimental feature: the Pump script for meta programming.
+ * double values streamed to an assertion are printed with enough precision
+   to differentiate any two different values.
+ * Google Test now works on Solaris and AIX.
+ * Build and test script improvements.
+ * Bug fixes and implementation clean-ups.
+
+ Potentially breaking changes:
+
+ * Stopped supporting VC++ 7.1 with exceptions disabled.
+ * Dropped support for 'make install'.
+
+Changes for 1.4.0:
+
+ * New feature: the event listener API
+ * New feature: test shuffling
+ * New feature: the XML report format is closer to junitreport and can
+   be parsed by Hudson now.
+ * New feature: when a test runs under Visual Studio, its failures are
+   integrated in the IDE.
+ * New feature: /MD(d) versions of VC++ projects.
+ * New feature: elapsed time for the tests is printed by default.
+ * New feature: comes with a TR1 tuple implementation such that Boost
+   is no longer needed for Combine().
+ * New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends.
+ * New feature: the Xcode project can now produce static gtest
+   libraries in addition to a framework.
+ * Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile,
+   Symbian, gcc, and C++Builder.
+ * Bug fixes and implementation clean-ups.
+
+Changes for 1.3.0:
+
+ * New feature: death tests on Windows, Cygwin, and Mac.
+ * New feature: ability to use Google Test assertions in other testing
+   frameworks.
+ * New feature: ability to run disabled test via
+   --gtest_also_run_disabled_tests.
+ * New feature: the --help flag for printing the usage.
+ * New feature: access to Google Test flag values in user code.
+ * New feature: a script that packs Google Test into one .h and one
+   .cc file for easy deployment.
+ * New feature: support for distributing test functions to multiple
+   machines (requires support from the test runner).
+ * Bug fixes and implementation clean-ups.
+
+Changes for 1.2.1:
+
+ * Compatibility fixes for Linux IA-64 and IBM z/OS.
+ * Added support for using Boost and other TR1 implementations.
+ * Changes to the build scripts to support upcoming release of Google C++
+   Mocking Framework.
+ * Added Makefile to the distribution package.
+ * Improved build instructions in README.
+
+Changes for 1.2.0:
+
+ * New feature: value-parameterized tests.
+ * New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS)
+   macros.
+ * Changed the XML report format to match JUnit/Ant's.
+ * Added tests to the Xcode project.
+ * Added scons/SConscript for building with SCons.
+ * Added src/gtest-all.cc for building Google Test from a single file.
+ * Fixed compatibility with Solaris and z/OS.
+ * Enabled running Python tests on systems with python 2.3 installed,
+   e.g. Mac OS X 10.4.
+ * Bug fixes.
+
+Changes for 1.1.0:
+
+ * New feature: type-parameterized tests.
+ * New feature: exception assertions.
+ * New feature: printing elapsed time of tests.
+ * Improved the robustness of death tests.
+ * Added an Xcode project and samples.
+ * Adjusted the output format on Windows to be understandable by Visual Studio.
+ * Minor bug fixes.
+
+Changes for 1.0.1:
+
+ * Added project files for Visual Studio 7.1.
+ * Fixed issues with compiling on Mac OS X.
+ * Fixed issues with compiling on Cygwin.
+
+Changes for 1.0.0:
+
+ * Initial Open Source release of Google Test
diff --git a/test/fmw/gtest/LICENSE b/test/fmw/gtest/LICENSE
new file mode 100644
index 0000000..1941a11
--- /dev/null
+++ b/test/fmw/gtest/LICENSE
@@ -0,0 +1,28 @@
+Copyright 2008, Google Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+    * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/test/fmw/gtest/README b/test/fmw/gtest/README
new file mode 100644
index 0000000..26f35a8
--- /dev/null
+++ b/test/fmw/gtest/README
@@ -0,0 +1,435 @@
+Google C++ Testing Framework
+============================
+
+http://code.google.com/p/googletest/
+
+Overview
+--------
+
+Google's framework for writing C++ tests on a variety of platforms
+(Linux, Mac OS X, Windows, Windows CE, Symbian, etc).  Based on the
+xUnit architecture.  Supports automatic test discovery, a rich set of
+assertions, user-defined assertions, death tests, fatal and non-fatal
+failures, various options for running the tests, and XML test report
+generation.
+
+Please see the project page above for more information as well as the
+mailing list for questions, discussions, and development.  There is
+also an IRC channel on OFTC (irc.oftc.net) #gtest available.  Please
+join us!
+
+Requirements for End Users
+--------------------------
+
+Google Test is designed to have fairly minimal requirements to build
+and use with your projects, but there are some.  Currently, we support
+Linux, Windows, Mac OS X, and Cygwin.  We will also make our best
+effort to support other platforms (e.g. Solaris, AIX, and z/OS).
+However, since core members of the Google Test project have no access
+to these platforms, Google Test may have outstanding issues there.  If
+you notice any problems on your platform, please notify
+googletestframework@googlegroups.com.  Patches for fixing them are
+even more welcome!
+
+### Linux Requirements ###
+
+These are the base requirements to build and use Google Test from a source
+package (as described below):
+  * GNU-compatible Make or gmake
+  * POSIX-standard shell
+  * POSIX(-2) Regular Expressions (regex.h)
+  * A C++98-standard-compliant compiler
+
+### Windows Requirements ###
+
+  * Microsoft Visual C++ 7.1 or newer
+
+### Cygwin Requirements ###
+
+  * Cygwin 1.5.25-14 or newer
+
+### Mac OS X Requirements ###
+
+  * Mac OS X 10.4 Tiger or newer
+  * Developer Tools Installed
+
+Also, you'll need CMake 2.6.4 or higher if you want to build the
+samples using the provided CMake script, regardless of the platform.
+
+Requirements for Contributors
+-----------------------------
+
+We welcome patches.  If you plan to contribute a patch, you need to
+build Google Test and its own tests from an SVN checkout (described
+below), which has further requirements:
+
+  * Python version 2.3 or newer (for running some of the tests and
+    re-generating certain source files from templates)
+  * CMake 2.6.4 or newer
+
+Getting the Source
+------------------
+
+There are two primary ways of getting Google Test's source code: you
+can download a stable source release in your preferred archive format,
+or directly check out the source from our Subversion (SVN) repositary.
+The SVN checkout requires a few extra steps and some extra software
+packages on your system, but lets you track the latest development and
+make patches much more easily, so we highly encourage it.
+
+### Source Package ###
+
+Google Test is released in versioned source packages which can be
+downloaded from the download page [1].  Several different archive
+formats are provided, but the only difference is the tools used to
+manipulate them, and the size of the resulting file.  Download
+whichever you are most comfortable with.
+
+  [1] http://code.google.com/p/googletest/downloads/list
+
+Once the package is downloaded, expand it using whichever tools you
+prefer for that type.  This will result in a new directory with the
+name "gtest-X.Y.Z" which contains all of the source code.  Here are
+some examples on Linux:
+
+  tar -xvzf gtest-X.Y.Z.tar.gz
+  tar -xvjf gtest-X.Y.Z.tar.bz2
+  unzip gtest-X.Y.Z.zip
+
+### SVN Checkout ###
+
+To check out the main branch (also known as the "trunk") of Google
+Test, run the following Subversion command:
+
+  svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
+
+Setting up the Build
+--------------------
+
+To build Google Test and your tests that use it, you need to tell your
+build system where to find its headers and source files.  The exact
+way to do it depends on which build system you use, and is usually
+straightforward.
+
+### Generic Build Instructions ###
+
+Suppose you put Google Test in directory ${GTEST_DIR}.  To build it,
+create a library build target (or a project as called by Visual Studio
+and Xcode) to compile
+
+  ${GTEST_DIR}/src/gtest-all.cc
+
+with ${GTEST_DIR}/include in the system header search path and ${GTEST_DIR}
+in the normal header search path.  Assuming a Linux-like system and gcc,
+something like the following will do:
+
+  g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \
+      -pthread -c ${GTEST_DIR}/src/gtest-all.cc
+  ar -rv libgtest.a gtest-all.o
+
+(We need -pthread as Google Test uses threads.)
+
+Next, you should compile your test source file with
+${GTEST_DIR}/include in the system header search path, and link it
+with gtest and any other necessary libraries:
+
+  g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \
+      -o your_test
+
+As an example, the make/ directory contains a Makefile that you can
+use to build Google Test on systems where GNU make is available
+(e.g. Linux, Mac OS X, and Cygwin).  It doesn't try to build Google
+Test's own tests.  Instead, it just builds the Google Test library and
+a sample test.  You can use it as a starting point for your own build
+script.
+
+If the default settings are correct for your environment, the
+following commands should succeed:
+
+  cd ${GTEST_DIR}/make
+  make
+  ./sample1_unittest
+
+If you see errors, try to tweak the contents of make/Makefile to make
+them go away.  There are instructions in make/Makefile on how to do
+it.
+
+### Using CMake ###
+
+Google Test comes with a CMake build script (CMakeLists.txt) that can
+be used on a wide range of platforms ("C" stands for cross-platofrm.).
+If you don't have CMake installed already, you can download it for
+free from http://www.cmake.org/.
+
+CMake works by generating native makefiles or build projects that can
+be used in the compiler environment of your choice.  The typical
+workflow starts with:
+
+  mkdir mybuild       # Create a directory to hold the build output.
+  cd mybuild
+  cmake ${GTEST_DIR}  # Generate native build scripts.
+
+If you want to build Google Test's samples, you should replace the
+last command with
+
+  cmake -Dgtest_build_samples=ON ${GTEST_DIR}
+
+If you are on a *nix system, you should now see a Makefile in the
+current directory.  Just type 'make' to build gtest.
+
+If you use Windows and have Vistual Studio installed, a gtest.sln file
+and several .vcproj files will be created.  You can then build them
+using Visual Studio.
+
+On Mac OS X with Xcode installed, a .xcodeproj file will be generated.
+
+### Legacy Build Scripts ###
+
+Before settling on CMake, we have been providing hand-maintained build
+projects/scripts for Visual Studio, Xcode, and Autotools.  While we
+continue to provide them for convenience, they are not actively
+maintained any more.  We highly recommend that you follow the
+instructions in the previous two sections to integrate Google Test
+with your existing build system.
+
+If you still need to use the legacy build scripts, here's how:
+
+The msvc\ folder contains two solutions with Visual C++ projects.
+Open the gtest.sln or gtest-md.sln file using Visual Studio, and you
+are ready to build Google Test the same way you build any Visual
+Studio project.  Files that have names ending with -md use DLL
+versions of Microsoft runtime libraries (the /MD or the /MDd compiler
+option).  Files without that suffix use static versions of the runtime
+libraries (the /MT or the /MTd option).  Please note that one must use
+the same option to compile both gtest and the test code.  If you use
+Visual Studio 2005 or above, we recommend the -md version as /MD is
+the default for new projects in these versions of Visual Studio.
+
+On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using
+Xcode.  Build the "gtest" target.  The universal binary framework will
+end up in your selected build directory (selected in the Xcode
+"Preferences..." -> "Building" pane and defaults to xcode/build).
+Alternatively, at the command line, enter:
+
+  xcodebuild
+
+This will build the "Release" configuration of gtest.framework in your
+default build location.  See the "xcodebuild" man page for more
+information about building different configurations and building in
+different locations.
+
+If you wish to use the Google Test Xcode project with Xcode 4.x and
+above, you need to either:
+ * update the SDK configuration options in xcode/Config/General.xconfig.
+   Comment options SDKROOT, MACOS_DEPLOYMENT_TARGET, and GCC_VERSION. If
+   you choose this route you lose the ability to target earlier versions
+   of MacOS X.
+ * Install an SDK for an earlier version. This doesn't appear to be
+   supported by Apple, but has been reported to work
+   (http://stackoverflow.com/questions/5378518).
+
+Tweaking Google Test
+--------------------
+
+Google Test can be used in diverse environments.  The default
+configuration may not work (or may not work well) out of the box in
+some environments.  However, you can easily tweak Google Test by
+defining control macros on the compiler command line.  Generally,
+these macros are named like GTEST_XYZ and you define them to either 1
+or 0 to enable or disable a certain feature.
+
+We list the most frequently used macros below.  For a complete list,
+see file include/gtest/internal/gtest-port.h.
+
+### Choosing a TR1 Tuple Library ###
+
+Some Google Test features require the C++ Technical Report 1 (TR1)
+tuple library, which is not yet available with all compilers.  The
+good news is that Google Test implements a subset of TR1 tuple that's
+enough for its own need, and will automatically use this when the
+compiler doesn't provide TR1 tuple.
+
+Usually you don't need to care about which tuple library Google Test
+uses.  However, if your project already uses TR1 tuple, you need to
+tell Google Test to use the same TR1 tuple library the rest of your
+project uses, or the two tuple implementations will clash.  To do
+that, add
+
+  -DGTEST_USE_OWN_TR1_TUPLE=0
+
+to the compiler flags while compiling Google Test and your tests.  If
+you want to force Google Test to use its own tuple library, just add
+
+  -DGTEST_USE_OWN_TR1_TUPLE=1
+
+to the compiler flags instead.
+
+If you don't want Google Test to use tuple at all, add
+
+  -DGTEST_HAS_TR1_TUPLE=0
+
+and all features using tuple will be disabled.
+
+### Multi-threaded Tests ###
+
+Google Test is thread-safe where the pthread library is available.
+After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE
+macro to see whether this is the case (yes if the macro is #defined to
+1, no if it's undefined.).
+
+If Google Test doesn't correctly detect whether pthread is available
+in your environment, you can force it with
+
+  -DGTEST_HAS_PTHREAD=1
+
+or
+
+  -DGTEST_HAS_PTHREAD=0
+
+When Google Test uses pthread, you may need to add flags to your
+compiler and/or linker to select the pthread library, or you'll get
+link errors.  If you use the CMake script or the deprecated Autotools
+script, this is taken care of for you.  If you use your own build
+script, you'll need to read your compiler and linker's manual to
+figure out what flags to add.
+
+### As a Shared Library (DLL) ###
+
+Google Test is compact, so most users can build and link it as a
+static library for the simplicity.  You can choose to use Google Test
+as a shared library (known as a DLL on Windows) if you prefer.
+
+To compile *gtest* as a shared library, add
+
+  -DGTEST_CREATE_SHARED_LIBRARY=1
+
+to the compiler flags.  You'll also need to tell the linker to produce
+a shared library instead - consult your linker's manual for how to do
+it.
+
+To compile your *tests* that use the gtest shared library, add
+
+  -DGTEST_LINKED_AS_SHARED_LIBRARY=1
+
+to the compiler flags.
+
+Note: while the above steps aren't technically necessary today when
+using some compilers (e.g. GCC), they may become necessary in the
+future, if we decide to improve the speed of loading the library (see
+http://gcc.gnu.org/wiki/Visibility for details).  Therefore you are
+recommended to always add the above flags when using Google Test as a
+shared library.  Otherwise a future release of Google Test may break
+your build script.
+
+### Avoiding Macro Name Clashes ###
+
+In C++, macros don't obey namespaces.  Therefore two libraries that
+both define a macro of the same name will clash if you #include both
+definitions.  In case a Google Test macro clashes with another
+library, you can force Google Test to rename its macro to avoid the
+conflict.
+
+Specifically, if both Google Test and some other code define macro
+FOO, you can add
+
+  -DGTEST_DONT_DEFINE_FOO=1
+
+to the compiler flags to tell Google Test to change the macro's name
+from FOO to GTEST_FOO.  Currently FOO can be FAIL, SUCCEED, or TEST.
+For example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write
+
+  GTEST_TEST(SomeTest, DoesThis) { ... }
+
+instead of
+
+  TEST(SomeTest, DoesThis) { ... }
+
+in order to define a test.
+
+Upgrating from an Earlier Version
+---------------------------------
+
+We strive to keep Google Test releases backward compatible.
+Sometimes, though, we have to make some breaking changes for the
+users' long-term benefits.  This section describes what you'll need to
+do if you are upgrading from an earlier version of Google Test.
+
+### Upgrading from 1.3.0 or Earlier ###
+
+You may need to explicitly enable or disable Google Test's own TR1
+tuple library.  See the instructions in section "Choosing a TR1 Tuple
+Library".
+
+### Upgrading from 1.4.0 or Earlier ###
+
+The Autotools build script (configure + make) is no longer officially
+supportted.  You are encouraged to migrate to your own build system or
+use CMake.  If you still need to use Autotools, you can find
+instructions in the README file from Google Test 1.4.0.
+
+On platforms where the pthread library is available, Google Test uses
+it in order to be thread-safe.  See the "Multi-threaded Tests" section
+for what this means to your build script.
+
+If you use Microsoft Visual C++ 7.1 with exceptions disabled, Google
+Test will no longer compile.  This should affect very few people, as a
+large portion of STL (including <string>) doesn't compile in this mode
+anyway.  We decided to stop supporting it in order to greatly simplify
+Google Test's implementation.
+
+Developing Google Test
+----------------------
+
+This section discusses how to make your own changes to Google Test.
+
+### Testing Google Test Itself ###
+
+To make sure your changes work as intended and don't break existing
+functionality, you'll want to compile and run Google Test's own tests.
+For that you can use CMake:
+
+  mkdir mybuild
+  cd mybuild
+  cmake -Dgtest_build_tests=ON ${GTEST_DIR}
+
+Make sure you have Python installed, as some of Google Test's tests
+are written in Python.  If the cmake command complains about not being
+able to find Python ("Could NOT find PythonInterp (missing:
+PYTHON_EXECUTABLE)"), try telling it explicitly where your Python
+executable can be found:
+
+  cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
+
+Next, you can build Google Test and all of its own tests.  On *nix,
+this is usually done by 'make'.  To run the tests, do
+
+  make test
+
+All tests should pass.
+
+### Regenerating Source Files ###
+
+Some of Google Test's source files are generated from templates (not
+in the C++ sense) using a script.  A template file is named FOO.pump,
+where FOO is the name of the file it will generate.  For example, the
+file include/gtest/internal/gtest-type-util.h.pump is used to generate
+gtest-type-util.h in the same directory.
+
+Normally you don't need to worry about regenerating the source files,
+unless you need to modify them.  In that case, you should modify the
+corresponding .pump files instead and run the pump.py Python script to
+regenerate them.  You can find pump.py in the scripts/ directory.
+Read the Pump manual [2] for how to use it.
+
+  [2] http://code.google.com/p/googletest/wiki/PumpManual
+
+### Contributing a Patch ###
+
+We welcome patches.  Please read the Google Test developer's guide [3]
+for how you can contribute.  In particular, make sure you have signed
+the Contributor License Agreement, or we won't be able to accept the
+patch.
+
+  [3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide
+
+Happy testing!
diff --git a/test/fmw/gtest/include/gtest/gtest-death-test.h b/test/fmw/gtest/include/gtest/gtest-death-test.h
new file mode 100644
index 0000000..957a69c
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-death-test.h
@@ -0,0 +1,294 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file defines the public API for death tests.  It is
+// #included by gtest.h so a user doesn't need to include this
+// directly.
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
+#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
+
+#include "gtest/internal/gtest-death-test-internal.h"
+
+namespace testing {
+
+// This flag controls the style of death tests.  Valid values are "threadsafe",
+// meaning that the death test child process will re-execute the test binary
+// from the start, running only a single death test, or "fast",
+// meaning that the child process will execute the test logic immediately
+// after forking.
+GTEST_DECLARE_string_(death_test_style);
+
+#if GTEST_HAS_DEATH_TEST
+
+namespace internal {
+
+// Returns a Boolean value indicating whether the caller is currently
+// executing in the context of the death test child process.  Tools such as
+// Valgrind heap checkers may need this to modify their behavior in death
+// tests.  IMPORTANT: This is an internal utility.  Using it may break the
+// implementation of death tests.  User code MUST NOT use it.
+GTEST_API_ bool InDeathTestChild();
+
+}  // namespace internal
+
+// The following macros are useful for writing death tests.
+
+// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
+// executed:
+//
+//   1. It generates a warning if there is more than one active
+//   thread.  This is because it's safe to fork() or clone() only
+//   when there is a single thread.
+//
+//   2. The parent process clone()s a sub-process and runs the death
+//   test in it; the sub-process exits with code 0 at the end of the
+//   death test, if it hasn't exited already.
+//
+//   3. The parent process waits for the sub-process to terminate.
+//
+//   4. The parent process checks the exit code and error message of
+//   the sub-process.
+//
+// Examples:
+//
+//   ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
+//   for (int i = 0; i < 5; i++) {
+//     EXPECT_DEATH(server.ProcessRequest(i),
+//                  "Invalid request .* in ProcessRequest()")
+//                  << "Failed to die on request " << i;
+//   }
+//
+//   ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
+//
+//   bool KilledBySIGHUP(int exit_code) {
+//     return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
+//   }
+//
+//   ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
+//
+// On the regular expressions used in death tests:
+//
+//   On POSIX-compliant systems (*nix), we use the <regex.h> library,
+//   which uses the POSIX extended regex syntax.
+//
+//   On other platforms (e.g. Windows), we only support a simple regex
+//   syntax implemented as part of Google Test.  This limited
+//   implementation should be enough most of the time when writing
+//   death tests; though it lacks many features you can find in PCRE
+//   or POSIX extended regex syntax.  For example, we don't support
+//   union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
+//   repetition count ("x{5,7}"), among others.
+//
+//   Below is the syntax that we do support.  We chose it to be a
+//   subset of both PCRE and POSIX extended regex, so it's easy to
+//   learn wherever you come from.  In the following: 'A' denotes a
+//   literal character, period (.), or a single \\ escape sequence;
+//   'x' and 'y' denote regular expressions; 'm' and 'n' are for
+//   natural numbers.
+//
+//     c     matches any literal character c
+//     \\d   matches any decimal digit
+//     \\D   matches any character that's not a decimal digit
+//     \\f   matches \f
+//     \\n   matches \n
+//     \\r   matches \r
+//     \\s   matches any ASCII whitespace, including \n
+//     \\S   matches any character that's not a whitespace
+//     \\t   matches \t
+//     \\v   matches \v
+//     \\w   matches any letter, _, or decimal digit
+//     \\W   matches any character that \\w doesn't match
+//     \\c   matches any literal character c, which must be a punctuation
+//     .     matches any single character except \n
+//     A?    matches 0 or 1 occurrences of A
+//     A*    matches 0 or many occurrences of A
+//     A+    matches 1 or many occurrences of A
+//     ^     matches the beginning of a string (not that of each line)
+//     $     matches the end of a string (not that of each line)
+//     xy    matches x followed by y
+//
+//   If you accidentally use PCRE or POSIX extended regex features
+//   not implemented by us, you will get a run-time failure.  In that
+//   case, please try to rewrite your regular expression within the
+//   above syntax.
+//
+//   This implementation is *not* meant to be as highly tuned or robust
+//   as a compiled regex library, but should perform well enough for a
+//   death test, which already incurs significant overhead by launching
+//   a child process.
+//
+// Known caveats:
+//
+//   A "threadsafe" style death test obtains the path to the test
+//   program from argv[0] and re-executes it in the sub-process.  For
+//   simplicity, the current implementation doesn't search the PATH
+//   when launching the sub-process.  This means that the user must
+//   invoke the test program via a path that contains at least one
+//   path separator (e.g. path/to/foo_test and
+//   /absolute/path/to/bar_test are fine, but foo_test is not).  This
+//   is rarely a problem as people usually don't put the test binary
+//   directory in PATH.
+//
+// TODO(wan@google.com): make thread-safe death tests search the PATH.
+
+// Asserts that a given statement causes the program to exit, with an
+// integer exit status that satisfies predicate, and emitting error output
+// that matches regex.
+# define ASSERT_EXIT(statement, predicate, regex) \
+    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
+
+// Like ASSERT_EXIT, but continues on to successive tests in the
+// test case, if any:
+# define EXPECT_EXIT(statement, predicate, regex) \
+    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
+
+// Asserts that a given statement causes the program to exit, either by
+// explicitly exiting with a nonzero exit code or being killed by a
+// signal, and emitting error output that matches regex.
+# define ASSERT_DEATH(statement, regex) \
+    ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
+
+// Like ASSERT_DEATH, but continues on to successive tests in the
+// test case, if any:
+# define EXPECT_DEATH(statement, regex) \
+    EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
+
+// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
+
+// Tests that an exit code describes a normal exit with a given exit code.
+class GTEST_API_ ExitedWithCode {
+ public:
+  explicit ExitedWithCode(int exit_code);
+  bool operator()(int exit_status) const;
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ExitedWithCode& other);
+
+  const int exit_code_;
+};
+
+# if !GTEST_OS_WINDOWS
+// Tests that an exit code describes an exit due to termination by a
+// given signal.
+class GTEST_API_ KilledBySignal {
+ public:
+  explicit KilledBySignal(int signum);
+  bool operator()(int exit_status) const;
+ private:
+  const int signum_;
+};
+# endif  // !GTEST_OS_WINDOWS
+
+// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
+// The death testing framework causes this to have interesting semantics,
+// since the sideeffects of the call are only visible in opt mode, and not
+// in debug mode.
+//
+// In practice, this can be used to test functions that utilize the
+// LOG(DFATAL) macro using the following style:
+//
+// int DieInDebugOr12(int* sideeffect) {
+//   if (sideeffect) {
+//     *sideeffect = 12;
+//   }
+//   LOG(DFATAL) << "death";
+//   return 12;
+// }
+//
+// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {
+//   int sideeffect = 0;
+//   // Only asserts in dbg.
+//   EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
+//
+// #ifdef NDEBUG
+//   // opt-mode has sideeffect visible.
+//   EXPECT_EQ(12, sideeffect);
+// #else
+//   // dbg-mode no visible sideeffect.
+//   EXPECT_EQ(0, sideeffect);
+// #endif
+// }
+//
+// This will assert that DieInDebugReturn12InOpt() crashes in debug
+// mode, usually due to a DCHECK or LOG(DFATAL), but returns the
+// appropriate fallback value (12 in this case) in opt mode. If you
+// need to test that a function has appropriate side-effects in opt
+// mode, include assertions against the side-effects.  A general
+// pattern for this is:
+//
+// EXPECT_DEBUG_DEATH({
+//   // Side-effects here will have an effect after this statement in
+//   // opt mode, but none in debug mode.
+//   EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
+// }, "death");
+//
+# ifdef NDEBUG
+
+#  define EXPECT_DEBUG_DEATH(statement, regex) \
+  GTEST_EXECUTE_STATEMENT_(statement, regex)
+
+#  define ASSERT_DEBUG_DEATH(statement, regex) \
+  GTEST_EXECUTE_STATEMENT_(statement, regex)
+
+# else
+
+#  define EXPECT_DEBUG_DEATH(statement, regex) \
+  EXPECT_DEATH(statement, regex)
+
+#  define ASSERT_DEBUG_DEATH(statement, regex) \
+  ASSERT_DEATH(statement, regex)
+
+# endif  // NDEBUG for EXPECT_DEBUG_DEATH
+#endif  // GTEST_HAS_DEATH_TEST
+
+// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
+// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
+// death tests are supported; otherwise they just issue a warning.  This is
+// useful when you are combining death test assertions with normal test
+// assertions in one test.
+#if GTEST_HAS_DEATH_TEST
+# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
+    EXPECT_DEATH(statement, regex)
+# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
+    ASSERT_DEATH(statement, regex)
+#else
+# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
+    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
+# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
+    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
+#endif
+
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
diff --git a/test/fmw/gtest/include/gtest/gtest-message.h b/test/fmw/gtest/include/gtest/gtest-message.h
new file mode 100644
index 0000000..fe879bc
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-message.h
@@ -0,0 +1,250 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file defines the Message class.
+//
+// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
+// leave some internal implementation details in this header file.
+// They are clearly marked by comments like this:
+//
+//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+//
+// Such code is NOT meant to be used by a user directly, and is subject
+// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
+// program!
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
+#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
+
+#include <limits>
+
+#include "gtest/internal/gtest-port.h"
+
+// Ensures that there is at least one operator<< in the global namespace.
+// See Message& operator<<(...) below for why.
+void operator<<(const testing::internal::Secret&, int);
+
+namespace testing {
+
+// The Message class works like an ostream repeater.
+//
+// Typical usage:
+//
+//   1. You stream a bunch of values to a Message object.
+//      It will remember the text in a stringstream.
+//   2. Then you stream the Message object to an ostream.
+//      This causes the text in the Message to be streamed
+//      to the ostream.
+//
+// For example;
+//
+//   testing::Message foo;
+//   foo << 1 << " != " << 2;
+//   std::cout << foo;
+//
+// will print "1 != 2".
+//
+// Message is not intended to be inherited from.  In particular, its
+// destructor is not virtual.
+//
+// Note that stringstream behaves differently in gcc and in MSVC.  You
+// can stream a NULL char pointer to it in the former, but not in the
+// latter (it causes an access violation if you do).  The Message
+// class hides this difference by treating a NULL char pointer as
+// "(null)".
+class GTEST_API_ Message {
+ private:
+  // The type of basic IO manipulators (endl, ends, and flush) for
+  // narrow streams.
+  typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
+
+ public:
+  // Constructs an empty Message.
+  Message();
+
+  // Copy constructor.
+  Message(const Message& msg) : ss_(new ::std::stringstream) {  // NOLINT
+    *ss_ << msg.GetString();
+  }
+
+  // Constructs a Message from a C-string.
+  explicit Message(const char* str) : ss_(new ::std::stringstream) {
+    *ss_ << str;
+  }
+
+#if GTEST_OS_SYMBIAN
+  // Streams a value (either a pointer or not) to this object.
+  template <typename T>
+  inline Message& operator <<(const T& value) {
+    StreamHelper(typename internal::is_pointer<T>::type(), value);
+    return *this;
+  }
+#else
+  // Streams a non-pointer value to this object.
+  template <typename T>
+  inline Message& operator <<(const T& val) {
+    // Some libraries overload << for STL containers.  These
+    // overloads are defined in the global namespace instead of ::std.
+    //
+    // C++'s symbol lookup rule (i.e. Koenig lookup) says that these
+    // overloads are visible in either the std namespace or the global
+    // namespace, but not other namespaces, including the testing
+    // namespace which Google Test's Message class is in.
+    //
+    // To allow STL containers (and other types that has a << operator
+    // defined in the global namespace) to be used in Google Test
+    // assertions, testing::Message must access the custom << operator
+    // from the global namespace.  With this using declaration,
+    // overloads of << defined in the global namespace and those
+    // visible via Koenig lookup are both exposed in this function.
+    using ::operator <<;
+    *ss_ << val;
+    return *this;
+  }
+
+  // Streams a pointer value to this object.
+  //
+  // This function is an overload of the previous one.  When you
+  // stream a pointer to a Message, this definition will be used as it
+  // is more specialized.  (The C++ Standard, section
+  // [temp.func.order].)  If you stream a non-pointer, then the
+  // previous definition will be used.
+  //
+  // The reason for this overload is that streaming a NULL pointer to
+  // ostream is undefined behavior.  Depending on the compiler, you
+  // may get "0", "(nil)", "(null)", or an access violation.  To
+  // ensure consistent result across compilers, we always treat NULL
+  // as "(null)".
+  template <typename T>
+  inline Message& operator <<(T* const& pointer) {  // NOLINT
+    if (pointer == NULL) {
+      *ss_ << "(null)";
+    } else {
+      *ss_ << pointer;
+    }
+    return *this;
+  }
+#endif  // GTEST_OS_SYMBIAN
+
+  // Since the basic IO manipulators are overloaded for both narrow
+  // and wide streams, we have to provide this specialized definition
+  // of operator <<, even though its body is the same as the
+  // templatized version above.  Without this definition, streaming
+  // endl or other basic IO manipulators to Message will confuse the
+  // compiler.
+  Message& operator <<(BasicNarrowIoManip val) {
+    *ss_ << val;
+    return *this;
+  }
+
+  // Instead of 1/0, we want to see true/false for bool values.
+  Message& operator <<(bool b) {
+    return *this << (b ? "true" : "false");
+  }
+
+  // These two overloads allow streaming a wide C string to a Message
+  // using the UTF-8 encoding.
+  Message& operator <<(const wchar_t* wide_c_str);
+  Message& operator <<(wchar_t* wide_c_str);
+
+#if GTEST_HAS_STD_WSTRING
+  // Converts the given wide string to a narrow string using the UTF-8
+  // encoding, and streams the result to this Message object.
+  Message& operator <<(const ::std::wstring& wstr);
+#endif  // GTEST_HAS_STD_WSTRING
+
+#if GTEST_HAS_GLOBAL_WSTRING
+  // Converts the given wide string to a narrow string using the UTF-8
+  // encoding, and streams the result to this Message object.
+  Message& operator <<(const ::wstring& wstr);
+#endif  // GTEST_HAS_GLOBAL_WSTRING
+
+  // Gets the text streamed to this object so far as an std::string.
+  // Each '\0' character in the buffer is replaced with "\\0".
+  //
+  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+  std::string GetString() const;
+
+ private:
+
+#if GTEST_OS_SYMBIAN
+  // These are needed as the Nokia Symbian Compiler cannot decide between
+  // const T& and const T* in a function template. The Nokia compiler _can_
+  // decide between class template specializations for T and T*, so a
+  // tr1::type_traits-like is_pointer works, and we can overload on that.
+  template <typename T>
+  inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) {
+    if (pointer == NULL) {
+      *ss_ << "(null)";
+    } else {
+      *ss_ << pointer;
+    }
+  }
+  template <typename T>
+  inline void StreamHelper(internal::false_type /*is_pointer*/,
+                           const T& value) {
+    // See the comments in Message& operator <<(const T&) above for why
+    // we need this using statement.
+    using ::operator <<;
+    *ss_ << value;
+  }
+#endif  // GTEST_OS_SYMBIAN
+
+  // We'll hold the text streamed to this object here.
+  const internal::scoped_ptr< ::std::stringstream> ss_;
+
+  // We declare (but don't implement) this to prevent the compiler
+  // from implementing the assignment operator.
+  void operator=(const Message&);
+};
+
+// Streams a Message to an ostream.
+inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
+  return os << sb.GetString();
+}
+
+namespace internal {
+
+// Converts a streamable value to an std::string.  A NULL pointer is
+// converted to "(null)".  When the input value is a ::string,
+// ::std::string, ::wstring, or ::std::wstring object, each NUL
+// character in it is replaced with "\\0".
+template <typename T>
+std::string StreamableToString(const T& streamable) {
+  return (Message() << streamable).GetString();
+}
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
diff --git a/test/fmw/gtest/include/gtest/gtest-param-test.h b/test/fmw/gtest/include/gtest/gtest-param-test.h
new file mode 100644
index 0000000..d6702c8
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-param-test.h
@@ -0,0 +1,1421 @@
+// This file was GENERATED by command:
+//     pump.py gtest-param-test.h.pump
+// DO NOT EDIT BY HAND!!!
+
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: vladl@google.com (Vlad Losev)
+//
+// Macros and functions for implementing parameterized tests
+// in Google C++ Testing Framework (Google Test)
+//
+// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
+//
+#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
+#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
+
+
+// Value-parameterized tests allow you to test your code with different
+// parameters without writing multiple copies of the same test.
+//
+// Here is how you use value-parameterized tests:
+
+#if 0
+
+// To write value-parameterized tests, first you should define a fixture
+// class. It is usually derived from testing::TestWithParam<T> (see below for
+// another inheritance scheme that's sometimes useful in more complicated
+// class hierarchies), where the type of your parameter values.
+// TestWithParam<T> is itself derived from testing::Test. T can be any
+// copyable type. If it's a raw pointer, you are responsible for managing the
+// lifespan of the pointed values.
+
+class FooTest : public ::testing::TestWithParam<const char*> {
+  // You can implement all the usual class fixture members here.
+};
+
+// Then, use the TEST_P macro to define as many parameterized tests
+// for this fixture as you want. The _P suffix is for "parameterized"
+// or "pattern", whichever you prefer to think.
+
+TEST_P(FooTest, DoesBlah) {
+  // Inside a test, access the test parameter with the GetParam() method
+  // of the TestWithParam<T> class:
+  EXPECT_TRUE(foo.Blah(GetParam()));
+  ...
+}
+
+TEST_P(FooTest, HasBlahBlah) {
+  ...
+}
+
+// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
+// case with any set of parameters you want. Google Test defines a number
+// of functions for generating test parameters. They return what we call
+// (surprise!) parameter generators. Here is a  summary of them, which
+// are all in the testing namespace:
+//
+//
+//  Range(begin, end [, step]) - Yields values {begin, begin+step,
+//                               begin+step+step, ...}. The values do not
+//                               include end. step defaults to 1.
+//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.
+//  ValuesIn(container)        - Yields values from a C-style array, an STL
+//  ValuesIn(begin,end)          container, or an iterator range [begin, end).
+//  Bool()                     - Yields sequence {false, true}.
+//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product
+//                               for the math savvy) of the values generated
+//                               by the N generators.
+//
+// For more details, see comments at the definitions of these functions below
+// in this file.
+//
+// The following statement will instantiate tests from the FooTest test case
+// each with parameter values "meeny", "miny", and "moe".
+
+INSTANTIATE_TEST_CASE_P(InstantiationName,
+                        FooTest,
+                        Values("meeny", "miny", "moe"));
+
+// To distinguish different instances of the pattern, (yes, you
+// can instantiate it more then once) the first argument to the
+// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
+// actual test case name. Remember to pick unique prefixes for different
+// instantiations. The tests from the instantiation above will have
+// these names:
+//
+//    * InstantiationName/FooTest.DoesBlah/0 for "meeny"
+//    * InstantiationName/FooTest.DoesBlah/1 for "miny"
+//    * InstantiationName/FooTest.DoesBlah/2 for "moe"
+//    * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
+//    * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
+//    * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
+//
+// You can use these names in --gtest_filter.
+//
+// This statement will instantiate all tests from FooTest again, each
+// with parameter values "cat" and "dog":
+
+const char* pets[] = {"cat", "dog"};
+INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
+
+// The tests from the instantiation above will have these names:
+//
+//    * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
+//    * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
+//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
+//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
+//
+// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
+// in the given test case, whether their definitions come before or
+// AFTER the INSTANTIATE_TEST_CASE_P statement.
+//
+// Please also note that generator expressions (including parameters to the
+// generators) are evaluated in InitGoogleTest(), after main() has started.
+// This allows the user on one hand, to adjust generator parameters in order
+// to dynamically determine a set of tests to run and on the other hand,
+// give the user a chance to inspect the generated tests with Google Test
+// reflection API before RUN_ALL_TESTS() is executed.
+//
+// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
+// for more examples.
+//
+// In the future, we plan to publish the API for defining new parameter
+// generators. But for now this interface remains part of the internal
+// implementation and is subject to change.
+//
+//
+// A parameterized test fixture must be derived from testing::Test and from
+// testing::WithParamInterface<T>, where T is the type of the parameter
+// values. Inheriting from TestWithParam<T> satisfies that requirement because
+// TestWithParam<T> inherits from both Test and WithParamInterface. In more
+// complicated hierarchies, however, it is occasionally useful to inherit
+// separately from Test and WithParamInterface. For example:
+
+class BaseTest : public ::testing::Test {
+  // You can inherit all the usual members for a non-parameterized test
+  // fixture here.
+};
+
+class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
+  // The usual test fixture members go here too.
+};
+
+TEST_F(BaseTest, HasFoo) {
+  // This is an ordinary non-parameterized test.
+}
+
+TEST_P(DerivedTest, DoesBlah) {
+  // GetParam works just the same here as if you inherit from TestWithParam.
+  EXPECT_TRUE(foo.Blah(GetParam()));
+}
+
+#endif  // 0
+
+#include "gtest/internal/gtest-port.h"
+
+#if !GTEST_OS_SYMBIAN
+# include <utility>
+#endif
+
+// scripts/fuse_gtest.py depends on gtest's own header being #included
+// *unconditionally*.  Therefore these #includes cannot be moved
+// inside #if GTEST_HAS_PARAM_TEST.
+#include "gtest/internal/gtest-internal.h"
+#include "gtest/internal/gtest-param-util.h"
+#include "gtest/internal/gtest-param-util-generated.h"
+
+#if GTEST_HAS_PARAM_TEST
+
+namespace testing {
+
+// Functions producing parameter generators.
+//
+// Google Test uses these generators to produce parameters for value-
+// parameterized tests. When a parameterized test case is instantiated
+// with a particular generator, Google Test creates and runs tests
+// for each element in the sequence produced by the generator.
+//
+// In the following sample, tests from test case FooTest are instantiated
+// each three times with parameter values 3, 5, and 8:
+//
+// class FooTest : public TestWithParam<int> { ... };
+//
+// TEST_P(FooTest, TestThis) {
+// }
+// TEST_P(FooTest, TestThat) {
+// }
+// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
+//
+
+// Range() returns generators providing sequences of values in a range.
+//
+// Synopsis:
+// Range(start, end)
+//   - returns a generator producing a sequence of values {start, start+1,
+//     start+2, ..., }.
+// Range(start, end, step)
+//   - returns a generator producing a sequence of values {start, start+step,
+//     start+step+step, ..., }.
+// Notes:
+//   * The generated sequences never include end. For example, Range(1, 5)
+//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
+//     returns a generator producing {1, 3, 5, 7}.
+//   * start and end must have the same type. That type may be any integral or
+//     floating-point type or a user defined type satisfying these conditions:
+//     * It must be assignable (have operator=() defined).
+//     * It must have operator+() (operator+(int-compatible type) for
+//       two-operand version).
+//     * It must have operator<() defined.
+//     Elements in the resulting sequences will also have that type.
+//   * Condition start < end must be satisfied in order for resulting sequences
+//     to contain any elements.
+//
+template <typename T, typename IncrementT>
+internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
+  return internal::ParamGenerator<T>(
+      new internal::RangeGenerator<T, IncrementT>(start, end, step));
+}
+
+template <typename T>
+internal::ParamGenerator<T> Range(T start, T end) {
+  return Range(start, end, 1);
+}
+
+// ValuesIn() function allows generation of tests with parameters coming from
+// a container.
+//
+// Synopsis:
+// ValuesIn(const T (&array)[N])
+//   - returns a generator producing sequences with elements from
+//     a C-style array.
+// ValuesIn(const Container& container)
+//   - returns a generator producing sequences with elements from
+//     an STL-style container.
+// ValuesIn(Iterator begin, Iterator end)
+//   - returns a generator producing sequences with elements from
+//     a range [begin, end) defined by a pair of STL-style iterators. These
+//     iterators can also be plain C pointers.
+//
+// Please note that ValuesIn copies the values from the containers
+// passed in and keeps them to generate tests in RUN_ALL_TESTS().
+//
+// Examples:
+//
+// This instantiates tests from test case StringTest
+// each with C-string values of "foo", "bar", and "baz":
+//
+// const char* strings[] = {"foo", "bar", "baz"};
+// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
+//
+// This instantiates tests from test case StlStringTest
+// each with STL strings with values "a" and "b":
+//
+// ::std::vector< ::std::string> GetParameterStrings() {
+//   ::std::vector< ::std::string> v;
+//   v.push_back("a");
+//   v.push_back("b");
+//   return v;
+// }
+//
+// INSTANTIATE_TEST_CASE_P(CharSequence,
+//                         StlStringTest,
+//                         ValuesIn(GetParameterStrings()));
+//
+//
+// This will also instantiate tests from CharTest
+// each with parameter values 'a' and 'b':
+//
+// ::std::list<char> GetParameterChars() {
+//   ::std::list<char> list;
+//   list.push_back('a');
+//   list.push_back('b');
+//   return list;
+// }
+// ::std::list<char> l = GetParameterChars();
+// INSTANTIATE_TEST_CASE_P(CharSequence2,
+//                         CharTest,
+//                         ValuesIn(l.begin(), l.end()));
+//
+template <typename ForwardIterator>
+internal::ParamGenerator<
+  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
+ValuesIn(ForwardIterator begin, ForwardIterator end) {
+  typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
+      ::value_type ParamType;
+  return internal::ParamGenerator<ParamType>(
+      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
+}
+
+template <typename T, size_t N>
+internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
+  return ValuesIn(array, array + N);
+}
+
+template <class Container>
+internal::ParamGenerator<typename Container::value_type> ValuesIn(
+    const Container& container) {
+  return ValuesIn(container.begin(), container.end());
+}
+
+// Values() allows generating tests from explicitly specified list of
+// parameters.
+//
+// Synopsis:
+// Values(T v1, T v2, ..., T vN)
+//   - returns a generator producing sequences with elements v1, v2, ..., vN.
+//
+// For example, this instantiates tests from test case BarTest each
+// with values "one", "two", and "three":
+//
+// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
+//
+// This instantiates tests from test case BazTest each with values 1, 2, 3.5.
+// The exact type of values will depend on the type of parameter in BazTest.
+//
+// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
+//
+// Currently, Values() supports from 1 to 50 parameters.
+//
+template <typename T1>
+internal::ValueArray1<T1> Values(T1 v1) {
+  return internal::ValueArray1<T1>(v1);
+}
+
+template <typename T1, typename T2>
+internal::ValueArray2<T1, T2> Values(T1 v1, T2 v2) {
+  return internal::ValueArray2<T1, T2>(v1, v2);
+}
+
+template <typename T1, typename T2, typename T3>
+internal::ValueArray3<T1, T2, T3> Values(T1 v1, T2 v2, T3 v3) {
+  return internal::ValueArray3<T1, T2, T3>(v1, v2, v3);
+}
+
+template <typename T1, typename T2, typename T3, typename T4>
+internal::ValueArray4<T1, T2, T3, T4> Values(T1 v1, T2 v2, T3 v3, T4 v4) {
+  return internal::ValueArray4<T1, T2, T3, T4>(v1, v2, v3, v4);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+internal::ValueArray5<T1, T2, T3, T4, T5> Values(T1 v1, T2 v2, T3 v3, T4 v4,
+    T5 v5) {
+  return internal::ValueArray5<T1, T2, T3, T4, T5>(v1, v2, v3, v4, v5);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6>
+internal::ValueArray6<T1, T2, T3, T4, T5, T6> Values(T1 v1, T2 v2, T3 v3,
+    T4 v4, T5 v5, T6 v6) {
+  return internal::ValueArray6<T1, T2, T3, T4, T5, T6>(v1, v2, v3, v4, v5, v6);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7>
+internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7> Values(T1 v1, T2 v2, T3 v3,
+    T4 v4, T5 v5, T6 v6, T7 v7) {
+  return internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7>(v1, v2, v3, v4, v5,
+      v6, v7);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8>
+internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8> Values(T1 v1, T2 v2,
+    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {
+  return internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8>(v1, v2, v3, v4,
+      v5, v6, v7, v8);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9>
+internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9> Values(T1 v1, T2 v2,
+    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) {
+  return internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(v1, v2, v3,
+      v4, v5, v6, v7, v8, v9);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10>
+internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Values(T1 v1,
+    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) {
+  return internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(v1,
+      v2, v3, v4, v5, v6, v7, v8, v9, v10);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11>
+internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
+    T11> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11) {
+  return internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
+      T11>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12>
+internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+    T12> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12) {
+  return internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13>
+internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+    T13> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13) {
+  return internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14>
+internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) {
+  return internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
+      v14);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15>
+internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
+    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) {
+  return internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
+      v13, v14, v15);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16>
+internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16) {
+  return internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
+      v12, v13, v14, v15, v16);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17>
+internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17) {
+  return internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
+      v11, v12, v13, v14, v15, v16, v17);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18>
+internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
+    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17, T18 v18) {
+  return internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
+      v10, v11, v12, v13, v14, v15, v16, v17, v18);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19>
+internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
+    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
+    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) {
+  return internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19>(v1, v2, v3, v4, v5, v6, v7, v8,
+      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20>
+internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20> Values(T1 v1, T2 v2, T3 v3, T4 v4,
+    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) {
+  return internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20>(v1, v2, v3, v4, v5, v6, v7,
+      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21>
+internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21> Values(T1 v1, T2 v2, T3 v3, T4 v4,
+    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) {
+  return internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(v1, v2, v3, v4, v5, v6,
+      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22>
+internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22> Values(T1 v1, T2 v2, T3 v3,
+    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+    T21 v21, T22 v22) {
+  return internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>(v1, v2, v3, v4,
+      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+      v20, v21, v22);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23>
+internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> Values(T1 v1, T2 v2,
+    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+    T21 v21, T22 v22, T23 v23) {
+  return internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>(v1, v2, v3,
+      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+      v20, v21, v22, v23);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24>
+internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Values(T1 v1, T2 v2,
+    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+    T21 v21, T22 v22, T23 v23, T24 v24) {
+  return internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>(v1, v2,
+      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
+      v19, v20, v21, v22, v23, v24);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25>
+internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Values(T1 v1,
+    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
+    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
+    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) {
+  return internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25>(v1,
+      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
+      v18, v19, v20, v21, v22, v23, v24, v25);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26>
+internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+    T26> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26) {
+  return internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
+      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27>
+internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+    T27> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26, T27 v27) {
+  return internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
+      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28>
+internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+    T28> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26, T27 v27, T28 v28) {
+  return internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
+      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
+      v28);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29>
+internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26, T27 v27, T28 v28, T29 v29) {
+  return internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
+      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
+      v27, v28, v29);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30>
+internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
+    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
+    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
+    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) {
+  return internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
+      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
+      v26, v27, v28, v29, v30);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31>
+internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) {
+  return internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
+      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
+      v25, v26, v27, v28, v29, v30, v31);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32>
+internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+    T32 v32) {
+  return internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
+      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+      v24, v25, v26, v27, v28, v29, v30, v31, v32);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33>
+internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
+    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+    T32 v32, T33 v33) {
+  return internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33>(v1, v2, v3, v4, v5, v6, v7, v8,
+      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34>
+internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
+    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
+    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
+    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
+    T31 v31, T32 v32, T33 v33, T34 v34) {
+  return internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34>(v1, v2, v3, v4, v5, v6, v7,
+      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
+      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35>
+internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35> Values(T1 v1, T2 v2, T3 v3, T4 v4,
+    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
+    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
+    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) {
+  return internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35>(v1, v2, v3, v4, v5, v6,
+      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
+      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36>
+internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36> Values(T1 v1, T2 v2, T3 v3, T4 v4,
+    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
+    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
+    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) {
+  return internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36>(v1, v2, v3, v4,
+      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
+      v34, v35, v36);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37>
+internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37> Values(T1 v1, T2 v2, T3 v3,
+    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
+    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
+    T37 v37) {
+  return internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37>(v1, v2, v3,
+      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
+      v34, v35, v36, v37);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38>
+internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Values(T1 v1, T2 v2,
+    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
+    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
+    T37 v37, T38 v38) {
+  return internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38>(v1, v2,
+      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
+      v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32,
+      v33, v34, v35, v36, v37, v38);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39>
+internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Values(T1 v1, T2 v2,
+    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
+    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
+    T37 v37, T38 v38, T39 v39) {
+  return internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39>(v1,
+      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
+      v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+      v32, v33, v34, v35, v36, v37, v38, v39);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40>
+internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Values(T1 v1,
+    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
+    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
+    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27,
+    T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35,
+    T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) {
+  return internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
+      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29,
+      v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41>
+internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+    T41> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) {
+  return internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
+      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28,
+      v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42>
+internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+    T42> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+    T42 v42) {
+  return internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
+      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
+      v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41,
+      v42);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43>
+internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+    T43> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+    T42 v42, T43 v43) {
+  return internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
+      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
+      v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,
+      v41, v42, v43);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44>
+internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+    T42 v42, T43 v43, T44 v44) {
+  return internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43, T44>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
+      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
+      v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39,
+      v40, v41, v42, v43, v44);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45>
+internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44, T45> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
+    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
+    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
+    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
+    T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
+    T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) {
+  return internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43, T44, T45>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
+      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
+      v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38,
+      v39, v40, v41, v42, v43, v44, v45);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46>
+internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44, T45, T46> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
+    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) {
+  return internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43, T44, T45, T46>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
+      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
+      v38, v39, v40, v41, v42, v43, v44, v45, v46);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47>
+internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44, T45, T46, T47> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
+    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) {
+  return internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43, T44, T45, T46, T47>(v1, v2, v3, v4, v5, v6, v7, v8,
+      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
+      v38, v39, v40, v41, v42, v43, v44, v45, v46, v47);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48>
+internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44, T45, T46, T47, T48> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
+    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
+    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47,
+    T48 v48) {
+  return internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43, T44, T45, T46, T47, T48>(v1, v2, v3, v4, v5, v6, v7,
+      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
+      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36,
+      v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49>
+internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44, T45, T46, T47, T48, T49> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
+    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
+    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
+    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
+    T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38,
+    T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46,
+    T47 v47, T48 v48, T49 v49) {
+  return internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49>(v1, v2, v3, v4, v5, v6,
+      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
+      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35,
+      v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49, typename T50>
+internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44, T45, T46, T47, T48, T49, T50> Values(T1 v1, T2 v2, T3 v3, T4 v4,
+    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
+    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
+    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37,
+    T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45,
+    T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) {
+  return internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>(v1, v2, v3, v4,
+      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
+      v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47,
+      v48, v49, v50);
+}
+
+// Bool() allows generating tests with parameters in a set of (false, true).
+//
+// Synopsis:
+// Bool()
+//   - returns a generator producing sequences with elements {false, true}.
+//
+// It is useful when testing code that depends on Boolean flags. Combinations
+// of multiple flags can be tested when several Bool()'s are combined using
+// Combine() function.
+//
+// In the following example all tests in the test case FlagDependentTest
+// will be instantiated twice with parameters false and true.
+//
+// class FlagDependentTest : public testing::TestWithParam<bool> {
+//   virtual void SetUp() {
+//     external_flag = GetParam();
+//   }
+// }
+// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
+//
+inline internal::ParamGenerator<bool> Bool() {
+  return Values(false, true);
+}
+
+# if GTEST_HAS_COMBINE
+// Combine() allows the user to combine two or more sequences to produce
+// values of a Cartesian product of those sequences' elements.
+//
+// Synopsis:
+// Combine(gen1, gen2, ..., genN)
+//   - returns a generator producing sequences with elements coming from
+//     the Cartesian product of elements from the sequences generated by
+//     gen1, gen2, ..., genN. The sequence elements will have a type of
+//     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
+//     of elements from sequences produces by gen1, gen2, ..., genN.
+//
+// Combine can have up to 10 arguments. This number is currently limited
+// by the maximum number of elements in the tuple implementation used by Google
+// Test.
+//
+// Example:
+//
+// This will instantiate tests in test case AnimalTest each one with
+// the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
+// tuple("dog", BLACK), and tuple("dog", WHITE):
+//
+// enum Color { BLACK, GRAY, WHITE };
+// class AnimalTest
+//     : public testing::TestWithParam<tuple<const char*, Color> > {...};
+//
+// TEST_P(AnimalTest, AnimalLooksNice) {...}
+//
+// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
+//                         Combine(Values("cat", "dog"),
+//                                 Values(BLACK, WHITE)));
+//
+// This will instantiate tests in FlagDependentTest with all variations of two
+// Boolean flags:
+//
+// class FlagDependentTest
+//     : public testing::TestWithParam<tuple<bool, bool> > {
+//   virtual void SetUp() {
+//     // Assigns external_flag_1 and external_flag_2 values from the tuple.
+//     tie(external_flag_1, external_flag_2) = GetParam();
+//   }
+// };
+//
+// TEST_P(FlagDependentTest, TestFeature1) {
+//   // Test your code using external_flag_1 and external_flag_2 here.
+// }
+// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,
+//                         Combine(Bool(), Bool()));
+//
+template <typename Generator1, typename Generator2>
+internal::CartesianProductHolder2<Generator1, Generator2> Combine(
+    const Generator1& g1, const Generator2& g2) {
+  return internal::CartesianProductHolder2<Generator1, Generator2>(
+      g1, g2);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3>
+internal::CartesianProductHolder3<Generator1, Generator2, Generator3> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3) {
+  return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(
+      g1, g2, g3);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3,
+    typename Generator4>
+internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
+    Generator4> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3,
+        const Generator4& g4) {
+  return internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
+      Generator4>(
+      g1, g2, g3, g4);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3,
+    typename Generator4, typename Generator5>
+internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
+    Generator4, Generator5> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3,
+        const Generator4& g4, const Generator5& g5) {
+  return internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
+      Generator4, Generator5>(
+      g1, g2, g3, g4, g5);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3,
+    typename Generator4, typename Generator5, typename Generator6>
+internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
+    Generator4, Generator5, Generator6> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3,
+        const Generator4& g4, const Generator5& g5, const Generator6& g6) {
+  return internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
+      Generator4, Generator5, Generator6>(
+      g1, g2, g3, g4, g5, g6);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3,
+    typename Generator4, typename Generator5, typename Generator6,
+    typename Generator7>
+internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
+    Generator4, Generator5, Generator6, Generator7> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3,
+        const Generator4& g4, const Generator5& g5, const Generator6& g6,
+        const Generator7& g7) {
+  return internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
+      Generator4, Generator5, Generator6, Generator7>(
+      g1, g2, g3, g4, g5, g6, g7);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3,
+    typename Generator4, typename Generator5, typename Generator6,
+    typename Generator7, typename Generator8>
+internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
+    Generator4, Generator5, Generator6, Generator7, Generator8> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3,
+        const Generator4& g4, const Generator5& g5, const Generator6& g6,
+        const Generator7& g7, const Generator8& g8) {
+  return internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
+      Generator4, Generator5, Generator6, Generator7, Generator8>(
+      g1, g2, g3, g4, g5, g6, g7, g8);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3,
+    typename Generator4, typename Generator5, typename Generator6,
+    typename Generator7, typename Generator8, typename Generator9>
+internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
+    Generator4, Generator5, Generator6, Generator7, Generator8,
+    Generator9> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3,
+        const Generator4& g4, const Generator5& g5, const Generator6& g6,
+        const Generator7& g7, const Generator8& g8, const Generator9& g9) {
+  return internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
+      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9>(
+      g1, g2, g3, g4, g5, g6, g7, g8, g9);
+}
+
+template <typename Generator1, typename Generator2, typename Generator3,
+    typename Generator4, typename Generator5, typename Generator6,
+    typename Generator7, typename Generator8, typename Generator9,
+    typename Generator10>
+internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
+    Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
+    Generator10> Combine(
+    const Generator1& g1, const Generator2& g2, const Generator3& g3,
+        const Generator4& g4, const Generator5& g5, const Generator6& g6,
+        const Generator7& g7, const Generator8& g8, const Generator9& g9,
+        const Generator10& g10) {
+  return internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
+      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
+      Generator10>(
+      g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);
+}
+# endif  // GTEST_HAS_COMBINE
+
+
+
+# define TEST_P(test_case_name, test_name) \
+  class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
+      : public test_case_name { \
+   public: \
+    GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
+    virtual void TestBody(); \
+   private: \
+    static int AddToRegistry() { \
+      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
+          GetTestCasePatternHolder<test_case_name>(\
+              #test_case_name, __FILE__, __LINE__)->AddTestPattern(\
+                  #test_case_name, \
+                  #test_name, \
+                  new ::testing::internal::TestMetaFactory< \
+                      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
+      return 0; \
+    } \
+    static int gtest_registering_dummy_; \
+    GTEST_DISALLOW_COPY_AND_ASSIGN_(\
+        GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
+  }; \
+  int GTEST_TEST_CLASS_NAME_(test_case_name, \
+                             test_name)::gtest_registering_dummy_ = \
+      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
+  void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
+
+# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \
+  ::testing::internal::ParamGenerator<test_case_name::ParamType> \
+      gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
+  int gtest_##prefix##test_case_name##_dummy_ = \
+      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
+          GetTestCasePatternHolder<test_case_name>(\
+              #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\
+                  #prefix, \
+                  &gtest_##prefix##test_case_name##_EvalGenerator_, \
+                  __FILE__, __LINE__)
+
+}  // namespace testing
+
+#endif  // GTEST_HAS_PARAM_TEST
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
diff --git a/test/fmw/gtest/include/gtest/gtest-param-test.h.pump b/test/fmw/gtest/include/gtest/gtest-param-test.h.pump
new file mode 100644
index 0000000..2dc9303
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-param-test.h.pump
@@ -0,0 +1,487 @@
+$$ -*- mode: c++; -*-
+$var n = 50  $$ Maximum length of Values arguments we want to support.
+$var maxtuple = 10  $$ Maximum number of Combine arguments we want to support.
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: vladl@google.com (Vlad Losev)
+//
+// Macros and functions for implementing parameterized tests
+// in Google C++ Testing Framework (Google Test)
+//
+// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
+//
+#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
+#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
+
+
+// Value-parameterized tests allow you to test your code with different
+// parameters without writing multiple copies of the same test.
+//
+// Here is how you use value-parameterized tests:
+
+#if 0
+
+// To write value-parameterized tests, first you should define a fixture
+// class. It is usually derived from testing::TestWithParam<T> (see below for
+// another inheritance scheme that's sometimes useful in more complicated
+// class hierarchies), where the type of your parameter values.
+// TestWithParam<T> is itself derived from testing::Test. T can be any
+// copyable type. If it's a raw pointer, you are responsible for managing the
+// lifespan of the pointed values.
+
+class FooTest : public ::testing::TestWithParam<const char*> {
+  // You can implement all the usual class fixture members here.
+};
+
+// Then, use the TEST_P macro to define as many parameterized tests
+// for this fixture as you want. The _P suffix is for "parameterized"
+// or "pattern", whichever you prefer to think.
+
+TEST_P(FooTest, DoesBlah) {
+  // Inside a test, access the test parameter with the GetParam() method
+  // of the TestWithParam<T> class:
+  EXPECT_TRUE(foo.Blah(GetParam()));
+  ...
+}
+
+TEST_P(FooTest, HasBlahBlah) {
+  ...
+}
+
+// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
+// case with any set of parameters you want. Google Test defines a number
+// of functions for generating test parameters. They return what we call
+// (surprise!) parameter generators. Here is a  summary of them, which
+// are all in the testing namespace:
+//
+//
+//  Range(begin, end [, step]) - Yields values {begin, begin+step,
+//                               begin+step+step, ...}. The values do not
+//                               include end. step defaults to 1.
+//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.
+//  ValuesIn(container)        - Yields values from a C-style array, an STL
+//  ValuesIn(begin,end)          container, or an iterator range [begin, end).
+//  Bool()                     - Yields sequence {false, true}.
+//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product
+//                               for the math savvy) of the values generated
+//                               by the N generators.
+//
+// For more details, see comments at the definitions of these functions below
+// in this file.
+//
+// The following statement will instantiate tests from the FooTest test case
+// each with parameter values "meeny", "miny", and "moe".
+
+INSTANTIATE_TEST_CASE_P(InstantiationName,
+                        FooTest,
+                        Values("meeny", "miny", "moe"));
+
+// To distinguish different instances of the pattern, (yes, you
+// can instantiate it more then once) the first argument to the
+// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
+// actual test case name. Remember to pick unique prefixes for different
+// instantiations. The tests from the instantiation above will have
+// these names:
+//
+//    * InstantiationName/FooTest.DoesBlah/0 for "meeny"
+//    * InstantiationName/FooTest.DoesBlah/1 for "miny"
+//    * InstantiationName/FooTest.DoesBlah/2 for "moe"
+//    * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
+//    * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
+//    * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
+//
+// You can use these names in --gtest_filter.
+//
+// This statement will instantiate all tests from FooTest again, each
+// with parameter values "cat" and "dog":
+
+const char* pets[] = {"cat", "dog"};
+INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
+
+// The tests from the instantiation above will have these names:
+//
+//    * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
+//    * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
+//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
+//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
+//
+// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
+// in the given test case, whether their definitions come before or
+// AFTER the INSTANTIATE_TEST_CASE_P statement.
+//
+// Please also note that generator expressions (including parameters to the
+// generators) are evaluated in InitGoogleTest(), after main() has started.
+// This allows the user on one hand, to adjust generator parameters in order
+// to dynamically determine a set of tests to run and on the other hand,
+// give the user a chance to inspect the generated tests with Google Test
+// reflection API before RUN_ALL_TESTS() is executed.
+//
+// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
+// for more examples.
+//
+// In the future, we plan to publish the API for defining new parameter
+// generators. But for now this interface remains part of the internal
+// implementation and is subject to change.
+//
+//
+// A parameterized test fixture must be derived from testing::Test and from
+// testing::WithParamInterface<T>, where T is the type of the parameter
+// values. Inheriting from TestWithParam<T> satisfies that requirement because
+// TestWithParam<T> inherits from both Test and WithParamInterface. In more
+// complicated hierarchies, however, it is occasionally useful to inherit
+// separately from Test and WithParamInterface. For example:
+
+class BaseTest : public ::testing::Test {
+  // You can inherit all the usual members for a non-parameterized test
+  // fixture here.
+};
+
+class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
+  // The usual test fixture members go here too.
+};
+
+TEST_F(BaseTest, HasFoo) {
+  // This is an ordinary non-parameterized test.
+}
+
+TEST_P(DerivedTest, DoesBlah) {
+  // GetParam works just the same here as if you inherit from TestWithParam.
+  EXPECT_TRUE(foo.Blah(GetParam()));
+}
+
+#endif  // 0
+
+#include "gtest/internal/gtest-port.h"
+
+#if !GTEST_OS_SYMBIAN
+# include <utility>
+#endif
+
+// scripts/fuse_gtest.py depends on gtest's own header being #included
+// *unconditionally*.  Therefore these #includes cannot be moved
+// inside #if GTEST_HAS_PARAM_TEST.
+#include "gtest/internal/gtest-internal.h"
+#include "gtest/internal/gtest-param-util.h"
+#include "gtest/internal/gtest-param-util-generated.h"
+
+#if GTEST_HAS_PARAM_TEST
+
+namespace testing {
+
+// Functions producing parameter generators.
+//
+// Google Test uses these generators to produce parameters for value-
+// parameterized tests. When a parameterized test case is instantiated
+// with a particular generator, Google Test creates and runs tests
+// for each element in the sequence produced by the generator.
+//
+// In the following sample, tests from test case FooTest are instantiated
+// each three times with parameter values 3, 5, and 8:
+//
+// class FooTest : public TestWithParam<int> { ... };
+//
+// TEST_P(FooTest, TestThis) {
+// }
+// TEST_P(FooTest, TestThat) {
+// }
+// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
+//
+
+// Range() returns generators providing sequences of values in a range.
+//
+// Synopsis:
+// Range(start, end)
+//   - returns a generator producing a sequence of values {start, start+1,
+//     start+2, ..., }.
+// Range(start, end, step)
+//   - returns a generator producing a sequence of values {start, start+step,
+//     start+step+step, ..., }.
+// Notes:
+//   * The generated sequences never include end. For example, Range(1, 5)
+//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
+//     returns a generator producing {1, 3, 5, 7}.
+//   * start and end must have the same type. That type may be any integral or
+//     floating-point type or a user defined type satisfying these conditions:
+//     * It must be assignable (have operator=() defined).
+//     * It must have operator+() (operator+(int-compatible type) for
+//       two-operand version).
+//     * It must have operator<() defined.
+//     Elements in the resulting sequences will also have that type.
+//   * Condition start < end must be satisfied in order for resulting sequences
+//     to contain any elements.
+//
+template <typename T, typename IncrementT>
+internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
+  return internal::ParamGenerator<T>(
+      new internal::RangeGenerator<T, IncrementT>(start, end, step));
+}
+
+template <typename T>
+internal::ParamGenerator<T> Range(T start, T end) {
+  return Range(start, end, 1);
+}
+
+// ValuesIn() function allows generation of tests with parameters coming from
+// a container.
+//
+// Synopsis:
+// ValuesIn(const T (&array)[N])
+//   - returns a generator producing sequences with elements from
+//     a C-style array.
+// ValuesIn(const Container& container)
+//   - returns a generator producing sequences with elements from
+//     an STL-style container.
+// ValuesIn(Iterator begin, Iterator end)
+//   - returns a generator producing sequences with elements from
+//     a range [begin, end) defined by a pair of STL-style iterators. These
+//     iterators can also be plain C pointers.
+//
+// Please note that ValuesIn copies the values from the containers
+// passed in and keeps them to generate tests in RUN_ALL_TESTS().
+//
+// Examples:
+//
+// This instantiates tests from test case StringTest
+// each with C-string values of "foo", "bar", and "baz":
+//
+// const char* strings[] = {"foo", "bar", "baz"};
+// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
+//
+// This instantiates tests from test case StlStringTest
+// each with STL strings with values "a" and "b":
+//
+// ::std::vector< ::std::string> GetParameterStrings() {
+//   ::std::vector< ::std::string> v;
+//   v.push_back("a");
+//   v.push_back("b");
+//   return v;
+// }
+//
+// INSTANTIATE_TEST_CASE_P(CharSequence,
+//                         StlStringTest,
+//                         ValuesIn(GetParameterStrings()));
+//
+//
+// This will also instantiate tests from CharTest
+// each with parameter values 'a' and 'b':
+//
+// ::std::list<char> GetParameterChars() {
+//   ::std::list<char> list;
+//   list.push_back('a');
+//   list.push_back('b');
+//   return list;
+// }
+// ::std::list<char> l = GetParameterChars();
+// INSTANTIATE_TEST_CASE_P(CharSequence2,
+//                         CharTest,
+//                         ValuesIn(l.begin(), l.end()));
+//
+template <typename ForwardIterator>
+internal::ParamGenerator<
+  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
+ValuesIn(ForwardIterator begin, ForwardIterator end) {
+  typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
+      ::value_type ParamType;
+  return internal::ParamGenerator<ParamType>(
+      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
+}
+
+template <typename T, size_t N>
+internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
+  return ValuesIn(array, array + N);
+}
+
+template <class Container>
+internal::ParamGenerator<typename Container::value_type> ValuesIn(
+    const Container& container) {
+  return ValuesIn(container.begin(), container.end());
+}
+
+// Values() allows generating tests from explicitly specified list of
+// parameters.
+//
+// Synopsis:
+// Values(T v1, T v2, ..., T vN)
+//   - returns a generator producing sequences with elements v1, v2, ..., vN.
+//
+// For example, this instantiates tests from test case BarTest each
+// with values "one", "two", and "three":
+//
+// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
+//
+// This instantiates tests from test case BazTest each with values 1, 2, 3.5.
+// The exact type of values will depend on the type of parameter in BazTest.
+//
+// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
+//
+// Currently, Values() supports from 1 to $n parameters.
+//
+$range i 1..n
+$for i [[
+$range j 1..i
+
+template <$for j, [[typename T$j]]>
+internal::ValueArray$i<$for j, [[T$j]]> Values($for j, [[T$j v$j]]) {
+  return internal::ValueArray$i<$for j, [[T$j]]>($for j, [[v$j]]);
+}
+
+]]
+
+// Bool() allows generating tests with parameters in a set of (false, true).
+//
+// Synopsis:
+// Bool()
+//   - returns a generator producing sequences with elements {false, true}.
+//
+// It is useful when testing code that depends on Boolean flags. Combinations
+// of multiple flags can be tested when several Bool()'s are combined using
+// Combine() function.
+//
+// In the following example all tests in the test case FlagDependentTest
+// will be instantiated twice with parameters false and true.
+//
+// class FlagDependentTest : public testing::TestWithParam<bool> {
+//   virtual void SetUp() {
+//     external_flag = GetParam();
+//   }
+// }
+// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
+//
+inline internal::ParamGenerator<bool> Bool() {
+  return Values(false, true);
+}
+
+# if GTEST_HAS_COMBINE
+// Combine() allows the user to combine two or more sequences to produce
+// values of a Cartesian product of those sequences' elements.
+//
+// Synopsis:
+// Combine(gen1, gen2, ..., genN)
+//   - returns a generator producing sequences with elements coming from
+//     the Cartesian product of elements from the sequences generated by
+//     gen1, gen2, ..., genN. The sequence elements will have a type of
+//     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
+//     of elements from sequences produces by gen1, gen2, ..., genN.
+//
+// Combine can have up to $maxtuple arguments. This number is currently limited
+// by the maximum number of elements in the tuple implementation used by Google
+// Test.
+//
+// Example:
+//
+// This will instantiate tests in test case AnimalTest each one with
+// the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
+// tuple("dog", BLACK), and tuple("dog", WHITE):
+//
+// enum Color { BLACK, GRAY, WHITE };
+// class AnimalTest
+//     : public testing::TestWithParam<tuple<const char*, Color> > {...};
+//
+// TEST_P(AnimalTest, AnimalLooksNice) {...}
+//
+// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
+//                         Combine(Values("cat", "dog"),
+//                                 Values(BLACK, WHITE)));
+//
+// This will instantiate tests in FlagDependentTest with all variations of two
+// Boolean flags:
+//
+// class FlagDependentTest
+//     : public testing::TestWithParam<tuple<bool, bool> > {
+//   virtual void SetUp() {
+//     // Assigns external_flag_1 and external_flag_2 values from the tuple.
+//     tie(external_flag_1, external_flag_2) = GetParam();
+//   }
+// };
+//
+// TEST_P(FlagDependentTest, TestFeature1) {
+//   // Test your code using external_flag_1 and external_flag_2 here.
+// }
+// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,
+//                         Combine(Bool(), Bool()));
+//
+$range i 2..maxtuple
+$for i [[
+$range j 1..i
+
+template <$for j, [[typename Generator$j]]>
+internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
+    $for j, [[const Generator$j& g$j]]) {
+  return internal::CartesianProductHolder$i<$for j, [[Generator$j]]>(
+      $for j, [[g$j]]);
+}
+
+]]
+# endif  // GTEST_HAS_COMBINE
+
+
+
+# define TEST_P(test_case_name, test_name) \
+  class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
+      : public test_case_name { \
+   public: \
+    GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
+    virtual void TestBody(); \
+   private: \
+    static int AddToRegistry() { \
+      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
+          GetTestCasePatternHolder<test_case_name>(\
+              #test_case_name, __FILE__, __LINE__)->AddTestPattern(\
+                  #test_case_name, \
+                  #test_name, \
+                  new ::testing::internal::TestMetaFactory< \
+                      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
+      return 0; \
+    } \
+    static int gtest_registering_dummy_; \
+    GTEST_DISALLOW_COPY_AND_ASSIGN_(\
+        GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
+  }; \
+  int GTEST_TEST_CLASS_NAME_(test_case_name, \
+                             test_name)::gtest_registering_dummy_ = \
+      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
+  void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
+
+# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \
+  ::testing::internal::ParamGenerator<test_case_name::ParamType> \
+      gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
+  int gtest_##prefix##test_case_name##_dummy_ = \
+      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
+          GetTestCasePatternHolder<test_case_name>(\
+              #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\
+                  #prefix, \
+                  &gtest_##prefix##test_case_name##_EvalGenerator_, \
+                  __FILE__, __LINE__)
+
+}  // namespace testing
+
+#endif  // GTEST_HAS_PARAM_TEST
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
diff --git a/test/fmw/gtest/include/gtest/gtest-printers.h b/test/fmw/gtest/include/gtest/gtest-printers.h
new file mode 100644
index 0000000..0639d9f
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-printers.h
@@ -0,0 +1,855 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Test - The Google C++ Testing Framework
+//
+// This file implements a universal value printer that can print a
+// value of any type T:
+//
+//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
+//
+// A user can teach this function how to print a class type T by
+// defining either operator<<() or PrintTo() in the namespace that
+// defines T.  More specifically, the FIRST defined function in the
+// following list will be used (assuming T is defined in namespace
+// foo):
+//
+//   1. foo::PrintTo(const T&, ostream*)
+//   2. operator<<(ostream&, const T&) defined in either foo or the
+//      global namespace.
+//
+// If none of the above is defined, it will print the debug string of
+// the value if it is a protocol buffer, or print the raw bytes in the
+// value otherwise.
+//
+// To aid debugging: when T is a reference type, the address of the
+// value is also printed; when T is a (const) char pointer, both the
+// pointer value and the NUL-terminated string it points to are
+// printed.
+//
+// We also provide some convenient wrappers:
+//
+//   // Prints a value to a string.  For a (const or not) char
+//   // pointer, the NUL-terminated string (but not the pointer) is
+//   // printed.
+//   std::string ::testing::PrintToString(const T& value);
+//
+//   // Prints a value tersely: for a reference type, the referenced
+//   // value (but not the address) is printed; for a (const or not) char
+//   // pointer, the NUL-terminated string (but not the pointer) is
+//   // printed.
+//   void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
+//
+//   // Prints value using the type inferred by the compiler.  The difference
+//   // from UniversalTersePrint() is that this function prints both the
+//   // pointer and the NUL-terminated string for a (const or not) char pointer.
+//   void ::testing::internal::UniversalPrint(const T& value, ostream*);
+//
+//   // Prints the fields of a tuple tersely to a string vector, one
+//   // element for each field. Tuple support must be enabled in
+//   // gtest-port.h.
+//   std::vector<string> UniversalTersePrintTupleFieldsToStrings(
+//       const Tuple& value);
+//
+// Known limitation:
+//
+// The print primitives print the elements of an STL-style container
+// using the compiler-inferred type of *iter where iter is a
+// const_iterator of the container.  When const_iterator is an input
+// iterator but not a forward iterator, this inferred type may not
+// match value_type, and the print output may be incorrect.  In
+// practice, this is rarely a problem as for most containers
+// const_iterator is a forward iterator.  We'll fix this if there's an
+// actual need for it.  Note that this fix cannot rely on value_type
+// being defined as many user-defined container types don't have
+// value_type.
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
+#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
+
+#include <ostream>  // NOLINT
+#include <sstream>
+#include <string>
+#include <utility>
+#include <vector>
+#include "gtest/internal/gtest-port.h"
+#include "gtest/internal/gtest-internal.h"
+
+namespace testing {
+
+// Definitions in the 'internal' and 'internal2' name spaces are
+// subject to change without notice.  DO NOT USE THEM IN USER CODE!
+namespace internal2 {
+
+// Prints the given number of bytes in the given object to the given
+// ostream.
+GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
+                                     size_t count,
+                                     ::std::ostream* os);
+
+// For selecting which printer to use when a given type has neither <<
+// nor PrintTo().
+enum TypeKind {
+  kProtobuf,              // a protobuf type
+  kConvertibleToInteger,  // a type implicitly convertible to BiggestInt
+                          // (e.g. a named or unnamed enum type)
+  kOtherType              // anything else
+};
+
+// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
+// by the universal printer to print a value of type T when neither
+// operator<< nor PrintTo() is defined for T, where kTypeKind is the
+// "kind" of T as defined by enum TypeKind.
+template <typename T, TypeKind kTypeKind>
+class TypeWithoutFormatter {
+ public:
+  // This default version is called when kTypeKind is kOtherType.
+  static void PrintValue(const T& value, ::std::ostream* os) {
+    PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),
+                         sizeof(value), os);
+  }
+};
+
+// We print a protobuf using its ShortDebugString() when the string
+// doesn't exceed this many characters; otherwise we print it using
+// DebugString() for better readability.
+const size_t kProtobufOneLinerMaxLength = 50;
+
+template <typename T>
+class TypeWithoutFormatter<T, kProtobuf> {
+ public:
+  static void PrintValue(const T& value, ::std::ostream* os) {
+    const ::testing::internal::string short_str = value.ShortDebugString();
+    const ::testing::internal::string pretty_str =
+        short_str.length() <= kProtobufOneLinerMaxLength ?
+        short_str : ("\n" + value.DebugString());
+    *os << ("<" + pretty_str + ">");
+  }
+};
+
+template <typename T>
+class TypeWithoutFormatter<T, kConvertibleToInteger> {
+ public:
+  // Since T has no << operator or PrintTo() but can be implicitly
+  // converted to BiggestInt, we print it as a BiggestInt.
+  //
+  // Most likely T is an enum type (either named or unnamed), in which
+  // case printing it as an integer is the desired behavior.  In case
+  // T is not an enum, printing it as an integer is the best we can do
+  // given that it has no user-defined printer.
+  static void PrintValue(const T& value, ::std::ostream* os) {
+    const internal::BiggestInt kBigInt = value;
+    *os << kBigInt;
+  }
+};
+
+// Prints the given value to the given ostream.  If the value is a
+// protocol message, its debug string is printed; if it's an enum or
+// of a type implicitly convertible to BiggestInt, it's printed as an
+// integer; otherwise the bytes in the value are printed.  This is
+// what UniversalPrinter<T>::Print() does when it knows nothing about
+// type T and T has neither << operator nor PrintTo().
+//
+// A user can override this behavior for a class type Foo by defining
+// a << operator in the namespace where Foo is defined.
+//
+// We put this operator in namespace 'internal2' instead of 'internal'
+// to simplify the implementation, as much code in 'internal' needs to
+// use << in STL, which would conflict with our own << were it defined
+// in 'internal'.
+//
+// Note that this operator<< takes a generic std::basic_ostream<Char,
+// CharTraits> type instead of the more restricted std::ostream.  If
+// we define it to take an std::ostream instead, we'll get an
+// "ambiguous overloads" compiler error when trying to print a type
+// Foo that supports streaming to std::basic_ostream<Char,
+// CharTraits>, as the compiler cannot tell whether
+// operator<<(std::ostream&, const T&) or
+// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
+// specific.
+template <typename Char, typename CharTraits, typename T>
+::std::basic_ostream<Char, CharTraits>& operator<<(
+    ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
+  TypeWithoutFormatter<T,
+      (internal::IsAProtocolMessage<T>::value ? kProtobuf :
+       internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?
+       kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);
+  return os;
+}
+
+}  // namespace internal2
+}  // namespace testing
+
+// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
+// magic needed for implementing UniversalPrinter won't work.
+namespace testing_internal {
+
+// Used to print a value that is not an STL-style container when the
+// user doesn't define PrintTo() for it.
+template <typename T>
+void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
+  // With the following statement, during unqualified name lookup,
+  // testing::internal2::operator<< appears as if it was declared in
+  // the nearest enclosing namespace that contains both
+  // ::testing_internal and ::testing::internal2, i.e. the global
+  // namespace.  For more details, refer to the C++ Standard section
+  // 7.3.4-1 [namespace.udir].  This allows us to fall back onto
+  // testing::internal2::operator<< in case T doesn't come with a <<
+  // operator.
+  //
+  // We cannot write 'using ::testing::internal2::operator<<;', which
+  // gcc 3.3 fails to compile due to a compiler bug.
+  using namespace ::testing::internal2;  // NOLINT
+
+  // Assuming T is defined in namespace foo, in the next statement,
+  // the compiler will consider all of:
+  //
+  //   1. foo::operator<< (thanks to Koenig look-up),
+  //   2. ::operator<< (as the current namespace is enclosed in ::),
+  //   3. testing::internal2::operator<< (thanks to the using statement above).
+  //
+  // The operator<< whose type matches T best will be picked.
+  //
+  // We deliberately allow #2 to be a candidate, as sometimes it's
+  // impossible to define #1 (e.g. when foo is ::std, defining
+  // anything in it is undefined behavior unless you are a compiler
+  // vendor.).
+  *os << value;
+}
+
+}  // namespace testing_internal
+
+namespace testing {
+namespace internal {
+
+// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
+// value to the given ostream.  The caller must ensure that
+// 'ostream_ptr' is not NULL, or the behavior is undefined.
+//
+// We define UniversalPrinter as a class template (as opposed to a
+// function template), as we need to partially specialize it for
+// reference types, which cannot be done with function templates.
+template <typename T>
+class UniversalPrinter;
+
+template <typename T>
+void UniversalPrint(const T& value, ::std::ostream* os);
+
+// Used to print an STL-style container when the user doesn't define
+// a PrintTo() for it.
+template <typename C>
+void DefaultPrintTo(IsContainer /* dummy */,
+                    false_type /* is not a pointer */,
+                    const C& container, ::std::ostream* os) {
+  const size_t kMaxCount = 32;  // The maximum number of elements to print.
+  *os << '{';
+  size_t count = 0;
+  for (typename C::const_iterator it = container.begin();
+       it != container.end(); ++it, ++count) {
+    if (count > 0) {
+      *os << ',';
+      if (count == kMaxCount) {  // Enough has been printed.
+        *os << " ...";
+        break;
+      }
+    }
+    *os << ' ';
+    // We cannot call PrintTo(*it, os) here as PrintTo() doesn't
+    // handle *it being a native array.
+    internal::UniversalPrint(*it, os);
+  }
+
+  if (count > 0) {
+    *os << ' ';
+  }
+  *os << '}';
+}
+
+// Used to print a pointer that is neither a char pointer nor a member
+// pointer, when the user doesn't define PrintTo() for it.  (A member
+// variable pointer or member function pointer doesn't really point to
+// a location in the address space.  Their representation is
+// implementation-defined.  Therefore they will be printed as raw
+// bytes.)
+template <typename T>
+void DefaultPrintTo(IsNotContainer /* dummy */,
+                    true_type /* is a pointer */,
+                    T* p, ::std::ostream* os) {
+  if (p == NULL) {
+    *os << "NULL";
+  } else {
+    // C++ doesn't allow casting from a function pointer to any object
+    // pointer.
+    //
+    // IsTrue() silences warnings: "Condition is always true",
+    // "unreachable code".
+    if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {
+      // T is not a function type.  We just call << to print p,
+      // relying on ADL to pick up user-defined << for their pointer
+      // types, if any.
+      *os << p;
+    } else {
+      // T is a function type, so '*os << p' doesn't do what we want
+      // (it just prints p as bool).  We want to print p as a const
+      // void*.  However, we cannot cast it to const void* directly,
+      // even using reinterpret_cast, as earlier versions of gcc
+      // (e.g. 3.4.5) cannot compile the cast when p is a function
+      // pointer.  Casting to UInt64 first solves the problem.
+      *os << reinterpret_cast<const void*>(
+          reinterpret_cast<internal::UInt64>(p));
+    }
+  }
+}
+
+// Used to print a non-container, non-pointer value when the user
+// doesn't define PrintTo() for it.
+template <typename T>
+void DefaultPrintTo(IsNotContainer /* dummy */,
+                    false_type /* is not a pointer */,
+                    const T& value, ::std::ostream* os) {
+  ::testing_internal::DefaultPrintNonContainerTo(value, os);
+}
+
+// Prints the given value using the << operator if it has one;
+// otherwise prints the bytes in it.  This is what
+// UniversalPrinter<T>::Print() does when PrintTo() is not specialized
+// or overloaded for type T.
+//
+// A user can override this behavior for a class type Foo by defining
+// an overload of PrintTo() in the namespace where Foo is defined.  We
+// give the user this option as sometimes defining a << operator for
+// Foo is not desirable (e.g. the coding style may prevent doing it,
+// or there is already a << operator but it doesn't do what the user
+// wants).
+template <typename T>
+void PrintTo(const T& value, ::std::ostream* os) {
+  // DefaultPrintTo() is overloaded.  The type of its first two
+  // arguments determine which version will be picked.  If T is an
+  // STL-style container, the version for container will be called; if
+  // T is a pointer, the pointer version will be called; otherwise the
+  // generic version will be called.
+  //
+  // Note that we check for container types here, prior to we check
+  // for protocol message types in our operator<<.  The rationale is:
+  //
+  // For protocol messages, we want to give people a chance to
+  // override Google Mock's format by defining a PrintTo() or
+  // operator<<.  For STL containers, other formats can be
+  // incompatible with Google Mock's format for the container
+  // elements; therefore we check for container types here to ensure
+  // that our format is used.
+  //
+  // The second argument of DefaultPrintTo() is needed to bypass a bug
+  // in Symbian's C++ compiler that prevents it from picking the right
+  // overload between:
+  //
+  //   PrintTo(const T& x, ...);
+  //   PrintTo(T* x, ...);
+  DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);
+}
+
+// The following list of PrintTo() overloads tells
+// UniversalPrinter<T>::Print() how to print standard types (built-in
+// types, strings, plain arrays, and pointers).
+
+// Overloads for various char types.
+GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
+GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
+inline void PrintTo(char c, ::std::ostream* os) {
+  // When printing a plain char, we always treat it as unsigned.  This
+  // way, the output won't be affected by whether the compiler thinks
+  // char is signed or not.
+  PrintTo(static_cast<unsigned char>(c), os);
+}
+
+// Overloads for other simple built-in types.
+inline void PrintTo(bool x, ::std::ostream* os) {
+  *os << (x ? "true" : "false");
+}
+
+// Overload for wchar_t type.
+// Prints a wchar_t as a symbol if it is printable or as its internal
+// code otherwise and also as its decimal code (except for L'\0').
+// The L'\0' char is printed as "L'\\0'". The decimal code is printed
+// as signed integer when wchar_t is implemented by the compiler
+// as a signed type and is printed as an unsigned integer when wchar_t
+// is implemented as an unsigned type.
+GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
+
+// Overloads for C strings.
+GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
+inline void PrintTo(char* s, ::std::ostream* os) {
+  PrintTo(ImplicitCast_<const char*>(s), os);
+}
+
+// signed/unsigned char is often used for representing binary data, so
+// we print pointers to it as void* to be safe.
+inline void PrintTo(const signed char* s, ::std::ostream* os) {
+  PrintTo(ImplicitCast_<const void*>(s), os);
+}
+inline void PrintTo(signed char* s, ::std::ostream* os) {
+  PrintTo(ImplicitCast_<const void*>(s), os);
+}
+inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
+  PrintTo(ImplicitCast_<const void*>(s), os);
+}
+inline void PrintTo(unsigned char* s, ::std::ostream* os) {
+  PrintTo(ImplicitCast_<const void*>(s), os);
+}
+
+// MSVC can be configured to define wchar_t as a typedef of unsigned
+// short.  It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
+// type.  When wchar_t is a typedef, defining an overload for const
+// wchar_t* would cause unsigned short* be printed as a wide string,
+// possibly causing invalid memory accesses.
+#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
+// Overloads for wide C strings
+GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
+inline void PrintTo(wchar_t* s, ::std::ostream* os) {
+  PrintTo(ImplicitCast_<const wchar_t*>(s), os);
+}
+#endif
+
+// Overload for C arrays.  Multi-dimensional arrays are printed
+// properly.
+
+// Prints the given number of elements in an array, without printing
+// the curly braces.
+template <typename T>
+void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
+  UniversalPrint(a[0], os);
+  for (size_t i = 1; i != count; i++) {
+    *os << ", ";
+    UniversalPrint(a[i], os);
+  }
+}
+
+// Overloads for ::string and ::std::string.
+#if GTEST_HAS_GLOBAL_STRING
+GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);
+inline void PrintTo(const ::string& s, ::std::ostream* os) {
+  PrintStringTo(s, os);
+}
+#endif  // GTEST_HAS_GLOBAL_STRING
+
+GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
+inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
+  PrintStringTo(s, os);
+}
+
+// Overloads for ::wstring and ::std::wstring.
+#if GTEST_HAS_GLOBAL_WSTRING
+GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
+inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
+  PrintWideStringTo(s, os);
+}
+#endif  // GTEST_HAS_GLOBAL_WSTRING
+
+#if GTEST_HAS_STD_WSTRING
+GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
+inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
+  PrintWideStringTo(s, os);
+}
+#endif  // GTEST_HAS_STD_WSTRING
+
+#if GTEST_HAS_TR1_TUPLE
+// Overload for ::std::tr1::tuple.  Needed for printing function arguments,
+// which are packed as tuples.
+
+// Helper function for printing a tuple.  T must be instantiated with
+// a tuple type.
+template <typename T>
+void PrintTupleTo(const T& t, ::std::ostream* os);
+
+// Overloaded PrintTo() for tuples of various arities.  We support
+// tuples of up-to 10 fields.  The following implementation works
+// regardless of whether tr1::tuple is implemented using the
+// non-standard variadic template feature or not.
+
+inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1>
+void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2>
+void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3>
+void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3, typename T4>
+void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
+             ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6>
+void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
+             ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7>
+void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
+             ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7, typename T8>
+void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
+             ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7, typename T8, typename T9>
+void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
+             ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7, typename T8, typename T9, typename T10>
+void PrintTo(
+    const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
+    ::std::ostream* os) {
+  PrintTupleTo(t, os);
+}
+#endif  // GTEST_HAS_TR1_TUPLE
+
+// Overload for std::pair.
+template <typename T1, typename T2>
+void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
+  *os << '(';
+  // We cannot use UniversalPrint(value.first, os) here, as T1 may be
+  // a reference type.  The same for printing value.second.
+  UniversalPrinter<T1>::Print(value.first, os);
+  *os << ", ";
+  UniversalPrinter<T2>::Print(value.second, os);
+  *os << ')';
+}
+
+// Implements printing a non-reference type T by letting the compiler
+// pick the right overload of PrintTo() for T.
+template <typename T>
+class UniversalPrinter {
+ public:
+  // MSVC warns about adding const to a function type, so we want to
+  // disable the warning.
+#ifdef _MSC_VER
+# pragma warning(push)          // Saves the current warning state.
+# pragma warning(disable:4180)  // Temporarily disables warning 4180.
+#endif  // _MSC_VER
+
+  // Note: we deliberately don't call this PrintTo(), as that name
+  // conflicts with ::testing::internal::PrintTo in the body of the
+  // function.
+  static void Print(const T& value, ::std::ostream* os) {
+    // By default, ::testing::internal::PrintTo() is used for printing
+    // the value.
+    //
+    // Thanks to Koenig look-up, if T is a class and has its own
+    // PrintTo() function defined in its namespace, that function will
+    // be visible here.  Since it is more specific than the generic ones
+    // in ::testing::internal, it will be picked by the compiler in the
+    // following statement - exactly what we want.
+    PrintTo(value, os);
+  }
+
+#ifdef _MSC_VER
+# pragma warning(pop)           // Restores the warning state.
+#endif  // _MSC_VER
+};
+
+// UniversalPrintArray(begin, len, os) prints an array of 'len'
+// elements, starting at address 'begin'.
+template <typename T>
+void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
+  if (len == 0) {
+    *os << "{}";
+  } else {
+    *os << "{ ";
+    const size_t kThreshold = 18;
+    const size_t kChunkSize = 8;
+    // If the array has more than kThreshold elements, we'll have to
+    // omit some details by printing only the first and the last
+    // kChunkSize elements.
+    // TODO(wan@google.com): let the user control the threshold using a flag.
+    if (len <= kThreshold) {
+      PrintRawArrayTo(begin, len, os);
+    } else {
+      PrintRawArrayTo(begin, kChunkSize, os);
+      *os << ", ..., ";
+      PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
+    }
+    *os << " }";
+  }
+}
+// This overload prints a (const) char array compactly.
+GTEST_API_ void UniversalPrintArray(
+    const char* begin, size_t len, ::std::ostream* os);
+
+// This overload prints a (const) wchar_t array compactly.
+GTEST_API_ void UniversalPrintArray(
+    const wchar_t* begin, size_t len, ::std::ostream* os);
+
+// Implements printing an array type T[N].
+template <typename T, size_t N>
+class UniversalPrinter<T[N]> {
+ public:
+  // Prints the given array, omitting some elements when there are too
+  // many.
+  static void Print(const T (&a)[N], ::std::ostream* os) {
+    UniversalPrintArray(a, N, os);
+  }
+};
+
+// Implements printing a reference type T&.
+template <typename T>
+class UniversalPrinter<T&> {
+ public:
+  // MSVC warns about adding const to a function type, so we want to
+  // disable the warning.
+#ifdef _MSC_VER
+# pragma warning(push)          // Saves the current warning state.
+# pragma warning(disable:4180)  // Temporarily disables warning 4180.
+#endif  // _MSC_VER
+
+  static void Print(const T& value, ::std::ostream* os) {
+    // Prints the address of the value.  We use reinterpret_cast here
+    // as static_cast doesn't compile when T is a function type.
+    *os << "@" << reinterpret_cast<const void*>(&value) << " ";
+
+    // Then prints the value itself.
+    UniversalPrint(value, os);
+  }
+
+#ifdef _MSC_VER
+# pragma warning(pop)           // Restores the warning state.
+#endif  // _MSC_VER
+};
+
+// Prints a value tersely: for a reference type, the referenced value
+// (but not the address) is printed; for a (const) char pointer, the
+// NUL-terminated string (but not the pointer) is printed.
+
+template <typename T>
+class UniversalTersePrinter {
+ public:
+  static void Print(const T& value, ::std::ostream* os) {
+    UniversalPrint(value, os);
+  }
+};
+template <typename T>
+class UniversalTersePrinter<T&> {
+ public:
+  static void Print(const T& value, ::std::ostream* os) {
+    UniversalPrint(value, os);
+  }
+};
+template <typename T, size_t N>
+class UniversalTersePrinter<T[N]> {
+ public:
+  static void Print(const T (&value)[N], ::std::ostream* os) {
+    UniversalPrinter<T[N]>::Print(value, os);
+  }
+};
+template <>
+class UniversalTersePrinter<const char*> {
+ public:
+  static void Print(const char* str, ::std::ostream* os) {
+    if (str == NULL) {
+      *os << "NULL";
+    } else {
+      UniversalPrint(string(str), os);
+    }
+  }
+};
+template <>
+class UniversalTersePrinter<char*> {
+ public:
+  static void Print(char* str, ::std::ostream* os) {
+    UniversalTersePrinter<const char*>::Print(str, os);
+  }
+};
+
+#if GTEST_HAS_STD_WSTRING
+template <>
+class UniversalTersePrinter<const wchar_t*> {
+ public:
+  static void Print(const wchar_t* str, ::std::ostream* os) {
+    if (str == NULL) {
+      *os << "NULL";
+    } else {
+      UniversalPrint(::std::wstring(str), os);
+    }
+  }
+};
+#endif
+
+template <>
+class UniversalTersePrinter<wchar_t*> {
+ public:
+  static void Print(wchar_t* str, ::std::ostream* os) {
+    UniversalTersePrinter<const wchar_t*>::Print(str, os);
+  }
+};
+
+template <typename T>
+void UniversalTersePrint(const T& value, ::std::ostream* os) {
+  UniversalTersePrinter<T>::Print(value, os);
+}
+
+// Prints a value using the type inferred by the compiler.  The
+// difference between this and UniversalTersePrint() is that for a
+// (const) char pointer, this prints both the pointer and the
+// NUL-terminated string.
+template <typename T>
+void UniversalPrint(const T& value, ::std::ostream* os) {
+  // A workarond for the bug in VC++ 7.1 that prevents us from instantiating
+  // UniversalPrinter with T directly.
+  typedef T T1;
+  UniversalPrinter<T1>::Print(value, os);
+}
+
+#if GTEST_HAS_TR1_TUPLE
+typedef ::std::vector<string> Strings;
+
+// This helper template allows PrintTo() for tuples and
+// UniversalTersePrintTupleFieldsToStrings() to be defined by
+// induction on the number of tuple fields.  The idea is that
+// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N
+// fields in tuple t, and can be defined in terms of
+// TuplePrefixPrinter<N - 1>.
+
+// The inductive case.
+template <size_t N>
+struct TuplePrefixPrinter {
+  // Prints the first N fields of a tuple.
+  template <typename Tuple>
+  static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
+    TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
+    *os << ", ";
+    UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
+        ::Print(::std::tr1::get<N - 1>(t), os);
+  }
+
+  // Tersely prints the first N fields of a tuple to a string vector,
+  // one element for each field.
+  template <typename Tuple>
+  static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
+    TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
+    ::std::stringstream ss;
+    UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
+    strings->push_back(ss.str());
+  }
+};
+
+// Base cases.
+template <>
+struct TuplePrefixPrinter<0> {
+  template <typename Tuple>
+  static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
+
+  template <typename Tuple>
+  static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
+};
+// We have to specialize the entire TuplePrefixPrinter<> class
+// template here, even though the definition of
+// TersePrintPrefixToStrings() is the same as the generic version, as
+// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't
+// support specializing a method template of a class template.
+template <>
+struct TuplePrefixPrinter<1> {
+  template <typename Tuple>
+  static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
+    UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
+        Print(::std::tr1::get<0>(t), os);
+  }
+
+  template <typename Tuple>
+  static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
+    ::std::stringstream ss;
+    UniversalTersePrint(::std::tr1::get<0>(t), &ss);
+    strings->push_back(ss.str());
+  }
+};
+
+// Helper function for printing a tuple.  T must be instantiated with
+// a tuple type.
+template <typename T>
+void PrintTupleTo(const T& t, ::std::ostream* os) {
+  *os << "(";
+  TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
+      PrintPrefixTo(t, os);
+  *os << ")";
+}
+
+// Prints the fields of a tuple tersely to a string vector, one
+// element for each field.  See the comment before
+// UniversalTersePrint() for how we define "tersely".
+template <typename Tuple>
+Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
+  Strings result;
+  TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
+      TersePrintPrefixToStrings(value, &result);
+  return result;
+}
+#endif  // GTEST_HAS_TR1_TUPLE
+
+}  // namespace internal
+
+template <typename T>
+::std::string PrintToString(const T& value) {
+  ::std::stringstream ss;
+  internal::UniversalTersePrinter<T>::Print(value, &ss);
+  return ss.str();
+}
+
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
diff --git a/test/fmw/gtest/include/gtest/gtest-spi.h b/test/fmw/gtest/include/gtest/gtest-spi.h
new file mode 100644
index 0000000..f63fa9a
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-spi.h
@@ -0,0 +1,232 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// Utilities for testing Google Test itself and code that uses Google Test
+// (e.g. frameworks built on top of Google Test).
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_
+#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_
+
+#include "gtest/gtest.h"
+
+namespace testing {
+
+// This helper class can be used to mock out Google Test failure reporting
+// so that we can test Google Test or code that builds on Google Test.
+//
+// An object of this class appends a TestPartResult object to the
+// TestPartResultArray object given in the constructor whenever a Google Test
+// failure is reported. It can either intercept only failures that are
+// generated in the same thread that created this object or it can intercept
+// all generated failures. The scope of this mock object can be controlled with
+// the second argument to the two arguments constructor.
+class GTEST_API_ ScopedFakeTestPartResultReporter
+    : public TestPartResultReporterInterface {
+ public:
+  // The two possible mocking modes of this object.
+  enum InterceptMode {
+    INTERCEPT_ONLY_CURRENT_THREAD,  // Intercepts only thread local failures.
+    INTERCEPT_ALL_THREADS           // Intercepts all failures.
+  };
+
+  // The c'tor sets this object as the test part result reporter used
+  // by Google Test.  The 'result' parameter specifies where to report the
+  // results. This reporter will only catch failures generated in the current
+  // thread. DEPRECATED
+  explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);
+
+  // Same as above, but you can choose the interception scope of this object.
+  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,
+                                   TestPartResultArray* result);
+
+  // The d'tor restores the previous test part result reporter.
+  virtual ~ScopedFakeTestPartResultReporter();
+
+  // Appends the TestPartResult object to the TestPartResultArray
+  // received in the constructor.
+  //
+  // This method is from the TestPartResultReporterInterface
+  // interface.
+  virtual void ReportTestPartResult(const TestPartResult& result);
+ private:
+  void Init();
+
+  const InterceptMode intercept_mode_;
+  TestPartResultReporterInterface* old_reporter_;
+  TestPartResultArray* const result_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
+};
+
+namespace internal {
+
+// A helper class for implementing EXPECT_FATAL_FAILURE() and
+// EXPECT_NONFATAL_FAILURE().  Its destructor verifies that the given
+// TestPartResultArray contains exactly one failure that has the given
+// type and contains the given substring.  If that's not the case, a
+// non-fatal failure will be generated.
+class GTEST_API_ SingleFailureChecker {
+ public:
+  // The constructor remembers the arguments.
+  SingleFailureChecker(const TestPartResultArray* results,
+                       TestPartResult::Type type,
+                       const string& substr);
+  ~SingleFailureChecker();
+ private:
+  const TestPartResultArray* const results_;
+  const TestPartResult::Type type_;
+  const string substr_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
+};
+
+}  // namespace internal
+
+}  // namespace testing
+
+// A set of macros for testing Google Test assertions or code that's expected
+// to generate Google Test fatal failures.  It verifies that the given
+// statement will cause exactly one fatal Google Test failure with 'substr'
+// being part of the failure message.
+//
+// There are two different versions of this macro. EXPECT_FATAL_FAILURE only
+// affects and considers failures generated in the current thread and
+// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
+//
+// The verification of the assertion is done correctly even when the statement
+// throws an exception or aborts the current function.
+//
+// Known restrictions:
+//   - 'statement' cannot reference local non-static variables or
+//     non-static members of the current object.
+//   - 'statement' cannot return a value.
+//   - You cannot stream a failure message to this macro.
+//
+// Note that even though the implementations of the following two
+// macros are much alike, we cannot refactor them to use a common
+// helper macro, due to some peculiarity in how the preprocessor
+// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in
+// gtest_unittest.cc will fail to compile if we do that.
+#define EXPECT_FATAL_FAILURE(statement, substr) \
+  do { \
+    class GTestExpectFatalFailureHelper {\
+     public:\
+      static void Execute() { statement; }\
+    };\
+    ::testing::TestPartResultArray gtest_failures;\
+    ::testing::internal::SingleFailureChecker gtest_checker(\
+        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
+    {\
+      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+          ::testing::ScopedFakeTestPartResultReporter:: \
+          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
+      GTestExpectFatalFailureHelper::Execute();\
+    }\
+  } while (::testing::internal::AlwaysFalse())
+
+#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
+  do { \
+    class GTestExpectFatalFailureHelper {\
+     public:\
+      static void Execute() { statement; }\
+    };\
+    ::testing::TestPartResultArray gtest_failures;\
+    ::testing::internal::SingleFailureChecker gtest_checker(\
+        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
+    {\
+      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+          ::testing::ScopedFakeTestPartResultReporter:: \
+          INTERCEPT_ALL_THREADS, &gtest_failures);\
+      GTestExpectFatalFailureHelper::Execute();\
+    }\
+  } while (::testing::internal::AlwaysFalse())
+
+// A macro for testing Google Test assertions or code that's expected to
+// generate Google Test non-fatal failures.  It asserts that the given
+// statement will cause exactly one non-fatal Google Test failure with 'substr'
+// being part of the failure message.
+//
+// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
+// affects and considers failures generated in the current thread and
+// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
+//
+// 'statement' is allowed to reference local variables and members of
+// the current object.
+//
+// The verification of the assertion is done correctly even when the statement
+// throws an exception or aborts the current function.
+//
+// Known restrictions:
+//   - You cannot stream a failure message to this macro.
+//
+// Note that even though the implementations of the following two
+// macros are much alike, we cannot refactor them to use a common
+// helper macro, due to some peculiarity in how the preprocessor
+// works.  If we do that, the code won't compile when the user gives
+// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that
+// expands to code containing an unprotected comma.  The
+// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc
+// catches that.
+//
+// For the same reason, we have to write
+//   if (::testing::internal::AlwaysTrue()) { statement; }
+// instead of
+//   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
+// to avoid an MSVC warning on unreachable code.
+#define EXPECT_NONFATAL_FAILURE(statement, substr) \
+  do {\
+    ::testing::TestPartResultArray gtest_failures;\
+    ::testing::internal::SingleFailureChecker gtest_checker(\
+        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
+        (substr));\
+    {\
+      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+          ::testing::ScopedFakeTestPartResultReporter:: \
+          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
+      if (::testing::internal::AlwaysTrue()) { statement; }\
+    }\
+  } while (::testing::internal::AlwaysFalse())
+
+#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
+  do {\
+    ::testing::TestPartResultArray gtest_failures;\
+    ::testing::internal::SingleFailureChecker gtest_checker(\
+        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
+        (substr));\
+    {\
+      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+          ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \
+          &gtest_failures);\
+      if (::testing::internal::AlwaysTrue()) { statement; }\
+    }\
+  } while (::testing::internal::AlwaysFalse())
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_SPI_H_
diff --git a/test/fmw/gtest/include/gtest/gtest-test-part.h b/test/fmw/gtest/include/gtest/gtest-test-part.h
new file mode 100644
index 0000000..77eb844
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-test-part.h
@@ -0,0 +1,179 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: mheule@google.com (Markus Heule)
+//
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
+#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
+
+#include <iosfwd>
+#include <vector>
+#include "gtest/internal/gtest-internal.h"
+#include "gtest/internal/gtest-string.h"
+
+namespace testing {
+
+// A copyable object representing the result of a test part (i.e. an
+// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
+//
+// Don't inherit from TestPartResult as its destructor is not virtual.
+class GTEST_API_ TestPartResult {
+ public:
+  // The possible outcomes of a test part (i.e. an assertion or an
+  // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
+  enum Type {
+    kSuccess,          // Succeeded.
+    kNonFatalFailure,  // Failed but the test can continue.
+    kFatalFailure      // Failed and the test should be terminated.
+  };
+
+  // C'tor.  TestPartResult does NOT have a default constructor.
+  // Always use this constructor (with parameters) to create a
+  // TestPartResult object.
+  TestPartResult(Type a_type,
+                 const char* a_file_name,
+                 int a_line_number,
+                 const char* a_message)
+      : type_(a_type),
+        file_name_(a_file_name == NULL ? "" : a_file_name),
+        line_number_(a_line_number),
+        summary_(ExtractSummary(a_message)),
+        message_(a_message) {
+  }
+
+  // Gets the outcome of the test part.
+  Type type() const { return type_; }
+
+  // Gets the name of the source file where the test part took place, or
+  // NULL if it's unknown.
+  const char* file_name() const {
+    return file_name_.empty() ? NULL : file_name_.c_str();
+  }
+
+  // Gets the line in the source file where the test part took place,
+  // or -1 if it's unknown.
+  int line_number() const { return line_number_; }
+
+  // Gets the summary of the failure message.
+  const char* summary() const { return summary_.c_str(); }
+
+  // Gets the message associated with the test part.
+  const char* message() const { return message_.c_str(); }
+
+  // Returns true iff the test part passed.
+  bool passed() const { return type_ == kSuccess; }
+
+  // Returns true iff the test part failed.
+  bool failed() const { return type_ != kSuccess; }
+
+  // Returns true iff the test part non-fatally failed.
+  bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
+
+  // Returns true iff the test part fatally failed.
+  bool fatally_failed() const { return type_ == kFatalFailure; }
+
+ private:
+  Type type_;
+
+  // Gets the summary of the failure message by omitting the stack
+  // trace in it.
+  static std::string ExtractSummary(const char* message);
+
+  // The name of the source file where the test part took place, or
+  // "" if the source file is unknown.
+  std::string file_name_;
+  // The line in the source file where the test part took place, or -1
+  // if the line number is unknown.
+  int line_number_;
+  std::string summary_;  // The test failure summary.
+  std::string message_;  // The test failure message.
+};
+
+// Prints a TestPartResult object.
+std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
+
+// An array of TestPartResult objects.
+//
+// Don't inherit from TestPartResultArray as its destructor is not
+// virtual.
+class GTEST_API_ TestPartResultArray {
+ public:
+  TestPartResultArray() {}
+
+  // Appends the given TestPartResult to the array.
+  void Append(const TestPartResult& result);
+
+  // Returns the TestPartResult at the given index (0-based).
+  const TestPartResult& GetTestPartResult(int index) const;
+
+  // Returns the number of TestPartResult objects in the array.
+  int size() const;
+
+ private:
+  std::vector<TestPartResult> array_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
+};
+
+// This interface knows how to report a test part result.
+class TestPartResultReporterInterface {
+ public:
+  virtual ~TestPartResultReporterInterface() {}
+
+  virtual void ReportTestPartResult(const TestPartResult& result) = 0;
+};
+
+namespace internal {
+
+// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
+// statement generates new fatal failures. To do so it registers itself as the
+// current test part result reporter. Besides checking if fatal failures were
+// reported, it only delegates the reporting to the former result reporter.
+// The original result reporter is restored in the destructor.
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+class GTEST_API_ HasNewFatalFailureHelper
+    : public TestPartResultReporterInterface {
+ public:
+  HasNewFatalFailureHelper();
+  virtual ~HasNewFatalFailureHelper();
+  virtual void ReportTestPartResult(const TestPartResult& result);
+  bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
+ private:
+  bool has_new_fatal_failure_;
+  TestPartResultReporterInterface* original_reporter_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
+};
+
+}  // namespace internal
+
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
diff --git a/test/fmw/gtest/include/gtest/gtest-typed-test.h b/test/fmw/gtest/include/gtest/gtest-typed-test.h
new file mode 100644
index 0000000..fe1e83b
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest-typed-test.h
@@ -0,0 +1,259 @@
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
+#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
+
+// This header implements typed tests and type-parameterized tests.
+
+// Typed (aka type-driven) tests repeat the same test for types in a
+// list.  You must know which types you want to test with when writing
+// typed tests. Here's how you do it:
+
+#if 0
+
+// First, define a fixture class template.  It should be parameterized
+// by a type.  Remember to derive it from testing::Test.
+template <typename T>
+class FooTest : public testing::Test {
+ public:
+  ...
+  typedef std::list<T> List;
+  static T shared_;
+  T value_;
+};
+
+// Next, associate a list of types with the test case, which will be
+// repeated for each type in the list.  The typedef is necessary for
+// the macro to parse correctly.
+typedef testing::Types<char, int, unsigned int> MyTypes;
+TYPED_TEST_CASE(FooTest, MyTypes);
+
+// If the type list contains only one type, you can write that type
+// directly without Types<...>:
+//   TYPED_TEST_CASE(FooTest, int);
+
+// Then, use TYPED_TEST() instead of TEST_F() to define as many typed
+// tests for this test case as you want.
+TYPED_TEST(FooTest, DoesBlah) {
+  // Inside a test, refer to TypeParam to get the type parameter.
+  // Since we are inside a derived class template, C++ requires use to
+  // visit the members of FooTest via 'this'.
+  TypeParam n = this->value_;
+
+  // To visit static members of the fixture, add the TestFixture::
+  // prefix.
+  n += TestFixture::shared_;
+
+  // To refer to typedefs in the fixture, add the "typename
+  // TestFixture::" prefix.
+  typename TestFixture::List values;
+  values.push_back(n);
+  ...
+}
+
+TYPED_TEST(FooTest, HasPropertyA) { ... }
+
+#endif  // 0
+
+// Type-parameterized tests are abstract test patterns parameterized
+// by a type.  Compared with typed tests, type-parameterized tests
+// allow you to define the test pattern without knowing what the type
+// parameters are.  The defined pattern can be instantiated with
+// different types any number of times, in any number of translation
+// units.
+//
+// If you are designing an interface or concept, you can define a
+// suite of type-parameterized tests to verify properties that any
+// valid implementation of the interface/concept should have.  Then,
+// each implementation can easily instantiate the test suite to verify
+// that it conforms to the requirements, without having to write
+// similar tests repeatedly.  Here's an example:
+
+#if 0
+
+// First, define a fixture class template.  It should be parameterized
+// by a type.  Remember to derive it from testing::Test.
+template <typename T>
+class FooTest : public testing::Test {
+  ...
+};
+
+// Next, declare that you will define a type-parameterized test case
+// (the _P suffix is for "parameterized" or "pattern", whichever you
+// prefer):
+TYPED_TEST_CASE_P(FooTest);
+
+// Then, use TYPED_TEST_P() to define as many type-parameterized tests
+// for this type-parameterized test case as you want.
+TYPED_TEST_P(FooTest, DoesBlah) {
+  // Inside a test, refer to TypeParam to get the type parameter.
+  TypeParam n = 0;
+  ...
+}
+
+TYPED_TEST_P(FooTest, HasPropertyA) { ... }
+
+// Now the tricky part: you need to register all test patterns before
+// you can instantiate them.  The first argument of the macro is the
+// test case name; the rest are the names of the tests in this test
+// case.
+REGISTER_TYPED_TEST_CASE_P(FooTest,
+                           DoesBlah, HasPropertyA);
+
+// Finally, you are free to instantiate the pattern with the types you
+// want.  If you put the above code in a header file, you can #include
+// it in multiple C++ source files and instantiate it multiple times.
+//
+// To distinguish different instances of the pattern, the first
+// argument to the INSTANTIATE_* macro is a prefix that will be added
+// to the actual test case name.  Remember to pick unique prefixes for
+// different instances.
+typedef testing::Types<char, int, unsigned int> MyTypes;
+INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
+
+// If the type list contains only one type, you can write that type
+// directly without Types<...>:
+//   INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);
+
+#endif  // 0
+
+#include "gtest/internal/gtest-port.h"
+#include "gtest/internal/gtest-type-util.h"
+
+// Implements typed tests.
+
+#if GTEST_HAS_TYPED_TEST
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Expands to the name of the typedef for the type parameters of the
+// given test case.
+# define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
+
+// The 'Types' template argument below must have spaces around it
+// since some compilers may choke on '>>' when passing a template
+// instance (e.g. Types<int>)
+# define TYPED_TEST_CASE(CaseName, Types) \
+  typedef ::testing::internal::TypeList< Types >::type \
+      GTEST_TYPE_PARAMS_(CaseName)
+
+# define TYPED_TEST(CaseName, TestName) \
+  template <typename gtest_TypeParam_> \
+  class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
+      : public CaseName<gtest_TypeParam_> { \
+   private: \
+    typedef CaseName<gtest_TypeParam_> TestFixture; \
+    typedef gtest_TypeParam_ TypeParam; \
+    virtual void TestBody(); \
+  }; \
+  bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \
+      ::testing::internal::TypeParameterizedTest< \
+          CaseName, \
+          ::testing::internal::TemplateSel< \
+              GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
+          GTEST_TYPE_PARAMS_(CaseName)>::Register(\
+              "", #CaseName, #TestName, 0); \
+  template <typename gtest_TypeParam_> \
+  void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()
+
+#endif  // GTEST_HAS_TYPED_TEST
+
+// Implements type-parameterized tests.
+
+#if GTEST_HAS_TYPED_TEST_P
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Expands to the namespace name that the type-parameterized tests for
+// the given type-parameterized test case are defined in.  The exact
+// name of the namespace is subject to change without notice.
+# define GTEST_CASE_NAMESPACE_(TestCaseName) \
+  gtest_case_##TestCaseName##_
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Expands to the name of the variable used to remember the names of
+// the defined tests in the given test case.
+# define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
+  gtest_typed_test_case_p_state_##TestCaseName##_
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
+//
+// Expands to the name of the variable used to remember the names of
+// the registered tests in the given test case.
+# define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
+  gtest_registered_test_names_##TestCaseName##_
+
+// The variables defined in the type-parameterized test macros are
+// static as typically these macros are used in a .h file that can be
+// #included in multiple translation units linked together.
+# define TYPED_TEST_CASE_P(CaseName) \
+  static ::testing::internal::TypedTestCasePState \
+      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
+
+# define TYPED_TEST_P(CaseName, TestName) \
+  namespace GTEST_CASE_NAMESPACE_(CaseName) { \
+  template <typename gtest_TypeParam_> \
+  class TestName : public CaseName<gtest_TypeParam_> { \
+   private: \
+    typedef CaseName<gtest_TypeParam_> TestFixture; \
+    typedef gtest_TypeParam_ TypeParam; \
+    virtual void TestBody(); \
+  }; \
+  static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
+      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
+          __FILE__, __LINE__, #CaseName, #TestName); \
+  } \
+  template <typename gtest_TypeParam_> \
+  void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()
+
+# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
+  namespace GTEST_CASE_NAMESPACE_(CaseName) { \
+  typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
+  } \
+  static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \
+      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
+          __FILE__, __LINE__, #__VA_ARGS__)
+
+// The 'Types' template argument below must have spaces around it
+// since some compilers may choke on '>>' when passing a template
+// instance (e.g. Types<int>)
+# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
+  bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \
+      ::testing::internal::TypeParameterizedTestCase<CaseName, \
+          GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
+          ::testing::internal::TypeList< Types >::type>::Register(\
+              #Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
+
+#endif  // GTEST_HAS_TYPED_TEST_P
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
diff --git a/test/fmw/gtest/include/gtest/gtest.h b/test/fmw/gtest/include/gtest/gtest.h
new file mode 100644
index 0000000..6fa0a39
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest.h
@@ -0,0 +1,2291 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file defines the public API for Google Test.  It should be
+// included by any test program that uses Google Test.
+//
+// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
+// leave some internal implementation details in this header file.
+// They are clearly marked by comments like this:
+//
+//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+//
+// Such code is NOT meant to be used by a user directly, and is subject
+// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
+// program!
+//
+// Acknowledgment: Google Test borrowed the idea of automatic test
+// registration from Barthelemy Dagenais' (barthelemy@prologique.com)
+// easyUnit framework.
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
+#define GTEST_INCLUDE_GTEST_GTEST_H_
+
+#include <limits>
+#include <ostream>
+#include <vector>
+
+#include "gtest/internal/gtest-internal.h"
+#include "gtest/internal/gtest-string.h"
+#include "gtest/gtest-death-test.h"
+#include "gtest/gtest-message.h"
+#include "gtest/gtest-param-test.h"
+#include "gtest/gtest-printers.h"
+#include "gtest/gtest_prod.h"
+#include "gtest/gtest-test-part.h"
+#include "gtest/gtest-typed-test.h"
+
+// Depending on the platform, different string classes are available.
+// On Linux, in addition to ::std::string, Google also makes use of
+// class ::string, which has the same interface as ::std::string, but
+// has a different implementation.
+//
+// The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that
+// ::string is available AND is a distinct type to ::std::string, or
+// define it to 0 to indicate otherwise.
+//
+// If the user's ::std::string and ::string are the same class due to
+// aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0.
+//
+// If the user doesn't define GTEST_HAS_GLOBAL_STRING, it is defined
+// heuristically.
+
+namespace testing {
+
+// Declares the flags.
+
+// This flag temporary enables the disabled tests.
+GTEST_DECLARE_bool_(also_run_disabled_tests);
+
+// This flag brings the debugger on an assertion failure.
+GTEST_DECLARE_bool_(break_on_failure);
+
+// This flag controls whether Google Test catches all test-thrown exceptions
+// and logs them as failures.
+GTEST_DECLARE_bool_(catch_exceptions);
+
+// This flag enables using colors in terminal output. Available values are
+// "yes" to enable colors, "no" (disable colors), or "auto" (the default)
+// to let Google Test decide.
+GTEST_DECLARE_string_(color);
+
+// This flag sets up the filter to select by name using a glob pattern
+// the tests to run. If the filter is not given all tests are executed.
+GTEST_DECLARE_string_(filter);
+
+// This flag causes the Google Test to list tests. None of the tests listed
+// are actually run if the flag is provided.
+GTEST_DECLARE_bool_(list_tests);
+
+// This flag controls whether Google Test emits a detailed XML report to a file
+// in addition to its normal textual output.
+GTEST_DECLARE_string_(output);
+
+// This flags control whether Google Test prints the elapsed time for each
+// test.
+GTEST_DECLARE_bool_(print_time);
+
+// This flag specifies the random number seed.
+GTEST_DECLARE_int32_(random_seed);
+
+// This flag sets how many times the tests are repeated. The default value
+// is 1. If the value is -1 the tests are repeating forever.
+GTEST_DECLARE_int32_(repeat);
+
+// This flag controls whether Google Test includes Google Test internal
+// stack frames in failure stack traces.
+GTEST_DECLARE_bool_(show_internal_stack_frames);
+
+// When this flag is specified, tests' order is randomized on every iteration.
+GTEST_DECLARE_bool_(shuffle);
+
+// This flag specifies the maximum number of stack frames to be
+// printed in a failure message.
+GTEST_DECLARE_int32_(stack_trace_depth);
+
+// When this flag is specified, a failed assertion will throw an
+// exception if exceptions are enabled, or exit the program with a
+// non-zero code otherwise.
+GTEST_DECLARE_bool_(throw_on_failure);
+
+// When this flag is set with a "host:port" string, on supported
+// platforms test results are streamed to the specified port on
+// the specified host machine.
+GTEST_DECLARE_string_(stream_result_to);
+
+// The upper limit for valid stack trace depths.
+const int kMaxStackTraceDepth = 100;
+
+namespace internal {
+
+class AssertHelper;
+class DefaultGlobalTestPartResultReporter;
+class ExecDeathTest;
+class NoExecDeathTest;
+class FinalSuccessChecker;
+class GTestFlagSaver;
+class StreamingListenerTest;
+class TestResultAccessor;
+class TestEventListenersAccessor;
+class TestEventRepeater;
+class UnitTestRecordPropertyTestHelper;
+class WindowsDeathTest;
+class UnitTestImpl* GetUnitTestImpl();
+void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
+                                    const std::string& message);
+
+}  // namespace internal
+
+// The friend relationship of some of these classes is cyclic.
+// If we don't forward declare them the compiler might confuse the classes
+// in friendship clauses with same named classes on the scope.
+class Test;
+class TestCase;
+class TestInfo;
+class UnitTest;
+
+// A class for indicating whether an assertion was successful.  When
+// the assertion wasn't successful, the AssertionResult object
+// remembers a non-empty message that describes how it failed.
+//
+// To create an instance of this class, use one of the factory functions
+// (AssertionSuccess() and AssertionFailure()).
+//
+// This class is useful for two purposes:
+//   1. Defining predicate functions to be used with Boolean test assertions
+//      EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts
+//   2. Defining predicate-format functions to be
+//      used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
+//
+// For example, if you define IsEven predicate:
+//
+//   testing::AssertionResult IsEven(int n) {
+//     if ((n % 2) == 0)
+//       return testing::AssertionSuccess();
+//     else
+//       return testing::AssertionFailure() << n << " is odd";
+//   }
+//
+// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))
+// will print the message
+//
+//   Value of: IsEven(Fib(5))
+//     Actual: false (5 is odd)
+//   Expected: true
+//
+// instead of a more opaque
+//
+//   Value of: IsEven(Fib(5))
+//     Actual: false
+//   Expected: true
+//
+// in case IsEven is a simple Boolean predicate.
+//
+// If you expect your predicate to be reused and want to support informative
+// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up
+// about half as often as positive ones in our tests), supply messages for
+// both success and failure cases:
+//
+//   testing::AssertionResult IsEven(int n) {
+//     if ((n % 2) == 0)
+//       return testing::AssertionSuccess() << n << " is even";
+//     else
+//       return testing::AssertionFailure() << n << " is odd";
+//   }
+//
+// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print
+//
+//   Value of: IsEven(Fib(6))
+//     Actual: true (8 is even)
+//   Expected: false
+//
+// NB: Predicates that support negative Boolean assertions have reduced
+// performance in positive ones so be careful not to use them in tests
+// that have lots (tens of thousands) of positive Boolean assertions.
+//
+// To use this class with EXPECT_PRED_FORMAT assertions such as:
+//
+//   // Verifies that Foo() returns an even number.
+//   EXPECT_PRED_FORMAT1(IsEven, Foo());
+//
+// you need to define:
+//
+//   testing::AssertionResult IsEven(const char* expr, int n) {
+//     if ((n % 2) == 0)
+//       return testing::AssertionSuccess();
+//     else
+//       return testing::AssertionFailure()
+//         << "Expected: " << expr << " is even\n  Actual: it's " << n;
+//   }
+//
+// If Foo() returns 5, you will see the following message:
+//
+//   Expected: Foo() is even
+//     Actual: it's 5
+//
+class GTEST_API_ AssertionResult {
+ public:
+  // Copy constructor.
+  // Used in EXPECT_TRUE/FALSE(assertion_result).
+  AssertionResult(const AssertionResult& other);
+  // Used in the EXPECT_TRUE/FALSE(bool_expression).
+  explicit AssertionResult(bool success) : success_(success) {}
+
+  // Returns true iff the assertion succeeded.
+  operator bool() const { return success_; }  // NOLINT
+
+  // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
+  AssertionResult operator!() const;
+
+  // Returns the text streamed into this AssertionResult. Test assertions
+  // use it when they fail (i.e., the predicate's outcome doesn't match the
+  // assertion's expectation). When nothing has been streamed into the
+  // object, returns an empty string.
+  const char* message() const {
+    return message_.get() != NULL ?  message_->c_str() : "";
+  }
+  // TODO(vladl@google.com): Remove this after making sure no clients use it.
+  // Deprecated; please use message() instead.
+  const char* failure_message() const { return message(); }
+
+  // Streams a custom failure message into this object.
+  template <typename T> AssertionResult& operator<<(const T& value) {
+    AppendMessage(Message() << value);
+    return *this;
+  }
+
+  // Allows streaming basic output manipulators such as endl or flush into
+  // this object.
+  AssertionResult& operator<<(
+      ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
+    AppendMessage(Message() << basic_manipulator);
+    return *this;
+  }
+
+ private:
+  // Appends the contents of message to message_.
+  void AppendMessage(const Message& a_message) {
+    if (message_.get() == NULL)
+      message_.reset(new ::std::string);
+    message_->append(a_message.GetString().c_str());
+  }
+
+  // Stores result of the assertion predicate.
+  bool success_;
+  // Stores the message describing the condition in case the expectation
+  // construct is not satisfied with the predicate's outcome.
+  // Referenced via a pointer to avoid taking too much stack frame space
+  // with test assertions.
+  internal::scoped_ptr< ::std::string> message_;
+
+  GTEST_DISALLOW_ASSIGN_(AssertionResult);
+};
+
+// Makes a successful assertion result.
+GTEST_API_ AssertionResult AssertionSuccess();
+
+// Makes a failed assertion result.
+GTEST_API_ AssertionResult AssertionFailure();
+
+// Makes a failed assertion result with the given failure message.
+// Deprecated; use AssertionFailure() << msg.
+GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
+
+// The abstract class that all tests inherit from.
+//
+// In Google Test, a unit test program contains one or many TestCases, and
+// each TestCase contains one or many Tests.
+//
+// When you define a test using the TEST macro, you don't need to
+// explicitly derive from Test - the TEST macro automatically does
+// this for you.
+//
+// The only time you derive from Test is when defining a test fixture
+// to be used a TEST_F.  For example:
+//
+//   class FooTest : public testing::Test {
+//    protected:
+//     virtual void SetUp() { ... }
+//     virtual void TearDown() { ... }
+//     ...
+//   };
+//
+//   TEST_F(FooTest, Bar) { ... }
+//   TEST_F(FooTest, Baz) { ... }
+//
+// Test is not copyable.
+class GTEST_API_ Test {
+ public:
+  friend class TestInfo;
+
+  // Defines types for pointers to functions that set up and tear down
+  // a test case.
+  typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc;
+  typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc;
+
+  // The d'tor is virtual as we intend to inherit from Test.
+  virtual ~Test();
+
+  // Sets up the stuff shared by all tests in this test case.
+  //
+  // Google Test will call Foo::SetUpTestCase() before running the first
+  // test in test case Foo.  Hence a sub-class can define its own
+  // SetUpTestCase() method to shadow the one defined in the super
+  // class.
+  static void SetUpTestCase() {}
+
+  // Tears down the stuff shared by all tests in this test case.
+  //
+  // Google Test will call Foo::TearDownTestCase() after running the last
+  // test in test case Foo.  Hence a sub-class can define its own
+  // TearDownTestCase() method to shadow the one defined in the super
+  // class.
+  static void TearDownTestCase() {}
+
+  // Returns true iff the current test has a fatal failure.
+  static bool HasFatalFailure();
+
+  // Returns true iff the current test has a non-fatal failure.
+  static bool HasNonfatalFailure();
+
+  // Returns true iff the current test has a (either fatal or
+  // non-fatal) failure.
+  static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
+
+  // Logs a property for the current test, test case, or for the entire
+  // invocation of the test program when used outside of the context of a
+  // test case.  Only the last value for a given key is remembered.  These
+  // are public static so they can be called from utility functions that are
+  // not members of the test fixture.  Calls to RecordProperty made during
+  // lifespan of the test (from the moment its constructor starts to the
+  // moment its destructor finishes) will be output in XML as attributes of
+  // the <testcase> element.  Properties recorded from fixture's
+  // SetUpTestCase or TearDownTestCase are logged as attributes of the
+  // corresponding <testsuite> element.  Calls to RecordProperty made in the
+  // global context (before or after invocation of RUN_ALL_TESTS and from
+  // SetUp/TearDown method of Environment objects registered with Google
+  // Test) will be output as attributes of the <testsuites> element.
+  static void RecordProperty(const std::string& key, const std::string& value);
+  static void RecordProperty(const std::string& key, int value);
+
+ protected:
+  // Creates a Test object.
+  Test();
+
+  // Sets up the test fixture.
+  virtual void SetUp();
+
+  // Tears down the test fixture.
+  virtual void TearDown();
+
+ private:
+  // Returns true iff the current test has the same fixture class as
+  // the first test in the current test case.
+  static bool HasSameFixtureClass();
+
+  // Runs the test after the test fixture has been set up.
+  //
+  // A sub-class must implement this to define the test logic.
+  //
+  // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.
+  // Instead, use the TEST or TEST_F macro.
+  virtual void TestBody() = 0;
+
+  // Sets up, executes, and tears down the test.
+  void Run();
+
+  // Deletes self.  We deliberately pick an unusual name for this
+  // internal method to avoid clashing with names used in user TESTs.
+  void DeleteSelf_() { delete this; }
+
+  // Uses a GTestFlagSaver to save and restore all Google Test flags.
+  const internal::GTestFlagSaver* const gtest_flag_saver_;
+
+  // Often a user mis-spells SetUp() as Setup() and spends a long time
+  // wondering why it is never called by Google Test.  The declaration of
+  // the following method is solely for catching such an error at
+  // compile time:
+  //
+  //   - The return type is deliberately chosen to be not void, so it
+  //   will be a conflict if a user declares void Setup() in his test
+  //   fixture.
+  //
+  //   - This method is private, so it will be another compiler error
+  //   if a user calls it from his test fixture.
+  //
+  // DO NOT OVERRIDE THIS FUNCTION.
+  //
+  // If you see an error about overriding the following function or
+  // about it being private, you have mis-spelled SetUp() as Setup().
+  struct Setup_should_be_spelled_SetUp {};
+  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
+
+  // We disallow copying Tests.
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
+};
+
+typedef internal::TimeInMillis TimeInMillis;
+
+// A copyable object representing a user specified test property which can be
+// output as a key/value string pair.
+//
+// Don't inherit from TestProperty as its destructor is not virtual.
+class TestProperty {
+ public:
+  // C'tor.  TestProperty does NOT have a default constructor.
+  // Always use this constructor (with parameters) to create a
+  // TestProperty object.
+  TestProperty(const std::string& a_key, const std::string& a_value) :
+    key_(a_key), value_(a_value) {
+  }
+
+  // Gets the user supplied key.
+  const char* key() const {
+    return key_.c_str();
+  }
+
+  // Gets the user supplied value.
+  const char* value() const {
+    return value_.c_str();
+  }
+
+  // Sets a new value, overriding the one supplied in the constructor.
+  void SetValue(const std::string& new_value) {
+    value_ = new_value;
+  }
+
+ private:
+  // The key supplied by the user.
+  std::string key_;
+  // The value supplied by the user.
+  std::string value_;
+};
+
+// The result of a single Test.  This includes a list of
+// TestPartResults, a list of TestProperties, a count of how many
+// death tests there are in the Test, and how much time it took to run
+// the Test.
+//
+// TestResult is not copyable.
+class GTEST_API_ TestResult {
+ public:
+  // Creates an empty TestResult.
+  TestResult();
+
+  // D'tor.  Do not inherit from TestResult.
+  ~TestResult();
+
+  // Gets the number of all test parts.  This is the sum of the number
+  // of successful test parts and the number of failed test parts.
+  int total_part_count() const;
+
+  // Returns the number of the test properties.
+  int test_property_count() const;
+
+  // Returns true iff the test passed (i.e. no test part failed).
+  bool Passed() const { return !Failed(); }
+
+  // Returns true iff the test failed.
+  bool Failed() const;
+
+  // Returns true iff the test fatally failed.
+  bool HasFatalFailure() const;
+
+  // Returns true iff the test has a non-fatal failure.
+  bool HasNonfatalFailure() const;
+
+  // Returns the elapsed time, in milliseconds.
+  TimeInMillis elapsed_time() const { return elapsed_time_; }
+
+  // Returns the i-th test part result among all the results. i can range
+  // from 0 to test_property_count() - 1. If i is not in that range, aborts
+  // the program.
+  const TestPartResult& GetTestPartResult(int i) const;
+
+  // Returns the i-th test property. i can range from 0 to
+  // test_property_count() - 1. If i is not in that range, aborts the
+  // program.
+  const TestProperty& GetTestProperty(int i) const;
+
+ private:
+  friend class TestInfo;
+  friend class TestCase;
+  friend class UnitTest;
+  friend class internal::DefaultGlobalTestPartResultReporter;
+  friend class internal::ExecDeathTest;
+  friend class internal::TestResultAccessor;
+  friend class internal::UnitTestImpl;
+  friend class internal::WindowsDeathTest;
+
+  // Gets the vector of TestPartResults.
+  const std::vector<TestPartResult>& test_part_results() const {
+    return test_part_results_;
+  }
+
+  // Gets the vector of TestProperties.
+  const std::vector<TestProperty>& test_properties() const {
+    return test_properties_;
+  }
+
+  // Sets the elapsed time.
+  void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
+
+  // Adds a test property to the list. The property is validated and may add
+  // a non-fatal failure if invalid (e.g., if it conflicts with reserved
+  // key names). If a property is already recorded for the same key, the
+  // value will be updated, rather than storing multiple values for the same
+  // key.  xml_element specifies the element for which the property is being
+  // recorded and is used for validation.
+  void RecordProperty(const std::string& xml_element,
+                      const TestProperty& test_property);
+
+  // Adds a failure if the key is a reserved attribute of Google Test
+  // testcase tags.  Returns true if the property is valid.
+  // TODO(russr): Validate attribute names are legal and human readable.
+  static bool ValidateTestProperty(const std::string& xml_element,
+                                   const TestProperty& test_property);
+
+  // Adds a test part result to the list.
+  void AddTestPartResult(const TestPartResult& test_part_result);
+
+  // Returns the death test count.
+  int death_test_count() const { return death_test_count_; }
+
+  // Increments the death test count, returning the new count.
+  int increment_death_test_count() { return ++death_test_count_; }
+
+  // Clears the test part results.
+  void ClearTestPartResults();
+
+  // Clears the object.
+  void Clear();
+
+  // Protects mutable state of the property vector and of owned
+  // properties, whose values may be updated.
+  internal::Mutex test_properites_mutex_;
+
+  // The vector of TestPartResults
+  std::vector<TestPartResult> test_part_results_;
+  // The vector of TestProperties
+  std::vector<TestProperty> test_properties_;
+  // Running count of death tests.
+  int death_test_count_;
+  // The elapsed time, in milliseconds.
+  TimeInMillis elapsed_time_;
+
+  // We disallow copying TestResult.
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
+};  // class TestResult
+
+// A TestInfo object stores the following information about a test:
+//
+//   Test case name
+//   Test name
+//   Whether the test should be run
+//   A function pointer that creates the test object when invoked
+//   Test result
+//
+// The constructor of TestInfo registers itself with the UnitTest
+// singleton such that the RUN_ALL_TESTS() macro knows which tests to
+// run.
+class GTEST_API_ TestInfo {
+ public:
+  // Destructs a TestInfo object.  This function is not virtual, so
+  // don't inherit from TestInfo.
+  ~TestInfo();
+
+  // Returns the test case name.
+  const char* test_case_name() const { return test_case_name_.c_str(); }
+
+  // Returns the test name.
+  const char* name() const { return name_.c_str(); }
+
+  // Returns the name of the parameter type, or NULL if this is not a typed
+  // or a type-parameterized test.
+  const char* type_param() const {
+    if (type_param_.get() != NULL)
+      return type_param_->c_str();
+    return NULL;
+  }
+
+  // Returns the text representation of the value parameter, or NULL if this
+  // is not a value-parameterized test.
+  const char* value_param() const {
+    if (value_param_.get() != NULL)
+      return value_param_->c_str();
+    return NULL;
+  }
+
+  // Returns true if this test should run, that is if the test is not
+  // disabled (or it is disabled but the also_run_disabled_tests flag has
+  // been specified) and its full name matches the user-specified filter.
+  //
+  // Google Test allows the user to filter the tests by their full names.
+  // The full name of a test Bar in test case Foo is defined as
+  // "Foo.Bar".  Only the tests that match the filter will run.
+  //
+  // A filter is a colon-separated list of glob (not regex) patterns,
+  // optionally followed by a '-' and a colon-separated list of
+  // negative patterns (tests to exclude).  A test is run if it
+  // matches one of the positive patterns and does not match any of
+  // the negative patterns.
+  //
+  // For example, *A*:Foo.* is a filter that matches any string that
+  // contains the character 'A' or starts with "Foo.".
+  bool should_run() const { return should_run_; }
+
+  // Returns true iff this test will appear in the XML report.
+  bool is_reportable() const {
+    // For now, the XML report includes all tests matching the filter.
+    // In the future, we may trim tests that are excluded because of
+    // sharding.
+    return matches_filter_;
+  }
+
+  // Returns the result of the test.
+  const TestResult* result() const { return &result_; }
+
+ private:
+#if GTEST_HAS_DEATH_TEST
+  friend class internal::DefaultDeathTestFactory;
+#endif  // GTEST_HAS_DEATH_TEST
+  friend class Test;
+  friend class TestCase;
+  friend class internal::UnitTestImpl;
+  friend class internal::StreamingListenerTest;
+  friend TestInfo* internal::MakeAndRegisterTestInfo(
+      const char* test_case_name,
+      const char* name,
+      const char* type_param,
+      const char* value_param,
+      internal::TypeId fixture_class_id,
+      Test::SetUpTestCaseFunc set_up_tc,
+      Test::TearDownTestCaseFunc tear_down_tc,
+      internal::TestFactoryBase* factory);
+
+  // Constructs a TestInfo object. The newly constructed instance assumes
+  // ownership of the factory object.
+  TestInfo(const std::string& test_case_name,
+           const std::string& name,
+           const char* a_type_param,   // NULL if not a type-parameterized test
+           const char* a_value_param,  // NULL if not a value-parameterized test
+           internal::TypeId fixture_class_id,
+           internal::TestFactoryBase* factory);
+
+  // Increments the number of death tests encountered in this test so
+  // far.
+  int increment_death_test_count() {
+    return result_.increment_death_test_count();
+  }
+
+  // Creates the test object, runs it, records its result, and then
+  // deletes it.
+  void Run();
+
+  static void ClearTestResult(TestInfo* test_info) {
+    test_info->result_.Clear();
+  }
+
+  // These fields are immutable properties of the test.
+  const std::string test_case_name_;     // Test case name
+  const std::string name_;               // Test name
+  // Name of the parameter type, or NULL if this is not a typed or a
+  // type-parameterized test.
+  const internal::scoped_ptr<const ::std::string> type_param_;
+  // Text representation of the value parameter, or NULL if this is not a
+  // value-parameterized test.
+  const internal::scoped_ptr<const ::std::string> value_param_;
+  const internal::TypeId fixture_class_id_;   // ID of the test fixture class
+  bool should_run_;                 // True iff this test should run
+  bool is_disabled_;                // True iff this test is disabled
+  bool matches_filter_;             // True if this test matches the
+                                    // user-specified filter.
+  internal::TestFactoryBase* const factory_;  // The factory that creates
+                                              // the test object
+
+  // This field is mutable and needs to be reset before running the
+  // test for the second time.
+  TestResult result_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
+};
+
+// A test case, which consists of a vector of TestInfos.
+//
+// TestCase is not copyable.
+class GTEST_API_ TestCase {
+ public:
+  // Creates a TestCase with the given name.
+  //
+  // TestCase does NOT have a default constructor.  Always use this
+  // constructor to create a TestCase object.
+  //
+  // Arguments:
+  //
+  //   name:         name of the test case
+  //   a_type_param: the name of the test's type parameter, or NULL if
+  //                 this is not a type-parameterized test.
+  //   set_up_tc:    pointer to the function that sets up the test case
+  //   tear_down_tc: pointer to the function that tears down the test case
+  TestCase(const char* name, const char* a_type_param,
+           Test::SetUpTestCaseFunc set_up_tc,
+           Test::TearDownTestCaseFunc tear_down_tc);
+
+  // Destructor of TestCase.
+  virtual ~TestCase();
+
+  // Gets the name of the TestCase.
+  const char* name() const { return name_.c_str(); }
+
+  // Returns the name of the parameter type, or NULL if this is not a
+  // type-parameterized test case.
+  const char* type_param() const {
+    if (type_param_.get() != NULL)
+      return type_param_->c_str();
+    return NULL;
+  }
+
+  // Returns true if any test in this test case should run.
+  bool should_run() const { return should_run_; }
+
+  // Gets the number of successful tests in this test case.
+  int successful_test_count() const;
+
+  // Gets the number of failed tests in this test case.
+  int failed_test_count() const;
+
+  // Gets the number of disabled tests that will be reported in the XML report.
+  int reportable_disabled_test_count() const;
+
+  // Gets the number of disabled tests in this test case.
+  int disabled_test_count() const;
+
+  // Gets the number of tests to be printed in the XML report.
+  int reportable_test_count() const;
+
+  // Get the number of tests in this test case that should run.
+  int test_to_run_count() const;
+
+  // Gets the number of all tests in this test case.
+  int total_test_count() const;
+
+  // Returns true iff the test case passed.
+  bool Passed() const { return !Failed(); }
+
+  // Returns true iff the test case failed.
+  bool Failed() const { return failed_test_count() > 0; }
+
+  // Returns the elapsed time, in milliseconds.
+  TimeInMillis elapsed_time() const { return elapsed_time_; }
+
+  // Returns the i-th test among all the tests. i can range from 0 to
+  // total_test_count() - 1. If i is not in that range, returns NULL.
+  const TestInfo* GetTestInfo(int i) const;
+
+  // Returns the TestResult that holds test properties recorded during
+  // execution of SetUpTestCase and TearDownTestCase.
+  const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
+
+ private:
+  friend class Test;
+  friend class internal::UnitTestImpl;
+
+  // Gets the (mutable) vector of TestInfos in this TestCase.
+  std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
+
+  // Gets the (immutable) vector of TestInfos in this TestCase.
+  const std::vector<TestInfo*>& test_info_list() const {
+    return test_info_list_;
+  }
+
+  // Returns the i-th test among all the tests. i can range from 0 to
+  // total_test_count() - 1. If i is not in that range, returns NULL.
+  TestInfo* GetMutableTestInfo(int i);
+
+  // Sets the should_run member.
+  void set_should_run(bool should) { should_run_ = should; }
+
+  // Adds a TestInfo to this test case.  Will delete the TestInfo upon
+  // destruction of the TestCase object.
+  void AddTestInfo(TestInfo * test_info);
+
+  // Clears the results of all tests in this test case.
+  void ClearResult();
+
+  // Clears the results of all tests in the given test case.
+  static void ClearTestCaseResult(TestCase* test_case) {
+    test_case->ClearResult();
+  }
+
+  // Runs every test in this TestCase.
+  void Run();
+
+  // Runs SetUpTestCase() for this TestCase.  This wrapper is needed
+  // for catching exceptions thrown from SetUpTestCase().
+  void RunSetUpTestCase() { (*set_up_tc_)(); }
+
+  // Runs TearDownTestCase() for this TestCase.  This wrapper is
+  // needed for catching exceptions thrown from TearDownTestCase().
+  void RunTearDownTestCase() { (*tear_down_tc_)(); }
+
+  // Returns true iff test passed.
+  static bool TestPassed(const TestInfo* test_info) {
+    return test_info->should_run() && test_info->result()->Passed();
+  }
+
+  // Returns true iff test failed.
+  static bool TestFailed(const TestInfo* test_info) {
+    return test_info->should_run() && test_info->result()->Failed();
+  }
+
+  // Returns true iff the test is disabled and will be reported in the XML
+  // report.
+  static bool TestReportableDisabled(const TestInfo* test_info) {
+    return test_info->is_reportable() && test_info->is_disabled_;
+  }
+
+  // Returns true iff test is disabled.
+  static bool TestDisabled(const TestInfo* test_info) {
+    return test_info->is_disabled_;
+  }
+
+  // Returns true iff this test will appear in the XML report.
+  static bool TestReportable(const TestInfo* test_info) {
+    return test_info->is_reportable();
+  }
+
+  // Returns true if the given test should run.
+  static bool ShouldRunTest(const TestInfo* test_info) {
+    return test_info->should_run();
+  }
+
+  // Shuffles the tests in this test case.
+  void ShuffleTests(internal::Random* random);
+
+  // Restores the test order to before the first shuffle.
+  void UnshuffleTests();
+
+  // Name of the test case.
+  std::string name_;
+  // Name of the parameter type, or NULL if this is not a typed or a
+  // type-parameterized test.
+  const internal::scoped_ptr<const ::std::string> type_param_;
+  // The vector of TestInfos in their original order.  It owns the
+  // elements in the vector.
+  std::vector<TestInfo*> test_info_list_;
+  // Provides a level of indirection for the test list to allow easy
+  // shuffling and restoring the test order.  The i-th element in this
+  // vector is the index of the i-th test in the shuffled test list.
+  std::vector<int> test_indices_;
+  // Pointer to the function that sets up the test case.
+  Test::SetUpTestCaseFunc set_up_tc_;
+  // Pointer to the function that tears down the test case.
+  Test::TearDownTestCaseFunc tear_down_tc_;
+  // True iff any test in this test case should run.
+  bool should_run_;
+  // Elapsed time, in milliseconds.
+  TimeInMillis elapsed_time_;
+  // Holds test properties recorded during execution of SetUpTestCase and
+  // TearDownTestCase.
+  TestResult ad_hoc_test_result_;
+
+  // We disallow copying TestCases.
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);
+};
+
+// An Environment object is capable of setting up and tearing down an
+// environment.  The user should subclass this to define his own
+// environment(s).
+//
+// An Environment object does the set-up and tear-down in virtual
+// methods SetUp() and TearDown() instead of the constructor and the
+// destructor, as:
+//
+//   1. You cannot safely throw from a destructor.  This is a problem
+//      as in some cases Google Test is used where exceptions are enabled, and
+//      we may want to implement ASSERT_* using exceptions where they are
+//      available.
+//   2. You cannot use ASSERT_* directly in a constructor or
+//      destructor.
+class Environment {
+ public:
+  // The d'tor is virtual as we need to subclass Environment.
+  virtual ~Environment() {}
+
+  // Override this to define how to set up the environment.
+  virtual void SetUp() {}
+
+  // Override this to define how to tear down the environment.
+  virtual void TearDown() {}
+ private:
+  // If you see an error about overriding the following function or
+  // about it being private, you have mis-spelled SetUp() as Setup().
+  struct Setup_should_be_spelled_SetUp {};
+  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
+};
+
+// The interface for tracing execution of tests. The methods are organized in
+// the order the corresponding events are fired.
+class TestEventListener {
+ public:
+  virtual ~TestEventListener() {}
+
+  // Fired before any test activity starts.
+  virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
+
+  // Fired before each iteration of tests starts.  There may be more than
+  // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
+  // index, starting from 0.
+  virtual void OnTestIterationStart(const UnitTest& unit_test,
+                                    int iteration) = 0;
+
+  // Fired before environment set-up for each iteration of tests starts.
+  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
+
+  // Fired after environment set-up for each iteration of tests ends.
+  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
+
+  // Fired before the test case starts.
+  virtual void OnTestCaseStart(const TestCase& test_case) = 0;
+
+  // Fired before the test starts.
+  virtual void OnTestStart(const TestInfo& test_info) = 0;
+
+  // Fired after a failed assertion or a SUCCEED() invocation.
+  virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
+
+  // Fired after the test ends.
+  virtual void OnTestEnd(const TestInfo& test_info) = 0;
+
+  // Fired after the test case ends.
+  virtual void OnTestCaseEnd(const TestCase& test_case) = 0;
+
+  // Fired before environment tear-down for each iteration of tests starts.
+  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
+
+  // Fired after environment tear-down for each iteration of tests ends.
+  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
+
+  // Fired after each iteration of tests finishes.
+  virtual void OnTestIterationEnd(const UnitTest& unit_test,
+                                  int iteration) = 0;
+
+  // Fired after all test activities have ended.
+  virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
+};
+
+// The convenience class for users who need to override just one or two
+// methods and are not concerned that a possible change to a signature of
+// the methods they override will not be caught during the build.  For
+// comments about each method please see the definition of TestEventListener
+// above.
+class EmptyTestEventListener : public TestEventListener {
+ public:
+  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
+  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
+                                    int /*iteration*/) {}
+  virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}
+  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
+  virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
+  virtual void OnTestStart(const TestInfo& /*test_info*/) {}
+  virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}
+  virtual void OnTestEnd(const TestInfo& /*test_info*/) {}
+  virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
+  virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}
+  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
+  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
+                                  int /*iteration*/) {}
+  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
+};
+
+// TestEventListeners lets users add listeners to track events in Google Test.
+class GTEST_API_ TestEventListeners {
+ public:
+  TestEventListeners();
+  ~TestEventListeners();
+
+  // Appends an event listener to the end of the list. Google Test assumes
+  // the ownership of the listener (i.e. it will delete the listener when
+  // the test program finishes).
+  void Append(TestEventListener* listener);
+
+  // Removes the given event listener from the list and returns it.  It then
+  // becomes the caller's responsibility to delete the listener. Returns
+  // NULL if the listener is not found in the list.
+  TestEventListener* Release(TestEventListener* listener);
+
+  // Returns the standard listener responsible for the default console
+  // output.  Can be removed from the listeners list to shut down default
+  // console output.  Note that removing this object from the listener list
+  // with Release transfers its ownership to the caller and makes this
+  // function return NULL the next time.
+  TestEventListener* default_result_printer() const {
+    return default_result_printer_;
+  }
+
+  // Returns the standard listener responsible for the default XML output
+  // controlled by the --gtest_output=xml flag.  Can be removed from the
+  // listeners list by users who want to shut down the default XML output
+  // controlled by this flag and substitute it with custom one.  Note that
+  // removing this object from the listener list with Release transfers its
+  // ownership to the caller and makes this function return NULL the next
+  // time.
+  TestEventListener* default_xml_generator() const {
+    return default_xml_generator_;
+  }
+
+ private:
+  friend class TestCase;
+  friend class TestInfo;
+  friend class internal::DefaultGlobalTestPartResultReporter;
+  friend class internal::NoExecDeathTest;
+  friend class internal::TestEventListenersAccessor;
+  friend class internal::UnitTestImpl;
+
+  // Returns repeater that broadcasts the TestEventListener events to all
+  // subscribers.
+  TestEventListener* repeater();
+
+  // Sets the default_result_printer attribute to the provided listener.
+  // The listener is also added to the listener list and previous
+  // default_result_printer is removed from it and deleted. The listener can
+  // also be NULL in which case it will not be added to the list. Does
+  // nothing if the previous and the current listener objects are the same.
+  void SetDefaultResultPrinter(TestEventListener* listener);
+
+  // Sets the default_xml_generator attribute to the provided listener.  The
+  // listener is also added to the listener list and previous
+  // default_xml_generator is removed from it and deleted. The listener can
+  // also be NULL in which case it will not be added to the list. Does
+  // nothing if the previous and the current listener objects are the same.
+  void SetDefaultXmlGenerator(TestEventListener* listener);
+
+  // Controls whether events will be forwarded by the repeater to the
+  // listeners in the list.
+  bool EventForwardingEnabled() const;
+  void SuppressEventForwarding();
+
+  // The actual list of listeners.
+  internal::TestEventRepeater* repeater_;
+  // Listener responsible for the standard result output.
+  TestEventListener* default_result_printer_;
+  // Listener responsible for the creation of the XML output file.
+  TestEventListener* default_xml_generator_;
+
+  // We disallow copying TestEventListeners.
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
+};
+
+// A UnitTest consists of a vector of TestCases.
+//
+// This is a singleton class.  The only instance of UnitTest is
+// created when UnitTest::GetInstance() is first called.  This
+// instance is never deleted.
+//
+// UnitTest is not copyable.
+//
+// This class is thread-safe as long as the methods are called
+// according to their specification.
+class GTEST_API_ UnitTest {
+ public:
+  // Gets the singleton UnitTest object.  The first time this method
+  // is called, a UnitTest object is constructed and returned.
+  // Consecutive calls will return the same object.
+  static UnitTest* GetInstance();
+
+  // Runs all tests in this UnitTest object and prints the result.
+  // Returns 0 if successful, or 1 otherwise.
+  //
+  // This method can only be called from the main thread.
+  //
+  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+  int Run() GTEST_MUST_USE_RESULT_;
+
+  // Returns the working directory when the first TEST() or TEST_F()
+  // was executed.  The UnitTest object owns the string.
+  const char* original_working_dir() const;
+
+  // Returns the TestCase object for the test that's currently running,
+  // or NULL if no test is running.
+  const TestCase* current_test_case() const
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
+  // Returns the TestInfo object for the test that's currently running,
+  // or NULL if no test is running.
+  const TestInfo* current_test_info() const
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
+  // Returns the random seed used at the start of the current test run.
+  int random_seed() const;
+
+#if GTEST_HAS_PARAM_TEST
+  // Returns the ParameterizedTestCaseRegistry object used to keep track of
+  // value-parameterized tests and instantiate and register them.
+  //
+  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+  internal::ParameterizedTestCaseRegistry& parameterized_test_registry()
+      GTEST_LOCK_EXCLUDED_(mutex_);
+#endif  // GTEST_HAS_PARAM_TEST
+
+  // Gets the number of successful test cases.
+  int successful_test_case_count() const;
+
+  // Gets the number of failed test cases.
+  int failed_test_case_count() const;
+
+  // Gets the number of all test cases.
+  int total_test_case_count() const;
+
+  // Gets the number of all test cases that contain at least one test
+  // that should run.
+  int test_case_to_run_count() const;
+
+  // Gets the number of successful tests.
+  int successful_test_count() const;
+
+  // Gets the number of failed tests.
+  int failed_test_count() const;
+
+  // Gets the number of disabled tests that will be reported in the XML report.
+  int reportable_disabled_test_count() const;
+
+  // Gets the number of disabled tests.
+  int disabled_test_count() const;
+
+  // Gets the number of tests to be printed in the XML report.
+  int reportable_test_count() const;
+
+  // Gets the number of all tests.
+  int total_test_count() const;
+
+  // Gets the number of tests that should run.
+  int test_to_run_count() const;
+
+  // Gets the time of the test program start, in ms from the start of the
+  // UNIX epoch.
+  TimeInMillis start_timestamp() const;
+
+  // Gets the elapsed time, in milliseconds.
+  TimeInMillis elapsed_time() const;
+
+  // Returns true iff the unit test passed (i.e. all test cases passed).
+  bool Passed() const;
+
+  // Returns true iff the unit test failed (i.e. some test case failed
+  // or something outside of all tests failed).
+  bool Failed() const;
+
+  // Gets the i-th test case among all the test cases. i can range from 0 to
+  // total_test_case_count() - 1. If i is not in that range, returns NULL.
+  const TestCase* GetTestCase(int i) const;
+
+  // Returns the TestResult containing information on test failures and
+  // properties logged outside of individual test cases.
+  const TestResult& ad_hoc_test_result() const;
+
+  // Returns the list of event listeners that can be used to track events
+  // inside Google Test.
+  TestEventListeners& listeners();
+
+ private:
+  // Registers and returns a global test environment.  When a test
+  // program is run, all global test environments will be set-up in
+  // the order they were registered.  After all tests in the program
+  // have finished, all global test environments will be torn-down in
+  // the *reverse* order they were registered.
+  //
+  // The UnitTest object takes ownership of the given environment.
+  //
+  // This method can only be called from the main thread.
+  Environment* AddEnvironment(Environment* env);
+
+  // Adds a TestPartResult to the current TestResult object.  All
+  // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
+  // eventually call this to report their results.  The user code
+  // should use the assertion macros instead of calling this directly.
+  void AddTestPartResult(TestPartResult::Type result_type,
+                         const char* file_name,
+                         int line_number,
+                         const std::string& message,
+                         const std::string& os_stack_trace)
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
+  // Adds a TestProperty to the current TestResult object when invoked from
+  // inside a test, to current TestCase's ad_hoc_test_result_ when invoked
+  // from SetUpTestCase or TearDownTestCase, or to the global property set
+  // when invoked elsewhere.  If the result already contains a property with
+  // the same key, the value will be updated.
+  void RecordProperty(const std::string& key, const std::string& value);
+
+  // Gets the i-th test case among all the test cases. i can range from 0 to
+  // total_test_case_count() - 1. If i is not in that range, returns NULL.
+  TestCase* GetMutableTestCase(int i);
+
+  // Accessors for the implementation object.
+  internal::UnitTestImpl* impl() { return impl_; }
+  const internal::UnitTestImpl* impl() const { return impl_; }
+
+  // These classes and funcions are friends as they need to access private
+  // members of UnitTest.
+  friend class Test;
+  friend class internal::AssertHelper;
+  friend class internal::ScopedTrace;
+  friend class internal::StreamingListenerTest;
+  friend class internal::UnitTestRecordPropertyTestHelper;
+  friend Environment* AddGlobalTestEnvironment(Environment* env);
+  friend internal::UnitTestImpl* internal::GetUnitTestImpl();
+  friend void internal::ReportFailureInUnknownLocation(
+      TestPartResult::Type result_type,
+      const std::string& message);
+
+  // Creates an empty UnitTest.
+  UnitTest();
+
+  // D'tor
+  virtual ~UnitTest();
+
+  // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
+  // Google Test trace stack.
+  void PushGTestTrace(const internal::TraceInfo& trace)
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
+  // Pops a trace from the per-thread Google Test trace stack.
+  void PopGTestTrace()
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
+  // Protects mutable state in *impl_.  This is mutable as some const
+  // methods need to lock it too.
+  mutable internal::Mutex mutex_;
+
+  // Opaque implementation object.  This field is never changed once
+  // the object is constructed.  We don't mark it as const here, as
+  // doing so will cause a warning in the constructor of UnitTest.
+  // Mutable state in *impl_ is protected by mutex_.
+  internal::UnitTestImpl* impl_;
+
+  // We disallow copying UnitTest.
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
+};
+
+// A convenient wrapper for adding an environment for the test
+// program.
+//
+// You should call this before RUN_ALL_TESTS() is called, probably in
+// main().  If you use gtest_main, you need to call this before main()
+// starts for it to take effect.  For example, you can define a global
+// variable like this:
+//
+//   testing::Environment* const foo_env =
+//       testing::AddGlobalTestEnvironment(new FooEnvironment);
+//
+// However, we strongly recommend you to write your own main() and
+// call AddGlobalTestEnvironment() there, as relying on initialization
+// of global variables makes the code harder to read and may cause
+// problems when you register multiple environments from different
+// translation units and the environments have dependencies among them
+// (remember that the compiler doesn't guarantee the order in which
+// global variables from different translation units are initialized).
+inline Environment* AddGlobalTestEnvironment(Environment* env) {
+  return UnitTest::GetInstance()->AddEnvironment(env);
+}
+
+// Initializes Google Test.  This must be called before calling
+// RUN_ALL_TESTS().  In particular, it parses a command line for the
+// flags that Google Test recognizes.  Whenever a Google Test flag is
+// seen, it is removed from argv, and *argc is decremented.
+//
+// No value is returned.  Instead, the Google Test flag variables are
+// updated.
+//
+// Calling the function for the second time has no user-visible effect.
+GTEST_API_ void InitGoogleTest(int* argc, char** argv);
+
+// This overloaded version can be used in Windows programs compiled in
+// UNICODE mode.
+GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
+
+namespace internal {
+
+// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
+// value of type ToPrint that is an operand of a comparison assertion
+// (e.g. ASSERT_EQ).  OtherOperand is the type of the other operand in
+// the comparison, and is used to help determine the best way to
+// format the value.  In particular, when the value is a C string
+// (char pointer) and the other operand is an STL string object, we
+// want to format the C string as a string, since we know it is
+// compared by value with the string object.  If the value is a char
+// pointer but the other operand is not an STL string object, we don't
+// know whether the pointer is supposed to point to a NUL-terminated
+// string, and thus want to print it as a pointer to be safe.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+
+// The default case.
+template <typename ToPrint, typename OtherOperand>
+class FormatForComparison {
+ public:
+  static ::std::string Format(const ToPrint& value) {
+    return ::testing::PrintToString(value);
+  }
+};
+
+// Array.
+template <typename ToPrint, size_t N, typename OtherOperand>
+class FormatForComparison<ToPrint[N], OtherOperand> {
+ public:
+  static ::std::string Format(const ToPrint* value) {
+    return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
+  }
+};
+
+// By default, print C string as pointers to be safe, as we don't know
+// whether they actually point to a NUL-terminated string.
+
+#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)                \
+  template <typename OtherOperand>                                      \
+  class FormatForComparison<CharType*, OtherOperand> {                  \
+   public:                                                              \
+    static ::std::string Format(CharType* value) {                      \
+      return ::testing::PrintToString(static_cast<const void*>(value)); \
+    }                                                                   \
+  }
+
+GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
+GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
+GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
+GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
+
+#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
+
+// If a C string is compared with an STL string object, we know it's meant
+// to point to a NUL-terminated string, and thus can print it as a string.
+
+#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
+  template <>                                                           \
+  class FormatForComparison<CharType*, OtherStringType> {               \
+   public:                                                              \
+    static ::std::string Format(CharType* value) {                      \
+      return ::testing::PrintToString(value);                           \
+    }                                                                   \
+  }
+
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
+
+#if GTEST_HAS_GLOBAL_STRING
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);
+#endif
+
+#if GTEST_HAS_GLOBAL_WSTRING
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);
+#endif
+
+#if GTEST_HAS_STD_WSTRING
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
+GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
+#endif
+
+#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
+
+// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
+// operand to be used in a failure message.  The type (but not value)
+// of the other operand may affect the format.  This allows us to
+// print a char* as a raw pointer when it is compared against another
+// char* or void*, and print it as a C string when it is compared
+// against an std::string object, for example.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+template <typename T1, typename T2>
+std::string FormatForComparisonFailureMessage(
+    const T1& value, const T2& /* other_operand */) {
+  return FormatForComparison<T1, T2>::Format(value);
+}
+
+// The helper function for {ASSERT|EXPECT}_EQ.
+template <typename T1, typename T2>
+AssertionResult CmpHelperEQ(const char* expected_expression,
+                            const char* actual_expression,
+                            const T1& expected,
+                            const T2& actual) {
+#ifdef _MSC_VER
+# pragma warning(push)          // Saves the current warning state.
+# pragma warning(disable:4389)  // Temporarily disables warning on
+                                // signed/unsigned mismatch.
+#endif
+
+  if (expected == actual) {
+    return AssertionSuccess();
+  }
+
+#ifdef _MSC_VER
+# pragma warning(pop)          // Restores the warning state.
+#endif
+
+  return EqFailure(expected_expression,
+                   actual_expression,
+                   FormatForComparisonFailureMessage(expected, actual),
+                   FormatForComparisonFailureMessage(actual, expected),
+                   false);
+}
+
+// With this overloaded version, we allow anonymous enums to be used
+// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
+// can be implicitly cast to BiggestInt.
+GTEST_API_ AssertionResult CmpHelperEQ(const char* expected_expression,
+                                       const char* actual_expression,
+                                       BiggestInt expected,
+                                       BiggestInt actual);
+
+// The helper class for {ASSERT|EXPECT}_EQ.  The template argument
+// lhs_is_null_literal is true iff the first argument to ASSERT_EQ()
+// is a null pointer literal.  The following default implementation is
+// for lhs_is_null_literal being false.
+template <bool lhs_is_null_literal>
+class EqHelper {
+ public:
+  // This templatized version is for the general case.
+  template <typename T1, typename T2>
+  static AssertionResult Compare(const char* expected_expression,
+                                 const char* actual_expression,
+                                 const T1& expected,
+                                 const T2& actual) {
+    return CmpHelperEQ(expected_expression, actual_expression, expected,
+                       actual);
+  }
+
+  // With this overloaded version, we allow anonymous enums to be used
+  // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous
+  // enums can be implicitly cast to BiggestInt.
+  //
+  // Even though its body looks the same as the above version, we
+  // cannot merge the two, as it will make anonymous enums unhappy.
+  static AssertionResult Compare(const char* expected_expression,
+                                 const char* actual_expression,
+                                 BiggestInt expected,
+                                 BiggestInt actual) {
+    return CmpHelperEQ(expected_expression, actual_expression, expected,
+                       actual);
+  }
+};
+
+// This specialization is used when the first argument to ASSERT_EQ()
+// is a null pointer literal, like NULL, false, or 0.
+template <>
+class EqHelper<true> {
+ public:
+  // We define two overloaded versions of Compare().  The first
+  // version will be picked when the second argument to ASSERT_EQ() is
+  // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or
+  // EXPECT_EQ(false, a_bool).
+  template <typename T1, typename T2>
+  static AssertionResult Compare(
+      const char* expected_expression,
+      const char* actual_expression,
+      const T1& expected,
+      const T2& actual,
+      // The following line prevents this overload from being considered if T2
+      // is not a pointer type.  We need this because ASSERT_EQ(NULL, my_ptr)
+      // expands to Compare("", "", NULL, my_ptr), which requires a conversion
+      // to match the Secret* in the other overload, which would otherwise make
+      // this template match better.
+      typename EnableIf<!is_pointer<T2>::value>::type* = 0) {
+    return CmpHelperEQ(expected_expression, actual_expression, expected,
+                       actual);
+  }
+
+  // This version will be picked when the second argument to ASSERT_EQ() is a
+  // pointer, e.g. ASSERT_EQ(NULL, a_pointer).
+  template <typename T>
+  static AssertionResult Compare(
+      const char* expected_expression,
+      const char* actual_expression,
+      // We used to have a second template parameter instead of Secret*.  That
+      // template parameter would deduce to 'long', making this a better match
+      // than the first overload even without the first overload's EnableIf.
+      // Unfortunately, gcc with -Wconversion-null warns when "passing NULL to
+      // non-pointer argument" (even a deduced integral argument), so the old
+      // implementation caused warnings in user code.
+      Secret* /* expected (NULL) */,
+      T* actual) {
+    // We already know that 'expected' is a null pointer.
+    return CmpHelperEQ(expected_expression, actual_expression,
+                       static_cast<T*>(NULL), actual);
+  }
+};
+
+// A macro for implementing the helper functions needed to implement
+// ASSERT_?? and EXPECT_??.  It is here just to avoid copy-and-paste
+// of similar code.
+//
+// For each templatized helper function, we also define an overloaded
+// version for BiggestInt in order to reduce code bloat and allow
+// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
+// with gcc 4.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
+template <typename T1, typename T2>\
+AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
+                                   const T1& val1, const T2& val2) {\
+  if (val1 op val2) {\
+    return AssertionSuccess();\
+  } else {\
+    return AssertionFailure() \
+        << "Expected: (" << expr1 << ") " #op " (" << expr2\
+        << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
+        << " vs " << FormatForComparisonFailureMessage(val2, val1);\
+  }\
+}\
+GTEST_API_ AssertionResult CmpHelper##op_name(\
+    const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+
+// Implements the helper function for {ASSERT|EXPECT}_NE
+GTEST_IMPL_CMP_HELPER_(NE, !=);
+// Implements the helper function for {ASSERT|EXPECT}_LE
+GTEST_IMPL_CMP_HELPER_(LE, <=);
+// Implements the helper function for {ASSERT|EXPECT}_LT
+GTEST_IMPL_CMP_HELPER_(LT, <);
+// Implements the helper function for {ASSERT|EXPECT}_GE
+GTEST_IMPL_CMP_HELPER_(GE, >=);
+// Implements the helper function for {ASSERT|EXPECT}_GT
+GTEST_IMPL_CMP_HELPER_(GT, >);
+
+#undef GTEST_IMPL_CMP_HELPER_
+
+// The helper function for {ASSERT|EXPECT}_STREQ.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,
+                                          const char* actual_expression,
+                                          const char* expected,
+                                          const char* actual);
+
+// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
+                                              const char* actual_expression,
+                                              const char* expected,
+                                              const char* actual);
+
+// The helper function for {ASSERT|EXPECT}_STRNE.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
+                                          const char* s2_expression,
+                                          const char* s1,
+                                          const char* s2);
+
+// The helper function for {ASSERT|EXPECT}_STRCASENE.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
+                                              const char* s2_expression,
+                                              const char* s1,
+                                              const char* s2);
+
+
+// Helper function for *_STREQ on wide strings.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,
+                                          const char* actual_expression,
+                                          const wchar_t* expected,
+                                          const wchar_t* actual);
+
+// Helper function for *_STRNE on wide strings.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
+                                          const char* s2_expression,
+                                          const wchar_t* s1,
+                                          const wchar_t* s2);
+
+}  // namespace internal
+
+// IsSubstring() and IsNotSubstring() are intended to be used as the
+// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
+// themselves.  They check whether needle is a substring of haystack
+// (NULL is considered a substring of itself only), and return an
+// appropriate error message when they fail.
+//
+// The {needle,haystack}_expr arguments are the stringified
+// expressions that generated the two real arguments.
+GTEST_API_ AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const char* needle, const char* haystack);
+GTEST_API_ AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const wchar_t* needle, const wchar_t* haystack);
+GTEST_API_ AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const char* needle, const char* haystack);
+GTEST_API_ AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const wchar_t* needle, const wchar_t* haystack);
+GTEST_API_ AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::string& needle, const ::std::string& haystack);
+GTEST_API_ AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::string& needle, const ::std::string& haystack);
+
+#if GTEST_HAS_STD_WSTRING
+GTEST_API_ AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::wstring& needle, const ::std::wstring& haystack);
+GTEST_API_ AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::wstring& needle, const ::std::wstring& haystack);
+#endif  // GTEST_HAS_STD_WSTRING
+
+namespace internal {
+
+// Helper template function for comparing floating-points.
+//
+// Template parameter:
+//
+//   RawType: the raw floating-point type (either float or double)
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+template <typename RawType>
+AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression,
+                                         const char* actual_expression,
+                                         RawType expected,
+                                         RawType actual) {
+  const FloatingPoint<RawType> lhs(expected), rhs(actual);
+
+  if (lhs.AlmostEquals(rhs)) {
+    return AssertionSuccess();
+  }
+
+  ::std::stringstream expected_ss;
+  expected_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
+              << expected;
+
+  ::std::stringstream actual_ss;
+  actual_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
+            << actual;
+
+  return EqFailure(expected_expression,
+                   actual_expression,
+                   StringStreamToString(&expected_ss),
+                   StringStreamToString(&actual_ss),
+                   false);
+}
+
+// Helper function for implementing ASSERT_NEAR.
+//
+// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
+                                                const char* expr2,
+                                                const char* abs_error_expr,
+                                                double val1,
+                                                double val2,
+                                                double abs_error);
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+// A class that enables one to stream messages to assertion macros
+class GTEST_API_ AssertHelper {
+ public:
+  // Constructor.
+  AssertHelper(TestPartResult::Type type,
+               const char* file,
+               int line,
+               const char* message);
+  ~AssertHelper();
+
+  // Message assignment is a semantic trick to enable assertion
+  // streaming; see the GTEST_MESSAGE_ macro below.
+  void operator=(const Message& message) const;
+
+ private:
+  // We put our data in a struct so that the size of the AssertHelper class can
+  // be as small as possible.  This is important because gcc is incapable of
+  // re-using stack space even for temporary variables, so every EXPECT_EQ
+  // reserves stack space for another AssertHelper.
+  struct AssertHelperData {
+    AssertHelperData(TestPartResult::Type t,
+                     const char* srcfile,
+                     int line_num,
+                     const char* msg)
+        : type(t), file(srcfile), line(line_num), message(msg) { }
+
+    TestPartResult::Type const type;
+    const char* const file;
+    int const line;
+    std::string const message;
+
+   private:
+    GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
+  };
+
+  AssertHelperData* const data_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
+};
+
+}  // namespace internal
+
+#if GTEST_HAS_PARAM_TEST
+// The pure interface class that all value-parameterized tests inherit from.
+// A value-parameterized class must inherit from both ::testing::Test and
+// ::testing::WithParamInterface. In most cases that just means inheriting
+// from ::testing::TestWithParam, but more complicated test hierarchies
+// may need to inherit from Test and WithParamInterface at different levels.
+//
+// This interface has support for accessing the test parameter value via
+// the GetParam() method.
+//
+// Use it with one of the parameter generator defining functions, like Range(),
+// Values(), ValuesIn(), Bool(), and Combine().
+//
+// class FooTest : public ::testing::TestWithParam<int> {
+//  protected:
+//   FooTest() {
+//     // Can use GetParam() here.
+//   }
+//   virtual ~FooTest() {
+//     // Can use GetParam() here.
+//   }
+//   virtual void SetUp() {
+//     // Can use GetParam() here.
+//   }
+//   virtual void TearDown {
+//     // Can use GetParam() here.
+//   }
+// };
+// TEST_P(FooTest, DoesBar) {
+//   // Can use GetParam() method here.
+//   Foo foo;
+//   ASSERT_TRUE(foo.DoesBar(GetParam()));
+// }
+// INSTANTIATE_TEST_CASE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));
+
+template <typename T>
+class WithParamInterface {
+ public:
+  typedef T ParamType;
+  virtual ~WithParamInterface() {}
+
+  // The current parameter value. Is also available in the test fixture's
+  // constructor. This member function is non-static, even though it only
+  // references static data, to reduce the opportunity for incorrect uses
+  // like writing 'WithParamInterface<bool>::GetParam()' for a test that
+  // uses a fixture whose parameter type is int.
+  const ParamType& GetParam() const {
+    GTEST_CHECK_(parameter_ != NULL)
+        << "GetParam() can only be called inside a value-parameterized test "
+        << "-- did you intend to write TEST_P instead of TEST_F?";
+    return *parameter_;
+  }
+
+ private:
+  // Sets parameter value. The caller is responsible for making sure the value
+  // remains alive and unchanged throughout the current test.
+  static void SetParam(const ParamType* parameter) {
+    parameter_ = parameter;
+  }
+
+  // Static value used for accessing parameter during a test lifetime.
+  static const ParamType* parameter_;
+
+  // TestClass must be a subclass of WithParamInterface<T> and Test.
+  template <class TestClass> friend class internal::ParameterizedTestFactory;
+};
+
+template <typename T>
+const T* WithParamInterface<T>::parameter_ = NULL;
+
+// Most value-parameterized classes can ignore the existence of
+// WithParamInterface, and can just inherit from ::testing::TestWithParam.
+
+template <typename T>
+class TestWithParam : public Test, public WithParamInterface<T> {
+};
+
+#endif  // GTEST_HAS_PARAM_TEST
+
+// Macros for indicating success/failure in test code.
+
+// ADD_FAILURE unconditionally adds a failure to the current test.
+// SUCCEED generates a success - it doesn't automatically make the
+// current test successful, as a test is only successful when it has
+// no failure.
+//
+// EXPECT_* verifies that a certain condition is satisfied.  If not,
+// it behaves like ADD_FAILURE.  In particular:
+//
+//   EXPECT_TRUE  verifies that a Boolean condition is true.
+//   EXPECT_FALSE verifies that a Boolean condition is false.
+//
+// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except
+// that they will also abort the current function on failure.  People
+// usually want the fail-fast behavior of FAIL and ASSERT_*, but those
+// writing data-driven tests often find themselves using ADD_FAILURE
+// and EXPECT_* more.
+
+// Generates a nonfatal failure with a generic message.
+#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
+
+// Generates a nonfatal failure at the given source file location with
+// a generic message.
+#define ADD_FAILURE_AT(file, line) \
+  GTEST_MESSAGE_AT_(file, line, "Failed", \
+                    ::testing::TestPartResult::kNonFatalFailure)
+
+// Generates a fatal failure with a generic message.
+#define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
+
+// Define this macro to 1 to omit the definition of FAIL(), which is a
+// generic name and clashes with some other libraries.
+#if !GTEST_DONT_DEFINE_FAIL
+# define FAIL() GTEST_FAIL()
+#endif
+
+// Generates a success with a generic message.
+#define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
+
+// Define this macro to 1 to omit the definition of SUCCEED(), which
+// is a generic name and clashes with some other libraries.
+#if !GTEST_DONT_DEFINE_SUCCEED
+# define SUCCEED() GTEST_SUCCEED()
+#endif
+
+// Macros for testing exceptions.
+//
+//    * {ASSERT|EXPECT}_THROW(statement, expected_exception):
+//         Tests that the statement throws the expected exception.
+//    * {ASSERT|EXPECT}_NO_THROW(statement):
+//         Tests that the statement doesn't throw any exception.
+//    * {ASSERT|EXPECT}_ANY_THROW(statement):
+//         Tests that the statement throws an exception.
+
+#define EXPECT_THROW(statement, expected_exception) \
+  GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
+#define EXPECT_NO_THROW(statement) \
+  GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
+#define EXPECT_ANY_THROW(statement) \
+  GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
+#define ASSERT_THROW(statement, expected_exception) \
+  GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
+#define ASSERT_NO_THROW(statement) \
+  GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
+#define ASSERT_ANY_THROW(statement) \
+  GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
+
+// Boolean assertions. Condition can be either a Boolean expression or an
+// AssertionResult. For more information on how to use AssertionResult with
+// these macros see comments on that class.
+#define EXPECT_TRUE(condition) \
+  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
+                      GTEST_NONFATAL_FAILURE_)
+#define EXPECT_FALSE(condition) \
+  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
+                      GTEST_NONFATAL_FAILURE_)
+#define ASSERT_TRUE(condition) \
+  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
+                      GTEST_FATAL_FAILURE_)
+#define ASSERT_FALSE(condition) \
+  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
+                      GTEST_FATAL_FAILURE_)
+
+// Includes the auto-generated header that implements a family of
+// generic predicate assertion macros.
+#include "gtest/gtest_pred_impl.h"
+
+// Macros for testing equalities and inequalities.
+//
+//    * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual
+//    * {ASSERT|EXPECT}_NE(v1, v2):           Tests that v1 != v2
+//    * {ASSERT|EXPECT}_LT(v1, v2):           Tests that v1 < v2
+//    * {ASSERT|EXPECT}_LE(v1, v2):           Tests that v1 <= v2
+//    * {ASSERT|EXPECT}_GT(v1, v2):           Tests that v1 > v2
+//    * {ASSERT|EXPECT}_GE(v1, v2):           Tests that v1 >= v2
+//
+// When they are not, Google Test prints both the tested expressions and
+// their actual values.  The values must be compatible built-in types,
+// or you will get a compiler error.  By "compatible" we mean that the
+// values can be compared by the respective operator.
+//
+// Note:
+//
+//   1. It is possible to make a user-defined type work with
+//   {ASSERT|EXPECT}_??(), but that requires overloading the
+//   comparison operators and is thus discouraged by the Google C++
+//   Usage Guide.  Therefore, you are advised to use the
+//   {ASSERT|EXPECT}_TRUE() macro to assert that two objects are
+//   equal.
+//
+//   2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on
+//   pointers (in particular, C strings).  Therefore, if you use it
+//   with two C strings, you are testing how their locations in memory
+//   are related, not how their content is related.  To compare two C
+//   strings by content, use {ASSERT|EXPECT}_STR*().
+//
+//   3. {ASSERT|EXPECT}_EQ(expected, actual) is preferred to
+//   {ASSERT|EXPECT}_TRUE(expected == actual), as the former tells you
+//   what the actual value is when it fails, and similarly for the
+//   other comparisons.
+//
+//   4. Do not depend on the order in which {ASSERT|EXPECT}_??()
+//   evaluate their arguments, which is undefined.
+//
+//   5. These macros evaluate their arguments exactly once.
+//
+// Examples:
+//
+//   EXPECT_NE(5, Foo());
+//   EXPECT_EQ(NULL, a_pointer);
+//   ASSERT_LT(i, array_size);
+//   ASSERT_GT(records.size(), 0) << "There is no record left.";
+
+#define EXPECT_EQ(expected, actual) \
+  EXPECT_PRED_FORMAT2(::testing::internal:: \
+                      EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
+                      expected, actual)
+#define EXPECT_NE(expected, actual) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, expected, actual)
+#define EXPECT_LE(val1, val2) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
+#define EXPECT_LT(val1, val2) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
+#define EXPECT_GE(val1, val2) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
+#define EXPECT_GT(val1, val2) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
+
+#define GTEST_ASSERT_EQ(expected, actual) \
+  ASSERT_PRED_FORMAT2(::testing::internal:: \
+                      EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
+                      expected, actual)
+#define GTEST_ASSERT_NE(val1, val2) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
+#define GTEST_ASSERT_LE(val1, val2) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
+#define GTEST_ASSERT_LT(val1, val2) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
+#define GTEST_ASSERT_GE(val1, val2) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
+#define GTEST_ASSERT_GT(val1, val2) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
+
+// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
+// ASSERT_XY(), which clashes with some users' own code.
+
+#if !GTEST_DONT_DEFINE_ASSERT_EQ
+# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_NE
+# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_LE
+# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_LT
+# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_GE
+# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_GT
+# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
+#endif
+
+// C-string Comparisons.  All tests treat NULL and any non-NULL string
+// as different.  Two NULLs are equal.
+//
+//    * {ASSERT|EXPECT}_STREQ(s1, s2):     Tests that s1 == s2
+//    * {ASSERT|EXPECT}_STRNE(s1, s2):     Tests that s1 != s2
+//    * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case
+//    * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case
+//
+// For wide or narrow string objects, you can use the
+// {ASSERT|EXPECT}_??() macros.
+//
+// Don't depend on the order in which the arguments are evaluated,
+// which is undefined.
+//
+// These macros evaluate their arguments exactly once.
+
+#define EXPECT_STREQ(expected, actual) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual)
+#define EXPECT_STRNE(s1, s2) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
+#define EXPECT_STRCASEEQ(expected, actual) \
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual)
+#define EXPECT_STRCASENE(s1, s2)\
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
+
+#define ASSERT_STREQ(expected, actual) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual)
+#define ASSERT_STRNE(s1, s2) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
+#define ASSERT_STRCASEEQ(expected, actual) \
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual)
+#define ASSERT_STRCASENE(s1, s2)\
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
+
+// Macros for comparing floating-point numbers.
+//
+//    * {ASSERT|EXPECT}_FLOAT_EQ(expected, actual):
+//         Tests that two float values are almost equal.
+//    * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual):
+//         Tests that two double values are almost equal.
+//    * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):
+//         Tests that v1 and v2 are within the given distance to each other.
+//
+// Google Test uses ULP-based comparison to automatically pick a default
+// error bound that is appropriate for the operands.  See the
+// FloatingPoint template class in gtest-internal.h if you are
+// interested in the implementation details.
+
+#define EXPECT_FLOAT_EQ(expected, actual)\
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
+                      expected, actual)
+
+#define EXPECT_DOUBLE_EQ(expected, actual)\
+  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
+                      expected, actual)
+
+#define ASSERT_FLOAT_EQ(expected, actual)\
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
+                      expected, actual)
+
+#define ASSERT_DOUBLE_EQ(expected, actual)\
+  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
+                      expected, actual)
+
+#define EXPECT_NEAR(val1, val2, abs_error)\
+  EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
+                      val1, val2, abs_error)
+
+#define ASSERT_NEAR(val1, val2, abs_error)\
+  ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
+                      val1, val2, abs_error)
+
+// These predicate format functions work on floating-point values, and
+// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.
+//
+//   EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);
+
+// Asserts that val1 is less than, or almost equal to, val2.  Fails
+// otherwise.  In particular, it fails if either val1 or val2 is NaN.
+GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
+                                   float val1, float val2);
+GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
+                                    double val1, double val2);
+
+
+#if GTEST_OS_WINDOWS
+
+// Macros that test for HRESULT failure and success, these are only useful
+// on Windows, and rely on Windows SDK macros and APIs to compile.
+//
+//    * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)
+//
+// When expr unexpectedly fails or succeeds, Google Test prints the
+// expected result and the actual result with both a human-readable
+// string representation of the error, if available, as well as the
+// hex result code.
+# define EXPECT_HRESULT_SUCCEEDED(expr) \
+    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
+
+# define ASSERT_HRESULT_SUCCEEDED(expr) \
+    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
+
+# define EXPECT_HRESULT_FAILED(expr) \
+    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
+
+# define ASSERT_HRESULT_FAILED(expr) \
+    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
+
+#endif  // GTEST_OS_WINDOWS
+
+// Macros that execute statement and check that it doesn't generate new fatal
+// failures in the current thread.
+//
+//   * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);
+//
+// Examples:
+//
+//   EXPECT_NO_FATAL_FAILURE(Process());
+//   ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
+//
+#define ASSERT_NO_FATAL_FAILURE(statement) \
+    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
+#define EXPECT_NO_FATAL_FAILURE(statement) \
+    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
+
+// Causes a trace (including the source file path, the current line
+// number, and the given message) to be included in every test failure
+// message generated by code in the current scope.  The effect is
+// undone when the control leaves the current scope.
+//
+// The message argument can be anything streamable to std::ostream.
+//
+// In the implementation, we include the current line number as part
+// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
+// to appear in the same block - as long as they are on different
+// lines.
+#define SCOPED_TRACE(message) \
+  ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
+    __FILE__, __LINE__, ::testing::Message() << (message))
+
+// Compile-time assertion for type equality.
+// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
+// the same type.  The value it returns is not interesting.
+//
+// Instead of making StaticAssertTypeEq a class template, we make it a
+// function template that invokes a helper class template.  This
+// prevents a user from misusing StaticAssertTypeEq<T1, T2> by
+// defining objects of that type.
+//
+// CAVEAT:
+//
+// When used inside a method of a class template,
+// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
+// instantiated.  For example, given:
+//
+//   template <typename T> class Foo {
+//    public:
+//     void Bar() { testing::StaticAssertTypeEq<int, T>(); }
+//   };
+//
+// the code:
+//
+//   void Test1() { Foo<bool> foo; }
+//
+// will NOT generate a compiler error, as Foo<bool>::Bar() is never
+// actually instantiated.  Instead, you need:
+//
+//   void Test2() { Foo<bool> foo; foo.Bar(); }
+//
+// to cause a compiler error.
+template <typename T1, typename T2>
+bool StaticAssertTypeEq() {
+  (void)internal::StaticAssertTypeEqHelper<T1, T2>();
+  return true;
+}
+
+// Defines a test.
+//
+// The first parameter is the name of the test case, and the second
+// parameter is the name of the test within the test case.
+//
+// The convention is to end the test case name with "Test".  For
+// example, a test case for the Foo class can be named FooTest.
+//
+// The user should put his test code between braces after using this
+// macro.  Example:
+//
+//   TEST(FooTest, InitializesCorrectly) {
+//     Foo foo;
+//     EXPECT_TRUE(foo.StatusIsOK());
+//   }
+
+// Note that we call GetTestTypeId() instead of GetTypeId<
+// ::testing::Test>() here to get the type ID of testing::Test.  This
+// is to work around a suspected linker bug when using Google Test as
+// a framework on Mac OS X.  The bug causes GetTypeId<
+// ::testing::Test>() to return different values depending on whether
+// the call is from the Google Test framework itself or from user test
+// code.  GetTestTypeId() is guaranteed to always return the same
+// value, as it always calls GetTypeId<>() from the Google Test
+// framework.
+#define GTEST_TEST(test_case_name, test_name)\
+  GTEST_TEST_(test_case_name, test_name, \
+              ::testing::Test, ::testing::internal::GetTestTypeId())
+
+// Define this macro to 1 to omit the definition of TEST(), which
+// is a generic name and clashes with some other libraries.
+#if !GTEST_DONT_DEFINE_TEST
+# define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)
+#endif
+
+// Defines a test that uses a test fixture.
+//
+// The first parameter is the name of the test fixture class, which
+// also doubles as the test case name.  The second parameter is the
+// name of the test within the test case.
+//
+// A test fixture class must be declared earlier.  The user should put
+// his test code between braces after using this macro.  Example:
+//
+//   class FooTest : public testing::Test {
+//    protected:
+//     virtual void SetUp() { b_.AddElement(3); }
+//
+//     Foo a_;
+//     Foo b_;
+//   };
+//
+//   TEST_F(FooTest, InitializesCorrectly) {
+//     EXPECT_TRUE(a_.StatusIsOK());
+//   }
+//
+//   TEST_F(FooTest, ReturnsElementCountCorrectly) {
+//     EXPECT_EQ(0, a_.size());
+//     EXPECT_EQ(1, b_.size());
+//   }
+
+#define TEST_F(test_fixture, test_name)\
+  GTEST_TEST_(test_fixture, test_name, test_fixture, \
+              ::testing::internal::GetTypeId<test_fixture>())
+
+}  // namespace testing
+
+// Use this function in main() to run all tests.  It returns 0 if all
+// tests are successful, or 1 otherwise.
+//
+// RUN_ALL_TESTS() should be invoked after the command line has been
+// parsed by InitGoogleTest().
+//
+// This function was formerly a macro; thus, it is in the global
+// namespace and has an all-caps name.
+int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
+
+inline int RUN_ALL_TESTS() {
+  return ::testing::UnitTest::GetInstance()->Run();
+}
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_H_
diff --git a/test/fmw/gtest/include/gtest/gtest_pred_impl.h b/test/fmw/gtest/include/gtest/gtest_pred_impl.h
new file mode 100644
index 0000000..30ae712
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest_pred_impl.h
@@ -0,0 +1,358 @@
+// Copyright 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command
+// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!
+//
+// Implements a family of generic predicate assertion macros.
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
+#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
+
+// Makes sure this header is not included before gtest.h.
+#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
+# error Do not include gtest_pred_impl.h directly.  Include gtest.h instead.
+#endif  // GTEST_INCLUDE_GTEST_GTEST_H_
+
+// This header implements a family of generic predicate assertion
+// macros:
+//
+//   ASSERT_PRED_FORMAT1(pred_format, v1)
+//   ASSERT_PRED_FORMAT2(pred_format, v1, v2)
+//   ...
+//
+// where pred_format is a function or functor that takes n (in the
+// case of ASSERT_PRED_FORMATn) values and their source expression
+// text, and returns a testing::AssertionResult.  See the definition
+// of ASSERT_EQ in gtest.h for an example.
+//
+// If you don't care about formatting, you can use the more
+// restrictive version:
+//
+//   ASSERT_PRED1(pred, v1)
+//   ASSERT_PRED2(pred, v1, v2)
+//   ...
+//
+// where pred is an n-ary function or functor that returns bool,
+// and the values v1, v2, ..., must support the << operator for
+// streaming to std::ostream.
+//
+// We also define the EXPECT_* variations.
+//
+// For now we only support predicates whose arity is at most 5.
+// Please email googletestframework@googlegroups.com if you need
+// support for higher arities.
+
+// GTEST_ASSERT_ is the basic statement to which all of the assertions
+// in this file reduce.  Don't use this in your code.
+
+#define GTEST_ASSERT_(expression, on_failure) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (const ::testing::AssertionResult gtest_ar = (expression)) \
+    ; \
+  else \
+    on_failure(gtest_ar.failure_message())
+
+
+// Helper function for implementing {EXPECT|ASSERT}_PRED1.  Don't use
+// this in your code.
+template <typename Pred,
+          typename T1>
+AssertionResult AssertPred1Helper(const char* pred_text,
+                                  const char* e1,
+                                  Pred pred,
+                                  const T1& v1) {
+  if (pred(v1)) return AssertionSuccess();
+
+  return AssertionFailure() << pred_text << "("
+                            << e1 << ") evaluates to false, where"
+                            << "\n" << e1 << " evaluates to " << v1;
+}
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
+// Don't use this in your code.
+#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
+  GTEST_ASSERT_(pred_format(#v1, v1), \
+                on_failure)
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED1.  Don't use
+// this in your code.
+#define GTEST_PRED1_(pred, v1, on_failure)\
+  GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
+                                             #v1, \
+                                             pred, \
+                                             v1), on_failure)
+
+// Unary predicate assertion macros.
+#define EXPECT_PRED_FORMAT1(pred_format, v1) \
+  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
+#define EXPECT_PRED1(pred, v1) \
+  GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
+#define ASSERT_PRED_FORMAT1(pred_format, v1) \
+  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
+#define ASSERT_PRED1(pred, v1) \
+  GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
+
+
+
+// Helper function for implementing {EXPECT|ASSERT}_PRED2.  Don't use
+// this in your code.
+template <typename Pred,
+          typename T1,
+          typename T2>
+AssertionResult AssertPred2Helper(const char* pred_text,
+                                  const char* e1,
+                                  const char* e2,
+                                  Pred pred,
+                                  const T1& v1,
+                                  const T2& v2) {
+  if (pred(v1, v2)) return AssertionSuccess();
+
+  return AssertionFailure() << pred_text << "("
+                            << e1 << ", "
+                            << e2 << ") evaluates to false, where"
+                            << "\n" << e1 << " evaluates to " << v1
+                            << "\n" << e2 << " evaluates to " << v2;
+}
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
+// Don't use this in your code.
+#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
+  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
+                on_failure)
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED2.  Don't use
+// this in your code.
+#define GTEST_PRED2_(pred, v1, v2, on_failure)\
+  GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
+                                             #v1, \
+                                             #v2, \
+                                             pred, \
+                                             v1, \
+                                             v2), on_failure)
+
+// Binary predicate assertion macros.
+#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
+  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
+#define EXPECT_PRED2(pred, v1, v2) \
+  GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
+#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
+  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
+#define ASSERT_PRED2(pred, v1, v2) \
+  GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
+
+
+
+// Helper function for implementing {EXPECT|ASSERT}_PRED3.  Don't use
+// this in your code.
+template <typename Pred,
+          typename T1,
+          typename T2,
+          typename T3>
+AssertionResult AssertPred3Helper(const char* pred_text,
+                                  const char* e1,
+                                  const char* e2,
+                                  const char* e3,
+                                  Pred pred,
+                                  const T1& v1,
+                                  const T2& v2,
+                                  const T3& v3) {
+  if (pred(v1, v2, v3)) return AssertionSuccess();
+
+  return AssertionFailure() << pred_text << "("
+                            << e1 << ", "
+                            << e2 << ", "
+                            << e3 << ") evaluates to false, where"
+                            << "\n" << e1 << " evaluates to " << v1
+                            << "\n" << e2 << " evaluates to " << v2
+                            << "\n" << e3 << " evaluates to " << v3;
+}
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
+// Don't use this in your code.
+#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
+  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
+                on_failure)
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED3.  Don't use
+// this in your code.
+#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
+  GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
+                                             #v1, \
+                                             #v2, \
+                                             #v3, \
+                                             pred, \
+                                             v1, \
+                                             v2, \
+                                             v3), on_failure)
+
+// Ternary predicate assertion macros.
+#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
+  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
+#define EXPECT_PRED3(pred, v1, v2, v3) \
+  GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
+#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
+  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
+#define ASSERT_PRED3(pred, v1, v2, v3) \
+  GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
+
+
+
+// Helper function for implementing {EXPECT|ASSERT}_PRED4.  Don't use
+// this in your code.
+template <typename Pred,
+          typename T1,
+          typename T2,
+          typename T3,
+          typename T4>
+AssertionResult AssertPred4Helper(const char* pred_text,
+                                  const char* e1,
+                                  const char* e2,
+                                  const char* e3,
+                                  const char* e4,
+                                  Pred pred,
+                                  const T1& v1,
+                                  const T2& v2,
+                                  const T3& v3,
+                                  const T4& v4) {
+  if (pred(v1, v2, v3, v4)) return AssertionSuccess();
+
+  return AssertionFailure() << pred_text << "("
+                            << e1 << ", "
+                            << e2 << ", "
+                            << e3 << ", "
+                            << e4 << ") evaluates to false, where"
+                            << "\n" << e1 << " evaluates to " << v1
+                            << "\n" << e2 << " evaluates to " << v2
+                            << "\n" << e3 << " evaluates to " << v3
+                            << "\n" << e4 << " evaluates to " << v4;
+}
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
+// Don't use this in your code.
+#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
+  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
+                on_failure)
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED4.  Don't use
+// this in your code.
+#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
+  GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
+                                             #v1, \
+                                             #v2, \
+                                             #v3, \
+                                             #v4, \
+                                             pred, \
+                                             v1, \
+                                             v2, \
+                                             v3, \
+                                             v4), on_failure)
+
+// 4-ary predicate assertion macros.
+#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
+  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
+#define EXPECT_PRED4(pred, v1, v2, v3, v4) \
+  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
+#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
+  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
+#define ASSERT_PRED4(pred, v1, v2, v3, v4) \
+  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
+
+
+
+// Helper function for implementing {EXPECT|ASSERT}_PRED5.  Don't use
+// this in your code.
+template <typename Pred,
+          typename T1,
+          typename T2,
+          typename T3,
+          typename T4,
+          typename T5>
+AssertionResult AssertPred5Helper(const char* pred_text,
+                                  const char* e1,
+                                  const char* e2,
+                                  const char* e3,
+                                  const char* e4,
+                                  const char* e5,
+                                  Pred pred,
+                                  const T1& v1,
+                                  const T2& v2,
+                                  const T3& v3,
+                                  const T4& v4,
+                                  const T5& v5) {
+  if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
+
+  return AssertionFailure() << pred_text << "("
+                            << e1 << ", "
+                            << e2 << ", "
+                            << e3 << ", "
+                            << e4 << ", "
+                            << e5 << ") evaluates to false, where"
+                            << "\n" << e1 << " evaluates to " << v1
+                            << "\n" << e2 << " evaluates to " << v2
+                            << "\n" << e3 << " evaluates to " << v3
+                            << "\n" << e4 << " evaluates to " << v4
+                            << "\n" << e5 << " evaluates to " << v5;
+}
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
+// Don't use this in your code.
+#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
+  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
+                on_failure)
+
+// Internal macro for implementing {EXPECT|ASSERT}_PRED5.  Don't use
+// this in your code.
+#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
+  GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
+                                             #v1, \
+                                             #v2, \
+                                             #v3, \
+                                             #v4, \
+                                             #v5, \
+                                             pred, \
+                                             v1, \
+                                             v2, \
+                                             v3, \
+                                             v4, \
+                                             v5), on_failure)
+
+// 5-ary predicate assertion macros.
+#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
+  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
+#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
+  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
+#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
+  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
+#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
+  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
+
+
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
diff --git a/test/fmw/gtest/include/gtest/gtest_prod.h b/test/fmw/gtest/include/gtest/gtest_prod.h
new file mode 100644
index 0000000..da80ddc
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/gtest_prod.h
@@ -0,0 +1,58 @@
+// Copyright 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// Google C++ Testing Framework definitions useful in production code.
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
+#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
+
+// When you need to test the private or protected members of a class,
+// use the FRIEND_TEST macro to declare your tests as friends of the
+// class.  For example:
+//
+// class MyClass {
+//  private:
+//   void MyMethod();
+//   FRIEND_TEST(MyClassTest, MyMethod);
+// };
+//
+// class MyClassTest : public testing::Test {
+//   // ...
+// };
+//
+// TEST_F(MyClassTest, MyMethod) {
+//   // Can call MyClass::MyMethod() here.
+// }
+
+#define FRIEND_TEST(test_case_name, test_name)\
+friend class test_case_name##_##test_name##_Test
+
+#endif  // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h b/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h
new file mode 100644
index 0000000..2b3a78f
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h
@@ -0,0 +1,319 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file defines internal utilities needed for implementing
+// death tests.  They are subject to change without notice.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
+
+#include "gtest/internal/gtest-internal.h"
+
+#include <stdio.h>
+
+namespace testing {
+namespace internal {
+
+GTEST_DECLARE_string_(internal_run_death_test);
+
+// Names of the flags (needed for parsing Google Test flags).
+const char kDeathTestStyleFlag[] = "death_test_style";
+const char kDeathTestUseFork[] = "death_test_use_fork";
+const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
+
+#if GTEST_HAS_DEATH_TEST
+
+// DeathTest is a class that hides much of the complexity of the
+// GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method
+// returns a concrete class that depends on the prevailing death test
+// style, as defined by the --gtest_death_test_style and/or
+// --gtest_internal_run_death_test flags.
+
+// In describing the results of death tests, these terms are used with
+// the corresponding definitions:
+//
+// exit status:  The integer exit information in the format specified
+//               by wait(2)
+// exit code:    The integer code passed to exit(3), _exit(2), or
+//               returned from main()
+class GTEST_API_ DeathTest {
+ public:
+  // Create returns false if there was an error determining the
+  // appropriate action to take for the current death test; for example,
+  // if the gtest_death_test_style flag is set to an invalid value.
+  // The LastMessage method will return a more detailed message in that
+  // case.  Otherwise, the DeathTest pointer pointed to by the "test"
+  // argument is set.  If the death test should be skipped, the pointer
+  // is set to NULL; otherwise, it is set to the address of a new concrete
+  // DeathTest object that controls the execution of the current test.
+  static bool Create(const char* statement, const RE* regex,
+                     const char* file, int line, DeathTest** test);
+  DeathTest();
+  virtual ~DeathTest() { }
+
+  // A helper class that aborts a death test when it's deleted.
+  class ReturnSentinel {
+   public:
+    explicit ReturnSentinel(DeathTest* test) : test_(test) { }
+    ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
+   private:
+    DeathTest* const test_;
+    GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
+  } GTEST_ATTRIBUTE_UNUSED_;
+
+  // An enumeration of possible roles that may be taken when a death
+  // test is encountered.  EXECUTE means that the death test logic should
+  // be executed immediately.  OVERSEE means that the program should prepare
+  // the appropriate environment for a child process to execute the death
+  // test, then wait for it to complete.
+  enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
+
+  // An enumeration of the three reasons that a test might be aborted.
+  enum AbortReason {
+    TEST_ENCOUNTERED_RETURN_STATEMENT,
+    TEST_THREW_EXCEPTION,
+    TEST_DID_NOT_DIE
+  };
+
+  // Assumes one of the above roles.
+  virtual TestRole AssumeRole() = 0;
+
+  // Waits for the death test to finish and returns its status.
+  virtual int Wait() = 0;
+
+  // Returns true if the death test passed; that is, the test process
+  // exited during the test, its exit status matches a user-supplied
+  // predicate, and its stderr output matches a user-supplied regular
+  // expression.
+  // The user-supplied predicate may be a macro expression rather
+  // than a function pointer or functor, or else Wait and Passed could
+  // be combined.
+  virtual bool Passed(bool exit_status_ok) = 0;
+
+  // Signals that the death test did not die as expected.
+  virtual void Abort(AbortReason reason) = 0;
+
+  // Returns a human-readable outcome message regarding the outcome of
+  // the last death test.
+  static const char* LastMessage();
+
+  static void set_last_death_test_message(const std::string& message);
+
+ private:
+  // A string containing a description of the outcome of the last death test.
+  static std::string last_death_test_message_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
+};
+
+// Factory interface for death tests.  May be mocked out for testing.
+class DeathTestFactory {
+ public:
+  virtual ~DeathTestFactory() { }
+  virtual bool Create(const char* statement, const RE* regex,
+                      const char* file, int line, DeathTest** test) = 0;
+};
+
+// A concrete DeathTestFactory implementation for normal use.
+class DefaultDeathTestFactory : public DeathTestFactory {
+ public:
+  virtual bool Create(const char* statement, const RE* regex,
+                      const char* file, int line, DeathTest** test);
+};
+
+// Returns true if exit_status describes a process that was terminated
+// by a signal, or exited normally with a nonzero exit code.
+GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
+
+// Traps C++ exceptions escaping statement and reports them as test
+// failures. Note that trapping SEH exceptions is not implemented here.
+# if GTEST_HAS_EXCEPTIONS
+#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
+  try { \
+    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+  } catch (const ::std::exception& gtest_exception) { \
+    fprintf(\
+        stderr, \
+        "\n%s: Caught std::exception-derived exception escaping the " \
+        "death test statement. Exception message: %s\n", \
+        ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
+        gtest_exception.what()); \
+    fflush(stderr); \
+    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
+  } catch (...) { \
+    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
+  }
+
+# else
+#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
+  GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
+
+# endif
+
+// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
+// ASSERT_EXIT*, and EXPECT_EXIT*.
+# define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (::testing::internal::AlwaysTrue()) { \
+    const ::testing::internal::RE& gtest_regex = (regex); \
+    ::testing::internal::DeathTest* gtest_dt; \
+    if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \
+        __FILE__, __LINE__, &gtest_dt)) { \
+      goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
+    } \
+    if (gtest_dt != NULL) { \
+      ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
+          gtest_dt_ptr(gtest_dt); \
+      switch (gtest_dt->AssumeRole()) { \
+        case ::testing::internal::DeathTest::OVERSEE_TEST: \
+          if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
+            goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
+          } \
+          break; \
+        case ::testing::internal::DeathTest::EXECUTE_TEST: { \
+          ::testing::internal::DeathTest::ReturnSentinel \
+              gtest_sentinel(gtest_dt); \
+          GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
+          gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
+          break; \
+        } \
+        default: \
+          break; \
+      } \
+    } \
+  } else \
+    GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
+      fail(::testing::internal::DeathTest::LastMessage())
+// The symbol "fail" here expands to something into which a message
+// can be streamed.
+
+// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
+// NDEBUG mode. In this case we need the statements to be executed, the regex is
+// ignored, and the macro must accept a streamed message even though the message
+// is never printed.
+# define GTEST_EXECUTE_STATEMENT_(statement, regex) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (::testing::internal::AlwaysTrue()) { \
+     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+  } else \
+    ::testing::Message()
+
+// A class representing the parsed contents of the
+// --gtest_internal_run_death_test flag, as it existed when
+// RUN_ALL_TESTS was called.
+class InternalRunDeathTestFlag {
+ public:
+  InternalRunDeathTestFlag(const std::string& a_file,
+                           int a_line,
+                           int an_index,
+                           int a_write_fd)
+      : file_(a_file), line_(a_line), index_(an_index),
+        write_fd_(a_write_fd) {}
+
+  ~InternalRunDeathTestFlag() {
+    if (write_fd_ >= 0)
+      posix::Close(write_fd_);
+  }
+
+  const std::string& file() const { return file_; }
+  int line() const { return line_; }
+  int index() const { return index_; }
+  int write_fd() const { return write_fd_; }
+
+ private:
+  std::string file_;
+  int line_;
+  int index_;
+  int write_fd_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
+};
+
+// Returns a newly created InternalRunDeathTestFlag object with fields
+// initialized from the GTEST_FLAG(internal_run_death_test) flag if
+// the flag is specified; otherwise returns NULL.
+InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
+
+#else  // GTEST_HAS_DEATH_TEST
+
+// This macro is used for implementing macros such as
+// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
+// death tests are not supported. Those macros must compile on such systems
+// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
+// systems that support death tests. This allows one to write such a macro
+// on a system that does not support death tests and be sure that it will
+// compile on a death-test supporting system.
+//
+// Parameters:
+//   statement -  A statement that a macro such as EXPECT_DEATH would test
+//                for program termination. This macro has to make sure this
+//                statement is compiled but not executed, to ensure that
+//                EXPECT_DEATH_IF_SUPPORTED compiles with a certain
+//                parameter iff EXPECT_DEATH compiles with it.
+//   regex     -  A regex that a macro such as EXPECT_DEATH would use to test
+//                the output of statement.  This parameter has to be
+//                compiled but not evaluated by this macro, to ensure that
+//                this macro only accepts expressions that a macro such as
+//                EXPECT_DEATH would accept.
+//   terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
+//                and a return statement for ASSERT_DEATH_IF_SUPPORTED.
+//                This ensures that ASSERT_DEATH_IF_SUPPORTED will not
+//                compile inside functions where ASSERT_DEATH doesn't
+//                compile.
+//
+//  The branch that has an always false condition is used to ensure that
+//  statement and regex are compiled (and thus syntactically correct) but
+//  never executed. The unreachable code macro protects the terminator
+//  statement from generating an 'unreachable code' warning in case
+//  statement unconditionally returns or throws. The Message constructor at
+//  the end allows the syntax of streaming additional messages into the
+//  macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
+# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
+    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+    if (::testing::internal::AlwaysTrue()) { \
+      GTEST_LOG_(WARNING) \
+          << "Death tests are not supported on this platform.\n" \
+          << "Statement '" #statement "' cannot be verified."; \
+    } else if (::testing::internal::AlwaysFalse()) { \
+      ::testing::internal::RE::PartialMatch(".*", (regex)); \
+      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+      terminator; \
+    } else \
+      ::testing::Message()
+
+#endif  // GTEST_HAS_DEATH_TEST
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-filepath.h b/test/fmw/gtest/include/gtest/internal/gtest-filepath.h
new file mode 100644
index 0000000..7a13b4b
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-filepath.h
@@ -0,0 +1,206 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: keith.ray@gmail.com (Keith Ray)
+//
+// Google Test filepath utilities
+//
+// This header file declares classes and functions used internally by
+// Google Test.  They are subject to change without notice.
+//
+// This file is #included in <gtest/internal/gtest-internal.h>.
+// Do not include this header file separately!
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
+
+#include "gtest/internal/gtest-string.h"
+
+namespace testing {
+namespace internal {
+
+// FilePath - a class for file and directory pathname manipulation which
+// handles platform-specific conventions (like the pathname separator).
+// Used for helper functions for naming files in a directory for xml output.
+// Except for Set methods, all methods are const or static, which provides an
+// "immutable value object" -- useful for peace of mind.
+// A FilePath with a value ending in a path separator ("like/this/") represents
+// a directory, otherwise it is assumed to represent a file. In either case,
+// it may or may not represent an actual file or directory in the file system.
+// Names are NOT checked for syntax correctness -- no checking for illegal
+// characters, malformed paths, etc.
+
+class GTEST_API_ FilePath {
+ public:
+  FilePath() : pathname_("") { }
+  FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
+
+  explicit FilePath(const std::string& pathname) : pathname_(pathname) {
+    Normalize();
+  }
+
+  FilePath& operator=(const FilePath& rhs) {
+    Set(rhs);
+    return *this;
+  }
+
+  void Set(const FilePath& rhs) {
+    pathname_ = rhs.pathname_;
+  }
+
+  const std::string& string() const { return pathname_; }
+  const char* c_str() const { return pathname_.c_str(); }
+
+  // Returns the current working directory, or "" if unsuccessful.
+  static FilePath GetCurrentDir();
+
+  // Given directory = "dir", base_name = "test", number = 0,
+  // extension = "xml", returns "dir/test.xml". If number is greater
+  // than zero (e.g., 12), returns "dir/test_12.xml".
+  // On Windows platform, uses \ as the separator rather than /.
+  static FilePath MakeFileName(const FilePath& directory,
+                               const FilePath& base_name,
+                               int number,
+                               const char* extension);
+
+  // Given directory = "dir", relative_path = "test.xml",
+  // returns "dir/test.xml".
+  // On Windows, uses \ as the separator rather than /.
+  static FilePath ConcatPaths(const FilePath& directory,
+                              const FilePath& relative_path);
+
+  // Returns a pathname for a file that does not currently exist. The pathname
+  // will be directory/base_name.extension or
+  // directory/base_name_<number>.extension if directory/base_name.extension
+  // already exists. The number will be incremented until a pathname is found
+  // that does not already exist.
+  // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
+  // There could be a race condition if two or more processes are calling this
+  // function at the same time -- they could both pick the same filename.
+  static FilePath GenerateUniqueFileName(const FilePath& directory,
+                                         const FilePath& base_name,
+                                         const char* extension);
+
+  // Returns true iff the path is "".
+  bool IsEmpty() const { return pathname_.empty(); }
+
+  // If input name has a trailing separator character, removes it and returns
+  // the name, otherwise return the name string unmodified.
+  // On Windows platform, uses \ as the separator, other platforms use /.
+  FilePath RemoveTrailingPathSeparator() const;
+
+  // Returns a copy of the FilePath with the directory part removed.
+  // Example: FilePath("path/to/file").RemoveDirectoryName() returns
+  // FilePath("file"). If there is no directory part ("just_a_file"), it returns
+  // the FilePath unmodified. If there is no file part ("just_a_dir/") it
+  // returns an empty FilePath ("").
+  // On Windows platform, '\' is the path separator, otherwise it is '/'.
+  FilePath RemoveDirectoryName() const;
+
+  // RemoveFileName returns the directory path with the filename removed.
+  // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
+  // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
+  // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
+  // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
+  // On Windows platform, '\' is the path separator, otherwise it is '/'.
+  FilePath RemoveFileName() const;
+
+  // Returns a copy of the FilePath with the case-insensitive extension removed.
+  // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
+  // FilePath("dir/file"). If a case-insensitive extension is not
+  // found, returns a copy of the original FilePath.
+  FilePath RemoveExtension(const char* extension) const;
+
+  // Creates directories so that path exists. Returns true if successful or if
+  // the directories already exist; returns false if unable to create
+  // directories for any reason. Will also return false if the FilePath does
+  // not represent a directory (that is, it doesn't end with a path separator).
+  bool CreateDirectoriesRecursively() const;
+
+  // Create the directory so that path exists. Returns true if successful or
+  // if the directory already exists; returns false if unable to create the
+  // directory for any reason, including if the parent directory does not
+  // exist. Not named "CreateDirectory" because that's a macro on Windows.
+  bool CreateFolder() const;
+
+  // Returns true if FilePath describes something in the file-system,
+  // either a file, directory, or whatever, and that something exists.
+  bool FileOrDirectoryExists() const;
+
+  // Returns true if pathname describes a directory in the file-system
+  // that exists.
+  bool DirectoryExists() const;
+
+  // Returns true if FilePath ends with a path separator, which indicates that
+  // it is intended to represent a directory. Returns false otherwise.
+  // This does NOT check that a directory (or file) actually exists.
+  bool IsDirectory() const;
+
+  // Returns true if pathname describes a root directory. (Windows has one
+  // root directory per disk drive.)
+  bool IsRootDirectory() const;
+
+  // Returns true if pathname describes an absolute path.
+  bool IsAbsolutePath() const;
+
+ private:
+  // Replaces multiple consecutive separators with a single separator.
+  // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
+  // redundancies that might be in a pathname involving "." or "..".
+  //
+  // A pathname with multiple consecutive separators may occur either through
+  // user error or as a result of some scripts or APIs that generate a pathname
+  // with a trailing separator. On other platforms the same API or script
+  // may NOT generate a pathname with a trailing "/". Then elsewhere that
+  // pathname may have another "/" and pathname components added to it,
+  // without checking for the separator already being there.
+  // The script language and operating system may allow paths like "foo//bar"
+  // but some of the functions in FilePath will not handle that correctly. In
+  // particular, RemoveTrailingPathSeparator() only removes one separator, and
+  // it is called in CreateDirectoriesRecursively() assuming that it will change
+  // a pathname from directory syntax (trailing separator) to filename syntax.
+  //
+  // On Windows this method also replaces the alternate path separator '/' with
+  // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
+  // "bar\\foo".
+
+  void Normalize();
+
+  // Returns a pointer to the last occurence of a valid path separator in
+  // the FilePath. On Windows, for example, both '/' and '\' are valid path
+  // separators. Returns NULL if no path separator was found.
+  const char* FindLastPathSeparator() const;
+
+  std::string pathname_;
+};  // class FilePath
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-internal.h b/test/fmw/gtest/include/gtest/internal/gtest-internal.h
new file mode 100644
index 0000000..0dcc3a3
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-internal.h
@@ -0,0 +1,1158 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file declares functions and macros used internally by
+// Google Test.  They are subject to change without notice.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
+
+#include "gtest/internal/gtest-port.h"
+
+#if GTEST_OS_LINUX
+# include <stdlib.h>
+# include <sys/types.h>
+# include <sys/wait.h>
+# include <unistd.h>
+#endif  // GTEST_OS_LINUX
+
+#if GTEST_HAS_EXCEPTIONS
+# include <stdexcept>
+#endif
+
+#include <ctype.h>
+#include <float.h>
+#include <string.h>
+#include <iomanip>
+#include <limits>
+#include <set>
+
+#include "gtest/gtest-message.h"
+#include "gtest/internal/gtest-string.h"
+#include "gtest/internal/gtest-filepath.h"
+#include "gtest/internal/gtest-type-util.h"
+
+// Due to C++ preprocessor weirdness, we need double indirection to
+// concatenate two tokens when one of them is __LINE__.  Writing
+//
+//   foo ## __LINE__
+//
+// will result in the token foo__LINE__, instead of foo followed by
+// the current line number.  For more details, see
+// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
+#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
+#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
+
+class ProtocolMessage;
+namespace proto2 { class Message; }
+
+namespace testing {
+
+// Forward declarations.
+
+class AssertionResult;                 // Result of an assertion.
+class Message;                         // Represents a failure message.
+class Test;                            // Represents a test.
+class TestInfo;                        // Information about a test.
+class TestPartResult;                  // Result of a test part.
+class UnitTest;                        // A collection of test cases.
+
+template <typename T>
+::std::string PrintToString(const T& value);
+
+namespace internal {
+
+struct TraceInfo;                      // Information about a trace point.
+class ScopedTrace;                     // Implements scoped trace.
+class TestInfoImpl;                    // Opaque implementation of TestInfo
+class UnitTestImpl;                    // Opaque implementation of UnitTest
+
+// How many times InitGoogleTest() has been called.
+GTEST_API_ extern int g_init_gtest_count;
+
+// The text used in failure messages to indicate the start of the
+// stack trace.
+GTEST_API_ extern const char kStackTraceMarker[];
+
+// Two overloaded helpers for checking at compile time whether an
+// expression is a null pointer literal (i.e. NULL or any 0-valued
+// compile-time integral constant).  Their return values have
+// different sizes, so we can use sizeof() to test which version is
+// picked by the compiler.  These helpers have no implementations, as
+// we only need their signatures.
+//
+// Given IsNullLiteralHelper(x), the compiler will pick the first
+// version if x can be implicitly converted to Secret*, and pick the
+// second version otherwise.  Since Secret is a secret and incomplete
+// type, the only expression a user can write that has type Secret* is
+// a null pointer literal.  Therefore, we know that x is a null
+// pointer literal if and only if the first version is picked by the
+// compiler.
+char IsNullLiteralHelper(Secret* p);
+char (&IsNullLiteralHelper(...))[2];  // NOLINT
+
+// A compile-time bool constant that is true if and only if x is a
+// null pointer literal (i.e. NULL or any 0-valued compile-time
+// integral constant).
+#ifdef GTEST_ELLIPSIS_NEEDS_POD_
+// We lose support for NULL detection where the compiler doesn't like
+// passing non-POD classes through ellipsis (...).
+# define GTEST_IS_NULL_LITERAL_(x) false
+#else
+# define GTEST_IS_NULL_LITERAL_(x) \
+    (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
+#endif  // GTEST_ELLIPSIS_NEEDS_POD_
+
+// Appends the user-supplied message to the Google-Test-generated message.
+GTEST_API_ std::string AppendUserMessage(
+    const std::string& gtest_msg, const Message& user_msg);
+
+#if GTEST_HAS_EXCEPTIONS
+
+// This exception is thrown by (and only by) a failed Google Test
+// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
+// are enabled).  We derive it from std::runtime_error, which is for
+// errors presumably detectable only at run time.  Since
+// std::runtime_error inherits from std::exception, many testing
+// frameworks know how to extract and print the message inside it.
+class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
+ public:
+  explicit GoogleTestFailureException(const TestPartResult& failure);
+};
+
+#endif  // GTEST_HAS_EXCEPTIONS
+
+// A helper class for creating scoped traces in user programs.
+class GTEST_API_ ScopedTrace {
+ public:
+  // The c'tor pushes the given source file location and message onto
+  // a trace stack maintained by Google Test.
+  ScopedTrace(const char* file, int line, const Message& message);
+
+  // The d'tor pops the info pushed by the c'tor.
+  //
+  // Note that the d'tor is not virtual in order to be efficient.
+  // Don't inherit from ScopedTrace!
+  ~ScopedTrace();
+
+ private:
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
+} GTEST_ATTRIBUTE_UNUSED_;  // A ScopedTrace object does its job in its
+                            // c'tor and d'tor.  Therefore it doesn't
+                            // need to be used otherwise.
+
+// Constructs and returns the message for an equality assertion
+// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
+//
+// The first four parameters are the expressions used in the assertion
+// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
+// where foo is 5 and bar is 6, we have:
+//
+//   expected_expression: "foo"
+//   actual_expression:   "bar"
+//   expected_value:      "5"
+//   actual_value:        "6"
+//
+// The ignoring_case parameter is true iff the assertion is a
+// *_STRCASEEQ*.  When it's true, the string " (ignoring case)" will
+// be inserted into the message.
+GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
+                                     const char* actual_expression,
+                                     const std::string& expected_value,
+                                     const std::string& actual_value,
+                                     bool ignoring_case);
+
+// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
+GTEST_API_ std::string GetBoolAssertionFailureMessage(
+    const AssertionResult& assertion_result,
+    const char* expression_text,
+    const char* actual_predicate_value,
+    const char* expected_predicate_value);
+
+// This template class represents an IEEE floating-point number
+// (either single-precision or double-precision, depending on the
+// template parameters).
+//
+// The purpose of this class is to do more sophisticated number
+// comparison.  (Due to round-off error, etc, it's very unlikely that
+// two floating-points will be equal exactly.  Hence a naive
+// comparison by the == operation often doesn't work.)
+//
+// Format of IEEE floating-point:
+//
+//   The most-significant bit being the leftmost, an IEEE
+//   floating-point looks like
+//
+//     sign_bit exponent_bits fraction_bits
+//
+//   Here, sign_bit is a single bit that designates the sign of the
+//   number.
+//
+//   For float, there are 8 exponent bits and 23 fraction bits.
+//
+//   For double, there are 11 exponent bits and 52 fraction bits.
+//
+//   More details can be found at
+//   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
+//
+// Template parameter:
+//
+//   RawType: the raw floating-point type (either float or double)
+template <typename RawType>
+class FloatingPoint {
+ public:
+  // Defines the unsigned integer type that has the same size as the
+  // floating point number.
+  typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;
+
+  // Constants.
+
+  // # of bits in a number.
+  static const size_t kBitCount = 8*sizeof(RawType);
+
+  // # of fraction bits in a number.
+  static const size_t kFractionBitCount =
+    std::numeric_limits<RawType>::digits - 1;
+
+  // # of exponent bits in a number.
+  static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
+
+  // The mask for the sign bit.
+  static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
+
+  // The mask for the fraction bits.
+  static const Bits kFractionBitMask =
+    ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
+
+  // The mask for the exponent bits.
+  static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
+
+  // How many ULP's (Units in the Last Place) we want to tolerate when
+  // comparing two numbers.  The larger the value, the more error we
+  // allow.  A 0 value means that two numbers must be exactly the same
+  // to be considered equal.
+  //
+  // The maximum error of a single floating-point operation is 0.5
+  // units in the last place.  On Intel CPU's, all floating-point
+  // calculations are done with 80-bit precision, while double has 64
+  // bits.  Therefore, 4 should be enough for ordinary use.
+  //
+  // See the following article for more details on ULP:
+  // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
+  static const size_t kMaxUlps = 4;
+
+  // Constructs a FloatingPoint from a raw floating-point number.
+  //
+  // On an Intel CPU, passing a non-normalized NAN (Not a Number)
+  // around may change its bits, although the new value is guaranteed
+  // to be also a NAN.  Therefore, don't expect this constructor to
+  // preserve the bits in x when x is a NAN.
+  explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
+
+  // Static methods
+
+  // Reinterprets a bit pattern as a floating-point number.
+  //
+  // This function is needed to test the AlmostEquals() method.
+  static RawType ReinterpretBits(const Bits bits) {
+    FloatingPoint fp(0);
+    fp.u_.bits_ = bits;
+    return fp.u_.value_;
+  }
+
+  // Returns the floating-point number that represent positive infinity.
+  static RawType Infinity() {
+    return ReinterpretBits(kExponentBitMask);
+  }
+
+  // Returns the maximum representable finite floating-point number.
+  static RawType Max();
+
+  // Non-static methods
+
+  // Returns the bits that represents this number.
+  const Bits &bits() const { return u_.bits_; }
+
+  // Returns the exponent bits of this number.
+  Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
+
+  // Returns the fraction bits of this number.
+  Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
+
+  // Returns the sign bit of this number.
+  Bits sign_bit() const { return kSignBitMask & u_.bits_; }
+
+  // Returns true iff this is NAN (not a number).
+  bool is_nan() const {
+    // It's a NAN if the exponent bits are all ones and the fraction
+    // bits are not entirely zeros.
+    return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
+  }
+
+  // Returns true iff this number is at most kMaxUlps ULP's away from
+  // rhs.  In particular, this function:
+  //
+  //   - returns false if either number is (or both are) NAN.
+  //   - treats really large numbers as almost equal to infinity.
+  //   - thinks +0.0 and -0.0 are 0 DLP's apart.
+  bool AlmostEquals(const FloatingPoint& rhs) const {
+    // The IEEE standard says that any comparison operation involving
+    // a NAN must return false.
+    if (is_nan() || rhs.is_nan()) return false;
+
+    return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
+        <= kMaxUlps;
+  }
+
+ private:
+  // The data type used to store the actual floating-point number.
+  union FloatingPointUnion {
+    RawType value_;  // The raw floating-point number.
+    Bits bits_;      // The bits that represent the number.
+  };
+
+  // Converts an integer from the sign-and-magnitude representation to
+  // the biased representation.  More precisely, let N be 2 to the
+  // power of (kBitCount - 1), an integer x is represented by the
+  // unsigned number x + N.
+  //
+  // For instance,
+  //
+  //   -N + 1 (the most negative number representable using
+  //          sign-and-magnitude) is represented by 1;
+  //   0      is represented by N; and
+  //   N - 1  (the biggest number representable using
+  //          sign-and-magnitude) is represented by 2N - 1.
+  //
+  // Read http://en.wikipedia.org/wiki/Signed_number_representations
+  // for more details on signed number representations.
+  static Bits SignAndMagnitudeToBiased(const Bits &sam) {
+    if (kSignBitMask & sam) {
+      // sam represents a negative number.
+      return ~sam + 1;
+    } else {
+      // sam represents a positive number.
+      return kSignBitMask | sam;
+    }
+  }
+
+  // Given two numbers in the sign-and-magnitude representation,
+  // returns the distance between them as an unsigned number.
+  static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
+                                                     const Bits &sam2) {
+    const Bits biased1 = SignAndMagnitudeToBiased(sam1);
+    const Bits biased2 = SignAndMagnitudeToBiased(sam2);
+    return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
+  }
+
+  FloatingPointUnion u_;
+};
+
+// We cannot use std::numeric_limits<T>::max() as it clashes with the max()
+// macro defined by <windows.h>.
+template <>
+inline float FloatingPoint<float>::Max() { return FLT_MAX; }
+template <>
+inline double FloatingPoint<double>::Max() { return DBL_MAX; }
+
+// Typedefs the instances of the FloatingPoint template class that we
+// care to use.
+typedef FloatingPoint<float> Float;
+typedef FloatingPoint<double> Double;
+
+// In order to catch the mistake of putting tests that use different
+// test fixture classes in the same test case, we need to assign
+// unique IDs to fixture classes and compare them.  The TypeId type is
+// used to hold such IDs.  The user should treat TypeId as an opaque
+// type: the only operation allowed on TypeId values is to compare
+// them for equality using the == operator.
+typedef const void* TypeId;
+
+template <typename T>
+class TypeIdHelper {
+ public:
+  // dummy_ must not have a const type.  Otherwise an overly eager
+  // compiler (e.g. MSVC 7.1 & 8.0) may try to merge
+  // TypeIdHelper<T>::dummy_ for different Ts as an "optimization".
+  static bool dummy_;
+};
+
+template <typename T>
+bool TypeIdHelper<T>::dummy_ = false;
+
+// GetTypeId<T>() returns the ID of type T.  Different values will be
+// returned for different types.  Calling the function twice with the
+// same type argument is guaranteed to return the same ID.
+template <typename T>
+TypeId GetTypeId() {
+  // The compiler is required to allocate a different
+  // TypeIdHelper<T>::dummy_ variable for each T used to instantiate
+  // the template.  Therefore, the address of dummy_ is guaranteed to
+  // be unique.
+  return &(TypeIdHelper<T>::dummy_);
+}
+
+// Returns the type ID of ::testing::Test.  Always call this instead
+// of GetTypeId< ::testing::Test>() to get the type ID of
+// ::testing::Test, as the latter may give the wrong result due to a
+// suspected linker bug when compiling Google Test as a Mac OS X
+// framework.
+GTEST_API_ TypeId GetTestTypeId();
+
+// Defines the abstract factory interface that creates instances
+// of a Test object.
+class TestFactoryBase {
+ public:
+  virtual ~TestFactoryBase() {}
+
+  // Creates a test instance to run. The instance is both created and destroyed
+  // within TestInfoImpl::Run()
+  virtual Test* CreateTest() = 0;
+
+ protected:
+  TestFactoryBase() {}
+
+ private:
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
+};
+
+// This class provides implementation of TeastFactoryBase interface.
+// It is used in TEST and TEST_F macros.
+template <class TestClass>
+class TestFactoryImpl : public TestFactoryBase {
+ public:
+  virtual Test* CreateTest() { return new TestClass; }
+};
+
+#if GTEST_OS_WINDOWS
+
+// Predicate-formatters for implementing the HRESULT checking macros
+// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
+// We pass a long instead of HRESULT to avoid causing an
+// include dependency for the HRESULT type.
+GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
+                                            long hr);  // NOLINT
+GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
+                                            long hr);  // NOLINT
+
+#endif  // GTEST_OS_WINDOWS
+
+// Types of SetUpTestCase() and TearDownTestCase() functions.
+typedef void (*SetUpTestCaseFunc)();
+typedef void (*TearDownTestCaseFunc)();
+
+// Creates a new TestInfo object and registers it with Google Test;
+// returns the created object.
+//
+// Arguments:
+//
+//   test_case_name:   name of the test case
+//   name:             name of the test
+//   type_param        the name of the test's type parameter, or NULL if
+//                     this is not a typed or a type-parameterized test.
+//   value_param       text representation of the test's value parameter,
+//                     or NULL if this is not a type-parameterized test.
+//   fixture_class_id: ID of the test fixture class
+//   set_up_tc:        pointer to the function that sets up the test case
+//   tear_down_tc:     pointer to the function that tears down the test case
+//   factory:          pointer to the factory that creates a test object.
+//                     The newly created TestInfo instance will assume
+//                     ownership of the factory object.
+GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
+    const char* test_case_name,
+    const char* name,
+    const char* type_param,
+    const char* value_param,
+    TypeId fixture_class_id,
+    SetUpTestCaseFunc set_up_tc,
+    TearDownTestCaseFunc tear_down_tc,
+    TestFactoryBase* factory);
+
+// If *pstr starts with the given prefix, modifies *pstr to be right
+// past the prefix and returns true; otherwise leaves *pstr unchanged
+// and returns false.  None of pstr, *pstr, and prefix can be NULL.
+GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
+
+#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
+
+// State of the definition of a type-parameterized test case.
+class GTEST_API_ TypedTestCasePState {
+ public:
+  TypedTestCasePState() : registered_(false) {}
+
+  // Adds the given test name to defined_test_names_ and return true
+  // if the test case hasn't been registered; otherwise aborts the
+  // program.
+  bool AddTestName(const char* file, int line, const char* case_name,
+                   const char* test_name) {
+    if (registered_) {
+      fprintf(stderr, "%s Test %s must be defined before "
+              "REGISTER_TYPED_TEST_CASE_P(%s, ...).\n",
+              FormatFileLocation(file, line).c_str(), test_name, case_name);
+      fflush(stderr);
+      posix::Abort();
+    }
+    defined_test_names_.insert(test_name);
+    return true;
+  }
+
+  // Verifies that registered_tests match the test names in
+  // defined_test_names_; returns registered_tests if successful, or
+  // aborts the program otherwise.
+  const char* VerifyRegisteredTestNames(
+      const char* file, int line, const char* registered_tests);
+
+ private:
+  bool registered_;
+  ::std::set<const char*> defined_test_names_;
+};
+
+// Skips to the first non-space char after the first comma in 'str';
+// returns NULL if no comma is found in 'str'.
+inline const char* SkipComma(const char* str) {
+  const char* comma = strchr(str, ',');
+  if (comma == NULL) {
+    return NULL;
+  }
+  while (IsSpace(*(++comma))) {}
+  return comma;
+}
+
+// Returns the prefix of 'str' before the first comma in it; returns
+// the entire string if it contains no comma.
+inline std::string GetPrefixUntilComma(const char* str) {
+  const char* comma = strchr(str, ',');
+  return comma == NULL ? str : std::string(str, comma);
+}
+
+// TypeParameterizedTest<Fixture, TestSel, Types>::Register()
+// registers a list of type-parameterized tests with Google Test.  The
+// return value is insignificant - we just need to return something
+// such that we can call this function in a namespace scope.
+//
+// Implementation note: The GTEST_TEMPLATE_ macro declares a template
+// template parameter.  It's defined in gtest-type-util.h.
+template <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>
+class TypeParameterizedTest {
+ public:
+  // 'index' is the index of the test in the type list 'Types'
+  // specified in INSTANTIATE_TYPED_TEST_CASE_P(Prefix, TestCase,
+  // Types).  Valid values for 'index' are [0, N - 1] where N is the
+  // length of Types.
+  static bool Register(const char* prefix, const char* case_name,
+                       const char* test_names, int index) {
+    typedef typename Types::Head Type;
+    typedef Fixture<Type> FixtureClass;
+    typedef typename GTEST_BIND_(TestSel, Type) TestClass;
+
+    // First, registers the first type-parameterized test in the type
+    // list.
+    MakeAndRegisterTestInfo(
+        (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + "/"
+         + StreamableToString(index)).c_str(),
+        GetPrefixUntilComma(test_names).c_str(),
+        GetTypeName<Type>().c_str(),
+        NULL,  // No value parameter.
+        GetTypeId<FixtureClass>(),
+        TestClass::SetUpTestCase,
+        TestClass::TearDownTestCase,
+        new TestFactoryImpl<TestClass>);
+
+    // Next, recurses (at compile time) with the tail of the type list.
+    return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>
+        ::Register(prefix, case_name, test_names, index + 1);
+  }
+};
+
+// The base case for the compile time recursion.
+template <GTEST_TEMPLATE_ Fixture, class TestSel>
+class TypeParameterizedTest<Fixture, TestSel, Types0> {
+ public:
+  static bool Register(const char* /*prefix*/, const char* /*case_name*/,
+                       const char* /*test_names*/, int /*index*/) {
+    return true;
+  }
+};
+
+// TypeParameterizedTestCase<Fixture, Tests, Types>::Register()
+// registers *all combinations* of 'Tests' and 'Types' with Google
+// Test.  The return value is insignificant - we just need to return
+// something such that we can call this function in a namespace scope.
+template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>
+class TypeParameterizedTestCase {
+ public:
+  static bool Register(const char* prefix, const char* case_name,
+                       const char* test_names) {
+    typedef typename Tests::Head Head;
+
+    // First, register the first test in 'Test' for each type in 'Types'.
+    TypeParameterizedTest<Fixture, Head, Types>::Register(
+        prefix, case_name, test_names, 0);
+
+    // Next, recurses (at compile time) with the tail of the test list.
+    return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>
+        ::Register(prefix, case_name, SkipComma(test_names));
+  }
+};
+
+// The base case for the compile time recursion.
+template <GTEST_TEMPLATE_ Fixture, typename Types>
+class TypeParameterizedTestCase<Fixture, Templates0, Types> {
+ public:
+  static bool Register(const char* /*prefix*/, const char* /*case_name*/,
+                       const char* /*test_names*/) {
+    return true;
+  }
+};
+
+#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
+
+// Returns the current OS stack trace as an std::string.
+//
+// The maximum number of stack frames to be included is specified by
+// the gtest_stack_trace_depth flag.  The skip_count parameter
+// specifies the number of top frames to be skipped, which doesn't
+// count against the number of frames to be included.
+//
+// For example, if Foo() calls Bar(), which in turn calls
+// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
+// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
+GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(
+    UnitTest* unit_test, int skip_count);
+
+// Helpers for suppressing warnings on unreachable code or constant
+// condition.
+
+// Always returns true.
+GTEST_API_ bool AlwaysTrue();
+
+// Always returns false.
+inline bool AlwaysFalse() { return !AlwaysTrue(); }
+
+// Helper for suppressing false warning from Clang on a const char*
+// variable declared in a conditional expression always being NULL in
+// the else branch.
+struct GTEST_API_ ConstCharPtr {
+  ConstCharPtr(const char* str) : value(str) {}
+  operator bool() const { return true; }
+  const char* value;
+};
+
+// A simple Linear Congruential Generator for generating random
+// numbers with a uniform distribution.  Unlike rand() and srand(), it
+// doesn't use global state (and therefore can't interfere with user
+// code).  Unlike rand_r(), it's portable.  An LCG isn't very random,
+// but it's good enough for our purposes.
+class GTEST_API_ Random {
+ public:
+  static const UInt32 kMaxRange = 1u << 31;
+
+  explicit Random(UInt32 seed) : state_(seed) {}
+
+  void Reseed(UInt32 seed) { state_ = seed; }
+
+  // Generates a random number from [0, range).  Crashes if 'range' is
+  // 0 or greater than kMaxRange.
+  UInt32 Generate(UInt32 range);
+
+ private:
+  UInt32 state_;
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
+};
+
+// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
+// compiler error iff T1 and T2 are different types.
+template <typename T1, typename T2>
+struct CompileAssertTypesEqual;
+
+template <typename T>
+struct CompileAssertTypesEqual<T, T> {
+};
+
+// Removes the reference from a type if it is a reference type,
+// otherwise leaves it unchanged.  This is the same as
+// tr1::remove_reference, which is not widely available yet.
+template <typename T>
+struct RemoveReference { typedef T type; };  // NOLINT
+template <typename T>
+struct RemoveReference<T&> { typedef T type; };  // NOLINT
+
+// A handy wrapper around RemoveReference that works when the argument
+// T depends on template parameters.
+#define GTEST_REMOVE_REFERENCE_(T) \
+    typename ::testing::internal::RemoveReference<T>::type
+
+// Removes const from a type if it is a const type, otherwise leaves
+// it unchanged.  This is the same as tr1::remove_const, which is not
+// widely available yet.
+template <typename T>
+struct RemoveConst { typedef T type; };  // NOLINT
+template <typename T>
+struct RemoveConst<const T> { typedef T type; };  // NOLINT
+
+// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above
+// definition to fail to remove the const in 'const int[3]' and 'const
+// char[3][4]'.  The following specialization works around the bug.
+template <typename T, size_t N>
+struct RemoveConst<const T[N]> {
+  typedef typename RemoveConst<T>::type type[N];
+};
+
+#if defined(_MSC_VER) && _MSC_VER < 1400
+// This is the only specialization that allows VC++ 7.1 to remove const in
+// 'const int[3] and 'const int[3][4]'.  However, it causes trouble with GCC
+// and thus needs to be conditionally compiled.
+template <typename T, size_t N>
+struct RemoveConst<T[N]> {
+  typedef typename RemoveConst<T>::type type[N];
+};
+#endif
+
+// A handy wrapper around RemoveConst that works when the argument
+// T depends on template parameters.
+#define GTEST_REMOVE_CONST_(T) \
+    typename ::testing::internal::RemoveConst<T>::type
+
+// Turns const U&, U&, const U, and U all into U.
+#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
+    GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
+
+// Adds reference to a type if it is not a reference type,
+// otherwise leaves it unchanged.  This is the same as
+// tr1::add_reference, which is not widely available yet.
+template <typename T>
+struct AddReference { typedef T& type; };  // NOLINT
+template <typename T>
+struct AddReference<T&> { typedef T& type; };  // NOLINT
+
+// A handy wrapper around AddReference that works when the argument T
+// depends on template parameters.
+#define GTEST_ADD_REFERENCE_(T) \
+    typename ::testing::internal::AddReference<T>::type
+
+// Adds a reference to const on top of T as necessary.  For example,
+// it transforms
+//
+//   char         ==> const char&
+//   const char   ==> const char&
+//   char&        ==> const char&
+//   const char&  ==> const char&
+//
+// The argument T must depend on some template parameters.
+#define GTEST_REFERENCE_TO_CONST_(T) \
+    GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))
+
+// ImplicitlyConvertible<From, To>::value is a compile-time bool
+// constant that's true iff type From can be implicitly converted to
+// type To.
+template <typename From, typename To>
+class ImplicitlyConvertible {
+ private:
+  // We need the following helper functions only for their types.
+  // They have no implementations.
+
+  // MakeFrom() is an expression whose type is From.  We cannot simply
+  // use From(), as the type From may not have a public default
+  // constructor.
+  static From MakeFrom();
+
+  // These two functions are overloaded.  Given an expression
+  // Helper(x), the compiler will pick the first version if x can be
+  // implicitly converted to type To; otherwise it will pick the
+  // second version.
+  //
+  // The first version returns a value of size 1, and the second
+  // version returns a value of size 2.  Therefore, by checking the
+  // size of Helper(x), which can be done at compile time, we can tell
+  // which version of Helper() is used, and hence whether x can be
+  // implicitly converted to type To.
+  static char Helper(To);
+  static char (&Helper(...))[2];  // NOLINT
+
+  // We have to put the 'public' section after the 'private' section,
+  // or MSVC refuses to compile the code.
+ public:
+  // MSVC warns about implicitly converting from double to int for
+  // possible loss of data, so we need to temporarily disable the
+  // warning.
+#ifdef _MSC_VER
+# pragma warning(push)          // Saves the current warning state.
+# pragma warning(disable:4244)  // Temporarily disables warning 4244.
+
+  static const bool value =
+      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
+# pragma warning(pop)           // Restores the warning state.
+#elif defined(__BORLANDC__)
+  // C++Builder cannot use member overload resolution during template
+  // instantiation.  The simplest workaround is to use its C++0x type traits
+  // functions (C++Builder 2009 and above only).
+  static const bool value = __is_convertible(From, To);
+#else
+  static const bool value =
+      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
+#endif  // _MSV_VER
+};
+template <typename From, typename To>
+const bool ImplicitlyConvertible<From, To>::value;
+
+// IsAProtocolMessage<T>::value is a compile-time bool constant that's
+// true iff T is type ProtocolMessage, proto2::Message, or a subclass
+// of those.
+template <typename T>
+struct IsAProtocolMessage
+    : public bool_constant<
+  ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value ||
+  ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> {
+};
+
+// When the compiler sees expression IsContainerTest<C>(0), if C is an
+// STL-style container class, the first overload of IsContainerTest
+// will be viable (since both C::iterator* and C::const_iterator* are
+// valid types and NULL can be implicitly converted to them).  It will
+// be picked over the second overload as 'int' is a perfect match for
+// the type of argument 0.  If C::iterator or C::const_iterator is not
+// a valid type, the first overload is not viable, and the second
+// overload will be picked.  Therefore, we can determine whether C is
+// a container class by checking the type of IsContainerTest<C>(0).
+// The value of the expression is insignificant.
+//
+// Note that we look for both C::iterator and C::const_iterator.  The
+// reason is that C++ injects the name of a class as a member of the
+// class itself (e.g. you can refer to class iterator as either
+// 'iterator' or 'iterator::iterator').  If we look for C::iterator
+// only, for example, we would mistakenly think that a class named
+// iterator is an STL container.
+//
+// Also note that the simpler approach of overloading
+// IsContainerTest(typename C::const_iterator*) and
+// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
+typedef int IsContainer;
+template <class C>
+IsContainer IsContainerTest(int /* dummy */,
+                            typename C::iterator* /* it */ = NULL,
+                            typename C::const_iterator* /* const_it */ = NULL) {
+  return 0;
+}
+
+typedef char IsNotContainer;
+template <class C>
+IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
+
+// EnableIf<condition>::type is void when 'Cond' is true, and
+// undefined when 'Cond' is false.  To use SFINAE to make a function
+// overload only apply when a particular expression is true, add
+// "typename EnableIf<expression>::type* = 0" as the last parameter.
+template<bool> struct EnableIf;
+template<> struct EnableIf<true> { typedef void type; };  // NOLINT
+
+// Utilities for native arrays.
+
+// ArrayEq() compares two k-dimensional native arrays using the
+// elements' operator==, where k can be any integer >= 0.  When k is
+// 0, ArrayEq() degenerates into comparing a single pair of values.
+
+template <typename T, typename U>
+bool ArrayEq(const T* lhs, size_t size, const U* rhs);
+
+// This generic version is used when k is 0.
+template <typename T, typename U>
+inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
+
+// This overload is used when k >= 1.
+template <typename T, typename U, size_t N>
+inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
+  return internal::ArrayEq(lhs, N, rhs);
+}
+
+// This helper reduces code bloat.  If we instead put its logic inside
+// the previous ArrayEq() function, arrays with different sizes would
+// lead to different copies of the template code.
+template <typename T, typename U>
+bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
+  for (size_t i = 0; i != size; i++) {
+    if (!internal::ArrayEq(lhs[i], rhs[i]))
+      return false;
+  }
+  return true;
+}
+
+// Finds the first element in the iterator range [begin, end) that
+// equals elem.  Element may be a native array type itself.
+template <typename Iter, typename Element>
+Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
+  for (Iter it = begin; it != end; ++it) {
+    if (internal::ArrayEq(*it, elem))
+      return it;
+  }
+  return end;
+}
+
+// CopyArray() copies a k-dimensional native array using the elements'
+// operator=, where k can be any integer >= 0.  When k is 0,
+// CopyArray() degenerates into copying a single value.
+
+template <typename T, typename U>
+void CopyArray(const T* from, size_t size, U* to);
+
+// This generic version is used when k is 0.
+template <typename T, typename U>
+inline void CopyArray(const T& from, U* to) { *to = from; }
+
+// This overload is used when k >= 1.
+template <typename T, typename U, size_t N>
+inline void CopyArray(const T(&from)[N], U(*to)[N]) {
+  internal::CopyArray(from, N, *to);
+}
+
+// This helper reduces code bloat.  If we instead put its logic inside
+// the previous CopyArray() function, arrays with different sizes
+// would lead to different copies of the template code.
+template <typename T, typename U>
+void CopyArray(const T* from, size_t size, U* to) {
+  for (size_t i = 0; i != size; i++) {
+    internal::CopyArray(from[i], to + i);
+  }
+}
+
+// The relation between an NativeArray object (see below) and the
+// native array it represents.
+enum RelationToSource {
+  kReference,  // The NativeArray references the native array.
+  kCopy        // The NativeArray makes a copy of the native array and
+               // owns the copy.
+};
+
+// Adapts a native array to a read-only STL-style container.  Instead
+// of the complete STL container concept, this adaptor only implements
+// members useful for Google Mock's container matchers.  New members
+// should be added as needed.  To simplify the implementation, we only
+// support Element being a raw type (i.e. having no top-level const or
+// reference modifier).  It's the client's responsibility to satisfy
+// this requirement.  Element can be an array type itself (hence
+// multi-dimensional arrays are supported).
+template <typename Element>
+class NativeArray {
+ public:
+  // STL-style container typedefs.
+  typedef Element value_type;
+  typedef Element* iterator;
+  typedef const Element* const_iterator;
+
+  // Constructs from a native array.
+  NativeArray(const Element* array, size_t count, RelationToSource relation) {
+    Init(array, count, relation);
+  }
+
+  // Copy constructor.
+  NativeArray(const NativeArray& rhs) {
+    Init(rhs.array_, rhs.size_, rhs.relation_to_source_);
+  }
+
+  ~NativeArray() {
+    // Ensures that the user doesn't instantiate NativeArray with a
+    // const or reference type.
+    static_cast<void>(StaticAssertTypeEqHelper<Element,
+        GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>());
+    if (relation_to_source_ == kCopy)
+      delete[] array_;
+  }
+
+  // STL-style container methods.
+  size_t size() const { return size_; }
+  const_iterator begin() const { return array_; }
+  const_iterator end() const { return array_ + size_; }
+  bool operator==(const NativeArray& rhs) const {
+    return size() == rhs.size() &&
+        ArrayEq(begin(), size(), rhs.begin());
+  }
+
+ private:
+  // Initializes this object; makes a copy of the input array if
+  // 'relation' is kCopy.
+  void Init(const Element* array, size_t a_size, RelationToSource relation) {
+    if (relation == kReference) {
+      array_ = array;
+    } else {
+      Element* const copy = new Element[a_size];
+      CopyArray(array, a_size, copy);
+      array_ = copy;
+    }
+    size_ = a_size;
+    relation_to_source_ = relation;
+  }
+
+  const Element* array_;
+  size_t size_;
+  RelationToSource relation_to_source_;
+
+  GTEST_DISALLOW_ASSIGN_(NativeArray);
+};
+
+}  // namespace internal
+}  // namespace testing
+
+#define GTEST_MESSAGE_AT_(file, line, message, result_type) \
+  ::testing::internal::AssertHelper(result_type, file, line, message) \
+    = ::testing::Message()
+
+#define GTEST_MESSAGE_(message, result_type) \
+  GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
+
+#define GTEST_FATAL_FAILURE_(message) \
+  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
+
+#define GTEST_NONFATAL_FAILURE_(message) \
+  GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
+
+#define GTEST_SUCCESS_(message) \
+  GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
+
+// Suppresses MSVC warnings 4072 (unreachable code) for the code following
+// statement if it returns or throws (or doesn't return or throw in some
+// situations).
+#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
+  if (::testing::internal::AlwaysTrue()) { statement; }
+
+#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (::testing::internal::ConstCharPtr gtest_msg = "") { \
+    bool gtest_caught_expected = false; \
+    try { \
+      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+    } \
+    catch (expected_exception const&) { \
+      gtest_caught_expected = true; \
+    } \
+    catch (...) { \
+      gtest_msg.value = \
+          "Expected: " #statement " throws an exception of type " \
+          #expected_exception ".\n  Actual: it throws a different type."; \
+      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
+    } \
+    if (!gtest_caught_expected) { \
+      gtest_msg.value = \
+          "Expected: " #statement " throws an exception of type " \
+          #expected_exception ".\n  Actual: it throws nothing."; \
+      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
+    } \
+  } else \
+    GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
+      fail(gtest_msg.value)
+
+#define GTEST_TEST_NO_THROW_(statement, fail) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (::testing::internal::AlwaysTrue()) { \
+    try { \
+      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+    } \
+    catch (...) { \
+      goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
+    } \
+  } else \
+    GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
+      fail("Expected: " #statement " doesn't throw an exception.\n" \
+           "  Actual: it throws.")
+
+#define GTEST_TEST_ANY_THROW_(statement, fail) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (::testing::internal::AlwaysTrue()) { \
+    bool gtest_caught_any = false; \
+    try { \
+      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+    } \
+    catch (...) { \
+      gtest_caught_any = true; \
+    } \
+    if (!gtest_caught_any) { \
+      goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
+    } \
+  } else \
+    GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
+      fail("Expected: " #statement " throws an exception.\n" \
+           "  Actual: it doesn't.")
+
+
+// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
+// either a boolean expression or an AssertionResult. text is a textual
+// represenation of expression as it was passed into the EXPECT_TRUE.
+#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (const ::testing::AssertionResult gtest_ar_ = \
+      ::testing::AssertionResult(expression)) \
+    ; \
+  else \
+    fail(::testing::internal::GetBoolAssertionFailureMessage(\
+        gtest_ar_, text, #actual, #expected).c_str())
+
+#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+  if (::testing::internal::AlwaysTrue()) { \
+    ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
+    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+    if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
+      goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
+    } \
+  } else \
+    GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
+      fail("Expected: " #statement " doesn't generate new fatal " \
+           "failures in the current thread.\n" \
+           "  Actual: it does.")
+
+// Expands to the name of the class that implements the given test.
+#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
+  test_case_name##_##test_name##_Test
+
+// Helper macro for defining tests.
+#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\
+class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
+ public:\
+  GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
+ private:\
+  virtual void TestBody();\
+  static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(\
+      GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
+};\
+\
+::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
+  ::test_info_ =\
+    ::testing::internal::MakeAndRegisterTestInfo(\
+        #test_case_name, #test_name, NULL, NULL, \
+        (parent_id), \
+        parent_class::SetUpTestCase, \
+        parent_class::TearDownTestCase, \
+        new ::testing::internal::TestFactoryImpl<\
+            GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
+void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h b/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h
new file mode 100644
index 0000000..b1362cd
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h
@@ -0,0 +1,233 @@
+// Copyright 2003 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: Dan Egnor (egnor@google.com)
+//
+// A "smart" pointer type with reference tracking.  Every pointer to a
+// particular object is kept on a circular linked list.  When the last pointer
+// to an object is destroyed or reassigned, the object is deleted.
+//
+// Used properly, this deletes the object when the last reference goes away.
+// There are several caveats:
+// - Like all reference counting schemes, cycles lead to leaks.
+// - Each smart pointer is actually two pointers (8 bytes instead of 4).
+// - Every time a pointer is assigned, the entire list of pointers to that
+//   object is traversed.  This class is therefore NOT SUITABLE when there
+//   will often be more than two or three pointers to a particular object.
+// - References are only tracked as long as linked_ptr<> objects are copied.
+//   If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
+//   will happen (double deletion).
+//
+// A good use of this class is storing object references in STL containers.
+// You can safely put linked_ptr<> in a vector<>.
+// Other uses may not be as good.
+//
+// Note: If you use an incomplete type with linked_ptr<>, the class
+// *containing* linked_ptr<> must have a constructor and destructor (even
+// if they do nothing!).
+//
+// Bill Gibbons suggested we use something like this.
+//
+// Thread Safety:
+//   Unlike other linked_ptr implementations, in this implementation
+//   a linked_ptr object is thread-safe in the sense that:
+//     - it's safe to copy linked_ptr objects concurrently,
+//     - it's safe to copy *from* a linked_ptr and read its underlying
+//       raw pointer (e.g. via get()) concurrently, and
+//     - it's safe to write to two linked_ptrs that point to the same
+//       shared object concurrently.
+// TODO(wan@google.com): rename this to safe_linked_ptr to avoid
+// confusion with normal linked_ptr.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
+
+#include <stdlib.h>
+#include <assert.h>
+
+#include "gtest/internal/gtest-port.h"
+
+namespace testing {
+namespace internal {
+
+// Protects copying of all linked_ptr objects.
+GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
+
+// This is used internally by all instances of linked_ptr<>.  It needs to be
+// a non-template class because different types of linked_ptr<> can refer to
+// the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
+// So, it needs to be possible for different types of linked_ptr to participate
+// in the same circular linked list, so we need a single class type here.
+//
+// DO NOT USE THIS CLASS DIRECTLY YOURSELF.  Use linked_ptr<T>.
+class linked_ptr_internal {
+ public:
+  // Create a new circle that includes only this instance.
+  void join_new() {
+    next_ = this;
+  }
+
+  // Many linked_ptr operations may change p.link_ for some linked_ptr
+  // variable p in the same circle as this object.  Therefore we need
+  // to prevent two such operations from occurring concurrently.
+  //
+  // Note that different types of linked_ptr objects can coexist in a
+  // circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and
+  // linked_ptr<Derived2>).  Therefore we must use a single mutex to
+  // protect all linked_ptr objects.  This can create serious
+  // contention in production code, but is acceptable in a testing
+  // framework.
+
+  // Join an existing circle.
+  void join(linked_ptr_internal const* ptr)
+      GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {
+    MutexLock lock(&g_linked_ptr_mutex);
+
+    linked_ptr_internal const* p = ptr;
+    while (p->next_ != ptr) p = p->next_;
+    p->next_ = this;
+    next_ = ptr;
+  }
+
+  // Leave whatever circle we're part of.  Returns true if we were the
+  // last member of the circle.  Once this is done, you can join() another.
+  bool depart()
+      GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {
+    MutexLock lock(&g_linked_ptr_mutex);
+
+    if (next_ == this) return true;
+    linked_ptr_internal const* p = next_;
+    while (p->next_ != this) p = p->next_;
+    p->next_ = next_;
+    return false;
+  }
+
+ private:
+  mutable linked_ptr_internal const* next_;
+};
+
+template <typename T>
+class linked_ptr {
+ public:
+  typedef T element_type;
+
+  // Take over ownership of a raw pointer.  This should happen as soon as
+  // possible after the object is created.
+  explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
+  ~linked_ptr() { depart(); }
+
+  // Copy an existing linked_ptr<>, adding ourselves to the list of references.
+  template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
+  linked_ptr(linked_ptr const& ptr) {  // NOLINT
+    assert(&ptr != this);
+    copy(&ptr);
+  }
+
+  // Assignment releases the old value and acquires the new.
+  template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
+    depart();
+    copy(&ptr);
+    return *this;
+  }
+
+  linked_ptr& operator=(linked_ptr const& ptr) {
+    if (&ptr != this) {
+      depart();
+      copy(&ptr);
+    }
+    return *this;
+  }
+
+  // Smart pointer members.
+  void reset(T* ptr = NULL) {
+    depart();
+    capture(ptr);
+  }
+  T* get() const { return value_; }
+  T* operator->() const { return value_; }
+  T& operator*() const { return *value_; }
+
+  bool operator==(T* p) const { return value_ == p; }
+  bool operator!=(T* p) const { return value_ != p; }
+  template <typename U>
+  bool operator==(linked_ptr<U> const& ptr) const {
+    return value_ == ptr.get();
+  }
+  template <typename U>
+  bool operator!=(linked_ptr<U> const& ptr) const {
+    return value_ != ptr.get();
+  }
+
+ private:
+  template <typename U>
+  friend class linked_ptr;
+
+  T* value_;
+  linked_ptr_internal link_;
+
+  void depart() {
+    if (link_.depart()) delete value_;
+  }
+
+  void capture(T* ptr) {
+    value_ = ptr;
+    link_.join_new();
+  }
+
+  template <typename U> void copy(linked_ptr<U> const* ptr) {
+    value_ = ptr->get();
+    if (value_)
+      link_.join(&ptr->link_);
+    else
+      link_.join_new();
+  }
+};
+
+template<typename T> inline
+bool operator==(T* ptr, const linked_ptr<T>& x) {
+  return ptr == x.get();
+}
+
+template<typename T> inline
+bool operator!=(T* ptr, const linked_ptr<T>& x) {
+  return ptr != x.get();
+}
+
+// A function to convert T* into linked_ptr<T>
+// Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation
+// for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
+template <typename T>
+linked_ptr<T> make_linked_ptr(T* ptr) {
+  return linked_ptr<T>(ptr);
+}
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h
new file mode 100644
index 0000000..e805485
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h
@@ -0,0 +1,5143 @@
+// This file was GENERATED by command:
+//     pump.py gtest-param-util-generated.h.pump
+// DO NOT EDIT BY HAND!!!
+
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: vladl@google.com (Vlad Losev)
+
+// Type and function utilities for implementing parameterized tests.
+// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
+//
+// Currently Google Test supports at most 50 arguments in Values,
+// and at most 10 arguments in Combine. Please contact
+// googletestframework@googlegroups.com if you need more.
+// Please note that the number of arguments to Combine is limited
+// by the maximum arity of the implementation of tr1::tuple which is
+// currently set at 10.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
+
+// scripts/fuse_gtest.py depends on gtest's own header being #included
+// *unconditionally*.  Therefore these #includes cannot be moved
+// inside #if GTEST_HAS_PARAM_TEST.
+#include "gtest/internal/gtest-param-util.h"
+#include "gtest/internal/gtest-port.h"
+
+#if GTEST_HAS_PARAM_TEST
+
+namespace testing {
+
+// Forward declarations of ValuesIn(), which is implemented in
+// include/gtest/gtest-param-test.h.
+template <typename ForwardIterator>
+internal::ParamGenerator<
+  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
+ValuesIn(ForwardIterator begin, ForwardIterator end);
+
+template <typename T, size_t N>
+internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
+
+template <class Container>
+internal::ParamGenerator<typename Container::value_type> ValuesIn(
+    const Container& container);
+
+namespace internal {
+
+// Used in the Values() function to provide polymorphic capabilities.
+template <typename T1>
+class ValueArray1 {
+ public:
+  explicit ValueArray1(T1 v1) : v1_(v1) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray1& other);
+
+  const T1 v1_;
+};
+
+template <typename T1, typename T2>
+class ValueArray2 {
+ public:
+  ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray2& other);
+
+  const T1 v1_;
+  const T2 v2_;
+};
+
+template <typename T1, typename T2, typename T3>
+class ValueArray3 {
+ public:
+  ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray3& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4>
+class ValueArray4 {
+ public:
+  ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3),
+      v4_(v4) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray4& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+class ValueArray5 {
+ public:
+  ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3),
+      v4_(v4), v5_(v5) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray5& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6>
+class ValueArray6 {
+ public:
+  ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2),
+      v3_(v3), v4_(v4), v5_(v5), v6_(v6) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray6& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7>
+class ValueArray7 {
+ public:
+  ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1),
+      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray7& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8>
+class ValueArray8 {
+ public:
+  ValueArray8(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+      T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray8& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9>
+class ValueArray9 {
+ public:
+  ValueArray9(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
+      T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray9& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10>
+class ValueArray10 {
+ public:
+  ValueArray10(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray10& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11>
+class ValueArray11 {
+ public:
+  ValueArray11(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
+      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray11& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12>
+class ValueArray12 {
+ public:
+  ValueArray12(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
+      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray12& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13>
+class ValueArray13 {
+ public:
+  ValueArray13(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
+      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
+      v12_(v12), v13_(v13) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray13& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14>
+class ValueArray14 {
+ public:
+  ValueArray14(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) : v1_(v1), v2_(v2), v3_(v3),
+      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray14& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15>
+class ValueArray15 {
+ public:
+  ValueArray15(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) : v1_(v1), v2_(v2),
+      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray15& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16>
+class ValueArray16 {
+ public:
+  ValueArray16(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16) : v1_(v1),
+      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
+      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
+      v16_(v16) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray16& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17>
+class ValueArray17 {
+ public:
+  ValueArray17(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
+      T17 v17) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray17& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18>
+class ValueArray18 {
+ public:
+  ValueArray18(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray18& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19>
+class ValueArray19 {
+ public:
+  ValueArray19(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
+      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
+      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray19& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20>
+class ValueArray20 {
+ public:
+  ValueArray20(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
+      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
+      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
+      v19_(v19), v20_(v20) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray20& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21>
+class ValueArray21 {
+ public:
+  ValueArray21(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
+      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
+      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
+      v18_(v18), v19_(v19), v20_(v20), v21_(v21) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray21& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22>
+class ValueArray22 {
+ public:
+  ValueArray22(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22) : v1_(v1), v2_(v2), v3_(v3),
+      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray22& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23>
+class ValueArray23 {
+ public:
+  ValueArray23(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23) : v1_(v1), v2_(v2),
+      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
+      v23_(v23) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray23& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24>
+class ValueArray24 {
+ public:
+  ValueArray24(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24) : v1_(v1),
+      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
+      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
+      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
+      v22_(v22), v23_(v23), v24_(v24) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray24& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25>
+class ValueArray25 {
+ public:
+  ValueArray25(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
+      T25 v25) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray25& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26>
+class ValueArray26 {
+ public:
+  ValueArray26(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray26& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27>
+class ValueArray27 {
+ public:
+  ValueArray27(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
+      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
+      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
+      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
+      v26_(v26), v27_(v27) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray27& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28>
+class ValueArray28 {
+ public:
+  ValueArray28(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
+      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
+      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
+      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
+      v25_(v25), v26_(v26), v27_(v27), v28_(v28) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray28& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29>
+class ValueArray29 {
+ public:
+  ValueArray29(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
+      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
+      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
+      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
+      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray29& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30>
+class ValueArray30 {
+ public:
+  ValueArray30(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) : v1_(v1), v2_(v2), v3_(v3),
+      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
+      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
+      v29_(v29), v30_(v30) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray30& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31>
+class ValueArray31 {
+ public:
+  ValueArray31(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) : v1_(v1), v2_(v2),
+      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
+      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
+      v29_(v29), v30_(v30), v31_(v31) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray31& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32>
+class ValueArray32 {
+ public:
+  ValueArray32(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32) : v1_(v1),
+      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
+      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
+      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
+      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
+      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray32& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33>
+class ValueArray33 {
+ public:
+  ValueArray33(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
+      T33 v33) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
+      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
+      v33_(v33) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray33& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34>
+class ValueArray34 {
+ public:
+  ValueArray34(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
+      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
+      v33_(v33), v34_(v34) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray34& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35>
+class ValueArray35 {
+ public:
+  ValueArray35(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
+      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
+      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
+      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
+      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),
+      v32_(v32), v33_(v33), v34_(v34), v35_(v35) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray35& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36>
+class ValueArray36 {
+ public:
+  ValueArray36(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
+      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
+      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
+      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
+      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),
+      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray36& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37>
+class ValueArray37 {
+ public:
+  ValueArray37(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
+      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
+      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
+      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
+      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),
+      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),
+      v36_(v36), v37_(v37) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray37& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38>
+class ValueArray38 {
+ public:
+  ValueArray38(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38) : v1_(v1), v2_(v2), v3_(v3),
+      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
+      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
+      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
+      v35_(v35), v36_(v36), v37_(v37), v38_(v38) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray38& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39>
+class ValueArray39 {
+ public:
+  ValueArray39(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39) : v1_(v1), v2_(v2),
+      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
+      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
+      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
+      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray39& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40>
+class ValueArray40 {
+ public:
+  ValueArray40(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) : v1_(v1),
+      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
+      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
+      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
+      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
+      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),
+      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),
+      v40_(v40) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray40& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41>
+class ValueArray41 {
+ public:
+  ValueArray41(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
+      T41 v41) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
+      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
+      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
+      v39_(v39), v40_(v40), v41_(v41) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray41& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42>
+class ValueArray42 {
+ public:
+  ValueArray42(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
+      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
+      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
+      v39_(v39), v40_(v40), v41_(v41), v42_(v42) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray42& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43>
+class ValueArray43 {
+ public:
+  ValueArray43(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
+      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
+      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
+      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
+      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),
+      v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37),
+      v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray43& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44>
+class ValueArray44 {
+ public:
+  ValueArray44(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43, T44 v44) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
+      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
+      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
+      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
+      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),
+      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36),
+      v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42),
+      v43_(v43), v44_(v44) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray44& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+  const T44 v44_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45>
+class ValueArray45 {
+ public:
+  ValueArray45(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43, T44 v44, T45 v45) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
+      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
+      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
+      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
+      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),
+      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),
+      v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41),
+      v42_(v42), v43_(v43), v44_(v44), v45_(v45) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
+        static_cast<T>(v45_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray45& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+  const T44 v44_;
+  const T45 v45_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46>
+class ValueArray46 {
+ public:
+  ValueArray46(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) : v1_(v1), v2_(v2), v3_(v3),
+      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
+      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
+      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
+      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),
+      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
+        static_cast<T>(v45_), static_cast<T>(v46_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray46& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+  const T44 v44_;
+  const T45 v45_;
+  const T46 v46_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47>
+class ValueArray47 {
+ public:
+  ValueArray47(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) : v1_(v1), v2_(v2),
+      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
+      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
+      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
+      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
+      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
+      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),
+      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46),
+      v47_(v47) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
+        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray47& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+  const T44 v44_;
+  const T45 v45_;
+  const T46 v46_;
+  const T47 v47_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48>
+class ValueArray48 {
+ public:
+  ValueArray48(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48) : v1_(v1),
+      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
+      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
+      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
+      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
+      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),
+      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),
+      v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45),
+      v46_(v46), v47_(v47), v48_(v48) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
+        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),
+        static_cast<T>(v48_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray48& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+  const T44 v44_;
+  const T45 v45_;
+  const T46 v46_;
+  const T47 v47_;
+  const T48 v48_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49>
+class ValueArray49 {
+ public:
+  ValueArray49(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48,
+      T49 v49) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
+      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
+      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
+      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),
+      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
+        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),
+        static_cast<T>(v48_), static_cast<T>(v49_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray49& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+  const T44 v44_;
+  const T45 v45_;
+  const T46 v46_;
+  const T47 v47_;
+  const T48 v48_;
+  const T49 v49_;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49, typename T50>
+class ValueArray50 {
+ public:
+  ValueArray50(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48, T49 v49,
+      T50 v50) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
+      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
+      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
+      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
+      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
+      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
+      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),
+      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49), v50_(v50) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
+        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
+        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
+        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
+        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
+        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
+        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
+        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
+        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
+        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
+        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
+        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
+        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
+        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
+        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
+        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),
+        static_cast<T>(v48_), static_cast<T>(v49_), static_cast<T>(v50_)};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray50& other);
+
+  const T1 v1_;
+  const T2 v2_;
+  const T3 v3_;
+  const T4 v4_;
+  const T5 v5_;
+  const T6 v6_;
+  const T7 v7_;
+  const T8 v8_;
+  const T9 v9_;
+  const T10 v10_;
+  const T11 v11_;
+  const T12 v12_;
+  const T13 v13_;
+  const T14 v14_;
+  const T15 v15_;
+  const T16 v16_;
+  const T17 v17_;
+  const T18 v18_;
+  const T19 v19_;
+  const T20 v20_;
+  const T21 v21_;
+  const T22 v22_;
+  const T23 v23_;
+  const T24 v24_;
+  const T25 v25_;
+  const T26 v26_;
+  const T27 v27_;
+  const T28 v28_;
+  const T29 v29_;
+  const T30 v30_;
+  const T31 v31_;
+  const T32 v32_;
+  const T33 v33_;
+  const T34 v34_;
+  const T35 v35_;
+  const T36 v36_;
+  const T37 v37_;
+  const T38 v38_;
+  const T39 v39_;
+  const T40 v40_;
+  const T41 v41_;
+  const T42 v42_;
+  const T43 v43_;
+  const T44 v44_;
+  const T45 v45_;
+  const T46 v46_;
+  const T47 v47_;
+  const T48 v48_;
+  const T49 v49_;
+  const T50 v50_;
+};
+
+# if GTEST_HAS_COMBINE
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Generates values from the Cartesian product of values produced
+// by the argument generators.
+//
+template <typename T1, typename T2>
+class CartesianProductGenerator2
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2> ParamType;
+
+  CartesianProductGenerator2(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2)
+      : g1_(g1), g2_(g2) {}
+  virtual ~CartesianProductGenerator2() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current2_;
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator2::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator2& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+};  // class CartesianProductGenerator2
+
+
+template <typename T1, typename T2, typename T3>
+class CartesianProductGenerator3
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3> ParamType;
+
+  CartesianProductGenerator3(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)
+      : g1_(g1), g2_(g2), g3_(g3) {}
+  virtual ~CartesianProductGenerator3() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current3_;
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator3::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator3& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+};  // class CartesianProductGenerator3
+
+
+template <typename T1, typename T2, typename T3, typename T4>
+class CartesianProductGenerator4
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3, T4> ParamType;
+
+  CartesianProductGenerator4(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
+      const ParamGenerator<T4>& g4)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
+  virtual ~CartesianProductGenerator4() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin(), g4_, g4_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
+        g4_, g4_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3,
+      const ParamGenerator<T4>& g4,
+      const typename ParamGenerator<T4>::iterator& current4)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
+          begin4_(g4.begin()), end4_(g4.end()), current4_(current4)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current4_;
+      if (current4_ == end4_) {
+        current4_ = begin4_;
+        ++current3_;
+      }
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_ &&
+          current4_ == typed_other->current4_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_),
+        begin4_(other.begin4_),
+        end4_(other.end4_),
+        current4_(other.current4_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_,
+            *current4_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_ ||
+          current4_ == end4_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    const typename ParamGenerator<T4>::iterator begin4_;
+    const typename ParamGenerator<T4>::iterator end4_;
+    typename ParamGenerator<T4>::iterator current4_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator4::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator4& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+  const ParamGenerator<T4> g4_;
+};  // class CartesianProductGenerator4
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+class CartesianProductGenerator5
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5> ParamType;
+
+  CartesianProductGenerator5(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
+      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
+  virtual ~CartesianProductGenerator5() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
+        g4_, g4_.end(), g5_, g5_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3,
+      const ParamGenerator<T4>& g4,
+      const typename ParamGenerator<T4>::iterator& current4,
+      const ParamGenerator<T5>& g5,
+      const typename ParamGenerator<T5>::iterator& current5)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
+          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
+          begin5_(g5.begin()), end5_(g5.end()), current5_(current5)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current5_;
+      if (current5_ == end5_) {
+        current5_ = begin5_;
+        ++current4_;
+      }
+      if (current4_ == end4_) {
+        current4_ = begin4_;
+        ++current3_;
+      }
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_ &&
+          current4_ == typed_other->current4_ &&
+          current5_ == typed_other->current5_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_),
+        begin4_(other.begin4_),
+        end4_(other.end4_),
+        current4_(other.current4_),
+        begin5_(other.begin5_),
+        end5_(other.end5_),
+        current5_(other.current5_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_,
+            *current4_, *current5_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_ ||
+          current4_ == end4_ ||
+          current5_ == end5_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    const typename ParamGenerator<T4>::iterator begin4_;
+    const typename ParamGenerator<T4>::iterator end4_;
+    typename ParamGenerator<T4>::iterator current4_;
+    const typename ParamGenerator<T5>::iterator begin5_;
+    const typename ParamGenerator<T5>::iterator end5_;
+    typename ParamGenerator<T5>::iterator current5_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator5::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator5& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+  const ParamGenerator<T4> g4_;
+  const ParamGenerator<T5> g5_;
+};  // class CartesianProductGenerator5
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6>
+class CartesianProductGenerator6
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5,
+        T6> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> ParamType;
+
+  CartesianProductGenerator6(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
+      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
+      const ParamGenerator<T6>& g6)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
+  virtual ~CartesianProductGenerator6() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
+        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3,
+      const ParamGenerator<T4>& g4,
+      const typename ParamGenerator<T4>::iterator& current4,
+      const ParamGenerator<T5>& g5,
+      const typename ParamGenerator<T5>::iterator& current5,
+      const ParamGenerator<T6>& g6,
+      const typename ParamGenerator<T6>::iterator& current6)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
+          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
+          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
+          begin6_(g6.begin()), end6_(g6.end()), current6_(current6)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current6_;
+      if (current6_ == end6_) {
+        current6_ = begin6_;
+        ++current5_;
+      }
+      if (current5_ == end5_) {
+        current5_ = begin5_;
+        ++current4_;
+      }
+      if (current4_ == end4_) {
+        current4_ = begin4_;
+        ++current3_;
+      }
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_ &&
+          current4_ == typed_other->current4_ &&
+          current5_ == typed_other->current5_ &&
+          current6_ == typed_other->current6_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_),
+        begin4_(other.begin4_),
+        end4_(other.end4_),
+        current4_(other.current4_),
+        begin5_(other.begin5_),
+        end5_(other.end5_),
+        current5_(other.current5_),
+        begin6_(other.begin6_),
+        end6_(other.end6_),
+        current6_(other.current6_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_,
+            *current4_, *current5_, *current6_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_ ||
+          current4_ == end4_ ||
+          current5_ == end5_ ||
+          current6_ == end6_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    const typename ParamGenerator<T4>::iterator begin4_;
+    const typename ParamGenerator<T4>::iterator end4_;
+    typename ParamGenerator<T4>::iterator current4_;
+    const typename ParamGenerator<T5>::iterator begin5_;
+    const typename ParamGenerator<T5>::iterator end5_;
+    typename ParamGenerator<T5>::iterator current5_;
+    const typename ParamGenerator<T6>::iterator begin6_;
+    const typename ParamGenerator<T6>::iterator end6_;
+    typename ParamGenerator<T6>::iterator current6_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator6::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator6& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+  const ParamGenerator<T4> g4_;
+  const ParamGenerator<T5> g5_;
+  const ParamGenerator<T6> g6_;
+};  // class CartesianProductGenerator6
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7>
+class CartesianProductGenerator7
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
+        T7> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;
+
+  CartesianProductGenerator7(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
+      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
+      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
+  virtual ~CartesianProductGenerator7() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
+        g7_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
+        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3,
+      const ParamGenerator<T4>& g4,
+      const typename ParamGenerator<T4>::iterator& current4,
+      const ParamGenerator<T5>& g5,
+      const typename ParamGenerator<T5>::iterator& current5,
+      const ParamGenerator<T6>& g6,
+      const typename ParamGenerator<T6>::iterator& current6,
+      const ParamGenerator<T7>& g7,
+      const typename ParamGenerator<T7>::iterator& current7)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
+          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
+          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
+          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
+          begin7_(g7.begin()), end7_(g7.end()), current7_(current7)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current7_;
+      if (current7_ == end7_) {
+        current7_ = begin7_;
+        ++current6_;
+      }
+      if (current6_ == end6_) {
+        current6_ = begin6_;
+        ++current5_;
+      }
+      if (current5_ == end5_) {
+        current5_ = begin5_;
+        ++current4_;
+      }
+      if (current4_ == end4_) {
+        current4_ = begin4_;
+        ++current3_;
+      }
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_ &&
+          current4_ == typed_other->current4_ &&
+          current5_ == typed_other->current5_ &&
+          current6_ == typed_other->current6_ &&
+          current7_ == typed_other->current7_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_),
+        begin4_(other.begin4_),
+        end4_(other.end4_),
+        current4_(other.current4_),
+        begin5_(other.begin5_),
+        end5_(other.end5_),
+        current5_(other.current5_),
+        begin6_(other.begin6_),
+        end6_(other.end6_),
+        current6_(other.current6_),
+        begin7_(other.begin7_),
+        end7_(other.end7_),
+        current7_(other.current7_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_,
+            *current4_, *current5_, *current6_, *current7_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_ ||
+          current4_ == end4_ ||
+          current5_ == end5_ ||
+          current6_ == end6_ ||
+          current7_ == end7_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    const typename ParamGenerator<T4>::iterator begin4_;
+    const typename ParamGenerator<T4>::iterator end4_;
+    typename ParamGenerator<T4>::iterator current4_;
+    const typename ParamGenerator<T5>::iterator begin5_;
+    const typename ParamGenerator<T5>::iterator end5_;
+    typename ParamGenerator<T5>::iterator current5_;
+    const typename ParamGenerator<T6>::iterator begin6_;
+    const typename ParamGenerator<T6>::iterator end6_;
+    typename ParamGenerator<T6>::iterator current6_;
+    const typename ParamGenerator<T7>::iterator begin7_;
+    const typename ParamGenerator<T7>::iterator end7_;
+    typename ParamGenerator<T7>::iterator current7_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator7::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator7& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+  const ParamGenerator<T4> g4_;
+  const ParamGenerator<T5> g5_;
+  const ParamGenerator<T6> g6_;
+  const ParamGenerator<T7> g7_;
+};  // class CartesianProductGenerator7
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8>
+class CartesianProductGenerator8
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
+        T7, T8> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;
+
+  CartesianProductGenerator8(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
+      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
+      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
+      const ParamGenerator<T8>& g8)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
+          g8_(g8) {}
+  virtual ~CartesianProductGenerator8() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
+        g7_.begin(), g8_, g8_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
+        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
+        g8_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3,
+      const ParamGenerator<T4>& g4,
+      const typename ParamGenerator<T4>::iterator& current4,
+      const ParamGenerator<T5>& g5,
+      const typename ParamGenerator<T5>::iterator& current5,
+      const ParamGenerator<T6>& g6,
+      const typename ParamGenerator<T6>::iterator& current6,
+      const ParamGenerator<T7>& g7,
+      const typename ParamGenerator<T7>::iterator& current7,
+      const ParamGenerator<T8>& g8,
+      const typename ParamGenerator<T8>::iterator& current8)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
+          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
+          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
+          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
+          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
+          begin8_(g8.begin()), end8_(g8.end()), current8_(current8)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current8_;
+      if (current8_ == end8_) {
+        current8_ = begin8_;
+        ++current7_;
+      }
+      if (current7_ == end7_) {
+        current7_ = begin7_;
+        ++current6_;
+      }
+      if (current6_ == end6_) {
+        current6_ = begin6_;
+        ++current5_;
+      }
+      if (current5_ == end5_) {
+        current5_ = begin5_;
+        ++current4_;
+      }
+      if (current4_ == end4_) {
+        current4_ = begin4_;
+        ++current3_;
+      }
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_ &&
+          current4_ == typed_other->current4_ &&
+          current5_ == typed_other->current5_ &&
+          current6_ == typed_other->current6_ &&
+          current7_ == typed_other->current7_ &&
+          current8_ == typed_other->current8_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_),
+        begin4_(other.begin4_),
+        end4_(other.end4_),
+        current4_(other.current4_),
+        begin5_(other.begin5_),
+        end5_(other.end5_),
+        current5_(other.current5_),
+        begin6_(other.begin6_),
+        end6_(other.end6_),
+        current6_(other.current6_),
+        begin7_(other.begin7_),
+        end7_(other.end7_),
+        current7_(other.current7_),
+        begin8_(other.begin8_),
+        end8_(other.end8_),
+        current8_(other.current8_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_,
+            *current4_, *current5_, *current6_, *current7_, *current8_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_ ||
+          current4_ == end4_ ||
+          current5_ == end5_ ||
+          current6_ == end6_ ||
+          current7_ == end7_ ||
+          current8_ == end8_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    const typename ParamGenerator<T4>::iterator begin4_;
+    const typename ParamGenerator<T4>::iterator end4_;
+    typename ParamGenerator<T4>::iterator current4_;
+    const typename ParamGenerator<T5>::iterator begin5_;
+    const typename ParamGenerator<T5>::iterator end5_;
+    typename ParamGenerator<T5>::iterator current5_;
+    const typename ParamGenerator<T6>::iterator begin6_;
+    const typename ParamGenerator<T6>::iterator end6_;
+    typename ParamGenerator<T6>::iterator current6_;
+    const typename ParamGenerator<T7>::iterator begin7_;
+    const typename ParamGenerator<T7>::iterator end7_;
+    typename ParamGenerator<T7>::iterator current7_;
+    const typename ParamGenerator<T8>::iterator begin8_;
+    const typename ParamGenerator<T8>::iterator end8_;
+    typename ParamGenerator<T8>::iterator current8_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator8::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator8& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+  const ParamGenerator<T4> g4_;
+  const ParamGenerator<T5> g5_;
+  const ParamGenerator<T6> g6_;
+  const ParamGenerator<T7> g7_;
+  const ParamGenerator<T8> g8_;
+};  // class CartesianProductGenerator8
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9>
+class CartesianProductGenerator9
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
+        T7, T8, T9> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;
+
+  CartesianProductGenerator9(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
+      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
+      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
+      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
+          g9_(g9) {}
+  virtual ~CartesianProductGenerator9() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
+        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
+        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
+        g8_.end(), g9_, g9_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3,
+      const ParamGenerator<T4>& g4,
+      const typename ParamGenerator<T4>::iterator& current4,
+      const ParamGenerator<T5>& g5,
+      const typename ParamGenerator<T5>::iterator& current5,
+      const ParamGenerator<T6>& g6,
+      const typename ParamGenerator<T6>::iterator& current6,
+      const ParamGenerator<T7>& g7,
+      const typename ParamGenerator<T7>::iterator& current7,
+      const ParamGenerator<T8>& g8,
+      const typename ParamGenerator<T8>::iterator& current8,
+      const ParamGenerator<T9>& g9,
+      const typename ParamGenerator<T9>::iterator& current9)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
+          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
+          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
+          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
+          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
+          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
+          begin9_(g9.begin()), end9_(g9.end()), current9_(current9)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current9_;
+      if (current9_ == end9_) {
+        current9_ = begin9_;
+        ++current8_;
+      }
+      if (current8_ == end8_) {
+        current8_ = begin8_;
+        ++current7_;
+      }
+      if (current7_ == end7_) {
+        current7_ = begin7_;
+        ++current6_;
+      }
+      if (current6_ == end6_) {
+        current6_ = begin6_;
+        ++current5_;
+      }
+      if (current5_ == end5_) {
+        current5_ = begin5_;
+        ++current4_;
+      }
+      if (current4_ == end4_) {
+        current4_ = begin4_;
+        ++current3_;
+      }
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_ &&
+          current4_ == typed_other->current4_ &&
+          current5_ == typed_other->current5_ &&
+          current6_ == typed_other->current6_ &&
+          current7_ == typed_other->current7_ &&
+          current8_ == typed_other->current8_ &&
+          current9_ == typed_other->current9_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_),
+        begin4_(other.begin4_),
+        end4_(other.end4_),
+        current4_(other.current4_),
+        begin5_(other.begin5_),
+        end5_(other.end5_),
+        current5_(other.current5_),
+        begin6_(other.begin6_),
+        end6_(other.end6_),
+        current6_(other.current6_),
+        begin7_(other.begin7_),
+        end7_(other.end7_),
+        current7_(other.current7_),
+        begin8_(other.begin8_),
+        end8_(other.end8_),
+        current8_(other.current8_),
+        begin9_(other.begin9_),
+        end9_(other.end9_),
+        current9_(other.current9_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_,
+            *current4_, *current5_, *current6_, *current7_, *current8_,
+            *current9_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_ ||
+          current4_ == end4_ ||
+          current5_ == end5_ ||
+          current6_ == end6_ ||
+          current7_ == end7_ ||
+          current8_ == end8_ ||
+          current9_ == end9_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    const typename ParamGenerator<T4>::iterator begin4_;
+    const typename ParamGenerator<T4>::iterator end4_;
+    typename ParamGenerator<T4>::iterator current4_;
+    const typename ParamGenerator<T5>::iterator begin5_;
+    const typename ParamGenerator<T5>::iterator end5_;
+    typename ParamGenerator<T5>::iterator current5_;
+    const typename ParamGenerator<T6>::iterator begin6_;
+    const typename ParamGenerator<T6>::iterator end6_;
+    typename ParamGenerator<T6>::iterator current6_;
+    const typename ParamGenerator<T7>::iterator begin7_;
+    const typename ParamGenerator<T7>::iterator end7_;
+    typename ParamGenerator<T7>::iterator current7_;
+    const typename ParamGenerator<T8>::iterator begin8_;
+    const typename ParamGenerator<T8>::iterator end8_;
+    typename ParamGenerator<T8>::iterator current8_;
+    const typename ParamGenerator<T9>::iterator begin9_;
+    const typename ParamGenerator<T9>::iterator end9_;
+    typename ParamGenerator<T9>::iterator current9_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator9::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator9& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+  const ParamGenerator<T4> g4_;
+  const ParamGenerator<T5> g5_;
+  const ParamGenerator<T6> g6_;
+  const ParamGenerator<T7> g7_;
+  const ParamGenerator<T8> g8_;
+  const ParamGenerator<T9> g9_;
+};  // class CartesianProductGenerator9
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10>
+class CartesianProductGenerator10
+    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
+        T7, T8, T9, T10> > {
+ public:
+  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;
+
+  CartesianProductGenerator10(const ParamGenerator<T1>& g1,
+      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
+      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
+      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
+      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9,
+      const ParamGenerator<T10>& g10)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
+          g9_(g9), g10_(g10) {}
+  virtual ~CartesianProductGenerator10() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
+        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
+        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin(), g10_, g10_.begin());
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
+        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
+        g8_.end(), g9_, g9_.end(), g10_, g10_.end());
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base,
+      const ParamGenerator<T1>& g1,
+      const typename ParamGenerator<T1>::iterator& current1,
+      const ParamGenerator<T2>& g2,
+      const typename ParamGenerator<T2>::iterator& current2,
+      const ParamGenerator<T3>& g3,
+      const typename ParamGenerator<T3>::iterator& current3,
+      const ParamGenerator<T4>& g4,
+      const typename ParamGenerator<T4>::iterator& current4,
+      const ParamGenerator<T5>& g5,
+      const typename ParamGenerator<T5>::iterator& current5,
+      const ParamGenerator<T6>& g6,
+      const typename ParamGenerator<T6>::iterator& current6,
+      const ParamGenerator<T7>& g7,
+      const typename ParamGenerator<T7>::iterator& current7,
+      const ParamGenerator<T8>& g8,
+      const typename ParamGenerator<T8>::iterator& current8,
+      const ParamGenerator<T9>& g9,
+      const typename ParamGenerator<T9>::iterator& current9,
+      const ParamGenerator<T10>& g10,
+      const typename ParamGenerator<T10>::iterator& current10)
+        : base_(base),
+          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
+          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
+          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
+          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
+          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
+          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
+          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
+          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
+          begin9_(g9.begin()), end9_(g9.end()), current9_(current9),
+          begin10_(g10.begin()), end10_(g10.end()), current10_(current10)    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current10_;
+      if (current10_ == end10_) {
+        current10_ = begin10_;
+        ++current9_;
+      }
+      if (current9_ == end9_) {
+        current9_ = begin9_;
+        ++current8_;
+      }
+      if (current8_ == end8_) {
+        current8_ = begin8_;
+        ++current7_;
+      }
+      if (current7_ == end7_) {
+        current7_ = begin7_;
+        ++current6_;
+      }
+      if (current6_ == end6_) {
+        current6_ = begin6_;
+        ++current5_;
+      }
+      if (current5_ == end5_) {
+        current5_ = begin5_;
+        ++current4_;
+      }
+      if (current4_ == end4_) {
+        current4_ = begin4_;
+        ++current3_;
+      }
+      if (current3_ == end3_) {
+        current3_ = begin3_;
+        ++current2_;
+      }
+      if (current2_ == end2_) {
+        current2_ = begin2_;
+        ++current1_;
+      }
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         (
+          current1_ == typed_other->current1_ &&
+          current2_ == typed_other->current2_ &&
+          current3_ == typed_other->current3_ &&
+          current4_ == typed_other->current4_ &&
+          current5_ == typed_other->current5_ &&
+          current6_ == typed_other->current6_ &&
+          current7_ == typed_other->current7_ &&
+          current8_ == typed_other->current8_ &&
+          current9_ == typed_other->current9_ &&
+          current10_ == typed_other->current10_);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_),
+        begin1_(other.begin1_),
+        end1_(other.end1_),
+        current1_(other.current1_),
+        begin2_(other.begin2_),
+        end2_(other.end2_),
+        current2_(other.current2_),
+        begin3_(other.begin3_),
+        end3_(other.end3_),
+        current3_(other.current3_),
+        begin4_(other.begin4_),
+        end4_(other.end4_),
+        current4_(other.current4_),
+        begin5_(other.begin5_),
+        end5_(other.end5_),
+        current5_(other.current5_),
+        begin6_(other.begin6_),
+        end6_(other.end6_),
+        current6_(other.current6_),
+        begin7_(other.begin7_),
+        end7_(other.end7_),
+        current7_(other.current7_),
+        begin8_(other.begin8_),
+        end8_(other.end8_),
+        current8_(other.current8_),
+        begin9_(other.begin9_),
+        end9_(other.end9_),
+        current9_(other.current9_),
+        begin10_(other.begin10_),
+        end10_(other.end10_),
+        current10_(other.current10_) {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType(*current1_, *current2_, *current3_,
+            *current4_, *current5_, *current6_, *current7_, *current8_,
+            *current9_, *current10_);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+          current1_ == end1_ ||
+          current2_ == end2_ ||
+          current3_ == end3_ ||
+          current4_ == end4_ ||
+          current5_ == end5_ ||
+          current6_ == end6_ ||
+          current7_ == end7_ ||
+          current8_ == end8_ ||
+          current9_ == end9_ ||
+          current10_ == end10_;
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+    const typename ParamGenerator<T1>::iterator begin1_;
+    const typename ParamGenerator<T1>::iterator end1_;
+    typename ParamGenerator<T1>::iterator current1_;
+    const typename ParamGenerator<T2>::iterator begin2_;
+    const typename ParamGenerator<T2>::iterator end2_;
+    typename ParamGenerator<T2>::iterator current2_;
+    const typename ParamGenerator<T3>::iterator begin3_;
+    const typename ParamGenerator<T3>::iterator end3_;
+    typename ParamGenerator<T3>::iterator current3_;
+    const typename ParamGenerator<T4>::iterator begin4_;
+    const typename ParamGenerator<T4>::iterator end4_;
+    typename ParamGenerator<T4>::iterator current4_;
+    const typename ParamGenerator<T5>::iterator begin5_;
+    const typename ParamGenerator<T5>::iterator end5_;
+    typename ParamGenerator<T5>::iterator current5_;
+    const typename ParamGenerator<T6>::iterator begin6_;
+    const typename ParamGenerator<T6>::iterator end6_;
+    typename ParamGenerator<T6>::iterator current6_;
+    const typename ParamGenerator<T7>::iterator begin7_;
+    const typename ParamGenerator<T7>::iterator end7_;
+    typename ParamGenerator<T7>::iterator current7_;
+    const typename ParamGenerator<T8>::iterator begin8_;
+    const typename ParamGenerator<T8>::iterator end8_;
+    typename ParamGenerator<T8>::iterator current8_;
+    const typename ParamGenerator<T9>::iterator begin9_;
+    const typename ParamGenerator<T9>::iterator end9_;
+    typename ParamGenerator<T9>::iterator current9_;
+    const typename ParamGenerator<T10>::iterator begin10_;
+    const typename ParamGenerator<T10>::iterator end10_;
+    typename ParamGenerator<T10>::iterator current10_;
+    ParamType current_value_;
+  };  // class CartesianProductGenerator10::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator10& other);
+
+  const ParamGenerator<T1> g1_;
+  const ParamGenerator<T2> g2_;
+  const ParamGenerator<T3> g3_;
+  const ParamGenerator<T4> g4_;
+  const ParamGenerator<T5> g5_;
+  const ParamGenerator<T6> g6_;
+  const ParamGenerator<T7> g7_;
+  const ParamGenerator<T8> g8_;
+  const ParamGenerator<T9> g9_;
+  const ParamGenerator<T10> g10_;
+};  // class CartesianProductGenerator10
+
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Helper classes providing Combine() with polymorphic features. They allow
+// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
+// convertible to U.
+//
+template <class Generator1, class Generator2>
+class CartesianProductHolder2 {
+ public:
+CartesianProductHolder2(const Generator1& g1, const Generator2& g2)
+      : g1_(g1), g2_(g2) {}
+  template <typename T1, typename T2>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2> >(
+        new CartesianProductGenerator2<T1, T2>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder2& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+};  // class CartesianProductHolder2
+
+template <class Generator1, class Generator2, class Generator3>
+class CartesianProductHolder3 {
+ public:
+CartesianProductHolder3(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3)
+      : g1_(g1), g2_(g2), g3_(g3) {}
+  template <typename T1, typename T2, typename T3>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >(
+        new CartesianProductGenerator3<T1, T2, T3>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder3& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+};  // class CartesianProductHolder3
+
+template <class Generator1, class Generator2, class Generator3,
+    class Generator4>
+class CartesianProductHolder4 {
+ public:
+CartesianProductHolder4(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3, const Generator4& g4)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
+  template <typename T1, typename T2, typename T3, typename T4>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >(
+        new CartesianProductGenerator4<T1, T2, T3, T4>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_),
+        static_cast<ParamGenerator<T4> >(g4_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder4& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+  const Generator4 g4_;
+};  // class CartesianProductHolder4
+
+template <class Generator1, class Generator2, class Generator3,
+    class Generator4, class Generator5>
+class CartesianProductHolder5 {
+ public:
+CartesianProductHolder5(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3, const Generator4& g4, const Generator5& g5)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
+  template <typename T1, typename T2, typename T3, typename T4, typename T5>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >(
+        new CartesianProductGenerator5<T1, T2, T3, T4, T5>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_),
+        static_cast<ParamGenerator<T4> >(g4_),
+        static_cast<ParamGenerator<T5> >(g5_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder5& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+  const Generator4 g4_;
+  const Generator5 g5_;
+};  // class CartesianProductHolder5
+
+template <class Generator1, class Generator2, class Generator3,
+    class Generator4, class Generator5, class Generator6>
+class CartesianProductHolder6 {
+ public:
+CartesianProductHolder6(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3, const Generator4& g4, const Generator5& g5,
+    const Generator6& g6)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
+  template <typename T1, typename T2, typename T3, typename T4, typename T5,
+      typename T6>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >(
+        new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_),
+        static_cast<ParamGenerator<T4> >(g4_),
+        static_cast<ParamGenerator<T5> >(g5_),
+        static_cast<ParamGenerator<T6> >(g6_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder6& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+  const Generator4 g4_;
+  const Generator5 g5_;
+  const Generator6 g6_;
+};  // class CartesianProductHolder6
+
+template <class Generator1, class Generator2, class Generator3,
+    class Generator4, class Generator5, class Generator6, class Generator7>
+class CartesianProductHolder7 {
+ public:
+CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3, const Generator4& g4, const Generator5& g5,
+    const Generator6& g6, const Generator7& g7)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
+  template <typename T1, typename T2, typename T3, typename T4, typename T5,
+      typename T6, typename T7>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
+      T7> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> >(
+        new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_),
+        static_cast<ParamGenerator<T4> >(g4_),
+        static_cast<ParamGenerator<T5> >(g5_),
+        static_cast<ParamGenerator<T6> >(g6_),
+        static_cast<ParamGenerator<T7> >(g7_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder7& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+  const Generator4 g4_;
+  const Generator5 g5_;
+  const Generator6 g6_;
+  const Generator7 g7_;
+};  // class CartesianProductHolder7
+
+template <class Generator1, class Generator2, class Generator3,
+    class Generator4, class Generator5, class Generator6, class Generator7,
+    class Generator8>
+class CartesianProductHolder8 {
+ public:
+CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3, const Generator4& g4, const Generator5& g5,
+    const Generator6& g6, const Generator7& g7, const Generator8& g8)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
+          g8_(g8) {}
+  template <typename T1, typename T2, typename T3, typename T4, typename T5,
+      typename T6, typename T7, typename T8>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7,
+      T8> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(
+        new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_),
+        static_cast<ParamGenerator<T4> >(g4_),
+        static_cast<ParamGenerator<T5> >(g5_),
+        static_cast<ParamGenerator<T6> >(g6_),
+        static_cast<ParamGenerator<T7> >(g7_),
+        static_cast<ParamGenerator<T8> >(g8_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder8& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+  const Generator4 g4_;
+  const Generator5 g5_;
+  const Generator6 g6_;
+  const Generator7 g7_;
+  const Generator8 g8_;
+};  // class CartesianProductHolder8
+
+template <class Generator1, class Generator2, class Generator3,
+    class Generator4, class Generator5, class Generator6, class Generator7,
+    class Generator8, class Generator9>
+class CartesianProductHolder9 {
+ public:
+CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3, const Generator4& g4, const Generator5& g5,
+    const Generator6& g6, const Generator7& g7, const Generator8& g8,
+    const Generator9& g9)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
+          g9_(g9) {}
+  template <typename T1, typename T2, typename T3, typename T4, typename T5,
+      typename T6, typename T7, typename T8, typename T9>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
+      T9> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
+        T9> >(
+        new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_),
+        static_cast<ParamGenerator<T4> >(g4_),
+        static_cast<ParamGenerator<T5> >(g5_),
+        static_cast<ParamGenerator<T6> >(g6_),
+        static_cast<ParamGenerator<T7> >(g7_),
+        static_cast<ParamGenerator<T8> >(g8_),
+        static_cast<ParamGenerator<T9> >(g9_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder9& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+  const Generator4 g4_;
+  const Generator5 g5_;
+  const Generator6 g6_;
+  const Generator7 g7_;
+  const Generator8 g8_;
+  const Generator9 g9_;
+};  // class CartesianProductHolder9
+
+template <class Generator1, class Generator2, class Generator3,
+    class Generator4, class Generator5, class Generator6, class Generator7,
+    class Generator8, class Generator9, class Generator10>
+class CartesianProductHolder10 {
+ public:
+CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
+    const Generator3& g3, const Generator4& g4, const Generator5& g5,
+    const Generator6& g6, const Generator7& g7, const Generator8& g8,
+    const Generator9& g9, const Generator10& g10)
+      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
+          g9_(g9), g10_(g10) {}
+  template <typename T1, typename T2, typename T3, typename T4, typename T5,
+      typename T6, typename T7, typename T8, typename T9, typename T10>
+  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
+      T9, T10> >() const {
+    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
+        T9, T10> >(
+        new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
+            T10>(
+        static_cast<ParamGenerator<T1> >(g1_),
+        static_cast<ParamGenerator<T2> >(g2_),
+        static_cast<ParamGenerator<T3> >(g3_),
+        static_cast<ParamGenerator<T4> >(g4_),
+        static_cast<ParamGenerator<T5> >(g5_),
+        static_cast<ParamGenerator<T6> >(g6_),
+        static_cast<ParamGenerator<T7> >(g7_),
+        static_cast<ParamGenerator<T8> >(g8_),
+        static_cast<ParamGenerator<T9> >(g9_),
+        static_cast<ParamGenerator<T10> >(g10_)));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder10& other);
+
+  const Generator1 g1_;
+  const Generator2 g2_;
+  const Generator3 g3_;
+  const Generator4 g4_;
+  const Generator5 g5_;
+  const Generator6 g6_;
+  const Generator7 g7_;
+  const Generator8 g8_;
+  const Generator9 g9_;
+  const Generator10 g10_;
+};  // class CartesianProductHolder10
+
+# endif  // GTEST_HAS_COMBINE
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  //  GTEST_HAS_PARAM_TEST
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump
new file mode 100644
index 0000000..009206f
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump
@@ -0,0 +1,301 @@
+$$ -*- mode: c++; -*-
+$var n = 50  $$ Maximum length of Values arguments we want to support.
+$var maxtuple = 10  $$ Maximum number of Combine arguments we want to support.
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: vladl@google.com (Vlad Losev)
+
+// Type and function utilities for implementing parameterized tests.
+// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
+//
+// Currently Google Test supports at most $n arguments in Values,
+// and at most $maxtuple arguments in Combine. Please contact
+// googletestframework@googlegroups.com if you need more.
+// Please note that the number of arguments to Combine is limited
+// by the maximum arity of the implementation of tr1::tuple which is
+// currently set at $maxtuple.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
+
+// scripts/fuse_gtest.py depends on gtest's own header being #included
+// *unconditionally*.  Therefore these #includes cannot be moved
+// inside #if GTEST_HAS_PARAM_TEST.
+#include "gtest/internal/gtest-param-util.h"
+#include "gtest/internal/gtest-port.h"
+
+#if GTEST_HAS_PARAM_TEST
+
+namespace testing {
+
+// Forward declarations of ValuesIn(), which is implemented in
+// include/gtest/gtest-param-test.h.
+template <typename ForwardIterator>
+internal::ParamGenerator<
+  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
+ValuesIn(ForwardIterator begin, ForwardIterator end);
+
+template <typename T, size_t N>
+internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
+
+template <class Container>
+internal::ParamGenerator<typename Container::value_type> ValuesIn(
+    const Container& container);
+
+namespace internal {
+
+// Used in the Values() function to provide polymorphic capabilities.
+template <typename T1>
+class ValueArray1 {
+ public:
+  explicit ValueArray1(T1 v1) : v1_(v1) {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray1& other);
+
+  const T1 v1_;
+};
+
+$range i 2..n
+$for i [[
+$range j 1..i
+
+template <$for j, [[typename T$j]]>
+class ValueArray$i {
+ public:
+  ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}
+
+  template <typename T>
+  operator ParamGenerator<T>() const {
+    const T array[] = {$for j, [[static_cast<T>(v$(j)_)]]};
+    return ValuesIn(array);
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const ValueArray$i& other);
+
+$for j [[
+
+  const T$j v$(j)_;
+]]
+
+};
+
+]]
+
+# if GTEST_HAS_COMBINE
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Generates values from the Cartesian product of values produced
+// by the argument generators.
+//
+$range i 2..maxtuple
+$for i [[
+$range j 1..i
+$range k 2..i
+
+template <$for j, [[typename T$j]]>
+class CartesianProductGenerator$i
+    : public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > {
+ public:
+  typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType;
+
+  CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])
+      : $for j, [[g$(j)_(g$j)]] {}
+  virtual ~CartesianProductGenerator$i() {}
+
+  virtual ParamIteratorInterface<ParamType>* Begin() const {
+    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);
+  }
+  virtual ParamIteratorInterface<ParamType>* End() const {
+    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<ParamType> {
+   public:
+    Iterator(const ParamGeneratorInterface<ParamType>* base, $for j, [[
+
+      const ParamGenerator<T$j>& g$j,
+      const typename ParamGenerator<T$j>::iterator& current$(j)]])
+        : base_(base),
+$for j, [[
+
+          begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)
+]]    {
+      ComputeCurrentValue();
+    }
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
+      return base_;
+    }
+    // Advance should not be called on beyond-of-range iterators
+    // so no component iterators must be beyond end of range, either.
+    virtual void Advance() {
+      assert(!AtEnd());
+      ++current$(i)_;
+
+$for k [[
+      if (current$(i+2-k)_ == end$(i+2-k)_) {
+        current$(i+2-k)_ = begin$(i+2-k)_;
+        ++current$(i+2-k-1)_;
+      }
+
+]]
+      ComputeCurrentValue();
+    }
+    virtual ParamIteratorInterface<ParamType>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const ParamType* Current() const { return &current_value_; }
+    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const Iterator* typed_other =
+          CheckedDowncastToActualType<const Iterator>(&other);
+      // We must report iterators equal if they both point beyond their
+      // respective ranges. That can happen in a variety of fashions,
+      // so we have to consult AtEnd().
+      return (AtEnd() && typed_other->AtEnd()) ||
+         ($for j  && [[
+
+          current$(j)_ == typed_other->current$(j)_
+]]);
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : base_(other.base_), $for j, [[
+
+        begin$(j)_(other.begin$(j)_),
+        end$(j)_(other.end$(j)_),
+        current$(j)_(other.current$(j)_)
+]] {
+      ComputeCurrentValue();
+    }
+
+    void ComputeCurrentValue() {
+      if (!AtEnd())
+        current_value_ = ParamType($for j, [[*current$(j)_]]);
+    }
+    bool AtEnd() const {
+      // We must report iterator past the end of the range when either of the
+      // component iterators has reached the end of its range.
+      return
+$for j  || [[
+
+          current$(j)_ == end$(j)_
+]];
+    }
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<ParamType>* const base_;
+    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
+    // current[i]_ is the actual traversing iterator.
+$for j [[
+
+    const typename ParamGenerator<T$j>::iterator begin$(j)_;
+    const typename ParamGenerator<T$j>::iterator end$(j)_;
+    typename ParamGenerator<T$j>::iterator current$(j)_;
+]]
+
+    ParamType current_value_;
+  };  // class CartesianProductGenerator$i::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductGenerator$i& other);
+
+
+$for j [[
+  const ParamGenerator<T$j> g$(j)_;
+
+]]
+};  // class CartesianProductGenerator$i
+
+
+]]
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Helper classes providing Combine() with polymorphic features. They allow
+// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
+// convertible to U.
+//
+$range i 2..maxtuple
+$for i [[
+$range j 1..i
+
+template <$for j, [[class Generator$j]]>
+class CartesianProductHolder$i {
+ public:
+CartesianProductHolder$i($for j, [[const Generator$j& g$j]])
+      : $for j, [[g$(j)_(g$j)]] {}
+  template <$for j, [[typename T$j]]>
+  operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const {
+    return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >(
+        new CartesianProductGenerator$i<$for j, [[T$j]]>(
+$for j,[[
+
+        static_cast<ParamGenerator<T$j> >(g$(j)_)
+]]));
+  }
+
+ private:
+  // No implementation - assignment is unsupported.
+  void operator=(const CartesianProductHolder$i& other);
+
+
+$for j [[
+  const Generator$j g$(j)_;
+
+]]
+};  // class CartesianProductHolder$i
+
+]]
+
+# endif  // GTEST_HAS_COMBINE
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  //  GTEST_HAS_PARAM_TEST
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-param-util.h b/test/fmw/gtest/include/gtest/internal/gtest-param-util.h
new file mode 100644
index 0000000..d5e1028
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-param-util.h
@@ -0,0 +1,619 @@
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: vladl@google.com (Vlad Losev)
+
+// Type and function utilities for implementing parameterized tests.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
+
+#include <iterator>
+#include <utility>
+#include <vector>
+
+// scripts/fuse_gtest.py depends on gtest's own header being #included
+// *unconditionally*.  Therefore these #includes cannot be moved
+// inside #if GTEST_HAS_PARAM_TEST.
+#include "gtest/internal/gtest-internal.h"
+#include "gtest/internal/gtest-linked_ptr.h"
+#include "gtest/internal/gtest-port.h"
+#include "gtest/gtest-printers.h"
+
+#if GTEST_HAS_PARAM_TEST
+
+namespace testing {
+namespace internal {
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Outputs a message explaining invalid registration of different
+// fixture class for the same test case. This may happen when
+// TEST_P macro is used to define two tests with the same name
+// but in different namespaces.
+GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,
+                                          const char* file, int line);
+
+template <typename> class ParamGeneratorInterface;
+template <typename> class ParamGenerator;
+
+// Interface for iterating over elements provided by an implementation
+// of ParamGeneratorInterface<T>.
+template <typename T>
+class ParamIteratorInterface {
+ public:
+  virtual ~ParamIteratorInterface() {}
+  // A pointer to the base generator instance.
+  // Used only for the purposes of iterator comparison
+  // to make sure that two iterators belong to the same generator.
+  virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
+  // Advances iterator to point to the next element
+  // provided by the generator. The caller is responsible
+  // for not calling Advance() on an iterator equal to
+  // BaseGenerator()->End().
+  virtual void Advance() = 0;
+  // Clones the iterator object. Used for implementing copy semantics
+  // of ParamIterator<T>.
+  virtual ParamIteratorInterface* Clone() const = 0;
+  // Dereferences the current iterator and provides (read-only) access
+  // to the pointed value. It is the caller's responsibility not to call
+  // Current() on an iterator equal to BaseGenerator()->End().
+  // Used for implementing ParamGenerator<T>::operator*().
+  virtual const T* Current() const = 0;
+  // Determines whether the given iterator and other point to the same
+  // element in the sequence generated by the generator.
+  // Used for implementing ParamGenerator<T>::operator==().
+  virtual bool Equals(const ParamIteratorInterface& other) const = 0;
+};
+
+// Class iterating over elements provided by an implementation of
+// ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
+// and implements the const forward iterator concept.
+template <typename T>
+class ParamIterator {
+ public:
+  typedef T value_type;
+  typedef const T& reference;
+  typedef ptrdiff_t difference_type;
+
+  // ParamIterator assumes ownership of the impl_ pointer.
+  ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
+  ParamIterator& operator=(const ParamIterator& other) {
+    if (this != &other)
+      impl_.reset(other.impl_->Clone());
+    return *this;
+  }
+
+  const T& operator*() const { return *impl_->Current(); }
+  const T* operator->() const { return impl_->Current(); }
+  // Prefix version of operator++.
+  ParamIterator& operator++() {
+    impl_->Advance();
+    return *this;
+  }
+  // Postfix version of operator++.
+  ParamIterator operator++(int /*unused*/) {
+    ParamIteratorInterface<T>* clone = impl_->Clone();
+    impl_->Advance();
+    return ParamIterator(clone);
+  }
+  bool operator==(const ParamIterator& other) const {
+    return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
+  }
+  bool operator!=(const ParamIterator& other) const {
+    return !(*this == other);
+  }
+
+ private:
+  friend class ParamGenerator<T>;
+  explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
+  scoped_ptr<ParamIteratorInterface<T> > impl_;
+};
+
+// ParamGeneratorInterface<T> is the binary interface to access generators
+// defined in other translation units.
+template <typename T>
+class ParamGeneratorInterface {
+ public:
+  typedef T ParamType;
+
+  virtual ~ParamGeneratorInterface() {}
+
+  // Generator interface definition
+  virtual ParamIteratorInterface<T>* Begin() const = 0;
+  virtual ParamIteratorInterface<T>* End() const = 0;
+};
+
+// Wraps ParamGeneratorInterface<T> and provides general generator syntax
+// compatible with the STL Container concept.
+// This class implements copy initialization semantics and the contained
+// ParamGeneratorInterface<T> instance is shared among all copies
+// of the original object. This is possible because that instance is immutable.
+template<typename T>
+class ParamGenerator {
+ public:
+  typedef ParamIterator<T> iterator;
+
+  explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
+  ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
+
+  ParamGenerator& operator=(const ParamGenerator& other) {
+    impl_ = other.impl_;
+    return *this;
+  }
+
+  iterator begin() const { return iterator(impl_->Begin()); }
+  iterator end() const { return iterator(impl_->End()); }
+
+ private:
+  linked_ptr<const ParamGeneratorInterface<T> > impl_;
+};
+
+// Generates values from a range of two comparable values. Can be used to
+// generate sequences of user-defined types that implement operator+() and
+// operator<().
+// This class is used in the Range() function.
+template <typename T, typename IncrementT>
+class RangeGenerator : public ParamGeneratorInterface<T> {
+ public:
+  RangeGenerator(T begin, T end, IncrementT step)
+      : begin_(begin), end_(end),
+        step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
+  virtual ~RangeGenerator() {}
+
+  virtual ParamIteratorInterface<T>* Begin() const {
+    return new Iterator(this, begin_, 0, step_);
+  }
+  virtual ParamIteratorInterface<T>* End() const {
+    return new Iterator(this, end_, end_index_, step_);
+  }
+
+ private:
+  class Iterator : public ParamIteratorInterface<T> {
+   public:
+    Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
+             IncrementT step)
+        : base_(base), value_(value), index_(index), step_(step) {}
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
+      return base_;
+    }
+    virtual void Advance() {
+      value_ = value_ + step_;
+      index_++;
+    }
+    virtual ParamIteratorInterface<T>* Clone() const {
+      return new Iterator(*this);
+    }
+    virtual const T* Current() const { return &value_; }
+    virtual bool Equals(const ParamIteratorInterface<T>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      const int other_index =
+          CheckedDowncastToActualType<const Iterator>(&other)->index_;
+      return index_ == other_index;
+    }
+
+   private:
+    Iterator(const Iterator& other)
+        : ParamIteratorInterface<T>(),
+          base_(other.base_), value_(other.value_), index_(other.index_),
+          step_(other.step_) {}
+
+    // No implementation - assignment is unsupported.
+    void operator=(const Iterator& other);
+
+    const ParamGeneratorInterface<T>* const base_;
+    T value_;
+    int index_;
+    const IncrementT step_;
+  };  // class RangeGenerator::Iterator
+
+  static int CalculateEndIndex(const T& begin,
+                               const T& end,
+                               const IncrementT& step) {
+    int end_index = 0;
+    for (T i = begin; i < end; i = i + step)
+      end_index++;
+    return end_index;
+  }
+
+  // No implementation - assignment is unsupported.
+  void operator=(const RangeGenerator& other);
+
+  const T begin_;
+  const T end_;
+  const IncrementT step_;
+  // The index for the end() iterator. All the elements in the generated
+  // sequence are indexed (0-based) to aid iterator comparison.
+  const int end_index_;
+};  // class RangeGenerator
+
+
+// Generates values from a pair of STL-style iterators. Used in the
+// ValuesIn() function. The elements are copied from the source range
+// since the source can be located on the stack, and the generator
+// is likely to persist beyond that stack frame.
+template <typename T>
+class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
+ public:
+  template <typename ForwardIterator>
+  ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
+      : container_(begin, end) {}
+  virtual ~ValuesInIteratorRangeGenerator() {}
+
+  virtual ParamIteratorInterface<T>* Begin() const {
+    return new Iterator(this, container_.begin());
+  }
+  virtual ParamIteratorInterface<T>* End() const {
+    return new Iterator(this, container_.end());
+  }
+
+ private:
+  typedef typename ::std::vector<T> ContainerType;
+
+  class Iterator : public ParamIteratorInterface<T> {
+   public:
+    Iterator(const ParamGeneratorInterface<T>* base,
+             typename ContainerType::const_iterator iterator)
+        : base_(base), iterator_(iterator) {}
+    virtual ~Iterator() {}
+
+    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
+      return base_;
+    }
+    virtual void Advance() {
+      ++iterator_;
+      value_.reset();
+    }
+    virtual ParamIteratorInterface<T>* Clone() const {
+      return new Iterator(*this);
+    }
+    // We need to use cached value referenced by iterator_ because *iterator_
+    // can return a temporary object (and of type other then T), so just
+    // having "return &*iterator_;" doesn't work.
+    // value_ is updated here and not in Advance() because Advance()
+    // can advance iterator_ beyond the end of the range, and we cannot
+    // detect that fact. The client code, on the other hand, is
+    // responsible for not calling Current() on an out-of-range iterator.
+    virtual const T* Current() const {
+      if (value_.get() == NULL)
+        value_.reset(new T(*iterator_));
+      return value_.get();
+    }
+    virtual bool Equals(const ParamIteratorInterface<T>& other) const {
+      // Having the same base generator guarantees that the other
+      // iterator is of the same type and we can downcast.
+      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
+          << "The program attempted to compare iterators "
+          << "from different generators." << std::endl;
+      return iterator_ ==
+          CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
+    }
+
+   private:
+    Iterator(const Iterator& other)
+          // The explicit constructor call suppresses a false warning
+          // emitted by gcc when supplied with the -Wextra option.
+        : ParamIteratorInterface<T>(),
+          base_(other.base_),
+          iterator_(other.iterator_) {}
+
+    const ParamGeneratorInterface<T>* const base_;
+    typename ContainerType::const_iterator iterator_;
+    // A cached value of *iterator_. We keep it here to allow access by
+    // pointer in the wrapping iterator's operator->().
+    // value_ needs to be mutable to be accessed in Current().
+    // Use of scoped_ptr helps manage cached value's lifetime,
+    // which is bound by the lifespan of the iterator itself.
+    mutable scoped_ptr<const T> value_;
+  };  // class ValuesInIteratorRangeGenerator::Iterator
+
+  // No implementation - assignment is unsupported.
+  void operator=(const ValuesInIteratorRangeGenerator& other);
+
+  const ContainerType container_;
+};  // class ValuesInIteratorRangeGenerator
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Stores a parameter value and later creates tests parameterized with that
+// value.
+template <class TestClass>
+class ParameterizedTestFactory : public TestFactoryBase {
+ public:
+  typedef typename TestClass::ParamType ParamType;
+  explicit ParameterizedTestFactory(ParamType parameter) :
+      parameter_(parameter) {}
+  virtual Test* CreateTest() {
+    TestClass::SetParam(&parameter_);
+    return new TestClass();
+  }
+
+ private:
+  const ParamType parameter_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
+};
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// TestMetaFactoryBase is a base class for meta-factories that create
+// test factories for passing into MakeAndRegisterTestInfo function.
+template <class ParamType>
+class TestMetaFactoryBase {
+ public:
+  virtual ~TestMetaFactoryBase() {}
+
+  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
+};
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// TestMetaFactory creates test factories for passing into
+// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
+// ownership of test factory pointer, same factory object cannot be passed
+// into that method twice. But ParameterizedTestCaseInfo is going to call
+// it for each Test/Parameter value combination. Thus it needs meta factory
+// creator class.
+template <class TestCase>
+class TestMetaFactory
+    : public TestMetaFactoryBase<typename TestCase::ParamType> {
+ public:
+  typedef typename TestCase::ParamType ParamType;
+
+  TestMetaFactory() {}
+
+  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) {
+    return new ParameterizedTestFactory<TestCase>(parameter);
+  }
+
+ private:
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
+};
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// ParameterizedTestCaseInfoBase is a generic interface
+// to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase
+// accumulates test information provided by TEST_P macro invocations
+// and generators provided by INSTANTIATE_TEST_CASE_P macro invocations
+// and uses that information to register all resulting test instances
+// in RegisterTests method. The ParameterizeTestCaseRegistry class holds
+// a collection of pointers to the ParameterizedTestCaseInfo objects
+// and calls RegisterTests() on each of them when asked.
+class ParameterizedTestCaseInfoBase {
+ public:
+  virtual ~ParameterizedTestCaseInfoBase() {}
+
+  // Base part of test case name for display purposes.
+  virtual const string& GetTestCaseName() const = 0;
+  // Test case id to verify identity.
+  virtual TypeId GetTestCaseTypeId() const = 0;
+  // UnitTest class invokes this method to register tests in this
+  // test case right before running them in RUN_ALL_TESTS macro.
+  // This method should not be called more then once on any single
+  // instance of a ParameterizedTestCaseInfoBase derived class.
+  virtual void RegisterTests() = 0;
+
+ protected:
+  ParameterizedTestCaseInfoBase() {}
+
+ private:
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);
+};
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// ParameterizedTestCaseInfo accumulates tests obtained from TEST_P
+// macro invocations for a particular test case and generators
+// obtained from INSTANTIATE_TEST_CASE_P macro invocations for that
+// test case. It registers tests with all values generated by all
+// generators when asked.
+template <class TestCase>
+class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
+ public:
+  // ParamType and GeneratorCreationFunc are private types but are required
+  // for declarations of public methods AddTestPattern() and
+  // AddTestCaseInstantiation().
+  typedef typename TestCase::ParamType ParamType;
+  // A function that returns an instance of appropriate generator type.
+  typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
+
+  explicit ParameterizedTestCaseInfo(const char* name)
+      : test_case_name_(name) {}
+
+  // Test case base name for display purposes.
+  virtual const string& GetTestCaseName() const { return test_case_name_; }
+  // Test case id to verify identity.
+  virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
+  // TEST_P macro uses AddTestPattern() to record information
+  // about a single test in a LocalTestInfo structure.
+  // test_case_name is the base name of the test case (without invocation
+  // prefix). test_base_name is the name of an individual test without
+  // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
+  // test case base name and DoBar is test base name.
+  void AddTestPattern(const char* test_case_name,
+                      const char* test_base_name,
+                      TestMetaFactoryBase<ParamType>* meta_factory) {
+    tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,
+                                                       test_base_name,
+                                                       meta_factory)));
+  }
+  // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information
+  // about a generator.
+  int AddTestCaseInstantiation(const string& instantiation_name,
+                               GeneratorCreationFunc* func,
+                               const char* /* file */,
+                               int /* line */) {
+    instantiations_.push_back(::std::make_pair(instantiation_name, func));
+    return 0;  // Return value used only to run this method in namespace scope.
+  }
+  // UnitTest class invokes this method to register tests in this test case
+  // test cases right before running tests in RUN_ALL_TESTS macro.
+  // This method should not be called more then once on any single
+  // instance of a ParameterizedTestCaseInfoBase derived class.
+  // UnitTest has a guard to prevent from calling this method more then once.
+  virtual void RegisterTests() {
+    for (typename TestInfoContainer::iterator test_it = tests_.begin();
+         test_it != tests_.end(); ++test_it) {
+      linked_ptr<TestInfo> test_info = *test_it;
+      for (typename InstantiationContainer::iterator gen_it =
+               instantiations_.begin(); gen_it != instantiations_.end();
+               ++gen_it) {
+        const string& instantiation_name = gen_it->first;
+        ParamGenerator<ParamType> generator((*gen_it->second)());
+
+        string test_case_name;
+        if ( !instantiation_name.empty() )
+          test_case_name = instantiation_name + "/";
+        test_case_name += test_info->test_case_base_name;
+
+        int i = 0;
+        for (typename ParamGenerator<ParamType>::iterator param_it =
+                 generator.begin();
+             param_it != generator.end(); ++param_it, ++i) {
+          Message test_name_stream;
+          test_name_stream << test_info->test_base_name << "/" << i;
+          MakeAndRegisterTestInfo(
+              test_case_name.c_str(),
+              test_name_stream.GetString().c_str(),
+              NULL,  // No type parameter.
+              PrintToString(*param_it).c_str(),
+              GetTestCaseTypeId(),
+              TestCase::SetUpTestCase,
+              TestCase::TearDownTestCase,
+              test_info->test_meta_factory->CreateTestFactory(*param_it));
+        }  // for param_it
+      }  // for gen_it
+    }  // for test_it
+  }  // RegisterTests
+
+ private:
+  // LocalTestInfo structure keeps information about a single test registered
+  // with TEST_P macro.
+  struct TestInfo {
+    TestInfo(const char* a_test_case_base_name,
+             const char* a_test_base_name,
+             TestMetaFactoryBase<ParamType>* a_test_meta_factory) :
+        test_case_base_name(a_test_case_base_name),
+        test_base_name(a_test_base_name),
+        test_meta_factory(a_test_meta_factory) {}
+
+    const string test_case_base_name;
+    const string test_base_name;
+    const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
+  };
+  typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;
+  // Keeps pairs of <Instantiation name, Sequence generator creation function>
+  // received from INSTANTIATE_TEST_CASE_P macros.
+  typedef ::std::vector<std::pair<string, GeneratorCreationFunc*> >
+      InstantiationContainer;
+
+  const string test_case_name_;
+  TestInfoContainer tests_;
+  InstantiationContainer instantiations_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo);
+};  // class ParameterizedTestCaseInfo
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase
+// classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P
+// macros use it to locate their corresponding ParameterizedTestCaseInfo
+// descriptors.
+class ParameterizedTestCaseRegistry {
+ public:
+  ParameterizedTestCaseRegistry() {}
+  ~ParameterizedTestCaseRegistry() {
+    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
+         it != test_case_infos_.end(); ++it) {
+      delete *it;
+    }
+  }
+
+  // Looks up or creates and returns a structure containing information about
+  // tests and instantiations of a particular test case.
+  template <class TestCase>
+  ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
+      const char* test_case_name,
+      const char* file,
+      int line) {
+    ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;
+    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
+         it != test_case_infos_.end(); ++it) {
+      if ((*it)->GetTestCaseName() == test_case_name) {
+        if ((*it)->GetTestCaseTypeId() != GetTypeId<TestCase>()) {
+          // Complain about incorrect usage of Google Test facilities
+          // and terminate the program since we cannot guaranty correct
+          // test case setup and tear-down in this case.
+          ReportInvalidTestCaseType(test_case_name,  file, line);
+          posix::Abort();
+        } else {
+          // At this point we are sure that the object we found is of the same
+          // type we are looking for, so we downcast it to that type
+          // without further checks.
+          typed_test_info = CheckedDowncastToActualType<
+              ParameterizedTestCaseInfo<TestCase> >(*it);
+        }
+        break;
+      }
+    }
+    if (typed_test_info == NULL) {
+      typed_test_info = new ParameterizedTestCaseInfo<TestCase>(test_case_name);
+      test_case_infos_.push_back(typed_test_info);
+    }
+    return typed_test_info;
+  }
+  void RegisterTests() {
+    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
+         it != test_case_infos_.end(); ++it) {
+      (*it)->RegisterTests();
+    }
+  }
+
+ private:
+  typedef ::std::vector<ParameterizedTestCaseInfoBase*> TestCaseInfoContainer;
+
+  TestCaseInfoContainer test_case_infos_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry);
+};
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  //  GTEST_HAS_PARAM_TEST
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-port.h b/test/fmw/gtest/include/gtest/internal/gtest-port.h
new file mode 100644
index 0000000..dc4fe0c
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-port.h
@@ -0,0 +1,1947 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: wan@google.com (Zhanyong Wan)
+//
+// Low-level types and utilities for porting Google Test to various
+// platforms.  They are subject to change without notice.  DO NOT USE
+// THEM IN USER CODE.
+//
+// This file is fundamental to Google Test.  All other Google Test source
+// files are expected to #include this.  Therefore, it cannot #include
+// any other Google Test header.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
+
+// The user can define the following macros in the build script to
+// control Google Test's behavior.  If the user doesn't define a macro
+// in this list, Google Test will define it.
+//
+//   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)
+//                              is/isn't available.
+//   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions
+//                              are enabled.
+//   GTEST_HAS_GLOBAL_STRING  - Define it to 1/0 to indicate that ::string
+//                              is/isn't available (some systems define
+//                              ::string, which is different to std::string).
+//   GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
+//                              is/isn't available (some systems define
+//                              ::wstring, which is different to std::wstring).
+//   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular
+//                              expressions are/aren't available.
+//   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>
+//                              is/isn't available.
+//   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't
+//                              enabled.
+//   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that
+//                              std::wstring does/doesn't work (Google Test can
+//                              be used where std::wstring is unavailable).
+//   GTEST_HAS_TR1_TUPLE      - Define it to 1/0 to indicate tr1::tuple
+//                              is/isn't available.
+//   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the
+//                              compiler supports Microsoft's "Structured
+//                              Exception Handling".
+//   GTEST_HAS_STREAM_REDIRECTION
+//                            - Define it to 1/0 to indicate whether the
+//                              platform supports I/O stream redirection using
+//                              dup() and dup2().
+//   GTEST_USE_OWN_TR1_TUPLE  - Define it to 1/0 to indicate whether Google
+//                              Test's own tr1 tuple implementation should be
+//                              used.  Unused when the user sets
+//                              GTEST_HAS_TR1_TUPLE to 0.
+//   GTEST_LANG_CXX11         - Define it to 1/0 to indicate that Google Test
+//                              is building in C++11/C++98 mode.
+//   GTEST_LINKED_AS_SHARED_LIBRARY
+//                            - Define to 1 when compiling tests that use
+//                              Google Test as a shared library (known as
+//                              DLL on Windows).
+//   GTEST_CREATE_SHARED_LIBRARY
+//                            - Define to 1 when compiling Google Test itself
+//                              as a shared library.
+
+// This header defines the following utilities:
+//
+// Macros indicating the current platform (defined to 1 if compiled on
+// the given platform; otherwise undefined):
+//   GTEST_OS_AIX      - IBM AIX
+//   GTEST_OS_CYGWIN   - Cygwin
+//   GTEST_OS_HPUX     - HP-UX
+//   GTEST_OS_LINUX    - Linux
+//     GTEST_OS_LINUX_ANDROID - Google Android
+//   GTEST_OS_MAC      - Mac OS X
+//     GTEST_OS_IOS    - iOS
+//       GTEST_OS_IOS_SIMULATOR - iOS simulator
+//   GTEST_OS_NACL     - Google Native Client (NaCl)
+//   GTEST_OS_OPENBSD  - OpenBSD
+//   GTEST_OS_QNX      - QNX
+//   GTEST_OS_SOLARIS  - Sun Solaris
+//   GTEST_OS_SYMBIAN  - Symbian
+//   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)
+//     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop
+//     GTEST_OS_WINDOWS_MINGW    - MinGW
+//     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile
+//   GTEST_OS_ZOS      - z/OS
+//
+// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
+// most stable support.  Since core members of the Google Test project
+// don't have access to other platforms, support for them may be less
+// stable.  If you notice any problems on your platform, please notify
+// googletestframework@googlegroups.com (patches for fixing them are
+// even more welcome!).
+//
+// Note that it is possible that none of the GTEST_OS_* macros are defined.
+//
+// Macros indicating available Google Test features (defined to 1 if
+// the corresponding feature is supported; otherwise undefined):
+//   GTEST_HAS_COMBINE      - the Combine() function (for value-parameterized
+//                            tests)
+//   GTEST_HAS_DEATH_TEST   - death tests
+//   GTEST_HAS_PARAM_TEST   - value-parameterized tests
+//   GTEST_HAS_TYPED_TEST   - typed tests
+//   GTEST_HAS_TYPED_TEST_P - type-parameterized tests
+//   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with
+//                            GTEST_HAS_POSIX_RE (see above) which users can
+//                            define themselves.
+//   GTEST_USES_SIMPLE_RE   - our own simple regex is used;
+//                            the above two are mutually exclusive.
+//   GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
+//
+// Macros for basic C++ coding:
+//   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
+//   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a
+//                              variable don't have to be used.
+//   GTEST_DISALLOW_ASSIGN_   - disables operator=.
+//   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
+//   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.
+//
+// Synchronization:
+//   Mutex, MutexLock, ThreadLocal, GetThreadCount()
+//                  - synchronization primitives.
+//   GTEST_IS_THREADSAFE - defined to 1 to indicate that the above
+//                         synchronization primitives have real implementations
+//                         and Google Test is thread-safe; or 0 otherwise.
+//
+// Template meta programming:
+//   is_pointer     - as in TR1; needed on Symbian and IBM XL C/C++ only.
+//   IteratorTraits - partial implementation of std::iterator_traits, which
+//                    is not available in libCstd when compiled with Sun C++.
+//
+// Smart pointers:
+//   scoped_ptr     - as in TR2.
+//
+// Regular expressions:
+//   RE             - a simple regular expression class using the POSIX
+//                    Extended Regular Expression syntax on UNIX-like
+//                    platforms, or a reduced regular exception syntax on
+//                    other platforms, including Windows.
+//
+// Logging:
+//   GTEST_LOG_()   - logs messages at the specified severity level.
+//   LogToStderr()  - directs all log messages to stderr.
+//   FlushInfoLog() - flushes informational log messages.
+//
+// Stdout and stderr capturing:
+//   CaptureStdout()     - starts capturing stdout.
+//   GetCapturedStdout() - stops capturing stdout and returns the captured
+//                         string.
+//   CaptureStderr()     - starts capturing stderr.
+//   GetCapturedStderr() - stops capturing stderr and returns the captured
+//                         string.
+//
+// Integer types:
+//   TypeWithSize   - maps an integer to a int type.
+//   Int32, UInt32, Int64, UInt64, TimeInMillis
+//                  - integers of known sizes.
+//   BiggestInt     - the biggest signed integer type.
+//
+// Command-line utilities:
+//   GTEST_FLAG()       - references a flag.
+//   GTEST_DECLARE_*()  - declares a flag.
+//   GTEST_DEFINE_*()   - defines a flag.
+//   GetInjectableArgvs() - returns the command line as a vector of strings.
+//
+// Environment variable utilities:
+//   GetEnv()             - gets the value of an environment variable.
+//   BoolFromGTestEnv()   - parses a bool environment variable.
+//   Int32FromGTestEnv()  - parses an Int32 environment variable.
+//   StringFromGTestEnv() - parses a string environment variable.
+
+#include <ctype.h>   // for isspace, etc
+#include <stddef.h>  // for ptrdiff_t
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifndef _WIN32_WCE
+# include <sys/types.h>
+# include <sys/stat.h>
+#endif  // !_WIN32_WCE
+
+#if defined __APPLE__
+# include <AvailabilityMacros.h>
+# include <TargetConditionals.h>
+#endif
+
+#include <iostream>  // NOLINT
+#include <sstream>  // NOLINT
+#include <string>  // NOLINT
+
+#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
+#define GTEST_FLAG_PREFIX_ "gtest_"
+#define GTEST_FLAG_PREFIX_DASH_ "gtest-"
+#define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
+#define GTEST_NAME_ "Google Test"
+#define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/"
+
+// Determines the version of gcc that is used to compile this.
+#ifdef __GNUC__
+// 40302 means version 4.3.2.
+# define GTEST_GCC_VER_ \
+    (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
+#endif  // __GNUC__
+
+// Determines the platform on which Google Test is compiled.
+#ifdef __CYGWIN__
+# define GTEST_OS_CYGWIN 1
+#elif defined __SYMBIAN32__
+# define GTEST_OS_SYMBIAN 1
+#elif defined _WIN32
+# define GTEST_OS_WINDOWS 1
+# ifdef _WIN32_WCE
+#  define GTEST_OS_WINDOWS_MOBILE 1
+# elif defined(__MINGW__) || defined(__MINGW32__)
+#  define GTEST_OS_WINDOWS_MINGW 1
+# else
+#  define GTEST_OS_WINDOWS_DESKTOP 1
+# endif  // _WIN32_WCE
+#elif defined __APPLE__
+# define GTEST_OS_MAC 1
+# if TARGET_OS_IPHONE
+#  define GTEST_OS_IOS 1
+#  if TARGET_IPHONE_SIMULATOR
+#   define GTEST_OS_IOS_SIMULATOR 1
+#  endif
+# endif
+#elif defined __linux__
+# define GTEST_OS_LINUX 1
+# if defined __ANDROID__
+#  define GTEST_OS_LINUX_ANDROID 1
+# endif
+#elif defined __MVS__
+# define GTEST_OS_ZOS 1
+#elif defined(__sun) && defined(__SVR4)
+# define GTEST_OS_SOLARIS 1
+#elif defined(_AIX)
+# define GTEST_OS_AIX 1
+#elif defined(__hpux)
+# define GTEST_OS_HPUX 1
+#elif defined __native_client__
+# define GTEST_OS_NACL 1
+#elif defined __OpenBSD__
+# define GTEST_OS_OPENBSD 1
+#elif defined __QNX__
+# define GTEST_OS_QNX 1
+#endif  // __CYGWIN__
+
+#ifndef GTEST_LANG_CXX11
+// gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when
+// -std={c,gnu}++{0x,11} is passed.  The C++11 standard specifies a
+// value for __cplusplus, and recent versions of clang, gcc, and
+// probably other compilers set that too in C++11 mode.
+# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L
+// Compiling in at least C++11 mode.
+#  define GTEST_LANG_CXX11 1
+# else
+#  define GTEST_LANG_CXX11 0
+# endif
+#endif
+
+// Brings in definitions for functions used in the testing::internal::posix
+// namespace (read, write, close, chdir, isatty, stat). We do not currently
+// use them on Windows Mobile.
+#if !GTEST_OS_WINDOWS
+// This assumes that non-Windows OSes provide unistd.h. For OSes where this
+// is not the case, we need to include headers that provide the functions
+// mentioned above.
+# include <unistd.h>
+# include <strings.h>
+#elif !GTEST_OS_WINDOWS_MOBILE
+# include <direct.h>
+# include <io.h>
+#endif
+
+#if GTEST_OS_LINUX_ANDROID
+// Used to define __ANDROID_API__ matching the target NDK API level.
+#  include <android/api-level.h>  // NOLINT
+#endif
+
+// Defines this to true iff Google Test can use POSIX regular expressions.
+#ifndef GTEST_HAS_POSIX_RE
+# if GTEST_OS_LINUX_ANDROID
+// On Android, <regex.h> is only available starting with Gingerbread.
+#  define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
+# else
+#  define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
+# endif
+#endif
+
+#if GTEST_HAS_POSIX_RE
+
+// On some platforms, <regex.h> needs someone to define size_t, and
+// won't compile otherwise.  We can #include it here as we already
+// included <stdlib.h>, which is guaranteed to define size_t through
+// <stddef.h>.
+# include <regex.h>  // NOLINT
+
+# define GTEST_USES_POSIX_RE 1
+
+#elif GTEST_OS_WINDOWS
+
+// <regex.h> is not available on Windows.  Use our own simple regex
+// implementation instead.
+# define GTEST_USES_SIMPLE_RE 1
+
+#else
+
+// <regex.h> may not be available on this platform.  Use our own
+// simple regex implementation instead.
+# define GTEST_USES_SIMPLE_RE 1
+
+#endif  // GTEST_HAS_POSIX_RE
+
+#ifndef GTEST_HAS_EXCEPTIONS
+// The user didn't tell us whether exceptions are enabled, so we need
+// to figure it out.
+# if defined(_MSC_VER) || defined(__BORLANDC__)
+// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
+// macro to enable exceptions, so we'll do the same.
+// Assumes that exceptions are enabled by default.
+#  ifndef _HAS_EXCEPTIONS
+#   define _HAS_EXCEPTIONS 1
+#  endif  // _HAS_EXCEPTIONS
+#  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
+# elif defined(__GNUC__) && __EXCEPTIONS
+// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
+#  define GTEST_HAS_EXCEPTIONS 1
+# elif defined(__SUNPRO_CC)
+// Sun Pro CC supports exceptions.  However, there is no compile-time way of
+// detecting whether they are enabled or not.  Therefore, we assume that
+// they are enabled unless the user tells us otherwise.
+#  define GTEST_HAS_EXCEPTIONS 1
+# elif defined(__IBMCPP__) && __EXCEPTIONS
+// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
+#  define GTEST_HAS_EXCEPTIONS 1
+# elif defined(__HP_aCC)
+// Exception handling is in effect by default in HP aCC compiler. It has to
+// be turned of by +noeh compiler option if desired.
+#  define GTEST_HAS_EXCEPTIONS 1
+# else
+// For other compilers, we assume exceptions are disabled to be
+// conservative.
+#  define GTEST_HAS_EXCEPTIONS 0
+# endif  // defined(_MSC_VER) || defined(__BORLANDC__)
+#endif  // GTEST_HAS_EXCEPTIONS
+
+#if !defined(GTEST_HAS_STD_STRING)
+// Even though we don't use this macro any longer, we keep it in case
+// some clients still depend on it.
+# define GTEST_HAS_STD_STRING 1
+#elif !GTEST_HAS_STD_STRING
+// The user told us that ::std::string isn't available.
+# error "Google Test cannot be used where ::std::string isn't available."
+#endif  // !defined(GTEST_HAS_STD_STRING)
+
+#ifndef GTEST_HAS_GLOBAL_STRING
+// The user didn't tell us whether ::string is available, so we need
+// to figure it out.
+
+# define GTEST_HAS_GLOBAL_STRING 0
+
+#endif  // GTEST_HAS_GLOBAL_STRING
+
+#ifndef GTEST_HAS_STD_WSTRING
+// The user didn't tell us whether ::std::wstring is available, so we need
+// to figure it out.
+// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
+//   is available.
+
+// Cygwin 1.7 and below doesn't support ::std::wstring.
+// Solaris' libc++ doesn't support it either.  Android has
+// no support for it at least as recent as Froyo (2.2).
+# define GTEST_HAS_STD_WSTRING \
+    (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
+
+#endif  // GTEST_HAS_STD_WSTRING
+
+#ifndef GTEST_HAS_GLOBAL_WSTRING
+// The user didn't tell us whether ::wstring is available, so we need
+// to figure it out.
+# define GTEST_HAS_GLOBAL_WSTRING \
+    (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
+#endif  // GTEST_HAS_GLOBAL_WSTRING
+
+// Determines whether RTTI is available.
+#ifndef GTEST_HAS_RTTI
+// The user didn't tell us whether RTTI is enabled, so we need to
+// figure it out.
+
+# ifdef _MSC_VER
+
+#  ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.
+#   define GTEST_HAS_RTTI 1
+#  else
+#   define GTEST_HAS_RTTI 0
+#  endif
+
+// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
+# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)
+
+#  ifdef __GXX_RTTI
+// When building against STLport with the Android NDK and with
+// -frtti -fno-exceptions, the build fails at link time with undefined
+// references to __cxa_bad_typeid. Note sure if STL or toolchain bug,
+// so disable RTTI when detected.
+#   if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \
+       !defined(__EXCEPTIONS)
+#    define GTEST_HAS_RTTI 0
+#   else
+#    define GTEST_HAS_RTTI 1
+#   endif  // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS
+#  else
+#   define GTEST_HAS_RTTI 0
+#  endif  // __GXX_RTTI
+
+// Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends
+// using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the
+// first version with C++ support.
+# elif defined(__clang__)
+
+#  define GTEST_HAS_RTTI __has_feature(cxx_rtti)
+
+// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
+// both the typeid and dynamic_cast features are present.
+# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
+
+#  ifdef __RTTI_ALL__
+#   define GTEST_HAS_RTTI 1
+#  else
+#   define GTEST_HAS_RTTI 0
+#  endif
+
+# else
+
+// For all other compilers, we assume RTTI is enabled.
+#  define GTEST_HAS_RTTI 1
+
+# endif  // _MSC_VER
+
+#endif  // GTEST_HAS_RTTI
+
+// It's this header's responsibility to #include <typeinfo> when RTTI
+// is enabled.
+#if GTEST_HAS_RTTI
+# include <typeinfo>
+#endif
+
+// Determines whether Google Test can use the pthreads library.
+#ifndef GTEST_HAS_PTHREAD
+// The user didn't tell us explicitly, so we assume pthreads support is
+// available on Linux and Mac.
+//
+// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
+// to your compiler flags.
+# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \
+    || GTEST_OS_QNX)
+#endif  // GTEST_HAS_PTHREAD
+
+#if GTEST_HAS_PTHREAD
+// gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is
+// true.
+# include <pthread.h>  // NOLINT
+
+// For timespec and nanosleep, used below.
+# include <time.h>  // NOLINT
+#endif
+
+// Determines whether Google Test can use tr1/tuple.  You can define
+// this macro to 0 to prevent Google Test from using tuple (any
+// feature depending on tuple with be disabled in this mode).
+#ifndef GTEST_HAS_TR1_TUPLE
+# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)
+// STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>.
+#  define GTEST_HAS_TR1_TUPLE 0
+# else
+// The user didn't tell us not to do it, so we assume it's OK.
+#  define GTEST_HAS_TR1_TUPLE 1
+# endif
+#endif  // GTEST_HAS_TR1_TUPLE
+
+// Determines whether Google Test's own tr1 tuple implementation
+// should be used.
+#ifndef GTEST_USE_OWN_TR1_TUPLE
+// The user didn't tell us, so we need to figure it out.
+
+// We use our own TR1 tuple if we aren't sure the user has an
+// implementation of it already.  At this time, libstdc++ 4.0.0+ and
+// MSVC 2010 are the only mainstream standard libraries that come
+// with a TR1 tuple implementation.  NVIDIA's CUDA NVCC compiler
+// pretends to be GCC by defining __GNUC__ and friends, but cannot
+// compile GCC's tuple implementation.  MSVC 2008 (9.0) provides TR1
+// tuple in a 323 MB Feature Pack download, which we cannot assume the
+// user has.  QNX's QCC compiler is a modified GCC but it doesn't
+// support TR1 tuple.  libc++ only provides std::tuple, in C++11 mode,
+// and it can be used with some compilers that define __GNUC__.
+# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
+      && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600
+#  define GTEST_ENV_HAS_TR1_TUPLE_ 1
+# endif
+
+// C++11 specifies that <tuple> provides std::tuple. Use that if gtest is used
+// in C++11 mode and libstdc++ isn't very old (binaries targeting OS X 10.6
+// can build with clang but need to use gcc4.2's libstdc++).
+# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
+#  define GTEST_ENV_HAS_STD_TUPLE_ 1
+# endif
+
+# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
+#  define GTEST_USE_OWN_TR1_TUPLE 0
+# else
+#  define GTEST_USE_OWN_TR1_TUPLE 1
+# endif
+
+#endif  // GTEST_USE_OWN_TR1_TUPLE
+
+// To avoid conditional compilation everywhere, we make it
+// gtest-port.h's responsibility to #include the header implementing
+// tr1/tuple.
+#if GTEST_HAS_TR1_TUPLE
+
+# if GTEST_USE_OWN_TR1_TUPLE
+#  include "gtest/internal/gtest-tuple.h"
+# elif GTEST_ENV_HAS_STD_TUPLE_
+#  include <tuple>
+// C++11 puts its tuple into the ::std namespace rather than
+// ::std::tr1.  gtest expects tuple to live in ::std::tr1, so put it there.
+// This causes undefined behavior, but supported compilers react in
+// the way we intend.
+namespace std {
+namespace tr1 {
+using ::std::get;
+using ::std::make_tuple;
+using ::std::tuple;
+using ::std::tuple_element;
+using ::std::tuple_size;
+}
+}
+
+# elif GTEST_OS_SYMBIAN
+
+// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
+// use STLport's tuple implementation, which unfortunately doesn't
+// work as the copy of STLport distributed with Symbian is incomplete.
+// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to
+// use its own tuple implementation.
+#  ifdef BOOST_HAS_TR1_TUPLE
+#   undef BOOST_HAS_TR1_TUPLE
+#  endif  // BOOST_HAS_TR1_TUPLE
+
+// This prevents <boost/tr1/detail/config.hpp>, which defines
+// BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.
+#  define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
+#  include <tuple>
+
+# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
+// GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header.  This does
+// not conform to the TR1 spec, which requires the header to be <tuple>.
+
+#  if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
+// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
+// which is #included by <tr1/tuple>, to not compile when RTTI is
+// disabled.  _TR1_FUNCTIONAL is the header guard for
+// <tr1/functional>.  Hence the following #define is a hack to prevent
+// <tr1/functional> from being included.
+#   define _TR1_FUNCTIONAL 1
+#   include <tr1/tuple>
+#   undef _TR1_FUNCTIONAL  // Allows the user to #include
+                        // <tr1/functional> if he chooses to.
+#  else
+#   include <tr1/tuple>  // NOLINT
+#  endif  // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
+
+# else
+// If the compiler is not GCC 4.0+, we assume the user is using a
+// spec-conforming TR1 implementation.
+#  include <tuple>  // NOLINT
+# endif  // GTEST_USE_OWN_TR1_TUPLE
+
+#endif  // GTEST_HAS_TR1_TUPLE
+
+// Determines whether clone(2) is supported.
+// Usually it will only be available on Linux, excluding
+// Linux on the Itanium architecture.
+// Also see http://linux.die.net/man/2/clone.
+#ifndef GTEST_HAS_CLONE
+// The user didn't tell us, so we need to figure it out.
+
+# if GTEST_OS_LINUX && !defined(__ia64__)
+#  if GTEST_OS_LINUX_ANDROID
+// On Android, clone() is only available on ARM starting with Gingerbread.
+#    if defined(__arm__) && __ANDROID_API__ >= 9
+#     define GTEST_HAS_CLONE 1
+#    else
+#     define GTEST_HAS_CLONE 0
+#    endif
+#  else
+#   define GTEST_HAS_CLONE 1
+#  endif
+# else
+#  define GTEST_HAS_CLONE 0
+# endif  // GTEST_OS_LINUX && !defined(__ia64__)
+
+#endif  // GTEST_HAS_CLONE
+
+// Determines whether to support stream redirection. This is used to test
+// output correctness and to implement death tests.
+#ifndef GTEST_HAS_STREAM_REDIRECTION
+// By default, we assume that stream redirection is supported on all
+// platforms except known mobile ones.
+# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN
+#  define GTEST_HAS_STREAM_REDIRECTION 0
+# else
+#  define GTEST_HAS_STREAM_REDIRECTION 1
+# endif  // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN
+#endif  // GTEST_HAS_STREAM_REDIRECTION
+
+// Determines whether to support death tests.
+// Google Test does not support death tests for VC 7.1 and earlier as
+// abort() in a VC 7.1 application compiled as GUI in debug config
+// pops up a dialog window that cannot be suppressed programmatically.
+#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
+     (GTEST_OS_MAC && !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \
+     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
+     GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
+     GTEST_OS_OPENBSD || GTEST_OS_QNX)
+# define GTEST_HAS_DEATH_TEST 1
+# include <vector>  // NOLINT
+#endif
+
+// We don't support MSVC 7.1 with exceptions disabled now.  Therefore
+// all the compilers we care about are adequate for supporting
+// value-parameterized tests.
+#define GTEST_HAS_PARAM_TEST 1
+
+// Determines whether to support type-driven tests.
+
+// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
+// Sun Pro CC, IBM Visual Age, and HP aCC support.
+#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \
+    defined(__IBMCPP__) || defined(__HP_aCC)
+# define GTEST_HAS_TYPED_TEST 1
+# define GTEST_HAS_TYPED_TEST_P 1
+#endif
+
+// Determines whether to support Combine(). This only makes sense when
+// value-parameterized tests are enabled.  The implementation doesn't
+// work on Sun Studio since it doesn't understand templated conversion
+// operators.
+#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)
+# define GTEST_HAS_COMBINE 1
+#endif
+
+// Determines whether the system compiler uses UTF-16 for encoding wide strings.
+#define GTEST_WIDE_STRING_USES_UTF16_ \
+    (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
+
+// Determines whether test results can be streamed to a socket.
+#if GTEST_OS_LINUX
+# define GTEST_CAN_STREAM_RESULTS_ 1
+#endif
+
+// Defines some utility macros.
+
+// The GNU compiler emits a warning if nested "if" statements are followed by
+// an "else" statement and braces are not used to explicitly disambiguate the
+// "else" binding.  This leads to problems with code like:
+//
+//   if (gate)
+//     ASSERT_*(condition) << "Some message";
+//
+// The "switch (0) case 0:" idiom is used to suppress this.
+#ifdef __INTEL_COMPILER
+# define GTEST_AMBIGUOUS_ELSE_BLOCKER_
+#else
+# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT
+#endif
+
+// Use this annotation at the end of a struct/class definition to
+// prevent the compiler from optimizing away instances that are never
+// used.  This is useful when all interesting logic happens inside the
+// c'tor and / or d'tor.  Example:
+//
+//   struct Foo {
+//     Foo() { ... }
+//   } GTEST_ATTRIBUTE_UNUSED_;
+//
+// Also use it after a variable or parameter declaration to tell the
+// compiler the variable/parameter does not have to be used.
+#if defined(__GNUC__) && !defined(COMPILER_ICC)
+# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
+#else
+# define GTEST_ATTRIBUTE_UNUSED_
+#endif
+
+// A macro to disallow operator=
+// This should be used in the private: declarations for a class.
+#define GTEST_DISALLOW_ASSIGN_(type)\
+  void operator=(type const &)
+
+// A macro to disallow copy constructor and operator=
+// This should be used in the private: declarations for a class.
+#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
+  type(type const &);\
+  GTEST_DISALLOW_ASSIGN_(type)
+
+// Tell the compiler to warn about unused return values for functions declared
+// with this macro.  The macro should be used on function declarations
+// following the argument list:
+//
+//   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
+#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)
+# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
+#else
+# define GTEST_MUST_USE_RESULT_
+#endif  // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
+
+// Determine whether the compiler supports Microsoft's Structured Exception
+// Handling.  This is supported by several Windows compilers but generally
+// does not exist on any other system.
+#ifndef GTEST_HAS_SEH
+// The user didn't tell us, so we need to figure it out.
+
+# if defined(_MSC_VER) || defined(__BORLANDC__)
+// These two compilers are known to support SEH.
+#  define GTEST_HAS_SEH 1
+# else
+// Assume no SEH.
+#  define GTEST_HAS_SEH 0
+# endif
+
+#endif  // GTEST_HAS_SEH
+
+#ifdef _MSC_VER
+
+# if GTEST_LINKED_AS_SHARED_LIBRARY
+#  define GTEST_API_ __declspec(dllimport)
+# elif GTEST_CREATE_SHARED_LIBRARY
+#  define GTEST_API_ __declspec(dllexport)
+# endif
+
+#endif  // _MSC_VER
+
+#ifndef GTEST_API_
+# define GTEST_API_
+#endif
+
+#ifdef __GNUC__
+// Ask the compiler to never inline a given function.
+# define GTEST_NO_INLINE_ __attribute__((noinline))
+#else
+# define GTEST_NO_INLINE_
+#endif
+
+// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
+#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
+# define GTEST_HAS_CXXABI_H_ 1
+#else
+# define GTEST_HAS_CXXABI_H_ 0
+#endif
+
+namespace testing {
+
+class Message;
+
+namespace internal {
+
+// A secret type that Google Test users don't know about.  It has no
+// definition on purpose.  Therefore it's impossible to create a
+// Secret object, which is what we want.
+class Secret;
+
+// The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time
+// expression is true. For example, you could use it to verify the
+// size of a static array:
+//
+//   GTEST_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
+//                         content_type_names_incorrect_size);
+//
+// or to make sure a struct is smaller than a certain size:
+//
+//   GTEST_COMPILE_ASSERT_(sizeof(foo) < 128, foo_too_large);
+//
+// The second argument to the macro is the name of the variable. If
+// the expression is false, most compilers will issue a warning/error
+// containing the name of the variable.
+
+template <bool>
+struct CompileAssert {
+};
+
+#define GTEST_COMPILE_ASSERT_(expr, msg) \
+  typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \
+      msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_
+
+// Implementation details of GTEST_COMPILE_ASSERT_:
+//
+// - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1
+//   elements (and thus is invalid) when the expression is false.
+//
+// - The simpler definition
+//
+//    #define GTEST_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1]
+//
+//   does not work, as gcc supports variable-length arrays whose sizes
+//   are determined at run-time (this is gcc's extension and not part
+//   of the C++ standard).  As a result, gcc fails to reject the
+//   following code with the simple definition:
+//
+//     int foo;
+//     GTEST_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo is
+//                                      // not a compile-time constant.
+//
+// - By using the type CompileAssert<(bool(expr))>, we ensures that
+//   expr is a compile-time constant.  (Template arguments must be
+//   determined at compile-time.)
+//
+// - The outter parentheses in CompileAssert<(bool(expr))> are necessary
+//   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written
+//
+//     CompileAssert<bool(expr)>
+//
+//   instead, these compilers will refuse to compile
+//
+//     GTEST_COMPILE_ASSERT_(5 > 0, some_message);
+//
+//   (They seem to think the ">" in "5 > 0" marks the end of the
+//   template argument list.)
+//
+// - The array size is (bool(expr) ? 1 : -1), instead of simply
+//
+//     ((expr) ? 1 : -1).
+//
+//   This is to avoid running into a bug in MS VC 7.1, which
+//   causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
+
+// StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
+//
+// This template is declared, but intentionally undefined.
+template <typename T1, typename T2>
+struct StaticAssertTypeEqHelper;
+
+template <typename T>
+struct StaticAssertTypeEqHelper<T, T> {};
+
+#if GTEST_HAS_GLOBAL_STRING
+typedef ::string string;
+#else
+typedef ::std::string string;
+#endif  // GTEST_HAS_GLOBAL_STRING
+
+#if GTEST_HAS_GLOBAL_WSTRING
+typedef ::wstring wstring;
+#elif GTEST_HAS_STD_WSTRING
+typedef ::std::wstring wstring;
+#endif  // GTEST_HAS_GLOBAL_WSTRING
+
+// A helper for suppressing warnings on constant condition.  It just
+// returns 'condition'.
+GTEST_API_ bool IsTrue(bool condition);
+
+// Defines scoped_ptr.
+
+// This implementation of scoped_ptr is PARTIAL - it only contains
+// enough stuff to satisfy Google Test's need.
+template <typename T>
+class scoped_ptr {
+ public:
+  typedef T element_type;
+
+  explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
+  ~scoped_ptr() { reset(); }
+
+  T& operator*() const { return *ptr_; }
+  T* operator->() const { return ptr_; }
+  T* get() const { return ptr_; }
+
+  T* release() {
+    T* const ptr = ptr_;
+    ptr_ = NULL;
+    return ptr;
+  }
+
+  void reset(T* p = NULL) {
+    if (p != ptr_) {
+      if (IsTrue(sizeof(T) > 0)) {  // Makes sure T is a complete type.
+        delete ptr_;
+      }
+      ptr_ = p;
+    }
+  }
+
+ private:
+  T* ptr_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
+};
+
+// Defines RE.
+
+// A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended
+// Regular Expression syntax.
+class GTEST_API_ RE {
+ public:
+  // A copy constructor is required by the Standard to initialize object
+  // references from r-values.
+  RE(const RE& other) { Init(other.pattern()); }
+
+  // Constructs an RE from a string.
+  RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT
+
+#if GTEST_HAS_GLOBAL_STRING
+
+  RE(const ::string& regex) { Init(regex.c_str()); }  // NOLINT
+
+#endif  // GTEST_HAS_GLOBAL_STRING
+
+  RE(const char* regex) { Init(regex); }  // NOLINT
+  ~RE();
+
+  // Returns the string representation of the regex.
+  const char* pattern() const { return pattern_; }
+
+  // FullMatch(str, re) returns true iff regular expression re matches
+  // the entire str.
+  // PartialMatch(str, re) returns true iff regular expression re
+  // matches a substring of str (including str itself).
+  //
+  // TODO(wan@google.com): make FullMatch() and PartialMatch() work
+  // when str contains NUL characters.
+  static bool FullMatch(const ::std::string& str, const RE& re) {
+    return FullMatch(str.c_str(), re);
+  }
+  static bool PartialMatch(const ::std::string& str, const RE& re) {
+    return PartialMatch(str.c_str(), re);
+  }
+
+#if GTEST_HAS_GLOBAL_STRING
+
+  static bool FullMatch(const ::string& str, const RE& re) {
+    return FullMatch(str.c_str(), re);
+  }
+  static bool PartialMatch(const ::string& str, const RE& re) {
+    return PartialMatch(str.c_str(), re);
+  }
+
+#endif  // GTEST_HAS_GLOBAL_STRING
+
+  static bool FullMatch(const char* str, const RE& re);
+  static bool PartialMatch(const char* str, const RE& re);
+
+ private:
+  void Init(const char* regex);
+
+  // We use a const char* instead of an std::string, as Google Test used to be
+  // used where std::string is not available.  TODO(wan@google.com): change to
+  // std::string.
+  const char* pattern_;
+  bool is_valid_;
+
+#if GTEST_USES_POSIX_RE
+
+  regex_t full_regex_;     // For FullMatch().
+  regex_t partial_regex_;  // For PartialMatch().
+
+#else  // GTEST_USES_SIMPLE_RE
+
+  const char* full_pattern_;  // For FullMatch();
+
+#endif
+
+  GTEST_DISALLOW_ASSIGN_(RE);
+};
+
+// Formats a source file path and a line number as they would appear
+// in an error message from the compiler used to compile this code.
+GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
+
+// Formats a file location for compiler-independent XML output.
+// Although this function is not platform dependent, we put it next to
+// FormatFileLocation in order to contrast the two functions.
+GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
+                                                               int line);
+
+// Defines logging utilities:
+//   GTEST_LOG_(severity) - logs messages at the specified severity level. The
+//                          message itself is streamed into the macro.
+//   LogToStderr()  - directs all log messages to stderr.
+//   FlushInfoLog() - flushes informational log messages.
+
+enum GTestLogSeverity {
+  GTEST_INFO,
+  GTEST_WARNING,
+  GTEST_ERROR,
+  GTEST_FATAL
+};
+
+// Formats log entry severity, provides a stream object for streaming the
+// log message, and terminates the message with a newline when going out of
+// scope.
+class GTEST_API_ GTestLog {
+ public:
+  GTestLog(GTestLogSeverity severity, const char* file, int line);
+
+  // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
+  ~GTestLog();
+
+  ::std::ostream& GetStream() { return ::std::cerr; }
+
+ private:
+  const GTestLogSeverity severity_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
+};
+
+#define GTEST_LOG_(severity) \
+    ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
+                                  __FILE__, __LINE__).GetStream()
+
+inline void LogToStderr() {}
+inline void FlushInfoLog() { fflush(NULL); }
+
+// INTERNAL IMPLEMENTATION - DO NOT USE.
+//
+// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
+// is not satisfied.
+//  Synopsys:
+//    GTEST_CHECK_(boolean_condition);
+//     or
+//    GTEST_CHECK_(boolean_condition) << "Additional message";
+//
+//    This checks the condition and if the condition is not satisfied
+//    it prints message about the condition violation, including the
+//    condition itself, plus additional message streamed into it, if any,
+//    and then it aborts the program. It aborts the program irrespective of
+//    whether it is built in the debug mode or not.
+#define GTEST_CHECK_(condition) \
+    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+    if (::testing::internal::IsTrue(condition)) \
+      ; \
+    else \
+      GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
+
+// An all-mode assert to verify that the given POSIX-style function
+// call returns 0 (indicating success).  Known limitation: this
+// doesn't expand to a balanced 'if' statement, so enclose the macro
+// in {} if you need to use it as the only statement in an 'if'
+// branch.
+#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
+  if (const int gtest_error = (posix_call)) \
+    GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
+                      << gtest_error
+
+// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
+//
+// Use ImplicitCast_ as a safe version of static_cast for upcasting in
+// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
+// const Foo*).  When you use ImplicitCast_, the compiler checks that
+// the cast is safe.  Such explicit ImplicitCast_s are necessary in
+// surprisingly many situations where C++ demands an exact type match
+// instead of an argument type convertable to a target type.
+//
+// The syntax for using ImplicitCast_ is the same as for static_cast:
+//
+//   ImplicitCast_<ToType>(expr)
+//
+// ImplicitCast_ would have been part of the C++ standard library,
+// but the proposal was submitted too late.  It will probably make
+// its way into the language in the future.
+//
+// This relatively ugly name is intentional. It prevents clashes with
+// similar functions users may have (e.g., implicit_cast). The internal
+// namespace alone is not enough because the function can be found by ADL.
+template<typename To>
+inline To ImplicitCast_(To x) { return x; }
+
+// When you upcast (that is, cast a pointer from type Foo to type
+// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
+// always succeed.  When you downcast (that is, cast a pointer from
+// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
+// how do you know the pointer is really of type SubclassOfFoo?  It
+// could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,
+// when you downcast, you should use this macro.  In debug mode, we
+// use dynamic_cast<> to double-check the downcast is legal (we die
+// if it's not).  In normal mode, we do the efficient static_cast<>
+// instead.  Thus, it's important to test in debug mode to make sure
+// the cast is legal!
+//    This is the only place in the code we should use dynamic_cast<>.
+// In particular, you SHOULDN'T be using dynamic_cast<> in order to
+// do RTTI (eg code like this:
+//    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
+//    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
+// You should design the code some other way not to need this.
+//
+// This relatively ugly name is intentional. It prevents clashes with
+// similar functions users may have (e.g., down_cast). The internal
+// namespace alone is not enough because the function can be found by ADL.
+template<typename To, typename From>  // use like this: DownCast_<T*>(foo);
+inline To DownCast_(From* f) {  // so we only accept pointers
+  // Ensures that To is a sub-type of From *.  This test is here only
+  // for compile-time type checking, and has no overhead in an
+  // optimized build at run-time, as it will be optimized away
+  // completely.
+  if (false) {
+    const To to = NULL;
+    ::testing::internal::ImplicitCast_<From*>(to);
+  }
+
+#if GTEST_HAS_RTTI
+  // RTTI: debug mode only!
+  GTEST_CHECK_(f == NULL || dynamic_cast<To>(f) != NULL);
+#endif
+  return static_cast<To>(f);
+}
+
+// Downcasts the pointer of type Base to Derived.
+// Derived must be a subclass of Base. The parameter MUST
+// point to a class of type Derived, not any subclass of it.
+// When RTTI is available, the function performs a runtime
+// check to enforce this.
+template <class Derived, class Base>
+Derived* CheckedDowncastToActualType(Base* base) {
+#if GTEST_HAS_RTTI
+  GTEST_CHECK_(typeid(*base) == typeid(Derived));
+  return dynamic_cast<Derived*>(base);  // NOLINT
+#else
+  return static_cast<Derived*>(base);  // Poor man's downcast.
+#endif
+}
+
+#if GTEST_HAS_STREAM_REDIRECTION
+
+// Defines the stderr capturer:
+//   CaptureStdout     - starts capturing stdout.
+//   GetCapturedStdout - stops capturing stdout and returns the captured string.
+//   CaptureStderr     - starts capturing stderr.
+//   GetCapturedStderr - stops capturing stderr and returns the captured string.
+//
+GTEST_API_ void CaptureStdout();
+GTEST_API_ std::string GetCapturedStdout();
+GTEST_API_ void CaptureStderr();
+GTEST_API_ std::string GetCapturedStderr();
+
+#endif  // GTEST_HAS_STREAM_REDIRECTION
+
+
+#if GTEST_HAS_DEATH_TEST
+
+const ::std::vector<testing::internal::string>& GetInjectableArgvs();
+void SetInjectableArgvs(const ::std::vector<testing::internal::string>*
+                             new_argvs);
+
+// A copy of all command line arguments.  Set by InitGoogleTest().
+extern ::std::vector<testing::internal::string> g_argvs;
+
+#endif  // GTEST_HAS_DEATH_TEST
+
+// Defines synchronization primitives.
+
+#if GTEST_HAS_PTHREAD
+
+// Sleeps for (roughly) n milli-seconds.  This function is only for
+// testing Google Test's own constructs.  Don't use it in user tests,
+// either directly or indirectly.
+inline void SleepMilliseconds(int n) {
+  const timespec time = {
+    0,                  // 0 seconds.
+    n * 1000L * 1000L,  // And n ms.
+  };
+  nanosleep(&time, NULL);
+}
+
+// Allows a controller thread to pause execution of newly created
+// threads until notified.  Instances of this class must be created
+// and destroyed in the controller thread.
+//
+// This class is only for testing Google Test's own constructs. Do not
+// use it in user tests, either directly or indirectly.
+class Notification {
+ public:
+  Notification() : notified_(false) {
+    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));
+  }
+  ~Notification() {
+    pthread_mutex_destroy(&mutex_);
+  }
+
+  // Notifies all threads created with this notification to start. Must
+  // be called from the controller thread.
+  void Notify() {
+    pthread_mutex_lock(&mutex_);
+    notified_ = true;
+    pthread_mutex_unlock(&mutex_);
+  }
+
+  // Blocks until the controller thread notifies. Must be called from a test
+  // thread.
+  void WaitForNotification() {
+    for (;;) {
+      pthread_mutex_lock(&mutex_);
+      const bool notified = notified_;
+      pthread_mutex_unlock(&mutex_);
+      if (notified)
+        break;
+      SleepMilliseconds(10);
+    }
+  }
+
+ private:
+  pthread_mutex_t mutex_;
+  bool notified_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
+};
+
+// As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
+// Consequently, it cannot select a correct instantiation of ThreadWithParam
+// in order to call its Run(). Introducing ThreadWithParamBase as a
+// non-templated base class for ThreadWithParam allows us to bypass this
+// problem.
+class ThreadWithParamBase {
+ public:
+  virtual ~ThreadWithParamBase() {}
+  virtual void Run() = 0;
+};
+
+// pthread_create() accepts a pointer to a function type with the C linkage.
+// According to the Standard (7.5/1), function types with different linkages
+// are different even if they are otherwise identical.  Some compilers (for
+// example, SunStudio) treat them as different types.  Since class methods
+// cannot be defined with C-linkage we need to define a free C-function to
+// pass into pthread_create().
+extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
+  static_cast<ThreadWithParamBase*>(thread)->Run();
+  return NULL;
+}
+
+// Helper class for testing Google Test's multi-threading constructs.
+// To use it, write:
+//
+//   void ThreadFunc(int param) { /* Do things with param */ }
+//   Notification thread_can_start;
+//   ...
+//   // The thread_can_start parameter is optional; you can supply NULL.
+//   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);
+//   thread_can_start.Notify();
+//
+// These classes are only for testing Google Test's own constructs. Do
+// not use them in user tests, either directly or indirectly.
+template <typename T>
+class ThreadWithParam : public ThreadWithParamBase {
+ public:
+  typedef void (*UserThreadFunc)(T);
+
+  ThreadWithParam(
+      UserThreadFunc func, T param, Notification* thread_can_start)
+      : func_(func),
+        param_(param),
+        thread_can_start_(thread_can_start),
+        finished_(false) {
+    ThreadWithParamBase* const base = this;
+    // The thread can be created only after all fields except thread_
+    // have been initialized.
+    GTEST_CHECK_POSIX_SUCCESS_(
+        pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));
+  }
+  ~ThreadWithParam() { Join(); }
+
+  void Join() {
+    if (!finished_) {
+      GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0));
+      finished_ = true;
+    }
+  }
+
+  virtual void Run() {
+    if (thread_can_start_ != NULL)
+      thread_can_start_->WaitForNotification();
+    func_(param_);
+  }
+
+ private:
+  const UserThreadFunc func_;  // User-supplied thread function.
+  const T param_;  // User-supplied parameter to the thread function.
+  // When non-NULL, used to block execution until the controller thread
+  // notifies.
+  Notification* const thread_can_start_;
+  bool finished_;  // true iff we know that the thread function has finished.
+  pthread_t thread_;  // The native thread object.
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
+};
+
+// MutexBase and Mutex implement mutex on pthreads-based platforms. They
+// are used in conjunction with class MutexLock:
+//
+//   Mutex mutex;
+//   ...
+//   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the end
+//                            // of the current scope.
+//
+// MutexBase implements behavior for both statically and dynamically
+// allocated mutexes.  Do not use MutexBase directly.  Instead, write
+// the following to define a static mutex:
+//
+//   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
+//
+// You can forward declare a static mutex like this:
+//
+//   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
+//
+// To create a dynamic mutex, just define an object of type Mutex.
+class MutexBase {
+ public:
+  // Acquires this mutex.
+  void Lock() {
+    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
+    owner_ = pthread_self();
+    has_owner_ = true;
+  }
+
+  // Releases this mutex.
+  void Unlock() {
+    // Since the lock is being released the owner_ field should no longer be
+    // considered valid. We don't protect writing to has_owner_ here, as it's
+    // the caller's responsibility to ensure that the current thread holds the
+    // mutex when this is called.
+    has_owner_ = false;
+    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
+  }
+
+  // Does nothing if the current thread holds the mutex. Otherwise, crashes
+  // with high probability.
+  void AssertHeld() const {
+    GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
+        << "The current thread is not holding the mutex @" << this;
+  }
+
+  // A static mutex may be used before main() is entered.  It may even
+  // be used before the dynamic initialization stage.  Therefore we
+  // must be able to initialize a static mutex object at link time.
+  // This means MutexBase has to be a POD and its member variables
+  // have to be public.
+ public:
+  pthread_mutex_t mutex_;  // The underlying pthread mutex.
+  // has_owner_ indicates whether the owner_ field below contains a valid thread
+  // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All
+  // accesses to the owner_ field should be protected by a check of this field.
+  // An alternative might be to memset() owner_ to all zeros, but there's no
+  // guarantee that a zero'd pthread_t is necessarily invalid or even different
+  // from pthread_self().
+  bool has_owner_;
+  pthread_t owner_;  // The thread holding the mutex.
+};
+
+// Forward-declares a static mutex.
+# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
+    extern ::testing::internal::MutexBase mutex
+
+// Defines and statically (i.e. at link time) initializes a static mutex.
+// The initialization list here does not explicitly initialize each field,
+// instead relying on default initialization for the unspecified fields. In
+// particular, the owner_ field (a pthread_t) is not explicitly initialized.
+// This allows initialization to work whether pthread_t is a scalar or struct.
+// The flag -Wmissing-field-initializers must not be specified for this to work.
+# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
+    ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false }
+
+// The Mutex class can only be used for mutexes created at runtime. It
+// shares its API with MutexBase otherwise.
+class Mutex : public MutexBase {
+ public:
+  Mutex() {
+    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));
+    has_owner_ = false;
+  }
+  ~Mutex() {
+    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
+  }
+
+ private:
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
+};
+
+// We cannot name this class MutexLock as the ctor declaration would
+// conflict with a macro named MutexLock, which is defined on some
+// platforms.  Hence the typedef trick below.
+class GTestMutexLock {
+ public:
+  explicit GTestMutexLock(MutexBase* mutex)
+      : mutex_(mutex) { mutex_->Lock(); }
+
+  ~GTestMutexLock() { mutex_->Unlock(); }
+
+ private:
+  MutexBase* const mutex_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
+};
+
+typedef GTestMutexLock MutexLock;
+
+// Helpers for ThreadLocal.
+
+// pthread_key_create() requires DeleteThreadLocalValue() to have
+// C-linkage.  Therefore it cannot be templatized to access
+// ThreadLocal<T>.  Hence the need for class
+// ThreadLocalValueHolderBase.
+class ThreadLocalValueHolderBase {
+ public:
+  virtual ~ThreadLocalValueHolderBase() {}
+};
+
+// Called by pthread to delete thread-local data stored by
+// pthread_setspecific().
+extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
+  delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
+}
+
+// Implements thread-local storage on pthreads-based systems.
+//
+//   // Thread 1
+//   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.
+//
+//   // Thread 2
+//   tl.set(150);  // Changes the value for thread 2 only.
+//   EXPECT_EQ(150, tl.get());
+//
+//   // Thread 1
+//   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.
+//   tl.set(200);
+//   EXPECT_EQ(200, tl.get());
+//
+// The template type argument T must have a public copy constructor.
+// In addition, the default ThreadLocal constructor requires T to have
+// a public default constructor.
+//
+// An object managed for a thread by a ThreadLocal instance is deleted
+// when the thread exits.  Or, if the ThreadLocal instance dies in
+// that thread, when the ThreadLocal dies.  It's the user's
+// responsibility to ensure that all other threads using a ThreadLocal
+// have exited when it dies, or the per-thread objects for those
+// threads will not be deleted.
+//
+// Google Test only uses global ThreadLocal objects.  That means they
+// will die after main() has returned.  Therefore, no per-thread
+// object managed by Google Test will be leaked as long as all threads
+// using Google Test have exited when main() returns.
+template <typename T>
+class ThreadLocal {
+ public:
+  ThreadLocal() : key_(CreateKey()),
+                  default_() {}
+  explicit ThreadLocal(const T& value) : key_(CreateKey()),
+                                         default_(value) {}
+
+  ~ThreadLocal() {
+    // Destroys the managed object for the current thread, if any.
+    DeleteThreadLocalValue(pthread_getspecific(key_));
+
+    // Releases resources associated with the key.  This will *not*
+    // delete managed objects for other threads.
+    GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
+  }
+
+  T* pointer() { return GetOrCreateValue(); }
+  const T* pointer() const { return GetOrCreateValue(); }
+  const T& get() const { return *pointer(); }
+  void set(const T& value) { *pointer() = value; }
+
+ private:
+  // Holds a value of type T.
+  class ValueHolder : public ThreadLocalValueHolderBase {
+   public:
+    explicit ValueHolder(const T& value) : value_(value) {}
+
+    T* pointer() { return &value_; }
+
+   private:
+    T value_;
+    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
+  };
+
+  static pthread_key_t CreateKey() {
+    pthread_key_t key;
+    // When a thread exits, DeleteThreadLocalValue() will be called on
+    // the object managed for that thread.
+    GTEST_CHECK_POSIX_SUCCESS_(
+        pthread_key_create(&key, &DeleteThreadLocalValue));
+    return key;
+  }
+
+  T* GetOrCreateValue() const {
+    ThreadLocalValueHolderBase* const holder =
+        static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
+    if (holder != NULL) {
+      return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
+    }
+
+    ValueHolder* const new_holder = new ValueHolder(default_);
+    ThreadLocalValueHolderBase* const holder_base = new_holder;
+    GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
+    return new_holder->pointer();
+  }
+
+  // A key pthreads uses for looking up per-thread values.
+  const pthread_key_t key_;
+  const T default_;  // The default value for each thread.
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
+};
+
+# define GTEST_IS_THREADSAFE 1
+
+#else  // GTEST_HAS_PTHREAD
+
+// A dummy implementation of synchronization primitives (mutex, lock,
+// and thread-local variable).  Necessary for compiling Google Test where
+// mutex is not supported - using Google Test in multiple threads is not
+// supported on such platforms.
+
+class Mutex {
+ public:
+  Mutex() {}
+  void Lock() {}
+  void Unlock() {}
+  void AssertHeld() const {}
+};
+
+# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
+  extern ::testing::internal::Mutex mutex
+
+# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
+
+class GTestMutexLock {
+ public:
+  explicit GTestMutexLock(Mutex*) {}  // NOLINT
+};
+
+typedef GTestMutexLock MutexLock;
+
+template <typename T>
+class ThreadLocal {
+ public:
+  ThreadLocal() : value_() {}
+  explicit ThreadLocal(const T& value) : value_(value) {}
+  T* pointer() { return &value_; }
+  const T* pointer() const { return &value_; }
+  const T& get() const { return value_; }
+  void set(const T& value) { value_ = value; }
+ private:
+  T value_;
+};
+
+// The above synchronization primitives have dummy implementations.
+// Therefore Google Test is not thread-safe.
+# define GTEST_IS_THREADSAFE 0
+
+#endif  // GTEST_HAS_PTHREAD
+
+// Returns the number of threads running in the process, or 0 to indicate that
+// we cannot detect it.
+GTEST_API_ size_t GetThreadCount();
+
+// Passing non-POD classes through ellipsis (...) crashes the ARM
+// compiler and generates a warning in Sun Studio.  The Nokia Symbian
+// and the IBM XL C/C++ compiler try to instantiate a copy constructor
+// for objects passed through ellipsis (...), failing for uncopyable
+// objects.  We define this to ensure that only POD is passed through
+// ellipsis on these systems.
+#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
+// We lose support for NULL detection where the compiler doesn't like
+// passing non-POD classes through ellipsis (...).
+# define GTEST_ELLIPSIS_NEEDS_POD_ 1
+#else
+# define GTEST_CAN_COMPARE_NULL 1
+#endif
+
+// The Nokia Symbian and IBM XL C/C++ compilers cannot decide between
+// const T& and const T* in a function template.  These compilers
+// _can_ decide between class template specializations for T and T*,
+// so a tr1::type_traits-like is_pointer works.
+#if defined(__SYMBIAN32__) || defined(__IBMCPP__)
+# define GTEST_NEEDS_IS_POINTER_ 1
+#endif
+
+template <bool bool_value>
+struct bool_constant {
+  typedef bool_constant<bool_value> type;
+  static const bool value = bool_value;
+};
+template <bool bool_value> const bool bool_constant<bool_value>::value;
+
+typedef bool_constant<false> false_type;
+typedef bool_constant<true> true_type;
+
+template <typename T>
+struct is_pointer : public false_type {};
+
+template <typename T>
+struct is_pointer<T*> : public true_type {};
+
+template <typename Iterator>
+struct IteratorTraits {
+  typedef typename Iterator::value_type value_type;
+};
+
+template <typename T>
+struct IteratorTraits<T*> {
+  typedef T value_type;
+};
+
+template <typename T>
+struct IteratorTraits<const T*> {
+  typedef T value_type;
+};
+
+#if GTEST_OS_WINDOWS
+# define GTEST_PATH_SEP_ "\\"
+# define GTEST_HAS_ALT_PATH_SEP_ 1
+// The biggest signed integer type the compiler supports.
+typedef __int64 BiggestInt;
+#else
+# define GTEST_PATH_SEP_ "/"
+# define GTEST_HAS_ALT_PATH_SEP_ 0
+typedef long long BiggestInt;  // NOLINT
+#endif  // GTEST_OS_WINDOWS
+
+// Utilities for char.
+
+// isspace(int ch) and friends accept an unsigned char or EOF.  char
+// may be signed, depending on the compiler (or compiler flags).
+// Therefore we need to cast a char to unsigned char before calling
+// isspace(), etc.
+
+inline bool IsAlpha(char ch) {
+  return isalpha(static_cast<unsigned char>(ch)) != 0;
+}
+inline bool IsAlNum(char ch) {
+  return isalnum(static_cast<unsigned char>(ch)) != 0;
+}
+inline bool IsDigit(char ch) {
+  return isdigit(static_cast<unsigned char>(ch)) != 0;
+}
+inline bool IsLower(char ch) {
+  return islower(static_cast<unsigned char>(ch)) != 0;
+}
+inline bool IsSpace(char ch) {
+  return isspace(static_cast<unsigned char>(ch)) != 0;
+}
+inline bool IsUpper(char ch) {
+  return isupper(static_cast<unsigned char>(ch)) != 0;
+}
+inline bool IsXDigit(char ch) {
+  return isxdigit(static_cast<unsigned char>(ch)) != 0;
+}
+inline bool IsXDigit(wchar_t ch) {
+  const unsigned char low_byte = static_cast<unsigned char>(ch);
+  return ch == low_byte && isxdigit(low_byte) != 0;
+}
+
+inline char ToLower(char ch) {
+  return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
+}
+inline char ToUpper(char ch) {
+  return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
+}
+
+// The testing::internal::posix namespace holds wrappers for common
+// POSIX functions.  These wrappers hide the differences between
+// Windows/MSVC and POSIX systems.  Since some compilers define these
+// standard functions as macros, the wrapper cannot have the same name
+// as the wrapped function.
+
+namespace posix {
+
+// Functions with a different name on Windows.
+
+#if GTEST_OS_WINDOWS
+
+typedef struct _stat StatStruct;
+
+# ifdef __BORLANDC__
+inline int IsATTY(int fd) { return isatty(fd); }
+inline int StrCaseCmp(const char* s1, const char* s2) {
+  return stricmp(s1, s2);
+}
+inline char* StrDup(const char* src) { return strdup(src); }
+# else  // !__BORLANDC__
+#  if GTEST_OS_WINDOWS_MOBILE
+inline int IsATTY(int /* fd */) { return 0; }
+#  else
+inline int IsATTY(int fd) { return _isatty(fd); }
+#  endif  // GTEST_OS_WINDOWS_MOBILE
+inline int StrCaseCmp(const char* s1, const char* s2) {
+  return _stricmp(s1, s2);
+}
+inline char* StrDup(const char* src) { return _strdup(src); }
+# endif  // __BORLANDC__
+
+# if GTEST_OS_WINDOWS_MOBILE
+inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
+// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
+// time and thus not defined there.
+# else
+inline int FileNo(FILE* file) { return _fileno(file); }
+inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
+inline int RmDir(const char* dir) { return _rmdir(dir); }
+inline bool IsDir(const StatStruct& st) {
+  return (_S_IFDIR & st.st_mode) != 0;
+}
+# endif  // GTEST_OS_WINDOWS_MOBILE
+
+#else
+
+typedef struct stat StatStruct;
+
+inline int FileNo(FILE* file) { return fileno(file); }
+inline int IsATTY(int fd) { return isatty(fd); }
+inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
+inline int StrCaseCmp(const char* s1, const char* s2) {
+  return strcasecmp(s1, s2);
+}
+inline char* StrDup(const char* src) { return strdup(src); }
+inline int RmDir(const char* dir) { return rmdir(dir); }
+inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
+
+#endif  // GTEST_OS_WINDOWS
+
+// Functions deprecated by MSVC 8.0.
+
+#ifdef _MSC_VER
+// Temporarily disable warning 4996 (deprecated function).
+# pragma warning(push)
+# pragma warning(disable:4996)
+#endif
+
+inline const char* StrNCpy(char* dest, const char* src, size_t n) {
+  return strncpy(dest, src, n);
+}
+
+// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
+// StrError() aren't needed on Windows CE at this time and thus not
+// defined there.
+
+#if !GTEST_OS_WINDOWS_MOBILE
+inline int ChDir(const char* dir) { return chdir(dir); }
+#endif
+inline FILE* FOpen(const char* path, const char* mode) {
+  return fopen(path, mode);
+}
+#if !GTEST_OS_WINDOWS_MOBILE
+inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
+  return freopen(path, mode, stream);
+}
+inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
+#endif
+inline int FClose(FILE* fp) { return fclose(fp); }
+#if !GTEST_OS_WINDOWS_MOBILE
+inline int Read(int fd, void* buf, unsigned int count) {
+  return static_cast<int>(read(fd, buf, count));
+}
+inline int Write(int fd, const void* buf, unsigned int count) {
+  return static_cast<int>(write(fd, buf, count));
+}
+inline int Close(int fd) { return close(fd); }
+inline const char* StrError(int errnum) { return strerror(errnum); }
+#endif
+inline const char* GetEnv(const char* name) {
+#if GTEST_OS_WINDOWS_MOBILE
+  // We are on Windows CE, which has no environment variables.
+  return NULL;
+#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
+  // Environment variables which we programmatically clear will be set to the
+  // empty string rather than unset (NULL).  Handle that case.
+  const char* const env = getenv(name);
+  return (env != NULL && env[0] != '\0') ? env : NULL;
+#else
+  return getenv(name);
+#endif
+}
+
+#ifdef _MSC_VER
+# pragma warning(pop)  // Restores the warning state.
+#endif
+
+#if GTEST_OS_WINDOWS_MOBILE
+// Windows CE has no C library. The abort() function is used in
+// several places in Google Test. This implementation provides a reasonable
+// imitation of standard behaviour.
+void Abort();
+#else
+inline void Abort() { abort(); }
+#endif  // GTEST_OS_WINDOWS_MOBILE
+
+}  // namespace posix
+
+// MSVC "deprecates" snprintf and issues warnings wherever it is used.  In
+// order to avoid these warnings, we need to use _snprintf or _snprintf_s on
+// MSVC-based platforms.  We map the GTEST_SNPRINTF_ macro to the appropriate
+// function in order to achieve that.  We use macro definition here because
+// snprintf is a variadic function.
+#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
+// MSVC 2005 and above support variadic macros.
+# define GTEST_SNPRINTF_(buffer, size, format, ...) \
+     _snprintf_s(buffer, size, size, format, __VA_ARGS__)
+#elif defined(_MSC_VER)
+// Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't
+// complain about _snprintf.
+# define GTEST_SNPRINTF_ _snprintf
+#else
+# define GTEST_SNPRINTF_ snprintf
+#endif
+
+// The maximum number a BiggestInt can represent.  This definition
+// works no matter BiggestInt is represented in one's complement or
+// two's complement.
+//
+// We cannot rely on numeric_limits in STL, as __int64 and long long
+// are not part of standard C++ and numeric_limits doesn't need to be
+// defined for them.
+const BiggestInt kMaxBiggestInt =
+    ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
+
+// This template class serves as a compile-time function from size to
+// type.  It maps a size in bytes to a primitive type with that
+// size. e.g.
+//
+//   TypeWithSize<4>::UInt
+//
+// is typedef-ed to be unsigned int (unsigned integer made up of 4
+// bytes).
+//
+// Such functionality should belong to STL, but I cannot find it
+// there.
+//
+// Google Test uses this class in the implementation of floating-point
+// comparison.
+//
+// For now it only handles UInt (unsigned int) as that's all Google Test
+// needs.  Other types can be easily added in the future if need
+// arises.
+template <size_t size>
+class TypeWithSize {
+ public:
+  // This prevents the user from using TypeWithSize<N> with incorrect
+  // values of N.
+  typedef void UInt;
+};
+
+// The specialization for size 4.
+template <>
+class TypeWithSize<4> {
+ public:
+  // unsigned int has size 4 in both gcc and MSVC.
+  //
+  // As base/basictypes.h doesn't compile on Windows, we cannot use
+  // uint32, uint64, and etc here.
+  typedef int Int;
+  typedef unsigned int UInt;
+};
+
+// The specialization for size 8.
+template <>
+class TypeWithSize<8> {
+ public:
+#if GTEST_OS_WINDOWS
+  typedef __int64 Int;
+  typedef unsigned __int64 UInt;
+#else
+  typedef long long Int;  // NOLINT
+  typedef unsigned long long UInt;  // NOLINT
+#endif  // GTEST_OS_WINDOWS
+};
+
+// Integer types of known sizes.
+typedef TypeWithSize<4>::Int Int32;
+typedef TypeWithSize<4>::UInt UInt32;
+typedef TypeWithSize<8>::Int Int64;
+typedef TypeWithSize<8>::UInt UInt64;
+typedef TypeWithSize<8>::Int TimeInMillis;  // Represents time in milliseconds.
+
+// Utilities for command line flags and environment variables.
+
+// Macro for referencing flags.
+#define GTEST_FLAG(name) FLAGS_gtest_##name
+
+// Macros for declaring flags.
+#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
+#define GTEST_DECLARE_int32_(name) \
+    GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
+#define GTEST_DECLARE_string_(name) \
+    GTEST_API_ extern ::std::string GTEST_FLAG(name)
+
+// Macros for defining flags.
+#define GTEST_DEFINE_bool_(name, default_val, doc) \
+    GTEST_API_ bool GTEST_FLAG(name) = (default_val)
+#define GTEST_DEFINE_int32_(name, default_val, doc) \
+    GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
+#define GTEST_DEFINE_string_(name, default_val, doc) \
+    GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
+
+// Thread annotations
+#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
+#define GTEST_LOCK_EXCLUDED_(locks)
+
+// Parses 'str' for a 32-bit signed integer.  If successful, writes the result
+// to *value and returns true; otherwise leaves *value unchanged and returns
+// false.
+// TODO(chandlerc): Find a better way to refactor flag and environment parsing
+// out of both gtest-port.cc and gtest.cc to avoid exporting this utility
+// function.
+bool ParseInt32(const Message& src_text, const char* str, Int32* value);
+
+// Parses a bool/Int32/string from the environment variable
+// corresponding to the given Google Test flag.
+bool BoolFromGTestEnv(const char* flag, bool default_val);
+GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
+const char* StringFromGTestEnv(const char* flag, const char* default_val);
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-string.h b/test/fmw/gtest/include/gtest/internal/gtest-string.h
new file mode 100644
index 0000000..97f1a7f
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-string.h
@@ -0,0 +1,167 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file declares the String class and functions used internally by
+// Google Test.  They are subject to change without notice. They should not used
+// by code external to Google Test.
+//
+// This header file is #included by <gtest/internal/gtest-internal.h>.
+// It should not be #included by other files.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
+
+#ifdef __BORLANDC__
+// string.h is not guaranteed to provide strcpy on C++ Builder.
+# include <mem.h>
+#endif
+
+#include <string.h>
+#include <string>
+
+#include "gtest/internal/gtest-port.h"
+
+namespace testing {
+namespace internal {
+
+// String - an abstract class holding static string utilities.
+class GTEST_API_ String {
+ public:
+  // Static utility methods
+
+  // Clones a 0-terminated C string, allocating memory using new.  The
+  // caller is responsible for deleting the return value using
+  // delete[].  Returns the cloned string, or NULL if the input is
+  // NULL.
+  //
+  // This is different from strdup() in string.h, which allocates
+  // memory using malloc().
+  static const char* CloneCString(const char* c_str);
+
+#if GTEST_OS_WINDOWS_MOBILE
+  // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
+  // able to pass strings to Win32 APIs on CE we need to convert them
+  // to 'Unicode', UTF-16.
+
+  // Creates a UTF-16 wide string from the given ANSI string, allocating
+  // memory using new. The caller is responsible for deleting the return
+  // value using delete[]. Returns the wide string, or NULL if the
+  // input is NULL.
+  //
+  // The wide string is created using the ANSI codepage (CP_ACP) to
+  // match the behaviour of the ANSI versions of Win32 calls and the
+  // C runtime.
+  static LPCWSTR AnsiToUtf16(const char* c_str);
+
+  // Creates an ANSI string from the given wide string, allocating
+  // memory using new. The caller is responsible for deleting the return
+  // value using delete[]. Returns the ANSI string, or NULL if the
+  // input is NULL.
+  //
+  // The returned string is created using the ANSI codepage (CP_ACP) to
+  // match the behaviour of the ANSI versions of Win32 calls and the
+  // C runtime.
+  static const char* Utf16ToAnsi(LPCWSTR utf16_str);
+#endif
+
+  // Compares two C strings.  Returns true iff they have the same content.
+  //
+  // Unlike strcmp(), this function can handle NULL argument(s).  A
+  // NULL C string is considered different to any non-NULL C string,
+  // including the empty string.
+  static bool CStringEquals(const char* lhs, const char* rhs);
+
+  // Converts a wide C string to a String using the UTF-8 encoding.
+  // NULL will be converted to "(null)".  If an error occurred during
+  // the conversion, "(failed to convert from wide string)" is
+  // returned.
+  static std::string ShowWideCString(const wchar_t* wide_c_str);
+
+  // Compares two wide C strings.  Returns true iff they have the same
+  // content.
+  //
+  // Unlike wcscmp(), this function can handle NULL argument(s).  A
+  // NULL C string is considered different to any non-NULL C string,
+  // including the empty string.
+  static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
+
+  // Compares two C strings, ignoring case.  Returns true iff they
+  // have the same content.
+  //
+  // Unlike strcasecmp(), this function can handle NULL argument(s).
+  // A NULL C string is considered different to any non-NULL C string,
+  // including the empty string.
+  static bool CaseInsensitiveCStringEquals(const char* lhs,
+                                           const char* rhs);
+
+  // Compares two wide C strings, ignoring case.  Returns true iff they
+  // have the same content.
+  //
+  // Unlike wcscasecmp(), this function can handle NULL argument(s).
+  // A NULL C string is considered different to any non-NULL wide C string,
+  // including the empty string.
+  // NB: The implementations on different platforms slightly differ.
+  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
+  // environment variable. On GNU platform this method uses wcscasecmp
+  // which compares according to LC_CTYPE category of the current locale.
+  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
+  // current locale.
+  static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
+                                               const wchar_t* rhs);
+
+  // Returns true iff the given string ends with the given suffix, ignoring
+  // case. Any string is considered to end with an empty suffix.
+  static bool EndsWithCaseInsensitive(
+      const std::string& str, const std::string& suffix);
+
+  // Formats an int value as "%02d".
+  static std::string FormatIntWidth2(int value);  // "%02d" for width == 2
+
+  // Formats an int value as "%X".
+  static std::string FormatHexInt(int value);
+
+  // Formats a byte as "%02X".
+  static std::string FormatByte(unsigned char value);
+
+ private:
+  String();  // Not meant to be instantiated.
+};  // class String
+
+// Gets the content of the stringstream's buffer as an std::string.  Each '\0'
+// character in the buffer is replaced with "\\0".
+GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-tuple.h b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h
new file mode 100644
index 0000000..7b3dfc3
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h
@@ -0,0 +1,1012 @@
+// This file was GENERATED by command:
+//     pump.py gtest-tuple.h.pump
+// DO NOT EDIT BY HAND!!!
+
+// Copyright 2009 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
+
+#include <utility>  // For ::std::pair.
+
+// The compiler used in Symbian has a bug that prevents us from declaring the
+// tuple template as a friend (it complains that tuple is redefined).  This
+// hack bypasses the bug by declaring the members that should otherwise be
+// private as public.
+// Sun Studio versions < 12 also have the above bug.
+#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
+# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
+#else
+# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
+    template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
+   private:
+#endif
+
+// GTEST_n_TUPLE_(T) is the type of an n-tuple.
+#define GTEST_0_TUPLE_(T) tuple<>
+#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
+    void, void, void>
+#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
+    void, void, void>
+#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
+    void, void, void>
+#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
+    void, void, void>
+#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
+    void, void, void>
+#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
+    void, void, void>
+#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
+    void, void, void>
+#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
+    T##7, void, void>
+#define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
+    T##7, T##8, void>
+#define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
+    T##7, T##8, T##9>
+
+// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
+#define GTEST_0_TYPENAMES_(T)
+#define GTEST_1_TYPENAMES_(T) typename T##0
+#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
+#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
+#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
+    typename T##3
+#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
+    typename T##3, typename T##4
+#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
+    typename T##3, typename T##4, typename T##5
+#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
+    typename T##3, typename T##4, typename T##5, typename T##6
+#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
+    typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
+#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
+    typename T##3, typename T##4, typename T##5, typename T##6, \
+    typename T##7, typename T##8
+#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
+    typename T##3, typename T##4, typename T##5, typename T##6, \
+    typename T##7, typename T##8, typename T##9
+
+// In theory, defining stuff in the ::std namespace is undefined
+// behavior.  We can do this as we are playing the role of a standard
+// library vendor.
+namespace std {
+namespace tr1 {
+
+template <typename T0 = void, typename T1 = void, typename T2 = void,
+    typename T3 = void, typename T4 = void, typename T5 = void,
+    typename T6 = void, typename T7 = void, typename T8 = void,
+    typename T9 = void>
+class tuple;
+
+// Anything in namespace gtest_internal is Google Test's INTERNAL
+// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
+namespace gtest_internal {
+
+// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
+template <typename T>
+struct ByRef { typedef const T& type; };  // NOLINT
+template <typename T>
+struct ByRef<T&> { typedef T& type; };  // NOLINT
+
+// A handy wrapper for ByRef.
+#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
+
+// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This
+// is the same as tr1::add_reference<T>::type.
+template <typename T>
+struct AddRef { typedef T& type; };  // NOLINT
+template <typename T>
+struct AddRef<T&> { typedef T& type; };  // NOLINT
+
+// A handy wrapper for AddRef.
+#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
+
+// A helper for implementing get<k>().
+template <int k> class Get;
+
+// A helper for implementing tuple_element<k, T>.  kIndexValid is true
+// iff k < the number of fields in tuple type T.
+template <bool kIndexValid, int kIndex, class Tuple>
+struct TupleElement;
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 0, GTEST_10_TUPLE_(T) > {
+  typedef T0 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 1, GTEST_10_TUPLE_(T) > {
+  typedef T1 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 2, GTEST_10_TUPLE_(T) > {
+  typedef T2 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 3, GTEST_10_TUPLE_(T) > {
+  typedef T3 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 4, GTEST_10_TUPLE_(T) > {
+  typedef T4 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 5, GTEST_10_TUPLE_(T) > {
+  typedef T5 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 6, GTEST_10_TUPLE_(T) > {
+  typedef T6 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 7, GTEST_10_TUPLE_(T) > {
+  typedef T7 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 8, GTEST_10_TUPLE_(T) > {
+  typedef T8 type;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct TupleElement<true, 9, GTEST_10_TUPLE_(T) > {
+  typedef T9 type;
+};
+
+}  // namespace gtest_internal
+
+template <>
+class tuple<> {
+ public:
+  tuple() {}
+  tuple(const tuple& /* t */)  {}
+  tuple& operator=(const tuple& /* t */) { return *this; }
+};
+
+template <GTEST_1_TYPENAMES_(T)>
+class GTEST_1_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}
+
+  tuple(const tuple& t) : f0_(t.f0_) {}
+
+  template <GTEST_1_TYPENAMES_(U)>
+  tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_1_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_1_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_1_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    return *this;
+  }
+
+  T0 f0_;
+};
+
+template <GTEST_2_TYPENAMES_(T)>
+class GTEST_2_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),
+      f1_(f1) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}
+
+  template <GTEST_2_TYPENAMES_(U)>
+  tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}
+  template <typename U0, typename U1>
+  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_2_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_2_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+  template <typename U0, typename U1>
+  tuple& operator=(const ::std::pair<U0, U1>& p) {
+    f0_ = p.first;
+    f1_ = p.second;
+    return *this;
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_2_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+};
+
+template <GTEST_3_TYPENAMES_(T)>
+class GTEST_3_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
+
+  template <GTEST_3_TYPENAMES_(U)>
+  tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_3_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_3_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_3_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+};
+
+template <GTEST_4_TYPENAMES_(T)>
+class GTEST_4_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_(), f3_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),
+      f3_(f3) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}
+
+  template <GTEST_4_TYPENAMES_(U)>
+  tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
+      f3_(t.f3_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_4_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_4_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_4_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    f3_ = t.f3_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+  T3 f3_;
+};
+
+template <GTEST_5_TYPENAMES_(T)>
+class GTEST_5_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,
+      GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
+      f4_(t.f4_) {}
+
+  template <GTEST_5_TYPENAMES_(U)>
+  tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
+      f3_(t.f3_), f4_(t.f4_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_5_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_5_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_5_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    f3_ = t.f3_;
+    f4_ = t.f4_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+  T3 f3_;
+  T4 f4_;
+};
+
+template <GTEST_6_TYPENAMES_(T)>
+class GTEST_6_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
+      GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
+      f5_(f5) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
+      f4_(t.f4_), f5_(t.f5_) {}
+
+  template <GTEST_6_TYPENAMES_(U)>
+  tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
+      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_6_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_6_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_6_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    f3_ = t.f3_;
+    f4_ = t.f4_;
+    f5_ = t.f5_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+  T3 f3_;
+  T4 f4_;
+  T5 f5_;
+};
+
+template <GTEST_7_TYPENAMES_(T)>
+class GTEST_7_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
+      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),
+      f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
+      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
+
+  template <GTEST_7_TYPENAMES_(U)>
+  tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
+      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_7_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_7_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_7_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    f3_ = t.f3_;
+    f4_ = t.f4_;
+    f5_ = t.f5_;
+    f6_ = t.f6_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+  T3 f3_;
+  T4 f4_;
+  T5 f5_;
+  T6 f6_;
+};
+
+template <GTEST_8_TYPENAMES_(T)>
+class GTEST_8_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
+      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,
+      GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
+      f5_(f5), f6_(f6), f7_(f7) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
+      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
+
+  template <GTEST_8_TYPENAMES_(U)>
+  tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
+      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_8_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_8_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_8_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    f3_ = t.f3_;
+    f4_ = t.f4_;
+    f5_ = t.f5_;
+    f6_ = t.f6_;
+    f7_ = t.f7_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+  T3 f3_;
+  T4 f4_;
+  T5 f5_;
+  T6 f6_;
+  T7 f7_;
+};
+
+template <GTEST_9_TYPENAMES_(T)>
+class GTEST_9_TUPLE_(T) {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
+      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
+      GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
+      f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
+      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
+
+  template <GTEST_9_TYPENAMES_(U)>
+  tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
+      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_9_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_9_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_9_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    f3_ = t.f3_;
+    f4_ = t.f4_;
+    f5_ = t.f5_;
+    f6_ = t.f6_;
+    f7_ = t.f7_;
+    f8_ = t.f8_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+  T3 f3_;
+  T4 f4_;
+  T5 f5_;
+  T6 f6_;
+  T7 f7_;
+  T8 f8_;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+class tuple {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),
+      f9_() {}
+
+  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
+      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
+      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
+      GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),
+      f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}
+
+  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
+      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}
+
+  template <GTEST_10_TYPENAMES_(U)>
+  tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
+      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),
+      f9_(t.f9_) {}
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_10_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_10_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_10_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {
+    f0_ = t.f0_;
+    f1_ = t.f1_;
+    f2_ = t.f2_;
+    f3_ = t.f3_;
+    f4_ = t.f4_;
+    f5_ = t.f5_;
+    f6_ = t.f6_;
+    f7_ = t.f7_;
+    f8_ = t.f8_;
+    f9_ = t.f9_;
+    return *this;
+  }
+
+  T0 f0_;
+  T1 f1_;
+  T2 f2_;
+  T3 f3_;
+  T4 f4_;
+  T5 f5_;
+  T6 f6_;
+  T7 f7_;
+  T8 f8_;
+  T9 f9_;
+};
+
+// 6.1.3.2 Tuple creation functions.
+
+// Known limitations: we don't support passing an
+// std::tr1::reference_wrapper<T> to make_tuple().  And we don't
+// implement tie().
+
+inline tuple<> make_tuple() { return tuple<>(); }
+
+template <GTEST_1_TYPENAMES_(T)>
+inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {
+  return GTEST_1_TUPLE_(T)(f0);
+}
+
+template <GTEST_2_TYPENAMES_(T)>
+inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {
+  return GTEST_2_TUPLE_(T)(f0, f1);
+}
+
+template <GTEST_3_TYPENAMES_(T)>
+inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {
+  return GTEST_3_TUPLE_(T)(f0, f1, f2);
+}
+
+template <GTEST_4_TYPENAMES_(T)>
+inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
+    const T3& f3) {
+  return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);
+}
+
+template <GTEST_5_TYPENAMES_(T)>
+inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
+    const T3& f3, const T4& f4) {
+  return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);
+}
+
+template <GTEST_6_TYPENAMES_(T)>
+inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
+    const T3& f3, const T4& f4, const T5& f5) {
+  return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);
+}
+
+template <GTEST_7_TYPENAMES_(T)>
+inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
+    const T3& f3, const T4& f4, const T5& f5, const T6& f6) {
+  return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);
+}
+
+template <GTEST_8_TYPENAMES_(T)>
+inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
+    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {
+  return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);
+}
+
+template <GTEST_9_TYPENAMES_(T)>
+inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
+    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
+    const T8& f8) {
+  return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);
+}
+
+template <GTEST_10_TYPENAMES_(T)>
+inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
+    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
+    const T8& f8, const T9& f9) {
+  return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
+}
+
+// 6.1.3.3 Tuple helper classes.
+
+template <typename Tuple> struct tuple_size;
+
+template <GTEST_0_TYPENAMES_(T)>
+struct tuple_size<GTEST_0_TUPLE_(T) > {
+  static const int value = 0;
+};
+
+template <GTEST_1_TYPENAMES_(T)>
+struct tuple_size<GTEST_1_TUPLE_(T) > {
+  static const int value = 1;
+};
+
+template <GTEST_2_TYPENAMES_(T)>
+struct tuple_size<GTEST_2_TUPLE_(T) > {
+  static const int value = 2;
+};
+
+template <GTEST_3_TYPENAMES_(T)>
+struct tuple_size<GTEST_3_TUPLE_(T) > {
+  static const int value = 3;
+};
+
+template <GTEST_4_TYPENAMES_(T)>
+struct tuple_size<GTEST_4_TUPLE_(T) > {
+  static const int value = 4;
+};
+
+template <GTEST_5_TYPENAMES_(T)>
+struct tuple_size<GTEST_5_TUPLE_(T) > {
+  static const int value = 5;
+};
+
+template <GTEST_6_TYPENAMES_(T)>
+struct tuple_size<GTEST_6_TUPLE_(T) > {
+  static const int value = 6;
+};
+
+template <GTEST_7_TYPENAMES_(T)>
+struct tuple_size<GTEST_7_TUPLE_(T) > {
+  static const int value = 7;
+};
+
+template <GTEST_8_TYPENAMES_(T)>
+struct tuple_size<GTEST_8_TUPLE_(T) > {
+  static const int value = 8;
+};
+
+template <GTEST_9_TYPENAMES_(T)>
+struct tuple_size<GTEST_9_TUPLE_(T) > {
+  static const int value = 9;
+};
+
+template <GTEST_10_TYPENAMES_(T)>
+struct tuple_size<GTEST_10_TUPLE_(T) > {
+  static const int value = 10;
+};
+
+template <int k, class Tuple>
+struct tuple_element {
+  typedef typename gtest_internal::TupleElement<
+      k < (tuple_size<Tuple>::value), k, Tuple>::type type;
+};
+
+#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
+
+// 6.1.3.4 Element access.
+
+namespace gtest_internal {
+
+template <>
+class Get<0> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
+  Field(Tuple& t) { return t.f0_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
+  ConstField(const Tuple& t) { return t.f0_; }
+};
+
+template <>
+class Get<1> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
+  Field(Tuple& t) { return t.f1_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
+  ConstField(const Tuple& t) { return t.f1_; }
+};
+
+template <>
+class Get<2> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
+  Field(Tuple& t) { return t.f2_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
+  ConstField(const Tuple& t) { return t.f2_; }
+};
+
+template <>
+class Get<3> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
+  Field(Tuple& t) { return t.f3_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
+  ConstField(const Tuple& t) { return t.f3_; }
+};
+
+template <>
+class Get<4> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
+  Field(Tuple& t) { return t.f4_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
+  ConstField(const Tuple& t) { return t.f4_; }
+};
+
+template <>
+class Get<5> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
+  Field(Tuple& t) { return t.f5_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
+  ConstField(const Tuple& t) { return t.f5_; }
+};
+
+template <>
+class Get<6> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
+  Field(Tuple& t) { return t.f6_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
+  ConstField(const Tuple& t) { return t.f6_; }
+};
+
+template <>
+class Get<7> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
+  Field(Tuple& t) { return t.f7_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
+  ConstField(const Tuple& t) { return t.f7_; }
+};
+
+template <>
+class Get<8> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
+  Field(Tuple& t) { return t.f8_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
+  ConstField(const Tuple& t) { return t.f8_; }
+};
+
+template <>
+class Get<9> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
+  Field(Tuple& t) { return t.f9_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
+  ConstField(const Tuple& t) { return t.f9_; }
+};
+
+}  // namespace gtest_internal
+
+template <int k, GTEST_10_TYPENAMES_(T)>
+GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
+get(GTEST_10_TUPLE_(T)& t) {
+  return gtest_internal::Get<k>::Field(t);
+}
+
+template <int k, GTEST_10_TYPENAMES_(T)>
+GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_10_TUPLE_(T)))
+get(const GTEST_10_TUPLE_(T)& t) {
+  return gtest_internal::Get<k>::ConstField(t);
+}
+
+// 6.1.3.5 Relational operators
+
+// We only implement == and !=, as we don't have a need for the rest yet.
+
+namespace gtest_internal {
+
+// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
+// first k fields of t1 equals the first k fields of t2.
+// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
+// k1 != k2.
+template <int kSize1, int kSize2>
+struct SameSizeTuplePrefixComparator;
+
+template <>
+struct SameSizeTuplePrefixComparator<0, 0> {
+  template <class Tuple1, class Tuple2>
+  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
+    return true;
+  }
+};
+
+template <int k>
+struct SameSizeTuplePrefixComparator<k, k> {
+  template <class Tuple1, class Tuple2>
+  static bool Eq(const Tuple1& t1, const Tuple2& t2) {
+    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
+        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
+  }
+};
+
+}  // namespace gtest_internal
+
+template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
+inline bool operator==(const GTEST_10_TUPLE_(T)& t,
+                       const GTEST_10_TUPLE_(U)& u) {
+  return gtest_internal::SameSizeTuplePrefixComparator<
+      tuple_size<GTEST_10_TUPLE_(T) >::value,
+      tuple_size<GTEST_10_TUPLE_(U) >::value>::Eq(t, u);
+}
+
+template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
+inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
+                       const GTEST_10_TUPLE_(U)& u) { return !(t == u); }
+
+// 6.1.4 Pairs.
+// Unimplemented.
+
+}  // namespace tr1
+}  // namespace std
+
+#undef GTEST_0_TUPLE_
+#undef GTEST_1_TUPLE_
+#undef GTEST_2_TUPLE_
+#undef GTEST_3_TUPLE_
+#undef GTEST_4_TUPLE_
+#undef GTEST_5_TUPLE_
+#undef GTEST_6_TUPLE_
+#undef GTEST_7_TUPLE_
+#undef GTEST_8_TUPLE_
+#undef GTEST_9_TUPLE_
+#undef GTEST_10_TUPLE_
+
+#undef GTEST_0_TYPENAMES_
+#undef GTEST_1_TYPENAMES_
+#undef GTEST_2_TYPENAMES_
+#undef GTEST_3_TYPENAMES_
+#undef GTEST_4_TYPENAMES_
+#undef GTEST_5_TYPENAMES_
+#undef GTEST_6_TYPENAMES_
+#undef GTEST_7_TYPENAMES_
+#undef GTEST_8_TYPENAMES_
+#undef GTEST_9_TYPENAMES_
+#undef GTEST_10_TYPENAMES_
+
+#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
+#undef GTEST_BY_REF_
+#undef GTEST_ADD_REF_
+#undef GTEST_TUPLE_ELEMENT_
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump
new file mode 100644
index 0000000..c7d9e03
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump
@@ -0,0 +1,339 @@
+$$ -*- mode: c++; -*-
+$var n = 10  $$ Maximum number of tuple fields we want to support.
+$$ This meta comment fixes auto-indentation in Emacs. }}
+// Copyright 2009 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
+
+#include <utility>  // For ::std::pair.
+
+// The compiler used in Symbian has a bug that prevents us from declaring the
+// tuple template as a friend (it complains that tuple is redefined).  This
+// hack bypasses the bug by declaring the members that should otherwise be
+// private as public.
+// Sun Studio versions < 12 also have the above bug.
+#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
+# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
+#else
+# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
+    template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \
+   private:
+#endif
+
+
+$range i 0..n-1
+$range j 0..n
+$range k 1..n
+// GTEST_n_TUPLE_(T) is the type of an n-tuple.
+#define GTEST_0_TUPLE_(T) tuple<>
+
+$for k [[
+$range m 0..k-1
+$range m2 k..n-1
+#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]>
+
+]]
+
+// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
+
+$for j [[
+$range m 0..j-1
+#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]]
+
+
+]]
+
+// In theory, defining stuff in the ::std namespace is undefined
+// behavior.  We can do this as we are playing the role of a standard
+// library vendor.
+namespace std {
+namespace tr1 {
+
+template <$for i, [[typename T$i = void]]>
+class tuple;
+
+// Anything in namespace gtest_internal is Google Test's INTERNAL
+// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
+namespace gtest_internal {
+
+// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
+template <typename T>
+struct ByRef { typedef const T& type; };  // NOLINT
+template <typename T>
+struct ByRef<T&> { typedef T& type; };  // NOLINT
+
+// A handy wrapper for ByRef.
+#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
+
+// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This
+// is the same as tr1::add_reference<T>::type.
+template <typename T>
+struct AddRef { typedef T& type; };  // NOLINT
+template <typename T>
+struct AddRef<T&> { typedef T& type; };  // NOLINT
+
+// A handy wrapper for AddRef.
+#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
+
+// A helper for implementing get<k>().
+template <int k> class Get;
+
+// A helper for implementing tuple_element<k, T>.  kIndexValid is true
+// iff k < the number of fields in tuple type T.
+template <bool kIndexValid, int kIndex, class Tuple>
+struct TupleElement;
+
+
+$for i [[
+template <GTEST_$(n)_TYPENAMES_(T)>
+struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T) > {
+  typedef T$i type;
+};
+
+
+]]
+}  // namespace gtest_internal
+
+template <>
+class tuple<> {
+ public:
+  tuple() {}
+  tuple(const tuple& /* t */)  {}
+  tuple& operator=(const tuple& /* t */) { return *this; }
+};
+
+
+$for k [[
+$range m 0..k-1
+template <GTEST_$(k)_TYPENAMES_(T)>
+class $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] {
+ public:
+  template <int k> friend class gtest_internal::Get;
+
+  tuple() : $for m, [[f$(m)_()]] {}
+
+  explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]]
+$for m, [[f$(m)_(f$m)]] {}
+
+  tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
+
+  template <GTEST_$(k)_TYPENAMES_(U)>
+  tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
+
+$if k == 2 [[
+  template <typename U0, typename U1>
+  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
+
+]]
+
+  tuple& operator=(const tuple& t) { return CopyFrom(t); }
+
+  template <GTEST_$(k)_TYPENAMES_(U)>
+  tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) {
+    return CopyFrom(t);
+  }
+
+$if k == 2 [[
+  template <typename U0, typename U1>
+  tuple& operator=(const ::std::pair<U0, U1>& p) {
+    f0_ = p.first;
+    f1_ = p.second;
+    return *this;
+  }
+
+]]
+
+  GTEST_DECLARE_TUPLE_AS_FRIEND_
+
+  template <GTEST_$(k)_TYPENAMES_(U)>
+  tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) {
+
+$for m [[
+    f$(m)_ = t.f$(m)_;
+
+]]
+    return *this;
+  }
+
+
+$for m [[
+  T$m f$(m)_;
+
+]]
+};
+
+
+]]
+// 6.1.3.2 Tuple creation functions.
+
+// Known limitations: we don't support passing an
+// std::tr1::reference_wrapper<T> to make_tuple().  And we don't
+// implement tie().
+
+inline tuple<> make_tuple() { return tuple<>(); }
+
+$for k [[
+$range m 0..k-1
+
+template <GTEST_$(k)_TYPENAMES_(T)>
+inline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) {
+  return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]);
+}
+
+]]
+
+// 6.1.3.3 Tuple helper classes.
+
+template <typename Tuple> struct tuple_size;
+
+
+$for j [[
+template <GTEST_$(j)_TYPENAMES_(T)>
+struct tuple_size<GTEST_$(j)_TUPLE_(T) > {
+  static const int value = $j;
+};
+
+
+]]
+template <int k, class Tuple>
+struct tuple_element {
+  typedef typename gtest_internal::TupleElement<
+      k < (tuple_size<Tuple>::value), k, Tuple>::type type;
+};
+
+#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
+
+// 6.1.3.4 Element access.
+
+namespace gtest_internal {
+
+
+$for i [[
+template <>
+class Get<$i> {
+ public:
+  template <class Tuple>
+  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
+  Field(Tuple& t) { return t.f$(i)_; }  // NOLINT
+
+  template <class Tuple>
+  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
+  ConstField(const Tuple& t) { return t.f$(i)_; }
+};
+
+
+]]
+}  // namespace gtest_internal
+
+template <int k, GTEST_$(n)_TYPENAMES_(T)>
+GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))
+get(GTEST_$(n)_TUPLE_(T)& t) {
+  return gtest_internal::Get<k>::Field(t);
+}
+
+template <int k, GTEST_$(n)_TYPENAMES_(T)>
+GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_$(n)_TUPLE_(T)))
+get(const GTEST_$(n)_TUPLE_(T)& t) {
+  return gtest_internal::Get<k>::ConstField(t);
+}
+
+// 6.1.3.5 Relational operators
+
+// We only implement == and !=, as we don't have a need for the rest yet.
+
+namespace gtest_internal {
+
+// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
+// first k fields of t1 equals the first k fields of t2.
+// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
+// k1 != k2.
+template <int kSize1, int kSize2>
+struct SameSizeTuplePrefixComparator;
+
+template <>
+struct SameSizeTuplePrefixComparator<0, 0> {
+  template <class Tuple1, class Tuple2>
+  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
+    return true;
+  }
+};
+
+template <int k>
+struct SameSizeTuplePrefixComparator<k, k> {
+  template <class Tuple1, class Tuple2>
+  static bool Eq(const Tuple1& t1, const Tuple2& t2) {
+    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
+        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
+  }
+};
+
+}  // namespace gtest_internal
+
+template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
+inline bool operator==(const GTEST_$(n)_TUPLE_(T)& t,
+                       const GTEST_$(n)_TUPLE_(U)& u) {
+  return gtest_internal::SameSizeTuplePrefixComparator<
+      tuple_size<GTEST_$(n)_TUPLE_(T) >::value,
+      tuple_size<GTEST_$(n)_TUPLE_(U) >::value>::Eq(t, u);
+}
+
+template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
+inline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t,
+                       const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); }
+
+// 6.1.4 Pairs.
+// Unimplemented.
+
+}  // namespace tr1
+}  // namespace std
+
+
+$for j [[
+#undef GTEST_$(j)_TUPLE_
+
+]]
+
+
+$for j [[
+#undef GTEST_$(j)_TYPENAMES_
+
+]]
+
+#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
+#undef GTEST_BY_REF_
+#undef GTEST_ADD_REF_
+#undef GTEST_TUPLE_ELEMENT_
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-type-util.h b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h
new file mode 100644
index 0000000..e46f7cf
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h
@@ -0,0 +1,3331 @@
+// This file was GENERATED by command:
+//     pump.py gtest-type-util.h.pump
+// DO NOT EDIT BY HAND!!!
+
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Type utilities needed for implementing typed and type-parameterized
+// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
+//
+// Currently we support at most 50 types in a list, and at most 50
+// type-parameterized tests in one type-parameterized test case.
+// Please contact googletestframework@googlegroups.com if you need
+// more.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
+
+#include "gtest/internal/gtest-port.h"
+
+// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using
+// libstdc++ (which is where cxxabi.h comes from).
+# if GTEST_HAS_CXXABI_H_
+#  include <cxxabi.h>
+# elif defined(__HP_aCC)
+#  include <acxx_demangle.h>
+# endif  // GTEST_HASH_CXXABI_H_
+
+namespace testing {
+namespace internal {
+
+// GetTypeName<T>() returns a human-readable name of type T.
+// NB: This function is also used in Google Mock, so don't move it inside of
+// the typed-test-only section below.
+template <typename T>
+std::string GetTypeName() {
+# if GTEST_HAS_RTTI
+
+  const char* const name = typeid(T).name();
+#  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)
+  int status = 0;
+  // gcc's implementation of typeid(T).name() mangles the type name,
+  // so we have to demangle it.
+#   if GTEST_HAS_CXXABI_H_
+  using abi::__cxa_demangle;
+#   endif  // GTEST_HAS_CXXABI_H_
+  char* const readable_name = __cxa_demangle(name, 0, 0, &status);
+  const std::string name_str(status == 0 ? readable_name : name);
+  free(readable_name);
+  return name_str;
+#  else
+  return name;
+#  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC
+
+# else
+
+  return "<type>";
+
+# endif  // GTEST_HAS_RTTI
+}
+
+#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
+
+// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
+// type.  This can be used as a compile-time assertion to ensure that
+// two types are equal.
+
+template <typename T1, typename T2>
+struct AssertTypeEq;
+
+template <typename T>
+struct AssertTypeEq<T, T> {
+  typedef bool type;
+};
+
+// A unique type used as the default value for the arguments of class
+// template Types.  This allows us to simulate variadic templates
+// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
+// support directly.
+struct None {};
+
+// The following family of struct and struct templates are used to
+// represent type lists.  In particular, TypesN<T1, T2, ..., TN>
+// represents a type list with N types (T1, T2, ..., and TN) in it.
+// Except for Types0, every struct in the family has two member types:
+// Head for the first type in the list, and Tail for the rest of the
+// list.
+
+// The empty type list.
+struct Types0 {};
+
+// Type lists of length 1, 2, 3, and so on.
+
+template <typename T1>
+struct Types1 {
+  typedef T1 Head;
+  typedef Types0 Tail;
+};
+template <typename T1, typename T2>
+struct Types2 {
+  typedef T1 Head;
+  typedef Types1<T2> Tail;
+};
+
+template <typename T1, typename T2, typename T3>
+struct Types3 {
+  typedef T1 Head;
+  typedef Types2<T2, T3> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4>
+struct Types4 {
+  typedef T1 Head;
+  typedef Types3<T2, T3, T4> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+struct Types5 {
+  typedef T1 Head;
+  typedef Types4<T2, T3, T4, T5> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6>
+struct Types6 {
+  typedef T1 Head;
+  typedef Types5<T2, T3, T4, T5, T6> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7>
+struct Types7 {
+  typedef T1 Head;
+  typedef Types6<T2, T3, T4, T5, T6, T7> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8>
+struct Types8 {
+  typedef T1 Head;
+  typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9>
+struct Types9 {
+  typedef T1 Head;
+  typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10>
+struct Types10 {
+  typedef T1 Head;
+  typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11>
+struct Types11 {
+  typedef T1 Head;
+  typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12>
+struct Types12 {
+  typedef T1 Head;
+  typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13>
+struct Types13 {
+  typedef T1 Head;
+  typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14>
+struct Types14 {
+  typedef T1 Head;
+  typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15>
+struct Types15 {
+  typedef T1 Head;
+  typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16>
+struct Types16 {
+  typedef T1 Head;
+  typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17>
+struct Types17 {
+  typedef T1 Head;
+  typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18>
+struct Types18 {
+  typedef T1 Head;
+  typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19>
+struct Types19 {
+  typedef T1 Head;
+  typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20>
+struct Types20 {
+  typedef T1 Head;
+  typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21>
+struct Types21 {
+  typedef T1 Head;
+  typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22>
+struct Types22 {
+  typedef T1 Head;
+  typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23>
+struct Types23 {
+  typedef T1 Head;
+  typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24>
+struct Types24 {
+  typedef T1 Head;
+  typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25>
+struct Types25 {
+  typedef T1 Head;
+  typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26>
+struct Types26 {
+  typedef T1 Head;
+  typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27>
+struct Types27 {
+  typedef T1 Head;
+  typedef Types26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28>
+struct Types28 {
+  typedef T1 Head;
+  typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29>
+struct Types29 {
+  typedef T1 Head;
+  typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30>
+struct Types30 {
+  typedef T1 Head;
+  typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31>
+struct Types31 {
+  typedef T1 Head;
+  typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32>
+struct Types32 {
+  typedef T1 Head;
+  typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33>
+struct Types33 {
+  typedef T1 Head;
+  typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34>
+struct Types34 {
+  typedef T1 Head;
+  typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35>
+struct Types35 {
+  typedef T1 Head;
+  typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36>
+struct Types36 {
+  typedef T1 Head;
+  typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37>
+struct Types37 {
+  typedef T1 Head;
+  typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38>
+struct Types38 {
+  typedef T1 Head;
+  typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39>
+struct Types39 {
+  typedef T1 Head;
+  typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40>
+struct Types40 {
+  typedef T1 Head;
+  typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41>
+struct Types41 {
+  typedef T1 Head;
+  typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42>
+struct Types42 {
+  typedef T1 Head;
+  typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43>
+struct Types43 {
+  typedef T1 Head;
+  typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44>
+struct Types44 {
+  typedef T1 Head;
+  typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+      T44> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45>
+struct Types45 {
+  typedef T1 Head;
+  typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+      T44, T45> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46>
+struct Types46 {
+  typedef T1 Head;
+  typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+      T44, T45, T46> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47>
+struct Types47 {
+  typedef T1 Head;
+  typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+      T44, T45, T46, T47> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48>
+struct Types48 {
+  typedef T1 Head;
+  typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+      T44, T45, T46, T47, T48> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49>
+struct Types49 {
+  typedef T1 Head;
+  typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+      T44, T45, T46, T47, T48, T49> Tail;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49, typename T50>
+struct Types50 {
+  typedef T1 Head;
+  typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+      T44, T45, T46, T47, T48, T49, T50> Tail;
+};
+
+
+}  // namespace internal
+
+// We don't want to require the users to write TypesN<...> directly,
+// as that would require them to count the length.  Types<...> is much
+// easier to write, but generates horrible messages when there is a
+// compiler error, as gcc insists on printing out each template
+// argument, even if it has the default value (this means Types<int>
+// will appear as Types<int, None, None, ..., None> in the compiler
+// errors).
+//
+// Our solution is to combine the best part of the two approaches: a
+// user would write Types<T1, ..., TN>, and Google Test will translate
+// that to TypesN<T1, ..., TN> internally to make error messages
+// readable.  The translation is done by the 'type' member of the
+// Types template.
+template <typename T1 = internal::None, typename T2 = internal::None,
+    typename T3 = internal::None, typename T4 = internal::None,
+    typename T5 = internal::None, typename T6 = internal::None,
+    typename T7 = internal::None, typename T8 = internal::None,
+    typename T9 = internal::None, typename T10 = internal::None,
+    typename T11 = internal::None, typename T12 = internal::None,
+    typename T13 = internal::None, typename T14 = internal::None,
+    typename T15 = internal::None, typename T16 = internal::None,
+    typename T17 = internal::None, typename T18 = internal::None,
+    typename T19 = internal::None, typename T20 = internal::None,
+    typename T21 = internal::None, typename T22 = internal::None,
+    typename T23 = internal::None, typename T24 = internal::None,
+    typename T25 = internal::None, typename T26 = internal::None,
+    typename T27 = internal::None, typename T28 = internal::None,
+    typename T29 = internal::None, typename T30 = internal::None,
+    typename T31 = internal::None, typename T32 = internal::None,
+    typename T33 = internal::None, typename T34 = internal::None,
+    typename T35 = internal::None, typename T36 = internal::None,
+    typename T37 = internal::None, typename T38 = internal::None,
+    typename T39 = internal::None, typename T40 = internal::None,
+    typename T41 = internal::None, typename T42 = internal::None,
+    typename T43 = internal::None, typename T44 = internal::None,
+    typename T45 = internal::None, typename T46 = internal::None,
+    typename T47 = internal::None, typename T48 = internal::None,
+    typename T49 = internal::None, typename T50 = internal::None>
+struct Types {
+  typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
+};
+
+template <>
+struct Types<internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types0 type;
+};
+template <typename T1>
+struct Types<T1, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types1<T1> type;
+};
+template <typename T1, typename T2>
+struct Types<T1, T2, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types2<T1, T2> type;
+};
+template <typename T1, typename T2, typename T3>
+struct Types<T1, T2, T3, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types3<T1, T2, T3> type;
+};
+template <typename T1, typename T2, typename T3, typename T4>
+struct Types<T1, T2, T3, T4, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types4<T1, T2, T3, T4> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+struct Types<T1, T2, T3, T4, T5, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types5<T1, T2, T3, T4, T5> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6>
+struct Types<T1, T2, T3, T4, T5, T6, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7>
+struct Types<T1, T2, T3, T4, T5, T6, T7, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
+      T12> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
+      T26> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
+      T40> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, internal::None,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None, internal::None> {
+  typedef internal::Types43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None, internal::None> {
+  typedef internal::Types44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
+    internal::None, internal::None, internal::None, internal::None,
+    internal::None> {
+  typedef internal::Types45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44, T45> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
+    T46, internal::None, internal::None, internal::None, internal::None> {
+  typedef internal::Types46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44, T45, T46> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
+    T46, T47, internal::None, internal::None, internal::None> {
+  typedef internal::Types47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44, T45, T46, T47> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
+    T46, T47, T48, internal::None, internal::None> {
+  typedef internal::Types48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44, T45, T46, T47, T48> type;
+};
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49>
+struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
+    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
+    T46, T47, T48, T49, internal::None> {
+  typedef internal::Types49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44, T45, T46, T47, T48, T49> type;
+};
+
+namespace internal {
+
+# define GTEST_TEMPLATE_ template <typename T> class
+
+// The template "selector" struct TemplateSel<Tmpl> is used to
+// represent Tmpl, which must be a class template with one type
+// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined
+// as the type Tmpl<T>.  This allows us to actually instantiate the
+// template "selected" by TemplateSel<Tmpl>.
+//
+// This trick is necessary for simulating typedef for class templates,
+// which C++ doesn't support directly.
+template <GTEST_TEMPLATE_ Tmpl>
+struct TemplateSel {
+  template <typename T>
+  struct Bind {
+    typedef Tmpl<T> type;
+  };
+};
+
+# define GTEST_BIND_(TmplSel, T) \
+  TmplSel::template Bind<T>::type
+
+// A unique struct template used as the default value for the
+// arguments of class template Templates.  This allows us to simulate
+// variadic templates (e.g. Templates<int>, Templates<int, double>,
+// and etc), which C++ doesn't support directly.
+template <typename T>
+struct NoneT {};
+
+// The following family of struct and struct templates are used to
+// represent template lists.  In particular, TemplatesN<T1, T2, ...,
+// TN> represents a list of N templates (T1, T2, ..., and TN).  Except
+// for Templates0, every struct in the family has two member types:
+// Head for the selector of the first template in the list, and Tail
+// for the rest of the list.
+
+// The empty template list.
+struct Templates0 {};
+
+// Template lists of length 1, 2, 3, and so on.
+
+template <GTEST_TEMPLATE_ T1>
+struct Templates1 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates0 Tail;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
+struct Templates2 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates1<T2> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
+struct Templates3 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates2<T2, T3> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4>
+struct Templates4 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates3<T2, T3, T4> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
+struct Templates5 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates4<T2, T3, T4, T5> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
+struct Templates6 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates5<T2, T3, T4, T5, T6> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7>
+struct Templates7 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates6<T2, T3, T4, T5, T6, T7> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
+struct Templates8 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates7<T2, T3, T4, T5, T6, T7, T8> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
+struct Templates9 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10>
+struct Templates10 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
+struct Templates11 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
+struct Templates12 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13>
+struct Templates13 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
+struct Templates14 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
+struct Templates15 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16>
+struct Templates16 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
+struct Templates17 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
+struct Templates18 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19>
+struct Templates19 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
+struct Templates20 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
+struct Templates21 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22>
+struct Templates22 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
+struct Templates23 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
+struct Templates24 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25>
+struct Templates25 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
+struct Templates26 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
+struct Templates27 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28>
+struct Templates28 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
+struct Templates29 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
+struct Templates30 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31>
+struct Templates31 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
+struct Templates32 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
+struct Templates33 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34>
+struct Templates34 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
+struct Templates35 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
+struct Templates36 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37>
+struct Templates37 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
+struct Templates38 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
+struct Templates39 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40>
+struct Templates40 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
+struct Templates41 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
+struct Templates42 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43>
+struct Templates43 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
+struct Templates44 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43, T44> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
+struct Templates45 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43, T44, T45> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46>
+struct Templates46 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43, T44, T45, T46> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
+struct Templates47 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43, T44, T45, T46, T47> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
+struct Templates48 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43, T44, T45, T46, T47, T48> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
+    GTEST_TEMPLATE_ T49>
+struct Templates49 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43, T44, T45, T46, T47, T48, T49> Tail;
+};
+
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
+    GTEST_TEMPLATE_ T49, GTEST_TEMPLATE_ T50>
+struct Templates50 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
+      T43, T44, T45, T46, T47, T48, T49, T50> Tail;
+};
+
+
+// We don't want to require the users to write TemplatesN<...> directly,
+// as that would require them to count the length.  Templates<...> is much
+// easier to write, but generates horrible messages when there is a
+// compiler error, as gcc insists on printing out each template
+// argument, even if it has the default value (this means Templates<list>
+// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
+// errors).
+//
+// Our solution is to combine the best part of the two approaches: a
+// user would write Templates<T1, ..., TN>, and Google Test will translate
+// that to TemplatesN<T1, ..., TN> internally to make error messages
+// readable.  The translation is done by the 'type' member of the
+// Templates template.
+template <GTEST_TEMPLATE_ T1 = NoneT, GTEST_TEMPLATE_ T2 = NoneT,
+    GTEST_TEMPLATE_ T3 = NoneT, GTEST_TEMPLATE_ T4 = NoneT,
+    GTEST_TEMPLATE_ T5 = NoneT, GTEST_TEMPLATE_ T6 = NoneT,
+    GTEST_TEMPLATE_ T7 = NoneT, GTEST_TEMPLATE_ T8 = NoneT,
+    GTEST_TEMPLATE_ T9 = NoneT, GTEST_TEMPLATE_ T10 = NoneT,
+    GTEST_TEMPLATE_ T11 = NoneT, GTEST_TEMPLATE_ T12 = NoneT,
+    GTEST_TEMPLATE_ T13 = NoneT, GTEST_TEMPLATE_ T14 = NoneT,
+    GTEST_TEMPLATE_ T15 = NoneT, GTEST_TEMPLATE_ T16 = NoneT,
+    GTEST_TEMPLATE_ T17 = NoneT, GTEST_TEMPLATE_ T18 = NoneT,
+    GTEST_TEMPLATE_ T19 = NoneT, GTEST_TEMPLATE_ T20 = NoneT,
+    GTEST_TEMPLATE_ T21 = NoneT, GTEST_TEMPLATE_ T22 = NoneT,
+    GTEST_TEMPLATE_ T23 = NoneT, GTEST_TEMPLATE_ T24 = NoneT,
+    GTEST_TEMPLATE_ T25 = NoneT, GTEST_TEMPLATE_ T26 = NoneT,
+    GTEST_TEMPLATE_ T27 = NoneT, GTEST_TEMPLATE_ T28 = NoneT,
+    GTEST_TEMPLATE_ T29 = NoneT, GTEST_TEMPLATE_ T30 = NoneT,
+    GTEST_TEMPLATE_ T31 = NoneT, GTEST_TEMPLATE_ T32 = NoneT,
+    GTEST_TEMPLATE_ T33 = NoneT, GTEST_TEMPLATE_ T34 = NoneT,
+    GTEST_TEMPLATE_ T35 = NoneT, GTEST_TEMPLATE_ T36 = NoneT,
+    GTEST_TEMPLATE_ T37 = NoneT, GTEST_TEMPLATE_ T38 = NoneT,
+    GTEST_TEMPLATE_ T39 = NoneT, GTEST_TEMPLATE_ T40 = NoneT,
+    GTEST_TEMPLATE_ T41 = NoneT, GTEST_TEMPLATE_ T42 = NoneT,
+    GTEST_TEMPLATE_ T43 = NoneT, GTEST_TEMPLATE_ T44 = NoneT,
+    GTEST_TEMPLATE_ T45 = NoneT, GTEST_TEMPLATE_ T46 = NoneT,
+    GTEST_TEMPLATE_ T47 = NoneT, GTEST_TEMPLATE_ T48 = NoneT,
+    GTEST_TEMPLATE_ T49 = NoneT, GTEST_TEMPLATE_ T50 = NoneT>
+struct Templates {
+  typedef Templates50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
+};
+
+template <>
+struct Templates<NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT> {
+  typedef Templates0 type;
+};
+template <GTEST_TEMPLATE_ T1>
+struct Templates<T1, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT> {
+  typedef Templates1<T1> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
+struct Templates<T1, T2, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT> {
+  typedef Templates2<T1, T2> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
+struct Templates<T1, T2, T3, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates3<T1, T2, T3> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4>
+struct Templates<T1, T2, T3, T4, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates4<T1, T2, T3, T4> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
+struct Templates<T1, T2, T3, T4, T5, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates5<T1, T2, T3, T4, T5> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
+struct Templates<T1, T2, T3, T4, T5, T6, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates6<T1, T2, T3, T4, T5, T6> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates7<T1, T2, T3, T4, T5, T6, T7> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates8<T1, T2, T3, T4, T5, T6, T7, T8> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT> {
+  typedef Templates22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT> {
+  typedef Templates23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT> {
+  typedef Templates24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT> {
+  typedef Templates25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT> {
+  typedef Templates26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT> {
+  typedef Templates27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT> {
+  typedef Templates28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT> {
+  typedef Templates29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, NoneT, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, NoneT, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, NoneT, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, NoneT, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, NoneT,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
+    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43, T44> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
+    T45, NoneT, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43, T44, T45> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
+    T45, T46, NoneT, NoneT, NoneT, NoneT> {
+  typedef Templates46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43, T44, T45, T46> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
+    T45, T46, T47, NoneT, NoneT, NoneT> {
+  typedef Templates47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43, T44, T45, T46, T47> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
+    T45, T46, T47, T48, NoneT, NoneT> {
+  typedef Templates48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43, T44, T45, T46, T47, T48> type;
+};
+template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
+    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
+    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
+    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
+    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
+    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
+    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
+    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
+    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
+    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
+    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
+    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
+    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
+    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
+    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
+    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
+    GTEST_TEMPLATE_ T49>
+struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
+    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
+    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
+    T45, T46, T47, T48, T49, NoneT> {
+  typedef Templates49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
+      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
+      T42, T43, T44, T45, T46, T47, T48, T49> type;
+};
+
+// The TypeList template makes it possible to use either a single type
+// or a Types<...> list in TYPED_TEST_CASE() and
+// INSTANTIATE_TYPED_TEST_CASE_P().
+
+template <typename T>
+struct TypeList {
+  typedef Types1<T> type;
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+    typename T6, typename T7, typename T8, typename T9, typename T10,
+    typename T11, typename T12, typename T13, typename T14, typename T15,
+    typename T16, typename T17, typename T18, typename T19, typename T20,
+    typename T21, typename T22, typename T23, typename T24, typename T25,
+    typename T26, typename T27, typename T28, typename T29, typename T30,
+    typename T31, typename T32, typename T33, typename T34, typename T35,
+    typename T36, typename T37, typename T38, typename T39, typename T40,
+    typename T41, typename T42, typename T43, typename T44, typename T45,
+    typename T46, typename T47, typename T48, typename T49, typename T50>
+struct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
+    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
+    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
+    T44, T45, T46, T47, T48, T49, T50> > {
+  typedef typename Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
+      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
+      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
+      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>::type type;
+};
+
+#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
diff --git a/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump
new file mode 100644
index 0000000..251fdf0
--- /dev/null
+++ b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump
@@ -0,0 +1,297 @@
+$$ -*- mode: c++; -*-
+$var n = 50  $$ Maximum length of type lists we want to support.
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Type utilities needed for implementing typed and type-parameterized
+// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
+//
+// Currently we support at most $n types in a list, and at most $n
+// type-parameterized tests in one type-parameterized test case.
+// Please contact googletestframework@googlegroups.com if you need
+// more.
+
+#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
+#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
+
+#include "gtest/internal/gtest-port.h"
+
+// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using
+// libstdc++ (which is where cxxabi.h comes from).
+# if GTEST_HAS_CXXABI_H_
+#  include <cxxabi.h>
+# elif defined(__HP_aCC)
+#  include <acxx_demangle.h>
+# endif  // GTEST_HASH_CXXABI_H_
+
+namespace testing {
+namespace internal {
+
+// GetTypeName<T>() returns a human-readable name of type T.
+// NB: This function is also used in Google Mock, so don't move it inside of
+// the typed-test-only section below.
+template <typename T>
+std::string GetTypeName() {
+# if GTEST_HAS_RTTI
+
+  const char* const name = typeid(T).name();
+#  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)
+  int status = 0;
+  // gcc's implementation of typeid(T).name() mangles the type name,
+  // so we have to demangle it.
+#   if GTEST_HAS_CXXABI_H_
+  using abi::__cxa_demangle;
+#   endif  // GTEST_HAS_CXXABI_H_
+  char* const readable_name = __cxa_demangle(name, 0, 0, &status);
+  const std::string name_str(status == 0 ? readable_name : name);
+  free(readable_name);
+  return name_str;
+#  else
+  return name;
+#  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC
+
+# else
+
+  return "<type>";
+
+# endif  // GTEST_HAS_RTTI
+}
+
+#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
+
+// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
+// type.  This can be used as a compile-time assertion to ensure that
+// two types are equal.
+
+template <typename T1, typename T2>
+struct AssertTypeEq;
+
+template <typename T>
+struct AssertTypeEq<T, T> {
+  typedef bool type;
+};
+
+// A unique type used as the default value for the arguments of class
+// template Types.  This allows us to simulate variadic templates
+// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
+// support directly.
+struct None {};
+
+// The following family of struct and struct templates are used to
+// represent type lists.  In particular, TypesN<T1, T2, ..., TN>
+// represents a type list with N types (T1, T2, ..., and TN) in it.
+// Except for Types0, every struct in the family has two member types:
+// Head for the first type in the list, and Tail for the rest of the
+// list.
+
+// The empty type list.
+struct Types0 {};
+
+// Type lists of length 1, 2, 3, and so on.
+
+template <typename T1>
+struct Types1 {
+  typedef T1 Head;
+  typedef Types0 Tail;
+};
+
+$range i 2..n
+
+$for i [[
+$range j 1..i
+$range k 2..i
+template <$for j, [[typename T$j]]>
+struct Types$i {
+  typedef T1 Head;
+  typedef Types$(i-1)<$for k, [[T$k]]> Tail;
+};
+
+
+]]
+
+}  // namespace internal
+
+// We don't want to require the users to write TypesN<...> directly,
+// as that would require them to count the length.  Types<...> is much
+// easier to write, but generates horrible messages when there is a
+// compiler error, as gcc insists on printing out each template
+// argument, even if it has the default value (this means Types<int>
+// will appear as Types<int, None, None, ..., None> in the compiler
+// errors).
+//
+// Our solution is to combine the best part of the two approaches: a
+// user would write Types<T1, ..., TN>, and Google Test will translate
+// that to TypesN<T1, ..., TN> internally to make error messages
+// readable.  The translation is done by the 'type' member of the
+// Types template.
+
+$range i 1..n
+template <$for i, [[typename T$i = internal::None]]>
+struct Types {
+  typedef internal::Types$n<$for i, [[T$i]]> type;
+};
+
+template <>
+struct Types<$for i, [[internal::None]]> {
+  typedef internal::Types0 type;
+};
+
+$range i 1..n-1
+$for i [[
+$range j 1..i
+$range k i+1..n
+template <$for j, [[typename T$j]]>
+struct Types<$for j, [[T$j]]$for k[[, internal::None]]> {
+  typedef internal::Types$i<$for j, [[T$j]]> type;
+};
+
+]]
+
+namespace internal {
+
+# define GTEST_TEMPLATE_ template <typename T> class
+
+// The template "selector" struct TemplateSel<Tmpl> is used to
+// represent Tmpl, which must be a class template with one type
+// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined
+// as the type Tmpl<T>.  This allows us to actually instantiate the
+// template "selected" by TemplateSel<Tmpl>.
+//
+// This trick is necessary for simulating typedef for class templates,
+// which C++ doesn't support directly.
+template <GTEST_TEMPLATE_ Tmpl>
+struct TemplateSel {
+  template <typename T>
+  struct Bind {
+    typedef Tmpl<T> type;
+  };
+};
+
+# define GTEST_BIND_(TmplSel, T) \
+  TmplSel::template Bind<T>::type
+
+// A unique struct template used as the default value for the
+// arguments of class template Templates.  This allows us to simulate
+// variadic templates (e.g. Templates<int>, Templates<int, double>,
+// and etc), which C++ doesn't support directly.
+template <typename T>
+struct NoneT {};
+
+// The following family of struct and struct templates are used to
+// represent template lists.  In particular, TemplatesN<T1, T2, ...,
+// TN> represents a list of N templates (T1, T2, ..., and TN).  Except
+// for Templates0, every struct in the family has two member types:
+// Head for the selector of the first template in the list, and Tail
+// for the rest of the list.
+
+// The empty template list.
+struct Templates0 {};
+
+// Template lists of length 1, 2, 3, and so on.
+
+template <GTEST_TEMPLATE_ T1>
+struct Templates1 {
+  typedef TemplateSel<T1> Head;
+  typedef Templates0 Tail;
+};
+
+$range i 2..n
+
+$for i [[
+$range j 1..i
+$range k 2..i
+template <$for j, [[GTEST_TEMPLATE_ T$j]]>
+struct Templates$i {
+  typedef TemplateSel<T1> Head;
+  typedef Templates$(i-1)<$for k, [[T$k]]> Tail;
+};
+
+
+]]
+
+// We don't want to require the users to write TemplatesN<...> directly,
+// as that would require them to count the length.  Templates<...> is much
+// easier to write, but generates horrible messages when there is a
+// compiler error, as gcc insists on printing out each template
+// argument, even if it has the default value (this means Templates<list>
+// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
+// errors).
+//
+// Our solution is to combine the best part of the two approaches: a
+// user would write Templates<T1, ..., TN>, and Google Test will translate
+// that to TemplatesN<T1, ..., TN> internally to make error messages
+// readable.  The translation is done by the 'type' member of the
+// Templates template.
+
+$range i 1..n
+template <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]>
+struct Templates {
+  typedef Templates$n<$for i, [[T$i]]> type;
+};
+
+template <>
+struct Templates<$for i, [[NoneT]]> {
+  typedef Templates0 type;
+};
+
+$range i 1..n-1
+$for i [[
+$range j 1..i
+$range k i+1..n
+template <$for j, [[GTEST_TEMPLATE_ T$j]]>
+struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {
+  typedef Templates$i<$for j, [[T$j]]> type;
+};
+
+]]
+
+// The TypeList template makes it possible to use either a single type
+// or a Types<...> list in TYPED_TEST_CASE() and
+// INSTANTIATE_TYPED_TEST_CASE_P().
+
+template <typename T>
+struct TypeList {
+  typedef Types1<T> type;
+};
+
+
+$range i 1..n
+template <$for i, [[typename T$i]]>
+struct TypeList<Types<$for i, [[T$i]]> > {
+  typedef typename Types<$for i, [[T$i]]>::type type;
+};
+
+#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
diff --git a/test/fmw/gtest/src/gtest-all.cc b/test/fmw/gtest/src/gtest-all.cc
new file mode 100644
index 0000000..0a9cee5
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-all.cc
@@ -0,0 +1,48 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: mheule@google.com (Markus Heule)
+//
+// Google C++ Testing Framework (Google Test)
+//
+// Sometimes it's desirable to build Google Test by compiling a single file.
+// This file serves this purpose.
+
+// This line ensures that gtest.h can be compiled on its own, even
+// when it's fused.
+#include "gtest/gtest.h"
+
+// The following lines pull in the real gtest *.cc files.
+#include "src/gtest.cc"
+#include "src/gtest-death-test.cc"
+#include "src/gtest-filepath.cc"
+#include "src/gtest-port.cc"
+#include "src/gtest-printers.cc"
+#include "src/gtest-test-part.cc"
+#include "src/gtest-typed-test.cc"
diff --git a/test/fmw/gtest/src/gtest-death-test.cc b/test/fmw/gtest/src/gtest-death-test.cc
new file mode 100644
index 0000000..a6023fc
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-death-test.cc
@@ -0,0 +1,1344 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)
+//
+// This file implements death tests.
+
+#include "gtest/gtest-death-test.h"
+#include "gtest/internal/gtest-port.h"
+
+#if GTEST_HAS_DEATH_TEST
+
+# if GTEST_OS_MAC
+#  include <crt_externs.h>
+# endif  // GTEST_OS_MAC
+
+# include <errno.h>
+# include <fcntl.h>
+# include <limits.h>
+
+# if GTEST_OS_LINUX
+#  include <signal.h>
+# endif  // GTEST_OS_LINUX
+
+# include <stdarg.h>
+
+# if GTEST_OS_WINDOWS
+#  include <windows.h>
+# else
+#  include <sys/mman.h>
+#  include <sys/wait.h>
+# endif  // GTEST_OS_WINDOWS
+
+# if GTEST_OS_QNX
+#  include <spawn.h>
+# endif  // GTEST_OS_QNX
+
+#endif  // GTEST_HAS_DEATH_TEST
+
+#include "gtest/gtest-message.h"
+#include "gtest/internal/gtest-string.h"
+
+// Indicates that this translation unit is part of Google Test's
+// implementation.  It must come before gtest-internal-inl.h is
+// included, or there will be a compiler error.  This trick is to
+// prevent a user from accidentally including gtest-internal-inl.h in
+// his code.
+#define GTEST_IMPLEMENTATION_ 1
+#include "src/gtest-internal-inl.h"
+#undef GTEST_IMPLEMENTATION_
+
+namespace testing {
+
+// Constants.
+
+// The default death test style.
+static const char kDefaultDeathTestStyle[] = "fast";
+
+GTEST_DEFINE_string_(
+    death_test_style,
+    internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle),
+    "Indicates how to run a death test in a forked child process: "
+    "\"threadsafe\" (child process re-executes the test binary "
+    "from the beginning, running only the specific death test) or "
+    "\"fast\" (child process runs the death test immediately "
+    "after forking).");
+
+GTEST_DEFINE_bool_(
+    death_test_use_fork,
+    internal::BoolFromGTestEnv("death_test_use_fork", false),
+    "Instructs to use fork()/_exit() instead of clone() in death tests. "
+    "Ignored and always uses fork() on POSIX systems where clone() is not "
+    "implemented. Useful when running under valgrind or similar tools if "
+    "those do not support clone(). Valgrind 3.3.1 will just fail if "
+    "it sees an unsupported combination of clone() flags. "
+    "It is not recommended to use this flag w/o valgrind though it will "
+    "work in 99% of the cases. Once valgrind is fixed, this flag will "
+    "most likely be removed.");
+
+namespace internal {
+GTEST_DEFINE_string_(
+    internal_run_death_test, "",
+    "Indicates the file, line number, temporal index of "
+    "the single death test to run, and a file descriptor to "
+    "which a success code may be sent, all separated by "
+    "the '|' characters.  This flag is specified if and only if the current "
+    "process is a sub-process launched for running a thread-safe "
+    "death test.  FOR INTERNAL USE ONLY.");
+}  // namespace internal
+
+#if GTEST_HAS_DEATH_TEST
+
+namespace internal {
+
+// Valid only for fast death tests. Indicates the code is running in the
+// child process of a fast style death test.
+static bool g_in_fast_death_test_child = false;
+
+// Returns a Boolean value indicating whether the caller is currently
+// executing in the context of the death test child process.  Tools such as
+// Valgrind heap checkers may need this to modify their behavior in death
+// tests.  IMPORTANT: This is an internal utility.  Using it may break the
+// implementation of death tests.  User code MUST NOT use it.
+bool InDeathTestChild() {
+# if GTEST_OS_WINDOWS
+
+  // On Windows, death tests are thread-safe regardless of the value of the
+  // death_test_style flag.
+  return !GTEST_FLAG(internal_run_death_test).empty();
+
+# else
+
+  if (GTEST_FLAG(death_test_style) == "threadsafe")
+    return !GTEST_FLAG(internal_run_death_test).empty();
+  else
+    return g_in_fast_death_test_child;
+#endif
+}
+
+}  // namespace internal
+
+// ExitedWithCode constructor.
+ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {
+}
+
+// ExitedWithCode function-call operator.
+bool ExitedWithCode::operator()(int exit_status) const {
+# if GTEST_OS_WINDOWS
+
+  return exit_status == exit_code_;
+
+# else
+
+  return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;
+
+# endif  // GTEST_OS_WINDOWS
+}
+
+# if !GTEST_OS_WINDOWS
+// KilledBySignal constructor.
+KilledBySignal::KilledBySignal(int signum) : signum_(signum) {
+}
+
+// KilledBySignal function-call operator.
+bool KilledBySignal::operator()(int exit_status) const {
+  return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;
+}
+# endif  // !GTEST_OS_WINDOWS
+
+namespace internal {
+
+// Utilities needed for death tests.
+
+// Generates a textual description of a given exit code, in the format
+// specified by wait(2).
+static std::string ExitSummary(int exit_code) {
+  Message m;
+
+# if GTEST_OS_WINDOWS
+
+  m << "Exited with exit status " << exit_code;
+
+# else
+
+  if (WIFEXITED(exit_code)) {
+    m << "Exited with exit status " << WEXITSTATUS(exit_code);
+  } else if (WIFSIGNALED(exit_code)) {
+    m << "Terminated by signal " << WTERMSIG(exit_code);
+  }
+#  ifdef WCOREDUMP
+  if (WCOREDUMP(exit_code)) {
+    m << " (core dumped)";
+  }
+#  endif
+# endif  // GTEST_OS_WINDOWS
+
+  return m.GetString();
+}
+
+// Returns true if exit_status describes a process that was terminated
+// by a signal, or exited normally with a nonzero exit code.
+bool ExitedUnsuccessfully(int exit_status) {
+  return !ExitedWithCode(0)(exit_status);
+}
+
+# if !GTEST_OS_WINDOWS
+// Generates a textual failure message when a death test finds more than
+// one thread running, or cannot determine the number of threads, prior
+// to executing the given statement.  It is the responsibility of the
+// caller not to pass a thread_count of 1.
+static std::string DeathTestThreadWarning(size_t thread_count) {
+  Message msg;
+  msg << "Death tests use fork(), which is unsafe particularly"
+      << " in a threaded context. For this test, " << GTEST_NAME_ << " ";
+  if (thread_count == 0)
+    msg << "couldn't detect the number of threads.";
+  else
+    msg << "detected " << thread_count << " threads.";
+  return msg.GetString();
+}
+# endif  // !GTEST_OS_WINDOWS
+
+// Flag characters for reporting a death test that did not die.
+static const char kDeathTestLived = 'L';
+static const char kDeathTestReturned = 'R';
+static const char kDeathTestThrew = 'T';
+static const char kDeathTestInternalError = 'I';
+
+// An enumeration describing all of the possible ways that a death test can
+// conclude.  DIED means that the process died while executing the test
+// code; LIVED means that process lived beyond the end of the test code;
+// RETURNED means that the test statement attempted to execute a return
+// statement, which is not allowed; THREW means that the test statement
+// returned control by throwing an exception.  IN_PROGRESS means the test
+// has not yet concluded.
+// TODO(vladl@google.com): Unify names and possibly values for
+// AbortReason, DeathTestOutcome, and flag characters above.
+enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
+
+// Routine for aborting the program which is safe to call from an
+// exec-style death test child process, in which case the error
+// message is propagated back to the parent process.  Otherwise, the
+// message is simply printed to stderr.  In either case, the program
+// then exits with status 1.
+void DeathTestAbort(const std::string& message) {
+  // On a POSIX system, this function may be called from a threadsafe-style
+  // death test child process, which operates on a very small stack.  Use
+  // the heap for any additional non-minuscule memory requirements.
+  const InternalRunDeathTestFlag* const flag =
+      GetUnitTestImpl()->internal_run_death_test_flag();
+  if (flag != NULL) {
+    FILE* parent = posix::FDOpen(flag->write_fd(), "w");
+    fputc(kDeathTestInternalError, parent);
+    fprintf(parent, "%s", message.c_str());
+    fflush(parent);
+    _exit(1);
+  } else {
+    fprintf(stderr, "%s", message.c_str());
+    fflush(stderr);
+    posix::Abort();
+  }
+}
+
+// A replacement for CHECK that calls DeathTestAbort if the assertion
+// fails.
+# define GTEST_DEATH_TEST_CHECK_(expression) \
+  do { \
+    if (!::testing::internal::IsTrue(expression)) { \
+      DeathTestAbort( \
+          ::std::string("CHECK failed: File ") + __FILE__ +  ", line " \
+          + ::testing::internal::StreamableToString(__LINE__) + ": " \
+          + #expression); \
+    } \
+  } while (::testing::internal::AlwaysFalse())
+
+// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for
+// evaluating any system call that fulfills two conditions: it must return
+// -1 on failure, and set errno to EINTR when it is interrupted and
+// should be tried again.  The macro expands to a loop that repeatedly
+// evaluates the expression as long as it evaluates to -1 and sets
+// errno to EINTR.  If the expression evaluates to -1 but errno is
+// something other than EINTR, DeathTestAbort is called.
+# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \
+  do { \
+    int gtest_retval; \
+    do { \
+      gtest_retval = (expression); \
+    } while (gtest_retval == -1 && errno == EINTR); \
+    if (gtest_retval == -1) { \
+      DeathTestAbort( \
+          ::std::string("CHECK failed: File ") + __FILE__ + ", line " \
+          + ::testing::internal::StreamableToString(__LINE__) + ": " \
+          + #expression + " != -1"); \
+    } \
+  } while (::testing::internal::AlwaysFalse())
+
+// Returns the message describing the last system error in errno.
+std::string GetLastErrnoDescription() {
+    return errno == 0 ? "" : posix::StrError(errno);
+}
+
+// This is called from a death test parent process to read a failure
+// message from the death test child process and log it with the FATAL
+// severity. On Windows, the message is read from a pipe handle. On other
+// platforms, it is read from a file descriptor.
+static void FailFromInternalError(int fd) {
+  Message error;
+  char buffer[256];
+  int num_read;
+
+  do {
+    while ((num_read = posix::Read(fd, buffer, 255)) > 0) {
+      buffer[num_read] = '\0';
+      error << buffer;
+    }
+  } while (num_read == -1 && errno == EINTR);
+
+  if (num_read == 0) {
+    GTEST_LOG_(FATAL) << error.GetString();
+  } else {
+    const int last_error = errno;
+    GTEST_LOG_(FATAL) << "Error while reading death test internal: "
+                      << GetLastErrnoDescription() << " [" << last_error << "]";
+  }
+}
+
+// Death test constructor.  Increments the running death test count
+// for the current test.
+DeathTest::DeathTest() {
+  TestInfo* const info = GetUnitTestImpl()->current_test_info();
+  if (info == NULL) {
+    DeathTestAbort("Cannot run a death test outside of a TEST or "
+                   "TEST_F construct");
+  }
+}
+
+// Creates and returns a death test by dispatching to the current
+// death test factory.
+bool DeathTest::Create(const char* statement, const RE* regex,
+                       const char* file, int line, DeathTest** test) {
+  return GetUnitTestImpl()->death_test_factory()->Create(
+      statement, regex, file, line, test);
+}
+
+const char* DeathTest::LastMessage() {
+  return last_death_test_message_.c_str();
+}
+
+void DeathTest::set_last_death_test_message(const std::string& message) {
+  last_death_test_message_ = message;
+}
+
+std::string DeathTest::last_death_test_message_;
+
+// Provides cross platform implementation for some death functionality.
+class DeathTestImpl : public DeathTest {
+ protected:
+  DeathTestImpl(const char* a_statement, const RE* a_regex)
+      : statement_(a_statement),
+        regex_(a_regex),
+        spawned_(false),
+        status_(-1),
+        outcome_(IN_PROGRESS),
+        read_fd_(-1),
+        write_fd_(-1) {}
+
+  // read_fd_ is expected to be closed and cleared by a derived class.
+  ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }
+
+  void Abort(AbortReason reason);
+  virtual bool Passed(bool status_ok);
+
+  const char* statement() const { return statement_; }
+  const RE* regex() const { return regex_; }
+  bool spawned() const { return spawned_; }
+  void set_spawned(bool is_spawned) { spawned_ = is_spawned; }
+  int status() const { return status_; }
+  void set_status(int a_status) { status_ = a_status; }
+  DeathTestOutcome outcome() const { return outcome_; }
+  void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }
+  int read_fd() const { return read_fd_; }
+  void set_read_fd(int fd) { read_fd_ = fd; }
+  int write_fd() const { return write_fd_; }
+  void set_write_fd(int fd) { write_fd_ = fd; }
+
+  // Called in the parent process only. Reads the result code of the death
+  // test child process via a pipe, interprets it to set the outcome_
+  // member, and closes read_fd_.  Outputs diagnostics and terminates in
+  // case of unexpected codes.
+  void ReadAndInterpretStatusByte();
+
+ private:
+  // The textual content of the code this object is testing.  This class
+  // doesn't own this string and should not attempt to delete it.
+  const char* const statement_;
+  // The regular expression which test output must match.  DeathTestImpl
+  // doesn't own this object and should not attempt to delete it.
+  const RE* const regex_;
+  // True if the death test child process has been successfully spawned.
+  bool spawned_;
+  // The exit status of the child process.
+  int status_;
+  // How the death test concluded.
+  DeathTestOutcome outcome_;
+  // Descriptor to the read end of the pipe to the child process.  It is
+  // always -1 in the child process.  The child keeps its write end of the
+  // pipe in write_fd_.
+  int read_fd_;
+  // Descriptor to the child's write end of the pipe to the parent process.
+  // It is always -1 in the parent process.  The parent keeps its end of the
+  // pipe in read_fd_.
+  int write_fd_;
+};
+
+// Called in the parent process only. Reads the result code of the death
+// test child process via a pipe, interprets it to set the outcome_
+// member, and closes read_fd_.  Outputs diagnostics and terminates in
+// case of unexpected codes.
+void DeathTestImpl::ReadAndInterpretStatusByte() {
+  char flag;
+  int bytes_read;
+
+  // The read() here blocks until data is available (signifying the
+  // failure of the death test) or until the pipe is closed (signifying
+  // its success), so it's okay to call this in the parent before
+  // the child process has exited.
+  do {
+    bytes_read = posix::Read(read_fd(), &flag, 1);
+  } while (bytes_read == -1 && errno == EINTR);
+
+  if (bytes_read == 0) {
+    set_outcome(DIED);
+  } else if (bytes_read == 1) {
+    switch (flag) {
+      case kDeathTestReturned:
+        set_outcome(RETURNED);
+        break;
+      case kDeathTestThrew:
+        set_outcome(THREW);
+        break;
+      case kDeathTestLived:
+        set_outcome(LIVED);
+        break;
+      case kDeathTestInternalError:
+        FailFromInternalError(read_fd());  // Does not return.
+        break;
+      default:
+        GTEST_LOG_(FATAL) << "Death test child process reported "
+                          << "unexpected status byte ("
+                          << static_cast<unsigned int>(flag) << ")";
+    }
+  } else {
+    GTEST_LOG_(FATAL) << "Read from death test child process failed: "
+                      << GetLastErrnoDescription();
+  }
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));
+  set_read_fd(-1);
+}
+
+// Signals that the death test code which should have exited, didn't.
+// Should be called only in a death test child process.
+// Writes a status byte to the child's status file descriptor, then
+// calls _exit(1).
+void DeathTestImpl::Abort(AbortReason reason) {
+  // The parent process considers the death test to be a failure if
+  // it finds any data in our pipe.  So, here we write a single flag byte
+  // to the pipe, then exit.
+  const char status_ch =
+      reason == TEST_DID_NOT_DIE ? kDeathTestLived :
+      reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;
+
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
+  // We are leaking the descriptor here because on some platforms (i.e.,
+  // when built as Windows DLL), destructors of global objects will still
+  // run after calling _exit(). On such systems, write_fd_ will be
+  // indirectly closed from the destructor of UnitTestImpl, causing double
+  // close if it is also closed here. On debug configurations, double close
+  // may assert. As there are no in-process buffers to flush here, we are
+  // relying on the OS to close the descriptor after the process terminates
+  // when the destructors are not run.
+  _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)
+}
+
+// Returns an indented copy of stderr output for a death test.
+// This makes distinguishing death test output lines from regular log lines
+// much easier.
+static ::std::string FormatDeathTestOutput(const ::std::string& output) {
+  ::std::string ret;
+  for (size_t at = 0; ; ) {
+    const size_t line_end = output.find('\n', at);
+    ret += "[  DEATH   ] ";
+    if (line_end == ::std::string::npos) {
+      ret += output.substr(at);
+      break;
+    }
+    ret += output.substr(at, line_end + 1 - at);
+    at = line_end + 1;
+  }
+  return ret;
+}
+
+// Assesses the success or failure of a death test, using both private
+// members which have previously been set, and one argument:
+//
+// Private data members:
+//   outcome:  An enumeration describing how the death test
+//             concluded: DIED, LIVED, THREW, or RETURNED.  The death test
+//             fails in the latter three cases.
+//   status:   The exit status of the child process. On *nix, it is in the
+//             in the format specified by wait(2). On Windows, this is the
+//             value supplied to the ExitProcess() API or a numeric code
+//             of the exception that terminated the program.
+//   regex:    A regular expression object to be applied to
+//             the test's captured standard error output; the death test
+//             fails if it does not match.
+//
+// Argument:
+//   status_ok: true if exit_status is acceptable in the context of
+//              this particular death test, which fails if it is false
+//
+// Returns true iff all of the above conditions are met.  Otherwise, the
+// first failing condition, in the order given above, is the one that is
+// reported. Also sets the last death test message string.
+bool DeathTestImpl::Passed(bool status_ok) {
+  if (!spawned())
+    return false;
+
+  const std::string error_message = GetCapturedStderr();
+
+  bool success = false;
+  Message buffer;
+
+  buffer << "Death test: " << statement() << "\n";
+  switch (outcome()) {
+    case LIVED:
+      buffer << "    Result: failed to die.\n"
+             << " Error msg:\n" << FormatDeathTestOutput(error_message);
+      break;
+    case THREW:
+      buffer << "    Result: threw an exception.\n"
+             << " Error msg:\n" << FormatDeathTestOutput(error_message);
+      break;
+    case RETURNED:
+      buffer << "    Result: illegal return in test statement.\n"
+             << " Error msg:\n" << FormatDeathTestOutput(error_message);
+      break;
+    case DIED:
+      if (status_ok) {
+        const bool matched = RE::PartialMatch(error_message.c_str(), *regex());
+        if (matched) {
+          success = true;
+        } else {
+          buffer << "    Result: died but not with expected error.\n"
+                 << "  Expected: " << regex()->pattern() << "\n"
+                 << "Actual msg:\n" << FormatDeathTestOutput(error_message);
+        }
+      } else {
+        buffer << "    Result: died but not with expected exit code:\n"
+               << "            " << ExitSummary(status()) << "\n"
+               << "Actual msg:\n" << FormatDeathTestOutput(error_message);
+      }
+      break;
+    case IN_PROGRESS:
+    default:
+      GTEST_LOG_(FATAL)
+          << "DeathTest::Passed somehow called before conclusion of test";
+  }
+
+  DeathTest::set_last_death_test_message(buffer.GetString());
+  return success;
+}
+
+# if GTEST_OS_WINDOWS
+// WindowsDeathTest implements death tests on Windows. Due to the
+// specifics of starting new processes on Windows, death tests there are
+// always threadsafe, and Google Test considers the
+// --gtest_death_test_style=fast setting to be equivalent to
+// --gtest_death_test_style=threadsafe there.
+//
+// A few implementation notes:  Like the Linux version, the Windows
+// implementation uses pipes for child-to-parent communication. But due to
+// the specifics of pipes on Windows, some extra steps are required:
+//
+// 1. The parent creates a communication pipe and stores handles to both
+//    ends of it.
+// 2. The parent starts the child and provides it with the information
+//    necessary to acquire the handle to the write end of the pipe.
+// 3. The child acquires the write end of the pipe and signals the parent
+//    using a Windows event.
+// 4. Now the parent can release the write end of the pipe on its side. If
+//    this is done before step 3, the object's reference count goes down to
+//    0 and it is destroyed, preventing the child from acquiring it. The
+//    parent now has to release it, or read operations on the read end of
+//    the pipe will not return when the child terminates.
+// 5. The parent reads child's output through the pipe (outcome code and
+//    any possible error messages) from the pipe, and its stderr and then
+//    determines whether to fail the test.
+//
+// Note: to distinguish Win32 API calls from the local method and function
+// calls, the former are explicitly resolved in the global namespace.
+//
+class WindowsDeathTest : public DeathTestImpl {
+ public:
+  WindowsDeathTest(const char* a_statement,
+                   const RE* a_regex,
+                   const char* file,
+                   int line)
+      : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {}
+
+  // All of these virtual functions are inherited from DeathTest.
+  virtual int Wait();
+  virtual TestRole AssumeRole();
+
+ private:
+  // The name of the file in which the death test is located.
+  const char* const file_;
+  // The line number on which the death test is located.
+  const int line_;
+  // Handle to the write end of the pipe to the child process.
+  AutoHandle write_handle_;
+  // Child process handle.
+  AutoHandle child_handle_;
+  // Event the child process uses to signal the parent that it has
+  // acquired the handle to the write end of the pipe. After seeing this
+  // event the parent can release its own handles to make sure its
+  // ReadFile() calls return when the child terminates.
+  AutoHandle event_handle_;
+};
+
+// Waits for the child in a death test to exit, returning its exit
+// status, or 0 if no child process exists.  As a side effect, sets the
+// outcome data member.
+int WindowsDeathTest::Wait() {
+  if (!spawned())
+    return 0;
+
+  // Wait until the child either signals that it has acquired the write end
+  // of the pipe or it dies.
+  const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
+  switch (::WaitForMultipleObjects(2,
+                                   wait_handles,
+                                   FALSE,  // Waits for any of the handles.
+                                   INFINITE)) {
+    case WAIT_OBJECT_0:
+    case WAIT_OBJECT_0 + 1:
+      break;
+    default:
+      GTEST_DEATH_TEST_CHECK_(false);  // Should not get here.
+  }
+
+  // The child has acquired the write end of the pipe or exited.
+  // We release the handle on our side and continue.
+  write_handle_.Reset();
+  event_handle_.Reset();
+
+  ReadAndInterpretStatusByte();
+
+  // Waits for the child process to exit if it haven't already. This
+  // returns immediately if the child has already exited, regardless of
+  // whether previous calls to WaitForMultipleObjects synchronized on this
+  // handle or not.
+  GTEST_DEATH_TEST_CHECK_(
+      WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),
+                                             INFINITE));
+  DWORD status_code;
+  GTEST_DEATH_TEST_CHECK_(
+      ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);
+  child_handle_.Reset();
+  set_status(static_cast<int>(status_code));
+  return status();
+}
+
+// The AssumeRole process for a Windows death test.  It creates a child
+// process with the same executable as the current process to run the
+// death test.  The child process is given the --gtest_filter and
+// --gtest_internal_run_death_test flags such that it knows to run the
+// current death test only.
+DeathTest::TestRole WindowsDeathTest::AssumeRole() {
+  const UnitTestImpl* const impl = GetUnitTestImpl();
+  const InternalRunDeathTestFlag* const flag =
+      impl->internal_run_death_test_flag();
+  const TestInfo* const info = impl->current_test_info();
+  const int death_test_index = info->result()->death_test_count();
+
+  if (flag != NULL) {
+    // ParseInternalRunDeathTestFlag() has performed all the necessary
+    // processing.
+    set_write_fd(flag->write_fd());
+    return EXECUTE_TEST;
+  }
+
+  // WindowsDeathTest uses an anonymous pipe to communicate results of
+  // a death test.
+  SECURITY_ATTRIBUTES handles_are_inheritable = {
+    sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
+  HANDLE read_handle, write_handle;
+  GTEST_DEATH_TEST_CHECK_(
+      ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable,
+                   0)  // Default buffer size.
+      != FALSE);
+  set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle),
+                                O_RDONLY));
+  write_handle_.Reset(write_handle);
+  event_handle_.Reset(::CreateEvent(
+      &handles_are_inheritable,
+      TRUE,    // The event will automatically reset to non-signaled state.
+      FALSE,   // The initial state is non-signalled.
+      NULL));  // The even is unnamed.
+  GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL);
+  const std::string filter_flag =
+      std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" +
+      info->test_case_name() + "." + info->name();
+  const std::string internal_flag =
+      std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag +
+      "=" + file_ + "|" + StreamableToString(line_) + "|" +
+      StreamableToString(death_test_index) + "|" +
+      StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) +
+      // size_t has the same width as pointers on both 32-bit and 64-bit
+      // Windows platforms.
+      // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
+      "|" + StreamableToString(reinterpret_cast<size_t>(write_handle)) +
+      "|" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get()));
+
+  char executable_path[_MAX_PATH + 1];  // NOLINT
+  GTEST_DEATH_TEST_CHECK_(
+      _MAX_PATH + 1 != ::GetModuleFileNameA(NULL,
+                                            executable_path,
+                                            _MAX_PATH));
+
+  std::string command_line =
+      std::string(::GetCommandLineA()) + " " + filter_flag + " \"" +
+      internal_flag + "\"";
+
+  DeathTest::set_last_death_test_message("");
+
+  CaptureStderr();
+  // Flush the log buffers since the log streams are shared with the child.
+  FlushInfoLog();
+
+  // The child process will share the standard handles with the parent.
+  STARTUPINFOA startup_info;
+  memset(&startup_info, 0, sizeof(STARTUPINFO));
+  startup_info.dwFlags = STARTF_USESTDHANDLES;
+  startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);
+  startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
+  startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);
+
+  PROCESS_INFORMATION process_info;
+  GTEST_DEATH_TEST_CHECK_(::CreateProcessA(
+      executable_path,
+      const_cast<char*>(command_line.c_str()),
+      NULL,   // Retuned process handle is not inheritable.
+      NULL,   // Retuned thread handle is not inheritable.
+      TRUE,   // Child inherits all inheritable handles (for write_handle_).
+      0x0,    // Default creation flags.
+      NULL,   // Inherit the parent's environment.
+      UnitTest::GetInstance()->original_working_dir(),
+      &startup_info,
+      &process_info) != FALSE);
+  child_handle_.Reset(process_info.hProcess);
+  ::CloseHandle(process_info.hThread);
+  set_spawned(true);
+  return OVERSEE_TEST;
+}
+# else  // We are not on Windows.
+
+// ForkingDeathTest provides implementations for most of the abstract
+// methods of the DeathTest interface.  Only the AssumeRole method is
+// left undefined.
+class ForkingDeathTest : public DeathTestImpl {
+ public:
+  ForkingDeathTest(const char* statement, const RE* regex);
+
+  // All of these virtual functions are inherited from DeathTest.
+  virtual int Wait();
+
+ protected:
+  void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }
+
+ private:
+  // PID of child process during death test; 0 in the child process itself.
+  pid_t child_pid_;
+};
+
+// Constructs a ForkingDeathTest.
+ForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex)
+    : DeathTestImpl(a_statement, a_regex),
+      child_pid_(-1) {}
+
+// Waits for the child in a death test to exit, returning its exit
+// status, or 0 if no child process exists.  As a side effect, sets the
+// outcome data member.
+int ForkingDeathTest::Wait() {
+  if (!spawned())
+    return 0;
+
+  ReadAndInterpretStatusByte();
+
+  int status_value;
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));
+  set_status(status_value);
+  return status_value;
+}
+
+// A concrete death test class that forks, then immediately runs the test
+// in the child process.
+class NoExecDeathTest : public ForkingDeathTest {
+ public:
+  NoExecDeathTest(const char* a_statement, const RE* a_regex) :
+      ForkingDeathTest(a_statement, a_regex) { }
+  virtual TestRole AssumeRole();
+};
+
+// The AssumeRole process for a fork-and-run death test.  It implements a
+// straightforward fork, with a simple pipe to transmit the status byte.
+DeathTest::TestRole NoExecDeathTest::AssumeRole() {
+  const size_t thread_count = GetThreadCount();
+  if (thread_count != 1) {
+    GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count);
+  }
+
+  int pipe_fd[2];
+  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);
+
+  DeathTest::set_last_death_test_message("");
+  CaptureStderr();
+  // When we fork the process below, the log file buffers are copied, but the
+  // file descriptors are shared.  We flush all log files here so that closing
+  // the file descriptors in the child process doesn't throw off the
+  // synchronization between descriptors and buffers in the parent process.
+  // This is as close to the fork as possible to avoid a race condition in case
+  // there are multiple threads running before the death test, and another
+  // thread writes to the log file.
+  FlushInfoLog();
+
+  const pid_t child_pid = fork();
+  GTEST_DEATH_TEST_CHECK_(child_pid != -1);
+  set_child_pid(child_pid);
+  if (child_pid == 0) {
+    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0]));
+    set_write_fd(pipe_fd[1]);
+    // Redirects all logging to stderr in the child process to prevent
+    // concurrent writes to the log files.  We capture stderr in the parent
+    // process and append the child process' output to a log.
+    LogToStderr();
+    // Event forwarding to the listeners of event listener API mush be shut
+    // down in death test subprocesses.
+    GetUnitTestImpl()->listeners()->SuppressEventForwarding();
+    g_in_fast_death_test_child = true;
+    return EXECUTE_TEST;
+  } else {
+    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
+    set_read_fd(pipe_fd[0]);
+    set_spawned(true);
+    return OVERSEE_TEST;
+  }
+}
+
+// A concrete death test class that forks and re-executes the main
+// program from the beginning, with command-line flags set that cause
+// only this specific death test to be run.
+class ExecDeathTest : public ForkingDeathTest {
+ public:
+  ExecDeathTest(const char* a_statement, const RE* a_regex,
+                const char* file, int line) :
+      ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
+  virtual TestRole AssumeRole();
+ private:
+  static ::std::vector<testing::internal::string>
+  GetArgvsForDeathTestChildProcess() {
+    ::std::vector<testing::internal::string> args = GetInjectableArgvs();
+    return args;
+  }
+  // The name of the file in which the death test is located.
+  const char* const file_;
+  // The line number on which the death test is located.
+  const int line_;
+};
+
+// Utility class for accumulating command-line arguments.
+class Arguments {
+ public:
+  Arguments() {
+    args_.push_back(NULL);
+  }
+
+  ~Arguments() {
+    for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();
+         ++i) {
+      free(*i);
+    }
+  }
+  void AddArgument(const char* argument) {
+    args_.insert(args_.end() - 1, posix::StrDup(argument));
+  }
+
+  template <typename Str>
+  void AddArguments(const ::std::vector<Str>& arguments) {
+    for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
+         i != arguments.end();
+         ++i) {
+      args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
+    }
+  }
+  char* const* Argv() {
+    return &args_[0];
+  }
+
+ private:
+  std::vector<char*> args_;
+};
+
+// A struct that encompasses the arguments to the child process of a
+// threadsafe-style death test process.
+struct ExecDeathTestArgs {
+  char* const* argv;  // Command-line arguments for the child's call to exec
+  int close_fd;       // File descriptor to close; the read end of a pipe
+};
+
+#  if GTEST_OS_MAC
+inline char** GetEnviron() {
+  // When Google Test is built as a framework on MacOS X, the environ variable
+  // is unavailable. Apple's documentation (man environ) recommends using
+  // _NSGetEnviron() instead.
+  return *_NSGetEnviron();
+}
+#  else
+// Some POSIX platforms expect you to declare environ. extern "C" makes
+// it reside in the global namespace.
+extern "C" char** environ;
+inline char** GetEnviron() { return environ; }
+#  endif  // GTEST_OS_MAC
+
+#  if !GTEST_OS_QNX
+// The main function for a threadsafe-style death test child process.
+// This function is called in a clone()-ed process and thus must avoid
+// any potentially unsafe operations like malloc or libc functions.
+static int ExecDeathTestChildMain(void* child_arg) {
+  ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg);
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));
+
+  // We need to execute the test program in the same environment where
+  // it was originally invoked.  Therefore we change to the original
+  // working directory first.
+  const char* const original_dir =
+      UnitTest::GetInstance()->original_working_dir();
+  // We can safely call chdir() as it's a direct system call.
+  if (chdir(original_dir) != 0) {
+    DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " +
+                   GetLastErrnoDescription());
+    return EXIT_FAILURE;
+  }
+
+  // We can safely call execve() as it's a direct system call.  We
+  // cannot use execvp() as it's a libc function and thus potentially
+  // unsafe.  Since execve() doesn't search the PATH, the user must
+  // invoke the test program via a valid path that contains at least
+  // one path separator.
+  execve(args->argv[0], args->argv, GetEnviron());
+  DeathTestAbort(std::string("execve(") + args->argv[0] + ", ...) in " +
+                 original_dir + " failed: " +
+                 GetLastErrnoDescription());
+  return EXIT_FAILURE;
+}
+#  endif  // !GTEST_OS_QNX
+
+// Two utility routines that together determine the direction the stack
+// grows.
+// This could be accomplished more elegantly by a single recursive
+// function, but we want to guard against the unlikely possibility of
+// a smart compiler optimizing the recursion away.
+//
+// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining
+// StackLowerThanAddress into StackGrowsDown, which then doesn't give
+// correct answer.
+void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_;
+void StackLowerThanAddress(const void* ptr, bool* result) {
+  int dummy;
+  *result = (&dummy < ptr);
+}
+
+bool StackGrowsDown() {
+  int dummy;
+  bool result;
+  StackLowerThanAddress(&dummy, &result);
+  return result;
+}
+
+// Spawns a child process with the same executable as the current process in
+// a thread-safe manner and instructs it to run the death test.  The
+// implementation uses fork(2) + exec.  On systems where clone(2) is
+// available, it is used instead, being slightly more thread-safe.  On QNX,
+// fork supports only single-threaded environments, so this function uses
+// spawn(2) there instead.  The function dies with an error message if
+// anything goes wrong.
+static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
+  ExecDeathTestArgs args = { argv, close_fd };
+  pid_t child_pid = -1;
+
+#  if GTEST_OS_QNX
+  // Obtains the current directory and sets it to be closed in the child
+  // process.
+  const int cwd_fd = open(".", O_RDONLY);
+  GTEST_DEATH_TEST_CHECK_(cwd_fd != -1);
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC));
+  // We need to execute the test program in the same environment where
+  // it was originally invoked.  Therefore we change to the original
+  // working directory first.
+  const char* const original_dir =
+      UnitTest::GetInstance()->original_working_dir();
+  // We can safely call chdir() as it's a direct system call.
+  if (chdir(original_dir) != 0) {
+    DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " +
+                   GetLastErrnoDescription());
+    return EXIT_FAILURE;
+  }
+
+  int fd_flags;
+  // Set close_fd to be closed after spawn.
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD));
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD,
+                                        fd_flags | FD_CLOEXEC));
+  struct inheritance inherit = {0};
+  // spawn is a system call.
+  child_pid = spawn(args.argv[0], 0, NULL, &inherit, args.argv, GetEnviron());
+  // Restores the current working directory.
+  GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1);
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd));
+
+#  else   // GTEST_OS_QNX
+#   if GTEST_OS_LINUX
+  // When a SIGPROF signal is received while fork() or clone() are executing,
+  // the process may hang. To avoid this, we ignore SIGPROF here and re-enable
+  // it after the call to fork()/clone() is complete.
+  struct sigaction saved_sigprof_action;
+  struct sigaction ignore_sigprof_action;
+  memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action));
+  sigemptyset(&ignore_sigprof_action.sa_mask);
+  ignore_sigprof_action.sa_handler = SIG_IGN;
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction(
+      SIGPROF, &ignore_sigprof_action, &saved_sigprof_action));
+#   endif  // GTEST_OS_LINUX
+
+#   if GTEST_HAS_CLONE
+  const bool use_fork = GTEST_FLAG(death_test_use_fork);
+
+  if (!use_fork) {
+    static const bool stack_grows_down = StackGrowsDown();
+    const size_t stack_size = getpagesize();
+    // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
+    void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE,
+                             MAP_ANON | MAP_PRIVATE, -1, 0);
+    GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);
+
+    // Maximum stack alignment in bytes:  For a downward-growing stack, this
+    // amount is subtracted from size of the stack space to get an address
+    // that is within the stack space and is aligned on all systems we care
+    // about.  As far as I know there is no ABI with stack alignment greater
+    // than 64.  We assume stack and stack_size already have alignment of
+    // kMaxStackAlignment.
+    const size_t kMaxStackAlignment = 64;
+    void* const stack_top =
+        static_cast<char*>(stack) +
+            (stack_grows_down ? stack_size - kMaxStackAlignment : 0);
+    GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment &&
+        reinterpret_cast<intptr_t>(stack_top) % kMaxStackAlignment == 0);
+
+    child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);
+
+    GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);
+  }
+#   else
+  const bool use_fork = true;
+#   endif  // GTEST_HAS_CLONE
+
+  if (use_fork && (child_pid = fork()) == 0) {
+      ExecDeathTestChildMain(&args);
+      _exit(0);
+  }
+#  endif  // GTEST_OS_QNX
+#  if GTEST_OS_LINUX
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(
+      sigaction(SIGPROF, &saved_sigprof_action, NULL));
+#  endif  // GTEST_OS_LINUX
+
+  GTEST_DEATH_TEST_CHECK_(child_pid != -1);
+  return child_pid;
+}
+
+// The AssumeRole process for a fork-and-exec death test.  It re-executes the
+// main program from the beginning, setting the --gtest_filter
+// and --gtest_internal_run_death_test flags to cause only the current
+// death test to be re-run.
+DeathTest::TestRole ExecDeathTest::AssumeRole() {
+  const UnitTestImpl* const impl = GetUnitTestImpl();
+  const InternalRunDeathTestFlag* const flag =
+      impl->internal_run_death_test_flag();
+  const TestInfo* const info = impl->current_test_info();
+  const int death_test_index = info->result()->death_test_count();
+
+  if (flag != NULL) {
+    set_write_fd(flag->write_fd());
+    return EXECUTE_TEST;
+  }
+
+  int pipe_fd[2];
+  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);
+  // Clear the close-on-exec flag on the write end of the pipe, lest
+  // it be closed when the child process does an exec:
+  GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);
+
+  const std::string filter_flag =
+      std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "="
+      + info->test_case_name() + "." + info->name();
+  const std::string internal_flag =
+      std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "="
+      + file_ + "|" + StreamableToString(line_) + "|"
+      + StreamableToString(death_test_index) + "|"
+      + StreamableToString(pipe_fd[1]);
+  Arguments args;
+  args.AddArguments(GetArgvsForDeathTestChildProcess());
+  args.AddArgument(filter_flag.c_str());
+  args.AddArgument(internal_flag.c_str());
+
+  DeathTest::set_last_death_test_message("");
+
+  CaptureStderr();
+  // See the comment in NoExecDeathTest::AssumeRole for why the next line
+  // is necessary.
+  FlushInfoLog();
+
+  const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]);
+  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
+  set_child_pid(child_pid);
+  set_read_fd(pipe_fd[0]);
+  set_spawned(true);
+  return OVERSEE_TEST;
+}
+
+# endif  // !GTEST_OS_WINDOWS
+
+// Creates a concrete DeathTest-derived class that depends on the
+// --gtest_death_test_style flag, and sets the pointer pointed to
+// by the "test" argument to its address.  If the test should be
+// skipped, sets that pointer to NULL.  Returns true, unless the
+// flag is set to an invalid value.
+bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
+                                     const char* file, int line,
+                                     DeathTest** test) {
+  UnitTestImpl* const impl = GetUnitTestImpl();
+  const InternalRunDeathTestFlag* const flag =
+      impl->internal_run_death_test_flag();
+  const int death_test_index = impl->current_test_info()
+      ->increment_death_test_count();
+
+  if (flag != NULL) {
+    if (death_test_index > flag->index()) {
+      DeathTest::set_last_death_test_message(
+          "Death test count (" + StreamableToString(death_test_index)
+          + ") somehow exceeded expected maximum ("
+          + StreamableToString(flag->index()) + ")");
+      return false;
+    }
+
+    if (!(flag->file() == file && flag->line() == line &&
+          flag->index() == death_test_index)) {
+      *test = NULL;
+      return true;
+    }
+  }
+
+# if GTEST_OS_WINDOWS
+
+  if (GTEST_FLAG(death_test_style) == "threadsafe" ||
+      GTEST_FLAG(death_test_style) == "fast") {
+    *test = new WindowsDeathTest(statement, regex, file, line);
+  }
+
+# else
+
+  if (GTEST_FLAG(death_test_style) == "threadsafe") {
+    *test = new ExecDeathTest(statement, regex, file, line);
+  } else if (GTEST_FLAG(death_test_style) == "fast") {
+    *test = new NoExecDeathTest(statement, regex);
+  }
+
+# endif  // GTEST_OS_WINDOWS
+
+  else {  // NOLINT - this is more readable than unbalanced brackets inside #if.
+    DeathTest::set_last_death_test_message(
+        "Unknown death test style \"" + GTEST_FLAG(death_test_style)
+        + "\" encountered");
+    return false;
+  }
+
+  return true;
+}
+
+// Splits a given string on a given delimiter, populating a given
+// vector with the fields.  GTEST_HAS_DEATH_TEST implies that we have
+// ::std::string, so we can use it here.
+static void SplitString(const ::std::string& str, char delimiter,
+                        ::std::vector< ::std::string>* dest) {
+  ::std::vector< ::std::string> parsed;
+  ::std::string::size_type pos = 0;
+  while (::testing::internal::AlwaysTrue()) {
+    const ::std::string::size_type colon = str.find(delimiter, pos);
+    if (colon == ::std::string::npos) {
+      parsed.push_back(str.substr(pos));
+      break;
+    } else {
+      parsed.push_back(str.substr(pos, colon - pos));
+      pos = colon + 1;
+    }
+  }
+  dest->swap(parsed);
+}
+
+# if GTEST_OS_WINDOWS
+// Recreates the pipe and event handles from the provided parameters,
+// signals the event, and returns a file descriptor wrapped around the pipe
+// handle. This function is called in the child process only.
+int GetStatusFileDescriptor(unsigned int parent_process_id,
+                            size_t write_handle_as_size_t,
+                            size_t event_handle_as_size_t) {
+  AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,
+                                                   FALSE,  // Non-inheritable.
+                                                   parent_process_id));
+  if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {
+    DeathTestAbort("Unable to open parent process " +
+                   StreamableToString(parent_process_id));
+  }
+
+  // TODO(vladl@google.com): Replace the following check with a
+  // compile-time assertion when available.
+  GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t));
+
+  const HANDLE write_handle =
+      reinterpret_cast<HANDLE>(write_handle_as_size_t);
+  HANDLE dup_write_handle;
+
+  // The newly initialized handle is accessible only in in the parent
+  // process. To obtain one accessible within the child, we need to use
+  // DuplicateHandle.
+  if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
+                         ::GetCurrentProcess(), &dup_write_handle,
+                         0x0,    // Requested privileges ignored since
+                                 // DUPLICATE_SAME_ACCESS is used.
+                         FALSE,  // Request non-inheritable handler.
+                         DUPLICATE_SAME_ACCESS)) {
+    DeathTestAbort("Unable to duplicate the pipe handle " +
+                   StreamableToString(write_handle_as_size_t) +
+                   " from the parent process " +
+                   StreamableToString(parent_process_id));
+  }
+
+  const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t);
+  HANDLE dup_event_handle;
+
+  if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,
+                         ::GetCurrentProcess(), &dup_event_handle,
+                         0x0,
+                         FALSE,
+                         DUPLICATE_SAME_ACCESS)) {
+    DeathTestAbort("Unable to duplicate the event handle " +
+                   StreamableToString(event_handle_as_size_t) +
+                   " from the parent process " +
+                   StreamableToString(parent_process_id));
+  }
+
+  const int write_fd =
+      ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND);
+  if (write_fd == -1) {
+    DeathTestAbort("Unable to convert pipe handle " +
+                   StreamableToString(write_handle_as_size_t) +
+                   " to a file descriptor");
+  }
+
+  // Signals the parent that the write end of the pipe has been acquired
+  // so the parent can release its own write end.
+  ::SetEvent(dup_event_handle);
+
+  return write_fd;
+}
+# endif  // GTEST_OS_WINDOWS
+
+// Returns a newly created InternalRunDeathTestFlag object with fields
+// initialized from the GTEST_FLAG(internal_run_death_test) flag if
+// the flag is specified; otherwise returns NULL.
+InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
+  if (GTEST_FLAG(internal_run_death_test) == "") return NULL;
+
+  // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
+  // can use it here.
+  int line = -1;
+  int index = -1;
+  ::std::vector< ::std::string> fields;
+  SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);
+  int write_fd = -1;
+
+# if GTEST_OS_WINDOWS
+
+  unsigned int parent_process_id = 0;
+  size_t write_handle_as_size_t = 0;
+  size_t event_handle_as_size_t = 0;
+
+  if (fields.size() != 6
+      || !ParseNaturalNumber(fields[1], &line)
+      || !ParseNaturalNumber(fields[2], &index)
+      || !ParseNaturalNumber(fields[3], &parent_process_id)
+      || !ParseNaturalNumber(fields[4], &write_handle_as_size_t)
+      || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {
+    DeathTestAbort("Bad --gtest_internal_run_death_test flag: " +
+                   GTEST_FLAG(internal_run_death_test));
+  }
+  write_fd = GetStatusFileDescriptor(parent_process_id,
+                                     write_handle_as_size_t,
+                                     event_handle_as_size_t);
+# else
+
+  if (fields.size() != 4
+      || !ParseNaturalNumber(fields[1], &line)
+      || !ParseNaturalNumber(fields[2], &index)
+      || !ParseNaturalNumber(fields[3], &write_fd)) {
+    DeathTestAbort("Bad --gtest_internal_run_death_test flag: "
+        + GTEST_FLAG(internal_run_death_test));
+  }
+
+# endif  // GTEST_OS_WINDOWS
+
+  return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);
+}
+
+}  // namespace internal
+
+#endif  // GTEST_HAS_DEATH_TEST
+
+}  // namespace testing
diff --git a/test/fmw/gtest/src/gtest-filepath.cc b/test/fmw/gtest/src/gtest-filepath.cc
new file mode 100644
index 0000000..6be58b6
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-filepath.cc
@@ -0,0 +1,382 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: keith.ray@gmail.com (Keith Ray)
+
+#include "gtest/gtest-message.h"
+#include "gtest/internal/gtest-filepath.h"
+#include "gtest/internal/gtest-port.h"
+
+#include <stdlib.h>
+
+#if GTEST_OS_WINDOWS_MOBILE
+# include <windows.h>
+#elif GTEST_OS_WINDOWS
+# include <direct.h>
+# include <io.h>
+#elif GTEST_OS_SYMBIAN
+// Symbian OpenC has PATH_MAX in sys/syslimits.h
+# include <sys/syslimits.h>
+#else
+# include <limits.h>
+# include <climits>  // Some Linux distributions define PATH_MAX here.
+#endif  // GTEST_OS_WINDOWS_MOBILE
+
+#if GTEST_OS_WINDOWS
+# define GTEST_PATH_MAX_ _MAX_PATH
+#elif defined(PATH_MAX)
+# define GTEST_PATH_MAX_ PATH_MAX
+#elif defined(_XOPEN_PATH_MAX)
+# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX
+#else
+# define GTEST_PATH_MAX_ _POSIX_PATH_MAX
+#endif  // GTEST_OS_WINDOWS
+
+#include "gtest/internal/gtest-string.h"
+
+namespace testing {
+namespace internal {
+
+#if GTEST_OS_WINDOWS
+// On Windows, '\\' is the standard path separator, but many tools and the
+// Windows API also accept '/' as an alternate path separator. Unless otherwise
+// noted, a file path can contain either kind of path separators, or a mixture
+// of them.
+const char kPathSeparator = '\\';
+const char kAlternatePathSeparator = '/';
+const char kPathSeparatorString[] = "\\";
+const char kAlternatePathSeparatorString[] = "/";
+# if GTEST_OS_WINDOWS_MOBILE
+// Windows CE doesn't have a current directory. You should not use
+// the current directory in tests on Windows CE, but this at least
+// provides a reasonable fallback.
+const char kCurrentDirectoryString[] = "\\";
+// Windows CE doesn't define INVALID_FILE_ATTRIBUTES
+const DWORD kInvalidFileAttributes = 0xffffffff;
+# else
+const char kCurrentDirectoryString[] = ".\\";
+# endif  // GTEST_OS_WINDOWS_MOBILE
+#else
+const char kPathSeparator = '/';
+const char kPathSeparatorString[] = "/";
+const char kCurrentDirectoryString[] = "./";
+#endif  // GTEST_OS_WINDOWS
+
+// Returns whether the given character is a valid path separator.
+static bool IsPathSeparator(char c) {
+#if GTEST_HAS_ALT_PATH_SEP_
+  return (c == kPathSeparator) || (c == kAlternatePathSeparator);
+#else
+  return c == kPathSeparator;
+#endif
+}
+
+// Returns the current working directory, or "" if unsuccessful.
+FilePath FilePath::GetCurrentDir() {
+#if GTEST_OS_WINDOWS_MOBILE
+  // Windows CE doesn't have a current directory, so we just return
+  // something reasonable.
+  return FilePath(kCurrentDirectoryString);
+#elif GTEST_OS_WINDOWS
+  char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
+  return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
+#else
+  char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
+  return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
+#endif  // GTEST_OS_WINDOWS_MOBILE
+}
+
+// Returns a copy of the FilePath with the case-insensitive extension removed.
+// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
+// FilePath("dir/file"). If a case-insensitive extension is not
+// found, returns a copy of the original FilePath.
+FilePath FilePath::RemoveExtension(const char* extension) const {
+  const std::string dot_extension = std::string(".") + extension;
+  if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) {
+    return FilePath(pathname_.substr(
+        0, pathname_.length() - dot_extension.length()));
+  }
+  return *this;
+}
+
+// Returns a pointer to the last occurence of a valid path separator in
+// the FilePath. On Windows, for example, both '/' and '\' are valid path
+// separators. Returns NULL if no path separator was found.
+const char* FilePath::FindLastPathSeparator() const {
+  const char* const last_sep = strrchr(c_str(), kPathSeparator);
+#if GTEST_HAS_ALT_PATH_SEP_
+  const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);
+  // Comparing two pointers of which only one is NULL is undefined.
+  if (last_alt_sep != NULL &&
+      (last_sep == NULL || last_alt_sep > last_sep)) {
+    return last_alt_sep;
+  }
+#endif
+  return last_sep;
+}
+
+// Returns a copy of the FilePath with the directory part removed.
+// Example: FilePath("path/to/file").RemoveDirectoryName() returns
+// FilePath("file"). If there is no directory part ("just_a_file"), it returns
+// the FilePath unmodified. If there is no file part ("just_a_dir/") it
+// returns an empty FilePath ("").
+// On Windows platform, '\' is the path separator, otherwise it is '/'.
+FilePath FilePath::RemoveDirectoryName() const {
+  const char* const last_sep = FindLastPathSeparator();
+  return last_sep ? FilePath(last_sep + 1) : *this;
+}
+
+// RemoveFileName returns the directory path with the filename removed.
+// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
+// If the FilePath is "a_file" or "/a_file", RemoveFileName returns
+// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
+// not have a file, like "just/a/dir/", it returns the FilePath unmodified.
+// On Windows platform, '\' is the path separator, otherwise it is '/'.
+FilePath FilePath::RemoveFileName() const {
+  const char* const last_sep = FindLastPathSeparator();
+  std::string dir;
+  if (last_sep) {
+    dir = std::string(c_str(), last_sep + 1 - c_str());
+  } else {
+    dir = kCurrentDirectoryString;
+  }
+  return FilePath(dir);
+}
+
+// Helper functions for naming files in a directory for xml output.
+
+// Given directory = "dir", base_name = "test", number = 0,
+// extension = "xml", returns "dir/test.xml". If number is greater
+// than zero (e.g., 12), returns "dir/test_12.xml".
+// On Windows platform, uses \ as the separator rather than /.
+FilePath FilePath::MakeFileName(const FilePath& directory,
+                                const FilePath& base_name,
+                                int number,
+                                const char* extension) {
+  std::string file;
+  if (number == 0) {
+    file = base_name.string() + "." + extension;
+  } else {
+    file = base_name.string() + "_" + StreamableToString(number)
+        + "." + extension;
+  }
+  return ConcatPaths(directory, FilePath(file));
+}
+
+// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".
+// On Windows, uses \ as the separator rather than /.
+FilePath FilePath::ConcatPaths(const FilePath& directory,
+                               const FilePath& relative_path) {
+  if (directory.IsEmpty())
+    return relative_path;
+  const FilePath dir(directory.RemoveTrailingPathSeparator());
+  return FilePath(dir.string() + kPathSeparator + relative_path.string());
+}
+
+// Returns true if pathname describes something findable in the file-system,
+// either a file, directory, or whatever.
+bool FilePath::FileOrDirectoryExists() const {
+#if GTEST_OS_WINDOWS_MOBILE
+  LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());
+  const DWORD attributes = GetFileAttributes(unicode);
+  delete [] unicode;
+  return attributes != kInvalidFileAttributes;
+#else
+  posix::StatStruct file_stat;
+  return posix::Stat(pathname_.c_str(), &file_stat) == 0;
+#endif  // GTEST_OS_WINDOWS_MOBILE
+}
+
+// Returns true if pathname describes a directory in the file-system
+// that exists.
+bool FilePath::DirectoryExists() const {
+  bool result = false;
+#if GTEST_OS_WINDOWS
+  // Don't strip off trailing separator if path is a root directory on
+  // Windows (like "C:\\").
+  const FilePath& path(IsRootDirectory() ? *this :
+                                           RemoveTrailingPathSeparator());
+#else
+  const FilePath& path(*this);
+#endif
+
+#if GTEST_OS_WINDOWS_MOBILE
+  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
+  const DWORD attributes = GetFileAttributes(unicode);
+  delete [] unicode;
+  if ((attributes != kInvalidFileAttributes) &&
+      (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
+    result = true;
+  }
+#else
+  posix::StatStruct file_stat;
+  result = posix::Stat(path.c_str(), &file_stat) == 0 &&
+      posix::IsDir(file_stat);
+#endif  // GTEST_OS_WINDOWS_MOBILE
+
+  return result;
+}
+
+// Returns true if pathname describes a root directory. (Windows has one
+// root directory per disk drive.)
+bool FilePath::IsRootDirectory() const {
+#if GTEST_OS_WINDOWS
+  // TODO(wan@google.com): on Windows a network share like
+  // \\server\share can be a root directory, although it cannot be the
+  // current directory.  Handle this properly.
+  return pathname_.length() == 3 && IsAbsolutePath();
+#else
+  return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);
+#endif
+}
+
+// Returns true if pathname describes an absolute path.
+bool FilePath::IsAbsolutePath() const {
+  const char* const name = pathname_.c_str();
+#if GTEST_OS_WINDOWS
+  return pathname_.length() >= 3 &&
+     ((name[0] >= 'a' && name[0] <= 'z') ||
+      (name[0] >= 'A' && name[0] <= 'Z')) &&
+     name[1] == ':' &&
+     IsPathSeparator(name[2]);
+#else
+  return IsPathSeparator(name[0]);
+#endif
+}
+
+// Returns a pathname for a file that does not currently exist. The pathname
+// will be directory/base_name.extension or
+// directory/base_name_<number>.extension if directory/base_name.extension
+// already exists. The number will be incremented until a pathname is found
+// that does not already exist.
+// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
+// There could be a race condition if two or more processes are calling this
+// function at the same time -- they could both pick the same filename.
+FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
+                                          const FilePath& base_name,
+                                          const char* extension) {
+  FilePath full_pathname;
+  int number = 0;
+  do {
+    full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
+  } while (full_pathname.FileOrDirectoryExists());
+  return full_pathname;
+}
+
+// Returns true if FilePath ends with a path separator, which indicates that
+// it is intended to represent a directory. Returns false otherwise.
+// This does NOT check that a directory (or file) actually exists.
+bool FilePath::IsDirectory() const {
+  return !pathname_.empty() &&
+         IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);
+}
+
+// Create directories so that path exists. Returns true if successful or if
+// the directories already exist; returns false if unable to create directories
+// for any reason.
+bool FilePath::CreateDirectoriesRecursively() const {
+  if (!this->IsDirectory()) {
+    return false;
+  }
+
+  if (pathname_.length() == 0 || this->DirectoryExists()) {
+    return true;
+  }
+
+  const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());
+  return parent.CreateDirectoriesRecursively() && this->CreateFolder();
+}
+
+// Create the directory so that path exists. Returns true if successful or
+// if the directory already exists; returns false if unable to create the
+// directory for any reason, including if the parent directory does not
+// exist. Not named "CreateDirectory" because that's a macro on Windows.
+bool FilePath::CreateFolder() const {
+#if GTEST_OS_WINDOWS_MOBILE
+  FilePath removed_sep(this->RemoveTrailingPathSeparator());
+  LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
+  int result = CreateDirectory(unicode, NULL) ? 0 : -1;
+  delete [] unicode;
+#elif GTEST_OS_WINDOWS
+  int result = _mkdir(pathname_.c_str());
+#else
+  int result = mkdir(pathname_.c_str(), 0777);
+#endif  // GTEST_OS_WINDOWS_MOBILE
+
+  if (result == -1) {
+    return this->DirectoryExists();  // An error is OK if the directory exists.
+  }
+  return true;  // No error.
+}
+
+// If input name has a trailing separator character, remove it and return the
+// name, otherwise return the name string unmodified.
+// On Windows platform, uses \ as the separator, other platforms use /.
+FilePath FilePath::RemoveTrailingPathSeparator() const {
+  return IsDirectory()
+      ? FilePath(pathname_.substr(0, pathname_.length() - 1))
+      : *this;
+}
+
+// Removes any redundant separators that might be in the pathname.
+// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
+// redundancies that might be in a pathname involving "." or "..".
+// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share).
+void FilePath::Normalize() {
+  if (pathname_.c_str() == NULL) {
+    pathname_ = "";
+    return;
+  }
+  const char* src = pathname_.c_str();
+  char* const dest = new char[pathname_.length() + 1];
+  char* dest_ptr = dest;
+  memset(dest_ptr, 0, pathname_.length() + 1);
+
+  while (*src != '\0') {
+    *dest_ptr = *src;
+    if (!IsPathSeparator(*src)) {
+      src++;
+    } else {
+#if GTEST_HAS_ALT_PATH_SEP_
+      if (*dest_ptr == kAlternatePathSeparator) {
+        *dest_ptr = kPathSeparator;
+      }
+#endif
+      while (IsPathSeparator(*src))
+        src++;
+    }
+    dest_ptr++;
+  }
+  *dest_ptr = '\0';
+  pathname_ = dest;
+  delete[] dest;
+}
+
+}  // namespace internal
+}  // namespace testing
diff --git a/test/fmw/gtest/src/gtest-internal-inl.h b/test/fmw/gtest/src/gtest-internal-inl.h
new file mode 100644
index 0000000..35df303
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-internal-inl.h
@@ -0,0 +1,1218 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Utility functions and classes used by the Google C++ testing framework.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// This file contains purely Google Test's internal implementation.  Please
+// DO NOT #INCLUDE IT IN A USER PROGRAM.
+
+#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
+#define GTEST_SRC_GTEST_INTERNAL_INL_H_
+
+// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is
+// part of Google Test's implementation; otherwise it's undefined.
+#if !GTEST_IMPLEMENTATION_
+// A user is trying to include this from his code - just say no.
+# error "gtest-internal-inl.h is part of Google Test's internal implementation."
+# error "It must not be included except by Google Test itself."
+#endif  // GTEST_IMPLEMENTATION_
+
+#ifndef _WIN32_WCE
+# include <errno.h>
+#endif  // !_WIN32_WCE
+#include <stddef.h>
+#include <stdlib.h>  // For strtoll/_strtoul64/malloc/free.
+#include <string.h>  // For memmove.
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+#include "gtest/internal/gtest-port.h"
+
+#if GTEST_CAN_STREAM_RESULTS_
+# include <arpa/inet.h>  // NOLINT
+# include <netdb.h>  // NOLINT
+#endif
+
+#if GTEST_OS_WINDOWS
+# include <windows.h>  // NOLINT
+#endif  // GTEST_OS_WINDOWS
+
+#include "gtest/gtest.h"  // NOLINT
+#include "gtest/gtest-spi.h"
+
+namespace testing {
+
+// Declares the flags.
+//
+// We don't want the users to modify this flag in the code, but want
+// Google Test's own unit tests to be able to access it. Therefore we
+// declare it here as opposed to in gtest.h.
+GTEST_DECLARE_bool_(death_test_use_fork);
+
+namespace internal {
+
+// The value of GetTestTypeId() as seen from within the Google Test
+// library.  This is solely for testing GetTestTypeId().
+GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;
+
+// Names of the flags (needed for parsing Google Test flags).
+const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
+const char kBreakOnFailureFlag[] = "break_on_failure";
+const char kCatchExceptionsFlag[] = "catch_exceptions";
+const char kColorFlag[] = "color";
+const char kFilterFlag[] = "filter";
+const char kListTestsFlag[] = "list_tests";
+const char kOutputFlag[] = "output";
+const char kPrintTimeFlag[] = "print_time";
+const char kRandomSeedFlag[] = "random_seed";
+const char kRepeatFlag[] = "repeat";
+const char kShuffleFlag[] = "shuffle";
+const char kStackTraceDepthFlag[] = "stack_trace_depth";
+const char kStreamResultToFlag[] = "stream_result_to";
+const char kThrowOnFailureFlag[] = "throw_on_failure";
+
+// A valid random seed must be in [1, kMaxRandomSeed].
+const int kMaxRandomSeed = 99999;
+
+// g_help_flag is true iff the --help flag or an equivalent form is
+// specified on the command line.
+GTEST_API_ extern bool g_help_flag;
+
+// Returns the current time in milliseconds.
+GTEST_API_ TimeInMillis GetTimeInMillis();
+
+// Returns true iff Google Test should use colors in the output.
+GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
+
+// Formats the given time in milliseconds as seconds.
+GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);
+
+// Converts the given time in milliseconds to a date string in the ISO 8601
+// format, without the timezone information.  N.B.: due to the use the
+// non-reentrant localtime() function, this function is not thread safe.  Do
+// not use it in any code that can be called from multiple threads.
+GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms);
+
+// Parses a string for an Int32 flag, in the form of "--flag=value".
+//
+// On success, stores the value of the flag in *value, and returns
+// true.  On failure, returns false without changing *value.
+GTEST_API_ bool ParseInt32Flag(
+    const char* str, const char* flag, Int32* value);
+
+// Returns a random seed in range [1, kMaxRandomSeed] based on the
+// given --gtest_random_seed flag value.
+inline int GetRandomSeedFromFlag(Int32 random_seed_flag) {
+  const unsigned int raw_seed = (random_seed_flag == 0) ?
+      static_cast<unsigned int>(GetTimeInMillis()) :
+      static_cast<unsigned int>(random_seed_flag);
+
+  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that
+  // it's easy to type.
+  const int normalized_seed =
+      static_cast<int>((raw_seed - 1U) %
+                       static_cast<unsigned int>(kMaxRandomSeed)) + 1;
+  return normalized_seed;
+}
+
+// Returns the first valid random seed after 'seed'.  The behavior is
+// undefined if 'seed' is invalid.  The seed after kMaxRandomSeed is
+// considered to be 1.
+inline int GetNextRandomSeed(int seed) {
+  GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed)
+      << "Invalid random seed " << seed << " - must be in [1, "
+      << kMaxRandomSeed << "].";
+  const int next_seed = seed + 1;
+  return (next_seed > kMaxRandomSeed) ? 1 : next_seed;
+}
+
+// This class saves the values of all Google Test flags in its c'tor, and
+// restores them in its d'tor.
+class GTestFlagSaver {
+ public:
+  // The c'tor.
+  GTestFlagSaver() {
+    also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);
+    break_on_failure_ = GTEST_FLAG(break_on_failure);
+    catch_exceptions_ = GTEST_FLAG(catch_exceptions);
+    color_ = GTEST_FLAG(color);
+    death_test_style_ = GTEST_FLAG(death_test_style);
+    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
+    filter_ = GTEST_FLAG(filter);
+    internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
+    list_tests_ = GTEST_FLAG(list_tests);
+    output_ = GTEST_FLAG(output);
+    print_time_ = GTEST_FLAG(print_time);
+    random_seed_ = GTEST_FLAG(random_seed);
+    repeat_ = GTEST_FLAG(repeat);
+    shuffle_ = GTEST_FLAG(shuffle);
+    stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);
+    stream_result_to_ = GTEST_FLAG(stream_result_to);
+    throw_on_failure_ = GTEST_FLAG(throw_on_failure);
+  }
+
+  // The d'tor is not virtual.  DO NOT INHERIT FROM THIS CLASS.
+  ~GTestFlagSaver() {
+    GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;
+    GTEST_FLAG(break_on_failure) = break_on_failure_;
+    GTEST_FLAG(catch_exceptions) = catch_exceptions_;
+    GTEST_FLAG(color) = color_;
+    GTEST_FLAG(death_test_style) = death_test_style_;
+    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
+    GTEST_FLAG(filter) = filter_;
+    GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
+    GTEST_FLAG(list_tests) = list_tests_;
+    GTEST_FLAG(output) = output_;
+    GTEST_FLAG(print_time) = print_time_;
+    GTEST_FLAG(random_seed) = random_seed_;
+    GTEST_FLAG(repeat) = repeat_;
+    GTEST_FLAG(shuffle) = shuffle_;
+    GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;
+    GTEST_FLAG(stream_result_to) = stream_result_to_;
+    GTEST_FLAG(throw_on_failure) = throw_on_failure_;
+  }
+
+ private:
+  // Fields for saving the original values of flags.
+  bool also_run_disabled_tests_;
+  bool break_on_failure_;
+  bool catch_exceptions_;
+  std::string color_;
+  std::string death_test_style_;
+  bool death_test_use_fork_;
+  std::string filter_;
+  std::string internal_run_death_test_;
+  bool list_tests_;
+  std::string output_;
+  bool print_time_;
+  internal::Int32 random_seed_;
+  internal::Int32 repeat_;
+  bool shuffle_;
+  internal::Int32 stack_trace_depth_;
+  std::string stream_result_to_;
+  bool throw_on_failure_;
+} GTEST_ATTRIBUTE_UNUSED_;
+
+// Converts a Unicode code point to a narrow string in UTF-8 encoding.
+// code_point parameter is of type UInt32 because wchar_t may not be
+// wide enough to contain a code point.
+// If the code_point is not a valid Unicode code point
+// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
+// to "(Invalid Unicode 0xXXXXXXXX)".
+GTEST_API_ std::string CodePointToUtf8(UInt32 code_point);
+
+// Converts a wide string to a narrow string in UTF-8 encoding.
+// The wide string is assumed to have the following encoding:
+//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
+//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)
+// Parameter str points to a null-terminated wide string.
+// Parameter num_chars may additionally limit the number
+// of wchar_t characters processed. -1 is used when the entire string
+// should be processed.
+// If the string contains code points that are not valid Unicode code points
+// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
+// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
+// and contains invalid UTF-16 surrogate pairs, values in those pairs
+// will be encoded as individual Unicode characters from Basic Normal Plane.
+GTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars);
+
+// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
+// if the variable is present. If a file already exists at this location, this
+// function will write over it. If the variable is present, but the file cannot
+// be created, prints an error and exits.
+void WriteToShardStatusFileIfNeeded();
+
+// Checks whether sharding is enabled by examining the relevant
+// environment variable values. If the variables are present,
+// but inconsistent (e.g., shard_index >= total_shards), prints
+// an error and exits. If in_subprocess_for_death_test, sharding is
+// disabled because it must only be applied to the original test
+// process. Otherwise, we could filter out death tests we intended to execute.
+GTEST_API_ bool ShouldShard(const char* total_shards_str,
+                            const char* shard_index_str,
+                            bool in_subprocess_for_death_test);
+
+// Parses the environment variable var as an Int32. If it is unset,
+// returns default_val. If it is not an Int32, prints an error and
+// and aborts.
+GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);
+
+// Given the total number of shards, the shard index, and the test id,
+// returns true iff the test should be run on this shard. The test id is
+// some arbitrary but unique non-negative integer assigned to each test
+// method. Assumes that 0 <= shard_index < total_shards.
+GTEST_API_ bool ShouldRunTestOnShard(
+    int total_shards, int shard_index, int test_id);
+
+// STL container utilities.
+
+// Returns the number of elements in the given container that satisfy
+// the given predicate.
+template <class Container, typename Predicate>
+inline int CountIf(const Container& c, Predicate predicate) {
+  // Implemented as an explicit loop since std::count_if() in libCstd on
+  // Solaris has a non-standard signature.
+  int count = 0;
+  for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {
+    if (predicate(*it))
+      ++count;
+  }
+  return count;
+}
+
+// Applies a function/functor to each element in the container.
+template <class Container, typename Functor>
+void ForEach(const Container& c, Functor functor) {
+  std::for_each(c.begin(), c.end(), functor);
+}
+
+// Returns the i-th element of the vector, or default_value if i is not
+// in range [0, v.size()).
+template <typename E>
+inline E GetElementOr(const std::vector<E>& v, int i, E default_value) {
+  return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i];
+}
+
+// Performs an in-place shuffle of a range of the vector's elements.
+// 'begin' and 'end' are element indices as an STL-style range;
+// i.e. [begin, end) are shuffled, where 'end' == size() means to
+// shuffle to the end of the vector.
+template <typename E>
+void ShuffleRange(internal::Random* random, int begin, int end,
+                  std::vector<E>* v) {
+  const int size = static_cast<int>(v->size());
+  GTEST_CHECK_(0 <= begin && begin <= size)
+      << "Invalid shuffle range start " << begin << ": must be in range [0, "
+      << size << "].";
+  GTEST_CHECK_(begin <= end && end <= size)
+      << "Invalid shuffle range finish " << end << ": must be in range ["
+      << begin << ", " << size << "].";
+
+  // Fisher-Yates shuffle, from
+  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
+  for (int range_width = end - begin; range_width >= 2; range_width--) {
+    const int last_in_range = begin + range_width - 1;
+    const int selected = begin + random->Generate(range_width);
+    std::swap((*v)[selected], (*v)[last_in_range]);
+  }
+}
+
+// Performs an in-place shuffle of the vector's elements.
+template <typename E>
+inline void Shuffle(internal::Random* random, std::vector<E>* v) {
+  ShuffleRange(random, 0, static_cast<int>(v->size()), v);
+}
+
+// A function for deleting an object.  Handy for being used as a
+// functor.
+template <typename T>
+static void Delete(T* x) {
+  delete x;
+}
+
+// A predicate that checks the key of a TestProperty against a known key.
+//
+// TestPropertyKeyIs is copyable.
+class TestPropertyKeyIs {
+ public:
+  // Constructor.
+  //
+  // TestPropertyKeyIs has NO default constructor.
+  explicit TestPropertyKeyIs(const std::string& key) : key_(key) {}
+
+  // Returns true iff the test name of test property matches on key_.
+  bool operator()(const TestProperty& test_property) const {
+    return test_property.key() == key_;
+  }
+
+ private:
+  std::string key_;
+};
+
+// Class UnitTestOptions.
+//
+// This class contains functions for processing options the user
+// specifies when running the tests.  It has only static members.
+//
+// In most cases, the user can specify an option using either an
+// environment variable or a command line flag.  E.g. you can set the
+// test filter using either GTEST_FILTER or --gtest_filter.  If both
+// the variable and the flag are present, the latter overrides the
+// former.
+class GTEST_API_ UnitTestOptions {
+ public:
+  // Functions for processing the gtest_output flag.
+
+  // Returns the output format, or "" for normal printed output.
+  static std::string GetOutputFormat();
+
+  // Returns the absolute path of the requested output file, or the
+  // default (test_detail.xml in the original working directory) if
+  // none was explicitly specified.
+  static std::string GetAbsolutePathToOutputFile();
+
+  // Functions for processing the gtest_filter flag.
+
+  // Returns true iff the wildcard pattern matches the string.  The
+  // first ':' or '\0' character in pattern marks the end of it.
+  //
+  // This recursive algorithm isn't very efficient, but is clear and
+  // works well enough for matching test names, which are short.
+  static bool PatternMatchesString(const char *pattern, const char *str);
+
+  // Returns true iff the user-specified filter matches the test case
+  // name and the test name.
+  static bool FilterMatchesTest(const std::string &test_case_name,
+                                const std::string &test_name);
+
+#if GTEST_OS_WINDOWS
+  // Function for supporting the gtest_catch_exception flag.
+
+  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
+  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
+  // This function is useful as an __except condition.
+  static int GTestShouldProcessSEH(DWORD exception_code);
+#endif  // GTEST_OS_WINDOWS
+
+  // Returns true if "name" matches the ':' separated list of glob-style
+  // filters in "filter".
+  static bool MatchesFilter(const std::string& name, const char* filter);
+};
+
+// Returns the current application's name, removing directory path if that
+// is present.  Used by UnitTestOptions::GetOutputFile.
+GTEST_API_ FilePath GetCurrentExecutableName();
+
+// The role interface for getting the OS stack trace as a string.
+class OsStackTraceGetterInterface {
+ public:
+  OsStackTraceGetterInterface() {}
+  virtual ~OsStackTraceGetterInterface() {}
+
+  // Returns the current OS stack trace as an std::string.  Parameters:
+  //
+  //   max_depth  - the maximum number of stack frames to be included
+  //                in the trace.
+  //   skip_count - the number of top frames to be skipped; doesn't count
+  //                against max_depth.
+  virtual string CurrentStackTrace(int max_depth, int skip_count) = 0;
+
+  // UponLeavingGTest() should be called immediately before Google Test calls
+  // user code. It saves some information about the current stack that
+  // CurrentStackTrace() will use to find and hide Google Test stack frames.
+  virtual void UponLeavingGTest() = 0;
+
+ private:
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);
+};
+
+// A working implementation of the OsStackTraceGetterInterface interface.
+class OsStackTraceGetter : public OsStackTraceGetterInterface {
+ public:
+  OsStackTraceGetter() : caller_frame_(NULL) {}
+
+  virtual string CurrentStackTrace(int max_depth, int skip_count)
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
+  virtual void UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_);
+
+  // This string is inserted in place of stack frames that are part of
+  // Google Test's implementation.
+  static const char* const kElidedFramesMarker;
+
+ private:
+  Mutex mutex_;  // protects all internal state
+
+  // We save the stack frame below the frame that calls user code.
+  // We do this because the address of the frame immediately below
+  // the user code changes between the call to UponLeavingGTest()
+  // and any calls to CurrentStackTrace() from within the user code.
+  void* caller_frame_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);
+};
+
+// Information about a Google Test trace point.
+struct TraceInfo {
+  const char* file;
+  int line;
+  std::string message;
+};
+
+// This is the default global test part result reporter used in UnitTestImpl.
+// This class should only be used by UnitTestImpl.
+class DefaultGlobalTestPartResultReporter
+  : public TestPartResultReporterInterface {
+ public:
+  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);
+  // Implements the TestPartResultReporterInterface. Reports the test part
+  // result in the current test.
+  virtual void ReportTestPartResult(const TestPartResult& result);
+
+ private:
+  UnitTestImpl* const unit_test_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);
+};
+
+// This is the default per thread test part result reporter used in
+// UnitTestImpl. This class should only be used by UnitTestImpl.
+class DefaultPerThreadTestPartResultReporter
+    : public TestPartResultReporterInterface {
+ public:
+  explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);
+  // Implements the TestPartResultReporterInterface. The implementation just
+  // delegates to the current global test part result reporter of *unit_test_.
+  virtual void ReportTestPartResult(const TestPartResult& result);
+
+ private:
+  UnitTestImpl* const unit_test_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);
+};
+
+// The private implementation of the UnitTest class.  We don't protect
+// the methods under a mutex, as this class is not accessible by a
+// user and the UnitTest class that delegates work to this class does
+// proper locking.
+class GTEST_API_ UnitTestImpl {
+ public:
+  explicit UnitTestImpl(UnitTest* parent);
+  virtual ~UnitTestImpl();
+
+  // There are two different ways to register your own TestPartResultReporter.
+  // You can register your own repoter to listen either only for test results
+  // from the current thread or for results from all threads.
+  // By default, each per-thread test result repoter just passes a new
+  // TestPartResult to the global test result reporter, which registers the
+  // test part result for the currently running test.
+
+  // Returns the global test part result reporter.
+  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();
+
+  // Sets the global test part result reporter.
+  void SetGlobalTestPartResultReporter(
+      TestPartResultReporterInterface* reporter);
+
+  // Returns the test part result reporter for the current thread.
+  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();
+
+  // Sets the test part result reporter for the current thread.
+  void SetTestPartResultReporterForCurrentThread(
+      TestPartResultReporterInterface* reporter);
+
+  // Gets the number of successful test cases.
+  int successful_test_case_count() const;
+
+  // Gets the number of failed test cases.
+  int failed_test_case_count() const;
+
+  // Gets the number of all test cases.
+  int total_test_case_count() const;
+
+  // Gets the number of all test cases that contain at least one test
+  // that should run.
+  int test_case_to_run_count() const;
+
+  // Gets the number of successful tests.
+  int successful_test_count() const;
+
+  // Gets the number of failed tests.
+  int failed_test_count() const;
+
+  // Gets the number of disabled tests that will be reported in the XML report.
+  int reportable_disabled_test_count() const;
+
+  // Gets the number of disabled tests.
+  int disabled_test_count() const;
+
+  // Gets the number of tests to be printed in the XML report.
+  int reportable_test_count() const;
+
+  // Gets the number of all tests.
+  int total_test_count() const;
+
+  // Gets the number of tests that should run.
+  int test_to_run_count() const;
+
+  // Gets the time of the test program start, in ms from the start of the
+  // UNIX epoch.
+  TimeInMillis start_timestamp() const { return start_timestamp_; }
+
+  // Gets the elapsed time, in milliseconds.
+  TimeInMillis elapsed_time() const { return elapsed_time_; }
+
+  // Returns true iff the unit test passed (i.e. all test cases passed).
+  bool Passed() const { return !Failed(); }
+
+  // Returns true iff the unit test failed (i.e. some test case failed
+  // or something outside of all tests failed).
+  bool Failed() const {
+    return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed();
+  }
+
+  // Gets the i-th test case among all the test cases. i can range from 0 to
+  // total_test_case_count() - 1. If i is not in that range, returns NULL.
+  const TestCase* GetTestCase(int i) const {
+    const int index = GetElementOr(test_case_indices_, i, -1);
+    return index < 0 ? NULL : test_cases_[i];
+  }
+
+  // Gets the i-th test case among all the test cases. i can range from 0 to
+  // total_test_case_count() - 1. If i is not in that range, returns NULL.
+  TestCase* GetMutableTestCase(int i) {
+    const int index = GetElementOr(test_case_indices_, i, -1);
+    return index < 0 ? NULL : test_cases_[index];
+  }
+
+  // Provides access to the event listener list.
+  TestEventListeners* listeners() { return &listeners_; }
+
+  // Returns the TestResult for the test that's currently running, or
+  // the TestResult for the ad hoc test if no test is running.
+  TestResult* current_test_result();
+
+  // Returns the TestResult for the ad hoc test.
+  const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; }
+
+  // Sets the OS stack trace getter.
+  //
+  // Does nothing if the input and the current OS stack trace getter
+  // are the same; otherwise, deletes the old getter and makes the
+  // input the current getter.
+  void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);
+
+  // Returns the current OS stack trace getter if it is not NULL;
+  // otherwise, creates an OsStackTraceGetter, makes it the current
+  // getter, and returns it.
+  OsStackTraceGetterInterface* os_stack_trace_getter();
+
+  // Returns the current OS stack trace as an std::string.
+  //
+  // The maximum number of stack frames to be included is specified by
+  // the gtest_stack_trace_depth flag.  The skip_count parameter
+  // specifies the number of top frames to be skipped, which doesn't
+  // count against the number of frames to be included.
+  //
+  // For example, if Foo() calls Bar(), which in turn calls
+  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the
+  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.
+  std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_;
+
+  // Finds and returns a TestCase with the given name.  If one doesn't
+  // exist, creates one and returns it.
+  //
+  // Arguments:
+  //
+  //   test_case_name: name of the test case
+  //   type_param:     the name of the test's type parameter, or NULL if
+  //                   this is not a typed or a type-parameterized test.
+  //   set_up_tc:      pointer to the function that sets up the test case
+  //   tear_down_tc:   pointer to the function that tears down the test case
+  TestCase* GetTestCase(const char* test_case_name,
+                        const char* type_param,
+                        Test::SetUpTestCaseFunc set_up_tc,
+                        Test::TearDownTestCaseFunc tear_down_tc);
+
+  // Adds a TestInfo to the unit test.
+  //
+  // Arguments:
+  //
+  //   set_up_tc:    pointer to the function that sets up the test case
+  //   tear_down_tc: pointer to the function that tears down the test case
+  //   test_info:    the TestInfo object
+  void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc,
+                   Test::TearDownTestCaseFunc tear_down_tc,
+                   TestInfo* test_info) {
+    // In order to support thread-safe death tests, we need to
+    // remember the original working directory when the test program
+    // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as
+    // the user may have changed the current directory before calling
+    // RUN_ALL_TESTS().  Therefore we capture the current directory in
+    // AddTestInfo(), which is called to register a TEST or TEST_F
+    // before main() is reached.
+    if (original_working_dir_.IsEmpty()) {
+      original_working_dir_.Set(FilePath::GetCurrentDir());
+      GTEST_CHECK_(!original_working_dir_.IsEmpty())
+          << "Failed to get the current working directory.";
+    }
+
+    GetTestCase(test_info->test_case_name(),
+                test_info->type_param(),
+                set_up_tc,
+                tear_down_tc)->AddTestInfo(test_info);
+  }
+
+#if GTEST_HAS_PARAM_TEST
+  // Returns ParameterizedTestCaseRegistry object used to keep track of
+  // value-parameterized tests and instantiate and register them.
+  internal::ParameterizedTestCaseRegistry& parameterized_test_registry() {
+    return parameterized_test_registry_;
+  }
+#endif  // GTEST_HAS_PARAM_TEST
+
+  // Sets the TestCase object for the test that's currently running.
+  void set_current_test_case(TestCase* a_current_test_case) {
+    current_test_case_ = a_current_test_case;
+  }
+
+  // Sets the TestInfo object for the test that's currently running.  If
+  // current_test_info is NULL, the assertion results will be stored in
+  // ad_hoc_test_result_.
+  void set_current_test_info(TestInfo* a_current_test_info) {
+    current_test_info_ = a_current_test_info;
+  }
+
+  // Registers all parameterized tests defined using TEST_P and
+  // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter
+  // combination. This method can be called more then once; it has guards
+  // protecting from registering the tests more then once.  If
+  // value-parameterized tests are disabled, RegisterParameterizedTests is
+  // present but does nothing.
+  void RegisterParameterizedTests();
+
+  // Runs all tests in this UnitTest object, prints the result, and
+  // returns true if all tests are successful.  If any exception is
+  // thrown during a test, this test is considered to be failed, but
+  // the rest of the tests will still be run.
+  bool RunAllTests();
+
+  // Clears the results of all tests, except the ad hoc tests.
+  void ClearNonAdHocTestResult() {
+    ForEach(test_cases_, TestCase::ClearTestCaseResult);
+  }
+
+  // Clears the results of ad-hoc test assertions.
+  void ClearAdHocTestResult() {
+    ad_hoc_test_result_.Clear();
+  }
+
+  // Adds a TestProperty to the current TestResult object when invoked in a
+  // context of a test or a test case, or to the global property set. If the
+  // result already contains a property with the same key, the value will be
+  // updated.
+  void RecordProperty(const TestProperty& test_property);
+
+  enum ReactionToSharding {
+    HONOR_SHARDING_PROTOCOL,
+    IGNORE_SHARDING_PROTOCOL
+  };
+
+  // Matches the full name of each test against the user-specified
+  // filter to decide whether the test should run, then records the
+  // result in each TestCase and TestInfo object.
+  // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests
+  // based on sharding variables in the environment.
+  // Returns the number of tests that should run.
+  int FilterTests(ReactionToSharding shard_tests);
+
+  // Prints the names of the tests matching the user-specified filter flag.
+  void ListTestsMatchingFilter();
+
+  const TestCase* current_test_case() const { return current_test_case_; }
+  TestInfo* current_test_info() { return current_test_info_; }
+  const TestInfo* current_test_info() const { return current_test_info_; }
+
+  // Returns the vector of environments that need to be set-up/torn-down
+  // before/after the tests are run.
+  std::vector<Environment*>& environments() { return environments_; }
+
+  // Getters for the per-thread Google Test trace stack.
+  std::vector<TraceInfo>& gtest_trace_stack() {
+    return *(gtest_trace_stack_.pointer());
+  }
+  const std::vector<TraceInfo>& gtest_trace_stack() const {
+    return gtest_trace_stack_.get();
+  }
+
+#if GTEST_HAS_DEATH_TEST
+  void InitDeathTestSubprocessControlInfo() {
+    internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());
+  }
+  // Returns a pointer to the parsed --gtest_internal_run_death_test
+  // flag, or NULL if that flag was not specified.
+  // This information is useful only in a death test child process.
+  // Must not be called before a call to InitGoogleTest.
+  const InternalRunDeathTestFlag* internal_run_death_test_flag() const {
+    return internal_run_death_test_flag_.get();
+  }
+
+  // Returns a pointer to the current death test factory.
+  internal::DeathTestFactory* death_test_factory() {
+    return death_test_factory_.get();
+  }
+
+  void SuppressTestEventsIfInSubprocess();
+
+  friend class ReplaceDeathTestFactory;
+#endif  // GTEST_HAS_DEATH_TEST
+
+  // Initializes the event listener performing XML output as specified by
+  // UnitTestOptions. Must not be called before InitGoogleTest.
+  void ConfigureXmlOutput();
+
+#if GTEST_CAN_STREAM_RESULTS_
+  // Initializes the event listener for streaming test results to a socket.
+  // Must not be called before InitGoogleTest.
+  void ConfigureStreamingOutput();
+#endif
+
+  // Performs initialization dependent upon flag values obtained in
+  // ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to
+  // ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest
+  // this function is also called from RunAllTests.  Since this function can be
+  // called more than once, it has to be idempotent.
+  void PostFlagParsingInit();
+
+  // Gets the random seed used at the start of the current test iteration.
+  int random_seed() const { return random_seed_; }
+
+  // Gets the random number generator.
+  internal::Random* random() { return &random_; }
+
+  // Shuffles all test cases, and the tests within each test case,
+  // making sure that death tests are still run first.
+  void ShuffleTests();
+
+  // Restores the test cases and tests to their order before the first shuffle.
+  void UnshuffleTests();
+
+  // Returns the value of GTEST_FLAG(catch_exceptions) at the moment
+  // UnitTest::Run() starts.
+  bool catch_exceptions() const { return catch_exceptions_; }
+
+ private:
+  friend class ::testing::UnitTest;
+
+  // Used by UnitTest::Run() to capture the state of
+  // GTEST_FLAG(catch_exceptions) at the moment it starts.
+  void set_catch_exceptions(bool value) { catch_exceptions_ = value; }
+
+  // The UnitTest object that owns this implementation object.
+  UnitTest* const parent_;
+
+  // The working directory when the first TEST() or TEST_F() was
+  // executed.
+  internal::FilePath original_working_dir_;
+
+  // The default test part result reporters.
+  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;
+  DefaultPerThreadTestPartResultReporter
+      default_per_thread_test_part_result_reporter_;
+
+  // Points to (but doesn't own) the global test part result reporter.
+  TestPartResultReporterInterface* global_test_part_result_repoter_;
+
+  // Protects read and write access to global_test_part_result_reporter_.
+  internal::Mutex global_test_part_result_reporter_mutex_;
+
+  // Points to (but doesn't own) the per-thread test part result reporter.
+  internal::ThreadLocal<TestPartResultReporterInterface*>
+      per_thread_test_part_result_reporter_;
+
+  // The vector of environments that need to be set-up/torn-down
+  // before/after the tests are run.
+  std::vector<Environment*> environments_;
+
+  // The vector of TestCases in their original order.  It owns the
+  // elements in the vector.
+  std::vector<TestCase*> test_cases_;
+
+  // Provides a level of indirection for the test case list to allow
+  // easy shuffling and restoring the test case order.  The i-th
+  // element of this vector is the index of the i-th test case in the
+  // shuffled order.
+  std::vector<int> test_case_indices_;
+
+#if GTEST_HAS_PARAM_TEST
+  // ParameterizedTestRegistry object used to register value-parameterized
+  // tests.
+  internal::ParameterizedTestCaseRegistry parameterized_test_registry_;
+
+  // Indicates whether RegisterParameterizedTests() has been called already.
+  bool parameterized_tests_registered_;
+#endif  // GTEST_HAS_PARAM_TEST
+
+  // Index of the last death test case registered.  Initially -1.
+  int last_death_test_case_;
+
+  // This points to the TestCase for the currently running test.  It
+  // changes as Google Test goes through one test case after another.
+  // When no test is running, this is set to NULL and Google Test
+  // stores assertion results in ad_hoc_test_result_.  Initially NULL.
+  TestCase* current_test_case_;
+
+  // This points to the TestInfo for the currently running test.  It
+  // changes as Google Test goes through one test after another.  When
+  // no test is running, this is set to NULL and Google Test stores
+  // assertion results in ad_hoc_test_result_.  Initially NULL.
+  TestInfo* current_test_info_;
+
+  // Normally, a user only writes assertions inside a TEST or TEST_F,
+  // or inside a function called by a TEST or TEST_F.  Since Google
+  // Test keeps track of which test is current running, it can
+  // associate such an assertion with the test it belongs to.
+  //
+  // If an assertion is encountered when no TEST or TEST_F is running,
+  // Google Test attributes the assertion result to an imaginary "ad hoc"
+  // test, and records the result in ad_hoc_test_result_.
+  TestResult ad_hoc_test_result_;
+
+  // The list of event listeners that can be used to track events inside
+  // Google Test.
+  TestEventListeners listeners_;
+
+  // The OS stack trace getter.  Will be deleted when the UnitTest
+  // object is destructed.  By default, an OsStackTraceGetter is used,
+  // but the user can set this field to use a custom getter if that is
+  // desired.
+  OsStackTraceGetterInterface* os_stack_trace_getter_;
+
+  // True iff PostFlagParsingInit() has been called.
+  bool post_flag_parse_init_performed_;
+
+  // The random number seed used at the beginning of the test run.
+  int random_seed_;
+
+  // Our random number generator.
+  internal::Random random_;
+
+  // The time of the test program start, in ms from the start of the
+  // UNIX epoch.
+  TimeInMillis start_timestamp_;
+
+  // How long the test took to run, in milliseconds.
+  TimeInMillis elapsed_time_;
+
+#if GTEST_HAS_DEATH_TEST
+  // The decomposed components of the gtest_internal_run_death_test flag,
+  // parsed when RUN_ALL_TESTS is called.
+  internal::scoped_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;
+  internal::scoped_ptr<internal::DeathTestFactory> death_test_factory_;
+#endif  // GTEST_HAS_DEATH_TEST
+
+  // A per-thread stack of traces created by the SCOPED_TRACE() macro.
+  internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;
+
+  // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()
+  // starts.
+  bool catch_exceptions_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);
+};  // class UnitTestImpl
+
+// Convenience function for accessing the global UnitTest
+// implementation object.
+inline UnitTestImpl* GetUnitTestImpl() {
+  return UnitTest::GetInstance()->impl();
+}
+
+#if GTEST_USES_SIMPLE_RE
+
+// Internal helper functions for implementing the simple regular
+// expression matcher.
+GTEST_API_ bool IsInSet(char ch, const char* str);
+GTEST_API_ bool IsAsciiDigit(char ch);
+GTEST_API_ bool IsAsciiPunct(char ch);
+GTEST_API_ bool IsRepeat(char ch);
+GTEST_API_ bool IsAsciiWhiteSpace(char ch);
+GTEST_API_ bool IsAsciiWordChar(char ch);
+GTEST_API_ bool IsValidEscape(char ch);
+GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);
+GTEST_API_ bool ValidateRegex(const char* regex);
+GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);
+GTEST_API_ bool MatchRepetitionAndRegexAtHead(
+    bool escaped, char ch, char repeat, const char* regex, const char* str);
+GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);
+
+#endif  // GTEST_USES_SIMPLE_RE
+
+// Parses the command line for Google Test flags, without initializing
+// other parts of Google Test.
+GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);
+GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);
+
+#if GTEST_HAS_DEATH_TEST
+
+// Returns the message describing the last system error, regardless of the
+// platform.
+GTEST_API_ std::string GetLastErrnoDescription();
+
+# if GTEST_OS_WINDOWS
+// Provides leak-safe Windows kernel handle ownership.
+class AutoHandle {
+ public:
+  AutoHandle() : handle_(INVALID_HANDLE_VALUE) {}
+  explicit AutoHandle(HANDLE handle) : handle_(handle) {}
+
+  ~AutoHandle() { Reset(); }
+
+  HANDLE Get() const { return handle_; }
+  void Reset() { Reset(INVALID_HANDLE_VALUE); }
+  void Reset(HANDLE handle) {
+    if (handle != handle_) {
+      if (handle_ != INVALID_HANDLE_VALUE)
+        ::CloseHandle(handle_);
+      handle_ = handle;
+    }
+  }
+
+ private:
+  HANDLE handle_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
+};
+# endif  // GTEST_OS_WINDOWS
+
+// Attempts to parse a string into a positive integer pointed to by the
+// number parameter.  Returns true if that is possible.
+// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use
+// it here.
+template <typename Integer>
+bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
+  // Fail fast if the given string does not begin with a digit;
+  // this bypasses strtoXXX's "optional leading whitespace and plus
+  // or minus sign" semantics, which are undesirable here.
+  if (str.empty() || !IsDigit(str[0])) {
+    return false;
+  }
+  errno = 0;
+
+  char* end;
+  // BiggestConvertible is the largest integer type that system-provided
+  // string-to-number conversion routines can return.
+
+# if GTEST_OS_WINDOWS && !defined(__GNUC__)
+
+  // MSVC and C++ Builder define __int64 instead of the standard long long.
+  typedef unsigned __int64 BiggestConvertible;
+  const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);
+
+# else
+
+  typedef unsigned long long BiggestConvertible;  // NOLINT
+  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);
+
+# endif  // GTEST_OS_WINDOWS && !defined(__GNUC__)
+
+  const bool parse_success = *end == '\0' && errno == 0;
+
+  // TODO(vladl@google.com): Convert this to compile time assertion when it is
+  // available.
+  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));
+
+  const Integer result = static_cast<Integer>(parsed);
+  if (parse_success && static_cast<BiggestConvertible>(result) == parsed) {
+    *number = result;
+    return true;
+  }
+  return false;
+}
+#endif  // GTEST_HAS_DEATH_TEST
+
+// TestResult contains some private methods that should be hidden from
+// Google Test user but are required for testing. This class allow our tests
+// to access them.
+//
+// This class is supplied only for the purpose of testing Google Test's own
+// constructs. Do not use it in user tests, either directly or indirectly.
+class TestResultAccessor {
+ public:
+  static void RecordProperty(TestResult* test_result,
+                             const std::string& xml_element,
+                             const TestProperty& property) {
+    test_result->RecordProperty(xml_element, property);
+  }
+
+  static void ClearTestPartResults(TestResult* test_result) {
+    test_result->ClearTestPartResults();
+  }
+
+  static const std::vector<testing::TestPartResult>& test_part_results(
+      const TestResult& test_result) {
+    return test_result.test_part_results();
+  }
+};
+
+#if GTEST_CAN_STREAM_RESULTS_
+
+// Streams test results to the given port on the given host machine.
+class StreamingListener : public EmptyTestEventListener {
+ public:
+  // Abstract base class for writing strings to a socket.
+  class AbstractSocketWriter {
+   public:
+    virtual ~AbstractSocketWriter() {}
+
+    // Sends a string to the socket.
+    virtual void Send(const string& message) = 0;
+
+    // Closes the socket.
+    virtual void CloseConnection() {}
+
+    // Sends a string and a newline to the socket.
+    void SendLn(const string& message) {
+      Send(message + "\n");
+    }
+  };
+
+  // Concrete class for actually writing strings to a socket.
+  class SocketWriter : public AbstractSocketWriter {
+   public:
+    SocketWriter(const string& host, const string& port)
+        : sockfd_(-1), host_name_(host), port_num_(port) {
+      MakeConnection();
+    }
+
+    virtual ~SocketWriter() {
+      if (sockfd_ != -1)
+        CloseConnection();
+    }
+
+    // Sends a string to the socket.
+    virtual void Send(const string& message) {
+      GTEST_CHECK_(sockfd_ != -1)
+          << "Send() can be called only when there is a connection.";
+
+      const int len = static_cast<int>(message.length());
+      if (write(sockfd_, message.c_str(), len) != len) {
+        GTEST_LOG_(WARNING)
+            << "stream_result_to: failed to stream to "
+            << host_name_ << ":" << port_num_;
+      }
+    }
+
+   private:
+    // Creates a client socket and connects to the server.
+    void MakeConnection();
+
+    // Closes the socket.
+    void CloseConnection() {
+      GTEST_CHECK_(sockfd_ != -1)
+          << "CloseConnection() can be called only when there is a connection.";
+
+      close(sockfd_);
+      sockfd_ = -1;
+    }
+
+    int sockfd_;  // socket file descriptor
+    const string host_name_;
+    const string port_num_;
+
+    GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);
+  };  // class SocketWriter
+
+  // Escapes '=', '&', '%', and '\n' characters in str as "%xx".
+  static string UrlEncode(const char* str);
+
+  StreamingListener(const string& host, const string& port)
+      : socket_writer_(new SocketWriter(host, port)) { Start(); }
+
+  explicit StreamingListener(AbstractSocketWriter* socket_writer)
+      : socket_writer_(socket_writer) { Start(); }
+
+  void OnTestProgramStart(const UnitTest& /* unit_test */) {
+    SendLn("event=TestProgramStart");
+  }
+
+  void OnTestProgramEnd(const UnitTest& unit_test) {
+    // Note that Google Test current only report elapsed time for each
+    // test iteration, not for the entire test program.
+    SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed()));
+
+    // Notify the streaming server to stop.
+    socket_writer_->CloseConnection();
+  }
+
+  void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) {
+    SendLn("event=TestIterationStart&iteration=" +
+           StreamableToString(iteration));
+  }
+
+  void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) {
+    SendLn("event=TestIterationEnd&passed=" +
+           FormatBool(unit_test.Passed()) + "&elapsed_time=" +
+           StreamableToString(unit_test.elapsed_time()) + "ms");
+  }
+
+  void OnTestCaseStart(const TestCase& test_case) {
+    SendLn(std::string("event=TestCaseStart&name=") + test_case.name());
+  }
+
+  void OnTestCaseEnd(const TestCase& test_case) {
+    SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed())
+           + "&elapsed_time=" + StreamableToString(test_case.elapsed_time())
+           + "ms");
+  }
+
+  void OnTestStart(const TestInfo& test_info) {
+    SendLn(std::string("event=TestStart&name=") + test_info.name());
+  }
+
+  void OnTestEnd(const TestInfo& test_info) {
+    SendLn("event=TestEnd&passed=" +
+           FormatBool((test_info.result())->Passed()) +
+           "&elapsed_time=" +
+           StreamableToString((test_info.result())->elapsed_time()) + "ms");
+  }
+
+  void OnTestPartResult(const TestPartResult& test_part_result) {
+    const char* file_name = test_part_result.file_name();
+    if (file_name == NULL)
+      file_name = "";
+    SendLn("event=TestPartResult&file=" + UrlEncode(file_name) +
+           "&line=" + StreamableToString(test_part_result.line_number()) +
+           "&message=" + UrlEncode(test_part_result.message()));
+  }
+
+ private:
+  // Sends the given message and a newline to the socket.
+  void SendLn(const string& message) { socket_writer_->SendLn(message); }
+
+  // Called at the start of streaming to notify the receiver what
+  // protocol we are using.
+  void Start() { SendLn("gtest_streaming_protocol_version=1.0"); }
+
+  string FormatBool(bool value) { return value ? "1" : "0"; }
+
+  const scoped_ptr<AbstractSocketWriter> socket_writer_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);
+};  // class StreamingListener
+
+#endif  // GTEST_CAN_STREAM_RESULTS_
+
+}  // namespace internal
+}  // namespace testing
+
+#endif  // GTEST_SRC_GTEST_INTERNAL_INL_H_
diff --git a/test/fmw/gtest/src/gtest-port.cc b/test/fmw/gtest/src/gtest-port.cc
new file mode 100644
index 0000000..0c4df5f
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-port.cc
@@ -0,0 +1,805 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+#include "gtest/internal/gtest-port.h"
+
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#if GTEST_OS_WINDOWS_MOBILE
+# include <windows.h>  // For TerminateProcess()
+#elif GTEST_OS_WINDOWS
+# include <io.h>
+# include <sys/stat.h>
+#else
+# include <unistd.h>
+#endif  // GTEST_OS_WINDOWS_MOBILE
+
+#if GTEST_OS_MAC
+# include <mach/mach_init.h>
+# include <mach/task.h>
+# include <mach/vm_map.h>
+#endif  // GTEST_OS_MAC
+
+#if GTEST_OS_QNX
+# include <devctl.h>
+# include <sys/procfs.h>
+#endif  // GTEST_OS_QNX
+
+#include "gtest/gtest-spi.h"
+#include "gtest/gtest-message.h"
+#include "gtest/internal/gtest-internal.h"
+#include "gtest/internal/gtest-string.h"
+
+// Indicates that this translation unit is part of Google Test's
+// implementation.  It must come before gtest-internal-inl.h is
+// included, or there will be a compiler error.  This trick is to
+// prevent a user from accidentally including gtest-internal-inl.h in
+// his code.
+#define GTEST_IMPLEMENTATION_ 1
+#include "src/gtest-internal-inl.h"
+#undef GTEST_IMPLEMENTATION_
+
+namespace testing {
+namespace internal {
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+// MSVC and C++Builder do not provide a definition of STDERR_FILENO.
+const int kStdOutFileno = 1;
+const int kStdErrFileno = 2;
+#else
+const int kStdOutFileno = STDOUT_FILENO;
+const int kStdErrFileno = STDERR_FILENO;
+#endif  // _MSC_VER
+
+#if GTEST_OS_MAC
+
+// Returns the number of threads running in the process, or 0 to indicate that
+// we cannot detect it.
+size_t GetThreadCount() {
+  const task_t task = mach_task_self();
+  mach_msg_type_number_t thread_count;
+  thread_act_array_t thread_list;
+  const kern_return_t status = task_threads(task, &thread_list, &thread_count);
+  if (status == KERN_SUCCESS) {
+    // task_threads allocates resources in thread_list and we need to free them
+    // to avoid leaks.
+    vm_deallocate(task,
+                  reinterpret_cast<vm_address_t>(thread_list),
+                  sizeof(thread_t) * thread_count);
+    return static_cast<size_t>(thread_count);
+  } else {
+    return 0;
+  }
+}
+
+#elif GTEST_OS_QNX
+
+// Returns the number of threads running in the process, or 0 to indicate that
+// we cannot detect it.
+size_t GetThreadCount() {
+  const int fd = open("/proc/self/as", O_RDONLY);
+  if (fd < 0) {
+    return 0;
+  }
+  procfs_info process_info;
+  const int status =
+      devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), NULL);
+  close(fd);
+  if (status == EOK) {
+    return static_cast<size_t>(process_info.num_threads);
+  } else {
+    return 0;
+  }
+}
+
+#else
+
+size_t GetThreadCount() {
+  // There's no portable way to detect the number of threads, so we just
+  // return 0 to indicate that we cannot detect it.
+  return 0;
+}
+
+#endif  // GTEST_OS_MAC
+
+#if GTEST_USES_POSIX_RE
+
+// Implements RE.  Currently only needed for death tests.
+
+RE::~RE() {
+  if (is_valid_) {
+    // regfree'ing an invalid regex might crash because the content
+    // of the regex is undefined. Since the regex's are essentially
+    // the same, one cannot be valid (or invalid) without the other
+    // being so too.
+    regfree(&partial_regex_);
+    regfree(&full_regex_);
+  }
+  free(const_cast<char*>(pattern_));
+}
+
+// Returns true iff regular expression re matches the entire str.
+bool RE::FullMatch(const char* str, const RE& re) {
+  if (!re.is_valid_) return false;
+
+  regmatch_t match;
+  return regexec(&re.full_regex_, str, 1, &match, 0) == 0;
+}
+
+// Returns true iff regular expression re matches a substring of str
+// (including str itself).
+bool RE::PartialMatch(const char* str, const RE& re) {
+  if (!re.is_valid_) return false;
+
+  regmatch_t match;
+  return regexec(&re.partial_regex_, str, 1, &match, 0) == 0;
+}
+
+// Initializes an RE from its string representation.
+void RE::Init(const char* regex) {
+  pattern_ = posix::StrDup(regex);
+
+  // Reserves enough bytes to hold the regular expression used for a
+  // full match.
+  const size_t full_regex_len = strlen(regex) + 10;
+  char* const full_pattern = new char[full_regex_len];
+
+  snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
+  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;
+  // We want to call regcomp(&partial_regex_, ...) even if the
+  // previous expression returns false.  Otherwise partial_regex_ may
+  // not be properly initialized can may cause trouble when it's
+  // freed.
+  //
+  // Some implementation of POSIX regex (e.g. on at least some
+  // versions of Cygwin) doesn't accept the empty string as a valid
+  // regex.  We change it to an equivalent form "()" to be safe.
+  if (is_valid_) {
+    const char* const partial_regex = (*regex == '\0') ? "()" : regex;
+    is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;
+  }
+  EXPECT_TRUE(is_valid_)
+      << "Regular expression \"" << regex
+      << "\" is not a valid POSIX Extended regular expression.";
+
+  delete[] full_pattern;
+}
+
+#elif GTEST_USES_SIMPLE_RE
+
+// Returns true iff ch appears anywhere in str (excluding the
+// terminating '\0' character).
+bool IsInSet(char ch, const char* str) {
+  return ch != '\0' && strchr(str, ch) != NULL;
+}
+
+// Returns true iff ch belongs to the given classification.  Unlike
+// similar functions in <ctype.h>, these aren't affected by the
+// current locale.
+bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }
+bool IsAsciiPunct(char ch) {
+  return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~");
+}
+bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); }
+bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); }
+bool IsAsciiWordChar(char ch) {
+  return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||
+      ('0' <= ch && ch <= '9') || ch == '_';
+}
+
+// Returns true iff "\\c" is a supported escape sequence.
+bool IsValidEscape(char c) {
+  return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW"));
+}
+
+// Returns true iff the given atom (specified by escaped and pattern)
+// matches ch.  The result is undefined if the atom is invalid.
+bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
+  if (escaped) {  // "\\p" where p is pattern_char.
+    switch (pattern_char) {
+      case 'd': return IsAsciiDigit(ch);
+      case 'D': return !IsAsciiDigit(ch);
+      case 'f': return ch == '\f';
+      case 'n': return ch == '\n';
+      case 'r': return ch == '\r';
+      case 's': return IsAsciiWhiteSpace(ch);
+      case 'S': return !IsAsciiWhiteSpace(ch);
+      case 't': return ch == '\t';
+      case 'v': return ch == '\v';
+      case 'w': return IsAsciiWordChar(ch);
+      case 'W': return !IsAsciiWordChar(ch);
+    }
+    return IsAsciiPunct(pattern_char) && pattern_char == ch;
+  }
+
+  return (pattern_char == '.' && ch != '\n') || pattern_char == ch;
+}
+
+// Helper function used by ValidateRegex() to format error messages.
+std::string FormatRegexSyntaxError(const char* regex, int index) {
+  return (Message() << "Syntax error at index " << index
+          << " in simple regular expression \"" << regex << "\": ").GetString();
+}
+
+// Generates non-fatal failures and returns false if regex is invalid;
+// otherwise returns true.
+bool ValidateRegex(const char* regex) {
+  if (regex == NULL) {
+    // TODO(wan@google.com): fix the source file location in the
+    // assertion failures to match where the regex is used in user
+    // code.
+    ADD_FAILURE() << "NULL is not a valid simple regular expression.";
+    return false;
+  }
+
+  bool is_valid = true;
+
+  // True iff ?, *, or + can follow the previous atom.
+  bool prev_repeatable = false;
+  for (int i = 0; regex[i]; i++) {
+    if (regex[i] == '\\') {  // An escape sequence
+      i++;
+      if (regex[i] == '\0') {
+        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
+                      << "'\\' cannot appear at the end.";
+        return false;
+      }
+
+      if (!IsValidEscape(regex[i])) {
+        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
+                      << "invalid escape sequence \"\\" << regex[i] << "\".";
+        is_valid = false;
+      }
+      prev_repeatable = true;
+    } else {  // Not an escape sequence.
+      const char ch = regex[i];
+
+      if (ch == '^' && i > 0) {
+        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
+                      << "'^' can only appear at the beginning.";
+        is_valid = false;
+      } else if (ch == '$' && regex[i + 1] != '\0') {
+        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
+                      << "'$' can only appear at the end.";
+        is_valid = false;
+      } else if (IsInSet(ch, "()[]{}|")) {
+        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
+                      << "'" << ch << "' is unsupported.";
+        is_valid = false;
+      } else if (IsRepeat(ch) && !prev_repeatable) {
+        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
+                      << "'" << ch << "' can only follow a repeatable token.";
+        is_valid = false;
+      }
+
+      prev_repeatable = !IsInSet(ch, "^$?*+");
+    }
+  }
+
+  return is_valid;
+}
+
+// Matches a repeated regex atom followed by a valid simple regular
+// expression.  The regex atom is defined as c if escaped is false,
+// or \c otherwise.  repeat is the repetition meta character (?, *,
+// or +).  The behavior is undefined if str contains too many
+// characters to be indexable by size_t, in which case the test will
+// probably time out anyway.  We are fine with this limitation as
+// std::string has it too.
+bool MatchRepetitionAndRegexAtHead(
+    bool escaped, char c, char repeat, const char* regex,
+    const char* str) {
+  const size_t min_count = (repeat == '+') ? 1 : 0;
+  const size_t max_count = (repeat == '?') ? 1 :
+      static_cast<size_t>(-1) - 1;
+  // We cannot call numeric_limits::max() as it conflicts with the
+  // max() macro on Windows.
+
+  for (size_t i = 0; i <= max_count; ++i) {
+    // We know that the atom matches each of the first i characters in str.
+    if (i >= min_count && MatchRegexAtHead(regex, str + i)) {
+      // We have enough matches at the head, and the tail matches too.
+      // Since we only care about *whether* the pattern matches str
+      // (as opposed to *how* it matches), there is no need to find a
+      // greedy match.
+      return true;
+    }
+    if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i]))
+      return false;
+  }
+  return false;
+}
+
+// Returns true iff regex matches a prefix of str.  regex must be a
+// valid simple regular expression and not start with "^", or the
+// result is undefined.
+bool MatchRegexAtHead(const char* regex, const char* str) {
+  if (*regex == '\0')  // An empty regex matches a prefix of anything.
+    return true;
+
+  // "$" only matches the end of a string.  Note that regex being
+  // valid guarantees that there's nothing after "$" in it.
+  if (*regex == '$')
+    return *str == '\0';
+
+  // Is the first thing in regex an escape sequence?
+  const bool escaped = *regex == '\\';
+  if (escaped)
+    ++regex;
+  if (IsRepeat(regex[1])) {
+    // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so
+    // here's an indirect recursion.  It terminates as the regex gets
+    // shorter in each recursion.
+    return MatchRepetitionAndRegexAtHead(
+        escaped, regex[0], regex[1], regex + 2, str);
+  } else {
+    // regex isn't empty, isn't "$", and doesn't start with a
+    // repetition.  We match the first atom of regex with the first
+    // character of str and recurse.
+    return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) &&
+        MatchRegexAtHead(regex + 1, str + 1);
+  }
+}
+
+// Returns true iff regex matches any substring of str.  regex must be
+// a valid simple regular expression, or the result is undefined.
+//
+// The algorithm is recursive, but the recursion depth doesn't exceed
+// the regex length, so we won't need to worry about running out of
+// stack space normally.  In rare cases the time complexity can be
+// exponential with respect to the regex length + the string length,
+// but usually it's must faster (often close to linear).
+bool MatchRegexAnywhere(const char* regex, const char* str) {
+  if (regex == NULL || str == NULL)
+    return false;
+
+  if (*regex == '^')
+    return MatchRegexAtHead(regex + 1, str);
+
+  // A successful match can be anywhere in str.
+  do {
+    if (MatchRegexAtHead(regex, str))
+      return true;
+  } while (*str++ != '\0');
+  return false;
+}
+
+// Implements the RE class.
+
+RE::~RE() {
+  free(const_cast<char*>(pattern_));
+  free(const_cast<char*>(full_pattern_));
+}
+
+// Returns true iff regular expression re matches the entire str.
+bool RE::FullMatch(const char* str, const RE& re) {
+  return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);
+}
+
+// Returns true iff regular expression re matches a substring of str
+// (including str itself).
+bool RE::PartialMatch(const char* str, const RE& re) {
+  return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);
+}
+
+// Initializes an RE from its string representation.
+void RE::Init(const char* regex) {
+  pattern_ = full_pattern_ = NULL;
+  if (regex != NULL) {
+    pattern_ = posix::StrDup(regex);
+  }
+
+  is_valid_ = ValidateRegex(regex);
+  if (!is_valid_) {
+    // No need to calculate the full pattern when the regex is invalid.
+    return;
+  }
+
+  const size_t len = strlen(regex);
+  // Reserves enough bytes to hold the regular expression used for a
+  // full match: we need space to prepend a '^', append a '$', and
+  // terminate the string with '\0'.
+  char* buffer = static_cast<char*>(malloc(len + 3));
+  full_pattern_ = buffer;
+
+  if (*regex != '^')
+    *buffer++ = '^';  // Makes sure full_pattern_ starts with '^'.
+
+  // We don't use snprintf or strncpy, as they trigger a warning when
+  // compiled with VC++ 8.0.
+  memcpy(buffer, regex, len);
+  buffer += len;
+
+  if (len == 0 || regex[len - 1] != '$')
+    *buffer++ = '$';  // Makes sure full_pattern_ ends with '$'.
+
+  *buffer = '\0';
+}
+
+#endif  // GTEST_USES_POSIX_RE
+
+const char kUnknownFile[] = "unknown file";
+
+// Formats a source file path and a line number as they would appear
+// in an error message from the compiler used to compile this code.
+GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {
+  const std::string file_name(file == NULL ? kUnknownFile : file);
+
+  if (line < 0) {
+    return file_name + ":";
+  }
+#ifdef _MSC_VER
+  return file_name + "(" + StreamableToString(line) + "):";
+#else
+  return file_name + ":" + StreamableToString(line) + ":";
+#endif  // _MSC_VER
+}
+
+// Formats a file location for compiler-independent XML output.
+// Although this function is not platform dependent, we put it next to
+// FormatFileLocation in order to contrast the two functions.
+// Note that FormatCompilerIndependentFileLocation() does NOT append colon
+// to the file location it produces, unlike FormatFileLocation().
+GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(
+    const char* file, int line) {
+  const std::string file_name(file == NULL ? kUnknownFile : file);
+
+  if (line < 0)
+    return file_name;
+  else
+    return file_name + ":" + StreamableToString(line);
+}
+
+
+GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)
+    : severity_(severity) {
+  const char* const marker =
+      severity == GTEST_INFO ?    "[  INFO ]" :
+      severity == GTEST_WARNING ? "[WARNING]" :
+      severity == GTEST_ERROR ?   "[ ERROR ]" : "[ FATAL ]";
+  GetStream() << ::std::endl << marker << " "
+              << FormatFileLocation(file, line).c_str() << ": ";
+}
+
+// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
+GTestLog::~GTestLog() {
+  GetStream() << ::std::endl;
+  if (severity_ == GTEST_FATAL) {
+    fflush(stderr);
+    posix::Abort();
+  }
+}
+// Disable Microsoft deprecation warnings for POSIX functions called from
+// this class (creat, dup, dup2, and close)
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable: 4996)
+#endif  // _MSC_VER
+
+#if GTEST_HAS_STREAM_REDIRECTION
+
+// Object that captures an output stream (stdout/stderr).
+class CapturedStream {
+ public:
+  // The ctor redirects the stream to a temporary file.
+  explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
+# if GTEST_OS_WINDOWS
+    char temp_dir_path[MAX_PATH + 1] = { '\0' };  // NOLINT
+    char temp_file_path[MAX_PATH + 1] = { '\0' };  // NOLINT
+
+    ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);
+    const UINT success = ::GetTempFileNameA(temp_dir_path,
+                                            "gtest_redir",
+                                            0,  // Generate unique file name.
+                                            temp_file_path);
+    GTEST_CHECK_(success != 0)
+        << "Unable to create a temporary file in " << temp_dir_path;
+    const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
+    GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file "
+                                    << temp_file_path;
+    filename_ = temp_file_path;
+# else
+    // There's no guarantee that a test has write access to the current
+    // directory, so we create the temporary file in the /tmp directory
+    // instead. We use /tmp on most systems, and /sdcard on Android.
+    // That's because Android doesn't have /tmp.
+#  if GTEST_OS_LINUX_ANDROID
+    // Note: Android applications are expected to call the framework's
+    // Context.getExternalStorageDirectory() method through JNI to get
+    // the location of the world-writable SD Card directory. However,
+    // this requires a Context handle, which cannot be retrieved
+    // globally from native code. Doing so also precludes running the
+    // code as part of a regular standalone executable, which doesn't
+    // run in a Dalvik process (e.g. when running it through 'adb shell').
+    //
+    // The location /sdcard is directly accessible from native code
+    // and is the only location (unofficially) supported by the Android
+    // team. It's generally a symlink to the real SD Card mount point
+    // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or
+    // other OEM-customized locations. Never rely on these, and always
+    // use /sdcard.
+    char name_template[] = "/sdcard/gtest_captured_stream.XXXXXX";
+#  else
+    char name_template[] = "/tmp/captured_stream.XXXXXX";
+#  endif  // GTEST_OS_LINUX_ANDROID
+    const int captured_fd = mkstemp(name_template);
+    filename_ = name_template;
+# endif  // GTEST_OS_WINDOWS
+    fflush(NULL);
+    dup2(captured_fd, fd_);
+    close(captured_fd);
+  }
+
+  ~CapturedStream() {
+    remove(filename_.c_str());
+  }
+
+  std::string GetCapturedString() {
+    if (uncaptured_fd_ != -1) {
+      // Restores the original stream.
+      fflush(NULL);
+      dup2(uncaptured_fd_, fd_);
+      close(uncaptured_fd_);
+      uncaptured_fd_ = -1;
+    }
+
+    FILE* const file = posix::FOpen(filename_.c_str(), "r");
+    const std::string content = ReadEntireFile(file);
+    posix::FClose(file);
+    return content;
+  }
+
+ private:
+  // Reads the entire content of a file as an std::string.
+  static std::string ReadEntireFile(FILE* file);
+
+  // Returns the size (in bytes) of a file.
+  static size_t GetFileSize(FILE* file);
+
+  const int fd_;  // A stream to capture.
+  int uncaptured_fd_;
+  // Name of the temporary file holding the stderr output.
+  ::std::string filename_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);
+};
+
+// Returns the size (in bytes) of a file.
+size_t CapturedStream::GetFileSize(FILE* file) {
+  fseek(file, 0, SEEK_END);
+  return static_cast<size_t>(ftell(file));
+}
+
+// Reads the entire content of a file as a string.
+std::string CapturedStream::ReadEntireFile(FILE* file) {
+  const size_t file_size = GetFileSize(file);
+  char* const buffer = new char[file_size];
+
+  size_t bytes_last_read = 0;  // # of bytes read in the last fread()
+  size_t bytes_read = 0;       // # of bytes read so far
+
+  fseek(file, 0, SEEK_SET);
+
+  // Keeps reading the file until we cannot read further or the
+  // pre-determined file size is reached.
+  do {
+    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);
+    bytes_read += bytes_last_read;
+  } while (bytes_last_read > 0 && bytes_read < file_size);
+
+  const std::string content(buffer, bytes_read);
+  delete[] buffer;
+
+  return content;
+}
+
+# ifdef _MSC_VER
+#  pragma warning(pop)
+# endif  // _MSC_VER
+
+static CapturedStream* g_captured_stderr = NULL;
+static CapturedStream* g_captured_stdout = NULL;
+
+// Starts capturing an output stream (stdout/stderr).
+void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
+  if (*stream != NULL) {
+    GTEST_LOG_(FATAL) << "Only one " << stream_name
+                      << " capturer can exist at a time.";
+  }
+  *stream = new CapturedStream(fd);
+}
+
+// Stops capturing the output stream and returns the captured string.
+std::string GetCapturedStream(CapturedStream** captured_stream) {
+  const std::string content = (*captured_stream)->GetCapturedString();
+
+  delete *captured_stream;
+  *captured_stream = NULL;
+
+  return content;
+}
+
+// Starts capturing stdout.
+void CaptureStdout() {
+  CaptureStream(kStdOutFileno, "stdout", &g_captured_stdout);
+}
+
+// Starts capturing stderr.
+void CaptureStderr() {
+  CaptureStream(kStdErrFileno, "stderr", &g_captured_stderr);
+}
+
+// Stops capturing stdout and returns the captured string.
+std::string GetCapturedStdout() {
+  return GetCapturedStream(&g_captured_stdout);
+}
+
+// Stops capturing stderr and returns the captured string.
+std::string GetCapturedStderr() {
+  return GetCapturedStream(&g_captured_stderr);
+}
+
+#endif  // GTEST_HAS_STREAM_REDIRECTION
+
+#if GTEST_HAS_DEATH_TEST
+
+// A copy of all command line arguments.  Set by InitGoogleTest().
+::std::vector<testing::internal::string> g_argvs;
+
+static const ::std::vector<testing::internal::string>* g_injected_test_argvs =
+                                        NULL;  // Owned.
+
+void SetInjectableArgvs(const ::std::vector<testing::internal::string>* argvs) {
+  if (g_injected_test_argvs != argvs)
+    delete g_injected_test_argvs;
+  g_injected_test_argvs = argvs;
+}
+
+const ::std::vector<testing::internal::string>& GetInjectableArgvs() {
+  if (g_injected_test_argvs != NULL) {
+    return *g_injected_test_argvs;
+  }
+  return g_argvs;
+}
+#endif  // GTEST_HAS_DEATH_TEST
+
+#if GTEST_OS_WINDOWS_MOBILE
+namespace posix {
+void Abort() {
+  DebugBreak();
+  TerminateProcess(GetCurrentProcess(), 1);
+}
+}  // namespace posix
+#endif  // GTEST_OS_WINDOWS_MOBILE
+
+// Returns the name of the environment variable corresponding to the
+// given flag.  For example, FlagToEnvVar("foo") will return
+// "GTEST_FOO" in the open-source version.
+static std::string FlagToEnvVar(const char* flag) {
+  const std::string full_flag =
+      (Message() << GTEST_FLAG_PREFIX_ << flag).GetString();
+
+  Message env_var;
+  for (size_t i = 0; i != full_flag.length(); i++) {
+    env_var << ToUpper(full_flag.c_str()[i]);
+  }
+
+  return env_var.GetString();
+}
+
+// Parses 'str' for a 32-bit signed integer.  If successful, writes
+// the result to *value and returns true; otherwise leaves *value
+// unchanged and returns false.
+bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
+  // Parses the environment variable as a decimal integer.
+  char* end = NULL;
+  const long long_value = strtol(str, &end, 10);  // NOLINT
+
+  // Has strtol() consumed all characters in the string?
+  if (*end != '\0') {
+    // No - an invalid character was encountered.
+    Message msg;
+    msg << "WARNING: " << src_text
+        << " is expected to be a 32-bit integer, but actually"
+        << " has value \"" << str << "\".\n";
+    printf("%s", msg.GetString().c_str());
+    fflush(stdout);
+    return false;
+  }
+
+  // Is the parsed value in the range of an Int32?
+  const Int32 result = static_cast<Int32>(long_value);
+  if (long_value == LONG_MAX || long_value == LONG_MIN ||
+      // The parsed value overflows as a long.  (strtol() returns
+      // LONG_MAX or LONG_MIN when the input overflows.)
+      result != long_value
+      // The parsed value overflows as an Int32.
+      ) {
+    Message msg;
+    msg << "WARNING: " << src_text
+        << " is expected to be a 32-bit integer, but actually"
+        << " has value " << str << ", which overflows.\n";
+    printf("%s", msg.GetString().c_str());
+    fflush(stdout);
+    return false;
+  }
+
+  *value = result;
+  return true;
+}
+
+// Reads and returns the Boolean environment variable corresponding to
+// the given flag; if it's not set, returns default_value.
+//
+// The value is considered true iff it's not "0".
+bool BoolFromGTestEnv(const char* flag, bool default_value) {
+  const std::string env_var = FlagToEnvVar(flag);
+  const char* const string_value = posix::GetEnv(env_var.c_str());
+  return string_value == NULL ?
+      default_value : strcmp(string_value, "0") != 0;
+}
+
+// Reads and returns a 32-bit integer stored in the environment
+// variable corresponding to the given flag; if it isn't set or
+// doesn't represent a valid 32-bit integer, returns default_value.
+Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
+  const std::string env_var = FlagToEnvVar(flag);
+  const char* const string_value = posix::GetEnv(env_var.c_str());
+  if (string_value == NULL) {
+    // The environment variable is not set.
+    return default_value;
+  }
+
+  Int32 result = default_value;
+  if (!ParseInt32(Message() << "Environment variable " << env_var,
+                  string_value, &result)) {
+    printf("The default value %s is used.\n",
+           (Message() << default_value).GetString().c_str());
+    fflush(stdout);
+    return default_value;
+  }
+
+  return result;
+}
+
+// Reads and returns the string environment variable corresponding to
+// the given flag; if it's not set, returns default_value.
+const char* StringFromGTestEnv(const char* flag, const char* default_value) {
+  const std::string env_var = FlagToEnvVar(flag);
+  const char* const value = posix::GetEnv(env_var.c_str());
+  return value == NULL ? default_value : value;
+}
+
+}  // namespace internal
+}  // namespace testing
diff --git a/test/fmw/gtest/src/gtest-printers.cc b/test/fmw/gtest/src/gtest-printers.cc
new file mode 100644
index 0000000..75fa408
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-printers.cc
@@ -0,0 +1,363 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Test - The Google C++ Testing Framework
+//
+// This file implements a universal value printer that can print a
+// value of any type T:
+//
+//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
+//
+// It uses the << operator when possible, and prints the bytes in the
+// object otherwise.  A user can override its behavior for a class
+// type Foo by defining either operator<<(::std::ostream&, const Foo&)
+// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that
+// defines Foo.
+
+#include "gtest/gtest-printers.h"
+#include <ctype.h>
+#include <stdio.h>
+#include <ostream>  // NOLINT
+#include <string>
+#include "gtest/internal/gtest-port.h"
+
+namespace testing {
+
+namespace {
+
+using ::std::ostream;
+
+// Prints a segment of bytes in the given object.
+void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
+                                size_t count, ostream* os) {
+  char text[5] = "";
+  for (size_t i = 0; i != count; i++) {
+    const size_t j = start + i;
+    if (i != 0) {
+      // Organizes the bytes into groups of 2 for easy parsing by
+      // human.
+      if ((j % 2) == 0)
+        *os << ' ';
+      else
+        *os << '-';
+    }
+    GTEST_SNPRINTF_(text, sizeof(text), "%02X", obj_bytes[j]);
+    *os << text;
+  }
+}
+
+// Prints the bytes in the given value to the given ostream.
+void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
+                              ostream* os) {
+  // Tells the user how big the object is.
+  *os << count << "-byte object <";
+
+  const size_t kThreshold = 132;
+  const size_t kChunkSize = 64;
+  // If the object size is bigger than kThreshold, we'll have to omit
+  // some details by printing only the first and the last kChunkSize
+  // bytes.
+  // TODO(wan): let the user control the threshold using a flag.
+  if (count < kThreshold) {
+    PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);
+  } else {
+    PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);
+    *os << " ... ";
+    // Rounds up to 2-byte boundary.
+    const size_t resume_pos = (count - kChunkSize + 1)/2*2;
+    PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);
+  }
+  *os << ">";
+}
+
+}  // namespace
+
+namespace internal2 {
+
+// Delegates to PrintBytesInObjectToImpl() to print the bytes in the
+// given object.  The delegation simplifies the implementation, which
+// uses the << operator and thus is easier done outside of the
+// ::testing::internal namespace, which contains a << operator that
+// sometimes conflicts with the one in STL.
+void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,
+                          ostream* os) {
+  PrintBytesInObjectToImpl(obj_bytes, count, os);
+}
+
+}  // namespace internal2
+
+namespace internal {
+
+// Depending on the value of a char (or wchar_t), we print it in one
+// of three formats:
+//   - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
+//   - as a hexidecimal escape sequence (e.g. '\x7F'), or
+//   - as a special escape sequence (e.g. '\r', '\n').
+enum CharFormat {
+  kAsIs,
+  kHexEscape,
+  kSpecialEscape
+};
+
+// Returns true if c is a printable ASCII character.  We test the
+// value of c directly instead of calling isprint(), which is buggy on
+// Windows Mobile.
+inline bool IsPrintableAscii(wchar_t c) {
+  return 0x20 <= c && c <= 0x7E;
+}
+
+// Prints a wide or narrow char c as a character literal without the
+// quotes, escaping it when necessary; returns how c was formatted.
+// The template argument UnsignedChar is the unsigned version of Char,
+// which is the type of c.
+template <typename UnsignedChar, typename Char>
+static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {
+  switch (static_cast<wchar_t>(c)) {
+    case L'\0':
+      *os << "\\0";
+      break;
+    case L'\'':
+      *os << "\\'";
+      break;
+    case L'\\':
+      *os << "\\\\";
+      break;
+    case L'\a':
+      *os << "\\a";
+      break;
+    case L'\b':
+      *os << "\\b";
+      break;
+    case L'\f':
+      *os << "\\f";
+      break;
+    case L'\n':
+      *os << "\\n";
+      break;
+    case L'\r':
+      *os << "\\r";
+      break;
+    case L'\t':
+      *os << "\\t";
+      break;
+    case L'\v':
+      *os << "\\v";
+      break;
+    default:
+      if (IsPrintableAscii(c)) {
+        *os << static_cast<char>(c);
+        return kAsIs;
+      } else {
+        *os << "\\x" + String::FormatHexInt(static_cast<UnsignedChar>(c));
+        return kHexEscape;
+      }
+  }
+  return kSpecialEscape;
+}
+
+// Prints a wchar_t c as if it's part of a string literal, escaping it when
+// necessary; returns how c was formatted.
+static CharFormat PrintAsStringLiteralTo(wchar_t c, ostream* os) {
+  switch (c) {
+    case L'\'':
+      *os << "'";
+      return kAsIs;
+    case L'"':
+      *os << "\\\"";
+      return kSpecialEscape;
+    default:
+      return PrintAsCharLiteralTo<wchar_t>(c, os);
+  }
+}
+
+// Prints a char c as if it's part of a string literal, escaping it when
+// necessary; returns how c was formatted.
+static CharFormat PrintAsStringLiteralTo(char c, ostream* os) {
+  return PrintAsStringLiteralTo(
+      static_cast<wchar_t>(static_cast<unsigned char>(c)), os);
+}
+
+// Prints a wide or narrow character c and its code.  '\0' is printed
+// as "'\\0'", other unprintable characters are also properly escaped
+// using the standard C++ escape sequence.  The template argument
+// UnsignedChar is the unsigned version of Char, which is the type of c.
+template <typename UnsignedChar, typename Char>
+void PrintCharAndCodeTo(Char c, ostream* os) {
+  // First, print c as a literal in the most readable form we can find.
+  *os << ((sizeof(c) > 1) ? "L'" : "'");
+  const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);
+  *os << "'";
+
+  // To aid user debugging, we also print c's code in decimal, unless
+  // it's 0 (in which case c was printed as '\\0', making the code
+  // obvious).
+  if (c == 0)
+    return;
+  *os << " (" << static_cast<int>(c);
+
+  // For more convenience, we print c's code again in hexidecimal,
+  // unless c was already printed in the form '\x##' or the code is in
+  // [1, 9].
+  if (format == kHexEscape || (1 <= c && c <= 9)) {
+    // Do nothing.
+  } else {
+    *os << ", 0x" << String::FormatHexInt(static_cast<UnsignedChar>(c));
+  }
+  *os << ")";
+}
+
+void PrintTo(unsigned char c, ::std::ostream* os) {
+  PrintCharAndCodeTo<unsigned char>(c, os);
+}
+void PrintTo(signed char c, ::std::ostream* os) {
+  PrintCharAndCodeTo<unsigned char>(c, os);
+}
+
+// Prints a wchar_t as a symbol if it is printable or as its internal
+// code otherwise and also as its code.  L'\0' is printed as "L'\\0'".
+void PrintTo(wchar_t wc, ostream* os) {
+  PrintCharAndCodeTo<wchar_t>(wc, os);
+}
+
+// Prints the given array of characters to the ostream.  CharType must be either
+// char or wchar_t.
+// The array starts at begin, the length is len, it may include '\0' characters
+// and may not be NUL-terminated.
+template <typename CharType>
+static void PrintCharsAsStringTo(
+    const CharType* begin, size_t len, ostream* os) {
+  const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
+  *os << kQuoteBegin;
+  bool is_previous_hex = false;
+  for (size_t index = 0; index < len; ++index) {
+    const CharType cur = begin[index];
+    if (is_previous_hex && IsXDigit(cur)) {
+      // Previous character is of '\x..' form and this character can be
+      // interpreted as another hexadecimal digit in its number. Break string to
+      // disambiguate.
+      *os << "\" " << kQuoteBegin;
+    }
+    is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;
+  }
+  *os << "\"";
+}
+
+// Prints a (const) char/wchar_t array of 'len' elements, starting at address
+// 'begin'.  CharType must be either char or wchar_t.
+template <typename CharType>
+static void UniversalPrintCharArray(
+    const CharType* begin, size_t len, ostream* os) {
+  // The code
+  //   const char kFoo[] = "foo";
+  // generates an array of 4, not 3, elements, with the last one being '\0'.
+  //
+  // Therefore when printing a char array, we don't print the last element if
+  // it's '\0', such that the output matches the string literal as it's
+  // written in the source code.
+  if (len > 0 && begin[len - 1] == '\0') {
+    PrintCharsAsStringTo(begin, len - 1, os);
+    return;
+  }
+
+  // If, however, the last element in the array is not '\0', e.g.
+  //    const char kFoo[] = { 'f', 'o', 'o' };
+  // we must print the entire array.  We also print a message to indicate
+  // that the array is not NUL-terminated.
+  PrintCharsAsStringTo(begin, len, os);
+  *os << " (no terminating NUL)";
+}
+
+// Prints a (const) char array of 'len' elements, starting at address 'begin'.
+void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
+  UniversalPrintCharArray(begin, len, os);
+}
+
+// Prints a (const) wchar_t array of 'len' elements, starting at address
+// 'begin'.
+void UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) {
+  UniversalPrintCharArray(begin, len, os);
+}
+
+// Prints the given C string to the ostream.
+void PrintTo(const char* s, ostream* os) {
+  if (s == NULL) {
+    *os << "NULL";
+  } else {
+    *os << ImplicitCast_<const void*>(s) << " pointing to ";
+    PrintCharsAsStringTo(s, strlen(s), os);
+  }
+}
+
+// MSVC compiler can be configured to define whar_t as a typedef
+// of unsigned short. Defining an overload for const wchar_t* in that case
+// would cause pointers to unsigned shorts be printed as wide strings,
+// possibly accessing more memory than intended and causing invalid
+// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when
+// wchar_t is implemented as a native type.
+#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
+// Prints the given wide C string to the ostream.
+void PrintTo(const wchar_t* s, ostream* os) {
+  if (s == NULL) {
+    *os << "NULL";
+  } else {
+    *os << ImplicitCast_<const void*>(s) << " pointing to ";
+    PrintCharsAsStringTo(s, wcslen(s), os);
+  }
+}
+#endif  // wchar_t is native
+
+// Prints a ::string object.
+#if GTEST_HAS_GLOBAL_STRING
+void PrintStringTo(const ::string& s, ostream* os) {
+  PrintCharsAsStringTo(s.data(), s.size(), os);
+}
+#endif  // GTEST_HAS_GLOBAL_STRING
+
+void PrintStringTo(const ::std::string& s, ostream* os) {
+  PrintCharsAsStringTo(s.data(), s.size(), os);
+}
+
+// Prints a ::wstring object.
+#if GTEST_HAS_GLOBAL_WSTRING
+void PrintWideStringTo(const ::wstring& s, ostream* os) {
+  PrintCharsAsStringTo(s.data(), s.size(), os);
+}
+#endif  // GTEST_HAS_GLOBAL_WSTRING
+
+#if GTEST_HAS_STD_WSTRING
+void PrintWideStringTo(const ::std::wstring& s, ostream* os) {
+  PrintCharsAsStringTo(s.data(), s.size(), os);
+}
+#endif  // GTEST_HAS_STD_WSTRING
+
+}  // namespace internal
+
+}  // namespace testing
diff --git a/test/fmw/gtest/src/gtest-test-part.cc b/test/fmw/gtest/src/gtest-test-part.cc
new file mode 100644
index 0000000..c60eef3
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-test-part.cc
@@ -0,0 +1,110 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: mheule@google.com (Markus Heule)
+//
+// The Google C++ Testing Framework (Google Test)
+
+#include "gtest/gtest-test-part.h"
+
+// Indicates that this translation unit is part of Google Test's
+// implementation.  It must come before gtest-internal-inl.h is
+// included, or there will be a compiler error.  This trick is to
+// prevent a user from accidentally including gtest-internal-inl.h in
+// his code.
+#define GTEST_IMPLEMENTATION_ 1
+#include "src/gtest-internal-inl.h"
+#undef GTEST_IMPLEMENTATION_
+
+namespace testing {
+
+using internal::GetUnitTestImpl;
+
+// Gets the summary of the failure message by omitting the stack trace
+// in it.
+std::string TestPartResult::ExtractSummary(const char* message) {
+  const char* const stack_trace = strstr(message, internal::kStackTraceMarker);
+  return stack_trace == NULL ? message :
+      std::string(message, stack_trace);
+}
+
+// Prints a TestPartResult object.
+std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
+  return os
+      << result.file_name() << ":" << result.line_number() << ": "
+      << (result.type() == TestPartResult::kSuccess ? "Success" :
+          result.type() == TestPartResult::kFatalFailure ? "Fatal failure" :
+          "Non-fatal failure") << ":\n"
+      << result.message() << std::endl;
+}
+
+// Appends a TestPartResult to the array.
+void TestPartResultArray::Append(const TestPartResult& result) {
+  array_.push_back(result);
+}
+
+// Returns the TestPartResult at the given index (0-based).
+const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {
+  if (index < 0 || index >= size()) {
+    printf("\nInvalid index (%d) into TestPartResultArray.\n", index);
+    internal::posix::Abort();
+  }
+
+  return array_[index];
+}
+
+// Returns the number of TestPartResult objects in the array.
+int TestPartResultArray::size() const {
+  return static_cast<int>(array_.size());
+}
+
+namespace internal {
+
+HasNewFatalFailureHelper::HasNewFatalFailureHelper()
+    : has_new_fatal_failure_(false),
+      original_reporter_(GetUnitTestImpl()->
+                         GetTestPartResultReporterForCurrentThread()) {
+  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);
+}
+
+HasNewFatalFailureHelper::~HasNewFatalFailureHelper() {
+  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(
+      original_reporter_);
+}
+
+void HasNewFatalFailureHelper::ReportTestPartResult(
+    const TestPartResult& result) {
+  if (result.fatally_failed())
+    has_new_fatal_failure_ = true;
+  original_reporter_->ReportTestPartResult(result);
+}
+
+}  // namespace internal
+
+}  // namespace testing
diff --git a/test/fmw/gtest/src/gtest-typed-test.cc b/test/fmw/gtest/src/gtest-typed-test.cc
new file mode 100644
index 0000000..f0079f4
--- /dev/null
+++ b/test/fmw/gtest/src/gtest-typed-test.cc
@@ -0,0 +1,110 @@
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+#include "gtest/gtest-typed-test.h"
+#include "gtest/gtest.h"
+
+namespace testing {
+namespace internal {
+
+#if GTEST_HAS_TYPED_TEST_P
+
+// Skips to the first non-space char in str. Returns an empty string if str
+// contains only whitespace characters.
+static const char* SkipSpaces(const char* str) {
+  while (IsSpace(*str))
+    str++;
+  return str;
+}
+
+// Verifies that registered_tests match the test names in
+// defined_test_names_; returns registered_tests if successful, or
+// aborts the program otherwise.
+const char* TypedTestCasePState::VerifyRegisteredTestNames(
+    const char* file, int line, const char* registered_tests) {
+  typedef ::std::set<const char*>::const_iterator DefinedTestIter;
+  registered_ = true;
+
+  // Skip initial whitespace in registered_tests since some
+  // preprocessors prefix stringizied literals with whitespace.
+  registered_tests = SkipSpaces(registered_tests);
+
+  Message errors;
+  ::std::set<std::string> tests;
+  for (const char* names = registered_tests; names != NULL;
+       names = SkipComma(names)) {
+    const std::string name = GetPrefixUntilComma(names);
+    if (tests.count(name) != 0) {
+      errors << "Test " << name << " is listed more than once.\n";
+      continue;
+    }
+
+    bool found = false;
+    for (DefinedTestIter it = defined_test_names_.begin();
+         it != defined_test_names_.end();
+         ++it) {
+      if (name == *it) {
+        found = true;
+        break;
+      }
+    }
+
+    if (found) {
+      tests.insert(name);
+    } else {
+      errors << "No test named " << name
+             << " can be found in this test case.\n";
+    }
+  }
+
+  for (DefinedTestIter it = defined_test_names_.begin();
+       it != defined_test_names_.end();
+       ++it) {
+    if (tests.count(*it) == 0) {
+      errors << "You forgot to list test " << *it << ".\n";
+    }
+  }
+
+  const std::string& errors_str = errors.GetString();
+  if (errors_str != "") {
+    fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
+            errors_str.c_str());
+    fflush(stderr);
+    posix::Abort();
+  }
+
+  return registered_tests;
+}
+
+#endif  // GTEST_HAS_TYPED_TEST_P
+
+}  // namespace internal
+}  // namespace testing
diff --git a/test/fmw/gtest/src/gtest.cc b/test/fmw/gtest/src/gtest.cc
new file mode 100644
index 0000000..6de53dd
--- /dev/null
+++ b/test/fmw/gtest/src/gtest.cc
@@ -0,0 +1,5015 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// The Google C++ Testing Framework (Google Test)
+
+#include "gtest/gtest.h"
+#include "gtest/gtest-spi.h"
+
+#include <ctype.h>
+#include <math.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <wchar.h>
+#include <wctype.h>
+
+#include <algorithm>
+#include <iomanip>
+#include <limits>
+#include <ostream>  // NOLINT
+#include <sstream>
+#include <vector>
+
+#if GTEST_OS_LINUX
+
+// TODO(kenton@google.com): Use autoconf to detect availability of
+// gettimeofday().
+# define GTEST_HAS_GETTIMEOFDAY_ 1
+
+# include <fcntl.h>  // NOLINT
+# include <limits.h>  // NOLINT
+# include <sched.h>  // NOLINT
+// Declares vsnprintf().  This header is not available on Windows.
+# include <strings.h>  // NOLINT
+# include <sys/mman.h>  // NOLINT
+# include <sys/time.h>  // NOLINT
+# include <unistd.h>  // NOLINT
+# include <string>
+
+#elif GTEST_OS_SYMBIAN
+# define GTEST_HAS_GETTIMEOFDAY_ 1
+# include <sys/time.h>  // NOLINT
+
+#elif GTEST_OS_ZOS
+# define GTEST_HAS_GETTIMEOFDAY_ 1
+# include <sys/time.h>  // NOLINT
+
+// On z/OS we additionally need strings.h for strcasecmp.
+# include <strings.h>  // NOLINT
+
+#elif GTEST_OS_WINDOWS_MOBILE  // We are on Windows CE.
+
+# include <windows.h>  // NOLINT
+
+#elif GTEST_OS_WINDOWS  // We are on Windows proper.
+
+# include <io.h>  // NOLINT
+# include <sys/timeb.h>  // NOLINT
+# include <sys/types.h>  // NOLINT
+# include <sys/stat.h>  // NOLINT
+
+# if GTEST_OS_WINDOWS_MINGW
+// MinGW has gettimeofday() but not _ftime64().
+// TODO(kenton@google.com): Use autoconf to detect availability of
+//   gettimeofday().
+// TODO(kenton@google.com): There are other ways to get the time on
+//   Windows, like GetTickCount() or GetSystemTimeAsFileTime().  MinGW
+//   supports these.  consider using them instead.
+#  define GTEST_HAS_GETTIMEOFDAY_ 1
+#  include <sys/time.h>  // NOLINT
+# endif  // GTEST_OS_WINDOWS_MINGW
+
+// cpplint thinks that the header is already included, so we want to
+// silence it.
+# include <windows.h>  // NOLINT
+
+#else
+
+// Assume other platforms have gettimeofday().
+// TODO(kenton@google.com): Use autoconf to detect availability of
+//   gettimeofday().
+# define GTEST_HAS_GETTIMEOFDAY_ 1
+
+// cpplint thinks that the header is already included, so we want to
+// silence it.
+# include <sys/time.h>  // NOLINT
+# include <unistd.h>  // NOLINT
+
+#endif  // GTEST_OS_LINUX
+
+#if GTEST_HAS_EXCEPTIONS
+# include <stdexcept>
+#endif
+
+#if GTEST_CAN_STREAM_RESULTS_
+# include <arpa/inet.h>  // NOLINT
+# include <netdb.h>  // NOLINT
+#endif
+
+// Indicates that this translation unit is part of Google Test's
+// implementation.  It must come before gtest-internal-inl.h is
+// included, or there will be a compiler error.  This trick is to
+// prevent a user from accidentally including gtest-internal-inl.h in
+// his code.
+#define GTEST_IMPLEMENTATION_ 1
+#include "src/gtest-internal-inl.h"
+#undef GTEST_IMPLEMENTATION_
+
+#if GTEST_OS_WINDOWS
+# define vsnprintf _vsnprintf
+#endif  // GTEST_OS_WINDOWS
+
+namespace testing {
+
+using internal::CountIf;
+using internal::ForEach;
+using internal::GetElementOr;
+using internal::Shuffle;
+
+// Constants.
+
+// A test whose test case name or test name matches this filter is
+// disabled and not run.
+static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*";
+
+// A test case whose name matches this filter is considered a death
+// test case and will be run before test cases whose name doesn't
+// match this filter.
+static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*";
+
+// A test filter that matches everything.
+static const char kUniversalFilter[] = "*";
+
+// The default output file for XML output.
+static const char kDefaultOutputFile[] = "test_detail.xml";
+
+// The environment variable name for the test shard index.
+static const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
+// The environment variable name for the total number of test shards.
+static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS";
+// The environment variable name for the test shard status file.
+static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE";
+
+namespace internal {
+
+// The text used in failure messages to indicate the start of the
+// stack trace.
+const char kStackTraceMarker[] = "\nStack trace:\n";
+
+// g_help_flag is true iff the --help flag or an equivalent form is
+// specified on the command line.
+bool g_help_flag = false;
+
+}  // namespace internal
+
+static const char* GetDefaultFilter() {
+  return kUniversalFilter;
+}
+
+GTEST_DEFINE_bool_(
+    also_run_disabled_tests,
+    internal::BoolFromGTestEnv("also_run_disabled_tests", false),
+    "Run disabled tests too, in addition to the tests normally being run.");
+
+GTEST_DEFINE_bool_(
+    break_on_failure,
+    internal::BoolFromGTestEnv("break_on_failure", false),
+    "True iff a failed assertion should be a debugger break-point.");
+
+GTEST_DEFINE_bool_(
+    catch_exceptions,
+    internal::BoolFromGTestEnv("catch_exceptions", true),
+    "True iff " GTEST_NAME_
+    " should catch exceptions and treat them as test failures.");
+
+GTEST_DEFINE_string_(
+    color,
+    internal::StringFromGTestEnv("color", "auto"),
+    "Whether to use colors in the output.  Valid values: yes, no, "
+    "and auto.  'auto' means to use colors if the output is "
+    "being sent to a terminal and the TERM environment variable "
+    "is set to a terminal type that supports colors.");
+
+GTEST_DEFINE_string_(
+    filter,
+    internal::StringFromGTestEnv("filter", GetDefaultFilter()),
+    "A colon-separated list of glob (not regex) patterns "
+    "for filtering the tests to run, optionally followed by a "
+    "'-' and a : separated list of negative patterns (tests to "
+    "exclude).  A test is run if it matches one of the positive "
+    "patterns and does not match any of the negative patterns.");
+
+GTEST_DEFINE_bool_(list_tests, false,
+                   "List all tests without running them.");
+
+GTEST_DEFINE_string_(
+    output,
+    internal::StringFromGTestEnv("output", ""),
+    "A format (currently must be \"xml\"), optionally followed "
+    "by a colon and an output file name or directory. A directory "
+    "is indicated by a trailing pathname separator. "
+    "Examples: \"xml:filename.xml\", \"xml::directoryname/\". "
+    "If a directory is specified, output files will be created "
+    "within that directory, with file-names based on the test "
+    "executable's name and, if necessary, made unique by adding "
+    "digits.");
+
+GTEST_DEFINE_bool_(
+    print_time,
+    internal::BoolFromGTestEnv("print_time", true),
+    "True iff " GTEST_NAME_
+    " should display elapsed time in text output.");
+
+GTEST_DEFINE_int32_(
+    random_seed,
+    internal::Int32FromGTestEnv("random_seed", 0),
+    "Random number seed to use when shuffling test orders.  Must be in range "
+    "[1, 99999], or 0 to use a seed based on the current time.");
+
+GTEST_DEFINE_int32_(
+    repeat,
+    internal::Int32FromGTestEnv("repeat", 1),
+    "How many times to repeat each test.  Specify a negative number "
+    "for repeating forever.  Useful for shaking out flaky tests.");
+
+GTEST_DEFINE_bool_(
+    show_internal_stack_frames, false,
+    "True iff " GTEST_NAME_ " should include internal stack frames when "
+    "printing test failure stack traces.");
+
+GTEST_DEFINE_bool_(
+    shuffle,
+    internal::BoolFromGTestEnv("shuffle", false),
+    "True iff " GTEST_NAME_
+    " should randomize tests' order on every run.");
+
+GTEST_DEFINE_int32_(
+    stack_trace_depth,
+    internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth),
+    "The maximum number of stack frames to print when an "
+    "assertion fails.  The valid range is 0 through 100, inclusive.");
+
+GTEST_DEFINE_string_(
+    stream_result_to,
+    internal::StringFromGTestEnv("stream_result_to", ""),
+    "This flag specifies the host name and the port number on which to stream "
+    "test results. Example: \"localhost:555\". The flag is effective only on "
+    "Linux.");
+
+GTEST_DEFINE_bool_(
+    throw_on_failure,
+    internal::BoolFromGTestEnv("throw_on_failure", false),
+    "When this flag is specified, a failed assertion will throw an exception "
+    "if exceptions are enabled or exit the program with a non-zero code "
+    "otherwise.");
+
+namespace internal {
+
+// Generates a random number from [0, range), using a Linear
+// Congruential Generator (LCG).  Crashes if 'range' is 0 or greater
+// than kMaxRange.
+UInt32 Random::Generate(UInt32 range) {
+  // These constants are the same as are used in glibc's rand(3).
+  state_ = (1103515245U*state_ + 12345U) % kMaxRange;
+
+  GTEST_CHECK_(range > 0)
+      << "Cannot generate a number in the range [0, 0).";
+  GTEST_CHECK_(range <= kMaxRange)
+      << "Generation of a number in [0, " << range << ") was requested, "
+      << "but this can only generate numbers in [0, " << kMaxRange << ").";
+
+  // Converting via modulus introduces a bit of downward bias, but
+  // it's simple, and a linear congruential generator isn't too good
+  // to begin with.
+  return state_ % range;
+}
+
+// GTestIsInitialized() returns true iff the user has initialized
+// Google Test.  Useful for catching the user mistake of not initializing
+// Google Test before calling RUN_ALL_TESTS().
+//
+// A user must call testing::InitGoogleTest() to initialize Google
+// Test.  g_init_gtest_count is set to the number of times
+// InitGoogleTest() has been called.  We don't protect this variable
+// under a mutex as it is only accessed in the main thread.
+GTEST_API_ int g_init_gtest_count = 0;
+static bool GTestIsInitialized() { return g_init_gtest_count != 0; }
+
+// Iterates over a vector of TestCases, keeping a running sum of the
+// results of calling a given int-returning method on each.
+// Returns the sum.
+static int SumOverTestCaseList(const std::vector<TestCase*>& case_list,
+                               int (TestCase::*method)() const) {
+  int sum = 0;
+  for (size_t i = 0; i < case_list.size(); i++) {
+    sum += (case_list[i]->*method)();
+  }
+  return sum;
+}
+
+// Returns true iff the test case passed.
+static bool TestCasePassed(const TestCase* test_case) {
+  return test_case->should_run() && test_case->Passed();
+}
+
+// Returns true iff the test case failed.
+static bool TestCaseFailed(const TestCase* test_case) {
+  return test_case->should_run() && test_case->Failed();
+}
+
+// Returns true iff test_case contains at least one test that should
+// run.
+static bool ShouldRunTestCase(const TestCase* test_case) {
+  return test_case->should_run();
+}
+
+// AssertHelper constructor.
+AssertHelper::AssertHelper(TestPartResult::Type type,
+                           const char* file,
+                           int line,
+                           const char* message)
+    : data_(new AssertHelperData(type, file, line, message)) {
+}
+
+AssertHelper::~AssertHelper() {
+  delete data_;
+}
+
+// Message assignment, for assertion streaming support.
+void AssertHelper::operator=(const Message& message) const {
+  UnitTest::GetInstance()->
+    AddTestPartResult(data_->type, data_->file, data_->line,
+                      AppendUserMessage(data_->message, message),
+                      UnitTest::GetInstance()->impl()
+                      ->CurrentOsStackTraceExceptTop(1)
+                      // Skips the stack frame for this function itself.
+                      );  // NOLINT
+}
+
+// Mutex for linked pointers.
+GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);
+
+// Application pathname gotten in InitGoogleTest.
+std::string g_executable_path;
+
+// Returns the current application's name, removing directory path if that
+// is present.
+FilePath GetCurrentExecutableName() {
+  FilePath result;
+
+#if GTEST_OS_WINDOWS
+  result.Set(FilePath(g_executable_path).RemoveExtension("exe"));
+#else
+  result.Set(FilePath(g_executable_path));
+#endif  // GTEST_OS_WINDOWS
+
+  return result.RemoveDirectoryName();
+}
+
+// Functions for processing the gtest_output flag.
+
+// Returns the output format, or "" for normal printed output.
+std::string UnitTestOptions::GetOutputFormat() {
+  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
+  if (gtest_output_flag == NULL) return std::string("");
+
+  const char* const colon = strchr(gtest_output_flag, ':');
+  return (colon == NULL) ?
+      std::string(gtest_output_flag) :
+      std::string(gtest_output_flag, colon - gtest_output_flag);
+}
+
+// Returns the name of the requested output file, or the default if none
+// was explicitly specified.
+std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
+  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
+  if (gtest_output_flag == NULL)
+    return "";
+
+  const char* const colon = strchr(gtest_output_flag, ':');
+  if (colon == NULL)
+    return internal::FilePath::ConcatPaths(
+        internal::FilePath(
+            UnitTest::GetInstance()->original_working_dir()),
+        internal::FilePath(kDefaultOutputFile)).string();
+
+  internal::FilePath output_name(colon + 1);
+  if (!output_name.IsAbsolutePath())
+    // TODO(wan@google.com): on Windows \some\path is not an absolute
+    // path (as its meaning depends on the current drive), yet the
+    // following logic for turning it into an absolute path is wrong.
+    // Fix it.
+    output_name = internal::FilePath::ConcatPaths(
+        internal::FilePath(UnitTest::GetInstance()->original_working_dir()),
+        internal::FilePath(colon + 1));
+
+  if (!output_name.IsDirectory())
+    return output_name.string();
+
+  internal::FilePath result(internal::FilePath::GenerateUniqueFileName(
+      output_name, internal::GetCurrentExecutableName(),
+      GetOutputFormat().c_str()));
+  return result.string();
+}
+
+// Returns true iff the wildcard pattern matches the string.  The
+// first ':' or '\0' character in pattern marks the end of it.
+//
+// This recursive algorithm isn't very efficient, but is clear and
+// works well enough for matching test names, which are short.
+bool UnitTestOptions::PatternMatchesString(const char *pattern,
+                                           const char *str) {
+  switch (*pattern) {
+    case '\0':
+    case ':':  // Either ':' or '\0' marks the end of the pattern.
+      return *str == '\0';
+    case '?':  // Matches any single character.
+      return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
+    case '*':  // Matches any string (possibly empty) of characters.
+      return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
+          PatternMatchesString(pattern + 1, str);
+    default:  // Non-special character.  Matches itself.
+      return *pattern == *str &&
+          PatternMatchesString(pattern + 1, str + 1);
+  }
+}
+
+bool UnitTestOptions::MatchesFilter(
+    const std::string& name, const char* filter) {
+  const char *cur_pattern = filter;
+  for (;;) {
+    if (PatternMatchesString(cur_pattern, name.c_str())) {
+      return true;
+    }
+
+    // Finds the next pattern in the filter.
+    cur_pattern = strchr(cur_pattern, ':');
+
+    // Returns if no more pattern can be found.
+    if (cur_pattern == NULL) {
+      return false;
+    }
+
+    // Skips the pattern separater (the ':' character).
+    cur_pattern++;
+  }
+}
+
+// Returns true iff the user-specified filter matches the test case
+// name and the test name.
+bool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name,
+                                        const std::string &test_name) {
+  const std::string& full_name = test_case_name + "." + test_name.c_str();
+
+  // Split --gtest_filter at '-', if there is one, to separate into
+  // positive filter and negative filter portions
+  const char* const p = GTEST_FLAG(filter).c_str();
+  const char* const dash = strchr(p, '-');
+  std::string positive;
+  std::string negative;
+  if (dash == NULL) {
+    positive = GTEST_FLAG(filter).c_str();  // Whole string is a positive filter
+    negative = "";
+  } else {
+    positive = std::string(p, dash);   // Everything up to the dash
+    negative = std::string(dash + 1);  // Everything after the dash
+    if (positive.empty()) {
+      // Treat '-test1' as the same as '*-test1'
+      positive = kUniversalFilter;
+    }
+  }
+
+  // A filter is a colon-separated list of patterns.  It matches a
+  // test if any pattern in it matches the test.
+  return (MatchesFilter(full_name, positive.c_str()) &&
+          !MatchesFilter(full_name, negative.c_str()));
+}
+
+#if GTEST_HAS_SEH
+// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
+// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
+// This function is useful as an __except condition.
+int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
+  // Google Test should handle a SEH exception if:
+  //   1. the user wants it to, AND
+  //   2. this is not a breakpoint exception, AND
+  //   3. this is not a C++ exception (VC++ implements them via SEH,
+  //      apparently).
+  //
+  // SEH exception code for C++ exceptions.
+  // (see http://support.microsoft.com/kb/185294 for more information).
+  const DWORD kCxxExceptionCode = 0xe06d7363;
+
+  bool should_handle = true;
+
+  if (!GTEST_FLAG(catch_exceptions))
+    should_handle = false;
+  else if (exception_code == EXCEPTION_BREAKPOINT)
+    should_handle = false;
+  else if (exception_code == kCxxExceptionCode)
+    should_handle = false;
+
+  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
+}
+#endif  // GTEST_HAS_SEH
+
+}  // namespace internal
+
+// The c'tor sets this object as the test part result reporter used by
+// Google Test.  The 'result' parameter specifies where to report the
+// results. Intercepts only failures from the current thread.
+ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
+    TestPartResultArray* result)
+    : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),
+      result_(result) {
+  Init();
+}
+
+// The c'tor sets this object as the test part result reporter used by
+// Google Test.  The 'result' parameter specifies where to report the
+// results.
+ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
+    InterceptMode intercept_mode, TestPartResultArray* result)
+    : intercept_mode_(intercept_mode),
+      result_(result) {
+  Init();
+}
+
+void ScopedFakeTestPartResultReporter::Init() {
+  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
+  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
+    old_reporter_ = impl->GetGlobalTestPartResultReporter();
+    impl->SetGlobalTestPartResultReporter(this);
+  } else {
+    old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
+    impl->SetTestPartResultReporterForCurrentThread(this);
+  }
+}
+
+// The d'tor restores the test part result reporter used by Google Test
+// before.
+ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {
+  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
+  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
+    impl->SetGlobalTestPartResultReporter(old_reporter_);
+  } else {
+    impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
+  }
+}
+
+// Increments the test part result count and remembers the result.
+// This method is from the TestPartResultReporterInterface interface.
+void ScopedFakeTestPartResultReporter::ReportTestPartResult(
+    const TestPartResult& result) {
+  result_->Append(result);
+}
+
+namespace internal {
+
+// Returns the type ID of ::testing::Test.  We should always call this
+// instead of GetTypeId< ::testing::Test>() to get the type ID of
+// testing::Test.  This is to work around a suspected linker bug when
+// using Google Test as a framework on Mac OS X.  The bug causes
+// GetTypeId< ::testing::Test>() to return different values depending
+// on whether the call is from the Google Test framework itself or
+// from user test code.  GetTestTypeId() is guaranteed to always
+// return the same value, as it always calls GetTypeId<>() from the
+// gtest.cc, which is within the Google Test framework.
+TypeId GetTestTypeId() {
+  return GetTypeId<Test>();
+}
+
+// The value of GetTestTypeId() as seen from within the Google Test
+// library.  This is solely for testing GetTestTypeId().
+extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
+
+// This predicate-formatter checks that 'results' contains a test part
+// failure of the given type and that the failure message contains the
+// given substring.
+AssertionResult HasOneFailure(const char* /* results_expr */,
+                              const char* /* type_expr */,
+                              const char* /* substr_expr */,
+                              const TestPartResultArray& results,
+                              TestPartResult::Type type,
+                              const string& substr) {
+  const std::string expected(type == TestPartResult::kFatalFailure ?
+                        "1 fatal failure" :
+                        "1 non-fatal failure");
+  Message msg;
+  if (results.size() != 1) {
+    msg << "Expected: " << expected << "\n"
+        << "  Actual: " << results.size() << " failures";
+    for (int i = 0; i < results.size(); i++) {
+      msg << "\n" << results.GetTestPartResult(i);
+    }
+    return AssertionFailure() << msg;
+  }
+
+  const TestPartResult& r = results.GetTestPartResult(0);
+  if (r.type() != type) {
+    return AssertionFailure() << "Expected: " << expected << "\n"
+                              << "  Actual:\n"
+                              << r;
+  }
+
+  if (strstr(r.message(), substr.c_str()) == NULL) {
+    return AssertionFailure() << "Expected: " << expected << " containing \""
+                              << substr << "\"\n"
+                              << "  Actual:\n"
+                              << r;
+  }
+
+  return AssertionSuccess();
+}
+
+// The constructor of SingleFailureChecker remembers where to look up
+// test part results, what type of failure we expect, and what
+// substring the failure message should contain.
+SingleFailureChecker:: SingleFailureChecker(
+    const TestPartResultArray* results,
+    TestPartResult::Type type,
+    const string& substr)
+    : results_(results),
+      type_(type),
+      substr_(substr) {}
+
+// The destructor of SingleFailureChecker verifies that the given
+// TestPartResultArray contains exactly one failure that has the given
+// type and contains the given substring.  If that's not the case, a
+// non-fatal failure will be generated.
+SingleFailureChecker::~SingleFailureChecker() {
+  EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);
+}
+
+DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(
+    UnitTestImpl* unit_test) : unit_test_(unit_test) {}
+
+void DefaultGlobalTestPartResultReporter::ReportTestPartResult(
+    const TestPartResult& result) {
+  unit_test_->current_test_result()->AddTestPartResult(result);
+  unit_test_->listeners()->repeater()->OnTestPartResult(result);
+}
+
+DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(
+    UnitTestImpl* unit_test) : unit_test_(unit_test) {}
+
+void DefaultPerThreadTestPartResultReporter::ReportTestPartResult(
+    const TestPartResult& result) {
+  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);
+}
+
+// Returns the global test part result reporter.
+TestPartResultReporterInterface*
+UnitTestImpl::GetGlobalTestPartResultReporter() {
+  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
+  return global_test_part_result_repoter_;
+}
+
+// Sets the global test part result reporter.
+void UnitTestImpl::SetGlobalTestPartResultReporter(
+    TestPartResultReporterInterface* reporter) {
+  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
+  global_test_part_result_repoter_ = reporter;
+}
+
+// Returns the test part result reporter for the current thread.
+TestPartResultReporterInterface*
+UnitTestImpl::GetTestPartResultReporterForCurrentThread() {
+  return per_thread_test_part_result_reporter_.get();
+}
+
+// Sets the test part result reporter for the current thread.
+void UnitTestImpl::SetTestPartResultReporterForCurrentThread(
+    TestPartResultReporterInterface* reporter) {
+  per_thread_test_part_result_reporter_.set(reporter);
+}
+
+// Gets the number of successful test cases.
+int UnitTestImpl::successful_test_case_count() const {
+  return CountIf(test_cases_, TestCasePassed);
+}
+
+// Gets the number of failed test cases.
+int UnitTestImpl::failed_test_case_count() const {
+  return CountIf(test_cases_, TestCaseFailed);
+}
+
+// Gets the number of all test cases.
+int UnitTestImpl::total_test_case_count() const {
+  return static_cast<int>(test_cases_.size());
+}
+
+// Gets the number of all test cases that contain at least one test
+// that should run.
+int UnitTestImpl::test_case_to_run_count() const {
+  return CountIf(test_cases_, ShouldRunTestCase);
+}
+
+// Gets the number of successful tests.
+int UnitTestImpl::successful_test_count() const {
+  return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);
+}
+
+// Gets the number of failed tests.
+int UnitTestImpl::failed_test_count() const {
+  return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);
+}
+
+// Gets the number of disabled tests that will be reported in the XML report.
+int UnitTestImpl::reportable_disabled_test_count() const {
+  return SumOverTestCaseList(test_cases_,
+                             &TestCase::reportable_disabled_test_count);
+}
+
+// Gets the number of disabled tests.
+int UnitTestImpl::disabled_test_count() const {
+  return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);
+}
+
+// Gets the number of tests to be printed in the XML report.
+int UnitTestImpl::reportable_test_count() const {
+  return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count);
+}
+
+// Gets the number of all tests.
+int UnitTestImpl::total_test_count() const {
+  return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);
+}
+
+// Gets the number of tests that should run.
+int UnitTestImpl::test_to_run_count() const {
+  return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count);
+}
+
+// Returns the current OS stack trace as an std::string.
+//
+// The maximum number of stack frames to be included is specified by
+// the gtest_stack_trace_depth flag.  The skip_count parameter
+// specifies the number of top frames to be skipped, which doesn't
+// count against the number of frames to be included.
+//
+// For example, if Foo() calls Bar(), which in turn calls
+// CurrentOsStackTraceExceptTop(1), Foo() will be included in the
+// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
+std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
+  (void)skip_count;
+  return "";
+}
+
+// Returns the current time in milliseconds.
+TimeInMillis GetTimeInMillis() {
+#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)
+  // Difference between 1970-01-01 and 1601-01-01 in milliseconds.
+  // http://analogous.blogspot.com/2005/04/epoch.html
+  const TimeInMillis kJavaEpochToWinFileTimeDelta =
+    static_cast<TimeInMillis>(116444736UL) * 100000UL;
+  const DWORD kTenthMicrosInMilliSecond = 10000;
+
+  SYSTEMTIME now_systime;
+  FILETIME now_filetime;
+  ULARGE_INTEGER now_int64;
+  // TODO(kenton@google.com): Shouldn't this just use
+  //   GetSystemTimeAsFileTime()?
+  GetSystemTime(&now_systime);
+  if (SystemTimeToFileTime(&now_systime, &now_filetime)) {
+    now_int64.LowPart = now_filetime.dwLowDateTime;
+    now_int64.HighPart = now_filetime.dwHighDateTime;
+    now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -
+      kJavaEpochToWinFileTimeDelta;
+    return now_int64.QuadPart;
+  }
+  return 0;
+#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_
+  __timeb64 now;
+
+# ifdef _MSC_VER
+
+  // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
+  // (deprecated function) there.
+  // TODO(kenton@google.com): Use GetTickCount()?  Or use
+  //   SystemTimeToFileTime()
+#  pragma warning(push)          // Saves the current warning state.
+#  pragma warning(disable:4996)  // Temporarily disables warning 4996.
+  _ftime64(&now);
+#  pragma warning(pop)           // Restores the warning state.
+# else
+
+  _ftime64(&now);
+
+# endif  // _MSC_VER
+
+  return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
+#elif GTEST_HAS_GETTIMEOFDAY_
+  struct timeval now;
+  gettimeofday(&now, NULL);
+  return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;
+#else
+# error "Don't know how to get the current time on your system."
+#endif
+}
+
+// Utilities
+
+// class String.
+
+#if GTEST_OS_WINDOWS_MOBILE
+// Creates a UTF-16 wide string from the given ANSI string, allocating
+// memory using new. The caller is responsible for deleting the return
+// value using delete[]. Returns the wide string, or NULL if the
+// input is NULL.
+LPCWSTR String::AnsiToUtf16(const char* ansi) {
+  if (!ansi) return NULL;
+  const int length = strlen(ansi);
+  const int unicode_length =
+      MultiByteToWideChar(CP_ACP, 0, ansi, length,
+                          NULL, 0);
+  WCHAR* unicode = new WCHAR[unicode_length + 1];
+  MultiByteToWideChar(CP_ACP, 0, ansi, length,
+                      unicode, unicode_length);
+  unicode[unicode_length] = 0;
+  return unicode;
+}
+
+// Creates an ANSI string from the given wide string, allocating
+// memory using new. The caller is responsible for deleting the return
+// value using delete[]. Returns the ANSI string, or NULL if the
+// input is NULL.
+const char* String::Utf16ToAnsi(LPCWSTR utf16_str)  {
+  if (!utf16_str) return NULL;
+  const int ansi_length =
+      WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
+                          NULL, 0, NULL, NULL);
+  char* ansi = new char[ansi_length + 1];
+  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
+                      ansi, ansi_length, NULL, NULL);
+  ansi[ansi_length] = 0;
+  return ansi;
+}
+
+#endif  // GTEST_OS_WINDOWS_MOBILE
+
+// Compares two C strings.  Returns true iff they have the same content.
+//
+// Unlike strcmp(), this function can handle NULL argument(s).  A NULL
+// C string is considered different to any non-NULL C string,
+// including the empty string.
+bool String::CStringEquals(const char * lhs, const char * rhs) {
+  if ( lhs == NULL ) return rhs == NULL;
+
+  if ( rhs == NULL ) return false;
+
+  return strcmp(lhs, rhs) == 0;
+}
+
+#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
+
+// Converts an array of wide chars to a narrow string using the UTF-8
+// encoding, and streams the result to the given Message object.
+static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,
+                                     Message* msg) {
+  for (size_t i = 0; i != length; ) {  // NOLINT
+    if (wstr[i] != L'\0') {
+      *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
+      while (i != length && wstr[i] != L'\0')
+        i++;
+    } else {
+      *msg << '\0';
+      i++;
+    }
+  }
+}
+
+#endif  // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
+
+}  // namespace internal
+
+// Constructs an empty Message.
+// We allocate the stringstream separately because otherwise each use of
+// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
+// stack frame leading to huge stack frames in some cases; gcc does not reuse
+// the stack space.
+Message::Message() : ss_(new ::std::stringstream) {
+  // By default, we want there to be enough precision when printing
+  // a double to a Message.
+  *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
+}
+
+// These two overloads allow streaming a wide C string to a Message
+// using the UTF-8 encoding.
+Message& Message::operator <<(const wchar_t* wide_c_str) {
+  return *this << internal::String::ShowWideCString(wide_c_str);
+}
+Message& Message::operator <<(wchar_t* wide_c_str) {
+  return *this << internal::String::ShowWideCString(wide_c_str);
+}
+
+#if GTEST_HAS_STD_WSTRING
+// Converts the given wide string to a narrow string using the UTF-8
+// encoding, and streams the result to this Message object.
+Message& Message::operator <<(const ::std::wstring& wstr) {
+  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
+  return *this;
+}
+#endif  // GTEST_HAS_STD_WSTRING
+
+#if GTEST_HAS_GLOBAL_WSTRING
+// Converts the given wide string to a narrow string using the UTF-8
+// encoding, and streams the result to this Message object.
+Message& Message::operator <<(const ::wstring& wstr) {
+  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
+  return *this;
+}
+#endif  // GTEST_HAS_GLOBAL_WSTRING
+
+// Gets the text streamed to this object so far as an std::string.
+// Each '\0' character in the buffer is replaced with "\\0".
+std::string Message::GetString() const {
+  return internal::StringStreamToString(ss_.get());
+}
+
+// AssertionResult constructors.
+// Used in EXPECT_TRUE/FALSE(assertion_result).
+AssertionResult::AssertionResult(const AssertionResult& other)
+    : success_(other.success_),
+      message_(other.message_.get() != NULL ?
+               new ::std::string(*other.message_) :
+               static_cast< ::std::string*>(NULL)) {
+}
+
+// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
+AssertionResult AssertionResult::operator!() const {
+  AssertionResult negation(!success_);
+  if (message_.get() != NULL)
+    negation << *message_;
+  return negation;
+}
+
+// Makes a successful assertion result.
+AssertionResult AssertionSuccess() {
+  return AssertionResult(true);
+}
+
+// Makes a failed assertion result.
+AssertionResult AssertionFailure() {
+  return AssertionResult(false);
+}
+
+// Makes a failed assertion result with the given failure message.
+// Deprecated; use AssertionFailure() << message.
+AssertionResult AssertionFailure(const Message& message) {
+  return AssertionFailure() << message;
+}
+
+namespace internal {
+
+// Constructs and returns the message for an equality assertion
+// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
+//
+// The first four parameters are the expressions used in the assertion
+// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
+// where foo is 5 and bar is 6, we have:
+//
+//   expected_expression: "foo"
+//   actual_expression:   "bar"
+//   expected_value:      "5"
+//   actual_value:        "6"
+//
+// The ignoring_case parameter is true iff the assertion is a
+// *_STRCASEEQ*.  When it's true, the string " (ignoring case)" will
+// be inserted into the message.
+AssertionResult EqFailure(const char* expected_expression,
+                          const char* actual_expression,
+                          const std::string& expected_value,
+                          const std::string& actual_value,
+                          bool ignoring_case) {
+  Message msg;
+  msg << "Value of: " << actual_expression;
+  if (actual_value != actual_expression) {
+    msg << "\n  Actual: " << actual_value;
+  }
+
+  msg << "\nExpected: " << expected_expression;
+  if (ignoring_case) {
+    msg << " (ignoring case)";
+  }
+  if (expected_value != expected_expression) {
+    msg << "\nWhich is: " << expected_value;
+  }
+
+  return AssertionFailure() << msg;
+}
+
+// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
+std::string GetBoolAssertionFailureMessage(
+    const AssertionResult& assertion_result,
+    const char* expression_text,
+    const char* actual_predicate_value,
+    const char* expected_predicate_value) {
+  const char* actual_message = assertion_result.message();
+  Message msg;
+  msg << "Value of: " << expression_text
+      << "\n  Actual: " << actual_predicate_value;
+  if (actual_message[0] != '\0')
+    msg << " (" << actual_message << ")";
+  msg << "\nExpected: " << expected_predicate_value;
+  return msg.GetString();
+}
+
+// Helper function for implementing ASSERT_NEAR.
+AssertionResult DoubleNearPredFormat(const char* expr1,
+                                     const char* expr2,
+                                     const char* abs_error_expr,
+                                     double val1,
+                                     double val2,
+                                     double abs_error) {
+  const double diff = fabs(val1 - val2);
+  if (diff <= abs_error) return AssertionSuccess();
+
+  // TODO(wan): do not print the value of an expression if it's
+  // already a literal.
+  return AssertionFailure()
+      << "The difference between " << expr1 << " and " << expr2
+      << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n"
+      << expr1 << " evaluates to " << val1 << ",\n"
+      << expr2 << " evaluates to " << val2 << ", and\n"
+      << abs_error_expr << " evaluates to " << abs_error << ".";
+}
+
+
+// Helper template for implementing FloatLE() and DoubleLE().
+template <typename RawType>
+AssertionResult FloatingPointLE(const char* expr1,
+                                const char* expr2,
+                                RawType val1,
+                                RawType val2) {
+  // Returns success if val1 is less than val2,
+  if (val1 < val2) {
+    return AssertionSuccess();
+  }
+
+  // or if val1 is almost equal to val2.
+  const FloatingPoint<RawType> lhs(val1), rhs(val2);
+  if (lhs.AlmostEquals(rhs)) {
+    return AssertionSuccess();
+  }
+
+  // Note that the above two checks will both fail if either val1 or
+  // val2 is NaN, as the IEEE floating-point standard requires that
+  // any predicate involving a NaN must return false.
+
+  ::std::stringstream val1_ss;
+  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
+          << val1;
+
+  ::std::stringstream val2_ss;
+  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
+          << val2;
+
+  return AssertionFailure()
+      << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
+      << "  Actual: " << StringStreamToString(&val1_ss) << " vs "
+      << StringStreamToString(&val2_ss);
+}
+
+}  // namespace internal
+
+// Asserts that val1 is less than, or almost equal to, val2.  Fails
+// otherwise.  In particular, it fails if either val1 or val2 is NaN.
+AssertionResult FloatLE(const char* expr1, const char* expr2,
+                        float val1, float val2) {
+  return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);
+}
+
+// Asserts that val1 is less than, or almost equal to, val2.  Fails
+// otherwise.  In particular, it fails if either val1 or val2 is NaN.
+AssertionResult DoubleLE(const char* expr1, const char* expr2,
+                         double val1, double val2) {
+  return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);
+}
+
+namespace internal {
+
+// The helper function for {ASSERT|EXPECT}_EQ with int or enum
+// arguments.
+AssertionResult CmpHelperEQ(const char* expected_expression,
+                            const char* actual_expression,
+                            BiggestInt expected,
+                            BiggestInt actual) {
+  if (expected == actual) {
+    return AssertionSuccess();
+  }
+
+  return EqFailure(expected_expression,
+                   actual_expression,
+                   FormatForComparisonFailureMessage(expected, actual),
+                   FormatForComparisonFailureMessage(actual, expected),
+                   false);
+}
+
+// A macro for implementing the helper functions needed to implement
+// ASSERT_?? and EXPECT_?? with integer or enum arguments.  It is here
+// just to avoid copy-and-paste of similar code.
+#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
+AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
+                                   BiggestInt val1, BiggestInt val2) {\
+  if (val1 op val2) {\
+    return AssertionSuccess();\
+  } else {\
+    return AssertionFailure() \
+        << "Expected: (" << expr1 << ") " #op " (" << expr2\
+        << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
+        << " vs " << FormatForComparisonFailureMessage(val2, val1);\
+  }\
+}
+
+// Implements the helper function for {ASSERT|EXPECT}_NE with int or
+// enum arguments.
+GTEST_IMPL_CMP_HELPER_(NE, !=)
+// Implements the helper function for {ASSERT|EXPECT}_LE with int or
+// enum arguments.
+GTEST_IMPL_CMP_HELPER_(LE, <=)
+// Implements the helper function for {ASSERT|EXPECT}_LT with int or
+// enum arguments.
+GTEST_IMPL_CMP_HELPER_(LT, < )
+// Implements the helper function for {ASSERT|EXPECT}_GE with int or
+// enum arguments.
+GTEST_IMPL_CMP_HELPER_(GE, >=)
+// Implements the helper function for {ASSERT|EXPECT}_GT with int or
+// enum arguments.
+GTEST_IMPL_CMP_HELPER_(GT, > )
+
+#undef GTEST_IMPL_CMP_HELPER_
+
+// The helper function for {ASSERT|EXPECT}_STREQ.
+AssertionResult CmpHelperSTREQ(const char* expected_expression,
+                               const char* actual_expression,
+                               const char* expected,
+                               const char* actual) {
+  if (String::CStringEquals(expected, actual)) {
+    return AssertionSuccess();
+  }
+
+  return EqFailure(expected_expression,
+                   actual_expression,
+                   PrintToString(expected),
+                   PrintToString(actual),
+                   false);
+}
+
+// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
+AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
+                                   const char* actual_expression,
+                                   const char* expected,
+                                   const char* actual) {
+  if (String::CaseInsensitiveCStringEquals(expected, actual)) {
+    return AssertionSuccess();
+  }
+
+  return EqFailure(expected_expression,
+                   actual_expression,
+                   PrintToString(expected),
+                   PrintToString(actual),
+                   true);
+}
+
+// The helper function for {ASSERT|EXPECT}_STRNE.
+AssertionResult CmpHelperSTRNE(const char* s1_expression,
+                               const char* s2_expression,
+                               const char* s1,
+                               const char* s2) {
+  if (!String::CStringEquals(s1, s2)) {
+    return AssertionSuccess();
+  } else {
+    return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
+                              << s2_expression << "), actual: \""
+                              << s1 << "\" vs \"" << s2 << "\"";
+  }
+}
+
+// The helper function for {ASSERT|EXPECT}_STRCASENE.
+AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
+                                   const char* s2_expression,
+                                   const char* s1,
+                                   const char* s2) {
+  if (!String::CaseInsensitiveCStringEquals(s1, s2)) {
+    return AssertionSuccess();
+  } else {
+    return AssertionFailure()
+        << "Expected: (" << s1_expression << ") != ("
+        << s2_expression << ") (ignoring case), actual: \""
+        << s1 << "\" vs \"" << s2 << "\"";
+  }
+}
+
+}  // namespace internal
+
+namespace {
+
+// Helper functions for implementing IsSubString() and IsNotSubstring().
+
+// This group of overloaded functions return true iff needle is a
+// substring of haystack.  NULL is considered a substring of itself
+// only.
+
+bool IsSubstringPred(const char* needle, const char* haystack) {
+  if (needle == NULL || haystack == NULL)
+    return needle == haystack;
+
+  return strstr(haystack, needle) != NULL;
+}
+
+bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {
+  if (needle == NULL || haystack == NULL)
+    return needle == haystack;
+
+  return wcsstr(haystack, needle) != NULL;
+}
+
+// StringType here can be either ::std::string or ::std::wstring.
+template <typename StringType>
+bool IsSubstringPred(const StringType& needle,
+                     const StringType& haystack) {
+  return haystack.find(needle) != StringType::npos;
+}
+
+// This function implements either IsSubstring() or IsNotSubstring(),
+// depending on the value of the expected_to_be_substring parameter.
+// StringType here can be const char*, const wchar_t*, ::std::string,
+// or ::std::wstring.
+template <typename StringType>
+AssertionResult IsSubstringImpl(
+    bool expected_to_be_substring,
+    const char* needle_expr, const char* haystack_expr,
+    const StringType& needle, const StringType& haystack) {
+  if (IsSubstringPred(needle, haystack) == expected_to_be_substring)
+    return AssertionSuccess();
+
+  const bool is_wide_string = sizeof(needle[0]) > 1;
+  const char* const begin_string_quote = is_wide_string ? "L\"" : "\"";
+  return AssertionFailure()
+      << "Value of: " << needle_expr << "\n"
+      << "  Actual: " << begin_string_quote << needle << "\"\n"
+      << "Expected: " << (expected_to_be_substring ? "" : "not ")
+      << "a substring of " << haystack_expr << "\n"
+      << "Which is: " << begin_string_quote << haystack << "\"";
+}
+
+}  // namespace
+
+// IsSubstring() and IsNotSubstring() check whether needle is a
+// substring of haystack (NULL is considered a substring of itself
+// only), and return an appropriate error message when they fail.
+
+AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const char* needle, const char* haystack) {
+  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
+}
+
+AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const wchar_t* needle, const wchar_t* haystack) {
+  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
+}
+
+AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const char* needle, const char* haystack) {
+  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
+}
+
+AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const wchar_t* needle, const wchar_t* haystack) {
+  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
+}
+
+AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::string& needle, const ::std::string& haystack) {
+  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
+}
+
+AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::string& needle, const ::std::string& haystack) {
+  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
+}
+
+#if GTEST_HAS_STD_WSTRING
+AssertionResult IsSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::wstring& needle, const ::std::wstring& haystack) {
+  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
+}
+
+AssertionResult IsNotSubstring(
+    const char* needle_expr, const char* haystack_expr,
+    const ::std::wstring& needle, const ::std::wstring& haystack) {
+  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
+}
+#endif  // GTEST_HAS_STD_WSTRING
+
+namespace internal {
+
+#if GTEST_OS_WINDOWS
+
+namespace {
+
+// Helper function for IsHRESULT{SuccessFailure} predicates
+AssertionResult HRESULTFailureHelper(const char* expr,
+                                     const char* expected,
+                                     long hr) {  // NOLINT
+# if GTEST_OS_WINDOWS_MOBILE
+
+  // Windows CE doesn't support FormatMessage.
+  const char error_text[] = "";
+
+# else
+
+  // Looks up the human-readable system message for the HRESULT code
+  // and since we're not passing any params to FormatMessage, we don't
+  // want inserts expanded.
+  const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
+                       FORMAT_MESSAGE_IGNORE_INSERTS;
+  const DWORD kBufSize = 4096;
+  // Gets the system's human readable message string for this HRESULT.
+  char error_text[kBufSize] = { '\0' };
+  DWORD message_length = ::FormatMessageA(kFlags,
+                                          0,  // no source, we're asking system
+                                          hr,  // the error
+                                          0,  // no line width restrictions
+                                          error_text,  // output buffer
+                                          kBufSize,  // buf size
+                                          NULL);  // no arguments for inserts
+  // Trims tailing white space (FormatMessage leaves a trailing CR-LF)
+  for (; message_length && IsSpace(error_text[message_length - 1]);
+          --message_length) {
+    error_text[message_length - 1] = '\0';
+  }
+
+# endif  // GTEST_OS_WINDOWS_MOBILE
+
+  const std::string error_hex("0x" + String::FormatHexInt(hr));
+  return ::testing::AssertionFailure()
+      << "Expected: " << expr << " " << expected << ".\n"
+      << "  Actual: " << error_hex << " " << error_text << "\n";
+}
+
+}  // namespace
+
+AssertionResult IsHRESULTSuccess(const char* expr, long hr) {  // NOLINT
+  if (SUCCEEDED(hr)) {
+    return AssertionSuccess();
+  }
+  return HRESULTFailureHelper(expr, "succeeds", hr);
+}
+
+AssertionResult IsHRESULTFailure(const char* expr, long hr) {  // NOLINT
+  if (FAILED(hr)) {
+    return AssertionSuccess();
+  }
+  return HRESULTFailureHelper(expr, "fails", hr);
+}
+
+#endif  // GTEST_OS_WINDOWS
+
+// Utility functions for encoding Unicode text (wide strings) in
+// UTF-8.
+
+// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8
+// like this:
+//
+// Code-point length   Encoding
+//   0 -  7 bits       0xxxxxxx
+//   8 - 11 bits       110xxxxx 10xxxxxx
+//  12 - 16 bits       1110xxxx 10xxxxxx 10xxxxxx
+//  17 - 21 bits       11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+
+// The maximum code-point a one-byte UTF-8 sequence can represent.
+const UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) <<  7) - 1;
+
+// The maximum code-point a two-byte UTF-8 sequence can represent.
+const UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1;
+
+// The maximum code-point a three-byte UTF-8 sequence can represent.
+const UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1;
+
+// The maximum code-point a four-byte UTF-8 sequence can represent.
+const UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1;
+
+// Chops off the n lowest bits from a bit pattern.  Returns the n
+// lowest bits.  As a side effect, the original bit pattern will be
+// shifted to the right by n bits.
+inline UInt32 ChopLowBits(UInt32* bits, int n) {
+  const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1);
+  *bits >>= n;
+  return low_bits;
+}
+
+// Converts a Unicode code point to a narrow string in UTF-8 encoding.
+// code_point parameter is of type UInt32 because wchar_t may not be
+// wide enough to contain a code point.
+// If the code_point is not a valid Unicode code point
+// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
+// to "(Invalid Unicode 0xXXXXXXXX)".
+std::string CodePointToUtf8(UInt32 code_point) {
+  if (code_point > kMaxCodePoint4) {
+    return "(Invalid Unicode 0x" + String::FormatHexInt(code_point) + ")";
+  }
+
+  char str[5];  // Big enough for the largest valid code point.
+  if (code_point <= kMaxCodePoint1) {
+    str[1] = '\0';
+    str[0] = static_cast<char>(code_point);                          // 0xxxxxxx
+  } else if (code_point <= kMaxCodePoint2) {
+    str[2] = '\0';
+    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
+    str[0] = static_cast<char>(0xC0 | code_point);                   // 110xxxxx
+  } else if (code_point <= kMaxCodePoint3) {
+    str[3] = '\0';
+    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
+    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
+    str[0] = static_cast<char>(0xE0 | code_point);                   // 1110xxxx
+  } else {  // code_point <= kMaxCodePoint4
+    str[4] = '\0';
+    str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
+    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
+    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
+    str[0] = static_cast<char>(0xF0 | code_point);                   // 11110xxx
+  }
+  return str;
+}
+
+// The following two functions only make sense if the the system
+// uses UTF-16 for wide string encoding. All supported systems
+// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
+
+// Determines if the arguments constitute UTF-16 surrogate pair
+// and thus should be combined into a single Unicode code point
+// using CreateCodePointFromUtf16SurrogatePair.
+inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {
+  return sizeof(wchar_t) == 2 &&
+      (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;
+}
+
+// Creates a Unicode code point from UTF16 surrogate pair.
+inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,
+                                                    wchar_t second) {
+  const UInt32 mask = (1 << 10) - 1;
+  return (sizeof(wchar_t) == 2) ?
+      (((first & mask) << 10) | (second & mask)) + 0x10000 :
+      // This function should not be called when the condition is
+      // false, but we provide a sensible default in case it is.
+      static_cast<UInt32>(first);
+}
+
+// Converts a wide string to a narrow string in UTF-8 encoding.
+// The wide string is assumed to have the following encoding:
+//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
+//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)
+// Parameter str points to a null-terminated wide string.
+// Parameter num_chars may additionally limit the number
+// of wchar_t characters processed. -1 is used when the entire string
+// should be processed.
+// If the string contains code points that are not valid Unicode code points
+// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
+// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
+// and contains invalid UTF-16 surrogate pairs, values in those pairs
+// will be encoded as individual Unicode characters from Basic Normal Plane.
+std::string WideStringToUtf8(const wchar_t* str, int num_chars) {
+  if (num_chars == -1)
+    num_chars = static_cast<int>(wcslen(str));
+
+  ::std::stringstream stream;
+  for (int i = 0; i < num_chars; ++i) {
+    UInt32 unicode_code_point;
+
+    if (str[i] == L'\0') {
+      break;
+    } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
+      unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
+                                                                 str[i + 1]);
+      i++;
+    } else {
+      unicode_code_point = static_cast<UInt32>(str[i]);
+    }
+
+    stream << CodePointToUtf8(unicode_code_point);
+  }
+  return StringStreamToString(&stream);
+}
+
+// Converts a wide C string to an std::string using the UTF-8 encoding.
+// NULL will be converted to "(null)".
+std::string String::ShowWideCString(const wchar_t * wide_c_str) {
+  if (wide_c_str == NULL)  return "(null)";
+
+  return internal::WideStringToUtf8(wide_c_str, -1);
+}
+
+// Compares two wide C strings.  Returns true iff they have the same
+// content.
+//
+// Unlike wcscmp(), this function can handle NULL argument(s).  A NULL
+// C string is considered different to any non-NULL C string,
+// including the empty string.
+bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {
+  if (lhs == NULL) return rhs == NULL;
+
+  if (rhs == NULL) return false;
+
+  return wcscmp(lhs, rhs) == 0;
+}
+
+// Helper function for *_STREQ on wide strings.
+AssertionResult CmpHelperSTREQ(const char* expected_expression,
+                               const char* actual_expression,
+                               const wchar_t* expected,
+                               const wchar_t* actual) {
+  if (String::WideCStringEquals(expected, actual)) {
+    return AssertionSuccess();
+  }
+
+  return EqFailure(expected_expression,
+                   actual_expression,
+                   PrintToString(expected),
+                   PrintToString(actual),
+                   false);
+}
+
+// Helper function for *_STRNE on wide strings.
+AssertionResult CmpHelperSTRNE(const char* s1_expression,
+                               const char* s2_expression,
+                               const wchar_t* s1,
+                               const wchar_t* s2) {
+  if (!String::WideCStringEquals(s1, s2)) {
+    return AssertionSuccess();
+  }
+
+  return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
+                            << s2_expression << "), actual: "
+                            << PrintToString(s1)
+                            << " vs " << PrintToString(s2);
+}
+
+// Compares two C strings, ignoring case.  Returns true iff they have
+// the same content.
+//
+// Unlike strcasecmp(), this function can handle NULL argument(s).  A
+// NULL C string is considered different to any non-NULL C string,
+// including the empty string.
+bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
+  if (lhs == NULL)
+    return rhs == NULL;
+  if (rhs == NULL)
+    return false;
+  return posix::StrCaseCmp(lhs, rhs) == 0;
+}
+
+  // Compares two wide C strings, ignoring case.  Returns true iff they
+  // have the same content.
+  //
+  // Unlike wcscasecmp(), this function can handle NULL argument(s).
+  // A NULL C string is considered different to any non-NULL wide C string,
+  // including the empty string.
+  // NB: The implementations on different platforms slightly differ.
+  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
+  // environment variable. On GNU platform this method uses wcscasecmp
+  // which compares according to LC_CTYPE category of the current locale.
+  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
+  // current locale.
+bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
+                                              const wchar_t* rhs) {
+  if (lhs == NULL) return rhs == NULL;
+
+  if (rhs == NULL) return false;
+
+#if GTEST_OS_WINDOWS
+  return _wcsicmp(lhs, rhs) == 0;
+#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
+  return wcscasecmp(lhs, rhs) == 0;
+#else
+  // Android, Mac OS X and Cygwin don't define wcscasecmp.
+  // Other unknown OSes may not define it either.
+  wint_t left, right;
+  do {
+    left = towlower(*lhs++);
+    right = towlower(*rhs++);
+  } while (left && left == right);
+  return left == right;
+#endif  // OS selector
+}
+
+// Returns true iff str ends with the given suffix, ignoring case.
+// Any string is considered to end with an empty suffix.
+bool String::EndsWithCaseInsensitive(
+    const std::string& str, const std::string& suffix) {
+  const size_t str_len = str.length();
+  const size_t suffix_len = suffix.length();
+  return (str_len >= suffix_len) &&
+         CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,
+                                      suffix.c_str());
+}
+
+// Formats an int value as "%02d".
+std::string String::FormatIntWidth2(int value) {
+  std::stringstream ss;
+  ss << std::setfill('0') << std::setw(2) << value;
+  return ss.str();
+}
+
+// Formats an int value as "%X".
+std::string String::FormatHexInt(int value) {
+  std::stringstream ss;
+  ss << std::hex << std::uppercase << value;
+  return ss.str();
+}
+
+// Formats a byte as "%02X".
+std::string String::FormatByte(unsigned char value) {
+  std::stringstream ss;
+  ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase
+     << static_cast<unsigned int>(value);
+  return ss.str();
+}
+
+// Converts the buffer in a stringstream to an std::string, converting NUL
+// bytes to "\\0" along the way.
+std::string StringStreamToString(::std::stringstream* ss) {
+  const ::std::string& str = ss->str();
+  const char* const start = str.c_str();
+  const char* const end = start + str.length();
+
+  std::string result;
+  result.reserve(2 * (end - start));
+  for (const char* ch = start; ch != end; ++ch) {
+    if (*ch == '\0') {
+      result += "\\0";  // Replaces NUL with "\\0";
+    } else {
+      result += *ch;
+    }
+  }
+
+  return result;
+}
+
+// Appends the user-supplied message to the Google-Test-generated message.
+std::string AppendUserMessage(const std::string& gtest_msg,
+                              const Message& user_msg) {
+  // Appends the user message if it's non-empty.
+  const std::string user_msg_string = user_msg.GetString();
+  if (user_msg_string.empty()) {
+    return gtest_msg;
+  }
+
+  return gtest_msg + "\n" + user_msg_string;
+}
+
+}  // namespace internal
+
+// class TestResult
+
+// Creates an empty TestResult.
+TestResult::TestResult()
+    : death_test_count_(0),
+      elapsed_time_(0) {
+}
+
+// D'tor.
+TestResult::~TestResult() {
+}
+
+// Returns the i-th test part result among all the results. i can
+// range from 0 to total_part_count() - 1. If i is not in that range,
+// aborts the program.
+const TestPartResult& TestResult::GetTestPartResult(int i) const {
+  if (i < 0 || i >= total_part_count())
+    internal::posix::Abort();
+  return test_part_results_.at(i);
+}
+
+// Returns the i-th test property. i can range from 0 to
+// test_property_count() - 1. If i is not in that range, aborts the
+// program.
+const TestProperty& TestResult::GetTestProperty(int i) const {
+  if (i < 0 || i >= test_property_count())
+    internal::posix::Abort();
+  return test_properties_.at(i);
+}
+
+// Clears the test part results.
+void TestResult::ClearTestPartResults() {
+  test_part_results_.clear();
+}
+
+// Adds a test part result to the list.
+void TestResult::AddTestPartResult(const TestPartResult& test_part_result) {
+  test_part_results_.push_back(test_part_result);
+}
+
+// Adds a test property to the list. If a property with the same key as the
+// supplied property is already represented, the value of this test_property
+// replaces the old value for that key.
+void TestResult::RecordProperty(const std::string& xml_element,
+                                const TestProperty& test_property) {
+  if (!ValidateTestProperty(xml_element, test_property)) {
+    return;
+  }
+  internal::MutexLock lock(&test_properites_mutex_);
+  const std::vector<TestProperty>::iterator property_with_matching_key =
+      std::find_if(test_properties_.begin(), test_properties_.end(),
+                   internal::TestPropertyKeyIs(test_property.key()));
+  if (property_with_matching_key == test_properties_.end()) {
+    test_properties_.push_back(test_property);
+    return;
+  }
+  property_with_matching_key->SetValue(test_property.value());
+}
+
+// The list of reserved attributes used in the <testsuites> element of XML
+// output.
+static const char* const kReservedTestSuitesAttributes[] = {
+  "disabled",
+  "errors",
+  "failures",
+  "name",
+  "random_seed",
+  "tests",
+  "time",
+  "timestamp"
+};
+
+// The list of reserved attributes used in the <testsuite> element of XML
+// output.
+static const char* const kReservedTestSuiteAttributes[] = {
+  "disabled",
+  "errors",
+  "failures",
+  "name",
+  "tests",
+  "time"
+};
+
+// The list of reserved attributes used in the <testcase> element of XML output.
+static const char* const kReservedTestCaseAttributes[] = {
+  "classname",
+  "name",
+  "status",
+  "time",
+  "type_param",
+  "value_param"
+};
+
+template <int kSize>
+std::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) {
+  return std::vector<std::string>(array, array + kSize);
+}
+
+static std::vector<std::string> GetReservedAttributesForElement(
+    const std::string& xml_element) {
+  if (xml_element == "testsuites") {
+    return ArrayAsVector(kReservedTestSuitesAttributes);
+  } else if (xml_element == "testsuite") {
+    return ArrayAsVector(kReservedTestSuiteAttributes);
+  } else if (xml_element == "testcase") {
+    return ArrayAsVector(kReservedTestCaseAttributes);
+  } else {
+    GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
+  }
+  // This code is unreachable but some compilers may not realizes that.
+  return std::vector<std::string>();
+}
+
+static std::string FormatWordList(const std::vector<std::string>& words) {
+  Message word_list;
+  for (size_t i = 0; i < words.size(); ++i) {
+    if (i > 0 && words.size() > 2) {
+      word_list << ", ";
+    }
+    if (i == words.size() - 1) {
+      word_list << "and ";
+    }
+    word_list << "'" << words[i] << "'";
+  }
+  return word_list.GetString();
+}
+
+bool ValidateTestPropertyName(const std::string& property_name,
+                              const std::vector<std::string>& reserved_names) {
+  if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=
+          reserved_names.end()) {
+    ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name
+                  << " (" << FormatWordList(reserved_names)
+                  << " are reserved by " << GTEST_NAME_ << ")";
+    return false;
+  }
+  return true;
+}
+
+// Adds a failure if the key is a reserved attribute of the element named
+// xml_element.  Returns true if the property is valid.
+bool TestResult::ValidateTestProperty(const std::string& xml_element,
+                                      const TestProperty& test_property) {
+  return ValidateTestPropertyName(test_property.key(),
+                                  GetReservedAttributesForElement(xml_element));
+}
+
+// Clears the object.
+void TestResult::Clear() {
+  test_part_results_.clear();
+  test_properties_.clear();
+  death_test_count_ = 0;
+  elapsed_time_ = 0;
+}
+
+// Returns true iff the test failed.
+bool TestResult::Failed() const {
+  for (int i = 0; i < total_part_count(); ++i) {
+    if (GetTestPartResult(i).failed())
+      return true;
+  }
+  return false;
+}
+
+// Returns true iff the test part fatally failed.
+static bool TestPartFatallyFailed(const TestPartResult& result) {
+  return result.fatally_failed();
+}
+
+// Returns true iff the test fatally failed.
+bool TestResult::HasFatalFailure() const {
+  return CountIf(test_part_results_, TestPartFatallyFailed) > 0;
+}
+
+// Returns true iff the test part non-fatally failed.
+static bool TestPartNonfatallyFailed(const TestPartResult& result) {
+  return result.nonfatally_failed();
+}
+
+// Returns true iff the test has a non-fatal failure.
+bool TestResult::HasNonfatalFailure() const {
+  return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;
+}
+
+// Gets the number of all test parts.  This is the sum of the number
+// of successful test parts and the number of failed test parts.
+int TestResult::total_part_count() const {
+  return static_cast<int>(test_part_results_.size());
+}
+
+// Returns the number of the test properties.
+int TestResult::test_property_count() const {
+  return static_cast<int>(test_properties_.size());
+}
+
+// class Test
+
+// Creates a Test object.
+
+// The c'tor saves the values of all Google Test flags.
+Test::Test()
+    : gtest_flag_saver_(new internal::GTestFlagSaver) {
+}
+
+// The d'tor restores the values of all Google Test flags.
+Test::~Test() {
+  delete gtest_flag_saver_;
+}
+
+// Sets up the test fixture.
+//
+// A sub-class may override this.
+void Test::SetUp() {
+}
+
+// Tears down the test fixture.
+//
+// A sub-class may override this.
+void Test::TearDown() {
+}
+
+// Allows user supplied key value pairs to be recorded for later output.
+void Test::RecordProperty(const std::string& key, const std::string& value) {
+  UnitTest::GetInstance()->RecordProperty(key, value);
+}
+
+// Allows user supplied key value pairs to be recorded for later output.
+void Test::RecordProperty(const std::string& key, int value) {
+  Message value_message;
+  value_message << value;
+  RecordProperty(key, value_message.GetString().c_str());
+}
+
+namespace internal {
+
+void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
+                                    const std::string& message) {
+  // This function is a friend of UnitTest and as such has access to
+  // AddTestPartResult.
+  UnitTest::GetInstance()->AddTestPartResult(
+      result_type,
+      NULL,  // No info about the source file where the exception occurred.
+      -1,    // We have no info on which line caused the exception.
+      message,
+      "");   // No stack trace, either.
+}
+
+}  // namespace internal
+
+// Google Test requires all tests in the same test case to use the same test
+// fixture class.  This function checks if the current test has the
+// same fixture class as the first test in the current test case.  If
+// yes, it returns true; otherwise it generates a Google Test failure and
+// returns false.
+bool Test::HasSameFixtureClass() {
+  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
+  const TestCase* const test_case = impl->current_test_case();
+
+  // Info about the first test in the current test case.
+  const TestInfo* const first_test_info = test_case->test_info_list()[0];
+  const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;
+  const char* const first_test_name = first_test_info->name();
+
+  // Info about the current test.
+  const TestInfo* const this_test_info = impl->current_test_info();
+  const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;
+  const char* const this_test_name = this_test_info->name();
+
+  if (this_fixture_id != first_fixture_id) {
+    // Is the first test defined using TEST?
+    const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();
+    // Is this test defined using TEST?
+    const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();
+
+    if (first_is_TEST || this_is_TEST) {
+      // The user mixed TEST and TEST_F in this test case - we'll tell
+      // him/her how to fix it.
+
+      // Gets the name of the TEST and the name of the TEST_F.  Note
+      // that first_is_TEST and this_is_TEST cannot both be true, as
+      // the fixture IDs are different for the two tests.
+      const char* const TEST_name =
+          first_is_TEST ? first_test_name : this_test_name;
+      const char* const TEST_F_name =
+          first_is_TEST ? this_test_name : first_test_name;
+
+      ADD_FAILURE()
+          << "All tests in the same test case must use the same test fixture\n"
+          << "class, so mixing TEST_F and TEST in the same test case is\n"
+          << "illegal.  In test case " << this_test_info->test_case_name()
+          << ",\n"
+          << "test " << TEST_F_name << " is defined using TEST_F but\n"
+          << "test " << TEST_name << " is defined using TEST.  You probably\n"
+          << "want to change the TEST to TEST_F or move it to another test\n"
+          << "case.";
+    } else {
+      // The user defined two fixture classes with the same name in
+      // two namespaces - we'll tell him/her how to fix it.
+      ADD_FAILURE()
+          << "All tests in the same test case must use the same test fixture\n"
+          << "class.  However, in test case "
+          << this_test_info->test_case_name() << ",\n"
+          << "you defined test " << first_test_name
+          << " and test " << this_test_name << "\n"
+          << "using two different test fixture classes.  This can happen if\n"
+          << "the two classes are from different namespaces or translation\n"
+          << "units and have the same name.  You should probably rename one\n"
+          << "of the classes to put the tests into different test cases.";
+    }
+    return false;
+  }
+
+  return true;
+}
+
+#if GTEST_HAS_SEH
+
+// Adds an "exception thrown" fatal failure to the current test.  This
+// function returns its result via an output parameter pointer because VC++
+// prohibits creation of objects with destructors on stack in functions
+// using __try (see error C2712).
+static std::string* FormatSehExceptionMessage(DWORD exception_code,
+                                              const char* location) {
+  Message message;
+  message << "SEH exception with code 0x" << std::setbase(16) <<
+    exception_code << std::setbase(10) << " thrown in " << location << ".";
+
+  return new std::string(message.GetString());
+}
+
+#endif  // GTEST_HAS_SEH
+
+namespace internal {
+
+#if GTEST_HAS_EXCEPTIONS
+
+// Adds an "exception thrown" fatal failure to the current test.
+static std::string FormatCxxExceptionMessage(const char* description,
+                                             const char* location) {
+  Message message;
+  if (description != NULL) {
+    message << "C++ exception with description \"" << description << "\"";
+  } else {
+    message << "Unknown C++ exception";
+  }
+  message << " thrown in " << location << ".";
+
+  return message.GetString();
+}
+
+static std::string PrintTestPartResultToString(
+    const TestPartResult& test_part_result);
+
+GoogleTestFailureException::GoogleTestFailureException(
+    const TestPartResult& failure)
+    : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}
+
+#endif  // GTEST_HAS_EXCEPTIONS
+
+// We put these helper functions in the internal namespace as IBM's xlC
+// compiler rejects the code if they were declared static.
+
+// Runs the given method and handles SEH exceptions it throws, when
+// SEH is supported; returns the 0-value for type Result in case of an
+// SEH exception.  (Microsoft compilers cannot handle SEH and C++
+// exceptions in the same function.  Therefore, we provide a separate
+// wrapper function for handling SEH exceptions.)
+template <class T, typename Result>
+Result HandleSehExceptionsInMethodIfSupported(
+    T* object, Result (T::*method)(), const char* location) {
+#if GTEST_HAS_SEH
+  __try {
+    return (object->*method)();
+  } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT
+      GetExceptionCode())) {
+    // We create the exception message on the heap because VC++ prohibits
+    // creation of objects with destructors on stack in functions using __try
+    // (see error C2712).
+    std::string* exception_message = FormatSehExceptionMessage(
+        GetExceptionCode(), location);
+    internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
+                                             *exception_message);
+    delete exception_message;
+    return static_cast<Result>(0);
+  }
+#else
+  (void)location;
+  return (object->*method)();
+#endif  // GTEST_HAS_SEH
+}
+
+// Runs the given method and catches and reports C++ and/or SEH-style
+// exceptions, if they are supported; returns the 0-value for type
+// Result in case of an SEH exception.
+template <class T, typename Result>
+Result HandleExceptionsInMethodIfSupported(
+    T* object, Result (T::*method)(), const char* location) {
+  // NOTE: The user code can affect the way in which Google Test handles
+  // exceptions by setting GTEST_FLAG(catch_exceptions), but only before
+  // RUN_ALL_TESTS() starts. It is technically possible to check the flag
+  // after the exception is caught and either report or re-throw the
+  // exception based on the flag's value:
+  //
+  // try {
+  //   // Perform the test method.
+  // } catch (...) {
+  //   if (GTEST_FLAG(catch_exceptions))
+  //     // Report the exception as failure.
+  //   else
+  //     throw;  // Re-throws the original exception.
+  // }
+  //
+  // However, the purpose of this flag is to allow the program to drop into
+  // the debugger when the exception is thrown. On most platforms, once the
+  // control enters the catch block, the exception origin information is
+  // lost and the debugger will stop the program at the point of the
+  // re-throw in this function -- instead of at the point of the original
+  // throw statement in the code under test.  For this reason, we perform
+  // the check early, sacrificing the ability to affect Google Test's
+  // exception handling in the method where the exception is thrown.
+  if (internal::GetUnitTestImpl()->catch_exceptions()) {
+#if GTEST_HAS_EXCEPTIONS
+    try {
+      return HandleSehExceptionsInMethodIfSupported(object, method, location);
+    } catch (const internal::GoogleTestFailureException&) {  // NOLINT
+      // This exception type can only be thrown by a failed Google
+      // Test assertion with the intention of letting another testing
+      // framework catch it.  Therefore we just re-throw it.
+      throw;
+    } catch (const std::exception& e) {  // NOLINT
+      internal::ReportFailureInUnknownLocation(
+          TestPartResult::kFatalFailure,
+          FormatCxxExceptionMessage(e.what(), location));
+    } catch (...) {  // NOLINT
+      internal::ReportFailureInUnknownLocation(
+          TestPartResult::kFatalFailure,
+          FormatCxxExceptionMessage(NULL, location));
+    }
+    return static_cast<Result>(0);
+#else
+    return HandleSehExceptionsInMethodIfSupported(object, method, location);
+#endif  // GTEST_HAS_EXCEPTIONS
+  } else {
+    return (object->*method)();
+  }
+}
+
+}  // namespace internal
+
+// Runs the test and updates the test result.
+void Test::Run() {
+  if (!HasSameFixtureClass()) return;
+
+  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
+  impl->os_stack_trace_getter()->UponLeavingGTest();
+  internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
+  // We will run the test only if SetUp() was successful.
+  if (!HasFatalFailure()) {
+    impl->os_stack_trace_getter()->UponLeavingGTest();
+    internal::HandleExceptionsInMethodIfSupported(
+        this, &Test::TestBody, "the test body");
+  }
+
+  // However, we want to clean up as much as possible.  Hence we will
+  // always call TearDown(), even if SetUp() or the test body has
+  // failed.
+  impl->os_stack_trace_getter()->UponLeavingGTest();
+  internal::HandleExceptionsInMethodIfSupported(
+      this, &Test::TearDown, "TearDown()");
+}
+
+// Returns true iff the current test has a fatal failure.
+bool Test::HasFatalFailure() {
+  return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();
+}
+
+// Returns true iff the current test has a non-fatal failure.
+bool Test::HasNonfatalFailure() {
+  return internal::GetUnitTestImpl()->current_test_result()->
+      HasNonfatalFailure();
+}
+
+// class TestInfo
+
+// Constructs a TestInfo object. It assumes ownership of the test factory
+// object.
+TestInfo::TestInfo(const std::string& a_test_case_name,
+                   const std::string& a_name,
+                   const char* a_type_param,
+                   const char* a_value_param,
+                   internal::TypeId fixture_class_id,
+                   internal::TestFactoryBase* factory)
+    : test_case_name_(a_test_case_name),
+      name_(a_name),
+      type_param_(a_type_param ? new std::string(a_type_param) : NULL),
+      value_param_(a_value_param ? new std::string(a_value_param) : NULL),
+      fixture_class_id_(fixture_class_id),
+      should_run_(false),
+      is_disabled_(false),
+      matches_filter_(false),
+      factory_(factory),
+      result_() {}
+
+// Destructs a TestInfo object.
+TestInfo::~TestInfo() { delete factory_; }
+
+namespace internal {
+
+// Creates a new TestInfo object and registers it with Google Test;
+// returns the created object.
+//
+// Arguments:
+//
+//   test_case_name:   name of the test case
+//   name:             name of the test
+//   type_param:       the name of the test's type parameter, or NULL if
+//                     this is not a typed or a type-parameterized test.
+//   value_param:      text representation of the test's value parameter,
+//                     or NULL if this is not a value-parameterized test.
+//   fixture_class_id: ID of the test fixture class
+//   set_up_tc:        pointer to the function that sets up the test case
+//   tear_down_tc:     pointer to the function that tears down the test case
+//   factory:          pointer to the factory that creates a test object.
+//                     The newly created TestInfo instance will assume
+//                     ownership of the factory object.
+TestInfo* MakeAndRegisterTestInfo(
+    const char* test_case_name,
+    const char* name,
+    const char* type_param,
+    const char* value_param,
+    TypeId fixture_class_id,
+    SetUpTestCaseFunc set_up_tc,
+    TearDownTestCaseFunc tear_down_tc,
+    TestFactoryBase* factory) {
+  TestInfo* const test_info =
+      new TestInfo(test_case_name, name, type_param, value_param,
+                   fixture_class_id, factory);
+  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
+  return test_info;
+}
+
+#if GTEST_HAS_PARAM_TEST
+void ReportInvalidTestCaseType(const char* test_case_name,
+                               const char* file, int line) {
+  Message errors;
+  errors
+      << "Attempted redefinition of test case " << test_case_name << ".\n"
+      << "All tests in the same test case must use the same test fixture\n"
+      << "class.  However, in test case " << test_case_name << ", you tried\n"
+      << "to define a test using a fixture class different from the one\n"
+      << "used earlier. This can happen if the two fixture classes are\n"
+      << "from different namespaces and have the same name. You should\n"
+      << "probably rename one of the classes to put the tests into different\n"
+      << "test cases.";
+
+  fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
+          errors.GetString().c_str());
+}
+#endif  // GTEST_HAS_PARAM_TEST
+
+}  // namespace internal
+
+namespace {
+
+// A predicate that checks the test name of a TestInfo against a known
+// value.
+//
+// This is used for implementation of the TestCase class only.  We put
+// it in the anonymous namespace to prevent polluting the outer
+// namespace.
+//
+// TestNameIs is copyable.
+class TestNameIs {
+ public:
+  // Constructor.
+  //
+  // TestNameIs has NO default constructor.
+  explicit TestNameIs(const char* name)
+      : name_(name) {}
+
+  // Returns true iff the test name of test_info matches name_.
+  bool operator()(const TestInfo * test_info) const {
+    return test_info && test_info->name() == name_;
+  }
+
+ private:
+  std::string name_;
+};
+
+}  // namespace
+
+namespace internal {
+
+// This method expands all parameterized tests registered with macros TEST_P
+// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
+// This will be done just once during the program runtime.
+void UnitTestImpl::RegisterParameterizedTests() {
+#if GTEST_HAS_PARAM_TEST
+  if (!parameterized_tests_registered_) {
+    parameterized_test_registry_.RegisterTests();
+    parameterized_tests_registered_ = true;
+  }
+#endif
+}
+
+}  // namespace internal
+
+// Creates the test object, runs it, records its result, and then
+// deletes it.
+void TestInfo::Run() {
+  if (!should_run_) return;
+
+  // Tells UnitTest where to store test result.
+  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
+  impl->set_current_test_info(this);
+
+  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
+
+  // Notifies the unit test event listeners that a test is about to start.
+  repeater->OnTestStart(*this);
+
+  const TimeInMillis start = internal::GetTimeInMillis();
+
+  impl->os_stack_trace_getter()->UponLeavingGTest();
+
+  // Creates the test object.
+  Test* const test = internal::HandleExceptionsInMethodIfSupported(
+      factory_, &internal::TestFactoryBase::CreateTest,
+      "the test fixture's constructor");
+
+  // Runs the test only if the test object was created and its
+  // constructor didn't generate a fatal failure.
+  if ((test != NULL) && !Test::HasFatalFailure()) {
+    // This doesn't throw as all user code that can throw are wrapped into
+    // exception handling code.
+    test->Run();
+  }
+
+  // Deletes the test object.
+  impl->os_stack_trace_getter()->UponLeavingGTest();
+  internal::HandleExceptionsInMethodIfSupported(
+      test, &Test::DeleteSelf_, "the test fixture's destructor");
+
+  result_.set_elapsed_time(internal::GetTimeInMillis() - start);
+
+  // Notifies the unit test event listener that a test has just finished.
+  repeater->OnTestEnd(*this);
+
+  // Tells UnitTest to stop associating assertion results to this
+  // test.
+  impl->set_current_test_info(NULL);
+}
+
+// class TestCase
+
+// Gets the number of successful tests in this test case.
+int TestCase::successful_test_count() const {
+  return CountIf(test_info_list_, TestPassed);
+}
+
+// Gets the number of failed tests in this test case.
+int TestCase::failed_test_count() const {
+  return CountIf(test_info_list_, TestFailed);
+}
+
+// Gets the number of disabled tests that will be reported in the XML report.
+int TestCase::reportable_disabled_test_count() const {
+  return CountIf(test_info_list_, TestReportableDisabled);
+}
+
+// Gets the number of disabled tests in this test case.
+int TestCase::disabled_test_count() const {
+  return CountIf(test_info_list_, TestDisabled);
+}
+
+// Gets the number of tests to be printed in the XML report.
+int TestCase::reportable_test_count() const {
+  return CountIf(test_info_list_, TestReportable);
+}
+
+// Get the number of tests in this test case that should run.
+int TestCase::test_to_run_count() const {
+  return CountIf(test_info_list_, ShouldRunTest);
+}
+
+// Gets the number of all tests.
+int TestCase::total_test_count() const {
+  return static_cast<int>(test_info_list_.size());
+}
+
+// Creates a TestCase with the given name.
+//
+// Arguments:
+//
+//   name:         name of the test case
+//   a_type_param: the name of the test case's type parameter, or NULL if
+//                 this is not a typed or a type-parameterized test case.
+//   set_up_tc:    pointer to the function that sets up the test case
+//   tear_down_tc: pointer to the function that tears down the test case
+TestCase::TestCase(const char* a_name, const char* a_type_param,
+                   Test::SetUpTestCaseFunc set_up_tc,
+                   Test::TearDownTestCaseFunc tear_down_tc)
+    : name_(a_name),
+      type_param_(a_type_param ? new std::string(a_type_param) : NULL),
+      set_up_tc_(set_up_tc),
+      tear_down_tc_(tear_down_tc),
+      should_run_(false),
+      elapsed_time_(0) {
+}
+
+// Destructor of TestCase.
+TestCase::~TestCase() {
+  // Deletes every Test in the collection.
+  ForEach(test_info_list_, internal::Delete<TestInfo>);
+}
+
+// Returns the i-th test among all the tests. i can range from 0 to
+// total_test_count() - 1. If i is not in that range, returns NULL.
+const TestInfo* TestCase::GetTestInfo(int i) const {
+  const int index = GetElementOr(test_indices_, i, -1);
+  return index < 0 ? NULL : test_info_list_[index];
+}
+
+// Returns the i-th test among all the tests. i can range from 0 to
+// total_test_count() - 1. If i is not in that range, returns NULL.
+TestInfo* TestCase::GetMutableTestInfo(int i) {
+  const int index = GetElementOr(test_indices_, i, -1);
+  return index < 0 ? NULL : test_info_list_[index];
+}
+
+// Adds a test to this test case.  Will delete the test upon
+// destruction of the TestCase object.
+void TestCase::AddTestInfo(TestInfo * test_info) {
+  test_info_list_.push_back(test_info);
+  test_indices_.push_back(static_cast<int>(test_indices_.size()));
+}
+
+// Runs every test in this TestCase.
+void TestCase::Run() {
+  if (!should_run_) return;
+
+  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
+  impl->set_current_test_case(this);
+
+  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
+
+  repeater->OnTestCaseStart(*this);
+  impl->os_stack_trace_getter()->UponLeavingGTest();
+  internal::HandleExceptionsInMethodIfSupported(
+      this, &TestCase::RunSetUpTestCase, "SetUpTestCase()");
+
+  const internal::TimeInMillis start = internal::GetTimeInMillis();
+  for (int i = 0; i < total_test_count(); i++) {
+    GetMutableTestInfo(i)->Run();
+  }
+  elapsed_time_ = internal::GetTimeInMillis() - start;
+
+  impl->os_stack_trace_getter()->UponLeavingGTest();
+  internal::HandleExceptionsInMethodIfSupported(
+      this, &TestCase::RunTearDownTestCase, "TearDownTestCase()");
+
+  repeater->OnTestCaseEnd(*this);
+  impl->set_current_test_case(NULL);
+}
+
+// Clears the results of all tests in this test case.
+void TestCase::ClearResult() {
+  ad_hoc_test_result_.Clear();
+  ForEach(test_info_list_, TestInfo::ClearTestResult);
+}
+
+// Shuffles the tests in this test case.
+void TestCase::ShuffleTests(internal::Random* random) {
+  Shuffle(random, &test_indices_);
+}
+
+// Restores the test order to before the first shuffle.
+void TestCase::UnshuffleTests() {
+  for (size_t i = 0; i < test_indices_.size(); i++) {
+    test_indices_[i] = static_cast<int>(i);
+  }
+}
+
+// Formats a countable noun.  Depending on its quantity, either the
+// singular form or the plural form is used. e.g.
+//
+// FormatCountableNoun(1, "formula", "formuli") returns "1 formula".
+// FormatCountableNoun(5, "book", "books") returns "5 books".
+static std::string FormatCountableNoun(int count,
+                                       const char * singular_form,
+                                       const char * plural_form) {
+  return internal::StreamableToString(count) + " " +
+      (count == 1 ? singular_form : plural_form);
+}
+
+// Formats the count of tests.
+static std::string FormatTestCount(int test_count) {
+  return FormatCountableNoun(test_count, "test", "tests");
+}
+
+// Formats the count of test cases.
+static std::string FormatTestCaseCount(int test_case_count) {
+  return FormatCountableNoun(test_case_count, "test case", "test cases");
+}
+
+// Converts a TestPartResult::Type enum to human-friendly string
+// representation.  Both kNonFatalFailure and kFatalFailure are translated
+// to "Failure", as the user usually doesn't care about the difference
+// between the two when viewing the test result.
+static const char * TestPartResultTypeToString(TestPartResult::Type type) {
+  switch (type) {
+    case TestPartResult::kSuccess:
+      return "Success";
+
+    case TestPartResult::kNonFatalFailure:
+    case TestPartResult::kFatalFailure:
+#ifdef _MSC_VER
+      return "error: ";
+#else
+      return "Failure\n";
+#endif
+    default:
+      return "Unknown result type";
+  }
+}
+
+namespace internal {
+
+// Prints a TestPartResult to an std::string.
+static std::string PrintTestPartResultToString(
+    const TestPartResult& test_part_result) {
+  return (Message()
+          << internal::FormatFileLocation(test_part_result.file_name(),
+                                          test_part_result.line_number())
+          << " " << TestPartResultTypeToString(test_part_result.type())
+          << test_part_result.message()).GetString();
+}
+
+// Prints a TestPartResult.
+static void PrintTestPartResult(const TestPartResult& test_part_result) {
+  const std::string& result =
+      PrintTestPartResultToString(test_part_result);
+  printf("%s\n", result.c_str());
+  fflush(stdout);
+  // If the test program runs in Visual Studio or a debugger, the
+  // following statements add the test part result message to the Output
+  // window such that the user can double-click on it to jump to the
+  // corresponding source code location; otherwise they do nothing.
+#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
+  // We don't call OutputDebugString*() on Windows Mobile, as printing
+  // to stdout is done by OutputDebugString() there already - we don't
+  // want the same message printed twice.
+  ::OutputDebugStringA(result.c_str());
+  ::OutputDebugStringA("\n");
+#endif
+}
+
+// class PrettyUnitTestResultPrinter
+
+enum GTestColor {
+  COLOR_DEFAULT,
+  COLOR_RED,
+  COLOR_GREEN,
+  COLOR_YELLOW
+};
+
+#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
+
+// Returns the character attribute for the given color.
+WORD GetColorAttribute(GTestColor color) {
+  switch (color) {
+    case COLOR_RED:    return FOREGROUND_RED;
+    case COLOR_GREEN:  return FOREGROUND_GREEN;
+    case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;
+    default:           return 0;
+  }
+}
+
+#else
+
+// Returns the ANSI color code for the given color.  COLOR_DEFAULT is
+// an invalid input.
+const char* GetAnsiColorCode(GTestColor color) {
+  switch (color) {
+    case COLOR_RED:     return "1";
+    case COLOR_GREEN:   return "2";
+    case COLOR_YELLOW:  return "3";
+    default:            return NULL;
+  };
+}
+
+#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
+
+// Returns true iff Google Test should use colors in the output.
+bool ShouldUseColor(bool stdout_is_tty) {
+  const char* const gtest_color = GTEST_FLAG(color).c_str();
+
+  if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
+#if GTEST_OS_WINDOWS
+    // On Windows the TERM variable is usually not set, but the
+    // console there does support colors.
+    return stdout_is_tty;
+#else
+    // On non-Windows platforms, we rely on the TERM variable.
+    const char* const term = posix::GetEnv("TERM");
+    const bool term_supports_color =
+        String::CStringEquals(term, "xterm") ||
+        String::CStringEquals(term, "xterm-color") ||
+        String::CStringEquals(term, "xterm-256color") ||
+        String::CStringEquals(term, "screen") ||
+        String::CStringEquals(term, "screen-256color") ||
+        String::CStringEquals(term, "linux") ||
+        String::CStringEquals(term, "cygwin");
+    return stdout_is_tty && term_supports_color;
+#endif  // GTEST_OS_WINDOWS
+  }
+
+  return String::CaseInsensitiveCStringEquals(gtest_color, "yes") ||
+      String::CaseInsensitiveCStringEquals(gtest_color, "true") ||
+      String::CaseInsensitiveCStringEquals(gtest_color, "t") ||
+      String::CStringEquals(gtest_color, "1");
+  // We take "yes", "true", "t", and "1" as meaning "yes".  If the
+  // value is neither one of these nor "auto", we treat it as "no" to
+  // be conservative.
+}
+
+// Helpers for printing colored strings to stdout. Note that on Windows, we
+// cannot simply emit special characters and have the terminal change colors.
+// This routine must actually emit the characters rather than return a string
+// that would be colored when printed, as can be done on Linux.
+void ColoredPrintf(GTestColor color, const char* fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+
+#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS
+  const bool use_color = false;
+#else
+  static const bool in_color_mode =
+      ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
+  const bool use_color = in_color_mode && (color != COLOR_DEFAULT);
+#endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
+  // The '!= 0' comparison is necessary to satisfy MSVC 7.1.
+
+  if (!use_color) {
+    vprintf(fmt, args);
+    va_end(args);
+    return;
+  }
+
+#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
+  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
+
+  // Gets the current text color.
+  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
+  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
+  const WORD old_color_attrs = buffer_info.wAttributes;
+
+  // We need to flush the stream buffers into the console before each
+  // SetConsoleTextAttribute call lest it affect the text that is already
+  // printed but has not yet reached the console.
+  fflush(stdout);
+  SetConsoleTextAttribute(stdout_handle,
+                          GetColorAttribute(color) | FOREGROUND_INTENSITY);
+  vprintf(fmt, args);
+
+  fflush(stdout);
+  // Restores the text color.
+  SetConsoleTextAttribute(stdout_handle, old_color_attrs);
+#else
+  printf("\033[0;3%sm", GetAnsiColorCode(color));
+  vprintf(fmt, args);
+  printf("\033[m");  // Resets the terminal to default.
+#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
+  va_end(args);
+}
+
+// Text printed in Google Test's text output and --gunit_list_tests
+// output to label the type parameter and value parameter for a test.
+static const char kTypeParamLabel[] = "TypeParam";
+static const char kValueParamLabel[] = "GetParam()";
+
+void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
+  const char* const type_param = test_info.type_param();
+  const char* const value_param = test_info.value_param();
+
+  if (type_param != NULL || value_param != NULL) {
+    printf(", where ");
+    if (type_param != NULL) {
+      printf("%s = %s", kTypeParamLabel, type_param);
+      if (value_param != NULL)
+        printf(" and ");
+    }
+    if (value_param != NULL) {
+      printf("%s = %s", kValueParamLabel, value_param);
+    }
+  }
+}
+
+// This class implements the TestEventListener interface.
+//
+// Class PrettyUnitTestResultPrinter is copyable.
+class PrettyUnitTestResultPrinter : public TestEventListener {
+ public:
+  PrettyUnitTestResultPrinter() {}
+  static void PrintTestName(const char * test_case, const char * test) {
+    printf("%s.%s", test_case, test);
+  }
+
+  // The following methods override what's in the TestEventListener class.
+  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
+  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
+  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
+  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
+  virtual void OnTestCaseStart(const TestCase& test_case);
+  virtual void OnTestStart(const TestInfo& test_info);
+  virtual void OnTestPartResult(const TestPartResult& result);
+  virtual void OnTestEnd(const TestInfo& test_info);
+  virtual void OnTestCaseEnd(const TestCase& test_case);
+  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
+  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
+  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
+  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
+
+ private:
+  static void PrintFailedTests(const UnitTest& unit_test);
+};
+
+  // Fired before each iteration of tests starts.
+void PrettyUnitTestResultPrinter::OnTestIterationStart(
+    const UnitTest& unit_test, int iteration) {
+  if (GTEST_FLAG(repeat) != 1)
+    printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
+
+  const char* const filter = GTEST_FLAG(filter).c_str();
+
+  // Prints the filter if it's not *.  This reminds the user that some
+  // tests may be skipped.
+  if (!String::CStringEquals(filter, kUniversalFilter)) {
+    ColoredPrintf(COLOR_YELLOW,
+                  "Note: %s filter = %s\n", GTEST_NAME_, filter);
+  }
+
+  if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
+    const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
+    ColoredPrintf(COLOR_YELLOW,
+                  "Note: This is test shard %d of %s.\n",
+                  static_cast<int>(shard_index) + 1,
+                  internal::posix::GetEnv(kTestTotalShards));
+  }
+
+  if (GTEST_FLAG(shuffle)) {
+    ColoredPrintf(COLOR_YELLOW,
+                  "Note: Randomizing tests' orders with a seed of %d .\n",
+                  unit_test.random_seed());
+  }
+
+  ColoredPrintf(COLOR_GREEN,  "[==========] ");
+  printf("Running %s from %s.\n",
+         FormatTestCount(unit_test.test_to_run_count()).c_str(),
+         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
+  fflush(stdout);
+}
+
+void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(
+    const UnitTest& /*unit_test*/) {
+  ColoredPrintf(COLOR_GREEN,  "[----------] ");
+  printf("Global test environment set-up.\n");
+  fflush(stdout);
+}
+
+void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
+  const std::string counts =
+      FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
+  ColoredPrintf(COLOR_GREEN, "[----------] ");
+  printf("%s from %s", counts.c_str(), test_case.name());
+  if (test_case.type_param() == NULL) {
+    printf("\n");
+  } else {
+    printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
+  }
+  fflush(stdout);
+}
+
+void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
+  ColoredPrintf(COLOR_GREEN,  "[ RUN      ] ");
+  PrintTestName(test_info.test_case_name(), test_info.name());
+  printf("\n");
+  fflush(stdout);
+}
+
+// Called after an assertion failure.
+void PrettyUnitTestResultPrinter::OnTestPartResult(
+    const TestPartResult& result) {
+  // If the test part succeeded, we don't need to do anything.
+  if (result.type() == TestPartResult::kSuccess)
+    return;
+
+  // Print failure message from the assertion (e.g. expected this and got that).
+  PrintTestPartResult(result);
+  fflush(stdout);
+}
+
+void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
+  if (test_info.result()->Passed()) {
+    ColoredPrintf(COLOR_GREEN, "[       OK ] ");
+  } else {
+    ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
+  }
+  PrintTestName(test_info.test_case_name(), test_info.name());
+  if (test_info.result()->Failed())
+    PrintFullTestCommentIfPresent(test_info);
+
+  if (GTEST_FLAG(print_time)) {
+    printf(" (%s ms)\n", internal::StreamableToString(
+           test_info.result()->elapsed_time()).c_str());
+  } else {
+    printf("\n");
+  }
+  fflush(stdout);
+}
+
+void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
+  if (!GTEST_FLAG(print_time)) return;
+
+  const std::string counts =
+      FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
+  ColoredPrintf(COLOR_GREEN, "[----------] ");
+  printf("%s from %s (%s ms total)\n\n",
+         counts.c_str(), test_case.name(),
+         internal::StreamableToString(test_case.elapsed_time()).c_str());
+  fflush(stdout);
+}
+
+void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(
+    const UnitTest& /*unit_test*/) {
+  ColoredPrintf(COLOR_GREEN,  "[----------] ");
+  printf("Global test environment tear-down\n");
+  fflush(stdout);
+}
+
+// Internal helper for printing the list of failed tests.
+void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {
+  const int failed_test_count = unit_test.failed_test_count();
+  if (failed_test_count == 0) {
+    return;
+  }
+
+  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
+    const TestCase& test_case = *unit_test.GetTestCase(i);
+    if (!test_case.should_run() || (test_case.failed_test_count() == 0)) {
+      continue;
+    }
+    for (int j = 0; j < test_case.total_test_count(); ++j) {
+      const TestInfo& test_info = *test_case.GetTestInfo(j);
+      if (!test_info.should_run() || test_info.result()->Passed()) {
+        continue;
+      }
+      ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
+      printf("%s.%s", test_case.name(), test_info.name());
+      PrintFullTestCommentIfPresent(test_info);
+      printf("\n");
+    }
+  }
+}
+
+void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
+                                                     int /*iteration*/) {
+  ColoredPrintf(COLOR_GREEN,  "[==========] ");
+  printf("%s from %s ran.",
+         FormatTestCount(unit_test.test_to_run_count()).c_str(),
+         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
+  if (GTEST_FLAG(print_time)) {
+    printf(" (%s ms total)",
+           internal::StreamableToString(unit_test.elapsed_time()).c_str());
+  }
+  printf("\n");
+  ColoredPrintf(COLOR_GREEN,  "[  PASSED  ] ");
+  printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
+
+  int num_failures = unit_test.failed_test_count();
+  if (!unit_test.Passed()) {
+    const int failed_test_count = unit_test.failed_test_count();
+    ColoredPrintf(COLOR_RED,  "[  FAILED  ] ");
+    printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str());
+    PrintFailedTests(unit_test);
+    printf("\n%2d FAILED %s\n", num_failures,
+                        num_failures == 1 ? "TEST" : "TESTS");
+  }
+
+  int num_disabled = unit_test.reportable_disabled_test_count();
+  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
+    if (!num_failures) {
+      printf("\n");  // Add a spacer if no FAILURE banner is displayed.
+    }
+    ColoredPrintf(COLOR_YELLOW,
+                  "  YOU HAVE %d DISABLED %s\n\n",
+                  num_disabled,
+                  num_disabled == 1 ? "TEST" : "TESTS");
+  }
+  // Ensure that Google Test output is printed before, e.g., heapchecker output.
+  fflush(stdout);
+}
+
+// End PrettyUnitTestResultPrinter
+
+// class TestEventRepeater
+//
+// This class forwards events to other event listeners.
+class TestEventRepeater : public TestEventListener {
+ public:
+  TestEventRepeater() : forwarding_enabled_(true) {}
+  virtual ~TestEventRepeater();
+  void Append(TestEventListener *listener);
+  TestEventListener* Release(TestEventListener* listener);
+
+  // Controls whether events will be forwarded to listeners_. Set to false
+  // in death test child processes.
+  bool forwarding_enabled() const { return forwarding_enabled_; }
+  void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
+
+  virtual void OnTestProgramStart(const UnitTest& unit_test);
+  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
+  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
+  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);
+  virtual void OnTestCaseStart(const TestCase& test_case);
+  virtual void OnTestStart(const TestInfo& test_info);
+  virtual void OnTestPartResult(const TestPartResult& result);
+  virtual void OnTestEnd(const TestInfo& test_info);
+  virtual void OnTestCaseEnd(const TestCase& test_case);
+  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
+  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);
+  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
+  virtual void OnTestProgramEnd(const UnitTest& unit_test);
+
+ private:
+  // Controls whether events will be forwarded to listeners_. Set to false
+  // in death test child processes.
+  bool forwarding_enabled_;
+  // The list of listeners that receive events.
+  std::vector<TestEventListener*> listeners_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);
+};
+
+TestEventRepeater::~TestEventRepeater() {
+  ForEach(listeners_, Delete<TestEventListener>);
+}
+
+void TestEventRepeater::Append(TestEventListener *listener) {
+  listeners_.push_back(listener);
+}
+
+// TODO(vladl@google.com): Factor the search functionality into Vector::Find.
+TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
+  for (size_t i = 0; i < listeners_.size(); ++i) {
+    if (listeners_[i] == listener) {
+      listeners_.erase(listeners_.begin() + i);
+      return listener;
+    }
+  }
+
+  return NULL;
+}
+
+// Since most methods are very similar, use macros to reduce boilerplate.
+// This defines a member that forwards the call to all listeners.
+#define GTEST_REPEATER_METHOD_(Name, Type) \
+void TestEventRepeater::Name(const Type& parameter) { \
+  if (forwarding_enabled_) { \
+    for (size_t i = 0; i < listeners_.size(); i++) { \
+      listeners_[i]->Name(parameter); \
+    } \
+  } \
+}
+// This defines a member that forwards the call to all listeners in reverse
+// order.
+#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \
+void TestEventRepeater::Name(const Type& parameter) { \
+  if (forwarding_enabled_) { \
+    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \
+      listeners_[i]->Name(parameter); \
+    } \
+  } \
+}
+
+GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)
+GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)
+GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase)
+GTEST_REPEATER_METHOD_(OnTestStart, TestInfo)
+GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)
+GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)
+GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)
+GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)
+GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)
+GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase)
+GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)
+
+#undef GTEST_REPEATER_METHOD_
+#undef GTEST_REVERSE_REPEATER_METHOD_
+
+void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
+                                             int iteration) {
+  if (forwarding_enabled_) {
+    for (size_t i = 0; i < listeners_.size(); i++) {
+      listeners_[i]->OnTestIterationStart(unit_test, iteration);
+    }
+  }
+}
+
+void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,
+                                           int iteration) {
+  if (forwarding_enabled_) {
+    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) {
+      listeners_[i]->OnTestIterationEnd(unit_test, iteration);
+    }
+  }
+}
+
+// End TestEventRepeater
+
+// This class generates an XML output file.
+class XmlUnitTestResultPrinter : public EmptyTestEventListener {
+ public:
+  explicit XmlUnitTestResultPrinter(const char* output_file);
+
+  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
+
+ private:
+  // Is c a whitespace character that is normalized to a space character
+  // when it appears in an XML attribute value?
+  static bool IsNormalizableWhitespace(char c) {
+    return c == 0x9 || c == 0xA || c == 0xD;
+  }
+
+  // May c appear in a well-formed XML document?
+  static bool IsValidXmlCharacter(char c) {
+    return IsNormalizableWhitespace(c) || c >= 0x20;
+  }
+
+  // Returns an XML-escaped copy of the input string str.  If
+  // is_attribute is true, the text is meant to appear as an attribute
+  // value, and normalizable whitespace is preserved by replacing it
+  // with character references.
+  static std::string EscapeXml(const std::string& str, bool is_attribute);
+
+  // Returns the given string with all characters invalid in XML removed.
+  static std::string RemoveInvalidXmlCharacters(const std::string& str);
+
+  // Convenience wrapper around EscapeXml when str is an attribute value.
+  static std::string EscapeXmlAttribute(const std::string& str) {
+    return EscapeXml(str, true);
+  }
+
+  // Convenience wrapper around EscapeXml when str is not an attribute value.
+  static std::string EscapeXmlText(const char* str) {
+    return EscapeXml(str, false);
+  }
+
+  // Verifies that the given attribute belongs to the given element and
+  // streams the attribute as XML.
+  static void OutputXmlAttribute(std::ostream* stream,
+                                 const std::string& element_name,
+                                 const std::string& name,
+                                 const std::string& value);
+
+  // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
+  static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
+
+  // Streams an XML representation of a TestInfo object.
+  static void OutputXmlTestInfo(::std::ostream* stream,
+                                const char* test_case_name,
+                                const TestInfo& test_info);
+
+  // Prints an XML representation of a TestCase object
+  static void PrintXmlTestCase(::std::ostream* stream,
+                               const TestCase& test_case);
+
+  // Prints an XML summary of unit_test to output stream out.
+  static void PrintXmlUnitTest(::std::ostream* stream,
+                               const UnitTest& unit_test);
+
+  // Produces a string representing the test properties in a result as space
+  // delimited XML attributes based on the property key="value" pairs.
+  // When the std::string is not empty, it includes a space at the beginning,
+  // to delimit this attribute from prior attributes.
+  static std::string TestPropertiesAsXmlAttributes(const TestResult& result);
+
+  // The output file.
+  const std::string output_file_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);
+};
+
+// Creates a new XmlUnitTestResultPrinter.
+XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
+    : output_file_(output_file) {
+  if (output_file_.c_str() == NULL || output_file_.empty()) {
+    fprintf(stderr, "XML output file may not be null\n");
+    fflush(stderr);
+    exit(EXIT_FAILURE);
+  }
+}
+
+// Called after the unit test ends.
+void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
+                                                  int /*iteration*/) {
+  FILE* xmlout = NULL;
+  FilePath output_file(output_file_);
+  FilePath output_dir(output_file.RemoveFileName());
+
+  if (output_dir.CreateDirectoriesRecursively()) {
+    xmlout = posix::FOpen(output_file_.c_str(), "w");
+  }
+  if (xmlout == NULL) {
+    // TODO(wan): report the reason of the failure.
+    //
+    // We don't do it for now as:
+    //
+    //   1. There is no urgent need for it.
+    //   2. It's a bit involved to make the errno variable thread-safe on
+    //      all three operating systems (Linux, Windows, and Mac OS).
+    //   3. To interpret the meaning of errno in a thread-safe way,
+    //      we need the strerror_r() function, which is not available on
+    //      Windows.
+    fprintf(stderr,
+            "Unable to open file \"%s\"\n",
+            output_file_.c_str());
+    fflush(stderr);
+    exit(EXIT_FAILURE);
+  }
+  std::stringstream stream;
+  PrintXmlUnitTest(&stream, unit_test);
+  fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
+  fclose(xmlout);
+}
+
+// Returns an XML-escaped copy of the input string str.  If is_attribute
+// is true, the text is meant to appear as an attribute value, and
+// normalizable whitespace is preserved by replacing it with character
+// references.
+//
+// Invalid XML characters in str, if any, are stripped from the output.
+// It is expected that most, if not all, of the text processed by this
+// module will consist of ordinary English text.
+// If this module is ever modified to produce version 1.1 XML output,
+// most invalid characters can be retained using character references.
+// TODO(wan): It might be nice to have a minimally invasive, human-readable
+// escaping scheme for invalid characters, rather than dropping them.
+std::string XmlUnitTestResultPrinter::EscapeXml(
+    const std::string& str, bool is_attribute) {
+  Message m;
+
+  for (size_t i = 0; i < str.size(); ++i) {
+    const char ch = str[i];
+    switch (ch) {
+      case '<':
+        m << "&lt;";
+        break;
+      case '>':
+        m << "&gt;";
+        break;
+      case '&':
+        m << "&amp;";
+        break;
+      case '\'':
+        if (is_attribute)
+          m << "&apos;";
+        else
+          m << '\'';
+        break;
+      case '"':
+        if (is_attribute)
+          m << "&quot;";
+        else
+          m << '"';
+        break;
+      default:
+        if (IsValidXmlCharacter(ch)) {
+          if (is_attribute && IsNormalizableWhitespace(ch))
+            m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
+              << ";";
+          else
+            m << ch;
+        }
+        break;
+    }
+  }
+
+  return m.GetString();
+}
+
+// Returns the given string with all characters invalid in XML removed.
+// Currently invalid characters are dropped from the string. An
+// alternative is to replace them with certain characters such as . or ?.
+std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(
+    const std::string& str) {
+  std::string output;
+  output.reserve(str.size());
+  for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
+    if (IsValidXmlCharacter(*it))
+      output.push_back(*it);
+
+  return output;
+}
+
+// The following routines generate an XML representation of a UnitTest
+// object.
+//
+// This is how Google Test concepts map to the DTD:
+//
+// <testsuites name="AllTests">        <-- corresponds to a UnitTest object
+//   <testsuite name="testcase-name">  <-- corresponds to a TestCase object
+//     <testcase name="test-name">     <-- corresponds to a TestInfo object
+//       <failure message="...">...</failure>
+//       <failure message="...">...</failure>
+//       <failure message="...">...</failure>
+//                                     <-- individual assertion failures
+//     </testcase>
+//   </testsuite>
+// </testsuites>
+
+// Formats the given time in milliseconds as seconds.
+std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {
+  ::std::stringstream ss;
+  ss << ms/1000.0;
+  return ss.str();
+}
+
+// Converts the given epoch time in milliseconds to a date string in the ISO
+// 8601 format, without the timezone information.
+std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) {
+  // Using non-reentrant version as localtime_r is not portable.
+  time_t seconds = static_cast<time_t>(ms / 1000);
+#ifdef _MSC_VER
+# pragma warning(push)          // Saves the current warning state.
+# pragma warning(disable:4996)  // Temporarily disables warning 4996
+                                // (function or variable may be unsafe).
+  const struct tm* const time_struct = localtime(&seconds);  // NOLINT
+# pragma warning(pop)           // Restores the warning state again.
+#else
+  const struct tm* const time_struct = localtime(&seconds);  // NOLINT
+#endif
+  if (time_struct == NULL)
+    return "";  // Invalid ms value
+
+  // YYYY-MM-DDThh:mm:ss
+  return StreamableToString(time_struct->tm_year + 1900) + "-" +
+      String::FormatIntWidth2(time_struct->tm_mon + 1) + "-" +
+      String::FormatIntWidth2(time_struct->tm_mday) + "T" +
+      String::FormatIntWidth2(time_struct->tm_hour) + ":" +
+      String::FormatIntWidth2(time_struct->tm_min) + ":" +
+      String::FormatIntWidth2(time_struct->tm_sec);
+}
+
+// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
+void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
+                                                     const char* data) {
+  const char* segment = data;
+  *stream << "<![CDATA[";
+  for (;;) {
+    const char* const next_segment = strstr(segment, "]]>");
+    if (next_segment != NULL) {
+      stream->write(
+          segment, static_cast<std::streamsize>(next_segment - segment));
+      *stream << "]]>]]&gt;<![CDATA[";
+      segment = next_segment + strlen("]]>");
+    } else {
+      *stream << segment;
+      break;
+    }
+  }
+  *stream << "]]>";
+}
+
+void XmlUnitTestResultPrinter::OutputXmlAttribute(
+    std::ostream* stream,
+    const std::string& element_name,
+    const std::string& name,
+    const std::string& value) {
+  const std::vector<std::string>& allowed_names =
+      GetReservedAttributesForElement(element_name);
+
+  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
+                   allowed_names.end())
+      << "Attribute " << name << " is not allowed for element <" << element_name
+      << ">.";
+
+  *stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\"";
+}
+
+// Prints an XML representation of a TestInfo object.
+// TODO(wan): There is also value in printing properties with the plain printer.
+void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
+                                                 const char* test_case_name,
+                                                 const TestInfo& test_info) {
+  const TestResult& result = *test_info.result();
+  const std::string kTestcase = "testcase";
+
+  *stream << "    <testcase";
+  OutputXmlAttribute(stream, kTestcase, "name", test_info.name());
+
+  if (test_info.value_param() != NULL) {
+    OutputXmlAttribute(stream, kTestcase, "value_param",
+                       test_info.value_param());
+  }
+  if (test_info.type_param() != NULL) {
+    OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param());
+  }
+
+  OutputXmlAttribute(stream, kTestcase, "status",
+                     test_info.should_run() ? "run" : "notrun");
+  OutputXmlAttribute(stream, kTestcase, "time",
+                     FormatTimeInMillisAsSeconds(result.elapsed_time()));
+  OutputXmlAttribute(stream, kTestcase, "classname", test_case_name);
+  *stream << TestPropertiesAsXmlAttributes(result);
+
+  int failures = 0;
+  for (int i = 0; i < result.total_part_count(); ++i) {
+    const TestPartResult& part = result.GetTestPartResult(i);
+    if (part.failed()) {
+      if (++failures == 1) {
+        *stream << ">\n";
+      }
+      const string location = internal::FormatCompilerIndependentFileLocation(
+          part.file_name(), part.line_number());
+      const string summary = location + "\n" + part.summary();
+      *stream << "      <failure message=\""
+              << EscapeXmlAttribute(summary.c_str())
+              << "\" type=\"\">";
+      const string detail = location + "\n" + part.message();
+      OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
+      *stream << "</failure>\n";
+    }
+  }
+
+  if (failures == 0)
+    *stream << " />\n";
+  else
+    *stream << "    </testcase>\n";
+}
+
+// Prints an XML representation of a TestCase object
+void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,
+                                                const TestCase& test_case) {
+  const std::string kTestsuite = "testsuite";
+  *stream << "  <" << kTestsuite;
+  OutputXmlAttribute(stream, kTestsuite, "name", test_case.name());
+  OutputXmlAttribute(stream, kTestsuite, "tests",
+                     StreamableToString(test_case.reportable_test_count()));
+  OutputXmlAttribute(stream, kTestsuite, "failures",
+                     StreamableToString(test_case.failed_test_count()));
+  OutputXmlAttribute(
+      stream, kTestsuite, "disabled",
+      StreamableToString(test_case.reportable_disabled_test_count()));
+  OutputXmlAttribute(stream, kTestsuite, "errors", "0");
+  OutputXmlAttribute(stream, kTestsuite, "time",
+                     FormatTimeInMillisAsSeconds(test_case.elapsed_time()));
+  *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result())
+          << ">\n";
+
+  for (int i = 0; i < test_case.total_test_count(); ++i) {
+    if (test_case.GetTestInfo(i)->is_reportable())
+      OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i));
+  }
+  *stream << "  </" << kTestsuite << ">\n";
+}
+
+// Prints an XML summary of unit_test to output stream out.
+void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,
+                                                const UnitTest& unit_test) {
+  const std::string kTestsuites = "testsuites";
+
+  *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+  *stream << "<" << kTestsuites;
+
+  OutputXmlAttribute(stream, kTestsuites, "tests",
+                     StreamableToString(unit_test.reportable_test_count()));
+  OutputXmlAttribute(stream, kTestsuites, "failures",
+                     StreamableToString(unit_test.failed_test_count()));
+  OutputXmlAttribute(
+      stream, kTestsuites, "disabled",
+      StreamableToString(unit_test.reportable_disabled_test_count()));
+  OutputXmlAttribute(stream, kTestsuites, "errors", "0");
+  OutputXmlAttribute(
+      stream, kTestsuites, "timestamp",
+      FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));
+  OutputXmlAttribute(stream, kTestsuites, "time",
+                     FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));
+
+  if (GTEST_FLAG(shuffle)) {
+    OutputXmlAttribute(stream, kTestsuites, "random_seed",
+                       StreamableToString(unit_test.random_seed()));
+  }
+
+  *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
+
+  OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
+  *stream << ">\n";
+
+  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
+    if (unit_test.GetTestCase(i)->reportable_test_count() > 0)
+      PrintXmlTestCase(stream, *unit_test.GetTestCase(i));
+  }
+  *stream << "</" << kTestsuites << ">\n";
+}
+
+// Produces a string representing the test properties in a result as space
+// delimited XML attributes based on the property key="value" pairs.
+std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
+    const TestResult& result) {
+  Message attributes;
+  for (int i = 0; i < result.test_property_count(); ++i) {
+    const TestProperty& property = result.GetTestProperty(i);
+    attributes << " " << property.key() << "="
+        << "\"" << EscapeXmlAttribute(property.value()) << "\"";
+  }
+  return attributes.GetString();
+}
+
+// End XmlUnitTestResultPrinter
+
+#if GTEST_CAN_STREAM_RESULTS_
+
+// Checks if str contains '=', '&', '%' or '\n' characters. If yes,
+// replaces them by "%xx" where xx is their hexadecimal value. For
+// example, replaces "=" with "%3D".  This algorithm is O(strlen(str))
+// in both time and space -- important as the input str may contain an
+// arbitrarily long test failure message and stack trace.
+string StreamingListener::UrlEncode(const char* str) {
+  string result;
+  result.reserve(strlen(str) + 1);
+  for (char ch = *str; ch != '\0'; ch = *++str) {
+    switch (ch) {
+      case '%':
+      case '=':
+      case '&':
+      case '\n':
+        result.append("%" + String::FormatByte(static_cast<unsigned char>(ch)));
+        break;
+      default:
+        result.push_back(ch);
+        break;
+    }
+  }
+  return result;
+}
+
+void StreamingListener::SocketWriter::MakeConnection() {
+  GTEST_CHECK_(sockfd_ == -1)
+      << "MakeConnection() can't be called when there is already a connection.";
+
+  addrinfo hints;
+  memset(&hints, 0, sizeof(hints));
+  hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.
+  hints.ai_socktype = SOCK_STREAM;
+  addrinfo* servinfo = NULL;
+
+  // Use the getaddrinfo() to get a linked list of IP addresses for
+  // the given host name.
+  const int error_num = getaddrinfo(
+      host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);
+  if (error_num != 0) {
+    GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
+                        << gai_strerror(error_num);
+  }
+
+  // Loop through all the results and connect to the first we can.
+  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL;
+       cur_addr = cur_addr->ai_next) {
+    sockfd_ = socket(
+        cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
+    if (sockfd_ != -1) {
+      // Connect the client socket to the server socket.
+      if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
+        close(sockfd_);
+        sockfd_ = -1;
+      }
+    }
+  }
+
+  freeaddrinfo(servinfo);  // all done with this structure
+
+  if (sockfd_ == -1) {
+    GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
+                        << host_name_ << ":" << port_num_;
+  }
+}
+
+// End of class Streaming Listener
+#endif  // GTEST_CAN_STREAM_RESULTS__
+
+// Class ScopedTrace
+
+// Pushes the given source file location and message onto a per-thread
+// trace stack maintained by Google Test.
+ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
+    GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
+  TraceInfo trace;
+  trace.file = file;
+  trace.line = line;
+  trace.message = message.GetString();
+
+  UnitTest::GetInstance()->PushGTestTrace(trace);
+}
+
+// Pops the info pushed by the c'tor.
+ScopedTrace::~ScopedTrace()
+    GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
+  UnitTest::GetInstance()->PopGTestTrace();
+}
+
+
+// class OsStackTraceGetter
+
+// Returns the current OS stack trace as an std::string.  Parameters:
+//
+//   max_depth  - the maximum number of stack frames to be included
+//                in the trace.
+//   skip_count - the number of top frames to be skipped; doesn't count
+//                against max_depth.
+//
+string OsStackTraceGetter::CurrentStackTrace(int /* max_depth */,
+                                             int /* skip_count */)
+    GTEST_LOCK_EXCLUDED_(mutex_) {
+  return "";
+}
+
+void OsStackTraceGetter::UponLeavingGTest()
+    GTEST_LOCK_EXCLUDED_(mutex_) {
+}
+
+const char* const
+OsStackTraceGetter::kElidedFramesMarker =
+    "... " GTEST_NAME_ " internal frames ...";
+
+// A helper class that creates the premature-exit file in its
+// constructor and deletes the file in its destructor.
+class ScopedPrematureExitFile {
+ public:
+  explicit ScopedPrematureExitFile(const char* premature_exit_filepath)
+      : premature_exit_filepath_(premature_exit_filepath) {
+    // If a path to the premature-exit file is specified...
+    if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') {
+      // create the file with a single "0" character in it.  I/O
+      // errors are ignored as there's nothing better we can do and we
+      // don't want to fail the test because of this.
+      FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
+      fwrite("0", 1, 1, pfile);
+      fclose(pfile);
+    }
+  }
+
+  ~ScopedPrematureExitFile() {
+    if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') {
+      remove(premature_exit_filepath_);
+    }
+  }
+
+ private:
+  const char* const premature_exit_filepath_;
+
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);
+};
+
+}  // namespace internal
+
+// class TestEventListeners
+
+TestEventListeners::TestEventListeners()
+    : repeater_(new internal::TestEventRepeater()),
+      default_result_printer_(NULL),
+      default_xml_generator_(NULL) {
+}
+
+TestEventListeners::~TestEventListeners() { delete repeater_; }
+
+// Returns the standard listener responsible for the default console
+// output.  Can be removed from the listeners list to shut down default
+// console output.  Note that removing this object from the listener list
+// with Release transfers its ownership to the user.
+void TestEventListeners::Append(TestEventListener* listener) {
+  repeater_->Append(listener);
+}
+
+// Removes the given event listener from the list and returns it.  It then
+// becomes the caller's responsibility to delete the listener. Returns
+// NULL if the listener is not found in the list.
+TestEventListener* TestEventListeners::Release(TestEventListener* listener) {
+  if (listener == default_result_printer_)
+    default_result_printer_ = NULL;
+  else if (listener == default_xml_generator_)
+    default_xml_generator_ = NULL;
+  return repeater_->Release(listener);
+}
+
+// Returns repeater that broadcasts the TestEventListener events to all
+// subscribers.
+TestEventListener* TestEventListeners::repeater() { return repeater_; }
+
+// Sets the default_result_printer attribute to the provided listener.
+// The listener is also added to the listener list and previous
+// default_result_printer is removed from it and deleted. The listener can
+// also be NULL in which case it will not be added to the list. Does
+// nothing if the previous and the current listener objects are the same.
+void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {
+  if (default_result_printer_ != listener) {
+    // It is an error to pass this method a listener that is already in the
+    // list.
+    delete Release(default_result_printer_);
+    default_result_printer_ = listener;
+    if (listener != NULL)
+      Append(listener);
+  }
+}
+
+// Sets the default_xml_generator attribute to the provided listener.  The
+// listener is also added to the listener list and previous
+// default_xml_generator is removed from it and deleted. The listener can
+// also be NULL in which case it will not be added to the list. Does
+// nothing if the previous and the current listener objects are the same.
+void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {
+  if (default_xml_generator_ != listener) {
+    // It is an error to pass this method a listener that is already in the
+    // list.
+    delete Release(default_xml_generator_);
+    default_xml_generator_ = listener;
+    if (listener != NULL)
+      Append(listener);
+  }
+}
+
+// Controls whether events will be forwarded by the repeater to the
+// listeners in the list.
+bool TestEventListeners::EventForwardingEnabled() const {
+  return repeater_->forwarding_enabled();
+}
+
+void TestEventListeners::SuppressEventForwarding() {
+  repeater_->set_forwarding_enabled(false);
+}
+
+// class UnitTest
+
+// Gets the singleton UnitTest object.  The first time this method is
+// called, a UnitTest object is constructed and returned.  Consecutive
+// calls will return the same object.
+//
+// We don't protect this under mutex_ as a user is not supposed to
+// call this before main() starts, from which point on the return
+// value will never change.
+UnitTest* UnitTest::GetInstance() {
+  // When compiled with MSVC 7.1 in optimized mode, destroying the
+  // UnitTest object upon exiting the program messes up the exit code,
+  // causing successful tests to appear failed.  We have to use a
+  // different implementation in this case to bypass the compiler bug.
+  // This implementation makes the compiler happy, at the cost of
+  // leaking the UnitTest object.
+
+  // CodeGear C++Builder insists on a public destructor for the
+  // default implementation.  Use this implementation to keep good OO
+  // design with private destructor.
+
+#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
+  static UnitTest* const instance = new UnitTest;
+  return instance;
+#else
+  static UnitTest instance;
+  return &instance;
+#endif  // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
+}
+
+// Gets the number of successful test cases.
+int UnitTest::successful_test_case_count() const {
+  return impl()->successful_test_case_count();
+}
+
+// Gets the number of failed test cases.
+int UnitTest::failed_test_case_count() const {
+  return impl()->failed_test_case_count();
+}
+
+// Gets the number of all test cases.
+int UnitTest::total_test_case_count() const {
+  return impl()->total_test_case_count();
+}
+
+// Gets the number of all test cases that contain at least one test
+// that should run.
+int UnitTest::test_case_to_run_count() const {
+  return impl()->test_case_to_run_count();
+}
+
+// Gets the number of successful tests.
+int UnitTest::successful_test_count() const {
+  return impl()->successful_test_count();
+}
+
+// Gets the number of failed tests.
+int UnitTest::failed_test_count() const { return impl()->failed_test_count(); }
+
+// Gets the number of disabled tests that will be reported in the XML report.
+int UnitTest::reportable_disabled_test_count() const {
+  return impl()->reportable_disabled_test_count();
+}
+
+// Gets the number of disabled tests.
+int UnitTest::disabled_test_count() const {
+  return impl()->disabled_test_count();
+}
+
+// Gets the number of tests to be printed in the XML report.
+int UnitTest::reportable_test_count() const {
+  return impl()->reportable_test_count();
+}
+
+// Gets the number of all tests.
+int UnitTest::total_test_count() const { return impl()->total_test_count(); }
+
+// Gets the number of tests that should run.
+int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }
+
+// Gets the time of the test program start, in ms from the start of the
+// UNIX epoch.
+internal::TimeInMillis UnitTest::start_timestamp() const {
+    return impl()->start_timestamp();
+}
+
+// Gets the elapsed time, in milliseconds.
+internal::TimeInMillis UnitTest::elapsed_time() const {
+  return impl()->elapsed_time();
+}
+
+// Returns true iff the unit test passed (i.e. all test cases passed).
+bool UnitTest::Passed() const { return impl()->Passed(); }
+
+// Returns true iff the unit test failed (i.e. some test case failed
+// or something outside of all tests failed).
+bool UnitTest::Failed() const { return impl()->Failed(); }
+
+// Gets the i-th test case among all the test cases. i can range from 0 to
+// total_test_case_count() - 1. If i is not in that range, returns NULL.
+const TestCase* UnitTest::GetTestCase(int i) const {
+  return impl()->GetTestCase(i);
+}
+
+// Returns the TestResult containing information on test failures and
+// properties logged outside of individual test cases.
+const TestResult& UnitTest::ad_hoc_test_result() const {
+  return *impl()->ad_hoc_test_result();
+}
+
+// Gets the i-th test case among all the test cases. i can range from 0 to
+// total_test_case_count() - 1. If i is not in that range, returns NULL.
+TestCase* UnitTest::GetMutableTestCase(int i) {
+  return impl()->GetMutableTestCase(i);
+}
+
+// Returns the list of event listeners that can be used to track events
+// inside Google Test.
+TestEventListeners& UnitTest::listeners() {
+  return *impl()->listeners();
+}
+
+// Registers and returns a global test environment.  When a test
+// program is run, all global test environments will be set-up in the
+// order they were registered.  After all tests in the program have
+// finished, all global test environments will be torn-down in the
+// *reverse* order they were registered.
+//
+// The UnitTest object takes ownership of the given environment.
+//
+// We don't protect this under mutex_, as we only support calling it
+// from the main thread.
+Environment* UnitTest::AddEnvironment(Environment* env) {
+  if (env == NULL) {
+    return NULL;
+  }
+
+  impl_->environments().push_back(env);
+  return env;
+}
+
+// Adds a TestPartResult to the current TestResult object.  All Google Test
+// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call
+// this to report their results.  The user code should use the
+// assertion macros instead of calling this directly.
+void UnitTest::AddTestPartResult(
+    TestPartResult::Type result_type,
+    const char* file_name,
+    int line_number,
+    const std::string& message,
+    const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {
+  Message msg;
+  msg << message;
+
+  internal::MutexLock lock(&mutex_);
+  if (impl_->gtest_trace_stack().size() > 0) {
+    msg << "\n" << GTEST_NAME_ << " trace:";
+
+    for (int i = static_cast<int>(impl_->gtest_trace_stack().size());
+         i > 0; --i) {
+      const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
+      msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
+          << " " << trace.message;
+    }
+  }
+
+  if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) {
+    msg << internal::kStackTraceMarker << os_stack_trace;
+  }
+
+  const TestPartResult result =
+    TestPartResult(result_type, file_name, line_number,
+                   msg.GetString().c_str());
+  impl_->GetTestPartResultReporterForCurrentThread()->
+      ReportTestPartResult(result);
+
+  if (result_type != TestPartResult::kSuccess) {
+    // gtest_break_on_failure takes precedence over
+    // gtest_throw_on_failure.  This allows a user to set the latter
+    // in the code (perhaps in order to use Google Test assertions
+    // with another testing framework) and specify the former on the
+    // command line for debugging.
+    if (GTEST_FLAG(break_on_failure)) {
+#if GTEST_OS_WINDOWS
+      // Using DebugBreak on Windows allows gtest to still break into a debugger
+      // when a failure happens and both the --gtest_break_on_failure and
+      // the --gtest_catch_exceptions flags are specified.
+      DebugBreak();
+#else
+      // Dereference NULL through a volatile pointer to prevent the compiler
+      // from removing. We use this rather than abort() or __builtin_trap() for
+      // portability: Symbian doesn't implement abort() well, and some debuggers
+      // don't correctly trap abort().
+      *static_cast<volatile int*>(NULL) = 1;
+#endif  // GTEST_OS_WINDOWS
+    } else if (GTEST_FLAG(throw_on_failure)) {
+#if GTEST_HAS_EXCEPTIONS
+      throw internal::GoogleTestFailureException(result);
+#else
+      // We cannot call abort() as it generates a pop-up in debug mode
+      // that cannot be suppressed in VC 7.1 or below.
+      exit(1);
+#endif
+    }
+  }
+}
+
+// Adds a TestProperty to the current TestResult object when invoked from
+// inside a test, to current TestCase's ad_hoc_test_result_ when invoked
+// from SetUpTestCase or TearDownTestCase, or to the global property set
+// when invoked elsewhere.  If the result already contains a property with
+// the same key, the value will be updated.
+void UnitTest::RecordProperty(const std::string& key,
+                              const std::string& value) {
+  impl_->RecordProperty(TestProperty(key, value));
+}
+
+// Runs all tests in this UnitTest object and prints the result.
+// Returns 0 if successful, or 1 otherwise.
+//
+// We don't protect this under mutex_, as we only support calling it
+// from the main thread.
+int UnitTest::Run() {
+  const bool in_death_test_child_process =
+      internal::GTEST_FLAG(internal_run_death_test).length() > 0;
+
+  // Google Test implements this protocol for catching that a test
+  // program exits before returning control to Google Test:
+  //
+  //   1. Upon start, Google Test creates a file whose absolute path
+  //      is specified by the environment variable
+  //      TEST_PREMATURE_EXIT_FILE.
+  //   2. When Google Test has finished its work, it deletes the file.
+  //
+  // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before
+  // running a Google-Test-based test program and check the existence
+  // of the file at the end of the test execution to see if it has
+  // exited prematurely.
+
+  // If we are in the child process of a death test, don't
+  // create/delete the premature exit file, as doing so is unnecessary
+  // and will confuse the parent process.  Otherwise, create/delete
+  // the file upon entering/leaving this function.  If the program
+  // somehow exits before this function has a chance to return, the
+  // premature-exit file will be left undeleted, causing a test runner
+  // that understands the premature-exit-file protocol to report the
+  // test as having failed.
+  const internal::ScopedPrematureExitFile premature_exit_file(
+      in_death_test_child_process ?
+      NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
+
+  // Captures the value of GTEST_FLAG(catch_exceptions).  This value will be
+  // used for the duration of the program.
+  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
+
+#if GTEST_HAS_SEH
+  // Either the user wants Google Test to catch exceptions thrown by the
+  // tests or this is executing in the context of death test child
+  // process. In either case the user does not want to see pop-up dialogs
+  // about crashes - they are expected.
+  if (impl()->catch_exceptions() || in_death_test_child_process) {
+# if !GTEST_OS_WINDOWS_MOBILE
+    // SetErrorMode doesn't exist on CE.
+    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
+                 SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+# endif  // !GTEST_OS_WINDOWS_MOBILE
+
+# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
+    // Death test children can be terminated with _abort().  On Windows,
+    // _abort() can show a dialog with a warning message.  This forces the
+    // abort message to go to stderr instead.
+    _set_error_mode(_OUT_TO_STDERR);
+# endif
+
+# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
+    // In the debug version, Visual Studio pops up a separate dialog
+    // offering a choice to debug the aborted program. We need to suppress
+    // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
+    // executed. Google Test will notify the user of any unexpected
+    // failure via stderr.
+    //
+    // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
+    // Users of prior VC versions shall suffer the agony and pain of
+    // clicking through the countless debug dialogs.
+    // TODO(vladl@google.com): find a way to suppress the abort dialog() in the
+    // debug mode when compiled with VC 7.1 or lower.
+    if (!GTEST_FLAG(break_on_failure))
+      _set_abort_behavior(
+          0x0,                                    // Clear the following flags:
+          _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump.
+# endif
+  }
+#endif  // GTEST_HAS_SEH
+
+  return internal::HandleExceptionsInMethodIfSupported(
+      impl(),
+      &internal::UnitTestImpl::RunAllTests,
+      "auxiliary test code (environments or event listeners)") ? 0 : 1;
+}
+
+// Returns the working directory when the first TEST() or TEST_F() was
+// executed.
+const char* UnitTest::original_working_dir() const {
+  return impl_->original_working_dir_.c_str();
+}
+
+// Returns the TestCase object for the test that's currently running,
+// or NULL if no test is running.
+const TestCase* UnitTest::current_test_case() const
+    GTEST_LOCK_EXCLUDED_(mutex_) {
+  internal::MutexLock lock(&mutex_);
+  return impl_->current_test_case();
+}
+
+// Returns the TestInfo object for the test that's currently running,
+// or NULL if no test is running.
+const TestInfo* UnitTest::current_test_info() const
+    GTEST_LOCK_EXCLUDED_(mutex_) {
+  internal::MutexLock lock(&mutex_);
+  return impl_->current_test_info();
+}
+
+// Returns the random seed used at the start of the current test run.
+int UnitTest::random_seed() const { return impl_->random_seed(); }
+
+#if GTEST_HAS_PARAM_TEST
+// Returns ParameterizedTestCaseRegistry object used to keep track of
+// value-parameterized tests and instantiate and register them.
+internal::ParameterizedTestCaseRegistry&
+    UnitTest::parameterized_test_registry()
+        GTEST_LOCK_EXCLUDED_(mutex_) {
+  return impl_->parameterized_test_registry();
+}
+#endif  // GTEST_HAS_PARAM_TEST
+
+// Creates an empty UnitTest.
+UnitTest::UnitTest() {
+  impl_ = new internal::UnitTestImpl(this);
+}
+
+// Destructor of UnitTest.
+UnitTest::~UnitTest() {
+  delete impl_;
+}
+
+// Pushes a trace defined by SCOPED_TRACE() on to the per-thread
+// Google Test trace stack.
+void UnitTest::PushGTestTrace(const internal::TraceInfo& trace)
+    GTEST_LOCK_EXCLUDED_(mutex_) {
+  internal::MutexLock lock(&mutex_);
+  impl_->gtest_trace_stack().push_back(trace);
+}
+
+// Pops a trace from the per-thread Google Test trace stack.
+void UnitTest::PopGTestTrace()
+    GTEST_LOCK_EXCLUDED_(mutex_) {
+  internal::MutexLock lock(&mutex_);
+  impl_->gtest_trace_stack().pop_back();
+}
+
+namespace internal {
+
+UnitTestImpl::UnitTestImpl(UnitTest* parent)
+    : parent_(parent),
+#ifdef _MSC_VER
+# pragma warning(push)                    // Saves the current warning state.
+# pragma warning(disable:4355)            // Temporarily disables warning 4355
+                                         // (using this in initializer).
+      default_global_test_part_result_reporter_(this),
+      default_per_thread_test_part_result_reporter_(this),
+# pragma warning(pop)                     // Restores the warning state again.
+#else
+      default_global_test_part_result_reporter_(this),
+      default_per_thread_test_part_result_reporter_(this),
+#endif  // _MSC_VER
+      global_test_part_result_repoter_(
+          &default_global_test_part_result_reporter_),
+      per_thread_test_part_result_reporter_(
+          &default_per_thread_test_part_result_reporter_),
+#if GTEST_HAS_PARAM_TEST
+      parameterized_test_registry_(),
+      parameterized_tests_registered_(false),
+#endif  // GTEST_HAS_PARAM_TEST
+      last_death_test_case_(-1),
+      current_test_case_(NULL),
+      current_test_info_(NULL),
+      ad_hoc_test_result_(),
+      os_stack_trace_getter_(NULL),
+      post_flag_parse_init_performed_(false),
+      random_seed_(0),  // Will be overridden by the flag before first use.
+      random_(0),  // Will be reseeded before first use.
+      start_timestamp_(0),
+      elapsed_time_(0),
+#if GTEST_HAS_DEATH_TEST
+      death_test_factory_(new DefaultDeathTestFactory),
+#endif
+      // Will be overridden by the flag before first use.
+      catch_exceptions_(false) {
+  listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);
+}
+
+UnitTestImpl::~UnitTestImpl() {
+  // Deletes every TestCase.
+  ForEach(test_cases_, internal::Delete<TestCase>);
+
+  // Deletes every Environment.
+  ForEach(environments_, internal::Delete<Environment>);
+
+  delete os_stack_trace_getter_;
+}
+
+// Adds a TestProperty to the current TestResult object when invoked in a
+// context of a test, to current test case's ad_hoc_test_result when invoke
+// from SetUpTestCase/TearDownTestCase, or to the global property set
+// otherwise.  If the result already contains a property with the same key,
+// the value will be updated.
+void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
+  std::string xml_element;
+  TestResult* test_result;  // TestResult appropriate for property recording.
+
+  if (current_test_info_ != NULL) {
+    xml_element = "testcase";
+    test_result = &(current_test_info_->result_);
+  } else if (current_test_case_ != NULL) {
+    xml_element = "testsuite";
+    test_result = &(current_test_case_->ad_hoc_test_result_);
+  } else {
+    xml_element = "testsuites";
+    test_result = &ad_hoc_test_result_;
+  }
+  test_result->RecordProperty(xml_element, test_property);
+}
+
+#if GTEST_HAS_DEATH_TEST
+// Disables event forwarding if the control is currently in a death test
+// subprocess. Must not be called before InitGoogleTest.
+void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
+  if (internal_run_death_test_flag_.get() != NULL)
+    listeners()->SuppressEventForwarding();
+}
+#endif  // GTEST_HAS_DEATH_TEST
+
+// Initializes event listeners performing XML output as specified by
+// UnitTestOptions. Must not be called before InitGoogleTest.
+void UnitTestImpl::ConfigureXmlOutput() {
+  const std::string& output_format = UnitTestOptions::GetOutputFormat();
+  if (output_format == "xml") {
+    listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
+        UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
+  } else if (output_format != "") {
+    printf("WARNING: unrecognized output format \"%s\" ignored.\n",
+           output_format.c_str());
+    fflush(stdout);
+  }
+}
+
+#if GTEST_CAN_STREAM_RESULTS_
+// Initializes event listeners for streaming test results in string form.
+// Must not be called before InitGoogleTest.
+void UnitTestImpl::ConfigureStreamingOutput() {
+  const std::string& target = GTEST_FLAG(stream_result_to);
+  if (!target.empty()) {
+    const size_t pos = target.find(':');
+    if (pos != std::string::npos) {
+      listeners()->Append(new StreamingListener(target.substr(0, pos),
+                                                target.substr(pos+1)));
+    } else {
+      printf("WARNING: unrecognized streaming target \"%s\" ignored.\n",
+             target.c_str());
+      fflush(stdout);
+    }
+  }
+}
+#endif  // GTEST_CAN_STREAM_RESULTS_
+
+// Performs initialization dependent upon flag values obtained in
+// ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to
+// ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest
+// this function is also called from RunAllTests.  Since this function can be
+// called more than once, it has to be idempotent.
+void UnitTestImpl::PostFlagParsingInit() {
+  // Ensures that this function does not execute more than once.
+  if (!post_flag_parse_init_performed_) {
+    post_flag_parse_init_performed_ = true;
+
+#if GTEST_HAS_DEATH_TEST
+    InitDeathTestSubprocessControlInfo();
+    SuppressTestEventsIfInSubprocess();
+#endif  // GTEST_HAS_DEATH_TEST
+
+    // Registers parameterized tests. This makes parameterized tests
+    // available to the UnitTest reflection API without running
+    // RUN_ALL_TESTS.
+    RegisterParameterizedTests();
+
+    // Configures listeners for XML output. This makes it possible for users
+    // to shut down the default XML output before invoking RUN_ALL_TESTS.
+    ConfigureXmlOutput();
+
+#if GTEST_CAN_STREAM_RESULTS_
+    // Configures listeners for streaming test results to the specified server.
+    ConfigureStreamingOutput();
+#endif  // GTEST_CAN_STREAM_RESULTS_
+  }
+}
+
+// A predicate that checks the name of a TestCase against a known
+// value.
+//
+// This is used for implementation of the UnitTest class only.  We put
+// it in the anonymous namespace to prevent polluting the outer
+// namespace.
+//
+// TestCaseNameIs is copyable.
+class TestCaseNameIs {
+ public:
+  // Constructor.
+  explicit TestCaseNameIs(const std::string& name)
+      : name_(name) {}
+
+  // Returns true iff the name of test_case matches name_.
+  bool operator()(const TestCase* test_case) const {
+    return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0;
+  }
+
+ private:
+  std::string name_;
+};
+
+// Finds and returns a TestCase with the given name.  If one doesn't
+// exist, creates one and returns it.  It's the CALLER'S
+// RESPONSIBILITY to ensure that this function is only called WHEN THE
+// TESTS ARE NOT SHUFFLED.
+//
+// Arguments:
+//
+//   test_case_name: name of the test case
+//   type_param:     the name of the test case's type parameter, or NULL if
+//                   this is not a typed or a type-parameterized test case.
+//   set_up_tc:      pointer to the function that sets up the test case
+//   tear_down_tc:   pointer to the function that tears down the test case
+TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,
+                                    const char* type_param,
+                                    Test::SetUpTestCaseFunc set_up_tc,
+                                    Test::TearDownTestCaseFunc tear_down_tc) {
+  // Can we find a TestCase with the given name?
+  const std::vector<TestCase*>::const_iterator test_case =
+      std::find_if(test_cases_.begin(), test_cases_.end(),
+                   TestCaseNameIs(test_case_name));
+
+  if (test_case != test_cases_.end())
+    return *test_case;
+
+  // No.  Let's create one.
+  TestCase* const new_test_case =
+      new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);
+
+  // Is this a death test case?
+  if (internal::UnitTestOptions::MatchesFilter(test_case_name,
+                                               kDeathTestCaseFilter)) {
+    // Yes.  Inserts the test case after the last death test case
+    // defined so far.  This only works when the test cases haven't
+    // been shuffled.  Otherwise we may end up running a death test
+    // after a non-death test.
+    ++last_death_test_case_;
+    test_cases_.insert(test_cases_.begin() + last_death_test_case_,
+                       new_test_case);
+  } else {
+    // No.  Appends to the end of the list.
+    test_cases_.push_back(new_test_case);
+  }
+
+  test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));
+  return new_test_case;
+}
+
+// Helpers for setting up / tearing down the given environment.  They
+// are for use in the ForEach() function.
+static void SetUpEnvironment(Environment* env) { env->SetUp(); }
+static void TearDownEnvironment(Environment* env) { env->TearDown(); }
+
+// Runs all tests in this UnitTest object, prints the result, and
+// returns true if all tests are successful.  If any exception is
+// thrown during a test, the test is considered to be failed, but the
+// rest of the tests will still be run.
+//
+// When parameterized tests are enabled, it expands and registers
+// parameterized tests first in RegisterParameterizedTests().
+// All other functions called from RunAllTests() may safely assume that
+// parameterized tests are ready to be counted and run.
+bool UnitTestImpl::RunAllTests() {
+  // Makes sure InitGoogleTest() was called.
+  if (!GTestIsInitialized()) {
+    printf("%s",
+           "\nThis test program did NOT call ::testing::InitGoogleTest "
+           "before calling RUN_ALL_TESTS().  Please fix it.\n");
+    return false;
+  }
+
+  // Do not run any test if the --help flag was specified.
+  if (g_help_flag)
+    return true;
+
+  // Repeats the call to the post-flag parsing initialization in case the
+  // user didn't call InitGoogleTest.
+  PostFlagParsingInit();
+
+  // Even if sharding is not on, test runners may want to use the
+  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
+  // protocol.
+  internal::WriteToShardStatusFileIfNeeded();
+
+  // True iff we are in a subprocess for running a thread-safe-style
+  // death test.
+  bool in_subprocess_for_death_test = false;
+
+#if GTEST_HAS_DEATH_TEST
+  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
+#endif  // GTEST_HAS_DEATH_TEST
+
+  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
+                                        in_subprocess_for_death_test);
+
+  // Compares the full test names with the filter to decide which
+  // tests to run.
+  const bool has_tests_to_run = FilterTests(should_shard
+                                              ? HONOR_SHARDING_PROTOCOL
+                                              : IGNORE_SHARDING_PROTOCOL) > 0;
+
+  // Lists the tests and exits if the --gtest_list_tests flag was specified.
+  if (GTEST_FLAG(list_tests)) {
+    // This must be called *after* FilterTests() has been called.
+    ListTestsMatchingFilter();
+    return true;
+  }
+
+  random_seed_ = GTEST_FLAG(shuffle) ?
+      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
+
+  // True iff at least one test has failed.
+  bool failed = false;
+
+  TestEventListener* repeater = listeners()->repeater();
+
+  start_timestamp_ = GetTimeInMillis();
+  repeater->OnTestProgramStart(*parent_);
+
+  // How many times to repeat the tests?  We don't want to repeat them
+  // when we are inside the subprocess of a death test.
+  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
+  // Repeats forever if the repeat count is negative.
+  const bool forever = repeat < 0;
+  for (int i = 0; forever || i != repeat; i++) {
+    // We want to preserve failures generated by ad-hoc test
+    // assertions executed before RUN_ALL_TESTS().
+    ClearNonAdHocTestResult();
+
+    const TimeInMillis start = GetTimeInMillis();
+
+    // Shuffles test cases and tests if requested.
+    if (has_tests_to_run && GTEST_FLAG(shuffle)) {
+      random()->Reseed(random_seed_);
+      // This should be done before calling OnTestIterationStart(),
+      // such that a test event listener can see the actual test order
+      // in the event.
+      ShuffleTests();
+    }
+
+    // Tells the unit test event listeners that the tests are about to start.
+    repeater->OnTestIterationStart(*parent_, i);
+
+    // Runs each test case if there is at least one test to run.
+    if (has_tests_to_run) {
+      // Sets up all environments beforehand.
+      repeater->OnEnvironmentsSetUpStart(*parent_);
+      ForEach(environments_, SetUpEnvironment);
+      repeater->OnEnvironmentsSetUpEnd(*parent_);
+
+      // Runs the tests only if there was no fatal failure during global
+      // set-up.
+      if (!Test::HasFatalFailure()) {
+        for (int test_index = 0; test_index < total_test_case_count();
+             test_index++) {
+          GetMutableTestCase(test_index)->Run();
+        }
+      }
+
+      // Tears down all environments in reverse order afterwards.
+      repeater->OnEnvironmentsTearDownStart(*parent_);
+      std::for_each(environments_.rbegin(), environments_.rend(),
+                    TearDownEnvironment);
+      repeater->OnEnvironmentsTearDownEnd(*parent_);
+    }
+
+    elapsed_time_ = GetTimeInMillis() - start;
+
+    // Tells the unit test event listener that the tests have just finished.
+    repeater->OnTestIterationEnd(*parent_, i);
+
+    // Gets the result and clears it.
+    if (!Passed()) {
+      failed = true;
+    }
+
+    // Restores the original test order after the iteration.  This
+    // allows the user to quickly repro a failure that happens in the
+    // N-th iteration without repeating the first (N - 1) iterations.
+    // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
+    // case the user somehow changes the value of the flag somewhere
+    // (it's always safe to unshuffle the tests).
+    UnshuffleTests();
+
+    if (GTEST_FLAG(shuffle)) {
+      // Picks a new random seed for each iteration.
+      random_seed_ = GetNextRandomSeed(random_seed_);
+    }
+  }
+
+  repeater->OnTestProgramEnd(*parent_);
+
+  return !failed;
+}
+
+// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
+// if the variable is present. If a file already exists at this location, this
+// function will write over it. If the variable is present, but the file cannot
+// be created, prints an error and exits.
+void WriteToShardStatusFileIfNeeded() {
+  const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
+  if (test_shard_file != NULL) {
+    FILE* const file = posix::FOpen(test_shard_file, "w");
+    if (file == NULL) {
+      ColoredPrintf(COLOR_RED,
+                    "Could not write to the test shard status file \"%s\" "
+                    "specified by the %s environment variable.\n",
+                    test_shard_file, kTestShardStatusFile);
+      fflush(stdout);
+      exit(EXIT_FAILURE);
+    }
+    fclose(file);
+  }
+}
+
+// Checks whether sharding is enabled by examining the relevant
+// environment variable values. If the variables are present,
+// but inconsistent (i.e., shard_index >= total_shards), prints
+// an error and exits. If in_subprocess_for_death_test, sharding is
+// disabled because it must only be applied to the original test
+// process. Otherwise, we could filter out death tests we intended to execute.
+bool ShouldShard(const char* total_shards_env,
+                 const char* shard_index_env,
+                 bool in_subprocess_for_death_test) {
+  if (in_subprocess_for_death_test) {
+    return false;
+  }
+
+  const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);
+  const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);
+
+  if (total_shards == -1 && shard_index == -1) {
+    return false;
+  } else if (total_shards == -1 && shard_index != -1) {
+    const Message msg = Message()
+      << "Invalid environment variables: you have "
+      << kTestShardIndex << " = " << shard_index
+      << ", but have left " << kTestTotalShards << " unset.\n";
+    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
+    fflush(stdout);
+    exit(EXIT_FAILURE);
+  } else if (total_shards != -1 && shard_index == -1) {
+    const Message msg = Message()
+      << "Invalid environment variables: you have "
+      << kTestTotalShards << " = " << total_shards
+      << ", but have left " << kTestShardIndex << " unset.\n";
+    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
+    fflush(stdout);
+    exit(EXIT_FAILURE);
+  } else if (shard_index < 0 || shard_index >= total_shards) {
+    const Message msg = Message()
+      << "Invalid environment variables: we require 0 <= "
+      << kTestShardIndex << " < " << kTestTotalShards
+      << ", but you have " << kTestShardIndex << "=" << shard_index
+      << ", " << kTestTotalShards << "=" << total_shards << ".\n";
+    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
+    fflush(stdout);
+    exit(EXIT_FAILURE);
+  }
+
+  return total_shards > 1;
+}
+
+// Parses the environment variable var as an Int32. If it is unset,
+// returns default_val. If it is not an Int32, prints an error
+// and aborts.
+Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
+  const char* str_val = posix::GetEnv(var);
+  if (str_val == NULL) {
+    return default_val;
+  }
+
+  Int32 result;
+  if (!ParseInt32(Message() << "The value of environment variable " << var,
+                  str_val, &result)) {
+    exit(EXIT_FAILURE);
+  }
+  return result;
+}
+
+// Given the total number of shards, the shard index, and the test id,
+// returns true iff the test should be run on this shard. The test id is
+// some arbitrary but unique non-negative integer assigned to each test
+// method. Assumes that 0 <= shard_index < total_shards.
+bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
+  return (test_id % total_shards) == shard_index;
+}
+
+// Compares the name of each test with the user-specified filter to
+// decide whether the test should be run, then records the result in
+// each TestCase and TestInfo object.
+// If shard_tests == true, further filters tests based on sharding
+// variables in the environment - see
+// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.
+// Returns the number of tests that should run.
+int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
+  const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
+      Int32FromEnvOrDie(kTestTotalShards, -1) : -1;
+  const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
+      Int32FromEnvOrDie(kTestShardIndex, -1) : -1;
+
+  // num_runnable_tests are the number of tests that will
+  // run across all shards (i.e., match filter and are not disabled).
+  // num_selected_tests are the number of tests to be run on
+  // this shard.
+  int num_runnable_tests = 0;
+  int num_selected_tests = 0;
+  for (size_t i = 0; i < test_cases_.size(); i++) {
+    TestCase* const test_case = test_cases_[i];
+    const std::string &test_case_name = test_case->name();
+    test_case->set_should_run(false);
+
+    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
+      TestInfo* const test_info = test_case->test_info_list()[j];
+      const std::string test_name(test_info->name());
+      // A test is disabled if test case name or test name matches
+      // kDisableTestFilter.
+      const bool is_disabled =
+          internal::UnitTestOptions::MatchesFilter(test_case_name,
+                                                   kDisableTestFilter) ||
+          internal::UnitTestOptions::MatchesFilter(test_name,
+                                                   kDisableTestFilter);
+      test_info->is_disabled_ = is_disabled;
+
+      const bool matches_filter =
+          internal::UnitTestOptions::FilterMatchesTest(test_case_name,
+                                                       test_name);
+      test_info->matches_filter_ = matches_filter;
+
+      const bool is_runnable =
+          (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
+          matches_filter;
+
+      const bool is_selected = is_runnable &&
+          (shard_tests == IGNORE_SHARDING_PROTOCOL ||
+           ShouldRunTestOnShard(total_shards, shard_index,
+                                num_runnable_tests));
+
+      num_runnable_tests += is_runnable;
+      num_selected_tests += is_selected;
+
+      test_info->should_run_ = is_selected;
+      test_case->set_should_run(test_case->should_run() || is_selected);
+    }
+  }
+  return num_selected_tests;
+}
+
+// Prints the given C-string on a single line by replacing all '\n'
+// characters with string "\\n".  If the output takes more than
+// max_length characters, only prints the first max_length characters
+// and "...".
+static void PrintOnOneLine(const char* str, int max_length) {
+  if (str != NULL) {
+    for (int i = 0; *str != '\0'; ++str) {
+      if (i >= max_length) {
+        printf("...");
+        break;
+      }
+      if (*str == '\n') {
+        printf("\\n");
+        i += 2;
+      } else {
+        printf("%c", *str);
+        ++i;
+      }
+    }
+  }
+}
+
+// Prints the names of the tests matching the user-specified filter flag.
+void UnitTestImpl::ListTestsMatchingFilter() {
+  // Print at most this many characters for each type/value parameter.
+  const int kMaxParamLength = 250;
+
+  for (size_t i = 0; i < test_cases_.size(); i++) {
+    const TestCase* const test_case = test_cases_[i];
+    bool printed_test_case_name = false;
+
+    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
+      const TestInfo* const test_info =
+          test_case->test_info_list()[j];
+      if (test_info->matches_filter_) {
+        if (!printed_test_case_name) {
+          printed_test_case_name = true;
+          printf("%s.", test_case->name());
+          if (test_case->type_param() != NULL) {
+            printf("  # %s = ", kTypeParamLabel);
+            // We print the type parameter on a single line to make
+            // the output easy to parse by a program.
+            PrintOnOneLine(test_case->type_param(), kMaxParamLength);
+          }
+          printf("\n");
+        }
+        printf("  %s", test_info->name());
+        if (test_info->value_param() != NULL) {
+          printf("  # %s = ", kValueParamLabel);
+          // We print the value parameter on a single line to make the
+          // output easy to parse by a program.
+          PrintOnOneLine(test_info->value_param(), kMaxParamLength);
+        }
+        printf("\n");
+      }
+    }
+  }
+  fflush(stdout);
+}
+
+// Sets the OS stack trace getter.
+//
+// Does nothing if the input and the current OS stack trace getter are
+// the same; otherwise, deletes the old getter and makes the input the
+// current getter.
+void UnitTestImpl::set_os_stack_trace_getter(
+    OsStackTraceGetterInterface* getter) {
+  if (os_stack_trace_getter_ != getter) {
+    delete os_stack_trace_getter_;
+    os_stack_trace_getter_ = getter;
+  }
+}
+
+// Returns the current OS stack trace getter if it is not NULL;
+// otherwise, creates an OsStackTraceGetter, makes it the current
+// getter, and returns it.
+OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
+  if (os_stack_trace_getter_ == NULL) {
+    os_stack_trace_getter_ = new OsStackTraceGetter;
+  }
+
+  return os_stack_trace_getter_;
+}
+
+// Returns the TestResult for the test that's currently running, or
+// the TestResult for the ad hoc test if no test is running.
+TestResult* UnitTestImpl::current_test_result() {
+  return current_test_info_ ?
+      &(current_test_info_->result_) : &ad_hoc_test_result_;
+}
+
+// Shuffles all test cases, and the tests within each test case,
+// making sure that death tests are still run first.
+void UnitTestImpl::ShuffleTests() {
+  // Shuffles the death test cases.
+  ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_);
+
+  // Shuffles the non-death test cases.
+  ShuffleRange(random(), last_death_test_case_ + 1,
+               static_cast<int>(test_cases_.size()), &test_case_indices_);
+
+  // Shuffles the tests inside each test case.
+  for (size_t i = 0; i < test_cases_.size(); i++) {
+    test_cases_[i]->ShuffleTests(random());
+  }
+}
+
+// Restores the test cases and tests to their order before the first shuffle.
+void UnitTestImpl::UnshuffleTests() {
+  for (size_t i = 0; i < test_cases_.size(); i++) {
+    // Unshuffles the tests in each test case.
+    test_cases_[i]->UnshuffleTests();
+    // Resets the index of each test case.
+    test_case_indices_[i] = static_cast<int>(i);
+  }
+}
+
+// Returns the current OS stack trace as an std::string.
+//
+// The maximum number of stack frames to be included is specified by
+// the gtest_stack_trace_depth flag.  The skip_count parameter
+// specifies the number of top frames to be skipped, which doesn't
+// count against the number of frames to be included.
+//
+// For example, if Foo() calls Bar(), which in turn calls
+// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
+// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
+std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,
+                                            int skip_count) {
+  // We pass skip_count + 1 to skip this wrapper function in addition
+  // to what the user really wants to skip.
+  return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);
+}
+
+// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to
+// suppress unreachable code warnings.
+namespace {
+class ClassUniqueToAlwaysTrue {};
+}
+
+bool IsTrue(bool condition) { return condition; }
+
+bool AlwaysTrue() {
+#if GTEST_HAS_EXCEPTIONS
+  // This condition is always false so AlwaysTrue() never actually throws,
+  // but it makes the compiler think that it may throw.
+  if (IsTrue(false))
+    throw ClassUniqueToAlwaysTrue();
+#endif  // GTEST_HAS_EXCEPTIONS
+  return true;
+}
+
+// If *pstr starts with the given prefix, modifies *pstr to be right
+// past the prefix and returns true; otherwise leaves *pstr unchanged
+// and returns false.  None of pstr, *pstr, and prefix can be NULL.
+bool SkipPrefix(const char* prefix, const char** pstr) {
+  const size_t prefix_len = strlen(prefix);
+  if (strncmp(*pstr, prefix, prefix_len) == 0) {
+    *pstr += prefix_len;
+    return true;
+  }
+  return false;
+}
+
+// Parses a string as a command line flag.  The string should have
+// the format "--flag=value".  When def_optional is true, the "=value"
+// part can be omitted.
+//
+// Returns the value of the flag, or NULL if the parsing failed.
+const char* ParseFlagValue(const char* str,
+                           const char* flag,
+                           bool def_optional) {
+  // str and flag must not be NULL.
+  if (str == NULL || flag == NULL) return NULL;
+
+  // The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
+  const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag;
+  const size_t flag_len = flag_str.length();
+  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
+
+  // Skips the flag name.
+  const char* flag_end = str + flag_len;
+
+  // When def_optional is true, it's OK to not have a "=value" part.
+  if (def_optional && (flag_end[0] == '\0')) {
+    return flag_end;
+  }
+
+  // If def_optional is true and there are more characters after the
+  // flag name, or if def_optional is false, there must be a '=' after
+  // the flag name.
+  if (flag_end[0] != '=') return NULL;
+
+  // Returns the string after "=".
+  return flag_end + 1;
+}
+
+// Parses a string for a bool flag, in the form of either
+// "--flag=value" or "--flag".
+//
+// In the former case, the value is taken as true as long as it does
+// not start with '0', 'f', or 'F'.
+//
+// In the latter case, the value is taken as true.
+//
+// On success, stores the value of the flag in *value, and returns
+// true.  On failure, returns false without changing *value.
+bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
+  // Gets the value of the flag as a string.
+  const char* const value_str = ParseFlagValue(str, flag, true);
+
+  // Aborts if the parsing failed.
+  if (value_str == NULL) return false;
+
+  // Converts the string value to a bool.
+  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
+  return true;
+}
+
+// Parses a string for an Int32 flag, in the form of
+// "--flag=value".
+//
+// On success, stores the value of the flag in *value, and returns
+// true.  On failure, returns false without changing *value.
+bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
+  // Gets the value of the flag as a string.
+  const char* const value_str = ParseFlagValue(str, flag, false);
+
+  // Aborts if the parsing failed.
+  if (value_str == NULL) return false;
+
+  // Sets *value to the value of the flag.
+  return ParseInt32(Message() << "The value of flag --" << flag,
+                    value_str, value);
+}
+
+// Parses a string for a string flag, in the form of
+// "--flag=value".
+//
+// On success, stores the value of the flag in *value, and returns
+// true.  On failure, returns false without changing *value.
+bool ParseStringFlag(const char* str, const char* flag, std::string* value) {
+  // Gets the value of the flag as a string.
+  const char* const value_str = ParseFlagValue(str, flag, false);
+
+  // Aborts if the parsing failed.
+  if (value_str == NULL) return false;
+
+  // Sets *value to the value of the flag.
+  *value = value_str;
+  return true;
+}
+
+// Determines whether a string has a prefix that Google Test uses for its
+// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.
+// If Google Test detects that a command line flag has its prefix but is not
+// recognized, it will print its help message. Flags starting with
+// GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test
+// internal flags and do not trigger the help message.
+static bool HasGoogleTestFlagPrefix(const char* str) {
+  return (SkipPrefix("--", &str) ||
+          SkipPrefix("-", &str) ||
+          SkipPrefix("/", &str)) &&
+         !SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) &&
+         (SkipPrefix(GTEST_FLAG_PREFIX_, &str) ||
+          SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str));
+}
+
+// Prints a string containing code-encoded text.  The following escape
+// sequences can be used in the string to control the text color:
+//
+//   @@    prints a single '@' character.
+//   @R    changes the color to red.
+//   @G    changes the color to green.
+//   @Y    changes the color to yellow.
+//   @D    changes to the default terminal text color.
+//
+// TODO(wan@google.com): Write tests for this once we add stdout
+// capturing to Google Test.
+static void PrintColorEncoded(const char* str) {
+  GTestColor color = COLOR_DEFAULT;  // The current color.
+
+  // Conceptually, we split the string into segments divided by escape
+  // sequences.  Then we print one segment at a time.  At the end of
+  // each iteration, the str pointer advances to the beginning of the
+  // next segment.
+  for (;;) {
+    const char* p = strchr(str, '@');
+    if (p == NULL) {
+      ColoredPrintf(color, "%s", str);
+      return;
+    }
+
+    ColoredPrintf(color, "%s", std::string(str, p).c_str());
+
+    const char ch = p[1];
+    str = p + 2;
+    if (ch == '@') {
+      ColoredPrintf(color, "@");
+    } else if (ch == 'D') {
+      color = COLOR_DEFAULT;
+    } else if (ch == 'R') {
+      color = COLOR_RED;
+    } else if (ch == 'G') {
+      color = COLOR_GREEN;
+    } else if (ch == 'Y') {
+      color = COLOR_YELLOW;
+    } else {
+      --str;
+    }
+  }
+}
+
+static const char kColorEncodedHelpMessage[] =
+"This program contains tests written using " GTEST_NAME_ ". You can use the\n"
+"following command line flags to control its behavior:\n"
+"\n"
+"Test Selection:\n"
+"  @G--" GTEST_FLAG_PREFIX_ "list_tests@D\n"
+"      List the names of all tests instead of running them. The name of\n"
+"      TEST(Foo, Bar) is \"Foo.Bar\".\n"
+"  @G--" GTEST_FLAG_PREFIX_ "filter=@YPOSTIVE_PATTERNS"
+    "[@G-@YNEGATIVE_PATTERNS]@D\n"
+"      Run only the tests whose name matches one of the positive patterns but\n"
+"      none of the negative patterns. '?' matches any single character; '*'\n"
+"      matches any substring; ':' separates two patterns.\n"
+"  @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n"
+"      Run all disabled tests too.\n"
+"\n"
+"Test Execution:\n"
+"  @G--" GTEST_FLAG_PREFIX_ "repeat=@Y[COUNT]@D\n"
+"      Run the tests repeatedly; use a negative count to repeat forever.\n"
+"  @G--" GTEST_FLAG_PREFIX_ "shuffle@D\n"
+"      Randomize tests' orders on every iteration.\n"
+"  @G--" GTEST_FLAG_PREFIX_ "random_seed=@Y[NUMBER]@D\n"
+"      Random number seed to use for shuffling test orders (between 1 and\n"
+"      99999, or 0 to use a seed based on the current time).\n"
+"\n"
+"Test Output:\n"
+"  @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n"
+"      Enable/disable colored output. The default is @Gauto@D.\n"
+"  -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n"
+"      Don't print the elapsed time of each test.\n"
+"  @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G"
+    GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
+"      Generate an XML report in the given directory or with the given file\n"
+"      name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n"
+#if GTEST_CAN_STREAM_RESULTS_
+"  @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n"
+"      Stream test results to the given server.\n"
+#endif  // GTEST_CAN_STREAM_RESULTS_
+"\n"
+"Assertion Behavior:\n"
+#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
+"  @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n"
+"      Set the default death test style.\n"
+#endif  // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
+"  @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n"
+"      Turn assertion failures into debugger break-points.\n"
+"  @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n"
+"      Turn assertion failures into C++ exceptions.\n"
+"  @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n"
+"      Do not report exceptions as test failures. Instead, allow them\n"
+"      to crash the program or throw a pop-up (on Windows).\n"
+"\n"
+"Except for @G--" GTEST_FLAG_PREFIX_ "list_tests@D, you can alternatively set "
+    "the corresponding\n"
+"environment variable of a flag (all letters in upper-case). For example, to\n"
+"disable colored text output, you can either specify @G--" GTEST_FLAG_PREFIX_
+    "color=no@D or set\n"
+"the @G" GTEST_FLAG_PREFIX_UPPER_ "COLOR@D environment variable to @Gno@D.\n"
+"\n"
+"For more information, please read the " GTEST_NAME_ " documentation at\n"
+"@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ "\n"
+"(not one in your own code or tests), please report it to\n"
+"@G<" GTEST_DEV_EMAIL_ ">@D.\n";
+
+// Parses the command line for Google Test flags, without initializing
+// other parts of Google Test.  The type parameter CharType can be
+// instantiated to either char or wchar_t.
+template <typename CharType>
+void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
+  for (int i = 1; i < *argc; i++) {
+    const std::string arg_string = StreamableToString(argv[i]);
+    const char* const arg = arg_string.c_str();
+
+    using internal::ParseBoolFlag;
+    using internal::ParseInt32Flag;
+    using internal::ParseStringFlag;
+
+    // Do we see a Google Test flag?
+    if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
+                      &GTEST_FLAG(also_run_disabled_tests)) ||
+        ParseBoolFlag(arg, kBreakOnFailureFlag,
+                      &GTEST_FLAG(break_on_failure)) ||
+        ParseBoolFlag(arg, kCatchExceptionsFlag,
+                      &GTEST_FLAG(catch_exceptions)) ||
+        ParseStringFlag(arg, kColorFlag, &GTEST_FLAG(color)) ||
+        ParseStringFlag(arg, kDeathTestStyleFlag,
+                        &GTEST_FLAG(death_test_style)) ||
+        ParseBoolFlag(arg, kDeathTestUseFork,
+                      &GTEST_FLAG(death_test_use_fork)) ||
+        ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||
+        ParseStringFlag(arg, kInternalRunDeathTestFlag,
+                        &GTEST_FLAG(internal_run_death_test)) ||
+        ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||
+        ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) ||
+        ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||
+        ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||
+        ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||
+        ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||
+        ParseInt32Flag(arg, kStackTraceDepthFlag,
+                       &GTEST_FLAG(stack_trace_depth)) ||
+        ParseStringFlag(arg, kStreamResultToFlag,
+                        &GTEST_FLAG(stream_result_to)) ||
+        ParseBoolFlag(arg, kThrowOnFailureFlag,
+                      &GTEST_FLAG(throw_on_failure))
+        ) {
+      // Yes.  Shift the remainder of the argv list left by one.  Note
+      // that argv has (*argc + 1) elements, the last one always being
+      // NULL.  The following loop moves the trailing NULL element as
+      // well.
+      for (int j = i; j != *argc; j++) {
+        argv[j] = argv[j + 1];
+      }
+
+      // Decrements the argument count.
+      (*argc)--;
+
+      // We also need to decrement the iterator as we just removed
+      // an element.
+      i--;
+    } else if (arg_string == "--help" || arg_string == "-h" ||
+               arg_string == "-?" || arg_string == "/?" ||
+               HasGoogleTestFlagPrefix(arg)) {
+      // Both help flag and unrecognized Google Test flags (excluding
+      // internal ones) trigger help display.
+      g_help_flag = true;
+    }
+  }
+
+  if (g_help_flag) {
+    // We print the help here instead of in RUN_ALL_TESTS(), as the
+    // latter may not be called at all if the user is using Google
+    // Test with another testing framework.
+    PrintColorEncoded(kColorEncodedHelpMessage);
+  }
+}
+
+// Parses the command line for Google Test flags, without initializing
+// other parts of Google Test.
+void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
+  ParseGoogleTestFlagsOnlyImpl(argc, argv);
+}
+void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {
+  ParseGoogleTestFlagsOnlyImpl(argc, argv);
+}
+
+// The internal implementation of InitGoogleTest().
+//
+// The type parameter CharType can be instantiated to either char or
+// wchar_t.
+template <typename CharType>
+void InitGoogleTestImpl(int* argc, CharType** argv) {
+  g_init_gtest_count++;
+
+  // We don't want to run the initialization code twice.
+  if (g_init_gtest_count != 1) return;
+
+  if (*argc <= 0) return;
+
+  internal::g_executable_path = internal::StreamableToString(argv[0]);
+
+#if GTEST_HAS_DEATH_TEST
+
+  g_argvs.clear();
+  for (int i = 0; i != *argc; i++) {
+    g_argvs.push_back(StreamableToString(argv[i]));
+  }
+
+#endif  // GTEST_HAS_DEATH_TEST
+
+  ParseGoogleTestFlagsOnly(argc, argv);
+  GetUnitTestImpl()->PostFlagParsingInit();
+}
+
+}  // namespace internal
+
+// Initializes Google Test.  This must be called before calling
+// RUN_ALL_TESTS().  In particular, it parses a command line for the
+// flags that Google Test recognizes.  Whenever a Google Test flag is
+// seen, it is removed from argv, and *argc is decremented.
+//
+// No value is returned.  Instead, the Google Test flag variables are
+// updated.
+//
+// Calling the function for the second time has no user-visible effect.
+void InitGoogleTest(int* argc, char** argv) {
+  internal::InitGoogleTestImpl(argc, argv);
+}
+
+// This overloaded version can be used in Windows programs compiled in
+// UNICODE mode.
+void InitGoogleTest(int* argc, wchar_t** argv) {
+  internal::InitGoogleTestImpl(argc, argv);
+}
+
+}  // namespace testing
diff --git a/test/fmw/gtest/src/gtest_main.cc b/test/fmw/gtest/src/gtest_main.cc
new file mode 100644
index 0000000..f302822
--- /dev/null
+++ b/test/fmw/gtest/src/gtest_main.cc
@@ -0,0 +1,38 @@
+// Copyright 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <stdio.h>
+
+#include "gtest/gtest.h"
+
+GTEST_API_ int main(int argc, char **argv) {
+  printf("Running main() from gtest_main.cc\n");
+  testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java
index f2c85fb..690b07a 100644
--- a/test/lib/sun/hotspot/WhiteBox.java
+++ b/test/lib/sun/hotspot/WhiteBox.java
@@ -192,6 +192,16 @@
   public native long psVirtualSpaceAlignment();
   public native long psHeapGenerationAlignment();
 
+  /**
+   * Enumerates old regions with liveness less than specified and produces some statistics
+   * @param liveness percent of region's liveness (live_objects / total_region_size * 100).
+   * @return long[3] array where long[0] - total count of old regions
+   *                             long[1] - total memory of old regions
+   *                             long[2] - lowest estimation of total memory of old regions to be freed (non-full
+   *                             regions are not included)
+   */
+  public native long[] g1GetMixedGCInfo(int liveness);
+
   // NMT
   public native long NMTMalloc(long size);
   public native void NMTFree(long mem);
@@ -307,6 +317,11 @@
     Objects.requireNonNull(method);
     return enqueueMethodForCompilation0(method, compLevel, entry_bci);
   }
+  private native boolean enqueueInitializerForCompilation0(Class<?> aClass, int compLevel);
+  public  boolean enqueueInitializerForCompilation(Class<?> aClass, int compLevel) {
+    Objects.requireNonNull(aClass);
+    return enqueueInitializerForCompilation0(aClass, compLevel);
+  }
   private native void    clearMethodState0(Executable method);
   public         void    clearMethodState(Executable method) {
     Objects.requireNonNull(method);